summaryrefslogtreecommitdiff
path: root/sw/source/core/edit/edfcol.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-11-17 10:56:24 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-11-17 07:55:15 +0100
commite4969b2b63bff3f1dba2c46848107f4ab9c0fa3a (patch)
tree1d00918a7ac8be2852a41c40e1241b1fda5a83cc /sw/source/core/edit/edfcol.cxx
parent955412491cc9e6244016223f6ee2de05c4717661 (diff)
TSCP: add category from doc. properties if not found in header
If we selected the classification on the toolbar and then go into the classification dialog, we need to add the current category from the doc. properties to the classification result so it is shown in the dialog automatically. Change-Id: I80909d39efa61f263fdb7dd10188f8d7ae12d1e0 Reviewed-on: https://gerrit.libreoffice.org/44853 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/source/core/edit/edfcol.cxx')
-rw-r--r--sw/source/core/edit/edfcol.cxx37
1 files changed, 30 insertions, 7 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index d713d1ddca4f..48329c85a51e 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -921,6 +921,12 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
if (!pDocShell || !SfxObjectShell::Current())
return aResult;
+ const OUString sBlank;
+
+ uno::Reference<document::XDocumentProperties> xDocumentProperties = SfxObjectShell::Current()->getDocProperties();
+ uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
+ sfx::ClassificationKeyCreator aCreator(SfxClassificationHelper::getPolicyType());
+
uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel();
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
@@ -933,7 +939,13 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
bool bHeaderIsOn = false;
xPageStyle->getPropertyValue(UNO_NAME_HEADER_IS_ON) >>= bHeaderIsOn;
if (!bHeaderIsOn)
+ {
+ const OUString aValue = svx::classification::getProperty(xPropertyContainer, aCreator.makeCategoryNameKey());
+ if (!aValue.isEmpty())
+ aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
+
return aResult;
+ }
uno::Reference<text::XText> xHeaderText;
xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText;
@@ -941,12 +953,8 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xHeaderText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphEnumerationAccess->createEnumeration();
- uno::Reference<document::XDocumentProperties> xDocumentProperties = SfxObjectShell::Current()->getDocProperties();
- uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
-
- sfx::ClassificationKeyCreator aCreator(SfxClassificationHelper::getPolicyType());
-
- const OUString sBlank("");
+ // set to true if category was found in the header
+ bool bFoundClassificationCategory = false;
while (xParagraphs->hasMoreElements())
{
@@ -987,11 +995,19 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
if (!aValue.isEmpty())
aResult.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
}
- else if (aCreator.isCategoryNameKey(aName) || aCreator.isCategoryIdentifierKey(aName))
+ else if (aCreator.isCategoryNameKey(aName))
{
const OUString aValue = svx::classification::getProperty(xPropertyContainer, aName);
if (!aValue.isEmpty())
aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
+ bFoundClassificationCategory = true;
+ }
+ else if (aCreator.isCategoryIdentifierKey(aName))
+ {
+ const OUString aValue = svx::classification::getProperty(xPropertyContainer, aName);
+ if (!aValue.isEmpty())
+ aResult.push_back({ svx::ClassificationType::CATEGORY, sBlank, sBlank, aValue });
+ bFoundClassificationCategory = true;
}
else if (aCreator.isMarkingKey(aName))
{
@@ -1008,6 +1024,13 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio
}
}
+ if (!bFoundClassificationCategory)
+ {
+ const OUString aValue = svx::classification::getProperty(xPropertyContainer, aCreator.makeCategoryNameKey());
+ if (!aValue.isEmpty())
+ aResult.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
+ }
+
return aResult;
}