1cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5cde9e8dcSAndrew Rist * distributed with this work for additional information
6cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10cde9e8dcSAndrew Rist *
11cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cde9e8dcSAndrew Rist *
13cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18cde9e8dcSAndrew Rist * under the License.
19cde9e8dcSAndrew Rist *
20cde9e8dcSAndrew Rist *************************************************************/
21cde9e8dcSAndrew Rist
22cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "WrappedProperty.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
30cdf0e10cSrcweir
31cdf0e10cSrcweir using namespace ::com::sun::star;
32cdf0e10cSrcweir using ::com::sun::star::uno::Any;
33cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir
36cdf0e10cSrcweir
37cdf0e10cSrcweir //.............................................................................
38cdf0e10cSrcweir namespace chart
39cdf0e10cSrcweir {
40cdf0e10cSrcweir //.............................................................................
41cdf0e10cSrcweir
WrappedProperty(const OUString & rOuterName,const OUString & rInnerName)42cdf0e10cSrcweir WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName)
43cdf0e10cSrcweir : m_aOuterName( rOuterName )
44cdf0e10cSrcweir , m_aInnerName( rInnerName )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
~WrappedProperty()47cdf0e10cSrcweir WrappedProperty::~WrappedProperty()
48cdf0e10cSrcweir {
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
getOuterName() const51cdf0e10cSrcweir const OUString& WrappedProperty::getOuterName() const
52cdf0e10cSrcweir {
53cdf0e10cSrcweir return m_aOuterName;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir
56cdf0e10cSrcweir //virtual
getInnerName() const57cdf0e10cSrcweir ::rtl::OUString WrappedProperty::getInnerName() const
58cdf0e10cSrcweir {
59cdf0e10cSrcweir return m_aInnerName;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
convertInnerToOuterValue(const Any & rInnerValue) const62cdf0e10cSrcweir Any WrappedProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
63cdf0e10cSrcweir {
64cdf0e10cSrcweir return rInnerValue;
65cdf0e10cSrcweir }
convertOuterToInnerValue(const Any & rOuterValue) const66cdf0e10cSrcweir Any WrappedProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
67cdf0e10cSrcweir {
68cdf0e10cSrcweir return rOuterValue;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
setPropertyValue(const Any & rOuterValue,const Reference<beans::XPropertySet> & xInnerPropertySet) const71cdf0e10cSrcweir void WrappedProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
72cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir if(xInnerPropertySet.is())
75cdf0e10cSrcweir xInnerPropertySet->setPropertyValue( this->getInnerName(), this->convertOuterToInnerValue( rOuterValue ) );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
getPropertyValue(const Reference<beans::XPropertySet> & xInnerPropertySet) const78cdf0e10cSrcweir Any WrappedProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
79cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir Any aRet;
82cdf0e10cSrcweir if( xInnerPropertySet.is() )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir aRet = xInnerPropertySet->getPropertyValue( this->getInnerName() );
85cdf0e10cSrcweir aRet = this->convertInnerToOuterValue( aRet );
86cdf0e10cSrcweir }
87cdf0e10cSrcweir return aRet;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
setPropertyToDefault(const Reference<beans::XPropertyState> & xInnerPropertyState) const90cdf0e10cSrcweir void WrappedProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
91cdf0e10cSrcweir throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
92cdf0e10cSrcweir {
93*9ec58d04SHerbert Dürr if( xInnerPropertyState.is() && !this->getInnerName().isEmpty() )
94cdf0e10cSrcweir xInnerPropertyState->setPropertyToDefault(this->getInnerName());
95cdf0e10cSrcweir else
96cdf0e10cSrcweir {
97cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
98cdf0e10cSrcweir setPropertyValue( getPropertyDefault( xInnerPropertyState ), xInnerProp );
99cdf0e10cSrcweir }
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
getPropertyDefault(const Reference<beans::XPropertyState> & xInnerPropertyState) const102cdf0e10cSrcweir Any WrappedProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
103cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir Any aRet;
106cdf0e10cSrcweir if( xInnerPropertyState.is() )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir aRet = xInnerPropertyState->getPropertyDefault( this->getInnerName() );
109cdf0e10cSrcweir aRet = this->convertInnerToOuterValue( aRet );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir return aRet;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
getPropertyState(const Reference<beans::XPropertyState> & xInnerPropertyState) const114cdf0e10cSrcweir beans::PropertyState WrappedProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
115cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE;
118cdf0e10cSrcweir rtl::OUString aInnerName( this->getInnerName() );
119*9ec58d04SHerbert Dürr if( xInnerPropertyState.is() && !aInnerName.isEmpty() )
120cdf0e10cSrcweir aState = xInnerPropertyState->getPropertyState( aInnerName );
121cdf0e10cSrcweir else
122cdf0e10cSrcweir {
123cdf0e10cSrcweir try
124cdf0e10cSrcweir {
125cdf0e10cSrcweir Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
126cdf0e10cSrcweir uno::Any aValue = this->getPropertyValue( xInnerProp );
127cdf0e10cSrcweir if( !aValue.hasValue() )
128cdf0e10cSrcweir aState = beans::PropertyState_DEFAULT_VALUE;
129cdf0e10cSrcweir else
130cdf0e10cSrcweir {
131cdf0e10cSrcweir uno::Any aDefault = this->getPropertyDefault( xInnerPropertyState );
132cdf0e10cSrcweir if( aValue == aDefault )
133cdf0e10cSrcweir aState = beans::PropertyState_DEFAULT_VALUE;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir catch( beans::UnknownPropertyException& ex )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir }
141cdf0e10cSrcweir return aState;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir //.............................................................................
145cdf0e10cSrcweir } //namespace chart
146cdf0e10cSrcweir //.............................................................................
147