Kaydet (Commit) 1ef8bb7c authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

TSCP: simplify ApplyParagraphClassification

Change-Id: I67f9d173526d785bfbb2c09526f915aa7c6216eb
Reviewed-on: https://gerrit.libreoffice.org/43019Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 807bf068
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment