diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx index e83eadfd05e9..036951fa0ab1 100644 --- a/include/sfx2/classificationhelper.hxx +++ b/include/sfx2/classificationhelper.hxx @@ -63,6 +63,10 @@ public: const OUString& GetBACName(SfxClassificationPolicyType eType); /// Return all possible valid category names, based on the policy. std::vector GetBACNames(); + /// Get the currently selected category abbreviation for eType. Returns full name if no abbreviation defined. + const OUString& GetAbbreviatedBACName(SfxClassificationPolicyType eType); + /// Return all possible valid abbreviated category names, based on the policy. + std::vector GetAbbreviatedBACNames(); /// Setting this sets all the other properties, based on the policy. void SetBACName(const OUString& rName, SfxClassificationPolicyType eType); /// If GetImpactScale() and GetImpactLevel*() will return something meaningful. diff --git a/sfx2/classification/baf.xsd b/sfx2/classification/baf.xsd index a0bae6cc9ff1..abf003b38624 100644 --- a/sfx2/classification/baf.xsd +++ b/sfx2/classification/baf.xsd @@ -68,6 +68,7 @@ + diff --git a/sfx2/classification/example.xml b/sfx2/classification/example.xml index 82098031ff91..a5065e3d959a 100644 --- a/sfx2/classification/example.xml +++ b/sfx2/classification/example.xml @@ -9,7 +9,7 @@ - + UK-Cabinet @@ -17,7 +17,7 @@ - + Document: Header @@ -31,7 +31,7 @@ - + Document: Header @@ -55,7 +55,7 @@ - + Document: Header diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index 3378ed0df239..77932f4fb260 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -92,6 +92,7 @@ class SfxClassificationCategory public: /// PROP_BACNAME() is stored separately for easier lookup. OUString m_aName; + OUString m_aAbbreviatedName; std::map m_aLabels; }; @@ -170,7 +171,8 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const } else if (rName == "baf:BusinessAuthorizationCategory") { - OUString aName = xAttribs->getValueByName("Name"); + const OUString aName = xAttribs->getValueByName("Name"); + const OUString aAbbreviatedName = xAttribs->getValueByName("loextAbbreviatedName"); if (!m_pCategory && !aName.isEmpty()) { OUString aIdentifier = xAttribs->getValueByName("Identifier"); @@ -179,6 +181,8 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const m_aCategories.emplace_back(SfxClassificationCategory()); SfxClassificationCategory& rCategory = m_aCategories.back(); rCategory.m_aName = aName; + // Set the abbreviated name, if any, otherwise fallback on the full name. + rCategory.m_aAbbreviatedName = !aAbbreviatedName.isEmpty() ? aAbbreviatedName : aName; rCategory.m_aLabels["PolicyAuthority:Name"] = m_aPolicyAuthorityName; rCategory.m_aLabels["Policy:Name"] = m_aPolicyName; rCategory.m_aLabels["BusinessAuthorization:Identifier"] = m_aProgramID; @@ -587,6 +591,11 @@ const OUString& SfxClassificationHelper::GetBACName(SfxClassificationPolicyType return m_pImpl->m_aCategory[eType].m_aName; } +const OUString& SfxClassificationHelper::GetAbbreviatedBACName(SfxClassificationPolicyType eType) +{ + return m_pImpl->m_aCategory[eType].m_aAbbreviatedName; +} + bool SfxClassificationHelper::HasImpactLevel() { auto itCategory = m_pImpl->m_aCategory.find(SfxClassificationPolicyType::IntellectualProperty); @@ -754,6 +763,19 @@ std::vector SfxClassificationHelper::GetBACNames() return aRet; } +std::vector SfxClassificationHelper::GetAbbreviatedBACNames() +{ + if (m_pImpl->m_aCategories.empty()) + m_pImpl->parsePolicy(); + + std::vector aRet; + std::transform(m_pImpl->m_aCategories.begin(), m_pImpl->m_aCategories.end(), std::back_inserter(aRet), [](const SfxClassificationCategory& rCategory) + { + return rCategory.m_aAbbreviatedName; + }); + return aRet; +} + void SfxClassificationHelper::SetBACName(const OUString& rName, SfxClassificationPolicyType eType) { if (m_pImpl->m_aCategories.empty()) diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx index 45e83af10ae7..c0d0e0691a6c 100644 --- a/svx/source/dialog/ClassificationDialog.cxx +++ b/svx/source/dialog/ClassificationDialog.cxx @@ -178,7 +178,7 @@ std::vector ClassificationDialog::getResult() IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) { - sal_Int32 nSelected = rBox.GetSelectedEntryPos(); + const sal_Int32 nSelected = rBox.GetSelectedEntryPos(); if (nSelected >= 0) { std::unique_ptr pEditText(m_pEditWindow->pEdEngine->CreateTextObject()); @@ -198,7 +198,7 @@ IMPL_LINK(ClassificationDialog, SelectClassificationHdl, ListBox&, rBox, void) } } - OUString aString = maHelper.GetBACNames()[nSelected]; + const OUString aString = maHelper.GetAbbreviatedBACNames()[nSelected]; insertField(ClassificationType::CATEGORY, aString); m_pInternationalClassificationListBox->SelectEntryPos(nSelected); @@ -228,7 +228,7 @@ IMPL_LINK(ClassificationDialog, SelectMarkingHdl, ListBox&, rBox, void) } } - OUString aString = maHelper.GetMarkings()[nSelected]; + const OUString aString = maHelper.GetMarkings()[nSelected]; insertField(ClassificationType::MARKING, aString); } }