update dev300-m58
[ooovba.git] / chart2 / source / tools / WrappedDefaultProperty.cxx
blob5c98917c498631fe77c9c9923031ab4025b7e438
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WrappedDefaultProperty.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "WrappedDefaultProperty.hxx"
35 #include "macros.hxx"
37 using namespace ::com::sun::star;
39 using ::com::sun::star::uno::Reference;
40 using ::com::sun::star::uno::Sequence;
41 using ::rtl::OUString;
43 namespace chart
46 WrappedDefaultProperty::WrappedDefaultProperty(
47 const OUString& rOuterName, const OUString& rInnerName,
48 const uno::Any& rNewOuterDefault ) :
49 WrappedProperty( rOuterName, rInnerName ),
50 m_aOuterDefaultValue( rNewOuterDefault )
53 WrappedDefaultProperty::~WrappedDefaultProperty()
56 void WrappedDefaultProperty::setPropertyToDefault(
57 const Reference< beans::XPropertyState >& xInnerPropertyState ) const
58 throw (beans::UnknownPropertyException,
59 uno::RuntimeException)
61 Reference< beans::XPropertySet > xInnerPropSet( xInnerPropertyState, uno::UNO_QUERY );
62 if( xInnerPropSet.is())
63 this->setPropertyValue( m_aOuterDefaultValue, xInnerPropSet );
66 uno::Any WrappedDefaultProperty::getPropertyDefault(
67 const Reference< beans::XPropertyState >& /* xInnerPropertyState */ ) const
68 throw (beans::UnknownPropertyException,
69 lang::WrappedTargetException,
70 uno::RuntimeException)
72 return m_aOuterDefaultValue;
75 beans::PropertyState WrappedDefaultProperty::getPropertyState(
76 const Reference< beans::XPropertyState >& xInnerPropertyState ) const
77 throw (beans::UnknownPropertyException,
78 uno::RuntimeException)
80 beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE;
81 try
83 Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY_THROW );
84 uno::Any aValue = this->getPropertyValue( xInnerProp );
85 if( m_aOuterDefaultValue == this->convertInnerToOuterValue( aValue ))
86 aState = beans::PropertyState_DEFAULT_VALUE;
88 catch( beans::UnknownPropertyException& ex )
90 ASSERT_EXCEPTION( ex );
92 return aState;
95 } // namespace chart