include/sfx2/classificationhelper.hxx | 6 - include/sfx2/sfx.hrc | 2 sfx2/source/view/classificationcontroller.cxx | 118 ++++++++++++++++---------- sfx2/source/view/view.src | 11 ++ 4 files changed, 91 insertions(+), 46 deletions(-)
New commits: commit 16a8a52c84b8fd0c062fe8915838e2fbcd730cdf Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 19 17:26:57 2016 +0200 sfx2 classification toolbar: add listboxes for all policy types Previously only a single listbox was shown, but SfxClassificationPolicyType has 3 elements. Change-Id: Id51b73467ff4e85a1cef3e1aa71f636ae7c7afb9 Reviewed-on: https://gerrit.libreoffice.org/25161 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx index 6497d08..cc7a66f 100644 --- a/include/sfx2/classificationhelper.hxx +++ b/include/sfx2/classificationhelper.hxx @@ -36,9 +36,9 @@ enum class SfxClassificationCheckPasteResult /// Specifies a policy type, to be used with SetBACName(). Getters always use IntellectualProperty for now. enum class SfxClassificationPolicyType { - ExportControl, - NationalSecurity, - IntellectualProperty + ExportControl = 1, + NationalSecurity = 2, + IntellectualProperty = 3 }; /// Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties. diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc index 9309cd3..0c0921d 100644 --- a/include/sfx2/sfx.hrc +++ b/include/sfx2/sfx.hrc @@ -157,6 +157,8 @@ #define STR_TARGET_DOC_NOT_CLASSIFIED (RID_SFX_START+132) #define STR_DOC_CLASSIFICATION_TOO_LOW (RID_SFX_START+133) #define STR_CLASSIFIED_INTELLECTUAL_PROPERTY (RID_SFX_START+134) +#define STR_CLASSIFIED_NATIONAL_SECURITY (RID_SFX_START+135) +#define STR_CLASSIFIED_EXPORT_CONTROL (RID_SFX_START+136) #define STR_ACCTITLE_PRODUCTIVITYTOOLS (RID_SFX_START+157) #define SFX_THUMBNAIL_TEXT (RID_SFX_START+158) diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx index b1f8310..6ac651c 100644 --- a/sfx2/source/view/classificationcontroller.cxx +++ b/sfx2/source/view/classificationcontroller.cxx @@ -84,8 +84,8 @@ public: /// Classification control is the parent of all widgets that belongs to ClassificationCategoriesController. class SAL_WARN_UNUSED ClassificationControl : public vcl::Window { - VclPtr<FixedText> m_pLabel; - VclPtr<ListBox> m_pCategories; + std::map<SfxClassificationPolicyType, VclPtr<FixedText>> m_pLabels; + std::map<SfxClassificationPolicyType, VclPtr<ListBox>> m_pCategories; void SetOptimalSize(); virtual void DataChanged(const DataChangedEvent& rEvent) override; @@ -94,7 +94,7 @@ public: virtual ~ClassificationControl(); virtual void dispose() override; virtual void Resize() override; - VclPtr<ListBox> getCategories(); + VclPtr<ListBox> getCategories(SfxClassificationPolicyType eType); }; ClassificationPropertyListener::ClassificationPropertyListener(const rtl::Reference<comphelper::ConfigurationListener>& xListener, ClassificationCategoriesController& rController) @@ -158,15 +158,15 @@ uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindo if (pToolbar) { m_pClassification = VclPtr<ClassificationControl>::Create(pToolbar); - m_pClassification->getCategories()->SetSelectHdl(LINK(this, ClassificationCategoriesController, SelectHdl)); + m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty)->SetSelectHdl(LINK(this, ClassificationCategoriesController, SelectHdl)); } return uno::Reference<awt::XWindow>(VCLUnoHelper::GetInterface(m_pClassification)); } -IMPL_LINK_NOARG_TYPED(ClassificationCategoriesController, SelectHdl, ListBox&, void) +IMPL_LINK_TYPED(ClassificationCategoriesController, SelectHdl, ListBox&, rCategory, void) { - OUString aEntry = m_pClassification->getCategories()->GetSelectEntry(); + OUString aEntry = rCategory.GetSelectEntry(); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"Name", uno::makeAny(aEntry)}, @@ -184,43 +184,63 @@ void ClassificationCategoriesController::statusChanged(const frame::FeatureState return; SfxClassificationHelper aHelper(pObjectShell->getDocProperties()); - if (m_pClassification->getCategories()->GetEntryCount() == 0) + VclPtr<ListBox> pCategories = m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty); + if (pCategories->GetEntryCount() == 0) { std::vector<OUString> aNames = aHelper.GetBACNames(); for (const OUString& rName : aNames) - m_pClassification->getCategories()->InsertEntry(rName); + pCategories->InsertEntry(rName); // Normally VclBuilder::makeObject() does this. - m_pClassification->getCategories()->EnableAutoSize(true); + pCategories->EnableAutoSize(true); } // Restore state based on the doc. model. const OUString& rCategoryName = aHelper.GetBACName(); if (!rCategoryName.isEmpty()) - m_pClassification->getCategories()->SelectEntry(rCategoryName); + pCategories->SelectEntry(rCategoryName); } void ClassificationCategoriesController::removeEntries() { if (m_pClassification) - m_pClassification->getCategories()->Clear(); + m_pClassification->getCategories(SfxClassificationPolicyType::IntellectualProperty)->Clear(); } ClassificationControl::ClassificationControl(vcl::Window* pParent) : Window(pParent, WB_DIALOGCONTROL) - , m_pLabel(nullptr) - , m_pCategories(nullptr) { - OUString aText = SfxResId(STR_CLASSIFIED_INTELLECTUAL_PROPERTY); - m_pLabel = VclPtr<FixedText>::Create(this); - Size aTextSize(m_pLabel->GetTextWidth(aText), m_pLabel->GetTextHeight()); - // Padding. - aTextSize.Width() += 6; - m_pLabel->SetText(aText); - m_pLabel->SetSizePixel(aTextSize); - m_pLabel->Show(); - - m_pCategories = VclPtr<ListBox>::Create(this, WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_DROPDOWN|WB_SIMPLEMODE); - m_pCategories->Show(); + m_pLabels[SfxClassificationPolicyType::IntellectualProperty] = VclPtr<FixedText>::Create(this, WB_CENTER); + m_pLabels[SfxClassificationPolicyType::NationalSecurity] = VclPtr<FixedText>::Create(this, WB_CENTER); + m_pLabels[SfxClassificationPolicyType::ExportControl] = VclPtr<FixedText>::Create(this, WB_CENTER); + for (auto& rPair : m_pLabels) + { + OUString aText; + switch (rPair.first) + { + case SfxClassificationPolicyType::IntellectualProperty: + aText = SfxResId(STR_CLASSIFIED_INTELLECTUAL_PROPERTY); + break; + case SfxClassificationPolicyType::NationalSecurity: + aText = SfxResId(STR_CLASSIFIED_NATIONAL_SECURITY); + break; + case SfxClassificationPolicyType::ExportControl: + aText = SfxResId(STR_CLASSIFIED_EXPORT_CONTROL); + break; + } + auto& pLabel = rPair.second; + Size aTextSize(pLabel->GetTextWidth(aText), pLabel->GetTextHeight()); + // Padding. + aTextSize.Width() += 12; + pLabel->SetText(aText); + pLabel->SetSizePixel(aTextSize); + pLabel->Show(); + } + + m_pCategories[SfxClassificationPolicyType::IntellectualProperty] = VclPtr<ListBox>::Create(this, WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_DROPDOWN|WB_SIMPLEMODE); + m_pCategories[SfxClassificationPolicyType::NationalSecurity] = VclPtr<ListBox>::Create(this, WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_DROPDOWN|WB_SIMPLEMODE); + m_pCategories[SfxClassificationPolicyType::ExportControl] = VclPtr<ListBox>::Create(this, WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_DROPDOWN|WB_SIMPLEMODE); + for (auto& rPair : m_pCategories) + rPair.second->Show(); SetOptimalSize(); } @@ -232,8 +252,10 @@ ClassificationControl::~ClassificationControl() void ClassificationControl::dispose() { - m_pLabel.disposeAndClear(); - m_pCategories.disposeAndClear(); + for (auto& rPair : m_pLabels) + rPair.second.disposeAndClear(); + for (auto& rPair : m_pCategories) + rPair.second.disposeAndClear(); vcl::Window::dispose(); } @@ -241,34 +263,44 @@ void ClassificationControl::Resize() { // Give the label what it wants, and the remaining size to the listbox. Size aSize(GetOutputSizePixel()); - long nWLabel = m_pLabel->GetOutputSizePixel().Width(); - long nW = aSize.Width(); - long nH = aSize.Height(); - - long nPrefHeight = m_pLabel->get_preferred_size().Height(); - long nOffset = (nH - nPrefHeight) / 2; - m_pLabel->SetPosSizePixel(Point(0, nOffset), Size(nWLabel, nPrefHeight)); - - nPrefHeight = m_pCategories->get_preferred_size().Height(); - nOffset = (nH - nPrefHeight) / 2; - m_pCategories->SetPosSizePixel(Point(nWLabel, nOffset), Size(nW - nWLabel, nPrefHeight)); + long nXPosition = 0; + for (size_t i = m_pLabels.size(); i > 0; --i) + { + auto eType = static_cast<SfxClassificationPolicyType>(i); + auto& pLabel = m_pLabels[eType]; + long nWLabel = pLabel->GetOutputSizePixel().Width(); + long nW = aSize.Width() / m_pLabels.size(); + long nH = aSize.Height(); + + long nPrefHeight = pLabel->get_preferred_size().Height(); + long nOffset = (nH - nPrefHeight) / 2; + pLabel->SetPosSizePixel(Point(nXPosition, nOffset), Size(nWLabel, nPrefHeight)); + + auto& pCategories = m_pCategories[eType]; + nPrefHeight = pCategories->get_preferred_size().Height(); + nOffset = (nH - nPrefHeight) / 2; + pCategories->SetPosSizePixel(Point(nXPosition + nWLabel, nOffset), Size(nW - nWLabel, nPrefHeight)); + nXPosition += nW; + } } -VclPtr<ListBox> ClassificationControl::getCategories() +VclPtr<ListBox> ClassificationControl::getCategories(SfxClassificationPolicyType eType) { - return m_pCategories; + return m_pCategories[eType]; } void ClassificationControl::SetOptimalSize() { // Same as SvxColorDockingWindow. - const Size aLogicalAttrSize(150, 0); + const Size aLogicalAttrSize(150 * m_pLabels.size(), 0); Size aSize(LogicToPixel(aLogicalAttrSize,MAP_APPFONT)); - Point aPosition = m_pCategories->GetPosPixel(); + auto& pLabel = m_pLabels[SfxClassificationPolicyType::IntellectualProperty]; + auto& pCategories = m_pCategories[SfxClassificationPolicyType::IntellectualProperty]; + Point aPosition = pCategories->GetPosPixel(); - aSize.Height() = std::max(aSize.Height(), m_pLabel->get_preferred_size().Height()); - aSize.Height() = std::max(aSize.Height(), m_pCategories->get_preferred_size().Height()); + aSize.Height() = std::max(aSize.Height(), pLabel->get_preferred_size().Height()); + aSize.Height() = std::max(aSize.Height(), pCategories->get_preferred_size().Height()); aSize.Width() = aPosition.X() + aSize.Width(); diff --git a/sfx2/source/view/view.src b/sfx2/source/view/view.src index 787f527..16b3e59 100644 --- a/sfx2/source/view/view.src +++ b/sfx2/source/view/view.src @@ -111,6 +111,17 @@ String STR_CLASSIFIED_INTELLECTUAL_PROPERTY Text [ en-US ] = "Intellectual Property:" ; }; +String STR_CLASSIFIED_NATIONAL_SECURITY +{ + Text [ en-US ] = "National Security:" ; +} + +; +String STR_CLASSIFIED_EXPORT_CONTROL +{ + Text [ en-US ] = "Export Control:" ; +}; + PushButton BT_CHECKOUT { Pos = MAP_APPFONT( 0 , 0 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits