1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WrappedAutomaticPositionProperties.cxx,v $
10 * $Revision: 1.1.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_chart2.hxx"
33 #include "WrappedAutomaticPositionProperties.hxx"
34 #include "FastPropertyIdRanges.hxx"
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #include <com/sun/star/chart2/RelativePosition.hpp>
39 using namespace ::com::sun::star
;
40 using ::com::sun::star::uno::Any
;
41 using ::com::sun::star::uno::Reference
;
42 using ::com::sun::star::uno::Sequence
;
43 using ::com::sun::star::beans::Property
;
44 using ::rtl::OUString
;
46 //.............................................................................
52 class WrappedAutomaticPositionProperty
: public WrappedProperty
55 WrappedAutomaticPositionProperty();
56 virtual ~WrappedAutomaticPositionProperty();
58 virtual void setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
59 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
);
60 virtual Any
getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
61 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
);
62 virtual Any
getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
63 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
);
66 WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
67 : ::chart::WrappedProperty( C2U( "AutomaticPosition" ), rtl::OUString() )
70 WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty()
74 void WrappedAutomaticPositionProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
75 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
77 if( xInnerPropertySet
.is() )
79 bool bNewValue
= true;
80 if( ! (rOuterValue
>>= bNewValue
) )
81 throw lang::IllegalArgumentException( C2U("Property AutomaticPosition requires value of type boolean"), 0, 0 );
87 Any
aRelativePosition( xInnerPropertySet
->getPropertyValue( C2U( "RelativePosition" ) ) );
88 if( aRelativePosition
.hasValue() )
89 xInnerPropertySet
->setPropertyValue( C2U( "RelativePosition" ), Any() );
92 catch( uno::Exception
& ex
)
94 ASSERT_EXCEPTION( ex
);
99 Any
WrappedAutomaticPositionProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
100 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
102 Any
aRet( getPropertyDefault( Reference
< beans::XPropertyState
>( xInnerPropertySet
, uno::UNO_QUERY
) ) );
103 if( xInnerPropertySet
.is() )
105 Any
aRelativePosition( xInnerPropertySet
->getPropertyValue( C2U( "RelativePosition" ) ) );
106 if( !aRelativePosition
.hasValue() )
112 Any
WrappedAutomaticPositionProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
113 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
124 PROP_CHART_AUTOMATIC_POSITION
= FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP
127 void lcl_addWrappedProperties( std::vector
< WrappedProperty
* >& rList
)
129 rList
.push_back( new WrappedAutomaticPositionProperty() );
132 }//anonymous namespace
134 //-----------------------------------------------------------------------------
135 //-----------------------------------------------------------------------------
136 //-----------------------------------------------------------------------------
138 void WrappedAutomaticPositionProperties::addProperties( ::std::vector
< Property
> & rOutProperties
)
140 rOutProperties
.push_back(
141 Property( C2U( "AutomaticPosition" ),
142 PROP_CHART_AUTOMATIC_POSITION
,
143 ::getBooleanCppuType(),
144 beans::PropertyAttribute::BOUND
145 | beans::PropertyAttribute::MAYBEDEFAULT
));
148 //-----------------------------------------------------------------------------
149 //-----------------------------------------------------------------------------
152 void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector
< WrappedProperty
* >& rList
)
154 lcl_addWrappedProperties( rList
);
157 } //namespace wrapper
159 //.............................................................................