xref: /aoo41x/main/chart2/source/inc/AxisHelper.hxx (revision de7b3f82)
1*de7b3f82SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*de7b3f82SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*de7b3f82SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*de7b3f82SAndrew Rist  * distributed with this work for additional information
6*de7b3f82SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*de7b3f82SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*de7b3f82SAndrew Rist  * "License"); you may not use this file except in compliance
9*de7b3f82SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*de7b3f82SAndrew Rist  *
11*de7b3f82SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*de7b3f82SAndrew Rist  *
13*de7b3f82SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*de7b3f82SAndrew Rist  * software distributed under the License is distributed on an
15*de7b3f82SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*de7b3f82SAndrew Rist  * KIND, either express or implied.  See the License for the
17*de7b3f82SAndrew Rist  * specific language governing permissions and limitations
18*de7b3f82SAndrew Rist  * under the License.
19*de7b3f82SAndrew Rist  *
20*de7b3f82SAndrew Rist  *************************************************************/
21*de7b3f82SAndrew Rist 
22*de7b3f82SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CHART2_TOOLS_AXISHELPER_HXX
24cdf0e10cSrcweir #define _CHART2_TOOLS_AXISHELPER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "charttoolsdllapi.hxx"
27cdf0e10cSrcweir #include "ReferenceSizeProvider.hxx"
28cdf0e10cSrcweir #include "ExplicitCategoriesProvider.hxx"
29cdf0e10cSrcweir #include <com/sun/star/chart2/XChartType.hpp>
30cdf0e10cSrcweir #include <com/sun/star/chart2/XCoordinateSystem.hpp>
31cdf0e10cSrcweir #include <com/sun/star/chart2/XDiagram.hpp>
32cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
33cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <vector>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //.............................................................................
38cdf0e10cSrcweir namespace chart
39cdf0e10cSrcweir {
40cdf0e10cSrcweir //.............................................................................
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //-----------------------------------------------------------------------------
43cdf0e10cSrcweir /**
44cdf0e10cSrcweir */
45cdf0e10cSrcweir 
46cdf0e10cSrcweir class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper
47cdf0e10cSrcweir {
48cdf0e10cSrcweir public:
49cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > createLinearScaling();
50cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > createLogarithmicScaling( double fBase = 10.0 );
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     static ::com::sun::star::chart2::ScaleData createDefaultScale();
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     static void removeExplicitScaling( ::com::sun::star::chart2::ScaleData& rScaleData );
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     static bool isLogarithmic( const ::com::sun::star::uno::Reference<
57cdf0e10cSrcweir                 ::com::sun::star::chart2::XScaling >& xScaling );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     static void checkDateAxis( ::com::sun::star::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis );
60cdf0e10cSrcweir     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 );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     static sal_Int32 getExplicitNumberFormatKeyForAxis(
63cdf0e10cSrcweir                   const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
64cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCorrespondingCoordinateSystem
65cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier
66cdf0e10cSrcweir                 , bool bSearchForParallelAxisIfNothingIsFound );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
69cdf0e10cSrcweir            ::com::sun::star::chart2::XAxis >
70cdf0e10cSrcweir         createAxis( sal_Int32 nDimensionIndex, bool bMainAxis
71cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram
72cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
73cdf0e10cSrcweir                 , ReferenceSizeProvider * pRefSizeProvider = 0 );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
76cdf0e10cSrcweir            ::com::sun::star::chart2::XAxis >
77cdf0e10cSrcweir         createAxis(
78cdf0e10cSrcweir             sal_Int32 nDimensionIndex
79cdf0e10cSrcweir             , sal_Int32 nAxisIndex // 0==main or 1==secondary axis
80cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
81cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
82cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
83cdf0e10cSrcweir                     ::com::sun::star::uno::XComponentContext > & xContext
84cdf0e10cSrcweir             , ReferenceSizeProvider * pRefSizeProvider = 0 );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     static void showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
87cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram
88cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
89cdf0e10cSrcweir                 , ReferenceSizeProvider * pRefSizeProvider = 0 );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     static void showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
92cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram
93cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     static void hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis
96cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
97cdf0e10cSrcweir     static void hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
98cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     static sal_Bool isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis
101cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
102cdf0e10cSrcweir     static sal_Bool isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
103cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     static void makeAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
106cdf0e10cSrcweir     static void makeGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     static void makeAxisInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
109cdf0e10cSrcweir     static void makeGridInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     static void hideAxisIfNoDataIsAttached( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
112cdf0e10cSrcweir                                           , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     SAL_DLLPRIVATE static sal_Bool areAxisLabelsVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProperties );
115cdf0e10cSrcweir     static sal_Bool isAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
116cdf0e10cSrcweir     static sal_Bool isGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
119cdf0e10cSrcweir             ::com::sun::star::chart2::XCoordinateSystem >
120cdf0e10cSrcweir         getCoordinateSystemByIndex(
121cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
122cdf0e10cSrcweir             ::com::sun::star::chart2::XDiagram >& xDiagram
123cdf0e10cSrcweir             , sal_Int32 nIndex );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
126cdf0e10cSrcweir             ::com::sun::star::chart2::XCoordinateSystem >
127cdf0e10cSrcweir         getCoordinateSystemOfAxis(
128cdf0e10cSrcweir               const ::com::sun::star::uno::Reference<
129cdf0e10cSrcweir                 ::com::sun::star::chart2::XAxis >& xAxis
130cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
131cdf0e10cSrcweir                 ::com::sun::star::chart2::XDiagram >& xDiagram );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
134cdf0e10cSrcweir             ::com::sun::star::chart2::XAxis >
135cdf0e10cSrcweir         getAxis( sal_Int32 nDimensionIndex, bool bMainAxis
136cdf0e10cSrcweir                 , const ::com::sun::star::uno::Reference<
137cdf0e10cSrcweir                     ::com::sun::star::chart2::XDiagram >& xDiagram );
138cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
139cdf0e10cSrcweir             ::com::sun::star::chart2::XAxis >
140cdf0e10cSrcweir         getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
141cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
142cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
145cdf0e10cSrcweir             ::com::sun::star::chart2::XAxis >
146cdf0e10cSrcweir         getCrossingMainAxis( const ::com::sun::star::uno::Reference<
147cdf0e10cSrcweir                 ::com::sun::star::chart2::XAxis >& xAxis
148cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
149cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
152cdf0e10cSrcweir             ::com::sun::star::chart2::XAxis >
153cdf0e10cSrcweir         getParallelAxis( const ::com::sun::star::uno::Reference<
154cdf0e10cSrcweir                 ::com::sun::star::chart2::XAxis >& xAxis
155cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
156cdf0e10cSrcweir                     ::com::sun::star::chart2::XDiagram >& xDiagram );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
159cdf0e10cSrcweir             ::com::sun::star::beans::XPropertySet >
160cdf0e10cSrcweir         getGridProperties( const ::com::sun::star::uno::Reference<
161cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
162cdf0e10cSrcweir                 , sal_Int32 nDimensionIndex
163cdf0e10cSrcweir                 , sal_Int32 nAxisIndex //0: Primary axies, 1: secondary axis
164cdf0e10cSrcweir                 , sal_Int32 nSubGridIndex = -1 //-1: Main Grid; 0: First SubGrid etc
165cdf0e10cSrcweir                 );
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     static sal_Int32 getDimensionIndexOfAxis(
168cdf0e10cSrcweir               const ::com::sun::star::uno::Reference<
169cdf0e10cSrcweir                     ::com::sun::star::chart2::XAxis >& xAxis
170cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
171cdf0e10cSrcweir                     ::com::sun::star::chart2::XDiagram >& xDiagram );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     static bool getIndicesForAxis(
174cdf0e10cSrcweir               const ::com::sun::star::uno::Reference<
175cdf0e10cSrcweir                     ::com::sun::star::chart2::XAxis >& xAxis
176cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
177cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
178cdf0e10cSrcweir             , sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     static bool getIndicesForAxis(
181cdf0e10cSrcweir               const ::com::sun::star::uno::Reference<
182cdf0e10cSrcweir                     ::com::sun::star::chart2::XAxis >& xAxis
183cdf0e10cSrcweir             , const ::com::sun::star::uno::Reference<
184cdf0e10cSrcweir                     ::com::sun::star::chart2::XDiagram >& xDiagram
185cdf0e10cSrcweir             , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
188cdf0e10cSrcweir                </sal_True> are returned
189cdf0e10cSrcweir      */
190cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence<
191cdf0e10cSrcweir                 ::com::sun::star::uno::Reference<
192cdf0e10cSrcweir                     ::com::sun::star::chart2::XAxis > >
193cdf0e10cSrcweir             getAllAxesOfDiagram( const ::com::sun::star::uno::Reference<
194cdf0e10cSrcweir                     ::com::sun::star::chart2::XDiagram >& xDiagram
195cdf0e10cSrcweir             , bool bOnlyVisible = false );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
198cdf0e10cSrcweir                </sal_True> are returned
199cdf0e10cSrcweir      */
200cdf0e10cSrcweir     SAL_DLLPRIVATE static std::vector<
201cdf0e10cSrcweir                 ::com::sun::star::uno::Reference<
202cdf0e10cSrcweir                     ::com::sun::star::chart2::XAxis > >
203cdf0e10cSrcweir             getAllAxesOfCoordinateSystem( const ::com::sun::star::uno::Reference<
204cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys
205cdf0e10cSrcweir             , bool bOnlyVisible = false );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence<
208cdf0e10cSrcweir                 ::com::sun::star::uno::Reference<
209cdf0e10cSrcweir                     ::com::sun::star::beans::XPropertySet > >
210cdf0e10cSrcweir             getAllGrids( const ::com::sun::star::uno::Reference<
211cdf0e10cSrcweir                     ::com::sun::star::chart2::XDiagram >& xDiagram );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     static void getAxisOrGridPossibilities( ::com::sun::star::uno::Sequence< sal_Bool >& rPossibilityList
214cdf0e10cSrcweir         , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram, sal_Bool bAxis=sal_True );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     static void getAxisOrGridExcistence( ::com::sun::star::uno::Sequence< sal_Bool >& rExcistenceList
217cdf0e10cSrcweir         , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram, sal_Bool bAxis=sal_True );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     static bool changeVisibilityOfGrids( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram
220cdf0e10cSrcweir                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rOldExistenceList
221cdf0e10cSrcweir                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rNewExistenceList
222cdf0e10cSrcweir                         , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     static bool changeVisibilityOfAxes( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram>& xDiagram
225cdf0e10cSrcweir                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rOldExistenceList
226cdf0e10cSrcweir                         , const ::com::sun::star::uno::Sequence< sal_Bool >& rNewExistenceList
227cdf0e10cSrcweir                         , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
228cdf0e10cSrcweir                         , ReferenceSizeProvider * pRefSizeProvider = 0 );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     static bool shouldAxisBeDisplayed( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
231cdf0e10cSrcweir                                        , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
232cdf0e10cSrcweir     static bool isSecondaryYAxisNeeded( const ::com::sun::star::uno::Reference<
233cdf0e10cSrcweir                     ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
236cdf0e10cSrcweir             ::com::sun::star::chart2::XChartType >
237cdf0e10cSrcweir         getChartTypeByIndex( const ::com::sun::star::uno::Reference<
238cdf0e10cSrcweir             ::com::sun::star::chart2::XCoordinateSystem >& xCooSys, sal_Int32 nIndex );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     static void setRTLAxisLayout( const ::com::sun::star::uno::Reference<
241cdf0e10cSrcweir             ::com::sun::star::chart2::XCoordinateSystem >& xCooSys );
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     static ::com::sun::star::uno::Reference<
244cdf0e10cSrcweir             ::com::sun::star::chart2::XChartType >
245cdf0e10cSrcweir         getFirstChartTypeWithSeriesAttachedToAxisIndex( const ::com::sun::star::uno::Reference<
246cdf0e10cSrcweir             ::com::sun::star::chart2::XDiagram >& xDiagram, const sal_Int32 nAttachedAxisIndex );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     static bool isAxisPositioningEnabled();
249cdf0e10cSrcweir };
250cdf0e10cSrcweir 
251cdf0e10cSrcweir //.............................................................................
252cdf0e10cSrcweir } //namespace chart
253cdf0e10cSrcweir //.............................................................................
254cdf0e10cSrcweir #endif
255