1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ucbstore.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 /**************************************************************************
36 **************************************************************************
38 *************************************************************************/
42 #include <osl/diagnose.h>
43 #include <rtl/ustrbuf.hxx>
44 #include <cppuhelper/interfacecontainer.hxx>
45 #include <com/sun/star/beans/PropertyAttribute.hpp>
46 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
47 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
48 #include <com/sun/star/container/XNameContainer.hpp>
49 #include <com/sun/star/container/XNameReplace.hpp>
50 #include <com/sun/star/util/XChangesBatch.hpp>
51 #include "ucbstore.hxx"
53 using namespace com::sun::star::beans
;
54 using namespace com::sun::star::container
;
55 using namespace com::sun::star::lang
;
56 using namespace com::sun::star::ucb
;
57 using namespace com::sun::star::uno
;
58 using namespace com::sun::star::util
;
62 //=========================================================================
63 rtl::OUString
makeHierarchalNameSegment( const rtl::OUString
& rIn
)
65 rtl::OUStringBuffer aBuffer
;
66 aBuffer
.appendAscii( "['" );
68 sal_Int32 nCount
= rIn
.getLength();
69 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
71 const sal_Unicode c
= rIn
.getStr()[ n
];
75 aBuffer
.appendAscii( "&" );
79 aBuffer
.appendAscii( """ );
83 aBuffer
.appendAscii( "'" );
87 aBuffer
.appendAscii( "<" );
91 aBuffer
.appendAscii( ">" );
100 aBuffer
.appendAscii( "']" );
101 return rtl::OUString( aBuffer
.makeStringAndClear() );
104 //=========================================================================
106 #define STORE_CONTENTPROPERTIES_KEY "/org.openoffice.ucb.Store/ContentProperties"
108 // describe path of cfg entry
109 #define CFGPROPERTY_NODEPATH "nodepath"
110 // true->async. update; false->sync. update
111 #define CFGPROPERTY_LAZYWRITE "lazywrite"
113 //=========================================================================
115 struct equalString_Impl
117 bool operator()( const OUString
& s1
, const OUString
& s2
) const
119 return !!( s1
== s2
);
123 struct hashString_Impl
125 size_t operator()( const OUString
& rName
) const
127 return rName
.hashCode();
131 //=========================================================================
133 // PropertySetMap_Impl.
135 //=========================================================================
137 typedef std::hash_map
140 PersistentPropertySet
*,
146 //=========================================================================
148 // class PropertySetInfo_Impl
150 //=========================================================================
152 class PropertySetInfo_Impl
:
153 public OWeakObject
, public XTypeProvider
, public XPropertySetInfo
155 Reference
< XMultiServiceFactory
> m_xSMgr
;
156 Sequence
< Property
>* m_pProps
;
157 PersistentPropertySet
* m_pOwner
;
160 PropertySetInfo_Impl( const Reference
< XMultiServiceFactory
>& rxSMgr
,
161 PersistentPropertySet
* pOwner
);
162 virtual ~PropertySetInfo_Impl();
171 virtual Sequence
< Property
> SAL_CALL
getProperties()
172 throw( RuntimeException
);
173 virtual Property SAL_CALL
getPropertyByName( const OUString
& aName
)
174 throw( UnknownPropertyException
, RuntimeException
);
175 virtual sal_Bool SAL_CALL
hasPropertyByName( const OUString
& Name
)
176 throw( RuntimeException
);
178 // Non-interface methods.
179 void reset() { delete m_pProps
; m_pProps
= 0; }
182 //=========================================================================
186 //=========================================================================
191 Sequence
< Any
> m_aInitArgs
;
192 Reference
< XPropertySetRegistry
> m_xTheRegistry
;
195 //=========================================================================
196 //=========================================================================
197 //=========================================================================
199 // UcbStore Implementation.
201 //=========================================================================
202 //=========================================================================
203 //=========================================================================
205 UcbStore::UcbStore( const Reference
< XMultiServiceFactory
>& rXSMgr
)
207 m_pImpl( new UcbStore_Impl() )
211 //=========================================================================
213 UcbStore::~UcbStore()
218 //=========================================================================
220 // XInterface methods.
222 //=========================================================================
224 XINTERFACE_IMPL_4( UcbStore
,
227 XPropertySetRegistryFactory
,
230 //=========================================================================
232 // XTypeProvider methods.
234 //=========================================================================
236 XTYPEPROVIDER_IMPL_4( UcbStore
,
239 XPropertySetRegistryFactory
,
242 //=========================================================================
244 // XServiceInfo methods.
246 //=========================================================================
248 XSERVICEINFO_IMPL_1( UcbStore
,
249 OUString::createFromAscii(
250 "com.sun.star.comp.ucb.UcbStore" ),
251 OUString::createFromAscii(
252 STORE_SERVICE_NAME
) );
254 //=========================================================================
256 // Service factory implementation.
258 //=========================================================================
260 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbStore
);
262 //=========================================================================
264 // XPropertySetRegistryFactory methods.
266 //=========================================================================
269 Reference
< XPropertySetRegistry
> SAL_CALL
270 UcbStore::createPropertySetRegistry( const OUString
& )
271 throw( RuntimeException
)
273 // The URL parameter is ignored by this interface implementation. It always
274 // uses the configuration server as storage medium.
276 if ( !m_pImpl
->m_xTheRegistry
.is() )
278 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
279 if ( !m_pImpl
->m_xTheRegistry
.is() )
280 m_pImpl
->m_xTheRegistry
= new PropertySetRegistry( m_xSMgr
, *this );
282 return m_pImpl
->m_xTheRegistry
;
285 //=========================================================================
287 // XInitialization methods.
289 //=========================================================================
292 void SAL_CALL
UcbStore::initialize( const Sequence
< Any
>& aArguments
)
293 throw( Exception
, RuntimeException
)
295 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
296 m_pImpl
->m_aInitArgs
= aArguments
;
299 //=========================================================================
303 //=========================================================================
305 void UcbStore::removeRegistry()
307 if ( m_pImpl
->m_xTheRegistry
.is() )
309 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
310 if ( m_pImpl
->m_xTheRegistry
.is() )
311 m_pImpl
->m_xTheRegistry
= 0;
315 //=========================================================================
316 const Sequence
< Any
>& UcbStore::getInitArgs() const
318 return m_pImpl
->m_aInitArgs
;
321 //=========================================================================
323 // PropertySetRegistry_Impl.
325 //=========================================================================
327 struct PropertySetRegistry_Impl
329 UcbStore
* m_pCreator
;
330 PropertySetMap_Impl m_aPropSets
;
331 Reference
< XMultiServiceFactory
> m_xConfigProvider
;
332 Reference
< XInterface
> m_xRootReadAccess
;
333 Reference
< XInterface
> m_xRootWriteAccess
;
335 sal_Bool m_bTriedToGetRootReadAccess
; // #82494#
336 sal_Bool m_bTriedToGetRootWriteAccess
; // #82494#
338 PropertySetRegistry_Impl( UcbStore
& rCreator
)
339 : m_pCreator( &rCreator
),
340 m_bTriedToGetRootReadAccess( sal_False
),
341 m_bTriedToGetRootWriteAccess( sal_False
)
343 m_pCreator
->acquire();
346 ~PropertySetRegistry_Impl()
348 m_pCreator
->removeRegistry();
349 m_pCreator
->release();
353 //=========================================================================
354 //=========================================================================
355 //=========================================================================
357 // PropertySetRegistry Implementation.
359 //=========================================================================
360 //=========================================================================
361 //=========================================================================
363 PropertySetRegistry::PropertySetRegistry(
364 const Reference
< XMultiServiceFactory
>& rXSMgr
,
367 m_pImpl( new PropertySetRegistry_Impl( rCreator
) )
371 //=========================================================================
373 PropertySetRegistry::~PropertySetRegistry()
378 //=========================================================================
380 // XInterface methods.
382 //=========================================================================
384 XINTERFACE_IMPL_5( PropertySetRegistry
,
387 XPropertySetRegistry
,
388 XElementAccess
, /* base of XNameAccess */
391 //=========================================================================
393 // XTypeProvider methods.
395 //=========================================================================
397 XTYPEPROVIDER_IMPL_4( PropertySetRegistry
,
400 XPropertySetRegistry
,
403 //=========================================================================
405 // XServiceInfo methods.
407 //=========================================================================
409 XSERVICEINFO_NOFACTORY_IMPL_1( PropertySetRegistry
,
410 OUString::createFromAscii(
411 "com.sun.star.comp.ucb.PropertySetRegistry" ),
412 OUString::createFromAscii(
413 PROPSET_REG_SERVICE_NAME
) );
415 //=========================================================================
417 // XPropertySetRegistry methods.
419 //=========================================================================
422 Reference
< XPersistentPropertySet
> SAL_CALL
423 PropertySetRegistry::openPropertySet( const OUString
& key
, sal_Bool create
)
424 throw( RuntimeException
)
426 if ( key
.getLength() )
428 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
430 PropertySetMap_Impl
& rSets
= m_pImpl
->m_aPropSets
;
432 PropertySetMap_Impl::const_iterator it
= rSets
.find( key
);
433 if ( it
!= rSets
.end() )
435 // Already instanciated.
436 return Reference
< XPersistentPropertySet
>( (*it
).second
);
440 // Create new instance.
441 Reference
< XNameAccess
> xRootNameAccess(
442 getRootConfigReadAccess(), UNO_QUERY
);
443 if ( xRootNameAccess
.is() )
445 // Propertyset in registry?
446 if ( xRootNameAccess
->hasByName( key
) )
449 return Reference
< XPersistentPropertySet
>(
450 new PersistentPropertySet(
451 m_xSMgr
, *this, key
) );
455 // No. Create entry for propertyset.
457 Reference
< XSingleServiceFactory
> xFac(
458 getConfigWriteAccess( OUString() ), UNO_QUERY
);
459 Reference
< XChangesBatch
> xBatch( xFac
, UNO_QUERY
);
460 Reference
< XNameContainer
> xContainer( xFac
, UNO_QUERY
);
462 OSL_ENSURE( xFac
.is(),
463 "PropertySetRegistry::openPropertySet - "
466 OSL_ENSURE( xBatch
.is(),
467 "PropertySetRegistry::openPropertySet - "
470 OSL_ENSURE( xContainer
.is(),
471 "PropertySetRegistry::openPropertySet - "
474 if ( xFac
.is() && xBatch
.is() && xContainer
.is() )
478 // Create new "Properties" config item.
479 Reference
< XNameReplace
> xNameReplace(
480 xFac
->createInstance(), UNO_QUERY
);
482 if ( xNameReplace
.is() )
487 // xNameReplace->replaceByName(
488 // OUString::createFromAscii( "Values" ),
492 xContainer
->insertByName(
493 key
, makeAny( xNameReplace
) );
495 xBatch
->commitChanges();
497 return Reference
< XPersistentPropertySet
>(
498 new PersistentPropertySet(
499 m_xSMgr
, *this, key
) );
502 catch ( IllegalArgumentException
& )
506 OSL_ENSURE( sal_False
,
507 "PropertySetRegistry::openPropertySet - "
508 "caught IllegalArgumentException!" );
510 catch ( ElementExistException
& )
514 OSL_ENSURE( sal_False
,
515 "PropertySetRegistry::openPropertySet - "
516 "caught ElementExistException!" );
518 catch ( WrappedTargetException
& )
520 // insertByName, commitChanges
522 OSL_ENSURE( sal_False
,
523 "PropertySetRegistry::openPropertySet - "
524 "caught WrappedTargetException!" );
526 catch ( RuntimeException
& )
528 OSL_ENSURE( sal_False
,
529 "PropertySetRegistry::openPropertySet - "
530 "caught RuntimeException!" );
536 OSL_ENSURE( sal_False
,
537 "PropertySetRegistry::openPropertySet - "
538 "caught Exception!" );
544 // No entry. Fail, but no error.
545 return Reference
< XPersistentPropertySet
>();
549 OSL_ENSURE( sal_False
,
550 "PropertySetRegistry::openPropertySet - Error!" );
554 return Reference
< XPersistentPropertySet
>();
557 //=========================================================================
559 void SAL_CALL
PropertySetRegistry::removePropertySet( const OUString
& key
)
560 throw( RuntimeException
)
562 if ( !key
.getLength() )
565 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
567 Reference
< XNameAccess
> xRootNameAccess(
568 getRootConfigReadAccess(), UNO_QUERY
);
569 if ( xRootNameAccess
.is() )
571 // Propertyset in registry?
572 if ( !xRootNameAccess
->hasByName( key
) )
574 Reference
< XChangesBatch
> xBatch(
575 getConfigWriteAccess( OUString() ), UNO_QUERY
);
576 Reference
< XNameContainer
> xContainer( xBatch
, UNO_QUERY
);
578 OSL_ENSURE( xBatch
.is(),
579 "PropertySetRegistry::removePropertySet - "
582 OSL_ENSURE( xContainer
.is(),
583 "PropertySetRegistry::removePropertySet - "
586 if ( xBatch
.is() && xContainer
.is() )
591 xContainer
->removeByName( key
);
593 xBatch
->commitChanges();
598 catch ( NoSuchElementException
& )
602 OSL_ENSURE( sal_False
,
603 "PropertySetRegistry::removePropertySet - "
604 "caught NoSuchElementException!" );
607 catch ( WrappedTargetException
& )
611 OSL_ENSURE( sal_False
,
612 "PropertySetRegistry::removePropertySet - "
613 "caught WrappedTargetException!" );
621 OSL_ENSURE( sal_False
, "PropertySetRegistry::removePropertySet - Error!" );
624 //=========================================================================
626 // XElementAccess methods.
628 //=========================================================================
631 com::sun::star::uno::Type SAL_CALL
PropertySetRegistry::getElementType()
632 throw( RuntimeException
)
634 return getCppuType( ( Reference
< XPersistentPropertySet
> * ) 0 );
637 //=========================================================================
639 sal_Bool SAL_CALL
PropertySetRegistry::hasElements()
640 throw( RuntimeException
)
642 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
644 Reference
< XElementAccess
> xElemAccess(
645 getRootConfigReadAccess(), UNO_QUERY
);
646 if ( xElemAccess
.is() )
647 return xElemAccess
->hasElements();
652 //=========================================================================
654 // XNameAccess methods.
656 //=========================================================================
659 Any SAL_CALL
PropertySetRegistry::getByName( const OUString
& aName
)
660 throw( NoSuchElementException
, WrappedTargetException
, RuntimeException
)
662 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
664 Reference
< XNameAccess
> xNameAccess(
665 getRootConfigReadAccess(), UNO_QUERY
);
666 if ( xNameAccess
.is() )
671 return xNameAccess
->getByName( aName
);
673 catch ( NoSuchElementException
& )
677 catch ( WrappedTargetException
& )
686 //=========================================================================
688 Sequence
< OUString
> SAL_CALL
PropertySetRegistry::getElementNames()
689 throw( RuntimeException
)
691 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
693 Reference
< XNameAccess
> xNameAccess(
694 getRootConfigReadAccess(), UNO_QUERY
);
695 if ( xNameAccess
.is() )
697 return xNameAccess
->getElementNames();
699 return Sequence
< OUString
>( 0 );
702 //=========================================================================
704 sal_Bool SAL_CALL
PropertySetRegistry::hasByName( const OUString
& aName
)
705 throw( RuntimeException
)
707 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
709 Reference
< XNameAccess
> xNameAccess(
710 getRootConfigReadAccess(), UNO_QUERY
);
711 if ( xNameAccess
.is() )
713 return xNameAccess
->hasByName( aName
);
719 //=========================================================================
720 void PropertySetRegistry::add( PersistentPropertySet
* pSet
)
722 OUString
key( pSet
->getKey() );
724 if ( key
.getLength() )
726 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
727 m_pImpl
->m_aPropSets
[ key
] = pSet
;
731 //=========================================================================
732 void PropertySetRegistry::remove( PersistentPropertySet
* pSet
)
734 OUString
key( pSet
->getKey() );
736 if ( key
.getLength() )
738 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
740 PropertySetMap_Impl
& rSets
= m_pImpl
->m_aPropSets
;
742 PropertySetMap_Impl::iterator it
= rSets
.find( key
);
743 if ( it
!= rSets
.end() )
751 //=========================================================================
752 void PropertySetRegistry::renamePropertySet( const OUString
& rOldKey
,
753 const OUString
& rNewKey
)
755 if ( rOldKey
== rNewKey
)
758 Reference
< XNameAccess
> xRootNameAccess(
759 getConfigWriteAccess( OUString() ), UNO_QUERY
);
760 if ( xRootNameAccess
.is() )
763 if ( xRootNameAccess
->hasByName( rOldKey
) )
765 // New key not present?
766 if ( xRootNameAccess
->hasByName( rNewKey
) )
768 OSL_ENSURE( sal_False
,
769 "PropertySetRegistry::renamePropertySet - "
773 Reference
< XSingleServiceFactory
> xFac(
774 xRootNameAccess
, UNO_QUERY
);
775 Reference
< XChangesBatch
> xBatch( xFac
, UNO_QUERY
);
776 Reference
< XNameContainer
> xContainer( xFac
, UNO_QUERY
);
778 OSL_ENSURE( xFac
.is(),
779 "PropertySetRegistry::renamePropertySet - "
782 OSL_ENSURE( xBatch
.is(),
783 "PropertySetRegistry::renamePropertySet - "
786 OSL_ENSURE( xContainer
.is(),
787 "PropertySetRegistry::renamePropertySet - "
790 if ( xFac
.is() && xBatch
.is() && xContainer
.is() )
792 //////////////////////////////////////////////////////
793 // Create new "Properties" config item.
794 //////////////////////////////////////////////////////
798 Reference
< XNameReplace
> xNameReplace(
799 xFac
->createInstance(), UNO_QUERY
);
801 if ( xNameReplace
.is() )
804 xContainer
->insertByName(
805 rNewKey
, makeAny( xNameReplace
) );
807 xBatch
->commitChanges();
810 catch ( IllegalArgumentException
& )
814 OSL_ENSURE( sal_False
,
815 "PropertySetRegistry::renamePropertySet - "
816 "caught IllegalArgumentException!" );
819 catch ( ElementExistException
& )
823 OSL_ENSURE( sal_False
,
824 "PropertySetRegistry::renamePropertySet - "
825 "caught ElementExistException!" );
828 catch ( WrappedTargetException
& )
830 // insertByName, commitChanges
832 OSL_ENSURE( sal_False
,
833 "PropertySetRegistry::renamePropertySet - "
834 "caught WrappedTargetException!" );
837 catch ( RuntimeException
& )
839 OSL_ENSURE( sal_False
,
840 "PropertySetRegistry::renamePropertySet - "
841 "caught RuntimeException!" );
848 OSL_ENSURE( sal_False
,
849 "PropertySetRegistry::renamePropertySet - "
850 "caught Exception!" );
854 //////////////////////////////////////////////////////
856 //////////////////////////////////////////////////////
858 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
859 xRootNameAccess
, UNO_QUERY
);
860 if ( !xRootHierNameAccess
.is() )
862 OSL_ENSURE( sal_False
,
863 "PropertySetRegistry::renamePropertySet - "
864 "No hierarchical name access!" );
870 rtl::OUString aOldValuesKey
871 = makeHierarchalNameSegment( rOldKey
);
872 aOldValuesKey
+= OUString::createFromAscii( "/Values" );
874 Reference
< XNameAccess
> xOldNameAccess
;
875 xRootHierNameAccess
->getByHierarchicalName(
878 if ( !xOldNameAccess
.is() )
880 OSL_ENSURE( sal_False
,
881 "PersistentPropertySet::renamePropertySet - "
882 "No old name access!" );
886 // Obtain property names.
887 Sequence
< OUString
> aElems
888 = xOldNameAccess
->getElementNames();
889 sal_Int32 nCount
= aElems
.getLength();
892 rtl::OUString aNewValuesKey
893 = makeHierarchalNameSegment( rNewKey
);
894 aNewValuesKey
+= OUString::createFromAscii( "/Values" );
896 Reference
< XSingleServiceFactory
> xNewFac
;
897 xRootHierNameAccess
->getByHierarchicalName(
902 OSL_ENSURE( sal_False
,
903 "PersistentPropertySet::renamePropertySet - "
908 Reference
< XNameContainer
> xNewContainer(
909 xNewFac
, UNO_QUERY
);
910 if ( !xNewContainer
.is() )
912 OSL_ENSURE( sal_False
,
913 "PersistentPropertySet::renamePropertySet - "
914 "No new container!" );
918 aOldValuesKey
+= OUString::createFromAscii( "/" );
921 = OUString::createFromAscii( "/Handle" );
923 = OUString::createFromAscii( "/Value" );
925 = OUString::createFromAscii( "/State" );
927 = OUString::createFromAscii( "/Attributes" );
929 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
931 const OUString
& rPropName
= aElems
[ n
];
934 Reference
< XNameReplace
> xNewPropNameReplace(
935 xNewFac
->createInstance(), UNO_QUERY
);
937 if ( !xNewPropNameReplace
.is() )
939 OSL_ENSURE( sal_False
,
940 "PersistentPropertySet::renamePropertySet - "
941 "No new prop name replace!" );
948 OUString aKey
= aOldValuesKey
;
949 aKey
+= makeHierarchalNameSegment( rPropName
);
952 OUString aNewKey1
= aKey
;
953 aNewKey1
+= aHandleKey
;
955 xRootHierNameAccess
->getByHierarchicalName(
957 xNewPropNameReplace
->replaceByName(
958 OUString::createFromAscii( "Handle" ),
963 aNewKey1
+= aValueKey
;
965 xRootHierNameAccess
->getByHierarchicalName(
967 xNewPropNameReplace
->replaceByName(
968 OUString::createFromAscii( "Value" ),
973 aNewKey1
+= aStateKey
;
975 xRootHierNameAccess
->getByHierarchicalName(
977 xNewPropNameReplace
->replaceByName(
978 OUString::createFromAscii( "State" ),
983 aNewKey1
+= aAttrKey
;
985 xRootHierNameAccess
->getByHierarchicalName(
987 xNewPropNameReplace
->replaceByName(
988 OUString::createFromAscii( "Attributes" ),
992 xNewContainer
->insertByName(
993 rPropName
, makeAny( xNewPropNameReplace
) );
996 xBatch
->commitChanges();
1000 catch ( IllegalArgumentException
& )
1002 // insertByName, replaceByName
1004 OSL_ENSURE( sal_False
,
1005 "PropertySetRegistry::renamePropertySet - "
1006 "caught IllegalArgumentException!" );
1009 catch ( ElementExistException
& )
1013 OSL_ENSURE( sal_False
,
1014 "PropertySetRegistry::renamePropertySet - "
1015 "caught ElementExistException!" );
1018 catch ( WrappedTargetException
& )
1020 // insertByName, replaceByName, commitChanges
1022 OSL_ENSURE( sal_False
,
1023 "PropertySetRegistry::renamePropertySet - "
1024 "caught WrappedTargetException!" );
1027 catch ( NoSuchElementException
& )
1029 // getByHierarchicalName, replaceByName
1031 OSL_ENSURE( sal_False
,
1032 "PropertySetRegistry::renamePropertySet - "
1033 "caught NoSuchElementException!" );
1036 catch ( RuntimeException
& )
1038 OSL_ENSURE( sal_False
,
1039 "PropertySetRegistry::renamePropertySet - "
1040 "caught RuntimeException!" );
1043 catch ( Exception
& )
1047 OSL_ENSURE( sal_False
,
1048 "PropertySetRegistry::renamePropertySet - "
1049 "caught Exception!" );
1053 //////////////////////////////////////////////////////
1054 // Remove old entry...
1055 //////////////////////////////////////////////////////
1060 xContainer
->removeByName( rOldKey
);
1062 xBatch
->commitChanges();
1067 catch ( NoSuchElementException
& )
1071 OSL_ENSURE( sal_False
,
1072 "PropertySetRegistry::renamePropertySet - "
1073 "caught NoSuchElementException!" );
1076 catch ( WrappedTargetException
& )
1080 OSL_ENSURE( sal_False
,
1081 "PropertySetRegistry::renamePropertySet - "
1082 "caught WrappedTargetException!" );
1089 OSL_ENSURE( sal_False
, "PropertySetRegistry::renamePropertySet - Error!" );
1092 //=========================================================================
1093 Reference
< XMultiServiceFactory
> PropertySetRegistry::getConfigProvider()
1095 if ( !m_pImpl
->m_xConfigProvider
.is() )
1097 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1098 if ( !m_pImpl
->m_xConfigProvider
.is() )
1100 const Sequence
< Any
>& rInitArgs
1101 = m_pImpl
->m_pCreator
->getInitArgs();
1103 if ( rInitArgs
.getLength() > 0 )
1105 // Extract config provider from service init args.
1106 rInitArgs
[ 0 ] >>= m_pImpl
->m_xConfigProvider
;
1108 OSL_ENSURE( m_pImpl
->m_xConfigProvider
.is(),
1109 "PropertySetRegistry::getConfigProvider - "
1110 "No config provider!" );
1116 m_pImpl
->m_xConfigProvider
1117 = Reference
< XMultiServiceFactory
>(
1118 m_xSMgr
->createInstance(
1119 OUString::createFromAscii(
1120 "com.sun.star.configuration."
1121 "ConfigurationProvider" ) ),
1124 OSL_ENSURE( m_pImpl
->m_xConfigProvider
.is(),
1125 "PropertySetRegistry::getConfigProvider - "
1126 "No config provider!" );
1129 catch ( Exception
& )
1131 OSL_ENSURE( sal_False
,
1132 "PropertySetRegistry::getConfigProvider - "
1133 "caught exception!" );
1139 return m_pImpl
->m_xConfigProvider
;
1142 //=========================================================================
1143 Reference
< XInterface
> PropertySetRegistry::getRootConfigReadAccess()
1147 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1149 if ( !m_pImpl
->m_xRootReadAccess
.is() )
1151 if ( m_pImpl
->m_bTriedToGetRootReadAccess
) // #82494#
1153 OSL_ENSURE( sal_False
,
1154 "PropertySetRegistry::getRootConfigReadAccess - "
1155 "Unable to read any config data! -> #82494#" );
1156 return Reference
< XInterface
>();
1159 getConfigProvider();
1161 if ( m_pImpl
->m_xConfigProvider
.is() )
1163 Sequence
< Any
> aArguments( 1 );
1164 PropertyValue aProperty
;
1166 = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
1167 CFGPROPERTY_NODEPATH
) );
1169 <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
1170 STORE_CONTENTPROPERTIES_KEY
) );
1171 aArguments
[ 0 ] <<= aProperty
;
1173 m_pImpl
->m_bTriedToGetRootReadAccess
= sal_True
;
1175 m_pImpl
->m_xRootReadAccess
=
1176 m_pImpl
->m_xConfigProvider
->createInstanceWithArguments(
1177 OUString::createFromAscii(
1178 "com.sun.star.configuration.ConfigurationAccess" ),
1181 if ( m_pImpl
->m_xRootReadAccess
.is() )
1182 return m_pImpl
->m_xRootReadAccess
;
1186 return m_pImpl
->m_xRootReadAccess
;
1188 catch ( RuntimeException
& )
1192 catch ( Exception
& )
1194 // createInstance, createInstanceWithArguments
1196 OSL_ENSURE( sal_False
,
1197 "PropertySetRegistry::getRootConfigReadAccess - caught Exception!" );
1198 return Reference
< XInterface
>();
1201 OSL_ENSURE( sal_False
,
1202 "PropertySetRegistry::getRootConfigReadAccess - Error!" );
1203 return Reference
< XInterface
>();
1206 //=========================================================================
1207 Reference
< XInterface
> PropertySetRegistry::getConfigWriteAccess(
1208 const OUString
& rPath
)
1212 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1214 if ( !m_pImpl
->m_xRootWriteAccess
.is() )
1216 if ( m_pImpl
->m_bTriedToGetRootWriteAccess
) // #82494#
1218 OSL_ENSURE( sal_False
,
1219 "PropertySetRegistry::getConfigWriteAccess - "
1220 "Unable to write any config data! -> #82494#" );
1221 return Reference
< XInterface
>();
1224 getConfigProvider();
1226 if ( m_pImpl
->m_xConfigProvider
.is() )
1228 Sequence
< Any
> aArguments( 2 );
1229 PropertyValue aProperty
;
1232 = OUString( RTL_CONSTASCII_USTRINGPARAM(
1233 CFGPROPERTY_NODEPATH
) );
1235 <<= OUString( RTL_CONSTASCII_USTRINGPARAM(
1236 STORE_CONTENTPROPERTIES_KEY
) );
1237 aArguments
[ 0 ] <<= aProperty
;
1240 = OUString( RTL_CONSTASCII_USTRINGPARAM(
1241 CFGPROPERTY_LAZYWRITE
) );
1242 aProperty
.Value
<<= sal_True
;
1243 aArguments
[ 1 ] <<= aProperty
;
1245 m_pImpl
->m_bTriedToGetRootWriteAccess
= sal_True
;
1247 m_pImpl
->m_xRootWriteAccess
=
1248 m_pImpl
->m_xConfigProvider
->createInstanceWithArguments(
1249 OUString::createFromAscii(
1250 "com.sun.star.configuration.ConfigurationUpdateAccess" ),
1253 OSL_ENSURE( m_pImpl
->m_xRootWriteAccess
.is(),
1254 "PropertySetRegistry::getConfigWriteAccess - "
1255 "No config update access!" );
1259 if ( m_pImpl
->m_xRootWriteAccess
.is() )
1261 if ( rPath
.getLength() )
1263 Reference
< XHierarchicalNameAccess
> xNA(
1264 m_pImpl
->m_xRootWriteAccess
, UNO_QUERY
);
1267 Reference
< XInterface
> xInterface
;
1268 xNA
->getByHierarchicalName( rPath
) >>= xInterface
;
1270 if ( xInterface
.is() )
1275 return m_pImpl
->m_xRootWriteAccess
;
1278 catch ( RuntimeException
& )
1282 catch ( NoSuchElementException
& )
1284 // getByHierarchicalName
1286 OSL_ENSURE( sal_False
,
1287 "PropertySetRegistry::getConfigWriteAccess - "
1288 "caught NoSuchElementException!" );
1289 return Reference
< XInterface
>();
1291 catch ( Exception
& )
1293 // createInstance, createInstanceWithArguments
1295 OSL_ENSURE( sal_False
,
1296 "PropertySetRegistry::getConfigWriteAccess - "
1297 "caught Exception!" );
1298 return Reference
< XInterface
>();
1301 OSL_ENSURE( sal_False
,
1302 "PropertySetRegistry::getConfigWriteAccess - Error!" );
1303 return Reference
< XInterface
>();
1306 //=========================================================================
1308 // PropertyListeners_Impl.
1310 //=========================================================================
1312 typedef OMultiTypeInterfaceContainerHelperVar
1317 > PropertyListeners_Impl
;
1319 //=========================================================================
1321 // PersistentPropertySet_Impl.
1323 //=========================================================================
1325 struct PersistentPropertySet_Impl
1327 PropertySetRegistry
* m_pCreator
;
1328 PropertySetInfo_Impl
* m_pInfo
;
1330 OUString m_aFullKey
;
1331 osl::Mutex m_aMutex
;
1332 OInterfaceContainerHelper
* m_pDisposeEventListeners
;
1333 OInterfaceContainerHelper
* m_pPropSetChangeListeners
;
1334 PropertyListeners_Impl
* m_pPropertyChangeListeners
;
1336 PersistentPropertySet_Impl( PropertySetRegistry
& rCreator
,
1337 const OUString
& rKey
)
1338 : m_pCreator( &rCreator
), m_pInfo( NULL
), m_aKey( rKey
),
1339 m_pDisposeEventListeners( NULL
), m_pPropSetChangeListeners( NULL
),
1340 m_pPropertyChangeListeners( NULL
)
1342 m_pCreator
->acquire();
1345 ~PersistentPropertySet_Impl()
1347 m_pCreator
->release();
1352 delete m_pDisposeEventListeners
;
1353 delete m_pPropSetChangeListeners
;
1354 delete m_pPropertyChangeListeners
;
1358 //=========================================================================
1359 //=========================================================================
1360 //=========================================================================
1362 // PersistentPropertySet Implementation.
1364 //=========================================================================
1365 //=========================================================================
1366 //=========================================================================
1368 PersistentPropertySet::PersistentPropertySet(
1369 const Reference
< XMultiServiceFactory
>& rXSMgr
,
1370 PropertySetRegistry
& rCreator
,
1371 const OUString
& rKey
)
1372 : m_xSMgr( rXSMgr
),
1373 m_pImpl( new PersistentPropertySet_Impl( rCreator
, rKey
) )
1375 // register at creator.
1376 rCreator
.add( this );
1379 //=========================================================================
1381 PersistentPropertySet::~PersistentPropertySet()
1383 // deregister at creator.
1384 m_pImpl
->m_pCreator
->remove( this );
1389 //=========================================================================
1391 // XInterface methods.
1393 //=========================================================================
1395 XINTERFACE_IMPL_9( PersistentPropertySet
,
1399 XPropertySet
, /* base of XPersistentPropertySet */
1401 XPersistentPropertySet
,
1403 XPropertySetInfoChangeNotifier
,
1406 //=========================================================================
1408 // XTypeProvider methods.
1410 //=========================================================================
1412 XTYPEPROVIDER_IMPL_8( PersistentPropertySet
,
1416 XPersistentPropertySet
,
1419 XPropertySetInfoChangeNotifier
,
1422 //=========================================================================
1424 // XServiceInfo methods.
1426 //=========================================================================
1428 XSERVICEINFO_NOFACTORY_IMPL_1( PersistentPropertySet
,
1429 OUString::createFromAscii(
1430 "com.sun.star.comp.ucb.PersistentPropertySet" ),
1431 OUString::createFromAscii(
1432 PERS_PROPSET_SERVICE_NAME
) );
1434 //=========================================================================
1436 // XComponent methods.
1438 //=========================================================================
1441 void SAL_CALL
PersistentPropertySet::dispose()
1442 throw( RuntimeException
)
1444 if ( m_pImpl
->m_pDisposeEventListeners
&&
1445 m_pImpl
->m_pDisposeEventListeners
->getLength() )
1448 aEvt
.Source
= static_cast< XComponent
* >( this );
1449 m_pImpl
->m_pDisposeEventListeners
->disposeAndClear( aEvt
);
1452 if ( m_pImpl
->m_pPropSetChangeListeners
&&
1453 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
1456 aEvt
.Source
= static_cast< XPropertySetInfoChangeNotifier
* >( this );
1457 m_pImpl
->m_pPropSetChangeListeners
->disposeAndClear( aEvt
);
1460 if ( m_pImpl
->m_pPropertyChangeListeners
)
1463 aEvt
.Source
= static_cast< XPropertySet
* >( this );
1464 m_pImpl
->m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
1468 //=========================================================================
1470 void SAL_CALL
PersistentPropertySet::addEventListener(
1471 const Reference
< XEventListener
>& Listener
)
1472 throw( RuntimeException
)
1474 if ( !m_pImpl
->m_pDisposeEventListeners
)
1475 m_pImpl
->m_pDisposeEventListeners
=
1476 new OInterfaceContainerHelper( m_pImpl
->m_aMutex
);
1478 m_pImpl
->m_pDisposeEventListeners
->addInterface( Listener
);
1481 //=========================================================================
1483 void SAL_CALL
PersistentPropertySet::removeEventListener(
1484 const Reference
< XEventListener
>& Listener
)
1485 throw( RuntimeException
)
1487 if ( m_pImpl
->m_pDisposeEventListeners
)
1488 m_pImpl
->m_pDisposeEventListeners
->removeInterface( Listener
);
1490 // Note: Don't want to delete empty container here -> performance.
1493 //=========================================================================
1495 // XPropertySet methods.
1497 //=========================================================================
1500 Reference
< XPropertySetInfo
> SAL_CALL
1501 PersistentPropertySet::getPropertySetInfo()
1502 throw( RuntimeException
)
1504 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1506 PropertySetInfo_Impl
*& rpInfo
= m_pImpl
->m_pInfo
;
1509 rpInfo
= new PropertySetInfo_Impl( m_xSMgr
, this );
1512 return Reference
< XPropertySetInfo
>( rpInfo
);
1515 //=========================================================================
1517 void SAL_CALL
PersistentPropertySet::setPropertyValue(
1518 const OUString
& aPropertyName
, const Any
& aValue
)
1519 throw( UnknownPropertyException
,
1520 PropertyVetoException
,
1521 IllegalArgumentException
,
1522 WrappedTargetException
,
1525 if ( !aPropertyName
.getLength() )
1526 throw UnknownPropertyException();
1528 osl::ClearableGuard
< osl::Mutex
> aCGuard( m_pImpl
->m_aMutex
);
1530 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
1531 m_pImpl
->m_pCreator
->getRootConfigReadAccess(), UNO_QUERY
);
1532 if ( xRootHierNameAccess
.is() )
1534 OUString
aFullPropName( getFullKey() );
1535 aFullPropName
+= OUString::createFromAscii( "/" );
1536 aFullPropName
+= makeHierarchalNameSegment( aPropertyName
);
1538 // Does property exist?
1539 if ( xRootHierNameAccess
->hasByHierarchicalName( aFullPropName
) )
1541 Reference
< XNameReplace
> xNameReplace(
1542 m_pImpl
->m_pCreator
->getConfigWriteAccess(
1543 aFullPropName
), UNO_QUERY
);
1544 Reference
< XChangesBatch
> xBatch(
1545 m_pImpl
->m_pCreator
->getConfigWriteAccess(
1546 OUString() ), UNO_QUERY
);
1548 if ( xNameReplace
.is() && xBatch
.is() )
1553 OUString aValueName
= aFullPropName
;
1554 aValueName
+= OUString::createFromAscii( "/Value" );
1556 = xRootHierNameAccess
->getByHierarchicalName(
1558 // Check value type.
1559 if ( aOldValue
.getValueType() != aValue
.getValueType() )
1562 throw IllegalArgumentException();
1566 xNameReplace
->replaceByName(
1567 OUString::createFromAscii( "Value" ),
1570 // Write state ( Now it is a directly set value )
1571 xNameReplace
->replaceByName(
1572 OUString::createFromAscii( "State" ),
1573 makeAny( PropertyState_DIRECT_VALUE
) );
1576 xBatch
->commitChanges();
1578 PropertyChangeEvent aEvt
;
1579 if ( m_pImpl
->m_pPropertyChangeListeners
)
1582 aValueName
= aFullPropName
;
1583 aValueName
+= OUString::createFromAscii( "/Handle" );
1584 sal_Int32 nHandle
= -1;
1585 xRootHierNameAccess
->getByHierarchicalName( aValueName
)
1588 aEvt
.Source
= (OWeakObject
*)this;
1589 aEvt
.PropertyName
= aPropertyName
;
1590 aEvt
.PropertyHandle
= nHandle
;
1591 aEvt
.Further
= sal_False
;
1592 aEvt
.OldValue
= aOldValue
;
1593 aEvt
.NewValue
= aValue
;
1595 // Callback follows!
1598 notifyPropertyChangeEvent( aEvt
);
1602 catch ( IllegalArgumentException
& )
1606 catch ( NoSuchElementException
& )
1608 // getByHierarchicalName, replaceByName
1610 catch ( WrappedTargetException
& )
1612 // replaceByName, commitChanges
1618 throw UnknownPropertyException();
1621 //=========================================================================
1623 Any SAL_CALL
PersistentPropertySet::getPropertyValue(
1624 const OUString
& PropertyName
)
1625 throw( UnknownPropertyException
,
1626 WrappedTargetException
,
1629 if ( !PropertyName
.getLength() )
1630 throw UnknownPropertyException();
1632 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1634 Reference
< XHierarchicalNameAccess
> xNameAccess(
1635 m_pImpl
->m_pCreator
->getRootConfigReadAccess(), UNO_QUERY
);
1636 if ( xNameAccess
.is() )
1638 OUString
aFullPropName( getFullKey() );
1639 aFullPropName
+= OUString::createFromAscii( "/" );
1640 aFullPropName
+= makeHierarchalNameSegment( PropertyName
);
1641 aFullPropName
+= OUString::createFromAscii( "/Value" );
1644 return xNameAccess
->getByHierarchicalName( aFullPropName
);
1646 catch ( NoSuchElementException
& )
1648 throw UnknownPropertyException();
1652 throw UnknownPropertyException();
1655 //=========================================================================
1657 void SAL_CALL
PersistentPropertySet::addPropertyChangeListener(
1658 const OUString
& aPropertyName
,
1659 const Reference
< XPropertyChangeListener
>& xListener
)
1660 throw( UnknownPropertyException
,
1661 WrappedTargetException
,
1666 if ( !m_pImpl
->m_pPropertyChangeListeners
)
1667 m_pImpl
->m_pPropertyChangeListeners
=
1668 new PropertyListeners_Impl( m_pImpl
->m_aMutex
);
1670 m_pImpl
->m_pPropertyChangeListeners
->addInterface(
1671 aPropertyName
, xListener
);
1674 //=========================================================================
1676 void SAL_CALL
PersistentPropertySet::removePropertyChangeListener(
1677 const OUString
& aPropertyName
,
1678 const Reference
< XPropertyChangeListener
>& aListener
)
1679 throw( UnknownPropertyException
,
1680 WrappedTargetException
,
1685 if ( m_pImpl
->m_pPropertyChangeListeners
)
1686 m_pImpl
->m_pPropertyChangeListeners
->removeInterface(
1687 aPropertyName
, aListener
);
1689 // Note: Don't want to delete empty container here -> performance.
1692 //=========================================================================
1694 void SAL_CALL
PersistentPropertySet::addVetoableChangeListener(
1696 const Reference
< XVetoableChangeListener
>& )
1697 throw( UnknownPropertyException
,
1698 WrappedTargetException
,
1702 // OSL_ENSURE( sal_False,
1703 // "PersistentPropertySet::addVetoableChangeListener - N.Y.I." );
1706 //=========================================================================
1708 void SAL_CALL
PersistentPropertySet::removeVetoableChangeListener(
1710 const Reference
< XVetoableChangeListener
>& )
1711 throw( UnknownPropertyException
,
1712 WrappedTargetException
,
1716 // OSL_ENSURE( sal_False,
1717 // "PersistentPropertySet::removeVetoableChangeListener - N.Y.I." );
1720 //=========================================================================
1722 // XPersistentPropertySet methods.
1724 //=========================================================================
1727 Reference
< XPropertySetRegistry
> SAL_CALL
PersistentPropertySet::getRegistry()
1728 throw( RuntimeException
)
1730 return Reference
< XPropertySetRegistry
>( m_pImpl
->m_pCreator
);
1733 //=========================================================================
1735 OUString SAL_CALL
PersistentPropertySet::getKey()
1736 throw( RuntimeException
)
1738 return m_pImpl
->m_aKey
;
1741 //=========================================================================
1745 //=========================================================================
1748 rtl::OUString SAL_CALL
PersistentPropertySet::getName()
1749 throw( RuntimeException
)
1752 return m_pImpl
->m_aKey
;
1755 //=========================================================================
1757 void SAL_CALL
PersistentPropertySet::setName( const OUString
& aName
)
1758 throw( RuntimeException
)
1760 if ( aName
!= m_pImpl
->m_aKey
)
1761 m_pImpl
->m_pCreator
->renamePropertySet( m_pImpl
->m_aKey
, aName
);
1764 //=========================================================================
1766 // XPropertyContainer methods.
1768 //=========================================================================
1771 void SAL_CALL
PersistentPropertySet::addProperty(
1772 const OUString
& Name
, sal_Int16 Attributes
, const Any
& DefaultValue
)
1773 throw( PropertyExistException
,
1774 IllegalTypeException
,
1775 IllegalArgumentException
,
1778 if ( !Name
.getLength() )
1779 throw IllegalArgumentException();
1781 // @@@ What other types can't be written to config server?
1783 // Check type class ( Not all types can be written to storage )
1784 TypeClass eTypeClass
= DefaultValue
.getValueTypeClass();
1785 if ( eTypeClass
== TypeClass_INTERFACE
)
1786 throw IllegalTypeException();
1788 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1790 // Property already in set?
1792 OUString aFullValuesName
;
1794 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
1795 m_pImpl
->m_pCreator
->getRootConfigReadAccess(), UNO_QUERY
);
1796 if ( xRootHierNameAccess
.is() )
1798 aFullValuesName
= getFullKey();
1799 OUString aFullPropName
= aFullValuesName
;
1800 aFullPropName
+= OUString::createFromAscii( "/" );
1801 aFullPropName
+= makeHierarchalNameSegment( Name
);
1803 if ( xRootHierNameAccess
->hasByHierarchicalName( aFullPropName
) )
1806 throw PropertyExistException();
1810 // Property is always removeable.
1811 Attributes
|= PropertyAttribute::REMOVEABLE
;
1815 Reference
< XSingleServiceFactory
> xFac(
1816 m_pImpl
->m_pCreator
->getConfigWriteAccess( aFullValuesName
),
1818 Reference
< XNameContainer
> xContainer( xFac
, UNO_QUERY
);
1819 Reference
< XChangesBatch
> xBatch(
1820 m_pImpl
->m_pCreator
->getConfigWriteAccess( OUString() ),
1823 OSL_ENSURE( xFac
.is(),
1824 "PersistentPropertySet::addProperty - No factory!" );
1826 OSL_ENSURE( xBatch
.is(),
1827 "PersistentPropertySet::addProperty - No batch!" );
1829 OSL_ENSURE( xContainer
.is(),
1830 "PersistentPropertySet::addProperty - No container!" );
1832 if ( xFac
.is() && xBatch
.is() && xContainer
.is() )
1836 // Create new "PropertyValue" config item.
1837 Reference
< XNameReplace
> xNameReplace(
1838 xFac
->createInstance(), UNO_QUERY
);
1840 if ( xNameReplace
.is() )
1845 xNameReplace
->replaceByName(
1846 OUString::createFromAscii( "Handle" ),
1847 makeAny( sal_Int32( -1 ) ) );
1849 // Set default value
1850 xNameReplace
->replaceByName(
1851 OUString::createFromAscii( "Value" ),
1854 // Set state ( always "default" )
1855 xNameReplace
->replaceByName(
1856 OUString::createFromAscii( "State" ),
1857 makeAny( PropertyState_DEFAULT_VALUE
) );
1860 xNameReplace
->replaceByName(
1861 OUString::createFromAscii( "Attributes" ),
1862 makeAny( sal_Int32( Attributes
) ) );
1865 xContainer
->insertByName( Name
, makeAny( xNameReplace
) );
1868 xBatch
->commitChanges();
1870 // Property set info is invalid.
1871 if ( m_pImpl
->m_pInfo
)
1872 m_pImpl
->m_pInfo
->reset();
1874 // Notify propertyset info change listeners.
1875 if ( m_pImpl
->m_pPropSetChangeListeners
&&
1876 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
1878 PropertySetInfoChangeEvent
evt(
1879 static_cast< OWeakObject
* >( this ),
1882 PropertySetInfoChange::PROPERTY_INSERTED
);
1883 notifyPropertySetInfoChange( evt
);
1890 catch ( IllegalArgumentException
& )
1894 OSL_ENSURE( sal_False
,
1895 "PersistentPropertySet::addProperty - "
1896 "caught IllegalArgumentException!" );
1899 catch ( ElementExistException
& )
1903 OSL_ENSURE( sal_False
,
1904 "PersistentPropertySet::addProperty - "
1905 "caught ElementExistException!" );
1908 catch ( WrappedTargetException
& )
1910 // replaceByName, insertByName, commitChanges
1912 OSL_ENSURE( sal_False
,
1913 "PersistentPropertySet::addProperty - "
1914 "caught WrappedTargetException!" );
1917 catch ( RuntimeException
& )
1921 catch ( Exception
& )
1925 OSL_ENSURE( sal_False
,
1926 "PersistentPropertySet::addProperty - "
1927 "caught Exception!" );
1932 OSL_ENSURE( sal_False
,
1933 "PersistentPropertySet::addProperty - Error!" );
1936 //=========================================================================
1938 void SAL_CALL
PersistentPropertySet::removeProperty( const OUString
& Name
)
1939 throw( UnknownPropertyException
,
1940 NotRemoveableException
,
1943 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
1945 OUString aFullValuesName
;
1946 OUString aFullPropName
;
1948 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
1949 m_pImpl
->m_pCreator
->getRootConfigReadAccess(), UNO_QUERY
);
1950 if ( xRootHierNameAccess
.is() )
1952 aFullValuesName
= getFullKey();
1953 aFullPropName
= aFullValuesName
;
1954 aFullPropName
+= OUString::createFromAscii( "/" );
1955 aFullPropName
+= makeHierarchalNameSegment( Name
);
1958 if ( !xRootHierNameAccess
->hasByHierarchicalName( aFullPropName
) )
1959 throw UnknownPropertyException();
1961 // Property removeable?
1964 OUString aFullAttrName
= aFullPropName
;
1965 aFullAttrName
+= OUString::createFromAscii( "/Attributes" );
1967 sal_Int32 nAttribs
= 0;
1968 if ( xRootHierNameAccess
->getByHierarchicalName( aFullAttrName
)
1971 if ( !( nAttribs
& PropertyAttribute::REMOVEABLE
) )
1974 throw NotRemoveableException();
1979 OSL_ENSURE( sal_False
,
1980 "PersistentPropertySet::removeProperty - "
1985 catch ( NoSuchElementException
& )
1987 // getByHierarchicalName
1989 OSL_ENSURE( sal_False
,
1990 "PersistentPropertySet::removeProperty - "
1991 "caught NoSuchElementException!" );
1994 // Remove property...
1996 Reference
< XNameContainer
> xContainer(
1997 m_pImpl
->m_pCreator
->getConfigWriteAccess( aFullValuesName
),
1999 Reference
< XChangesBatch
> xBatch(
2000 m_pImpl
->m_pCreator
->getConfigWriteAccess( OUString() ),
2003 OSL_ENSURE( xBatch
.is(),
2004 "PersistentPropertySet::removeProperty - No batch!" );
2006 OSL_ENSURE( xContainer
.is(),
2007 "PersistentPropertySet::removeProperty - No container!" );
2009 if ( xBatch
.is() && xContainer
.is() )
2013 sal_Int32 nHandle
= -1;
2015 if ( m_pImpl
->m_pPropSetChangeListeners
&&
2016 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
2018 // Obtain property handle ( needed for propertysetinfo
2019 // change event )...
2023 OUString aFullHandleName
= aFullPropName
;
2025 += OUString::createFromAscii( "/Handle" );
2027 if ( ! ( xRootHierNameAccess
->getByHierarchicalName(
2028 aFullHandleName
) >>= nHandle
) )
2032 catch ( NoSuchElementException
& )
2034 // getByHierarchicalName
2036 OSL_ENSURE( sal_False
,
2037 "PersistentPropertySet::removeProperty - "
2038 "caught NoSuchElementException!" );
2043 xContainer
->removeByName( Name
);
2044 xBatch
->commitChanges();
2046 // Property set info is invalid.
2047 if ( m_pImpl
->m_pInfo
)
2048 m_pImpl
->m_pInfo
->reset();
2050 // Notify propertyset info change listeners.
2051 if ( m_pImpl
->m_pPropSetChangeListeners
&&
2052 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
2054 PropertySetInfoChangeEvent
evt(
2055 static_cast< OWeakObject
* >( this ),
2058 PropertySetInfoChange::PROPERTY_REMOVED
);
2059 notifyPropertySetInfoChange( evt
);
2065 catch ( NoSuchElementException
& )
2069 OSL_ENSURE( sal_False
,
2070 "PersistentPropertySet::removeProperty - "
2071 "caught NoSuchElementException!" );
2074 catch ( WrappedTargetException
& )
2078 OSL_ENSURE( sal_False
,
2079 "PersistentPropertySet::removeProperty - "
2080 "caught WrappedTargetException!" );
2086 OSL_ENSURE( sal_False
,
2087 "PersistentPropertySet::removeProperty - Error!" );
2090 //=========================================================================
2092 // XPropertySetInfoChangeNotifier methods.
2094 //=========================================================================
2097 void SAL_CALL
PersistentPropertySet::addPropertySetInfoChangeListener(
2098 const Reference
< XPropertySetInfoChangeListener
>& Listener
)
2099 throw( RuntimeException
)
2101 if ( !m_pImpl
->m_pPropSetChangeListeners
)
2102 m_pImpl
->m_pPropSetChangeListeners
=
2103 new OInterfaceContainerHelper( m_pImpl
->m_aMutex
);
2105 m_pImpl
->m_pPropSetChangeListeners
->addInterface( Listener
);
2108 //=========================================================================
2110 void SAL_CALL
PersistentPropertySet::removePropertySetInfoChangeListener(
2111 const Reference
< XPropertySetInfoChangeListener
>& Listener
)
2112 throw( RuntimeException
)
2114 if ( m_pImpl
->m_pPropSetChangeListeners
)
2115 m_pImpl
->m_pPropSetChangeListeners
->removeInterface( Listener
);
2118 //=========================================================================
2120 // XPropertyAccess methods.
2122 //=========================================================================
2125 Sequence
< PropertyValue
> SAL_CALL
PersistentPropertySet::getPropertyValues()
2126 throw( RuntimeException
)
2128 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
2130 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
2131 m_pImpl
->m_pCreator
->getRootConfigReadAccess(), UNO_QUERY
);
2132 if ( xRootHierNameAccess
.is() )
2136 Reference
< XNameAccess
> xNameAccess
;
2137 xRootHierNameAccess
->getByHierarchicalName(getFullKey())
2139 if ( xNameAccess
.is() )
2141 // Obtain property names.
2143 Sequence
< OUString
> aElems
= xNameAccess
->getElementNames();
2145 sal_Int32 nCount
= aElems
.getLength();
2148 Reference
< XHierarchicalNameAccess
> xHierNameAccess(
2149 xNameAccess
, UNO_QUERY
);
2151 OSL_ENSURE( xHierNameAccess
.is(),
2152 "PersistentPropertySet::getPropertyValues - "
2153 "No hierarchical name access!" );
2155 if ( xHierNameAccess
.is() )
2157 Sequence
< PropertyValue
> aValues( nCount
);
2159 const OUString aHandleName
2160 = OUString::createFromAscii( "/Handle" );
2161 const OUString aValueName
2162 = OUString::createFromAscii( "/Value" );
2163 const OUString aStateName
2164 = OUString::createFromAscii( "/State" );
2166 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
2168 PropertyValue
& rValue
= aValues
[ n
];
2169 OUString rName
= aElems
[ n
];
2171 = makeHierarchalNameSegment( rName
);
2173 // Set property name.
2175 rValue
.Name
= rName
;
2179 // Obtain and set property handle
2180 OUString aHierName
= aXMLName
;
2181 aHierName
+= aHandleName
;
2183 = xHierNameAccess
->getByHierarchicalName(
2186 if ( !( aKeyValue
>>= rValue
.Handle
) )
2187 OSL_ENSURE( sal_False
,
2188 "PersistentPropertySet::getPropertyValues - "
2189 "Error getting property handle!" );
2191 catch ( NoSuchElementException
& )
2193 // getByHierarchicalName
2195 OSL_ENSURE( sal_False
,
2196 "PersistentPropertySet::getPropertyValues - "
2197 "NoSuchElementException!" );
2202 // Obtain and set property value
2203 OUString aHierName
= aXMLName
;
2204 aHierName
+= aValueName
;
2206 = xHierNameAccess
->getByHierarchicalName(
2209 // Note: The value may be void if addProperty
2210 // was called with a default value
2213 catch ( NoSuchElementException
& )
2215 // getByHierarchicalName
2217 OSL_ENSURE( sal_False
,
2218 "PersistentPropertySet::getPropertyValues - "
2219 "NoSuchElementException!" );
2224 // Obtain and set property state
2225 OUString aHierName
= aXMLName
;
2226 aHierName
+= aStateName
;
2228 = xHierNameAccess
->getByHierarchicalName(
2231 sal_Int32 nState
= 0;
2232 if ( !( aKeyValue
>>= nState
) )
2233 OSL_ENSURE( sal_False
,
2234 "PersistentPropertySet::getPropertyValues - "
2235 "Error getting property state!" );
2237 rValue
.State
= PropertyState( nState
);
2239 catch ( NoSuchElementException
& )
2241 // getByHierarchicalName
2243 OSL_ENSURE( sal_False
,
2244 "PersistentPropertySet::getPropertyValues - "
2245 "NoSuchElementException!" );
2254 catch ( NoSuchElementException
& )
2256 // getByHierarchicalName
2260 return Sequence
< PropertyValue
>( 0 );
2263 //=========================================================================
2265 void SAL_CALL
PersistentPropertySet::setPropertyValues(
2266 const Sequence
< PropertyValue
>& aProps
)
2267 throw( UnknownPropertyException
,
2268 PropertyVetoException
,
2269 IllegalArgumentException
,
2270 WrappedTargetException
,
2273 sal_Int32 nCount
= aProps
.getLength();
2277 osl::ClearableGuard
< osl::Mutex
> aCGuard( m_pImpl
->m_aMutex
);
2279 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
2280 m_pImpl
->m_pCreator
->getRootConfigReadAccess(), UNO_QUERY
);
2281 if ( xRootHierNameAccess
.is() )
2283 const PropertyValue
* pNewValues
= aProps
.getConstArray();
2285 typedef std::list
< PropertyChangeEvent
> Events
;
2288 OUString
aFullPropNamePrefix( getFullKey() );
2289 aFullPropNamePrefix
+= OUString::createFromAscii( "/" );
2291 // Iterate over given property value sequence.
2292 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
2294 const PropertyValue
& rNewValue
= pNewValues
[ n
];
2295 const OUString
& rName
= rNewValue
.Name
;
2297 OUString aFullPropName
= aFullPropNamePrefix
;
2298 aFullPropName
+= makeHierarchalNameSegment( rName
);
2300 // Does property exist?
2301 if ( xRootHierNameAccess
->hasByHierarchicalName( aFullPropName
) )
2303 Reference
< XNameReplace
> xNameReplace(
2304 m_pImpl
->m_pCreator
->getConfigWriteAccess(
2305 aFullPropName
), UNO_QUERY
);
2306 Reference
< XChangesBatch
> xBatch(
2307 m_pImpl
->m_pCreator
->getConfigWriteAccess(
2308 OUString() ), UNO_QUERY
);
2310 if ( xNameReplace
.is() && xBatch
.is() )
2315 xNameReplace
->replaceByName(
2316 OUString::createFromAscii( "Handle" ),
2317 makeAny( rNewValue
.Handle
) );
2320 OUString aValueName
= aFullPropName
;
2321 aValueName
+= OUString::createFromAscii( "/Value" );
2323 = xRootHierNameAccess
->getByHierarchicalName(
2326 xNameReplace
->replaceByName(
2327 OUString::createFromAscii( "Value" ),
2330 // Write state ( Now it is a directly set value )
2331 xNameReplace
->replaceByName(
2332 OUString::createFromAscii( "State" ),
2333 makeAny( PropertyState_DIRECT_VALUE
) );
2336 xBatch
->commitChanges();
2338 if ( m_pImpl
->m_pPropertyChangeListeners
)
2340 PropertyChangeEvent aEvt
;
2341 aEvt
.Source
= (OWeakObject
*)this;
2342 aEvt
.PropertyName
= rNewValue
.Name
;
2343 aEvt
.PropertyHandle
= rNewValue
.Handle
;
2344 aEvt
.Further
= sal_False
;
2345 aEvt
.OldValue
= aOldValue
;
2346 aEvt
.NewValue
= rNewValue
.Value
;
2348 aEvents
.push_back( aEvt
);
2351 catch ( IllegalArgumentException
& )
2355 catch ( NoSuchElementException
& )
2357 // getByHierarchicalName, replaceByName
2359 catch ( WrappedTargetException
& )
2361 // replaceByName, commitChanges
2367 // Callback follows!
2370 if ( m_pImpl
->m_pPropertyChangeListeners
)
2372 // Notify property changes.
2373 Events::const_iterator it
= aEvents
.begin();
2374 Events::const_iterator end
= aEvents
.end();
2378 notifyPropertyChangeEvent( (*it
) );
2386 OSL_ENSURE( sal_False
,
2387 "PersistentPropertySet::setPropertyValues - Nothing set!" );
2390 //=========================================================================
2392 // Non-interface methods
2394 //=========================================================================
2396 void PersistentPropertySet::notifyPropertyChangeEvent(
2397 const PropertyChangeEvent
& rEvent
) const
2399 // Get "normal" listeners for the property.
2400 OInterfaceContainerHelper
* pContainer
=
2401 m_pImpl
->m_pPropertyChangeListeners
->getContainer(
2402 rEvent
.PropertyName
);
2403 if ( pContainer
&& pContainer
->getLength() )
2405 OInterfaceIteratorHelper
aIter( *pContainer
);
2406 while ( aIter
.hasMoreElements() )
2409 Reference
< XPropertyChangeListener
> xListener(
2410 aIter
.next(), UNO_QUERY
);
2411 if ( xListener
.is() )
2412 xListener
->propertyChange( rEvent
);
2416 // Get "normal" listeners for all properties.
2417 OInterfaceContainerHelper
* pNoNameContainer
=
2418 m_pImpl
->m_pPropertyChangeListeners
->getContainer( OUString() );
2419 if ( pNoNameContainer
&& pNoNameContainer
->getLength() )
2421 OInterfaceIteratorHelper
aIter( *pNoNameContainer
);
2422 while ( aIter
.hasMoreElements() )
2425 Reference
< XPropertyChangeListener
> xListener(
2426 aIter
.next(), UNO_QUERY
);
2427 if ( xListener
.is() )
2428 xListener
->propertyChange( rEvent
);
2433 //=========================================================================
2434 void PersistentPropertySet::notifyPropertySetInfoChange(
2435 const PropertySetInfoChangeEvent
& evt
) const
2437 if ( !m_pImpl
->m_pPropSetChangeListeners
)
2440 // Notify event listeners.
2441 OInterfaceIteratorHelper
aIter( *( m_pImpl
->m_pPropSetChangeListeners
) );
2442 while ( aIter
.hasMoreElements() )
2445 Reference
< XPropertySetInfoChangeListener
>
2446 xListener( aIter
.next(), UNO_QUERY
);
2447 if ( xListener
.is() )
2448 xListener
->propertySetInfoChange( evt
);
2452 //=========================================================================
2453 const OUString
& PersistentPropertySet::getFullKey()
2455 if ( !m_pImpl
->m_aFullKey
.getLength() )
2457 osl::Guard
< osl::Mutex
> aGuard( m_pImpl
->m_aMutex
);
2458 if ( !m_pImpl
->m_aFullKey
.getLength() )
2461 = makeHierarchalNameSegment( m_pImpl
->m_aKey
);
2463 += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/Values" ) );
2467 return m_pImpl
->m_aFullKey
;
2470 //=========================================================================
2471 PropertySetRegistry
& PersistentPropertySet::getPropertySetRegistry()
2473 return *m_pImpl
->m_pCreator
;
2476 //=========================================================================
2477 //=========================================================================
2479 // PropertySetInfo_Impl Implementation.
2481 //=========================================================================
2482 //=========================================================================
2484 PropertySetInfo_Impl::PropertySetInfo_Impl(
2485 const Reference
< XMultiServiceFactory
>& rxSMgr
,
2486 PersistentPropertySet
* pOwner
)
2487 : m_xSMgr( rxSMgr
),
2493 //=========================================================================
2495 PropertySetInfo_Impl::~PropertySetInfo_Impl()
2499 // !!! Do not delete m_pOwner !!!
2502 //=========================================================================
2504 // XInterface methods.
2506 //=========================================================================
2508 XINTERFACE_IMPL_2( PropertySetInfo_Impl
,
2512 //=========================================================================
2514 // XTypeProvider methods.
2516 //=========================================================================
2518 XTYPEPROVIDER_IMPL_2( PropertySetInfo_Impl
,
2522 //=========================================================================
2524 // XPropertySetInfo methods.
2526 //=========================================================================
2529 Sequence
< Property
> SAL_CALL
PropertySetInfo_Impl::getProperties()
2530 throw( RuntimeException
)
2534 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
2535 m_pOwner
->getPropertySetRegistry().getRootConfigReadAccess(),
2537 if ( xRootHierNameAccess
.is() )
2541 Reference
< XNameAccess
> xNameAccess
;
2542 xRootHierNameAccess
->getByHierarchicalName(
2543 m_pOwner
->getFullKey() )
2545 if ( xNameAccess
.is() )
2547 // Obtain property names.
2549 Sequence
< OUString
> aElems
2550 = xNameAccess
->getElementNames();
2552 sal_uInt32 nCount
= aElems
.getLength();
2553 Sequence
< Property
>* pPropSeq
2554 = new Sequence
< Property
>( nCount
);
2558 Reference
< XHierarchicalNameAccess
> xHierNameAccess(
2559 xNameAccess
, UNO_QUERY
);
2561 OSL_ENSURE( xHierNameAccess
.is(),
2562 "PropertySetInfo_Impl::getProperties - "
2563 "No hierarchical name access!" );
2565 if ( xHierNameAccess
.is() )
2567 const OUString aHandleName
2568 = OUString::createFromAscii( "/Handle" );
2569 const OUString aValueName
2570 = OUString::createFromAscii( "/Value" );
2571 const OUString aAttrName
2572 = OUString::createFromAscii( "/Attributes" );
2574 Property
* pProps
= pPropSeq
->getArray();
2576 for ( sal_uInt32 n
= 0; n
< nCount
; ++n
)
2578 Property
& rProp
= pProps
[ n
];
2579 OUString rName
= aElems
[ n
];
2581 = makeHierarchalNameSegment( rName
);
2583 // Set property name.
2589 // Obtain and set property handle
2590 rtl::OUString aHierName
= aXMLName
;
2591 aHierName
+= aHandleName
;
2593 = xHierNameAccess
->getByHierarchicalName(
2596 if ( !( aKeyValue
>>= rProp
.Handle
) )
2597 OSL_ENSURE( sal_False
,
2598 "PropertySetInfo_Impl::getProperties - "
2599 "Error getting property handle!" );
2601 catch ( NoSuchElementException
& )
2603 // getByHierarchicalName
2605 OSL_ENSURE( sal_False
,
2606 "PropertySetInfo_Impl::getProperties - "
2607 "NoSuchElementException!" );
2612 // Obtain and set property type
2613 rtl::OUString aHierName
= aXMLName
;
2614 aHierName
+= aValueName
;
2616 = xHierNameAccess
->getByHierarchicalName(
2619 // Note: The type may be void if addProperty
2620 // was called with a default value
2623 rProp
.Type
= aKeyValue
.getValueType();
2625 catch ( NoSuchElementException
& )
2627 // getByHierarchicalName
2629 OSL_ENSURE( sal_False
,
2630 "PropertySetInfo_Impl::getProperties - "
2631 "NoSuchElementException!" );
2636 // Obtain and set property attributes
2637 rtl::OUString aHierName
= aXMLName
;
2638 aHierName
+= aAttrName
;
2640 = xHierNameAccess
->getByHierarchicalName(
2643 sal_Int32 nAttribs
= 0;
2644 if ( aKeyValue
>>= nAttribs
)
2646 = sal_Int16( nAttribs
);
2648 OSL_ENSURE( sal_False
,
2649 "PropertySetInfo_Impl::getProperties - "
2650 "Error getting property attributes!" );
2652 catch ( NoSuchElementException
& )
2654 // getByHierarchicalName
2656 OSL_ENSURE( sal_False
,
2657 "PropertySetInfo_Impl::getProperties - "
2658 "NoSuchElementException!" );
2665 m_pProps
= pPropSeq
;
2669 catch ( NoSuchElementException
& )
2671 // getByHierarchicalName
2675 OSL_ENSURE( sal_False
, "PropertySetInfo_Impl::getProperties - Error!" );
2676 m_pProps
= new Sequence
< Property
>( 0 );
2682 //=========================================================================
2684 Property SAL_CALL
PropertySetInfo_Impl::getPropertyByName(
2685 const OUString
& aName
)
2686 throw( UnknownPropertyException
, RuntimeException
)
2688 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
2689 m_pOwner
->getPropertySetRegistry().getRootConfigReadAccess(),
2691 if ( xRootHierNameAccess
.is() )
2693 OUString
aFullPropName( m_pOwner
->getFullKey() );
2694 aFullPropName
+= OUString::createFromAscii( "/" );
2695 aFullPropName
+= makeHierarchalNameSegment( aName
);
2697 // Does property exist?
2698 if ( !xRootHierNameAccess
->hasByHierarchicalName( aFullPropName
) )
2699 throw UnknownPropertyException();
2706 OUString aKey
= aFullPropName
;
2707 aKey
+= OUString::createFromAscii( "/Handle" );
2709 if ( !( xRootHierNameAccess
->getByHierarchicalName( aKey
)
2710 >>= aProp
.Handle
) )
2712 OSL_ENSURE( sal_False
,
2713 "PropertySetInfo_Impl::getPropertyByName - "
2718 // Obtain Value and extract type.
2719 aKey
= aFullPropName
;
2720 aKey
+= OUString::createFromAscii( "/Value" );
2722 Any aValue
= xRootHierNameAccess
->getByHierarchicalName( aKey
);
2723 if ( !aValue
.hasValue() )
2725 OSL_ENSURE( sal_False
,
2726 "PropertySetInfo_Impl::getPropertyByName - "
2731 aProp
.Type
= aValue
.getValueType();
2733 // Obtain Attributes.
2734 aKey
= aFullPropName
;
2735 aKey
+= OUString::createFromAscii( "/Attributes" );
2737 sal_Int32 nAttribs
= 0;
2738 if ( xRootHierNameAccess
->getByHierarchicalName( aKey
)
2740 aProp
.Attributes
= sal_Int16( nAttribs
);
2743 OSL_ENSURE( sal_False
,
2744 "PropertySetInfo_Impl::getPropertyByName - "
2755 catch ( NoSuchElementException
& )
2757 // getByHierarchicalName
2759 OSL_ENSURE( sal_False
,
2760 "PropertySetInfo_Impl::getPropertyByName - "
2761 "caught NoSuchElementException!" );
2766 OSL_ENSURE( sal_False
, "PropertySetInfo_Impl::getPropertyByName - Error!" );
2770 //=========================================================================
2772 sal_Bool SAL_CALL
PropertySetInfo_Impl::hasPropertyByName(
2773 const OUString
& Name
)
2774 throw( RuntimeException
)
2776 Reference
< XHierarchicalNameAccess
> xRootHierNameAccess(
2777 m_pOwner
->getPropertySetRegistry().getRootConfigReadAccess(),
2779 if ( xRootHierNameAccess
.is() )
2781 OUString
aFullPropName( m_pOwner
->getFullKey() );
2782 aFullPropName
+= OUString::createFromAscii( "/" );
2783 aFullPropName
+= makeHierarchalNameSegment( Name
);
2785 return xRootHierNameAccess
->hasByHierarchicalName( aFullPropName
);