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_DIALOGMODEL_HXX
20 : #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DIALOGMODEL_HXX
21 :
22 : #include "TimerTriggeredControllerLock.hxx"
23 : #include <com/sun/star/chart2/XChartDocument.hpp>
24 : #include <com/sun/star/frame/XModel.hpp>
25 : #include <com/sun/star/uno/XComponentContext.hpp>
26 :
27 : #include "ChartModel.hxx"
28 :
29 : #include <vector>
30 : #include <map>
31 : #include <boost/shared_ptr.hpp>
32 :
33 : namespace com { namespace sun { namespace star { namespace chart2 {
34 : class XDataSeriesContainer;
35 : class XDataSeries;
36 : class XChartType;
37 : class XChartTypeTemplate;
38 : struct InterpretedData;
39 : namespace data {
40 : class XDataProvider;
41 : class XLabeledDataSequence;
42 : }
43 : }}}}
44 :
45 : namespace chart
46 : {
47 :
48 : class RangeSelectionHelper;
49 :
50 : struct DialogModelTimeBasedInfo
51 : {
52 : DialogModelTimeBasedInfo();
53 :
54 : bool bTimeBased;
55 : sal_Int32 nStart;
56 : sal_Int32 nEnd;
57 : };
58 :
59 : class DialogModel
60 : {
61 : public:
62 : explicit DialogModel(
63 : const ::com::sun::star::uno::Reference<
64 : ::com::sun::star::chart2::XChartDocument > & xChartDocument,
65 : const ::com::sun::star::uno::Reference<
66 : ::com::sun::star::uno::XComponentContext > & xContext );
67 : ~DialogModel();
68 :
69 : typedef ::std::pair<
70 : OUString,
71 : ::std::pair< ::com::sun::star::uno::Reference<
72 : ::com::sun::star::chart2::XDataSeries >,
73 : ::com::sun::star::uno::Reference<
74 : ::com::sun::star::chart2::XChartType > > >
75 : tSeriesWithChartTypeByName;
76 :
77 : typedef ::std::map< OUString, OUString >
78 : tRolesWithRanges;
79 :
80 : void setTemplate(
81 : const ::com::sun::star::uno::Reference<
82 : ::com::sun::star::chart2::XChartTypeTemplate > & xTemplate );
83 :
84 : ::boost::shared_ptr< RangeSelectionHelper >
85 : getRangeSelectionHelper() const;
86 :
87 : ::com::sun::star::uno::Reference<
88 : ::com::sun::star::frame::XModel >
89 : getChartModel() const;
90 :
91 : ::com::sun::star::uno::Reference<
92 : ::com::sun::star::chart2::data::XDataProvider >
93 : getDataProvider() const;
94 :
95 : ::std::vector< ::com::sun::star::uno::Reference<
96 : ::com::sun::star::chart2::XDataSeriesContainer > >
97 : getAllDataSeriesContainers() const;
98 :
99 : ::std::vector< tSeriesWithChartTypeByName >
100 : getAllDataSeriesWithLabel() const;
101 :
102 : static tRolesWithRanges getRolesWithRanges(
103 : const ::com::sun::star::uno::Reference<
104 : ::com::sun::star::chart2::XDataSeries > & xSeries,
105 : const OUString & aRoleOfSequenceForLabel,
106 : const ::com::sun::star::uno::Reference<
107 : ::com::sun::star::chart2::XChartType > & xChartType );
108 :
109 : enum eMoveDirection
110 : {
111 : MOVE_DOWN,
112 : MOVE_UP
113 : };
114 :
115 : void moveSeries( const ::com::sun::star::uno::Reference<
116 : ::com::sun::star::chart2::XDataSeries > & xSeries,
117 : eMoveDirection eDirection );
118 :
119 : /// @return the newly inserted series
120 : ::com::sun::star::uno::Reference<
121 : ::com::sun::star::chart2::XDataSeries > insertSeriesAfter(
122 : const ::com::sun::star::uno::Reference<
123 : ::com::sun::star::chart2::XDataSeries > & xSeries,
124 : const ::com::sun::star::uno::Reference<
125 : ::com::sun::star::chart2::XChartType > & xChartType,
126 : bool bCreateDataCachedSequences = false );
127 :
128 : void deleteSeries(
129 : const ::com::sun::star::uno::Reference<
130 : ::com::sun::star::chart2::XDataSeries > & xSeries,
131 : const ::com::sun::star::uno::Reference<
132 : ::com::sun::star::chart2::XChartType > & xChartType );
133 :
134 : ::com::sun::star::uno::Reference<
135 : ::com::sun::star::chart2::data::XLabeledDataSequence >
136 : getCategories() const;
137 :
138 : void setCategories( const ::com::sun::star::uno::Reference<
139 : ::com::sun::star::chart2::data::XLabeledDataSequence > & xCategories );
140 :
141 : OUString getCategoriesRange() const;
142 :
143 : bool isCategoryDiagram() const;
144 :
145 : void detectArguments(
146 : OUString & rOutRangeString,
147 : bool & rOutUseColumns, bool & rOutFirstCellAsLabel, bool & rOutHasCategories ) const;
148 :
149 : bool allArgumentsForRectRangeDetected() const;
150 :
151 : bool setData( const ::com::sun::star::uno::Sequence<
152 : ::com::sun::star::beans::PropertyValue > & rArguments );
153 :
154 : void setTimeBasedRange( bool bTimeBased, sal_Int32 nStart, sal_Int32 nEnd) const;
155 :
156 0 : const DialogModelTimeBasedInfo& getTimeBasedInfo() const { return maTimeBasedInfo; }
157 :
158 : void startControllerLockTimer();
159 :
160 : static OUString ConvertRoleFromInternalToUI( const OUString & rRoleString );
161 : static OUString GetRoleDataLabel();
162 :
163 : // pass a role string (not translated) and get an index that serves for
164 : // relative ordering, to get e.g. x-values and y-values in the right order
165 : static sal_Int32 GetRoleIndexForSorting( const OUString & rInternalRoleString );
166 :
167 : private:
168 : ::com::sun::star::uno::Reference<
169 : ::com::sun::star::chart2::XChartDocument >
170 : m_xChartDocument;
171 :
172 : ::com::sun::star::uno::Reference<
173 : ::com::sun::star::chart2::XChartTypeTemplate >
174 : m_xTemplate;
175 :
176 : ::com::sun::star::uno::Reference<
177 : ::com::sun::star::uno::XComponentContext >
178 : m_xContext;
179 :
180 : mutable ::boost::shared_ptr< RangeSelectionHelper >
181 : m_spRangeSelectionHelper;
182 :
183 : TimerTriggeredControllerLock m_aTimerTriggeredControllerLock;
184 :
185 : private:
186 : void createBackup();
187 :
188 : void applyInterpretedData(
189 : const ::com::sun::star::chart2::InterpretedData & rNewData,
190 : const ::std::vector< ::com::sun::star::uno::Reference<
191 : ::com::sun::star::chart2::XDataSeries > > & rSeriesToReUse,
192 : bool bSetStyles );
193 :
194 : sal_Int32 countSeries() const;
195 :
196 : ChartModel& getModel() const;
197 : mutable DialogModelTimeBasedInfo maTimeBasedInfo;
198 : };
199 :
200 : } // namespace chart
201 :
202 : // INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DIALOGMODEL_HXX
203 : #endif
204 :
205 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|