xref: /AOO41X/main/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_chart2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "WrappedScaleProperty.hxx"
32*cdf0e10cSrcweir #include "macros.hxx"
33*cdf0e10cSrcweir #include "CommonConverters.hxx"
34*cdf0e10cSrcweir #include "AxisHelper.hxx"
35*cdf0e10cSrcweir #include <com/sun/star/chart2/XAxis.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisType.hpp>
37*cdf0e10cSrcweir #include <chartview/ExplicitScaleValues.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir using namespace ::com::sun::star;
40*cdf0e10cSrcweir using ::com::sun::star::uno::Any;
41*cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
42*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
43*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
44*cdf0e10cSrcweir using ::rtl::OUString;
45*cdf0e10cSrcweir using ::com::sun::star::chart::TimeIncrement;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir //.............................................................................
48*cdf0e10cSrcweir namespace chart
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir namespace wrapper
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty
54*cdf0e10cSrcweir                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
55*cdf0e10cSrcweir             : WrappedProperty(OUString(),OUString())
56*cdf0e10cSrcweir             , m_spChart2ModelContact( spChart2ModelContact )
57*cdf0e10cSrcweir             , m_eScaleProperty( eScaleProperty )
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir     switch( m_eScaleProperty )
60*cdf0e10cSrcweir     {
61*cdf0e10cSrcweir         case SCALE_PROP_MAX:
62*cdf0e10cSrcweir             m_aOuterName = C2U("Max");
63*cdf0e10cSrcweir             break;
64*cdf0e10cSrcweir         case SCALE_PROP_MIN:
65*cdf0e10cSrcweir             m_aOuterName = C2U("Min");
66*cdf0e10cSrcweir             break;
67*cdf0e10cSrcweir         case SCALE_PROP_ORIGIN:
68*cdf0e10cSrcweir             m_aOuterName = C2U("Origin");
69*cdf0e10cSrcweir             break;
70*cdf0e10cSrcweir         case SCALE_PROP_STEPMAIN:
71*cdf0e10cSrcweir             m_aOuterName = C2U("StepMain");
72*cdf0e10cSrcweir             break;
73*cdf0e10cSrcweir         case SCALE_PROP_STEPHELP:
74*cdf0e10cSrcweir             m_aOuterName = C2U("StepHelp");
75*cdf0e10cSrcweir             break;
76*cdf0e10cSrcweir         case SCALE_PROP_STEPHELP_COUNT:
77*cdf0e10cSrcweir             m_aOuterName = C2U("StepHelpCount");
78*cdf0e10cSrcweir             break;
79*cdf0e10cSrcweir         case SCALE_PROP_AUTO_MAX:
80*cdf0e10cSrcweir             m_aOuterName = C2U("AutoMax");
81*cdf0e10cSrcweir             break;
82*cdf0e10cSrcweir         case SCALE_PROP_AUTO_MIN:
83*cdf0e10cSrcweir             m_aOuterName = C2U("AutoMin");
84*cdf0e10cSrcweir             break;
85*cdf0e10cSrcweir         case SCALE_PROP_AUTO_ORIGIN:
86*cdf0e10cSrcweir             m_aOuterName = C2U("AutoOrigin");
87*cdf0e10cSrcweir             break;
88*cdf0e10cSrcweir         case SCALE_PROP_AUTO_STEPMAIN:
89*cdf0e10cSrcweir             m_aOuterName = C2U("AutoStepMain");
90*cdf0e10cSrcweir             break;
91*cdf0e10cSrcweir         case SCALE_PROP_AUTO_STEPHELP:
92*cdf0e10cSrcweir             m_aOuterName = C2U("AutoStepHelp");
93*cdf0e10cSrcweir             break;
94*cdf0e10cSrcweir         case SCALE_PROP_AXIS_TYPE:
95*cdf0e10cSrcweir             m_aOuterName = C2U("AxisType");
96*cdf0e10cSrcweir             break;
97*cdf0e10cSrcweir         case SCALE_PROP_DATE_INCREMENT:
98*cdf0e10cSrcweir             m_aOuterName = C2U("TimeIncrement");
99*cdf0e10cSrcweir             break;
100*cdf0e10cSrcweir         case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
101*cdf0e10cSrcweir             m_aOuterName = C2U("ExplicitTimeIncrement");
102*cdf0e10cSrcweir             break;
103*cdf0e10cSrcweir         case SCALE_PROP_LOGARITHMIC:
104*cdf0e10cSrcweir             m_aOuterName = C2U("Logarithmic");
105*cdf0e10cSrcweir             break;
106*cdf0e10cSrcweir         case SCALE_PROP_REVERSEDIRECTION:
107*cdf0e10cSrcweir             m_aOuterName = C2U("ReverseDirection");
108*cdf0e10cSrcweir             break;
109*cdf0e10cSrcweir         default:
110*cdf0e10cSrcweir             OSL_ENSURE(false,"unknown scale property");
111*cdf0e10cSrcweir             break;
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir WrappedScaleProperty::~WrappedScaleProperty()
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
120*cdf0e10cSrcweir             , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_MAX, spChart2ModelContact ) );
123*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_MIN, spChart2ModelContact ) );
124*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_ORIGIN, spChart2ModelContact ) );
125*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPMAIN, spChart2ModelContact ) );
126*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP, spChart2ModelContact ) );
127*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP_COUNT, spChart2ModelContact ) );
128*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MAX, spChart2ModelContact ) );
129*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MIN, spChart2ModelContact ) );
130*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) );
131*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) );
132*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) );
133*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) );
134*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) );
135*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_EXPLICIT_DATE_INCREMENT, spChart2ModelContact ) );
136*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) );
137*cdf0e10cSrcweir     rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir void WrappedScaleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
141*cdf0e10cSrcweir                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     setPropertyValue( m_eScaleProperty, rOuterValue, xInnerPropertySet );
144*cdf0e10cSrcweir }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir Any WrappedScaleProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
147*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir     return getPropertyValue( m_eScaleProperty, xInnerPropertySet );
150*cdf0e10cSrcweir }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
153*cdf0e10cSrcweir                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir     m_aOuterValue = rOuterValue;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
158*cdf0e10cSrcweir     OSL_ENSURE(xAxis.is(),"need an XAxis");
159*cdf0e10cSrcweir     if(!xAxis.is())
160*cdf0e10cSrcweir         return;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     bool bSetScaleData     = false;
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     chart2::ScaleData aScaleData( xAxis->getScaleData() );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     sal_Bool bBool = false;
167*cdf0e10cSrcweir     switch( eScaleProperty )
168*cdf0e10cSrcweir     {
169*cdf0e10cSrcweir         case SCALE_PROP_MAX:
170*cdf0e10cSrcweir         {
171*cdf0e10cSrcweir             aScaleData.Maximum = rOuterValue;
172*cdf0e10cSrcweir             bSetScaleData = true;
173*cdf0e10cSrcweir             break;
174*cdf0e10cSrcweir         }
175*cdf0e10cSrcweir         case SCALE_PROP_MIN:
176*cdf0e10cSrcweir         {
177*cdf0e10cSrcweir             aScaleData.Minimum = rOuterValue;
178*cdf0e10cSrcweir             bSetScaleData = true;
179*cdf0e10cSrcweir             break;
180*cdf0e10cSrcweir         }
181*cdf0e10cSrcweir         case SCALE_PROP_STEPMAIN:
182*cdf0e10cSrcweir         {
183*cdf0e10cSrcweir             aScaleData.IncrementData.Distance = rOuterValue;
184*cdf0e10cSrcweir             bSetScaleData = true;
185*cdf0e10cSrcweir             break;
186*cdf0e10cSrcweir         }
187*cdf0e10cSrcweir         case SCALE_PROP_STEPHELP:
188*cdf0e10cSrcweir         {
189*cdf0e10cSrcweir             Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
190*cdf0e10cSrcweir             if( rSubIncrements.getLength() == 0 )
191*cdf0e10cSrcweir                 rSubIncrements.realloc( 1 );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir             double fStepMain = 0, fStepHelp = 0;
194*cdf0e10cSrcweir             if( (rOuterValue >>= fStepHelp) )
195*cdf0e10cSrcweir             {
196*cdf0e10cSrcweir                 if( AxisHelper::isLogarithmic(aScaleData.Scaling) )
197*cdf0e10cSrcweir                 {
198*cdf0e10cSrcweir                     sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp);
199*cdf0e10cSrcweir                     rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
200*cdf0e10cSrcweir                 }
201*cdf0e10cSrcweir                 else if( (fStepHelp != 0.0) &&
202*cdf0e10cSrcweir                     (aScaleData.IncrementData.Distance >>= fStepMain) )
203*cdf0e10cSrcweir                 {
204*cdf0e10cSrcweir                     // approximate interval count
205*cdf0e10cSrcweir                     sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);
206*cdf0e10cSrcweir                     rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
207*cdf0e10cSrcweir                 }
208*cdf0e10cSrcweir             }
209*cdf0e10cSrcweir             bSetScaleData = true;
210*cdf0e10cSrcweir             break;
211*cdf0e10cSrcweir         }
212*cdf0e10cSrcweir         case SCALE_PROP_STEPHELP_COUNT:
213*cdf0e10cSrcweir         {
214*cdf0e10cSrcweir             Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
215*cdf0e10cSrcweir             if( rSubIncrements.getLength() == 0 )
216*cdf0e10cSrcweir                 rSubIncrements.realloc( 1 );
217*cdf0e10cSrcweir             sal_Int32 nIntervalCount=0;
218*cdf0e10cSrcweir             if( rOuterValue>>=nIntervalCount )
219*cdf0e10cSrcweir                 rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
220*cdf0e10cSrcweir             else
221*cdf0e10cSrcweir                 rSubIncrements[ 0 ].IntervalCount  = Any();
222*cdf0e10cSrcweir             bSetScaleData = true;
223*cdf0e10cSrcweir             break;
224*cdf0e10cSrcweir         }
225*cdf0e10cSrcweir         case SCALE_PROP_AUTO_MAX:
226*cdf0e10cSrcweir         {
227*cdf0e10cSrcweir             if( (rOuterValue >>= bBool) && bBool )
228*cdf0e10cSrcweir                 aScaleData.Maximum = Any();
229*cdf0e10cSrcweir             else
230*cdf0e10cSrcweir                 aScaleData.Maximum = getPropertyValue( SCALE_PROP_MAX, xInnerPropertySet );
231*cdf0e10cSrcweir             bSetScaleData = true;
232*cdf0e10cSrcweir             break;
233*cdf0e10cSrcweir         }
234*cdf0e10cSrcweir         case SCALE_PROP_AUTO_MIN:
235*cdf0e10cSrcweir         {
236*cdf0e10cSrcweir             if( (rOuterValue >>= bBool) && bBool )
237*cdf0e10cSrcweir                 aScaleData.Minimum = Any();
238*cdf0e10cSrcweir             else
239*cdf0e10cSrcweir                 aScaleData.Minimum = getPropertyValue( SCALE_PROP_MIN, xInnerPropertySet );
240*cdf0e10cSrcweir             bSetScaleData = true;
241*cdf0e10cSrcweir             break;
242*cdf0e10cSrcweir         }
243*cdf0e10cSrcweir         case SCALE_PROP_AUTO_STEPMAIN:
244*cdf0e10cSrcweir         {
245*cdf0e10cSrcweir             if( (rOuterValue >>= bBool) && bBool )
246*cdf0e10cSrcweir                 aScaleData.IncrementData.Distance = Any();
247*cdf0e10cSrcweir             else
248*cdf0e10cSrcweir                 aScaleData.IncrementData.Distance = getPropertyValue( SCALE_PROP_STEPMAIN, xInnerPropertySet );
249*cdf0e10cSrcweir             bSetScaleData = true;
250*cdf0e10cSrcweir             break;
251*cdf0e10cSrcweir         }
252*cdf0e10cSrcweir         case SCALE_PROP_AUTO_STEPHELP:
253*cdf0e10cSrcweir         {
254*cdf0e10cSrcweir             Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
255*cdf0e10cSrcweir             if( rSubIncrements.getLength() == 0 )
256*cdf0e10cSrcweir                 rSubIncrements.realloc( 1 );
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir             if( (rOuterValue >>= bBool) && bBool )
259*cdf0e10cSrcweir                 rSubIncrements[ 0 ].IntervalCount = Any();
260*cdf0e10cSrcweir             else
261*cdf0e10cSrcweir                 rSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet );
262*cdf0e10cSrcweir             bSetScaleData = true;
263*cdf0e10cSrcweir             break;
264*cdf0e10cSrcweir         }
265*cdf0e10cSrcweir         case SCALE_PROP_ORIGIN:
266*cdf0e10cSrcweir         {
267*cdf0e10cSrcweir             aScaleData.Origin = rOuterValue;
268*cdf0e10cSrcweir             bSetScaleData = true;
269*cdf0e10cSrcweir             break;
270*cdf0e10cSrcweir         }
271*cdf0e10cSrcweir         case SCALE_PROP_AUTO_ORIGIN:
272*cdf0e10cSrcweir         {
273*cdf0e10cSrcweir             if( (rOuterValue >>= bBool) && bBool )
274*cdf0e10cSrcweir                 aScaleData.Origin = Any();
275*cdf0e10cSrcweir             else
276*cdf0e10cSrcweir                 aScaleData.Origin = getPropertyValue( SCALE_PROP_ORIGIN, xInnerPropertySet );
277*cdf0e10cSrcweir             bSetScaleData = true;
278*cdf0e10cSrcweir             break;
279*cdf0e10cSrcweir         }
280*cdf0e10cSrcweir         case SCALE_PROP_AXIS_TYPE:
281*cdf0e10cSrcweir         {
282*cdf0e10cSrcweir             sal_Int32 nType = 0;
283*cdf0e10cSrcweir             if( (rOuterValue >>= nType) )
284*cdf0e10cSrcweir             {
285*cdf0e10cSrcweir                 if( ::com::sun::star::chart::ChartAxisType::AUTOMATIC == nType )
286*cdf0e10cSrcweir                 {
287*cdf0e10cSrcweir                     aScaleData.AutoDateAxis = true;
288*cdf0e10cSrcweir                     if( aScaleData.AxisType == AxisType::DATE )
289*cdf0e10cSrcweir                         aScaleData.AxisType = AxisType::CATEGORY;
290*cdf0e10cSrcweir                 }
291*cdf0e10cSrcweir                 else if( ::com::sun::star::chart::ChartAxisType::CATEGORY == nType )
292*cdf0e10cSrcweir                 {
293*cdf0e10cSrcweir                     aScaleData.AutoDateAxis = false;
294*cdf0e10cSrcweir                     if( aScaleData.AxisType == AxisType::DATE )
295*cdf0e10cSrcweir                         aScaleData.AxisType = AxisType::CATEGORY;
296*cdf0e10cSrcweir                 }
297*cdf0e10cSrcweir                 else if( ::com::sun::star::chart::ChartAxisType::DATE == nType )
298*cdf0e10cSrcweir                 {
299*cdf0e10cSrcweir                     if( aScaleData.AxisType == AxisType::CATEGORY )
300*cdf0e10cSrcweir                         aScaleData.AxisType = AxisType::DATE;
301*cdf0e10cSrcweir                 }
302*cdf0e10cSrcweir                 bSetScaleData = true;
303*cdf0e10cSrcweir             }
304*cdf0e10cSrcweir             break;
305*cdf0e10cSrcweir         }
306*cdf0e10cSrcweir         case SCALE_PROP_DATE_INCREMENT:
307*cdf0e10cSrcweir         {
308*cdf0e10cSrcweir             TimeIncrement aTimeIncrement;
309*cdf0e10cSrcweir             rOuterValue >>= aTimeIncrement;
310*cdf0e10cSrcweir             aScaleData.TimeIncrement = aTimeIncrement;
311*cdf0e10cSrcweir             bSetScaleData = true;
312*cdf0e10cSrcweir             break;
313*cdf0e10cSrcweir         }
314*cdf0e10cSrcweir         case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
315*cdf0e10cSrcweir             //read only property
316*cdf0e10cSrcweir             break;
317*cdf0e10cSrcweir         case SCALE_PROP_LOGARITHMIC:
318*cdf0e10cSrcweir         {
319*cdf0e10cSrcweir             if( rOuterValue >>= bBool )
320*cdf0e10cSrcweir             {
321*cdf0e10cSrcweir                 bool bWasLogarithm = AxisHelper::isLogarithmic( aScaleData.Scaling );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir                 // safe comparison between sal_Bool and bool
324*cdf0e10cSrcweir                 if( (!bBool) != (!bWasLogarithm) )
325*cdf0e10cSrcweir                 {
326*cdf0e10cSrcweir                     if( bBool )
327*cdf0e10cSrcweir                         aScaleData.Scaling = AxisHelper::createLogarithmicScaling( 10.0 );
328*cdf0e10cSrcweir                     else
329*cdf0e10cSrcweir                         aScaleData.Scaling = 0;
330*cdf0e10cSrcweir                     bSetScaleData = true;
331*cdf0e10cSrcweir                 }
332*cdf0e10cSrcweir             }
333*cdf0e10cSrcweir             break;
334*cdf0e10cSrcweir         }
335*cdf0e10cSrcweir         case SCALE_PROP_REVERSEDIRECTION:
336*cdf0e10cSrcweir         {
337*cdf0e10cSrcweir             if( rOuterValue >>= bBool )
338*cdf0e10cSrcweir             {
339*cdf0e10cSrcweir                 bool bWasReverse = ( AxisOrientation_REVERSE == aScaleData.Orientation );
340*cdf0e10cSrcweir                 if( (!bBool) != (!bWasReverse) ) // safe comparison between sal_Bool and bool
341*cdf0e10cSrcweir                 {
342*cdf0e10cSrcweir                     aScaleData.Orientation = bBool ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL;
343*cdf0e10cSrcweir                     bSetScaleData = true;
344*cdf0e10cSrcweir                 }
345*cdf0e10cSrcweir             }
346*cdf0e10cSrcweir             break;
347*cdf0e10cSrcweir         }
348*cdf0e10cSrcweir         default:
349*cdf0e10cSrcweir         {
350*cdf0e10cSrcweir             OSL_ENSURE(false,"unknown scale property");
351*cdf0e10cSrcweir             break;
352*cdf0e10cSrcweir         }
353*cdf0e10cSrcweir     }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     if( bSetScaleData )
356*cdf0e10cSrcweir         xAxis->setScaleData( aScaleData );
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
360*cdf0e10cSrcweir                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir     Any aRet( m_aOuterValue );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
365*cdf0e10cSrcweir     OSL_ENSURE(xAxis.is(),"need an XAxis");
366*cdf0e10cSrcweir     if(!xAxis.is())
367*cdf0e10cSrcweir         return aRet;
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     chart2::ScaleData aScaleData( xAxis->getScaleData() );
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir     ExplicitScaleData aExplicitScale;
372*cdf0e10cSrcweir     ExplicitIncrementData aExplicitIncrement;
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir     switch( eScaleProperty )
375*cdf0e10cSrcweir     {
376*cdf0e10cSrcweir         case SCALE_PROP_MAX:
377*cdf0e10cSrcweir         {
378*cdf0e10cSrcweir             aRet = aScaleData.Maximum;
379*cdf0e10cSrcweir             if( !aRet.hasValue() )
380*cdf0e10cSrcweir             {
381*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis(
382*cdf0e10cSrcweir                     xAxis, aExplicitScale, aExplicitIncrement );
383*cdf0e10cSrcweir                 aRet <<= aExplicitScale.Maximum;
384*cdf0e10cSrcweir             }
385*cdf0e10cSrcweir             break;
386*cdf0e10cSrcweir         }
387*cdf0e10cSrcweir         case SCALE_PROP_MIN:
388*cdf0e10cSrcweir         {
389*cdf0e10cSrcweir             aRet = aScaleData.Minimum;
390*cdf0e10cSrcweir             if( !aRet.hasValue() )
391*cdf0e10cSrcweir             {
392*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis(
393*cdf0e10cSrcweir                     xAxis, aExplicitScale, aExplicitIncrement );
394*cdf0e10cSrcweir                 aRet <<= aExplicitScale.Minimum;
395*cdf0e10cSrcweir             }
396*cdf0e10cSrcweir             break;
397*cdf0e10cSrcweir         }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir         case SCALE_PROP_STEPMAIN:
400*cdf0e10cSrcweir         {
401*cdf0e10cSrcweir             aRet = aScaleData.IncrementData.Distance;
402*cdf0e10cSrcweir             if( !aRet.hasValue() )
403*cdf0e10cSrcweir             {
404*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis(
405*cdf0e10cSrcweir                     xAxis, aExplicitScale, aExplicitIncrement );
406*cdf0e10cSrcweir                 aRet <<= aExplicitIncrement.Distance;
407*cdf0e10cSrcweir             }
408*cdf0e10cSrcweir             break;
409*cdf0e10cSrcweir         }
410*cdf0e10cSrcweir         case SCALE_PROP_STEPHELP:
411*cdf0e10cSrcweir         {
412*cdf0e10cSrcweir             // todo: evaluate PostEquidistant
413*cdf0e10cSrcweir             bool bNeedToCalculateExplicitValues = true;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir             bool bLogarithmic( AxisHelper::isLogarithmic(aScaleData.Scaling) );
416*cdf0e10cSrcweir             Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
417*cdf0e10cSrcweir             if( bLogarithmic )
418*cdf0e10cSrcweir             {
419*cdf0e10cSrcweir                 if( rSubIncrements.getLength() > 0 )
420*cdf0e10cSrcweir                 {
421*cdf0e10cSrcweir                     sal_Int32 nIntervalCount = 0;
422*cdf0e10cSrcweir                     rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount;
423*cdf0e10cSrcweir                     aRet = uno::makeAny( double(nIntervalCount) );
424*cdf0e10cSrcweir                     bNeedToCalculateExplicitValues = false;
425*cdf0e10cSrcweir                 }
426*cdf0e10cSrcweir             }
427*cdf0e10cSrcweir             else if( aScaleData.IncrementData.Distance.hasValue() )
428*cdf0e10cSrcweir             {
429*cdf0e10cSrcweir                 if( rSubIncrements.getLength() > 0 )
430*cdf0e10cSrcweir                 {
431*cdf0e10cSrcweir                     double fStepMain = 0;
432*cdf0e10cSrcweir                     sal_Int32 nIntervalCount = 0;
433*cdf0e10cSrcweir                     if( (aScaleData.IncrementData.Distance >>= fStepMain) &&
434*cdf0e10cSrcweir                         (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) &&
435*cdf0e10cSrcweir                         nIntervalCount > 0 )
436*cdf0e10cSrcweir                     {
437*cdf0e10cSrcweir                         aRet <<= ( fStepMain / static_cast< double >( nIntervalCount ) );
438*cdf0e10cSrcweir                         bNeedToCalculateExplicitValues = false;
439*cdf0e10cSrcweir                     }
440*cdf0e10cSrcweir                 }
441*cdf0e10cSrcweir                 else
442*cdf0e10cSrcweir                 {
443*cdf0e10cSrcweir                     aRet = aScaleData.IncrementData.Distance;
444*cdf0e10cSrcweir                     bNeedToCalculateExplicitValues = false;
445*cdf0e10cSrcweir                 }
446*cdf0e10cSrcweir             }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir             if( bNeedToCalculateExplicitValues )
449*cdf0e10cSrcweir             {
450*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis(
451*cdf0e10cSrcweir                     xAxis, aExplicitScale, aExplicitIncrement );
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir                 if( !aExplicitIncrement.SubIncrements.empty() &&
454*cdf0e10cSrcweir                      aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 )
455*cdf0e10cSrcweir                 {
456*cdf0e10cSrcweir                     if( bLogarithmic )
457*cdf0e10cSrcweir                     {
458*cdf0e10cSrcweir                         if( rSubIncrements.getLength() > 0 )
459*cdf0e10cSrcweir                         {
460*cdf0e10cSrcweir                             sal_Int32 nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount;
461*cdf0e10cSrcweir                             aRet = uno::makeAny( double(nIntervalCount) );
462*cdf0e10cSrcweir                         }
463*cdf0e10cSrcweir                     }
464*cdf0e10cSrcweir                     else
465*cdf0e10cSrcweir                         aRet <<= ( aExplicitIncrement.Distance /
466*cdf0e10cSrcweir                                 static_cast< double >(
467*cdf0e10cSrcweir                                     aExplicitIncrement.SubIncrements[ 0 ].IntervalCount ));
468*cdf0e10cSrcweir                 }
469*cdf0e10cSrcweir                 else
470*cdf0e10cSrcweir                 {
471*cdf0e10cSrcweir                     if( bLogarithmic )
472*cdf0e10cSrcweir                         aRet <<= 5.0;
473*cdf0e10cSrcweir                     else
474*cdf0e10cSrcweir                         aRet <<= aExplicitIncrement.Distance;
475*cdf0e10cSrcweir                 }
476*cdf0e10cSrcweir             }
477*cdf0e10cSrcweir             break;
478*cdf0e10cSrcweir         }
479*cdf0e10cSrcweir         case SCALE_PROP_STEPHELP_COUNT:
480*cdf0e10cSrcweir         {
481*cdf0e10cSrcweir             sal_Int32 nIntervalCount = 0;
482*cdf0e10cSrcweir             bool bNeedToCalculateExplicitValues = true;
483*cdf0e10cSrcweir             Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
484*cdf0e10cSrcweir             if( rSubIncrements.getLength() > 0 )
485*cdf0e10cSrcweir             {
486*cdf0e10cSrcweir                 if( (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && (nIntervalCount > 0) )
487*cdf0e10cSrcweir                     bNeedToCalculateExplicitValues = false;
488*cdf0e10cSrcweir             }
489*cdf0e10cSrcweir             if( bNeedToCalculateExplicitValues )
490*cdf0e10cSrcweir             {
491*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement );
492*cdf0e10cSrcweir                 if( !aExplicitIncrement.SubIncrements.empty() )
493*cdf0e10cSrcweir                     nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount;
494*cdf0e10cSrcweir             }
495*cdf0e10cSrcweir             aRet = uno::makeAny( nIntervalCount );
496*cdf0e10cSrcweir             break;
497*cdf0e10cSrcweir         }
498*cdf0e10cSrcweir         case SCALE_PROP_AUTO_MAX:
499*cdf0e10cSrcweir         {
500*cdf0e10cSrcweir             aRet <<= (sal_Bool)( !aScaleData.Maximum.hasValue() );
501*cdf0e10cSrcweir             break;
502*cdf0e10cSrcweir         }
503*cdf0e10cSrcweir         case SCALE_PROP_AUTO_MIN:
504*cdf0e10cSrcweir         {
505*cdf0e10cSrcweir             aRet <<= (sal_Bool)( !aScaleData.Minimum.hasValue() );
506*cdf0e10cSrcweir             break;
507*cdf0e10cSrcweir         }
508*cdf0e10cSrcweir         case SCALE_PROP_AUTO_STEPMAIN:
509*cdf0e10cSrcweir         {
510*cdf0e10cSrcweir             aRet <<= (sal_Bool)( !aScaleData.IncrementData.Distance.hasValue() );
511*cdf0e10cSrcweir             break;
512*cdf0e10cSrcweir         }
513*cdf0e10cSrcweir         case SCALE_PROP_AUTO_STEPHELP:
514*cdf0e10cSrcweir         {
515*cdf0e10cSrcweir             Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
516*cdf0e10cSrcweir             if( rSubIncrements.getLength() > 0 )
517*cdf0e10cSrcweir                 aRet <<= (sal_Bool)( !rSubIncrements[ 0 ].IntervalCount.hasValue() );
518*cdf0e10cSrcweir             else
519*cdf0e10cSrcweir                 aRet <<= sal_True;
520*cdf0e10cSrcweir             break;
521*cdf0e10cSrcweir         }
522*cdf0e10cSrcweir         case SCALE_PROP_ORIGIN:
523*cdf0e10cSrcweir         {
524*cdf0e10cSrcweir             aRet = aScaleData.Origin;
525*cdf0e10cSrcweir             if( !aRet.hasValue() )
526*cdf0e10cSrcweir             {
527*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis(
528*cdf0e10cSrcweir                     xAxis, aExplicitScale, aExplicitIncrement );
529*cdf0e10cSrcweir                 aRet <<= aExplicitScale.Origin;
530*cdf0e10cSrcweir             }
531*cdf0e10cSrcweir             break;
532*cdf0e10cSrcweir         }
533*cdf0e10cSrcweir         case SCALE_PROP_AUTO_ORIGIN:
534*cdf0e10cSrcweir         {
535*cdf0e10cSrcweir             aRet <<= !hasDoubleValue(aScaleData.Origin);
536*cdf0e10cSrcweir             break;
537*cdf0e10cSrcweir         }
538*cdf0e10cSrcweir         case SCALE_PROP_AXIS_TYPE:
539*cdf0e10cSrcweir         {
540*cdf0e10cSrcweir             sal_Int32 nType = ::com::sun::star::chart::ChartAxisType::AUTOMATIC;
541*cdf0e10cSrcweir             if( aScaleData.AxisType == AxisType::DATE )
542*cdf0e10cSrcweir             {
543*cdf0e10cSrcweir                 nType = ::com::sun::star::chart::ChartAxisType::DATE;
544*cdf0e10cSrcweir             }
545*cdf0e10cSrcweir             else if( aScaleData.AxisType == AxisType::CATEGORY )
546*cdf0e10cSrcweir             {
547*cdf0e10cSrcweir                 if( !aScaleData.AutoDateAxis )
548*cdf0e10cSrcweir                     nType = ::com::sun::star::chart::ChartAxisType::CATEGORY;
549*cdf0e10cSrcweir             }
550*cdf0e10cSrcweir             aRet = uno::makeAny( nType );
551*cdf0e10cSrcweir             break;
552*cdf0e10cSrcweir         }
553*cdf0e10cSrcweir         case SCALE_PROP_DATE_INCREMENT:
554*cdf0e10cSrcweir         {
555*cdf0e10cSrcweir             if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
556*cdf0e10cSrcweir                 aRet = uno::makeAny( aScaleData.TimeIncrement );
557*cdf0e10cSrcweir             break;
558*cdf0e10cSrcweir         }
559*cdf0e10cSrcweir         case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
560*cdf0e10cSrcweir         {
561*cdf0e10cSrcweir             if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
562*cdf0e10cSrcweir             {
563*cdf0e10cSrcweir                 m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement );
564*cdf0e10cSrcweir                 if( aExplicitScale.AxisType == AxisType::DATE )
565*cdf0e10cSrcweir                 {
566*cdf0e10cSrcweir                     TimeIncrement aTimeIncrement;
567*cdf0e10cSrcweir                     aTimeIncrement.MajorTimeInterval = uno::makeAny( aExplicitIncrement.MajorTimeInterval );
568*cdf0e10cSrcweir                     aTimeIncrement.MinorTimeInterval = uno::makeAny( aExplicitIncrement.MinorTimeInterval );
569*cdf0e10cSrcweir                     aTimeIncrement.TimeResolution = uno::makeAny( aExplicitScale.TimeResolution );
570*cdf0e10cSrcweir                     aRet = uno::makeAny(aTimeIncrement);
571*cdf0e10cSrcweir                 }
572*cdf0e10cSrcweir             }
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir             if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
575*cdf0e10cSrcweir                 aRet = uno::makeAny( aScaleData.TimeIncrement );
576*cdf0e10cSrcweir             break;
577*cdf0e10cSrcweir         }
578*cdf0e10cSrcweir         case SCALE_PROP_LOGARITHMIC:
579*cdf0e10cSrcweir         {
580*cdf0e10cSrcweir             aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) );
581*cdf0e10cSrcweir             break;
582*cdf0e10cSrcweir         }
583*cdf0e10cSrcweir         case SCALE_PROP_REVERSEDIRECTION:
584*cdf0e10cSrcweir         {
585*cdf0e10cSrcweir             aRet <<= static_cast< sal_Bool >( AxisOrientation_REVERSE == aScaleData.Orientation );
586*cdf0e10cSrcweir             break;
587*cdf0e10cSrcweir         }
588*cdf0e10cSrcweir         default:
589*cdf0e10cSrcweir         {
590*cdf0e10cSrcweir             OSL_ENSURE(false,"unknown scale property");
591*cdf0e10cSrcweir             break;
592*cdf0e10cSrcweir         }
593*cdf0e10cSrcweir     }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir     return aRet;
596*cdf0e10cSrcweir }
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir } //  namespace wrapper
599*cdf0e10cSrcweir } //  namespace chart
600*cdf0e10cSrcweir //.............................................................................
601