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