From c1e2acd58e38d4d51285eb522f2dfbde10267f75 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 9 Dec 2019 17:15:08 +0000 Subject: Resolves: tdf#129267 change margin unit when measurement unit changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib44ea95392489679b947311e9031efb84d501fad Reviewed-on: https://gerrit.libreoffice.org/84781 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/uibase/sidebar/PageFormatPanel.cxx | 31 ++++++++++++++++++---------- sw/source/uibase/sidebar/PageFormatPanel.hxx | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'sw') diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx index 2f7e3cbf976c..459b7e5dd023 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.cxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx @@ -58,6 +58,23 @@ VclPtr PageFormatPanel::Create( return VclPtr::Create(pParent, rxFrame, pBindings); } +void PageFormatPanel::SetMarginFieldUnit() +{ + auto nSelected = mpMarginSelectBox->GetSelectedEntryPos(); + mpMarginSelectBox->Clear(); + if (IsInch(meFUnit)) + { + for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i) + mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i])); + } + else + { + for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i) + mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_CM[i])); + } + mpMarginSelectBox->SelectEntryPos(nSelected); +} + PageFormatPanel::PageFormatPanel( vcl::Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, @@ -82,17 +99,6 @@ PageFormatPanel::PageFormatPanel( get(mpPaperHeight, "paperheight"); get(mpPaperOrientation, "paperorientation"); get(mpMarginSelectBox, "marginLB"); - FieldUnit eMetric = ::GetDfltMetric(false); - if (IsInch(eMetric)) - { - for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i) - mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i])); - } - else - { - for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i) - mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_CM[i])); - } get(mpCustomEntry, "customlabel"); Initialize(); } @@ -130,6 +136,7 @@ void PageFormatPanel::Initialize() meUnit = maPaperSizeController.GetCoreMetric(); SetFieldUnit( *mpPaperWidth, meFUnit ); SetFieldUnit( *mpPaperHeight, meFUnit ); + SetMarginFieldUnit(); aCustomEntry = mpCustomEntry->GetText(); const SvtOptionsDrawinglayer aDrawinglayerOpt; @@ -188,6 +195,8 @@ void PageFormatPanel::NotifyItemUpdate( { SetFieldUnit( *mpPaperHeight, meFUnit ); SetFieldUnit( *mpPaperWidth, meFUnit ); + SetMarginFieldUnit(); + UpdateMarginBox(); } meLastFUnit = meFUnit; } diff --git a/sw/source/uibase/sidebar/PageFormatPanel.hxx b/sw/source/uibase/sidebar/PageFormatPanel.hxx index d06b4e76a845..b6eaae68853e 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.hxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.hxx @@ -94,6 +94,7 @@ private: OUString aCustomEntry; void Initialize(); + void SetMarginFieldUnit(); void UpdateMarginBox(); void ExecuteMarginLRChange( const long nPageLeftMargin, const long nPageRightMargin ); void ExecuteMarginULChange( const long nPageTopMargin, const long nPageBottomMargin); -- cgit