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 "StackMode.hxx"
22 #include "charttoolsdllapi.hxx"
23 #include <com/sun/star/uno/Reference.h>
24 #include <rtl/ustring.hxx>
25 
26 #include <vector>
27 
28 namespace com::sun::star::beans { class XPropertySet; }
29 namespace com::sun::star::chart2 { class XChartType; }
30 namespace com::sun::star::chart2 { class XCoordinateSystem; }
31 namespace com::sun::star::chart2 { class XDataSeries; }
32 namespace com::sun::star::chart2 { class XDiagram; }
33 namespace com::sun::star::chart2::data { class XDataSequence; }
34 namespace com::sun::star::chart2::data { class XDataSource; }
35 namespace com::sun::star::chart2::data { class XLabeledDataSequence; }
36 namespace com::sun::star::uno { class Any; }
37 namespace com::sun::star::uno { template <class E> class Sequence; }
38 
39 namespace chart::DataSeriesHelper
40 {
41 
42 OOO_DLLPUBLIC_CHARTTOOLS OUString
43     getRole( const css::uno::Reference<css::chart2::data::XLabeledDataSequence>& xLabeledDataSequence );
44 
45 /** Retrieves the data sequence in the given data source that matches the
46     given role.  If more than one sequences match the role, the first match
47     is returned.  If no sequence matches, an empty reference is returned.
48 
49     @param aSource
50         The data source containing all data sequences to be searched through.
51 
52     @param aRole
53         The role that is to be filtered out.
54 */
55 OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XLabeledDataSequence >
56     getDataSequenceByRole( const css::uno::Reference< css::chart2::data::XDataSource > & xSource,
57                            const OUString& aRole,
58                            bool bMatchPrefix = false );
59 
60 /** Retrieves all data sequences in the given data source that match the given
61     role prefix.
62 
63     @param aSource
64         The data source containing all data sequences to be searched through.
65 
66     @param aRole
67         The role that is to be filtered out.
68 */
69 OOO_DLLPUBLIC_CHARTTOOLS std::vector<
70   css::uno::Reference< css::chart2::data::XLabeledDataSequence > >
71     getAllDataSequencesByRole( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & aDataSequences,
72                                const OUString& aRole );
73 
74 OOO_DLLPUBLIC_CHARTTOOLS
75 std::vector<css::uno::Reference<css::chart2::data::XLabeledDataSequence> >
76 getAllDataSequences(
77     const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& aSeries );
78 
79 /** Retrieves all data sequences found in the given data series and puts them
80     into a data source.  The order of sequences will match the order of the data
81     series.
82  */
83 OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XDataSource >
84     getDataSource( const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > & aSeries );
85 
86 /** Get the label of a series (e.g. for the legend)
87 
88     @param rLabelSequenceRole
89         The data sequence contained in xSeries that has this role will be used
90         to take its label.
91  */
92 OOO_DLLPUBLIC_CHARTTOOLS OUString getDataSeriesLabel(
93     const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
94     const OUString & rLabelSequenceRole );
95 
96 /** Get the label of a labeled sequence including necessary automatic generation
97  */
98 OOO_DLLPUBLIC_CHARTTOOLS OUString getLabelForLabeledDataSequence(
99     const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xLabeledSeq );
100 
101 OOO_DLLPUBLIC_CHARTTOOLS void setStackModeAtSeries(
102     const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > & aSeries,
103     const css::uno::Reference< css::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
104     StackMode eStackMode );
105 
106 OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getAttachedAxisIndex(
107     const css::uno::Reference< css::chart2::XDataSeries > & xSeries );
108 
109 /// @param nAxisIndex, if -1 it is determined by the given data series via getAttachedAxisIndex
110 OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getNumberFormatKeyFromAxis(
111     const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
112     const css::uno::Reference< css::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem,
113     sal_Int32 nDimensionIndex,
114     sal_Int32 nAxisIndex = -1 );
115 
116 OOO_DLLPUBLIC_CHARTTOOLS
117 css::uno::Reference< css::chart2::XCoordinateSystem >
118     getCoordinateSystemOfSeries(
119         const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
120         const css::uno::Reference< css::chart2::XDiagram > & xDiagram );
121 
122 OOO_DLLPUBLIC_CHARTTOOLS
123 css::uno::Reference< css::chart2::XChartType >
124     getChartTypeOfSeries(
125         const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
126         const css::uno::Reference< css::chart2::XDiagram > & xDiagram );
127 
128 OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries(
129     const css::uno::Reference< css::chart2::XDataSeries > & xSeries,
130     const css::uno::Reference< css::chart2::XChartType > & xChartType );
131 
132 OOO_DLLPUBLIC_CHARTTOOLS void switchSymbolsOnOrOff(
133     const css::uno::Reference< css::beans::XPropertySet > & xSeriesProperties,
134     bool bSymbolsOn, sal_Int32 nSeriesIndex );
135 
136 OOO_DLLPUBLIC_CHARTTOOLS void switchLinesOnOrOff(
137     const css::uno::Reference< css::beans::XPropertySet > & xSeriesProperties,
138     bool bLinesOn );
139 
140 OOO_DLLPUBLIC_CHARTTOOLS
141 void makeLinesThickOrThin( const css::uno::Reference< css::beans::XPropertySet > & xSeriesProperties, bool bThick );
142 
143 OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(
144         const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
145         const OUString& rPropertyName,
146         const css::uno::Any& rPropertyValue );
147 
148 OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue(
149     const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
150     const OUString& rPropertyName,
151     const css::uno::Any& rPropertyValue );
152 
153 OOO_DLLPUBLIC_CHARTTOOLS bool hasUnhiddenData( const css::uno::Reference<
154         css::chart2::XDataSeries >& xSeries );
155 
156 OOO_DLLPUBLIC_CHARTTOOLS
157 sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const css::uno::Reference<
158         css::chart2::data::XDataSequence >& xDataSequence, bool bTranslate );
159 
160 OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
161 
162 OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
163 
164 OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const css::uno::Reference< css::chart2::XDataSeries >& xSeries, sal_Int32 nPointIndex );
165 
166 OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
167 
168 OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelToPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet );
169 
170 OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
171 
172 OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet );
173 
174 } //  namespace chart::DataSeriesHelper
175 
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
177