Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/view/axes/VAxisProperties.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
#pragma once
20
21
#include "TickmarkProperties.hxx"
22
#include <Axis.hxx>
23
#include <LabelAlignment.hxx>
24
#include <DataTable.hxx>
25
26
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
27
#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
28
#include <com/sun/star/chart/ChartAxisPosition.hpp>
29
#include <com/sun/star/awt/Rectangle.hpp>
30
#include <com/sun/star/awt/Size.hpp>
31
#include <rtl/ref.hxx>
32
33
#include <vector>
34
#include <optional>
35
36
namespace chart { class ExplicitCategoriesProvider; }
37
namespace com::sun::star::beans { class XPropertySet; }
38
namespace com::sun::star::chart2::data { class XTextualDataSequence; }
39
40
namespace chart
41
{
42
43
//These properties describe how a couple of labels are arranged one to another.
44
//The couple can contain all labels for all tickmark depth or just the labels for one single depth or
45
//the labels from a coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together).
46
//... only allow side by side for different tick depth
47
enum class AxisLabelStaggering
48
{
49
      SideBySide
50
    , StaggerEven
51
    , StaggerOdd
52
    , StaggerAuto
53
};
54
55
struct AxisLabelProperties final
56
{
57
    AxisLabelProperties();
58
59
    css::awt::Size         m_aFontReferenceSize;//reference size to calculate the font height
60
    css::awt::Rectangle    m_aMaximumSpaceForLabels;//Labels need to be clipped in order to fit into this rectangle
61
62
    sal_Int32            m_nNumberFormatKey;
63
64
    AxisLabelStaggering  m_eStaggering;
65
66
    bool                 m_bLineBreakAllowed;
67
    bool                 m_bOverlapAllowed;
68
69
    bool                 m_bStackCharacters;
70
    double               m_fRotationAngleDegree;
71
72
    sal_Int32   m_nRhythm; //show only each nth label with n==nRhythm
73
74
    //methods:
75
    void init( const rtl::Reference< ::chart::Axis >&  xAxisModel );
76
77
    bool isStaggered() const;
78
79
    void autoRotate45();
80
};
81
82
struct AxisLabelAlignment
83
{
84
    double mfLabelDirection; /// which direction the labels are to be drawn.
85
    double mfInnerTickDirection; /// which direction the inner tickmarks are to be drawn.
86
87
    LabelAlignment meAlignment;
88
89
    AxisLabelAlignment();
90
};
91
92
struct AxisProperties final
93
{
94
    rtl::Reference<::chart::Axis> m_xAxisModel;
95
96
    sal_Int32   m_nDimensionIndex;
97
    bool        m_bIsMainAxis;//not secondary axis
98
    bool        m_bSwapXAndY;
99
100
    css::chart::ChartAxisPosition      m_eCrossoverType;
101
    css::chart::ChartAxisLabelPosition m_eLabelPos;
102
    css::chart::ChartAxisMarkPosition  m_eTickmarkPos;
103
104
    std::optional<double> m_pfMainLinePositionAtOtherAxis;
105
    std::optional<double> m_pfExrtaLinePositionAtOtherAxis;
106
107
    bool        m_bCrossingAxisHasReverseDirection;
108
    bool        m_bCrossingAxisIsCategoryAxes;
109
110
    AxisLabelAlignment maLabelAlignment;
111
112
    // Data table
113
    bool m_bDisplayDataTable;
114
    bool m_bDataTableAlignAxisValuesWithColumns;
115
116
    bool m_bDisplayLabels;
117
118
    // Compatibility option: starting from LibreOffice 5.1 the rotated
119
    // layout is preferred to staggering for axis labels.
120
    // So the default value of this flag for new documents is `false`.
121
    bool            m_bTryStaggeringFirst;
122
123
    sal_Int32       m_nNumberFormatKey;
124
125
    /*
126
    0: no tickmarks         1: inner tickmarks
127
    2: outer tickmarks      3: inner and outer tickmarks
128
    */
129
    sal_Int32                           m_nMajorTickmarks;
130
    sal_Int32                           m_nMinorTickmarks;
131
    std::vector<TickmarkProperties>   m_aTickmarkPropertiesList;
132
133
    VLineProperties                     m_aLineProperties;
134
135
    //for category axes ->
136
    sal_Int32                           m_nAxisType;//REALNUMBER, CATEGORY etc. type css::chart2::AxisType
137
    bool                                m_bComplexCategories;
138
    ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
139
    css::uno::Reference<css::chart2::data::XTextualDataSequence> m_xAxisTextProvider; //for categories or series names
140
    //<- category axes
141
142
    bool                                m_bLimitSpaceForLabels;
143
144
    rtl::Reference<::chart::DataTable> m_xDataTableModel;
145
146
    //methods:
147
148
    AxisProperties(rtl::Reference<::chart::Axis> xAxisModel,
149
                   ExplicitCategoriesProvider* pExplicitCategoriesProvider,
150
                   rtl::Reference<::chart::DataTable> const& xDataTableModel);
151
152
    void init(bool bCartesian=false);//init from model data (m_xAxisModel)
153
154
    void initAxisPositioning( const css::uno::Reference< css::beans::XPropertySet >& xAxisProp );
155
156
    static TickmarkProperties getBiggestTickmarkProperties();
157
    TickmarkProperties makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis ) const;
158
159
private:
160
    AxisProperties() = delete;
161
162
    TickmarkProperties  makeTickmarkProperties( sal_Int32 nDepth ) const;
163
    //@todo get this from somewhere; maybe for each subincrement
164
    //so far the model does not offer different settings for each tick depth
165
0
    const VLineProperties&  makeLinePropertiesForDepth() const { return m_aLineProperties; }
166
};
167
168
} //namespace chart
169
170
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */