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