1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _CHART2_VAXIS_PROPERTIES_HXX
28 #define _CHART2_VAXIS_PROPERTIES_HXX
29 
30 #include "TickmarkProperties.hxx"
31 #include "PlottingPositionHelper.hxx"
32 #include "LabelAlignment.hxx"
33 #include "ExplicitCategoriesProvider.hxx"
34 
35 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
36 #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
37 #include <com/sun/star/chart/ChartAxisPosition.hpp>
38 #include <com/sun/star/chart2/XAxis.hpp>
39 #include <com/sun/star/chart2/AxisType.hpp>
40 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
41 #include <com/sun/star/awt/Rectangle.hpp>
42 #include <com/sun/star/awt/Size.hpp>
43 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
44 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
45 #include <com/sun/star/lang/Locale.hpp>
46 
47 #include <vector>
48 
49 //.............................................................................
50 namespace chart
51 {
52 //.............................................................................
53 
54 //-----------------------------------------------------------------------------
55 /**
56 */
57 
58 //These properties describe how a couple of labels are arranged one to another.
59 //The couple can contain all labels for all tickmark depth or just the labels for one single depth or
60 //the labels from an coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together).
61 //... only allow side by side for different tick depth
62 enum AxisLabelStaggering
63 {
64       SIDE_BY_SIDE
65     , STAGGER_EVEN
66     , STAGGER_ODD
67     , STAGGER_AUTO
68 };
69 
70 struct AxisLabelProperties
71 {
72     AxisLabelProperties();
73 
74     ::com::sun::star::awt::Size         m_aFontReferenceSize;//reference size to calculate the font height
75     ::com::sun::star::awt::Rectangle    m_aMaximumSpaceForLabels;//Labels need to be clipped in order to fit into this rectangle
76 
77     sal_Int32            nNumberFormatKey;
78 
79     AxisLabelStaggering  eStaggering;
80 
81     sal_Bool             bLineBreakAllowed;
82     sal_Bool             bOverlapAllowed;
83 
84     sal_Bool             bStackCharacters;
85     double               fRotationAngleDegree;
86 
87     sal_Int32   nRhythm; //show only each nth label with n==nRhythm
88     bool        bRhythmIsFix; //states wether the given rhythm is fix or may be changed
89 
90     //methods:
91     void init( const ::com::sun::star::uno::Reference<
92                 ::com::sun::star::chart2::XAxis >&  xAxisModel );
93 
94     sal_Bool            getIsStaggered() const;
95 };
96 
97 struct AxisProperties
98 {
99     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > m_xAxisModel;
100 
101     sal_Int32   m_nDimensionIndex;
102     bool        m_bIsMainAxis;//not secondary axis
103     bool        m_bSwapXAndY;
104 
105     ::com::sun::star::chart::ChartAxisPosition      m_eCrossoverType;
106     ::com::sun::star::chart::ChartAxisLabelPosition m_eLabelPos;
107     ::com::sun::star::chart::ChartAxisMarkPosition  m_eTickmarkPos;
108 
109     double*     m_pfMainLinePositionAtOtherAxis;
110     double*     m_pfExrtaLinePositionAtOtherAxis;
111 
112     bool        m_bCrossingAxisHasReverseDirection;
113     bool        m_bCrossingAxisIsCategoryAxes;
114 
115     //this direction is used to indicate in which direction the labels are to be drawn
116     double          m_fLabelDirectionSign;
117     //this direction is used to indicate in which direction inner tickmarks are to be drawn
118     double          m_fInnerDirectionSign;
119     LabelAlignment  m_aLabelAlignment;
120     sal_Bool        m_bDisplayLabels;
121 
122     sal_Int32       m_nNumberFormatKey;
123 
124     /*
125     0: no tickmarks         1: inner tickmarks
126     2: outer tickmarks      3: inner and outer tickmarks
127     */
128     sal_Int32                           m_nMajorTickmarks;
129     sal_Int32                           m_nMinorTickmarks;
130     ::std::vector<TickmarkProperties>   m_aTickmarkPropertiesList;
131 
132     VLineProperties                     m_aLineProperties;
133 
134     //for category axes ->
135     sal_Int32                           m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
136     bool                                m_bComplexCategories;
137     ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
138     ::com::sun::star::uno::Reference<
139         ::com::sun::star::chart2::data::XTextualDataSequence >
140                                                     m_xAxisTextProvider; //for categries or series names
141     //<- category axes
142 
143     //methods:
144 
145     AxisProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxisModel
146                   , ExplicitCategoriesProvider* pExplicitCategoriesProvider );
147     AxisProperties( const AxisProperties& rAxisProperties );
148     virtual ~AxisProperties();
149     virtual void init(bool bCartesian=false);//init from model data (m_xAxisModel)
150 
151     void initAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProp );
152 
153     static TickmarkProperties getBiggestTickmarkProperties();
154     TickmarkProperties makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 nTextLevel ) const;
155 
156 private:
157     AxisProperties();
158 
159 protected:
160     virtual TickmarkProperties  makeTickmarkProperties( sal_Int32 nDepth ) const;
161     VLineProperties      makeLinePropertiesForDepth( sal_Int32 nDepth ) const;
162 };
163 
164 //.............................................................................
165 } //namespace chart
166 //.............................................................................
167 #endif
168