[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Miklos Vajna vmiklos at collabora.co.uk
Fri May 20 08:49:55 UTC 2016


 include/sfx2/classificationhelper.hxx         |    3 ++-
 sfx2/source/view/classificationcontroller.cxx |   23 ++++++++++++++++++-----
 sfx2/source/view/classificationhelper.cxx     |    6 +++---
 3 files changed, 23 insertions(+), 9 deletions(-)

New commits:
commit 5840c2787c61bcbb5401d2aa0fc9e163e303f76c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri May 20 09:37:21 2016 +0200

    sfx2 classification toolbar: set state of all listboxes on status change
    
    With this the listboxes reflect the state of the document after load.
    This also means that the only difference between the first listbox and
    the remaining ones is the first one influences the UI as well, but
    everything else is implemented.
    
    Change-Id: Ibea0e2fbc431f7327342fd8c2a1d31c34b73d6a8
    Reviewed-on: https://gerrit.libreoffice.org/25188
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index 8d7b0b1..18dd351 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -58,7 +58,8 @@ public:
 
     SfxClassificationHelper(const css::uno::Reference<css::document::XDocumentProperties>& 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<OUString> 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 5b8ca21..7abcdf6 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<ListBox> 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<SfxClassificationPolicyType>(i);
+        const OUString& rCategoryName = aHelper.GetBACName(eType);
+        if (!rCategoryName.isEmpty())
+        {
+            VclPtr<ListBox> 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<SfxClassificationPolicyType>(i);
+            VclPtr<ListBox> 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 eebe37c..0c93e93 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)
     {


More information about the Libreoffice-commits mailing list