/src/libreoffice/chart2/source/inc/DataBrowserModel.hxx
Line | Count | Source (jump to first uncovered line) |
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 | | #pragma once |
20 | | |
21 | | #include "DataSeries.hxx" |
22 | | #include "ChartType.hxx" |
23 | | |
24 | | #include <com/sun/star/uno/Reference.hxx> |
25 | | #include <rtl/ref.hxx> |
26 | | |
27 | | #include <memory> |
28 | | #include <utility> |
29 | | #include <vector> |
30 | | |
31 | | namespace com::sun::star::chart2 { |
32 | | class XDataSeries; |
33 | | } |
34 | | |
35 | | namespace chart |
36 | | { |
37 | | |
38 | | class DialogModel; |
39 | | class ChartModel; |
40 | | |
41 | | class DataBrowserModel final |
42 | | { |
43 | | public: |
44 | | explicit DataBrowserModel( |
45 | | const rtl::Reference<::chart::ChartModel> & xChartDoc ); |
46 | | ~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 ) 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 | | css::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); |
83 | | sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn ); |
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 css::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 | | const OUString & getRoleOfColumn( sal_Int32 nColumnIndex ) const; |
96 | | bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; |
97 | | |
98 | | struct tDataHeader |
99 | | { |
100 | | rtl::Reference< ::chart::DataSeries > m_xDataSeries; |
101 | | rtl::Reference< ::chart::ChartType > m_xChartType; |
102 | | bool m_bSwapXAndYAxis; |
103 | | sal_Int32 m_nStartColumn; |
104 | | sal_Int32 m_nEndColumn; |
105 | | |
106 | | // default CTOR |
107 | | tDataHeader() : |
108 | 0 | m_bSwapXAndYAxis( false ), |
109 | 0 | m_nStartColumn( -1 ), |
110 | 0 | m_nEndColumn( -1 ) |
111 | 0 | {} |
112 | | // "full" CTOR |
113 | | tDataHeader( |
114 | | rtl::Reference< ::chart::DataSeries > xDataSeries, |
115 | | rtl::Reference< ::chart::ChartType > xChartType, |
116 | | bool bSwapXAndYAxis, |
117 | | sal_Int32 nStartColumn, |
118 | | sal_Int32 nEndColumn ) : |
119 | 0 | m_xDataSeries(std::move( xDataSeries )), |
120 | 0 | m_xChartType(std::move( xChartType )), |
121 | 0 | m_bSwapXAndYAxis( bSwapXAndYAxis ), |
122 | 0 | m_nStartColumn( nStartColumn ), |
123 | 0 | m_nEndColumn( nEndColumn ) |
124 | 0 | {} |
125 | | }; |
126 | | |
127 | | typedef std::vector< tDataHeader > tDataHeaderVector; |
128 | | |
129 | 0 | const tDataHeaderVector& getDataHeaders() const { return m_aHeaders;} |
130 | | |
131 | | tDataHeader getHeaderForSeries( |
132 | | const css::uno::Reference< css::chart2::XDataSeries > &xSeries ) const; |
133 | | |
134 | | rtl::Reference< ::chart::DataSeries > |
135 | | getDataSeriesByColumn( sal_Int32 nColumn ) const; |
136 | | |
137 | | private: |
138 | | void updateFromModel(); |
139 | | |
140 | | void removeComplexCategoryLevel( sal_Int32 nAtColumnIndex ); |
141 | | |
142 | | void addErrorBarRanges( |
143 | | const rtl::Reference<::chart::DataSeries > & xDataSeries, |
144 | | sal_Int32 nNumberFormatKey, |
145 | | sal_Int32 & rInOutSequenceIndex, |
146 | | sal_Int32 & rInOutHeaderEnd, bool bYError ); |
147 | | |
148 | | sal_Int32 getCategoryColumnCount(); |
149 | | |
150 | | rtl::Reference<::chart::ChartModel> m_xChartDocument; |
151 | | std::unique_ptr< DialogModel > m_apDialogModel; |
152 | | |
153 | | struct tDataColumn; |
154 | | struct implColumnLess; |
155 | | |
156 | | typedef std::vector< tDataColumn > tDataColumnVector; |
157 | | |
158 | | tDataColumnVector m_aColumns; |
159 | | tDataHeaderVector m_aHeaders; |
160 | | }; |
161 | | |
162 | | } // namespace chart |
163 | | |
164 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |