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 "WrappedDefaultProperty.hxx"
21 : #include "macros.hxx"
22 :
23 : using namespace ::com::sun::star;
24 :
25 : using ::com::sun::star::uno::Reference;
26 : using ::com::sun::star::uno::Sequence;
27 :
28 : namespace chart
29 : {
30 :
31 0 : WrappedDefaultProperty::WrappedDefaultProperty(
32 : const OUString& rOuterName, const OUString& rInnerName,
33 : const uno::Any& rNewOuterDefault ) :
34 : WrappedProperty( rOuterName, rInnerName ),
35 0 : m_aOuterDefaultValue( rNewOuterDefault )
36 0 : {}
37 :
38 0 : WrappedDefaultProperty::~WrappedDefaultProperty()
39 0 : {}
40 :
41 0 : void WrappedDefaultProperty::setPropertyToDefault(
42 : const Reference< beans::XPropertyState >& xInnerPropertyState ) const
43 : throw (beans::UnknownPropertyException,
44 : uno::RuntimeException)
45 : {
46 0 : Reference< beans::XPropertySet > xInnerPropSet( xInnerPropertyState, uno::UNO_QUERY );
47 0 : if( xInnerPropSet.is())
48 0 : this->setPropertyValue( m_aOuterDefaultValue, xInnerPropSet );
49 0 : }
50 :
51 0 : uno::Any WrappedDefaultProperty::getPropertyDefault(
52 : const Reference< beans::XPropertyState >& /* xInnerPropertyState */ ) const
53 : throw (beans::UnknownPropertyException,
54 : lang::WrappedTargetException,
55 : uno::RuntimeException)
56 : {
57 0 : return m_aOuterDefaultValue;
58 : }
59 :
60 0 : beans::PropertyState WrappedDefaultProperty::getPropertyState(
61 : const Reference< beans::XPropertyState >& xInnerPropertyState ) const
62 : throw (beans::UnknownPropertyException,
63 : uno::RuntimeException)
64 : {
65 0 : beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE;
66 : try
67 : {
68 0 : Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY_THROW );
69 0 : uno::Any aValue = this->getPropertyValue( xInnerProp );
70 0 : if( m_aOuterDefaultValue == this->convertInnerToOuterValue( aValue ))
71 0 : aState = beans::PropertyState_DEFAULT_VALUE;
72 : }
73 0 : catch( const beans::UnknownPropertyException& ex )
74 : {
75 : ASSERT_EXCEPTION( ex );
76 : }
77 0 : return aState;
78 : }
79 :
80 : } // namespace chart
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|