diff options
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.cxx | 66 | ||||
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.hxx | 6 |
2 files changed, 51 insertions, 21 deletions
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index 98e57e7d594e..958970f49390 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -121,6 +121,7 @@ SlideBackground::SlideBackground( m_nPageRightMargin(0), m_nPageTopMargin(0), m_nPageBottomMargin(0), + meFUnit(GetModuleFieldUnit()), maCustomEntry(), mpBindings(pBindings) { @@ -143,27 +144,6 @@ SlideBackground::SlideBackground( get(mpMasterLabel, "masterlabel"); get(mpMarginSelectBox, "marginLB"); - ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() ); - SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr; - if (pDoc) - { - SdOptions* pOptions = SD_MOD()->GetSdOptions(pDoc->GetDocumentType()); - if (pOptions) - { - FieldUnit eMetric = static_cast<FieldUnit>(pOptions->GetMetric()); - if (IsInch(eMetric)) - { - for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i) - mpMarginSelectBox->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i])); - } - else - { - for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i) - mpMarginSelectBox->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_CM[i])); - } - } - } - maCustomEntry = get<FixedText>("customlabel")->GetText(); addListener(); @@ -189,8 +169,41 @@ bool SlideBackground::IsImpress() maContext == maImpressNotesContext ); } +FieldUnit SlideBackground::GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState) +{ + FieldUnit eUnit; + + if (pState && eState >= SfxItemState::DEFAULT) + eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pState)->GetValue()); + else + eUnit = GetModuleFieldUnit(); + + return eUnit; +} + +void SlideBackground::SetMarginsFieldUnit() +{ + 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(SdResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i])); + } + else + { + for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i) + mpMarginSelectBox->InsertEntry(SdResId(RID_PAGEFORMATPANEL_MARGINS_CM[i])); + } + + mpMarginSelectBox->SelectEntryPos(nSelected); +} + void SlideBackground::Initialize() { + SetMarginsFieldUnit(); + mpPaperSizeBox->FillPaperSizeEntries( PaperSizeApp::Draw ); mpPaperSizeBox->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl)); mpPaperOrientation->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl)); @@ -943,6 +956,17 @@ void SlideBackground::NotifyItemUpdate( } } break; + case SID_ATTR_METRIC: + { + FieldUnit eFUnit = GetCurrentUnit(eState, pState); + if (meFUnit != eFUnit) + { + meFUnit = eFUnit; + SetMarginsFieldUnit(); + UpdateMarginBox(); + } + } + break; default: break; } diff --git a/sd/source/ui/sidebar/SlideBackground.hxx b/sd/source/ui/sidebar/SlideBackground.hxx index 3a48860b7d78..f27184985af4 100644 --- a/sd/source/ui/sidebar/SlideBackground.hxx +++ b/sd/source/ui/sidebar/SlideBackground.hxx @@ -21,6 +21,8 @@ #define INCLUDED_SD_SOURCE_UI_SIDEBAR_SLIDEBACKGROUND_HXX #include <memory> +#include <svl/intitem.hxx> +#include <svx/dlgutil.hxx> #include <vcl/lstbox.hxx> #include <vcl/fixed.hxx> #include <vcl/button.hxx> @@ -132,6 +134,7 @@ private: long m_nPageRightMargin; long m_nPageTopMargin; long m_nPageBottomMargin; + FieldUnit meFUnit; OUString maCustomEntry; SfxBindings* const mpBindings; @@ -153,6 +156,7 @@ private: void Update(); void UpdateMarginBox(); void SetPanelTitle(const OUString& rTitle); + void SetMarginsFieldUnit(); Color const & GetColorSetOrDefault(); XGradient const & GetGradientSetOrDefault(); @@ -167,6 +171,8 @@ private: void ExecuteMarginULChange(const long mnPageTopMargin, const long mnPageBottomMargin); void populateMasterSlideDropdown(); void updateMasterSlideSelection(); + + static FieldUnit GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState); }; }} |