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>
This commit is contained in:
parent
955412491c
commit
e4969b2b63
1 changed files with 30 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue