diff options
-rw-r--r-- | include/sot/storage.hxx | 2 | ||||
-rw-r--r-- | oox/source/ole/vbaexport.cxx | 42 | ||||
-rw-r--r-- | sd/source/filter/eppt/eppt.cxx | 12 | ||||
-rw-r--r-- | sd/source/filter/eppt/eppt.hxx | 7 | ||||
-rw-r--r-- | sd/source/filter/ppt/pptin.cxx | 10 | ||||
-rw-r--r-- | sd/source/filter/ppt/pptin.hxx | 2 | ||||
-rw-r--r-- | sd/source/filter/sdpptwrp.cxx | 2 | ||||
-rw-r--r-- | sot/source/sdstor/storage.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/html/htmlreqifreader.cxx | 2 |
9 files changed, 44 insertions, 39 deletions
diff --git a/include/sot/storage.hxx b/include/sot/storage.hxx index 33d71d81a12e..65cde53d2a67 100644 --- a/include/sot/storage.hxx +++ b/include/sot/storage.hxx @@ -143,7 +143,7 @@ public: // create stream with connection to Storage, // more or less a Parent-Child relationship - SotStorageStream* OpenSotStream(const OUString & rEleName, + tools::SvRef<SotStorageStream> OpenSotStream(const OUString & rEleName, StreamMode = StreamMode::STD_READWRITE); SotStorage* OpenSotStorage(const OUString & rEleName, StreamMode = StreamMode::STD_READWRITE, diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx index 9b77a84bea70..4b3e1f092c3c 100644 --- a/oox/source/ole/vbaexport.cxx +++ b/oox/source/ole/vbaexport.cxx @@ -1001,10 +1001,10 @@ void getCorrectExportOrder(const css::uno::Reference<css::container::XNameContai #if VBA_USE_ORIGINAL_WM_STREAM || VBA_USE_ORIGINAL_DIR_STREAM \ || VBA_USE_ORIGINAL_PROJECT_STREAM || VBA_USE_ORIGINAL_VBA_PROJECT \ || VBA_USE_ORIGINAL_DIR_STREAM -void addFileStreamToSotStream(const OUString& rPath, SotStorageStream* pStream) +void addFileStreamToSotStream(const OUString& rPath, SotStorageStream& rStream) { SvFileStream aFileStream(rPath, StreamMode::READWRITE); - pStream->WriteStream(aFileStream); + rStream.WriteStream(aFileStream); } #endif @@ -1023,36 +1023,36 @@ void VbaExport::exportVBA(SotStorage* pRootStorage) // start here with the VBA export tools::SvRef<SotStorage> xVBAStream = pRootStorage->OpenSotStorage("VBA", StreamMode::READWRITE); - SotStorageStream* pDirStream = xVBAStream->OpenSotStream("dir", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pDirStream = xVBAStream->OpenSotStream("dir", StreamMode::READWRITE); - SotStorageStream* pVBAProjectStream = xVBAStream->OpenSotStream("_VBA_PROJECT", StreamMode::READWRITE); - SotStorageStream* pPROJECTStream = pRootStorage->OpenSotStream("PROJECT", StreamMode::READWRITE); - SotStorageStream* pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pVBAProjectStream = xVBAStream->OpenSotStream("_VBA_PROJECT", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pPROJECTStream = pRootStorage->OpenSotStream("PROJECT", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", StreamMode::READWRITE); #if VBA_USE_ORIGINAL_WM_STREAM OUString aProjectwmPath = "/home/moggi/Documents/testfiles/vba/PROJECTwm"; - addFileStreamToSotStream(aProjectwmPath, pPROJECTwmStream); + addFileStreamToSotStream(aProjectwmPath, *pPROJECTwmStream); #else exportPROJECTwmStream(*pPROJECTwmStream, aElementNames, aLibraryMap); #endif #if VBA_USE_ORIGINAL_DIR_STREAM OUString aDirPath = "/home/moggi/Documents/testfiles/vba/VBA/dir"; - addFileStreamToSotStream(aDirPath, pDirStream); + addFileStreamToSotStream(aDirPath, *pDirStream); #else exportDirStream(*pDirStream, xNameContainer, aLibraryMap, getProjectName()); #endif #if VBA_USE_ORIGINAL_PROJECT_STREAM OUString aProjectPath = "/home/moggi/Documents/testfiles/vba/PROJECT"; - addFileStreamToSotStream(aProjectPath, pPROJECTStream); + addFileStreamToSotStream(aProjectPath, *pPROJECTStream); #else exportPROJECTStream(*pPROJECTStream, xNameContainer, getProjectName(), aLibraryMap); #endif #if VBA_USE_ORIGINAL_VBA_PROJECT OUString a_VBA_ProjectPath = "/home/moggi/Documents/testfiles/vba/VBA/_VBA_PROJECT"; - addFileStreamToSotStream(a_VBA_ProjectPath, pVBAProjectStream); + addFileStreamToSotStream(a_VBA_ProjectPath, *pVBAProjectStream); #else exportVBAProjectStream(*pVBAProjectStream); #endif @@ -1063,16 +1063,16 @@ void VbaExport::exportVBA(SotStorage* pRootStorage) OUString aSheet2Path = "/home/moggi/Documents/testfiles/vba/VBA/Sheet2"; OUString aSheet3Path = "/home/moggi/Documents/testfiles/vba/VBA/Sheet3"; OUString aWorkbookPath = "/home/moggi/Documents/testfiles/vba/VBA/ThisWorkbook"; - SotStorageStream* pModule1Stream = xVBAStream->OpenSotStream("Module1", StreamMode::READWRITE); - SotStorageStream* pSheet1Stream = xVBAStream->OpenSotStream("Sheet1", StreamMode::READWRITE); - SotStorageStream* pSheet2Stream = xVBAStream->OpenSotStream("Sheet2", StreamMode::READWRITE); - SotStorageStream* pSheet3Stream = xVBAStream->OpenSotStream("Sheet3", StreamMode::READWRITE); - SotStorageStream* pWorkbookStream = xVBAStream->OpenSotStream("ThisWorkbook", StreamMode::READWRITE); - addFileStreamToSotStream(aModule1Path, pModule1Stream); - addFileStreamToSotStream(aSheet1Path, pSheet1Stream); - addFileStreamToSotStream(aSheet2Path, pSheet2Stream); - addFileStreamToSotStream(aSheet3Path, pSheet3Stream); - addFileStreamToSotStream(aWorkbookPath, pWorkbookStream); + tools::SvRef<SotStorageStream> pModule1Stream = xVBAStream->OpenSotStream("Module1", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pSheet1Stream = xVBAStream->OpenSotStream("Sheet1", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pSheet2Stream = xVBAStream->OpenSotStream("Sheet2", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pSheet3Stream = xVBAStream->OpenSotStream("Sheet3", StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pWorkbookStream = xVBAStream->OpenSotStream("ThisWorkbook", StreamMode::READWRITE); + addFileStreamToSotStream(aModule1Path, *pModule1Stream); + addFileStreamToSotStream(aSheet1Path, *pSheet1Stream); + addFileStreamToSotStream(aSheet2Path, *pSheet2Stream); + addFileStreamToSotStream(aSheet3Path, *pSheet3Stream); + addFileStreamToSotStream(aWorkbookPath, *pWorkbookStream); pModule1Stream->Commit(); pSheet1Stream->Commit(); @@ -1085,7 +1085,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage) for (sal_Int32 i = 0; i < n; ++i) { const OUString& rModuleName = aElementNames[aLibraryMap[i]]; - SotStorageStream* pModuleStream = xVBAStream->OpenSotStream(rModuleName, StreamMode::READWRITE); + tools::SvRef<SotStorageStream> pModuleStream = xVBAStream->OpenSotStream(rModuleName, StreamMode::READWRITE); css::uno::Any aCode = xNameContainer->getByName(rModuleName); css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName); OUString aSourceCode; diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index 5c1f9da7d7af..237fd2276f5d 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -106,12 +106,12 @@ void PPTWriter::exportPPTPre( const std::vector< css::beans::PropertyValue >& rM if ( !ImplCreateCurrentUserStream() ) return; - mpStrm.reset( mrStg->OpenSotStream( "PowerPoint Document" ) ); + mpStrm = mrStg->OpenSotStream( "PowerPoint Document" ); if ( !mpStrm ) return; if ( !mpPicStrm ) - mpPicStrm.reset( mrStg->OpenSotStream( "Pictures" ) ); + mpPicStrm = mrStg->OpenSotStream( "Pictures" ); auto aIter = std::find_if(rMediaData.begin(), rMediaData.end(), [](const css::beans::PropertyValue& rProp) { return rProp.Name == "BaseURI"; }); @@ -448,9 +448,9 @@ PPTWriter::~PPTWriter() { mpExEmbed.reset(); mpPptEscherEx.reset(); - mpCurUserStrm.reset(); - mpPicStrm.reset(); - mpStrm.reset(); + mpCurUserStrm.clear(); + mpPicStrm.clear(); + mpStrm.clear(); maStyleSheetList.clear(); maExOleObj.clear(); if ( mbStatusIndicator ) @@ -459,7 +459,7 @@ PPTWriter::~PPTWriter() bool PPTWriter::ImplCreateCurrentUserStream() { - mpCurUserStrm.reset( mrStg->OpenSotStream( "Current User" ) ); + mpCurUserStrm = mrStg->OpenSotStream( "Current User" ); if ( !mpCurUserStrm ) return false; char pUserName[] = "Current User"; diff --git a/sd/source/filter/eppt/eppt.hxx b/sd/source/filter/eppt/eppt.hxx index 04255e711d99..bed711891345 100644 --- a/sd/source/filter/eppt/eppt.hxx +++ b/sd/source/filter/eppt/eppt.hxx @@ -23,6 +23,7 @@ #include <vector> #include "escherex.hxx" #include <sal/types.h> +#include <sot/storage.hxx> #include "pptexsoundcollection.hxx" #include "text.hxx" @@ -127,9 +128,9 @@ class PPTWriter final : public PPTWriterBase, public PPTExBulletProvider sal_uInt32 mnTextSize; tools::SvRef<SotStorage> mrStg; - std::unique_ptr<SvStream> mpCurUserStrm; - std::unique_ptr<SvStream> mpStrm; - std::unique_ptr<SvStream> mpPicStrm; + tools::SvRef<SotStorageStream> mpCurUserStrm; + tools::SvRef<SotStorageStream> mpStrm; + tools::SvRef<SotStorageStream> mpPicStrm; std::unique_ptr<PptEscherEx> mpPptEscherEx; std::vector<std::unique_ptr<PPTExOleObjEntry>> maExOleObj; diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index 254da0754bba..f9831e0969e7 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -125,8 +125,8 @@ SdPPTImport::SdPPTImport( SdDrawDocument* pDocument, SvStream& rDocStream, SotSt pSummaryInformation.reset(); #endif - if (auto pCurrentUserStream - = std::unique_ptr<SvStream>(rStorage.OpenSotStream("Current User", StreamMode::STD_READ))) + tools::SvRef<SotStorageStream> pCurrentUserStream(rStorage.OpenSotStream("Current User", StreamMode::STD_READ)); + if (pCurrentUserStream) { ReadPptCurrentUserAtom(*pCurrentUserStream, maParam.aCurrentUserAtom); } @@ -182,7 +182,8 @@ ImplSdPPTImport::ImplSdPPTImport( SdDrawDocument* pDocument, SotStorage& rStorag { sal_uLong nOldPos = rStCtrl.Tell(); - pStData = rStorage_.OpenSotStream( "Pictures", StreamMode::STD_READ ); + mxPicturesStream = rStorage_.OpenSotStream( "Pictures", StreamMode::STD_READ ); + pStData = mxPicturesStream.get(); rStCtrl.Seek( maDocHd.GetRecBegFilePos() + 8 ); sal_uLong nDocLen = maDocHd.GetRecEndFilePos(); @@ -218,7 +219,8 @@ ImplSdPPTImport::ImplSdPPTImport( SdDrawDocument* pDocument, SotStorage& rStorag // Dtor ImplSdPPTImport::~ImplSdPPTImport() { - delete pStData; + pStData = nullptr; + mxPicturesStream.clear(); } // Import diff --git a/sd/source/filter/ppt/pptin.hxx b/sd/source/filter/ppt/pptin.hxx index 02c22e652350..f7bf91472e10 100644 --- a/sd/source/filter/ppt/pptin.hxx +++ b/sd/source/filter/ppt/pptin.hxx @@ -22,6 +22,7 @@ #include <filter/msfilter/svdfppt.hxx> #include <diadef.h> +#include <sot/storage.hxx> #include <svx/svdtypes.hxx> #include <memory> @@ -43,6 +44,7 @@ typedef ::std::map < SdrObject*, Ppt97AnimationPtr > tAnimationMap; class ImplSdPPTImport : public SdrPowerPointImport { + tools::SvRef<SotStorageStream> mxPicturesStream; SfxMedium& mrMed; SotStorage& mrStorage; DffRecordHeader maDocHd; diff --git a/sd/source/filter/sdpptwrp.cxx b/sd/source/filter/sdpptwrp.cxx index bf76d1c6df49..90f851e69fa4 100644 --- a/sd/source/filter/sdpptwrp.cxx +++ b/sd/source/filter/sdpptwrp.cxx @@ -186,7 +186,7 @@ bool SdPPTFilter::Import() // Document is DRM encrypted pStorage = lcl_DRMDecrypt(mrMedium, pStorage, aDecryptedStorageStrm); } - std::unique_ptr<SvStream> pDocStream(pStorage->OpenSotStream( "PowerPoint Document" , StreamMode::STD_READ )); + tools::SvRef<SotStorageStream> pDocStream(pStorage->OpenSotStream( "PowerPoint Document" , StreamMode::STD_READ )); if( pDocStream ) { pDocStream->SetVersion( pStorage->GetVersion() ); diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index dd038048986e..60bcb6dc8bd6 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -530,10 +530,10 @@ bool SotStorage::Commit() return ERRCODE_NONE == GetError(); } -SotStorageStream * SotStorage::OpenSotStream( const OUString & rEleName, +tools::SvRef<SotStorageStream> SotStorage::OpenSotStream( const OUString & rEleName, StreamMode nMode ) { - SotStorageStream * pStm = nullptr; + tools::SvRef<SotStorageStream> pStm; if( m_pOwnStg ) { // enable full Ole patches, diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx index 36d8c6676b5d..09ba240c13ff 100644 --- a/sw/source/filter/html/htmlreqifreader.cxx +++ b/sw/source/filter/html/htmlreqifreader.cxx @@ -69,7 +69,7 @@ OString ExtractOLEClassName(const tools::SvRef<SotStorage>& xStorage) { OString aRet; - SotStorageStream* pCompObj = xStorage->OpenSotStream("\1CompObj"); + tools::SvRef<SotStorageStream> pCompObj = xStorage->OpenSotStream("\1CompObj"); if (!pCompObj) return aRet; |