[Libreoffice-commits] core.git: cui/source filter/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 3 08:42:43 UTC 2021


 cui/source/dialogs/hltpbase.cxx                 |   10 ++---
 cui/source/options/optupdt.cxx                  |    2 -
 cui/source/tabpages/tpline.cxx                  |   26 ++++++-------
 filter/source/graphicfilter/icgm/cgm.cxx        |   12 +++---
 filter/source/msfilter/escherex.cxx             |    8 ++--
 filter/source/msfilter/msdffimp.cxx             |    8 ++--
 filter/source/msfilter/svdfppt.cxx              |    6 +--
 filter/source/pdf/pdfexport.cxx                 |   46 ++++++++++++------------
 filter/source/xsltfilter/LibXSLTTransformer.cxx |    3 +
 filter/source/xsltfilter/OleHandler.cxx         |    5 +-
 10 files changed, 64 insertions(+), 62 deletions(-)

New commits:
commit e83b5f6a015269ed7e5407a8440c0fc99fcfa397
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jun 1 13:26:04 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jun 3 10:41:59 2021 +0200

    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 at collabora.co.uk>

diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index b636c94ecb0f..6d752f10bf82 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -143,15 +143,15 @@ void SvxHyperlinkTabPageBase::InitStdControls ()
         SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : nullptr;
         if ( pFrame )
         {
-            std::unique_ptr<TargetList> pList(new TargetList);
-            SfxFrame::GetDefaultTargetList(*pList);
-            if( !pList->empty() )
+            TargetList aList;
+            SfxFrame::GetDefaultTargetList(aList);
+            if( !aList.empty() )
             {
-                size_t nCount = pList->size();
+                size_t nCount = aList.size();
                 size_t i;
                 for ( i = 0; i < nCount; i++ )
                 {
-                    mxCbbFrame->append_text( pList->at( i ) );
+                    mxCbbFrame->append_text( aList.at( i ) );
                 }
             }
         }
diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index d89fdec0aa4f..c9ad541e8005 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -126,7 +126,7 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
         }
 
         LanguageType eUILang = Application::GetSettings().GetUILanguageTag().getLanguageType();
-        std::unique_ptr<SvNumberFormatter> pNumberFormatter(new SvNumberFormatter( ::comphelper::getProcessComponentContext(), eUILang ));
+        std::optional<SvNumberFormatter> pNumberFormatter( std::in_place, ::comphelper::getProcessComponentContext(), eUILang );
         const Color*      pColor = nullptr;
         const Date& rNullDate = pNumberFormatter->GetNullDate();
         sal_uInt32  nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::DATE, eUILang );
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index e8b382fe9876..609946a0287d 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -824,9 +824,9 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
         pPage->SetSize(Size(1000,1000));
         pModel->InsertPage( pPage.get(), 0 );
         {
-        std::unique_ptr<SdrView> pView(new SdrView( *pModel, pVDev ));
-        pView->hideMarkHandles();
-        pView->ShowSdrPage(pPage.get());
+        SdrView aView( *pModel, pVDev );
+        aView.hideMarkHandles();
+        aView.ShowSdrPage(pPage.get());
         size_t nSymTmp = static_cast<size_t>(nSymType);
         if(m_pSymbolList)
         {
@@ -861,8 +861,8 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
                     pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100));
                     pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100));
 
-                    pView->MarkAll();
-                    GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
+                    aView.MarkAll();
+                    GDIMetaFile aMeta(aView.GetMarkedObjMetaFile());
 
                     m_aSymbolGraphic=Graphic(aMeta);
                     m_aSymbolSize=pObj->GetSnapRect().GetSize();
@@ -872,7 +872,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
                     bEnable=true;
                     bIgnoreGraphic=true;
 
-                    pView->UnmarkAll();
+                    aView.UnmarkAll();
                     pInvisibleSquare=pPage->RemoveObject(1);
                     SdrObject::Free( pInvisibleSquare);
                     pObj=pPage->RemoveObject(0);
@@ -1454,9 +1454,9 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void)
     pModel->InsertPage( pPage.get(), 0 );
     {
         // 3D View
-        std::unique_ptr<SdrView> pView(new SdrView( *pModel, pVDev ));
-        pView->hideMarkHandles();
-        pView->ShowSdrPage(pPage.get());
+        SdrView aView( *pModel, pVDev );
+        aView.hideMarkHandles();
+        aView.ShowSdrPage(pPage.get());
 
         // Generate invisible square to give all symbols a
         // bitmap size, which is independent from specific glyph
@@ -1487,10 +1487,10 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void)
             {
                 pObj->SetMergedItemSet(m_rOutAttrs);
             }
-            pView->MarkAll();
-            BitmapEx aBitmapEx(pView->GetMarkedObjBitmapEx());
-            GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
-            pView->UnmarkAll();
+            aView.MarkAll();
+            BitmapEx aBitmapEx(aView.GetMarkedObjBitmapEx());
+            GDIMetaFile aMeta(aView.GetMarkedObjMetaFile());
+            aView.UnmarkAll();
             pObj=pPage->RemoveObject(1);
             SdrObject::Free(pObj);
 
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());


More information about the Libreoffice-commits mailing list