Kaydet (Commit) 217dd153 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

TSCP: edit paragraph classification

Change-Id: Ib60a22fefe3464e29427a3d82b3af0926375433b
Reviewed-on: https://gerrit.libreoffice.org/43020Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 1ef8bb7c
...@@ -382,6 +382,7 @@ public: ...@@ -382,6 +382,7 @@ public:
/// Apply the classification to the paragraph at cursor. /// Apply the classification to the paragraph at cursor.
void ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResult); void ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResult);
std::vector<svx::ClassificationResult> CollectParagraphClassification();
/// Returns true iff the cursor is within a paragraph metadata field. /// Returns true iff the cursor is within a paragraph metadata field.
/// Currently there are two variants: signature and classification. /// Currently there are two variants: signature and classification.
......
...@@ -851,6 +851,74 @@ void SwEditShell::ApplyParagraphClassification(std::vector<svx::ClassificationRe ...@@ -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) sal_Int16 lcl_GetAngle(const drawing::HomogenMatrix3& rMatrix)
{ {
basegfx::B2DHomMatrix aTransformation; basegfx::B2DHomMatrix aTransformation;
......
...@@ -1186,7 +1186,7 @@ void SwDocShell::Execute(SfxRequest& rReq) ...@@ -1186,7 +1186,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
pShell->SignParagraph(); pShell->SignParagraph();
})); }));
std::vector<svx::ClassificationResult> aInput = pShell->CollectAdvancedClassification(); std::vector<svx::ClassificationResult> aInput = pShell->CollectParagraphClassification();
pDialog->setupValues(aInput); pDialog->setupValues(aInput);
if (RET_OK == pDialog->Execute()) if (RET_OK == pDialog->Execute())
......
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