Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / dialogs / DialogModel.hxx
bloba5acf7f37d50d12bb62cf7dc0990c3c14f8003d1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DIALOGMODEL_HXX
20 #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DIALOGMODEL_HXX
22 #include <TimerTriggeredControllerLock.hxx>
23 #include <rtl/ustring.hxx>
25 #include <map>
26 #include <memory>
27 #include <vector>
29 namespace chart { class ChartModel; }
30 namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } }
31 namespace com { namespace sun { namespace star { namespace chart2 { class XChartDocument; } } } }
32 namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } }
33 namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
34 namespace com { namespace sun { namespace star { namespace uno { template <class E> class Sequence; } } } }
36 namespace com { namespace sun { namespace star { namespace chart2 {
37 class XDataSeriesContainer;
38 class XDataSeries;
39 class XChartType;
40 class XChartTypeTemplate;
41 struct InterpretedData;
42 namespace data {
43 class XDataProvider;
44 class XLabeledDataSequence;
46 }}}}
48 namespace chart
51 class RangeSelectionHelper;
53 struct DialogModelTimeBasedInfo
55 DialogModelTimeBasedInfo();
57 bool bTimeBased;
58 sal_Int32 nStart;
59 sal_Int32 nEnd;
62 class DialogModel
64 public:
65 explicit DialogModel(
66 const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument,
67 const css::uno::Reference< css::uno::XComponentContext > & xContext );
68 ~DialogModel();
70 typedef std::pair<
71 OUString,
72 std::pair< css::uno::Reference< css::chart2::XDataSeries >,
73 css::uno::Reference< css::chart2::XChartType > > >
74 tSeriesWithChartTypeByName;
76 typedef std::map< OUString, OUString >
77 tRolesWithRanges;
79 void setTemplate(
80 const css::uno::Reference< css::chart2::XChartTypeTemplate > & xTemplate );
82 std::shared_ptr< RangeSelectionHelper > const &
83 getRangeSelectionHelper() const;
85 css::uno::Reference< css::frame::XModel >
86 getChartModel() const;
88 css::uno::Reference< css::chart2::data::XDataProvider >
89 getDataProvider() const;
91 std::vector< css::uno::Reference< css::chart2::XDataSeriesContainer > >
92 getAllDataSeriesContainers() const;
94 std::vector< tSeriesWithChartTypeByName >
95 getAllDataSeriesWithLabel() const;
97 static tRolesWithRanges getRolesWithRanges(
98 const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
99 const OUString & aRoleOfSequenceForLabel,
100 const css::uno::Reference< css::chart2::XChartType > & xChartType );
102 enum class MoveDirection
104 Down, Up
107 void moveSeries( const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
108 MoveDirection eDirection );
110 /// @return the newly inserted series
111 css::uno::Reference<
112 css::chart2::XDataSeries > insertSeriesAfter(
113 const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
114 const css::uno::Reference< css::chart2::XChartType > & xChartType,
115 bool bCreateDataCachedSequences = false );
117 void deleteSeries(
118 const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
119 const css::uno::Reference< css::chart2::XChartType > & xChartType );
121 css::uno::Reference< css::chart2::data::XLabeledDataSequence >
122 getCategories() const;
124 void setCategories( const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xCategories );
126 OUString getCategoriesRange() const;
128 bool isCategoryDiagram() const;
130 void detectArguments(
131 OUString & rOutRangeString,
132 bool & rOutUseColumns, bool & rOutFirstCellAsLabel, bool & rOutHasCategories ) const;
134 bool allArgumentsForRectRangeDetected() const;
136 void setData( const css::uno::Sequence< css::beans::PropertyValue > & rArguments );
138 void setTimeBasedRange( bool bTimeBased, sal_Int32 nStart, sal_Int32 nEnd) const;
140 const DialogModelTimeBasedInfo& getTimeBasedInfo() const { return maTimeBasedInfo; }
142 void startControllerLockTimer();
144 static OUString ConvertRoleFromInternalToUI( const OUString & rRoleString );
145 static OUString GetRoleDataLabel();
147 // pass a role string (not translated) and get an index that serves for
148 // relative ordering, to get e.g. x-values and y-values in the right order
149 static sal_Int32 GetRoleIndexForSorting( const OUString & rInternalRoleString );
151 ChartModel& getModel() const;
153 private:
154 css::uno::Reference< css::chart2::XChartDocument >
155 m_xChartDocument;
157 css::uno::Reference< css::chart2::XChartTypeTemplate >
158 m_xTemplate;
160 css::uno::Reference< css::uno::XComponentContext >
161 m_xContext;
163 mutable std::shared_ptr< RangeSelectionHelper >
164 m_spRangeSelectionHelper;
166 TimerTriggeredControllerLock m_aTimerTriggeredControllerLock;
168 private:
169 void applyInterpretedData(
170 const css::chart2::InterpretedData & rNewData,
171 const std::vector< css::uno::Reference< css::chart2::XDataSeries > > & rSeriesToReUse );
173 sal_Int32 countSeries() const;
175 mutable DialogModelTimeBasedInfo maTimeBasedInfo;
178 } // namespace chart
180 // INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DIALOGMODEL_HXX
181 #endif
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */