Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2122

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/22/2122/1

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)
---
M sw/source/core/txtnode/ndtxt.cxx
1 file changed, 30 insertions(+), 13 deletions(-)



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 @@
 
     // 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 @@
         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;

-- 
To view, visit https://gerrit.libreoffice.org/2122
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5ae2a82da9a6618bb451efabfd38769c495cc93
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Michael Stahl <mstahl@redhat.com>

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.