Kaydet (Commit) 4cf82f05 authored tarafından Michael Stahl's avatar Michael Stahl

sw: convert Replace0xFF to OUStringBuffer

Change-Id: I510021cff6aee73e04473700cc23eb90fc6d4fe7
üst 28f38798
...@@ -2894,8 +2894,8 @@ long SwTxtNode::GetLeftMarginForTabCalculation() const ...@@ -2894,8 +2894,8 @@ long SwTxtNode::GetLeftMarginForTabCalculation() const
} }
static void static void
Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt, Replace0xFF(SwTxtNode const& rNode, OUStringBuffer & rTxt, sal_Int32 & rTxtStt,
xub_StrLen nEndPos, sal_Bool const bExpandFlds) sal_Int32 nEndPos, sal_Bool const bExpandFlds)
{ {
if (rNode.GetpSwpHints()) if (rNode.GetpSwpHints())
{ {
...@@ -2903,8 +2903,8 @@ Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt, ...@@ -2903,8 +2903,8 @@ Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt,
for( int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter, for( int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter,
cSrchChr = CH_TXTATR_INWORD ) cSrchChr = CH_TXTATR_INWORD )
{ {
xub_StrLen nPos = rTxt.Search( cSrchChr ); sal_Int32 nPos = rTxt.indexOf(cSrchChr);
while( STRING_NOTFOUND != nPos && nPos < nEndPos ) while (-1 != nPos && nPos < nEndPos)
{ {
const SwTxtAttr* const pAttr = const SwTxtAttr* const pAttr =
rNode.GetTxtAttrForCharAt(rTxtStt + nPos); rNode.GetTxtAttrForCharAt(rTxtStt + nPos);
...@@ -2913,25 +2913,25 @@ Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt, ...@@ -2913,25 +2913,25 @@ Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt,
switch( pAttr->Which() ) switch( pAttr->Which() )
{ {
case RES_TXTATR_FIELD: case RES_TXTATR_FIELD:
rTxt.Erase( nPos, 1 ); rTxt.remove(nPos, 1);
if( bExpandFlds ) if( bExpandFlds )
{ {
const XubString aExpand( const OUString aExpand(
static_cast<SwTxtFld const*>(pAttr)->GetFld() static_cast<SwTxtFld const*>(pAttr)->GetFld()
.GetFld()->ExpandField(true)); .GetFld()->ExpandField(true));
rTxt.Insert( aExpand, nPos ); rTxt.insert(nPos, aExpand);
nPos = nPos + aExpand.Len(); nPos = nPos + aExpand.getLength();
nEndPos = nEndPos + aExpand.Len(); nEndPos = nEndPos + aExpand.getLength();
rTxtStt = rTxtStt - aExpand.Len(); rTxtStt = rTxtStt - aExpand.getLength();
} }
++rTxtStt; ++rTxtStt;
break; break;
case RES_TXTATR_FTN: case RES_TXTATR_FTN:
rTxt.Erase( nPos, 1 ); rTxt.remove(nPos, 1);
if( bExpandFlds ) if( bExpandFlds )
{ {
const SwFmtFtn& rFtn = pAttr->GetFtn(); const SwFmtFtn& rFtn = pAttr->GetFtn();
XubString sExpand; OUString sExpand;
if( rFtn.GetNumStr().Len() ) if( rFtn.GetNumStr().Len() )
sExpand = rFtn.GetNumStr(); sExpand = rFtn.GetNumStr();
else if( rFtn.IsEndNote() ) else if( rFtn.IsEndNote() )
...@@ -2940,21 +2940,21 @@ Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt, ...@@ -2940,21 +2940,21 @@ Replace0xFF(SwTxtNode const& rNode, XubString& rTxt, xub_StrLen& rTxtStt,
else else
sExpand = rNode.GetDoc()->GetFtnInfo().aFmt. sExpand = rNode.GetDoc()->GetFtnInfo().aFmt.
GetNumStr( rFtn.GetNumber() ); GetNumStr( rFtn.GetNumber() );
rTxt.Insert( sExpand, nPos ); rTxt.insert(nPos, sExpand);
nPos = nPos + sExpand.Len(); nPos = nPos + sExpand.getLength();
nEndPos = nEndPos + sExpand.Len(); nEndPos = nEndPos + sExpand.getLength();
rTxtStt = rTxtStt - sExpand.Len(); rTxtStt = rTxtStt - sExpand.getLength();
} }
++rTxtStt; ++rTxtStt;
break; break;
default: default:
rTxt.Erase( nPos, 1 ); rTxt.remove(nPos, 1);
++rTxtStt; ++rTxtStt;
} }
} }
else else
++nPos, ++nEndPos; ++nPos, ++nEndPos;
nPos = rTxt.Search( cSrchChr, nPos ); nPos = rTxt.indexOf(cSrchChr, nPos);
} }
} }
} }
...@@ -2971,10 +2971,10 @@ OUString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx, ...@@ -2971,10 +2971,10 @@ OUString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx,
const bool bAddSpaceAfterListLabelStr, const bool bAddSpaceAfterListLabelStr,
const bool bWithSpacesForLevel ) const const bool bWithSpacesForLevel ) const
{ {
XubString aTxt( OUStringBuffer aTxt(
(STRING_LEN == nLen) ? GetTxt().copy(nIdx) : GetTxt().copy(nIdx, nLen)); (STRING_LEN == nLen) ? GetTxt().copy(nIdx) : GetTxt().copy(nIdx, nLen));
xub_StrLen nTxtStt = nIdx; sal_Int32 nTxtStt = nIdx;
Replace0xFF(*this, aTxt, nTxtStt, aTxt.Len(), true); Replace0xFF(*this, aTxt, nTxtStt, aTxt.getLength(), true);
if( bWithNum ) if( bWithNum )
{ {
XubString aListLabelStr = GetNumString(); XubString aListLabelStr = GetNumString();
...@@ -2983,9 +2983,9 @@ OUString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx, ...@@ -2983,9 +2983,9 @@ OUString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx,
if ( bAddSpaceAfterListLabelStr ) if ( bAddSpaceAfterListLabelStr )
{ {
const sal_Unicode aSpace = ' '; const sal_Unicode aSpace = ' ';
aTxt.Insert( aSpace, 0 ); aTxt.insert(0, aSpace);
} }
aTxt.Insert( GetNumString(), 0 ); aTxt.insert(0, GetNumString());
} }
} }
...@@ -2994,12 +2994,12 @@ OUString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx, ...@@ -2994,12 +2994,12 @@ OUString SwTxtNode::GetExpandTxt( const xub_StrLen nIdx,
const sal_Unicode aSpace = ' '; const sal_Unicode aSpace = ' ';
for (int nLevel = GetActualListLevel(); nLevel > 0; --nLevel) for (int nLevel = GetActualListLevel(); nLevel > 0; --nLevel)
{ {
aTxt.Insert( aSpace , 0 ); aTxt.insert(0, aSpace);
aTxt.Insert( aSpace , 0 ); aTxt.insert(0, aSpace);
} }
} }
return aTxt; return aTxt.makeStringAndClear();
} }
sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx,
...@@ -3354,9 +3354,11 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, ...@@ -3354,9 +3354,11 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen,
} }
} }
XubString aTxt(nLen > GetTxt().getLength() ? GetTxt().copy(nIdx) : GetTxt().copy(nIdx, nLen)); OUStringBuffer aTxt((nLen > GetTxt().getLength())
? GetTxt().copy(nIdx)
: GetTxt().copy(nIdx, nLen));
xub_StrLen nTxtStt = nIdx, nIdxEnd = nIdx + aTxt.Len(); sal_Int32 nTxtStt = nIdx, nIdxEnd = nIdx + aTxt.getLength();
for( sal_uInt16 n = 0; n < aRedlArr.size(); n += 2 ) for( sal_uInt16 n = 0; n < aRedlArr.size(); n += 2 )
{ {
xub_StrLen nStt = aRedlArr[ n ], nEnd = aRedlArr[ n+1 ]; xub_StrLen nStt = aRedlArr[ n ], nEnd = aRedlArr[ n+1 ];
...@@ -3366,18 +3368,18 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, ...@@ -3366,18 +3368,18 @@ OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen,
if( nStt < nIdx ) nStt = nIdx; if( nStt < nIdx ) nStt = nIdx;
if( nIdxEnd < nEnd ) nEnd = nIdxEnd; if( nIdxEnd < nEnd ) nEnd = nIdxEnd;
xub_StrLen nDelCnt = nEnd - nStt; xub_StrLen nDelCnt = nEnd - nStt;
aTxt.Erase( nStt - nTxtStt, nDelCnt ); aTxt.remove(nStt - nTxtStt, nDelCnt);
Replace0xFF(*this, aTxt, nTxtStt, nStt - nTxtStt, bExpandFlds); Replace0xFF(*this, aTxt, nTxtStt, nStt - nTxtStt, bExpandFlds);
nTxtStt = nTxtStt + nDelCnt; nTxtStt = nTxtStt + nDelCnt;
} }
else if( nStt >= nIdxEnd ) else if( nStt >= nIdxEnd )
break; break;
} }
Replace0xFF(*this, aTxt, nTxtStt, aTxt.Len(), bExpandFlds); Replace0xFF(*this, aTxt, nTxtStt, aTxt.getLength(), bExpandFlds);
if( bWithNum ) if( bWithNum )
aTxt.Insert( GetNumString(), 0 ); aTxt.insert(0, GetNumString());
return aTxt; return aTxt.makeStringAndClear();
} }
/************************************************************************* /*************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment