summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-12-19 12:36:12 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-12-19 22:08:28 +0100
commitcbca3beb990df9e75218e27ff0f1b563cf3a67da (patch)
tree2150b1d6d4968dcc5a423f34d85ce5f038bd1fb3
parente3a002c53a544de02e5119c5b0a2fd4f972156a8 (diff)
weld PageFormatPanel
Change-Id: I98b40be22d11bee055ae321e8a93430bc69fe023 Reviewed-on: https://gerrit.libreoffice.org/85525 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.cxx143
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.hxx18
-rw-r--r--sw/uiconfig/swriter/ui/pageformatpanel.ui19
3 files changed, 93 insertions, 87 deletions
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx
index ad2fbc21c26a..269e03cead25 100644
--- a/sw/source/uibase/sidebar/PageFormatPanel.cxx
+++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx
@@ -63,8 +63,8 @@ VclPtr<vcl::Window> PageFormatPanel::Create(
void PageFormatPanel::SetMarginFieldUnit()
{
- auto nSelected = mpMarginSelectBox->GetSelectedEntryPos();
- mpMarginSelectBox->Clear();
+ auto nSelected = mxMarginSelectBox->get_active();
+ mxMarginSelectBox->clear();
const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper();
if (IsInch(meFUnit))
@@ -73,7 +73,7 @@ void PageFormatPanel::SetMarginFieldUnit()
for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i)
{
OUString sStr = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_INCH[i].second, 2, true, false) + sSuffix;
- mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i].first).replaceFirst("%1", sStr));
+ mxMarginSelectBox->append_text(SwResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i].first).replaceFirst("%1", sStr));
}
}
else
@@ -82,18 +82,24 @@ void PageFormatPanel::SetMarginFieldUnit()
for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i)
{
OUString sStr = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_CM[i].second, 2, true, false) + " " + sSuffix;
- mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_CM[i].first).replaceFirst("%1", sStr));
+ mxMarginSelectBox->append_text(SwResId(RID_PAGEFORMATPANEL_MARGINS_CM[i].first).replaceFirst("%1", sStr));
}
}
- mpMarginSelectBox->SelectEntryPos(nSelected);
+ mxMarginSelectBox->set_active(nSelected);
}
PageFormatPanel::PageFormatPanel(
vcl::Window* pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
SfxBindings* pBindings) :
- PanelLayout(pParent, "PageFormatPanel", "modules/swriter/ui/pageformatpanel.ui", rxFrame),
+ PanelLayout(pParent, "PageFormatPanel", "modules/swriter/ui/pageformatpanel.ui", rxFrame, true),
mpBindings( pBindings ),
+ mxPaperSizeBox(new SvxPaperSizeListBox(m_xBuilder->weld_combo_box("papersize"))),
+ mxPaperWidth(new RelativeField(m_xBuilder->weld_metric_spin_button("paperwidth", FieldUnit::CM))),
+ mxPaperHeight(new RelativeField(m_xBuilder->weld_metric_spin_button("paperheight", FieldUnit::CM))),
+ mxPaperOrientation(m_xBuilder->weld_combo_box("paperorientation")),
+ mxMarginSelectBox(m_xBuilder->weld_combo_box("marginLB")),
+ mxCustomEntry(m_xBuilder->weld_label("customlabel")),
maPaperSizeController(SID_ATTR_PAGE_SIZE, *pBindings, *this),
maPaperOrientationController(SID_ATTR_PAGE, *pBindings, *this),
maMetricController(SID_ATTR_METRIC, *pBindings,*this),
@@ -106,12 +112,6 @@ PageFormatPanel::PageFormatPanel(
meUnit(),
aCustomEntry()
{
- get(mpPaperSizeBox, "papersize");
- get(mpPaperWidth, "paperwidth");
- get(mpPaperHeight, "paperheight");
- get(mpPaperOrientation, "paperorientation");
- get(mpMarginSelectBox, "marginLB");
- get(mpCustomEntry, "customlabel");
Initialize();
}
@@ -122,12 +122,12 @@ PageFormatPanel::~PageFormatPanel()
void PageFormatPanel::dispose()
{
- mpPaperSizeBox.disposeAndClear();
- mpPaperWidth.disposeAndClear();
- mpPaperHeight.disposeAndClear();
- mpPaperOrientation.disposeAndClear();
- mpMarginSelectBox.disposeAndClear();
- mpCustomEntry.clear();
+ mxPaperSizeBox.reset();
+ mxPaperWidth.reset();
+ mxPaperHeight.reset();
+ mxPaperOrientation.reset();
+ mxMarginSelectBox.reset();
+ mxCustomEntry.reset();
maMetricController.dispose();
maPaperOrientationController.dispose();
@@ -143,25 +143,22 @@ void PageFormatPanel::dispose()
void PageFormatPanel::Initialize()
{
- mpPaperSizeBox->FillPaperSizeEntries( PaperSizeApp::Std );
- mpPaperSizeBox->SetDropDownLineCount(6);
+ mxPaperSizeBox->FillPaperSizeEntries( PaperSizeApp::Std );
meUnit = maPaperSizeController.GetCoreMetric();
- SetFieldUnit( *mpPaperWidth, meFUnit );
- SetFieldUnit( *mpPaperHeight, meFUnit );
+ mxPaperWidth->SetFieldUnit(meFUnit);
+ mxPaperHeight->SetFieldUnit(meFUnit);
SetMarginFieldUnit();
- aCustomEntry = mpCustomEntry->GetText();
+ aCustomEntry = mxCustomEntry->get_label();
const SvtOptionsDrawinglayer aDrawinglayerOpt;
- mpPaperWidth->SetMax(mpPaperWidth->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FieldUnit::CM);
- mpPaperWidth->SetLast(mpPaperWidth->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FieldUnit::CM);
- mpPaperHeight->SetMax(mpPaperHeight->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FieldUnit::CM);
- mpPaperHeight->SetLast(mpPaperHeight->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FieldUnit::CM);
+ mxPaperWidth->set_max(mxPaperWidth->normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FieldUnit::CM);
+ mxPaperHeight->set_max(mxPaperHeight->normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FieldUnit::CM);
- mpPaperSizeBox->SetSelectHdl( LINK(this, PageFormatPanel, PaperFormatModifyHdl ));
- mpPaperOrientation->SetSelectHdl( LINK(this, PageFormatPanel, PaperFormatModifyHdl ));
- mpPaperHeight->SetModifyHdl( LINK(this, PageFormatPanel, PaperSizeModifyHdl ));
- mpPaperWidth->SetModifyHdl( LINK(this, PageFormatPanel, PaperSizeModifyHdl ));
- mpMarginSelectBox->SetSelectHdl( LINK(this, PageFormatPanel, PaperModifyMarginHdl));
+ mxPaperSizeBox->connect_changed( LINK(this, PageFormatPanel, PaperFormatModifyHdl ));
+ mxPaperOrientation->connect_changed( LINK(this, PageFormatPanel, PaperFormatModifyHdl ));
+ mxPaperHeight->connect_value_changed( LINK(this, PageFormatPanel, PaperSizeModifyHdl ));
+ mxPaperWidth->connect_value_changed( LINK(this, PageFormatPanel, PaperSizeModifyHdl ));
+ mxMarginSelectBox->connect_changed( LINK(this, PageFormatPanel, PaperModifyMarginHdl));
mpBindings->Update(SID_ATTR_METRIC);
mpBindings->Update(SID_ATTR_PAGE);
@@ -188,14 +185,14 @@ void PageFormatPanel::NotifyItemUpdate(
{
Size aPaperSize = pSizeItem->GetSize();
- mpPaperWidth->SetValue( mpPaperWidth->Normalize( aPaperSize.Width() ), FieldUnit::TWIP );
- mpPaperHeight->SetValue( mpPaperHeight->Normalize( aPaperSize.Height() ), FieldUnit::TWIP );
+ mxPaperWidth->set_value(mxPaperWidth->normalize(aPaperSize.Width()), FieldUnit::TWIP);
+ mxPaperHeight->set_value(mxPaperHeight->normalize(aPaperSize.Height()), FieldUnit::TWIP);
- if(mpPaperOrientation->GetSelectedEntryPos() == 1)
+ if(mxPaperOrientation->get_active() == 1)
Swap(aPaperSize);
Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, meUnit);
- mpPaperSizeBox->SetSelection( ePaper );
+ mxPaperSizeBox->SetSelection( ePaper );
}
}
break;
@@ -206,8 +203,8 @@ void PageFormatPanel::NotifyItemUpdate(
if (eFUnit != meFUnit)
{
meFUnit = eFUnit;
- SetFieldUnit( *mpPaperHeight, meFUnit );
- SetFieldUnit( *mpPaperWidth, meFUnit );
+ mxPaperHeight->SetFieldUnit(meFUnit);
+ mxPaperWidth->SetFieldUnit(meFUnit);
SetMarginFieldUnit();
UpdateMarginBox();
}
@@ -220,9 +217,9 @@ void PageFormatPanel::NotifyItemUpdate(
{
mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) );
if ( mpPageItem->IsLandscape() )
- mpPaperOrientation->SelectEntryPos(1);
+ mxPaperOrientation->set_active(1);
else
- mpPaperOrientation->SelectEntryPos(0);
+ mxPaperOrientation->set_active(0);
}
}
break;
@@ -251,36 +248,36 @@ void PageFormatPanel::NotifyItemUpdate(
}
}
-IMPL_LINK_NOARG(PageFormatPanel, PaperFormatModifyHdl, ListBox&, void)
+IMPL_LINK_NOARG(PageFormatPanel, PaperFormatModifyHdl, weld::ComboBox&, void)
{
- Paper ePaper = mpPaperSizeBox->GetSelection();
+ Paper ePaper = mxPaperSizeBox->GetSelection();
Size aSize;
if(ePaper!=PAPER_USER)
aSize = SvxPaperInfo::GetPaperSize(ePaper, meUnit);
else
- aSize = Size(GetCoreValue( *mpPaperWidth, meUnit ), GetCoreValue( *mpPaperHeight, meUnit));
+ aSize = Size(mxPaperWidth->GetCoreValue(meUnit), mxPaperHeight->GetCoreValue(meUnit));
- if(mpPaperOrientation->GetSelectedEntryPos() == 1 || ePaper==PAPER_USER)
+ if (mxPaperOrientation->get_active() == 1 || ePaper==PAPER_USER)
Swap(aSize);
- mpPageItem->SetLandscape(mpPaperOrientation->GetSelectedEntryPos() == 1);
+ mpPageItem->SetLandscape(mxPaperOrientation->get_active() == 1);
SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, aSize);
mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD, { &aSizeItem, mpPageItem.get() });
}
-IMPL_LINK_NOARG(PageFormatPanel, PaperSizeModifyHdl, Edit&, void)
+IMPL_LINK_NOARG(PageFormatPanel, PaperSizeModifyHdl, weld::MetricSpinButton&, void)
{
- Size aSize( GetCoreValue( *mpPaperWidth, meUnit ), GetCoreValue( *mpPaperHeight, meUnit));
+ Size aSize(mxPaperWidth->GetCoreValue(meUnit), mxPaperHeight->GetCoreValue(meUnit));
SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, aSize);
mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD, { &aSizeItem });
}
-IMPL_LINK_NOARG(PageFormatPanel, PaperModifyMarginHdl, ListBox&, void)
+IMPL_LINK_NOARG(PageFormatPanel, PaperModifyMarginHdl, weld::ComboBox&, void)
{
bool bMirrored = false;
bool bApplyNewPageMargins = true;
- switch ( mpMarginSelectBox->GetSelectedEntryPos() )
+ switch (mxMarginSelectBox->get_active())
{
case 0:
SetNone(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored);
@@ -376,52 +373,62 @@ void PageFormatPanel::UpdateMarginBox()
mnPageTopMargin = mpPageULMarginItem->GetUpper();
mnPageBottomMargin = mpPageULMarginItem->GetLower();
+ int nCustomEntry = mxMarginSelectBox->find_text(aCustomEntry);
+
bool bMirrored = (mpPageItem->GetPageUsage() == SvxPageUsage::Mirror);
if( IsNone(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(0);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(0);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsNarrow(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(1);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(1);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsModerate(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(2);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(2);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsNormal075(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(3);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(3);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsNormal100(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(4);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(4);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsNormal125(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(5);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(5);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsWide(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(6);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(6);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else if( IsMirrored(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) )
{
- mpMarginSelectBox->SelectEntryPos(7);
- mpMarginSelectBox->RemoveEntry(aCustomEntry);
+ mxMarginSelectBox->set_active(7);
+ if (nCustomEntry != -1)
+ mxMarginSelectBox->remove(nCustomEntry);
}
else
{
- if(mpMarginSelectBox->GetEntryPos(aCustomEntry) == LISTBOX_ENTRY_NOTFOUND)
- mpMarginSelectBox->InsertEntry(aCustomEntry);
- mpMarginSelectBox->SelectEntry(aCustomEntry);
+ if (nCustomEntry == -1)
+ mxMarginSelectBox->append_text(aCustomEntry);
+ mxMarginSelectBox->set_active_text(aCustomEntry);
}
}
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.hxx b/sw/source/uibase/sidebar/PageFormatPanel.hxx
index 1df56eccae92..206d478fe403 100644
--- a/sw/source/uibase/sidebar/PageFormatPanel.hxx
+++ b/sw/source/uibase/sidebar/PageFormatPanel.hxx
@@ -67,12 +67,12 @@ private:
SfxBindings* mpBindings;
- VclPtr<PaperSizeListBox> mpPaperSizeBox;
- VclPtr<SvxRelativeField> mpPaperWidth;
- VclPtr<SvxRelativeField> mpPaperHeight;
- VclPtr<ListBox> mpPaperOrientation;
- VclPtr<ListBox> mpMarginSelectBox;
- VclPtr<FixedText> mpCustomEntry;
+ std::unique_ptr<SvxPaperSizeListBox> mxPaperSizeBox;
+ std::unique_ptr<RelativeField> mxPaperWidth;
+ std::unique_ptr<RelativeField> mxPaperHeight;
+ std::unique_ptr<weld::ComboBox> mxPaperOrientation;
+ std::unique_ptr<weld::ComboBox> mxMarginSelectBox;
+ std::unique_ptr<weld::Label> mxCustomEntry;
::sfx2::sidebar::ControllerItem maPaperSizeController;
::sfx2::sidebar::ControllerItem maPaperOrientationController;
@@ -98,9 +98,9 @@ private:
void UpdateMarginBox();
void ExecuteMarginLRChange( const long nPageLeftMargin, const long nPageRightMargin );
void ExecuteMarginULChange( const long nPageTopMargin, const long nPageBottomMargin);
- DECL_LINK(PaperFormatModifyHdl, ListBox&, void);
- DECL_LINK(PaperSizeModifyHdl, Edit&, void);
- DECL_LINK(PaperModifyMarginHdl, ListBox&, void );
+ DECL_LINK(PaperFormatModifyHdl, weld::ComboBox&, void);
+ DECL_LINK(PaperSizeModifyHdl, weld::MetricSpinButton&, void);
+ DECL_LINK(PaperModifyMarginHdl, weld::ComboBox&, void );
};
} } //end of namespace sw::sidebar
diff --git a/sw/uiconfig/swriter/ui/pageformatpanel.ui b/sw/uiconfig/swriter/ui/pageformatpanel.ui
index 5dc85d0b78e5..deacf8cc7354 100644
--- a/sw/uiconfig/swriter/ui/pageformatpanel.ui
+++ b/sw/uiconfig/swriter/ui/pageformatpanel.ui
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
<object class="GtkGrid" id="PageFormatPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -21,8 +20,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="pageformatpanel|size">Size:</property>
- <property name="xalign">1</property>
<property name="mnemonic_widget">papersize</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -34,8 +33,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="pageformatpanel|width">Width:</property>
- <property name="xalign">1</property>
<property name="mnemonic_widget">paperwidth</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -47,8 +46,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="pageformatpanel|height">Height:</property>
- <property name="xalign">1</property>
<property name="mnemonic_widget">paperheight</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -60,8 +59,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="pageformatpanel|orientation">Orientation:</property>
- <property name="xalign">1</property>
<property name="mnemonic_widget">paperorientation</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -69,7 +68,7 @@
</packing>
</child>
<child>
- <object class="svxlo-SvxRelativeField" id="paperwidth">
+ <object class="GtkSpinButton" id="paperwidth">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
@@ -83,7 +82,7 @@
</packing>
</child>
<child>
- <object class="svxlo-SvxRelativeField" id="paperheight">
+ <object class="GtkSpinButton" id="paperheight">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
@@ -112,7 +111,7 @@
</packing>
</child>
<child>
- <object class="svxcorelo-PaperSizeListBox" id="papersize">
+ <object class="GtkComboBoxText" id="papersize">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -127,8 +126,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="pageformatpanel|margin">Margins:</property>
- <property name="xalign">1</property>
<property name="mnemonic_widget">marginLB</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>