merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / controller / chartapiwrapper / WrappedScaleTextProperties.cxx
blobb4c9339f4d6e1415370a1b0ae81bf98960bc2ad0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WrappedScaleTextProperties.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 "WrappedScaleTextProperties.hxx"
34 #include "FastPropertyIdRanges.hxx"
35 #include "macros.hxx"
37 #include <com/sun/star/beans/PropertyAttribute.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 //.............................................................................
47 namespace chart
49 namespace wrapper
52 class WrappedScaleTextProperty : public WrappedProperty
54 public:
55 WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
56 virtual ~WrappedScaleTextProperty();
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);
65 private:
66 ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
69 WrappedScaleTextProperty::WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
70 : ::chart::WrappedProperty( C2U( "ScaleText" ), rtl::OUString() )
71 , m_spChart2ModelContact( spChart2ModelContact )
75 WrappedScaleTextProperty::~WrappedScaleTextProperty()
79 void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
80 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
82 static const OUString aRefSizeName( RTL_CONSTASCII_USTRINGPARAM("ReferencePageSize") );
84 if( xInnerPropertySet.is() )
86 bool bNewValue = false;
87 if( ! (rOuterValue >>= bNewValue) )
89 if( rOuterValue.hasValue() )
90 throw lang::IllegalArgumentException( C2U("Property ScaleText requires value of type boolean"), 0, 0 );
93 try
95 if( bNewValue )
97 awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() );
98 xInnerPropertySet->setPropertyValue( aRefSizeName, uno::makeAny( aRefSize ) );
100 else
101 xInnerPropertySet->setPropertyValue( aRefSizeName, Any() );
103 catch( uno::Exception & ex )
105 ASSERT_EXCEPTION( ex );
110 Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
111 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
113 static const OUString aRefSizeName( RTL_CONSTASCII_USTRINGPARAM("ReferencePageSize") );
115 Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
116 if( xInnerPropertySet.is() )
118 if( xInnerPropertySet->getPropertyValue( aRefSizeName ).hasValue() )
119 aRet <<= true;
120 else
121 aRet <<= false;
124 return aRet;
127 Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
128 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
130 Any aRet;
131 aRet <<= false;
132 return aRet;
135 namespace
137 enum
139 PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP
142 }//anonymous namespace
144 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
147 //static
148 void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties )
150 rOutProperties.push_back(
151 Property( C2U( "ScaleText" ),
152 PROP_CHART_SCALE_TEXT,
153 ::getBooleanCppuType(),
154 beans::PropertyAttribute::MAYBEVOID
155 | beans::PropertyAttribute::MAYBEDEFAULT ));
158 //-----------------------------------------------------------------------------
159 //-----------------------------------------------------------------------------
161 //static
162 void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
163 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
165 rList.push_back( new WrappedScaleTextProperty( spChart2ModelContact ) );
168 } //namespace wrapper
169 } //namespace chart
170 //.............................................................................