summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-12-09 17:15:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-12-09 20:46:58 +0100
commitc1e2acd58e38d4d51285eb522f2dfbde10267f75 (patch)
tree8f6c808d3db9a547881bfd56f8160bad2215d093 /sw
parent23c024e7267510c09d89be934e526d56f76ec11b (diff)
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 <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.cxx31
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.hxx1
2 files changed, 21 insertions, 11 deletions
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);