diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-12 19:43:16 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-02-12 19:52:08 +0100 |
commit | e31807c83009655c342c929a118f0d28a8f63ddc (patch) | |
tree | db2681cc84146dbdf243f15d9d890a277e60ff56 | |
parent | 55b39ff42e6fe7424a106f590531af6717bd6e1e (diff) |
fdo#60668: filter out fieldmark chars from Index entries:
SwTxtNode::GetExpandTxt must filter out all dummy characters used to
represent fields, footnotes, field marks, etc.
Change-Id: Ie5ae2a82da9a6618bb451efabfd38769c495cc93
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 4881fb54129f..5a743b788a06 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2956,8 +2956,7 @@ sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, // mask hidden characters const sal_Unicode cChar = CH_TXTATR_BREAKWORD; - sal_uInt16 nHiddenChrs = - SwScriptInfo::MaskHiddenRanges( *this, sTmpText, 0, sTmpText.Len(), cChar ); + SwScriptInfo::MaskHiddenRanges(*this, sTmpText, 0, sTmpText.Len(), cChar); sTmpText = sTmpText.Copy( nIdx, nLen ); rDestNd.InsertText( sTmpText, aDestIdx ); @@ -3060,22 +3059,40 @@ sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, rDestNd.InsertText( GetNumString(), aDestIdx ); } - if ( nHiddenChrs > 0 ) + aDestIdx = 0; + sal_Int32 nStartDelete(-1); + while (aDestIdx < rDestNd.GetTxt().Len()) { - aDestIdx = 0; - while ( aDestIdx < rDestNd.GetTxt().Len() ) + sal_Unicode const cur(rDestNd.GetTxt().GetChar(aDestIdx.GetIndex())); + if ( (cChar == cur) // filter substituted hidden text + || (CH_TXT_ATR_FIELDSTART == cur) // filter all fieldmarks + || (CH_TXT_ATR_FIELDEND == cur) + || (CH_TXT_ATR_FORMELEMENT == cur)) { - if ( cChar == rDestNd.GetTxt().GetChar( aDestIdx.GetIndex() ) ) + if (-1 == nStartDelete) { - xub_StrLen nIndex = aDestIdx.GetIndex(); - while ( nIndex < rDestNd.GetTxt().Len() && - cChar == rDestNd.GetTxt().GetChar( ++nIndex ) ) - ; - rDestNd.EraseText( aDestIdx, nIndex - aDestIdx.GetIndex() ); + nStartDelete = aDestIdx.GetIndex(); // start deletion range } - else - ++aDestIdx; + ++aDestIdx; + if (aDestIdx < rDestNd.GetTxt().Len()) + { + continue; + } // else: end of paragraph => delete, see below } + else + { + if (-1 == nStartDelete) + { + ++aDestIdx; + continue; + } // else: delete, see below + } + assert(-1 != nStartDelete); // without delete range, would have contined + rDestNd.EraseText( + SwIndex(&rDestNd, static_cast<xub_StrLen>(nStartDelete)), + aDestIdx.GetIndex() - nStartDelete); + assert(aDestIdx.GetIndex() == nStartDelete); + nStartDelete = -1; // reset } return sal_True; |