1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
;
36 class WrappedAxisAndGridExistenceProperty
: public WrappedProperty
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
;
53 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
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
)
83 , m_nDimensionIndex( nDimensionIndex
)
85 switch( m_nDimensionIndex
)
92 m_aOuterName
= "HasXAxis";
94 m_aOuterName
= "HasSecondaryXAxis";
99 m_aOuterName
= "HasXAxisGrid";
101 m_aOuterName
= "HasXAxisHelpGrid";
109 OSL_ENSURE(m_bMain
,"there is no secondary z axis at the old api");
111 m_aOuterName
= "HasZAxis";
116 m_aOuterName
= "HasZAxisGrid";
118 m_aOuterName
= "HasZAxisHelpGrid";
127 m_aOuterName
= "HasYAxis";
129 m_aOuterName
= "HasSecondaryYAxis";
134 m_aOuterName
= "HasYAxisGrid";
136 m_aOuterName
= "HasYAxisHelpGrid";
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
)
160 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
164 AxisHelper::showAxis( m_nDimensionIndex
, m_bMain
, xDiagram
, m_spChart2ModelContact
->m_xContext
);
166 AxisHelper::showGrid( m_nDimensionIndex
, 0, m_bMain
, xDiagram
, m_spChart2ModelContact
->m_xContext
);
171 AxisHelper::hideAxis( m_nDimensionIndex
, m_bMain
, xDiagram
);
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
)
181 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
184 bool bShown
= AxisHelper::isAxisShown( m_nDimensionIndex
, m_bMain
, xDiagram
);
189 bool bShown
= AxisHelper::isGridShown( m_nDimensionIndex
, 0, m_bMain
, xDiagram
);
195 Any
WrappedAxisAndGridExistenceProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
196 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
203 class WrappedAxisTitleExistenceProperty
: public WrappedProperty
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
;
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
)
243 m_aOuterName
= "HasXAxisTitle";
244 m_eTitleType
= TitleHelper::X_AXIS_TITLE
;
247 m_aOuterName
= "HasZAxisTitle";
248 m_eTitleType
= TitleHelper::Z_AXIS_TITLE
;
251 m_aOuterName
= "HasSecondaryXAxisTitle";
252 m_eTitleType
= TitleHelper::SECONDARY_X_AXIS_TITLE
;
255 m_aOuterName
= "HasSecondaryYAxisTitle";
256 m_eTitleType
= TitleHelper::SECONDARY_Y_AXIS_TITLE
;
259 m_aOuterName
= "HasYAxisTitle";
260 m_eTitleType
= TitleHelper::Y_AXIS_TITLE
;
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
)
285 TitleHelper::createTitle( m_eTitleType
, aTitleText
286 , m_spChart2ModelContact
->getChartModel(), m_spChart2ModelContact
->m_xContext
);
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() )
309 Any
WrappedAxisTitleExistenceProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
310 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
317 class WrappedAxisLabelExistenceProperty
: public WrappedProperty
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
;
334 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
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
)
354 , m_nDimensionIndex( nDimensionIndex
)
356 switch( m_nDimensionIndex
)
359 m_bMain
? m_aOuterName
= "HasXAxisDescription" : m_aOuterName
= "HasSecondaryXAxisDescription";
362 OSL_ENSURE(m_bMain
,"there is no description available for a secondary z axis");
363 m_aOuterName
= "HasZAxisDescription";
366 m_bMain
? m_aOuterName
= "HasYAxisDescription" : m_aOuterName
= "HasSecondaryYAxisDescription";
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
)
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
);
395 xProp
->setPropertyValue( "Show", uno::makeAny( sal_False
) );
398 xProp
->setPropertyValue( "DisplayLabels", rOuterValue
);
401 Any
WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
402 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
405 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
406 Reference
< beans::XPropertySet
> xProp( AxisHelper::getAxis( m_nDimensionIndex
, m_bMain
, xDiagram
), uno::UNO_QUERY
);
408 aRet
= xProp
->getPropertyValue( "DisplayLabels" );
414 Any
WrappedAxisLabelExistenceProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
415 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
422 } //namespace wrapper
425 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */