merge the formfield patch from ooo-build
[ooovba.git] / sc / inc / chartpos.hxx
blob31e5d5395d1c5a91201f5ac650e6f51d0dddf3a0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chartpos.hxx,v $
10 * $Revision: 1.3.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CHARTPOS_HXX
32 #define SC_CHARTPOS_HXX
34 // -----------------------------------------------------------------------
36 #include "collect.hxx"
37 #include "rangelst.hxx"
40 class ScAddress;
41 class Table;
43 class ScChartPositionMap
45 friend class ScChartPositioner;
47 ScAddress** ppData;
48 ScAddress** ppColHeader;
49 ScAddress** ppRowHeader;
50 ULONG nCount;
51 SCCOL nColCount;
52 SCROW nRowCount;
54 ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
55 SCCOL nColAdd, // Header-Spalten
56 SCROW nRowAdd, // Header-Zeilen
57 Table& rCols // Table mit Col-Tables mit Address*
59 ~ScChartPositionMap(); //! deletes all ScAddress*
61 // not implemented
62 ScChartPositionMap( const ScChartPositionMap& );
63 ScChartPositionMap& operator=( const ScChartPositionMap& );
65 public:
67 ULONG GetCount() const { return nCount; }
68 SCCOL GetColCount() const { return nColCount; }
69 SCROW GetRowCount() const { return nRowCount; }
71 BOOL IsValid( SCCOL nCol, SCROW nRow ) const
72 { return nCol < nColCount && nRow < nRowCount; }
73 // Daten spaltenweise
74 ULONG GetIndex( SCCOL nCol, SCROW nRow ) const
75 { return (ULONG) nCol * nRowCount + nRow; }
77 const ScAddress* GetPosition( ULONG nIndex ) const
79 if ( nIndex < nCount )
80 return ppData[ nIndex ];
81 return NULL;
84 //! kann NULL sein und damit "kein Wert"
85 const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
87 if ( IsValid( nChartCol, nChartRow ) )
88 return ppData[ GetIndex( nChartCol, nChartRow ) ];
89 return NULL;
91 const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const
93 if ( nChartCol < nColCount )
94 return ppColHeader[ nChartCol ];
95 return NULL;
97 const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const
99 if ( nChartRow < nRowCount )
100 return ppRowHeader[ nChartRow ];
101 return NULL;
103 //UNUSED2009-05 ScRangeListRef GetColRanges( SCCOL nChartCol ) const;
104 //UNUSED2009-05 ScRangeListRef GetRowRanges( SCROW nChartRow ) const;
108 enum ScChartGlue {
109 SC_CHARTGLUE_NA,
110 SC_CHARTGLUE_NONE, // alte Mimik
111 SC_CHARTGLUE_COLS, // alte Mimik
112 SC_CHARTGLUE_ROWS,
113 SC_CHARTGLUE_BOTH
116 class ScDocument;
118 class ScChartPositioner // nur noch Parameter-Struct
120 ScRangeListRef aRangeListRef;
121 ScDocument* pDocument;
122 ScChartPositionMap* pPositionMap;
123 ScChartGlue eGlue;
124 SCCOL nStartCol;
125 SCROW nStartRow;
126 BOOL bColHeaders;
127 BOOL bRowHeaders;
128 BOOL bDummyUpperLeft;
130 private:
131 void CheckColRowHeaders();
133 void GlueState(); // zusammengefasste Bereiche
134 void CreatePositionMap();
136 public:
137 ScChartPositioner( ScDocument* pDoc, SCTAB nTab,
138 SCCOL nStartColP, SCROW nStartRowP,
139 SCCOL nEndColP, SCROW nEndRowP );
140 ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList );
141 ScChartPositioner( const ScChartPositioner& rPositioner );
143 virtual ~ScChartPositioner();
145 const ScRangeListRef& GetRangeList() const { return aRangeListRef; }
146 void SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
147 void SetRangeList( const ScRange& rNew );
149 void SetHeaders(BOOL bCol, BOOL bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
150 BOOL HasColHeaders() const { return bColHeaders; }
151 BOOL HasRowHeaders() const { return bRowHeaders; }
152 void SetDummyUpperLeft(BOOL bNew) { bDummyUpperLeft = bNew; }
153 void SeteGlue(ScChartGlue eNew) { eGlue = eNew; }
154 void SetStartCol(SCCOL nNew) { nStartCol = nNew; }
155 void SetStartRow(SCROW nNew) { nStartRow = nNew; }
157 BOOL operator==(const ScChartPositioner& rCmp) const;
159 void InvalidateGlue()
161 eGlue = SC_CHARTGLUE_NA;
162 if ( pPositionMap )
164 delete pPositionMap;
165 pPositionMap = NULL;
168 const ScChartPositionMap* GetPositionMap();
172 #endif