update dev300-m58
[ooovba.git] / configmgr / source / misc / propertysethelper.cxx
blob1d68423605b6df0816514089d8022095bf130710
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: propertysethelper.cxx,v $
10 * $Revision: 1.5 $
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_configmgr.hxx"
34 #include "propertysethelper.hxx"
35 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include <cppuhelper/typeprovider.hxx>
39 //..........................................................................
40 namespace configmgr {
41 namespace apihelper {
42 //..........................................................................
43 namespace uno = com::sun::star::uno;
44 namespace lang = com::sun::star::lang;
45 namespace beans = com::sun::star::beans;
46 //..........................................................................
47 PropertySetHelper::PropertySetHelper()
48 : BroadcasterBase()
49 , cppu::OWeakObject()
50 , cppu::OPropertySetHelper( BroadcasterBase::getBroadcastHelper() )
51 , m_pHelper(0)
55 //..........................................................................
56 PropertySetHelper::~PropertySetHelper()
58 delete m_pHelper;
61 //..........................................................................
62 // XInterface
63 uno::Any SAL_CALL PropertySetHelper::queryInterface( uno::Type const & rType ) throw (uno::RuntimeException)
65 uno::Any aResult = cppu::OPropertySetHelper::queryInterface(rType);
66 if (!aResult.hasValue())
67 aResult = OWeakObject::queryInterface(rType);
68 return aResult;
71 void SAL_CALL PropertySetHelper::acquire() throw ()
73 OWeakObject::acquire();
76 void SAL_CALL PropertySetHelper::release() throw ()
78 if (m_refCount == 1)
79 this->disposing();
81 OWeakObject::release();
84 //..........................................................................
85 // XTypeProvider
86 uno::Sequence< uno::Type > SAL_CALL PropertySetHelper::getTypes() throw (uno::RuntimeException)
88 // could be static instance
89 cppu::OTypeCollection aTypes(
90 ::getCppuType( static_cast< uno::Reference< beans::XPropertySet > const * >(0) ),
91 ::getCppuType( static_cast< uno::Reference< beans::XMultiPropertySet > const * >(0) ),
92 ::getCppuType( static_cast< uno::Reference< beans::XFastPropertySet > const * >(0) ),
93 ::getCppuType( static_cast< uno::Reference< lang::XTypeProvider > const * >(0) ) );
95 return aTypes.getTypes();
98 //..........................................................................
99 // cppu::OPropertySetHelper
100 uno::Reference< beans::XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo( )
101 throw (uno::RuntimeException)
103 return createPropertySetInfo(getInfoHelper());
106 //..........................................................................
107 cppu::IPropertyArrayHelper & SAL_CALL PropertySetHelper::getInfoHelper()
109 osl::MutexGuard aGuard( getBroadcastMutex() );
110 if (!m_pHelper)
111 m_pHelper = newInfoHelper();
113 OSL_ENSURE(m_pHelper,"Derived class did not create new PropertyInfoHelper");
114 if (!m_pHelper)
115 throw uno::RuntimeException(rtl::OUString::createFromAscii("No PropertyArrayHelper available"),*this);
117 return *m_pHelper;
120 //..........................................................................
121 sal_Bool SAL_CALL PropertySetHelper::convertFastPropertyValue(
122 uno::Any & rConvertedValue, uno::Any & rOldValue, sal_Int32 nHandle, const uno::Any& rValue )
123 throw (lang::IllegalArgumentException)
125 this->getFastPropertyValue(rOldValue, nHandle);
126 rConvertedValue = rValue;
127 return rValue.isExtractableTo( rOldValue.getValueType() );
129 //..........................................................................
130 } // namespace apihelper
131 } // namespace configmgr
132 //..........................................................................