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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_chart2.hxx" 30 31 #include "WrappedProperty.hxx" 32 #include "macros.hxx" 33 #include <com/sun/star/drawing/LineStyle.hpp> 34 35 using namespace ::com::sun::star; 36 using ::com::sun::star::uno::Any; 37 using ::com::sun::star::uno::Reference; 38 using ::rtl::OUString; 39 40 41 //............................................................................. 42 namespace chart 43 { 44 //............................................................................. 45 46 WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName) 47 : m_aOuterName( rOuterName ) 48 , m_aInnerName( rInnerName ) 49 { 50 } 51 WrappedProperty::~WrappedProperty() 52 { 53 } 54 55 const OUString& WrappedProperty::getOuterName() const 56 { 57 return m_aOuterName; 58 } 59 60 //virtual 61 ::rtl::OUString WrappedProperty::getInnerName() const 62 { 63 return m_aInnerName; 64 } 65 66 Any WrappedProperty::convertInnerToOuterValue( const Any& rInnerValue ) const 67 { 68 return rInnerValue; 69 } 70 Any WrappedProperty::convertOuterToInnerValue( const Any& rOuterValue ) const 71 { 72 return rOuterValue; 73 } 74 75 void WrappedProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const 76 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 77 { 78 if(xInnerPropertySet.is()) 79 xInnerPropertySet->setPropertyValue( this->getInnerName(), this->convertOuterToInnerValue( rOuterValue ) ); 80 } 81 82 Any WrappedProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 83 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 84 { 85 Any aRet; 86 if( xInnerPropertySet.is() ) 87 { 88 aRet = xInnerPropertySet->getPropertyValue( this->getInnerName() ); 89 aRet = this->convertInnerToOuterValue( aRet ); 90 } 91 return aRet; 92 } 93 94 void WrappedProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 95 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) 96 { 97 if( xInnerPropertyState.is() && this->getInnerName().getLength() ) 98 xInnerPropertyState->setPropertyToDefault(this->getInnerName()); 99 else 100 { 101 Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY ); 102 setPropertyValue( getPropertyDefault( xInnerPropertyState ), xInnerProp ); 103 } 104 } 105 106 Any WrappedProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 107 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 108 { 109 Any aRet; 110 if( xInnerPropertyState.is() ) 111 { 112 aRet = xInnerPropertyState->getPropertyDefault( this->getInnerName() ); 113 aRet = this->convertInnerToOuterValue( aRet ); 114 } 115 return aRet; 116 } 117 118 beans::PropertyState WrappedProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 119 throw (beans::UnknownPropertyException, uno::RuntimeException) 120 { 121 beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE; 122 rtl::OUString aInnerName( this->getInnerName() ); 123 if( xInnerPropertyState.is() && aInnerName.getLength() ) 124 aState = xInnerPropertyState->getPropertyState( aInnerName ); 125 else 126 { 127 try 128 { 129 Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY ); 130 uno::Any aValue = this->getPropertyValue( xInnerProp ); 131 if( !aValue.hasValue() ) 132 aState = beans::PropertyState_DEFAULT_VALUE; 133 else 134 { 135 uno::Any aDefault = this->getPropertyDefault( xInnerPropertyState ); 136 if( aValue == aDefault ) 137 aState = beans::PropertyState_DEFAULT_VALUE; 138 } 139 } 140 catch( beans::UnknownPropertyException& ex ) 141 { 142 ASSERT_EXCEPTION( ex ); 143 } 144 } 145 return aState; 146 } 147 148 //............................................................................. 149 } //namespace chart 150 //............................................................................. 151