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