diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-12-03 12:27:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-12-03 16:09:36 +0000 |
commit | d83328b233f51d4a70bfeaae90129a68dccf825b (patch) | |
tree | 82f2aa22d722f744af83fdfb634d6f78be1bbc4e /sw | |
parent | f1bd4db85538e4979dea6e0d6d306ac89210ea32 (diff) |
longparas: convert GetTextBreak to sal_Int32
Change-Id: I693e4c9916e1968c33ebd922829662f6efc27bfb
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/swfont.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 47 | ||||
-rw-r--r-- | sw/source/core/txtnode/fntcap.cxx | 33 |
3 files changed, 36 insertions, 46 deletions
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index fb3849d9d633..6f17a43b7935 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -338,7 +338,7 @@ public: Size GetCapitalSize( SwDrawTextInfo& rInf ) { return aSub[nActual].GetCapitalSize( rInf ); } - xub_StrLen GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, + sal_Int32 GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, const SwScriptInfo* pScript, const OUString& rTxt, long nTextWidth, const xub_StrLen nIdx, const xub_StrLen nLen ); diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 781023fc84f3..3ea5be795b7a 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2357,7 +2357,7 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) OSL_ENSURE( !bCompress || ( rInf.GetScriptInfo() && rInf.GetScriptInfo()-> CountCompChg()), "Compression without info" ); - xub_StrLen nTxtBreak = 0; + sal_Int32 nTxtBreak = 0; long nKern = 0; sal_uInt16 nLn = ( rInf.GetLen() == STRING_LEN ? rInf.GetText().getLength() @@ -2477,24 +2477,19 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) bTextReplaced = true; } - 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, + nTxtBreak = rInf.GetOut().GetTextBreak( *pTmpText, nTextWidth, static_cast<sal_Unicode>('-'), nHyphPos, - nTmpIdx2, nTmpLen2, nKern ); + nTmpIdx, nTmpLen, nKern ); *rInf.GetHyphPos() = (nHyphPos == -1) ? STRING_LEN : static_cast<xub_StrLen>(nHyphPos); } else - nTxtBreak = rInf.GetOut().GetTextBreak( sTmpText, nTextWidth, - nTmpIdx2, nTmpLen2, nKern ); + nTxtBreak = rInf.GetOut().GetTextBreak( *pTmpText, nTextWidth, + nTmpIdx, nTmpLen, nKern ); - nTmpIdx = nTmpIdx2; // ditto - nTmpLen = nTmpLen2; // ditto - if ( bTextReplaced && STRING_LEN != nTxtBreak ) + if ( bTextReplaced && nTxtBreak != -1 ) { if ( nTmpLen != nLn ) nTxtBreak = sw_CalcCaseMap( *this, rInf.GetText(), @@ -2504,17 +2499,19 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) } } + xub_StrLen nTxtBreak2 = nTxtBreak == -1 ? STRING_LEN : nTxtBreak; + if ( ! bCompress ) - return nTxtBreak; + return nTxtBreak2; - nTxtBreak = nTxtBreak - rInf.GetIdx(); + nTxtBreak2 = nTxtBreak2 - rInf.GetIdx(); - if( nTxtBreak < nLn ) + if( nTxtBreak2 < nLn ) { - if( !nTxtBreak && nLn ) + if( !nTxtBreak2 && nLn ) nLn = 1; - else if( nLn > 2 * nTxtBreak ) - nLn = 2 * nTxtBreak; + else if( nLn > 2 * nTxtBreak2 ) + nLn = 2 * nTxtBreak2; sal_Int32 *pKernArray = new sal_Int32[ nLn ]; rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray, rInf.GetIdx(), nLn ); @@ -2522,22 +2519,22 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) rInf.GetKanaComp(), (sal_uInt16)GetHeight( nActual ) ) ) { long nKernAdd = nKern; - xub_StrLen nTmpBreak = nTxtBreak; - if( nKern && nTxtBreak ) - nKern *= nTxtBreak - 1; - while( nTxtBreak<nLn && nTextWidth >= pKernArray[nTxtBreak] +nKern ) + xub_StrLen nTmpBreak = nTxtBreak2; + if( nKern && nTxtBreak2 ) + nKern *= nTxtBreak2 - 1; + while( nTxtBreak2<nLn && nTextWidth >= pKernArray[nTxtBreak2] +nKern ) { nKern += nKernAdd; - ++nTxtBreak; + ++nTxtBreak2; } if( rInf.GetHyphPos() ) - *rInf.GetHyphPos() += nTxtBreak - nTmpBreak; // It's not perfect + *rInf.GetHyphPos() += nTxtBreak2 - nTmpBreak; // It's not perfect } delete[] pKernArray; } - nTxtBreak = nTxtBreak + rInf.GetIdx(); + nTxtBreak2 = nTxtBreak2 + rInf.GetIdx(); - return nTxtBreak; + return nTxtBreak2; } extern Color aGlobalRetoucheColor; diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx index 2ae345bcaa5f..70dae9ef58c6 100644 --- a/sw/source/core/txtnode/fntcap.cxx +++ b/sw/source/core/txtnode/fntcap.cxx @@ -182,17 +182,17 @@ class SwDoGetCapitalBreak : public SwDoCapitals { protected: long nTxtWidth; - xub_StrLen nBreak; + sal_Int32 m_nBreak; public: SwDoGetCapitalBreak( SwDrawTextInfo &rInfo, long const nWidth) : SwDoCapitals ( rInfo ) , nTxtWidth( nWidth ) - , nBreak( STRING_LEN ) + , m_nBreak( -1 ) { } virtual ~SwDoGetCapitalBreak() {} virtual void Init( SwFntObj *pUpperFont, SwFntObj *pLowerFont ); virtual void Do(); - xub_StrLen GetBreak() const { return nBreak; } + sal_Int32 getBreak() const { return m_nBreak; } }; void SwDoGetCapitalBreak::Init( SwFntObj *, SwFntObj * ) @@ -208,30 +208,23 @@ void SwDoGetCapitalBreak::Do() else { xub_StrLen nEnd = rInf.GetEnd(); - OUString sText(rInf.GetText()); // only needed until rInf.GetText() returns OUString - sal_Int32 nIdx2 = rInf.GetIdx(); // ditto - sal_Int32 nLen2 = rInf.GetLen(); // ditto - nBreak = GetOut().GetTextBreak( sText, nTxtWidth, - nIdx2, nLen2, rInf.GetKern() ); + m_nBreak = GetOut().GetTextBreak( rInf.GetText(), nTxtWidth, + rInf.GetIdx(), rInf.GetLen(), rInf.GetKern() ); - rInf.SetText(sText); // ditto - rInf.SetIdx(nIdx2); // ditto - rInf.SetLen(nLen2); // ditto + if (m_nBreak > nEnd || m_nBreak < 0) + m_nBreak = nEnd; - if( nBreak > nEnd ) - nBreak = nEnd; - - // nBreak may be relative to the display string. It has to be + // m_nBreak may be relative to the display string. It has to be // calculated relative to the original string: if ( GetCapInf() ) { if ( GetCapInf()->nLen != rInf.GetLen() ) - nBreak = sw_CalcCaseMap( *rInf.GetFont(), + m_nBreak = sw_CalcCaseMap( *rInf.GetFont(), GetCapInf()->rString, GetCapInf()->nIdx, - GetCapInf()->nLen, nBreak ); + GetCapInf()->nLen, m_nBreak ); else - nBreak = nBreak + GetCapInf()->nIdx; + m_nBreak = m_nBreak + GetCapInf()->nIdx; } nTxtWidth = 0; @@ -243,7 +236,7 @@ void SwDoGetCapitalBreak::Do() * SwFont::GetCapitalBreak() *************************************************************************/ -xub_StrLen SwFont::GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, +sal_Int32 SwFont::GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, const SwScriptInfo* pScript, const OUString& rTxt, long const nTextWidth, const xub_StrLen nIdx, const xub_StrLen nLen ) { @@ -263,7 +256,7 @@ xub_StrLen SwFont::GetCapitalBreak( SwViewShell* pSh, const OutputDevice* pOut, SwDoGetCapitalBreak aDo(aInfo, nTextWidth); DoOnCapitals( aDo ); - return aDo.GetBreak(); + return aDo.getBreak(); } /************************************************************************* |