xref: /aoo41x/main/sc/inc/chartpos.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_CHARTPOS_HXX
29 #define SC_CHARTPOS_HXX
30 
31 // -----------------------------------------------------------------------
32 
33 #include "collect.hxx"
34 #include "rangelst.hxx"
35 
36 
37 class ScAddress;
38 class Table;
39 
40 class ScChartPositionMap
41 {
42 	friend class ScChartPositioner;
43 
44 			ScAddress**			ppData;
45 			ScAddress**			ppColHeader;
46 			ScAddress**			ppRowHeader;
47 			sal_uLong				nCount;
48 			SCCOL				nColCount;
49 			SCROW				nRowCount;
50 
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*
55 									);
56 								~ScChartPositionMap();	//! deletes all ScAddress*
57 
58 								// not implemented
59 								ScChartPositionMap( const ScChartPositionMap& );
60 			ScChartPositionMap&	operator=( const ScChartPositionMap& );
61 
62 public:
63 
64 			sal_uLong				GetCount() const { return nCount; }
65 			SCCOL				GetColCount() const { return nColCount; }
66 			SCROW				GetRowCount() const { return nRowCount; }
67 
68 			sal_Bool				IsValid( SCCOL nCol, SCROW nRow ) const
69 									{ return nCol < nColCount && nRow < nRowCount; }
70 								// Daten spaltenweise
71 			sal_uLong				GetIndex( SCCOL nCol, SCROW nRow ) const
72 									{ return (sal_uLong) nCol * nRowCount + nRow; }
73 
74 			const ScAddress*	GetPosition( sal_uLong nIndex ) const
75 									{
76 										if ( nIndex < nCount )
77 											return ppData[ nIndex ];
78 										return NULL;
79 									}
80 
81                                     //! kann NULL sein und damit "kein Wert"
82 			const ScAddress*	GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
83 									{
84 										if ( IsValid( nChartCol, nChartRow ) )
85 											return ppData[ GetIndex( nChartCol, nChartRow ) ];
86 										return NULL;
87 									}
88 			const ScAddress*	GetColHeaderPosition( SCCOL nChartCol ) const
89 									{
90 										if ( nChartCol < nColCount )
91 											return ppColHeader[ nChartCol ];
92 										return NULL;
93 									}
94 			const ScAddress*	GetRowHeaderPosition( SCROW nChartRow ) const
95 									{
96 										if ( nChartRow < nRowCount )
97 											return ppRowHeader[ nChartRow ];
98 										return NULL;
99 									}
100 //UNUSED2009-05 ScRangeListRef		GetColRanges( SCCOL nChartCol ) const;
101 //UNUSED2009-05 ScRangeListRef		GetRowRanges( SCROW nChartRow ) const;
102 };
103 
104 
105 enum ScChartGlue {
106 	SC_CHARTGLUE_NA,
107 	SC_CHARTGLUE_NONE,      // alte Mimik
108 	SC_CHARTGLUE_COLS,		// alte Mimik
109 	SC_CHARTGLUE_ROWS,
110 	SC_CHARTGLUE_BOTH
111 };
112 
113 class ScDocument;
114 
115 class ScChartPositioner				// nur noch Parameter-Struct
116 {
117 	ScRangeListRef	aRangeListRef;
118 	ScDocument*	pDocument;
119 	ScChartPositionMap* pPositionMap;
120 	ScChartGlue	eGlue;
121 	SCCOL		nStartCol;
122 	SCROW		nStartRow;
123 	sal_Bool		bColHeaders;
124 	sal_Bool		bRowHeaders;
125 	sal_Bool		bDummyUpperLeft;
126 
127 private:
128 	void		CheckColRowHeaders();
129 
130 	void		GlueState();		// zusammengefasste Bereiche
131 	void		CreatePositionMap();
132 
133 public:
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 );
139 
140 	virtual	~ScChartPositioner();
141 
142 	const ScRangeListRef&	GetRangeList() const { return aRangeListRef; }
143 	void	SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
144 	void	SetRangeList( const ScRange& rNew );
145 
146 	void	SetHeaders(sal_Bool bCol, sal_Bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
147 	sal_Bool	HasColHeaders() const			 { return bColHeaders; }
148 	sal_Bool	HasRowHeaders() const			 { return bRowHeaders; }
149     void    SetDummyUpperLeft(sal_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; }
153 
154 	sal_Bool	operator==(const ScChartPositioner& rCmp) const;
155 
156 	void					InvalidateGlue()
157 								{
158 									eGlue = SC_CHARTGLUE_NA;
159 									if ( pPositionMap )
160 									{
161 										delete pPositionMap;
162 										pPositionMap = NULL;
163 									}
164 								}
165 	const ScChartPositionMap*	GetPositionMap();
166 };
167 
168 
169 #endif
170 
171