diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx index 8d7b0b1688d2..18dd3515b665 100644 --- a/include/sfx2/classificationhelper.hxx +++ b/include/sfx2/classificationhelper.hxx @@ -58,7 +58,8 @@ public: SfxClassificationHelper(const css::uno::Reference& xDocumentProperties); ~SfxClassificationHelper(); - const OUString& GetBACName(); + /// Get the currently selected category for eType. + const OUString& GetBACName(SfxClassificationPolicyType eType); /// Return all possible valid category names, based on the policy. std::vector GetBACNames(); /// Setting this sets all the other properties, based on the policy. diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx index 5b8ca213c149..7abcdf650bde 100644 --- a/sfx2/source/view/classificationcontroller.cxx +++ b/sfx2/source/view/classificationcontroller.cxx @@ -208,16 +208,29 @@ void ClassificationCategoriesController::statusChanged(const frame::FeatureState } // Restore state based on the doc. model. - VclPtr pCategories = m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty); - const OUString& rCategoryName = aHelper.GetBACName(); - if (!rCategoryName.isEmpty()) - pCategories->SelectEntry(rCategoryName); + for (size_t i = m_pClassification->getLabelsSize(); i > 0; --i) + { + auto eType = static_cast(i); + const OUString& rCategoryName = aHelper.GetBACName(eType); + if (!rCategoryName.isEmpty()) + { + VclPtr pCategories = m_pClassification->getCategories(eType); + pCategories->SelectEntry(rCategoryName); + } + } } void ClassificationCategoriesController::removeEntries() { if (m_pClassification) - m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty)->Clear(); + { + for (size_t i = m_pClassification->getLabelsSize(); i > 0; --i) + { + auto eType = static_cast(i); + VclPtr pCategories = m_pClassification->getCategories(eType); + pCategories->Clear(); + } + } } ClassificationControl::ClassificationControl(vcl::Window* pParent) diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index eebe37c452fa..0c93e93dd636 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -542,9 +542,9 @@ SfxClassificationHelper::~SfxClassificationHelper() { } -const OUString& SfxClassificationHelper::GetBACName() +const OUString& SfxClassificationHelper::GetBACName(SfxClassificationPolicyType eType) { - return m_pImpl->m_aCategory[SfxClassificationPolicyType::IntellectualProperty].m_aName; + return m_pImpl->m_aCategory[eType].m_aName; } bool SfxClassificationHelper::HasImpactLevel() @@ -765,7 +765,7 @@ void SfxClassificationHelper::SetBACName(const OUString& rName, SfxClassificatio void SfxClassificationHelper::UpdateInfobar(SfxViewFrame& rViewFrame) { - OUString aBACName = GetBACName(); + OUString aBACName = GetBACName(SfxClassificationPolicyType::IntellectualProperty); bool bImpactLevel = HasImpactLevel(); if (!aBACName.isEmpty() && bImpactLevel) {