1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __XOLESIMPLESTORAGE_HXX_ 25 #define __XOLESIMPLESTORAGE_HXX_ 26 27 #include <com/sun/star/embed/XOLESimpleStorage.hpp> 28 #include <com/sun/star/container/XNameContainer.hpp> 29 #include <com/sun/star/lang/XComponent.hpp> 30 #include <com/sun/star/lang/XInitialization.hpp> 31 #include <com/sun/star/lang/XServiceInfo.hpp> 32 #include <com/sun/star/embed/XTransactedObject.hpp> 33 #include <com/sun/star/embed/XClassifiedObject.hpp> 34 35 36 #include <com/sun/star/io/XOutputStream.hpp> 37 #include <cppuhelper/implbase3.hxx> 38 #include <cppuhelper/interfacecontainer.h> 39 40 #include <osl/mutex.hxx> 41 42 #include <sot/stg.hxx> 43 44 45 class OLESimpleStorage : public ::cppu::WeakImplHelper3 46 < ::com::sun::star::embed::XOLESimpleStorage 47 , ::com::sun::star::lang::XInitialization 48 , ::com::sun::star::lang::XServiceInfo > 49 { 50 ::osl::Mutex m_aMutex; 51 52 sal_Bool m_bDisposed; 53 54 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream; 55 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xTempStream; 56 SvStream* m_pStream; 57 BaseStorage* m_pStorage; 58 59 ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners 60 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 61 62 sal_Bool m_bNoTemporaryCopy; 63 64 void UpdateOriginal_Impl(); 65 66 static void InsertInputStreamToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInputStream ) 67 throw ( ::com::sun::star::uno::Exception ); 68 69 static void InsertNameAccessToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& xNameAccess ) 70 throw ( ::com::sun::star::uno::Exception ); 71 72 public: 73 74 OLESimpleStorage( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory ); 75 76 virtual ~OLESimpleStorage(); 77 78 static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL impl_staticGetSupportedServiceNames(); 79 static ::rtl::OUString SAL_CALL impl_staticGetImplementationName(); 80 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 81 impl_staticCreateSelfInstance( 82 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); 83 84 85 //____________________________________________________________________________________________________ 86 // XInitialization 87 //____________________________________________________________________________________________________ 88 89 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 90 throw ( ::com::sun::star::uno::Exception, 91 ::com::sun::star::uno::RuntimeException); 92 93 //____________________________________________________________________________________________________ 94 // XNameContainer 95 //____________________________________________________________________________________________________ 96 97 virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 98 throw ( ::com::sun::star::lang::IllegalArgumentException, 99 ::com::sun::star::container::ElementExistException, 100 ::com::sun::star::lang::WrappedTargetException, 101 ::com::sun::star::uno::RuntimeException); 102 103 virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) 104 throw ( ::com::sun::star::container::NoSuchElementException, 105 ::com::sun::star::lang::WrappedTargetException, 106 ::com::sun::star::uno::RuntimeException); 107 108 virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 109 throw ( ::com::sun::star::lang::IllegalArgumentException, 110 ::com::sun::star::container::NoSuchElementException, 111 ::com::sun::star::lang::WrappedTargetException, 112 ::com::sun::star::uno::RuntimeException); 113 114 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 115 throw ( ::com::sun::star::container::NoSuchElementException, 116 ::com::sun::star::lang::WrappedTargetException, 117 ::com::sun::star::uno::RuntimeException ); 118 119 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 120 throw ( ::com::sun::star::uno::RuntimeException ); 121 122 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 123 throw ( ::com::sun::star::uno::RuntimeException ); 124 125 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 126 throw ( ::com::sun::star::uno::RuntimeException ); 127 128 virtual sal_Bool SAL_CALL hasElements() 129 throw ( ::com::sun::star::uno::RuntimeException ); 130 131 //____________________________________________________________________________________________________ 132 // XComponent 133 //____________________________________________________________________________________________________ 134 135 virtual void SAL_CALL dispose() 136 throw ( ::com::sun::star::uno::RuntimeException ); 137 138 virtual void SAL_CALL addEventListener( 139 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) 140 throw ( ::com::sun::star::uno::RuntimeException ); 141 142 virtual void SAL_CALL removeEventListener( 143 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) 144 throw ( ::com::sun::star::uno::RuntimeException ); 145 146 //____________________________________________________________________________________________________ 147 // XTransactedObject 148 //____________________________________________________________________________________________________ 149 150 virtual void SAL_CALL commit() 151 throw ( ::com::sun::star::io::IOException, 152 ::com::sun::star::lang::WrappedTargetException, 153 ::com::sun::star::uno::RuntimeException ); 154 155 virtual void SAL_CALL revert() 156 throw ( ::com::sun::star::io::IOException, 157 ::com::sun::star::lang::WrappedTargetException, 158 ::com::sun::star::uno::RuntimeException ); 159 160 //____________________________________________________________________________________________________ 161 // XClassifiedObject 162 //____________________________________________________________________________________________________ 163 164 virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getClassID() 165 throw ( ::com::sun::star::uno::RuntimeException ); 166 167 virtual ::rtl::OUString SAL_CALL getClassName() 168 throw ( ::com::sun::star::uno::RuntimeException ); 169 170 virtual void SAL_CALL setClassInfo( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aClassID, 171 const ::rtl::OUString& sClassName ) 172 throw ( ::com::sun::star::lang::NoSupportException, 173 ::com::sun::star::uno::RuntimeException ); 174 175 //____________________________________________________________________________________________________ 176 // XServiceInfo 177 //____________________________________________________________________________________________________ 178 179 virtual ::rtl::OUString SAL_CALL getImplementationName() 180 throw ( ::com::sun::star::uno::RuntimeException ); 181 182 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 183 throw ( ::com::sun::star::uno::RuntimeException ); 184 185 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 186 throw ( ::com::sun::star::uno::RuntimeException ); 187 188 }; 189 190 #endif 191 192