LibreOffice Module ucb (master) 1
hierarchydatasource.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21/**************************************************************************
22 TODO
23 **************************************************************************
24
25 Note: Configuration Management classes do not support XAggregation.
26 So I have to wrap the interesting interfaces manually.
27
28 *************************************************************************/
30#include <osl/diagnose.h>
31
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>
44#include <mutex>
45#include <utility>
46
47using namespace com::sun::star;
48using namespace hierarchy_ucp;
49
50
51// describe path of cfg entry
52constexpr OUStringLiteral CFGPROPERTY_NODEPATH = u"nodepath";
53
54constexpr OUStringLiteral READ_SERVICE_NAME = u"com.sun.star.ucb.HierarchyDataReadAccess";
55constexpr OUStringLiteral READWRITE_SERVICE_NAME = u"com.sun.star.ucb.HierarchyDataReadWriteAccess";
56
57constexpr OUStringLiteral CONFIG_DATA_ROOT_KEY = u"/org.openoffice.ucb.Hierarchy/Root";
58
59
60namespace hcp_impl
61{
62
63
64// HierarchyDataReadAccess Implementation.
65
66namespace {
67
68class 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
77{
78 std::mutex m_aMutex;
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;
90
91public:
92 HierarchyDataAccess( uno::Reference<
93 uno::XInterface > xConfigAccess,
94 bool bReadOnly );
95
96 // XInterface
97 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
98 virtual void SAL_CALL acquire()
99 noexcept override;
100 virtual void SAL_CALL release()
101 noexcept override;
102
103 // XServiceInfo
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;
107
108 // XTypeProvider
109 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
110 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
111
112 // XComponent
113 virtual void SAL_CALL
114 dispose() override;
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;
120
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;
126
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;
132
133 // XNameContainer
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;
138
139 // XNameReplace ( base of XNameContainer )
140 virtual void SAL_CALL
141 replaceByName( const OUString & aName, const uno::Any & aElement ) override;
142
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;
150
151 // XElementAccess ( base of XNameAccess )
152 virtual uno::Type SAL_CALL
153 getElementType() override;
154 virtual sal_Bool SAL_CALL
155 hasElements() override;
156
157 // XChangesNotifier
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;
164
165 // XChangesBatch
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;
172private:
173 template<class T>
174 css::uno::Reference<T> ensureOrigInterface(css::uno::Reference<T>& x);
175};
176
177}
178
179} // namespace hcp_impl
180
181using namespace hcp_impl;
182
183
184// HierarchyDataSource Implementation.
185
186
188 uno::Reference< uno::XComponentContext > xContext )
189: m_xContext(std::move( xContext ))
190{
191}
192
193
194// virtual
195HierarchyDataSource::~HierarchyDataSource()
196{
197}
198
199// XServiceInfo methods.
200OUString SAL_CALL HierarchyDataSource::getImplementationName() \
201{
202 return "com.sun.star.comp.ucb.HierarchyDataSource";
203}
204sal_Bool SAL_CALL HierarchyDataSource::supportsService( const OUString& ServiceName )
205{
206 return cppu::supportsService( this, ServiceName );
207}
208css::uno::Sequence< OUString > HierarchyDataSource::getSupportedServiceNames()
209{
210 return { "com.sun.star.ucb.DefaultHierarchyDataSource", "com.sun.star.ucb.HierarchyDataSource" };
211}
212
213extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
215 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
216{
217 return cppu::acquire(new HierarchyDataSource(context));
218}
219
220
221// XComponent methods.
222
223
224// virtual
225void SAL_CALL HierarchyDataSource::dispose()
226{
227 std::unique_lock aGuard( m_aMutex );
228
229 if ( m_aDisposeEventListeners.getLength(aGuard) )
230 {
231 lang::EventObject aEvt;
232 aEvt.Source = static_cast< lang::XComponent * >( this );
233 m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
234 }
235}
236
237
238// virtual
239void SAL_CALL HierarchyDataSource::addEventListener(
240 const uno::Reference< lang::XEventListener > & Listener )
241{
242 std::unique_lock aGuard( m_aMutex );
243
244 m_aDisposeEventListeners.addInterface( aGuard, Listener );
245}
246
247
248// virtual
249void SAL_CALL HierarchyDataSource::removeEventListener(
250 const uno::Reference< lang::XEventListener > & Listener )
251{
252 std::unique_lock aGuard( m_aMutex );
253
254 m_aDisposeEventListeners.removeInterface( aGuard, Listener );
255}
256
257
258// XMultiServiceFactory methods.
259
260
261// virtual
262uno::Reference< uno::XInterface > SAL_CALL
263HierarchyDataSource::createInstance( const OUString & aServiceSpecifier )
264{
265 // Create view to root node.
266
267 beans::PropertyValue aProp = comphelper::makePropertyValue(CFGPROPERTY_NODEPATH,
268 OUString( CONFIG_DATA_ROOT_KEY ));
269
270 uno::Sequence< uno::Any > aArguments{ uno::Any(aProp) };
271
272 return createInstanceWithArguments( aServiceSpecifier, aArguments, false );
273}
274
275
276// virtual
277uno::Reference< uno::XInterface > SAL_CALL
278HierarchyDataSource::createInstanceWithArguments(
279 const OUString & ServiceSpecifier,
280 const uno::Sequence< uno::Any > & Arguments )
281{
282 return createInstanceWithArguments( ServiceSpecifier, Arguments, true );
283}
284
285
286// virtual
287uno::Sequence< OUString > SAL_CALL
288HierarchyDataSource::getAvailableServiceNames()
289{
291}
292
293
294// Non-interface methods
295
296
297uno::Reference< uno::XInterface >
298HierarchyDataSource::createInstanceWithArguments(
299 std::u16string_view ServiceSpecifier,
300 const uno::Sequence< uno::Any > & Arguments,
301 bool bCheckArgs )
302{
303 // Check service specifier.
304 bool bReadOnly = ServiceSpecifier == READ_SERVICE_NAME;
305 bool bReadWrite = !bReadOnly && ServiceSpecifier == READWRITE_SERVICE_NAME;
306
307 if ( !bReadOnly && !bReadWrite )
308 {
309 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
310 "Unsupported service specifier!" );
311 return uno::Reference< uno::XInterface >();
312 }
313
314 uno::Sequence< uno::Any > aNewArgs( Arguments );
315 auto aNewArgsRange = asNonConstRange(aNewArgs);
316
317 if ( bCheckArgs )
318 {
319 // Check arguments.
320 bool bHasNodePath = false;
321 sal_Int32 nCount = Arguments.getLength();
322 for ( sal_Int32 n = 0; n < nCount; ++n )
323 {
324 beans::PropertyValue aProp;
325 if ( Arguments[ n ] >>= aProp )
326 {
327 if ( aProp.Name == CFGPROPERTY_NODEPATH )
328 {
329 OUString aPath;
330 if ( aProp.Value >>= aPath )
331 {
332 bHasNodePath = true;
333
334 // Create path to data inside the configuration.
335 OUString aConfigPath;
336 if ( !createConfigPath( aPath, aConfigPath ) )
337 {
338 OSL_FAIL( "HierarchyDataSource::"
339 "createInstanceWithArguments - "
340 "Invalid node path!" );
341 return uno::Reference< uno::XInterface >();
342 }
343
344 aProp.Value <<= aConfigPath;
345
346 // Set new path in arguments.
347 aNewArgsRange[ n ] <<= aProp;
348
349 break;
350 }
351 else
352 {
353 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
354 "Invalid type for property 'nodepath'!" );
355 return uno::Reference< uno::XInterface >();
356 }
357 }
358 }
359 }
360
361 if ( !bHasNodePath )
362 {
363 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
364 "No 'nodepath' property!" );
365 return uno::Reference< uno::XInterface >();
366 }
367 }
368
369 // Create Configuration Provider.
370 uno::Reference< lang::XMultiServiceFactory > xProv = getConfigProvider();
371 if ( !xProv.is() )
372 return uno::Reference< uno::XInterface >();
373
374 uno::Reference< uno::XInterface > xConfigAccess;
375 try
376 {
377 if ( bReadOnly )
378 {
379 // Create configuration read-only access object.
380 xConfigAccess = xProv->createInstanceWithArguments(
381 "com.sun.star.configuration.ConfigurationAccess",
382 aNewArgs );
383 }
384 else
385 {
386 // Create configuration read-write access object.
387 xConfigAccess = xProv->createInstanceWithArguments(
388 "com.sun.star.configuration.ConfigurationUpdateAccess",
389 aNewArgs );
390 }
391 }
392 catch ( uno::Exception const & )
393 {
394 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
395 "Cannot instantiate configuration access!" );
396 throw;
397 }
398
399 if ( !xConfigAccess.is() )
400 {
401 OSL_FAIL( "HierarchyDataSource::createInstanceWithArguments - "
402 "Cannot instantiate configuration access!" );
403 return xConfigAccess;
404 }
405
406 return uno::Reference< uno::XInterface >(
407 static_cast< cppu::OWeakObject * >(
408 new HierarchyDataAccess( xConfigAccess, bReadOnly ) ) );
409}
410
411
412uno::Reference< lang::XMultiServiceFactory >
413HierarchyDataSource::getConfigProvider()
414{
415 if ( !m_xConfigProvider.is() )
416 {
417 std::unique_lock aGuard( m_aMutex );
418 if ( !m_xConfigProvider.is() )
419 {
420 try
421 {
422 m_xConfigProvider = configuration::theDefaultProvider::get( m_xContext );
423 }
424 catch ( uno::Exception const & )
425 {
426 OSL_FAIL( "HierarchyDataSource::getConfigProvider - "
427 "caught exception!" );
428 }
429 }
430 }
431
432 return m_xConfigProvider;
433}
434
435
436bool HierarchyDataSource::createConfigPath(
437 std::u16string_view rInPath, OUString & rOutPath )
438{
439 if ( !rInPath.empty() )
440 {
441 if ( o3tl::starts_with( rInPath, u"/" ) )
442 {
443 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
444 "Leading slash in node path!" );
445 return false;
446 }
447
448 if ( o3tl::ends_with( rInPath, u"/" ) )
449 {
450 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
451 "Trailing slash in node path!" );
452 return false;
453 }
454
455 rOutPath = CONFIG_DATA_ROOT_KEY + "/" + rInPath;
456 }
457 else
458 {
459 rOutPath = CONFIG_DATA_ROOT_KEY;
460 }
461
462 return true;
463}
464
465
466// HierarchyDataAccess Implementation.
467
468template<class T>
469css::uno::Reference<T> HierarchyDataAccess::ensureOrigInterface(css::uno::Reference<T>& x)
470{
471 if ( x.is() )
472 return x;
473 std::scoped_lock aGuard( m_aMutex );
474 if ( !x.is() )
475 x.set( m_xConfigAccess, uno::UNO_QUERY );
476 return x;
477}
478
479
480HierarchyDataAccess::HierarchyDataAccess( uno::Reference<
481 uno::XInterface > xConfigAccess,
482 bool bReadOnly )
483: m_xConfigAccess(std::move( xConfigAccess )),
485{
486}
487
488// XInterface methods.
489void SAL_CALL HierarchyDataAccess::acquire()
490 noexcept
491{
492 OWeakObject::acquire();
493}
494
495void SAL_CALL HierarchyDataAccess::release()
496 noexcept
497{
498 OWeakObject::release();
499}
500
501// virtual
502uno::Any SAL_CALL HierarchyDataAccess::queryInterface( const uno::Type & aType )
503{
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 ) );
513
514 // Interfaces supported only in read-write mode.
515 if ( !aRet.hasValue() && !m_bReadOnly )
516 {
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 ) );
522 }
523
524 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( aType );
525}
526
527
528// XTypeProvider methods.
529
530
531XTYPEPROVIDER_COMMON_IMPL( HierarchyDataAccess );
532
533
534// virtual
535uno::Sequence< uno::Type > SAL_CALL HierarchyDataAccess::getTypes()
536{
537 if ( m_bReadOnly )
538 {
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 ) );
546
547 return s_aReadOnlyTypes.getTypes();
548 }
549 else
550 {
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 ) );
560
561 return s_aReadWriteTypes.getTypes();
562 }
563}
564
565
566// XServiceInfo methods.
567
568OUString SAL_CALL HierarchyDataAccess::getImplementationName()
569{
570 return "com.sun.star.comp.ucb.HierarchyDataAccess";
571}
572
573sal_Bool SAL_CALL HierarchyDataAccess::supportsService( const OUString& ServiceName )
574{
575 return cppu::supportsService( this, ServiceName );
576}
577
578css::uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getSupportedServiceNames()
579{
581}
582
583
584// XComponent methods.
585
586
587// virtual
588void SAL_CALL HierarchyDataAccess::dispose()
589{
590 uno::Reference< lang::XComponent > xOrig
591 = ensureOrigInterface( m_xCfgC );
592
593 OSL_ENSURE( xOrig.is(),
594 "HierarchyDataAccess : Data source is not an XComponent!" );
595 xOrig->dispose();
596}
597
598
599// virtual
600void SAL_CALL HierarchyDataAccess::addEventListener(
601 const uno::Reference< lang::XEventListener > & xListener )
602{
603 uno::Reference< lang::XComponent > xOrig
604 = ensureOrigInterface( m_xCfgC );
605
606 OSL_ENSURE( xOrig.is(),
607 "HierarchyDataAccess : Data source is not an XComponent!" );
608 xOrig->addEventListener( xListener );
609}
610
611
612// virtual
613void SAL_CALL HierarchyDataAccess::removeEventListener(
614 const uno::Reference< lang::XEventListener > & aListener )
615{
616 uno::Reference< lang::XComponent > xOrig
617 = ensureOrigInterface( m_xCfgC );
618
619 OSL_ENSURE( xOrig.is(),
620 "HierarchyDataAccess : Data source is not an XComponent!" );
621 xOrig->removeEventListener( aListener );
622}
623
624
625// XHierarchicalNameAccess methods.
626
627
628// virtual
629uno::Any SAL_CALL HierarchyDataAccess::getByHierarchicalName(
630 const OUString & aName )
631{
632 uno::Reference< container::XHierarchicalNameAccess > xOrig
633 = ensureOrigInterface( m_xCfgHNA );
634
635 OSL_ENSURE( xOrig.is(),
636 "HierarchyDataAccess : "
637 "Data source is not an XHierarchicalNameAccess!" );
638 return xOrig->getByHierarchicalName( aName );
639}
640
641
642// virtual
643sal_Bool SAL_CALL HierarchyDataAccess::hasByHierarchicalName(
644 const OUString & aName )
645{
646 uno::Reference< container::XHierarchicalNameAccess > xOrig
647 = ensureOrigInterface( m_xCfgHNA );
648
649 OSL_ENSURE( xOrig.is(),
650 "HierarchyDataAccess : "
651 "Data source is not an XHierarchicalNameAccess!" );
652 return xOrig->hasByHierarchicalName( aName );
653}
654
655
656// XNameAccess methods.
657
658
659// virtual
660uno::Any SAL_CALL HierarchyDataAccess::getByName( const OUString & aName )
661{
662 uno::Reference< container::XNameAccess > xOrig
663 = ensureOrigInterface( m_xCfgNA );
664
665 OSL_ENSURE( xOrig.is(),
666 "HierarchyDataAccess : Data source is not an XNameAccess!" );
667 return xOrig->getByName( aName );
668}
669
670
671// virtual
672uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getElementNames()
673{
674 uno::Reference< container::XNameAccess > xOrig
675 = ensureOrigInterface( m_xCfgNA );
676
677 OSL_ENSURE( xOrig.is(),
678 "HierarchyDataAccess : Data source is not an XNameAccess!" );
679 return xOrig->getElementNames();
680}
681
682
683// virtual
684sal_Bool SAL_CALL HierarchyDataAccess::hasByName( const OUString & aName )
685{
686 uno::Reference< container::XNameAccess > xOrig
687 = ensureOrigInterface( m_xCfgNA );
688
689 OSL_ENSURE( xOrig.is(),
690 "HierarchyDataAccess : Data source is not an XNameAccess!" );
691 return xOrig->hasByName( aName );
692}
693
694
695// XElementAccess methods.
696
697
698// virtual
699uno::Type SAL_CALL HierarchyDataAccess::getElementType()
700{
701 uno::Reference< container::XElementAccess > xOrig
702 = ensureOrigInterface( m_xCfgEA );
703
704 OSL_ENSURE( xOrig.is(),
705 "HierarchyDataAccess : Data source is not an XElementAccess!" );
706 return xOrig->getElementType();
707}
708
709
710// virtual
711sal_Bool SAL_CALL HierarchyDataAccess::hasElements()
712{
713 uno::Reference< container::XElementAccess > xOrig
714 = ensureOrigInterface( m_xCfgEA );
715
716 OSL_ENSURE( xOrig.is(),
717 "HierarchyDataAccess : Data source is not an XElementAccess!" );
718 return xOrig->hasElements();
719}
720
721
722// XChangesNotifier methods.
723
724
725// virtual
726void SAL_CALL HierarchyDataAccess::addChangesListener(
727 const uno::Reference< util::XChangesListener > & aListener )
728{
729 uno::Reference< util::XChangesNotifier > xOrig
730 = ensureOrigInterface( m_xCfgCN );
731
732 OSL_ENSURE( xOrig.is(),
733 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
734 xOrig->addChangesListener( aListener );
735}
736
737
738// virtual
739void SAL_CALL HierarchyDataAccess::removeChangesListener(
740 const uno::Reference< util::XChangesListener > & aListener )
741{
742 uno::Reference< util::XChangesNotifier > xOrig
743 = ensureOrigInterface( m_xCfgCN );
744
745 OSL_ENSURE( xOrig.is(),
746 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
747 xOrig->removeChangesListener( aListener );
748}
749
750
751// XSingleServiceFactory methods.
752
753
754// virtual
755uno::Reference< uno::XInterface > SAL_CALL HierarchyDataAccess::createInstance()
756{
757 uno::Reference< lang::XSingleServiceFactory > xOrig
758 = ensureOrigInterface( m_xCfgSSF );
759
760 OSL_ENSURE( xOrig.is(),
761 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
762 return xOrig->createInstance();
763}
764
765
766// virtual
767uno::Reference< uno::XInterface > SAL_CALL
768HierarchyDataAccess::createInstanceWithArguments(
769 const uno::Sequence< uno::Any > & aArguments )
770{
771 uno::Reference< lang::XSingleServiceFactory > xOrig
772 = ensureOrigInterface( m_xCfgSSF );
773
774 OSL_ENSURE( xOrig.is(),
775 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
776 return xOrig->createInstanceWithArguments( aArguments );
777}
778
779
780// XNameContainer methods.
781
782
783// virtual
784void SAL_CALL
785HierarchyDataAccess::insertByName( const OUString & aName,
786 const uno::Any & aElement )
787{
788 uno::Reference< container::XNameContainer > xOrig
789 = ensureOrigInterface( m_xCfgNC );
790
791 OSL_ENSURE( xOrig.is(),
792 "HierarchyDataAccess : Data source is not an XNameContainer!" );
793 xOrig->insertByName( aName, aElement );
794}
795
796
797// virtual
798void SAL_CALL
799HierarchyDataAccess::removeByName( const OUString & Name )
800{
801 uno::Reference< container::XNameContainer > xOrig
802 = ensureOrigInterface( m_xCfgNC );
803
804 OSL_ENSURE( xOrig.is(),
805 "HierarchyDataAccess : Data source is not an XNameContainer!" );
806 xOrig->removeByName( Name );
807}
808
809
810// XNameReplace methods.
811
812
813// virtual
814void SAL_CALL HierarchyDataAccess::replaceByName( const OUString & aName,
815 const uno::Any & aElement )
816{
817 uno::Reference< container::XNameReplace > xOrig
818 = ensureOrigInterface( m_xCfgNR );
819
820 OSL_ENSURE( xOrig.is(),
821 "HierarchyDataAccess : Data source is not an XNameReplace!" );
822 xOrig->replaceByName( aName, aElement );
823}
824
825
826// XChangesBatch methods.
827
828
829// virtual
830void SAL_CALL HierarchyDataAccess::commitChanges()
831{
832 uno::Reference< util::XChangesBatch > xOrig
833 = ensureOrigInterface( m_xCfgCB );
834
835 OSL_ENSURE( xOrig.is(),
836 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
837 xOrig->commitChanges();
838}
839
840
841// virtual
842sal_Bool SAL_CALL HierarchyDataAccess::hasPendingChanges()
843{
844 uno::Reference< util::XChangesBatch > xOrig
845 = ensureOrigInterface( m_xCfgCB );
846
847 OSL_ENSURE( xOrig.is(),
848 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
849 return xOrig->hasPendingChanges();
850}
851
852
853// virtual
854uno::Sequence< util::ElementChange > SAL_CALL
855HierarchyDataAccess::getPendingChanges()
856{
857 uno::Reference< util::XChangesBatch > xOrig
858 = ensureOrigInterface( m_xCfgCB );
859
860 OSL_ENSURE( xOrig.is(),
861 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
862 return xOrig->getPendingChanges();
863}
864
865/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
int nCount
float u
float x
bool bReadOnly
uno::Reference< container::XNameContainer > m_xCfgNC
uno::Reference< lang::XComponent > m_xCfgC
std::mutex m_aMutex
uno::Reference< container::XNameAccess > m_xCfgNA
constexpr OUStringLiteral CFGPROPERTY_NODEPATH
bool m_bReadOnly
uno::Reference< util::XChangesBatch > m_xCfgCB
XTYPEPROVIDER_COMMON_IMPL(HierarchyDataAccess)
uno::Reference< lang::XSingleServiceFactory > m_xCfgSSF
uno::Reference< container::XNameReplace > m_xCfgNR
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_HierarchyDataSource_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral READ_SERVICE_NAME
uno::Reference< uno::XInterface > m_xConfigAccess
constexpr OUStringLiteral CONFIG_DATA_ROOT_KEY
uno::Reference< util::XChangesNotifier > m_xCfgCN
uno::Reference< container::XHierarchicalNameAccess > m_xCfgHNA
uno::Reference< container::XElementAccess > m_xCfgEA
constexpr OUStringLiteral READWRITE_SERVICE_NAME
Sequence< PropertyValue > aArguments
sal_Int64 n
#define CPPU_TYPE_REF(T)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Type
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral READWRITE_SERVICE_NAME
constexpr OUStringLiteral READ_SERVICE_NAME
constexpr bool ends_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
bool hasValue()
unsigned char sal_Bool
signed char sal_Int8
Reference< XMultiServiceFactory > m_xConfigProvider