[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sw/source
Michael Stahl
mstahl at redhat.com
Wed Feb 13 00:39:32 PST 2013
sw/source/core/txtnode/ndtxt.cxx | 43 +++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 13 deletions(-)
New commits:
commit aa3c9716c2492447e7dc3daa3592efbf52e8f186
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Feb 12 19:43:16 2013 +0100
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
(cherry picked from commit e31807c83009655c342c929a118f0d28a8f63ddc)
Reviewed-on: https://gerrit.libreoffice.org/2122
Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 4fedcfa..eb2dd25 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2959,8 +2959,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 );
@@ -3063,22 +3062,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;
More information about the Libreoffice-commits
mailing list