bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchydatasource.cxx
blob253a1d8e79a76d15c5037eb697a19a1c712a4caf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 /**************************************************************************
22 TODO
23 **************************************************************************
25 Note: Configuration Management classes do not support XAggregation.
26 So I have to wrap the interesting interfaces manually.
28 *************************************************************************/
29 #include "hierarchydatasource.hxx"
30 #include <osl/diagnose.h>
32 #include <comphelper/interfacecontainer2.hxx>
33 #include <cppuhelper/queryinterface.hxx>
34 #include <cppuhelper/weak.hxx>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/configuration/theDefaultProvider.hpp>
37 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
38 #include <com/sun/star/container/XNameContainer.hpp>
39 #include <com/sun/star/util/XChangesBatch.hpp>
40 #include <com/sun/star/util/XChangesNotifier.hpp>
41 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
42 #include <ucbhelper/macros.hxx>
44 using namespace com::sun::star;
45 using namespace hierarchy_ucp;
48 // describe path of cfg entry
49 #define CFGPROPERTY_NODEPATH "nodepath"
51 #define READ_SERVICE_NAME u"com.sun.star.ucb.HierarchyDataReadAccess"
52 #define READWRITE_SERVICE_NAME u"com.sun.star.ucb.HierarchyDataReadWriteAccess"
54 #define CONFIG_DATA_ROOT_KEY \
55 "/org.openoffice.ucb.Hierarchy/Root"
58 namespace hcp_impl
62 // HierarchyDataReadAccess Implementation.
64 namespace {
66 class HierarchyDataAccess : public cppu::OWeakObject,
67 public lang::XServiceInfo,
68 public lang::XTypeProvider,
69 public lang::XComponent,
70 public lang::XSingleServiceFactory,
71 public container::XHierarchicalNameAccess,
72 public container::XNameContainer,
73 public util::XChangesNotifier,
74 public util::XChangesBatch
76 osl::Mutex m_aMutex;
77 uno::Reference< uno::XInterface > m_xConfigAccess;
78 uno::Reference< lang::XComponent > m_xCfgC;
79 uno::Reference< lang::XSingleServiceFactory > m_xCfgSSF;
80 uno::Reference< container::XHierarchicalNameAccess > m_xCfgHNA;
81 uno::Reference< container::XNameContainer > m_xCfgNC;
82 uno::Reference< container::XNameReplace > m_xCfgNR;
83 uno::Reference< container::XNameAccess > m_xCfgNA;
84 uno::Reference< container::XElementAccess > m_xCfgEA;
85 uno::Reference< util::XChangesNotifier > m_xCfgCN;
86 uno::Reference< util::XChangesBatch > m_xCfgCB;
87 bool m_bReadOnly;
89 public:
90 HierarchyDataAccess( const uno::Reference<
91 uno::XInterface > & xConfigAccess,
92 bool bReadOnly );
94 // XInterface
95 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
96 virtual void SAL_CALL acquire()
97 noexcept override;
98 virtual void SAL_CALL release()
99 noexcept override;
101 // XServiceInfo
102 virtual OUString SAL_CALL getImplementationName() override;
103 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
104 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
106 // XTypeProvider
107 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
108 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
110 // XComponent
111 virtual void SAL_CALL
112 dispose() override;
113 virtual void SAL_CALL
114 addEventListener( const uno::Reference< lang::XEventListener > & xListener ) override;
115 virtual void SAL_CALL
116 removeEventListener( const uno::Reference<
117 lang::XEventListener > & aListener ) override;
119 // XSingleServiceFactory
120 virtual uno::Reference< uno::XInterface > SAL_CALL
121 createInstance() override;
122 virtual uno::Reference< uno::XInterface > SAL_CALL
123 createInstanceWithArguments( const uno::Sequence< uno::Any > & aArguments ) override;
125 // XHierarchicalNameAccess
126 virtual uno::Any SAL_CALL
127 getByHierarchicalName( const OUString & aName ) override;
128 virtual sal_Bool SAL_CALL
129 hasByHierarchicalName( const OUString & aName ) override;
131 // XNameContainer
132 virtual void SAL_CALL
133 insertByName( const OUString & aName, const uno::Any & aElement ) override;
134 virtual void SAL_CALL
135 removeByName( const OUString & Name ) override;
137 // XNameReplace ( base of XNameContainer )
138 virtual void SAL_CALL
139 replaceByName( const OUString & aName, const uno::Any & aElement ) override;
141 // XNameAccess ( base of XNameReplace )
142 virtual uno::Any SAL_CALL
143 getByName( const OUString & aName ) override;
144 virtual uno::Sequence< OUString > SAL_CALL
145 getElementNames() override;
146 virtual sal_Bool SAL_CALL
147 hasByName( const OUString & aName ) override;
149 // XElementAccess ( base of XNameAccess )
150 virtual uno::Type SAL_CALL
151 getElementType() override;
152 virtual sal_Bool SAL_CALL
153 hasElements() override;
155 // XChangesNotifier
156 virtual void SAL_CALL
157 addChangesListener( const uno::Reference<
158 util::XChangesListener > & aListener ) override;
159 virtual void SAL_CALL
160 removeChangesListener( const uno::Reference<
161 util::XChangesListener > & aListener ) override;
163 // XChangesBatch
164 virtual void SAL_CALL
165 commitChanges() override;
166 virtual sal_Bool SAL_CALL
167 hasPendingChanges() override;
168 virtual uno::Sequence< util::ElementChange > SAL_CALL
169 getPendingChanges() override;
170 private:
171 template<class T>
172 css::uno::Reference<T> ensureOrigInterface(css::uno::Reference<T>& x);
177 } // namespace hcp_impl
179 using namespace hcp_impl;
182 // HierarchyDataSource Implementation.
185 HierarchyDataSource::HierarchyDataSource(
186 const uno::Reference< uno::XComponentContext > & rxContext )
187 : m_xContext( rxContext )
192 // virtual
193 HierarchyDataSource::~HierarchyDataSource()
197 // XServiceInfo methods.
198 OUString SAL_CALL HierarchyDataSource::getImplementationName() \
200 return "com.sun.star.comp.ucb.HierarchyDataSource";
202 sal_Bool SAL_CALL HierarchyDataSource::supportsService( const OUString& ServiceName )
204 return cppu::supportsService( this, ServiceName );
206 css::uno::Sequence< OUString > HierarchyDataSource::getSupportedServiceNames()
208 return { "com.sun.star.ucb.DefaultHierarchyDataSource", "com.sun.star.ucb.HierarchyDataSource" };
211 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
212 ucb_HierarchyDataSource_get_implementation(
213 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
215 return cppu::acquire(new HierarchyDataSource(context));
219 // XComponent methods.
222 // virtual
223 void SAL_CALL HierarchyDataSource::dispose()
225 osl::Guard< osl::Mutex > aGuard( m_aMutex );
227 if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
229 lang::EventObject aEvt;
230 aEvt.Source = static_cast< lang::XComponent * >( this );
231 m_pDisposeEventListeners->disposeAndClear( aEvt );
236 // virtual
237 void SAL_CALL HierarchyDataSource::addEventListener(
238 const uno::Reference< lang::XEventListener > & Listener )
240 osl::Guard< osl::Mutex > aGuard( m_aMutex );
242 if ( !m_pDisposeEventListeners )
243 m_pDisposeEventListeners.reset(
244 new comphelper::OInterfaceContainerHelper2( m_aMutex ) );
246 m_pDisposeEventListeners->addInterface( Listener );
250 // virtual
251 void SAL_CALL HierarchyDataSource::removeEventListener(
252 const uno::Reference< lang::XEventListener > & Listener )
254 osl::Guard< osl::Mutex > aGuard( m_aMutex );
256 if ( m_pDisposeEventListeners )
257 m_pDisposeEventListeners->removeInterface( Listener );
261 // XMultiServiceFactory methods.
264 // virtual
265 uno::Reference< uno::XInterface > SAL_CALL
266 HierarchyDataSource::createInstance( const OUString & aServiceSpecifier )
268 // Create view to root node.
270 beans::PropertyValue aProp;
271 aProp.Name = CFGPROPERTY_NODEPATH;
272 aProp.Value <<= OUString( CONFIG_DATA_ROOT_KEY );
274 uno::Sequence< uno::Any > aArguments( 1 );
275 aArguments[ 0 ] <<= aProp;
277 return createInstanceWithArguments( aServiceSpecifier, aArguments, false );
281 // virtual
282 uno::Reference< uno::XInterface > SAL_CALL
283 HierarchyDataSource::createInstanceWithArguments(
284 const OUString & ServiceSpecifier,
285 const uno::Sequence< uno::Any > & Arguments )
287 return createInstanceWithArguments( ServiceSpecifier, Arguments, true );
291 // virtual
292 uno::Sequence< OUString > SAL_CALL
293 HierarchyDataSource::getAvailableServiceNames()
295 uno::Sequence< OUString > aNames( 2 );
296 aNames[ 0 ] = READ_SERVICE_NAME;
297 aNames[ 1 ] = READWRITE_SERVICE_NAME;
298 return aNames;
302 // Non-interface methods
305 uno::Reference< uno::XInterface >
306 HierarchyDataSource::createInstanceWithArguments(
307 std::u16string_view ServiceSpecifier,
308 const uno::Sequence< uno::Any > & Arguments,
309 bool bCheckArgs )
311 osl::Guard< osl::Mutex > aGuard( m_aMutex );
313 // Check service specifier.
314 bool bReadOnly = ServiceSpecifier == READ_SERVICE_NAME;
315 bool bReadWrite = !bReadOnly && ServiceSpecifier == READWRITE_SERVICE_NAME;
317 if ( !bReadOnly && !bReadWrite )
319 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
320 "Unsupported service specifier!" );
321 return uno::Reference< uno::XInterface >();
324 uno::Sequence< uno::Any > aNewArgs( Arguments );
326 if ( bCheckArgs )
328 // Check arguments.
329 bool bHasNodePath = false;
330 sal_Int32 nCount = Arguments.getLength();
331 for ( sal_Int32 n = 0; n < nCount; ++n )
333 beans::PropertyValue aProp;
334 if ( Arguments[ n ] >>= aProp )
336 if ( aProp.Name == CFGPROPERTY_NODEPATH )
338 OUString aPath;
339 if ( aProp.Value >>= aPath )
341 bHasNodePath = true;
343 // Create path to data inside the configuration.
344 OUString aConfigPath;
345 if ( !createConfigPath( aPath, aConfigPath ) )
347 OSL_FAIL( "HierarchyDataSource::"
348 "createInstanceWithArguments - "
349 "Invalid node path!" );
350 return uno::Reference< uno::XInterface >();
353 aProp.Value <<= aConfigPath;
355 // Set new path in arguments.
356 aNewArgs[ n ] <<= aProp;
358 break;
360 else
362 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
363 "Invalid type for property 'nodepath'!" );
364 return uno::Reference< uno::XInterface >();
370 if ( !bHasNodePath )
372 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
373 "No 'nodepath' property!" );
374 return uno::Reference< uno::XInterface >();
378 // Create Configuration Provider.
379 uno::Reference< lang::XMultiServiceFactory > xProv = getConfigProvider();
380 if ( !xProv.is() )
381 return uno::Reference< uno::XInterface >();
383 uno::Reference< uno::XInterface > xConfigAccess;
386 if ( bReadOnly )
388 // Create configuration read-only access object.
389 xConfigAccess = xProv->createInstanceWithArguments(
390 "com.sun.star.configuration.ConfigurationAccess",
391 aNewArgs );
393 else
395 // Create configuration read-write access object.
396 xConfigAccess = xProv->createInstanceWithArguments(
397 "com.sun.star.configuration.ConfigurationUpdateAccess",
398 aNewArgs );
401 catch ( uno::Exception const & )
403 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
404 "Cannot instantiate configuration access!" );
405 throw;
408 if ( !xConfigAccess.is() )
410 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
411 "Cannot instantiate configuration access!" );
412 return xConfigAccess;
415 return uno::Reference< uno::XInterface >(
416 static_cast< cppu::OWeakObject * >(
417 new HierarchyDataAccess( xConfigAccess, bReadOnly ) ) );
421 uno::Reference< lang::XMultiServiceFactory >
422 HierarchyDataSource::getConfigProvider()
424 if ( !m_xConfigProvider.is() )
426 osl::Guard< osl::Mutex > aGuard( m_aMutex );
427 if ( !m_xConfigProvider.is() )
431 m_xConfigProvider = configuration::theDefaultProvider::get( m_xContext );
433 catch ( uno::Exception const & )
435 OSL_FAIL( "HierarchyDataSource::getConfigProvider - "
436 "caught exception!" );
441 return m_xConfigProvider;
445 bool HierarchyDataSource::createConfigPath(
446 const OUString & rInPath, OUString & rOutPath )
448 if ( !rInPath.isEmpty() )
450 if ( rInPath.startsWith( "/" ) )
452 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
453 "Leading slash in node path!" );
454 return false;
457 if ( rInPath.endsWith( "/" ) )
459 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
460 "Trailing slash in node path!" );
461 return false;
464 rOutPath = CONFIG_DATA_ROOT_KEY "/" + rInPath;
466 else
468 rOutPath = CONFIG_DATA_ROOT_KEY;
471 return true;
475 // HierarchyDataAccess Implementation.
477 template<class T>
478 css::uno::Reference<T> HierarchyDataAccess::ensureOrigInterface(css::uno::Reference<T>& x)
480 if ( x.is() )
481 return x;
482 osl::Guard< osl::Mutex > aGuard( m_aMutex );
483 if ( !x.is() )
484 x.set( m_xConfigAccess, uno::UNO_QUERY );
485 return x;
489 HierarchyDataAccess::HierarchyDataAccess( const uno::Reference<
490 uno::XInterface > & xConfigAccess,
491 bool bReadOnly )
492 : m_xConfigAccess( xConfigAccess ),
493 m_bReadOnly( bReadOnly )
497 // XInterface methods.
498 void SAL_CALL HierarchyDataAccess::acquire()
499 noexcept
501 OWeakObject::acquire();
504 void SAL_CALL HierarchyDataAccess::release()
505 noexcept
507 OWeakObject::release();
510 // virtual
511 uno::Any SAL_CALL HierarchyDataAccess::queryInterface( const uno::Type & aType )
513 // Interfaces supported in read-only and read-write mode.
514 uno::Any aRet = cppu::queryInterface( aType,
515 static_cast< lang::XTypeProvider * >( this ),
516 static_cast< lang::XServiceInfo * >( this ),
517 static_cast< lang::XComponent * >( this ),
518 static_cast< container::XHierarchicalNameAccess * >( this ),
519 static_cast< container::XNameAccess * >( this ),
520 static_cast< container::XElementAccess * >( this ),
521 static_cast< util::XChangesNotifier * >( this ) );
523 // Interfaces supported only in read-write mode.
524 if ( !aRet.hasValue() && !m_bReadOnly )
526 aRet = cppu::queryInterface( aType,
527 static_cast< lang::XSingleServiceFactory * >( this ),
528 static_cast< container::XNameContainer * >( this ),
529 static_cast< container::XNameReplace * >( this ),
530 static_cast< util::XChangesBatch * >( this ) );
533 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( aType );
537 // XTypeProvider methods.
540 XTYPEPROVIDER_COMMON_IMPL( HierarchyDataAccess );
543 // virtual
544 uno::Sequence< uno::Type > SAL_CALL HierarchyDataAccess::getTypes()
546 if ( m_bReadOnly )
548 static cppu::OTypeCollection s_aReadOnlyTypes(
549 CPPU_TYPE_REF( lang::XTypeProvider ),
550 CPPU_TYPE_REF( lang::XServiceInfo ),
551 CPPU_TYPE_REF( lang::XComponent ),
552 CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
553 CPPU_TYPE_REF( container::XNameAccess ),
554 CPPU_TYPE_REF( util::XChangesNotifier ) );
556 return s_aReadOnlyTypes.getTypes();
558 else
560 static cppu::OTypeCollection s_aReadWriteTypes(
561 CPPU_TYPE_REF( lang::XTypeProvider ),
562 CPPU_TYPE_REF( lang::XServiceInfo ),
563 CPPU_TYPE_REF( lang::XComponent ),
564 CPPU_TYPE_REF( lang::XSingleServiceFactory ),
565 CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
566 CPPU_TYPE_REF( container::XNameContainer ),
567 CPPU_TYPE_REF( util::XChangesBatch ),
568 CPPU_TYPE_REF( util::XChangesNotifier ) );
570 return s_aReadWriteTypes.getTypes();
575 // XServiceInfo methods.
577 OUString SAL_CALL HierarchyDataAccess::getImplementationName()
579 return "com.sun.star.comp.ucb.HierarchyDataAccess";
582 sal_Bool SAL_CALL HierarchyDataAccess::supportsService( const OUString& ServiceName )
584 return cppu::supportsService( this, ServiceName );
587 css::uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getSupportedServiceNames()
589 return { READ_SERVICE_NAME, READWRITE_SERVICE_NAME };
593 // XComponent methods.
596 // virtual
597 void SAL_CALL HierarchyDataAccess::dispose()
599 uno::Reference< lang::XComponent > xOrig
600 = ensureOrigInterface( m_xCfgC );
602 OSL_ENSURE( xOrig.is(),
603 "HierarchyDataAccess : Data source is not an XComponent!" );
604 xOrig->dispose();
608 // virtual
609 void SAL_CALL HierarchyDataAccess::addEventListener(
610 const uno::Reference< lang::XEventListener > & xListener )
612 uno::Reference< lang::XComponent > xOrig
613 = ensureOrigInterface( m_xCfgC );
615 OSL_ENSURE( xOrig.is(),
616 "HierarchyDataAccess : Data source is not an XComponent!" );
617 xOrig->addEventListener( xListener );
621 // virtual
622 void SAL_CALL HierarchyDataAccess::removeEventListener(
623 const uno::Reference< lang::XEventListener > & aListener )
625 uno::Reference< lang::XComponent > xOrig
626 = ensureOrigInterface( m_xCfgC );
628 OSL_ENSURE( xOrig.is(),
629 "HierarchyDataAccess : Data source is not an XComponent!" );
630 xOrig->removeEventListener( aListener );
634 // XHierarchicalNameAccess methods.
637 // virtual
638 uno::Any SAL_CALL HierarchyDataAccess::getByHierarchicalName(
639 const OUString & aName )
641 uno::Reference< container::XHierarchicalNameAccess > xOrig
642 = ensureOrigInterface( m_xCfgHNA );
644 OSL_ENSURE( xOrig.is(),
645 "HierarchyDataAccess : "
646 "Data source is not an XHierarchicalNameAccess!" );
647 return xOrig->getByHierarchicalName( aName );
651 // virtual
652 sal_Bool SAL_CALL HierarchyDataAccess::hasByHierarchicalName(
653 const OUString & aName )
655 uno::Reference< container::XHierarchicalNameAccess > xOrig
656 = ensureOrigInterface( m_xCfgHNA );
658 OSL_ENSURE( xOrig.is(),
659 "HierarchyDataAccess : "
660 "Data source is not an XHierarchicalNameAccess!" );
661 return xOrig->hasByHierarchicalName( aName );
665 // XNameAccess methods.
668 // virtual
669 uno::Any SAL_CALL HierarchyDataAccess::getByName( const OUString & aName )
671 uno::Reference< container::XNameAccess > xOrig
672 = ensureOrigInterface( m_xCfgNA );
674 OSL_ENSURE( xOrig.is(),
675 "HierarchyDataAccess : Data source is not an XNameAccess!" );
676 return xOrig->getByName( aName );
680 // virtual
681 uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getElementNames()
683 uno::Reference< container::XNameAccess > xOrig
684 = ensureOrigInterface( m_xCfgNA );
686 OSL_ENSURE( xOrig.is(),
687 "HierarchyDataAccess : Data source is not an XNameAccess!" );
688 return xOrig->getElementNames();
692 // virtual
693 sal_Bool SAL_CALL HierarchyDataAccess::hasByName( const OUString & aName )
695 uno::Reference< container::XNameAccess > xOrig
696 = ensureOrigInterface( m_xCfgNA );
698 OSL_ENSURE( xOrig.is(),
699 "HierarchyDataAccess : Data source is not an XNameAccess!" );
700 return xOrig->hasByName( aName );
704 // XElementAccess methods.
707 // virtual
708 uno::Type SAL_CALL HierarchyDataAccess::getElementType()
710 uno::Reference< container::XElementAccess > xOrig
711 = ensureOrigInterface( m_xCfgEA );
713 OSL_ENSURE( xOrig.is(),
714 "HierarchyDataAccess : Data source is not an XElementAccess!" );
715 return xOrig->getElementType();
719 // virtual
720 sal_Bool SAL_CALL HierarchyDataAccess::hasElements()
722 uno::Reference< container::XElementAccess > xOrig
723 = ensureOrigInterface( m_xCfgEA );
725 OSL_ENSURE( xOrig.is(),
726 "HierarchyDataAccess : Data source is not an XElementAccess!" );
727 return xOrig->hasElements();
731 // XChangesNotifier methods.
734 // virtual
735 void SAL_CALL HierarchyDataAccess::addChangesListener(
736 const uno::Reference< util::XChangesListener > & aListener )
738 uno::Reference< util::XChangesNotifier > xOrig
739 = ensureOrigInterface( m_xCfgCN );
741 OSL_ENSURE( xOrig.is(),
742 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
743 xOrig->addChangesListener( aListener );
747 // virtual
748 void SAL_CALL HierarchyDataAccess::removeChangesListener(
749 const uno::Reference< util::XChangesListener > & aListener )
751 uno::Reference< util::XChangesNotifier > xOrig
752 = ensureOrigInterface( m_xCfgCN );
754 OSL_ENSURE( xOrig.is(),
755 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
756 xOrig->removeChangesListener( aListener );
760 // XSingleServiceFactory methods.
763 // virtual
764 uno::Reference< uno::XInterface > SAL_CALL HierarchyDataAccess::createInstance()
766 uno::Reference< lang::XSingleServiceFactory > xOrig
767 = ensureOrigInterface( m_xCfgSSF );
769 OSL_ENSURE( xOrig.is(),
770 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
771 return xOrig->createInstance();
775 // virtual
776 uno::Reference< uno::XInterface > SAL_CALL
777 HierarchyDataAccess::createInstanceWithArguments(
778 const uno::Sequence< uno::Any > & aArguments )
780 uno::Reference< lang::XSingleServiceFactory > xOrig
781 = ensureOrigInterface( m_xCfgSSF );
783 OSL_ENSURE( xOrig.is(),
784 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
785 return xOrig->createInstanceWithArguments( aArguments );
789 // XNameContainer methods.
792 // virtual
793 void SAL_CALL
794 HierarchyDataAccess::insertByName( const OUString & aName,
795 const uno::Any & aElement )
797 uno::Reference< container::XNameContainer > xOrig
798 = ensureOrigInterface( m_xCfgNC );
800 OSL_ENSURE( xOrig.is(),
801 "HierarchyDataAccess : Data source is not an XNameContainer!" );
802 xOrig->insertByName( aName, aElement );
806 // virtual
807 void SAL_CALL
808 HierarchyDataAccess::removeByName( const OUString & Name )
810 uno::Reference< container::XNameContainer > xOrig
811 = ensureOrigInterface( m_xCfgNC );
813 OSL_ENSURE( xOrig.is(),
814 "HierarchyDataAccess : Data source is not an XNameContainer!" );
815 xOrig->removeByName( Name );
819 // XNameReplace methods.
822 // virtual
823 void SAL_CALL HierarchyDataAccess::replaceByName( const OUString & aName,
824 const uno::Any & aElement )
826 uno::Reference< container::XNameReplace > xOrig
827 = ensureOrigInterface( m_xCfgNR );
829 OSL_ENSURE( xOrig.is(),
830 "HierarchyDataAccess : Data source is not an XNameReplace!" );
831 xOrig->replaceByName( aName, aElement );
835 // XChangesBatch methods.
838 // virtual
839 void SAL_CALL HierarchyDataAccess::commitChanges()
841 uno::Reference< util::XChangesBatch > xOrig
842 = ensureOrigInterface( m_xCfgCB );
844 OSL_ENSURE( xOrig.is(),
845 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
846 xOrig->commitChanges();
850 // virtual
851 sal_Bool SAL_CALL HierarchyDataAccess::hasPendingChanges()
853 uno::Reference< util::XChangesBatch > xOrig
854 = ensureOrigInterface( m_xCfgCB );
856 OSL_ENSURE( xOrig.is(),
857 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
858 return xOrig->hasPendingChanges();
862 // virtual
863 uno::Sequence< util::ElementChange > SAL_CALL
864 HierarchyDataAccess::getPendingChanges()
866 uno::Reference< util::XChangesBatch > xOrig
867 = ensureOrigInterface( m_xCfgCB );
869 OSL_ENSURE( xOrig.is(),
870 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
871 return xOrig->getPendingChanges();
874 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */