From 21ab418859d5f8fc16730dc26f1dda149ee132fc Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 12 May 2015 19:02:06 +0200 Subject: sw: replace that awful constructor that overloads SwTxtPortion copy-ctor ... with a CopyLinePortion function; how can you even... Change-Id: Ie7d459ee317522e35fdbbd3974afabe7a136fe62 --- sw/source/core/text/porlay.cxx | 6 +++--- sw/source/core/text/pormulti.cxx | 2 +- sw/source/core/text/portxt.cxx | 8 +++++--- sw/source/core/text/portxt.hxx | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 78572beee6d2..72845e871ae0 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -139,7 +139,7 @@ SwLinePortion *SwLineLayout::Insert( SwLinePortion *pIns ) { if( GetLen() ) { - pPortion = new SwTxtPortion(*static_cast(this)); + pPortion = SwTxtPortion::CopyLinePortion(*this); if( IsBlinking() && pBlink ) { SetBlinking( false ); @@ -161,7 +161,7 @@ SwLinePortion *SwLineLayout::Append( SwLinePortion *pIns ) // First attribute change: copy mass and length from *pIns into the first // text portion if( !pPortion ) - pPortion = new SwTxtPortion(*static_cast(this)); + pPortion = SwTxtPortion::CopyLinePortion(*this); // Call with scope or we'll end up with recursion! return pPortion->SwLinePortion::Append( pIns ); } @@ -184,7 +184,7 @@ SwMarginPortion *SwLineLayout::CalcLeftMargin() SwMarginPortion *pLeft = (GetPortion() && GetPortion()->IsMarginPortion()) ? static_cast(GetPortion()) : 0; if( !GetPortion() ) - SetPortion(new SwTxtPortion(*static_cast(this))); + SetPortion(SwTxtPortion::CopyLinePortion(*this)); if( !pLeft ) { pLeft = new SwMarginPortion( 0 ); diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 6b24834646be..755869f62849 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -678,7 +678,7 @@ void SwRubyPortion::_Adjust( SwTxtFormatInfo &rInf ) if( nLeft || nRight ) { if( !pCurr->GetPortion() ) - pCurr->SetPortion(new SwTxtPortion(*static_cast(pCurr))); + pCurr->SetPortion(SwTxtPortion::CopyLinePortion(*pCurr)); if( nLeft ) { SwMarginPortion *pMarg = new SwMarginPortion( 0 ); diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 691a7161fafc..4b78981d039d 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -208,10 +208,12 @@ static sal_Int32 lcl_AddSpace( const SwTxtSizeInfo &rInf, const OUString* pStr, return nCnt; } -SwTxtPortion::SwTxtPortion( const SwLinePortion &rPortion ) - : SwLinePortion( rPortion ) +SwTxtPortion * SwTxtPortion::CopyLinePortion(const SwLinePortion &rPortion) { - SetWhichPor( POR_TXT ); + SwTxtPortion *const pNew(new SwTxtPortion); + static_cast(*pNew) = rPortion; + pNew->SetWhichPor( POR_TXT ); // overwrite that! + return pNew; } void SwTxtPortion::BreakCut( SwTxtFormatInfo &rInf, const SwTxtGuess &rGuess ) diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx index 51ed3f129d56..3f30ba7fc75f 100644 --- a/sw/source/core/text/portxt.hxx +++ b/sw/source/core/text/portxt.hxx @@ -34,7 +34,7 @@ class SwTxtPortion : public SwLinePortion public: inline SwTxtPortion(){ SetWhichPor( POR_TXT ); } - SwTxtPortion( const SwLinePortion &rPortion ); + static SwTxtPortion * CopyLinePortion(const SwLinePortion &rPortion); virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE; virtual bool Format( SwTxtFormatInfo &rInf ) SAL_OVERRIDE; virtual void FormatEOL( SwTxtFormatInfo &rInf ) SAL_OVERRIDE; -- cgit