summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-10-01 19:34:28 -0400
committerAshod Nakashian <ashnakash@gmail.com>2017-10-02 14:14:35 +0200
commit217dd15374a7020aa498817bcf4ea28157e7080f (patch)
tree9d8b69763158167024d9e9e8cbfc472a2f9e8f7f
parent1ef8bb7c9d90766629d8c769cc05b9944637f68d (diff)
TSCP: edit paragraph classification
Change-Id: Ib60a22fefe3464e29427a3d82b3af0926375433b Reviewed-on: https://gerrit.libreoffice.org/43020 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--sw/inc/editsh.hxx1
-rw-r--r--sw/source/core/edit/edfcol.cxx68
-rw-r--r--sw/source/uibase/app/docsh2.cxx2
3 files changed, 70 insertions, 1 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index f25cd59b0c04..9b9692b4c47e 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -382,6 +382,7 @@ public:
/// Apply the classification to the paragraph at cursor.
void ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResult);
+ std::vector<svx::ClassificationResult> CollectParagraphClassification();
/// Returns true iff the cursor is within a paragraph metadata field.
/// Currently there are two variants: signature and classification.
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index fb13fedac53b..e1bd4cbcb144 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -851,6 +851,74 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe
}
}
+std::vector<svx::ClassificationResult> SwEditShell::CollectParagraphClassification()
+{
+ std::vector<svx::ClassificationResult> aResult;
+
+ SwDocShell* pDocShell = GetDoc()->GetDocShell();
+ if (!pDocShell)
+ return aResult;
+
+ SwTextNode* pNode = GetCursor()->Start()->nNode.GetNode().GetTextNode();
+ if (pNode == nullptr)
+ return aResult;
+
+ 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);
+
+ uno::Reference<container::XEnumerationAccess> xTextPortionEnumerationAccess(xParent, uno::UNO_QUERY);
+ if (!xTextPortionEnumerationAccess.is())
+ return aResult;
+
+ uno::Reference<container::XEnumeration> xTextPortions = xTextPortionEnumerationAccess->createEnumeration();
+
+ const OUString sPolicy = SfxClassificationHelper::policyTypeToString(getPolicyType());
+ const sal_Int32 nParagraph = 1;
+
+ while (xTextPortions->hasMoreElements())
+ {
+ uno::Reference<beans::XPropertySet> xTextPortion(xTextPortions->nextElement(), uno::UNO_QUERY);
+ OUString aTextPortionType;
+ xTextPortion->getPropertyValue(UNO_NAME_TEXT_PORTION_TYPE) >>= aTextPortionType;
+ if (aTextPortionType != UNO_NAME_TEXT_FIELD)
+ continue;
+
+ uno::Reference<lang::XServiceInfo> xField;
+ xTextPortion->getPropertyValue(UNO_NAME_TEXT_FIELD) >>= xField;
+ if (!xField->supportsService(MetadataFieldServiceName))
+ continue;
+
+ uno::Reference<text::XTextField> xTextField(xField, uno::UNO_QUERY);
+ const std::pair<OUString, OUString> rdfPair = lcl_getFieldRDF(xModel, xTextField, ParagraphClassificationRDFName);
+
+ uno::Reference<text::XTextRange> xTextRange(xField, uno::UNO_QUERY);
+ const OUString aName = rdfPair.second;
+ if (aName.startsWith(sPolicy + "Marking:Text:"))
+ {
+ const OUString aValue = xTextRange->getString();
+ aResult.push_back({ svx::ClassificationType::TEXT, aValue, nParagraph });
+ }
+ else if (aName.startsWith(sPolicy + "BusinessAuthorizationCategory:Name"))
+ {
+ const OUString aValue = xTextRange->getString();
+ aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, nParagraph });
+ }
+ else if (aName.startsWith(sPolicy + "Extension:Marking"))
+ {
+ const OUString aValue = xTextRange->getString();
+ aResult.push_back({ svx::ClassificationType::MARKING, aValue, nParagraph });
+ }
+ else if (aName.startsWith(sPolicy + "Extension:IntellectualPropertyPart"))
+ {
+ const OUString aValue = xTextRange->getString();
+ aResult.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, nParagraph });
+ }
+ }
+
+ return aResult;
+}
+
sal_Int16 lcl_GetAngle(const drawing::HomogenMatrix3& rMatrix)
{
basegfx::B2DHomMatrix aTransformation;
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 944e9aec3d45..3deb35e4690d 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1186,7 +1186,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
pShell->SignParagraph();
}));
- std::vector<svx::ClassificationResult> aInput = pShell->CollectAdvancedClassification();
+ std::vector<svx::ClassificationResult> aInput = pShell->CollectParagraphClassification();
pDialog->setupValues(aInput);
if (RET_OK == pDialog->Execute())