xref: /AOO41X/main/chart2/source/controller/dialogs/DataBrowserModel.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef CHART2_DATABROWSERMODEL_HXX
28*cdf0e10cSrcweir #define CHART2_DATABROWSERMODEL_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <memory>
34*cdf0e10cSrcweir #include <vector>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace chart2 {
37*cdf0e10cSrcweir     class XDataSeries;
38*cdf0e10cSrcweir     class XChartType;
39*cdf0e10cSrcweir     namespace data {
40*cdf0e10cSrcweir         class XLabeledDataSequence;
41*cdf0e10cSrcweir     }
42*cdf0e10cSrcweir }}}}
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir namespace chart
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class DialogModel;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir class DataBrowserModel
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir public:
52*cdf0e10cSrcweir 	explicit DataBrowserModel(
53*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc,
54*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
55*cdf0e10cSrcweir             ::com::sun::star::uno::XComponentContext > & xContext );
56*cdf0e10cSrcweir 	virtual ~DataBrowserModel();
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir     /** Inserts a new data series after the data series to which the data column
59*cdf0e10cSrcweir         with index nAfterColumnIndex belongs.
60*cdf0e10cSrcweir      */
61*cdf0e10cSrcweir     void insertDataSeries( sal_Int32 nAfterColumnIndex );
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     /** Inserts a new text column for complex categories.
64*cdf0e10cSrcweir      */
65*cdf0e10cSrcweir     void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex );
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir     /** Removes a data series to which the data column with index nAtColumnIndex
68*cdf0e10cSrcweir         belongs.
69*cdf0e10cSrcweir      */
70*cdf0e10cSrcweir     void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex );
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     /** Swaps the series to which the data column with index nFirstIndex belongs
73*cdf0e10cSrcweir         with the next series (which starts at an index >= nFirstIndex + 1)
74*cdf0e10cSrcweir      */
75*cdf0e10cSrcweir     void swapDataSeries( sal_Int32 nFirstIndex );
76*cdf0e10cSrcweir     void swapDataPointForAllSeries( sal_Int32 nFirstIndex );
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     void insertDataPointForAllSeries( sal_Int32 nAfterIndex );
79*cdf0e10cSrcweir     void removeDataPointForAllSeries( sal_Int32 nAtIndex );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     enum eCellType
82*cdf0e10cSrcweir     {
83*cdf0e10cSrcweir         NUMBER,
84*cdf0e10cSrcweir         TEXT,
85*cdf0e10cSrcweir         TEXTORDATE
86*cdf0e10cSrcweir     };
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const;
89*cdf0e10cSrcweir     /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan
90*cdf0e10cSrcweir     double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow );
91*cdf0e10cSrcweir     ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow );
92*cdf0e10cSrcweir     ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow );
93*cdf0e10cSrcweir     sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     /// returns </sal_True> if the number could successfully be set at the given position
96*cdf0e10cSrcweir     bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue );
97*cdf0e10cSrcweir     /// returns </sal_True> if the text could successfully be set at the given position
98*cdf0e10cSrcweir     bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::rtl::OUString & rText );
99*cdf0e10cSrcweir     bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::com::sun::star::uno::Any & aValue );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     sal_Int32 getColumnCount() const;
102*cdf0e10cSrcweir     sal_Int32 getMaxRowCount() const;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     // returns the UI string of the corresponding role
105*cdf0e10cSrcweir     ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const;
106*cdf0e10cSrcweir     bool isCategoriesColumn( sal_Int32 nColumnIndex ) const;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     struct tDataHeader
109*cdf0e10cSrcweir     {
110*cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
111*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries >     m_xDataSeries;
112*cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
113*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartType >      m_xChartType;
114*cdf0e10cSrcweir         bool                                            m_bSwapXAndYAxis;
115*cdf0e10cSrcweir         sal_Int32                                       m_nStartColumn;
116*cdf0e10cSrcweir         sal_Int32                                       m_nEndColumn;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir         // default CTOR
119*cdf0e10cSrcweir         tDataHeader() :
120*cdf0e10cSrcweir                 m_bSwapXAndYAxis( false ),
121*cdf0e10cSrcweir                 m_nStartColumn( -1 ),
122*cdf0e10cSrcweir                 m_nEndColumn( -1 )
123*cdf0e10cSrcweir         {}
124*cdf0e10cSrcweir         // "full" CTOR
125*cdf0e10cSrcweir         tDataHeader(
126*cdf0e10cSrcweir             ::com::sun::star::uno::Reference<
127*cdf0e10cSrcweir                 ::com::sun::star::chart2::XDataSeries > xDataSeries,
128*cdf0e10cSrcweir             ::com::sun::star::uno::Reference<
129*cdf0e10cSrcweir                 ::com::sun::star::chart2::XChartType >  xChartType,
130*cdf0e10cSrcweir             bool                                        bSwapXAndYAxis,
131*cdf0e10cSrcweir             sal_Int32                                   nStartColumn,
132*cdf0e10cSrcweir             sal_Int32                                   nEndColumn ) :
133*cdf0e10cSrcweir                 m_xDataSeries( xDataSeries ),
134*cdf0e10cSrcweir                 m_xChartType( xChartType ),
135*cdf0e10cSrcweir                 m_bSwapXAndYAxis( bSwapXAndYAxis ),
136*cdf0e10cSrcweir                 m_nStartColumn( nStartColumn ),
137*cdf0e10cSrcweir                 m_nEndColumn( nEndColumn )
138*cdf0e10cSrcweir         {}
139*cdf0e10cSrcweir     };
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     typedef ::std::vector< tDataHeader > tDataHeaderVector;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     const tDataHeaderVector& getDataHeaders() const;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     tDataHeader getHeaderForSeries(
146*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
147*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries > &xSeries ) const;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
150*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries >
151*cdf0e10cSrcweir         getDataSeriesByColumn( sal_Int32 nColumn ) const;
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir private:
154*cdf0e10cSrcweir     void updateFromModel();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     void addErrorBarRanges(
157*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
158*cdf0e10cSrcweir             ::com::sun::star::chart2::XDataSeries > & xDataSeries,
159*cdf0e10cSrcweir         sal_Int32 nNumberFormatKey,
160*cdf0e10cSrcweir         sal_Int32 & rInOutSequenceIndex,
161*cdf0e10cSrcweir         sal_Int32 & rInOutHeaderEnd );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     sal_Int32 getCategoryColumnCount();
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
166*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartDocument > m_xChartDocument;
167*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
168*cdf0e10cSrcweir             ::com::sun::star::uno::XComponentContext > m_xContext;
169*cdf0e10cSrcweir     ::std::auto_ptr< DialogModel > m_apDialogModel;
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     struct tDataColumn;
172*cdf0e10cSrcweir     struct implColumnLess;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     typedef ::std::vector< tDataColumn > tDataColumnVector;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     tDataColumnVector m_aColumns;
177*cdf0e10cSrcweir     tDataHeaderVector m_aHeaders;
178*cdf0e10cSrcweir };
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir } //  namespace chart
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir // CHART2_DATABROWSERMODEL_HXX
183*cdf0e10cSrcweir #endif
184