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 SC_CHARTPOS_HXX
21 #define SC_CHARTPOS_HXX
23 // -----------------------------------------------------------------------
25 #include "rangelst.hxx"
30 // map of row number to ScAddress*
31 typedef std::map
<sal_uLong
, ScAddress
*> RowMap
;
32 // map of column number to RowMap*
33 typedef std::map
<sal_uLong
, RowMap
*> ColumnMap
;
35 class ScChartPositionMap
37 friend class ScChartPositioner
;
40 ScAddress
** ppColHeader
;
41 ScAddress
** ppRowHeader
;
46 ScChartPositionMap( SCCOL nChartCols
, SCROW nChartRows
,
47 SCCOL nColAdd
, // header columns
48 SCROW nRowAdd
, // header rows
49 ColumnMap
& rCols
// table with col tables with address*
51 ~ScChartPositionMap(); //! deletes all ScAddress*
54 ScChartPositionMap( const ScChartPositionMap
& );
55 ScChartPositionMap
& operator=( const ScChartPositionMap
& );
59 sal_uLong
GetCount() const { return nCount
; }
60 SCCOL
GetColCount() const { return nColCount
; }
61 SCROW
GetRowCount() const { return nRowCount
; }
63 sal_Bool
IsValid( SCCOL nCol
, SCROW nRow
) const
64 { return nCol
< nColCount
&& nRow
< nRowCount
; }
65 // data column by column
66 sal_uLong
GetIndex( SCCOL nCol
, SCROW nRow
) const
67 { return (sal_uLong
) nCol
* nRowCount
+ nRow
; }
69 const ScAddress
* GetPosition( sal_uLong nIndex
) const
71 if ( nIndex
< nCount
)
72 return ppData
[ nIndex
];
76 //! might be NULL indicating "no value"
77 const ScAddress
* GetPosition( SCCOL nChartCol
, SCROW nChartRow
) const
79 if ( IsValid( nChartCol
, nChartRow
) )
80 return ppData
[ GetIndex( nChartCol
, nChartRow
) ];
83 const ScAddress
* GetColHeaderPosition( SCCOL nChartCol
) const
85 if ( nChartCol
< nColCount
)
86 return ppColHeader
[ nChartCol
];
89 const ScAddress
* GetRowHeaderPosition( SCROW nChartRow
) const
91 if ( nChartRow
< nRowCount
)
92 return ppRowHeader
[ nChartRow
];
100 SC_CHARTGLUE_NONE
, // old mimic
101 SC_CHARTGLUE_COLS
, // old mimic
108 class ScChartPositioner
// only parameter struct
110 ScRangeListRef aRangeListRef
;
111 ScDocument
* pDocument
;
112 ScChartPositionMap
* pPositionMap
;
116 sal_Bool bColHeaders
;
117 sal_Bool bRowHeaders
;
118 sal_Bool bDummyUpperLeft
;
121 void CheckColRowHeaders();
123 void GlueState(); // summarised areas
124 void CreatePositionMap();
127 ScChartPositioner( ScDocument
* pDoc
, SCTAB nTab
,
128 SCCOL nStartColP
, SCROW nStartRowP
,
129 SCCOL nEndColP
, SCROW nEndRowP
);
130 ScChartPositioner( ScDocument
* pDoc
, const ScRangeListRef
& rRangeList
);
131 ScChartPositioner( const ScChartPositioner
& rPositioner
);
133 virtual ~ScChartPositioner();
135 const ScRangeListRef
& GetRangeList() const { return aRangeListRef
; }
136 void SetRangeList( const ScRangeListRef
& rNew
) { aRangeListRef
= rNew
; }
137 void SetRangeList( const ScRange
& rNew
);
139 void SetHeaders(sal_Bool bCol
, sal_Bool bRow
) { bColHeaders
=bCol
; bRowHeaders
=bRow
; }
140 sal_Bool
HasColHeaders() const { return bColHeaders
; }
141 sal_Bool
HasRowHeaders() const { return bRowHeaders
; }
142 void SetDummyUpperLeft(sal_Bool bNew
) { bDummyUpperLeft
= bNew
; }
143 void SeteGlue(ScChartGlue eNew
) { eGlue
= eNew
; }
144 void SetStartCol(SCCOL nNew
) { nStartCol
= nNew
; }
145 void SetStartRow(SCROW nNew
) { nStartRow
= nNew
; }
147 sal_Bool
operator==(const ScChartPositioner
& rCmp
) const;
149 void InvalidateGlue()
151 eGlue
= SC_CHARTGLUE_NA
;
158 const ScChartPositionMap
* GetPositionMap();
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */