1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CHART2_VAXIS_PROPERTIES_HXX
24 #define _CHART2_VAXIS_PROPERTIES_HXX
25 
26 #include "TickmarkProperties.hxx"
27 #include "PlottingPositionHelper.hxx"
28 #include "LabelAlignment.hxx"
29 #include "ExplicitCategoriesProvider.hxx"
30 
31 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
32 #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
33 #include <com/sun/star/chart/ChartAxisPosition.hpp>
34 #include <com/sun/star/chart2/XAxis.hpp>
35 #include <com/sun/star/chart2/AxisType.hpp>
36 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
37 #include <com/sun/star/awt/Rectangle.hpp>
38 #include <com/sun/star/awt/Size.hpp>
39 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
40 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
41 #include <com/sun/star/lang/Locale.hpp>
42 
43 #include <vector>
44 
45 //.............................................................................
46 namespace chart
47 {
48 //.............................................................................
49 
50 //-----------------------------------------------------------------------------
51 /**
52 */
53 
54 //These properties describe how a couple of labels are arranged one to another.
55 //The couple can contain all labels for all tickmark depth or just the labels for one single depth or
56 //the labels from an coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together).
57 //... only allow side by side for different tick depth
58 enum AxisLabelStaggering
59 {
60       SIDE_BY_SIDE
61     , STAGGER_EVEN
62     , STAGGER_ODD
63     , STAGGER_AUTO
64 };
65 
66 struct AxisLabelProperties
67 {
68     AxisLabelProperties();
69 
70     ::com::sun::star::awt::Size         m_aFontReferenceSize;//reference size to calculate the font height
71     ::com::sun::star::awt::Rectangle    m_aMaximumSpaceForLabels;//Labels need to be clipped in order to fit into this rectangle
72 
73     sal_Int32            nNumberFormatKey;
74 
75     AxisLabelStaggering  eStaggering;
76 
77     sal_Bool             bLineBreakAllowed;
78     sal_Bool             bOverlapAllowed;
79 
80     sal_Bool             bStackCharacters;
81     double               fRotationAngleDegree;
82 
83     sal_Int32   nRhythm; //show only each nth label with n==nRhythm
84     bool        bRhythmIsFix; //states wether the given rhythm is fix or may be changed
85 
86     //methods:
87     void init( const ::com::sun::star::uno::Reference<
88                 ::com::sun::star::chart2::XAxis >&  xAxisModel );
89 
90     sal_Bool            getIsStaggered() const;
91 };
92 
93 struct AxisProperties
94 {
95     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > m_xAxisModel;
96 
97     sal_Int32   m_nDimensionIndex;
98     bool        m_bIsMainAxis;//not secondary axis
99     bool        m_bSwapXAndY;
100 
101     ::com::sun::star::chart::ChartAxisPosition      m_eCrossoverType;
102     ::com::sun::star::chart::ChartAxisLabelPosition m_eLabelPos;
103     ::com::sun::star::chart::ChartAxisMarkPosition  m_eTickmarkPos;
104 
105     double*     m_pfMainLinePositionAtOtherAxis;
106     double*     m_pfExrtaLinePositionAtOtherAxis;
107 
108     bool        m_bCrossingAxisHasReverseDirection;
109     bool        m_bCrossingAxisIsCategoryAxes;
110 
111     //this direction is used to indicate in which direction the labels are to be drawn
112     double          m_fLabelDirectionSign;
113     //this direction is used to indicate in which direction inner tickmarks are to be drawn
114     double          m_fInnerDirectionSign;
115     LabelAlignment  m_aLabelAlignment;
116     sal_Bool        m_bDisplayLabels;
117 
118     sal_Int32       m_nNumberFormatKey;
119 
120     /*
121     0: no tickmarks         1: inner tickmarks
122     2: outer tickmarks      3: inner and outer tickmarks
123     */
124     sal_Int32                           m_nMajorTickmarks;
125     sal_Int32                           m_nMinorTickmarks;
126     ::std::vector<TickmarkProperties>   m_aTickmarkPropertiesList;
127 
128     VLineProperties                     m_aLineProperties;
129 
130     //for category axes ->
131     sal_Int32                           m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
132     bool                                m_bComplexCategories;
133     ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
134     ::com::sun::star::uno::Reference<
135         ::com::sun::star::chart2::data::XTextualDataSequence >
136                                                     m_xAxisTextProvider; //for categries or series names
137     //<- category axes
138 
139     //methods:
140 
141     AxisProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxisModel
142                   , ExplicitCategoriesProvider* pExplicitCategoriesProvider );
143     AxisProperties( const AxisProperties& rAxisProperties );
144     virtual ~AxisProperties();
145     virtual void init(bool bCartesian=false);//init from model data (m_xAxisModel)
146 
147     void initAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProp );
148 
149     static TickmarkProperties getBiggestTickmarkProperties();
150     TickmarkProperties makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 nTextLevel ) const;
151 
152 private:
153     AxisProperties();
154 
155 protected:
156     virtual TickmarkProperties  makeTickmarkProperties( sal_Int32 nDepth ) const;
157     VLineProperties      makeLinePropertiesForDepth( sal_Int32 nDepth ) const;
158 };
159 
160 //.............................................................................
161 } //namespace chart
162 //.............................................................................
163 #endif
164