1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_CHARTPOS_HXX
29 #define SC_CHARTPOS_HXX
31 // -----------------------------------------------------------------------
33 #include "collect.hxx"
34 #include "rangelst.hxx"
40 class ScChartPositionMap
42 friend class ScChartPositioner
;
45 ScAddress
** ppColHeader
;
46 ScAddress
** ppRowHeader
;
51 ScChartPositionMap( SCCOL nChartCols
, SCROW nChartRows
,
52 SCCOL nColAdd
, // Header-Spalten
53 SCROW nRowAdd
, // Header-Zeilen
54 Table
& rCols
// Table mit Col-Tables mit Address*
56 ~ScChartPositionMap(); //! deletes all ScAddress*
59 ScChartPositionMap( const ScChartPositionMap
& );
60 ScChartPositionMap
& operator=( const ScChartPositionMap
& );
64 ULONG
GetCount() const { return nCount
; }
65 SCCOL
GetColCount() const { return nColCount
; }
66 SCROW
GetRowCount() const { return nRowCount
; }
68 BOOL
IsValid( SCCOL nCol
, SCROW nRow
) const
69 { return nCol
< nColCount
&& nRow
< nRowCount
; }
71 ULONG
GetIndex( SCCOL nCol
, SCROW nRow
) const
72 { return (ULONG
) nCol
* nRowCount
+ nRow
; }
74 const ScAddress
* GetPosition( ULONG nIndex
) const
76 if ( nIndex
< nCount
)
77 return ppData
[ nIndex
];
81 //! kann NULL sein und damit "kein Wert"
82 const ScAddress
* GetPosition( SCCOL nChartCol
, SCROW nChartRow
) const
84 if ( IsValid( nChartCol
, nChartRow
) )
85 return ppData
[ GetIndex( nChartCol
, nChartRow
) ];
88 const ScAddress
* GetColHeaderPosition( SCCOL nChartCol
) const
90 if ( nChartCol
< nColCount
)
91 return ppColHeader
[ nChartCol
];
94 const ScAddress
* GetRowHeaderPosition( SCROW nChartRow
) const
96 if ( nChartRow
< nRowCount
)
97 return ppRowHeader
[ nChartRow
];
100 //UNUSED2009-05 ScRangeListRef GetColRanges( SCCOL nChartCol ) const;
101 //UNUSED2009-05 ScRangeListRef GetRowRanges( SCROW nChartRow ) const;
107 SC_CHARTGLUE_NONE
, // alte Mimik
108 SC_CHARTGLUE_COLS
, // alte Mimik
115 class ScChartPositioner
// nur noch Parameter-Struct
117 ScRangeListRef aRangeListRef
;
118 ScDocument
* pDocument
;
119 ScChartPositionMap
* pPositionMap
;
125 BOOL bDummyUpperLeft
;
128 void CheckColRowHeaders();
130 void GlueState(); // zusammengefasste Bereiche
131 void CreatePositionMap();
134 ScChartPositioner( ScDocument
* pDoc
, SCTAB nTab
,
135 SCCOL nStartColP
, SCROW nStartRowP
,
136 SCCOL nEndColP
, SCROW nEndRowP
);
137 ScChartPositioner( ScDocument
* pDoc
, const ScRangeListRef
& rRangeList
);
138 ScChartPositioner( const ScChartPositioner
& rPositioner
);
140 virtual ~ScChartPositioner();
142 const ScRangeListRef
& GetRangeList() const { return aRangeListRef
; }
143 void SetRangeList( const ScRangeListRef
& rNew
) { aRangeListRef
= rNew
; }
144 void SetRangeList( const ScRange
& rNew
);
146 void SetHeaders(BOOL bCol
, BOOL bRow
) { bColHeaders
=bCol
; bRowHeaders
=bRow
; }
147 BOOL
HasColHeaders() const { return bColHeaders
; }
148 BOOL
HasRowHeaders() const { return bRowHeaders
; }
149 void SetDummyUpperLeft(BOOL bNew
) { bDummyUpperLeft
= bNew
; }
150 void SeteGlue(ScChartGlue eNew
) { eGlue
= eNew
; }
151 void SetStartCol(SCCOL nNew
) { nStartCol
= nNew
; }
152 void SetStartRow(SCROW nNew
) { nStartRow
= nNew
; }
154 BOOL
operator==(const ScChartPositioner
& rCmp
) const;
156 void InvalidateGlue()
158 eGlue
= SC_CHARTGLUE_NA
;
165 const ScChartPositionMap
* GetPositionMap();