Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSERMODEL_HXX
20 : #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSERMODEL_HXX
21 :
22 : #include <com/sun/star/chart2/XChartDocument.hpp>
23 : #include <com/sun/star/uno/XComponentContext.hpp>
24 :
25 : #include <vector>
26 :
27 : #include <boost/scoped_ptr.hpp>
28 :
29 : namespace com { namespace sun { namespace star { namespace chart2 {
30 : class XDataSeries;
31 : class XChartType;
32 : }}}}
33 :
34 : namespace chart
35 : {
36 :
37 : class DialogModel;
38 :
39 : class DataBrowserModel
40 : {
41 : public:
42 : explicit DataBrowserModel(
43 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc,
44 : const ::com::sun::star::uno::Reference<
45 : ::com::sun::star::uno::XComponentContext > & xContext );
46 : virtual ~DataBrowserModel();
47 :
48 : /** Inserts a new data series after the data series to which the data column
49 : with index nAfterColumnIndex belongs.
50 : */
51 : void insertDataSeries( sal_Int32 nAfterColumnIndex );
52 :
53 : /** Inserts a new text column for complex categories.
54 : */
55 : void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex );
56 :
57 : /** Removes a data series to which the data column with index nAtColumnIndex
58 : belongs.
59 : */
60 : void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex );
61 :
62 : /** Swaps the series to which the data column with index nFirstIndex belongs
63 : with the next series (which starts at an index >= nFirstIndex + 1)
64 : */
65 : void swapDataSeries( sal_Int32 nFirstIndex );
66 : void swapDataPointForAllSeries( sal_Int32 nFirstIndex );
67 :
68 : void insertDataPointForAllSeries( sal_Int32 nAfterIndex );
69 : void removeDataPointForAllSeries( sal_Int32 nAtIndex );
70 :
71 : enum eCellType
72 : {
73 : NUMBER,
74 : TEXT,
75 : TEXTORDATE
76 : };
77 :
78 : eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const;
79 : /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan
80 : double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow );
81 : OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow );
82 : ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow );
83 : sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow );
84 :
85 : /// returns </sal_True> if the number could successfully be set at the given position
86 : bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue );
87 : /// returns </sal_True> if the text could successfully be set at the given position
88 : bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const OUString & rText );
89 : bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::com::sun::star::uno::Any & aValue );
90 :
91 : sal_Int32 getColumnCount() const;
92 : sal_Int32 getMaxRowCount() const;
93 :
94 : // returns the UI string of the corresponding role
95 : OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const;
96 : bool isCategoriesColumn( sal_Int32 nColumnIndex ) const;
97 :
98 0 : struct tDataHeader
99 : {
100 : ::com::sun::star::uno::Reference<
101 : ::com::sun::star::chart2::XDataSeries > m_xDataSeries;
102 : ::com::sun::star::uno::Reference<
103 : ::com::sun::star::chart2::XChartType > m_xChartType;
104 : bool m_bSwapXAndYAxis;
105 : sal_Int32 m_nStartColumn;
106 : sal_Int32 m_nEndColumn;
107 :
108 : // default CTOR
109 0 : tDataHeader() :
110 : m_bSwapXAndYAxis( false ),
111 : m_nStartColumn( -1 ),
112 0 : m_nEndColumn( -1 )
113 0 : {}
114 : // "full" CTOR
115 0 : tDataHeader(
116 : ::com::sun::star::uno::Reference<
117 : ::com::sun::star::chart2::XDataSeries > xDataSeries,
118 : ::com::sun::star::uno::Reference<
119 : ::com::sun::star::chart2::XChartType > xChartType,
120 : bool bSwapXAndYAxis,
121 : sal_Int32 nStartColumn,
122 : sal_Int32 nEndColumn ) :
123 : m_xDataSeries( xDataSeries ),
124 : m_xChartType( xChartType ),
125 : m_bSwapXAndYAxis( bSwapXAndYAxis ),
126 : m_nStartColumn( nStartColumn ),
127 0 : m_nEndColumn( nEndColumn )
128 0 : {}
129 : };
130 :
131 : typedef ::std::vector< tDataHeader > tDataHeaderVector;
132 :
133 0 : const tDataHeaderVector& getDataHeaders() const { return m_aHeaders;}
134 :
135 : tDataHeader getHeaderForSeries(
136 : const ::com::sun::star::uno::Reference<
137 : ::com::sun::star::chart2::XDataSeries > &xSeries ) const;
138 :
139 : ::com::sun::star::uno::Reference<
140 : ::com::sun::star::chart2::XDataSeries >
141 : getDataSeriesByColumn( sal_Int32 nColumn ) const;
142 :
143 : private:
144 : void updateFromModel();
145 :
146 : void removeComplexCategoryLevel( sal_Int32 nAtColumnIndex );
147 :
148 : void addErrorBarRanges(
149 : const ::com::sun::star::uno::Reference<
150 : ::com::sun::star::chart2::XDataSeries > & xDataSeries,
151 : sal_Int32 nNumberFormatKey,
152 : sal_Int32 & rInOutSequenceIndex,
153 : sal_Int32 & rInOutHeaderEnd, bool bYError );
154 :
155 : sal_Int32 getCategoryColumnCount();
156 :
157 : ::com::sun::star::uno::Reference<
158 : ::com::sun::star::chart2::XChartDocument > m_xChartDocument;
159 : ::com::sun::star::uno::Reference<
160 : ::com::sun::star::uno::XComponentContext > m_xContext;
161 : boost::scoped_ptr< DialogModel > m_apDialogModel;
162 :
163 : struct tDataColumn;
164 : struct implColumnLess;
165 :
166 : typedef ::std::vector< tDataColumn > tDataColumnVector;
167 :
168 : tDataColumnVector m_aColumns;
169 : tDataHeaderVector m_aHeaders;
170 : };
171 :
172 : } // namespace chart
173 :
174 : // INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSERMODEL_HXX
175 : #endif
176 :
177 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|