sw/source/uibase/sidebar/PageFormatPanel.cxx | 31 +++++++++++++++++---------- sw/source/uibase/sidebar/PageFormatPanel.hxx | 1 2 files changed, 21 insertions(+), 11 deletions(-)
New commits: commit c1e2acd58e38d4d51285eb522f2dfbde10267f75 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Dec 9 17:15:08 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Dec 9 20:46:58 2019 +0100 Resolves: tdf#129267 change margin unit when measurement unit changes Change-Id: Ib44ea95392489679b947311e9031efb84d501fad Reviewed-on: https://gerrit.libreoffice.org/84781 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> 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<vcl::Window> PageFormatPanel::Create( return VclPtr<PageFormatPanel>::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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits