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 __XOLESIMPLESTORAGE_HXX_ 29 #define __XOLESIMPLESTORAGE_HXX_ 30 31 #include <com/sun/star/embed/XOLESimpleStorage.hpp> 32 #include <com/sun/star/container/XNameContainer.hpp> 33 #include <com/sun/star/lang/XComponent.hpp> 34 #include <com/sun/star/lang/XInitialization.hpp> 35 #include <com/sun/star/lang/XServiceInfo.hpp> 36 #include <com/sun/star/embed/XTransactedObject.hpp> 37 #include <com/sun/star/embed/XClassifiedObject.hpp> 38 39 40 #include <com/sun/star/io/XOutputStream.hpp> 41 #include <cppuhelper/implbase3.hxx> 42 #include <cppuhelper/interfacecontainer.h> 43 44 #include <osl/mutex.hxx> 45 46 #include <sot/stg.hxx> 47 48 49 class OLESimpleStorage : public ::cppu::WeakImplHelper3 50 < ::com::sun::star::embed::XOLESimpleStorage 51 , ::com::sun::star::lang::XInitialization 52 , ::com::sun::star::lang::XServiceInfo > 53 { 54 ::osl::Mutex m_aMutex; 55 56 sal_Bool m_bDisposed; 57 58 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream; 59 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xTempStream; 60 SvStream* m_pStream; 61 BaseStorage* m_pStorage; 62 63 ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners 64 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 65 66 sal_Bool m_bNoTemporaryCopy; 67 68 void UpdateOriginal_Impl(); 69 70 static void InsertInputStreamToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInputStream ) 71 throw ( ::com::sun::star::uno::Exception ); 72 73 static void InsertNameAccessToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& xNameAccess ) 74 throw ( ::com::sun::star::uno::Exception ); 75 76 public: 77 78 OLESimpleStorage( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory ); 79 80 virtual ~OLESimpleStorage(); 81 82 static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL impl_staticGetSupportedServiceNames(); 83 static ::rtl::OUString SAL_CALL impl_staticGetImplementationName(); 84 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 85 impl_staticCreateSelfInstance( 86 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); 87 88 89 //____________________________________________________________________________________________________ 90 // XInitialization 91 //____________________________________________________________________________________________________ 92 93 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 94 throw ( ::com::sun::star::uno::Exception, 95 ::com::sun::star::uno::RuntimeException); 96 97 //____________________________________________________________________________________________________ 98 // XNameContainer 99 //____________________________________________________________________________________________________ 100 101 virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 102 throw ( ::com::sun::star::lang::IllegalArgumentException, 103 ::com::sun::star::container::ElementExistException, 104 ::com::sun::star::lang::WrappedTargetException, 105 ::com::sun::star::uno::RuntimeException); 106 107 virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) 108 throw ( ::com::sun::star::container::NoSuchElementException, 109 ::com::sun::star::lang::WrappedTargetException, 110 ::com::sun::star::uno::RuntimeException); 111 112 virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 113 throw ( ::com::sun::star::lang::IllegalArgumentException, 114 ::com::sun::star::container::NoSuchElementException, 115 ::com::sun::star::lang::WrappedTargetException, 116 ::com::sun::star::uno::RuntimeException); 117 118 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 119 throw ( ::com::sun::star::container::NoSuchElementException, 120 ::com::sun::star::lang::WrappedTargetException, 121 ::com::sun::star::uno::RuntimeException ); 122 123 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 124 throw ( ::com::sun::star::uno::RuntimeException ); 125 126 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 127 throw ( ::com::sun::star::uno::RuntimeException ); 128 129 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 130 throw ( ::com::sun::star::uno::RuntimeException ); 131 132 virtual sal_Bool SAL_CALL hasElements() 133 throw ( ::com::sun::star::uno::RuntimeException ); 134 135 //____________________________________________________________________________________________________ 136 // XComponent 137 //____________________________________________________________________________________________________ 138 139 virtual void SAL_CALL dispose() 140 throw ( ::com::sun::star::uno::RuntimeException ); 141 142 virtual void SAL_CALL addEventListener( 143 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) 144 throw ( ::com::sun::star::uno::RuntimeException ); 145 146 virtual void SAL_CALL removeEventListener( 147 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) 148 throw ( ::com::sun::star::uno::RuntimeException ); 149 150 //____________________________________________________________________________________________________ 151 // XTransactedObject 152 //____________________________________________________________________________________________________ 153 154 virtual void SAL_CALL commit() 155 throw ( ::com::sun::star::io::IOException, 156 ::com::sun::star::lang::WrappedTargetException, 157 ::com::sun::star::uno::RuntimeException ); 158 159 virtual void SAL_CALL revert() 160 throw ( ::com::sun::star::io::IOException, 161 ::com::sun::star::lang::WrappedTargetException, 162 ::com::sun::star::uno::RuntimeException ); 163 164 //____________________________________________________________________________________________________ 165 // XClassifiedObject 166 //____________________________________________________________________________________________________ 167 168 virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getClassID() 169 throw ( ::com::sun::star::uno::RuntimeException ); 170 171 virtual ::rtl::OUString SAL_CALL getClassName() 172 throw ( ::com::sun::star::uno::RuntimeException ); 173 174 virtual void SAL_CALL setClassInfo( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aClassID, 175 const ::rtl::OUString& sClassName ) 176 throw ( ::com::sun::star::lang::NoSupportException, 177 ::com::sun::star::uno::RuntimeException ); 178 179 //____________________________________________________________________________________________________ 180 // XServiceInfo 181 //____________________________________________________________________________________________________ 182 183 virtual ::rtl::OUString SAL_CALL getImplementationName() 184 throw ( ::com::sun::star::uno::RuntimeException ); 185 186 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 187 throw ( ::com::sun::star::uno::RuntimeException ); 188 189 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 190 throw ( ::com::sun::star::uno::RuntimeException ); 191 192 }; 193 194 #endif 195 196