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