diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-02 15:30:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-02 21:54:03 +0200 |
commit | fa8822c48e2a79589bebbd015b36d1da8b338cc2 (patch) | |
tree | 0e3c8c305f08a2dee687e540b4795e7de90ad20f /sw | |
parent | 5d5a7293bf6a49b1828bdd9fdff989f0a9cd2e53 (diff) |
weld SwTableWidthDlg
Change-Id: I272a783c9b7a8f725314e416fbd81217105ee5a6
Reviewed-on: https://gerrit.libreoffice.org/52266
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/colwd.hxx | 20 | ||||
-rw-r--r-- | sw/inc/swabstdlg.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 15 | ||||
-rw-r--r-- | sw/source/ui/dialog/swuiexp.cxx | 1 | ||||
-rw-r--r-- | sw/source/ui/table/colwd.cxx | 67 | ||||
-rw-r--r-- | sw/source/uibase/inc/tablemgr.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/tabsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/table/tablemgr.cxx | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/columnwidth.ui | 19 |
10 files changed, 78 insertions, 62 deletions
diff --git a/sw/inc/colwd.hxx b/sw/inc/colwd.hxx index c6d13e159130..894ed19b2f5a 100644 --- a/sw/inc/colwd.hxx +++ b/sw/inc/colwd.hxx @@ -19,24 +19,22 @@ #ifndef INCLUDED_SW_INC_COLWD_HXX #define INCLUDED_SW_INC_COLWD_HXX -#include <svx/stddlg.hxx> -#include <vcl/field.hxx> +#include <vcl/weld.hxx> class SwTableFUNC; -class SwTableWidthDlg final : public SvxStandardDialog +class SwTableWidthDlg final : public weld::GenericDialogController { - VclPtr<NumericField> m_pColNF; - VclPtr<MetricField> m_pWidthMF; - SwTableFUNC &rFnc; + SwTableFUNC &m_rFnc; - virtual void Apply() override; - DECL_LINK(LoseFocusHdl, Edit&, void); + std::unique_ptr<weld::SpinButton> m_xColNF; + std::unique_ptr<weld::MetricSpinButton> m_xWidthMF; + + DECL_LINK(LoseFocusHdl, weld::SpinButton&, void); public: - SwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rFnc ); - virtual ~SwTableWidthDlg() override; - virtual void dispose() override; + SwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc); + short execute(); }; #endif diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 9e604f66ce68..9c900e9d4b6f 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -435,7 +435,7 @@ public: virtual VclPtr<SfxAbstractDialog> CreateSwBorderDlg ( vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType ) = 0; virtual VclPtr<SfxAbstractDialog> CreateSwWrapDlg ( vcl::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh ) = 0; - virtual VclPtr<VclAbstractDialog> CreateSwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rFnc) = 0; + virtual VclPtr<VclAbstractDialog> CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSwTableTabDlg(vcl::Window* pParent, const SfxItemSet* pItemSet, SwWrtShell* pSh) = 0; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 2d1da118cd18..ca8b8c12fb44 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -32,6 +32,7 @@ #include <break.hxx> #include <changedb.hxx> #include <chrdlg.hxx> +#include <colwd.hxx> #include <convert.hxx> #include <cption.hxx> #include <dbinsdlg.hxx> @@ -102,6 +103,10 @@ short AbstractSwBreakDlg_Impl::Execute() { return m_xDlg->execute(); } +short AbstractSwTableWidthDlg_Impl::Execute() +{ + return m_xDlg->execute(); +} short AbstractSwSortDlg_Impl::Execute() { return m_xDlg->execute(); @@ -841,10 +846,9 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwWrapDlg ( vcl::W return VclPtr<SwAbstractSfxDialog_Impl>::Create( pDlg ); } -VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rFnc) +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) { - VclPtr<Dialog> pDlg = VclPtr<SwTableWidthDlg>::Create(pParent, rFnc); - return VclPtr<VclAbstractDialog_Impl>::Create( pDlg ); + return VclPtr<AbstractSwTableWidthDlg_Impl>::Create(new SwTableWidthDlg(pParent, rFnc)); } VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwTableTabDlg(vcl::Window* pParent, diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index cf2343bb9e66..6635787db0fc 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -26,6 +26,7 @@ class SwAsciiFilterDlg; class Dialog; class SwBreakDlg; class SwSortDlg; +class SwTableWidthDlg; class SignatureLineDialog; class SfxTabDialog; class SwConvertTableDlg; @@ -142,6 +143,18 @@ public: virtual ::boost::optional<sal_uInt16> GetPageNumber() override; }; +class AbstractSwTableWidthDlg_Impl : public VclAbstractDialog +{ +protected: + std::unique_ptr<SwTableWidthDlg> m_xDlg; +public: + explicit AbstractSwTableWidthDlg_Impl(SwTableWidthDlg* p) + : m_xDlg(p) + { + } + virtual short Execute() override; +}; + class AbstractSplitTableDialog_Impl : public AbstractSplitTableDialog // add for { protected: @@ -487,7 +500,7 @@ public: virtual VclPtr<SfxAbstractDialog> CreateSwBorderDlg (vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType ) override; virtual VclPtr<SfxAbstractDialog> CreateSwWrapDlg ( vcl::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh ) override; - virtual VclPtr<VclAbstractDialog> CreateSwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rFnc) override; + virtual VclPtr<VclAbstractDialog> CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwTableTabDlg(vcl::Window* pParent, const SfxItemSet* pItemSet, SwWrtShell* pSh) override; virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pParent) override; diff --git a/sw/source/ui/dialog/swuiexp.cxx b/sw/source/ui/dialog/swuiexp.cxx index 336a779100b8..1b681c9e8b52 100644 --- a/sw/source/ui/dialog/swuiexp.cxx +++ b/sw/source/ui/dialog/swuiexp.cxx @@ -22,6 +22,7 @@ #include <abstract.hxx> #include <ascfldlg.hxx> #include <break.hxx> +#include <colwd.hxx> #include <convert.hxx> #include <srtdlg.hxx> #include <dbinsdlg.hxx> diff --git a/sw/source/ui/table/colwd.cxx b/sw/source/ui/table/colwd.cxx index 8ad8aaf6be64..4ca22dda4b5e 100644 --- a/sw/source/ui/table/colwd.cxx +++ b/sw/source/ui/table/colwd.cxx @@ -30,57 +30,48 @@ #include <cmdid.h> -IMPL_LINK_NOARG(SwTableWidthDlg, LoseFocusHdl, Edit&, void) +IMPL_LINK_NOARG(SwTableWidthDlg, LoseFocusHdl, weld::SpinButton&, void) { - sal_uInt16 nId = static_cast<sal_uInt16>(m_pColNF->GetValue())-1; - const SwTwips lWidth = rFnc.GetColWidth(nId); - m_pWidthMF->SetMax(m_pWidthMF->Normalize(rFnc.GetMaxColWidth(nId)), FUNIT_TWIP); - m_pWidthMF->SetValue(m_pWidthMF->Normalize(lWidth), FUNIT_TWIP); + sal_uInt16 nId = static_cast<sal_uInt16>(m_xColNF->get_value()) - 1; + const SwTwips lWidth = m_rFnc.GetColWidth(nId); + m_xWidthMF->set_max(m_xWidthMF->normalize(m_rFnc.GetMaxColWidth(nId)), FUNIT_TWIP); + m_xWidthMF->set_value(m_xWidthMF->normalize(lWidth), FUNIT_TWIP); } -SwTableWidthDlg::SwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rTableFnc ) - : SvxStandardDialog( pParent, "ColumnWidthDialog", "modules/swriter/ui/columnwidth.ui" ) - , rFnc(rTableFnc) +SwTableWidthDlg::SwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rTableFnc) + : GenericDialogController(pParent, "modules/swriter/ui/columnwidth.ui", "ColumnWidthDialog") + , m_rFnc(rTableFnc) + , m_xColNF(m_xBuilder->weld_spin_button("column")) + , m_xWidthMF(m_xBuilder->weld_metric_spin_button("width")) { - get(m_pColNF, "column"); - get(m_pWidthMF, "width"); - bool bIsWeb = rTableFnc.GetShell() && (dynamic_cast< const SwWebDocShell* >( rTableFnc.GetShell()->GetView().GetDocShell()) != nullptr ); FieldUnit eFieldUnit = SW_MOD()->GetUsrPref( bIsWeb )->GetMetric(); - ::SetFieldUnit(*m_pWidthMF, eFieldUnit); - - m_pColNF->SetValue( rFnc.GetCurColNum() +1 ); - m_pWidthMF->SetMin(m_pWidthMF->Normalize(MINLAY), FUNIT_TWIP); - if(!m_pWidthMF->GetMin()) - m_pWidthMF->SetMin(1); + ::SetFieldUnit(*m_xWidthMF, eFieldUnit); - if(rFnc.GetColCount() == 0) - m_pWidthMF->SetMin(m_pWidthMF->Normalize(rFnc.GetColWidth(0)), FUNIT_TWIP); - m_pColNF->SetMax(rFnc.GetColCount() +1 ); - m_pColNF->SetModifyHdl(LINK(this,SwTableWidthDlg, LoseFocusHdl)); - LoseFocusHdl(*m_pColNF); -} + m_xColNF->set_max(m_rFnc.GetColCount() + 1); + m_xColNF->set_value(m_rFnc.GetCurColNum() + 1); -SwTableWidthDlg::~SwTableWidthDlg() -{ - disposeOnce(); -} - -void SwTableWidthDlg::dispose() -{ - m_pColNF.clear(); - m_pWidthMF.clear(); - SvxStandardDialog::dispose(); + if (m_rFnc.GetColCount() == 0) + m_xWidthMF->set_min(m_xWidthMF->normalize(m_rFnc.GetColWidth(0)), FUNIT_TWIP); + else + m_xWidthMF->set_min(m_xWidthMF->normalize(MINLAY), FUNIT_TWIP); + m_xColNF->connect_value_changed(LINK(this, SwTableWidthDlg, LoseFocusHdl)); + LoseFocusHdl(*m_xColNF); } -void SwTableWidthDlg::Apply() +short SwTableWidthDlg::execute() { - rFnc.InitTabCols(); - rFnc.SetColWidth( - static_cast< sal_uInt16 >(m_pColNF->GetValue() - 1), - static_cast< sal_uInt16 >(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)))); + short nRet = run(); + if (nRet == RET_OK) + { + m_rFnc.InitTabCols(); + m_rFnc.SetColWidth( + static_cast<sal_uInt16>(m_xColNF->get_value() - 1), + static_cast<sal_uInt16>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FUNIT_TWIP)))); + } + return nRet; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/tablemgr.hxx b/sw/source/uibase/inc/tablemgr.hxx index 785862250fe9..3f6d3200a48f 100644 --- a/sw/source/uibase/inc/tablemgr.hxx +++ b/sw/source/uibase/inc/tablemgr.hxx @@ -53,7 +53,7 @@ public: ~SwTableFUNC(); void InitTabCols(); - void ColWidthDlg(vcl::Window *pParent ); + void ColWidthDlg(weld::Window *pParent); SwTwips GetColWidth(sal_uInt16 nNum) const; SwTwips GetMaxColWidth(sal_uInt16 nNum) const; void SetColWidth(sal_uInt16 nNum, SwTwips nWidth ); diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 94b56435e1b9..f42d14e5a956 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -1158,7 +1158,7 @@ void SwTableShell::Execute(SfxRequest &rReq) case FN_TABLE_SET_COL_WIDTH: { SwTableFUNC aMgr( &rSh ); - aMgr.ColWidthDlg(GetView().GetWindow()); + aMgr.ColWidthDlg(GetView().GetFrameWeld()); break; } case SID_TABLE_VERT_NONE: diff --git a/sw/source/uibase/table/tablemgr.cxx b/sw/source/uibase/table/tablemgr.cxx index 5f49fa04bf57..52b49a483e7d 100644 --- a/sw/source/uibase/table/tablemgr.cxx +++ b/sw/source/uibase/table/tablemgr.cxx @@ -50,7 +50,7 @@ using namespace ::com::sun::star; // Adjust line height (dialogue) -void SwTableFUNC::ColWidthDlg( vcl::Window *pParent ) +void SwTableFUNC::ColWidthDlg(weld::Window *pParent) { InitTabCols(); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); diff --git a/sw/uiconfig/swriter/ui/columnwidth.ui b/sw/uiconfig/swriter/ui/columnwidth.ui index 1b9706059f38..593d0c1ee209 100644 --- a/sw/uiconfig/swriter/ui/columnwidth.ui +++ b/sw/uiconfig/swriter/ui/columnwidth.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> <object class="GtkAdjustment" id="adjustment1"> @@ -14,6 +14,9 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="columnwidth|ColumnWidthDialog">Column Width</property> <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -29,6 +32,7 @@ <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="can_default">True</property> <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> @@ -98,10 +102,10 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="columnwidth|label2">Column:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">column</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -112,10 +116,10 @@ <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="columnwidth|label3">Width:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">width:0mm</property> + <property name="mnemonic_widget">width</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -126,6 +130,7 @@ <object class="GtkSpinButton" id="column"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment1</property> </object> <packing> @@ -134,9 +139,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="width:0mm"> + <object class="GtkSpinButton" id="width"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="climb_rate">0.01</property> <property name="digits">2</property> </object> @@ -173,5 +179,8 @@ <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> |