xref: /AOO41X/main/sc/inc/chartarr.hxx (revision 38d50f7b14e1cf975d8c6468d9633894cd59b523)
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 
GetColCount() const56     short GetColCount() const { return nColCnt; }
GetRowCount() const57     short GetRowCount() const { return nRowCnt; }
GetColText(short nCol) const58     const String& GetColText(short nCol) const { return pColText[nCol]; }
GetRowText(short nRow) const59     const String& GetRowText(short nRow) const { return pRowText[nRow]; }
GetData(short nCol,short nRow) const60     double GetData(short nCol, short nRow) const { return pData[nCol * nRowCnt + nRow]; }
SetData(short nCol,short nRow,const double & rVal)61     void SetData(short nCol, short nRow, const double& rVal) { pData[nCol * nRowCnt + nRow] = rVal; }
SetColText(short nCol,const String & rText)62     void SetColText(short nCol, const String& rText) { pColText[nCol] = rText; }
SetRowText(short nRow,const String & 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 
GetRangeList() const89     const ScRangeListRef&   GetRangeList() const { return aPositioner.GetRangeList(); }
SetRangeList(const ScRangeListRef & rNew)90     void    SetRangeList( const ScRangeListRef& rNew ) { aPositioner.SetRangeList(rNew); }
SetRangeList(const ScRange & rNew)91     void    SetRangeList( const ScRange& rNew ) { aPositioner.SetRangeList(rNew); }
GetPositionMap()92     const   ScChartPositionMap* GetPositionMap() { return aPositioner.GetPositionMap(); }
93 
SetHeaders(sal_Bool bCol,sal_Bool bRow)94     void    SetHeaders(sal_Bool bCol, sal_Bool bRow) { aPositioner.SetHeaders(bCol, bRow); }
HasColHeaders() const95     sal_Bool    HasColHeaders() const            { return aPositioner.HasColHeaders(); }
HasRowHeaders() const96     sal_Bool    HasRowHeaders() const            { return aPositioner.HasRowHeaders(); }
IsValid() const97     sal_Bool    IsValid() const                  { return bValid; }
SetName(const String & rNew)98     void    SetName(const String& rNew)      { aName = rNew; }
GetName() const99     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:
ScChartCollection()109     ScChartCollection() : ScCollection( 4,4 ) {}
ScChartCollection(const ScChartCollection & rColl)110     ScChartCollection( const ScChartCollection& rColl ):
111             ScCollection( rColl ) {}
112 
113     virtual ScDataObject*   Clone() const;
operator [](sal_uInt16 nIndex) const114     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