1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_CHARTPOS_HXX
21 #define INCLUDED_SC_INC_CHARTPOS_HXX
23 #include "rangelst.hxx"
27 // map of row number to ScAddress*
28 typedef std::map
<sal_uLong
, ScAddress
*> RowMap
;
29 // map of column number to RowMap*
30 typedef std::map
<sal_uLong
, RowMap
*> ColumnMap
;
32 class ScChartPositionMap
34 friend class ScChartPositioner
;
36 std::unique_ptr
<ScAddress
*[]> ppData
;
37 std::unique_ptr
<ScAddress
*[]> ppColHeader
;
38 std::unique_ptr
<ScAddress
*[]> ppRowHeader
;
43 ScChartPositionMap( SCCOL nChartCols
, SCROW nChartRows
,
44 SCCOL nColAdd
, // header columns
45 SCROW nRowAdd
, // header rows
46 ColumnMap
& rCols
// table with col tables with address*
49 ScChartPositionMap( const ScChartPositionMap
& ) = delete;
50 ScChartPositionMap
& operator=( const ScChartPositionMap
& ) = delete;
53 ~ScChartPositionMap(); //! deletes all ScAddress*
55 SCCOL
GetColCount() const { return nColCount
; }
56 SCROW
GetRowCount() const { return nRowCount
; }
58 bool IsValid( SCCOL nCol
, SCROW nRow
) const
59 { return nCol
< nColCount
&& nRow
< nRowCount
; }
60 // data column by column
61 sal_uLong
GetIndex( SCCOL nCol
, SCROW nRow
) const
62 { return static_cast<sal_uLong
>(nCol
) * nRowCount
+ nRow
; }
64 const ScAddress
* GetPosition( sal_uLong nIndex
) const
66 if ( nIndex
< nCount
)
67 return ppData
[ nIndex
];
71 //! might be NULL indicating "no value"
72 const ScAddress
* GetPosition( SCCOL nChartCol
, SCROW nChartRow
) const
74 if ( IsValid( nChartCol
, nChartRow
) )
75 return ppData
[ GetIndex( nChartCol
, nChartRow
) ];
78 const ScAddress
* GetColHeaderPosition( SCCOL nChartCol
) const
80 if ( nChartCol
< nColCount
)
81 return ppColHeader
[ nChartCol
];
84 const ScAddress
* GetRowHeaderPosition( SCROW nChartRow
) const
86 if ( nChartRow
< nRowCount
)
87 return ppRowHeader
[ nChartRow
];
92 enum class ScChartGlue
{
102 class ScChartPositioner final
// only parameter struct
104 ScRangeListRef aRangeListRef
;
105 ScDocument
* pDocument
;
106 std::unique_ptr
<ScChartPositionMap
> pPositionMap
;
112 bool bDummyUpperLeft
;
114 void CheckColRowHeaders();
116 void GlueState(); // summarised areas
117 void CreatePositionMap();
120 ScChartPositioner( ScDocument
* pDoc
, SCTAB nTab
,
121 SCCOL nStartColP
, SCROW nStartRowP
,
122 SCCOL nEndColP
, SCROW nEndRowP
);
123 ScChartPositioner( ScDocument
* pDoc
, const ScRangeListRef
& rRangeList
);
124 ScChartPositioner( const ScChartPositioner
& rPositioner
);
126 ~ScChartPositioner();
128 const ScRangeListRef
& GetRangeList() const { return aRangeListRef
; }
129 void SetRangeList( const ScRange
& rNew
);
131 void SetHeaders(bool bCol
, bool bRow
) { bColHeaders
=bCol
; bRowHeaders
=bRow
; }
132 bool HasColHeaders() const { return bColHeaders
; }
133 bool HasRowHeaders() const { return bRowHeaders
; }
135 void InvalidateGlue();
136 const ScChartPositionMap
* GetPositionMap();
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */