xref: /aoo41x/main/chart2/source/inc/InternalData.hxx (revision 67e470da)
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 #ifndef CHART2_INTERNALDATA_HXX
24 #define CHART2_INTERNALDATA_HXX
25 
26 #include <com/sun/star/uno/Sequence.hxx>
27 
28 #include <vector>
29 #include <valarray>
30 
31 namespace chart
32 {
33 
34 class InternalData
35 {
36 public:
37     InternalData();
38 
39     void createDefaultData();
40 
41     void setData( const ::com::sun::star::uno::Sequence<
42         ::com::sun::star::uno::Sequence< double > > & rDataInRows );
43     ::com::sun::star::uno::Sequence<
44         ::com::sun::star::uno::Sequence< double > > getData() const;
45 
46     ::com::sun::star::uno::Sequence< double > getColumnValues( sal_Int32 nColumnIndex ) const;
47     ::com::sun::star::uno::Sequence< double > getRowValues( sal_Int32 nRowIndex ) const;
48 
49     void setColumnValues( sal_Int32 nColumnIndex, const ::std::vector< double > & rNewData );
50     void setRowValues( sal_Int32 nRowIndex, const ::std::vector< double > & rNewData );
51 
52     void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::com::sun::star::uno::Any >& rComplexLabel );
53     void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::com::sun::star::uno::Any >& rComplexLabel );
54 
55     ::std::vector< ::com::sun::star::uno::Any > getComplexColumnLabel( sal_Int32 nColumnIndex ) const;
56     ::std::vector< ::com::sun::star::uno::Any > getComplexRowLabel( sal_Int32 nRowIndex ) const;
57 
58     void swapRowWithNext( sal_Int32 nRowIndex );
59     void swapColumnWithNext( sal_Int32 nColumnIndex );
60 
61     void insertColumn( sal_Int32 nAfterIndex );
62     void insertRow( sal_Int32 nAfterIndex );
63     void deleteColumn( sal_Int32 nAtIndex );
64     void deleteRow( sal_Int32 nAtIndex );
65 
66     /// @return the index of the newly appended column
67     sal_Int32 appendColumn();
68     /// @return the index of the newly appended row
69     sal_Int32 appendRow();
70 
71     sal_Int32 getRowCount() const;
72     sal_Int32 getColumnCount() const;
73 
74     typedef ::std::valarray< double > tDataType;
75     typedef ::std::vector< ::std::vector< ::com::sun::star::uno::Any > > tVecVecAny; //inner index is hierarchical level
76 
77     void setComplexRowLabels( const tVecVecAny& rNewRowLabels );
78     tVecVecAny getComplexRowLabels() const;
79     void setComplexColumnLabels( const tVecVecAny& rNewColumnLabels );
80     tVecVecAny getComplexColumnLabels() const;
81 
82 #if OSL_DEBUG_LEVEL > 2
83     void traceData() const;
84 #endif
85 
86 private: //methods
87     /** resizes the data if at least one of the given dimensions is larger than
88         before.  The data is never becoming smaller only larger.
89 
90         @return </sal_True>, if the data was enlarged
91     */
92     bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount );
93 
94 private:
95     sal_Int32   m_nColumnCount;
96     sal_Int32   m_nRowCount;
97 
98     tDataType    m_aData;
99     tVecVecAny   m_aRowLabels;//outer index is row index, inner index is category level
100     tVecVecAny   m_aColumnLabels;//outer index is column index
101 };
102 
103 #endif
104 
105 } //  namespace chart
106