From 0f34e96a5ce68a3039f65cd0f896b33f2d20af5f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 18 Aug 2018 15:05:10 +0200 Subject: return weld widgets by std::unique_ptr from builder Change-Id: I20c007b13dae2d1155034711ad1ad48bfdfd0ba8 Reviewed-on: https://gerrit.libreoffice.org/59288 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cui/source/dialogs/insdlg.cxx | 28 +++---- cui/source/options/optlingu.cxx | 6 +- cui/source/tabpages/transfrm.cxx | 10 +-- include/svtools/inettbc.hxx | 2 +- include/svtools/valueset.hxx | 2 +- include/svx/SvxColorValueSet.hxx | 2 +- include/svx/charmap.hxx | 2 +- include/svx/colorbox.hxx | 2 +- include/svx/frmdirlbox.hxx | 4 +- include/svx/hexcolorcontrol.hxx | 2 +- include/svx/langbox.hxx | 2 +- include/svx/pagenumberlistbox.hxx | 2 +- include/svx/papersizelistbox.hxx | 2 +- include/svx/relfld.hxx | 2 +- include/svx/searchcharmap.hxx | 2 +- include/svx/txencbox.hxx | 2 +- include/vcl/weld.hxx | 101 ++++++++++++++--------- sfx2/source/dialog/tabdlg.cxx | 6 +- starmath/inc/dialog.hxx | 2 +- starmath/inc/utility.hxx | 2 +- starmath/source/dialog.cxx | 6 +- starmath/source/utility.cxx | 4 +- svtools/source/control/inettbc.cxx | 4 +- svtools/source/control/valueset.cxx | 4 +- svtools/source/dialogs/restartdialog.cxx | 22 ++--- svx/source/dialog/charmap.cxx | 4 +- svx/source/dialog/compressgraphicdialog.cxx | 34 ++++---- svx/source/dialog/hdft.cxx | 8 +- svx/source/dialog/hexcolorcontrol.cxx | 4 +- svx/source/dialog/langbox.cxx | 4 +- svx/source/dialog/pagenumberlistbox.cxx | 4 +- svx/source/dialog/papersizelistbox.cxx | 4 +- svx/source/dialog/relfld.cxx | 4 +- svx/source/dialog/searchcharmap.cxx | 4 +- svx/source/dialog/txencbox.cxx | 4 +- svx/source/tbxctrls/SvxColorValueSet.cxx | 4 +- svx/source/tbxctrls/tbcontrl.cxx | 4 +- sw/source/ui/envelp/envprt.cxx | 24 +++--- sw/source/ui/index/swuiidxmrk.cxx | 6 +- sw/source/ui/table/tabledlg.cxx | 12 +-- sw/source/uibase/inc/numberingtypelistbox.hxx | 2 +- sw/source/uibase/inc/prcntfld.hxx | 2 +- sw/source/uibase/misc/numberingtypelistbox.cxx | 4 +- sw/source/uibase/utlui/prcntfld.cxx | 4 +- vcl/source/app/salvtables.cxx | 108 ++++++++++++------------- vcl/unx/gtk3/gtk3gtkinst.cxx | 104 ++++++++++++------------ 46 files changed, 298 insertions(+), 273 deletions(-) diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx index 54fb29dabf54..cf31b01d5d60 100644 --- a/cui/source/dialogs/insdlg.cxx +++ b/cui/source/dialogs/insdlg.cxx @@ -357,20 +357,20 @@ SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog(weld::Window *pParent void SfxInsertFloatingFrameDialog::Init() { - m_xEDName.reset(m_xBuilder->weld_entry("edname")); - m_xEDURL.reset(m_xBuilder->weld_entry("edurl")); - m_xBTOpen.reset(m_xBuilder->weld_button("buttonbrowse")); - m_xRBScrollingOn.reset(m_xBuilder->weld_radio_button("scrollbaron")); - m_xRBScrollingOff.reset(m_xBuilder->weld_radio_button("scrollbaroff")); - m_xRBScrollingAuto.reset(m_xBuilder->weld_radio_button("scrollbarauto")); - m_xRBFrameBorderOn.reset(m_xBuilder->weld_radio_button("borderon")); - m_xRBFrameBorderOff.reset(m_xBuilder->weld_radio_button("borderoff")); - m_xFTMarginWidth.reset(m_xBuilder->weld_label("widthlabel")); - m_xNMMarginWidth.reset(m_xBuilder->weld_spin_button("width")); - m_xCBMarginWidthDefault.reset(m_xBuilder->weld_check_button("defaultwidth")); - m_xFTMarginHeight.reset(m_xBuilder->weld_label("heightlabel")); - m_xNMMarginHeight.reset(m_xBuilder->weld_spin_button("height")); - m_xCBMarginHeightDefault.reset(m_xBuilder->weld_check_button("defaultheight")); + m_xEDName = m_xBuilder->weld_entry("edname"); + m_xEDURL = m_xBuilder->weld_entry("edurl"); + m_xBTOpen = m_xBuilder->weld_button("buttonbrowse"); + m_xRBScrollingOn = m_xBuilder->weld_radio_button("scrollbaron"); + m_xRBScrollingOff = m_xBuilder->weld_radio_button("scrollbaroff"); + m_xRBScrollingAuto = m_xBuilder->weld_radio_button("scrollbarauto"); + m_xRBFrameBorderOn = m_xBuilder->weld_radio_button("borderon"); + m_xRBFrameBorderOff = m_xBuilder->weld_radio_button("borderoff"); + m_xFTMarginWidth = m_xBuilder->weld_label("widthlabel"); + m_xNMMarginWidth = m_xBuilder->weld_spin_button("width"); + m_xCBMarginWidthDefault = m_xBuilder->weld_check_button("defaultwidth"); + m_xFTMarginHeight = m_xBuilder->weld_label("heightlabel"); + m_xNMMarginHeight = m_xBuilder->weld_spin_button("height"); + m_xCBMarginHeightDefault = m_xBuilder->weld_check_button("defaultheight"); Link aLink(LINK(this, SfxInsertFloatingFrameDialog, CheckHdl)); m_xCBMarginWidthDefault->connect_clicked(aLink); diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx index a746afe5117f..c427c10cd9dd 100644 --- a/cui/source/options/optlingu.cxx +++ b/cui/source/options/optlingu.cxx @@ -312,17 +312,17 @@ public: if (nRID == EID_NUM_PRE_BREAK) { m_xBeforeFrame->show(); - m_xBreakNF.reset(m_xBuilder->weld_spin_button("beforebreak")); + m_xBreakNF = m_xBuilder->weld_spin_button("beforebreak"); } else if(nRID == EID_NUM_POST_BREAK) { m_xAfterFrame->show(); - m_xBreakNF.reset(m_xBuilder->weld_spin_button("afterbreak")); + m_xBreakNF = m_xBuilder->weld_spin_button("afterbreak"); } else if(nRID == EID_NUM_MIN_WORDLEN) { m_xMinimalFrame->show(); - m_xBreakNF.reset(m_xBuilder->weld_spin_button("wordlength")); + m_xBreakNF = m_xBuilder->weld_spin_button("wordlength"); } } diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index d3c9479ab748..a9a368f1a560 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -414,11 +414,11 @@ SvxSlantTabPage::SvxSlantTabPage(TabPageParent pParent, const SfxItemSet& rInAtt { for (int i = 0; i < 2; ++i) { - m_aControlGroups[i].reset(m_xBuilder->weld_widget("controlgroups" + OString::number(i+1))); - m_aControlGroupX[i].reset(m_xBuilder->weld_widget("controlgroupx" + OString::number(i+1))); - m_aControlX[i].reset(m_xBuilder->weld_metric_spin_button("controlx" + OString::number(i+1), FUNIT_CM)); - m_aControlGroupY[i].reset(m_xBuilder->weld_widget("controlgroupy" + OString::number(i+1))); - m_aControlY[i].reset(m_xBuilder->weld_metric_spin_button("controly" + OString::number(i+1), FUNIT_CM)); + m_aControlGroups[i] = m_xBuilder->weld_widget("controlgroups" + OString::number(i+1)); + m_aControlGroupX[i] = m_xBuilder->weld_widget("controlgroupx" + OString::number(i+1)); + m_aControlX[i] = m_xBuilder->weld_metric_spin_button("controlx" + OString::number(i+1), FUNIT_CM); + m_aControlGroupY[i] = m_xBuilder->weld_widget("controlgroupy" + OString::number(i+1)); + m_aControlY[i] = m_xBuilder->weld_metric_spin_button("controly" + OString::number(i+1), FUNIT_CM); } // this page needs ExchangeSupport diff --git a/include/svtools/inettbc.hxx b/include/svtools/inettbc.hxx index 18764ec42ce8..6cba183eb953 100644 --- a/include/svtools/inettbc.hxx +++ b/include/svtools/inettbc.hxx @@ -112,7 +112,7 @@ class SVT_DLLPUBLIC URLBox SVT_DLLPRIVATE void Init(); public: - URLBox(weld::ComboBoxText* pWidget); + URLBox(std::unique_ptr pWidget); ~URLBox(); void SetText(const OUString& rStr) { m_xWidget->set_entry_text(rStr); } diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index 9d774063d11e..1e2921ba7a5e 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -475,7 +475,7 @@ protected: virtual css::uno::Reference CreateAccessible() override; public: - SvtValueSet(weld::ScrolledWindow* pScrolledWindow); + SvtValueSet(std::unique_ptr pScrolledWindow); virtual ~SvtValueSet() override; virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx index a1098fb7bd91..42315203980a 100644 --- a/include/svx/SvxColorValueSet.hxx +++ b/include/svx/SvxColorValueSet.hxx @@ -45,7 +45,7 @@ public: class SVX_DLLPUBLIC ColorValueSet : public SvtValueSet { public: - ColorValueSet(weld::ScrolledWindow* pWindow); + ColorValueSet(std::unique_ptr pWindow); virtual void Resize() override; diff --git a/include/svx/charmap.hxx b/include/svx/charmap.hxx index 5101b230059f..6871aae3dea7 100644 --- a/include/svx/charmap.hxx +++ b/include/svx/charmap.hxx @@ -65,7 +65,7 @@ protected: vcl::Font maFont; std::unique_ptr mxScrollArea; public: - SvxShowCharSet(weld::ScrolledWindow* pScrollArea, const VclPtr& rVirDev); + SvxShowCharSet(std::unique_ptr pScrollArea, const VclPtr& rVirDev); virtual ~SvxShowCharSet() override; virtual void RecalculateFont(vcl::RenderContext& rRenderContext); diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx index a4aa9de32133..efa949db4081 100644 --- a/include/svx/colorbox.hxx +++ b/include/svx/colorbox.hxx @@ -110,7 +110,7 @@ private: void LockWidthRequest(); ColorWindow* getColorWindow() const; public: - ColorListBox(weld::MenuButton* pControl, weld::Window* pWindow, bool bInterimBuilder = false); + ColorListBox(std::unique_ptr pControl, weld::Window* pWindow, bool bInterimBuilder = false); ~ColorListBox(); void SetSelectHdl(const Link& rLink) diff --git a/include/svx/frmdirlbox.hxx b/include/svx/frmdirlbox.hxx index 600a3240863e..fb2208f59190 100644 --- a/include/svx/frmdirlbox.hxx +++ b/include/svx/frmdirlbox.hxx @@ -58,8 +58,8 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxFrameDirectionListBox private: std::unique_ptr m_xControl; public: - explicit SvxFrameDirectionListBox(weld::ComboBoxText* pControl) - : m_xControl(pControl) + explicit SvxFrameDirectionListBox(std::unique_ptr pControl) + : m_xControl(std::move(pControl)) { } diff --git a/include/svx/hexcolorcontrol.hxx b/include/svx/hexcolorcontrol.hxx index 30302374d52b..8e6b34cf311a 100644 --- a/include/svx/hexcolorcontrol.hxx +++ b/include/svx/hexcolorcontrol.hxx @@ -41,7 +41,7 @@ private: DECL_LINK(ImplProcessInputHdl, OUString&, bool); public: - HexColorControl(weld::Entry* pEdit); + HexColorControl(std::unique_ptr pEdit); void connect_changed(const Link& rLink) { m_xEntry->connect_changed(rLink); } diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx index 848d93a2de72..9b130559320f 100644 --- a/include/svx/langbox.hxx +++ b/include/svx/langbox.hxx @@ -160,7 +160,7 @@ private: SVX_DLLPRIVATE void ImplClear(); DECL_LINK(ChangeHdl, weld::ComboBoxText&, void); public: - LanguageBox(weld::ComboBoxText* pControl); + LanguageBox(std::unique_ptr pControl); void SetLanguageList( SvxLanguageListFlags nLangList, bool bHasLangNone, bool bLangNoneIsLangAll = false ); void AddLanguages( const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList ); diff --git a/include/svx/pagenumberlistbox.hxx b/include/svx/pagenumberlistbox.hxx index 4d15369b0545..51cc94e53a81 100644 --- a/include/svx/pagenumberlistbox.hxx +++ b/include/svx/pagenumberlistbox.hxx @@ -39,7 +39,7 @@ class SVX_DLLPUBLIC SvxPageNumberListBox private: std::unique_ptr m_xControl; public: - SvxPageNumberListBox(weld::ComboBoxText* pControl); + SvxPageNumberListBox(std::unique_ptr pControl); int get_count() const { return m_xControl->get_count(); } OUString get_id(int pos) const { return m_xControl->get_id(pos); } int get_active() const { return m_xControl->get_active(); } diff --git a/include/svx/papersizelistbox.hxx b/include/svx/papersizelistbox.hxx index d9ed3b42582d..0ba2de17ccf5 100644 --- a/include/svx/papersizelistbox.hxx +++ b/include/svx/papersizelistbox.hxx @@ -48,7 +48,7 @@ class SVX_DLLPUBLIC SvxPaperSizeListBox private: std::unique_ptr m_xControl; public: - SvxPaperSizeListBox(weld::ComboBoxText *pControl); + SvxPaperSizeListBox(std::unique_ptr pControl); void FillPaperSizeEntries(PaperSizeApp eApp); void SetSelection(Paper eSize); diff --git a/include/svx/relfld.hxx b/include/svx/relfld.hxx index 8b4d50503fdb..00b8ade7dc3e 100644 --- a/include/svx/relfld.hxx +++ b/include/svx/relfld.hxx @@ -45,7 +45,7 @@ private: DECL_LINK(ModifyHdl, weld::Entry&, void); public: - RelativeField(weld::MetricSpinButton* pControl); + RelativeField(std::unique_ptr pControl); void EnableRelativeMode( sal_uInt16 nMin, sal_uInt16 nMax ); void SetRelative( bool bRelative ); diff --git a/include/svx/searchcharmap.hxx b/include/svx/searchcharmap.hxx index bcc4ac2dc5b9..7cdebe6acf12 100644 --- a/include/svx/searchcharmap.hxx +++ b/include/svx/searchcharmap.hxx @@ -53,7 +53,7 @@ class ScrollBar; class SVX_DLLPUBLIC SvxSearchCharSet : public SvxShowCharSet { public: - SvxSearchCharSet(weld::ScrolledWindow* pScrolledWindow, const VclPtr &rDevice); + SvxSearchCharSet(std::unique_ptr pScrolledWindow, const VclPtr &rDevice); virtual ~SvxSearchCharSet() override; virtual void RecalculateFont(vcl::RenderContext& rRenderContext) override; diff --git a/include/svx/txencbox.hxx b/include/svx/txencbox.hxx index 4555b7d338da..294362cc5f85 100644 --- a/include/svx/txencbox.hxx +++ b/include/svx/txencbox.hxx @@ -95,7 +95,7 @@ private: std::unique_ptr m_xControl; public: - TextEncodingBox(weld::ComboBoxText* pControl); + TextEncodingBox(std::unique_ptr pControl); ~TextEncodingBox(); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 0277b3cfae6f..b864231e105a 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -590,9 +591,9 @@ protected: void update_width_chars(); public: - MetricSpinButton(SpinButton* pSpinButton, FieldUnit eSrcUnit) + MetricSpinButton(std::unique_ptr pSpinButton, FieldUnit eSrcUnit) : m_eSrcUnit(eSrcUnit) - , m_xSpinButton(pSpinButton) + , m_xSpinButton(std::move(pSpinButton)) { update_width_chars(); m_xSpinButton->connect_output(LINK(this, MetricSpinButton, spin_button_output)); @@ -748,9 +749,9 @@ protected: void update_width_chars(); public: - TimeSpinButton(SpinButton* pSpinButton, TimeFieldFormat eFormat) + TimeSpinButton(std::unique_ptr pSpinButton, TimeFieldFormat eFormat) : m_eFormat(eFormat) - , m_xSpinButton(pSpinButton) + , m_xSpinButton(std::move(pSpinButton)) { update_width_chars(); m_xSpinButton->connect_output(LINK(this, TimeSpinButton, spin_button_output)); @@ -920,43 +921,67 @@ public: m_sHelpRoot = m_sHelpRoot.copy(0, nIdx); m_sHelpRoot = m_sHelpRoot + OString('/'); } - virtual MessageDialog* weld_message_dialog(const OString& id, bool bTakeOwnership = true) = 0; - virtual Dialog* weld_dialog(const OString& id, bool bTakeOwnership = true) = 0; - virtual Window* weld_window(const OString& id, bool bTakeOwnership = true) = 0; - virtual Widget* weld_widget(const OString& id, bool bTakeOwnership = false) = 0; - virtual Container* weld_container(const OString& id, bool bTakeOwnership = false) = 0; - virtual Button* weld_button(const OString& id, bool bTakeOwnership = false) = 0; - virtual MenuButton* weld_menu_button(const OString& id, bool bTakeOwnership = false) = 0; - virtual Frame* weld_frame(const OString& id, bool bTakeOwnership = false) = 0; - virtual ScrolledWindow* weld_scrolled_window(const OString& id, bool bTakeOwnership = false) + virtual std::unique_ptr weld_message_dialog(const OString& id, + bool bTakeOwnership = true) = 0; - virtual Notebook* weld_notebook(const OString& id, bool bTakeOwnership = false) = 0; - virtual ToggleButton* weld_toggle_button(const OString& id, bool bTakeOwnership = false) = 0; - virtual RadioButton* weld_radio_button(const OString& id, bool bTakeOwnership = false) = 0; - virtual CheckButton* weld_check_button(const OString& id, bool bTakeOwnership = false) = 0; - virtual SpinButton* weld_spin_button(const OString& id, bool bTakeOwnership = false) = 0; - MetricSpinButton* weld_metric_spin_button(const OString& id, FieldUnit eUnit, - bool bTakeOwnership = false) - { - return new MetricSpinButton(weld_spin_button(id, bTakeOwnership), eUnit); - } - virtual TimeSpinButton* weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, - bool bTakeOwnership = false) + virtual std::unique_ptr weld_dialog(const OString& id, bool bTakeOwnership = true) = 0; + virtual std::unique_ptr weld_window(const OString& id, bool bTakeOwnership = true) = 0; + virtual std::unique_ptr weld_widget(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr weld_container(const OString& id, + bool bTakeOwnership = false) = 0; - virtual ComboBoxText* weld_combo_box_text(const OString& id, bool bTakeOwnership = false) = 0; - virtual TreeView* weld_tree_view(const OString& id, bool bTakeOwnership = false) = 0; - virtual Label* weld_label(const OString& id, bool bTakeOwnership = false) = 0; - virtual TextView* weld_text_view(const OString& id, bool bTakeOwnership = false) = 0; - virtual Expander* weld_expander(const OString& id, bool bTakeOwnership = false) = 0; - virtual Entry* weld_entry(const OString& id, bool bTakeOwnership = false) = 0; - virtual Scale* weld_scale(const OString& id, bool bTakeOwnership = false) = 0; - virtual ProgressBar* weld_progress_bar(const OString& id, bool bTakeOwnership = false) = 0; - virtual DrawingArea* weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, - FactoryFunction pUITestFactoryFunction = nullptr, - void* pUserData = nullptr, bool bTakeOwnership = false) + virtual std::unique_ptr