1*cde9e8dcSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*cde9e8dcSAndrew Rist * distributed with this work for additional information 6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance 9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an 15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the 17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations 18*cde9e8dcSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*cde9e8dcSAndrew Rist *************************************************************/ 21*cde9e8dcSAndrew Rist 22*cde9e8dcSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_chart2.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "WrappedScaleTextProperties.hxx" 27cdf0e10cSrcweir #include "FastPropertyIdRanges.hxx" 28cdf0e10cSrcweir #include "macros.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir using namespace ::com::sun::star; 33cdf0e10cSrcweir using ::com::sun::star::uno::Any; 34cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 35cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 36cdf0e10cSrcweir using ::com::sun::star::beans::Property; 37cdf0e10cSrcweir using ::rtl::OUString; 38cdf0e10cSrcweir 39cdf0e10cSrcweir //............................................................................. 40cdf0e10cSrcweir namespace chart 41cdf0e10cSrcweir { 42cdf0e10cSrcweir namespace wrapper 43cdf0e10cSrcweir { 44cdf0e10cSrcweir 45cdf0e10cSrcweir class WrappedScaleTextProperty : public WrappedProperty 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); 49cdf0e10cSrcweir virtual ~WrappedScaleTextProperty(); 50cdf0e10cSrcweir 51cdf0e10cSrcweir virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 52cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); 53cdf0e10cSrcweir virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 54cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 55cdf0e10cSrcweir virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 56cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 57cdf0e10cSrcweir 58cdf0e10cSrcweir private: 59cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; 60cdf0e10cSrcweir }; 61cdf0e10cSrcweir 62cdf0e10cSrcweir WrappedScaleTextProperty::WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) 63cdf0e10cSrcweir : ::chart::WrappedProperty( C2U( "ScaleText" ), rtl::OUString() ) 64cdf0e10cSrcweir , m_spChart2ModelContact( spChart2ModelContact ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir WrappedScaleTextProperty::~WrappedScaleTextProperty() 69cdf0e10cSrcweir { 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 73cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir static const OUString aRefSizeName( RTL_CONSTASCII_USTRINGPARAM("ReferencePageSize") ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir if( xInnerPropertySet.is() ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir bool bNewValue = false; 80cdf0e10cSrcweir if( ! (rOuterValue >>= bNewValue) ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir if( rOuterValue.hasValue() ) 83cdf0e10cSrcweir throw lang::IllegalArgumentException( C2U("Property ScaleText requires value of type boolean"), 0, 0 ); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir try 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if( bNewValue ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() ); 91cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( aRefSizeName, uno::makeAny( aRefSize ) ); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir else 94cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( aRefSizeName, Any() ); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir catch( uno::Exception & ex ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir } 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 104cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir static const OUString aRefSizeName( RTL_CONSTASCII_USTRINGPARAM("ReferencePageSize") ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); 109cdf0e10cSrcweir if( xInnerPropertySet.is() ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir if( xInnerPropertySet->getPropertyValue( aRefSizeName ).hasValue() ) 112cdf0e10cSrcweir aRet <<= true; 113cdf0e10cSrcweir else 114cdf0e10cSrcweir aRet <<= false; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir return aRet; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const 121cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir Any aRet; 124cdf0e10cSrcweir aRet <<= false; 125cdf0e10cSrcweir return aRet; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir namespace 129cdf0e10cSrcweir { 130cdf0e10cSrcweir enum 131cdf0e10cSrcweir { 132cdf0e10cSrcweir PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP 133cdf0e10cSrcweir }; 134cdf0e10cSrcweir 135cdf0e10cSrcweir }//anonymous namespace 136cdf0e10cSrcweir 137cdf0e10cSrcweir //----------------------------------------------------------------------------- 138cdf0e10cSrcweir //----------------------------------------------------------------------------- 139cdf0e10cSrcweir //----------------------------------------------------------------------------- 140cdf0e10cSrcweir void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir rOutProperties.push_back( 143cdf0e10cSrcweir Property( C2U( "ScaleText" ), 144cdf0e10cSrcweir PROP_CHART_SCALE_TEXT, 145cdf0e10cSrcweir ::getBooleanCppuType(), 146cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 147cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir //----------------------------------------------------------------------------- 151cdf0e10cSrcweir //----------------------------------------------------------------------------- 152cdf0e10cSrcweir 153cdf0e10cSrcweir void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList 154cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir rList.push_back( new WrappedScaleTextProperty( spChart2ModelContact ) ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir } //namespace wrapper 160cdf0e10cSrcweir } //namespace chart 161cdf0e10cSrcweir //............................................................................. 162