Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchydatasource.cxx
blob004c27a5f2c1434e43c407ea1dc75cc5b1a743b4
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 <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/configuration/theDefaultProvider.hpp>
36 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
37 #include <com/sun/star/container/XNameContainer.hpp>
38 #include <com/sun/star/util/XChangesBatch.hpp>
39 #include <com/sun/star/util/XChangesNotifier.hpp>
40 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
41 #include <ucbhelper/getcomponentcontext.hxx>
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 "com.sun.star.ucb.HierarchyDataReadAccess"
52 #define READWRITE_SERVICE_NAME "com.sun.star.ucb.HierarchyDataReadWriteAccess"
54 #define CONFIG_DATA_ROOT_KEY \
55 "/org.openoffice.ucb.Hierarchy/Root"
58 namespace hcp_impl
62 // HierarchyDataReadAccess Implementation.
65 class HierarchyDataAccess : public cppu::OWeakObject,
66 public lang::XServiceInfo,
67 public lang::XTypeProvider,
68 public lang::XComponent,
69 public lang::XSingleServiceFactory,
70 public container::XHierarchicalNameAccess,
71 public container::XNameContainer,
72 public util::XChangesNotifier,
73 public util::XChangesBatch
75 osl::Mutex m_aMutex;
76 uno::Reference< uno::XInterface > m_xConfigAccess;
77 uno::Reference< lang::XComponent > m_xCfgC;
78 uno::Reference< lang::XSingleServiceFactory > m_xCfgSSF;
79 uno::Reference< container::XHierarchicalNameAccess > m_xCfgHNA;
80 uno::Reference< container::XNameContainer > m_xCfgNC;
81 uno::Reference< container::XNameReplace > m_xCfgNR;
82 uno::Reference< container::XNameAccess > m_xCfgNA;
83 uno::Reference< container::XElementAccess > m_xCfgEA;
84 uno::Reference< util::XChangesNotifier > m_xCfgCN;
85 uno::Reference< util::XChangesBatch > m_xCfgCB;
86 bool const m_bReadOnly;
88 public:
89 HierarchyDataAccess( const uno::Reference<
90 uno::XInterface > & xConfigAccess,
91 bool bReadOnly );
93 // XInterface
94 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
95 virtual void SAL_CALL acquire()
96 throw() override;
97 virtual void SAL_CALL release()
98 throw() override;
100 // XServiceInfo
101 virtual OUString SAL_CALL getImplementationName() override;
102 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
103 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
105 // XTypeProvider
106 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
107 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
109 // XComponent
110 virtual void SAL_CALL
111 dispose() override;
112 virtual void SAL_CALL
113 addEventListener( const uno::Reference< lang::XEventListener > & xListener ) override;
114 virtual void SAL_CALL
115 removeEventListener( const uno::Reference<
116 lang::XEventListener > & aListener ) override;
118 // XSingleServiceFactory
119 virtual uno::Reference< uno::XInterface > SAL_CALL
120 createInstance() override;
121 virtual uno::Reference< uno::XInterface > SAL_CALL
122 createInstanceWithArguments( const uno::Sequence< uno::Any > & aArguments ) override;
124 // XHierarchicalNameAccess
125 virtual uno::Any SAL_CALL
126 getByHierarchicalName( const OUString & aName ) override;
127 virtual sal_Bool SAL_CALL
128 hasByHierarchicalName( const OUString & aName ) override;
130 // XNameContainer
131 virtual void SAL_CALL
132 insertByName( const OUString & aName, const uno::Any & aElement ) override;
133 virtual void SAL_CALL
134 removeByName( const OUString & Name ) override;
136 // XNameReplace ( base of XNameContainer )
137 virtual void SAL_CALL
138 replaceByName( const OUString & aName, const uno::Any & aElement ) override;
140 // XNameAccess ( base of XNameReplace )
141 virtual uno::Any SAL_CALL
142 getByName( const OUString & aName ) override;
143 virtual uno::Sequence< OUString > SAL_CALL
144 getElementNames() override;
145 virtual sal_Bool SAL_CALL
146 hasByName( const OUString & aName ) override;
148 // XElementAccess ( base of XNameAccess )
149 virtual uno::Type SAL_CALL
150 getElementType() override;
151 virtual sal_Bool SAL_CALL
152 hasElements() override;
154 // XChangesNotifier
155 virtual void SAL_CALL
156 addChangesListener( const uno::Reference<
157 util::XChangesListener > & aListener ) override;
158 virtual void SAL_CALL
159 removeChangesListener( const uno::Reference<
160 util::XChangesListener > & aListener ) override;
162 // XChangesBatch
163 virtual void SAL_CALL
164 commitChanges() override;
165 virtual sal_Bool SAL_CALL
166 hasPendingChanges() override;
167 virtual uno::Sequence< util::ElementChange > SAL_CALL
168 getPendingChanges() override;
169 private:
170 template<class T>
171 css::uno::Reference<T> ensureOrigInterface(css::uno::Reference<T>& x);
174 } // namespace hcp_impl
176 using namespace hcp_impl;
179 // HierarchyDataSource Implementation.
182 HierarchyDataSource::HierarchyDataSource(
183 const uno::Reference< uno::XComponentContext > & rxContext )
184 : m_xContext( rxContext )
189 // virtual
190 HierarchyDataSource::~HierarchyDataSource()
194 // XServiceInfo methods.
196 XSERVICEINFO_COMMOM_IMPL( HierarchyDataSource,
197 "com.sun.star.comp.ucb.HierarchyDataSource" )
198 /// @throws css::uno::Exception
199 static css::uno::Reference< css::uno::XInterface >
200 HierarchyDataSource_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
202 css::lang::XServiceInfo* pX = new HierarchyDataSource( ucbhelper::getComponentContext(rSMgr) );
203 return css::uno::Reference< css::uno::XInterface >::query( pX );
206 css::uno::Sequence< OUString >
207 HierarchyDataSource::getSupportedServiceNames_Static()
209 return { "com.sun.star.ucb.DefaultHierarchyDataSource", "com.sun.star.ucb.HierarchyDataSource" };
212 ONE_INSTANCE_SERVICE_FACTORY_IMPL( HierarchyDataSource );
215 // XComponent methods.
218 // virtual
219 void SAL_CALL HierarchyDataSource::dispose()
221 osl::Guard< osl::Mutex > aGuard( m_aMutex );
223 if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
225 lang::EventObject aEvt;
226 aEvt.Source = static_cast< lang::XComponent * >( this );
227 m_pDisposeEventListeners->disposeAndClear( aEvt );
232 // virtual
233 void SAL_CALL HierarchyDataSource::addEventListener(
234 const uno::Reference< lang::XEventListener > & Listener )
236 osl::Guard< osl::Mutex > aGuard( m_aMutex );
238 if ( !m_pDisposeEventListeners )
239 m_pDisposeEventListeners.reset(
240 new comphelper::OInterfaceContainerHelper2( m_aMutex ) );
242 m_pDisposeEventListeners->addInterface( Listener );
246 // virtual
247 void SAL_CALL HierarchyDataSource::removeEventListener(
248 const uno::Reference< lang::XEventListener > & Listener )
250 osl::Guard< osl::Mutex > aGuard( m_aMutex );
252 if ( m_pDisposeEventListeners )
253 m_pDisposeEventListeners->removeInterface( Listener );
257 // XMultiServiceFactory methods.
260 // virtual
261 uno::Reference< uno::XInterface > SAL_CALL
262 HierarchyDataSource::createInstance( const OUString & aServiceSpecifier )
264 // Create view to root node.
266 beans::PropertyValue aProp;
267 aProp.Name = CFGPROPERTY_NODEPATH;
268 aProp.Value <<= OUString( CONFIG_DATA_ROOT_KEY );
270 uno::Sequence< uno::Any > aArguments( 1 );
271 aArguments[ 0 ] <<= aProp;
273 return createInstanceWithArguments( aServiceSpecifier, aArguments, false );
277 // virtual
278 uno::Reference< uno::XInterface > SAL_CALL
279 HierarchyDataSource::createInstanceWithArguments(
280 const OUString & ServiceSpecifier,
281 const uno::Sequence< uno::Any > & Arguments )
283 return createInstanceWithArguments( ServiceSpecifier, Arguments, true );
287 // virtual
288 uno::Sequence< OUString > SAL_CALL
289 HierarchyDataSource::getAvailableServiceNames()
291 uno::Sequence< OUString > aNames( 2 );
292 aNames[ 0 ] = READ_SERVICE_NAME;
293 aNames[ 1 ] = READWRITE_SERVICE_NAME;
294 return aNames;
298 // Non-interface methods
301 uno::Reference< uno::XInterface >
302 HierarchyDataSource::createInstanceWithArguments(
303 const OUString & ServiceSpecifier,
304 const uno::Sequence< uno::Any > & Arguments,
305 bool bCheckArgs )
307 osl::Guard< osl::Mutex > aGuard( m_aMutex );
309 // Check service specifier.
310 bool bReadOnly = ServiceSpecifier == READ_SERVICE_NAME;
311 bool bReadWrite = !bReadOnly && ServiceSpecifier == READWRITE_SERVICE_NAME;
313 if ( !bReadOnly && !bReadWrite )
315 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
316 "Unsupported service specifier!" );
317 return uno::Reference< uno::XInterface >();
320 uno::Sequence< uno::Any > aNewArgs( Arguments );
322 if ( bCheckArgs )
324 // Check arguments.
325 bool bHasNodePath = false;
326 sal_Int32 nCount = Arguments.getLength();
327 for ( sal_Int32 n = 0; n < nCount; ++n )
329 beans::PropertyValue aProp;
330 if ( Arguments[ n ] >>= aProp )
332 if ( aProp.Name == CFGPROPERTY_NODEPATH )
334 OUString aPath;
335 if ( aProp.Value >>= aPath )
337 bHasNodePath = true;
339 // Create path to data inside the configuration.
340 OUString aConfigPath;
341 if ( !createConfigPath( aPath, aConfigPath ) )
343 OSL_FAIL( "HierarchyDataSource::"
344 "createInstanceWithArguments - "
345 "Invalid node path!" );
346 return uno::Reference< uno::XInterface >();
349 aProp.Value <<= aConfigPath;
351 // Set new path in arguments.
352 aNewArgs[ n ] <<= aProp;
354 break;
356 else
358 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
359 "Invalid type for property 'nodepath'!" );
360 return uno::Reference< uno::XInterface >();
366 if ( !bHasNodePath )
368 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
369 "No 'nodepath' property!" );
370 return uno::Reference< uno::XInterface >();
374 // Create Configuration Provider.
375 uno::Reference< lang::XMultiServiceFactory > xProv = getConfigProvider();
376 if ( !xProv.is() )
377 return uno::Reference< uno::XInterface >();
379 uno::Reference< uno::XInterface > xConfigAccess;
382 if ( bReadOnly )
384 // Create configuration read-only access object.
385 xConfigAccess = xProv->createInstanceWithArguments(
386 "com.sun.star.configuration.ConfigurationAccess",
387 aNewArgs );
389 else
391 // Create configuration read-write access object.
392 xConfigAccess = xProv->createInstanceWithArguments(
393 "com.sun.star.configuration.ConfigurationUpdateAccess",
394 aNewArgs );
397 catch ( uno::Exception const & )
399 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
400 "Cannot instantiate configuration access!" );
401 throw;
404 if ( !xConfigAccess.is() )
406 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
407 "Cannot instantiate configuration access!" );
408 return xConfigAccess;
411 return uno::Reference< uno::XInterface >(
412 static_cast< cppu::OWeakObject * >(
413 new HierarchyDataAccess( xConfigAccess, bReadOnly ) ) );
417 uno::Reference< lang::XMultiServiceFactory >
418 HierarchyDataSource::getConfigProvider()
420 if ( !m_xConfigProvider.is() )
422 osl::Guard< osl::Mutex > aGuard( m_aMutex );
423 if ( !m_xConfigProvider.is() )
427 m_xConfigProvider = configuration::theDefaultProvider::get( m_xContext );
429 catch ( uno::Exception const & )
431 OSL_FAIL( "HierarchyDataSource::getConfigProvider - "
432 "caught exception!" );
437 return m_xConfigProvider;
441 bool HierarchyDataSource::createConfigPath(
442 const OUString & rInPath, OUString & rOutPath )
444 if ( !rInPath.isEmpty() )
446 if ( rInPath.startsWith( "/" ) )
448 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
449 "Leading slash in node path!" );
450 return false;
453 if ( rInPath.endsWith( "/" ) )
455 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
456 "Trailing slash in node path!" );
457 return false;
460 rOutPath = CONFIG_DATA_ROOT_KEY "/" + rInPath;
462 else
464 rOutPath = CONFIG_DATA_ROOT_KEY;
467 return true;
471 // HierarchyDataAccess Implementation.
473 template<class T>
474 css::uno::Reference<T> HierarchyDataAccess::ensureOrigInterface(css::uno::Reference<T>& x)
476 if ( x.is() )
477 return x;
478 osl::Guard< osl::Mutex > aGuard( m_aMutex );
479 if ( !x.is() )
480 x.set( m_xConfigAccess, uno::UNO_QUERY );
481 return x;
485 HierarchyDataAccess::HierarchyDataAccess( const uno::Reference<
486 uno::XInterface > & xConfigAccess,
487 bool bReadOnly )
488 : m_xConfigAccess( xConfigAccess ),
489 m_bReadOnly( bReadOnly )
493 // XInterface methods.
494 void SAL_CALL HierarchyDataAccess::acquire()
495 throw()
497 OWeakObject::acquire();
500 void SAL_CALL HierarchyDataAccess::release()
501 throw()
503 OWeakObject::release();
506 // virtual
507 uno::Any SAL_CALL HierarchyDataAccess::queryInterface( const uno::Type & aType )
509 // Interfaces supported in read-only and read-write mode.
510 uno::Any aRet = cppu::queryInterface( aType,
511 static_cast< lang::XTypeProvider * >( this ),
512 static_cast< lang::XServiceInfo * >( this ),
513 static_cast< lang::XComponent * >( this ),
514 static_cast< container::XHierarchicalNameAccess * >( this ),
515 static_cast< container::XNameAccess * >( this ),
516 static_cast< container::XElementAccess * >( this ),
517 static_cast< util::XChangesNotifier * >( this ) );
519 // Interfaces supported only in read-write mode.
520 if ( !aRet.hasValue() && !m_bReadOnly )
522 aRet = cppu::queryInterface( aType,
523 static_cast< lang::XSingleServiceFactory * >( this ),
524 static_cast< container::XNameContainer * >( this ),
525 static_cast< container::XNameReplace * >( this ),
526 static_cast< util::XChangesBatch * >( this ) );
529 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( aType );
533 // XTypeProvider methods.
536 XTYPEPROVIDER_COMMON_IMPL( HierarchyDataAccess );
539 // virtual
540 uno::Sequence< uno::Type > SAL_CALL HierarchyDataAccess::getTypes()
542 if ( m_bReadOnly )
544 static cppu::OTypeCollection s_aReadOnlyTypes(
545 CPPU_TYPE_REF( lang::XTypeProvider ),
546 CPPU_TYPE_REF( lang::XServiceInfo ),
547 CPPU_TYPE_REF( lang::XComponent ),
548 CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
549 CPPU_TYPE_REF( container::XNameAccess ),
550 CPPU_TYPE_REF( util::XChangesNotifier ) );
552 return s_aReadOnlyTypes.getTypes();
554 else
556 static cppu::OTypeCollection s_aReadWriteTypes(
557 CPPU_TYPE_REF( lang::XTypeProvider ),
558 CPPU_TYPE_REF( lang::XServiceInfo ),
559 CPPU_TYPE_REF( lang::XComponent ),
560 CPPU_TYPE_REF( lang::XSingleServiceFactory ),
561 CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
562 CPPU_TYPE_REF( container::XNameContainer ),
563 CPPU_TYPE_REF( util::XChangesBatch ),
564 CPPU_TYPE_REF( util::XChangesNotifier ) );
566 return s_aReadWriteTypes.getTypes();
571 // XServiceInfo methods.
573 OUString SAL_CALL HierarchyDataAccess::getImplementationName()
575 return "com.sun.star.comp.ucb.HierarchyDataAccess";
578 sal_Bool SAL_CALL HierarchyDataAccess::supportsService( const OUString& ServiceName )
580 return cppu::supportsService( this, ServiceName );
583 css::uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getSupportedServiceNames()
585 return { READ_SERVICE_NAME, READWRITE_SERVICE_NAME };
589 // XComponent methods.
592 // virtual
593 void SAL_CALL HierarchyDataAccess::dispose()
595 uno::Reference< lang::XComponent > xOrig
596 = ensureOrigInterface( m_xCfgC );
598 OSL_ENSURE( xOrig.is(),
599 "HierarchyDataAccess : Data source is not an XComponent!" );
600 xOrig->dispose();
604 // virtual
605 void SAL_CALL HierarchyDataAccess::addEventListener(
606 const uno::Reference< lang::XEventListener > & xListener )
608 uno::Reference< lang::XComponent > xOrig
609 = ensureOrigInterface( m_xCfgC );
611 OSL_ENSURE( xOrig.is(),
612 "HierarchyDataAccess : Data source is not an XComponent!" );
613 xOrig->addEventListener( xListener );
617 // virtual
618 void SAL_CALL HierarchyDataAccess::removeEventListener(
619 const uno::Reference< lang::XEventListener > & aListener )
621 uno::Reference< lang::XComponent > xOrig
622 = ensureOrigInterface( m_xCfgC );
624 OSL_ENSURE( xOrig.is(),
625 "HierarchyDataAccess : Data source is not an XComponent!" );
626 xOrig->removeEventListener( aListener );
630 // XHierarchicalNameAccess methods.
633 // virtual
634 uno::Any SAL_CALL HierarchyDataAccess::getByHierarchicalName(
635 const OUString & aName )
637 uno::Reference< container::XHierarchicalNameAccess > xOrig
638 = ensureOrigInterface( m_xCfgHNA );
640 OSL_ENSURE( xOrig.is(),
641 "HierarchyDataAccess : "
642 "Data source is not an XHierarchicalNameAccess!" );
643 return xOrig->getByHierarchicalName( aName );
647 // virtual
648 sal_Bool SAL_CALL HierarchyDataAccess::hasByHierarchicalName(
649 const OUString & aName )
651 uno::Reference< container::XHierarchicalNameAccess > xOrig
652 = ensureOrigInterface( m_xCfgHNA );
654 OSL_ENSURE( xOrig.is(),
655 "HierarchyDataAccess : "
656 "Data source is not an XHierarchicalNameAccess!" );
657 return xOrig->hasByHierarchicalName( aName );
661 // XNameAccess methods.
664 // virtual
665 uno::Any SAL_CALL HierarchyDataAccess::getByName( const OUString & aName )
667 uno::Reference< container::XNameAccess > xOrig
668 = ensureOrigInterface( m_xCfgNA );
670 OSL_ENSURE( xOrig.is(),
671 "HierarchyDataAccess : Data source is not an XNameAccess!" );
672 return xOrig->getByName( aName );
676 // virtual
677 uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getElementNames()
679 uno::Reference< container::XNameAccess > xOrig
680 = ensureOrigInterface( m_xCfgNA );
682 OSL_ENSURE( xOrig.is(),
683 "HierarchyDataAccess : Data source is not an XNameAccess!" );
684 return xOrig->getElementNames();
688 // virtual
689 sal_Bool SAL_CALL HierarchyDataAccess::hasByName( const OUString & aName )
691 uno::Reference< container::XNameAccess > xOrig
692 = ensureOrigInterface( m_xCfgNA );
694 OSL_ENSURE( xOrig.is(),
695 "HierarchyDataAccess : Data source is not an XNameAccess!" );
696 return xOrig->hasByName( aName );
700 // XElementAccess methods.
703 // virtual
704 uno::Type SAL_CALL HierarchyDataAccess::getElementType()
706 uno::Reference< container::XElementAccess > xOrig
707 = ensureOrigInterface( m_xCfgEA );
709 OSL_ENSURE( xOrig.is(),
710 "HierarchyDataAccess : Data source is not an XElementAccess!" );
711 return xOrig->getElementType();
715 // virtual
716 sal_Bool SAL_CALL HierarchyDataAccess::hasElements()
718 uno::Reference< container::XElementAccess > xOrig
719 = ensureOrigInterface( m_xCfgEA );
721 OSL_ENSURE( xOrig.is(),
722 "HierarchyDataAccess : Data source is not an XElementAccess!" );
723 return xOrig->hasElements();
727 // XChangesNotifier methods.
730 // virtual
731 void SAL_CALL HierarchyDataAccess::addChangesListener(
732 const uno::Reference< util::XChangesListener > & aListener )
734 uno::Reference< util::XChangesNotifier > xOrig
735 = ensureOrigInterface( m_xCfgCN );
737 OSL_ENSURE( xOrig.is(),
738 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
739 xOrig->addChangesListener( aListener );
743 // virtual
744 void SAL_CALL HierarchyDataAccess::removeChangesListener(
745 const uno::Reference< util::XChangesListener > & aListener )
747 uno::Reference< util::XChangesNotifier > xOrig
748 = ensureOrigInterface( m_xCfgCN );
750 OSL_ENSURE( xOrig.is(),
751 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
752 xOrig->removeChangesListener( aListener );
756 // XSingleServiceFactory methods.
759 // virtual
760 uno::Reference< uno::XInterface > SAL_CALL HierarchyDataAccess::createInstance()
762 uno::Reference< lang::XSingleServiceFactory > xOrig
763 = ensureOrigInterface( m_xCfgSSF );
765 OSL_ENSURE( xOrig.is(),
766 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
767 return xOrig->createInstance();
771 // virtual
772 uno::Reference< uno::XInterface > SAL_CALL
773 HierarchyDataAccess::createInstanceWithArguments(
774 const uno::Sequence< uno::Any > & aArguments )
776 uno::Reference< lang::XSingleServiceFactory > xOrig
777 = ensureOrigInterface( m_xCfgSSF );
779 OSL_ENSURE( xOrig.is(),
780 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
781 return xOrig->createInstanceWithArguments( aArguments );
785 // XNameContainer methods.
788 // virtual
789 void SAL_CALL
790 HierarchyDataAccess::insertByName( const OUString & aName,
791 const uno::Any & aElement )
793 uno::Reference< container::XNameContainer > xOrig
794 = ensureOrigInterface( m_xCfgNC );
796 OSL_ENSURE( xOrig.is(),
797 "HierarchyDataAccess : Data source is not an XNameContainer!" );
798 xOrig->insertByName( aName, aElement );
802 // virtual
803 void SAL_CALL
804 HierarchyDataAccess::removeByName( const OUString & Name )
806 uno::Reference< container::XNameContainer > xOrig
807 = ensureOrigInterface( m_xCfgNC );
809 OSL_ENSURE( xOrig.is(),
810 "HierarchyDataAccess : Data source is not an XNameContainer!" );
811 xOrig->removeByName( Name );
815 // XNameReplace methods.
818 // virtual
819 void SAL_CALL HierarchyDataAccess::replaceByName( const OUString & aName,
820 const uno::Any & aElement )
822 uno::Reference< container::XNameReplace > xOrig
823 = ensureOrigInterface( m_xCfgNR );
825 OSL_ENSURE( xOrig.is(),
826 "HierarchyDataAccess : Data source is not an XNameReplace!" );
827 xOrig->replaceByName( aName, aElement );
831 // XChangesBatch methods.
834 // virtual
835 void SAL_CALL HierarchyDataAccess::commitChanges()
837 uno::Reference< util::XChangesBatch > xOrig
838 = ensureOrigInterface( m_xCfgCB );
840 OSL_ENSURE( xOrig.is(),
841 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
842 xOrig->commitChanges();
846 // virtual
847 sal_Bool SAL_CALL HierarchyDataAccess::hasPendingChanges()
849 uno::Reference< util::XChangesBatch > xOrig
850 = ensureOrigInterface( m_xCfgCB );
852 OSL_ENSURE( xOrig.is(),
853 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
854 return xOrig->hasPendingChanges();
858 // virtual
859 uno::Sequence< util::ElementChange > SAL_CALL
860 HierarchyDataAccess::getPendingChanges()
862 uno::Reference< util::XChangesBatch > xOrig
863 = ensureOrigInterface( m_xCfgCB );
865 OSL_ENSURE( xOrig.is(),
866 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
867 return xOrig->getPendingChanges();
870 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */