1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef CHART2_REFERENCESIZEPROVIDER_HXX
28*cdf0e10cSrcweir #define CHART2_REFERENCESIZEPROVIDER_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
33*cdf0e10cSrcweir #include "charttoolsdllapi.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir namespace com { namespace sun { namespace star {
36*cdf0e10cSrcweir namespace chart2 {
37*cdf0e10cSrcweir     class XTitle;
38*cdf0e10cSrcweir     class XTitled;
39*cdf0e10cSrcweir }
40*cdf0e10cSrcweir }}}
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir // ----------------------------------------
43*cdf0e10cSrcweir namespace chart
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir class OOO_DLLPUBLIC_CHARTTOOLS ReferenceSizeProvider
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir public:
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir     enum AutoResizeState
51*cdf0e10cSrcweir     {
52*cdf0e10cSrcweir         AUTO_RESIZE_YES,
53*cdf0e10cSrcweir         AUTO_RESIZE_NO,
54*cdf0e10cSrcweir         AUTO_RESIZE_AMBIGUOUS,
55*cdf0e10cSrcweir         AUTO_RESIZE_UNKNOWN
56*cdf0e10cSrcweir     };
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir     ReferenceSizeProvider(
59*cdf0e10cSrcweir         ::com::sun::star::awt::Size aPageSize,
60*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
61*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartDocument > & xChartDoc );
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     ::com::sun::star::awt::Size getPageSize() const;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     /** Retrieves the state auto-resize from all objects that support this
66*cdf0e10cSrcweir         feature.  If all objects return the same state, AUTO_RESIZE_YES or
67*cdf0e10cSrcweir         AUTO_RESIZE_NO is returned.
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir         If no object supporting the feature is found, AUTO_RESIZE_UNKNOWN is
70*cdf0e10cSrcweir         returned.  If there are multiple objects, some with state YES and some
71*cdf0e10cSrcweir         with state NO, AUTO_RESIZE_AMBIGUOUS is returned.
72*cdf0e10cSrcweir     */
73*cdf0e10cSrcweir     static AutoResizeState getAutoResizeState(
74*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
75*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartDocument > & xChartDoc );
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     /** sets or resets the auto-resize at all objects that support this feature
78*cdf0e10cSrcweir         for text to the opposite of the current setting.  If the current state
79*cdf0e10cSrcweir         is ambiguous, it is turned on.  If the current state is unknown it stays
80*cdf0e10cSrcweir         unknown.
81*cdf0e10cSrcweir     */
82*cdf0e10cSrcweir     void toggleAutoResizeState();
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     /** Sets the ReferencePageSize according to the internal settings of this
86*cdf0e10cSrcweir         class at the XPropertySet, and the adapted font sizes if bAdaptFontSizes
87*cdf0e10cSrcweir         is </sal_True>.
88*cdf0e10cSrcweir      */
89*cdf0e10cSrcweir     SAL_DLLPRIVATE void setValuesAtPropertySet(
90*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
91*cdf0e10cSrcweir             ::com::sun::star::beans::XPropertySet > & xProp,
92*cdf0e10cSrcweir         bool bAdaptFontSizes = true );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     /** Sets the ReferencePageSize according to the internal settings of this
95*cdf0e10cSrcweir         class at the XTitle, and the adapted font sizes at the contained
96*cdf0e10cSrcweir         XFormattedStrings
97*cdf0e10cSrcweir      */
98*cdf0e10cSrcweir     SAL_DLLPRIVATE void setValuesAtTitle(
99*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
100*cdf0e10cSrcweir             ::com::sun::star::chart2::XTitle > & xTitle );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     /** Sets the internal value at all data series in the currently set model.
103*cdf0e10cSrcweir         This is useful, if you have changed a chart-type and thus probably added
104*cdf0e10cSrcweir         some new data series via model functionality.
105*cdf0e10cSrcweir      */
106*cdf0e10cSrcweir     void setValuesAtAllDataSeries();
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir private:
109*cdf0e10cSrcweir     SAL_DLLPRIVATE bool useAutoScale() const;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     /** sets the auto-resize at all objects that support this feature for text.
112*cdf0e10cSrcweir         eNewState must be either AUTO_RESIZE_YES or AUTO_RESIZE_NO
113*cdf0e10cSrcweir     */
114*cdf0e10cSrcweir     SAL_DLLPRIVATE void setAutoResizeState( AutoResizeState eNewState );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     /** Retrieves the auto-resize state from the given propertyset.  The result
117*cdf0e10cSrcweir         will be put into eInOutState.  If you initialize eInOutState with
118*cdf0e10cSrcweir         AUTO_RESIZE_UNKNOWN, you will get the actual state.  If you pass any
119*cdf0e10cSrcweir         other state, the result will be the accumulated state,
120*cdf0e10cSrcweir         esp. AUTO_RESIZE_AMBIGUOUS, if the value was NO before, and is YES for
121*cdf0e10cSrcweir         the current property set, or the other way round.
122*cdf0e10cSrcweir      */
123*cdf0e10cSrcweir     SAL_DLLPRIVATE static void getAutoResizeFromPropSet(
124*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
125*cdf0e10cSrcweir             ::com::sun::star::beans::XPropertySet > & xProp,
126*cdf0e10cSrcweir         AutoResizeState & rInOutState );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     SAL_DLLPRIVATE void impl_setValuesAtTitled(
129*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
130*cdf0e10cSrcweir             ::com::sun::star::chart2::XTitled > & xTitled );
131*cdf0e10cSrcweir     SAL_DLLPRIVATE static void impl_getAutoResizeFromTitled(
132*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
133*cdf0e10cSrcweir             ::com::sun::star::chart2::XTitled > & xTitled,
134*cdf0e10cSrcweir         AutoResizeState & rInOutState );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     ::com::sun::star::awt::Size m_aPageSize;
137*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
138*cdf0e10cSrcweir             ::com::sun::star::chart2::XChartDocument > m_xChartDoc;
139*cdf0e10cSrcweir     bool      m_bUseAutoScale;
140*cdf0e10cSrcweir };
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir } //  namespace chart
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir // CHART2_REFERENCESIZEPROVIDER_HXX
145*cdf0e10cSrcweir #endif
146