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 cppu::getXWeak(new HierarchyDataAccess(xConfigAccess, bReadOnly));
407}
408
409
410uno::Reference< lang::XMultiServiceFactory >
411HierarchyDataSource::getConfigProvider()
412{
413 if ( !m_xConfigProvider.is() )
414 {
415 std::unique_lock aGuard( m_aMutex );
416 if ( !m_xConfigProvider.is() )
417 {
418 try
419 {
420 m_xConfigProvider = configuration::theDefaultProvider::get( m_xContext );
421 }
422 catch ( uno::Exception const & )
423 {
424 OSL_FAIL( "HierarchyDataSource::getConfigProvider - "
425 "caught exception!" );
426 }
427 }
428 }
429
430 return m_xConfigProvider;
431}
432
433
434bool HierarchyDataSource::createConfigPath(
435 std::u16string_view rInPath, OUString & rOutPath )
436{
437 if ( !rInPath.empty() )
438 {
439 if ( o3tl::starts_with( rInPath, u"/" ) )
440 {
441 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
442 "Leading slash in node path!" );
443 return false;
444 }
445
446 if ( o3tl::ends_with( rInPath, u"/" ) )
447 {
448 OSL_FAIL( "HierarchyDataSource::createConfigPath - "
449 "Trailing slash in node path!" );
450 return false;
451 }
452
453 rOutPath = CONFIG_DATA_ROOT_KEY + "/" + rInPath;
454 }
455 else
456 {
457 rOutPath = CONFIG_DATA_ROOT_KEY;
458 }
459
460 return true;
461}
462
463
464// HierarchyDataAccess Implementation.
465
466template<class T>
467css::uno::Reference<T> HierarchyDataAccess::ensureOrigInterface(css::uno::Reference<T>& x)
468{
469 if ( x.is() )
470 return x;
471 std::scoped_lock aGuard( m_aMutex );
472 if ( !x.is() )
473 x.set( m_xConfigAccess, uno::UNO_QUERY );
474 return x;
475}
476
477
478HierarchyDataAccess::HierarchyDataAccess( uno::Reference<
479 uno::XInterface > xConfigAccess,
480 bool bReadOnly )
481: m_xConfigAccess(std::move( xConfigAccess )),
483{
484}
485
486// XInterface methods.
487void SAL_CALL HierarchyDataAccess::acquire()
488 noexcept
489{
490 OWeakObject::acquire();
491}
492
493void SAL_CALL HierarchyDataAccess::release()
494 noexcept
495{
496 OWeakObject::release();
497}
498
499// virtual
500uno::Any SAL_CALL HierarchyDataAccess::queryInterface( const uno::Type & aType )
501{
502 // Interfaces supported in read-only and read-write mode.
503 uno::Any aRet = cppu::queryInterface( aType,
504 static_cast< lang::XTypeProvider * >( this ),
505 static_cast< lang::XServiceInfo * >( this ),
506 static_cast< lang::XComponent * >( this ),
507 static_cast< container::XHierarchicalNameAccess * >( this ),
508 static_cast< container::XNameAccess * >( this ),
509 static_cast< container::XElementAccess * >( this ),
510 static_cast< util::XChangesNotifier * >( this ) );
511
512 // Interfaces supported only in read-write mode.
513 if ( !aRet.hasValue() && !m_bReadOnly )
514 {
515 aRet = cppu::queryInterface( aType,
516 static_cast< lang::XSingleServiceFactory * >( this ),
517 static_cast< container::XNameContainer * >( this ),
518 static_cast< container::XNameReplace * >( this ),
519 static_cast< util::XChangesBatch * >( this ) );
520 }
521
522 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( aType );
523}
524
525
526// XTypeProvider methods.
527
528
529XTYPEPROVIDER_COMMON_IMPL( HierarchyDataAccess );
530
531
532// virtual
533uno::Sequence< uno::Type > SAL_CALL HierarchyDataAccess::getTypes()
534{
535 if ( m_bReadOnly )
536 {
537 static cppu::OTypeCollection s_aReadOnlyTypes(
538 CPPU_TYPE_REF( lang::XTypeProvider ),
539 CPPU_TYPE_REF( lang::XServiceInfo ),
540 CPPU_TYPE_REF( lang::XComponent ),
541 CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
542 CPPU_TYPE_REF( container::XNameAccess ),
543 CPPU_TYPE_REF( util::XChangesNotifier ) );
544
545 return s_aReadOnlyTypes.getTypes();
546 }
547 else
548 {
549 static cppu::OTypeCollection s_aReadWriteTypes(
550 CPPU_TYPE_REF( lang::XTypeProvider ),
551 CPPU_TYPE_REF( lang::XServiceInfo ),
552 CPPU_TYPE_REF( lang::XComponent ),
553 CPPU_TYPE_REF( lang::XSingleServiceFactory ),
554 CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
555 CPPU_TYPE_REF( container::XNameContainer ),
556 CPPU_TYPE_REF( util::XChangesBatch ),
557 CPPU_TYPE_REF( util::XChangesNotifier ) );
558
559 return s_aReadWriteTypes.getTypes();
560 }
561}
562
563
564// XServiceInfo methods.
565
566OUString SAL_CALL HierarchyDataAccess::getImplementationName()
567{
568 return "com.sun.star.comp.ucb.HierarchyDataAccess";
569}
570
571sal_Bool SAL_CALL HierarchyDataAccess::supportsService( const OUString& ServiceName )
572{
573 return cppu::supportsService( this, ServiceName );
574}
575
576css::uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getSupportedServiceNames()
577{
579}
580
581
582// XComponent methods.
583
584
585// virtual
586void SAL_CALL HierarchyDataAccess::dispose()
587{
588 uno::Reference< lang::XComponent > xOrig
589 = ensureOrigInterface( m_xCfgC );
590
591 OSL_ENSURE( xOrig.is(),
592 "HierarchyDataAccess : Data source is not an XComponent!" );
593 xOrig->dispose();
594}
595
596
597// virtual
598void SAL_CALL HierarchyDataAccess::addEventListener(
599 const uno::Reference< lang::XEventListener > & xListener )
600{
601 uno::Reference< lang::XComponent > xOrig
602 = ensureOrigInterface( m_xCfgC );
603
604 OSL_ENSURE( xOrig.is(),
605 "HierarchyDataAccess : Data source is not an XComponent!" );
606 xOrig->addEventListener( xListener );
607}
608
609
610// virtual
611void SAL_CALL HierarchyDataAccess::removeEventListener(
612 const uno::Reference< lang::XEventListener > & aListener )
613{
614 uno::Reference< lang::XComponent > xOrig
615 = ensureOrigInterface( m_xCfgC );
616
617 OSL_ENSURE( xOrig.is(),
618 "HierarchyDataAccess : Data source is not an XComponent!" );
619 xOrig->removeEventListener( aListener );
620}
621
622
623// XHierarchicalNameAccess methods.
624
625
626// virtual
627uno::Any SAL_CALL HierarchyDataAccess::getByHierarchicalName(
628 const OUString & aName )
629{
630 uno::Reference< container::XHierarchicalNameAccess > xOrig
631 = ensureOrigInterface( m_xCfgHNA );
632
633 OSL_ENSURE( xOrig.is(),
634 "HierarchyDataAccess : "
635 "Data source is not an XHierarchicalNameAccess!" );
636 return xOrig->getByHierarchicalName( aName );
637}
638
639
640// virtual
641sal_Bool SAL_CALL HierarchyDataAccess::hasByHierarchicalName(
642 const OUString & aName )
643{
644 uno::Reference< container::XHierarchicalNameAccess > xOrig
645 = ensureOrigInterface( m_xCfgHNA );
646
647 OSL_ENSURE( xOrig.is(),
648 "HierarchyDataAccess : "
649 "Data source is not an XHierarchicalNameAccess!" );
650 return xOrig->hasByHierarchicalName( aName );
651}
652
653
654// XNameAccess methods.
655
656
657// virtual
658uno::Any SAL_CALL HierarchyDataAccess::getByName( const OUString & aName )
659{
660 uno::Reference< container::XNameAccess > xOrig
661 = ensureOrigInterface( m_xCfgNA );
662
663 OSL_ENSURE( xOrig.is(),
664 "HierarchyDataAccess : Data source is not an XNameAccess!" );
665 return xOrig->getByName( aName );
666}
667
668
669// virtual
670uno::Sequence< OUString > SAL_CALL HierarchyDataAccess::getElementNames()
671{
672 uno::Reference< container::XNameAccess > xOrig
673 = ensureOrigInterface( m_xCfgNA );
674
675 OSL_ENSURE( xOrig.is(),
676 "HierarchyDataAccess : Data source is not an XNameAccess!" );
677 return xOrig->getElementNames();
678}
679
680
681// virtual
682sal_Bool SAL_CALL HierarchyDataAccess::hasByName( const OUString & aName )
683{
684 uno::Reference< container::XNameAccess > xOrig
685 = ensureOrigInterface( m_xCfgNA );
686
687 OSL_ENSURE( xOrig.is(),
688 "HierarchyDataAccess : Data source is not an XNameAccess!" );
689 return xOrig->hasByName( aName );
690}
691
692
693// XElementAccess methods.
694
695
696// virtual
697uno::Type SAL_CALL HierarchyDataAccess::getElementType()
698{
699 uno::Reference< container::XElementAccess > xOrig
700 = ensureOrigInterface( m_xCfgEA );
701
702 OSL_ENSURE( xOrig.is(),
703 "HierarchyDataAccess : Data source is not an XElementAccess!" );
704 return xOrig->getElementType();
705}
706
707
708// virtual
709sal_Bool SAL_CALL HierarchyDataAccess::hasElements()
710{
711 uno::Reference< container::XElementAccess > xOrig
712 = ensureOrigInterface( m_xCfgEA );
713
714 OSL_ENSURE( xOrig.is(),
715 "HierarchyDataAccess : Data source is not an XElementAccess!" );
716 return xOrig->hasElements();
717}
718
719
720// XChangesNotifier methods.
721
722
723// virtual
724void SAL_CALL HierarchyDataAccess::addChangesListener(
725 const uno::Reference< util::XChangesListener > & aListener )
726{
727 uno::Reference< util::XChangesNotifier > xOrig
728 = ensureOrigInterface( m_xCfgCN );
729
730 OSL_ENSURE( xOrig.is(),
731 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
732 xOrig->addChangesListener( aListener );
733}
734
735
736// virtual
737void SAL_CALL HierarchyDataAccess::removeChangesListener(
738 const uno::Reference< util::XChangesListener > & aListener )
739{
740 uno::Reference< util::XChangesNotifier > xOrig
741 = ensureOrigInterface( m_xCfgCN );
742
743 OSL_ENSURE( xOrig.is(),
744 "HierarchyDataAccess : Data source is not an XChangesNotifier!" );
745 xOrig->removeChangesListener( aListener );
746}
747
748
749// XSingleServiceFactory methods.
750
751
752// virtual
753uno::Reference< uno::XInterface > SAL_CALL HierarchyDataAccess::createInstance()
754{
755 uno::Reference< lang::XSingleServiceFactory > xOrig
756 = ensureOrigInterface( m_xCfgSSF );
757
758 OSL_ENSURE( xOrig.is(),
759 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
760 return xOrig->createInstance();
761}
762
763
764// virtual
765uno::Reference< uno::XInterface > SAL_CALL
766HierarchyDataAccess::createInstanceWithArguments(
767 const uno::Sequence< uno::Any > & aArguments )
768{
769 uno::Reference< lang::XSingleServiceFactory > xOrig
770 = ensureOrigInterface( m_xCfgSSF );
771
772 OSL_ENSURE( xOrig.is(),
773 "HierarchyDataAccess : Data source is not an XSingleServiceFactory!" );
774 return xOrig->createInstanceWithArguments( aArguments );
775}
776
777
778// XNameContainer methods.
779
780
781// virtual
782void SAL_CALL
783HierarchyDataAccess::insertByName( const OUString & aName,
784 const uno::Any & aElement )
785{
786 uno::Reference< container::XNameContainer > xOrig
787 = ensureOrigInterface( m_xCfgNC );
788
789 OSL_ENSURE( xOrig.is(),
790 "HierarchyDataAccess : Data source is not an XNameContainer!" );
791 xOrig->insertByName( aName, aElement );
792}
793
794
795// virtual
796void SAL_CALL
797HierarchyDataAccess::removeByName( const OUString & Name )
798{
799 uno::Reference< container::XNameContainer > xOrig
800 = ensureOrigInterface( m_xCfgNC );
801
802 OSL_ENSURE( xOrig.is(),
803 "HierarchyDataAccess : Data source is not an XNameContainer!" );
804 xOrig->removeByName( Name );
805}
806
807
808// XNameReplace methods.
809
810
811// virtual
812void SAL_CALL HierarchyDataAccess::replaceByName( const OUString & aName,
813 const uno::Any & aElement )
814{
815 uno::Reference< container::XNameReplace > xOrig
816 = ensureOrigInterface( m_xCfgNR );
817
818 OSL_ENSURE( xOrig.is(),
819 "HierarchyDataAccess : Data source is not an XNameReplace!" );
820 xOrig->replaceByName( aName, aElement );
821}
822
823
824// XChangesBatch methods.
825
826
827// virtual
828void SAL_CALL HierarchyDataAccess::commitChanges()
829{
830 uno::Reference< util::XChangesBatch > xOrig
831 = ensureOrigInterface( m_xCfgCB );
832
833 OSL_ENSURE( xOrig.is(),
834 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
835 xOrig->commitChanges();
836}
837
838
839// virtual
840sal_Bool SAL_CALL HierarchyDataAccess::hasPendingChanges()
841{
842 uno::Reference< util::XChangesBatch > xOrig
843 = ensureOrigInterface( m_xCfgCB );
844
845 OSL_ENSURE( xOrig.is(),
846 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
847 return xOrig->hasPendingChanges();
848}
849
850
851// virtual
852uno::Sequence< util::ElementChange > SAL_CALL
853HierarchyDataAccess::getPendingChanges()
854{
855 uno::Reference< util::XChangesBatch > xOrig
856 = ensureOrigInterface( m_xCfgCB );
857
858 OSL_ENSURE( xOrig.is(),
859 "HierarchyDataAccess : Data source is not an XChangesBatch!" );
860 return xOrig->getPendingChanges();
861}
862
863/* 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