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