[Libreoffice-commits] core.git: include/vcl sd/source vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 22 13:48:31 UTC 2021


 include/vcl/graphicfilter.hxx        |   13 +++----------
 sd/source/filter/grf/sdgrffilter.cxx |    4 ++--
 sd/source/ui/func/fuinsert.cxx       |    2 +-
 vcl/source/filter/graphicfilter.cxx  |    8 ++++----
 4 files changed, 10 insertions(+), 17 deletions(-)

New commits:
commit 8ea426bfa978d338683bf4c715d358187a527ccd
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 22 11:49:00 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 22 15:47:48 2021 +0200

    no need to allocate the error separately in GraphicFilter
    
    Change-Id: I26c43cb72580d9cc384b3c4b70e43f47d3db0198
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119367
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index d153c9d97648..833007e28088 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -256,14 +256,6 @@ public:
     static OUString GetImportFormatShortName( GraphicFileFormat nFormat );
 };
 
-/** Information about errors during the GraphicFilter operation. */
-struct FilterErrorEx
-{
-    ErrCode   nStreamError;
-
-    FilterErrorEx() : nStreamError( ERRCODE_NONE ) {}
-};
-
 /** Class to import and export graphic formats. */
 class VCL_DLLPUBLIC GraphicFilter
 {
@@ -341,7 +333,7 @@ public:
     // Setting sizeLimit limits how much will be read from the stream.
     Graphic ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 sizeLimit = 0, const Size* pSizeHint = nullptr);
 
-    const FilterErrorEx&    GetLastError() const { return *pErrorEx;}
+    const ErrCode&          GetLastError() const { return *mxErrorEx;}
     void                    ResetLastError();
 
     Link<ConvertData&,bool> GetFilterCallback() const;
@@ -393,7 +385,8 @@ private:
 
                     DECL_LINK( FilterCallback, ConvertData&, bool );
 
-    std::unique_ptr<FilterErrorEx> pErrorEx;
+    /** Information about errors during the GraphicFilter operation. */
+    std::optional<ErrCode> mxErrorEx;
     bool                bUseConfig;
 };
 
diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx
index 103cc37ca606..ebceaee3b10a 100644
--- a/sd/source/filter/grf/sdgrffilter.cxx
+++ b/sd/source/filter/grf/sdgrffilter.cxx
@@ -149,7 +149,7 @@ bool SdGRFFilter::Import()
     ErrCode         nReturn = pIStm ? rGraphicFilter.ImportGraphic( aGraphic, aFileName, *pIStm, nFilter ) : ErrCode(1);
 
     if( nReturn )
-        HandleGraphicFilterError( nReturn, rGraphicFilter.GetLastError().nStreamError );
+        HandleGraphicFilterError( nReturn, rGraphicFilter.GetLastError() );
     else
     {
         if( mrDocument.GetPageCount() == 0 )
@@ -292,7 +292,7 @@ bool SdGRFFilter::Export()
                     if ( !bRet && xInteractionHandler.is() )
                         SdGRFFilter::HandleGraphicFilterError(
                             static_cast< SdGRFFilter_ImplInteractionHdl* >( xInteractionHandler.get() )->GetErrorCode(),
-                                            rGraphicFilter.GetLastError().nStreamError );
+                                            rGraphicFilter.GetLastError() );
                 }
             }
         }
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 01434b40f141..07d1417e0161 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -190,7 +190,7 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
     }
     else
     {
-        SdGRFFilter::HandleGraphicFilterError( nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
+        SdGRFFilter::HandleGraphicFilterError( nError, GraphicFilter::GetGraphicFilter().GetLastError() );
     }
 }
 
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 9ffd3601d714..1be4c82e7c4e 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -335,7 +335,7 @@ GraphicFilter::~GraphicFilter()
             delete pConfig;
     }
 
-    pErrorEx.reset();
+    mxErrorEx.reset();
 }
 
 void GraphicFilter::ImplInit()
@@ -358,12 +358,12 @@ void GraphicFilter::ImplInit()
         osl::FileBase::getSystemPathFromFileURL(url, aFilterPath);
     }
 
-    pErrorEx.reset( new FilterErrorEx );
+    mxErrorEx = ERRCODE_NONE;
 }
 
 ErrCode GraphicFilter::ImplSetError( ErrCode nError, const SvStream* pStm )
 {
-    pErrorEx->nStreamError = pStm ? pStm->GetError() : ERRCODE_NONE;
+    mxErrorEx = pStm ? pStm->GetError() : ERRCODE_NONE;
     return nError;
 }
 
@@ -1850,7 +1850,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
 
 void GraphicFilter::ResetLastError()
 {
-    pErrorEx->nStreamError = ERRCODE_NONE;
+    mxErrorEx = ERRCODE_NONE;
 }
 
 Link<ConvertData&,bool> GraphicFilter::GetFilterCallback() const


More information about the Libreoffice-commits mailing list