1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 /**************************************************************************
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/propertyvalue.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 <o3tl/string_view.hxx>
43 #include <ucbhelper/macros.hxx>
47 using namespace com::sun::star
;
48 using namespace hierarchy_ucp
;
51 // describe path of cfg entry
52 constexpr OUStringLiteral CFGPROPERTY_NODEPATH
= u
"nodepath";
54 constexpr OUStringLiteral READ_SERVICE_NAME
= u
"com.sun.star.ucb.HierarchyDataReadAccess";
55 constexpr OUStringLiteral READWRITE_SERVICE_NAME
= u
"com.sun.star.ucb.HierarchyDataReadWriteAccess";
57 constexpr OUStringLiteral CONFIG_DATA_ROOT_KEY
= u
"/org.openoffice.ucb.Hierarchy/Root";
64 // HierarchyDataReadAccess Implementation.
68 class HierarchyDataAccess
: public cppu::OWeakObject
,
69 public lang::XServiceInfo
,
70 public lang::XTypeProvider
,
71 public lang::XComponent
,
72 public lang::XSingleServiceFactory
,
73 public container::XHierarchicalNameAccess
,
74 public container::XNameContainer
,
75 public util::XChangesNotifier
,
76 public util::XChangesBatch
79 uno::Reference
< uno::XInterface
> m_xConfigAccess
;
80 uno::Reference
< lang::XComponent
> m_xCfgC
;
81 uno::Reference
< lang::XSingleServiceFactory
> m_xCfgSSF
;
82 uno::Reference
< container::XHierarchicalNameAccess
> m_xCfgHNA
;
83 uno::Reference
< container::XNameContainer
> m_xCfgNC
;
84 uno::Reference
< container::XNameReplace
> m_xCfgNR
;
85 uno::Reference
< container::XNameAccess
> m_xCfgNA
;
86 uno::Reference
< container::XElementAccess
> m_xCfgEA
;
87 uno::Reference
< util::XChangesNotifier
> m_xCfgCN
;
88 uno::Reference
< util::XChangesBatch
> m_xCfgCB
;
92 HierarchyDataAccess( uno::Reference
<
93 uno::XInterface
> xConfigAccess
,
97 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
98 virtual void SAL_CALL
acquire()
100 virtual void SAL_CALL
release()
104 virtual OUString SAL_CALL
getImplementationName() override
;
105 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
106 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
109 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
110 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
113 virtual void SAL_CALL
115 virtual void SAL_CALL
116 addEventListener( const uno::Reference
< lang::XEventListener
> & xListener
) override
;
117 virtual void SAL_CALL
118 removeEventListener( const uno::Reference
<
119 lang::XEventListener
> & aListener
) override
;
121 // XSingleServiceFactory
122 virtual uno::Reference
< uno::XInterface
> SAL_CALL
123 createInstance() override
;
124 virtual uno::Reference
< uno::XInterface
> SAL_CALL
125 createInstanceWithArguments( const uno::Sequence
< uno::Any
> & aArguments
) override
;
127 // XHierarchicalNameAccess
128 virtual uno::Any SAL_CALL
129 getByHierarchicalName( const OUString
& aName
) override
;
130 virtual sal_Bool SAL_CALL
131 hasByHierarchicalName( const OUString
& aName
) override
;
134 virtual void SAL_CALL
135 insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
136 virtual void SAL_CALL
137 removeByName( const OUString
& Name
) override
;
139 // XNameReplace ( base of XNameContainer )
140 virtual void SAL_CALL
141 replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
;
143 // XNameAccess ( base of XNameReplace )
144 virtual uno::Any SAL_CALL
145 getByName( const OUString
& aName
) override
;
146 virtual uno::Sequence
< OUString
> SAL_CALL
147 getElementNames() override
;
148 virtual sal_Bool SAL_CALL
149 hasByName( const OUString
& aName
) override
;
151 // XElementAccess ( base of XNameAccess )
152 virtual uno::Type SAL_CALL
153 getElementType() override
;
154 virtual sal_Bool SAL_CALL
155 hasElements() override
;
158 virtual void SAL_CALL
159 addChangesListener( const uno::Reference
<
160 util::XChangesListener
> & aListener
) override
;
161 virtual void SAL_CALL
162 removeChangesListener( const uno::Reference
<
163 util::XChangesListener
> & aListener
) override
;
166 virtual void SAL_CALL
167 commitChanges() override
;
168 virtual sal_Bool SAL_CALL
169 hasPendingChanges() override
;
170 virtual uno::Sequence
< util::ElementChange
> SAL_CALL
171 getPendingChanges() override
;
174 css::uno::Reference
<T
> ensureOrigInterface(css::uno::Reference
<T
>& x
);
179 } // namespace hcp_impl
181 using namespace hcp_impl
;
184 // HierarchyDataSource Implementation.
187 HierarchyDataSource::HierarchyDataSource(
188 uno::Reference
< uno::XComponentContext
> xContext
)
189 : m_xContext(std::move( xContext
))
195 HierarchyDataSource::~HierarchyDataSource()
199 // XServiceInfo methods.
200 OUString SAL_CALL
HierarchyDataSource::getImplementationName() \
202 return "com.sun.star.comp.ucb.HierarchyDataSource";
204 sal_Bool SAL_CALL
HierarchyDataSource::supportsService( const OUString
& ServiceName
)
206 return cppu::supportsService( this, ServiceName
);
208 css::uno::Sequence
< OUString
> HierarchyDataSource::getSupportedServiceNames()
210 return { "com.sun.star.ucb.DefaultHierarchyDataSource", "com.sun.star.ucb.HierarchyDataSource" };
213 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
214 ucb_HierarchyDataSource_get_implementation(
215 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
217 return cppu::acquire(new HierarchyDataSource(context
));
221 // XComponent methods.
225 void SAL_CALL
HierarchyDataSource::dispose()
227 std::unique_lock
aGuard( m_aMutex
);
229 if ( m_aDisposeEventListeners
.getLength(aGuard
) )
231 lang::EventObject aEvt
;
232 aEvt
.Source
= static_cast< lang::XComponent
* >( this );
233 m_aDisposeEventListeners
.disposeAndClear( aGuard
, aEvt
);
239 void SAL_CALL
HierarchyDataSource::addEventListener(
240 const uno::Reference
< lang::XEventListener
> & Listener
)
242 std::unique_lock
aGuard( m_aMutex
);
244 m_aDisposeEventListeners
.addInterface( aGuard
, Listener
);
249 void SAL_CALL
HierarchyDataSource::removeEventListener(
250 const uno::Reference
< lang::XEventListener
> & Listener
)
252 std::unique_lock
aGuard( m_aMutex
);
254 m_aDisposeEventListeners
.removeInterface( aGuard
, Listener
);
258 // XMultiServiceFactory methods.
262 uno::Reference
< uno::XInterface
> SAL_CALL
263 HierarchyDataSource::createInstance( const OUString
& aServiceSpecifier
)
265 // Create view to root node.
267 beans::PropertyValue aProp
= comphelper::makePropertyValue(CFGPROPERTY_NODEPATH
,
268 OUString( CONFIG_DATA_ROOT_KEY
));
270 uno::Sequence
< uno::Any
> aArguments
{ uno::Any(aProp
) };
272 return createInstanceWithArguments( aServiceSpecifier
, aArguments
, false );
277 uno::Reference
< uno::XInterface
> SAL_CALL
278 HierarchyDataSource::createInstanceWithArguments(
279 const OUString
& ServiceSpecifier
,
280 const uno::Sequence
< uno::Any
> & Arguments
)
282 return createInstanceWithArguments( ServiceSpecifier
, Arguments
, true );
287 uno::Sequence
< OUString
> SAL_CALL
288 HierarchyDataSource::getAvailableServiceNames()
290 return { READ_SERVICE_NAME
, READWRITE_SERVICE_NAME
};
294 // Non-interface methods
297 uno::Reference
< uno::XInterface
>
298 HierarchyDataSource::createInstanceWithArguments(
299 std::u16string_view ServiceSpecifier
,
300 const uno::Sequence
< uno::Any
> & Arguments
,
303 // Check service specifier.
304 bool bReadOnly
= ServiceSpecifier
== READ_SERVICE_NAME
;
305 bool bReadWrite
= !bReadOnly
&& ServiceSpecifier
== READWRITE_SERVICE_NAME
;
307 if ( !bReadOnly
&& !bReadWrite
)
309 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
310 "Unsupported service specifier!" );
311 return uno::Reference
< uno::XInterface
>();
314 uno::Sequence
< uno::Any
> aNewArgs( Arguments
);
315 auto aNewArgsRange
= asNonConstRange(aNewArgs
);
320 bool bHasNodePath
= false;
321 sal_Int32 nCount
= Arguments
.getLength();
322 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
324 beans::PropertyValue aProp
;
325 if ( Arguments
[ n
] >>= aProp
)
327 if ( aProp
.Name
== CFGPROPERTY_NODEPATH
)
330 if ( aProp
.Value
>>= aPath
)
334 // Create path to data inside the configuration.
335 OUString aConfigPath
;
336 if ( !createConfigPath( aPath
, aConfigPath
) )
338 OSL_FAIL( "HierarchyDataSource::"
339 "createInstanceWithArguments - "
340 "Invalid node path!" );
341 return uno::Reference
< uno::XInterface
>();
344 aProp
.Value
<<= aConfigPath
;
346 // Set new path in arguments.
347 aNewArgsRange
[ n
] <<= aProp
;
353 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
354 "Invalid type for property 'nodepath'!" );
355 return uno::Reference
< uno::XInterface
>();
363 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
364 "No 'nodepath' property!" );
365 return uno::Reference
< uno::XInterface
>();
369 // Create Configuration Provider.
370 uno::Reference
< lang::XMultiServiceFactory
> xProv
= getConfigProvider();
372 return uno::Reference
< uno::XInterface
>();
374 uno::Reference
< uno::XInterface
> xConfigAccess
;
379 // Create configuration read-only access object.
380 xConfigAccess
= xProv
->createInstanceWithArguments(
381 "com.sun.star.configuration.ConfigurationAccess",
386 // Create configuration read-write access object.
387 xConfigAccess
= xProv
->createInstanceWithArguments(
388 "com.sun.star.configuration.ConfigurationUpdateAccess",
392 catch ( uno::Exception
const & )
394 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
395 "Cannot instantiate configuration access!" );
399 if ( !xConfigAccess
.is() )
401 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
402 "Cannot instantiate configuration access!" );
403 return xConfigAccess
;
406 return uno::Reference
< uno::XInterface
>(
407 static_cast< cppu::OWeakObject
* >(
408 new HierarchyDataAccess( xConfigAccess
, bReadOnly
) ) );
412 uno::Reference
< lang::XMultiServiceFactory
>
413 HierarchyDataSource::getConfigProvider()
415 if ( !m_xConfigProvider
.is() )
417 std::unique_lock
aGuard( m_aMutex
);
418 if ( !m_xConfigProvider
.is() )
422 m_xConfigProvider
= configuration::theDefaultProvider::get( m_xContext
);
424 catch ( uno::Exception
const & )
426 OSL_FAIL( "HierarchyDataSource::getConfigProvider - "
427 "caught exception!" );
432 return m_xConfigProvider
;
436 bool HierarchyDataSource::createConfigPath(
437 std::u16string_view rInPath
, OUString
& rOutPath
)
439 if ( !rInPath
.empty() )
441 if ( o3tl::starts_with( rInPath
, u
"/" ) )
443 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
444 "Leading slash in node path!" );
448 if ( o3tl::ends_with( rInPath
, u
"/" ) )
450 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
451 "Trailing slash in node path!" );
455 rOutPath
= CONFIG_DATA_ROOT_KEY
+ "/" + rInPath
;
459 rOutPath
= CONFIG_DATA_ROOT_KEY
;
466 // HierarchyDataAccess Implementation.
469 css::uno::Reference
<T
> HierarchyDataAccess::ensureOrigInterface(css::uno::Reference
<T
>& x
)
473 std::scoped_lock
aGuard( m_aMutex
);
475 x
.set( m_xConfigAccess
, uno::UNO_QUERY
);
480 HierarchyDataAccess::HierarchyDataAccess( uno::Reference
<
481 uno::XInterface
> xConfigAccess
,
483 : m_xConfigAccess(std::move( xConfigAccess
)),
484 m_bReadOnly( bReadOnly
)
488 // XInterface methods.
489 void SAL_CALL
HierarchyDataAccess::acquire()
492 OWeakObject::acquire();
495 void SAL_CALL
HierarchyDataAccess::release()
498 OWeakObject::release();
502 uno::Any SAL_CALL
HierarchyDataAccess::queryInterface( const uno::Type
& aType
)
504 // Interfaces supported in read-only and read-write mode.
505 uno::Any aRet
= cppu::queryInterface( aType
,
506 static_cast< lang::XTypeProvider
* >( this ),
507 static_cast< lang::XServiceInfo
* >( this ),
508 static_cast< lang::XComponent
* >( this ),
509 static_cast< container::XHierarchicalNameAccess
* >( this ),
510 static_cast< container::XNameAccess
* >( this ),
511 static_cast< container::XElementAccess
* >( this ),
512 static_cast< util::XChangesNotifier
* >( this ) );
514 // Interfaces supported only in read-write mode.
515 if ( !aRet
.hasValue() && !m_bReadOnly
)
517 aRet
= cppu::queryInterface( aType
,
518 static_cast< lang::XSingleServiceFactory
* >( this ),
519 static_cast< container::XNameContainer
* >( this ),
520 static_cast< container::XNameReplace
* >( this ),
521 static_cast< util::XChangesBatch
* >( this ) );
524 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( aType
);
528 // XTypeProvider methods.
531 XTYPEPROVIDER_COMMON_IMPL( HierarchyDataAccess
);
535 uno::Sequence
< uno::Type
> SAL_CALL
HierarchyDataAccess::getTypes()
539 static cppu::OTypeCollection
s_aReadOnlyTypes(
540 CPPU_TYPE_REF( lang::XTypeProvider
),
541 CPPU_TYPE_REF( lang::XServiceInfo
),
542 CPPU_TYPE_REF( lang::XComponent
),
543 CPPU_TYPE_REF( container::XHierarchicalNameAccess
),
544 CPPU_TYPE_REF( container::XNameAccess
),
545 CPPU_TYPE_REF( util::XChangesNotifier
) );
547 return s_aReadOnlyTypes
.getTypes();
551 static cppu::OTypeCollection
s_aReadWriteTypes(
552 CPPU_TYPE_REF( lang::XTypeProvider
),
553 CPPU_TYPE_REF( lang::XServiceInfo
),
554 CPPU_TYPE_REF( lang::XComponent
),
555 CPPU_TYPE_REF( lang::XSingleServiceFactory
),
556 CPPU_TYPE_REF( container::XHierarchicalNameAccess
),
557 CPPU_TYPE_REF( container::XNameContainer
),
558 CPPU_TYPE_REF( util::XChangesBatch
),
559 CPPU_TYPE_REF( util::XChangesNotifier
) );
561 return s_aReadWriteTypes
.getTypes();
566 // XServiceInfo methods.
568 OUString SAL_CALL
HierarchyDataAccess::getImplementationName()
570 return "com.sun.star.comp.ucb.HierarchyDataAccess";
573 sal_Bool SAL_CALL
HierarchyDataAccess::supportsService( const OUString
& ServiceName
)
575 return cppu::supportsService( this, ServiceName
);
578 css::uno::Sequence
< OUString
> SAL_CALL
HierarchyDataAccess::getSupportedServiceNames()
580 return { READ_SERVICE_NAME
, READWRITE_SERVICE_NAME
};
584 // XComponent methods.
588 void SAL_CALL
HierarchyDataAccess::dispose()
590 uno::Reference
< lang::XComponent
> xOrig
591 = ensureOrigInterface( m_xCfgC
);
593 OSL_ENSURE( xOrig
.is(),
594 "HierarchyDataAccess : Data source is not an XComponent!" );
600 void SAL_CALL
HierarchyDataAccess::addEventListener(
601 const uno::Reference
< lang::XEventListener
> & xListener
)
603 uno::Reference
< lang::XComponent
> xOrig
604 = ensureOrigInterface( m_xCfgC
);
606 OSL_ENSURE( xOrig
.is(),
607 "HierarchyDataAccess : Data source is not an XComponent!" );
608 xOrig
->addEventListener( xListener
);
613 void SAL_CALL
HierarchyDataAccess::removeEventListener(
614 const uno::Reference
< lang::XEventListener
> & aListener
)
616 uno::Reference
< lang::XComponent
> xOrig
617 = ensureOrigInterface( m_xCfgC
);
619 OSL_ENSURE( xOrig
.is(),
620 "HierarchyDataAccess : Data source is not an XComponent!" );
621 xOrig
->removeEventListener( aListener
);
625 // XHierarchicalNameAccess methods.
629 uno::Any SAL_CALL
HierarchyDataAccess::getByHierarchicalName(
630 const OUString
& aName
)
632 uno::Reference
< container::XHierarchicalNameAccess
> xOrig
633 = ensureOrigInterface( m_xCfgHNA
);
635 OSL_ENSURE( xOrig
.is(),
636 "HierarchyDataAccess : "
637 "Data source is not an XHierarchicalNameAccess!" );
638 return xOrig
->getByHierarchicalName( aName
);
643 sal_Bool SAL_CALL
HierarchyDataAccess::hasByHierarchicalName(
644 const OUString
& aName
)
646 uno::Reference
< container::XHierarchicalNameAccess
> xOrig
647 = ensureOrigInterface( m_xCfgHNA
);
649 OSL_ENSURE( xOrig
.is(),
650 "HierarchyDataAccess : "
651 "Data source is not an XHierarchicalNameAccess!" );
652 return xOrig
->hasByHierarchicalName( aName
);
656 // XNameAccess methods.
660 uno::Any SAL_CALL
HierarchyDataAccess::getByName( const OUString
& aName
)
662 uno::Reference
< container::XNameAccess
> xOrig
663 = ensureOrigInterface( m_xCfgNA
);
665 OSL_ENSURE( xOrig
.is(),
666 "HierarchyDataAccess : Data source is not an XNameAccess!" );
667 return xOrig
->getByName( aName
);
672 uno::Sequence
< OUString
> SAL_CALL
HierarchyDataAccess::getElementNames()
674 uno::Reference
< container::XNameAccess
> xOrig
675 = ensureOrigInterface( m_xCfgNA
);
677 OSL_ENSURE( xOrig
.is(),
678 "HierarchyDataAccess : Data source is not an XNameAccess!" );
679 return xOrig
->getElementNames();
684 sal_Bool SAL_CALL
HierarchyDataAccess::hasByName( const OUString
& aName
)
686 uno::Reference
< container::XNameAccess
> xOrig
687 = ensureOrigInterface( m_xCfgNA
);
689 OSL_ENSURE( xOrig
.is(),
690 "HierarchyDataAccess : Data source is not an XNameAccess!" );
691 return xOrig
->hasByName( aName
);
695 // XElementAccess methods.
699 uno::Type SAL_CALL
HierarchyDataAccess::getElementType()
701 uno::Reference
< container::XElementAccess
> xOrig
702 = ensureOrigInterface( m_xCfgEA
);
704 OSL_ENSURE( xOrig
.is(),
705 "HierarchyDataAccess : Data source is not an XElementAccess!" );
706 return xOrig
->getElementType();
711 sal_Bool SAL_CALL
HierarchyDataAccess::hasElements()
713 uno::Reference
< container::XElementAccess
> xOrig
714 = ensureOrigInterface( m_xCfgEA
);
716 OSL_ENSURE( xOrig
.is(),
717 "HierarchyDataAccess : Data source is not an XElementAccess!" );
718 return xOrig
->hasElements();
722 // XChangesNotifier methods.
726 void SAL_CALL
HierarchyDataAccess::addChangesListener(
727 const uno::Reference
< util::XChangesListener
> & aListener
)
729 uno::Reference
< util::XChangesNotifier
> xOrig
730 = ensureOrigInterface( m_xCfgCN
);
732 OSL_ENSURE( xOrig
.is(),
733 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
734 xOrig
->addChangesListener( aListener
);
739 void SAL_CALL
HierarchyDataAccess::removeChangesListener(
740 const uno::Reference
< util::XChangesListener
> & aListener
)
742 uno::Reference
< util::XChangesNotifier
> xOrig
743 = ensureOrigInterface( m_xCfgCN
);
745 OSL_ENSURE( xOrig
.is(),
746 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
747 xOrig
->removeChangesListener( aListener
);
751 // XSingleServiceFactory methods.
755 uno::Reference
< uno::XInterface
> SAL_CALL
HierarchyDataAccess::createInstance()
757 uno::Reference
< lang::XSingleServiceFactory
> xOrig
758 = ensureOrigInterface( m_xCfgSSF
);
760 OSL_ENSURE( xOrig
.is(),
761 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
762 return xOrig
->createInstance();
767 uno::Reference
< uno::XInterface
> SAL_CALL
768 HierarchyDataAccess::createInstanceWithArguments(
769 const uno::Sequence
< uno::Any
> & aArguments
)
771 uno::Reference
< lang::XSingleServiceFactory
> xOrig
772 = ensureOrigInterface( m_xCfgSSF
);
774 OSL_ENSURE( xOrig
.is(),
775 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
776 return xOrig
->createInstanceWithArguments( aArguments
);
780 // XNameContainer methods.
785 HierarchyDataAccess::insertByName( const OUString
& aName
,
786 const uno::Any
& aElement
)
788 uno::Reference
< container::XNameContainer
> xOrig
789 = ensureOrigInterface( m_xCfgNC
);
791 OSL_ENSURE( xOrig
.is(),
792 "HierarchyDataAccess : Data source is not an XNameContainer!" );
793 xOrig
->insertByName( aName
, aElement
);
799 HierarchyDataAccess::removeByName( const OUString
& Name
)
801 uno::Reference
< container::XNameContainer
> xOrig
802 = ensureOrigInterface( m_xCfgNC
);
804 OSL_ENSURE( xOrig
.is(),
805 "HierarchyDataAccess : Data source is not an XNameContainer!" );
806 xOrig
->removeByName( Name
);
810 // XNameReplace methods.
814 void SAL_CALL
HierarchyDataAccess::replaceByName( const OUString
& aName
,
815 const uno::Any
& aElement
)
817 uno::Reference
< container::XNameReplace
> xOrig
818 = ensureOrigInterface( m_xCfgNR
);
820 OSL_ENSURE( xOrig
.is(),
821 "HierarchyDataAccess : Data source is not an XNameReplace!" );
822 xOrig
->replaceByName( aName
, aElement
);
826 // XChangesBatch methods.
830 void SAL_CALL
HierarchyDataAccess::commitChanges()
832 uno::Reference
< util::XChangesBatch
> xOrig
833 = ensureOrigInterface( m_xCfgCB
);
835 OSL_ENSURE( xOrig
.is(),
836 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
837 xOrig
->commitChanges();
842 sal_Bool SAL_CALL
HierarchyDataAccess::hasPendingChanges()
844 uno::Reference
< util::XChangesBatch
> xOrig
845 = ensureOrigInterface( m_xCfgCB
);
847 OSL_ENSURE( xOrig
.is(),
848 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
849 return xOrig
->hasPendingChanges();
854 uno::Sequence
< util::ElementChange
> SAL_CALL
855 HierarchyDataAccess::getPendingChanges()
857 uno::Reference
< util::XChangesBatch
> xOrig
858 = ensureOrigInterface( m_xCfgCB
);
860 OSL_ENSURE( xOrig
.is(),
861 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
862 return xOrig
->getPendingChanges();
865 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */