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>
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx
index 2f7e3cb..459b7e5 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 d06b4e7..b6eaae6 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);