Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / AxisHelper.hxx
blob5b9de9d9a1b0304fc5badb961736800e781eb4eb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
21 #include "charttoolsdllapi.hxx"
22 #include <com/sun/star/chart2/ScaleData.hpp>
23 #include <rtl/ref.hxx>
25 #include <vector>
27 namespace chart { class ChartModel; }
28 namespace chart { class ExplicitCategoriesProvider; }
29 namespace chart { class ReferenceSizeProvider; }
30 namespace com::sun::star::beans { class XPropertySet; }
31 namespace com::sun::star::chart2 { class XAxis; }
32 namespace com::sun::star::chart2 { class XChartDocument; }
33 namespace com::sun::star::chart2 { class XChartType; }
34 namespace com::sun::star::chart2 { class XCoordinateSystem; }
35 namespace com::sun::star::chart2 { class XDiagram; }
36 namespace com::sun::star::chart2 { class XScaling; }
37 namespace com::sun::star::uno { class XComponentContext; }
39 namespace chart
41 class Axis;
42 class BaseCoordinateSystem;
43 class ChartType;
44 class Diagram;
45 class GridProperties;
47 class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper
49 public:
50 static css::uno::Reference< css::chart2::XScaling > createLinearScaling();
51 static css::uno::Reference< css::chart2::XScaling > createLogarithmicScaling( double fBase = 10.0 );
53 static css::chart2::ScaleData createDefaultScale();
55 static void removeExplicitScaling( css::chart2::ScaleData& rScaleData );
57 static bool isLogarithmic( const css::uno::Reference< css::chart2::XScaling >& xScaling );
59 static void checkDateAxis( css::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis );
60 static css::chart2::ScaleData getDateCheckedScale( const rtl::Reference< ::chart::Axis >& xAxis, ChartModel& rModel );
62 static sal_Int32 getExplicitNumberFormatKeyForAxis(
63 const rtl::Reference< ::chart::Axis >& xAxis
64 , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCorrespondingCoordinateSystem
65 , const rtl::Reference< ::chart::ChartModel>& xChartDoc
66 , bool bSearchForParallelAxisIfNothingIsFound );
68 static rtl::Reference< ::chart::Axis >
69 createAxis( sal_Int32 nDimensionIndex, bool bMainAxis
70 , const rtl::Reference< ::chart::Diagram >& xDiagram
71 , const css::uno::Reference< css::uno::XComponentContext >& xContext
72 , ReferenceSizeProvider * pRefSizeProvider = nullptr );
74 static rtl::Reference< ::chart::Axis >
75 createAxis(
76 sal_Int32 nDimensionIndex
77 , sal_Int32 nAxisIndex // 0==main or 1==secondary axis
78 , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
79 , const css::uno::Reference< css::uno::XComponentContext > & xContext
80 , ReferenceSizeProvider * pRefSizeProvider = nullptr );
82 static void showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
83 , const rtl::Reference< ::chart::Diagram >& xDiagram
84 , const css::uno::Reference< css::uno::XComponentContext >& xContext
85 , ReferenceSizeProvider * pRefSizeProvider = nullptr );
87 static void showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
88 , const rtl::Reference< ::chart::Diagram >& xDiagram );
90 static void hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis
91 , const rtl::Reference< ::chart::Diagram >& xDiagram );
92 static void hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
93 , const rtl::Reference< ::chart::Diagram >& xDiagram );
95 static bool isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis
96 , const rtl::Reference< ::chart::Diagram >& xDiagram );
97 static bool isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
98 , const rtl::Reference< ::chart::Diagram >& xDiagram );
100 static void makeAxisVisible( const rtl::Reference< ::chart::Axis >& xAxis );
101 static void makeGridVisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties );
103 static void makeAxisInvisible( const rtl::Reference< ::chart::Axis >& xAxis );
104 static void makeGridInvisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties );
106 static void hideAxisIfNoDataIsAttached( const rtl::Reference< ::chart::Axis >& xAxis
107 , const rtl::Reference< ::chart::Diagram >& xDiagram);
109 SAL_DLLPRIVATE static bool areAxisLabelsVisible( const rtl::Reference< ::chart::Axis >& xAxisProperties );
110 static bool isAxisVisible( const rtl::Reference< ::chart::Axis >& xAxis );
111 static bool isGridVisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties );
113 static rtl::Reference< ::chart::BaseCoordinateSystem >
114 getCoordinateSystemByIndex(
115 const rtl::Reference< ::chart::Diagram >& xDiagram
116 , sal_Int32 nIndex );
118 static rtl::Reference< ::chart::BaseCoordinateSystem >
119 getCoordinateSystemOfAxis(
120 const rtl::Reference< ::chart::Axis >& xAxis
121 , const rtl::Reference< ::chart::Diagram >& xDiagram );
123 static rtl::Reference< ::chart::Axis >
124 getAxis( sal_Int32 nDimensionIndex, bool bMainAxis
125 , const rtl::Reference< ::chart::Diagram >& xDiagram );
126 static rtl::Reference< ::chart::Axis >
127 getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
128 , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );
130 static rtl::Reference< ::chart::Axis >
131 getCrossingMainAxis( const rtl::Reference< ::chart::Axis >& xAxis
132 , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );
134 static rtl::Reference< ::chart::Axis >
135 getParallelAxis( const rtl::Reference< ::chart::Axis >& xAxis
136 , const rtl::Reference< ::chart::Diagram >& xDiagram );
138 static rtl::Reference< ::chart::GridProperties >
139 getGridProperties( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
140 , sal_Int32 nDimensionIndex
141 , sal_Int32 nAxisIndex //0: Primary axis, 1: secondary axis
142 , sal_Int32 nSubGridIndex //-1: Main Grid; 0: First SubGrid etc
145 static sal_Int32 getDimensionIndexOfAxis(
146 const rtl::Reference< ::chart::Axis >& xAxis
147 , const rtl::Reference< ::chart::Diagram >& xDiagram );
149 static bool getIndicesForAxis(
150 const rtl::Reference< ::chart::Axis >& xAxis
151 , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
152 , sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
154 static bool getIndicesForAxis(
155 const rtl::Reference< ::chart::Axis >& xAxis
156 , const rtl::Reference< ::chart::Diagram >& xDiagram
157 , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
159 /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
160 </sal_True> are returned
162 static std::vector< rtl::Reference< ::chart::Axis > >
163 getAllAxesOfDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram
164 , bool bOnlyVisible = false );
166 /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
167 </sal_True> are returned
169 SAL_DLLPRIVATE static std::vector< rtl::Reference< ::chart::Axis > >
170 getAllAxesOfCoordinateSystem( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
171 , bool bOnlyVisible = false );
173 static std::vector< rtl::Reference< ::chart::GridProperties > >
174 getAllGrids( const rtl::Reference< ::chart::Diagram >& xDiagram );
176 static void getAxisOrGridPossibilities( css::uno::Sequence< sal_Bool >& rPossibilityList
177 , const rtl::Reference< ::chart::Diagram>& xDiagram, bool bAxis=true );
179 static void getAxisOrGridExistence( css::uno::Sequence< sal_Bool >& rExistenceList
180 , const rtl::Reference< ::chart::Diagram>& xDiagram, bool bAxis=true );
182 static bool changeVisibilityOfGrids( const rtl::Reference< ::chart::Diagram>& xDiagram
183 , const css::uno::Sequence< sal_Bool >& rOldExistenceList
184 , const css::uno::Sequence< sal_Bool >& rNewExistenceList );
186 static bool changeVisibilityOfAxes( const rtl::Reference< ::chart::Diagram>& xDiagram
187 , const css::uno::Sequence< sal_Bool >& rOldExistenceList
188 , const css::uno::Sequence< sal_Bool >& rNewExistenceList
189 , const css::uno::Reference< css::uno::XComponentContext >& xContext
190 , ReferenceSizeProvider * pRefSizeProvider );
192 static bool shouldAxisBeDisplayed( const rtl::Reference< ::chart::Axis >& xAxis
193 , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );
194 static bool isSecondaryYAxisNeeded( const rtl::Reference<
195 ::chart::BaseCoordinateSystem >& xCooSys );
197 static rtl::Reference< ::chart::ChartType >
198 getChartTypeByIndex( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys,
199 sal_Int32 nIndex );
201 static void setRTLAxisLayout( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );
203 static rtl::Reference< ::chart::ChartType >
204 getFirstChartTypeWithSeriesAttachedToAxisIndex( const rtl::Reference< ::chart::Diagram >& xDiagram, const sal_Int32 nAttachedAxisIndex );
206 static bool isAxisPositioningEnabled();
209 } //namespace chart
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */