include/svx/samecontentlistbox.hxx | 4 - include/svx/spacinglistbox.hxx | 2 svx/source/dialog/samecontentlistbox.cxx | 13 +++ svx/source/dialog/spacinglistbox.cxx | 46 +++++++++++ sw/source/uibase/sidebar/PageFooterPanel.cxx | 107 ++++++++++++++------------- sw/source/uibase/sidebar/PageFooterPanel.hxx | 19 ++-- sw/uiconfig/swriter/ui/pagefooterpanel.ui | 6 - 7 files changed, 133 insertions(+), 64 deletions(-)
New commits: commit 0a2b871ccdc5a76f793982bae45cb251c71e4b94 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Dec 19 13:41:16 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Dec 19 22:08:44 2019 +0100 weld PageFooterPanel Change-Id: Ice9e7c5ab9c1085021ebb3561cfb2bd0a6727066 Reviewed-on: https://gerrit.libreoffice.org/85526 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/svx/samecontentlistbox.hxx b/include/svx/samecontentlistbox.hxx index 842063125d2e..73946e2a3f35 100644 --- a/include/svx/samecontentlistbox.hxx +++ b/include/svx/samecontentlistbox.hxx @@ -22,14 +22,16 @@ #include <svx/svxdllapi.h> #include <vcl/lstbox.hxx> +#include <vcl/weld.hxx> /// Custom Widget ListBox to hold entries for SameContent setting of Header/Footer class SVX_DLLPUBLIC SameContentListBox final : public ListBox { public: SameContentListBox( vcl::Window* pParent ); + static void Fill(weld::ComboBox& rComboBox); Size GetOptimalSize() const override; }; #endif -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/spacinglistbox.hxx b/include/svx/spacinglistbox.hxx index 91e7fa18d777..df8b8c043e19 100644 --- a/include/svx/spacinglistbox.hxx +++ b/include/svx/spacinglistbox.hxx @@ -22,6 +22,7 @@ #include <svx/svxdllapi.h> #include <vcl/lstbox.hxx> +#include <vcl/weld.hxx> enum class SpacingType { SPACING_INCH, MARGINS_INCH, SPACING_CM, MARGINS_CM }; @@ -31,6 +32,7 @@ class SVX_DLLPUBLIC SpacingListBox final : public ListBox public: SpacingListBox( vcl::Window* pParent ); void Init(SpacingType eType); + static void Fill(SpacingType eType, weld::ComboBox&); Size GetOptimalSize() const override; }; diff --git a/svx/source/dialog/samecontentlistbox.cxx b/svx/source/dialog/samecontentlistbox.cxx index 29e72df42e73..e1bd38c05669 100644 --- a/svx/source/dialog/samecontentlistbox.cxx +++ b/svx/source/dialog/samecontentlistbox.cxx @@ -36,6 +36,19 @@ SameContentListBox::SameContentListBox(vcl::Window* pParent) SelectEntryPos(0); } +void SameContentListBox::Fill(weld::ComboBox& rComboBox) +{ + rComboBox.clear(); + for (size_t i = 0; i < SAL_N_ELEMENTS(RID_SVXSTRARY_SAMECONTENT); ++i) + { + OUString aStr = SvxResId(RID_SVXSTRARY_SAMECONTENT[i].first); + sal_uInt32 nData = RID_SVXSTRARY_SAMECONTENT[i].second; + rComboBox.append(OUString::number(nData), aStr); + } + rComboBox.set_active(0); + rComboBox.set_size_request(150, -1); +} + VCL_BUILDER_FACTORY(SameContentListBox); Size SameContentListBox::GetOptimalSize() const diff --git a/svx/source/dialog/spacinglistbox.cxx b/svx/source/dialog/spacinglistbox.cxx index 90654618f994..ac31393b3a2f 100644 --- a/svx/source/dialog/spacinglistbox.cxx +++ b/svx/source/dialog/spacinglistbox.cxx @@ -78,6 +78,52 @@ void SpacingListBox::Init(SpacingType eType) SelectEntryPos(nSelected); } +void SpacingListBox::Fill(SpacingType eType, weld::ComboBox& rComboBox) +{ + auto nSelected = rComboBox.get_active(); + if (nSelected == -1) + nSelected = 0; + rComboBox.clear(); + + const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); + OUString sSuffix; + + const measurement* pResources; + switch (eType) + { + case SpacingType::SPACING_INCH: + pResources = RID_SVXSTRARY_SPACING_INCH; + sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); + break; + case SpacingType::MARGINS_INCH: + pResources = RID_SVXSTRARY_MARGINS_INCH; + sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); + break; + case SpacingType::SPACING_CM: + pResources = RID_SVXSTRARY_SPACING_CM; + sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); + break; + default: + case SpacingType::MARGINS_CM: + sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); + pResources = RID_SVXSTRARY_MARGINS_CM; + break; + } + + while (pResources->key) + { + OUString sMeasurement = rLocaleData.getNum(pResources->human, 2, true, false) + sSuffix; + OUString aStr = SvxResId(pResources->key).replaceFirst("%1", sMeasurement); + sal_uInt32 nData = pResources->twips; + rComboBox.append(OUString::number(nData), aStr); + ++pResources; + } + + rComboBox.set_active(nSelected); + + rComboBox.set_size_request(150, -1); +} + VCL_BUILDER_FACTORY(SpacingListBox); Size SpacingListBox::GetOptimalSize() const diff --git a/sw/source/uibase/sidebar/PageFooterPanel.cxx b/sw/source/uibase/sidebar/PageFooterPanel.cxx index 4cc0c62d0624..a08e527d158e 100644 --- a/sw/source/uibase/sidebar/PageFooterPanel.cxx +++ b/sw/source/uibase/sidebar/PageFooterPanel.cxx @@ -54,15 +54,15 @@ VclPtr<vcl::Window> PageFooterPanel::Create( void PageFooterPanel::SetMarginsAndSpacingFieldUnit() { - mpFooterSpacingLB->Init(IsInch(meFUnit) ? SpacingType::SPACING_INCH : SpacingType::SPACING_CM); - mpFooterMarginPresetLB->Init(IsInch(meFUnit) ? SpacingType::MARGINS_INCH : SpacingType::MARGINS_CM); + SpacingListBox::Fill(IsInch(meFUnit) ? SpacingType::SPACING_INCH : SpacingType::SPACING_CM, *mxFooterSpacingLB); + SpacingListBox::Fill(IsInch(meFUnit) ? SpacingType::MARGINS_INCH : SpacingType::MARGINS_CM, *mxFooterMarginPresetLB); } PageFooterPanel::PageFooterPanel( vcl::Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, SfxBindings* pBindings) : - PanelLayout(pParent, "PageFooterPanel", "modules/swriter/ui/pagefooterpanel.ui", rxFrame), + PanelLayout(pParent, "PageFooterPanel", "modules/swriter/ui/pagefooterpanel.ui", rxFrame, true), mpBindings( pBindings ), maHFToggleController(SID_ATTR_PAGE_FOOTER, *pBindings, *this), maMetricController(SID_ATTR_METRIC, *pBindings,*this), @@ -74,14 +74,13 @@ PageFooterPanel::PageFooterPanel( mpFooterItem( new SfxBoolItem(SID_ATTR_PAGE_FOOTER) ), mpFooterLRMarginItem( new SvxLongLRSpaceItem(0, 0, SID_ATTR_PAGE_FOOTER_LRMARGIN)), mpFooterSpacingItem( new SvxLongULSpaceItem(0, 0, SID_ATTR_PAGE_FOOTER_SPACING)), - mpFooterLayoutItem( new SfxInt16Item(SID_ATTR_PAGE_FOOTER_LAYOUT)) + mpFooterLayoutItem( new SfxInt16Item(SID_ATTR_PAGE_FOOTER_LAYOUT)), + mxFooterToggle(m_xBuilder->weld_check_button("footertoggle")), + mxFooterSpacingLB(m_xBuilder->weld_combo_box("spacingpreset")), + mxFooterMarginPresetLB(m_xBuilder->weld_combo_box("footermarginpreset")), + mxFooterLayoutLB(m_xBuilder->weld_combo_box("samecontentLB")), + mxCustomEntry(m_xBuilder->weld_label("customlabel")) { - get(mpFooterToggle, "footertoggle"); - get(mpFooterSpacingLB, "spacingpreset"); - get(mpFooterLayoutLB, "samecontentLB"); - get(mpFooterMarginPresetLB, "footermarginpreset"); - get(mpCustomEntry, "customlabel"); - Initialize(); } @@ -92,12 +91,12 @@ PageFooterPanel::~PageFooterPanel() void PageFooterPanel::dispose() { - mpFooterToggle.disposeAndClear(); + mxFooterToggle.reset(); maMetricController.dispose(); - mpFooterSpacingLB.disposeAndClear(); - mpFooterLayoutLB.disposeAndClear(); - mpFooterMarginPresetLB.disposeAndClear(); - mpCustomEntry.clear(); + mxFooterSpacingLB.reset(); + mxFooterLayoutLB.reset(); + mxFooterMarginPresetLB.reset(); + mxCustomEntry.reset(); PanelLayout::dispose(); } @@ -116,13 +115,15 @@ FieldUnit PageFooterPanel::GetCurrentUnit(SfxItemState eState, const SfxPoolItem void PageFooterPanel::Initialize() { + SameContentListBox::Fill(*mxFooterLayoutLB); + SetMarginsAndSpacingFieldUnit(); - aCustomEntry = mpCustomEntry->GetText(); - mpFooterToggle->SetClickHdl( LINK(this, PageFooterPanel, FooterToggleHdl) ); - mpFooterMarginPresetLB->SetSelectHdl( LINK(this, PageFooterPanel, FooterLRMarginHdl)); - mpFooterSpacingLB->SetSelectHdl( LINK(this, PageFooterPanel, FooterSpacingHdl)); - mpFooterLayoutLB->SetSelectHdl( LINK(this, PageFooterPanel, FooterLayoutHdl)); + aCustomEntry = mxCustomEntry->get_label(); + mxFooterToggle->connect_toggled( LINK(this, PageFooterPanel, FooterToggleHdl) ); + mxFooterMarginPresetLB->connect_changed( LINK(this, PageFooterPanel, FooterLRMarginHdl)); + mxFooterSpacingLB->connect_changed( LINK(this, PageFooterPanel, FooterSpacingHdl)); + mxFooterLayoutLB->connect_changed( LINK(this, PageFooterPanel, FooterLayoutHdl)); mpBindings->Invalidate(SID_ATTR_METRIC); mpBindings->Invalidate(SID_ATTR_PAGE_FOOTER); @@ -133,17 +134,17 @@ void PageFooterPanel::Initialize() void PageFooterPanel::UpdateFooterCheck() { - if(mpFooterToggle->IsChecked()) + if (mxFooterToggle->get_active()) { - mpFooterSpacingLB->Enable(); - mpFooterLayoutLB->Enable(); - mpFooterMarginPresetLB->Enable(); + mxFooterSpacingLB->set_sensitive(true); + mxFooterLayoutLB->set_sensitive(true); + mxFooterMarginPresetLB->set_sensitive(true); } else { - mpFooterSpacingLB->Disable(); - mpFooterLayoutLB->Disable(); - mpFooterMarginPresetLB->Disable(); + mxFooterSpacingLB->set_sensitive(false); + mxFooterLayoutLB->set_sensitive(false); + mxFooterMarginPresetLB->set_sensitive(false); } } @@ -151,44 +152,48 @@ void PageFooterPanel::UpdateMarginControl() { sal_uInt16 nLeft = mpFooterLRMarginItem->GetLeft(); sal_uInt16 nRight = mpFooterLRMarginItem->GetRight(); - sal_uInt16 nCount = mpFooterMarginPresetLB->GetEntryCount(); + sal_uInt16 nCount = mxFooterMarginPresetLB->get_count(); if(nLeft == nRight) { - for(sal_uInt16 i = 0; i < nCount; i++) + for (sal_uInt16 i = 0; i < nCount; ++i) { - if(reinterpret_cast<sal_uLong>(mpFooterMarginPresetLB->GetEntryData(i)) == nLeft ) + if (mxFooterMarginPresetLB->get_id(i).toUInt32() == nLeft) { - mpFooterMarginPresetLB->SelectEntryPos(i); - mpFooterMarginPresetLB->RemoveEntry(aCustomEntry); + mxFooterMarginPresetLB->set_active(i); + int nCustomEntry = mxFooterMarginPresetLB->find_text(aCustomEntry); + if (nCustomEntry != -1) + mxFooterMarginPresetLB->remove(nCustomEntry); return; } } } - mpFooterMarginPresetLB->InsertEntry(aCustomEntry); - mpFooterMarginPresetLB->SelectEntry(aCustomEntry); + mxFooterMarginPresetLB->append_text(aCustomEntry); + mxFooterMarginPresetLB->set_active_text(aCustomEntry); } void PageFooterPanel::UpdateSpacingControl() { sal_uInt16 nBottom = mpFooterSpacingItem->GetUpper(); - sal_uInt16 nCount = mpFooterSpacingLB->GetEntryCount(); - for(sal_uInt16 i = 0; i < nCount; i++) + sal_uInt16 nCount = mxFooterSpacingLB->get_count(); + for (sal_uInt16 i = 0; i < nCount; ++i) { - if(reinterpret_cast<sal_uLong>(mpFooterSpacingLB->GetEntryData(i)) == nBottom ) + if (mxFooterSpacingLB->get_id(i).toUInt32() == nBottom) { - mpFooterSpacingLB->SelectEntryPos(i); - mpFooterSpacingLB->RemoveEntry(aCustomEntry); + mxFooterSpacingLB->set_active(i); + int nCustomEntry = mxFooterSpacingLB->find_text(aCustomEntry); + if (nCustomEntry != -1) + mxFooterSpacingLB->remove(nCustomEntry); return; } } - mpFooterSpacingLB->InsertEntry(aCustomEntry); - mpFooterSpacingLB->SelectEntry(aCustomEntry); + mxFooterSpacingLB->append_text(aCustomEntry); + mxFooterSpacingLB->set_active_text(aCustomEntry); } void PageFooterPanel::UpdateLayoutControl() { sal_uInt16 nLayout = mpFooterLayoutItem->GetValue(); - mpFooterLayoutLB->SelectEntryPos( nLayout ); + mxFooterLayoutLB->set_active(nLayout); } void PageFooterPanel::NotifyItemUpdate( @@ -207,7 +212,7 @@ void PageFooterPanel::NotifyItemUpdate( dynamic_cast<const SfxBoolItem*>( pState) ) { mpFooterItem.reset( static_cast<SfxBoolItem*>(pState->Clone()) ); - mpFooterToggle->Check(mpFooterItem->GetValue()); + mxFooterToggle->set_active(mpFooterItem->GetValue()); UpdateFooterCheck(); } } @@ -259,34 +264,34 @@ void PageFooterPanel::NotifyItemUpdate( } } -IMPL_LINK_NOARG( PageFooterPanel, FooterToggleHdl, Button*, void ) +IMPL_LINK_NOARG( PageFooterPanel, FooterToggleHdl, weld::ToggleButton&, void ) { - bool IsChecked = mpFooterToggle->IsChecked(); + bool IsChecked = mxFooterToggle->get_active(); mpFooterItem->SetValue(IsChecked); GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_FOOTER, SfxCallMode::RECORD, { mpFooterItem.get() } ); UpdateFooterCheck(); } -IMPL_LINK_NOARG( PageFooterPanel, FooterLRMarginHdl, ListBox&, void ) +IMPL_LINK_NOARG( PageFooterPanel, FooterLRMarginHdl, weld::ComboBox&, void ) { - sal_uInt16 nVal = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(mpFooterMarginPresetLB->GetSelectedEntryData())); + sal_uInt16 nVal = mxFooterMarginPresetLB->get_active_id().toUInt32(); mpFooterLRMarginItem->SetLeft(nVal); mpFooterLRMarginItem->SetRight(nVal); GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_FOOTER_LRMARGIN, SfxCallMode::RECORD, { mpFooterLRMarginItem.get() } ); } -IMPL_LINK_NOARG( PageFooterPanel, FooterSpacingHdl, ListBox&, void ) +IMPL_LINK_NOARG( PageFooterPanel, FooterSpacingHdl, weld::ComboBox&, void ) { - sal_uInt16 nVal = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(mpFooterSpacingLB->GetSelectedEntryData())); + sal_uInt16 nVal = mxFooterSpacingLB->get_active_id().toUInt32(); mpFooterSpacingItem->SetUpper(nVal); GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_FOOTER_SPACING, SfxCallMode::RECORD, { mpFooterSpacingItem.get() } ); } -IMPL_LINK_NOARG( PageFooterPanel, FooterLayoutHdl, ListBox&, void ) +IMPL_LINK_NOARG( PageFooterPanel, FooterLayoutHdl, weld::ComboBox&, void ) { - sal_uInt16 nVal = mpFooterLayoutLB->GetSelectedEntryPos(); + sal_uInt16 nVal = mxFooterLayoutLB->get_active(); mpFooterLayoutItem->SetValue(nVal); GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_PAGE_FOOTER_LAYOUT, SfxCallMode::RECORD, { mpFooterLayoutItem.get() } ); diff --git a/sw/source/uibase/sidebar/PageFooterPanel.hxx b/sw/source/uibase/sidebar/PageFooterPanel.hxx index d41789ecad67..00a536a38fb5 100644 --- a/sw/source/uibase/sidebar/PageFooterPanel.hxx +++ b/sw/source/uibase/sidebar/PageFooterPanel.hxx @@ -74,11 +74,6 @@ private: FieldUnit meFUnit; - VclPtr<CheckBox> mpFooterToggle; - VclPtr<SpacingListBox> mpFooterSpacingLB; - VclPtr<SpacingListBox> mpFooterMarginPresetLB; - VclPtr<SameContentListBox> mpFooterLayoutLB; - VclPtr<FixedText> mpCustomEntry; OUString aCustomEntry; void Initialize(); @@ -93,12 +88,18 @@ private: ::std::unique_ptr<SvxLongULSpaceItem> mpFooterSpacingItem; ::std::unique_ptr<SfxInt16Item> mpFooterLayoutItem; + std::unique_ptr<weld::CheckButton> mxFooterToggle; + std::unique_ptr<weld::ComboBox> mxFooterSpacingLB; + std::unique_ptr<weld::ComboBox> mxFooterMarginPresetLB; + std::unique_ptr<weld::ComboBox> mxFooterLayoutLB; + std::unique_ptr<weld::Label> mxCustomEntry; + static FieldUnit GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState); - DECL_LINK( FooterToggleHdl, Button*, void ); - DECL_LINK( FooterLRMarginHdl, ListBox&, void); - DECL_LINK( FooterSpacingHdl, ListBox&, void); - DECL_LINK( FooterLayoutHdl, ListBox&, void); + DECL_LINK( FooterToggleHdl, weld::ToggleButton&, void ); + DECL_LINK( FooterLRMarginHdl, weld::ComboBox&, void); + DECL_LINK( FooterSpacingHdl, weld::ComboBox&, void); + DECL_LINK( FooterLayoutHdl, weld::ComboBox&, void); }; } } //end of namespace sw::sidebar diff --git a/sw/uiconfig/swriter/ui/pagefooterpanel.ui b/sw/uiconfig/swriter/ui/pagefooterpanel.ui index a0b872b499fb..2df5d8d831fd 100644 --- a/sw/uiconfig/swriter/ui/pagefooterpanel.ui +++ b/sw/uiconfig/swriter/ui/pagefooterpanel.ui @@ -98,7 +98,7 @@ </packing> </child> <child> - <object class="svxcorelo-SpacingListBox" id="footermarginpreset"> + <object class="GtkComboBoxText" id="footermarginpreset"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> @@ -109,7 +109,7 @@ </packing> </child> <child> - <object class="svxcorelo-SpacingListBox" id="spacingpreset"> + <object class="GtkComboBoxText" id="spacingpreset"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> @@ -120,7 +120,7 @@ </packing> </child> <child> - <object class="svxcorelo-SameContentListBox" id="samecontentLB"> + <object class="GtkComboBoxText" id="samecontentLB"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits