xref: /aoo41x/main/chart2/source/inc/AxisHelper.hxx (revision de7b3f82)
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_TOOLS_AXISHELPER_HXX
24 #define _CHART2_TOOLS_AXISHELPER_HXX
25 
26 #include "charttoolsdllapi.hxx"
27 #include "ReferenceSizeProvider.hxx"
28 #include "ExplicitCategoriesProvider.hxx"
29 #include <com/sun/star/chart2/XChartType.hpp>
30 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
31 #include <com/sun/star/chart2/XDiagram.hpp>
32 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
34 
35 #include <vector>
36 
37 //.............................................................................
38 namespace chart
39 {
40 //.............................................................................
41 
42 //-----------------------------------------------------------------------------
43 /**
44 */
45 
46 class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper
47 {
48 public:
49     static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > createLinearScaling();
50     static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > createLogarithmicScaling( double fBase = 10.0 );
51 
52     static ::com::sun::star::chart2::ScaleData createDefaultScale();
53 
54     static void removeExplicitScaling( ::com::sun::star::chart2::ScaleData& rScaleData );
55 
56     static bool isLogarithmic( const ::com::sun::star::uno::Reference<
57                 ::com::sun::star::chart2::XScaling >& xScaling );
58 
59     static void checkDateAxis( ::com::sun::star::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis );
60     static ::com::sun::star::chart2::ScaleData getDateCheckedScale( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel );
61 
62     static sal_Int32 getExplicitNumberFormatKeyForAxis(
63                   const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
64                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCorrespondingCoordinateSystem
65                 , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier
66                 , bool bSearchForParallelAxisIfNothingIsFound );
67 
68     static ::com::sun::star::uno::Reference<
69            ::com::sun::star::chart2::XAxis >
70         createAxis( sal_Int32 nDimensionIndex, bool bMainAxis
71                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram
72                 , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
73                 , ReferenceSizeProvider * pRefSizeProvider = 0 );
74 
75     static ::com::sun::star::uno::Reference<
76            ::com::sun::star::chart2::XAxis >
77         createAxis(
78             sal_Int32 nDimensionIndex
79             , sal_Int32 nAxisIndex // 0==main or 1==secondary axis
80             , const ::com::sun::star::uno::Reference<
81                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
82             , const ::com::sun::star::uno::Reference<
83                     ::com::sun::star::uno::XComponentContext > & xContext
84             , ReferenceSizeProvider * pRefSizeProvider = 0 );
85 
86     static void showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
87                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram
88                 , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
89                 , ReferenceSizeProvider * pRefSizeProvider = 0 );
90 
91     static void showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
92                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram
93                 , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
94 
95     static void hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis
96                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
97     static void hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
98                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
99 
100     static sal_Bool isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis
101                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
102     static sal_Bool isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
103                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
104 
105     static void makeAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
106     static void makeGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
107 
108     static void makeAxisInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
109     static void makeGridInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
110 
111     static void hideAxisIfNoDataIsAttached( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
112                                           , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram);
113 
114     SAL_DLLPRIVATE static sal_Bool areAxisLabelsVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProperties );
115     static sal_Bool isAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
116     static sal_Bool isGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
117 
118     static ::com::sun::star::uno::Reference<
119             ::com::sun::star::chart2::XCoordinateSystem >
120         getCoordinateSystemByIndex(
121             const ::com::sun::star::uno::Reference<
122             ::com::sun::star::chart2::XDiagram >& xDiagram
123             , sal_Int32 nIndex );
124 
125     static ::com::sun::star::uno::Reference<
126             ::com::sun::star::chart2::XCoordinateSystem >
127         getCoordinateSystemOfAxis(
128               const ::com::sun::star::uno::Reference<
129                 ::com::sun::star::chart2::XAxis >& xAxis
130             , const ::com::sun::star::uno::Reference<
131                 ::com::sun::star::chart2::XDiagram >& xDiagram );
132 
133     static ::com::sun::star::uno::Reference<
134             ::com::sun::star::chart2::XAxis >
135         getAxis( sal_Int32 nDimensionIndex, bool bMainAxis
136                 , const ::com::sun::star::uno::Reference<
137                     ::com::sun::star::chart2::XDiagram >& xDiagram );
138     static ::com::sun::star::uno::Reference<
139             ::com::sun::star::chart2::XAxis >
140         getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
141             , const ::com::sun::star::uno::Reference<
142                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
143 
144     static ::com::sun::star::uno::Reference<
145             ::com::sun::star::chart2::XAxis >
146         getCrossingMainAxis( const ::com::sun::star::uno::Reference<
147                 ::com::sun::star::chart2::XAxis >& xAxis
148             , const ::com::sun::star::uno::Reference<
149                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
150 
151     static ::com::sun::star::uno::Reference<
152             ::com::sun::star::chart2::XAxis >
153         getParallelAxis( const ::com::sun::star::uno::Reference<
154                 ::com::sun::star::chart2::XAxis >& xAxis
155             , const ::com::sun::star::uno::Reference<
156                     ::com::sun::star::chart2::XDiagram >& xDiagram );
157 
158     static ::com::sun::star::uno::Reference<
159             ::com::sun::star::beans::XPropertySet >
160         getGridProperties( const ::com::sun::star::uno::Reference<
161                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
162                 , sal_Int32 nDimensionIndex
163                 , sal_Int32 nAxisIndex //0: Primary axies, 1: secondary axis
164                 , sal_Int32 nSubGridIndex = -1 //-1: Main Grid; 0: First SubGrid etc
165                 );
166 
167     static sal_Int32 getDimensionIndexOfAxis(
168               const ::com::sun::star::uno::Reference<
169                     ::com::sun::star::chart2::XAxis >& xAxis
170             , const ::com::sun::star::uno::Reference<
171                     ::com::sun::star::chart2::XDiagram >& xDiagram );
172 
173     static bool getIndicesForAxis(
174               const ::com::sun::star::uno::Reference<
175                     ::com::sun::star::chart2::XAxis >& xAxis
176             , const ::com::sun::star::uno::Reference<
177                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
178             , sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
179 
180     static bool getIndicesForAxis(
181               const ::com::sun::star::uno::Reference<
182                     ::com::sun::star::chart2::XAxis >& xAxis
183             , const ::com::sun::star::uno::Reference<
184                     ::com::sun::star::chart2::XDiagram >& xDiagram
185             , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
186 
187     /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
188                </sal_True> are returned
189      */
190     static ::com::sun::star::uno::Sequence<
191                 ::com::sun::star::uno::Reference<
192                     ::com::sun::star::chart2::XAxis > >
193             getAllAxesOfDiagram( const ::com::sun::star::uno::Reference<
194                     ::com::sun::star::chart2::XDiagram >& xDiagram
195             , bool bOnlyVisible = false );
196 
197     /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
198                </sal_True> are returned
199      */
200     SAL_DLLPRIVATE static std::vector<
201                 ::com::sun::star::uno::Reference<
202                     ::com::sun::star::chart2::XAxis > >
203             getAllAxesOfCoordinateSystem( const ::com::sun::star::uno::Reference<
204                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
205             , bool bOnlyVisible = false );
206 
207     static ::com::sun::star::uno::Sequence<
208                 ::com::sun::star::uno::Reference<
209                     ::com::sun::star::beans::XPropertySet > >
210             getAllGrids( const ::com::sun::star::uno::Reference<
211                     ::com::sun::star::chart2::XDiagram >& xDiagram );
212 
213     static void getAxisOrGridPossibilities( ::com::sun::star::uno::Sequence< sal_Bool >& rPossibilityList
214         , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram, sal_Bool bAxis=sal_True );
215 
216     static void getAxisOrGridExcistence( ::com::sun::star::uno::Sequence< sal_Bool >& rExcistenceList
217         , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram, sal_Bool bAxis=sal_True );
218 
219     static bool changeVisibilityOfGrids( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram
220                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rOldExistenceList
221                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rNewExistenceList
222                         , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
223 
224     static bool changeVisibilityOfAxes( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram
225                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rOldExistenceList
226                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rNewExistenceList
227                         , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
228                         , ReferenceSizeProvider * pRefSizeProvider = 0 );
229 
230     static bool shouldAxisBeDisplayed( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
231                                        , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
232     static bool isSecondaryYAxisNeeded( const ::com::sun::star::uno::Reference<
233                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
234 
235     static ::com::sun::star::uno::Reference<
236             ::com::sun::star::chart2::XChartType >
237         getChartTypeByIndex( const ::com::sun::star::uno::Reference<
238             ::com::sun::star::chart2::XCoordinateSystem >& xCooSys, sal_Int32 nIndex );
239 
240     static void setRTLAxisLayout( const ::com::sun::star::uno::Reference<
241             ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
242 
243     static ::com::sun::star::uno::Reference<
244             ::com::sun::star::chart2::XChartType >
245         getFirstChartTypeWithSeriesAttachedToAxisIndex( const ::com::sun::star::uno::Reference<
246             ::com::sun::star::chart2::XDiagram >& xDiagram, const sal_Int32 nAttachedAxisIndex );
247 
248     static bool isAxisPositioningEnabled();
249 };
250 
251 //.............................................................................
252 } //namespace chart
253 //.............................................................................
254 #endif
255