Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "WrappedProperty.hxx"
21 : #include "macros.hxx"
22 : #include <com/sun/star/drawing/LineStyle.hpp>
23 :
24 : using namespace ::com::sun::star;
25 : using ::com::sun::star::uno::Any;
26 : using ::com::sun::star::uno::Reference;
27 :
28 : namespace chart
29 : {
30 :
31 168560 : WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName)
32 : : m_aOuterName( rOuterName )
33 168560 : , m_aInnerName( rInnerName )
34 : {
35 168560 : }
36 223321 : WrappedProperty::~WrappedProperty()
37 : {
38 223321 : }
39 :
40 151830 : OUString WrappedProperty::getInnerName() const
41 : {
42 151830 : return m_aInnerName;
43 : }
44 :
45 77809 : Any WrappedProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
46 : {
47 77809 : return rInnerValue;
48 : }
49 2773 : Any WrappedProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
50 : {
51 2773 : return rOuterValue;
52 : }
53 :
54 2474 : void WrappedProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
55 : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
56 : {
57 2474 : if(xInnerPropertySet.is())
58 2474 : xInnerPropertySet->setPropertyValue( this->getInnerName(), this->convertOuterToInnerValue( rOuterValue ) );
59 2474 : }
60 :
61 69279 : Any WrappedProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
62 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
63 : {
64 69279 : Any aRet;
65 69279 : if( xInnerPropertySet.is() )
66 : {
67 69271 : aRet = xInnerPropertySet->getPropertyValue( this->getInnerName() );
68 69271 : aRet = this->convertInnerToOuterValue( aRet );
69 : }
70 69279 : return aRet;
71 : }
72 :
73 0 : void WrappedProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
74 : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
75 : {
76 0 : if( xInnerPropertyState.is() && !this->getInnerName().isEmpty() )
77 0 : xInnerPropertyState->setPropertyToDefault(this->getInnerName());
78 : else
79 : {
80 0 : Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
81 0 : setPropertyValue( getPropertyDefault( xInnerPropertyState ), xInnerProp );
82 : }
83 0 : }
84 :
85 9520 : Any WrappedProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
86 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
87 : {
88 9520 : Any aRet;
89 9520 : if( xInnerPropertyState.is() )
90 : {
91 9520 : aRet = xInnerPropertyState->getPropertyDefault( this->getInnerName() );
92 9520 : aRet = this->convertInnerToOuterValue( aRet );
93 : }
94 9520 : return aRet;
95 : }
96 :
97 80156 : beans::PropertyState WrappedProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
98 : throw (beans::UnknownPropertyException, uno::RuntimeException)
99 : {
100 80156 : beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE;
101 80156 : OUString aInnerName( this->getInnerName() );
102 80156 : if( xInnerPropertyState.is() && !aInnerName.isEmpty() )
103 43284 : aState = xInnerPropertyState->getPropertyState( aInnerName );
104 : else
105 : {
106 : try
107 : {
108 36872 : Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
109 73744 : uno::Any aValue = this->getPropertyValue( xInnerProp );
110 36872 : if( !aValue.hasValue() )
111 0 : aState = beans::PropertyState_DEFAULT_VALUE;
112 : else
113 : {
114 36872 : uno::Any aDefault = this->getPropertyDefault( xInnerPropertyState );
115 36872 : if( aValue == aDefault )
116 24158 : aState = beans::PropertyState_DEFAULT_VALUE;
117 36872 : }
118 : }
119 0 : catch( const beans::UnknownPropertyException& ex )
120 : {
121 : ASSERT_EXCEPTION( ex );
122 : }
123 : }
124 80156 : return aState;
125 : }
126 :
127 : } //namespace chart
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|