1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef CHART2_DATASERIESHELPER_HXX
28 #define CHART2_DATASERIESHELPER_HXX
29 
30 #include <com/sun/star/chart2/data/XDataSequence.hpp>
31 #include <com/sun/star/chart2/data/XDataSource.hpp>
32 #include <com/sun/star/chart2/XDataSeries.hpp>
33 #include <com/sun/star/chart2/XDiagram.hpp>
34 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
35 #include <com/sun/star/chart2/XChartType.hpp>
36 
37 #include "StackMode.hxx"
38 #include "charttoolsdllapi.hxx"
39 
40 #include <vector>
41 #include <functional>
42 #include <hash_set>
43 
44 namespace chart
45 {
46 
47 namespace DataSeriesHelper
48 {
49 
50 ::rtl::OUString GetRole(
51         const ::com::sun::star::uno::Reference<
52             ::com::sun::star::chart2::data::XLabeledDataSequence >& xLabeledDataSequence );
53 
54 /** Retrieves the data sequence in the given data source that matches the
55     given role.  If more than one sequences match the role, the first match
56     is returned.  If no sequence matches, an empty reference is returned.
57 
58     @param aSource
59         The data source containing all data sequences to be searched through.
60 
61     @param aRole
62         The role that is to be filtered out.
63 */
64 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
65     getDataSequenceByRole( const ::com::sun::star::uno::Reference<
66                                ::com::sun::star::chart2::data::XDataSource > & xSource,
67                            ::rtl::OUString aRole,
68                            bool bMatchPrefix = false );
69 
70 /** Retrieves all data sequences in the given data source that match the given
71     role.
72 
73     @param aSource
74         The data source containing all data sequences to be searched through.
75 
76     @param aRole
77         The role that is to be filtered out.
78 */
79 OOO_DLLPUBLIC_CHARTTOOLS ::std::vector<
80   ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >
81     getAllDataSequencesByRole( const ::com::sun::star::uno::Sequence<
82                                    ::com::sun::star::uno::Reference<
83                                        ::com::sun::star::chart2::data::XLabeledDataSequence > > & aDataSequences,
84                                ::rtl::OUString aRole,
85                                bool bMatchPrefix = false );
86 
87 /** Retrieves all data sequences found in the given data series and puts them
88     into a data source.  The order of sequences will match the order of the data
89     series.
90  */
91 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::uno::Reference<
92         ::com::sun::star::chart2::data::XDataSource >
93     getDataSource( const ::com::sun::star::uno::Sequence<
94                           ::com::sun::star::uno::Reference<
95                               ::com::sun::star::chart2::XDataSeries > > & aSeries );
96 
97 
98 /** Get the label of a series (e.g. for the legend)
99 
100     @param rLabelSequenceRole
101         The data sequence contained in xSeries that has this role will be used
102         to take its label.
103  */
104 OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString getDataSeriesLabel(
105     const ::com::sun::star::uno::Reference<
106         ::com::sun::star::chart2::XDataSeries > & xSeries,
107     const ::rtl::OUString & rLabelSequenceRole );
108 
109 /** Get the label of a labeled sequence including neccessary automatic generation
110  */
111 OOO_DLLPUBLIC_CHARTTOOLS ::rtl::OUString getLabelForLabeledDataSequence(
112     const ::com::sun::star::uno::Reference<
113         ::com::sun::star::chart2::data::XLabeledDataSequence > & xLabeledSeq );
114 
115 OOO_DLLPUBLIC_CHARTTOOLS void setStackModeAtSeries(
116     const ::com::sun::star::uno::Sequence<
117         ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > & aSeries,
118     const ::com::sun::star::uno::Reference<
119         ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
120     StackMode eStackMode );
121 
122 OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getAttachedAxisIndex(
123     const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries );
124 
125 /// @param nAxisIndex, if -1 it is determined by the given data series via getAttachedAxisIndex
126 OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getNumberFormatKeyFromAxis(
127     const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries,
128     const ::com::sun::star::uno::Reference<
129         ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
130     sal_Int32 nDimensionIndex,
131     sal_Int32 nAxisIndex = -1 );
132 
133 OOO_DLLPUBLIC_CHARTTOOLS
134 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >
135     getCoordinateSystemOfSeries(
136         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries,
137         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram );
138 
139 OOO_DLLPUBLIC_CHARTTOOLS
140 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >
141     getChartTypeOfSeries(
142         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xSeries,
143         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram );
144 
145 OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries(
146     const ::com::sun::star::uno::Reference<
147         ::com::sun::star::chart2::XDataSeries > & xSeries,
148     const ::com::sun::star::uno::Reference<
149         ::com::sun::star::chart2::XChartType > & xChartType );
150 
151 OOO_DLLPUBLIC_CHARTTOOLS void switchSymbolsOnOrOff(
152     const ::com::sun::star::uno::Reference<
153         ::com::sun::star::beans::XPropertySet > & xSeriesProperties,
154     bool bSymbolsOn, sal_Int32 nSeriesIndex );
155 
156 OOO_DLLPUBLIC_CHARTTOOLS void switchLinesOnOrOff(
157     const ::com::sun::star::uno::Reference<
158         ::com::sun::star::beans::XPropertySet > & xSeriesProperties,
159     bool bLinesOn );
160 
161 OOO_DLLPUBLIC_CHARTTOOLS
162 void makeLinesThickOrThin( const ::com::sun::star::uno::Reference<
163         ::com::sun::star::beans::XPropertySet > & xSeriesProperties, bool bThick );
164 
165 OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(
166     const ::com::sun::star::uno::Reference<
167         ::com::sun::star::chart2::XDataSeries >& xSeries,
168         const ::rtl::OUString& rPropertyName,
169         const ::com::sun::star::uno::Any& rPropertyValue );
170 
171 OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue(
172     const ::com::sun::star::uno::Reference<
173         ::com::sun::star::chart2::XDataSeries >& xSeries,
174     const ::rtl::OUString& rPropertyName,
175     const ::com::sun::star::uno::Any& rPropertyValue );
176 
177 OOO_DLLPUBLIC_CHARTTOOLS bool areAllSeriesAttachedToSameAxis(
178         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType,
179         sal_Int32 & rOutAxisIndex );
180 
181 OOO_DLLPUBLIC_CHARTTOOLS bool hasUnhiddenData( const ::com::sun::star::uno::Reference<
182         ::com::sun::star::chart2::XDataSeries >& xSeries );
183 
184 OOO_DLLPUBLIC_CHARTTOOLS
185 sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const ::com::sun::star::uno::Reference<
186         ::com::sun::star::chart2::data::XDataSequence >& xDataSequence, bool bTranslate );
187 
188 OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const ::com::sun::star::uno::Reference<
189         ::com::sun::star::chart2::XDataSeries >& xSeries );
190 
191 OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const ::com::sun::star::uno::Reference<
192         ::com::sun::star::chart2::XDataSeries >& xSeries );
193 
194 OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const ::com::sun::star::uno::Reference<
195         ::com::sun::star::chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex );
196 
197 OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const ::com::sun::star::uno::Reference<
198         ::com::sun::star::chart2::XDataSeries >& xSeries );
199 
200 OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelToPoint( const ::com::sun::star::uno::Reference<
201         ::com::sun::star::beans::XPropertySet >& xPointPropertySet );
202 
203 OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const ::com::sun::star::uno::Reference<
204         ::com::sun::star::chart2::XDataSeries >& xSeries );
205 
206 OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromPoint( const ::com::sun::star::uno::Reference<
207         ::com::sun::star::beans::XPropertySet >& xPointPropertySet );
208 
209 } //  namespace DataSeriesHelper
210 } //  namespace chart
211 
212 // CHART2_DATASERIESHELPER_HXX
213 #endif
214