1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_INC_AXISHELPER_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_AXISHELPER_HXX
22 #include "charttoolsdllapi.hxx"
23 #include "ReferenceSizeProvider.hxx"
24 #include "ExplicitCategoriesProvider.hxx"
25 #include <com/sun/star/chart2/XChartType.hpp>
26 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
27 #include <com/sun/star/chart2/XDiagram.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
31 #include "ChartModel.hxx"
41 class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper
44 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XScaling
> createLinearScaling();
45 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XScaling
> createLogarithmicScaling( double fBase
= 10.0 );
47 static ::com::sun::star::chart2::ScaleData
createDefaultScale();
49 static void removeExplicitScaling( ::com::sun::star::chart2::ScaleData
& rScaleData
);
51 static bool isLogarithmic( const ::com::sun::star::uno::Reference
<
52 ::com::sun::star::chart2::XScaling
>& xScaling
);
54 static void checkDateAxis( ::com::sun::star::chart2::ScaleData
& rScale
, ExplicitCategoriesProvider
* pExplicitCategoriesProvider
, bool bChartTypeAllowsDateAxis
);
55 static ::com::sun::star::chart2::ScaleData
getDateCheckedScale( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
, ChartModel
& rModel
);
57 static sal_Int32
getExplicitNumberFormatKeyForAxis(
58 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
59 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
>& xCorrespondingCoordinateSystem
60 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDoc
61 , bool bSearchForParallelAxisIfNothingIsFound
);
63 static ::com::sun::star::uno::Reference
<
64 ::com::sun::star::chart2::XAxis
>
65 createAxis( sal_Int32 nDimensionIndex
, bool bMainAxis
66 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
67 , const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
68 , ReferenceSizeProvider
* pRefSizeProvider
= 0 );
70 static ::com::sun::star::uno::Reference
<
71 ::com::sun::star::chart2::XAxis
>
73 sal_Int32 nDimensionIndex
74 , sal_Int32 nAxisIndex
// 0==main or 1==secondary axis
75 , const ::com::sun::star::uno::Reference
<
76 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
77 , const ::com::sun::star::uno::Reference
<
78 ::com::sun::star::uno::XComponentContext
> & xContext
79 , ReferenceSizeProvider
* pRefSizeProvider
= 0 );
81 static void showAxis( sal_Int32 nDimensionIndex
, bool bMainAxis
82 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
83 , const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
84 , ReferenceSizeProvider
* pRefSizeProvider
= 0 );
86 static void showGrid( sal_Int32 nDimensionIndex
, sal_Int32 nCooSysIndex
, bool bMainGrid
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
);
90 static void hideAxis( sal_Int32 nDimensionIndex
, bool bMainAxis
91 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
);
92 static void hideGrid( sal_Int32 nDimensionIndex
, sal_Int32 nCooSysIndex
, bool bMainGrid
93 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
);
95 static bool isAxisShown( sal_Int32 nDimensionIndex
, bool bMainAxis
96 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
);
97 static bool isGridShown( sal_Int32 nDimensionIndex
, sal_Int32 nCooSysIndex
, bool bMainGrid
98 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
);
100 static void makeAxisVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
);
101 static void makeGridVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xGridProperties
);
103 static void makeAxisInvisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
);
104 static void makeGridInvisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xGridProperties
);
106 static void hideAxisIfNoDataIsAttached( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
107 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
);
109 SAL_DLLPRIVATE
static bool areAxisLabelsVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xAxisProperties
);
110 static bool isAxisVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
);
111 static bool isGridVisible( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xGridProperties
);
113 static ::com::sun::star::uno::Reference
<
114 ::com::sun::star::chart2::XCoordinateSystem
>
115 getCoordinateSystemByIndex(
116 const ::com::sun::star::uno::Reference
<
117 ::com::sun::star::chart2::XDiagram
>& xDiagram
118 , sal_Int32 nIndex
);
120 static ::com::sun::star::uno::Reference
<
121 ::com::sun::star::chart2::XCoordinateSystem
>
122 getCoordinateSystemOfAxis(
123 const ::com::sun::star::uno::Reference
<
124 ::com::sun::star::chart2::XAxis
>& xAxis
125 , const ::com::sun::star::uno::Reference
<
126 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
128 static ::com::sun::star::uno::Reference
<
129 ::com::sun::star::chart2::XAxis
>
130 getAxis( sal_Int32 nDimensionIndex
, bool bMainAxis
131 , const ::com::sun::star::uno::Reference
<
132 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
133 static ::com::sun::star::uno::Reference
<
134 ::com::sun::star::chart2::XAxis
>
135 getAxis( sal_Int32 nDimensionIndex
, sal_Int32 nAxisIndex
136 , const ::com::sun::star::uno::Reference
<
137 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
);
139 static ::com::sun::star::uno::Reference
<
140 ::com::sun::star::chart2::XAxis
>
141 getCrossingMainAxis( const ::com::sun::star::uno::Reference
<
142 ::com::sun::star::chart2::XAxis
>& xAxis
143 , const ::com::sun::star::uno::Reference
<
144 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
);
146 static ::com::sun::star::uno::Reference
<
147 ::com::sun::star::chart2::XAxis
>
148 getParallelAxis( const ::com::sun::star::uno::Reference
<
149 ::com::sun::star::chart2::XAxis
>& xAxis
150 , const ::com::sun::star::uno::Reference
<
151 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
153 static ::com::sun::star::uno::Reference
<
154 ::com::sun::star::beans::XPropertySet
>
155 getGridProperties( const ::com::sun::star::uno::Reference
<
156 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
157 , sal_Int32 nDimensionIndex
158 , sal_Int32 nAxisIndex
//0: Primary axies, 1: secondary axis
159 , sal_Int32 nSubGridIndex
= -1 //-1: Main Grid; 0: First SubGrid etc
162 static sal_Int32
getDimensionIndexOfAxis(
163 const ::com::sun::star::uno::Reference
<
164 ::com::sun::star::chart2::XAxis
>& xAxis
165 , const ::com::sun::star::uno::Reference
<
166 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
168 static bool getIndicesForAxis(
169 const ::com::sun::star::uno::Reference
<
170 ::com::sun::star::chart2::XAxis
>& xAxis
171 , const ::com::sun::star::uno::Reference
<
172 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
173 , sal_Int32
& rOutDimensionIndex
, sal_Int32
& rOutAxisIndex
);
175 static bool getIndicesForAxis(
176 const ::com::sun::star::uno::Reference
<
177 ::com::sun::star::chart2::XAxis
>& xAxis
178 , const ::com::sun::star::uno::Reference
<
179 ::com::sun::star::chart2::XDiagram
>& xDiagram
180 , sal_Int32
& rOutCooSysIndex
, sal_Int32
& rOutDimensionIndex
, sal_Int32
& rOutAxisIndex
);
182 /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
183 </sal_True> are returned
185 static ::com::sun::star::uno::Sequence
<
186 ::com::sun::star::uno::Reference
<
187 ::com::sun::star::chart2::XAxis
> >
188 getAllAxesOfDiagram( const ::com::sun::star::uno::Reference
<
189 ::com::sun::star::chart2::XDiagram
>& xDiagram
190 , bool bOnlyVisible
= false );
192 /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
193 </sal_True> are returned
195 SAL_DLLPRIVATE
static std::vector
<
196 ::com::sun::star::uno::Reference
<
197 ::com::sun::star::chart2::XAxis
> >
198 getAllAxesOfCoordinateSystem( const ::com::sun::star::uno::Reference
<
199 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
200 , bool bOnlyVisible
= false );
202 static ::com::sun::star::uno::Sequence
<
203 ::com::sun::star::uno::Reference
<
204 ::com::sun::star::beans::XPropertySet
> >
205 getAllGrids( const ::com::sun::star::uno::Reference
<
206 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
208 static void getAxisOrGridPossibilities( ::com::sun::star::uno::Sequence
< sal_Bool
>& rPossibilityList
209 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
, bool bAxis
=true );
211 static void getAxisOrGridExcistence( ::com::sun::star::uno::Sequence
< sal_Bool
>& rExcistenceList
212 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
, bool bAxis
=true );
214 static bool changeVisibilityOfGrids( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
215 , const ::com::sun::star::uno::Sequence
< sal_Bool
>& rOldExistenceList
216 , const ::com::sun::star::uno::Sequence
< sal_Bool
>& rNewExistenceList
217 , const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
);
219 static bool changeVisibilityOfAxes( 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 , ReferenceSizeProvider
* pRefSizeProvider
= 0 );
225 static bool shouldAxisBeDisplayed( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
>& xAxis
226 , const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
);
227 static bool isSecondaryYAxisNeeded( const ::com::sun::star::uno::Reference
<
228 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
);
230 static ::com::sun::star::uno::Reference
<
231 ::com::sun::star::chart2::XChartType
>
232 getChartTypeByIndex( const ::com::sun::star::uno::Reference
<
233 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
, sal_Int32 nIndex
);
235 static void setRTLAxisLayout( const ::com::sun::star::uno::Reference
<
236 ::com::sun::star::chart2::XCoordinateSystem
>& xCooSys
);
238 static ::com::sun::star::uno::Reference
<
239 ::com::sun::star::chart2::XChartType
>
240 getFirstChartTypeWithSeriesAttachedToAxisIndex( const ::com::sun::star::uno::Reference
<
241 ::com::sun::star::chart2::XDiagram
>& xDiagram
, const sal_Int32 nAttachedAxisIndex
);
243 static bool isAxisPositioningEnabled();
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */