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