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 .
21 #include "TickmarkProperties.hxx"
23 #include <LabelAlignment.hxx>
24 #include <DataTable.hxx>
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 <com/sun/star/uno/Any.hxx>
32 #include <rtl/ref.hxx>
37 namespace chart
{ class ExplicitCategoriesProvider
; }
38 namespace com::sun::star::beans
{ class XPropertySet
; }
39 namespace com::sun::star::chart2
{ class XAxis
; }
40 namespace com::sun::star::chart2::data
{ class XTextualDataSequence
; }
45 //These properties describe how a couple of labels are arranged one to another.
46 //The couple can contain all labels for all tickmark depth or just the labels for one single depth or
47 //the labels from a coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together).
48 //... only allow side by side for different tick depth
49 enum class AxisLabelStaggering
57 struct AxisLabelProperties final
59 AxisLabelProperties();
61 css::awt::Size m_aFontReferenceSize
;//reference size to calculate the font height
62 css::awt::Rectangle m_aMaximumSpaceForLabels
;//Labels need to be clipped in order to fit into this rectangle
64 sal_Int32 m_nNumberFormatKey
;
66 AxisLabelStaggering m_eStaggering
;
68 bool m_bLineBreakAllowed
;
69 bool m_bOverlapAllowed
;
71 bool m_bStackCharacters
;
72 double m_fRotationAngleDegree
;
74 sal_Int32 m_nRhythm
; //show only each nth label with n==nRhythm
77 void init( const rtl::Reference
< ::chart::Axis
>& xAxisModel
);
79 bool isStaggered() const;
84 struct AxisLabelAlignment
86 double mfLabelDirection
; /// which direction the labels are to be drawn.
87 double mfInnerTickDirection
; /// which direction the inner tickmarks are to be drawn.
89 LabelAlignment meAlignment
;
94 struct AxisProperties final
96 rtl::Reference
<::chart::Axis
> m_xAxisModel
;
98 sal_Int32 m_nDimensionIndex
;
99 bool m_bIsMainAxis
;//not secondary axis
102 css::chart::ChartAxisPosition m_eCrossoverType
;
103 css::chart::ChartAxisLabelPosition m_eLabelPos
;
104 css::chart::ChartAxisMarkPosition m_eTickmarkPos
;
106 std::optional
<double> m_pfMainLinePositionAtOtherAxis
;
107 std::optional
<double> m_pfExrtaLinePositionAtOtherAxis
;
109 bool m_bCrossingAxisHasReverseDirection
;
110 bool m_bCrossingAxisIsCategoryAxes
;
112 AxisLabelAlignment maLabelAlignment
;
115 bool m_bDisplayDataTable
;
116 bool m_bDataTableAlignAxisValuesWithColumns
;
118 bool m_bDisplayLabels
;
120 // Compatibility option: starting from LibreOffice 5.1 the rotated
121 // layout is preferred to staggering for axis labels.
122 // So the default value of this flag for new documents is `false`.
123 bool m_bTryStaggeringFirst
;
125 sal_Int32 m_nNumberFormatKey
;
128 0: no tickmarks 1: inner tickmarks
129 2: outer tickmarks 3: inner and outer tickmarks
131 sal_Int32 m_nMajorTickmarks
;
132 sal_Int32 m_nMinorTickmarks
;
133 std::vector
<TickmarkProperties
> m_aTickmarkPropertiesList
;
135 VLineProperties m_aLineProperties
;
137 //for category axes ->
138 sal_Int32 m_nAxisType
;//REALNUMBER, CATEGORY etc. type css::chart2::AxisType
139 bool m_bComplexCategories
;
140 ExplicitCategoriesProvider
* m_pExplicitCategoriesProvider
;/*no ownership here*/
141 css::uno::Reference
<css::chart2::data::XTextualDataSequence
> m_xAxisTextProvider
; //for categories or series names
144 bool m_bLimitSpaceForLabels
;
146 rtl::Reference
<::chart::DataTable
> m_xDataTableModel
;
150 AxisProperties(rtl::Reference
<::chart::Axis
> xAxisModel
,
151 ExplicitCategoriesProvider
* pExplicitCategoriesProvider
,
152 rtl::Reference
<::chart::DataTable
> const& xDataTableModel
);
154 void init(bool bCartesian
=false);//init from model data (m_xAxisModel)
156 void initAxisPositioning( const css::uno::Reference
< css::beans::XPropertySet
>& xAxisProp
);
158 static TickmarkProperties
getBiggestTickmarkProperties();
159 TickmarkProperties
makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength
, sal_Int32 nTickStartDistanceToAxis
) const;
162 AxisProperties() = delete;
164 TickmarkProperties
makeTickmarkProperties( sal_Int32 nDepth
) const;
165 //@todo get this from somewhere; maybe for each subincrement
166 //so far the model does not offer different settings for each tick depth
167 const VLineProperties
& makeLinePropertiesForDepth() const { return m_aLineProperties
; }
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */