summaryrefslogtreecommitdiff
path: root/sfx2/source/view/classificationcontroller.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-05-19 20:15:53 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-05-20 07:04:08 +0000
commitcb69665923c819b9ab53ed7a634b3b698bdc7ea0 (patch)
tree2376737d386002615c25dee9d458bcf23eb11396 /sfx2/source/view/classificationcontroller.cxx
parent7b704dfbdb23540ff6366fa60c73474bbda9dc26 (diff)
sfx2 classification toolbar: add select handler to all listboxes
And also fill them up. With this, it's possible to set all policy types in a document. UI still reacts to the first listbox only, but File -> Properties shows that the other types are also set correctly. Change-Id: Ibf41ad7ea54819a4d149bce8e5f4d72b02f8d635 Reviewed-on: https://gerrit.libreoffice.org/25176 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sfx2/source/view/classificationcontroller.cxx')
-rw-r--r--sfx2/source/view/classificationcontroller.cxx49
1 files changed, 41 insertions, 8 deletions
diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx
index 6ac651c6d6f3..5b8ca213c149 100644
--- a/sfx2/source/view/classificationcontroller.cxx
+++ b/sfx2/source/view/classificationcontroller.cxx
@@ -95,6 +95,8 @@ public:
virtual void dispose() override;
virtual void Resize() override;
VclPtr<ListBox> getCategories(SfxClassificationPolicyType eType);
+ std::size_t getLabelsSize();
+ OUString getCategoryType(ListBox& rCategory);
};
ClassificationPropertyListener::ClassificationPropertyListener(const rtl::Reference<comphelper::ConfigurationListener>& xListener, ClassificationCategoriesController& rController)
@@ -158,7 +160,11 @@ uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindo
if (pToolbar)
{
m_pClassification = VclPtr<ClassificationControl>::Create(pToolbar);
- m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty)->SetSelectHdl(LINK(this, ClassificationCategoriesController, SelectHdl));
+ for (size_t i = m_pClassification->getLabelsSize(); i > 0; --i)
+ {
+ auto eType = static_cast<SfxClassificationPolicyType>(i);
+ m_pClassification->getCategories(eType)->SetSelectHdl(LINK(this, ClassificationCategoriesController, SelectHdl));
+ }
}
return uno::Reference<awt::XWindow>(VCLUnoHelper::GetInterface(m_pClassification));
@@ -167,9 +173,12 @@ uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindo
IMPL_LINK_TYPED(ClassificationCategoriesController, SelectHdl, ListBox&, rCategory, void)
{
OUString aEntry = rCategory.GetSelectEntry();
+
+ OUString aType = m_pClassification->getCategoryType(rCategory);
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"Name", uno::makeAny(aEntry)},
+ {"Type", uno::makeAny(aType)},
}));
comphelper::dispatchCommand(".uno:ClassificationApply", aPropertyValues);
}
@@ -184,17 +193,22 @@ void ClassificationCategoriesController::statusChanged(const frame::FeatureState
return;
SfxClassificationHelper aHelper(pObjectShell->getDocProperties());
- VclPtr<ListBox> pCategories = m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty);
- if (pCategories->GetEntryCount() == 0)
+ for (size_t i = m_pClassification->getLabelsSize(); i > 0; --i)
{
- std::vector<OUString> aNames = aHelper.GetBACNames();
- for (const OUString& rName : aNames)
- pCategories->InsertEntry(rName);
- // Normally VclBuilder::makeObject() does this.
- pCategories->EnableAutoSize(true);
+ auto eType = static_cast<SfxClassificationPolicyType>(i);
+ VclPtr<ListBox> pCategories = m_pClassification->getCategories(eType);
+ if (pCategories->GetEntryCount() == 0)
+ {
+ std::vector<OUString> aNames = aHelper.GetBACNames();
+ for (const OUString& rName : aNames)
+ pCategories->InsertEntry(rName);
+ // Normally VclBuilder::makeObject() does this.
+ pCategories->EnableAutoSize(true);
+ }
}
// 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);
@@ -289,6 +303,25 @@ VclPtr<ListBox> ClassificationControl::getCategories(SfxClassificationPolicyType
return m_pCategories[eType];
}
+std::size_t ClassificationControl::getLabelsSize()
+{
+ return m_pLabels.size();
+}
+
+OUString ClassificationControl::getCategoryType(ListBox& rCategory)
+{
+ OUString aRet;
+
+ auto it = std::find_if(m_pCategories.begin(), m_pCategories.end(), [&rCategory](const std::pair<SfxClassificationPolicyType, VclPtr<ListBox>>& rPair)
+ {
+ return rPair.second.get() == &rCategory;
+ });
+ if (it != m_pCategories.end())
+ aRet = SfxClassificationHelper::policyTypeToString(it->first);
+
+ return aRet;
+}
+
void ClassificationControl::SetOptimalSize()
{
// Same as SvxColorDockingWindow.