1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_chart2.hxx" 29 30 #include "WrappedAutomaticPositionProperties.hxx" 31 #include "FastPropertyIdRanges.hxx" 32 #include "macros.hxx" 33 #include <com/sun/star/beans/PropertyAttribute.hpp> 34 #include <com/sun/star/chart2/RelativePosition.hpp> 35 36 using namespace ::com::sun::star; 37 using ::com::sun::star::uno::Any; 38 using ::com::sun::star::uno::Reference; 39 using ::com::sun::star::uno::Sequence; 40 using ::com::sun::star::beans::Property; 41 using ::rtl::OUString; 42 43 //............................................................................. 44 namespace chart 45 { 46 namespace wrapper 47 { 48 49 class WrappedAutomaticPositionProperty : public WrappedProperty 50 { 51 public: 52 WrappedAutomaticPositionProperty(); 53 virtual ~WrappedAutomaticPositionProperty(); 54 55 virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 56 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); 57 virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 58 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 59 virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 60 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 61 }; 62 63 WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty() 64 : ::chart::WrappedProperty( C2U( "AutomaticPosition" ), rtl::OUString() ) 65 { 66 } 67 WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty() 68 { 69 } 70 71 void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 72 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 73 { 74 if( xInnerPropertySet.is() ) 75 { 76 bool bNewValue = true; 77 if( ! (rOuterValue >>= bNewValue) ) 78 throw lang::IllegalArgumentException( C2U("Property AutomaticPosition requires value of type boolean"), 0, 0 ); 79 80 try 81 { 82 if( bNewValue ) 83 { 84 Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) ); 85 if( aRelativePosition.hasValue() ) 86 xInnerPropertySet->setPropertyValue( C2U( "RelativePosition" ), Any() ); 87 } 88 } 89 catch( uno::Exception & ex ) 90 { 91 ASSERT_EXCEPTION( ex ); 92 } 93 } 94 } 95 96 Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 97 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 98 { 99 Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); 100 if( xInnerPropertySet.is() ) 101 { 102 Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) ); 103 if( !aRelativePosition.hasValue() ) 104 aRet <<= true; 105 } 106 return aRet; 107 } 108 109 Any WrappedAutomaticPositionProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const 110 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 111 { 112 Any aRet; 113 aRet <<= false; 114 return aRet; 115 } 116 117 namespace 118 { 119 enum 120 { 121 PROP_CHART_AUTOMATIC_POSITION = FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP 122 }; 123 124 void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList ) 125 { 126 rList.push_back( new WrappedAutomaticPositionProperty() ); 127 } 128 129 }//anonymous namespace 130 131 //----------------------------------------------------------------------------- 132 //----------------------------------------------------------------------------- 133 //----------------------------------------------------------------------------- 134 void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property > & rOutProperties ) 135 { 136 rOutProperties.push_back( 137 Property( C2U( "AutomaticPosition" ), 138 PROP_CHART_AUTOMATIC_POSITION, 139 ::getBooleanCppuType(), 140 beans::PropertyAttribute::BOUND 141 | beans::PropertyAttribute::MAYBEDEFAULT )); 142 } 143 144 //----------------------------------------------------------------------------- 145 //----------------------------------------------------------------------------- 146 147 void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList ) 148 { 149 lcl_addWrappedProperties( rList ); 150 } 151 152 } //namespace wrapper 153 } //namespace chart 154 //............................................................................. 155