LibreOffice Module ucb (master)  1
ucbstore.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  *************************************************************************/
26 
27 #include <memory>
28 #include <unordered_map>
29 #include <sal/log.hxx>
30 #include <osl/diagnose.h>
31 #include <rtl/ustrbuf.hxx>
32 #include <rtl/ref.hxx>
36 #include <com/sun/star/beans/IllegalTypeException.hpp>
37 #include <com/sun/star/beans/NotRemoveableException.hpp>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/beans/PropertyExistException.hpp>
40 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
41 #include <com/sun/star/configuration/theDefaultProvider.hpp>
42 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
43 #include <com/sun/star/container/XNameContainer.hpp>
44 #include <com/sun/star/container/XNameReplace.hpp>
45 #include <com/sun/star/util/XChangesBatch.hpp>
46 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
47 #include <cppuhelper/implbase.hxx>
49 #include <ucbhelper/macros.hxx>
50 #include <tools/diagnose_ex.h>
51 #include "ucbstore.hxx"
52 
53 using namespace com::sun::star::beans;
54 using namespace com::sun::star::configuration;
55 using namespace com::sun::star::container;
56 using namespace com::sun::star::lang;
57 using namespace com::sun::star::ucb;
58 using namespace com::sun::star::uno;
59 using namespace com::sun::star::util;
60 using namespace comphelper;
61 using namespace cppu;
62 
63 
64 static OUString makeHierarchalNameSegment( const OUString & rIn )
65 {
66  OUStringBuffer aBuffer;
67  aBuffer.append( "['" );
68 
69  sal_Int32 nCount = rIn.getLength();
70  for ( sal_Int32 n = 0; n < nCount; ++n )
71  {
72  const sal_Unicode c = rIn[ n ];
73  switch ( c )
74  {
75  case '&':
76  aBuffer.append( "&amp;" );
77  break;
78 
79  case '"':
80  aBuffer.append( "&quot;" );
81  break;
82 
83  case '\'':
84  aBuffer.append( "&apos;" );
85  break;
86 
87  case '<':
88  aBuffer.append( "&lt;" );
89  break;
90 
91  case '>':
92  aBuffer.append( "&gt;" );
93  break;
94 
95  default:
96  aBuffer.append( c );
97  break;
98  }
99  }
100 
101  aBuffer.append( "']" );
102  return aBuffer.makeStringAndClear();
103 }
104 
105 #define STORE_CONTENTPROPERTIES_KEY "/org.openoffice.ucb.Store/ContentProperties"
106 
107 // describe path of cfg entry
108 #define CFGPROPERTY_NODEPATH "nodepath"
109 
110 // PropertySetMap_Impl.
111 typedef std::unordered_map< OUString, PersistentPropertySet*> PropertySetMap_Impl;
112 
113 namespace {
114 
115 class PropertySetInfo_Impl : public cppu::WeakImplHelper < XPropertySetInfo >
116 {
117  std::unique_ptr<Sequence< Property >>
118  m_pProps;
120 
121 public:
122  explicit PropertySetInfo_Impl(PersistentPropertySet* pOwner);
123 
124  // XPropertySetInfo
125  virtual Sequence< Property > SAL_CALL getProperties() override;
126  virtual Property SAL_CALL getPropertyByName( const OUString& aName ) override;
127  virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
128 
129  // Non-interface methods.
130  void reset() { m_pProps.reset(); }
131 };
132 
133 }
134 
135 // UcbStore_Impl.
136 
137 
139 {
140  osl::Mutex m_aMutex;
143 };
144 
145 
146 // UcbStore Implementation.
147 
148 
150 : m_xContext( xContext ),
151  m_pImpl( new UcbStore_Impl )
152 {
153 }
154 
155 
156 // virtual
158 {
159 }
160 
162  "com.sun.star.comp.ucb.UcbStore" )
164 static css::uno::Reference< css::uno::XInterface >
165 UcbStore_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
166 {
167  return static_cast<css::lang::XServiceInfo*>(
169 }
170 
171 css::uno::Sequence< OUString >
173 {
174  css::uno::Sequence< OUString > aSNS { STORE_SERVICE_NAME };
175  return aSNS;
176 }
177 
178 // Service factory implementation.
179 
180 
182 
183 
184 // XPropertySetRegistryFactory methods.
185 
186 
187 // virtual
190 {
191  // The URL parameter is ignored by this interface implementation. It always
192  // uses the configuration server as storage medium.
193 
194  if ( !m_pImpl->m_xTheRegistry.is() )
195  {
196  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
197  if ( !m_pImpl->m_xTheRegistry.is() )
198  m_pImpl->m_xTheRegistry = new PropertySetRegistry( m_xContext, m_pImpl->m_aInitArgs );
199  }
200 
201  return m_pImpl->m_xTheRegistry;
202 }
203 
204 
205 // XInitialization methods.
206 
207 
208 // virtual
209 void SAL_CALL UcbStore::initialize( const Sequence< Any >& aArguments )
210 {
211  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
212  m_pImpl->m_aInitArgs = aArguments;
213 }
214 
215 
216 
217 // PropertySetRegistry_Impl.
218 
219 
221 {
227  osl::Mutex m_aMutex;
230 
231  explicit PropertySetRegistry_Impl(const Sequence<Any> &rInitArgs)
232  : m_aInitArgs(rInitArgs)
233  , m_bTriedToGetRootReadAccess(false)
234  , m_bTriedToGetRootWriteAccess(false)
235  {
236  }
237 };
238 
239 // PropertySetRegistry Implementation.
240 
241 
243  const Reference< XComponentContext >& xContext,
244  const Sequence< Any > &rInitArgs )
245 : m_xContext( xContext ),
246  m_pImpl( new PropertySetRegistry_Impl( rInitArgs ) )
247 {
248 }
249 
250 
251 // virtual
253 {
254 }
255 
256 
257 // XServiceInfo methods.
258 
259 
261 {
262  return "com.sun.star.comp.ucb.PropertySetRegistry";
263 }
264 
265 sal_Bool SAL_CALL PropertySetRegistry::supportsService( const OUString& ServiceName )
266 {
267  return cppu::supportsService( this, ServiceName );
268 }
269 
270 css::uno::Sequence< OUString > SAL_CALL PropertySetRegistry::getSupportedServiceNames()
271 {
272  return { PROPSET_REG_SERVICE_NAME };
273 }
274 
275 
276 // XPropertySetRegistry methods.
277 
278 
279 // virtual
281 PropertySetRegistry::openPropertySet( const OUString& key, sal_Bool create )
282 {
283  if ( !key.isEmpty() )
284  {
285  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
286 
287  PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
288 
289  PropertySetMap_Impl::const_iterator it = rSets.find( key );
290  if ( it != rSets.end() )
291  {
292  // Already instantiated.
293  return Reference< XPersistentPropertySet >( (*it).second );
294  }
295  else
296  {
297  // Create new instance.
298  Reference< XNameAccess > xRootNameAccess(
299  getRootConfigReadAccess(), UNO_QUERY );
300  if ( xRootNameAccess.is() )
301  {
302  // Propertyset in registry?
303  if ( xRootNameAccess->hasByName( key ) )
304  {
305  // Yep!
308  *this, key ) );
309  }
310  else if ( create )
311  {
312  // No. Create entry for propertyset.
313 
315  getConfigWriteAccess( OUString() ), UNO_QUERY );
316  Reference< XChangesBatch > xBatch( xFac, UNO_QUERY );
317  Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
318 
319  OSL_ENSURE( xFac.is(),
320  "PropertySetRegistry::openPropertySet - "
321  "No factory!" );
322 
323  OSL_ENSURE( xBatch.is(),
324  "PropertySetRegistry::openPropertySet - "
325  "No batch!" );
326 
327  OSL_ENSURE( xContainer.is(),
328  "PropertySetRegistry::openPropertySet - "
329  "No container!" );
330 
331  if ( xFac.is() && xBatch.is() && xContainer.is() )
332  {
333  try
334  {
335  // Create new "Properties" config item.
336  Reference< XNameReplace > xNameReplace(
337  xFac->createInstance(), UNO_QUERY );
338 
339  if ( xNameReplace.is() )
340  {
341  // Fill new item...
342 
343  // Insert new item.
344  xContainer->insertByName(
345  key, makeAny( xNameReplace ) );
346  // Commit changes.
347  xBatch->commitChanges();
348 
351  *this, key ) );
352  }
353  }
354  catch (const IllegalArgumentException&)
355  {
356  // insertByName
357 
358  OSL_FAIL( "PropertySetRegistry::openPropertySet - "
359  "caught IllegalArgumentException!" );
360  }
361  catch (const ElementExistException&)
362  {
363  // insertByName
364 
365  OSL_FAIL( "PropertySetRegistry::openPropertySet - "
366  "caught ElementExistException!" );
367  }
368  catch (const WrappedTargetException&)
369  {
370  // insertByName, commitChanges
371 
372  OSL_FAIL( "PropertySetRegistry::openPropertySet - "
373  "caught WrappedTargetException!" );
374  }
375  catch (const RuntimeException&)
376  {
377  OSL_FAIL( "PropertySetRegistry::openPropertySet - "
378  "caught RuntimeException!" );
379  }
380  catch (const Exception&)
381  {
382  // createInstance
383 
384  OSL_FAIL( "PropertySetRegistry::openPropertySet - "
385  "caught Exception!" );
386  }
387  }
388  }
389  else
390  {
391  // No entry. Fail, but no error.
393  }
394  }
395 
396  SAL_WARN( "ucb", "no root access" );
397  }
398  }
399 
401 }
402 
403 
404 // virtual
405 void SAL_CALL PropertySetRegistry::removePropertySet( const OUString& key )
406 {
407  if ( key.isEmpty() )
408  return;
409 
410  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
411 
412  Reference< XNameAccess > xRootNameAccess(
413  getRootConfigReadAccess(), UNO_QUERY );
414  if ( xRootNameAccess.is() )
415  {
416  // Propertyset in registry?
417  if ( !xRootNameAccess->hasByName( key ) )
418  return;
420  getConfigWriteAccess( OUString() ), UNO_QUERY );
421  Reference< XNameContainer > xContainer( xBatch, UNO_QUERY );
422 
423  if ( xBatch.is() && xContainer.is() )
424  {
425  try
426  {
427  // Remove item.
428  xContainer->removeByName( key );
429  // Commit changes.
430  xBatch->commitChanges();
431 
432  // Success.
433  return;
434  }
435  catch (const NoSuchElementException&)
436  {
437  // removeByName
438 
439  OSL_FAIL( "PropertySetRegistry::removePropertySet - "
440  "caught NoSuchElementException!" );
441  return;
442  }
443  catch (const WrappedTargetException&)
444  {
445  // commitChanges
446 
447  OSL_FAIL( "PropertySetRegistry::removePropertySet - "
448  "caught WrappedTargetException!" );
449  return;
450  }
451  }
452 
453  return;
454  }
455 
456  SAL_WARN( "ucb", "no root access" );
457 }
458 
459 
460 // XElementAccess methods.
461 
462 
463 // virtual
464 css::uno::Type SAL_CALL PropertySetRegistry::getElementType()
465 {
467 }
468 
469 
470 // virtual
472 {
473  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
474 
475  Reference< XElementAccess > xElemAccess(
476  getRootConfigReadAccess(), UNO_QUERY );
477  if ( xElemAccess.is() )
478  return xElemAccess->hasElements();
479 
480  return false;
481 }
482 
483 
484 // XNameAccess methods.
485 
486 
487 // virtual
488 Any SAL_CALL PropertySetRegistry::getByName( const OUString& aName )
489 {
490  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
491 
492  Reference< XNameAccess > xNameAccess(
493  getRootConfigReadAccess(), UNO_QUERY );
494  if ( xNameAccess.is() )
495  {
496 
497  try
498  {
499  return xNameAccess->getByName( aName );
500  }
501  catch (const NoSuchElementException&)
502  {
503  // getByName
504  }
505  catch (const WrappedTargetException&)
506  {
507  // getByName
508  }
509  }
510 
511  return Any();
512 }
513 
514 
515 // virtual
517 {
518  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
519 
520  Reference< XNameAccess > xNameAccess(
521  getRootConfigReadAccess(), UNO_QUERY );
522  if ( xNameAccess.is() )
523  {
524  return xNameAccess->getElementNames();
525  }
526  return Sequence< OUString >( 0 );
527 }
528 
529 
530 // virtual
531 sal_Bool SAL_CALL PropertySetRegistry::hasByName( const OUString& aName )
532 {
533  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
534 
535  Reference< XNameAccess > xNameAccess(
536  getRootConfigReadAccess(), UNO_QUERY );
537  if ( xNameAccess.is() )
538  {
539  return xNameAccess->hasByName( aName );
540  }
541 
542  return false;
543 }
544 
545 
547 {
548  OUString key( pSet->getKey() );
549 
550  if ( !key.isEmpty() )
551  {
552  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
553  m_pImpl->m_aPropSets[ key ] = pSet;
554  }
555 }
556 
557 
559 {
560  OUString key( pSet->getKey() );
561 
562  if ( !key.isEmpty() )
563  {
564  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
565 
566  PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
567 
568  PropertySetMap_Impl::iterator it = rSets.find( key );
569  if ( it != rSets.end() )
570  {
571  // Found.
572  rSets.erase( it );
573  }
574  }
575 }
576 
577 
578 void PropertySetRegistry::renamePropertySet( const OUString& rOldKey,
579  const OUString& rNewKey )
580 {
581  if ( rOldKey == rNewKey )
582  return;
583 
584  Reference< XNameAccess > xRootNameAccess(
585  getConfigWriteAccess( OUString() ), UNO_QUERY );
586  if ( xRootNameAccess.is() )
587  {
588  // Old key present?
589  if ( xRootNameAccess->hasByName( rOldKey ) )
590  {
591  // New key not present?
592  if ( xRootNameAccess->hasByName( rNewKey ) )
593  {
594  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
595  "New key exists!" );
596  return;
597  }
599  xRootNameAccess, UNO_QUERY );
600  Reference< XChangesBatch > xBatch( xFac, UNO_QUERY );
601  Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
602 
603  OSL_ENSURE( xFac.is(),
604  "PropertySetRegistry::renamePropertySet - "
605  "No factory!" );
606 
607  OSL_ENSURE( xBatch.is(),
608  "PropertySetRegistry::renamePropertySet - "
609  "No batch!" );
610 
611  OSL_ENSURE( xContainer.is(),
612  "PropertySetRegistry::renamePropertySet - "
613  "No container!" );
614 
615  if ( xFac.is() && xBatch.is() && xContainer.is() )
616  {
617 
618  // Create new "Properties" config item.
619 
620 
621  try
622  {
623  Reference< XNameReplace > xNameReplace(
624  xFac->createInstance(), UNO_QUERY );
625 
626  if ( xNameReplace.is() )
627  {
628  // Insert new item.
629  xContainer->insertByName(
630  rNewKey, makeAny( xNameReplace ) );
631  // Commit changes.
632  xBatch->commitChanges();
633  }
634  }
635  catch (const IllegalArgumentException&)
636  {
637  // insertByName
638 
639  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
640  "caught IllegalArgumentException!" );
641  return;
642  }
643  catch (const ElementExistException&)
644  {
645  // insertByName
646 
647  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
648  "caught ElementExistException!" );
649  return;
650  }
651  catch (const WrappedTargetException&)
652  {
653  // insertByName, commitChanges
654 
655  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
656  "caught WrappedTargetException!" );
657  return;
658  }
659  catch (const RuntimeException&)
660  {
661  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
662  "caught RuntimeException!" );
663  return;
664  }
665  catch (const Exception&)
666  {
667  // createInstance
668 
669  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
670  "caught Exception!" );
671  return;
672  }
673 
674 
675  // Copy data...
676 
677 
678  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
679  xRootNameAccess, UNO_QUERY );
680  if ( !xRootHierNameAccess.is() )
681  {
682  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
683  "No hierarchical name access!" );
684  return;
685  }
686 
687  try
688  {
689  OUString aOldValuesKey
690  = makeHierarchalNameSegment( rOldKey ) + "/Values";
691 
692  Reference< XNameAccess > xOldNameAccess;
693  xRootHierNameAccess->getByHierarchicalName(
694  aOldValuesKey )
695  >>= xOldNameAccess;
696  if ( !xOldNameAccess.is() )
697  {
698  OSL_FAIL( "PersistentPropertySet::renamePropertySet - "
699  "No old name access!" );
700  return;
701  }
702 
703  // Obtain property names.
704  const Sequence< OUString > aElems
705  = xOldNameAccess->getElementNames();
706  if ( aElems.hasElements() )
707  {
708  OUString aNewValuesKey
709  = makeHierarchalNameSegment( rNewKey ) + "/Values";
710 
712  xRootHierNameAccess->getByHierarchicalName(
713  aNewValuesKey )
714  >>= xNewFac;
715  if ( !xNewFac.is() )
716  {
717  OSL_FAIL( "PersistentPropertySet::renamePropertySet - "
718  "No new factory!" );
719  return;
720  }
721 
722  Reference< XNameContainer > xNewContainer(
723  xNewFac, UNO_QUERY );
724  if ( !xNewContainer.is() )
725  {
726  OSL_FAIL( "PersistentPropertySet::renamePropertySet - "
727  "No new container!" );
728  return;
729  }
730 
731  aOldValuesKey += "/";
732 
733  OUString const aHandleKey("/Handle");
734  OUString const aValueKey("/Value");
735  OUString const aStateKey("/State");
736  OUString const aAttrKey("/Attributes");
737 
738  for ( const OUString& rPropName : aElems )
739  {
740  // Create new item.
741  Reference< XNameReplace > xNewPropNameReplace(
742  xNewFac->createInstance(), UNO_QUERY );
743 
744  if ( !xNewPropNameReplace.is() )
745  {
746  OSL_FAIL( "PersistentPropertySet::renamePropertySet - "
747  "No new prop name replace!" );
748  return;
749  }
750 
751  // Fill new item...
752 
753  // Set Values
754  OUString aKey = aOldValuesKey;
755  aKey += makeHierarchalNameSegment( rPropName );
756 
757  // ... handle
758  OUString aNewKey1 = aKey + aHandleKey;
759  Any aAny =
760  xRootHierNameAccess->getByHierarchicalName(
761  aNewKey1 );
762  xNewPropNameReplace->replaceByName( "Handle", aAny );
763 
764  // ... value
765  aNewKey1 = aKey + aValueKey;
766  aAny =
767  xRootHierNameAccess->getByHierarchicalName(
768  aNewKey1 );
769  xNewPropNameReplace->replaceByName( "Value", aAny );
770 
771  // ... state
772  aNewKey1 = aKey + aStateKey;
773  aAny =
774  xRootHierNameAccess->getByHierarchicalName(
775  aNewKey1 );
776  xNewPropNameReplace->replaceByName( "State", aAny );
777 
778  // ... attributes
779  aNewKey1 = aKey + aAttrKey;
780  aAny =
781  xRootHierNameAccess->getByHierarchicalName(
782  aNewKey1 );
783  xNewPropNameReplace->replaceByName( "Attributes", aAny );
784 
785  // Insert new item.
786  xNewContainer->insertByName(
787  rPropName, makeAny( xNewPropNameReplace ) );
788 
789  // Commit changes.
790  xBatch->commitChanges();
791  }
792  }
793  }
794  catch (const IllegalArgumentException&)
795  {
796  // insertByName, replaceByName
797 
798  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
799  "caught IllegalArgumentException!" );
800  return;
801  }
802  catch (const ElementExistException&)
803  {
804  // insertByName
805 
806  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
807  "caught ElementExistException!" );
808  return;
809  }
810  catch (const WrappedTargetException&)
811  {
812  // insertByName, replaceByName, commitChanges
813 
814  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
815  "caught WrappedTargetException!" );
816  return;
817  }
818  catch (const NoSuchElementException&)
819  {
820  // getByHierarchicalName, replaceByName
821 
822  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
823  "caught NoSuchElementException!" );
824  return;
825  }
826  catch (const RuntimeException&)
827  {
828  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
829  "caught RuntimeException!" );
830  return;
831  }
832  catch (const Exception&)
833  {
834  // createInstance
835 
836  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
837  "caught Exception!" );
838  return;
839  }
840 
841 
842  // Remove old entry...
843 
844 
845  try
846  {
847  // Remove item.
848  xContainer->removeByName( rOldKey );
849  // Commit changes.
850  xBatch->commitChanges();
851 
852  // Success.
853  return;
854  }
855  catch (const NoSuchElementException&)
856  {
857  // removeByName
858 
859  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
860  "caught NoSuchElementException!" );
861  return;
862  }
863  catch (const WrappedTargetException&)
864  {
865  // commitChanges
866 
867  OSL_FAIL( "PropertySetRegistry::renamePropertySet - "
868  "caught WrappedTargetException!" );
869  return;
870  }
871  }
872  }
873  }
874 
875  OSL_FAIL( "PropertySetRegistry::renamePropertySet - Error!" );
876 }
877 
878 
880 {
881  if ( !m_pImpl->m_xConfigProvider.is() )
882  {
883  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
884  if ( !m_pImpl->m_xConfigProvider.is() )
885  {
886  const Sequence< Any >& rInitArgs = m_pImpl->m_aInitArgs;
887 
888  if ( rInitArgs.hasElements() )
889  {
890  // Extract config provider from service init args.
891  rInitArgs[ 0 ] >>= m_pImpl->m_xConfigProvider;
892 
893  OSL_ENSURE( m_pImpl->m_xConfigProvider.is(),
894  "PropertySetRegistry::getConfigProvider - "
895  "No config provider!" );
896  }
897  else
898  {
899  try
900  {
901  m_pImpl->m_xConfigProvider = theDefaultProvider::get( m_xContext );
902  }
903  catch (const Exception&)
904  {
905  TOOLS_WARN_EXCEPTION( "ucb", "");
906  }
907  }
908  }
909  }
910 
911  return m_pImpl->m_xConfigProvider;
912 }
913 
914 
916 {
917  try
918  {
919  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
920 
921  if ( !m_pImpl->m_xRootReadAccess.is() )
922  {
923  if ( m_pImpl->m_bTriedToGetRootReadAccess )
924  {
925  OSL_FAIL( "PropertySetRegistry::getRootConfigReadAccess - "
926  "Unable to read any config data! -> #82494#" );
927  return Reference< XInterface >();
928  }
929 
931 
932  if ( m_pImpl->m_xConfigProvider.is() )
933  {
935  {
937  }));
938 
939  m_pImpl->m_bTriedToGetRootReadAccess = true;
940 
941  m_pImpl->m_xRootReadAccess =
942  m_pImpl->m_xConfigProvider->createInstanceWithArguments(
943  "com.sun.star.configuration.ConfigurationAccess",
944  aArguments );
945 
946  if ( m_pImpl->m_xRootReadAccess.is() )
947  return m_pImpl->m_xRootReadAccess;
948  }
949  }
950  else
951  return m_pImpl->m_xRootReadAccess;
952  }
953  catch (const RuntimeException&)
954  {
955  throw;
956  }
957  catch (const Exception&)
958  {
959  // createInstance, createInstanceWithArguments
960 
961  OSL_FAIL( "PropertySetRegistry::getRootConfigReadAccess - caught Exception!" );
962  return Reference< XInterface >();
963  }
964 
965  SAL_WARN( "ucb", "Error!" );
966  return Reference< XInterface >();
967 }
968 
969 
971  const OUString& rPath )
972 {
973  try
974  {
975  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
976 
977  if ( !m_pImpl->m_xRootWriteAccess.is() )
978  {
979  if ( m_pImpl->m_bTriedToGetRootWriteAccess )
980  {
981  OSL_FAIL( "PropertySetRegistry::getConfigWriteAccess - "
982  "Unable to write any config data! -> #82494#" );
983  return Reference< XInterface >();
984  }
985 
987 
988  if ( m_pImpl->m_xConfigProvider.is() )
989  {
991  {
993  }));
994 
995  m_pImpl->m_bTriedToGetRootWriteAccess = true;
996 
997  m_pImpl->m_xRootWriteAccess =
998  m_pImpl->m_xConfigProvider->createInstanceWithArguments(
999  "com.sun.star.configuration.ConfigurationUpdateAccess",
1000  aArguments );
1001 
1002  OSL_ENSURE( m_pImpl->m_xRootWriteAccess.is(),
1003  "PropertySetRegistry::getConfigWriteAccess - "
1004  "No config update access!" );
1005  }
1006  }
1007 
1008  if ( m_pImpl->m_xRootWriteAccess.is() )
1009  {
1010  if ( !rPath.isEmpty() )
1011  {
1013  m_pImpl->m_xRootWriteAccess, UNO_QUERY );
1014  if ( xNA.is() )
1015  {
1016  Reference< XInterface > xInterface;
1017  xNA->getByHierarchicalName( rPath ) >>= xInterface;
1018 
1019  if ( xInterface.is() )
1020  return xInterface;
1021  }
1022  }
1023  else
1024  return m_pImpl->m_xRootWriteAccess;
1025  }
1026  }
1027  catch (const RuntimeException&)
1028  {
1029  throw;
1030  }
1031  catch (const NoSuchElementException&)
1032  {
1033  // getByHierarchicalName
1034 
1035  OSL_FAIL( "PropertySetRegistry::getConfigWriteAccess - "
1036  "caught NoSuchElementException!" );
1037  return Reference< XInterface >();
1038  }
1039  catch (const Exception&)
1040  {
1041  // createInstance, createInstanceWithArguments
1042 
1043  OSL_FAIL( "PropertySetRegistry::getConfigWriteAccess - "
1044  "caught Exception!" );
1045  return Reference< XInterface >();
1046  }
1047 
1048  OSL_FAIL( "PropertySetRegistry::getConfigWriteAccess - Error!" );
1049  return Reference< XInterface >();
1050 }
1051 
1053 
1055 {
1058  OUString m_aKey;
1059  OUString m_aFullKey;
1060  osl::Mutex m_aMutex;
1061  std::unique_ptr<OInterfaceContainerHelper2> m_pDisposeEventListeners;
1062  std::unique_ptr<OInterfaceContainerHelper2> m_pPropSetChangeListeners;
1063  std::unique_ptr<PropertyListeners_Impl> m_pPropertyChangeListeners;
1064 
1066  const OUString& rKey )
1067  : m_pCreator( &rCreator ), m_aKey( rKey )
1068  {
1069  }
1070 };
1071 
1072 
1073 // PersistentPropertySet Implementation.
1074 
1075 
1077  PropertySetRegistry& rCreator,
1078  const OUString& rKey )
1079 : m_pImpl( new PersistentPropertySet_Impl( rCreator, rKey ) )
1080 {
1081  // register at creator.
1082  rCreator.add( this );
1083 }
1084 
1085 
1086 // virtual
1088 {
1089  // deregister at creator.
1090  m_pImpl->m_pCreator->remove( this );
1091 }
1092 
1093 // XServiceInfo methods.
1094 
1096 {
1097  return "com.sun.star.comp.ucb.PersistentPropertySet";
1098 }
1099 
1100 sal_Bool SAL_CALL PersistentPropertySet::supportsService( const OUString& ServiceName )
1101 {
1102  return cppu::supportsService( this, ServiceName );
1103 }
1104 
1105 css::uno::Sequence< OUString > SAL_CALL
1107 {
1108  return { PERS_PROPSET_SERVICE_NAME };
1109 }
1110 
1111 
1112 // XComponent methods.
1113 
1114 
1115 // virtual
1117 {
1118  if ( m_pImpl->m_pDisposeEventListeners &&
1119  m_pImpl->m_pDisposeEventListeners->getLength() )
1120  {
1121  EventObject aEvt;
1122  aEvt.Source = static_cast< XComponent * >( this );
1123  m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
1124  }
1125 
1126  if ( m_pImpl->m_pPropSetChangeListeners &&
1127  m_pImpl->m_pPropSetChangeListeners->getLength() )
1128  {
1129  EventObject aEvt;
1130  aEvt.Source = static_cast< XPropertySetInfoChangeNotifier * >( this );
1131  m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
1132  }
1133 
1134  if ( m_pImpl->m_pPropertyChangeListeners )
1135  {
1136  EventObject aEvt;
1137  aEvt.Source = static_cast< XPropertySet * >( this );
1138  m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
1139  }
1140 }
1141 
1142 
1143 // virtual
1145  const Reference< XEventListener >& Listener )
1146 {
1147  if ( !m_pImpl->m_pDisposeEventListeners )
1148  m_pImpl->m_pDisposeEventListeners.reset(
1149  new OInterfaceContainerHelper2( m_pImpl->m_aMutex ) );
1150 
1151  m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
1152 }
1153 
1154 
1155 // virtual
1157  const Reference< XEventListener >& Listener )
1158 {
1159  if ( m_pImpl->m_pDisposeEventListeners )
1160  m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
1161 
1162  // Note: Don't want to delete empty container here -> performance.
1163 }
1164 
1165 
1166 // XPropertySet methods.
1167 
1168 
1169 // virtual
1171 {
1172  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1173 
1174  if ( !m_pImpl->m_pInfo.is() )
1175  {
1176  m_pImpl->m_pInfo = new PropertySetInfo_Impl( this );
1177  }
1178  return Reference< XPropertySetInfo >( m_pImpl->m_pInfo.get() );
1179 }
1180 
1181 
1182 // virtual
1183 void SAL_CALL PersistentPropertySet::setPropertyValue( const OUString& aPropertyName,
1184  const Any& aValue )
1185 {
1186  osl::ClearableGuard< osl::Mutex > aCGuard( m_pImpl->m_aMutex );
1187 
1188  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1189  m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1190  if ( xRootHierNameAccess.is() )
1191  {
1192  OUString aFullPropName( getFullKey() + "/" );
1193  aFullPropName += makeHierarchalNameSegment( aPropertyName );
1194 
1195  // Does property exist?
1196  if ( xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1197  {
1198  Reference< XNameReplace > xNameReplace(
1199  m_pImpl->m_pCreator->getConfigWriteAccess(
1200  aFullPropName ), UNO_QUERY );
1202  m_pImpl->m_pCreator->getConfigWriteAccess(
1203  OUString() ), UNO_QUERY );
1204 
1205  if ( xNameReplace.is() && xBatch.is() )
1206  {
1207  try
1208  {
1209  // Obtain old value
1210  OUString aValueName = aFullPropName + "/Value";
1211  Any aOldValue
1212  = xRootHierNameAccess->getByHierarchicalName(
1213  aValueName );
1214  // Check value type.
1215  if ( aOldValue.getValueType() != aValue.getValueType() )
1216  {
1217  aCGuard.clear();
1218  throw IllegalArgumentException();
1219  }
1220 
1221  // Write value
1222  xNameReplace->replaceByName( "Value", aValue );
1223 
1224  // Write state ( Now it is a directly set value )
1225  xNameReplace->replaceByName(
1226  "State",
1227  makeAny(
1228  sal_Int32(
1229  PropertyState_DIRECT_VALUE ) ) );
1230 
1231  // Commit changes.
1232  xBatch->commitChanges();
1233 
1234  PropertyChangeEvent aEvt;
1235  if ( m_pImpl->m_pPropertyChangeListeners )
1236  {
1237  // Obtain handle
1238  aValueName = aFullPropName + "/Handle";
1239  sal_Int32 nHandle = -1;
1240  xRootHierNameAccess->getByHierarchicalName( aValueName )
1241  >>= nHandle;
1242 
1243  aEvt.Source = static_cast<OWeakObject*>(this);
1244  aEvt.PropertyName = aPropertyName;
1245  aEvt.PropertyHandle = nHandle;
1246  aEvt.Further = false;
1247  aEvt.OldValue = aOldValue;
1248  aEvt.NewValue = aValue;
1249 
1250  // Callback follows!
1251  aCGuard.clear();
1252 
1253  notifyPropertyChangeEvent( aEvt );
1254  }
1255  return;
1256  }
1257  catch (const IllegalArgumentException&)
1258  {
1259  // replaceByName
1260  }
1261  catch (const NoSuchElementException&)
1262  {
1263  // getByHierarchicalName, replaceByName
1264  }
1265  catch (const WrappedTargetException&)
1266  {
1267  // replaceByName, commitChanges
1268  }
1269  }
1270  }
1271  }
1272 
1273  throw UnknownPropertyException(aPropertyName);
1274 }
1275 
1276 
1277 // virtual
1279  const OUString& PropertyName )
1280 {
1281  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1282 
1284  m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1285  if ( xNameAccess.is() )
1286  {
1287  OUString aFullPropName( getFullKey() + "/" );
1288  aFullPropName += makeHierarchalNameSegment( PropertyName ) + "/Value";
1289  try
1290  {
1291  return xNameAccess->getByHierarchicalName( aFullPropName );
1292  }
1293  catch (const NoSuchElementException&)
1294  {
1295  throw UnknownPropertyException(aFullPropName);
1296  }
1297  }
1298 
1299  throw UnknownPropertyException(PropertyName);
1300 }
1301 
1302 
1303 // virtual
1305  const OUString& aPropertyName,
1306  const Reference< XPropertyChangeListener >& xListener )
1307 {
1308 // load();
1309 
1310  if ( !m_pImpl->m_pPropertyChangeListeners )
1311  m_pImpl->m_pPropertyChangeListeners.reset(
1312  new PropertyListeners_Impl( m_pImpl->m_aMutex ) );
1313 
1314  m_pImpl->m_pPropertyChangeListeners->addInterface(
1315  aPropertyName, xListener );
1316 }
1317 
1318 
1319 // virtual
1321  const OUString& aPropertyName,
1322  const Reference< XPropertyChangeListener >& aListener )
1323 {
1324 // load();
1325 
1326  if ( m_pImpl->m_pPropertyChangeListeners )
1327  m_pImpl->m_pPropertyChangeListeners->removeInterface(
1328  aPropertyName, aListener );
1329 
1330  // Note: Don't want to delete empty container here -> performance.
1331 }
1332 
1333 
1334 // virtual
1336  const OUString&,
1338 {
1339 // load();
1340 // OSL_FAIL( // "PersistentPropertySet::addVetoableChangeListener - N.Y.I." );
1341 }
1342 
1343 
1344 // virtual
1346  const OUString&,
1348 {
1349 // load();
1350 // OSL_FAIL( // "PersistentPropertySet::removeVetoableChangeListener - N.Y.I." );
1351 }
1352 
1353 
1354 // XPersistentPropertySet methods.
1355 
1356 
1357 // virtual
1359 {
1360  return Reference< XPropertySetRegistry >( m_pImpl->m_pCreator.get() );
1361 }
1362 
1363 
1364 // virtual
1366 {
1367  return m_pImpl->m_aKey;
1368 }
1369 
1370 
1371 // XNamed methods.
1372 
1373 
1374 // virtual
1376 {
1377  // same as getKey()
1378  return m_pImpl->m_aKey;
1379 }
1380 
1381 
1382 // virtual
1383 void SAL_CALL PersistentPropertySet::setName( const OUString& aName )
1384 {
1385  if ( aName != m_pImpl->m_aKey )
1386  m_pImpl->m_pCreator->renamePropertySet( m_pImpl->m_aKey, aName );
1387 }
1388 
1389 
1390 // XPropertyContainer methods.
1391 
1392 
1393 // virtual
1395  const OUString& Name, sal_Int16 Attributes, const Any& DefaultValue )
1396 {
1397  if ( Name.isEmpty() )
1398  throw IllegalArgumentException();
1399 
1400  // @@@ What other types can't be written to config server?
1401 
1402  // Check type class ( Not all types can be written to storage )
1403  TypeClass eTypeClass = DefaultValue.getValueTypeClass();
1404  if ( eTypeClass == TypeClass_INTERFACE )
1405  throw IllegalTypeException();
1406 
1407  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1408 
1409  // Property already in set?
1410 
1411  OUString aFullValuesName;
1412 
1413  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1414  m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1415  if ( xRootHierNameAccess.is() )
1416  {
1417  aFullValuesName = getFullKey();
1418  OUString aFullPropName = aFullValuesName + "/";
1419  aFullPropName += makeHierarchalNameSegment( Name );
1420 
1421  if ( xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1422  {
1423  // Already in set.
1424  throw PropertyExistException();
1425  }
1426  }
1427 
1428  // Property is always removable.
1429  Attributes |= PropertyAttribute::REMOVABLE;
1430 
1431  // Add property.
1432 
1434  m_pImpl->m_pCreator->getConfigWriteAccess( aFullValuesName ),
1435  UNO_QUERY );
1436  Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
1438  m_pImpl->m_pCreator->getConfigWriteAccess( OUString() ),
1439  UNO_QUERY );
1440 
1441  OSL_ENSURE( xFac.is(),
1442  "PersistentPropertySet::addProperty - No factory!" );
1443 
1444  OSL_ENSURE( xBatch.is(),
1445  "PersistentPropertySet::addProperty - No batch!" );
1446 
1447  OSL_ENSURE( xContainer.is(),
1448  "PersistentPropertySet::addProperty - No container!" );
1449 
1450  if ( xFac.is() && xBatch.is() && xContainer.is() )
1451  {
1452  try
1453  {
1454  // Create new "PropertyValue" config item.
1455  Reference< XNameReplace > xNameReplace(
1456  xFac->createInstance(), UNO_QUERY );
1457 
1458  if ( xNameReplace.is() )
1459  {
1460  // Fill new item...
1461 
1462  // Set handle
1463  xNameReplace->replaceByName(
1464  "Handle",
1465  makeAny( sal_Int32( -1 ) ) );
1466 
1467  // Set default value
1468  xNameReplace->replaceByName(
1469  "Value",
1470  DefaultValue );
1471 
1472  // Set state ( always "default" )
1473  xNameReplace->replaceByName(
1474  "State",
1475  makeAny(
1476  sal_Int32(
1477  PropertyState_DEFAULT_VALUE ) ) );
1478 
1479  // Set attributes
1480  xNameReplace->replaceByName(
1481  "Attributes",
1482  makeAny( sal_Int32( Attributes ) ) );
1483 
1484  // Insert new item.
1485  xContainer->insertByName( Name, makeAny( xNameReplace ) );
1486 
1487  // Commit changes.
1488  xBatch->commitChanges();
1489 
1490  // Property set info is invalid.
1491  if ( m_pImpl->m_pInfo.is() )
1492  m_pImpl->m_pInfo->reset();
1493 
1494  // Notify propertyset info change listeners.
1495  if ( m_pImpl->m_pPropSetChangeListeners &&
1496  m_pImpl->m_pPropSetChangeListeners->getLength() )
1497  {
1498  PropertySetInfoChangeEvent evt(
1499  static_cast< OWeakObject * >( this ),
1500  Name,
1501  -1,
1502  PropertySetInfoChange::PROPERTY_INSERTED );
1504  }
1505 
1506  // Success.
1507  return;
1508  }
1509  }
1510  catch (const IllegalArgumentException&)
1511  {
1512  // insertByName
1513 
1514  OSL_FAIL( "PersistentPropertySet::addProperty - "
1515  "caught IllegalArgumentException!" );
1516  return;
1517  }
1518  catch (const ElementExistException&)
1519  {
1520  // insertByName
1521 
1522  OSL_FAIL( "PersistentPropertySet::addProperty - "
1523  "caught ElementExistException!" );
1524  return;
1525  }
1526  catch (const WrappedTargetException&)
1527  {
1528  // replaceByName, insertByName, commitChanges
1529 
1530  OSL_FAIL( "PersistentPropertySet::addProperty - "
1531  "caught WrappedTargetException!" );
1532  return;
1533  }
1534  catch (const RuntimeException&)
1535  {
1536  throw;
1537  }
1538  catch (const Exception&)
1539  {
1540  // createInstance
1541 
1542  OSL_FAIL( "PersistentPropertySet::addProperty - "
1543  "caught Exception!" );
1544  return;
1545  }
1546  }
1547 
1548  OSL_FAIL( "PersistentPropertySet::addProperty - Error!" );
1549 }
1550 
1551 
1552 // virtual
1553 void SAL_CALL PersistentPropertySet::removeProperty( const OUString& Name )
1554 {
1555  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1556 
1557  OUString aFullValuesName;
1558  OUString aFullPropName;
1559 
1560  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1561  m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1562  if ( xRootHierNameAccess.is() )
1563  {
1564  aFullValuesName = getFullKey();
1565  aFullPropName = aFullValuesName + "/";
1566  aFullPropName += makeHierarchalNameSegment( Name );
1567 
1568  // Property in set?
1569  if ( !xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1570  throw UnknownPropertyException(aFullPropName);
1571 
1572  // Property removable?
1573  try
1574  {
1575  OUString aFullAttrName = aFullPropName + "/Attributes";
1576 
1577  sal_Int32 nAttribs = 0;
1578  if ( xRootHierNameAccess->getByHierarchicalName( aFullAttrName )
1579  >>= nAttribs )
1580  {
1581  if ( !( nAttribs & PropertyAttribute::REMOVABLE ) )
1582  {
1583  // Not removable!
1584  throw NotRemoveableException();
1585  }
1586  }
1587  else
1588  {
1589  OSL_FAIL( "PersistentPropertySet::removeProperty - "
1590  "No attributes!" );
1591  return;
1592  }
1593  }
1594  catch (const NoSuchElementException&)
1595  {
1596  // getByHierarchicalName
1597 
1598  OSL_FAIL( "PersistentPropertySet::removeProperty - "
1599  "caught NoSuchElementException!" );
1600  }
1601 
1602  // Remove property...
1603 
1604  Reference< XNameContainer > xContainer(
1605  m_pImpl->m_pCreator->getConfigWriteAccess( aFullValuesName ),
1606  UNO_QUERY );
1608  m_pImpl->m_pCreator->getConfigWriteAccess( OUString() ),
1609  UNO_QUERY );
1610 
1611  OSL_ENSURE( xBatch.is(),
1612  "PersistentPropertySet::removeProperty - No batch!" );
1613 
1614  OSL_ENSURE( xContainer.is(),
1615  "PersistentPropertySet::removeProperty - No container!" );
1616 
1617  if ( xBatch.is() && xContainer.is() )
1618  {
1619  try
1620  {
1621  sal_Int32 nHandle = -1;
1622 
1623  if ( m_pImpl->m_pPropSetChangeListeners &&
1624  m_pImpl->m_pPropSetChangeListeners->getLength() )
1625  {
1626  // Obtain property handle ( needed for propertysetinfo
1627  // change event )...
1628 
1629  try
1630  {
1631  OUString aFullHandleName = aFullPropName + "/Handle";
1632 
1633  if ( ! ( xRootHierNameAccess->getByHierarchicalName(
1634  aFullHandleName ) >>= nHandle ) )
1635  nHandle = -1;
1636 
1637  }
1638  catch (const NoSuchElementException&)
1639  {
1640  // getByHierarchicalName
1641 
1642  OSL_FAIL( "PersistentPropertySet::removeProperty - "
1643  "caught NoSuchElementException!" );
1644  nHandle = -1;
1645  }
1646  }
1647 
1648  xContainer->removeByName( Name );
1649  xBatch->commitChanges();
1650 
1651  // Property set info is invalid.
1652  if ( m_pImpl->m_pInfo.is() )
1653  m_pImpl->m_pInfo->reset();
1654 
1655  // Notify propertyset info change listeners.
1656  if ( m_pImpl->m_pPropSetChangeListeners &&
1657  m_pImpl->m_pPropSetChangeListeners->getLength() )
1658  {
1659  PropertySetInfoChangeEvent evt(
1660  static_cast< OWeakObject * >( this ),
1661  Name,
1662  nHandle,
1663  PropertySetInfoChange::PROPERTY_REMOVED );
1665  }
1666 
1667  // Success.
1668  return;
1669  }
1670  catch (const NoSuchElementException&)
1671  {
1672  // removeByName
1673 
1674  OSL_FAIL( "PersistentPropertySet::removeProperty - "
1675  "caught NoSuchElementException!" );
1676  return;
1677  }
1678  catch (const WrappedTargetException&)
1679  {
1680  // commitChanges
1681 
1682  OSL_FAIL( "PersistentPropertySet::removeProperty - "
1683  "caught WrappedTargetException!" );
1684  return;
1685  }
1686  }
1687  }
1688 
1689  OSL_FAIL( "PersistentPropertySet::removeProperty - Error!" );
1690 }
1691 
1692 
1693 // XPropertySetInfoChangeNotifier methods.
1694 
1695 
1696 // virtual
1699 {
1700  if ( !m_pImpl->m_pPropSetChangeListeners )
1701  m_pImpl->m_pPropSetChangeListeners.reset(
1702  new OInterfaceContainerHelper2( m_pImpl->m_aMutex ) );
1703 
1704  m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
1705 }
1706 
1707 
1708 // virtual
1711 {
1712  if ( m_pImpl->m_pPropSetChangeListeners )
1713  m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
1714 }
1715 
1716 
1717 // XPropertyAccess methods.
1718 
1719 
1720 // virtual
1722 {
1723  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1724 
1725  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1726  m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1727  if ( xRootHierNameAccess.is() )
1728  {
1729  try
1730  {
1731  Reference< XNameAccess > xNameAccess;
1732  xRootHierNameAccess->getByHierarchicalName(getFullKey())
1733  >>= xNameAccess;
1734  if ( xNameAccess.is() )
1735  {
1736  // Obtain property names.
1737 
1738  Sequence< OUString > aElems = xNameAccess->getElementNames();
1739 
1740  sal_Int32 nCount = aElems.getLength();
1741  if ( nCount )
1742  {
1743  Reference< XHierarchicalNameAccess > xHierNameAccess(
1744  xNameAccess, UNO_QUERY );
1745 
1746  OSL_ENSURE( xHierNameAccess.is(),
1747  "PersistentPropertySet::getPropertyValues - "
1748  "No hierarchical name access!" );
1749 
1750  if ( xHierNameAccess.is() )
1751  {
1752  Sequence< PropertyValue > aValues( nCount );
1753 
1754  const OUString aHandleName("/Handle");
1755  const OUString aValueName("/Value");
1756  const OUString aStateName("/State");
1757 
1758  for ( sal_Int32 n = 0; n < nCount; ++n )
1759  {
1760  PropertyValue& rValue = aValues[ n ];
1761  OUString rName = aElems[ n ];
1762  OUString aXMLName
1763  = makeHierarchalNameSegment( rName );
1764 
1765  // Set property name.
1766 
1767  rValue.Name = rName;
1768 
1769  try
1770  {
1771  // Obtain and set property handle
1772  OUString aHierName = aXMLName + aHandleName;
1773  Any aKeyValue
1774  = xHierNameAccess->getByHierarchicalName(
1775  aHierName );
1776 
1777  if ( !( aKeyValue >>= rValue.Handle ) )
1778  OSL_FAIL( "PersistentPropertySet::getPropertyValues - "
1779  "Error getting property handle!" );
1780  }
1781  catch (const NoSuchElementException&)
1782  {
1783  // getByHierarchicalName
1784 
1785  OSL_FAIL( "PersistentPropertySet::getPropertyValues - "
1786  "NoSuchElementException!" );
1787  }
1788 
1789  try
1790  {
1791  // Obtain and set property value
1792  OUString aHierName = aXMLName + aValueName;
1793  rValue.Value
1794  = xHierNameAccess->getByHierarchicalName(
1795  aHierName );
1796 
1797  // Note: The value may be void if addProperty
1798  // was called with a default value
1799  // of type void.
1800  }
1801  catch (const NoSuchElementException&)
1802  {
1803  // getByHierarchicalName
1804 
1805  OSL_FAIL( "PersistentPropertySet::getPropertyValues - "
1806  "NoSuchElementException!" );
1807  }
1808 
1809  try
1810  {
1811  // Obtain and set property state
1812  OUString aHierName = aXMLName +aStateName;
1813  Any aKeyValue
1814  = xHierNameAccess->getByHierarchicalName(
1815  aHierName );
1816 
1817  sal_Int32 nState = 0;
1818  if ( !( aKeyValue >>= nState ) )
1819  OSL_FAIL( "PersistentPropertySet::getPropertyValues - "
1820  "Error getting property state!" );
1821  else
1822  rValue.State = PropertyState( nState );
1823  }
1824  catch (const NoSuchElementException&)
1825  {
1826  // getByHierarchicalName
1827 
1828  OSL_FAIL( "PersistentPropertySet::getPropertyValues - "
1829  "NoSuchElementException!" );
1830  }
1831  }
1832 
1833  return aValues;
1834  }
1835  }
1836  }
1837  }
1838  catch (const NoSuchElementException&)
1839  {
1840  // getByHierarchicalName
1841  }
1842  }
1843 
1844  return Sequence< PropertyValue >( 0 );
1845 }
1846 
1847 
1848 // virtual
1850  const Sequence< PropertyValue >& aProps )
1851 {
1852  if ( !aProps.hasElements() )
1853  return;
1854 
1855  osl::ClearableGuard< osl::Mutex > aCGuard( m_pImpl->m_aMutex );
1856 
1857  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1858  m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1859  if ( xRootHierNameAccess.is() )
1860  {
1861  std::vector< PropertyChangeEvent > aEvents;
1862 
1863  OUString aFullPropNamePrefix( getFullKey() + "/" );
1864 
1865  // Iterate over given property value sequence.
1866  for ( const PropertyValue& rNewValue : aProps )
1867  {
1868  const OUString& rName = rNewValue.Name;
1869 
1870  OUString aFullPropName = aFullPropNamePrefix;
1871  aFullPropName += makeHierarchalNameSegment( rName );
1872 
1873  // Does property exist?
1874  if ( xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1875  {
1876  Reference< XNameReplace > xNameReplace(
1877  m_pImpl->m_pCreator->getConfigWriteAccess(
1878  aFullPropName ), UNO_QUERY );
1880  m_pImpl->m_pCreator->getConfigWriteAccess(
1881  OUString() ), UNO_QUERY );
1882 
1883  if ( xNameReplace.is() && xBatch.is() )
1884  {
1885  try
1886  {
1887  // Write handle
1888  xNameReplace->replaceByName(
1889  "Handle",
1890  makeAny( rNewValue.Handle ) );
1891 
1892  // Save old value
1893  OUString aValueName = aFullPropName +"/Value";
1894  Any aOldValue
1895  = xRootHierNameAccess->getByHierarchicalName(
1896  aValueName );
1897  // Write value
1898  xNameReplace->replaceByName(
1899  "Value",
1900  rNewValue.Value );
1901 
1902  // Write state ( Now it is a directly set value )
1903  xNameReplace->replaceByName(
1904  "State",
1905  makeAny(
1906  sal_Int32(
1907  PropertyState_DIRECT_VALUE ) ) );
1908 
1909  // Commit changes.
1910  xBatch->commitChanges();
1911 
1912  if ( m_pImpl->m_pPropertyChangeListeners )
1913  {
1914  PropertyChangeEvent aEvt;
1915  aEvt.Source = static_cast<OWeakObject*>(this);
1916  aEvt.PropertyName = rNewValue.Name;
1917  aEvt.PropertyHandle = rNewValue.Handle;
1918  aEvt.Further = false;
1919  aEvt.OldValue = aOldValue;
1920  aEvt.NewValue = rNewValue.Value;
1921 
1922  aEvents.push_back( aEvt );
1923  }
1924  }
1925  catch (const IllegalArgumentException&)
1926  {
1927  // replaceByName
1928  }
1929  catch (const NoSuchElementException&)
1930  {
1931  // getByHierarchicalName, replaceByName
1932  }
1933  catch (const WrappedTargetException&)
1934  {
1935  // replaceByName, commitChanges
1936  }
1937  }
1938  }
1939  }
1940 
1941  // Callback follows!
1942  aCGuard.clear();
1943 
1944  if ( m_pImpl->m_pPropertyChangeListeners )
1945  {
1946  // Notify property changes.
1947  for (auto const& event : aEvents)
1948  {
1949  notifyPropertyChangeEvent( event );
1950  }
1951  }
1952 
1953  return;
1954  }
1955 
1956  OSL_FAIL( "PersistentPropertySet::setPropertyValues - Nothing set!" );
1957 }
1958 
1959 
1960 // Non-interface methods
1961 
1962 
1964  const PropertyChangeEvent& rEvent ) const
1965 {
1966  // Get "normal" listeners for the property.
1967  OInterfaceContainerHelper* pContainer =
1968  m_pImpl->m_pPropertyChangeListeners->getContainer(
1969  rEvent.PropertyName );
1970  if ( pContainer && pContainer->getLength() )
1971  {
1972  OInterfaceIteratorHelper aIter( *pContainer );
1973  while ( aIter.hasMoreElements() )
1974  {
1975  // Propagate event.
1977  aIter.next(), UNO_QUERY );
1978  if ( xListener.is() )
1979  xListener->propertyChange( rEvent );
1980  }
1981  }
1982 
1983  // Get "normal" listeners for all properties.
1984  OInterfaceContainerHelper* pNoNameContainer =
1985  m_pImpl->m_pPropertyChangeListeners->getContainer( OUString() );
1986  if ( pNoNameContainer && pNoNameContainer->getLength() )
1987  {
1988  OInterfaceIteratorHelper aIter( *pNoNameContainer );
1989  while ( aIter.hasMoreElements() )
1990  {
1991  // Propagate event.
1993  aIter.next(), UNO_QUERY );
1994  if ( xListener.is() )
1995  xListener->propertyChange( rEvent );
1996  }
1997  }
1998 }
1999 
2000 
2002  const PropertySetInfoChangeEvent& evt ) const
2003 {
2004  if ( !m_pImpl->m_pPropSetChangeListeners )
2005  return;
2006 
2007  // Notify event listeners.
2008  OInterfaceIteratorHelper2 aIter( *( m_pImpl->m_pPropSetChangeListeners ) );
2009  while ( aIter.hasMoreElements() )
2010  {
2011  // Propagate event.
2013  xListener( aIter.next(), UNO_QUERY );
2014  if ( xListener.is() )
2015  xListener->propertySetInfoChange( evt );
2016  }
2017 }
2018 
2019 
2021 {
2022  if ( m_pImpl->m_aFullKey.isEmpty() )
2023  {
2024  osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
2025  if ( m_pImpl->m_aFullKey.isEmpty() )
2026  {
2027  m_pImpl->m_aFullKey
2028  = makeHierarchalNameSegment( m_pImpl->m_aKey );
2029  m_pImpl->m_aFullKey
2030  += "/Values";
2031  }
2032  }
2033 
2034  return m_pImpl->m_aFullKey;
2035 }
2036 
2037 
2039 {
2040  return *m_pImpl->m_pCreator;
2041 }
2042 
2043 
2044 // PropertySetInfo_Impl Implementation.
2045 
2046 
2047 PropertySetInfo_Impl::PropertySetInfo_Impl(
2048  PersistentPropertySet* pOwner )
2049 : m_pOwner( pOwner )
2050 {
2051 }
2052 
2053 
2054 // XPropertySetInfo methods.
2055 
2056 
2057 // virtual
2058 Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties()
2059 {
2060  if ( !m_pProps )
2061  {
2062  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2063  m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(),
2064  UNO_QUERY );
2065  if ( xRootHierNameAccess.is() )
2066  {
2067  try
2068  {
2069  Reference< XNameAccess > xNameAccess;
2070  xRootHierNameAccess->getByHierarchicalName(
2071  m_pOwner->getFullKey() )
2072  >>= xNameAccess;
2073  if ( xNameAccess.is() )
2074  {
2075  // Obtain property names.
2076 
2077  Sequence< OUString > aElems
2078  = xNameAccess->getElementNames();
2079 
2080  sal_uInt32 nCount = aElems.getLength();
2081  Sequence< Property >* pPropSeq
2082  = new Sequence< Property >( nCount );
2083 
2084  if ( nCount )
2085  {
2086  Reference< XHierarchicalNameAccess > xHierNameAccess(
2087  xNameAccess, UNO_QUERY );
2088 
2089  OSL_ENSURE( xHierNameAccess.is(),
2090  "PropertySetInfo_Impl::getProperties - "
2091  "No hierarchical name access!" );
2092 
2093  if ( xHierNameAccess.is() )
2094  {
2095  const OUString aHandleName("/Handle");
2096  const OUString aValueName("/Value");
2097  const OUString aAttrName("/Attributes");
2098 
2099  Property* pProps = pPropSeq->getArray();
2100 
2101  for ( sal_uInt32 n = 0; n < nCount; ++n )
2102  {
2103  Property& rProp = pProps[ n ];
2104  OUString rName = aElems[ n ];
2105  OUString aXMLName
2106  = makeHierarchalNameSegment( rName );
2107 
2108  // Set property name.
2109 
2110  rProp.Name = rName;
2111 
2112  try
2113  {
2114  // Obtain and set property handle
2115  OUString aHierName = aXMLName + aHandleName;
2116  Any aKeyValue
2117  = xHierNameAccess->getByHierarchicalName(
2118  aHierName );
2119 
2120  if ( !( aKeyValue >>= rProp.Handle ) )
2121  OSL_FAIL( "PropertySetInfo_Impl::getProperties - "
2122  "Error getting property handle!" );
2123  }
2124  catch (const NoSuchElementException&)
2125  {
2126  // getByHierarchicalName
2127 
2128  OSL_FAIL( "PropertySetInfo_Impl::getProperties - "
2129  "NoSuchElementException!" );
2130  }
2131 
2132  try
2133  {
2134  // Obtain and set property type
2135  OUString aHierName = aXMLName + aValueName;
2136  Any aKeyValue
2137  = xHierNameAccess->getByHierarchicalName(
2138  aHierName );
2139 
2140  // Note: The type may be void if addProperty
2141  // was called with a default value
2142  // of type void.
2143 
2144  rProp.Type = aKeyValue.getValueType();
2145  }
2146  catch (const NoSuchElementException&)
2147  {
2148  // getByHierarchicalName
2149 
2150  OSL_FAIL( "PropertySetInfo_Impl::getProperties - "
2151  "NoSuchElementException!" );
2152  }
2153 
2154  try
2155  {
2156  // Obtain and set property attributes
2157  OUString aHierName = aXMLName + aAttrName;
2158  Any aKeyValue
2159  = xHierNameAccess->getByHierarchicalName(
2160  aHierName );
2161 
2162  sal_Int32 nAttribs = 0;
2163  if ( aKeyValue >>= nAttribs )
2164  rProp.Attributes
2165  = sal_Int16( nAttribs );
2166  else
2167  OSL_FAIL( "PropertySetInfo_Impl::getProperties - "
2168  "Error getting property attributes!" );
2169  }
2170  catch (const NoSuchElementException&)
2171  {
2172  // getByHierarchicalName
2173 
2174  OSL_FAIL( "PropertySetInfo_Impl::getProperties - "
2175  "NoSuchElementException!" );
2176  }
2177  }
2178  }
2179  }
2180 
2181  // Success.
2182  m_pProps.reset( pPropSeq );
2183  return *m_pProps;
2184  }
2185  }
2186  catch (const NoSuchElementException&)
2187  {
2188  // getByHierarchicalName
2189  }
2190  }
2191 
2192  OSL_FAIL( "PropertySetInfo_Impl::getProperties - Error!" );
2193  m_pProps.reset( new Sequence< Property >( 0 ) );
2194  }
2195 
2196  return *m_pProps;
2197 }
2198 
2199 
2200 // virtual
2201 Property SAL_CALL PropertySetInfo_Impl::getPropertyByName(
2202  const OUString& aName )
2203 {
2204  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2205  m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(),
2206  UNO_QUERY );
2207  if ( xRootHierNameAccess.is() )
2208  {
2209  OUString aFullPropName( m_pOwner->getFullKey() + "/" );
2210  aFullPropName += makeHierarchalNameSegment( aName );
2211 
2212  // Does property exist?
2213  if ( !xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
2214  throw UnknownPropertyException(aFullPropName);
2215 
2216  try
2217  {
2218  Property aProp;
2219 
2220  // Obtain handle.
2221  OUString aKey = aFullPropName + "/Handle";
2222 
2223  if ( !( xRootHierNameAccess->getByHierarchicalName( aKey )
2224  >>= aProp.Handle ) )
2225  {
2226  OSL_FAIL( "PropertySetInfo_Impl::getPropertyByName - "
2227  "No handle!" );
2228  return Property();
2229  }
2230 
2231  // Obtain Value and extract type.
2232  aKey = aFullPropName + "/Value";
2233 
2234  Any aValue = xRootHierNameAccess->getByHierarchicalName( aKey );
2235  if ( !aValue.hasValue() )
2236  {
2237  OSL_FAIL( "PropertySetInfo_Impl::getPropertyByName - "
2238  "No Value!" );
2239  return Property();
2240  }
2241 
2242  aProp.Type = aValue.getValueType();
2243 
2244  // Obtain Attributes.
2245  aKey = aFullPropName + "/Attributes";
2246 
2247  sal_Int32 nAttribs = 0;
2248  if ( xRootHierNameAccess->getByHierarchicalName( aKey )
2249  >>= nAttribs )
2250  aProp.Attributes = sal_Int16( nAttribs );
2251  else
2252  {
2253  OSL_FAIL( "PropertySetInfo_Impl::getPropertyByName - "
2254  "No attributes!" );
2255  return Property();
2256  }
2257 
2258  // set name.
2259  aProp.Name = aName;
2260 
2261  // Success.
2262  return aProp;
2263  }
2264  catch (const NoSuchElementException&)
2265  {
2266  // getByHierarchicalName
2267 
2268  OSL_FAIL( "PropertySetInfo_Impl::getPropertyByName - "
2269  "caught NoSuchElementException!" );
2270  }
2271 
2272  }
2273 
2274  OSL_FAIL( "PropertySetInfo_Impl::getPropertyByName - Error!" );
2275  return Property();
2276 }
2277 
2278 
2279 // virtual
2280 sal_Bool SAL_CALL PropertySetInfo_Impl::hasPropertyByName(
2281  const OUString& Name )
2282 {
2283  Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2284  m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(),
2285  UNO_QUERY );
2286  if ( xRootHierNameAccess.is() )
2287  {
2288  OUString aFullPropName( m_pOwner->getFullKey() + "/" );
2289  aFullPropName += makeHierarchalNameSegment( Name );
2290 
2291  return xRootHierNameAccess->hasByHierarchicalName( aFullPropName );
2292  }
2293 
2294  return false;
2295 }
2296 
2297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void remove(PersistentPropertySet *pSet)
Definition: ucbstore.cxx:558
PersistentPropertySet_Impl(PropertySetRegistry &rCreator, const OUString &rKey)
Definition: ucbstore.cxx:1065
virtual OUString SAL_CALL getName() override
Definition: ucbstore.cxx:1375
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: ucbstore.cxx:516
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: ucbstore.cxx:1335
PropertySetRegistry(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Sequence< css::uno::Any > &rInitArgs)
Definition: ucbstore.cxx:242
std::unique_ptr< UcbStore_Impl > m_pImpl
Definition: ucbstore.hxx:54
virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL getRegistry() override
Definition: ucbstore.cxx:1358
virtual css::uno::Type SAL_CALL getElementType() override
Definition: ucbstore.cxx:464
std::unique_ptr< PropertySetRegistry_Impl > m_pImpl
Definition: ucbstore.hxx:93
rtl::Reference< PropertySetInfo_Impl > m_pInfo
Definition: ucbstore.cxx:1057
PersistentPropertySet(PropertySetRegistry &rCreator, const OUString &rKey)
Definition: ucbstore.cxx:1076
Reference< XPropertySetRegistry > m_xTheRegistry
Definition: ucbstore.cxx:142
sal_Int64 n
Reference< XMultiServiceFactory > m_xConfigProvider
Definition: ucbstore.cxx:224
std::unique_ptr< uno::Sequence< beans::Property > > m_pProps
virtual ~PropertySetRegistry() override
Definition: ucbstore.cxx:252
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:1095
static OUString makeHierarchalNameSegment(const OUString &rIn)
Definition: ucbstore.cxx:64
XSERVICEINFO_COMMOM_IMPL(UcbStore,"com.sun.star.comp.ucb.UcbStore") static css
Definition: ucbstore.cxx:161
OUString Name
UCBHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > getComponentContext(css::uno::Reference< css::lang::XMultiServiceFactory > const &factory)
rtl::Reference< PropertySetRegistry > m_pCreator
Definition: ucbstore.cxx:1056
css::uno::XInterface *SAL_CALL next()
void renamePropertySet(const OUString &rOldKey, const OUString &rNewKey)
Definition: ucbstore.cxx:578
css::uno::Any const & rValue
#define STORE_CONTENTPROPERTIES_KEY
Definition: ucbstore.cxx:105
sal_uInt16 sal_Unicode
virtual void SAL_CALL removePropertySet(const OUString &key) override
Definition: ucbstore.cxx:405
Sequence< PropertyValue > aArguments
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
Definition: ucbstore.cxx:1721
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: ucbstore.cxx:1183
virtual ~PersistentPropertySet() override
Definition: ucbstore.cxx:1087
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:260
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucbstore.hxx:53
css::uno::Reference< css::uno::XInterface > getConfigWriteAccess(const OUString &rPath)
Definition: ucbstore.cxx:970
UcbStore(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: ucbstore.cxx:149
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:1106
int nCount
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual ~UcbStore() override
Definition: ucbstore.cxx:157
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:1100
Reference< XInterface > m_xRootWriteAccess
Definition: ucbstore.cxx:226
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: ucbstore.cxx:209
PropertySetRegistry_Impl(const Sequence< Any > &rInitArgs)
Definition: ucbstore.cxx:231
#define PROPSET_REG_SERVICE_NAME
Definition: ucbstore.hxx:42
OMultiTypeInterfaceContainerHelperVar< OUString > PropertyListeners_Impl
Definition: ucbstore.cxx:1052
osl::Mutex m_aMutex
Definition: ucbstore.cxx:140
sal_Int32 nHandle
ONE_INSTANCE_SERVICE_FACTORY_IMPL(UcbStore)
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: ucbstore.cxx:172
#define CFGPROPERTY_NODEPATH
Definition: ucbstore.cxx:108
virtual sal_Bool SAL_CALL hasElements() override
Definition: ucbstore.cxx:471
virtual void SAL_CALL removePropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: ucbstore.cxx:1709
sal_Int32 SAL_CALL getLength() const
#define PERS_PROPSET_SERVICE_NAME
Definition: ucbstore.hxx:43
#define TOOLS_WARN_EXCEPTION(area, stream)
friend class PersistentPropertySet
Definition: ucbstore.hxx:90
class SAL_NO_VTABLE XPropertySet
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
ContentProvider * m_pOwner
Definition: pkgprovider.cxx:58
virtual void SAL_CALL addPropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: ucbstore.cxx:1697
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:270
void add(PersistentPropertySet *pSet)
Definition: ucbstore.cxx:546
SvLinkSource * pOwner
void notifyPropertySetInfoChange(const css::beans::PropertySetInfoChangeEvent &evt) const
Definition: ucbstore.cxx:2001
const OUString & getFullKey()
Definition: ucbstore.cxx:2020
unsigned char sal_Bool
PropertySetMap_Impl m_aPropSets
Definition: ucbstore.cxx:223
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: ucbstore.cxx:488
css::uno::Type const & get()
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: ucbstore.cxx:1345
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:265
css::uno::Reference< css::uno::XInterface > getRootConfigReadAccess()
Definition: ucbstore.cxx:915
std::unordered_map< OUString, PersistentPropertySet * > PropertySetMap_Impl
Definition: ucbstore.cxx:111
const Sequence< Any > m_aInitArgs
Definition: ucbstore.cxx:222
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucbstore.cxx:1144
virtual void SAL_CALL dispose() override
Definition: ucbstore.cxx:1116
css::uno::Reference< css::lang::XMultiServiceFactory > getConfigProvider()
Definition: ucbstore.cxx:879
virtual void SAL_CALL setName(const OUString &aName) override
Definition: ucbstore.cxx:1383
std::unique_ptr< char[]> aBuffer
std::unique_ptr< OInterfaceContainerHelper2 > m_pDisposeEventListeners
Definition: ucbstore.cxx:1061
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: ucbstore.cxx:531
Reference< XInterface > m_xRootReadAccess
Definition: ucbstore.cxx:225
void notifyPropertyChangeEvent(const css::beans::PropertyChangeEvent &rEvent) const
Definition: ucbstore.cxx:1963
#define STORE_SERVICE_NAME
Definition: ucbstore.hxx:41
std::unique_ptr< PropertyListeners_Impl > m_pPropertyChangeListeners
Definition: ucbstore.cxx:1063
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: ucbstore.cxx:1320
OUString aName
virtual css::uno::Reference< css::ucb::XPersistentPropertySet > SAL_CALL openPropertySet(const OUString &key, sal_Bool create) override
Definition: ucbstore.cxx:281
std::unique_ptr< PersistentPropertySet_Impl > m_pImpl
Definition: ucbstore.hxx:156
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Definition: ucbstore.cxx:1849
virtual void SAL_CALL removeProperty(const OUString &Name) override
Definition: ucbstore.cxx:1553
Sequence< Any > m_aInitArgs
Definition: ucbstore.cxx:141
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: ucbstore.cxx:1170
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: ucbstore.cxx:1278
#define SAL_WARN(area, stream)
css::uno::XInterface * next()
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucbstore.cxx:1156
Reference< XComponentContext > m_xContext
std::unique_ptr< OInterfaceContainerHelper2 > m_pPropSetChangeListeners
Definition: ucbstore.cxx:1062
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
virtual OUString SAL_CALL getKey() override
Definition: ucbstore.cxx:1365
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucbstore.hxx:92
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: ucbstore.cxx:1304
sal_Int32 nState
virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL createPropertySetRegistry(const OUString &URL) override
Definition: ucbstore.cxx:189
bool SAL_CALL hasMoreElements() const
PropertySetRegistry & getPropertySetRegistry()
Definition: ucbstore.cxx:2038
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
Definition: ucbstore.cxx:1394
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)