Debian Codegraph @

chart2/source/controller/dialogs/DialogModel.hxx

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