summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-12-10 17:00:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-12-11 12:29:55 +0100
commit6ea6f61d4fabc81ac482ead028259a64608f0c48 (patch)
tree0736c60e4fef71ae253d2379fce1a8a1b9c4c619 /sd
parentcaf7e8e75ee23496bb57bb78b73838c04f8ec8ac (diff)
Related: tdf#129267 draw also has a similar panel combobox
Change-Id: Icde8c951ba3a0672cbc20989c90783e7c1606965 Reviewed-on: https://gerrit.libreoffice.org/84896 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/sidebar/SlideBackground.cxx66
-rw-r--r--sd/source/ui/sidebar/SlideBackground.hxx6
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);
};
}}