sw/source/core/txtnode/fntcache.cxx | 21 +++++++++++++++------ sw/source/core/txtnode/fntcap.cxx | 23 +++++++++++++++++------ vcl/inc/vcl/outdev.hxx | 10 +++++----- vcl/source/gdi/outdev3.cxx | 14 +++++++------- 4 files changed, 44 insertions(+), 24 deletions(-)
New commits: commit a2f6402b1fe769a430019042e14e63c9414715dc Author: Chr. Rossmanith <[email protected]> Date: Mon Mar 25 15:50:37 2013 +0100 Use OUString and sal_Int32 in GetTextBreak() Change-Id: I66b85365d1c59f802253b8abdb1e04e25950a09b Reviewed-on: https://gerrit.libreoffice.org/3098 Reviewed-by: Eike Rathke <[email protected]> Tested-by: Eike Rathke <[email protected]> diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index fb4f523..b41fa2c 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2437,14 +2437,23 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) bTextReplaced = true; } - if( rInf.GetHyphPos() ) - nTxtBreak = rInf.GetOut().GetTextBreak( *pTmpText, nTextWidth, - '-', *rInf.GetHyphPos(), - nTmpIdx, nTmpLen, nKern ); + OUString sTmpText(*pTmpText); // only needed until *pTmpText is OUString + sal_Int32 nTmpIdx2 = nTmpIdx; // ditto + sal_Int32 nTmpLen2 = nTmpLen; // ditto + if( rInf.GetHyphPos() ) { + sal_Int32 nHyphPos = *rInf.GetHyphPos(); + nTxtBreak = rInf.GetOut().GetTextBreak( sTmpText, nTextWidth, + static_cast<sal_Unicode>('-'), nHyphPos, + nTmpIdx2, nTmpLen2, nKern ); + xub_StrLen nTmpHyphPos = static_cast<xub_StrLen>(nHyphPos); + rInf.SetHyphPos(&nTmpHyphPos); + } else - nTxtBreak = rInf.GetOut().GetTextBreak( *pTmpText, nTextWidth, - nTmpIdx, nTmpLen, nKern ); + nTxtBreak = rInf.GetOut().GetTextBreak( sTmpText, nTextWidth, + nTmpIdx2, nTmpLen2, nKern ); + nTmpIdx = nTmpIdx2; // ditto + nTmpLen = nTmpLen2; // ditto if ( bTextReplaced && STRING_LEN != nTxtBreak ) { if ( nTmpLen != nLn ) diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx index ef40571..00ed43e 100644 --- a/sw/source/core/txtnode/fntcap.cxx +++ b/sw/source/core/txtnode/fntcap.cxx @@ -208,16 +208,27 @@ void SwDoGetCapitalBreak::Do() else { xub_StrLen nEnd = rInf.GetEnd(); + OUString sText(rInf.GetText()); // only needed until rInf.GetText() returns OUString + long nTxtWidth2 = nTxtWidth; // only needed until variables are migrated to sal_Int32 + sal_Int32 nIdx2 = rInf.GetIdx(); // ditto + sal_Int32 nLen2 = rInf.GetLen(); // ditto if( pExtraPos ) { - nBreak = GetOut().GetTextBreak( rInf.GetText(), nTxtWidth, '-', - *pExtraPos, rInf.GetIdx(), rInf.GetLen(), rInf.GetKern() ); - if( *pExtraPos > nEnd ) - *pExtraPos = nEnd; + sal_Int32 nExtraPos = *pExtraPos; // ditto + nBreak = GetOut().GetTextBreak( sText, nTxtWidth2, static_cast<sal_Unicode>('-'), + nExtraPos, nIdx2, nLen2, rInf.GetKern() ); + if( nExtraPos > nEnd ) + nExtraPos = nEnd; + *pExtraPos = nExtraPos; } else - nBreak = GetOut().GetTextBreak( rInf.GetText(), nTxtWidth, - rInf.GetIdx(), rInf.GetLen(), rInf.GetKern() ); + nBreak = GetOut().GetTextBreak( sText, nTxtWidth2, + nIdx2, nLen2, rInf.GetKern() ); + + rInf.SetText(sText); // ditto + rInf.SetIdx(nIdx2); // ditto + rInf.SetLen(nLen2); // ditto + nTxtWidth = nTxtWidth2; // ditto if( nBreak > nEnd ) nBreak = nEnd; diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index d8cae7d..a1424f6 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -590,12 +590,12 @@ public: void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, const XubString& rStr, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ); - xub_StrLen GetTextBreak( const XubString& rStr, long nTextWidth, - xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + xub_StrLen GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1, long nCharExtra = 0, sal_Bool bCellBreaking = sal_True ) const; - xub_StrLen GetTextBreak( const XubString& rStr, long nTextWidth, - sal_uInt16 nExtraChar, xub_StrLen& rExtraCharPos, - xub_StrLen nIndex, xub_StrLen nLen, + xub_StrLen GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Unicode nExtraChar, sal_Int32& rExtraCharPos, + sal_Int32 nIndex, sal_Int32 nLen, long nCharExtra = 0 ) const; /** Generate MetaTextActions for the text rect diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 19b2598..9cc6369 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -5795,7 +5795,7 @@ SalLayout* OutputDevice::ImplLayout( const OUString& rOrigStr, sal_Int32 nMinInd ImplInitFont(); // check string index and length - if( nMinIndex + nLen > rOrigStr.getLength() ) + if( -1 == nLen || nMinIndex + nLen > rOrigStr.getLength() ) { const sal_Int32 nNewLen = rOrigStr.getLength() - nMinIndex; if( nNewLen <= 0 ) @@ -6077,8 +6077,8 @@ sal_Bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, return (nCharPos != nIndex) ? sal_True : sal_False; } -xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth, - xub_StrLen nIndex, xub_StrLen nLen, +xub_StrLen OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Int32 nIndex, sal_Int32 nLen, long nCharExtra, sal_Bool /*TODO: bCellBreaking*/ ) const { DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -6109,9 +6109,9 @@ xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth, return nRetVal; } -xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth, - sal_Unicode nHyphenatorChar, xub_StrLen& rHyphenatorPos, - xub_StrLen nIndex, xub_StrLen nLen, +xub_StrLen OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Unicode nHyphenatorChar, sal_Int32& rHyphenatorPos, + sal_Int32 nIndex, sal_Int32 nLen, long nCharExtra ) const { DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -6143,7 +6143,7 @@ xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth, // calculate hyphenated break position rtl::OUString aHyphenatorStr(nHyphenatorChar); - xub_StrLen nTempLen = 1; + sal_Int32 nTempLen = 1; SalLayout* pHyphenatorLayout = ImplLayout( aHyphenatorStr, 0, nTempLen ); if( pHyphenatorLayout ) { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
