fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / WrappedAxisAndGridExistenceProperties.cxx
blobf78d625b080a47caa9df045fe51b167b102055f7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "WrappedAxisAndGridExistenceProperties.hxx"
21 #include "AxisHelper.hxx"
22 #include "ChartModelHelper.hxx"
23 #include "TitleHelper.hxx"
24 #include "macros.hxx"
26 using namespace ::com::sun::star;
27 using ::com::sun::star::uno::Any;
28 using ::com::sun::star::uno::Reference;
29 using ::com::sun::star::uno::Sequence;
31 namespace chart
33 namespace wrapper
36 class WrappedAxisAndGridExistenceProperty : public WrappedProperty
38 public:
39 WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex
40 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
41 virtual ~WrappedAxisAndGridExistenceProperty();
43 virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
44 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
46 virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
47 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
49 virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
50 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
52 private: //member
53 ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
54 bool m_bAxis;
55 bool m_bMain;
56 sal_Int32 m_nDimensionIndex;
59 void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
60 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
62 rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 0, spChart2ModelContact ) );//x axis
63 rList.push_back( new WrappedAxisAndGridExistenceProperty( true, false, 0, spChart2ModelContact ) );//x secondary axis
64 rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 0, spChart2ModelContact ) );//x grid
65 rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 0, spChart2ModelContact ) );//x help grid
67 rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 1, spChart2ModelContact ) );//y axis
68 rList.push_back( new WrappedAxisAndGridExistenceProperty( true, false, 1, spChart2ModelContact ) );//y secondary axis
69 rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 1, spChart2ModelContact ) );//y grid
70 rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 1, spChart2ModelContact ) );//y help grid
72 rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 2, spChart2ModelContact ) );//z axis
73 rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 2, spChart2ModelContact ) );//z grid
74 rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 2, spChart2ModelContact ) );//z help grid
77 WrappedAxisAndGridExistenceProperty::WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex
78 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
79 : WrappedProperty(OUString(),OUString())
80 , m_spChart2ModelContact( spChart2ModelContact )
81 , m_bAxis( bAxis )
82 , m_bMain( bMain )
83 , m_nDimensionIndex( nDimensionIndex )
85 switch( m_nDimensionIndex )
87 case 0:
89 if( m_bAxis )
91 if( m_bMain )
92 m_aOuterName = "HasXAxis";
93 else
94 m_aOuterName = "HasSecondaryXAxis";
96 else
98 if( m_bMain )
99 m_aOuterName = "HasXAxisGrid";
100 else
101 m_aOuterName = "HasXAxisHelpGrid";
104 break;
105 case 2:
107 if( m_bAxis )
109 OSL_ENSURE(m_bMain,"there is no secondary z axis at the old api");
110 m_bMain = true;
111 m_aOuterName = "HasZAxis";
113 else
115 if( m_bMain )
116 m_aOuterName = "HasZAxisGrid";
117 else
118 m_aOuterName = "HasZAxisHelpGrid";
121 break;
122 default:
124 if( m_bAxis )
126 if( m_bMain )
127 m_aOuterName = "HasYAxis";
128 else
129 m_aOuterName = "HasSecondaryYAxis";
131 else
133 if( m_bMain )
134 m_aOuterName = "HasYAxisGrid";
135 else
136 m_aOuterName = "HasYAxisHelpGrid";
139 break;
143 WrappedAxisAndGridExistenceProperty::~WrappedAxisAndGridExistenceProperty()
147 void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
148 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
150 bool bNewValue = false;
151 if( ! (rOuterValue >>= bNewValue) )
152 throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", 0, 0 );
154 bool bOldValue = false;
155 getPropertyValue( xInnerPropertySet ) >>= bOldValue;
157 if( bOldValue == bNewValue )
158 return;
160 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
161 if( bNewValue )
163 if( m_bAxis )
164 AxisHelper::showAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext );
165 else
166 AxisHelper::showGrid( m_nDimensionIndex, 0, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext );
168 else
170 if( m_bAxis )
171 AxisHelper::hideAxis( m_nDimensionIndex, m_bMain, xDiagram );
172 else
173 AxisHelper::hideGrid( m_nDimensionIndex, 0, m_bMain, xDiagram );
177 Any WrappedAxisAndGridExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const
178 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
180 Any aRet;
181 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
182 if(m_bAxis)
184 bool bShown = AxisHelper::isAxisShown( m_nDimensionIndex, m_bMain, xDiagram );
185 aRet <<= bShown;
187 else
189 bool bShown = AxisHelper::isGridShown( m_nDimensionIndex, 0, m_bMain, xDiagram );
190 aRet <<= bShown;
192 return aRet;
195 Any WrappedAxisAndGridExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
196 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
198 Any aRet;
199 aRet <<= false;
200 return aRet;
203 class WrappedAxisTitleExistenceProperty : public WrappedProperty
205 public:
206 WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex
207 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
208 virtual ~WrappedAxisTitleExistenceProperty();
210 virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
211 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
213 virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
214 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
216 virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
217 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
219 private: //member
220 ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
221 TitleHelper::eTitleType m_eTitleType;
224 void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
225 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
227 rList.push_back( new WrappedAxisTitleExistenceProperty( 0, spChart2ModelContact ) );//x axis title
228 rList.push_back( new WrappedAxisTitleExistenceProperty( 1, spChart2ModelContact ) );//y axis title
229 rList.push_back( new WrappedAxisTitleExistenceProperty( 2, spChart2ModelContact ) );//z axis title
230 rList.push_back( new WrappedAxisTitleExistenceProperty( 3, spChart2ModelContact ) );//secondary x axis title
231 rList.push_back( new WrappedAxisTitleExistenceProperty( 4, spChart2ModelContact ) );//secondary y axis title
234 WrappedAxisTitleExistenceProperty::WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex
235 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
236 : WrappedProperty(OUString(),OUString())
237 , m_spChart2ModelContact( spChart2ModelContact )
238 , m_eTitleType( TitleHelper::Y_AXIS_TITLE )
240 switch( nTitleIndex )
242 case 0:
243 m_aOuterName = "HasXAxisTitle";
244 m_eTitleType = TitleHelper::X_AXIS_TITLE;
245 break;
246 case 2:
247 m_aOuterName = "HasZAxisTitle";
248 m_eTitleType = TitleHelper::Z_AXIS_TITLE;
249 break;
250 case 3:
251 m_aOuterName = "HasSecondaryXAxisTitle";
252 m_eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
253 break;
254 case 4:
255 m_aOuterName = "HasSecondaryYAxisTitle";
256 m_eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
257 break;
258 default:
259 m_aOuterName = "HasYAxisTitle";
260 m_eTitleType = TitleHelper::Y_AXIS_TITLE;
261 break;
265 WrappedAxisTitleExistenceProperty::~WrappedAxisTitleExistenceProperty()
269 void WrappedAxisTitleExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
270 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
272 bool bNewValue = false;
273 if( ! (rOuterValue >>= bNewValue) )
274 throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", 0, 0 );
276 bool bOldValue = false;
277 getPropertyValue( xInnerPropertySet ) >>= bOldValue;
279 if( bOldValue == bNewValue )
280 return;
282 if( bNewValue )
284 OUString aTitleText;
285 TitleHelper::createTitle( m_eTitleType, aTitleText
286 , m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
288 else
290 TitleHelper::removeTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() );
294 Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
295 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
297 bool bHasTitle = false;
299 Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ) );
300 if( xTitle.is() && !TitleHelper::getCompleteString( xTitle ).isEmpty() )
301 bHasTitle = true;
303 Any aRet;
304 aRet <<= bHasTitle;
305 return aRet;
309 Any WrappedAxisTitleExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
310 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
312 Any aRet;
313 aRet <<= false;
314 return aRet;
317 class WrappedAxisLabelExistenceProperty : public WrappedProperty
319 public:
320 WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex
321 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
322 virtual ~WrappedAxisLabelExistenceProperty();
324 virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
325 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
327 virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
328 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
330 virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
331 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
333 private: //member
334 ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
335 bool m_bMain;
336 sal_Int32 m_nDimensionIndex;
339 void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
340 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
342 rList.push_back( new WrappedAxisLabelExistenceProperty( true, 0, spChart2ModelContact ) );//x axis
343 rList.push_back( new WrappedAxisLabelExistenceProperty( true, 1, spChart2ModelContact ) );//y axis
344 rList.push_back( new WrappedAxisLabelExistenceProperty( true, 2, spChart2ModelContact ) );//z axis
345 rList.push_back( new WrappedAxisLabelExistenceProperty( false, 0, spChart2ModelContact ) );//secondary x axis
346 rList.push_back( new WrappedAxisLabelExistenceProperty( false, 1, spChart2ModelContact ) );//secondary y axis
349 WrappedAxisLabelExistenceProperty::WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex
350 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
351 : WrappedProperty(OUString(),OUString())
352 , m_spChart2ModelContact( spChart2ModelContact )
353 , m_bMain( bMain )
354 , m_nDimensionIndex( nDimensionIndex )
356 switch( m_nDimensionIndex )
358 case 0:
359 m_bMain ? m_aOuterName = "HasXAxisDescription" : m_aOuterName = "HasSecondaryXAxisDescription";
360 break;
361 case 2:
362 OSL_ENSURE(m_bMain,"there is no description available for a secondary z axis");
363 m_aOuterName = "HasZAxisDescription";
364 break;
365 default:
366 m_bMain ? m_aOuterName = "HasYAxisDescription" : m_aOuterName = "HasSecondaryYAxisDescription";
367 break;
371 WrappedAxisLabelExistenceProperty::~WrappedAxisLabelExistenceProperty()
375 void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
376 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
378 bool bNewValue = false;
379 if( ! (rOuterValue >>= bNewValue) )
380 throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", 0, 0 );
382 bool bOldValue = false;
383 getPropertyValue( xInnerPropertySet ) >>= bOldValue;
385 if( bOldValue == bNewValue )
386 return;
388 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
389 Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY );
390 if( !xProp.is() && bNewValue )
392 //create axis if needed
393 xProp.set( AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ), uno::UNO_QUERY );
394 if( xProp.is() )
395 xProp->setPropertyValue( "Show", uno::makeAny( sal_False ) );
397 if( xProp.is() )
398 xProp->setPropertyValue( "DisplayLabels", rOuterValue );
401 Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
402 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
404 Any aRet;
405 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
406 Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY );
407 if( xProp.is() )
408 aRet = xProp->getPropertyValue( "DisplayLabels" );
409 else
410 aRet <<= false;
411 return aRet;
414 Any WrappedAxisLabelExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
415 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
417 Any aRet;
418 aRet <<= true;
419 return aRet;
422 } //namespace wrapper
423 } //namespace chart
425 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */