xref: /AOO41X/main/sc/inc/chartarr.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_CHARTARR_HXX
29 #define SC_CHARTARR_HXX
30 
31 // -----------------------------------------------------------------------
32 
33 #include "collect.hxx"
34 #include "rangelst.hxx"
35 #include "chartpos.hxx"
36 
37 class ScAddress;
38 class Table;
39 class ScDocument;
40 
41 
42 // ScMemChart is a stripped-down SchMemChart from old chart,
43 // used only to transport a rectangular data array for the UNO API,
44 // contains only column/row header text and data values.
45 
46 class ScMemChart
47 {
48     short           nRowCnt;
49     short           nColCnt;
50     double*         pData;
51     String*         pColText;
52     String*         pRowText;
53 
54     ScMemChart(const ScMemChart& rMemChart);      // not implemented
55 
56 public:
57     ScMemChart(short nCols, short nRows);
58     ~ScMemChart();
59 
60     short GetColCount() const { return nColCnt;	}
61     short GetRowCount() const {	return nRowCnt;	}
62     const String& GetColText(short nCol) const { return pColText[nCol]; }
63     const String& GetRowText(short nRow) const { return pRowText[nRow]; }
64     double GetData(short nCol, short nRow) const { return pData[nCol * nRowCnt + nRow]; }
65     void SetData(short nCol, short nRow, const double& rVal) { pData[nCol * nRowCnt + nRow] = rVal; }
66     void SetColText(short nCol, const String& rText) { pColText[nCol] = rText; }
67     void SetRowText(short nRow, const String& rText) { pRowText[nRow] = rText; }
68 };
69 
70 
71 class SC_DLLPUBLIC ScChartArray : public ScDataObject				// nur noch Parameter-Struct
72 {
73 	String		aName;
74 	ScDocument*	pDocument;
75 	ScChartPositioner aPositioner;
76 	sal_Bool		bValid;				// fuer Erzeugung aus SchMemChart
77 
78 private:
79     ScMemChart* CreateMemChartSingle();
80     ScMemChart* CreateMemChartMulti();
81 public:
82 	ScChartArray( ScDocument* pDoc, SCTAB nTab,
83 					SCCOL nStartColP, SCROW nStartRowP,
84 					SCCOL nEndColP, SCROW nEndRowP,
85 					const String& rChartName );
86 	ScChartArray( ScDocument* pDoc, const ScRangeListRef& rRangeList,
87 					const String& rChartName );
88 	ScChartArray( const ScChartArray& rArr );
89 
90 	virtual	~ScChartArray();
91 	virtual	ScDataObject* Clone() const;
92 
93 	const ScRangeListRef&	GetRangeList() const { return aPositioner.GetRangeList(); }
94 	void	SetRangeList( const ScRangeListRef& rNew ) { aPositioner.SetRangeList(rNew); }
95 	void	SetRangeList( const ScRange& rNew ) { aPositioner.SetRangeList(rNew); }
96     const   ScChartPositionMap* GetPositionMap() { return aPositioner.GetPositionMap(); }
97 
98 	void	SetHeaders(sal_Bool bCol, sal_Bool bRow) { aPositioner.SetHeaders(bCol, bRow); }
99 	sal_Bool	HasColHeaders() const			 { return aPositioner.HasColHeaders(); }
100 	sal_Bool	HasRowHeaders() const			 { return aPositioner.HasRowHeaders(); }
101 	sal_Bool	IsValid() const					 { return bValid; }
102 	void	SetName(const String& rNew)		 { aName = rNew; }
103 	const String& GetName() const			 { return aName; }
104 
105 	sal_Bool	operator==(const ScChartArray& rCmp) const;
106 
107     ScMemChart* CreateMemChart();
108 };
109 
110 class ScChartCollection : public ScCollection
111 {
112 public:
113 	ScChartCollection() : ScCollection( 4,4 ) {}
114 	ScChartCollection( const ScChartCollection& rColl ):
115 			ScCollection( rColl ) {}
116 
117 	virtual	ScDataObject*	Clone() const;
118 	ScChartArray*		operator[](sal_uInt16 nIndex) const
119 						{ return (ScChartArray*)At(nIndex); }
120 
121 	sal_Bool	operator==(const ScChartCollection& rCmp) const;
122 };
123 
124 
125 
126 #endif
127 
128