diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-02-19 13:32:14 +0100 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2020-05-14 14:38:06 +0200 |
commit | 88451e6be4e21913c2c9875ba74d80fbc393b292 (patch) | |
tree | 2ee084a56897d98eec1241805eb37fab518636c9 /vcl | |
parent | 31ecbdf2e548a337e70b55980cd8cfefdc292b86 (diff) |
Create header file for SalInstanceBuilder
Move more declarations for SalInstance to header file
b7240ffd003e202be04b462209cfb2abafcc18ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89102
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93480
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Change-Id: If8d7578d9a5926cdf565efbf0bc12719e5ef6fc2
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salvtables.hxx | 494 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 2146 |
2 files changed, 1527 insertions, 1113 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx new file mode 100644 index 000000000000..c25c163c6561 --- /dev/null +++ b/vcl/inc/salvtables.hxx @@ -0,0 +1,494 @@ +#ifndef INCLUDED_VCL_INC_SALVTABLES_HXX +#define INCLUDED_VCL_INC_SALVTABLES_HXX + +#include <vcl/weld.hxx> +#include <vcl/svapp.hxx> +#include <vcl/syswin.hxx> +#include <vcl/settings.hxx> +#include <vcl/virdev.hxx> +#include <vcl/ctrl.hxx> + +class SalInstanceBuilder : public weld::Builder +{ +private: + std::unique_ptr<VclBuilder> m_xBuilder; + VclPtr<vcl::Window> m_aOwnedToplevel; + +public: + SalInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile); + + VclBuilder& get_builder() const; + + virtual std::unique_ptr<weld::MessageDialog> + weld_message_dialog(const OString& id, bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::AboutDialog> + weld_about_dialog(const OString& id, bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id, + bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::Assistant> weld_assistant(const OString& id, + bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::Window> create_screenshot_window() override; + + virtual std::unique_ptr<weld::Window> weld_window(const OString& id, + bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id, + bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::Container> weld_container(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Box> weld_box(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Frame> weld_frame(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::ScrolledWindow> + weld_scrolled_window(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Button> weld_button(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::MenuButton> + weld_menu_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::LinkButton> + weld_link_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::ToggleButton> + weld_toggle_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::RadioButton> + weld_radio_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::CheckButton> + weld_check_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Scale> weld_scale(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::ProgressBar> + weld_progress_bar(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Spinner> weld_spinner(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Image> weld_image(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::SpinButton> + weld_spin_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::MetricSpinButton> + weld_metric_spin_button(const OString& id, FieldUnit eUnit, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::FormattedSpinButton> + weld_formatted_spin_button(const OString& id, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::TimeSpinButton> + weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::EntryTreeView> + weld_entry_tree_view(const OString& containerid, const OString& entryid, + const OString& treeviewid, bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Label> weld_label(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::DrawingArea> + weld_drawing_area(const OString& id, const a11yref& rA11yImpl, + FactoryFunction pUITestFactoryFunction, void* pUserData, + bool bTakeOwnership = false) override; + + virtual std::unique_ptr<weld::Menu> weld_menu(const OString& id, + bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id, + bool bTakeOwnership = true) override; + + virtual std::unique_ptr<weld::SizeGroup> create_size_group() override; + + OString get_current_page_help_id() const; + + virtual ~SalInstanceBuilder() override; +}; + +class SalInstanceWidget : public virtual weld::Widget +{ +protected: + VclPtr<vcl::Window> m_xWidget; + SalInstanceBuilder* m_pBuilder; + +private: + DECL_LINK(EventListener, VclWindowEvent&, void); + DECL_LINK(KeyEventListener, VclWindowEvent&, bool); + DECL_LINK(MouseEventListener, VclSimpleEvent&, void); + DECL_LINK(MnemonicActivateHdl, vcl::Window&, bool); + + const bool m_bTakeOwnership; + bool m_bEventListener; + bool m_bKeyEventListener; + bool m_bMouseEventListener; + int m_nBlockNotify; + +protected: + void ensure_event_listener(); + + // we want the ability to mark key events as handled, so use this variant + // for those, we get all keystrokes in this case, so we will need to filter + // them later + void ensure_key_listener(); + + // we want the ability to know about mouse events that happen in our children + // so use this variant, we will need to filter them later + void ensure_mouse_listener(); + + virtual void HandleEventListener(VclWindowEvent& rEvent); + virtual bool HandleKeyEventListener(VclWindowEvent& rEvent); + virtual void HandleMouseEventListener(VclSimpleEvent& rEvent); + + void set_background(const Color& rColor); + +public: + SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_sensitive(bool sensitive) override; + + virtual bool get_sensitive() const override; + + virtual bool get_visible() const override; + + virtual bool is_visible() const override; + + virtual void set_can_focus(bool bCanFocus) override; + + virtual void grab_focus() override; + + virtual bool has_focus() const override; + + virtual bool is_active() const override; + + virtual void set_has_default(bool has_default) override; + + virtual bool get_has_default() const override; + + virtual void show() override; + + virtual void hide() override; + + virtual void set_size_request(int nWidth, int nHeight) override; + + virtual Size get_size_request() const override; + + virtual Size get_preferred_size() const override; + + virtual float get_approximate_digit_width() const override; + + virtual int get_text_height() const override; + + virtual Size get_pixel_size(const OUString& rText) const override; + + virtual vcl::Font get_font() override; + + virtual OString get_buildable_name() const override; + + virtual void set_help_id(const OString& rId) override; + + virtual OString get_help_id() const override; + + virtual void set_grid_left_attach(int nAttach) override; + + virtual int get_grid_left_attach() const override; + + virtual void set_grid_width(int nCols) override; + + virtual void set_grid_top_attach(int nAttach) override; + + virtual int get_grid_top_attach() const override; + + virtual void set_hexpand(bool bExpand) override; + + virtual bool get_hexpand() const override; + + virtual void set_vexpand(bool bExpand) override; + + virtual bool get_vexpand() const override; + + virtual void set_secondary(bool bSecondary) override; + + virtual void set_margin_top(int nMargin) override; + + virtual void set_margin_bottom(int nMargin) override; + + virtual void set_margin_left(int nMargin) override; + + virtual void set_margin_right(int nMargin) override; + + virtual int get_margin_top() const override; + + virtual int get_margin_bottom() const override; + + virtual int get_margin_left() const override; + + virtual int get_margin_right() const override; + + virtual void set_accessible_name(const OUString& rName) override; + + virtual OUString get_accessible_name() const override; + + virtual OUString get_accessible_description() const override; + + virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) override; + + virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) override; + + virtual void + add_extra_accessible_relation(const css::accessibility::AccessibleRelation& rRelation) override; + + virtual void clear_extra_accessible_relations() override; + + virtual void set_tooltip_text(const OUString& rTip) override; + + virtual OUString get_tooltip_text() const override; + + virtual void connect_focus_in(const Link<Widget&, void>& rLink) override; + + virtual void connect_mnemonic_activate(const Link<Widget&, bool>& rLink) override; + + virtual void connect_focus_out(const Link<Widget&, void>& rLink) override; + + virtual void connect_size_allocate(const Link<const Size&, void>& rLink) override; + + virtual void connect_mouse_press(const Link<const MouseEvent&, bool>& rLink) override; + + virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) override; + + virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) override; + + virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override; + + virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink) override; + + virtual bool get_extents_relative_to(Widget& rRelative, int& x, int& y, int& width, + int& height) override; + + virtual void grab_add() override; + + virtual bool has_grab() const override; + + virtual void grab_remove() override; + + virtual bool get_direction() const override; + + virtual void set_direction(bool bRTL) override; + + virtual void freeze() override; + + virtual void thaw() override; + + virtual std::unique_ptr<weld::Container> weld_parent() const override; + + virtual ~SalInstanceWidget() override; + + vcl::Window* getWidget(); + + void disable_notify_events(); + + bool notify_events_disabled(); + + void enable_notify_events(); + + virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) override; + + virtual OUString strip_mnemonic(const OUString& rLabel) const override; + + virtual VclPtr<VirtualDevice> create_virtual_device() const override; + + virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override; + + virtual void set_stack_background() override; + + virtual void set_highlight_background() override; + + SystemWindow* getSystemWindow(); +}; + +class SalInstanceLabel : public SalInstanceWidget, public virtual weld::Label +{ +private: + // Control instead of FixedText so we can also use this for + // SelectableFixedText which is derived from Edit. We just typically need + // [G|S]etText which exists in their shared baseclass + VclPtr<Control> m_xLabel; + +public: + SalInstanceLabel(Control* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_label(const OUString& rText) override; + + virtual OUString get_label() const override; + + virtual void set_mnemonic_widget(Widget* pTarget) override; + + virtual void set_message_type(weld::EntryMessageType eType) override; + + virtual void set_font(const vcl::Font& rFont) override; +}; + +class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Container +{ +protected: + VclPtr<vcl::Window> m_xContainer; + +private: + void implResetDefault(const vcl::Window* _pWindow); + +public: + SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override; + virtual void recursively_unset_default_buttons() override; + virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override; +}; + +class SalInstanceWindow : public SalInstanceContainer, public virtual weld::Window +{ +private: + VclPtr<vcl::Window> m_xWindow; + + DECL_LINK(HelpHdl, vcl::Window&, bool); + + void override_child_help(vcl::Window* pParent); + + void clear_child_help(vcl::Window* pParent); + +public: + SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_title(const OUString& rTitle) override; + + virtual OUString get_title() const override; + + void help(); + + virtual void set_busy_cursor(bool bBusy) override; + + virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override; + + virtual void resize_to_request() override; + + virtual void set_modal(bool bModal) override; + + virtual bool get_modal() const override; + + virtual void window_move(int x, int y) override; + + virtual Size get_size() const override; + + virtual Point get_position() const override; + + virtual tools::Rectangle get_monitor_workarea() const override; + + virtual void set_centered_on_parent(bool /*bTrackGeometryRequests*/) override; + + virtual bool get_resizable() const override; + + virtual bool has_toplevel_focus() const override; + + virtual void present() override; + + virtual void set_window_state(const OString& rStr) override; + + virtual OString get_window_state(WindowStateMask nMask) const override; + + virtual SystemEnvData get_system_data() const override; + + virtual void connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) override; + + virtual void HandleEventListener(VclWindowEvent& rEvent) override; + + virtual void draw(VirtualDevice& rOutput) override; + + virtual weld::ScreenShotCollection collect_screenshot_data() override; + + virtual ~SalInstanceWindow() override; +}; + +class SalInstanceDialog : public SalInstanceWindow, public virtual weld::Dialog +{ +private: + VclPtr<::Dialog> m_xDialog; + + // for calc ref dialog that shrink to range selection widgets and resize back + VclPtr<vcl::Window> m_xRefEdit; + std::vector<VclPtr<vcl::Window>> m_aHiddenWidgets; // vector of hidden Controls + long m_nOldEditWidthReq; // Original width request of the input field + sal_Int32 m_nOldBorderWidth; // border width for expanded dialog + + DECL_LINK(PopupScreenShotMenuHdl, const CommandEvent&, bool); + +public: + SalInstanceDialog(::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual bool runAsync(std::shared_ptr<weld::DialogController> aOwner, + const std::function<void(sal_Int32)>& rEndDialogFn) override; + + virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf, + const std::function<void(sal_Int32)>& rEndDialogFn) override; + + virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override; + + virtual void undo_collapse() override; + + virtual void + SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) override; + + virtual int run() override; + + virtual void response(int nResponse) override; + + virtual void add_button(const OUString& rText, int nResponse, const OString& rHelpId) override; + + virtual void set_modal(bool bModal) override; + + virtual bool get_modal() const override; + + virtual weld::Button* weld_widget_for_response(int nResponse) override; + + virtual void set_default_response(int nResponse) override; + + virtual Container* weld_content_area() override; +}; + +#endif
\ No newline at end of file diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index d9d25ee5494f..65eb6083f1db 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -71,6 +71,7 @@ #include <aboutdialog.hxx> #include <bitmaps.hlst> #include <wizdlg.hxx> +#include <salvtables.hxx> SalFrame::SalFrame() : m_pWindow(nullptr) @@ -233,507 +234,476 @@ SalMenuItem::~SalMenuItem() { } -class SalInstanceBuilder; - -class SalInstanceWidget : public virtual weld::Widget +void SalInstanceWidget::ensure_event_listener() { -protected: - VclPtr<vcl::Window> m_xWidget; - SalInstanceBuilder* m_pBuilder; - -private: - DECL_LINK(EventListener, VclWindowEvent&, void); - DECL_LINK(KeyEventListener, VclWindowEvent&, bool); - DECL_LINK(MouseEventListener, VclSimpleEvent&, void); - DECL_LINK(MnemonicActivateHdl, vcl::Window&, bool); - - const bool m_bTakeOwnership; - bool m_bEventListener; - bool m_bKeyEventListener; - bool m_bMouseEventListener; - int m_nBlockNotify; - -protected: - void ensure_event_listener() - { - if (!m_bEventListener) - { - m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, EventListener)); - m_bEventListener = true; - } - } - - // we want the ability to mark key events as handled, so use this variant - // for those, we get all keystrokes in this case, so we will need to filter - // them later - void ensure_key_listener() - { - if (!m_bKeyEventListener) - { - Application::AddKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)); - m_bKeyEventListener = true; - } - } - - // we want the ability to know about mouse events that happen in our children - // so use this variant, we will need to filter them later - void ensure_mouse_listener() + if (!m_bEventListener) { - if (!m_bMouseEventListener) - { - Application::AddEventListener(LINK(this, SalInstanceWidget, MouseEventListener)); - m_bMouseEventListener = true; - } + m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, EventListener)); + m_bEventListener = true; } +} - virtual void HandleEventListener(VclWindowEvent& rEvent); - virtual bool HandleKeyEventListener(VclWindowEvent& rEvent); - virtual void HandleMouseEventListener(VclSimpleEvent& rEvent); - - void set_background(const Color& rColor) +// we want the ability to mark key events as handled, so use this variant +// for those, we get all keystrokes in this case, so we will need to filter +// them later +void SalInstanceWidget::ensure_key_listener() +{ + if (!m_bKeyEventListener) { - m_xWidget->SetControlBackground(rColor); - m_xWidget->SetBackground(m_xWidget->GetControlBackground()); - // turn off WB_CLIPCHILDREN otherwise the bg won't extend "under" - // transparent children of the widget - m_xWidget->SetStyle(m_xWidget->GetStyle() & ~WB_CLIPCHILDREN); + Application::AddKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)); + m_bKeyEventListener = true; } +} -public: - SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : m_xWidget(pWidget) - , m_pBuilder(pBuilder) - , m_bTakeOwnership(bTakeOwnership) - , m_bEventListener(false) - , m_bKeyEventListener(false) - , m_bMouseEventListener(false) - , m_nBlockNotify(0) +// we want the ability to know about mouse events that happen in our children +// so use this variant, we will need to filter them later +void SalInstanceWidget::ensure_mouse_listener() +{ + if (!m_bMouseEventListener) { + Application::AddEventListener(LINK(this, SalInstanceWidget, MouseEventListener)); + m_bMouseEventListener = true; } +} - virtual void set_sensitive(bool sensitive) override - { - m_xWidget->Enable(sensitive); - } +void SalInstanceWidget::set_background(const Color& rColor) +{ + m_xWidget->SetControlBackground(rColor); + m_xWidget->SetBackground(m_xWidget->GetControlBackground()); + // turn off WB_CLIPCHILDREN otherwise the bg won't extend "under" + // transparent children of the widget + m_xWidget->SetStyle(m_xWidget->GetStyle() & ~WB_CLIPCHILDREN); +} - virtual bool get_sensitive() const override - { - return m_xWidget->IsEnabled(); - } +SalInstanceWidget::SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : m_xWidget(pWidget) + , m_pBuilder(pBuilder) + , m_bTakeOwnership(bTakeOwnership) + , m_bEventListener(false) + , m_bKeyEventListener(false) + , m_bMouseEventListener(false) + , m_nBlockNotify(0) +{ +} - virtual bool get_visible() const override - { - return m_xWidget->IsVisible(); - } +void SalInstanceWidget::set_sensitive(bool sensitive) +{ + m_xWidget->Enable(sensitive); +} - virtual bool is_visible() const override - { - return m_xWidget->IsReallyVisible(); - } +bool SalInstanceWidget::get_sensitive() const +{ + return m_xWidget->IsEnabled(); +} - virtual void set_can_focus(bool bCanFocus) override - { - auto nStyle = m_xWidget->GetStyle() & ~(WB_TABSTOP | WB_NOTABSTOP); - if (bCanFocus) - nStyle |= WB_TABSTOP; - else - nStyle |= WB_NOTABSTOP; - m_xWidget->SetStyle(nStyle); - } +bool SalInstanceWidget::get_visible() const +{ + return m_xWidget->IsVisible(); +} - virtual void grab_focus() override - { - m_xWidget->GrabFocus(); - } +bool SalInstanceWidget::is_visible() const +{ + return m_xWidget->IsReallyVisible(); +} - virtual bool has_focus() const override - { - return m_xWidget->HasFocus(); - } +void SalInstanceWidget::set_can_focus(bool bCanFocus) +{ + auto nStyle = m_xWidget->GetStyle() & ~(WB_TABSTOP | WB_NOTABSTOP); + if (bCanFocus) + nStyle |= WB_TABSTOP; + else + nStyle |= WB_NOTABSTOP; + m_xWidget->SetStyle(nStyle); +} - virtual bool is_active() const override - { - return m_xWidget->IsActive(); - } +void SalInstanceWidget::grab_focus() +{ + m_xWidget->GrabFocus(); +} - virtual void set_has_default(bool has_default) override - { - m_xWidget->set_property("has-default", OUString::boolean(has_default)); - } +bool SalInstanceWidget::has_focus() const +{ + return m_xWidget->HasFocus(); +} - virtual bool get_has_default() const override - { - return m_xWidget->GetStyle() & WB_DEFBUTTON; - } +bool SalInstanceWidget::is_active() const +{ + return m_xWidget->IsActive(); +} - virtual void show() override - { - m_xWidget->Show(); - } +void SalInstanceWidget::set_has_default(bool has_default) +{ + m_xWidget->set_property("has-default", OUString::boolean(has_default)); +} - virtual void hide() override - { - m_xWidget->Hide(); - } +bool SalInstanceWidget::get_has_default() const +{ + return m_xWidget->GetStyle() & WB_DEFBUTTON; +} - virtual void set_size_request(int nWidth, int nHeight) override - { - m_xWidget->set_width_request(nWidth); - m_xWidget->set_height_request(nHeight); - } +void SalInstanceWidget::show() +{ + m_xWidget->Show(); +} - virtual Size get_size_request() const override - { - return Size(m_xWidget->get_width_request(), - m_xWidget->get_height_request()); - } +void SalInstanceWidget::hide() +{ + m_xWidget->Hide(); +} - virtual Size get_preferred_size() const override - { - return m_xWidget->get_preferred_size(); - } +void SalInstanceWidget::set_size_request(int nWidth, int nHeight) +{ + m_xWidget->set_width_request(nWidth); + m_xWidget->set_height_request(nHeight); +} - virtual float get_approximate_digit_width() const override - { - return m_xWidget->approximate_digit_width(); - } +Size SalInstanceWidget::get_size_request() const +{ + return Size(m_xWidget->get_width_request(), + m_xWidget->get_height_request()); +} - virtual int get_text_height() const override - { - return m_xWidget->GetTextHeight(); - } +Size SalInstanceWidget::get_preferred_size() const +{ + return m_xWidget->get_preferred_size(); +} - virtual Size get_pixel_size(const OUString& rText) const override - { - //TODO, or do I want GetTextBoundRect ?, just using width at the moment anyway - return Size(m_xWidget->GetTextWidth(rText), m_xWidget->GetTextHeight()); - } +float SalInstanceWidget::get_approximate_digit_width() const +{ + return m_xWidget->approximate_digit_width(); +} - virtual vcl::Font get_font() override - { - return m_xWidget->GetPointFont(*m_xWidget); - } +int SalInstanceWidget::get_text_height() const +{ + return m_xWidget->GetTextHeight(); +} - virtual OString get_buildable_name() const override - { - return m_xWidget->get_id().toUtf8(); - } +Size SalInstanceWidget::get_pixel_size(const OUString& rText) const +{ + //TODO, or do I want GetTextBoundRect ?, just using width at the moment anyway + return Size(m_xWidget->GetTextWidth(rText), m_xWidget->GetTextHeight()); +} - virtual void set_help_id(const OString& rId) override - { - return m_xWidget->SetHelpId(rId); - } +vcl::Font SalInstanceWidget::get_font() +{ + return m_xWidget->GetPointFont(*m_xWidget); +} - virtual OString get_help_id() const override - { - return m_xWidget->GetHelpId(); - } +OString SalInstanceWidget::get_buildable_name() const +{ + return m_xWidget->get_id().toUtf8(); +} - virtual void set_grid_left_attach(int nAttach) override - { - m_xWidget->set_grid_left_attach(nAttach); - } +void SalInstanceWidget::set_help_id(const OString& rId) +{ + return m_xWidget->SetHelpId(rId); +} - virtual int get_grid_left_attach() const override - { - return m_xWidget->get_grid_left_attach(); - } +OString SalInstanceWidget::get_help_id() const +{ + return m_xWidget->GetHelpId(); +} - virtual void set_grid_width(int nCols) override - { - m_xWidget->set_grid_width(nCols); - } +void SalInstanceWidget::set_grid_left_attach(int nAttach) +{ + m_xWidget->set_grid_left_attach(nAttach); +} - virtual void set_grid_top_attach(int nAttach) override - { - m_xWidget->set_grid_top_attach(nAttach); - } +int SalInstanceWidget::get_grid_left_attach() const +{ + return m_xWidget->get_grid_left_attach(); +} - virtual int get_grid_top_attach() const override - { - return m_xWidget->get_grid_top_attach(); - } +void SalInstanceWidget::set_grid_width(int nCols) +{ + m_xWidget->set_grid_width(nCols); +} - virtual void set_hexpand(bool bExpand) override - { - m_xWidget->set_hexpand(bExpand); - } +void SalInstanceWidget::set_grid_top_attach(int nAttach) +{ + m_xWidget->set_grid_top_attach(nAttach); +} - virtual bool get_hexpand() const override - { - return m_xWidget->get_hexpand(); - } +int SalInstanceWidget::get_grid_top_attach() const +{ + return m_xWidget->get_grid_top_attach(); +} - virtual void set_vexpand(bool bExpand) override - { - m_xWidget->set_vexpand(bExpand); - } +void SalInstanceWidget::set_hexpand(bool bExpand) +{ + m_xWidget->set_hexpand(bExpand); +} - virtual bool get_vexpand() const override - { - return m_xWidget->get_vexpand(); - } +bool SalInstanceWidget::get_hexpand() const +{ + return m_xWidget->get_hexpand(); +} - virtual void set_secondary(bool bSecondary) override - { - m_xWidget->set_secondary(bSecondary); - } +void SalInstanceWidget::set_vexpand(bool bExpand) +{ + m_xWidget->set_vexpand(bExpand); +} - virtual void set_margin_top(int nMargin) override - { - m_xWidget->set_margin_top(nMargin); - } +bool SalInstanceWidget::get_vexpand() const +{ + return m_xWidget->get_vexpand(); +} - virtual void set_margin_bottom(int nMargin) override - { - m_xWidget->set_margin_bottom(nMargin); - } +void SalInstanceWidget::set_secondary(bool bSecondary) +{ + m_xWidget->set_secondary(bSecondary); +} - virtual void set_margin_left(int nMargin) override - { - m_xWidget->set_margin_left(nMargin); - } +void SalInstanceWidget::set_margin_top(int nMargin) +{ + m_xWidget->set_margin_top(nMargin); +} - virtual void set_margin_right(int nMargin) override - { - m_xWidget->set_margin_bottom(nMargin); - } +void SalInstanceWidget::set_margin_bottom(int nMargin) +{ + m_xWidget->set_margin_bottom(nMargin); +} - virtual int get_margin_top() const override - { - return m_xWidget->get_margin_top(); - } +void SalInstanceWidget::set_margin_left(int nMargin) +{ + m_xWidget->set_margin_left(nMargin); +} - virtual int get_margin_bottom() const override - { - return m_xWidget->get_margin_bottom(); - } +void SalInstanceWidget::set_margin_right(int nMargin) +{ + m_xWidget->set_margin_bottom(nMargin); +} - virtual int get_margin_left() const override - { - return m_xWidget->get_margin_left(); - } +int SalInstanceWidget::get_margin_top() const +{ + return m_xWidget->get_margin_top(); +} - virtual int get_margin_right() const override - { - return m_xWidget->get_margin_bottom(); - } +int SalInstanceWidget::get_margin_bottom() const +{ + return m_xWidget->get_margin_bottom(); +} - virtual void set_accessible_name(const OUString& rName) override - { - m_xWidget->SetAccessibleName(rName); - } +int SalInstanceWidget::get_margin_left() const +{ + return m_xWidget->get_margin_left(); +} - virtual OUString get_accessible_name() const override - { - return m_xWidget->GetAccessibleName(); - } +int SalInstanceWidget::get_margin_right() const +{ + return m_xWidget->get_margin_bottom(); +} - virtual OUString get_accessible_description() const override - { - return m_xWidget->GetAccessibleDescription(); - } +void SalInstanceWidget::set_accessible_name(const OUString& rName) +{ + m_xWidget->SetAccessibleName(rName); +} - virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) override - { - vcl::Window* pAtkLabel = pLabel ? dynamic_cast<SalInstanceWidget&>(*pLabel).getWidget() : nullptr; - m_xWidget->SetAccessibleRelationLabeledBy(pAtkLabel); - } +OUString SalInstanceWidget::get_accessible_name() const +{ + return m_xWidget->GetAccessibleName(); +} - virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) override - { - vcl::Window* pAtkLabeled = pLabeled ? dynamic_cast<SalInstanceWidget&>(*pLabeled).getWidget() : nullptr; - m_xWidget->SetAccessibleRelationLabelFor(pAtkLabeled); - } +OUString SalInstanceWidget::get_accessible_description() const +{ + return m_xWidget->GetAccessibleDescription(); +} - virtual void add_extra_accessible_relation(const css::accessibility::AccessibleRelation &rRelation) override - { - m_xWidget->AddExtraAccessibleRelation(rRelation); - } +void SalInstanceWidget::set_accessible_relation_labeled_by(weld::Widget* pLabel) +{ + vcl::Window* pAtkLabel = pLabel ? dynamic_cast<SalInstanceWidget&>(*pLabel).getWidget() : nullptr; + m_xWidget->SetAccessibleRelationLabeledBy(pAtkLabel); +} - virtual void clear_extra_accessible_relations() override - { - m_xWidget->ClearExtraAccessibleRelations(); - } +void SalInstanceWidget::set_accessible_relation_label_for(weld::Widget* pLabeled) +{ + vcl::Window* pAtkLabeled = pLabeled ? dynamic_cast<SalInstanceWidget&>(*pLabeled).getWidget() : nullptr; + m_xWidget->SetAccessibleRelationLabelFor(pAtkLabeled); +} - virtual void set_tooltip_text(const OUString& rTip) override - { - m_xWidget->SetQuickHelpText(rTip); - } +void SalInstanceWidget::add_extra_accessible_relation(const css::accessibility::AccessibleRelation &rRelation) +{ + m_xWidget->AddExtraAccessibleRelation(rRelation); +} - virtual OUString get_tooltip_text() const override - { - return m_xWidget->GetQuickHelpText(); - } +void SalInstanceWidget::clear_extra_accessible_relations() +{ + m_xWidget->ClearExtraAccessibleRelations(); +} - virtual void connect_focus_in(const Link<Widget&, void>& rLink) override - { - ensure_event_listener(); - weld::Widget::connect_focus_in(rLink); - } +void SalInstanceWidget::set_tooltip_text(const OUString& rTip) +{ + m_xWidget->SetQuickHelpText(rTip); +} - virtual void connect_mnemonic_activate(const Link<Widget&, bool>& rLink) override - { - m_xWidget->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget, MnemonicActivateHdl)); - weld::Widget::connect_mnemonic_activate(rLink); - } +OUString SalInstanceWidget::get_tooltip_text() const +{ + return m_xWidget->GetQuickHelpText(); +} - virtual void connect_focus_out(const Link<Widget&, void>& rLink) override - { - ensure_event_listener(); - weld::Widget::connect_focus_out(rLink); - } +void SalInstanceWidget::connect_focus_in(const Link<Widget&, void>& rLink) +{ + ensure_event_listener(); + weld::Widget::connect_focus_in(rLink); +} - virtual void connect_size_allocate(const Link<const Size&, void>& rLink) override - { - ensure_event_listener(); - weld::Widget::connect_size_allocate(rLink); - } +void SalInstanceWidget::connect_mnemonic_activate(const Link<Widget&, bool>& rLink) +{ + m_xWidget->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget, MnemonicActivateHdl)); + weld::Widget::connect_mnemonic_activate(rLink); +} - virtual void connect_mouse_press(const Link<const MouseEvent&, bool>& rLink) override - { - ensure_mouse_listener(); - weld::Widget::connect_mouse_press(rLink); - } +void SalInstanceWidget::connect_focus_out(const Link<Widget&, void>& rLink) +{ + ensure_event_listener(); + weld::Widget::connect_focus_out(rLink); +} - virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) override - { - ensure_mouse_listener(); - weld::Widget::connect_mouse_move(rLink); - } +void SalInstanceWidget::connect_size_allocate(const Link<const Size&, void>& rLink) +{ + ensure_event_listener(); + weld::Widget::connect_size_allocate(rLink); +} - virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) override - { - ensure_mouse_listener(); - weld::Widget::connect_mouse_release(rLink); - } +void SalInstanceWidget::connect_mouse_press(const Link<const MouseEvent&, bool>& rLink) +{ + ensure_mouse_listener(); + weld::Widget::connect_mouse_press(rLink); +} - virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override - { - ensure_key_listener(); - weld::Widget::connect_key_press(rLink); - } +void SalInstanceWidget::connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) +{ + ensure_mouse_listener(); + weld::Widget::connect_mouse_move(rLink); +} - virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink) override - { - ensure_key_listener(); - weld::Widget::connect_key_release(rLink); - } +void SalInstanceWidget::connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) +{ + ensure_mouse_listener(); + weld::Widget::connect_mouse_release(rLink); +} - virtual bool get_extents_relative_to(Widget& rRelative, int& x, int &y, int& width, int &height) override - { - tools::Rectangle aRect(m_xWidget->GetWindowExtentsRelative(dynamic_cast<SalInstanceWidget&>(rRelative).getWidget())); - x = aRect.Left(); - y = aRect.Top(); - width = aRect.GetWidth(); - height = aRect.GetHeight(); - return true; - } +void SalInstanceWidget::connect_key_press(const Link<const KeyEvent&, bool>& rLink) +{ + ensure_key_listener(); + weld::Widget::connect_key_press(rLink); +} - virtual void grab_add() override - { - m_xWidget->CaptureMouse(); - } +void SalInstanceWidget::connect_key_release(const Link<const KeyEvent&, bool>& rLink) +{ + ensure_key_listener(); + weld::Widget::connect_key_release(rLink); +} - virtual bool has_grab() const override - { - return m_xWidget->IsMouseCaptured(); - } +bool SalInstanceWidget::get_extents_relative_to(Widget& rRelative, int& x, int &y, int& width, int &height) +{ + tools::Rectangle aRect(m_xWidget->GetWindowExtentsRelative(dynamic_cast<SalInstanceWidget&>(rRelative).getWidget())); + x = aRect.Left(); + y = aRect.Top(); + width = aRect.GetWidth(); + height = aRect.GetHeight(); + return true; +} - virtual void grab_remove() override - { - m_xWidget->ReleaseMouse(); - } +void SalInstanceWidget::grab_add() +{ + m_xWidget->CaptureMouse(); +} - virtual bool get_direction() const override - { - return m_xWidget->IsRTLEnabled(); - } +bool SalInstanceWidget::has_grab() const +{ + return m_xWidget->IsMouseCaptured(); +} - virtual void set_direction(bool bRTL) override - { - m_xWidget->EnableRTL(bRTL); - } +void SalInstanceWidget::grab_remove() +{ + m_xWidget->ReleaseMouse(); +} - virtual void freeze() override - { - m_xWidget->SetUpdateMode(false); - } +bool SalInstanceWidget::get_direction() const +{ + return m_xWidget->IsRTLEnabled(); +} - virtual void thaw() override - { - m_xWidget->SetUpdateMode(true); - } +void SalInstanceWidget::set_direction(bool bRTL) +{ + m_xWidget->EnableRTL(bRTL); +} - virtual std::unique_ptr<weld::Container> weld_parent() const override; +void SalInstanceWidget::freeze() +{ + m_xWidget->SetUpdateMode(false); +} - virtual ~SalInstanceWidget() override - { - if (m_aMnemonicActivateHdl.IsSet()) - m_xWidget->SetMnemonicActivateHdl(Link<vcl::Window&,bool>()); - if (m_bMouseEventListener) - Application::RemoveEventListener(LINK(this, SalInstanceWidget, MouseEventListener)); - if (m_bKeyEventListener) - Application::RemoveKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)); - if (m_bEventListener) - m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, EventListener)); - if (m_bTakeOwnership) - m_xWidget.disposeAndClear(); - } +void SalInstanceWidget::thaw() +{ + m_xWidget->SetUpdateMode(true); +} - vcl::Window* getWidget() - { - return m_xWidget; - } +SalInstanceWidget::~SalInstanceWidget() +{ + if (m_aMnemonicActivateHdl.IsSet()) + m_xWidget->SetMnemonicActivateHdl(Link<vcl::Window&,bool>()); + if (m_bMouseEventListener) + Application::RemoveEventListener(LINK(this, SalInstanceWidget, MouseEventListener)); + if (m_bKeyEventListener) + Application::RemoveKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)); + if (m_bEventListener) + m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, EventListener)); + if (m_bTakeOwnership) + m_xWidget.disposeAndClear(); +} - void disable_notify_events() - { - ++m_nBlockNotify; - } +vcl::Window* SalInstanceWidget::getWidget() +{ + return m_xWidget; +} - bool notify_events_disabled() - { - return m_nBlockNotify != 0; - } +void SalInstanceWidget::disable_notify_events() +{ + ++m_nBlockNotify; +} - void enable_notify_events() - { - --m_nBlockNotify; - } +bool SalInstanceWidget::notify_events_disabled() +{ + return m_nBlockNotify != 0; +} - virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) override; +void SalInstanceWidget::enable_notify_events() +{ + --m_nBlockNotify; +} - virtual OUString strip_mnemonic(const OUString &rLabel) const override - { - return rLabel.replaceFirst("~", ""); - } +OUString SalInstanceWidget::strip_mnemonic(const OUString &rLabel) const +{ + return rLabel.replaceFirst("~", ""); +} - virtual VclPtr<VirtualDevice> create_virtual_device() const override - { - // create with (annoying) separate alpha layer that LibreOffice itself uses - return VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); - } +VclPtr<VirtualDevice> SalInstanceWidget::create_virtual_device() const +{ + // create with (annoying) separate alpha layer that LibreOffice itself uses + return VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); +} - virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override - { - return m_xWidget->GetDropTarget(); - } +css::uno::Reference<css::datatransfer::dnd::XDropTarget> SalInstanceWidget::get_drop_target() +{ + return m_xWidget->GetDropTarget(); +} - virtual void set_stack_background() override - { - set_background(m_xWidget->GetSettings().GetStyleSettings().GetWindowColor());; - } +void SalInstanceWidget::set_stack_background() +{ + set_background(m_xWidget->GetSettings().GetStyleSettings().GetWindowColor());; +} - virtual void set_highlight_background() override - { - set_background(m_xWidget->GetSettings().GetStyleSettings().GetHighlightColor());; - } +void SalInstanceWidget::set_highlight_background() +{ + set_background(m_xWidget->GetSettings().GetStyleSettings().GetHighlightColor());; +} - SystemWindow* getSystemWindow() - { - return m_xWidget->GetSystemWindow(); - } -}; +SystemWindow* SalInstanceWidget::getSystemWindow() +{ + return m_xWidget->GetSystemWindow(); +} void SalInstanceWidget::HandleEventListener(VclWindowEvent& rEvent) { @@ -1095,66 +1065,61 @@ public: } }; -class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Container -{ -protected: - VclPtr<vcl::Window> m_xContainer; - -private: - void implResetDefault(const vcl::Window* _pWindow) - { - vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); - while (pChildLoop) +void SalInstanceContainer::implResetDefault(const vcl::Window* _pWindow) +{ + vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); + while (pChildLoop) + { + // does the window participate in the tabbing order? + if (pChildLoop->GetStyle() & WB_DIALOGCONTROL) + implResetDefault(pChildLoop); + + // is it a button? + WindowType eType = pChildLoop->GetType(); + if ( (WindowType::PUSHBUTTON == eType) + || (WindowType::OKBUTTON == eType) + || (WindowType::CANCELBUTTON == eType) + || (WindowType::HELPBUTTON == eType) + || (WindowType::IMAGEBUTTON == eType) + || (WindowType::MENUBUTTON == eType) + || (WindowType::MOREBUTTON == eType) + ) { - // does the window participate in the tabbing order? - if (pChildLoop->GetStyle() & WB_DIALOGCONTROL) - implResetDefault(pChildLoop); - - // is it a button? - WindowType eType = pChildLoop->GetType(); - if ( (WindowType::PUSHBUTTON == eType) - || (WindowType::OKBUTTON == eType) - || (WindowType::CANCELBUTTON == eType) - || (WindowType::HELPBUTTON == eType) - || (WindowType::IMAGEBUTTON == eType) - || (WindowType::MENUBUTTON == eType) - || (WindowType::MOREBUTTON == eType) - ) - { - pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON); - } - - // the next one ... - pChildLoop = pChildLoop->GetWindow(GetWindowType::Next); + pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON); } - } -public: - SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership) - , m_xContainer(pContainer) - { - } - virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override - { - SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); - assert(pVclWidget); - SalInstanceContainer* pNewVclParent = dynamic_cast<SalInstanceContainer*>(pNewParent); - assert(!pNewParent || pNewVclParent); - pVclWidget->getWidget()->SetParent(pNewVclParent ? pNewVclParent->getWidget() : nullptr); - } - virtual void recursively_unset_default_buttons() override - { - implResetDefault(m_xContainer.get()); - } - virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override - { - auto xPage = VclPtr<VclBin>::Create(m_xContainer.get()); - xPage->set_expand(true); - xPage->Show(); - return css::uno::Reference<css::awt::XWindow>(xPage->GetComponentInterface(), css::uno::UNO_QUERY); + // the next one ... + pChildLoop = pChildLoop->GetWindow(GetWindowType::Next); } -}; +} + +SalInstanceContainer::SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership) + , m_xContainer(pContainer) +{ +} + +void SalInstanceContainer::move(weld::Widget* pWidget, weld::Container* pNewParent) +{ + SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); + assert(pVclWidget); + SalInstanceContainer* pNewVclParent = dynamic_cast<SalInstanceContainer*>(pNewParent); + assert(!pNewParent || pNewVclParent); + pVclWidget->getWidget()->SetParent(pNewVclParent ? pNewVclParent->getWidget() : nullptr); +} + +void SalInstanceContainer::recursively_unset_default_buttons() +{ + implResetDefault(m_xContainer.get()); +} + +css::uno::Reference<css::awt::XWindow> SalInstanceContainer::CreateChildFrame() +{ + auto xPage = VclPtr<VclBin>::Create(m_xContainer.get()); + xPage->set_expand(true); + xPage->Show(); + return css::uno::Reference<css::awt::XWindow>(xPage->GetComponentInterface(), css::uno::UNO_QUERY); +} std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const { @@ -1207,193 +1172,182 @@ namespace } } -class SalInstanceWindow : public SalInstanceContainer, public virtual weld::Window +void SalInstanceWindow::override_child_help(vcl::Window* pParent) { -private: - VclPtr<vcl::Window> m_xWindow; - - DECL_LINK(HelpHdl, vcl::Window&, bool); - - void override_child_help(vcl::Window* pParent) - { - for (vcl::Window *pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next)) - override_child_help(pChild); - pParent->SetHelpHdl(LINK(this, SalInstanceWindow, HelpHdl)); - } + for (vcl::Window *pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next)) + override_child_help(pChild); + pParent->SetHelpHdl(LINK(this, SalInstanceWindow, HelpHdl)); +} - void clear_child_help(vcl::Window* pParent) - { - for (vcl::Window *pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next)) - clear_child_help(pChild); - pParent->SetHelpHdl(Link<vcl::Window&,bool>()); - } +void SalInstanceWindow::clear_child_help(vcl::Window* pParent) +{ + for (vcl::Window *pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next)) + clear_child_help(pChild); + pParent->SetHelpHdl(Link<vcl::Window&,bool>()); +} -public: - SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership) - , m_xWindow(pWindow) - { - override_child_help(m_xWindow); - } +SalInstanceWindow::SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership) + , m_xWindow(pWindow) +{ + override_child_help(m_xWindow); +} - virtual void set_title(const OUString& rTitle) override - { - m_xWindow->SetText(rTitle); - } +void SalInstanceWindow::set_title(const OUString& rTitle) +{ + m_xWindow->SetText(rTitle); +} - virtual OUString get_title() const override - { - return m_xWindow->GetText(); - } +OUString SalInstanceWindow::get_title() const +{ + return m_xWindow->GetText(); +} - void help(); +void SalInstanceWindow::set_busy_cursor(bool bBusy) +{ + if (bBusy) + m_xWindow->EnterWait(); + else + m_xWindow->LeaveWait(); +} - virtual void set_busy_cursor(bool bBusy) override - { - if (bBusy) - m_xWindow->EnterWait(); - else - m_xWindow->LeaveWait(); - } +css::uno::Reference<css::awt::XWindow> SalInstanceWindow::GetXWindow() +{ + css::uno::Reference<css::awt::XWindow> xWindow(m_xWindow->GetComponentInterface(), css::uno::UNO_QUERY); + return xWindow; +} - virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override +void SalInstanceWindow::resize_to_request() +{ + if (SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get())) { - css::uno::Reference<css::awt::XWindow> xWindow(m_xWindow->GetComponentInterface(), css::uno::UNO_QUERY); - return xWindow; + pSysWin->setOptimalLayoutSize(); + return; } - - virtual void resize_to_request() override + if (DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(m_xWindow.get())) { - if (SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get())) - { - pSysWin->setOptimalLayoutSize(); - return; - } - if (DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(m_xWindow.get())) - { - pDockWin->setOptimalLayoutSize(); - return; - } - assert(false && "must be system or docking window"); + pDockWin->setOptimalLayoutSize(); + return; } + assert(false && "must be system or docking window"); +} - virtual void set_modal(bool bModal) override - { - m_xWindow->ImplGetFrame()->SetModal(bModal); - } +void SalInstanceWindow::set_modal(bool bModal) +{ + m_xWindow->ImplGetFrame()->SetModal(bModal); +} - virtual bool get_modal() const override - { - return m_xWindow->ImplGetFrame()->GetModal(); - } +bool SalInstanceWindow::get_modal() const +{ + return m_xWindow->ImplGetFrame()->GetModal(); +} - virtual void window_move(int x, int y) override - { - m_xWindow->SetPosPixel(Point(x, y)); - } +void SalInstanceWindow::window_move(int x, int y) +{ + m_xWindow->SetPosPixel(Point(x, y)); +} - virtual Size get_size() const override - { - return m_xWindow->GetSizePixel(); - } +Size SalInstanceWindow::get_size() const +{ + return m_xWindow->GetSizePixel(); +} - virtual Point get_position() const override - { - return m_xWindow->GetPosPixel(); - } +Point SalInstanceWindow::get_position() const +{ + return m_xWindow->GetPosPixel(); +} - virtual tools::Rectangle get_monitor_workarea() const override - { - return m_xWindow->GetDesktopRectPixel(); - } +tools::Rectangle SalInstanceWindow::get_monitor_workarea() const +{ + return m_xWindow->GetDesktopRectPixel(); +} - virtual void set_centered_on_parent(bool /*bTrackGeometryRequests*/) override +void SalInstanceWindow::set_centered_on_parent(bool /*bTrackGeometryRequests*/) +{ + if (vcl::Window* pParent = m_xWidget->GetParent()) { - if (vcl::Window* pParent = m_xWidget->GetParent()) - { - Size aParentGeometry(pParent->GetSizePixel()); - Size aGeometry(m_xWidget->get_preferred_size()); - auto nX = (aParentGeometry.Width() - aGeometry.Width()) / 2; - auto nY = (aParentGeometry.Height() - aGeometry.Height()) / 2; - m_xWidget->SetPosPixel(Point(nX, nY)); - } + Size aParentGeometry(pParent->GetSizePixel()); + Size aGeometry(m_xWidget->get_preferred_size()); + auto nX = (aParentGeometry.Width() - aGeometry.Width()) / 2; + auto nY = (aParentGeometry.Height() - aGeometry.Height()) / 2; + m_xWidget->SetPosPixel(Point(nX, nY)); } +} - virtual bool get_resizable() const override - { - return m_xWindow->GetStyle() & WB_SIZEABLE; - } +bool SalInstanceWindow::get_resizable() const +{ + return m_xWindow->GetStyle() & WB_SIZEABLE; +} - virtual bool has_toplevel_focus() const override - { - return m_xWindow->HasChildPathFocus(); - } +bool SalInstanceWindow::has_toplevel_focus() const +{ + return m_xWindow->HasChildPathFocus(); +} - virtual void present() override - { - m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask); - } +void SalInstanceWindow::present() +{ + m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask); +} - virtual void set_window_state(const OString& rStr) override - { - SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); - assert(pSysWin); - pSysWin->SetWindowState(rStr); - } +void SalInstanceWindow::set_window_state(const OString& rStr) +{ + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); + assert(pSysWin); + pSysWin->SetWindowState(rStr); +} - virtual OString get_window_state(WindowStateMask nMask) const override - { - SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); - assert(pSysWin); - return pSysWin->GetWindowState(nMask); - } +OString SalInstanceWindow::get_window_state(WindowStateMask nMask) const +{ + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); + assert(pSysWin); + return pSysWin->GetWindowState(nMask); +} - virtual SystemEnvData get_system_data() const override - { - return *m_xWindow->GetSystemData(); - } +SystemEnvData SalInstanceWindow::get_system_data() const +{ + return *m_xWindow->GetSystemData(); +} - virtual void connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) override - { - ensure_event_listener(); - weld::Window::connect_toplevel_focus_changed(rLink); - } +void SalInstanceWindow::connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) +{ + ensure_event_listener(); + weld::Window::connect_toplevel_focus_changed(rLink); +} - virtual void HandleEventListener(VclWindowEvent& rEvent) override +void SalInstanceWindow::HandleEventListener(VclWindowEvent& rEvent) +{ + if (rEvent.GetId() == VclEventId::WindowActivate || rEvent.GetId() == VclEventId::WindowDeactivate) { - if (rEvent.GetId() == VclEventId::WindowActivate || rEvent.GetId() == VclEventId::WindowDeactivate) - { - signal_toplevel_focus_changed(); - return; - } - SalInstanceContainer::HandleEventListener(rEvent); + signal_toplevel_focus_changed(); + return; } + SalInstanceContainer::HandleEventListener(rEvent); +} - virtual void draw(VirtualDevice& rOutput) override - { - SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); - assert(pSysWin); - pSysWin->createScreenshot(rOutput); - } +void SalInstanceWindow::draw(VirtualDevice& rOutput) +{ + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); + assert(pSysWin); + pSysWin->createScreenshot(rOutput); +} - virtual weld::ScreenShotCollection collect_screenshot_data() override - { - weld::ScreenShotCollection aRet; +weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data() +{ + weld::ScreenShotCollection aRet; - // collect all children. Choose start pos to be negative - // of target dialog's position to get all positions relative to (0,0) - const Point aParentPos(m_xWindow->GetPosPixel()); - const basegfx::B2IPoint aTopLeft(-aParentPos.X(), -aParentPos.Y()); - CollectChildren(*m_xWindow, aTopLeft, aRet); + // collect all children. Choose start pos to be negative + // of target dialog's position to get all positions relative to (0,0) + const Point aParentPos(m_xWindow->GetPosPixel()); + const basegfx::B2IPoint aTopLeft(-aParentPos.X(), -aParentPos.Y()); + CollectChildren(*m_xWindow, aTopLeft, aRet); - return aRet; - } + return aRet; +} - virtual ~SalInstanceWindow() override - { - clear_child_help(m_xWindow); - } -}; +SalInstanceWindow::~SalInstanceWindow() +{ + clear_child_help(m_xWindow); +} IMPL_LINK_NOARG(SalInstanceWindow, HelpHdl, vcl::Window&, bool) { @@ -1426,195 +1380,177 @@ namespace } } -class SalInstanceDialog : public SalInstanceWindow, public virtual weld::Dialog +SalInstanceDialog::SalInstanceDialog(::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWindow(pDialog, pBuilder, bTakeOwnership) + , m_xDialog(pDialog) + , m_nOldEditWidthReq(0) + , m_nOldBorderWidth(0) { -private: - VclPtr<::Dialog> m_xDialog; - - // for calc ref dialog that shrink to range selection widgets and resize back - VclPtr<vcl::Window> m_xRefEdit; - std::vector<VclPtr<vcl::Window> > m_aHiddenWidgets; // vector of hidden Controls - long m_nOldEditWidthReq; // Original width request of the input field - sal_Int32 m_nOldBorderWidth; // border width for expanded dialog - - DECL_LINK(PopupScreenShotMenuHdl, const CommandEvent&, bool); - -public: - SalInstanceDialog(::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceWindow(pDialog, pBuilder, bTakeOwnership) - , m_xDialog(pDialog) - , m_nOldEditWidthReq(0) - , m_nOldBorderWidth(0) - { - const bool bScreenshotMode(officecfg::Office::Common::Misc::ScreenshotMode::get()); - if (bScreenshotMode) - { - m_xDialog->SetPopupMenuHdl(LINK(this, SalInstanceDialog, PopupScreenShotMenuHdl)); - } - } - - virtual bool runAsync(std::shared_ptr<weld::DialogController> aOwner, const std::function<void(sal_Int32)> &rEndDialogFn) override - { - VclAbstractDialog::AsyncContext aCtx; - aCtx.mxOwnerDialogController = aOwner; - aCtx.maEndDialogFn = rEndDialogFn; - VclButtonBox* pActionArea = m_xDialog->get_action_area(); - if (pActionArea) - pActionArea->sort_native_button_order(); - return m_xDialog->StartExecuteAsync(aCtx); - } - - virtual bool runAsync(std::shared_ptr<Dialog> const & rxSelf, const std::function<void(sal_Int32)> &rEndDialogFn) override + const bool bScreenshotMode(officecfg::Office::Common::Misc::ScreenshotMode::get()); + if (bScreenshotMode) { - assert( rxSelf.get() == this ); - VclAbstractDialog::AsyncContext aCtx; - // In order to store a shared_ptr to ourself, we have to have been constructed by make_shared, - // which is that rxSelf enforces. - aCtx.mxOwnerSelf = rxSelf; - aCtx.maEndDialogFn = rEndDialogFn; - VclButtonBox* pActionArea = m_xDialog->get_action_area(); - if (pActionArea) - pActionArea->sort_native_button_order(); - return m_xDialog->StartExecuteAsync(aCtx); + m_xDialog->SetPopupMenuHdl(LINK(this, SalInstanceDialog, PopupScreenShotMenuHdl)); } +} - virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override - { - SalInstanceWidget* pVclEdit = dynamic_cast<SalInstanceWidget*>(pEdit); - assert(pVclEdit); - SalInstanceWidget* pVclButton = dynamic_cast<SalInstanceWidget*>(pButton); - - vcl::Window* pRefEdit = pVclEdit->getWidget(); - vcl::Window* pRefBtn = pVclButton ? pVclButton->getWidget() : nullptr; +bool SalInstanceDialog::runAsync(std::shared_ptr<weld::DialogController> aOwner, const std::function<void(sal_Int32)> &rEndDialogFn) +{ + VclAbstractDialog::AsyncContext aCtx; + aCtx.mxOwnerDialogController = aOwner; + aCtx.maEndDialogFn = rEndDialogFn; + VclButtonBox* pActionArea = m_xDialog->get_action_area(); + if (pActionArea) + pActionArea->sort_native_button_order(); + return m_xDialog->StartExecuteAsync(aCtx); +} - auto nOldEditWidth = pRefEdit->GetSizePixel().Width(); - m_nOldEditWidthReq = pRefEdit->get_width_request(); +bool SalInstanceDialog::runAsync(std::shared_ptr<Dialog> const & rxSelf, const std::function<void(sal_Int32)> &rEndDialogFn) +{ + assert( rxSelf.get() == this ); + VclAbstractDialog::AsyncContext aCtx; + // In order to store a shared_ptr to ourself, we have to have been constructed by make_shared, + // which is that rxSelf enforces. + aCtx.mxOwnerSelf = rxSelf; + aCtx.maEndDialogFn = rEndDialogFn; + VclButtonBox* pActionArea = m_xDialog->get_action_area(); + if (pActionArea) + pActionArea->sort_native_button_order(); + return m_xDialog->StartExecuteAsync(aCtx); +} - //We want just pRefBtn and pRefEdit to be shown - //mark widgets we want to be visible, starting with pRefEdit - //and all its direct parents. - winset aVisibleWidgets; - vcl::Window *pContentArea = m_xDialog->get_content_area(); - for (vcl::Window *pCandidate = pRefEdit; - pCandidate && (pCandidate != pContentArea && pCandidate->IsVisible()); - pCandidate = pCandidate->GetWindow(GetWindowType::RealParent)) - { - aVisibleWidgets.insert(pCandidate); - } - //same again with pRefBtn, except stop if there's a - //shared parent in the existing widgets - for (vcl::Window *pCandidate = pRefBtn; - pCandidate && (pCandidate != pContentArea && pCandidate->IsVisible()); - pCandidate = pCandidate->GetWindow(GetWindowType::RealParent)) - { - if (aVisibleWidgets.insert(pCandidate).second) - break; - } +void SalInstanceDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton) +{ + SalInstanceWidget* pVclEdit = dynamic_cast<SalInstanceWidget*>(pEdit); + assert(pVclEdit); + SalInstanceWidget* pVclButton = dynamic_cast<SalInstanceWidget*>(pButton); - //hide everything except the aVisibleWidgets - hideUnless(pContentArea, aVisibleWidgets, m_aHiddenWidgets); + vcl::Window* pRefEdit = pVclEdit->getWidget(); + vcl::Window* pRefBtn = pVclButton ? pVclButton->getWidget() : nullptr; - // the insert function case has an initially hidden edit widget, so it has - // not start size, so take larger of actual size and size request - pRefEdit->set_width_request(std::max(nOldEditWidth, m_nOldEditWidthReq)); - m_nOldBorderWidth = m_xDialog->get_border_width(); - m_xDialog->set_border_width(0); - if (vcl::Window *pActionArea = m_xDialog->get_action_area()) - pActionArea->Hide(); - m_xDialog->setOptimalLayoutSize(); - m_xRefEdit = pRefEdit; - } + auto nOldEditWidth = pRefEdit->GetSizePixel().Width(); + m_nOldEditWidthReq = pRefEdit->get_width_request(); - virtual void undo_collapse() override + //We want just pRefBtn and pRefEdit to be shown + //mark widgets we want to be visible, starting with pRefEdit + //and all its direct parents. + winset aVisibleWidgets; + vcl::Window *pContentArea = m_xDialog->get_content_area(); + for (vcl::Window *pCandidate = pRefEdit; + pCandidate && (pCandidate != pContentArea && pCandidate->IsVisible()); + pCandidate = pCandidate->GetWindow(GetWindowType::RealParent)) { - // All others: Show(); - for (VclPtr<vcl::Window> const & pWindow : m_aHiddenWidgets) - { - pWindow->Show(); - } - m_aHiddenWidgets.clear(); - - m_xRefEdit->set_width_request(m_nOldEditWidthReq); - m_xRefEdit.clear(); - m_xDialog->set_border_width(m_nOldBorderWidth); - if (vcl::Window *pActionArea = m_xDialog->get_action_area()) - pActionArea->Show(); - m_xDialog->setOptimalLayoutSize(); + aVisibleWidgets.insert(pCandidate); } - - virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) override + //same again with pRefBtn, except stop if there's a + //shared parent in the existing widgets + for (vcl::Window *pCandidate = pRefBtn; + pCandidate && (pCandidate != pContentArea && pCandidate->IsVisible()); + pCandidate = pCandidate->GetWindow(GetWindowType::RealParent)) { - m_xDialog->SetInstallLOKNotifierHdl(rLink); + if (aVisibleWidgets.insert(pCandidate).second) + break; } - virtual int run() override - { - VclButtonBox* pActionArea = m_xDialog->get_action_area(); - if (pActionArea) - pActionArea->sort_native_button_order(); - return m_xDialog->Execute(); - } + //hide everything except the aVisibleWidgets + hideUnless(pContentArea, aVisibleWidgets, m_aHiddenWidgets); + + // the insert function case has an initially hidden edit widget, so it has + // not start size, so take larger of actual size and size request + pRefEdit->set_width_request(std::max(nOldEditWidth, m_nOldEditWidthReq)); + m_nOldBorderWidth = m_xDialog->get_border_width(); + m_xDialog->set_border_width(0); + if (vcl::Window *pActionArea = m_xDialog->get_action_area()) + pActionArea->Hide(); + m_xDialog->setOptimalLayoutSize(); + m_xRefEdit = pRefEdit; +} - virtual void response(int nResponse) override +void SalInstanceDialog::undo_collapse() +{ + // All others: Show(); + for (VclPtr<vcl::Window> const & pWindow : m_aHiddenWidgets) { - m_xDialog->EndDialog(nResponse); + pWindow->Show(); } + m_aHiddenWidgets.clear(); - virtual void add_button(const OUString& rText, int nResponse, const OString& rHelpId) override - { - VclButtonBox* pBox = m_xDialog->get_action_area(); - VclPtr<PushButton> xButton(VclPtr<PushButton>::Create(pBox, WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER)); - xButton->SetText(rText); - xButton->SetHelpId(rHelpId); + m_xRefEdit->set_width_request(m_nOldEditWidthReq); + m_xRefEdit.clear(); + m_xDialog->set_border_width(m_nOldBorderWidth); + if (vcl::Window *pActionArea = m_xDialog->get_action_area()) + pActionArea->Show(); + m_xDialog->setOptimalLayoutSize(); +} - switch (nResponse) - { - case RET_OK: - xButton->set_id("ok"); - break; - case RET_CLOSE: - xButton->set_id("close"); - break; - case RET_CANCEL: - xButton->set_id("cancel"); - break; - case RET_YES: - xButton->set_id("yes"); - break; - case RET_NO: - xButton->set_id("no"); - break; - } +void SalInstanceDialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) +{ + m_xDialog->SetInstallLOKNotifierHdl(rLink); +} - xButton->Show(); - m_xDialog->add_button(xButton, nResponse, true); - } +int SalInstanceDialog::run() +{ + VclButtonBox* pActionArea = m_xDialog->get_action_area(); + if (pActionArea) + pActionArea->sort_native_button_order(); + return m_xDialog->Execute(); +} - virtual void set_modal(bool bModal) override - { - if (get_modal() == bModal) - return; - m_xDialog->SetModalInputMode(bModal); - } +void SalInstanceDialog::response(int nResponse) +{ + m_xDialog->EndDialog(nResponse); +} + +void SalInstanceDialog::add_button(const OUString& rText, int nResponse, const OString& rHelpId) +{ + VclButtonBox* pBox = m_xDialog->get_action_area(); + VclPtr<PushButton> xButton(VclPtr<PushButton>::Create(pBox, WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER)); + xButton->SetText(rText); + xButton->SetHelpId(rHelpId); - virtual bool get_modal() const override + switch (nResponse) { - return m_xDialog->IsModalInputMode(); + case RET_OK: + xButton->set_id("ok"); + break; + case RET_CLOSE: + xButton->set_id("close"); + break; + case RET_CANCEL: + xButton->set_id("cancel"); + break; + case RET_YES: + xButton->set_id("yes"); + break; + case RET_NO: + xButton->set_id("no"); + break; } - virtual weld::Button* weld_widget_for_response(int nResponse) override; + xButton->Show(); + m_xDialog->add_button(xButton, nResponse, true); +} - virtual void set_default_response(int nResponse) override - { - m_xDialog->set_default_response(nResponse); - } +void SalInstanceDialog::set_modal(bool bModal) +{ + if (get_modal() == bModal) + return; + m_xDialog->SetModalInputMode(bModal); +} - virtual Container* weld_content_area() override - { - return new SalInstanceContainer(m_xDialog->get_content_area(), m_pBuilder, false); - } +bool SalInstanceDialog::get_modal() const +{ + return m_xDialog->IsModalInputMode(); +} -}; +void SalInstanceDialog::set_default_response(int nResponse) +{ + m_xDialog->set_default_response(nResponse); +} + +weld::Container* SalInstanceDialog::weld_content_area() +{ + return new SalInstanceContainer(m_xDialog->get_content_area(), m_pBuilder, false); +} IMPL_LINK(SalInstanceDialog, PopupScreenShotMenuHdl, const CommandEvent&, rCEvt, bool) { @@ -5150,54 +5086,45 @@ public: } }; -class SalInstanceLabel : public SalInstanceWidget, public virtual weld::Label +SalInstanceLabel::SalInstanceLabel(Control* pLabel, SalInstanceBuilder *pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pLabel, pBuilder, bTakeOwnership) + , m_xLabel(pLabel) { -private: - // Control instead of FixedText so we can also use this for - // SelectableFixedText which is derived from Edit. We just typically need - // [G|S]etText which exists in their shared baseclass - VclPtr<Control> m_xLabel; -public: - SalInstanceLabel(Control* pLabel, SalInstanceBuilder *pBuilder, bool bTakeOwnership) - : SalInstanceWidget(pLabel, pBuilder, bTakeOwnership) - , m_xLabel(pLabel) - { - } +} - virtual void set_label(const OUString& rText) override - { - m_xLabel->SetText(rText); - } +void SalInstanceLabel::set_label(const OUString& rText) +{ + m_xLabel->SetText(rText); +} - virtual OUString get_label() const override - { - return m_xLabel->GetText(); - } +OUString SalInstanceLabel::get_label() const +{ + return m_xLabel->GetText(); +} - virtual void set_mnemonic_widget(Widget* pTarget) override - { - FixedText* pLabel = dynamic_cast<FixedText*>(m_xLabel.get()); - assert(pLabel && "can't use set_mnemonic_widget on SelectableFixedText"); - SalInstanceWidget* pTargetWidget = dynamic_cast<SalInstanceWidget*>(pTarget); - pLabel->set_mnemonic_widget(pTargetWidget ? pTargetWidget->getWidget() : nullptr); - } +void SalInstanceLabel::set_mnemonic_widget(Widget* pTarget) +{ + FixedText* pLabel = dynamic_cast<FixedText*>(m_xLabel.get()); + assert(pLabel && "can't use set_mnemonic_widget on SelectableFixedText"); + SalInstanceWidget* pTargetWidget = dynamic_cast<SalInstanceWidget*>(pTarget); + pLabel->set_mnemonic_widget(pTargetWidget ? pTargetWidget->getWidget() : nullptr); +} - virtual void set_message_type(weld::EntryMessageType eType) override - { - if (eType == weld::EntryMessageType::Error) - m_xLabel->SetControlBackground(m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor()); - else if (eType == weld::EntryMessageType::Warning) - m_xLabel->SetControlBackground(COL_YELLOW); - else - m_xLabel->SetControlBackground(); - } +void SalInstanceLabel::set_message_type(weld::EntryMessageType eType) +{ + if (eType == weld::EntryMessageType::Error) + m_xLabel->SetControlBackground(m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor()); + else if (eType == weld::EntryMessageType::Warning) + m_xLabel->SetControlBackground(COL_YELLOW); + else + m_xLabel->SetControlBackground(); +} - virtual void set_font(const vcl::Font& rFont) override - { - m_xLabel->SetPointFont(*m_xLabel, rFont); - m_xLabel->Invalidate(); - } -}; +void SalInstanceLabel::set_font(const vcl::Font& rFont) +{ + m_xLabel->SetPointFont(*m_xLabel, rFont); + m_xLabel->Invalidate(); +} std::unique_ptr<weld::Label> SalInstanceFrame::weld_label_widget() const { @@ -6081,357 +6008,350 @@ IMPL_LINK(SalInstanceEntryTreeView, AutocompleteHdl, Edit&, rEdit, void) } } -class SalInstanceBuilder : public weld::Builder +SalInstanceBuilder::SalInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile) + : weld::Builder(rUIFile) + , m_xBuilder(new VclBuilder(pParent, rUIRoot, rUIFile, OString(), css::uno::Reference<css::frame::XFrame>(), false)) { -private: - std::unique_ptr<VclBuilder> m_xBuilder; - VclPtr<vcl::Window> m_aOwnedToplevel; -public: - SalInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile) - : weld::Builder(rUIFile) - , m_xBuilder(new VclBuilder(pParent, rUIRoot, rUIFile, OString(), css::uno::Reference<css::frame::XFrame>(), false)) - { - } +} - VclBuilder& get_builder() const - { - return *m_xBuilder; - } +VclBuilder& SalInstanceBuilder::get_builder() const +{ + return *m_xBuilder; +} - virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString &id, bool bTakeOwnership) override +std::unique_ptr<weld::MessageDialog> SalInstanceBuilder::weld_message_dialog(const OString &id, bool bTakeOwnership) +{ + MessageDialog* pMessageDialog = m_xBuilder->get<MessageDialog>(id); + std::unique_ptr<weld::MessageDialog> pRet(pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, this, false) : nullptr); + if (bTakeOwnership && pMessageDialog) { - MessageDialog* pMessageDialog = m_xBuilder->get<MessageDialog>(id); - std::unique_ptr<weld::MessageDialog> pRet(pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, this, false) : nullptr); - if (bTakeOwnership && pMessageDialog) - { - assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); - m_aOwnedToplevel.set(pMessageDialog); - m_xBuilder->drop_ownership(pMessageDialog); - } - return pRet; + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pMessageDialog); + m_xBuilder->drop_ownership(pMessageDialog); } + return pRet; +} - virtual std::unique_ptr<weld::AboutDialog> weld_about_dialog(const OString &id, bool bTakeOwnership) override +std::unique_ptr<weld::AboutDialog> SalInstanceBuilder::weld_about_dialog(const OString &id, bool bTakeOwnership) +{ + vcl::AboutDialog* pAboutDialog = m_xBuilder->get<vcl::AboutDialog>(id); + std::unique_ptr<weld::AboutDialog> pRet(pAboutDialog ? new SalInstanceAboutDialog(pAboutDialog, this, false) : nullptr); + if (bTakeOwnership && pAboutDialog) { - vcl::AboutDialog* pAboutDialog = m_xBuilder->get<vcl::AboutDialog>(id); - std::unique_ptr<weld::AboutDialog> pRet(pAboutDialog ? new SalInstanceAboutDialog(pAboutDialog, this, false) : nullptr); - if (bTakeOwnership && pAboutDialog) - { - assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); - m_aOwnedToplevel.set(pAboutDialog); - m_xBuilder->drop_ownership(pAboutDialog); - } - return pRet; + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pAboutDialog); + m_xBuilder->drop_ownership(pAboutDialog); } + return pRet; +} - virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString &id, bool bTakeOwnership) override +std::unique_ptr<weld::Dialog> SalInstanceBuilder::weld_dialog(const OString &id, bool bTakeOwnership) +{ + Dialog* pDialog = m_xBuilder->get<Dialog>(id); + std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false) : nullptr); + if (bTakeOwnership && pDialog) { - Dialog* pDialog = m_xBuilder->get<Dialog>(id); - std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false) : nullptr); - if (bTakeOwnership && pDialog) - { - assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); - m_aOwnedToplevel.set(pDialog); - m_xBuilder->drop_ownership(pDialog); - } - return pRet; + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pDialog); + m_xBuilder->drop_ownership(pDialog); } + return pRet; +} - virtual std::unique_ptr<weld::Assistant> weld_assistant(const OString &id, bool bTakeOwnership) override +std::unique_ptr<weld::Assistant> SalInstanceBuilder::weld_assistant(const OString &id, bool bTakeOwnership) +{ + vcl::RoadmapWizard* pDialog = m_xBuilder->get<vcl::RoadmapWizard>(id); + std::unique_ptr<weld::Assistant> pRet(pDialog ? new SalInstanceAssistant(pDialog, this, false) : nullptr); + if (bTakeOwnership && pDialog) { - vcl::RoadmapWizard* pDialog = m_xBuilder->get<vcl::RoadmapWizard>(id); - std::unique_ptr<weld::Assistant> pRet(pDialog ? new SalInstanceAssistant(pDialog, this, false) : nullptr); - if (bTakeOwnership && pDialog) - { - assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); - m_aOwnedToplevel.set(pDialog); - m_xBuilder->drop_ownership(pDialog); - } - return pRet; + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pDialog); + m_xBuilder->drop_ownership(pDialog); } + return pRet; +} - virtual std::unique_ptr<weld::Window> create_screenshot_window() override - { - assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); +std::unique_ptr<weld::Window> SalInstanceBuilder::create_screenshot_window() +{ + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); - vcl::Window *pRoot = m_xBuilder->get_widget_root(); - if (SystemWindow *pWindow = dynamic_cast<SystemWindow*>(pRoot)) - { - std::unique_ptr<weld::Window> xRet(new SalInstanceWindow(pWindow, this, false)); - m_aOwnedToplevel.set(pWindow); - m_xBuilder->drop_ownership(pWindow); - return xRet; - } + vcl::Window *pRoot = m_xBuilder->get_widget_root(); + if (SystemWindow *pWindow = dynamic_cast<SystemWindow*>(pRoot)) + { + std::unique_ptr<weld::Window> xRet(new SalInstanceWindow(pWindow, this, false)); + m_aOwnedToplevel.set(pWindow); + m_xBuilder->drop_ownership(pWindow); + return xRet; + } - VclPtrInstance<Dialog> xDialog(nullptr, WB_HIDE | WB_STDDIALOG | WB_SIZEABLE | WB_CLOSEABLE, Dialog::InitFlag::NoParent); - xDialog->SetText(utl::ConfigManager::getProductName()); + VclPtrInstance<Dialog> xDialog(nullptr, WB_HIDE | WB_STDDIALOG | WB_SIZEABLE | WB_CLOSEABLE, Dialog::InitFlag::NoParent); + xDialog->SetText(utl::ConfigManager::getProductName()); - auto xContentArea = VclPtr<VclVBox>::Create(xDialog, false, 12); - pRoot->SetParent(xContentArea); - assert(pRoot == xContentArea->GetWindow(GetWindowType::FirstChild)); - xContentArea->Show(); - pRoot->Show(); - xDialog->SetHelpId(pRoot->GetHelpId()); + auto xContentArea = VclPtr<VclVBox>::Create(xDialog, false, 12); + pRoot->SetParent(xContentArea); + assert(pRoot == xContentArea->GetWindow(GetWindowType::FirstChild)); + xContentArea->Show(); + pRoot->Show(); + xDialog->SetHelpId(pRoot->GetHelpId()); - m_aOwnedToplevel.set(xDialog); + m_aOwnedToplevel.set(xDialog); - return std::unique_ptr<weld::Dialog>(new SalInstanceDialog(xDialog, this, false)); - } + return std::unique_ptr<weld::Dialog>(new SalInstanceDialog(xDialog, this, false)); +} - virtual std::unique_ptr<weld::Window> weld_window(const OString &id, bool bTakeOwnership) override - { - SystemWindow* pWindow = m_xBuilder->get<SystemWindow>(id); - return pWindow ? std::make_unique<SalInstanceWindow>(pWindow, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Window> SalInstanceBuilder::weld_window(const OString &id, bool bTakeOwnership) +{ + SystemWindow* pWindow = m_xBuilder->get<SystemWindow>(id); + return pWindow ? std::make_unique<SalInstanceWindow>(pWindow, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Widget> weld_widget(const OString &id, bool bTakeOwnership) override - { - vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); - return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Widget> SalInstanceBuilder::weld_widget(const OString &id, bool bTakeOwnership) +{ + vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); + return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Container> weld_container(const OString &id, bool bTakeOwnership) override - { - vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id); - return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Container> SalInstanceBuilder::weld_container(const OString &id, bool bTakeOwnership) +{ + vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id); + return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Box> weld_box(const OString &id, bool bTakeOwnership) override - { - vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id); - return pContainer ? std::make_unique<SalInstanceBox>(pContainer, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Box> SalInstanceBuilder::weld_box(const OString &id, bool bTakeOwnership) +{ + vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id); + return pContainer ? std::make_unique<SalInstanceBox>(pContainer, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Frame> weld_frame(const OString &id, bool bTakeOwnership) override +std::unique_ptr<weld::Frame> SalInstanceBuilder::weld_frame(const OString &id, bool bTakeOwnership) +{ + VclFrame* pFrame = m_xBuilder->get<VclFrame>(id); + std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, this, false) : nullptr); + if (bTakeOwnership && pFrame) { - VclFrame* pFrame = m_xBuilder->get<VclFrame>(id); - std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, this, false) : nullptr); - if (bTakeOwnership && pFrame) - { - assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); - m_aOwnedToplevel.set(pFrame); - m_xBuilder->drop_ownership(pFrame); - } - return pRet; + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pFrame); + m_xBuilder->drop_ownership(pFrame); } + return pRet; +} - virtual std::unique_ptr<weld::ScrolledWindow> weld_scrolled_window(const OString &id, bool bTakeOwnership) override - { - VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id); - return pScrolledWindow ? std::make_unique<SalInstanceScrolledWindow>(pScrolledWindow, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::ScrolledWindow> SalInstanceBuilder::weld_scrolled_window(const OString &id, bool bTakeOwnership) +{ + VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id); + return pScrolledWindow ? std::make_unique<SalInstanceScrolledWindow>(pScrolledWindow, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString &id, bool bTakeOwnership) override - { - vcl::Window* pNotebook = m_xBuilder->get<vcl::Window>(id); - if (!pNotebook) - return nullptr; - if (pNotebook->GetType() == WindowType::TABCONTROL) - return std::make_unique<SalInstanceNotebook>(static_cast<TabControl*>(pNotebook), this, bTakeOwnership); - if (pNotebook->GetType() == WindowType::VERTICALTABCONTROL) - return std::make_unique<SalInstanceVerticalNotebook>(static_cast<VerticalTabControl*>(pNotebook), this, bTakeOwnership); +std::unique_ptr<weld::Notebook> SalInstanceBuilder::weld_notebook(const OString &id, bool bTakeOwnership) +{ + vcl::Window* pNotebook = m_xBuilder->get<vcl::Window>(id); + if (!pNotebook) return nullptr; - } + if (pNotebook->GetType() == WindowType::TABCONTROL) + return std::make_unique<SalInstanceNotebook>(static_cast<TabControl*>(pNotebook), this, bTakeOwnership); + if (pNotebook->GetType() == WindowType::VERTICALTABCONTROL) + return std::make_unique<SalInstanceVerticalNotebook>(static_cast<VerticalTabControl*>(pNotebook), this, bTakeOwnership); + return nullptr; +} - virtual std::unique_ptr<weld::Button> weld_button(const OString &id, bool bTakeOwnership) override - { - Button* pButton = m_xBuilder->get<Button>(id); - return pButton ? std::make_unique<SalInstanceButton>(pButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Button> SalInstanceBuilder::weld_button(const OString &id, bool bTakeOwnership) +{ + Button* pButton = m_xBuilder->get<Button>(id); + return pButton ? std::make_unique<SalInstanceButton>(pButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString &id, bool bTakeOwnership) override - { - MenuButton* pButton = m_xBuilder->get<MenuButton>(id); - return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::MenuButton> SalInstanceBuilder::weld_menu_button(const OString &id, bool bTakeOwnership) +{ + MenuButton* pButton = m_xBuilder->get<MenuButton>(id); + return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OString &id, bool bTakeOwnership) override - { - FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id); - return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::LinkButton> SalInstanceBuilder::weld_link_button(const OString &id, bool bTakeOwnership) +{ + FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id); + return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString &id, bool bTakeOwnership) override - { - PushButton* pToggleButton = m_xBuilder->get<PushButton>(id); - return pToggleButton ? std::make_unique<SalInstanceToggleButton>(pToggleButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::ToggleButton> SalInstanceBuilder::weld_toggle_button(const OString &id, bool bTakeOwnership) +{ + PushButton* pToggleButton = m_xBuilder->get<PushButton>(id); + return pToggleButton ? std::make_unique<SalInstanceToggleButton>(pToggleButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString &id, bool bTakeOwnership) override - { - RadioButton* pRadioButton = m_xBuilder->get<RadioButton>(id); - return pRadioButton ? std::make_unique<SalInstanceRadioButton>(pRadioButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::RadioButton> SalInstanceBuilder::weld_radio_button(const OString &id, bool bTakeOwnership) +{ + RadioButton* pRadioButton = m_xBuilder->get<RadioButton>(id); + return pRadioButton ? std::make_unique<SalInstanceRadioButton>(pRadioButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OString &id, bool bTakeOwnership) override - { - CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); - return pCheckButton ? std::make_unique<SalInstanceCheckButton>(pCheckButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::CheckButton> SalInstanceBuilder::weld_check_button(const OString &id, bool bTakeOwnership) +{ + CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); + return pCheckButton ? std::make_unique<SalInstanceCheckButton>(pCheckButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Scale> weld_scale(const OString &id, bool bTakeOwnership) override - { - Slider* pSlider = m_xBuilder->get<Slider>(id); - return pSlider ? std::make_unique<SalInstanceScale>(pSlider, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Scale> SalInstanceBuilder::weld_scale(const OString &id, bool bTakeOwnership) +{ + Slider* pSlider = m_xBuilder->get<Slider>(id); + return pSlider ? std::make_unique<SalInstanceScale>(pSlider, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::ProgressBar> weld_progress_bar(const OString &id, bool bTakeOwnership) override - { - ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id); - return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::ProgressBar> SalInstanceBuilder::weld_progress_bar(const OString &id, bool bTakeOwnership) +{ + ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id); + return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Spinner> weld_spinner(const OString &id, bool bTakeOwnership) override - { - Throbber* pThrobber = m_xBuilder->get<Throbber>(id); - return pThrobber ? std::make_unique<SalInstanceSpinner>(pThrobber, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Spinner> SalInstanceBuilder::weld_spinner(const OString &id, bool bTakeOwnership) +{ + Throbber* pThrobber = m_xBuilder->get<Throbber>(id); + return pThrobber ? std::make_unique<SalInstanceSpinner>(pThrobber, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Image> weld_image(const OString &id, bool bTakeOwnership) override - { - FixedImage* pImage = m_xBuilder->get<FixedImage>(id); - return pImage ? std::make_unique<SalInstanceImage>(pImage, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Image> SalInstanceBuilder::weld_image(const OString &id, bool bTakeOwnership) +{ + FixedImage* pImage = m_xBuilder->get<FixedImage>(id); + return pImage ? std::make_unique<SalInstanceImage>(pImage, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString &id, bool bTakeOwnership) override - { - Calendar* pCalendar = m_xBuilder->get<Calendar>(id); - return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Calendar> SalInstanceBuilder::weld_calendar(const OString &id, bool bTakeOwnership) +{ + Calendar* pCalendar = m_xBuilder->get<Calendar>(id); + return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Entry> weld_entry(const OString &id, bool bTakeOwnership) override - { - Edit* pEntry = m_xBuilder->get<Edit>(id); - return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Entry> SalInstanceBuilder::weld_entry(const OString &id, bool bTakeOwnership) +{ + Edit* pEntry = m_xBuilder->get<Edit>(id); + return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString &id, bool bTakeOwnership) override - { - FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); - return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::SpinButton> SalInstanceBuilder::weld_spin_button(const OString &id, bool bTakeOwnership) +{ + FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); + return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::MetricSpinButton> weld_metric_spin_button(const OString& id, FieldUnit eUnit, - bool bTakeOwnership) override +std::unique_ptr<weld::MetricSpinButton> SalInstanceBuilder::weld_metric_spin_button(const OString& id, FieldUnit eUnit, + bool bTakeOwnership) +{ + std::unique_ptr<weld::SpinButton> xButton(weld_spin_button(id, bTakeOwnership)); + if (xButton) { - std::unique_ptr<weld::SpinButton> xButton(weld_spin_button(id, bTakeOwnership)); - if (xButton) - { - SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(*xButton); - rButton.SetUseThousandSep(); - } - return std::make_unique<weld::MetricSpinButton>(std::move(xButton), eUnit); + SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(*xButton); + rButton.SetUseThousandSep(); } + return std::make_unique<weld::MetricSpinButton>(std::move(xButton), eUnit); +} - virtual std::unique_ptr<weld::FormattedSpinButton> weld_formatted_spin_button(const OString& id, - bool bTakeOwnership) override - { - FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); - return pSpinButton ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::FormattedSpinButton> SalInstanceBuilder::weld_formatted_spin_button(const OString& id, + bool bTakeOwnership) +{ + FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); + return pSpinButton ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::TimeSpinButton> weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, - bool bTakeOwnership) override - { - std::unique_ptr<weld::TimeSpinButton> pRet(new weld::TimeSpinButton(weld_spin_button(id, bTakeOwnership), eFormat)); - SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(pRet->get_widget()); - rButton.DisableRemainderFactor(); //so with hh::mm::ss, incrementing mm will not reset ss - return pRet; - } +std::unique_ptr<weld::TimeSpinButton> SalInstanceBuilder::weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, + bool bTakeOwnership) +{ + std::unique_ptr<weld::TimeSpinButton> pRet(new weld::TimeSpinButton(weld_spin_button(id, bTakeOwnership), eFormat)); + SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(pRet->get_widget()); + rButton.DisableRemainderFactor(); //so with hh::mm::ss, incrementing mm will not reset ss + return pRet; +} - virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString &id, bool bTakeOwnership) override - { - vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); - ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget); - if (pComboBox) - return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, this, bTakeOwnership); - ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); - return pListBox ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::ComboBox> SalInstanceBuilder::weld_combo_box(const OString &id, bool bTakeOwnership) +{ + vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); + ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget); + if (pComboBox) + return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, this, bTakeOwnership); + ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); + return pListBox ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OString& containerid, const OString& entryid, const OString& treeviewid, bool bTakeOwnership) override - { - vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(containerid); - return pContainer ? std::make_unique<SalInstanceEntryTreeView>(pContainer, this, bTakeOwnership, - weld_entry(entryid, bTakeOwnership), - weld_tree_view(treeviewid, bTakeOwnership)) : nullptr; - } +std::unique_ptr<weld::EntryTreeView> SalInstanceBuilder::weld_entry_tree_view(const OString& containerid, const OString& entryid, const OString& treeviewid, bool bTakeOwnership) +{ + vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(containerid); + return pContainer ? std::make_unique<SalInstanceEntryTreeView>(pContainer, this, bTakeOwnership, + weld_entry(entryid, bTakeOwnership), + weld_tree_view(treeviewid, bTakeOwnership)) : nullptr; +} - virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString &id, bool bTakeOwnership) override - { - SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id); - return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::TreeView> SalInstanceBuilder::weld_tree_view(const OString &id, bool bTakeOwnership) +{ + SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id); + return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString &id, bool bTakeOwnership) override - { - IconView* pIconView = m_xBuilder->get<IconView>(id); - return pIconView ? std::make_unique<SalInstanceIconView>(pIconView, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::IconView> SalInstanceBuilder::weld_icon_view(const OString &id, bool bTakeOwnership) +{ + IconView* pIconView = m_xBuilder->get<IconView>(id); + return pIconView ? std::make_unique<SalInstanceIconView>(pIconView, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Label> weld_label(const OString &id, bool bTakeOwnership) override - { - Control* pLabel = m_xBuilder->get<Control>(id); - return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Label> SalInstanceBuilder::weld_label(const OString &id, bool bTakeOwnership) +{ + Control* pLabel = m_xBuilder->get<Control>(id); + return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::TextView> weld_text_view(const OString &id, bool bTakeOwnership) override - { - VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id); - return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::TextView> SalInstanceBuilder::weld_text_view(const OString &id, bool bTakeOwnership) +{ + VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id); + return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Expander> weld_expander(const OString &id, bool bTakeOwnership) override - { - VclExpander* pExpander = m_xBuilder->get<VclExpander>(id); - return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Expander> SalInstanceBuilder::weld_expander(const OString &id, bool bTakeOwnership) +{ + VclExpander* pExpander = m_xBuilder->get<VclExpander>(id); + return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::DrawingArea> weld_drawing_area(const OString &id, const a11yref& rA11yImpl, - FactoryFunction pUITestFactoryFunction, void* pUserData, bool bTakeOwnership) override - { - VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id); - return pDrawingArea ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, this, rA11yImpl, - pUITestFactoryFunction, pUserData, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::DrawingArea> SalInstanceBuilder::weld_drawing_area(const OString &id, const a11yref& rA11yImpl, + FactoryFunction pUITestFactoryFunction, void* pUserData, bool bTakeOwnership) +{ + VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id); + return pDrawingArea ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, this, rA11yImpl, + pUITestFactoryFunction, pUserData, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Menu> weld_menu(const OString &id, bool bTakeOwnership) override - { - PopupMenu* pMenu = m_xBuilder->get_menu(id); - return pMenu ? std::make_unique<SalInstanceMenu>(pMenu, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Menu> SalInstanceBuilder::weld_menu(const OString &id, bool bTakeOwnership) +{ + PopupMenu* pMenu = m_xBuilder->get_menu(id); + return pMenu ? std::make_unique<SalInstanceMenu>(pMenu, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString &id, bool bTakeOwnership) override - { - ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id); - return pToolBox ? std::make_unique<SalInstanceToolbar>(pToolBox, this, bTakeOwnership) : nullptr; - } +std::unique_ptr<weld::Toolbar> SalInstanceBuilder::weld_toolbar(const OString &id, bool bTakeOwnership) +{ + ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id); + return pToolBox ? std::make_unique<SalInstanceToolbar>(pToolBox, this, bTakeOwnership) : nullptr; +} - virtual std::unique_ptr<weld::SizeGroup> create_size_group() override - { - return std::make_unique<SalInstanceSizeGroup>(); - } +std::unique_ptr<weld::SizeGroup> SalInstanceBuilder::create_size_group() +{ + return std::make_unique<SalInstanceSizeGroup>(); +} - OString get_current_page_help_id() const - { - TabControl *pCtrl = get_builder().get<TabControl>("tabcontrol"); - TabPage* pTabPage = pCtrl ? pCtrl->GetTabPage(pCtrl->GetCurPageId()) : nullptr; - vcl::Window *pTabChild = pTabPage ? pTabPage->GetWindow(GetWindowType::FirstChild) : nullptr; - pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr; - if (pTabChild) - return pTabChild->GetHelpId(); - return OString(); - } +OString SalInstanceBuilder::get_current_page_help_id() const +{ + TabControl *pCtrl = get_builder().get<TabControl>("tabcontrol"); + TabPage* pTabPage = pCtrl ? pCtrl->GetTabPage(pCtrl->GetCurPageId()) : nullptr; + vcl::Window *pTabChild = pTabPage ? pTabPage->GetWindow(GetWindowType::FirstChild) : nullptr; + pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr; + if (pTabChild) + return pTabChild->GetHelpId(); + return OString(); +} - virtual ~SalInstanceBuilder() override - { - if (VclBuilderContainer* pOwnedToplevel = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get())) - pOwnedToplevel->m_pUIBuilder = std::move(m_xBuilder); - else - m_xBuilder.reset(); - m_aOwnedToplevel.disposeAndClear(); - } -}; +SalInstanceBuilder::~SalInstanceBuilder() +{ + if (VclBuilderContainer* pOwnedToplevel = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get())) + pOwnedToplevel->m_pUIBuilder = std::move(m_xBuilder); + else + m_xBuilder.reset(); + m_aOwnedToplevel.disposeAndClear(); +} weld::Builder* SalInstance::CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) { |