update dev300-m58
[ooovba.git] / configmgr / source / api2 / setupdate.cxx
blob2dff6a99f40ba3d69bf4b6e21312f2d9308e184f
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: setupdate.cxx,v $
10 * $Revision: 1.7 $
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 "setupdate.hxx"
35 #include "accessimpl.hxx"
36 #include "updateimpl.hxx"
37 #include "apinodeupdate.hxx"
38 #include "apitypes.hxx"
39 #include <cppuhelper/queryinterface.hxx>
40 #include <cppuhelper/typeprovider.hxx>
42 namespace configmgr
44 //////////////////////////////////////////////////////////////////////////////////
45 // classes BasicSet / BasicValueSet
46 //////////////////////////////////////////////////////////////////////////////////
48 // XInterface joining
49 //////////////////////////////////////////////////////////////////////////////////
50 uno::Any SAL_CALL BasicSet::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
52 uno::Any aRet = BasicSetAccess::queryInterface( rType );
53 if (!aRet.hasValue())
55 aRet = cppu::queryInterface(rType
56 , static_cast< css::container::XNameContainer *>(this)
57 , static_cast< css::container::XNameReplace *>(this)
58 , static_cast< css::beans::XPropertyWithState *>(this)
59 , static_cast< css::lang::XSingleServiceFactory *>(this)
62 return aRet;
64 //..............................................................................
66 uno::Any SAL_CALL BasicValueSet::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
68 uno::Any aRet = BasicSetAccess::queryInterface( rType );
69 if (!aRet.hasValue())
71 aRet = cppu::queryInterface(rType
72 , static_cast< css::container::XNameContainer *>(this)
73 , static_cast< css::container::XNameReplace *>(this)
74 , static_cast< css::beans::XPropertyWithState *>(this)
77 return aRet;
80 // XTypeProvider joining
81 //////////////////////////////////////////////////////////////////////////////////
82 uno::Sequence< uno::Type > SAL_CALL BasicSet::getTypes( ) throw (uno::RuntimeException )
84 /*static ?*/
85 cppu::OTypeCollection aTypes(
86 configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)),
87 configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)),
88 configapi::getReferenceType(static_cast< css::beans::XPropertyWithState *>(this)),
89 configapi::getReferenceType(static_cast< css::lang::XSingleServiceFactory *>(this)),
90 BasicSetAccess::getTypes());
92 return aTypes.getTypes();
94 //..............................................................................
96 uno::Sequence< uno::Type > SAL_CALL BasicValueSet::getTypes( ) throw (uno::RuntimeException )
98 /*static ?*/
99 cppu::OTypeCollection aTypes(
100 configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)),
101 configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)),
102 configapi::getReferenceType(static_cast< css::beans::XPropertyWithState *>(this)),
103 BasicSetAccess::getTypes());
105 return aTypes.getTypes();
108 //uno::Sequence< sal_Int8 > SAL_CALL BasicSet::getImplementationId( ) throw (uno::RuntimeException ) = 0;
109 //uno::Sequence< sal_Int8 > SAL_CALL BasicValueSet::getImplementationId( ) throw (uno::RuntimeException ) = 0;
111 // safe write access
112 //////////////////////////////////////////////////////////////////////////////////
113 configapi::NodeTreeSetAccess& BasicSet::getSetNode()
115 configapi::NodeTreeSetAccess* pAccess = maybeGetUpdateAccess();
116 OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException");
118 if (!pAccess)
120 throw uno::RuntimeException(
121 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update-interface missing.")),
122 static_cast< css::container::XNameReplace * >(this)
125 return *pAccess;
128 configapi::NodeValueSetAccess& BasicValueSet::getSetNode()
130 configapi::NodeValueSetAccess* pAccess = maybeGetUpdateAccess();
131 OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException");
133 if (!pAccess)
135 throw uno::RuntimeException(
136 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update-interface missing.")),
137 static_cast< css::container::XNameReplace* >(this)
140 return *pAccess;
143 // New Interface methods
144 // XNameReplace
145 //////////////////////////////////////////////////////////////////////////////////
146 void SAL_CALL BasicSet::replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
147 throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
149 configapi::implReplaceByName( getSetNode(), rName, rElement );
151 //..............................................................................
153 void SAL_CALL BasicValueSet::replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
154 throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
156 configapi::implReplaceByName( getSetNode(), rName, rElement );
159 // XNameContainer
160 //////////////////////////////////////////////////////////////////////////////////
161 void SAL_CALL BasicSet::insertByName( const rtl::OUString& rName, const uno::Any& rElement)
162 throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException)
164 configapi::implInsertByName( getSetNode(), rName, rElement );
166 //..............................................................................
168 void SAL_CALL BasicValueSet::insertByName( const rtl::OUString& rName, const uno::Any& rElement)
169 throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException)
171 configapi::implInsertByName( getSetNode(), rName, rElement );
174 //----------------------------------------------------------------------------------
175 void SAL_CALL BasicSet::removeByName( const rtl::OUString& rName )
176 throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
178 configapi::implRemoveByName( getSetNode(), rName );
180 //..............................................................................
182 void SAL_CALL BasicValueSet::removeByName( const rtl::OUString& rName )
183 throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
185 configapi::implRemoveByName( getSetNode(), rName );
188 // XPropertyWithState
189 //////////////////////////////////////////////////////////////////////////////////
191 css::beans::PropertyState SAL_CALL BasicSet::getStateAsProperty() throw (uno::RuntimeException)
193 return configapi::implGetStateAsProperty( getSetNode() );
195 //..............................................................................
197 css::beans::PropertyState SAL_CALL BasicValueSet::getStateAsProperty() throw (uno::RuntimeException)
199 return configapi::implGetStateAsProperty( getSetNode() );
201 //-----------------------------------------------------------------------------------
203 void SAL_CALL BasicSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
205 configapi::implSetToDefaultAsProperty( getSetNode() );
207 //..............................................................................
209 void SAL_CALL BasicValueSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
211 configapi::implSetToDefaultAsProperty( getSetNode() );
213 //-----------------------------------------------------------------------------------
215 uno::Reference< uno::XInterface > SAL_CALL BasicSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
217 return configapi::implGetDefaultAsProperty( getSetNode() );
219 //..............................................................................
221 uno::Reference< uno::XInterface > SAL_CALL BasicValueSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
223 return configapi::implGetDefaultAsProperty( getSetNode() );
226 // XSingleServiceFactory (not for ValueSet)
227 //////////////////////////////////////////////////////////////////////////////////
228 uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstance( )
229 throw(uno::Exception, uno::RuntimeException)
231 return configapi::implCreateElement( getSetNode() );
234 //----------------------------------------------------------------------------------
235 uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments )
236 throw(uno::Exception, uno::RuntimeException)
238 return configapi::implCreateElement( getSetNode(), aArguments );
241 //-----------------------------------------------------------------------------------
242 } // namespace configmgr