merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / tools / WrappedProperty.cxx
blobb41d8a331f1153a2527bd8631995a6adf500e15a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "WrappedProperty.hxx"
32 #include "macros.hxx"
33 #include <com/sun/star/drawing/LineStyle.hpp>
35 using namespace ::com::sun::star;
36 using ::com::sun::star::uno::Any;
37 using ::com::sun::star::uno::Reference;
38 using ::rtl::OUString;
41 //.............................................................................
42 namespace chart
44 //.............................................................................
46 WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName)
47 : m_aOuterName( rOuterName )
48 , m_aInnerName( rInnerName )
51 WrappedProperty::~WrappedProperty()
55 const OUString& WrappedProperty::getOuterName() const
57 return m_aOuterName;
60 //virtual
61 ::rtl::OUString WrappedProperty::getInnerName() const
63 return m_aInnerName;
66 Any WrappedProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
68 return rInnerValue;
70 Any WrappedProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
72 return rOuterValue;
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)
78 if(xInnerPropertySet.is())
79 xInnerPropertySet->setPropertyValue( this->getInnerName(), this->convertOuterToInnerValue( rOuterValue ) );
82 Any WrappedProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
83 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
85 Any aRet;
86 if( xInnerPropertySet.is() )
88 aRet = xInnerPropertySet->getPropertyValue( this->getInnerName() );
89 aRet = this->convertInnerToOuterValue( aRet );
91 return aRet;
94 void WrappedProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
95 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
97 if( xInnerPropertyState.is() && this->getInnerName().getLength() )
98 xInnerPropertyState->setPropertyToDefault(this->getInnerName());
99 else
101 Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
102 setPropertyValue( getPropertyDefault( xInnerPropertyState ), xInnerProp );
106 Any WrappedProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
107 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
109 Any aRet;
110 if( xInnerPropertyState.is() )
112 aRet = xInnerPropertyState->getPropertyDefault( this->getInnerName() );
113 aRet = this->convertInnerToOuterValue( aRet );
115 return aRet;
118 beans::PropertyState WrappedProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
119 throw (beans::UnknownPropertyException, uno::RuntimeException)
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
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
135 uno::Any aDefault = this->getPropertyDefault( xInnerPropertyState );
136 if( aValue == aDefault )
137 aState = beans::PropertyState_DEFAULT_VALUE;
140 catch( beans::UnknownPropertyException& ex )
142 ASSERT_EXCEPTION( ex );
145 return aState;
148 //.............................................................................
149 } //namespace chart
150 //.............................................................................