1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _UCBSTORE_HXX 29 #define _UCBSTORE_HXX 30 31 #include <com/sun/star/lang/XTypeProvider.hpp> 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 34 #include <com/sun/star/container/XNamed.hpp> 35 #include <com/sun/star/container/XNameAccess.hpp> 36 #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp> 37 #include <com/sun/star/ucb/XPropertySetRegistry.hpp> 38 #include <com/sun/star/ucb/XPersistentPropertySet.hpp> 39 #include <com/sun/star/beans/XPropertyContainer.hpp> 40 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp> 41 #include <com/sun/star/beans/XPropertyAccess.hpp> 42 #include <com/sun/star/lang/XComponent.hpp> 43 #include <com/sun/star/lang/XInitialization.hpp> 44 #include <cppuhelper/weak.hxx> 45 #include <ucbhelper/macros.hxx> 46 47 //========================================================================= 48 49 #define STORE_SERVICE_NAME "com.sun.star.ucb.Store" 50 #define PROPSET_REG_SERVICE_NAME "com.sun.star.ucb.PropertySetRegistry" 51 #define PERS_PROPSET_SERVICE_NAME "com.sun.star.ucb.PersistentPropertySet" 52 53 //========================================================================= 54 55 struct UcbStore_Impl; 56 57 class UcbStore : 58 public cppu::OWeakObject, 59 public com::sun::star::lang::XTypeProvider, 60 public com::sun::star::lang::XServiceInfo, 61 public com::sun::star::ucb::XPropertySetRegistryFactory, 62 public com::sun::star::lang::XInitialization 63 { 64 com::sun::star::uno::Reference< 65 com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 66 UcbStore_Impl* m_pImpl; 67 68 public: 69 UcbStore( 70 const com::sun::star::uno::Reference< 71 com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); 72 virtual ~UcbStore(); 73 74 // XInterface 75 XINTERFACE_DECL() 76 77 // XTypeProvider 78 XTYPEPROVIDER_DECL() 79 80 // XServiceInfo 81 XSERVICEINFO_DECL() 82 83 // XPropertySetRegistryFactory 84 virtual com::sun::star::uno::Reference< 85 com::sun::star::ucb::XPropertySetRegistry > SAL_CALL 86 createPropertySetRegistry( const rtl::OUString& URL ) 87 throw( com::sun::star::uno::RuntimeException ); 88 89 // XInitialization 90 virtual void SAL_CALL 91 initialize( const ::com::sun::star::uno::Sequence< 92 ::com::sun::star::uno::Any >& aArguments ) 93 throw( ::com::sun::star::uno::Exception, 94 ::com::sun::star::uno::RuntimeException ); 95 96 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& 97 getInitArgs() const; 98 }; 99 100 //========================================================================= 101 102 struct PropertySetRegistry_Impl; 103 class PersistentPropertySet; 104 105 class PropertySetRegistry : 106 public cppu::OWeakObject, 107 public com::sun::star::lang::XTypeProvider, 108 public com::sun::star::lang::XServiceInfo, 109 public com::sun::star::ucb::XPropertySetRegistry, 110 public com::sun::star::container::XNameAccess 111 { 112 friend class PersistentPropertySet; 113 114 com::sun::star::uno::Reference< 115 com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 116 PropertySetRegistry_Impl* m_pImpl; 117 118 private: 119 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > 120 getConfigProvider(); 121 122 void add ( PersistentPropertySet* pSet ); 123 void remove( PersistentPropertySet* pSet ); 124 125 void renamePropertySet( const rtl::OUString& rOldKey, 126 const rtl::OUString& rNewKey ); 127 128 public: 129 PropertySetRegistry( 130 const com::sun::star::uno::Reference< 131 com::sun::star::lang::XMultiServiceFactory >& rXSMgr, 132 const ::com::sun::star::uno::Sequence< 133 ::com::sun::star::uno::Any >& rInitArgs); 134 virtual ~PropertySetRegistry(); 135 136 // XInterface 137 XINTERFACE_DECL() 138 139 // XTypeProvider 140 XTYPEPROVIDER_DECL() 141 142 // XServiceInfo 143 XSERVICEINFO_NOFACTORY_DECL() 144 145 // XPropertySetRegistry 146 virtual com::sun::star::uno::Reference< 147 com::sun::star::ucb::XPersistentPropertySet > SAL_CALL 148 openPropertySet( const rtl::OUString& key, sal_Bool create ) 149 throw( com::sun::star::uno::RuntimeException ); 150 virtual void SAL_CALL 151 removePropertySet( const rtl::OUString& key ) 152 throw( com::sun::star::uno::RuntimeException ); 153 154 // XElementAccess ( XNameAccess is derived from it ) 155 virtual com::sun::star::uno::Type SAL_CALL 156 getElementType() 157 throw( com::sun::star::uno::RuntimeException ); 158 virtual sal_Bool SAL_CALL 159 hasElements() 160 throw( com::sun::star::uno::RuntimeException ); 161 162 // XNameAccess 163 virtual com::sun::star::uno::Any SAL_CALL 164 getByName( const rtl::OUString& aName ) 165 throw( com::sun::star::container::NoSuchElementException, 166 com::sun::star::lang::WrappedTargetException, 167 com::sun::star::uno::RuntimeException ); 168 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 169 getElementNames() 170 throw( com::sun::star::uno::RuntimeException ); 171 virtual sal_Bool SAL_CALL 172 hasByName( const rtl::OUString& aName ) 173 throw( com::sun::star::uno::RuntimeException ); 174 175 // Non-interface methods 176 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > 177 getRootConfigReadAccess(); 178 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > 179 getConfigWriteAccess( const rtl::OUString& rPath ); 180 }; 181 182 //========================================================================= 183 184 struct PersistentPropertySet_Impl; 185 186 class PersistentPropertySet : 187 public cppu::OWeakObject, 188 public com::sun::star::lang::XTypeProvider, 189 public com::sun::star::lang::XServiceInfo, 190 public com::sun::star::lang::XComponent, 191 public com::sun::star::ucb::XPersistentPropertySet, 192 public com::sun::star::container::XNamed, 193 public com::sun::star::beans::XPropertyContainer, 194 public com::sun::star::beans::XPropertySetInfoChangeNotifier, 195 public com::sun::star::beans::XPropertyAccess 196 { 197 com::sun::star::uno::Reference< 198 com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 199 PersistentPropertySet_Impl* m_pImpl; 200 201 private: 202 void notifyPropertyChangeEvent( 203 const com::sun::star::beans::PropertyChangeEvent& rEvent ) const; 204 void notifyPropertySetInfoChange( 205 const com::sun::star::beans::PropertySetInfoChangeEvent& evt ) const; 206 207 public: 208 PersistentPropertySet( 209 const com::sun::star::uno::Reference< 210 com::sun::star::lang::XMultiServiceFactory >& rXSMgr, 211 PropertySetRegistry& rCreator, 212 const rtl::OUString& rKey ); 213 virtual ~PersistentPropertySet(); 214 215 // XInterface 216 XINTERFACE_DECL() 217 218 // XTypeProvider 219 XTYPEPROVIDER_DECL() 220 221 // XServiceInfo 222 XSERVICEINFO_NOFACTORY_DECL() 223 224 // XComponent 225 virtual void SAL_CALL 226 dispose() 227 throw( com::sun::star::uno::RuntimeException ); 228 virtual void SAL_CALL 229 addEventListener( const com::sun::star::uno::Reference< 230 com::sun::star::lang::XEventListener >& Listener ) 231 throw( com::sun::star::uno::RuntimeException ); 232 virtual void SAL_CALL 233 removeEventListener( const com::sun::star::uno::Reference< 234 com::sun::star::lang::XEventListener >& Listener ) 235 throw( com::sun::star::uno::RuntimeException ); 236 237 // XPropertySet 238 virtual com::sun::star::uno::Reference< 239 com::sun::star::beans::XPropertySetInfo > SAL_CALL 240 getPropertySetInfo() 241 throw( com::sun::star::uno::RuntimeException ); 242 virtual void SAL_CALL 243 setPropertyValue( const rtl::OUString& aPropertyName, 244 const com::sun::star::uno::Any& aValue ) 245 throw( com::sun::star::beans::UnknownPropertyException, 246 com::sun::star::beans::PropertyVetoException, 247 com::sun::star::lang::IllegalArgumentException, 248 com::sun::star::lang::WrappedTargetException, 249 com::sun::star::uno::RuntimeException ); 250 virtual com::sun::star::uno::Any SAL_CALL 251 getPropertyValue( const rtl::OUString& PropertyName ) 252 throw( com::sun::star::beans::UnknownPropertyException, 253 com::sun::star::lang::WrappedTargetException, 254 com::sun::star::uno::RuntimeException ); 255 virtual void SAL_CALL 256 addPropertyChangeListener( const rtl::OUString& aPropertyName, 257 const com::sun::star::uno::Reference< 258 com::sun::star::beans::XPropertyChangeListener >& xListener ) 259 throw( com::sun::star::beans::UnknownPropertyException, 260 com::sun::star::lang::WrappedTargetException, 261 com::sun::star::uno::RuntimeException ); 262 virtual void SAL_CALL 263 removePropertyChangeListener( const rtl::OUString& aPropertyName, 264 const com::sun::star::uno::Reference< 265 com::sun::star::beans::XPropertyChangeListener >& aListener ) 266 throw( com::sun::star::beans::UnknownPropertyException, 267 com::sun::star::lang::WrappedTargetException, 268 com::sun::star::uno::RuntimeException ); 269 virtual void SAL_CALL 270 addVetoableChangeListener( const rtl::OUString& PropertyName, 271 const com::sun::star::uno::Reference< 272 com::sun::star::beans::XVetoableChangeListener >& aListener ) 273 throw( com::sun::star::beans::UnknownPropertyException, 274 com::sun::star::lang::WrappedTargetException, 275 com::sun::star::uno::RuntimeException ); 276 virtual void SAL_CALL 277 removeVetoableChangeListener( const rtl::OUString& PropertyName, 278 const com::sun::star::uno::Reference< 279 com::sun::star::beans::XVetoableChangeListener >& aListener ) 280 throw( com::sun::star::beans::UnknownPropertyException, 281 com::sun::star::lang::WrappedTargetException, 282 com::sun::star::uno::RuntimeException ); 283 284 // XPersistentPropertySet 285 virtual com::sun::star::uno::Reference< 286 com::sun::star::ucb::XPropertySetRegistry > SAL_CALL 287 getRegistry() 288 throw( com::sun::star::uno::RuntimeException ); 289 virtual rtl::OUString SAL_CALL 290 getKey() 291 throw( com::sun::star::uno::RuntimeException ); 292 293 // XNamed 294 virtual rtl::OUString SAL_CALL 295 getName() 296 throw( ::com::sun::star::uno::RuntimeException ); 297 virtual void SAL_CALL 298 setName( const ::rtl::OUString& aName ) 299 throw( ::com::sun::star::uno::RuntimeException ); 300 301 // XPropertyContainer 302 virtual void SAL_CALL 303 addProperty( const rtl::OUString& Name, 304 sal_Int16 Attributes, 305 const com::sun::star::uno::Any& DefaultValue ) 306 throw( com::sun::star::beans::PropertyExistException, 307 com::sun::star::beans::IllegalTypeException, 308 com::sun::star::lang::IllegalArgumentException, 309 com::sun::star::uno::RuntimeException ); 310 virtual void SAL_CALL 311 removeProperty( const rtl::OUString& Name ) 312 throw( com::sun::star::beans::UnknownPropertyException, 313 com::sun::star::beans::NotRemoveableException, 314 com::sun::star::uno::RuntimeException ); 315 316 // XPropertySetInfoChangeNotifier 317 virtual void SAL_CALL 318 addPropertySetInfoChangeListener( const com::sun::star::uno::Reference< 319 com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ) 320 throw( com::sun::star::uno::RuntimeException ); 321 virtual void SAL_CALL 322 removePropertySetInfoChangeListener( const com::sun::star::uno::Reference< 323 com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ) 324 throw( com::sun::star::uno::RuntimeException ); 325 326 // XPropertyAccess 327 virtual com::sun::star::uno::Sequence< 328 com::sun::star::beans::PropertyValue > SAL_CALL 329 getPropertyValues() 330 throw( com::sun::star::uno::RuntimeException ); 331 virtual void SAL_CALL 332 setPropertyValues( const com::sun::star::uno::Sequence< 333 com::sun::star::beans::PropertyValue >& aProps ) 334 throw( com::sun::star::beans::UnknownPropertyException, 335 com::sun::star::beans::PropertyVetoException, 336 com::sun::star::lang::IllegalArgumentException, 337 com::sun::star::lang::WrappedTargetException, 338 com::sun::star::uno::RuntimeException ); 339 340 // Non-interface methods. 341 PropertySetRegistry& getPropertySetRegistry(); 342 const rtl::OUString& getFullKey(); 343 }; 344 345 #endif /* !_UCBSTORE_HXX */ 346