Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sc / chartarr.hxx
blob8396ca75fea14c5fe2ff5c4dd599ffb18d070582
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: chartarr.hxx,v $
10 * $Revision: 1.7 $
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_CHARTARR_HXX
32 #define SC_CHARTARR_HXX
34 // -----------------------------------------------------------------------
36 #ifndef SC_COLLECT_HXX
37 #include "collect.hxx"
38 #endif
39 #ifndef SC_RANGELST_HXX
40 #include "rangelst.hxx"
41 #endif
42 class Table;
43 namespace binfilter {
46 class ScAddress;
48 class ScChartPositionMap
50 friend class ScChartArray;
52 ScAddress** ppData;
53 ScAddress** ppColHeader;
54 ScAddress** ppRowHeader;
55 ULONG nCount;
56 USHORT nColCount;
57 USHORT nRowCount;
59 ScChartPositionMap( USHORT nChartCols, USHORT nChartRows,
60 USHORT nColAdd, // Header-Spalten
61 USHORT nRowAdd, // Header-Zeilen
62 Table& rCols // Table mit Col-Tables mit Address*
64 ~ScChartPositionMap(); //! deletes all ScAddress*
66 const ScAddress* GetPosition( ULONG nIndex ) const
68 if ( nIndex < nCount )
69 return ppData[ nIndex ];
70 return NULL;
73 // not implemented
74 ScChartPositionMap( const ScChartPositionMap& );
75 ScChartPositionMap& operator=( const ScChartPositionMap& );
77 public:
79 ULONG GetCount() const { return nCount; }
80 USHORT GetColCount() const { return nColCount; }
81 USHORT GetRowCount() const { return nRowCount; }
83 BOOL IsValid( USHORT nCol, USHORT nRow ) const
84 { return nCol < nColCount && nRow < nRowCount; }
85 // Daten spaltenweise
86 ULONG GetIndex( USHORT nCol, USHORT nRow ) const
87 { return (ULONG) nCol * nRowCount + nRow; }
89 //! kann NULL sein und damit "kein Wert"
90 const ScAddress* GetPosition( USHORT nChartCol, USHORT nChartRow ) const
92 if ( IsValid( nChartCol, nChartRow ) )
93 return ppData[ GetIndex( nChartCol, nChartRow ) ];
94 return NULL;
96 const ScAddress* GetColHeaderPosition( USHORT nChartCol ) const
98 if ( nChartCol < nColCount )
99 return ppColHeader[ nChartCol ];
100 return NULL;
102 const ScAddress* GetRowHeaderPosition( USHORT nChartRow ) const
104 if ( nChartRow < nRowCount )
105 return ppRowHeader[ nChartRow ];
106 return NULL;
111 enum ScChartGlue {
112 SC_CHARTGLUE_NA,
113 SC_CHARTGLUE_NONE, // alte Mimik
114 SC_CHARTGLUE_COLS, // alte Mimik
115 SC_CHARTGLUE_ROWS,
116 SC_CHARTGLUE_BOTH
119 class ScDocument;
120 class ScMultipleReadHeader;
121 class SchMemChart;
123 class ScChartArray : public DataObject // nur noch Parameter-Struct
125 ScRangeListRef aRangeListRef;
126 String aName;
127 ScDocument* pDocument;
128 ScChartPositionMap* pPositionMap;
129 ScChartGlue eGlue;
130 USHORT nStartCol;
131 USHORT nStartRow;
132 BOOL bColHeaders;
133 BOOL bRowHeaders;
134 BOOL bDummyUpperLeft;
135 BOOL bValid; // fuer Erzeugung aus SchMemChart
137 private:
138 SchMemChart* CreateMemChartSingle();
139 SchMemChart* CreateMemChartMulti();
141 void GlueState(); // zusammengefasste Bereiche
142 void CreatePositionMap();
144 public:
145 ScChartArray( ScDocument* pDoc, const ScRangeListRef& rRangeList,
146 const String& rChartName );
147 ScChartArray( const ScChartArray& rArr );
148 ScChartArray( ScDocument* pDoc, SvStream& rStream, ScMultipleReadHeader& rHdr );
149 ScChartArray( ScDocument* pDoc, const SchMemChart& rData );
151 virtual ~ScChartArray();
152 virtual DataObject* Clone() const{DBG_BF_ASSERT(0, "STRIP"); return NULL;} //STRIP001 virtual DataObject* Clone() const;
154 const ScRangeListRef& GetRangeList() const { return aRangeListRef; }
155 void SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
156 void SetRangeList( const ScRange& rNew );
157 void AddToRangeList( const ScRange& rRange );
158 void AddToRangeList( const ScRangeListRef& rAdd );
160 void SetHeaders(BOOL bCol, BOOL bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
161 BOOL HasColHeaders() const { return bColHeaders; }
162 BOOL HasRowHeaders() const { return bRowHeaders; }
163 BOOL IsValid() const { return bValid; }
164 void SetName(const String& rNew) { aName = rNew; }
165 const String& GetName() const { return aName; }
169 SchMemChart* CreateMemChart();
170 void SetExtraStrings( SchMemChart& rMem );
172 void InvalidateGlue()
174 eGlue = SC_CHARTGLUE_NA;
175 if ( pPositionMap )
177 delete pPositionMap;
178 pPositionMap = NULL;
181 const ScChartPositionMap* GetPositionMap();
183 static void CopySettings( SchMemChart& rDest, const SchMemChart& rSource );
186 class ScChartCollection : public Collection
188 public:
189 ScChartCollection() : Collection( 4,4 ) {}
190 ScChartCollection( const ScChartCollection& rColl ):
191 Collection( rColl ) {}
193 virtual DataObject* Clone() const{DBG_BF_ASSERT(0, "STRIP"); return NULL;} //STRIP001 virtual DataObject* Clone() const;
194 ScChartArray* operator[](USHORT nIndex) const
195 { return (ScChartArray*)At(nIndex); }
198 BOOL Load( ScDocument* pDoc, SvStream& rStream );
203 } //namespace binfilter
204 #endif