Line data Source code
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 : #ifndef INCLUDED_CHART2_SOURCE_VIEW_AXES_VAXISPROPERTIES_HXX
20 : #define INCLUDED_CHART2_SOURCE_VIEW_AXES_VAXISPROPERTIES_HXX
21 :
22 : #include "TickmarkProperties.hxx"
23 : #include "PlottingPositionHelper.hxx"
24 : #include "LabelAlignment.hxx"
25 : #include "ExplicitCategoriesProvider.hxx"
26 :
27 : #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
28 : #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
29 : #include <com/sun/star/chart/ChartAxisPosition.hpp>
30 : #include <com/sun/star/chart2/XAxis.hpp>
31 : #include <com/sun/star/chart2/AxisType.hpp>
32 : #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
33 : #include <com/sun/star/awt/Rectangle.hpp>
34 : #include <com/sun/star/awt/Size.hpp>
35 : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
36 : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
37 : #include <com/sun/star/lang/Locale.hpp>
38 :
39 : #include <vector>
40 : #include <boost/optional.hpp>
41 :
42 : namespace chart
43 : {
44 :
45 : /**
46 : */
47 :
48 : //These properties describe how a couple of labels are arranged one to another.
49 : //The couple can contain all labels for all tickmark depth or just the labels for one single depth or
50 : //the labels from an coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together).
51 : //... only allow side by side for different tick depth
52 : enum AxisLabelStaggering
53 : {
54 : SIDE_BY_SIDE
55 : , STAGGER_EVEN
56 : , STAGGER_ODD
57 : , STAGGER_AUTO
58 : };
59 :
60 : struct AxisLabelProperties SAL_FINAL
61 : {
62 : AxisLabelProperties();
63 :
64 : ::com::sun::star::awt::Size m_aFontReferenceSize;//reference size to calculate the font height
65 : ::com::sun::star::awt::Rectangle m_aMaximumSpaceForLabels;//Labels need to be clipped in order to fit into this rectangle
66 :
67 : sal_Int32 nNumberFormatKey;
68 :
69 : AxisLabelStaggering eStaggering;
70 :
71 : bool bLineBreakAllowed;
72 : bool bOverlapAllowed;
73 :
74 : bool bStackCharacters;
75 : double fRotationAngleDegree;
76 :
77 : sal_Int32 nRhythm; //show only each nth label with n==nRhythm
78 : bool bRhythmIsFix; //states whether the given rhythm is fix or may be changed
79 :
80 : //methods:
81 : void init( const ::com::sun::star::uno::Reference<
82 : ::com::sun::star::chart2::XAxis >& xAxisModel );
83 :
84 : bool isStaggered() const;
85 :
86 : void autoRotate45();
87 : };
88 :
89 : struct AxisLabelAlignment
90 : {
91 : double mfLabelDirection; /// which direction the labels are to be drawn.
92 : double mfInnerTickDirection; /// which direction the inner tickmarks are to be drawn.
93 :
94 : LabelAlignment meAlignment;
95 :
96 : AxisLabelAlignment();
97 : };
98 :
99 4232 : struct AxisProperties SAL_FINAL
100 : {
101 : css::uno::Reference<css::chart2::XAxis> m_xAxisModel;
102 :
103 : sal_Int32 m_nDimensionIndex;
104 : bool m_bIsMainAxis;//not secondary axis
105 : bool m_bSwapXAndY;
106 :
107 : css::chart::ChartAxisPosition m_eCrossoverType;
108 : css::chart::ChartAxisLabelPosition m_eLabelPos;
109 : css::chart::ChartAxisMarkPosition m_eTickmarkPos;
110 :
111 : boost::optional<double> m_pfMainLinePositionAtOtherAxis;
112 : boost::optional<double> m_pfExrtaLinePositionAtOtherAxis;
113 :
114 : bool m_bCrossingAxisHasReverseDirection;
115 : bool m_bCrossingAxisIsCategoryAxes;
116 :
117 : AxisLabelAlignment maLabelAlignment;
118 :
119 : bool m_bDisplayLabels;
120 :
121 : sal_Int32 m_nNumberFormatKey;
122 :
123 : /*
124 : 0: no tickmarks 1: inner tickmarks
125 : 2: outer tickmarks 3: inner and outer tickmarks
126 : */
127 : sal_Int32 m_nMajorTickmarks;
128 : sal_Int32 m_nMinorTickmarks;
129 : ::std::vector<TickmarkProperties> m_aTickmarkPropertiesList;
130 :
131 : VLineProperties m_aLineProperties;
132 :
133 : //for category axes ->
134 : sal_Int32 m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
135 : bool m_bComplexCategories;
136 : ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
137 : css::uno::Reference<css::chart2::data::XTextualDataSequence> m_xAxisTextProvider; //for categories or series names
138 : //<- category axes
139 :
140 : //methods:
141 :
142 : AxisProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxisModel
143 : , ExplicitCategoriesProvider* pExplicitCategoriesProvider );
144 : AxisProperties( const AxisProperties& rAxisProperties );
145 :
146 : void init(bool bCartesian=false);//init from model data (m_xAxisModel)
147 :
148 : void initAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProp );
149 :
150 : static TickmarkProperties getBiggestTickmarkProperties();
151 : TickmarkProperties makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 nTextLevel ) const;
152 :
153 : private:
154 : AxisProperties();
155 :
156 : TickmarkProperties makeTickmarkProperties( sal_Int32 nDepth ) const;
157 : //@todo get this from somewhere; maybe for each subincrement
158 : //so far the model does not offer different settings for each tick depth
159 2222 : VLineProperties makeLinePropertiesForDepth( sal_Int32 /*nDepth*/ ) const { return m_aLineProperties; }
160 : };
161 :
162 : } //namespace chart
163 : #endif
164 :
165 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|