summaryrefslogtreecommitdiffstats
path: root/chart2/source/inc/AxisHelper.hxx
blob: cd51d5adb3f6d0b2456d8013365a75736608b145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#pragma once

#include "charttoolsdllapi.hxx"
#include <com/sun/star/chart2/ScaleData.hpp>
#include <rtl/ref.hxx>

#include <vector>

namespace chart { class ChartModel; }
namespace chart { class ExplicitCategoriesProvider; }
namespace chart { class ReferenceSizeProvider; }
namespace com::sun::star::beans { class XPropertySet; }
namespace com::sun::star::chart2 { class XAxis; }
namespace com::sun::star::chart2 { class XChartDocument; }
namespace com::sun::star::chart2 { class XChartType; }
namespace com::sun::star::chart2 { class XCoordinateSystem; }
namespace com::sun::star::chart2 { class XDiagram; }
namespace com::sun::star::chart2 { class XScaling; }
namespace com::sun::star::uno { class XComponentContext; }

namespace chart
{
class Axis;
class BaseCoordinateSystem;
class ChartType;
class Diagram;

class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper
{
public:
    static css::uno::Reference< css::chart2::XScaling > createLinearScaling();
    static css::uno::Reference< css::chart2::XScaling > createLogarithmicScaling( double fBase = 10.0 );

    static css::chart2::ScaleData createDefaultScale();

    static void removeExplicitScaling( css::chart2::ScaleData& rScaleData );

    static bool isLogarithmic( const css::uno::Reference< css::chart2::XScaling >& xScaling );

    static void checkDateAxis( css::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis );
    static css::chart2::ScaleData getDateCheckedScale( const rtl::Reference< ::chart::Axis >& xAxis, ChartModel& rModel );

    static sal_Int32 getExplicitNumberFormatKeyForAxis(
                  const css::uno::Reference< css::chart2::XAxis >& xAxis
                , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCorrespondingCoordinateSystem
                , const rtl::Reference< ::chart::ChartModel>& xChartDoc
                , bool bSearchForParallelAxisIfNothingIsFound );
    static sal_Int32 getExplicitNumberFormatKeyForAxis(
                  const rtl::Reference< ::chart::Axis >& xAxis
                , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCorrespondingCoordinateSystem
                , const rtl::Reference< ::chart::ChartModel>& xChartDoc
                , bool bSearchForParallelAxisIfNothingIsFound );

    static rtl::Reference< ::chart::Axis >
        createAxis( sal_Int32 nDimensionIndex, bool bMainAxis
                , const rtl::Reference< ::chart::Diagram >& xDiagram
                , const css::uno::Reference< css::uno::XComponentContext >& xContext
                , ReferenceSizeProvider * pRefSizeProvider = nullptr );

    static rtl::Reference< ::chart::Axis >
        createAxis(
            sal_Int32 nDimensionIndex
            , sal_Int32 nAxisIndex // 0==main or 1==secondary axis
            , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
            , const css::uno::Reference< css::uno::XComponentContext > & xContext
            , ReferenceSizeProvider * pRefSizeProvider = nullptr );

    static void showAxis( sal_Int32 nDimensionIndex, bool bMainAxis
                , const rtl::Reference< ::chart::Diagram >& xDiagram
                , const css::uno::Reference< css::uno::XComponentContext >& xContext
                , ReferenceSizeProvider * pRefSizeProvider = nullptr );

    static void showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
                , const rtl::Reference< ::chart::Diagram >& xDiagram );

    static void hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis
                , const rtl::Reference< ::chart::Diagram >& xDiagram );
    static void hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
                , const rtl::Reference< ::chart::Diagram >& xDiagram );

    static bool isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis
                , const rtl::Reference< ::chart::Diagram >& xDiagram );
    static bool isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
                , const rtl::Reference< ::chart::Diagram >& xDiagram );

    static void makeAxisVisible( const rtl::Reference< ::chart::Axis >& xAxis );
    static void makeGridVisible( const css::uno::Reference< css::beans::XPropertySet >& xGridProperties );

    static void makeAxisInvisible( const rtl::Reference< ::chart::Axis >& xAxis );
    static void makeGridInvisible( const css::uno::Reference< css::beans::XPropertySet >& xGridProperties );

    static void hideAxisIfNoDataIsAttached( const rtl::Reference< ::chart::Axis >& xAxis
                                          , const rtl::Reference< ::chart::Diagram >& xDiagram);

    SAL_DLLPRIVATE static bool areAxisLabelsVisible( const css::uno::Reference< css::beans::XPropertySet >& xAxisProperties );
    static bool isAxisVisible( const css::uno::Reference< css::chart2::XAxis >& xAxis );
    static bool isGridVisible( const css::uno::Reference< css::beans::XPropertySet >& xGridProperties );

    static rtl::Reference< ::chart::BaseCoordinateSystem >
        getCoordinateSystemByIndex(
            const rtl::Reference< ::chart::Diagram >& xDiagram
            , sal_Int32 nIndex );

    static rtl::Reference< ::chart::BaseCoordinateSystem >
        getCoordinateSystemOfAxis(
              const css::uno::Reference< css::chart2::XAxis >& xAxis
            , const rtl::Reference< ::chart::Diagram >& xDiagram );
    static rtl::Reference< ::chart::BaseCoordinateSystem >
        getCoordinateSystemOfAxis(
              const rtl::Reference< ::chart::Axis >& xAxis
            , const rtl::Reference< ::chart::Diagram >& xDiagram );

    static rtl::Reference< ::chart::Axis >
        getAxis( sal_Int32 nDimensionIndex, bool bMainAxis
                , const rtl::Reference< ::chart::Diagram >& xDiagram );
    static rtl::Reference< ::chart::Axis >
        getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
            , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );

    static rtl::Reference< ::chart::Axis >
        getCrossingMainAxis( const css::uno::Reference< css::chart2::XAxis >& xAxis
            , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );
    static rtl::Reference< ::chart::Axis >
        getCrossingMainAxis( const rtl::Reference< ::chart::Axis >& xAxis
            , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );

    static rtl::Reference< ::chart::Axis >
        getParallelAxis( const css::uno::Reference< css::chart2::XAxis >& xAxis
            , const rtl::Reference< ::chart::Diagram >& xDiagram );

    static css::uno::Reference< css::beans::XPropertySet >
        getGridProperties( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
                , sal_Int32 nDimensionIndex
                , sal_Int32 nAxisIndex //0: Primary axis, 1: secondary axis
                , sal_Int32 nSubGridIndex //-1: Main Grid; 0: First SubGrid etc
                );

    static sal_Int32 getDimensionIndexOfAxis(
              const rtl::Reference< ::chart::Axis >& xAxis
            , const rtl::Reference< ::chart::Diagram >& xDiagram );

    static bool getIndicesForAxis(
              const css::uno::Reference< css::chart2::XAxis >& xAxis
            , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
            , sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
    static bool getIndicesForAxis(
              const rtl::Reference< ::chart::Axis >& xAxis
            , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
            , sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );

    static bool getIndicesForAxis(
              const css::uno::Reference< css::chart2::XAxis >& xAxis
            , const rtl::Reference< ::chart::Diagram >& xDiagram
            , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );
    static bool getIndicesForAxis(
              const rtl::Reference< ::chart::Axis >& xAxis
            , const rtl::Reference< ::chart::Diagram >& xDiagram
            , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex );

    /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
               </sal_True> are returned
     */
    static std::vector< rtl::Reference< ::chart::Axis > >
            getAllAxesOfDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram
            , bool bOnlyVisible = false );

    /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to
               </sal_True> are returned
     */
    SAL_DLLPRIVATE static std::vector< rtl::Reference< ::chart::Axis > >
            getAllAxesOfCoordinateSystem( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
            , bool bOnlyVisible = false );

    static css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > >
            getAllGrids( const rtl::Reference< ::chart::Diagram >& xDiagram );

    static void getAxisOrGridPossibilities( css::uno::Sequence< sal_Bool >& rPossibilityList
        , const rtl::Reference< ::chart::Diagram>& xDiagram, bool bAxis=true );

    static void getAxisOrGridExistence( css::uno::Sequence< sal_Bool >& rExistenceList
        , const rtl::Reference< ::chart::Diagram>& xDiagram, bool bAxis=true );

    static bool changeVisibilityOfGrids( const rtl::Reference< ::chart::Diagram>& xDiagram
                        , const css::uno::Sequence< sal_Bool >& rOldExistenceList
                        , const css::uno::Sequence< sal_Bool >& rNewExistenceList );

    static bool changeVisibilityOfAxes( const rtl::Reference< ::chart::Diagram>& xDiagram
                        , const css::uno::Sequence< sal_Bool >& rOldExistenceList
                        , const css::uno::Sequence< sal_Bool >& rNewExistenceList
                        , const css::uno::Reference< css::uno::XComponentContext >& xContext
                        , ReferenceSizeProvider * pRefSizeProvider );

    static bool shouldAxisBeDisplayed( const rtl::Reference< ::chart::Axis >& xAxis
                                       , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );
    static bool isSecondaryYAxisNeeded( const rtl::Reference<
                    ::chart::BaseCoordinateSystem >& xCooSys );

    static rtl::Reference< ::chart::ChartType >
        getChartTypeByIndex( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys,
                             sal_Int32 nIndex );

    static void setRTLAxisLayout( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys );

    static rtl::Reference< ::chart::ChartType >
        getFirstChartTypeWithSeriesAttachedToAxisIndex( const rtl::Reference< ::chart::Diagram >& xDiagram, const sal_Int32 nAttachedAxisIndex );

    static bool isAxisPositioningEnabled();
};

} //namespace chart

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */