diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-04-29 10:02:24 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-04-29 10:19:51 +0200 |
commit | 13a0477250793d1ab06329b244f26fffbebb0bab (patch) | |
tree | 40dd46454fc9ecf79b9c943981c67f0594ed2cb6 | |
parent | 9069a4a4775b89291eddb5cdc1d81263a7e772f5 (diff) |
SwTxtSizeInfo ctor: take a pointer, not a reference
The ctor later will turn that reference to a pointer anyway, but the old
code made it easy to pass a String, get it implicitly converted to
OUString, and then we took the address of the temporary OUString, later
resulting in accessing already freed memory. Instead, take an OUString
pointer, and then the compiler will warn about a String* -> OUString*
conversion. Adapt one remaining caller accordingly.
Change-Id: I4084dea1d245f0c8919d6afe47c5f391729f6eaf
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/porglue.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/text/txttab.cxx | 2 |
5 files changed, 13 insertions, 13 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 5adc1c5a1cda..b1ac0f29dfc8 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -312,7 +312,7 @@ void SwTxtSizeInfo::CtorInitTxtSizeInfo( SwTxtFrm *pFrame, SwFont *pNewFnt, SetLen( GetMinLen( *this ) ); } -SwTxtSizeInfo::SwTxtSizeInfo( const SwTxtSizeInfo &rNew, const OUString &rTxt, +SwTxtSizeInfo::SwTxtSizeInfo( const SwTxtSizeInfo &rNew, const OUString* pTxt_, const sal_Int32 nIndex, const xub_StrLen nLength ) : SwTxtInfo( rNew ), pKanaComp(((SwTxtSizeInfo&)rNew).GetpKanaComp()), @@ -323,7 +323,7 @@ SwTxtSizeInfo::SwTxtSizeInfo( const SwTxtSizeInfo &rNew, const OUString &rTxt, pUnderFnt(((SwTxtSizeInfo&)rNew).GetUnderFnt()), pFrm( rNew.pFrm ), pOpt(&rNew.GetOpt()), - pTxt(&rTxt), + pTxt(pTxt_), nIdx(nIndex), nLen(nLength), nKanaIdx( rNew.GetKanaIdx() ), @@ -474,8 +474,8 @@ void SwTxtPaintInfo::CtorInitTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPain #endif } -SwTxtPaintInfo::SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const XubString &rTxt ) - : SwTxtSizeInfo( rInf, rTxt ), +SwTxtPaintInfo::SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const OUString* pTxt_ ) + : SwTxtSizeInfo( rInf, pTxt_ ), pWrongList( rInf.GetpWrongList() ), pGrammarCheckList( rInf.GetGrammarCheckList() ), pSmartTags( rInf.GetSmartTags() ), // SMARTTAGS diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index e34aca8ecc0c..2faee80b15b4 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -201,7 +201,7 @@ protected: SwTxtSizeInfo() : pKanaComp(0), pVsh(0), pOut(0), pRef(0), pFnt(0), pUnderFnt(0), pFrm(0), pOpt(0), pTxt(0) {} public: SwTxtSizeInfo( const SwTxtSizeInfo &rInf ); - SwTxtSizeInfo( const SwTxtSizeInfo &rInf, const OUString &rTxt, + SwTxtSizeInfo( const SwTxtSizeInfo &rInf, const OUString* pTxt_, const sal_Int32 nIdx = 0, const xub_StrLen nLen = STRING_LEN ); @@ -400,7 +400,7 @@ protected: #endif public: SwTxtPaintInfo( const SwTxtPaintInfo &rInf ); - SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const XubString &rTxt ); + SwTxtPaintInfo( const SwTxtPaintInfo &rInf, const OUString* pTxt ); void CtorInitTxtPaintInfo( SwTxtFrm *pFrame, const SwRect &rPaint ); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index bb1d08bc5874..3befea223a83 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -490,7 +490,7 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst, SwCrsrMoveState* pCMS ) { const OUString aText = GetInfo().GetTxt(); - SwTxtSizeInfo aInf( GetInfo(), aText, nStart ); + SwTxtSizeInfo aInf( GetInfo(), &aText, nStart ); if( GetPropFont() ) aInf.GetFont()->SetProportion( GetPropFont() ); KSHORT nTmpAscent, nTmpHeight; // Zeilenhoehe @@ -1594,7 +1594,7 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint, nOldProp = 0; { OUString aText = rText; - SwTxtSizeInfo aSizeInf( GetInfo(), aText, nCurrStart ); + SwTxtSizeInfo aSizeInf( GetInfo(), &aText, nCurrStart ); ((SwTxtCursor*)this)->SeekAndChg( aSizeInf ); SwTxtSlot aDiffTxt( &aSizeInf, ((SwTxtPortion*)pPor), false, false ); SwFontSave aSave( aSizeInf, pPor->IsDropPortion() ? diff --git a/sw/source/core/text/porglue.cxx b/sw/source/core/text/porglue.cxx index d6d481fa934f..8769a41448b1 100644 --- a/sw/source/core/text/porglue.cxx +++ b/sw/source/core/text/porglue.cxx @@ -92,9 +92,9 @@ void SwGluePortion::Paint( const SwTxtPaintInfo &rInf ) const { OUStringBuffer aBuf; comphelper::string::padToLength(aBuf, GetFixWidth() / GetLen(), ' '); - String aTxt(aBuf.makeStringAndClear()); - SwTxtPaintInfo aInf( rInf, aTxt ); - aInf.DrawText( *this, aTxt.Len(), sal_True ); + OUString aTxt(aBuf.makeStringAndClear()); + SwTxtPaintInfo aInf( rInf, &aTxt ); + aInf.DrawText( *this, aTxt.getLength(), sal_True ); } if( rInf.OnWin() && rInf.GetOpt().IsBlank() && rInf.IsNoSymbol() ) @@ -110,7 +110,7 @@ void SwGluePortion::Paint( const SwTxtPaintInfo &rInf ) const SwPosSize aBulletSize( rInf.GetTxtSize( aBullet ) ); Point aPos( rInf.GetPos() ); aPos.X() += (Width()/2) - (aBulletSize.Width()/2); - SwTxtPaintInfo aInf( rInf, aBullet ); + SwTxtPaintInfo aInf( rInf, &aBullet ); aInf.SetPos( aPos ); SwTxtPortion aBulletPor; aBulletPor.Width( aBulletSize.Width() ); diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index 09cecb0dd77f..f4f3d95ab702 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -395,7 +395,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf ) pSave.reset( new SwFontSave( rInf, const_cast<SwFont*>(pNumberPortionFont) ) ); } OUString aTmp( ' ' ); - SwTxtSizeInfo aInf( rInf, aTmp ); + SwTxtSizeInfo aInf( rInf, &aTmp ); nMinimumTabWidth = aInf.GetTxtSize().Width(); } PrtWidth( nMinimumTabWidth ); |