merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / api2 / elementaccess.cxx
blobcb497a7a5146613a419c7d27f774a721692942e3
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: elementaccess.cxx,v $
10 * $Revision: 1.8 $
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 "elementaccess.hxx"
36 #include "elementimpl.hxx"
37 #include "apinotifierimpl.hxx"
39 #include "apitreeaccess.hxx"
41 //-----------------------------------------------------------------------------------
42 namespace configmgr
44 //-----------------------------------------------------------------------------------
46 namespace uno = com::sun::star::uno;
48 //-----------------------------------------------------------------------------------
49 // XInterface (but not method queryInterface)
50 //-----------------------------------------------------------------------------------
52 // acuire doesn't really do anything but forward. OTOH it should always be overridden when release() is
53 void SAL_CALL BasicInnerElement ::acquire() throw() { cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >::acquire(); }
54 void SAL_CALL BasicSetElement ::acquire() throw() { cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >::acquire(); }
55 void SAL_CALL BasicRootElement ::acquire() throw() { cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >::acquire(); }
56 void SAL_CALL BasicUpdateElement::acquire() throw() { cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >::acquire(); }
57 //-----------------------------------------------------------------------------------
59 void SAL_CALL BasicInnerElement::release() throw()
61 // FIXME: this looks highly flaky wrt. weak-refs etc.
62 bool bLastRef = (1 == m_refCount);
63 if (bLastRef)
65 UnoApiLock::acquire();
66 configapi::implDisposeObject( getNodeAccess(), getElementClass() );
68 cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >::release();
69 if (bLastRef)
70 UnoApiLock::release();
72 //-----------------------------------------------------------------------------------
74 void SAL_CALL BasicSetElement::release() throw()
76 // FIXME: this looks highly flaky wrt. weak-refs etc.
77 bool bLastRef = (1 == m_refCount);
78 if (bLastRef)
80 UnoApiLock::acquire();
81 configapi::implDisposeObject( getNodeAccess(), getElementClass() );
83 cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >::release();
84 if (bLastRef)
85 UnoApiLock::release();
87 //-----------------------------------------------------------------------------------
89 void SAL_CALL BasicRootElement::release() throw()
91 // FIXME: this looks highly flaky wrt. weak-refs etc.
92 bool bLastRef = (1 == m_refCount);
93 if (bLastRef)
95 UnoApiLock::acquire();
96 configapi::implDisposeObject( getNodeAccess(), getElementClass() );
98 cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >::release();
99 if (bLastRef)
100 UnoApiLock::release();
102 //-----------------------------------------------------------------------------------
104 void SAL_CALL BasicUpdateElement::release() throw()
106 // FIXME: this looks highly flaky wrt. weak-refs etc.
107 bool bLastRef = (1 == m_refCount);
108 if (bLastRef)
110 UnoApiLock::acquire();
111 configapi::implDisposeObject( getNodeAccess(), getElementClass() );
113 cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >::release();
114 if (bLastRef)
115 UnoApiLock::release();
117 //-----------------------------------------------------------------------------------
119 //-----------------------------------------------------------------------------------
120 // XTypeProvider (but not method getTypes)
121 //-----------------------------------------------------------------------------------
123 uno::Sequence<sal_Int8> SAL_CALL BasicInnerElement::getImplementationId( ) throw(uno::RuntimeException)
125 return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
127 //-----------------------------------------------------------------------------------
129 uno::Sequence<sal_Int8> SAL_CALL BasicSetElement::getImplementationId( ) throw(uno::RuntimeException)
131 return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
133 //-----------------------------------------------------------------------------------
135 uno::Sequence<sal_Int8> SAL_CALL BasicRootElement::getImplementationId( ) throw(uno::RuntimeException)
137 return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
139 //-----------------------------------------------------------------------------------
141 uno::Sequence<sal_Int8> SAL_CALL BasicUpdateElement::getImplementationId( ) throw(uno::RuntimeException)
143 return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
145 //-----------------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------------
148 // XChild (not for root elements)
149 //-----------------------------------------------------------------------------------
151 uno::Reference< uno::XInterface > SAL_CALL BasicInnerElement::getParent( ) throw(uno::RuntimeException)
153 return configapi::implGetParent( getNodeAccess(), getElementClass() );
155 //-----------------------------------------------------------------------------------
157 uno::Reference< uno::XInterface > SAL_CALL BasicSetElement::getParent( ) throw(uno::RuntimeException)
159 return configapi::implGetParent( getNodeAccess(), getElementClass() );
161 //-----------------------------------------------------------------------------------
163 //-----------------------------------------------------------------------------------
164 void SAL_CALL BasicInnerElement::setParent( const uno::Reference< uno::XInterface >& xParent )
165 throw(css::lang::NoSupportException, uno::RuntimeException)
167 configapi::implSetParent( getNodeAccess(), getElementClass(), xParent );
169 //-----------------------------------------------------------------------------------
171 void SAL_CALL BasicSetElement::setParent( const uno::Reference< uno::XInterface >& xParent )
172 throw(css::lang::NoSupportException, uno::RuntimeException)
174 configapi::implSetParent( getNodeAccess(), getElementClass(), xParent );
176 //-----------------------------------------------------------------------------------
178 //-----------------------------------------------------------------------------------
179 // XNamed
180 //-----------------------------------------------------------------------------------
182 rtl::OUString SAL_CALL BasicInnerElement::getName( ) throw(uno::RuntimeException)
184 return configapi::implGetName( getNodeAccess(), getElementClass() );
186 //-----------------------------------------------------------------------------------
188 rtl::OUString SAL_CALL BasicSetElement::getName( ) throw(uno::RuntimeException)
190 return configapi::implGetName( getNodeAccess(), getElementClass() );
192 //-----------------------------------------------------------------------------------
194 rtl::OUString SAL_CALL BasicRootElement::getName( ) throw(uno::RuntimeException)
196 return configapi::implGetName( getNodeAccess(), getElementClass() );
198 //-----------------------------------------------------------------------------------
200 rtl::OUString SAL_CALL BasicUpdateElement::getName( ) throw(uno::RuntimeException)
202 return configapi::implGetName( getNodeAccess(), getElementClass() );
204 //-----------------------------------------------------------------------------------
206 //-----------------------------------------------------------------------------------
207 void SAL_CALL BasicInnerElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
209 configapi::implSetName( getNodeAccess(), getElementClass(), aName );
211 //-----------------------------------------------------------------------------------
213 void SAL_CALL BasicSetElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
215 configapi::implSetName( getNodeAccess(), getElementClass(), aName );
217 //-----------------------------------------------------------------------------------
219 void SAL_CALL BasicRootElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
221 configapi::implSetName( getNodeAccess(), getElementClass(), aName );
223 //-----------------------------------------------------------------------------------
225 void SAL_CALL BasicUpdateElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
227 configapi::implSetName( getNodeAccess(), getElementClass(), aName );
229 //-----------------------------------------------------------------------------------
231 //-----------------------------------------------------------------------------------
232 // XChangesNotifier
233 //-----------------------------------------------------------------------------------
235 void SAL_CALL BasicRootElement::addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
236 throw(uno::RuntimeException)
238 configapi::implAddListener( getNodeAccess(), xListener );
240 //-----------------------------------------------------------------------------------
242 void SAL_CALL BasicUpdateElement::addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
243 throw(uno::RuntimeException)
245 configapi::implAddListener( getNodeAccess(), xListener );
247 //-----------------------------------------------------------------------------------
249 //-----------------------------------------------------------------------------------
250 void SAL_CALL BasicRootElement::removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
251 throw(uno::RuntimeException)
253 configapi::implRemoveListener( getNodeAccess(), xListener );
255 //-----------------------------------------------------------------------------------
257 void SAL_CALL BasicUpdateElement::removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
258 throw(uno::RuntimeException)
260 configapi::implRemoveListener( getNodeAccess(), xListener );
262 //-----------------------------------------------------------------------------------
264 //-----------------------------------------------------------------------------------
265 // XComponent
266 //-----------------------------------------------------------------------------------
268 void SAL_CALL BasicSetElement::dispose( ) throw(uno::RuntimeException)
270 configapi::implDispose( getElementClass() );
272 //-----------------------------------------------------------------------------------
274 void SAL_CALL BasicRootElement::dispose( ) throw(uno::RuntimeException)
276 configapi::implDispose( getElementClass() );
278 //-----------------------------------------------------------------------------------
280 void SAL_CALL BasicUpdateElement::dispose( ) throw(uno::RuntimeException)
282 configapi::implDispose( getElementClass() );
284 //-----------------------------------------------------------------------------------
286 //-----------------------------------------------------------------------------------
287 void SAL_CALL BasicSetElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
288 throw(uno::RuntimeException)
290 configapi::implAddListener( getNodeAccess(), xListener );
292 //-----------------------------------------------------------------------------------
294 void SAL_CALL BasicRootElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
295 throw(uno::RuntimeException)
297 configapi::implAddListener( getNodeAccess(), xListener );
299 //-----------------------------------------------------------------------------------
301 void SAL_CALL BasicUpdateElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
302 throw(uno::RuntimeException)
304 configapi::implAddListener( getNodeAccess(), xListener );
306 //-----------------------------------------------------------------------------------
308 //-----------------------------------------------------------------------------------
309 void SAL_CALL BasicSetElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
310 throw(uno::RuntimeException)
312 configapi::implRemoveListener( getNodeAccess(), xListener );
314 //-----------------------------------------------------------------------------------
316 void SAL_CALL BasicRootElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
317 throw(uno::RuntimeException)
319 configapi::implRemoveListener( getNodeAccess(), xListener );
321 //-----------------------------------------------------------------------------------
323 void SAL_CALL BasicUpdateElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
324 throw(uno::RuntimeException)
326 configapi::implRemoveListener( getNodeAccess(), xListener );
328 //-----------------------------------------------------------------------------------
330 //-----------------------------------------------------------------------------------
331 // XServiceInfo
332 //-----------------------------------------------------------------------------------
334 rtl::OUString SAL_CALL BasicInnerElement::getImplementationName( ) throw(uno::RuntimeException)
336 return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
338 //-----------------------------------------------------------------------------------
340 rtl::OUString SAL_CALL BasicSetElement::getImplementationName( ) throw(uno::RuntimeException)
342 return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
344 //-----------------------------------------------------------------------------------
346 rtl::OUString SAL_CALL BasicRootElement::getImplementationName( ) throw(uno::RuntimeException)
348 return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
350 //-----------------------------------------------------------------------------------
352 rtl::OUString SAL_CALL BasicUpdateElement::getImplementationName( ) throw(uno::RuntimeException)
354 return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
356 //-----------------------------------------------------------------------------------
358 //-----------------------------------------------------------------------------------
359 sal_Bool SAL_CALL BasicInnerElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
361 return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
363 //-----------------------------------------------------------------------------------
365 sal_Bool SAL_CALL BasicSetElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
367 return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
369 //-----------------------------------------------------------------------------------
371 sal_Bool SAL_CALL BasicRootElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
373 return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
375 //-----------------------------------------------------------------------------------
377 sal_Bool SAL_CALL BasicUpdateElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
379 return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
381 //-----------------------------------------------------------------------------------
383 //-----------------------------------------------------------------------------------
384 uno::Sequence< rtl::OUString > SAL_CALL BasicInnerElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
386 return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
388 //-----------------------------------------------------------------------------------
390 uno::Sequence< rtl::OUString > SAL_CALL BasicSetElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
392 return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
394 //-----------------------------------------------------------------------------------
396 uno::Sequence< rtl::OUString > SAL_CALL BasicRootElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
398 return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
400 //-----------------------------------------------------------------------------------
402 uno::Sequence< rtl::OUString > SAL_CALL BasicUpdateElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
404 return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
406 //-----------------------------------------------------------------------------------
408 // ONLY set elements
409 //-----------------------------------------------------------------------------------
411 //-----------------------------------------------------------------------------------
412 // XTemplateInstance
413 //-----------------------------------------------------------------------------------
415 rtl::OUString SAL_CALL BasicSetElement::getTemplateName( ) throw(uno::RuntimeException)
417 return configapi::implGetTemplateName( getElementClass() );
420 //-----------------------------------------------------------------------------------
421 // XUnoTunnel
422 //-----------------------------------------------------------------------------------
424 sal_Int64 SAL_CALL BasicSetElement::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier )
425 throw(uno::RuntimeException)
427 return configapi::implGetSomething( getElementClass(), aIdentifier);
430 //-----------------------------------------------------------------------------------
432 // ONLY root elements
433 //-----------------------------------------------------------------------------------
435 //-----------------------------------------------------------------------------------
436 // XLocalizable
437 //-----------------------------------------------------------------------------------
439 css::lang::Locale SAL_CALL BasicRootElement::getLocale( ) throw(uno::RuntimeException)
441 return configapi::implGetLocale( getElementClass() );
443 //-----------------------------------------------------------------------------------
445 css::lang::Locale SAL_CALL BasicUpdateElement::getLocale( ) throw(uno::RuntimeException)
447 return configapi::implGetLocale( getElementClass() );
449 //-----------------------------------------------------------------------------------
451 //-----------------------------------------------------------------------------------
452 void SAL_CALL BasicRootElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException)
454 configapi::implSetLocale( getElementClass(), eLocale );
456 //-----------------------------------------------------------------------------------
458 void SAL_CALL BasicUpdateElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException)
460 configapi::implSetLocale( getElementClass(), eLocale );
462 //-----------------------------------------------------------------------------------
464 //-----------------------------------------------------------------------------------
465 // XChangesBatch (only on update root)
466 //-----------------------------------------------------------------------------------
468 void SAL_CALL BasicUpdateElement::commitChanges( ) throw(css::lang::WrappedTargetException, uno::RuntimeException)
470 configapi::implCommitChanges( getElementClass() );
472 //-----------------------------------------------------------------------------------
474 sal_Bool SAL_CALL BasicUpdateElement::hasPendingChanges( ) throw(uno::RuntimeException)
476 return configapi::implHasPendingChanges( getElementClass() );
478 //-----------------------------------------------------------------------------------
480 uno::Sequence< css::util::ElementChange > SAL_CALL BasicUpdateElement::getPendingChanges( ) throw(uno::RuntimeException)
482 return configapi::implGetPendingChanges( getElementClass() );
484 //-----------------------------------------------------------------------------------
486 //-----------------------------------------------------------------------------------
487 } // namespace configmgr