From 3739a08653fbdb2c9268f7386dfccfad052aca82 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 4 Feb 2021 14:07:21 +0100 Subject: tdf#91920 sw page gutter margin: add UI Also update the preview widget and hide the new UI in Calc/Impress. (cherry picked from commit e1d7242341ec148b631a96e6d63697bce6a497c9) Change-Id: Ic5c0ba100f6e886651d83c04961e9f0566a4202c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110638 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna --- cui/source/inc/page.hxx | 2 ++ cui/source/tabpages/page.cxx | 24 +++++++++++++++++++++++- cui/uiconfig/ui/pageformatpage.ui | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx index 1019a9fbc214..a2d2dcf5dda4 100644 --- a/cui/source/inc/page.hxx +++ b/cui/source/inc/page.hxx @@ -106,6 +106,8 @@ private: std::unique_ptr m_xRightMarginEdit; std::unique_ptr m_xTopMarginEdit; std::unique_ptr m_xBottomMarginEdit; + std::unique_ptr m_xGutterMarginLbl; + std::unique_ptr m_xGutterMarginEdit; // layout settings std::unique_ptr m_xPageText; std::unique_ptr m_xLayoutBox; diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 508984bf882b..7a46f0fa2ae5 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -162,6 +162,8 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* , m_xRightMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargRight", FieldUnit::CM)) , m_xTopMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargTop", FieldUnit::CM)) , m_xBottomMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargBot", FieldUnit::CM)) + , m_xGutterMarginLbl(m_xBuilder->weld_label("labelGutterMargin")) + , m_xGutterMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargGut", FieldUnit::CM)) , m_xPageText(m_xBuilder->weld_label("labelPageLayout")) , m_xLayoutBox(m_xBuilder->weld_combo_box("comboPageLayout")) , m_xNumberFormatText(m_xBuilder->weld_label("labelPageNumbers")) @@ -231,6 +233,7 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* SetFieldUnit( *m_xRightMarginEdit, eFUnit ); SetFieldUnit( *m_xTopMarginEdit, eFUnit ); SetFieldUnit( *m_xBottomMarginEdit, eFUnit ); + SetFieldUnit(*m_xGutterMarginEdit, eFUnit); SetFieldUnit( *m_xPaperWidthEdit, eFUnit ); SetFieldUnit( *m_xPaperHeightEdit, eFUnit ); @@ -281,6 +284,9 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperRightMargin()), FieldUnit::MM); m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperTopMargin()), FieldUnit::MM); m_xBottomMarginEdit->set_max(m_xBottomMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperBottomMargin()), FieldUnit::MM); + m_xGutterMarginEdit->set_max( + m_xGutterMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperLeftMargin()), + FieldUnit::MM); // Get the i18n framework numberings and add them to the listbox. SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xNumberFormatBox->get_widget(), std::numeric_limits::max()); @@ -311,6 +317,7 @@ void SvxPageDescPage::Init_Impl() m_xRightMarginEdit->connect_value_changed(aLink); m_xTopMarginEdit->connect_value_changed(aLink); m_xBottomMarginEdit->connect_value_changed(aLink); + m_xGutterMarginEdit->connect_value_changed(aLink); m_xHorzBox->connect_toggled(LINK(this, SvxPageDescPage, CenterHdl_Impl)); m_xVertBox->connect_toggled(LINK(this, SvxPageDescPage, CenterHdl_Impl)); @@ -329,6 +336,7 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) { const SvxLRSpaceItem& rLRSpace = static_cast(*pItem); SetMetricValue( *m_xLeftMarginEdit, rLRSpace.GetLeft(), eUnit ); + SetMetricValue(*m_xGutterMarginEdit, rLRSpace.GetGutterMargin(), eUnit); m_aBspWin.SetLeft( static_cast(ConvertLong_Impl( rLRSpace.GetLeft(), eUnit )) ); SetMetricValue( *m_xRightMarginEdit, rLRSpace.GetRight(), eUnit ); @@ -478,6 +486,9 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) m_aBspWin.SetHorz(m_xHorzBox->get_active()); m_aBspWin.SetVert(m_xVertBox->get_active()); + m_xGutterMarginLbl->hide(); + m_xGutterMarginEdit->hide(); + break; } @@ -493,6 +504,9 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) m_xLayoutBox->hide(); m_xPageText->hide(); + m_xGutterMarginLbl->hide(); + m_xGutterMarginEdit->hide(); + break; } default: ;//prevent warning @@ -514,6 +528,7 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) m_xRightMarginEdit->save_value(); m_xTopMarginEdit->save_value(); m_xBottomMarginEdit->save_value(); + m_xGutterMarginEdit->save_value(); m_xLayoutBox->save_value(); m_xNumberFormatBox->save_value(); m_xPaperSizeBox->save_value(); @@ -593,6 +608,12 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) bModified = true; } + if (m_xGutterMarginEdit->get_value_changed_from_saved()) + { + aMargin.SetGutterMargin(static_cast(GetCoreValue(*m_xGutterMarginEdit, eUnit))); + bModified = true; + } + // set left and right margins if (bModified) { @@ -1012,7 +1033,8 @@ void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground ) // Margins m_aBspWin.SetTop( GetCoreValue( *m_xTopMarginEdit, MapUnit::MapTwip ) ); m_aBspWin.SetBottom( GetCoreValue( *m_xBottomMarginEdit, MapUnit::MapTwip ) ); - m_aBspWin.SetLeft( GetCoreValue( *m_xLeftMarginEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetLeft(GetCoreValue(*m_xLeftMarginEdit, MapUnit::MapTwip) + + GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip)); m_aBspWin.SetRight( GetCoreValue( *m_xRightMarginEdit, MapUnit::MapTwip ) ); // Layout diff --git a/cui/uiconfig/ui/pageformatpage.ui b/cui/uiconfig/ui/pageformatpage.ui index 0135d61e7457..3e6b46452f25 100644 --- a/cui/uiconfig/ui/pageformatpage.ui +++ b/cui/uiconfig/ui/pageformatpage.ui @@ -463,6 +463,38 @@ + + + True + False + Gutter: + True + spinMargBot + 0 + + + + + + 0 + 4 + + + + + True + True + True + True + + + + + + 1 + 4 + + -- cgit v1.2.3