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