[Libreoffice-commits] core.git: sw/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Oct 2 12:14:17 UTC 2017


 sw/source/core/edit/edfcol.cxx |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

New commits:
commit 1ef8bb7c9d90766629d8c769cc05b9944637f68d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 1 19:33:21 2017 -0400

    TSCP: simplify ApplyParagraphClassification
    
    Change-Id: I67f9d173526d785bfbb2c09526f915aa7c6216eb
    Reviewed-on: https://gerrit.libreoffice.org/43019
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index d41fbf5522ec..fb13fedac53b 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -773,10 +773,15 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
     if (!pDocShell)
         return;
 
+    SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
+    if (pNode == nullptr)
+        return;
+
+    uno::Reference<text::XTextContent> xParent = SwXParagraph::CreateXParagraph(*pNode->GetDoc(), pNode);
     uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel();
     uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY);
 
-    OUString sPolicy = SfxClassificationHelper::policyTypeToString(getPolicyType());
+    const OUString sPolicy = SfxClassificationHelper::policyTypeToString(getPolicyType());
 
     // Prevent recursive validation since this is triggered on node updates, which we do below.
     const bool bOldValidationFlag = SetParagraphSignatureValidation(false);
@@ -784,10 +789,6 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             SetParagraphSignatureValidation(bOldValidationFlag);
         });
 
-    SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
-    if (pNode == nullptr)
-        return;
-
     // Since we always insert at the start of the paragraph,
     // need to insert in reverse order.
     std::reverse(aResults.begin(), aResults.end());
@@ -800,7 +801,6 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             {
                 const OUString sKey = sPolicy + "Marking:Text:" + OUString::number(nTextNumber++);
 
-                const uno::Reference<text::XTextContent> xParent = SwXParagraph::CreateXParagraph(*pNode->GetDoc(), pNode);
                 uno::Reference<text::XTextField> xTextField = lcl_FindParagraphClassificationField(xModel, xParent, sKey);
                 if (!xTextField.is())
                     xTextField = lcl_InsertParagraphClassification(xModel, xParent);
@@ -813,7 +813,6 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             {
                 const OUString sKey = sPolicy + "BusinessAuthorizationCategory:Name";
 
-                const uno::Reference<text::XTextContent> xParent = SwXParagraph::CreateXParagraph(*pNode->GetDoc(), pNode);
                 uno::Reference<text::XTextField> xTextField = lcl_FindParagraphClassificationField(xModel, xParent, sKey);
                 if (!xTextField.is())
                     xTextField = lcl_InsertParagraphClassification(xModel, xParent);
@@ -826,7 +825,6 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             {
                 const OUString sKey = sPolicy + "Extension:Marking";
 
-                const uno::Reference<text::XTextContent> xParent = SwXParagraph::CreateXParagraph(*pNode->GetDoc(), pNode);
                 uno::Reference<text::XTextField> xTextField = lcl_FindParagraphClassificationField(xModel, xParent, sKey);
                 if (!xTextField.is())
                     xTextField = lcl_InsertParagraphClassification(xModel, xParent);
@@ -839,7 +837,6 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
             {
                 const OUString sKey = sPolicy + "Extension:IntellectualPropertyPart";
 
-                const uno::Reference<text::XTextContent> xParent = SwXParagraph::CreateXParagraph(*pNode->GetDoc(), pNode);
                 uno::Reference<text::XTextField> xTextField = lcl_FindParagraphClassificationField(xModel, xParent, sKey);
                 if (!xTextField.is())
                     xTextField = lcl_InsertParagraphClassification(xModel, xParent);


More information about the Libreoffice-commits mailing list