1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef INCLUDED_TDOC_STGELEMS_HXX 29*cdf0e10cSrcweir #define INCLUDED_TDOC_STGELEMS_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <memory> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "osl/mutex.hxx" 34*cdf0e10cSrcweir #include "rtl/ref.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "cppuhelper/implbase2.hxx" 37*cdf0e10cSrcweir #include "cppuhelper/implbase5.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "com/sun/star/embed/XStorage.hpp" 40*cdf0e10cSrcweir #include "com/sun/star/embed/XTransactedObject.hpp" 41*cdf0e10cSrcweir #include "com/sun/star/io/XOutputStream.hpp" 42*cdf0e10cSrcweir #include "com/sun/star/io/XStream.hpp" 43*cdf0e10cSrcweir #include "com/sun/star/io/XTruncate.hpp" 44*cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp" 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include "tdoc_storage.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir namespace tdoc_ucp { 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir struct MutexHolder 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir osl::Mutex m_aMutex; 53*cdf0e10cSrcweir }; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //======================================================================= 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir class ParentStorageHolder : public MutexHolder 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir public: 60*cdf0e10cSrcweir ParentStorageHolder( 61*cdf0e10cSrcweir const com::sun::star::uno::Reference< 62*cdf0e10cSrcweir com::sun::star::embed::XStorage > & xParentStorage, 63*cdf0e10cSrcweir const rtl::OUString & rUri ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir bool isParentARootStorage() const 66*cdf0e10cSrcweir { return m_bParentIsRootStorage; } 67*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::embed::XStorage > 68*cdf0e10cSrcweir getParentStorage() const 69*cdf0e10cSrcweir { return m_xParentStorage; } 70*cdf0e10cSrcweir void setParentStorage( const com::sun::star::uno::Reference< 71*cdf0e10cSrcweir com::sun::star::embed::XStorage > & xStg ) 72*cdf0e10cSrcweir { osl::MutexGuard aGuard( m_aMutex ); m_xParentStorage = xStg; } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir private: 75*cdf0e10cSrcweir com::sun::star::uno::Reference< 76*cdf0e10cSrcweir com::sun::star::embed::XStorage > m_xParentStorage; 77*cdf0e10cSrcweir bool m_bParentIsRootStorage; 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //======================================================================= 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir typedef 83*cdf0e10cSrcweir cppu::WeakImplHelper2< 84*cdf0e10cSrcweir com::sun::star::embed::XStorage, 85*cdf0e10cSrcweir com::sun::star::embed::XTransactedObject > StorageUNOBase; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir class Storage : public StorageUNOBase, public ParentStorageHolder 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir public: 90*cdf0e10cSrcweir Storage( 91*cdf0e10cSrcweir const com::sun::star::uno::Reference< 92*cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory > & xSMgr, 93*cdf0e10cSrcweir const rtl::Reference< StorageElementFactory > & xFactory, 94*cdf0e10cSrcweir const rtl::OUString & rUri, 95*cdf0e10cSrcweir const com::sun::star::uno::Reference< 96*cdf0e10cSrcweir com::sun::star::embed::XStorage > & xParentStorage, 97*cdf0e10cSrcweir const com::sun::star::uno::Reference< 98*cdf0e10cSrcweir com::sun::star::embed::XStorage > & xStorageToWrap ); 99*cdf0e10cSrcweir virtual ~Storage(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir bool isDocumentStorage() const { return m_bIsDocumentStorage; } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir // XInterface 104*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL queryInterface( 105*cdf0e10cSrcweir const com::sun::star::uno::Type& aType ) 106*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 107*cdf0e10cSrcweir virtual void SAL_CALL acquire() 108*cdf0e10cSrcweir throw (); 109*cdf0e10cSrcweir virtual void SAL_CALL release() 110*cdf0e10cSrcweir throw (); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // XTypeProvider (implemnented by base, but needs to be overridden for 113*cdf0e10cSrcweir // delegating to aggregate) 114*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL 115*cdf0e10cSrcweir getTypes() 116*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 117*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL 118*cdf0e10cSrcweir getImplementationId() 119*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // XComponent ( one of XStorage bases ) 122*cdf0e10cSrcweir virtual void SAL_CALL 123*cdf0e10cSrcweir dispose() 124*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 125*cdf0e10cSrcweir virtual void SAL_CALL 126*cdf0e10cSrcweir addEventListener( const com::sun::star::uno::Reference< 127*cdf0e10cSrcweir com::sun::star::lang::XEventListener > & xListener ) 128*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 129*cdf0e10cSrcweir virtual void SAL_CALL 130*cdf0e10cSrcweir removeEventListener( const com::sun::star::uno::Reference< 131*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& aListener ) 132*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // XNameAccess ( one of XStorage bases ) 135*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 136*cdf0e10cSrcweir getByName( const rtl::OUString& aName ) 137*cdf0e10cSrcweir throw ( com::sun::star::container::NoSuchElementException, 138*cdf0e10cSrcweir com::sun::star::lang::WrappedTargetException, 139*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 140*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 141*cdf0e10cSrcweir getElementNames() 142*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 143*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 144*cdf0e10cSrcweir hasByName( const rtl::OUString& aName ) 145*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // XElementAccess (base of XNameAccess) 148*cdf0e10cSrcweir virtual com::sun::star::uno::Type SAL_CALL 149*cdf0e10cSrcweir getElementType() 150*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 151*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 152*cdf0e10cSrcweir hasElements() 153*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // XStorage 156*cdf0e10cSrcweir virtual void SAL_CALL 157*cdf0e10cSrcweir copyToStorage( const com::sun::star::uno::Reference< 158*cdf0e10cSrcweir com::sun::star::embed::XStorage >& xDest ) 159*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 160*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 161*cdf0e10cSrcweir com::sun::star::io::IOException, 162*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 163*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 164*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL 165*cdf0e10cSrcweir openStreamElement( const ::rtl::OUString& aStreamName, 166*cdf0e10cSrcweir sal_Int32 nOpenMode ) 167*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 168*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 169*cdf0e10cSrcweir com::sun::star::packages::WrongPasswordException, 170*cdf0e10cSrcweir com::sun::star::io::IOException, 171*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 172*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 173*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL 174*cdf0e10cSrcweir openEncryptedStreamElement( const ::rtl::OUString& aStreamName, 175*cdf0e10cSrcweir sal_Int32 nOpenMode, 176*cdf0e10cSrcweir const ::rtl::OUString& aPassword ) 177*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 178*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 179*cdf0e10cSrcweir com::sun::star::packages::NoEncryptionException, 180*cdf0e10cSrcweir com::sun::star::packages::WrongPasswordException, 181*cdf0e10cSrcweir com::sun::star::io::IOException, 182*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 183*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 184*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::embed::XStorage > SAL_CALL 185*cdf0e10cSrcweir openStorageElement( const ::rtl::OUString& aStorName, 186*cdf0e10cSrcweir sal_Int32 nOpenMode ) 187*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 188*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 189*cdf0e10cSrcweir com::sun::star::io::IOException, 190*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 191*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 192*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL 193*cdf0e10cSrcweir cloneStreamElement( const ::rtl::OUString& aStreamName ) 194*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 195*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 196*cdf0e10cSrcweir com::sun::star::packages::WrongPasswordException, 197*cdf0e10cSrcweir com::sun::star::io::IOException, 198*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 199*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 200*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL 201*cdf0e10cSrcweir cloneEncryptedStreamElement( const ::rtl::OUString& aStreamName, 202*cdf0e10cSrcweir const ::rtl::OUString& aPassword ) 203*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 204*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 205*cdf0e10cSrcweir com::sun::star::packages::NoEncryptionException, 206*cdf0e10cSrcweir com::sun::star::packages::WrongPasswordException, 207*cdf0e10cSrcweir com::sun::star::io::IOException, 208*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 209*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 210*cdf0e10cSrcweir virtual void SAL_CALL 211*cdf0e10cSrcweir copyLastCommitTo( const com::sun::star::uno::Reference< 212*cdf0e10cSrcweir com::sun::star::embed::XStorage >& xTargetStorage ) 213*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 214*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 215*cdf0e10cSrcweir com::sun::star::io::IOException, 216*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 217*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 218*cdf0e10cSrcweir virtual void SAL_CALL 219*cdf0e10cSrcweir copyStorageElementLastCommitTo( const ::rtl::OUString& aStorName, 220*cdf0e10cSrcweir const com::sun::star::uno::Reference< 221*cdf0e10cSrcweir com::sun::star::embed::XStorage > & 222*cdf0e10cSrcweir xTargetStorage ) 223*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 224*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 225*cdf0e10cSrcweir com::sun::star::io::IOException, 226*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 227*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 228*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 229*cdf0e10cSrcweir isStreamElement( const ::rtl::OUString& aElementName ) 230*cdf0e10cSrcweir throw ( com::sun::star::container::NoSuchElementException, 231*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 232*cdf0e10cSrcweir com::sun::star::embed::InvalidStorageException, 233*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 234*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 235*cdf0e10cSrcweir isStorageElement( const ::rtl::OUString& aElementName ) 236*cdf0e10cSrcweir throw ( com::sun::star::container::NoSuchElementException, 237*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 238*cdf0e10cSrcweir com::sun::star::embed::InvalidStorageException, 239*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 240*cdf0e10cSrcweir virtual void SAL_CALL 241*cdf0e10cSrcweir removeElement( const ::rtl::OUString& aElementName ) 242*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 243*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 244*cdf0e10cSrcweir com::sun::star::container::NoSuchElementException, 245*cdf0e10cSrcweir com::sun::star::io::IOException, 246*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 247*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 248*cdf0e10cSrcweir virtual void SAL_CALL 249*cdf0e10cSrcweir renameElement( const ::rtl::OUString& aEleName, 250*cdf0e10cSrcweir const ::rtl::OUString& aNewName ) 251*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 252*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 253*cdf0e10cSrcweir com::sun::star::container::NoSuchElementException, 254*cdf0e10cSrcweir com::sun::star::container::ElementExistException, 255*cdf0e10cSrcweir com::sun::star::io::IOException, 256*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 257*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 258*cdf0e10cSrcweir virtual void SAL_CALL 259*cdf0e10cSrcweir copyElementTo( const ::rtl::OUString& aElementName, 260*cdf0e10cSrcweir const com::sun::star::uno::Reference< 261*cdf0e10cSrcweir com::sun::star::embed::XStorage >& xDest, 262*cdf0e10cSrcweir const ::rtl::OUString& aNewName ) 263*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 264*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 265*cdf0e10cSrcweir com::sun::star::container::NoSuchElementException, 266*cdf0e10cSrcweir com::sun::star::container::ElementExistException, 267*cdf0e10cSrcweir com::sun::star::io::IOException, 268*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 269*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 270*cdf0e10cSrcweir virtual void SAL_CALL 271*cdf0e10cSrcweir moveElementTo( const ::rtl::OUString& aElementName, 272*cdf0e10cSrcweir const com::sun::star::uno::Reference< 273*cdf0e10cSrcweir com::sun::star::embed::XStorage >& xDest, 274*cdf0e10cSrcweir const ::rtl::OUString& rNewName ) 275*cdf0e10cSrcweir throw ( com::sun::star::embed::InvalidStorageException, 276*cdf0e10cSrcweir com::sun::star::lang::IllegalArgumentException, 277*cdf0e10cSrcweir com::sun::star::container::NoSuchElementException, 278*cdf0e10cSrcweir com::sun::star::container::ElementExistException, 279*cdf0e10cSrcweir com::sun::star::io::IOException, 280*cdf0e10cSrcweir com::sun::star::embed::StorageWrappedTargetException, 281*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir // XTransactedObject 284*cdf0e10cSrcweir virtual void SAL_CALL commit() 285*cdf0e10cSrcweir throw ( com::sun::star::io::IOException, 286*cdf0e10cSrcweir com::sun::star::lang::WrappedTargetException, 287*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 288*cdf0e10cSrcweir virtual void SAL_CALL revert() 289*cdf0e10cSrcweir throw ( com::sun::star::io::IOException, 290*cdf0e10cSrcweir com::sun::star::lang::WrappedTargetException, 291*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir private: 294*cdf0e10cSrcweir Storage( const rtl::Reference< Storage > & rFactory ); // n.i. 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir rtl::Reference< StorageElementFactory > m_xFactory; 297*cdf0e10cSrcweir com::sun::star::uno::Reference< 298*cdf0e10cSrcweir com::sun::star::uno::XAggregation > m_xAggProxy; 299*cdf0e10cSrcweir com::sun::star::uno::Reference< 300*cdf0e10cSrcweir com::sun::star::embed::XStorage > m_xWrappedStorage; 301*cdf0e10cSrcweir com::sun::star::uno::Reference< 302*cdf0e10cSrcweir com::sun::star::embed::XTransactedObject > m_xWrappedTransObj; 303*cdf0e10cSrcweir com::sun::star::uno::Reference< 304*cdf0e10cSrcweir com::sun::star::lang::XComponent > m_xWrappedComponent; 305*cdf0e10cSrcweir com::sun::star::uno::Reference< 306*cdf0e10cSrcweir com::sun::star::lang::XTypeProvider > m_xWrappedTypeProv; 307*cdf0e10cSrcweir bool m_bIsDocumentStorage; 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir StorageElementFactory::StorageMap::iterator m_aContainerIt; 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir friend class StorageElementFactory; 312*cdf0e10cSrcweir friend class std::auto_ptr< Storage >; 313*cdf0e10cSrcweir }; 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir //======================================================================= 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir typedef 318*cdf0e10cSrcweir cppu::WeakImplHelper2< 319*cdf0e10cSrcweir com::sun::star::io::XOutputStream, 320*cdf0e10cSrcweir com::sun::star::lang::XComponent > OutputStreamUNOBase; 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir class OutputStream : public OutputStreamUNOBase, public ParentStorageHolder 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir public: 325*cdf0e10cSrcweir OutputStream( 326*cdf0e10cSrcweir const com::sun::star::uno::Reference< 327*cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory > & xSMgr, 328*cdf0e10cSrcweir const rtl::OUString & rUri, 329*cdf0e10cSrcweir const com::sun::star::uno::Reference< 330*cdf0e10cSrcweir com::sun::star::embed::XStorage > & xParentStorage, 331*cdf0e10cSrcweir const com::sun::star::uno::Reference< 332*cdf0e10cSrcweir com::sun::star::io::XOutputStream > & xStreamToWrap ); 333*cdf0e10cSrcweir virtual ~OutputStream(); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir // XInterface 336*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 337*cdf0e10cSrcweir queryInterface( const com::sun::star::uno::Type& aType ) 338*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir // XTypeProvider (implemnented by base, but needs to be overridden for 341*cdf0e10cSrcweir // delegating to aggregate) 342*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL 343*cdf0e10cSrcweir getTypes() 344*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 345*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL 346*cdf0e10cSrcweir getImplementationId() 347*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir // XOutputStream 350*cdf0e10cSrcweir virtual void SAL_CALL 351*cdf0e10cSrcweir writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData ) 352*cdf0e10cSrcweir throw ( com::sun::star::io::NotConnectedException, 353*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 354*cdf0e10cSrcweir com::sun::star::io::IOException, 355*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 356*cdf0e10cSrcweir virtual void SAL_CALL 357*cdf0e10cSrcweir flush( ) 358*cdf0e10cSrcweir throw ( com::sun::star::io::NotConnectedException, 359*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 360*cdf0e10cSrcweir com::sun::star::io::IOException, 361*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 362*cdf0e10cSrcweir // Note: We need to intercept this one. 363*cdf0e10cSrcweir virtual void SAL_CALL 364*cdf0e10cSrcweir closeOutput( ) 365*cdf0e10cSrcweir throw ( com::sun::star::io::NotConnectedException, 366*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 367*cdf0e10cSrcweir com::sun::star::io::IOException, 368*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir // XComponent 371*cdf0e10cSrcweir // Note: We need to intercept this one. 372*cdf0e10cSrcweir virtual void SAL_CALL 373*cdf0e10cSrcweir dispose() 374*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 375*cdf0e10cSrcweir virtual void SAL_CALL 376*cdf0e10cSrcweir addEventListener( const com::sun::star::uno::Reference< 377*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& xListener ) 378*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 379*cdf0e10cSrcweir virtual void SAL_CALL 380*cdf0e10cSrcweir removeEventListener( const com::sun::star::uno::Reference< 381*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& aListener ) 382*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir private: 385*cdf0e10cSrcweir com::sun::star::uno::Reference< 386*cdf0e10cSrcweir com::sun::star::uno::XAggregation > m_xAggProxy; 387*cdf0e10cSrcweir com::sun::star::uno::Reference< 388*cdf0e10cSrcweir com::sun::star::io::XOutputStream > m_xWrappedStream; 389*cdf0e10cSrcweir com::sun::star::uno::Reference< 390*cdf0e10cSrcweir com::sun::star::lang::XComponent > m_xWrappedComponent; 391*cdf0e10cSrcweir com::sun::star::uno::Reference< 392*cdf0e10cSrcweir com::sun::star::lang::XTypeProvider > m_xWrappedTypeProv; 393*cdf0e10cSrcweir }; 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir //======================================================================= 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir typedef cppu::WeakImplHelper5< com::sun::star::io::XStream, 398*cdf0e10cSrcweir com::sun::star::io::XOutputStream, 399*cdf0e10cSrcweir com::sun::star::io::XTruncate, 400*cdf0e10cSrcweir com::sun::star::io::XInputStream, 401*cdf0e10cSrcweir com::sun::star::lang::XComponent > 402*cdf0e10cSrcweir StreamUNOBase; 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir class Stream : public StreamUNOBase, public ParentStorageHolder 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir public: 407*cdf0e10cSrcweir Stream( 408*cdf0e10cSrcweir const com::sun::star::uno::Reference< 409*cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory > & xSMgr, 410*cdf0e10cSrcweir const rtl::OUString & rUri, 411*cdf0e10cSrcweir const com::sun::star::uno::Reference< 412*cdf0e10cSrcweir com::sun::star::embed::XStorage > & xParentStorage, 413*cdf0e10cSrcweir const com::sun::star::uno::Reference< 414*cdf0e10cSrcweir com::sun::star::io::XStream > & xStreamToWrap ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir virtual ~Stream(); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir // XInterface 419*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 420*cdf0e10cSrcweir queryInterface( const com::sun::star::uno::Type& aType ) 421*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir // XTypeProvider (implemnented by base, but needs to be overridden for 424*cdf0e10cSrcweir // delegating to aggregate) 425*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL 426*cdf0e10cSrcweir getTypes() 427*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 428*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL 429*cdf0e10cSrcweir getImplementationId() 430*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir // XStream 433*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 434*cdf0e10cSrcweir com::sun::star::io::XInputStream > SAL_CALL 435*cdf0e10cSrcweir getInputStream() 436*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 439*cdf0e10cSrcweir com::sun::star::io::XOutputStream > SAL_CALL 440*cdf0e10cSrcweir getOutputStream() 441*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir // XOutputStream 444*cdf0e10cSrcweir virtual void SAL_CALL 445*cdf0e10cSrcweir writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData ) 446*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 447*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 448*cdf0e10cSrcweir com::sun::star::io::IOException, 449*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir virtual void SAL_CALL 452*cdf0e10cSrcweir flush() 453*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 454*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 455*cdf0e10cSrcweir com::sun::star::io::IOException, 456*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir virtual void SAL_CALL 459*cdf0e10cSrcweir closeOutput() 460*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 461*cdf0e10cSrcweir com::sun::star::io::IOException, 462*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir // XTruncate 465*cdf0e10cSrcweir virtual void SAL_CALL 466*cdf0e10cSrcweir truncate() 467*cdf0e10cSrcweir throw( com::sun::star::io::IOException, 468*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir // XInputStream 471*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 472*cdf0e10cSrcweir readBytes( com::sun::star::uno::Sequence< sal_Int8 >& aData, 473*cdf0e10cSrcweir sal_Int32 nBytesToRead ) 474*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 475*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 476*cdf0e10cSrcweir com::sun::star::io::IOException, 477*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 480*cdf0e10cSrcweir readSomeBytes( com::sun::star::uno::Sequence< sal_Int8 >& aData, 481*cdf0e10cSrcweir sal_Int32 nMaxBytesToRead ) 482*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 483*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 484*cdf0e10cSrcweir com::sun::star::io::IOException, 485*cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir virtual void SAL_CALL 488*cdf0e10cSrcweir skipBytes( sal_Int32 nBytesToSkip ) 489*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 490*cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 491*cdf0e10cSrcweir com::sun::star::io::IOException, 492*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 495*cdf0e10cSrcweir available() 496*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 497*cdf0e10cSrcweir com::sun::star::io::IOException, 498*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir virtual void SAL_CALL 501*cdf0e10cSrcweir closeInput() 502*cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 503*cdf0e10cSrcweir com::sun::star::io::IOException, 504*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir // XComponent 507*cdf0e10cSrcweir // Note: We need to intercept this one. 508*cdf0e10cSrcweir virtual void SAL_CALL 509*cdf0e10cSrcweir dispose() 510*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 511*cdf0e10cSrcweir virtual void SAL_CALL 512*cdf0e10cSrcweir addEventListener( const com::sun::star::uno::Reference< 513*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& xListener ) 514*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 515*cdf0e10cSrcweir virtual void SAL_CALL 516*cdf0e10cSrcweir removeEventListener( const com::sun::star::uno::Reference< 517*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& aListener ) 518*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException ); 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir private: 521*cdf0e10cSrcweir void commitChanges() 522*cdf0e10cSrcweir throw( com::sun::star::io::IOException ); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir com::sun::star::uno::Reference< 525*cdf0e10cSrcweir com::sun::star::uno::XAggregation > m_xAggProxy; 526*cdf0e10cSrcweir com::sun::star::uno::Reference< 527*cdf0e10cSrcweir com::sun::star::io::XStream > m_xWrappedStream; 528*cdf0e10cSrcweir com::sun::star::uno::Reference< 529*cdf0e10cSrcweir com::sun::star::io::XOutputStream > m_xWrappedOutputStream; 530*cdf0e10cSrcweir com::sun::star::uno::Reference< 531*cdf0e10cSrcweir com::sun::star::io::XTruncate > m_xWrappedTruncate; 532*cdf0e10cSrcweir com::sun::star::uno::Reference< 533*cdf0e10cSrcweir com::sun::star::io::XInputStream > m_xWrappedInputStream; 534*cdf0e10cSrcweir com::sun::star::uno::Reference< 535*cdf0e10cSrcweir com::sun::star::lang::XComponent > m_xWrappedComponent; 536*cdf0e10cSrcweir com::sun::star::uno::Reference< 537*cdf0e10cSrcweir com::sun::star::lang::XTypeProvider > m_xWrappedTypeProv; 538*cdf0e10cSrcweir }; 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir } // namespace tdoc_ucp 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir #endif /* !INCLUDED_TDOC_STGELEMS_HXX */ 543