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 "WrappedAutomaticPositionProperties.hxx"
21 #include "FastPropertyIdRanges.hxx"
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <com/sun/star/chart2/RelativePosition.hpp>
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
;
30 using ::com::sun::star::beans::Property
;
37 class WrappedAutomaticPositionProperty
: public WrappedProperty
40 WrappedAutomaticPositionProperty();
41 virtual ~WrappedAutomaticPositionProperty();
43 virtual void setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
44 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
) SAL_OVERRIDE
;
45 virtual Any
getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
46 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) SAL_OVERRIDE
;
47 virtual Any
getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
48 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) SAL_OVERRIDE
;
51 WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
52 : ::chart::WrappedProperty( "AutomaticPosition" , OUString() )
55 WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty()
59 void WrappedAutomaticPositionProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
60 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
62 if( xInnerPropertySet
.is() )
64 bool bNewValue
= true;
65 if( ! (rOuterValue
>>= bNewValue
) )
66 throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", 0, 0 );
72 Any
aRelativePosition( xInnerPropertySet
->getPropertyValue( "RelativePosition" ) );
73 if( aRelativePosition
.hasValue() )
74 xInnerPropertySet
->setPropertyValue( "RelativePosition", Any() );
77 catch( const uno::Exception
& ex
)
79 ASSERT_EXCEPTION( ex
);
84 Any
WrappedAutomaticPositionProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
85 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
87 Any
aRet( getPropertyDefault( Reference
< beans::XPropertyState
>( xInnerPropertySet
, uno::UNO_QUERY
) ) );
88 if( xInnerPropertySet
.is() )
90 Any
aRelativePosition( xInnerPropertySet
->getPropertyValue( "RelativePosition" ) );
91 if( !aRelativePosition
.hasValue() )
97 Any
WrappedAutomaticPositionProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
98 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
109 PROP_CHART_AUTOMATIC_POSITION
= FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP
112 void lcl_addWrappedProperties( std::vector
< WrappedProperty
* >& rList
)
114 rList
.push_back( new WrappedAutomaticPositionProperty() );
117 }//anonymous namespace
119 void WrappedAutomaticPositionProperties::addProperties( ::std::vector
< Property
> & rOutProperties
)
121 rOutProperties
.push_back(
122 Property( "AutomaticPosition",
123 PROP_CHART_AUTOMATIC_POSITION
,
124 cppu::UnoType
<bool>::get(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::MAYBEDEFAULT
));
129 void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector
< WrappedProperty
* >& rList
)
131 lcl_addWrappedProperties( rList
);
134 } //namespace wrapper
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */