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