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 #ifndef INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX 21 #define INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX 22 23 #include <com/sun/star/lang/XServiceInfo.hpp> 24 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 25 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 26 #include <com/sun/star/container/XNamed.hpp> 27 #include <com/sun/star/container/XNameAccess.hpp> 28 #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp> 29 #include <com/sun/star/ucb/XPropertySetRegistry.hpp> 30 #include <com/sun/star/ucb/XPersistentPropertySet.hpp> 31 #include <com/sun/star/uno/XComponentContext.hpp> 32 #include <com/sun/star/beans/XPropertyContainer.hpp> 33 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp> 34 #include <com/sun/star/beans/XPropertyAccess.hpp> 35 #include <com/sun/star/lang/XComponent.hpp> 36 #include <com/sun/star/lang/XInitialization.hpp> 37 #include <cppuhelper/implbase.hxx> 38 #include <memory> 39 40 41 #define STORE_SERVICE_NAME "com.sun.star.ucb.Store" 42 #define PROPSET_REG_SERVICE_NAME "com.sun.star.ucb.PropertySetRegistry" 43 #define PERS_PROPSET_SERVICE_NAME "com.sun.star.ucb.PersistentPropertySet" 44 45 46 struct UcbStore_Impl; 47 48 class UcbStore : public cppu::WeakImplHelper < 49 css::lang::XServiceInfo, 50 css::ucb::XPropertySetRegistryFactory, 51 css::lang::XInitialization > 52 { 53 css::uno::Reference< css::uno::XComponentContext > m_xContext; 54 std::unique_ptr<UcbStore_Impl> m_pImpl; 55 56 public: 57 explicit UcbStore( const css::uno::Reference< css::uno::XComponentContext >& xContext ); 58 virtual ~UcbStore() override; 59 60 // XServiceInfo 61 virtual OUString SAL_CALL getImplementationName() override; 62 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 63 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 64 65 static OUString getImplementationName_Static(); 66 static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); 67 68 static css::uno::Reference< css::lang::XSingleServiceFactory > 69 createServiceFactory( const css::uno::Reference< 70 css::lang::XMultiServiceFactory >& rxServiceMgr ); 71 72 // XPropertySetRegistryFactory 73 virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL 74 createPropertySetRegistry( const OUString& URL ) override; 75 76 // XInitialization 77 virtual void SAL_CALL 78 initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; 79 }; 80 81 82 struct PropertySetRegistry_Impl; 83 class PersistentPropertySet; 84 85 class PropertySetRegistry : public cppu::WeakImplHelper < 86 css::lang::XServiceInfo, 87 css::ucb::XPropertySetRegistry, 88 css::container::XNameAccess > 89 { 90 friend class PersistentPropertySet; 91 92 css::uno::Reference< css::uno::XComponentContext > m_xContext; 93 std::unique_ptr<PropertySetRegistry_Impl> m_pImpl; 94 95 private: 96 css::uno::Reference< css::lang::XMultiServiceFactory > 97 getConfigProvider(); 98 99 void add ( PersistentPropertySet* pSet ); 100 void remove( PersistentPropertySet* pSet ); 101 102 void renamePropertySet( const OUString& rOldKey, 103 const OUString& rNewKey ); 104 105 public: 106 PropertySetRegistry( 107 const css::uno::Reference< css::uno::XComponentContext >& xContext, 108 const css::uno::Sequence< css::uno::Any >& rInitArgs); 109 virtual ~PropertySetRegistry() override; 110 111 112 // XServiceInfo 113 virtual OUString SAL_CALL getImplementationName() override; 114 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 115 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 116 117 // XPropertySetRegistry 118 virtual css::uno::Reference< css::ucb::XPersistentPropertySet > SAL_CALL 119 openPropertySet( const OUString& key, sal_Bool create ) override; 120 virtual void SAL_CALL 121 removePropertySet( const OUString& key ) override; 122 123 // XElementAccess ( XNameAccess is derived from it ) 124 virtual css::uno::Type SAL_CALL 125 getElementType() override; 126 virtual sal_Bool SAL_CALL 127 hasElements() override; 128 129 // XNameAccess 130 virtual css::uno::Any SAL_CALL 131 getByName( const OUString& aName ) override; 132 virtual css::uno::Sequence< OUString > SAL_CALL 133 getElementNames() override; 134 virtual sal_Bool SAL_CALL 135 hasByName( const OUString& aName ) override; 136 137 // Non-interface methods 138 css::uno::Reference< css::uno::XInterface > 139 getRootConfigReadAccess(); 140 css::uno::Reference< css::uno::XInterface > 141 getConfigWriteAccess( const OUString& rPath ); 142 }; 143 144 145 struct PersistentPropertySet_Impl; 146 147 class PersistentPropertySet : public cppu::WeakImplHelper < 148 css::lang::XServiceInfo, 149 css::lang::XComponent, 150 css::ucb::XPersistentPropertySet, 151 css::container::XNamed, 152 css::beans::XPropertyContainer, 153 css::beans::XPropertySetInfoChangeNotifier, 154 css::beans::XPropertyAccess > 155 { 156 std::unique_ptr<PersistentPropertySet_Impl> m_pImpl; 157 158 private: 159 void notifyPropertyChangeEvent( 160 const css::beans::PropertyChangeEvent& rEvent ) const; 161 void notifyPropertySetInfoChange( 162 const css::beans::PropertySetInfoChangeEvent& evt ) const; 163 164 public: 165 PersistentPropertySet( 166 PropertySetRegistry& rCreator, 167 const OUString& rKey ); 168 virtual ~PersistentPropertySet() override; 169 170 // XServiceInfo 171 virtual OUString SAL_CALL getImplementationName() override; 172 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 173 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 174 175 // XComponent 176 virtual void SAL_CALL 177 dispose() override; 178 virtual void SAL_CALL 179 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override; 180 virtual void SAL_CALL 181 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override; 182 183 // XPropertySet 184 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL 185 getPropertySetInfo() override; 186 virtual void SAL_CALL 187 setPropertyValue( const OUString& aPropertyName, 188 const css::uno::Any& aValue ) override; 189 virtual css::uno::Any SAL_CALL 190 getPropertyValue( const OUString& PropertyName ) override; 191 virtual void SAL_CALL 192 addPropertyChangeListener( const OUString& aPropertyName, 193 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; 194 virtual void SAL_CALL 195 removePropertyChangeListener( const OUString& aPropertyName, 196 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; 197 virtual void SAL_CALL 198 addVetoableChangeListener( const OUString& PropertyName, 199 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; 200 virtual void SAL_CALL 201 removeVetoableChangeListener( const OUString& PropertyName, 202 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; 203 204 // XPersistentPropertySet 205 virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL 206 getRegistry() override; 207 virtual OUString SAL_CALL 208 getKey() override; 209 210 // XNamed 211 virtual OUString SAL_CALL 212 getName() override; 213 virtual void SAL_CALL 214 setName( const OUString& aName ) override; 215 216 // XPropertyContainer 217 virtual void SAL_CALL 218 addProperty( const OUString& Name, 219 sal_Int16 Attributes, 220 const css::uno::Any& DefaultValue ) override; 221 virtual void SAL_CALL 222 removeProperty( const OUString& Name ) override; 223 224 // XPropertySetInfoChangeNotifier 225 virtual void SAL_CALL 226 addPropertySetInfoChangeListener( const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override; 227 virtual void SAL_CALL 228 removePropertySetInfoChangeListener( const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override; 229 230 // XPropertyAccess 231 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL 232 getPropertyValues() override; 233 virtual void SAL_CALL 234 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override; 235 236 // Non-interface methods. 237 PropertySetRegistry& getPropertySetRegistry(); 238 const OUString& getFullKey(); 239 }; 240 241 #endif // INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX 242 243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 244