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