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 CHART2_DATABROWSERMODEL_HXX
20 : #define CHART2_DATABROWSERMODEL_HXX
21 :
22 : #include <com/sun/star/chart2/XChartDocument.hpp>
23 : #include <com/sun/star/uno/XComponentContext.hpp>
24 :
25 : #include <memory>
26 : #include <vector>
27 :
28 : namespace com { namespace sun { namespace star { namespace chart2 {
29 : class XDataSeries;
30 : class XChartType;
31 : }}}}
32 :
33 : namespace chart
34 : {
35 :
36 : class DialogModel;
37 :
38 : class DataBrowserModel
39 : {
40 : public:
41 : explicit DataBrowserModel(
42 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc,
43 : const ::com::sun::star::uno::Reference<
44 : ::com::sun::star::uno::XComponentContext > & xContext );
45 : virtual ~DataBrowserModel();
46 :
47 : /** Inserts a new data series after the data series to which the data column
48 : with index nAfterColumnIndex belongs.
49 : */
50 : void insertDataSeries( sal_Int32 nAfterColumnIndex );
51 :
52 : /** Inserts a new text column for complex categories.
53 : */
54 : void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex );
55 :
56 : /** Removes a data series to which the data column with index nAtColumnIndex
57 : belongs.
58 : */
59 : void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex );
60 :
61 : /** Swaps the series to which the data column with index nFirstIndex belongs
62 : with the next series (which starts at an index >= nFirstIndex + 1)
63 : */
64 : void swapDataSeries( sal_Int32 nFirstIndex );
65 : void swapDataPointForAllSeries( sal_Int32 nFirstIndex );
66 :
67 : void insertDataPointForAllSeries( sal_Int32 nAfterIndex );
68 : void removeDataPointForAllSeries( sal_Int32 nAtIndex );
69 :
70 : enum eCellType
71 : {
72 : NUMBER,
73 : TEXT,
74 : TEXTORDATE
75 : };
76 :
77 : eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const;
78 : /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan
79 : double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow );
80 : ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow );
81 : ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow );
82 : sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow );
83 :
84 : /// returns </sal_True> if the number could successfully be set at the given position
85 : bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue );
86 : /// returns </sal_True> if the text could successfully be set at the given position
87 : bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::rtl::OUString & rText );
88 : bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::com::sun::star::uno::Any & aValue );
89 :
90 : sal_Int32 getColumnCount() const;
91 : sal_Int32 getMaxRowCount() const;
92 :
93 : // returns the UI string of the corresponding role
94 : ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const;
95 : bool isCategoriesColumn( sal_Int32 nColumnIndex ) const;
96 :
97 0 : struct tDataHeader
98 : {
99 : ::com::sun::star::uno::Reference<
100 : ::com::sun::star::chart2::XDataSeries > m_xDataSeries;
101 : ::com::sun::star::uno::Reference<
102 : ::com::sun::star::chart2::XChartType > m_xChartType;
103 : bool m_bSwapXAndYAxis;
104 : sal_Int32 m_nStartColumn;
105 : sal_Int32 m_nEndColumn;
106 :
107 : // default CTOR
108 0 : tDataHeader() :
109 : m_bSwapXAndYAxis( false ),
110 : m_nStartColumn( -1 ),
111 0 : m_nEndColumn( -1 )
112 0 : {}
113 : // "full" CTOR
114 0 : tDataHeader(
115 : ::com::sun::star::uno::Reference<
116 : ::com::sun::star::chart2::XDataSeries > xDataSeries,
117 : ::com::sun::star::uno::Reference<
118 : ::com::sun::star::chart2::XChartType > xChartType,
119 : bool bSwapXAndYAxis,
120 : sal_Int32 nStartColumn,
121 : sal_Int32 nEndColumn ) :
122 : m_xDataSeries( xDataSeries ),
123 : m_xChartType( xChartType ),
124 : m_bSwapXAndYAxis( bSwapXAndYAxis ),
125 : m_nStartColumn( nStartColumn ),
126 0 : m_nEndColumn( nEndColumn )
127 0 : {}
128 : };
129 :
130 : typedef ::std::vector< tDataHeader > tDataHeaderVector;
131 :
132 : const tDataHeaderVector& getDataHeaders() const;
133 :
134 : tDataHeader getHeaderForSeries(
135 : const ::com::sun::star::uno::Reference<
136 : ::com::sun::star::chart2::XDataSeries > &xSeries ) const;
137 :
138 : ::com::sun::star::uno::Reference<
139 : ::com::sun::star::chart2::XDataSeries >
140 : getDataSeriesByColumn( sal_Int32 nColumn ) const;
141 :
142 : private:
143 : void updateFromModel();
144 :
145 : void addErrorBarRanges(
146 : const ::com::sun::star::uno::Reference<
147 : ::com::sun::star::chart2::XDataSeries > & xDataSeries,
148 : sal_Int32 nNumberFormatKey,
149 : sal_Int32 & rInOutSequenceIndex,
150 : sal_Int32 & rInOutHeaderEnd, bool bYError );
151 :
152 : sal_Int32 getCategoryColumnCount();
153 :
154 : ::com::sun::star::uno::Reference<
155 : ::com::sun::star::chart2::XChartDocument > m_xChartDocument;
156 : ::com::sun::star::uno::Reference<
157 : ::com::sun::star::uno::XComponentContext > m_xContext;
158 : ::std::auto_ptr< DialogModel > m_apDialogModel;
159 :
160 : struct tDataColumn;
161 : struct implColumnLess;
162 :
163 : typedef ::std::vector< tDataColumn > tDataColumnVector;
164 :
165 : tDataColumnVector m_aColumns;
166 : tDataHeaderVector m_aHeaders;
167 : };
168 :
169 : } // namespace chart
170 :
171 : // CHART2_DATABROWSERMODEL_HXX
172 : #endif
173 :
174 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|