sd/source/ui/sidebar/SlideBackground.cxx | 66 +++++++++++++++++++++---------- sd/source/ui/sidebar/SlideBackground.hxx | 6 ++ svx/inc/rotationstrings.hrc | 10 ---- 3 files changed, 51 insertions(+), 31 deletions(-)
New commits: commit d90044c533683146c62e7b0848999eb76c7ef3ec Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Dec 10 17:00:31 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Dec 11 11:27:15 2019 +0100 Related: tdf#129267 draw also has a similar panel combobox Change-Id: Icde8c951ba3a0672cbc20989c90783e7c1606965 Reviewed-on: https://gerrit.libreoffice.org/84880 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index 873bbd46759e..c28242b57a61 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -125,6 +125,7 @@ SlideBackground::SlideBackground( m_nPageRightMargin(0), m_nPageTopMargin(0), m_nPageBottomMargin(0), + meFUnit(GetModuleFieldUnit()), maCustomEntry(), mpBindings(pBindings) { @@ -147,27 +148,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(); @@ -193,8 +173,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)); @@ -947,6 +960,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); }; }} commit 8b2ae3bd629f8569db4900a1861cc963a9056132 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Dec 10 19:39:18 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Dec 11 11:27:05 2019 +0100 this is a new source file Change-Id: I1b86e221b1234fafa2ff1fbf7117c082fb799075 Reviewed-on: https://gerrit.libreoffice.org/84891 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/svx/inc/rotationstrings.hrc b/svx/inc/rotationstrings.hrc index dfc6c7aa7b44..229f2bee53c5 100644 --- a/svx/inc/rotationstrings.hrc +++ b/svx/inc/rotationstrings.hrc @@ -5,16 +5,6 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #ifndef INCLUDED_SVX_INC_ROTATIONSTRINGS_HRC _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits