[Libreoffice-commits] core.git: sc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Thu Feb 9 05:53:45 UTC 2017


 sc/source/filter/html/htmlimp.cxx |   13 +++----------
 sc/source/filter/inc/eeimport.hxx |    3 ++-
 sc/source/filter/inc/htmlimp.hxx  |    1 -
 sc/source/filter/inc/rtfimp.hxx   |    1 -
 sc/source/filter/rtf/eeimpars.cxx |    3 +--
 sc/source/filter/rtf/rtfimp.cxx   |    9 +--------
 6 files changed, 7 insertions(+), 23 deletions(-)

New commits:
commit 14c8ed764c5a4dc64f10389a83d396f055af145b
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Wed Feb 8 14:23:14 2017 +0100

    use std::unique_ptr and reorder members
    
    use unique_ptr for ScEEParser.
    
    mpParser needs mpEngine to initialise.
    declare, construct and destruct in right order.
    make use of virtual dtor of mpParser.
    
    let dtor default for ScRTFImport and ScHTMLImport (they have
    no own members).
    
    Change-Id: Ic6f830df121d687084ea394e68a37797e53f7108
    Reviewed-on: https://gerrit.libreoffice.org/34044
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index ecf3c1a..4c2b9c7 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -93,16 +93,9 @@ ScHTMLImport::ScHTMLImport( ScDocument* pDocP, const OUString& rBaseURL, const S
             SvxPaperInfo::GetPaperSize( PAPER_A4 ), MapMode( MapUnit::MapTwip ) );
     }
     if( bCalcWidthHeight )
-        mpParser = new ScHTMLLayoutParser( mpEngine.get(), rBaseURL, aPageSize, pDocP );
+        mpParser.reset( new ScHTMLLayoutParser( mpEngine.get(), rBaseURL, aPageSize, pDocP ));
     else
-        mpParser = new ScHTMLQueryParser( mpEngine.get(), pDocP );
-}
-
-ScHTMLImport::~ScHTMLImport()
-{
-    // Ordering is important, otherwise we get an error in some other Dtor!
-    // OK, as ScEEImport is the Base Class
-    delete static_cast<ScHTMLParser*>(mpParser);        // before EditEngine!
+        mpParser.reset( new ScHTMLQueryParser( mpEngine.get(), pDocP ));
 }
 
 void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const OUString& rName, const ScRange& rRange )
@@ -120,7 +113,7 @@ void ScHTMLImport::WriteToDocument(
 {
     ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor, pFormatter, bConvertDate );
 
-    const ScHTMLParser* pParser = static_cast<ScHTMLParser*>(mpParser);
+    const ScHTMLParser* pParser = static_cast<ScHTMLParser*>(mpParser.get());
     const ScHTMLTable* pGlobTable = pParser->GetGlobalTable();
     if( !pGlobTable )
         return;
diff --git a/sc/source/filter/inc/eeimport.hxx b/sc/source/filter/inc/eeimport.hxx
index 88995c3..55a20cc 100644
--- a/sc/source/filter/inc/eeimport.hxx
+++ b/sc/source/filter/inc/eeimport.hxx
@@ -39,9 +39,10 @@ class ScEEImport : public ScEEAbsImport
 protected:
     ScRange             maRange;
     ScDocument*         mpDoc;
-    ScEEParser*         mpParser;
     std::unique_ptr<ScTabEditEngine>
                         mpEngine;
+    std::unique_ptr<ScEEParser>        // needs mpEngine
+                        mpParser;      // must reset before mpEngine resets
     RowHeightMap        maRowHeights;
 
     bool                GraphicSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
diff --git a/sc/source/filter/inc/htmlimp.hxx b/sc/source/filter/inc/htmlimp.hxx
index ff36053..c27c36e6 100644
--- a/sc/source/filter/inc/htmlimp.hxx
+++ b/sc/source/filter/inc/htmlimp.hxx
@@ -30,7 +30,6 @@ private:
 
 public:
     ScHTMLImport( ScDocument* pDoc, const OUString& rBaseURL, const ScRange& rRange, bool bCalcWidthHeight );
-    virtual ~ScHTMLImport() override;
 
     virtual void        WriteToDocument( bool bSizeColsRows = false, double nOutputFactor = 1.0,
                                          SvNumberFormatter* pFormatter = nullptr, bool bConvertDate = true ) override;
diff --git a/sc/source/filter/inc/rtfimp.hxx b/sc/source/filter/inc/rtfimp.hxx
index 4422dbf..f248f99 100644
--- a/sc/source/filter/inc/rtfimp.hxx
+++ b/sc/source/filter/inc/rtfimp.hxx
@@ -26,7 +26,6 @@ class ScRTFImport : public ScEEImport
 {
 public:
                         ScRTFImport( ScDocument* pDoc, const ScRange& rRange );
-                        virtual ~ScRTFImport() override;
 };
 
 #endif
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index ad68893..4b0ad2b 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -60,8 +60,7 @@
 
 ScEEImport::ScEEImport( ScDocument* pDocP, const ScRange& rRange ) :
     maRange( rRange ),
-    mpDoc( pDocP ),
-    mpParser( nullptr )
+    mpDoc( pDocP )
 {
     const ScPatternAttr* pPattern = mpDoc->GetPattern(
         maRange.aStart.Col(), maRange.aStart.Row(), maRange.aStart.Tab() );
diff --git a/sc/source/filter/rtf/rtfimp.cxx b/sc/source/filter/rtf/rtfimp.cxx
index 8a3cd17..000e3ab 100644
--- a/sc/source/filter/rtf/rtfimp.cxx
+++ b/sc/source/filter/rtf/rtfimp.cxx
@@ -43,14 +43,7 @@ ScEEAbsImport *ScFormatFilterPluginImpl::CreateRTFImport( ScDocument* pDoc, cons
 ScRTFImport::ScRTFImport( ScDocument* pDocP, const ScRange& rRange ) :
     ScEEImport( pDocP, rRange )
 {
-    mpParser = new ScRTFParser( mpEngine.get() );
-}
-
-ScRTFImport::~ScRTFImport()
-{
-    // ordering is important; get error in some other Dtor otherwise!
-    // Is correct, as ScEEImport is Base Class
-    delete static_cast<ScRTFParser*>(mpParser);     // before EditEngine!
+    mpParser.reset(new ScRTFParser( mpEngine.get() ));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list