Kaydet (Commit) 14c8ed76 authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

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/34044Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e70048eb
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -26,7 +26,6 @@ class ScRTFImport : public ScEEImport
{
public:
ScRTFImport( ScDocument* pDoc, const ScRange& rRange );
virtual ~ScRTFImport() override;
};
#endif
......
......@@ -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() );
......
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment