1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chartarr.hxx,v $
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"
39 #ifndef SC_RANGELST_HXX
40 #include "rangelst.hxx"
48 class ScChartPositionMap
50 friend class ScChartArray
;
53 ScAddress
** ppColHeader
;
54 ScAddress
** ppRowHeader
;
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
];
74 ScChartPositionMap( const ScChartPositionMap
& );
75 ScChartPositionMap
& operator=( const ScChartPositionMap
& );
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
; }
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
) ];
96 const ScAddress
* GetColHeaderPosition( USHORT nChartCol
) const
98 if ( nChartCol
< nColCount
)
99 return ppColHeader
[ nChartCol
];
102 const ScAddress
* GetRowHeaderPosition( USHORT nChartRow
) const
104 if ( nChartRow
< nRowCount
)
105 return ppRowHeader
[ nChartRow
];
113 SC_CHARTGLUE_NONE
, // alte Mimik
114 SC_CHARTGLUE_COLS
, // alte Mimik
120 class ScMultipleReadHeader
;
123 class ScChartArray
: public DataObject
// nur noch Parameter-Struct
125 ScRangeListRef aRangeListRef
;
127 ScDocument
* pDocument
;
128 ScChartPositionMap
* pPositionMap
;
134 BOOL bDummyUpperLeft
;
135 BOOL bValid
; // fuer Erzeugung aus SchMemChart
138 SchMemChart
* CreateMemChartSingle();
139 SchMemChart
* CreateMemChartMulti();
141 void GlueState(); // zusammengefasste Bereiche
142 void CreatePositionMap();
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
;
181 const ScChartPositionMap
* GetPositionMap();
183 static void CopySettings( SchMemChart
& rDest
, const SchMemChart
& rSource
);
186 class ScChartCollection
: public Collection
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