xref: /aoo4110/main/sc/inc/chartpos.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_CHARTPOS_HXX
25 #define SC_CHARTPOS_HXX
26 
27 // -----------------------------------------------------------------------
28 
29 #include "collect.hxx"
30 #include "rangelst.hxx"
31 
32 
33 class ScAddress;
34 class Table;
35 
36 class ScChartPositionMap
37 {
38 	friend class ScChartPositioner;
39 
40 			ScAddress**			ppData;
41 			ScAddress**			ppColHeader;
42 			ScAddress**			ppRowHeader;
43 			sal_uLong				nCount;
44 			SCCOL				nColCount;
45 			SCROW				nRowCount;
46 
47 								ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
48 									SCCOL nColAdd,		// Header-Spalten
49 									SCROW nRowAdd,		// Header-Zeilen
50 									Table& rCols		// Table mit Col-Tables mit Address*
51 									);
52 								~ScChartPositionMap();	//! deletes all ScAddress*
53 
54 								// not implemented
55 								ScChartPositionMap( const ScChartPositionMap& );
56 			ScChartPositionMap&	operator=( const ScChartPositionMap& );
57 
58 public:
59 
GetCount() const60 			sal_uLong				GetCount() const { return nCount; }
GetColCount() const61 			SCCOL				GetColCount() const { return nColCount; }
GetRowCount() const62 			SCROW				GetRowCount() const { return nRowCount; }
63 
IsValid(SCCOL nCol,SCROW nRow) const64 			sal_Bool				IsValid( SCCOL nCol, SCROW nRow ) const
65 									{ return nCol < nColCount && nRow < nRowCount; }
66 								// Daten spaltenweise
GetIndex(SCCOL nCol,SCROW nRow) const67 			sal_uLong				GetIndex( SCCOL nCol, SCROW nRow ) const
68 									{ return (sal_uLong) nCol * nRowCount + nRow; }
69 
GetPosition(sal_uLong nIndex) const70 			const ScAddress*	GetPosition( sal_uLong nIndex ) const
71 									{
72 										if ( nIndex < nCount )
73 											return ppData[ nIndex ];
74 										return NULL;
75 									}
76 
77                                     //! kann NULL sein und damit "kein Wert"
GetPosition(SCCOL nChartCol,SCROW nChartRow) const78 			const ScAddress*	GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
79 									{
80 										if ( IsValid( nChartCol, nChartRow ) )
81 											return ppData[ GetIndex( nChartCol, nChartRow ) ];
82 										return NULL;
83 									}
GetColHeaderPosition(SCCOL nChartCol) const84 			const ScAddress*	GetColHeaderPosition( SCCOL nChartCol ) const
85 									{
86 										if ( nChartCol < nColCount )
87 											return ppColHeader[ nChartCol ];
88 										return NULL;
89 									}
GetRowHeaderPosition(SCROW nChartRow) const90 			const ScAddress*	GetRowHeaderPosition( SCROW nChartRow ) const
91 									{
92 										if ( nChartRow < nRowCount )
93 											return ppRowHeader[ nChartRow ];
94 										return NULL;
95 									}
96 //UNUSED2009-05 ScRangeListRef		GetColRanges( SCCOL nChartCol ) const;
97 //UNUSED2009-05 ScRangeListRef		GetRowRanges( SCROW nChartRow ) const;
98 };
99 
100 
101 enum ScChartGlue {
102 	SC_CHARTGLUE_NA,
103 	SC_CHARTGLUE_NONE,      // alte Mimik
104 	SC_CHARTGLUE_COLS,		// alte Mimik
105 	SC_CHARTGLUE_ROWS,
106 	SC_CHARTGLUE_BOTH
107 };
108 
109 class ScDocument;
110 
111 class ScChartPositioner				// nur noch Parameter-Struct
112 {
113 	ScRangeListRef	aRangeListRef;
114 	ScDocument*	pDocument;
115 	ScChartPositionMap* pPositionMap;
116 	ScChartGlue	eGlue;
117 	SCCOL		nStartCol;
118 	SCROW		nStartRow;
119 	sal_Bool		bColHeaders;
120 	sal_Bool		bRowHeaders;
121 	sal_Bool		bDummyUpperLeft;
122 
123 private:
124 	void		CheckColRowHeaders();
125 
126 	void		GlueState();		// zusammengefasste Bereiche
127 	void		CreatePositionMap();
128 
129 public:
130 	ScChartPositioner( ScDocument* pDoc, SCTAB nTab,
131 					SCCOL nStartColP, SCROW nStartRowP,
132 					SCCOL nEndColP, SCROW nEndRowP );
133 	ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList );
134     ScChartPositioner( const ScChartPositioner& rPositioner );
135 
136 	virtual	~ScChartPositioner();
137 
GetRangeList() const138 	const ScRangeListRef&	GetRangeList() const { return aRangeListRef; }
SetRangeList(const ScRangeListRef & rNew)139 	void	SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
140 	void	SetRangeList( const ScRange& rNew );
141 
SetHeaders(sal_Bool bCol,sal_Bool bRow)142 	void	SetHeaders(sal_Bool bCol, sal_Bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
HasColHeaders() const143 	sal_Bool	HasColHeaders() const			 { return bColHeaders; }
HasRowHeaders() const144 	sal_Bool	HasRowHeaders() const			 { return bRowHeaders; }
SetDummyUpperLeft(sal_Bool bNew)145     void    SetDummyUpperLeft(sal_Bool bNew) { bDummyUpperLeft = bNew; }
SeteGlue(ScChartGlue eNew)146     void    SeteGlue(ScChartGlue eNew) { eGlue = eNew; }
SetStartCol(SCCOL nNew)147     void    SetStartCol(SCCOL nNew) { nStartCol = nNew; }
SetStartRow(SCROW nNew)148     void    SetStartRow(SCROW nNew) { nStartRow = nNew; }
149 
150 	sal_Bool	operator==(const ScChartPositioner& rCmp) const;
151 
InvalidateGlue()152 	void					InvalidateGlue()
153 								{
154 									eGlue = SC_CHARTGLUE_NA;
155 									if ( pPositionMap )
156 									{
157 										delete pPositionMap;
158 										pPositionMap = NULL;
159 									}
160 								}
161 	const ScChartPositionMap*	GetPositionMap();
162 };
163 
164 
165 #endif
166 
167