summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-05-12 19:02:06 +0200
committerMichael Stahl <mstahl@redhat.com>2015-05-12 19:16:39 +0200
commit21ab418859d5f8fc16730dc26f1dda149ee132fc (patch)
treede5b1fb85f15a2f012d318b92902dcf96c2e3b35
parentba587924b14d3e03f5c2bddf66d1da18089fc580 (diff)
sw: replace that awful constructor that overloads SwTxtPortion copy-ctor
... with a CopyLinePortion function; how can you even... Change-Id: Ie7d459ee317522e35fdbbd3974afabe7a136fe62
-rw-r--r--sw/source/core/text/porlay.cxx6
-rw-r--r--sw/source/core/text/pormulti.cxx2
-rw-r--r--sw/source/core/text/portxt.cxx8
-rw-r--r--sw/source/core/text/portxt.hxx2
4 files changed, 10 insertions, 8 deletions
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<SwLinePortion*>(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<SwLinePortion*>(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<SwMarginPortion *>(GetPortion()) : 0;
if( !GetPortion() )
- SetPortion(new SwTxtPortion(*static_cast<SwLinePortion*>(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<SwLinePortion*>(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<SwLinePortion&>(*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;