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