1*de7b3f82SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*de7b3f82SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*de7b3f82SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*de7b3f82SAndrew Rist  * distributed with this work for additional information
6*de7b3f82SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*de7b3f82SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*de7b3f82SAndrew Rist  * "License"); you may not use this file except in compliance
9*de7b3f82SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*de7b3f82SAndrew Rist  *
11*de7b3f82SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*de7b3f82SAndrew Rist  *
13*de7b3f82SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*de7b3f82SAndrew Rist  * software distributed under the License is distributed on an
15*de7b3f82SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*de7b3f82SAndrew Rist  * KIND, either express or implied.  See the License for the
17*de7b3f82SAndrew Rist  * specific language governing permissions and limitations
18*de7b3f82SAndrew Rist  * under the License.
19*de7b3f82SAndrew Rist  *
20*de7b3f82SAndrew Rist  *************************************************************/
21*de7b3f82SAndrew Rist 
22*de7b3f82SAndrew Rist 
23cdf0e10cSrcweir #ifndef CHART2_DATASERIESHELPER_HXX
24cdf0e10cSrcweir #define CHART2_DATASERIESHELPER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSequence.hpp>
27cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSource.hpp>
28cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeries.hpp>
29cdf0e10cSrcweir #include <com/sun/star/chart2/XDiagram.hpp>
30cdf0e10cSrcweir #include <com/sun/star/chart2/XCoordinateSystem.hpp>
31cdf0e10cSrcweir #include <com/sun/star/chart2/XChartType.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "StackMode.hxx"
34cdf0e10cSrcweir #include "charttoolsdllapi.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <vector>
37cdf0e10cSrcweir #include <functional>
38cdf0e10cSrcweir #include <hash_set>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace chart
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir namespace DataSeriesHelper
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir ::rtl::OUString GetRole(
47cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
48cdf0e10cSrcweir             ::com::sun::star::chart2::data::XLabeledDataSequence >& xLabeledDataSequence );
49cdf0e10cSrcweir 
50cdf0e10cSrcweir /** Retrieves the data sequence in the given data source that matches the
51cdf0e10cSrcweir     given role.  If more than one sequences match the role, the first match
52cdf0e10cSrcweir     is returned.  If no sequence matches, an empty reference is returned.
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     @param aSource
55cdf0e10cSrcweir         The data source containing all data sequences to be searched through.
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     @param aRole
58cdf0e10cSrcweir         The role that is to be filtered out.
59cdf0e10cSrcweir */
60cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
61cdf0e10cSrcweir     getDataSequenceByRole( const ::com::sun::star::uno::Reference<
62cdf0e10cSrcweir                                ::com::sun::star::chart2::data::XDataSource > & xSource,
63cdf0e10cSrcweir                            ::rtl::OUString aRole,
64cdf0e10cSrcweir                            bool bMatchPrefix = false );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir /** Retrieves all data sequences in the given data source that match the given
67cdf0e10cSrcweir     role.
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     @param aSource
70cdf0e10cSrcweir         The data source containing all data sequences to be searched through.
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     @param aRole
73cdf0e10cSrcweir         The role that is to be filtered out.
74cdf0e10cSrcweir */
75cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::std::vector<
76cdf0e10cSrcweir   ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >
77cdf0e10cSrcweir     getAllDataSequencesByRole( const ::com::sun::star::uno::Sequence<
78cdf0e10cSrcweir                                    ::com::sun::star::uno::Reference<
79cdf0e10cSrcweir                                        ::com::sun::star::chart2::data::XLabeledDataSequence > > & aDataSequences,
80cdf0e10cSrcweir                                ::rtl::OUString aRole,
81cdf0e10cSrcweir                                bool bMatchPrefix = false );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir /** Retrieves all data sequences found in the given data series and puts them
84cdf0e10cSrcweir     into a data source.  The order of sequences will match the order of the data
85cdf0e10cSrcweir     series.
86cdf0e10cSrcweir  */
87cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::uno::Reference<
88cdf0e10cSrcweir         ::com::sun::star::chart2::data::XDataSource >
89cdf0e10cSrcweir     getDataSource( const ::com::sun::star::uno::Sequence<
90cdf0e10cSrcweir                           ::com::sun::star::uno::Reference<
91cdf0e10cSrcweir                               ::com::sun::star::chart2::XDataSeries > > & aSeries );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir /** Get the label of a series (e.g. for the legend)
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     @param rLabelSequenceRole
97cdf0e10cSrcweir         The data sequence contained in xSeries that has this role will be used
98cdf0e10cSrcweir         to take its label.
99cdf0e10cSrcweir  */
100cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString getDataSeriesLabel(
101cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
102cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries > & xSeries,
103cdf0e10cSrcweir     const ::rtl::OUString & rLabelSequenceRole );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /** Get the label of a labeled sequence including neccessary automatic generation
106cdf0e10cSrcweir  */
107cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString getLabelForLabeledDataSequence(
108cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
109cdf0e10cSrcweir         ::com::sun::star::chart2::data::XLabeledDataSequence > & xLabeledSeq );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void setStackModeAtSeries(
112cdf0e10cSrcweir     const ::com::sun::star::uno::Sequence<
113cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > & aSeries,
114cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
115cdf0e10cSrcweir         ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
116cdf0e10cSrcweir     StackMode eStackMode );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getAttachedAxisIndex(
119cdf0e10cSrcweir     const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir /// @param nAxisIndex, if -1 it is determined by the given data series via getAttachedAxisIndex
122cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getNumberFormatKeyFromAxis(
123cdf0e10cSrcweir     const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries,
124cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
125cdf0e10cSrcweir         ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
126cdf0e10cSrcweir     sal_Int32 nDimensionIndex,
127cdf0e10cSrcweir     sal_Int32 nAxisIndex = -1 );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS
130cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >
131cdf0e10cSrcweir     getCoordinateSystemOfSeries(
132cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries,
133cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS
136cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >
137cdf0e10cSrcweir     getChartTypeOfSeries(
138cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries,
139cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries(
142cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
143cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries > & xSeries,
144cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
145cdf0e10cSrcweir         ::com::sun::star::chart2::XChartType > & xChartType );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void switchSymbolsOnOrOff(
148cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
149cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet > & xSeriesProperties,
150cdf0e10cSrcweir     bool bSymbolsOn, sal_Int32 nSeriesIndex );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void switchLinesOnOrOff(
153cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
154cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet > & xSeriesProperties,
155cdf0e10cSrcweir     bool bLinesOn );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS
158cdf0e10cSrcweir void makeLinesThickOrThin( const ::com::sun::star::uno::Reference<
159cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet > & xSeriesProperties, bool bThick );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(
162cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
163cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries,
164cdf0e10cSrcweir         const ::rtl::OUString& rPropertyName,
165cdf0e10cSrcweir         const ::com::sun::star::uno::Any& rPropertyValue );
166cdf0e10cSrcweir 
167cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue(
168cdf0e10cSrcweir     const ::com::sun::star::uno::Reference<
169cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries,
170cdf0e10cSrcweir     const ::rtl::OUString& rPropertyName,
171cdf0e10cSrcweir     const ::com::sun::star::uno::Any& rPropertyValue );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS bool areAllSeriesAttachedToSameAxis(
174cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType,
175cdf0e10cSrcweir         sal_Int32 & rOutAxisIndex );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS bool hasUnhiddenData( const ::com::sun::star::uno::Reference<
178cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS
181cdf0e10cSrcweir sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const ::com::sun::star::uno::Reference<
182cdf0e10cSrcweir         ::com::sun::star::chart2::data::XDataSequence >& xDataSequence, bool bTranslate );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const ::com::sun::star::uno::Reference<
185cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const ::com::sun::star::uno::Reference<
188cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const ::com::sun::star::uno::Reference<
191cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const ::com::sun::star::uno::Reference<
194cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelToPoint( const ::com::sun::star::uno::Reference<
197cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet >& xPointPropertySet );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const ::com::sun::star::uno::Reference<
200cdf0e10cSrcweir         ::com::sun::star::chart2::XDataSeries >& xSeries );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromPoint( const ::com::sun::star::uno::Reference<
203cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet >& xPointPropertySet );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir } //  namespace DataSeriesHelper
206cdf0e10cSrcweir } //  namespace chart
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // CHART2_DATASERIESHELPER_HXX
209cdf0e10cSrcweir #endif
210