include/svtools/editbrowsebox.hxx | 1 + include/vcl/weldutils.hxx | 6 +++--- svtools/source/brwbox/ebbcontrols.cxx | 6 ++++-- vcl/source/app/weldutils.cxx | 20 ++++++++++---------- 4 files changed, 18 insertions(+), 15 deletions(-)
New commits: commit 8ac055fa8aa7ea6c15fc5e8c36df840978878a6f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Jul 3 10:58:37 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Jul 3 18:09:53 2020 +0200 change FormattedEntry to not own the Entry it operates on Change-Id: I5b5753312a5bbfed3dbcdc47cc1781cbcf168750 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97858 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx index 8b5bc44f7e28..260d1a3dd792 100644 --- a/include/svtools/editbrowsebox.hxx +++ b/include/svtools/editbrowsebox.hxx @@ -581,6 +581,7 @@ namespace svt weld::FormattedEntry& get_formatter() { return *m_xFormattedEntry; } private: + std::unique_ptr<weld::Entry> m_xEntry; std::unique_ptr<weld::FormattedEntry> m_xFormattedEntry; }; diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx index a6a87389d6e4..d9f1ae2c894d 100644 --- a/include/vcl/weldutils.hxx +++ b/include/vcl/weldutils.hxx @@ -157,11 +157,11 @@ public: class VCL_DLLPUBLIC FormattedEntry : public Formatter { public: - FormattedEntry(std::unique_ptr<weld::Entry> xEntry); + FormattedEntry(weld::Entry& rEntry); void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aModifyHdl = rLink; } - weld::Entry* get_widget() { return m_xEntry.get(); } + weld::Entry& get_widget() { return m_rEntry; } // Formatter overrides virtual Selection GetEntrySelection() const override; @@ -174,7 +174,7 @@ public: void SetEntrySelectionOptions(SelectionOptions eOptions) { m_eOptions = eOptions; } private: - std::unique_ptr<weld::Entry> m_xEntry; + weld::Entry& m_rEntry; Link<weld::Entry&, void> m_aModifyHdl; SelectionOptions m_eOptions; DECL_DLLPRIVATE_LINK(ModifyHdl, weld::Entry&, void); diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx index 8513f53f22f5..70f7a64b5b6d 100644 --- a/svtools/source/brwbox/ebbcontrols.cxx +++ b/svtools/source/brwbox/ebbcontrols.cxx @@ -383,14 +383,16 @@ namespace svt FormattedControl::FormattedControl(vcl::Window* pParent) : EditControlBase(pParent) - , m_xFormattedEntry(new weld::FormattedEntry(m_xBuilder->weld_entry("entry"))) + , m_xEntry(m_xBuilder->weld_entry("entry")) + , m_xFormattedEntry(new weld::FormattedEntry(*m_xEntry)) { - init(m_xFormattedEntry->get_widget()); + init(m_xEntry.get()); } void FormattedControl::dispose() { m_xFormattedEntry.reset(); + m_xEntry.reset(); EditControlBase::dispose(); } diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx index 2b175e403304..32fd74642563 100644 --- a/vcl/source/app/weldutils.cxx +++ b/vcl/source/app/weldutils.cxx @@ -125,39 +125,39 @@ void RemoveParentKeepChildren(weld::TreeView& rTreeView, weld::TreeIter& rParent rTreeView.remove(rParent); } -FormattedEntry::FormattedEntry(std::unique_ptr<weld::Entry> xEntry) - : m_xEntry(std::move(xEntry)) +FormattedEntry::FormattedEntry(weld::Entry& rEntry) + : m_rEntry(rEntry) , m_eOptions(Application::GetSettings().GetStyleSettings().GetSelectionOptions()) { - m_xEntry->connect_changed(LINK(this, FormattedEntry, ModifyHdl)); - m_xEntry->connect_focus_out(LINK(this, FormattedEntry, FocusOutHdl)); + m_rEntry.connect_changed(LINK(this, FormattedEntry, ModifyHdl)); + m_rEntry.connect_focus_out(LINK(this, FormattedEntry, FocusOutHdl)); } Selection FormattedEntry::GetEntrySelection() const { int nStartPos, nEndPos; - m_xEntry->get_selection_bounds(nStartPos, nEndPos); + m_rEntry.get_selection_bounds(nStartPos, nEndPos); return Selection(nStartPos, nEndPos); } -OUString FormattedEntry::GetEntryText() const { return m_xEntry->get_text(); } +OUString FormattedEntry::GetEntryText() const { return m_rEntry.get_text(); } void FormattedEntry::SetEntryText(const OUString& rText, const Selection& rSel) { - m_xEntry->set_text(rText); + m_rEntry.set_text(rText); auto nMin = rSel.Min(); auto nMax = rSel.Max(); - m_xEntry->select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax); + m_rEntry.select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax); } void FormattedEntry::SetEntryTextColor(const Color* pColor) { - m_xEntry->set_font_color(pColor ? *pColor : COL_AUTO); + m_rEntry.set_font_color(pColor ? *pColor : COL_AUTO); } SelectionOptions FormattedEntry::GetEntrySelectionOptions() const { return m_eOptions; } -void FormattedEntry::FieldModified() { m_aModifyHdl.Call(*m_xEntry); } +void FormattedEntry::FieldModified() { m_aModifyHdl.Call(m_rEntry); } IMPL_LINK_NOARG(FormattedEntry, ModifyHdl, weld::Entry&, void) { Modify(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits