diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-06-01 13:26:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-06-03 10:41:59 +0200 |
commit | e83b5f6a015269ed7e5407a8440c0fc99fcfa397 (patch) | |
tree | 782a18ed3665d88ea7e51e56174fbd5ea95a3e85 /filter | |
parent | f5e1314ffa564077c27fb9c954c792b498bcae12 (diff) |
no need to allocate these on the heap
Change-Id: Ic4b16e776a731e5e9bea61e99acb7257c5220322
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116585
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/icgm/cgm.cxx | 12 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 8 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 8 | ||||
-rw-r--r-- | filter/source/msfilter/svdfppt.cxx | 6 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 46 | ||||
-rw-r--r-- | filter/source/xsltfilter/LibXSLTTransformer.cxx | 3 | ||||
-rw-r--r-- | filter/source/xsltfilter/OleHandler.cxx | 5 |
7 files changed, 45 insertions, 43 deletions
diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx index 02f1d0219f02..1cf7c7ca0b36 100644 --- a/filter/source/graphicfilter/icgm/cgm.cxx +++ b/filter/source/graphicfilter/icgm/cgm.cxx @@ -693,8 +693,8 @@ ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, css::u { try { - std::unique_ptr<CGM> pCGM(new CGM(rXModel)); - if (pCGM->IsValid()) + CGM aCGM(rXModel); + if (aCGM.IsValid()) { rIn.SetEndian(SvStreamEndian::BIG); sal_uInt64 const nInSize = rIn.remainingSize(); @@ -706,7 +706,7 @@ ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, css::u if ( bProgressBar ) aXStatInd->start( "CGM Import" , nInSize ); - while (pCGM->IsValid() && (rIn.Tell() < nInSize) && !pCGM->IsFinished()) + while (aCGM.IsValid() && (rIn.Tell() < nInSize) && !aCGM.IsFinished()) { if ( bProgressBar ) { @@ -718,12 +718,12 @@ ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, css::u } } - if (!pCGM->Write(rIn)) + if (!aCGM.Write(rIn)) break; } - if ( pCGM->IsValid() ) + if ( aCGM.IsValid() ) { - nStatus = pCGM->GetBackGroundColor() | 0xff000000; + nStatus = aCGM.GetBackGroundColor() | 0xff000000; } if ( bProgressBar ) aXStatInd->end(); diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 06ac5c24f841..81a792a00baf 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -1345,8 +1345,8 @@ bool EscherPropertyContainer::CreateOLEGraphicProperties(const uno::Reference<dr if (pGraphic) { Graphic aGraphic(*pGraphic); - std::unique_ptr<GraphicObject> xGraphicObject(new GraphicObject(aGraphic)); - bRetValue = CreateGraphicProperties(rXShape, *xGraphicObject); + GraphicObject aGraphicObject(aGraphic); + bRetValue = CreateGraphicProperties(rXShape, aGraphicObject); } } } @@ -1391,8 +1391,8 @@ bool EscherPropertyContainer::CreateMediaGraphicProperties(const uno::Reference< SdrObject* pSdrObject(GetSdrObjectFromXShape(rXShape)); // SJ: leaving unoapi, because currently there is if (auto pSdrMediaObj = dynamic_cast<const SdrMediaObj*>(pSdrObject)) // no access to the native graphic object { - std::unique_ptr<GraphicObject> xGraphicObject(new GraphicObject(pSdrMediaObj->getSnapshot())); - bRetValue = CreateGraphicProperties(rXShape, *xGraphicObject); + GraphicObject aGraphicObject(pSdrMediaObj->getSnapshot()); + bRetValue = CreateGraphicProperties(rXShape, aGraphicObject); } } return bRetValue; diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index cdd0365bc508..f7176c186a77 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -7065,16 +7065,16 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo { //TODO/MBA: check if (and when) storage and stream will be destroyed! std::shared_ptr<const SfxFilter> pFilter; - std::unique_ptr<SvMemoryStream> xMemStream (new SvMemoryStream); + SvMemoryStream aMemStream; if ( pName ) { // TODO/LATER: perhaps we need to retrieve VisArea and Metafile from the storage also - SvxMSDffManager::ExtractOwnStream(rSrcStg, *xMemStream); + SvxMSDffManager::ExtractOwnStream(rSrcStg, aMemStream); } else { SfxFilterMatcher aMatch( sStarName ); - tools::SvRef<SotStorage> xStorage = new SotStorage( false, *xMemStream ); + tools::SvRef<SotStorage> xStorage = new SotStorage( false, aMemStream ); rSrcStg.CopyTo( xStorage.get() ); xStorage->Commit(); xStorage.clear(); @@ -7107,7 +7107,7 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo uno::Sequence<beans::PropertyValue> aMedium(aFilterName.isEmpty() ? 3 : 4); aMedium[0].Name = "InputStream"; - uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( *xMemStream ); + uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( aMemStream ); aMedium[0].Value <<= xStream; aMedium[1].Name = "URL"; aMedium[1].Value <<= OUString( "private:stream" ); diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index c1bab48ffac8..bcf243b3f920 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -2121,7 +2121,7 @@ void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOpt DffRecordHeader* pExEmbed = nullptr; pHd->SeekToBegOfRecord( rStCtrl ); - std::unique_ptr<DffRecordManager> pExObjListManager(new DffRecordManager( rStCtrl )); + DffRecordManager aExObjListManager( rStCtrl ); sal_uInt16 i, nRecType(PPT_PST_ExEmbed); for ( i = 0; i < 2; i++ ) @@ -2131,8 +2131,8 @@ void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOpt case 0 : nRecType = PPT_PST_ExEmbed; break; case 1 : nRecType = PPT_PST_ExControl; break; } - for ( pExEmbed = pExObjListManager->GetRecordHeader( nRecType ); - pExEmbed; pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) ) + for ( pExEmbed = aExObjListManager.GetRecordHeader( nRecType ); + pExEmbed; pExEmbed = aExObjListManager.GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) ) { pExEmbed->SeekToContent( rStCtrl ); diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index abc33c5536de..2932d2e52ac9 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -834,8 +834,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& aContext.UseReferenceXObject = mbUseReferenceXObject; // all context data set, time to create the printing device - std::unique_ptr<vcl::PDFWriter> pPDFWriter(new vcl::PDFWriter( aContext, xEnc )); - OutputDevice* pOut = pPDFWriter->GetReferenceDevice(); + vcl::PDFWriter aPDFWriter( aContext, xEnc ); + OutputDevice* pOut = aPDFWriter.GetReferenceDevice(); DBG_ASSERT( pOut, "PDFExport::Export: no reference device" ); xDevice->SetOutputDevice(pOut); @@ -845,7 +845,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& // export stream // get mimetype OUString aSrcMimetype = getMimetypeForDocument( mxContext, mxSrcDoc ); - pPDFWriter->AddStream( aSrcMimetype, + aPDFWriter.AddStream( aSrcMimetype, new PDFExportStreamDoc( mxSrcDoc, aPreparedPermissionPassword ) ); } @@ -853,19 +853,19 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& if ( pOut ) { DBG_ASSERT( pOut->GetExtOutDevData() == nullptr, "PDFExport: ExtOutDevData already set!!!" ); - std::unique_ptr<vcl::PDFExtOutDevData> pPDFExtOutDevData(new vcl::PDFExtOutDevData( *pOut )); - pOut->SetExtOutDevData( pPDFExtOutDevData.get() ); - pPDFExtOutDevData->SetIsExportNotes( mbExportNotes ); - pPDFExtOutDevData->SetIsExportTaggedPDF( mbUseTaggedPDF ); - pPDFExtOutDevData->SetIsExportTransitionEffects( mbUseTransitionEffects ); - pPDFExtOutDevData->SetIsExportFormFields( mbExportFormFields ); - pPDFExtOutDevData->SetIsExportBookmarks( mbExportBookmarks ); - pPDFExtOutDevData->SetIsExportHiddenSlides( mbExportHiddenSlides ); - pPDFExtOutDevData->SetIsSinglePageSheets( mbSinglePageSheets ); - pPDFExtOutDevData->SetIsLosslessCompression( mbUseLosslessCompression ); - pPDFExtOutDevData->SetCompressionQuality( mnQuality ); - pPDFExtOutDevData->SetIsReduceImageResolution( mbReduceImageResolution ); - pPDFExtOutDevData->SetIsExportNamedDestinations( mbExportBmkToDest ); + vcl::PDFExtOutDevData aPDFExtOutDevData( *pOut ); + pOut->SetExtOutDevData( &aPDFExtOutDevData ); + aPDFExtOutDevData.SetIsExportNotes( mbExportNotes ); + aPDFExtOutDevData.SetIsExportTaggedPDF( mbUseTaggedPDF ); + aPDFExtOutDevData.SetIsExportTransitionEffects( mbUseTransitionEffects ); + aPDFExtOutDevData.SetIsExportFormFields( mbExportFormFields ); + aPDFExtOutDevData.SetIsExportBookmarks( mbExportBookmarks ); + aPDFExtOutDevData.SetIsExportHiddenSlides( mbExportHiddenSlides ); + aPDFExtOutDevData.SetIsSinglePageSheets( mbSinglePageSheets ); + aPDFExtOutDevData.SetIsLosslessCompression( mbUseLosslessCompression ); + aPDFExtOutDevData.SetCompressionQuality( mnQuality ); + aPDFExtOutDevData.SetIsReduceImageResolution( mbReduceImageResolution ); + aPDFExtOutDevData.SetIsExportNamedDestinations( mbExportBmkToDest ); Sequence< PropertyValue > aRenderOptions( 8 ); aRenderOptions[ 0 ].Name = "RenderDevice"; @@ -952,26 +952,26 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& bRet = nPageCount > 0; if ( bRet && bExportPages ) - bRet = ExportSelection( *pPDFWriter, xRenderable, aSelection, aRangeEnum, aRenderOptions, nPageCount ); + bRet = ExportSelection( aPDFWriter, xRenderable, aSelection, aRangeEnum, aRenderOptions, nPageCount ); if ( bRet && bExportNotesPages ) { rExportNotesValue <<= true; - bRet = ExportSelection( *pPDFWriter, xRenderable, aSelection, aRangeEnum, aRenderOptions, nPageCount ); + bRet = ExportSelection( aPDFWriter, xRenderable, aSelection, aRangeEnum, aRenderOptions, nPageCount ); } if ( mxStatusIndicator.is() ) mxStatusIndicator->end(); // if during the export the doc locale was set copy it to PDF writer - const css::lang::Locale& rLoc( pPDFExtOutDevData->GetDocumentLocale() ); + const css::lang::Locale& rLoc( aPDFExtOutDevData.GetDocumentLocale() ); if( !rLoc.Language.isEmpty() ) - pPDFWriter->SetDocumentLocale( rLoc ); + aPDFWriter.SetDocumentLocale( rLoc ); if( bRet ) { - pPDFExtOutDevData->PlayGlobalActions( *pPDFWriter ); - bRet = pPDFWriter->Emit(); - aErrors = pPDFWriter->GetErrors(); + aPDFExtOutDevData.PlayGlobalActions( aPDFWriter ); + bRet = aPDFWriter.Emit(); + aErrors = aPDFWriter.GetErrors(); } pOut->SetExtOutDevData( nullptr ); if( bReChangeToNormalView ) diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx index 027e338a0677..e11777a59e8d 100644 --- a/filter/source/xsltfilter/LibXSLTTransformer.cxx +++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx @@ -11,6 +11,7 @@ #include <algorithm> #include <cstring> #include <map> +#include <optional> #include <string_view> #include <utility> #include <vector> @@ -288,7 +289,7 @@ namespace XSLT xsltSetGenericDebugFunc(stderr, NULL); xsltDebugDumpExtensions(NULL); #endif - std::unique_ptr<OleHandler> oh(new OleHandler(m_transformer->getComponentContext())); + std::optional<OleHandler> oh(std::in_place, m_transformer->getComponentContext()); if (styleSheet) { xsltTransformContextPtr tcontext = xsltNewTransformContext( diff --git a/filter/source/xsltfilter/OleHandler.cxx b/filter/source/xsltfilter/OleHandler.cxx index 49a8991cc9e8..44b698aaa5a1 100644 --- a/filter/source/xsltfilter/OleHandler.cxx +++ b/filter/source/xsltfilter/OleHandler.cxx @@ -27,6 +27,7 @@ #include "OleHandler.hxx" #include <memory> +#include <optional> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -119,7 +120,7 @@ namespace XSLT } // Decompress the bytes - std::unique_ptr< ::ZipUtils::Inflater> decompresser(new ::ZipUtils::Inflater(false)); + std::optional< ::ZipUtils::Inflater> decompresser(std::in_place, false); decompresser->setInput(content); Sequence<sal_Int8> result(oleLength); decompresser->doInflateSegment(result, 0, oleLength); @@ -187,7 +188,7 @@ namespace XSLT // Compress the bytes Sequence<sal_Int8> output(oledata.getLength()); - std::unique_ptr< ::ZipUtils::Deflater> compresser(new ::ZipUtils::Deflater(sal_Int32(3), false)); + std::optional< ::ZipUtils::Deflater> compresser(std::in_place, sal_Int32(3), false); compresser->setInputSegment(oledata); compresser->finish(); int compressedDataLength = compresser->doDeflateSegment(output, oledata.getLength()); |