sw/source/core/edit/edfcol.cxx |   33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

New commits:
commit ed01e23aeb08addc9ac7d74014483b5af57b15d9
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Oct 1 20:10:44 2017 -0400

    TSCP: remove classification fields before editing
    
    Change-Id: If6f66a03c5c97ec87931944147d64b3f6de1ef03
    Reviewed-on: https://gerrit.libreoffice.org/43021
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index e1bd4cbcb144..0d7523252d75 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -789,6 +789,15 @@ void 
SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             SetParagraphSignatureValidation(bOldValidationFlag);
         });
 
+    // Remove all paragraph classification fields.
+    for (;;)
+    {
+        uno::Reference<text::XTextField> xTextField = 
lcl_FindParagraphClassificationField(xModel, xParent);
+        if (!xTextField.is())
+            break;
+        lcl_RemoveParagraphMetadataField(xTextField);
+    }
+
     // Since we always insert at the start of the paragraph,
     // need to insert in reverse order.
     std::reverse(aResults.begin(), aResults.end());
@@ -800,11 +809,7 @@ void 
SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             case svx::ClassificationType::TEXT:
             {
                 const OUString sKey = sPolicy + "Marking:Text:" + 
OUString::number(nTextNumber++);
-
-                uno::Reference<text::XTextField> xTextField = 
lcl_FindParagraphClassificationField(xModel, xParent, sKey);
-                if (!xTextField.is())
-                    xTextField = lcl_InsertParagraphClassification(xModel, 
xParent);
-
+                uno::Reference<text::XTextField> xTextField = 
lcl_InsertParagraphClassification(xModel, xParent);
                 lcl_UpdateParagraphClassificationField(GetDoc(), xModel, 
xTextField, sKey, rResult.msString);
             }
             break;
@@ -812,11 +817,7 @@ void 
SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             case svx::ClassificationType::CATEGORY:
             {
                 const OUString sKey = sPolicy + 
"BusinessAuthorizationCategory:Name";
-
-                uno::Reference<text::XTextField> xTextField = 
lcl_FindParagraphClassificationField(xModel, xParent, sKey);
-                if (!xTextField.is())
-                    xTextField = lcl_InsertParagraphClassification(xModel, 
xParent);
-
+                uno::Reference<text::XTextField> xTextField = 
lcl_InsertParagraphClassification(xModel, xParent);
                 lcl_UpdateParagraphClassificationField(GetDoc(), xModel, 
xTextField, sKey, rResult.msString);
             }
             break;
@@ -824,11 +825,7 @@ void 
SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             case svx::ClassificationType::MARKING:
             {
                 const OUString sKey = sPolicy + "Extension:Marking";
-
-                uno::Reference<text::XTextField> xTextField = 
lcl_FindParagraphClassificationField(xModel, xParent, sKey);
-                if (!xTextField.is())
-                    xTextField = lcl_InsertParagraphClassification(xModel, 
xParent);
-
+                uno::Reference<text::XTextField> xTextField = 
lcl_InsertParagraphClassification(xModel, xParent);
                 lcl_UpdateParagraphClassificationField(GetDoc(), xModel, 
xTextField, sKey, rResult.msString);
             }
             break;
@@ -836,11 +833,7 @@ void 
SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
             {
                 const OUString sKey = sPolicy + 
"Extension:IntellectualPropertyPart";
-
-                uno::Reference<text::XTextField> xTextField = 
lcl_FindParagraphClassificationField(xModel, xParent, sKey);
-                if (!xTextField.is())
-                    xTextField = lcl_InsertParagraphClassification(xModel, 
xParent);
-
+                uno::Reference<text::XTextField> xTextField = 
lcl_InsertParagraphClassification(xModel, xParent);
                 lcl_UpdateParagraphClassificationField(GetDoc(), xModel, 
xTextField, sKey, rResult.msString);
             }
             break;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to