vcl/inc/salvtables.hxx | 498 ++++++ vcl/source/app/salvtables.cxx | 3413 ++++++++++++++++++------------------------ 2 files changed, 1980 insertions(+), 1931 deletions(-)
New commits: commit aad94d48b19135a2e46ac7b2c0f41f3bb29bb5a7 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Feb 20 10:34:59 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Feb 20 17:32:27 2020 +0100 Silence warnings in salvtables.hxx Change-Id: I2d621688776c789b24ec1c593da2e4880cefd3a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89103 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index a239f3f3f8b6..3d41d3589871 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -17,120 +17,123 @@ private: public: SalInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile); - virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString& id, - bool bTakeOwnership) override; + 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) 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) override; + bool bTakeOwnership = true) override; virtual std::unique_ptr<weld::Assistant> weld_assistant(const OString& id, - bool bTakeOwnership) override; + 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) override; + bool bTakeOwnership = true) override; virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Container> weld_container(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; - virtual std::unique_ptr<weld::Box> weld_box(const OString& id, bool bTakeOwnership) 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) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::ScrolledWindow> - weld_scrolled_window(const OString& id, bool bTakeOwnership) override; + weld_scrolled_window(const OString& id, bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Button> weld_button(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; - virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString& id, - bool bTakeOwnership) 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) 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) 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) 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) 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) override; + bool bTakeOwnership = false) override; - virtual std::unique_ptr<weld::ProgressBar> weld_progress_bar(const OString& id, - bool bTakeOwnership) 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) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Image> weld_image(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; - virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString& id, - bool bTakeOwnership) 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) override; + 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) override; + 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) override; + 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) override; + 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) 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) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Label> weld_label(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id, - bool bTakeOwnership) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id, - bool bTakeOwnership) override; + 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) override; + weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, + FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr, + bool bTakeOwnership = false) override; - virtual std::unique_ptr<weld::Menu> weld_menu(const OString& id, bool bTakeOwnership) 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) override; + bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::SizeGroup> create_size_group() override; @@ -478,7 +481,8 @@ public: virtual void response(int nResponse) override; - virtual void add_button(const OUString& rText, int nResponse, const OString& rHelpId) override; + virtual void add_button(const OUString& rText, int nResponse, + const OString& rHelpId = OString()) override; virtual void set_modal(bool bModal) override; commit 3832609a238d47375e634cbda4d092b11108fee4 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Feb 19 13:32:14 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Feb 20 17:32:15 2020 +0100 Create header file for SalInstanceBuilder Change-Id: If8d7578d9a5926cdf565efbf0bc12719e5ef6fc2 Move more declarations for SalInstance to header file Change-Id: Ib7240ffd003e202be04b462209cfb2abafcc18ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89102 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx new file mode 100644 index 000000000000..a239f3f3f8b6 --- /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); + + virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::AboutDialog> weld_about_dialog(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Assistant> weld_assistant(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Window> create_screenshot_window() override; + + virtual std::unique_ptr<weld::Window> weld_window(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Container> weld_container(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Box> weld_box(const OString& id, bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Frame> weld_frame(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::ScrolledWindow> + weld_scrolled_window(const OString& id, bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Button> weld_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Scale> weld_scale(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::ProgressBar> weld_progress_bar(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Spinner> weld_spinner(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Image> weld_image(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::MetricSpinButton> + weld_metric_spin_button(const OString& id, FieldUnit eUnit, bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::FormattedSpinButton> + weld_formatted_spin_button(const OString& id, bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::TimeSpinButton> + weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OString& containerid, + const OString& entryid, + const OString& treeviewid, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Label> weld_label(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::DrawingArea> + weld_drawing_area(const OString& id, const a11yref& rA11yImpl, + FactoryFunction pUITestFactoryFunction, void* pUserData, + bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Menu> weld_menu(const OString& id, bool bTakeOwnership) override; + + virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id, + bool bTakeOwnership) 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 + connect_get_property_tree(const Link<boost::property_tree::ptree&, void>& rLink) override; + + virtual void set_stack_background() override; + + virtual void set_toolbar_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 weld::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 68347a215ada..4d4e1c6372ef 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -72,6 +72,7 @@ #include <aboutdialog.hxx> #include <bitmaps.hlst> #include <wizdlg.hxx> +#include <salvtables.hxx> #include <boost/property_tree/ptree.hpp> @@ -84,11 +85,9 @@ SalFrame::SalFrame() // this file contains the virtual destructors of the sal interface // compilers usually put their vtables where the destructor is -SalFrame::~SalFrame() -{ -} +SalFrame::~SalFrame() {} -void SalFrame::SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc ) +void SalFrame::SetCallback(vcl::Window* pWindow, SALFRAMEPROC pProc) { m_pWindow = pWindow; m_pProc = pProc; @@ -96,12 +95,9 @@ void SalFrame::SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc ) // default to full-frame flushes // on ports where partial-flushes are much cheaper this method should be overridden -void SalFrame::Flush( const tools::Rectangle& ) -{ - Flush(); -} +void SalFrame::Flush(const tools::Rectangle&) { Flush(); } -void SalFrame::SetRepresentedURL( const OUString& ) +void SalFrame::SetRepresentedURL(const OUString&) { // currently this is Mac only functionality } @@ -111,648 +107,436 @@ SalInstance::SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex) { } -SalInstance::~SalInstance() -{ -} +SalInstance::~SalInstance() {} -comphelper::SolarMutex* SalInstance::GetYieldMutex() -{ - return m_pYieldMutex.get(); -} +comphelper::SolarMutex* SalInstance::GetYieldMutex() { return m_pYieldMutex.get(); } -sal_uInt32 SalInstance::ReleaseYieldMutexAll() -{ - return m_pYieldMutex->release(true); -} +sal_uInt32 SalInstance::ReleaseYieldMutexAll() { return m_pYieldMutex->release(true); } -void SalInstance::AcquireYieldMutex(sal_uInt32 nCount) -{ - m_pYieldMutex->acquire(nCount); -} +void SalInstance::AcquireYieldMutex(sal_uInt32 nCount) { m_pYieldMutex->acquire(nCount); } -std::unique_ptr<SalSession> SalInstance::CreateSalSession() -{ - return nullptr; -} +std::unique_ptr<SalSession> SalInstance::CreateSalSession() { return nullptr; } -std::unique_ptr<SalMenu> SalInstance::CreateMenu( bool, Menu* ) +std::unique_ptr<SalMenu> SalInstance::CreateMenu(bool, Menu*) { // default: no native menus return nullptr; } -std::unique_ptr<SalMenuItem> SalInstance::CreateMenuItem( const SalItemParams & ) -{ - return nullptr; -} +std::unique_ptr<SalMenuItem> SalInstance::CreateMenuItem(const SalItemParams&) { return nullptr; } -bool SalInstance::CallEventCallback( void const * pEvent, int nBytes ) +bool SalInstance::CallEventCallback(void const* pEvent, int nBytes) { - return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes ); + return m_pEventInst.is() && m_pEventInst->dispatchEvent(pEvent, nBytes); } -SalTimer::~SalTimer() COVERITY_NOEXCEPT_FALSE -{ -} +SalTimer::~SalTimer() COVERITY_NOEXCEPT_FALSE {} void SalBitmap::DropScaledCache() { if (ImplSVData* pSVData = ImplGetSVData()) { auto& rCache = pSVData->maGDIData.maScaleCache; - rCache.remove_if([this] (const o3tl::lru_map<SalBitmap*, BitmapEx>::key_value_pair_t& rKeyValuePair) - { return rKeyValuePair.first == this; }); + rCache.remove_if( + [this](const o3tl::lru_map<SalBitmap*, BitmapEx>::key_value_pair_t& rKeyValuePair) { + return rKeyValuePair.first == this; + }); } } -SalBitmap::~SalBitmap() -{ - DropScaledCache(); -} +SalBitmap::~SalBitmap() { DropScaledCache(); } -SalSystem::~SalSystem() -{ -} +SalSystem::~SalSystem() {} -SalPrinter::~SalPrinter() -{ -} +SalPrinter::~SalPrinter() {} -bool SalPrinter::StartJob( const OUString*, const OUString&, const OUString&, - ImplJobSetup*, vcl::PrinterController& ) +bool SalPrinter::StartJob(const OUString*, const OUString&, const OUString&, ImplJobSetup*, + vcl::PrinterController&) { return false; } -SalInfoPrinter::~SalInfoPrinter() -{ -} +SalInfoPrinter::~SalInfoPrinter() {} -SalVirtualDevice::~SalVirtualDevice() -{ -} +SalVirtualDevice::~SalVirtualDevice() {} -SalObject::~SalObject() -{ -} +SalObject::~SalObject() {} -SalMenu::~SalMenu() -{ -} +SalMenu::~SalMenu() {} -bool SalMenu::ShowNativePopupMenu(FloatingWindow *, const tools::Rectangle&, FloatWinPopupFlags ) +bool SalMenu::ShowNativePopupMenu(FloatingWindow*, const tools::Rectangle&, FloatWinPopupFlags) { return false; } -void SalMenu::ShowCloseButton(bool) -{ -} +void SalMenu::ShowCloseButton(bool) {} -bool SalMenu::AddMenuBarButton( const SalMenuButtonItem& ) -{ - return false; -} +bool SalMenu::AddMenuBarButton(const SalMenuButtonItem&) { return false; } -void SalMenu::RemoveMenuBarButton( sal_uInt16 ) -{ -} +void SalMenu::RemoveMenuBarButton(sal_uInt16) {} -tools::Rectangle SalMenu::GetMenuBarButtonRectPixel( sal_uInt16, SalFrame* ) +tools::Rectangle SalMenu::GetMenuBarButtonRectPixel(sal_uInt16, SalFrame*) { return tools::Rectangle(); } -int SalMenu::GetMenuBarHeight() const -{ - return 0; -} - -void SalMenu::ApplyPersona() -{ -} - -SalMenuItem::~SalMenuItem() -{ -} +int SalMenu::GetMenuBarHeight() const { return 0; } -class SalInstanceBuilder; +void SalMenu::ApplyPersona() {} -namespace { +SalMenuItem::~SalMenuItem() {} -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_bMouseEventListener) - { - Application::AddEventListener(LINK(this, SalInstanceWidget, MouseEventListener)); - m_bMouseEventListener = true; - } - } - - virtual void HandleEventListener(VclWindowEvent& rEvent); - virtual bool HandleKeyEventListener(VclWindowEvent& rEvent); - virtual void HandleMouseEventListener(VclSimpleEvent& rEvent); - - void 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); - } - -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) + if (!m_bEventListener) { + m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, EventListener)); + m_bEventListener = true; } +} - virtual void set_sensitive(bool sensitive) override +// 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->Enable(sensitive); + Application::AddKeyListener(LINK(this, SalInstanceWidget, KeyEventListener)); + m_bKeyEventListener = true; } +} - virtual bool get_sensitive() const override +// 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) { - return m_xWidget->IsEnabled(); + Application::AddEventListener(LINK(this, SalInstanceWidget, MouseEventListener)); + m_bMouseEventListener = true; } +} - virtual bool get_visible() const override - { - return m_xWidget->IsVisible(); - } +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 is_visible() const override - { - return m_xWidget->IsReallyVisible(); - } +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 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); - } +void SalInstanceWidget::set_sensitive(bool sensitive) { m_xWidget->Enable(sensitive); } - virtual void grab_focus() override - { - m_xWidget->GrabFocus(); - } +bool SalInstanceWidget::get_sensitive() const { return m_xWidget->IsEnabled(); } - virtual bool has_focus() const override - { - return m_xWidget->HasFocus(); - } +bool SalInstanceWidget::get_visible() const { return m_xWidget->IsVisible(); } - virtual bool is_active() const override - { - return m_xWidget->IsActive(); - } +bool SalInstanceWidget::is_visible() const { return m_xWidget->IsReallyVisible(); } - virtual void set_has_default(bool has_default) override - { - m_xWidget->set_property("has-default", OUString::boolean(has_default)); - } +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 get_has_default() const override - { - return m_xWidget->GetStyle() & WB_DEFBUTTON; - } +void SalInstanceWidget::grab_focus() { m_xWidget->GrabFocus(); } - virtual void show() override - { - m_xWidget->Show(); - } +bool SalInstanceWidget::has_focus() const { return m_xWidget->HasFocus(); } - virtual void hide() override - { - m_xWidget->Hide(); - } +bool SalInstanceWidget::is_active() const { return m_xWidget->IsActive(); } - virtual void set_size_request(int nWidth, int nHeight) override - { - m_xWidget->set_width_request(nWidth); - m_xWidget->set_height_request(nHeight); - } +void SalInstanceWidget::set_has_default(bool has_default) +{ + m_xWidget->set_property("has-default", OUString::boolean(has_default)); +} - virtual Size get_size_request() const override - { - return Size(m_xWidget->get_width_request(), - m_xWidget->get_height_request()); - } +bool SalInstanceWidget::get_has_default() const { return m_xWidget->GetStyle() & WB_DEFBUTTON; } - virtual Size get_preferred_size() const override - { - return m_xWidget->get_preferred_size(); - } +void SalInstanceWidget::show() { m_xWidget->Show(); } - virtual float get_approximate_digit_width() const override - { - return m_xWidget->approximate_digit_width(); - } +void SalInstanceWidget::hide() { m_xWidget->Hide(); } - virtual int get_text_height() const override - { - return m_xWidget->GetTextHeight(); - } +void SalInstanceWidget::set_size_request(int nWidth, int nHeight) +{ + m_xWidget->set_width_request(nWidth); + m_xWidget->set_height_request(nHeight); +} - 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()); - } +Size SalInstanceWidget::get_size_request() const +{ + return Size(m_xWidget->get_width_request(), m_xWidget->get_height_request()); +} - virtual vcl::Font get_font() override - { - return m_xWidget->GetPointFont(*m_xWidget); - } +Size SalInstanceWidget::get_preferred_size() const { return m_xWidget->get_preferred_size(); } - virtual OString get_buildable_name() const override - { - return m_xWidget->get_id().toUtf8(); - } +float SalInstanceWidget::get_approximate_digit_width() const +{ + return m_xWidget->approximate_digit_width(); +} - virtual void set_help_id(const OString& rId) override - { - return m_xWidget->SetHelpId(rId); - } +int SalInstanceWidget::get_text_height() const { return m_xWidget->GetTextHeight(); } - virtual OString get_help_id() const override - { - return m_xWidget->GetHelpId(); - } +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_grid_left_attach(int nAttach) override - { - m_xWidget->set_grid_left_attach(nAttach); - } +vcl::Font SalInstanceWidget::get_font() { return m_xWidget->GetPointFont(*m_xWidget); } - virtual int get_grid_left_attach() const override - { - return m_xWidget->get_grid_left_attach(); - } +OString SalInstanceWidget::get_buildable_name() const { return m_xWidget->get_id().toUtf8(); } - virtual void set_grid_width(int nCols) override - { - m_xWidget->set_grid_width(nCols); - } +void SalInstanceWidget::set_help_id(const OString& rId) { return m_xWidget->SetHelpId(rId); } - virtual void set_grid_top_attach(int nAttach) override - { - m_xWidget->set_grid_top_attach(nAttach); - } +OString SalInstanceWidget::get_help_id() const { return m_xWidget->GetHelpId(); } - virtual int get_grid_top_attach() const override - { - return m_xWidget->get_grid_top_attach(); - } +void SalInstanceWidget::set_grid_left_attach(int nAttach) +{ + m_xWidget->set_grid_left_attach(nAttach); +} - virtual void set_hexpand(bool bExpand) override - { - m_xWidget->set_hexpand(bExpand); - } +int SalInstanceWidget::get_grid_left_attach() const { return m_xWidget->get_grid_left_attach(); } - virtual bool get_hexpand() const override - { - return m_xWidget->get_hexpand(); - } +void SalInstanceWidget::set_grid_width(int nCols) { m_xWidget->set_grid_width(nCols); } - virtual void set_vexpand(bool bExpand) override - { - m_xWidget->set_vexpand(bExpand); - } +void SalInstanceWidget::set_grid_top_attach(int nAttach) +{ + m_xWidget->set_grid_top_attach(nAttach); +} - virtual bool get_vexpand() const override - { - return m_xWidget->get_vexpand(); - } +int SalInstanceWidget::get_grid_top_attach() const { return m_xWidget->get_grid_top_attach(); } - virtual void set_secondary(bool bSecondary) override - { - m_xWidget->set_secondary(bSecondary); - } +void SalInstanceWidget::set_hexpand(bool bExpand) { m_xWidget->set_hexpand(bExpand); } - virtual void set_margin_top(int nMargin) override - { - m_xWidget->set_margin_top(nMargin); - } +bool SalInstanceWidget::get_hexpand() const { return m_xWidget->get_hexpand(); } - virtual void set_margin_bottom(int nMargin) override - { - m_xWidget->set_margin_bottom(nMargin); - } +void SalInstanceWidget::set_vexpand(bool bExpand) { m_xWidget->set_vexpand(bExpand); } - virtual void set_margin_left(int nMargin) override - { - m_xWidget->set_margin_left(nMargin); - } +bool SalInstanceWidget::get_vexpand() const { return m_xWidget->get_vexpand(); } - virtual void set_margin_right(int nMargin) override - { - m_xWidget->set_margin_bottom(nMargin); - } +void SalInstanceWidget::set_secondary(bool bSecondary) { m_xWidget->set_secondary(bSecondary); } - virtual int get_margin_top() const override - { - return m_xWidget->get_margin_top(); - } +void SalInstanceWidget::set_margin_top(int nMargin) { m_xWidget->set_margin_top(nMargin); } - virtual int get_margin_bottom() const override - { - return m_xWidget->get_margin_bottom(); - } +void SalInstanceWidget::set_margin_bottom(int nMargin) { m_xWidget->set_margin_bottom(nMargin); } - virtual int get_margin_left() const override - { - return m_xWidget->get_margin_left(); - } +void SalInstanceWidget::set_margin_left(int nMargin) { m_xWidget->set_margin_left(nMargin); } - virtual int get_margin_right() const override - { - return m_xWidget->get_margin_bottom(); - } +void SalInstanceWidget::set_margin_right(int nMargin) { m_xWidget->set_margin_bottom(nMargin); } - virtual void set_accessible_name(const OUString& rName) override - { - m_xWidget->SetAccessibleName(rName); - } +int SalInstanceWidget::get_margin_top() const { return m_xWidget->get_margin_top(); } - virtual OUString get_accessible_name() const override - { - return m_xWidget->GetAccessibleName(); - } +int SalInstanceWidget::get_margin_bottom() const { return m_xWidget->get_margin_bottom(); } - virtual OUString get_accessible_description() const override - { - return m_xWidget->GetAccessibleDescription(); - } +int SalInstanceWidget::get_margin_left() const { return m_xWidget->get_margin_left(); } - 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); - } +int SalInstanceWidget::get_margin_right() const { return m_xWidget->get_margin_bottom(); } - 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); - } +void SalInstanceWidget::set_accessible_name(const OUString& rName) +{ + m_xWidget->SetAccessibleName(rName); +} - virtual void add_extra_accessible_relation(const css::accessibility::AccessibleRelation &rRelation) override - { - m_xWidget->AddExtraAccessibleRelation(rRelation); - } +OUString SalInstanceWidget::get_accessible_name() const { return m_xWidget->GetAccessibleName(); } - virtual void clear_extra_accessible_relations() override - { - m_xWidget->ClearExtraAccessibleRelations(); - } +OUString SalInstanceWidget::get_accessible_description() const +{ + return m_xWidget->GetAccessibleDescription(); +} - virtual void set_tooltip_text(const OUString& rTip) override - { - m_xWidget->SetQuickHelpText(rTip); - } +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 OUString get_tooltip_text() const override - { - return m_xWidget->GetQuickHelpText(); - } +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 connect_focus_in(const Link<Widget&, void>& rLink) override - { - ensure_event_listener(); - weld::Widget::connect_focus_in(rLink); - } +void SalInstanceWidget::add_extra_accessible_relation( + const css::accessibility::AccessibleRelation& rRelation) +{ + m_xWidget->AddExtraAccessibleRelation(rRelation); +} - virtual void connect_mnemonic_activate(const Link<Widget&, bool>& rLink) override - { - m_xWidget->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget, MnemonicActivateHdl)); - weld::Widget::connect_mnemonic_activate(rLink); - } +void SalInstanceWidget::clear_extra_accessible_relations() +{ + m_xWidget->ClearExtraAccessibleRelations(); +} - virtual void connect_focus_out(const Link<Widget&, void>& rLink) override - { - ensure_event_listener(); - weld::Widget::connect_focus_out(rLink); - } +void SalInstanceWidget::set_tooltip_text(const OUString& rTip) +{ + m_xWidget->SetQuickHelpText(rTip); +} - virtual void connect_size_allocate(const Link<const Size&, void>& rLink) override - { - ensure_event_listener(); - weld::Widget::connect_size_allocate(rLink); - } +OUString SalInstanceWidget::get_tooltip_text() const { return m_xWidget->GetQuickHelpText(); } - 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_in(const Link<Widget&, void>& rLink) +{ + ensure_event_listener(); + weld::Widget::connect_focus_in(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_mnemonic_activate(const Link<Widget&, bool>& rLink) +{ + m_xWidget->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget, MnemonicActivateHdl)); + weld::Widget::connect_mnemonic_activate(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_focus_out(const Link<Widget&, void>& rLink) +{ + ensure_event_listener(); + weld::Widget::connect_focus_out(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_size_allocate(const Link<const Size&, void>& rLink) +{ + ensure_event_listener(); + weld::Widget::connect_size_allocate(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_press(const Link<const MouseEvent&, bool>& rLink) +{ + ensure_mouse_listener(); + weld::Widget::connect_mouse_press(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_mouse_move(const Link<const MouseEvent&, bool>& rLink) +{ + ensure_mouse_listener(); + weld::Widget::connect_mouse_move(rLink); +} - virtual void grab_add() override - { - m_xWidget->CaptureMouse(); - } +void SalInstanceWidget::connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) +{ + ensure_mouse_listener(); + weld::Widget::connect_mouse_release(rLink); +} - virtual bool has_grab() const override - { - return m_xWidget->IsMouseCaptured(); - } +void SalInstanceWidget::connect_key_press(const Link<const KeyEvent&, bool>& rLink) +{ + ensure_key_listener(); + weld::Widget::connect_key_press(rLink); +} - virtual void grab_remove() override - { - m_xWidget->ReleaseMouse(); - } +void SalInstanceWidget::connect_key_release(const Link<const KeyEvent&, bool>& rLink) +{ + ensure_key_listener(); + weld::Widget::connect_key_release(rLink); +} - virtual bool get_direction() const override - { - return m_xWidget->IsRTLEnabled(); - } +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 set_direction(bool bRTL) override - { - m_xWidget->EnableRTL(bRTL); - } +void SalInstanceWidget::grab_add() { m_xWidget->CaptureMouse(); } - virtual void freeze() override - { - m_xWidget->SetUpdateMode(false); - } +bool SalInstanceWidget::has_grab() const { return m_xWidget->IsMouseCaptured(); } - virtual void thaw() override - { - m_xWidget->SetUpdateMode(true); - } +void SalInstanceWidget::grab_remove() { m_xWidget->ReleaseMouse(); } - virtual std::unique_ptr<weld::Container> weld_parent() const override; +bool SalInstanceWidget::get_direction() const { return m_xWidget->IsRTLEnabled(); } - 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::set_direction(bool bRTL) { m_xWidget->EnableRTL(bRTL); } - vcl::Window* getWidget() - { - return m_xWidget; - } +void SalInstanceWidget::freeze() { m_xWidget->SetUpdateMode(false); } - void disable_notify_events() - { - ++m_nBlockNotify; - } +void SalInstanceWidget::thaw() { m_xWidget->SetUpdateMode(true); } - bool notify_events_disabled() - { - return m_nBlockNotify != 0; - } +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 enable_notify_events() - { - --m_nBlockNotify; - } +vcl::Window* SalInstanceWidget::getWidget() { return m_xWidget; } - virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) override; +void SalInstanceWidget::disable_notify_events() { ++m_nBlockNotify; } - virtual OUString strip_mnemonic(const OUString &rLabel) const override - { - return rLabel.replaceFirst("~", ""); - } +bool SalInstanceWidget::notify_events_disabled() { return m_nBlockNotify != 0; } - 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); - } +void SalInstanceWidget::enable_notify_events() { --m_nBlockNotify; } - virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override - { - return m_xWidget->GetDropTarget(); - } +OUString SalInstanceWidget::strip_mnemonic(const OUString& rLabel) const +{ + return rLabel.replaceFirst("~", ""); +} - virtual void connect_get_property_tree(const Link<boost::property_tree::ptree&, void>& rLink) override - { - m_xWidget->SetDumpAsPropertyTreeHdl(rLink); - } +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 void set_stack_background() override - { - set_background(m_xWidget->GetSettings().GetStyleSettings().GetWindowColor()); - } +css::uno::Reference<css::datatransfer::dnd::XDropTarget> SalInstanceWidget::get_drop_target() +{ + return m_xWidget->GetDropTarget(); +} - virtual void set_toolbar_background() override - { - m_xWidget->SetBackground(); - m_xWidget->SetPaintTransparent(true); - } +void SalInstanceWidget::connect_get_property_tree( + const Link<boost::property_tree::ptree&, void>& rLink) +{ + m_xWidget->SetDumpAsPropertyTreeHdl(rLink); +} - virtual void set_highlight_background() override - { - set_background(m_xWidget->GetSettings().GetStyleSettings().GetHighlightColor()); - } +void SalInstanceWidget::set_stack_background() +{ + set_background(m_xWidget->GetSettings().GetStyleSettings().GetWindowColor()); +} - SystemWindow* getSystemWindow() - { - return m_xWidget->GetSystemWindow(); - } -}; +void SalInstanceWidget::set_toolbar_background() +{ + m_xWidget->SetBackground(); + m_xWidget->SetPaintTransparent(true); +} +void SalInstanceWidget::set_highlight_background() +{ + set_background(m_xWidget->GetSettings().GetStyleSettings().GetHighlightColor()); } +SystemWindow* SalInstanceWidget::getSystemWindow() { return m_xWidget->GetSystemWindow(); } + void SalInstanceWidget::HandleEventListener(VclWindowEvent& rEvent) { if (rEvent.GetId() == VclEventId::WindowGetFocus) @@ -834,48 +618,51 @@ IMPL_LINK_NOARG(SalInstanceWidget, MnemonicActivateHdl, vcl::Window&, bool) namespace { - Image createImage(const OUString& rImage) +Image createImage(const OUString& rImage) +{ + if (rImage.isEmpty()) + return Image(); + if (rImage.lastIndexOf('.') != rImage.getLength() - 4) { - if (rImage.isEmpty()) - return Image(); - if (rImage.lastIndexOf('.') != rImage.getLength() - 4) - { - assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image"); - if (rImage == "dialog-warning") - return Image(StockImage::Yes, IMG_WARN); - else if (rImage == "dialog-error") - return Image(StockImage::Yes, IMG_ERROR); - else if (rImage == "dialog-information") - return Image(StockImage::Yes, IMG_INFO); - } - return Image(StockImage::Yes, rImage); + assert((rImage == "dialog-warning" || rImage == "dialog-error" + || rImage == "dialog-information") + && "unknown stock image"); + if (rImage == "dialog-warning") + return Image(StockImage::Yes, IMG_WARN); + else if (rImage == "dialog-error") + return Image(StockImage::Yes, IMG_ERROR); + else if (rImage == "dialog-information") + return Image(StockImage::Yes, IMG_INFO); } + return Image(StockImage::Yes, rImage); +} + +Image createImage(const VirtualDevice& rDevice) +{ + return Image(rDevice.GetBitmapEx(Point(), rDevice.GetOutputSizePixel())); +} - Image createImage(const VirtualDevice& rDevice) +sal_uInt16 insert_to_menu(sal_uInt16 nLastId, PopupMenu* pMenu, int pos, const OUString& rId, + const OUString& rStr, const OUString* pIconName, + const VirtualDevice* pImageSurface, bool bCheck) +{ + const sal_uInt16 nNewid = nLastId + 1; + pMenu->InsertItem(nNewid, rStr, bCheck ? MenuItemBits::CHECKABLE : MenuItemBits::NONE, + OUStringToOString(rId, RTL_TEXTENCODING_UTF8), pos == -1 ? MENU_APPEND : pos); + if (pIconName) { - return Image(rDevice.GetBitmapEx(Point(), rDevice.GetOutputSizePixel())); + pMenu->SetItemImage(nNewid, createImage(*pIconName)); } - - sal_uInt16 insert_to_menu(sal_uInt16 nLastId, PopupMenu* pMenu, int pos, const OUString& rId, const OUString& rStr, - const OUString* pIconName, const VirtualDevice* pImageSurface, bool bCheck) + else if (pImageSurface) { - const sal_uInt16 nNewid = nLastId + 1; - pMenu->InsertItem(nNewid, rStr, bCheck ? MenuItemBits::CHECKABLE : MenuItemBits::NONE, - OUStringToOString(rId, RTL_TEXTENCODING_UTF8), pos == -1 ? MENU_APPEND : pos); - if (pIconName) - { - pMenu->SetItemImage(nNewid, createImage(*pIconName)); - } - else if (pImageSurface) - { - pMenu->SetItemImage(nNewid, createImage(*pImageSurface)); - } - return nNewid; + pMenu->SetItemImage(nNewid, createImage(*pImageSurface)); } + return nNewid; +} } -namespace { - +namespace +{ class SalInstanceMenu : public weld::Menu { private: @@ -885,20 +672,22 @@ private: sal_uInt16 m_nLastId; DECL_LINK(SelectMenuHdl, ::Menu*, bool); + public: SalInstanceMenu(PopupMenu* pMenu, bool bTakeOwnership) : m_xMenu(pMenu) , m_bTakeOwnership(bTakeOwnership) { const auto nCount = m_xMenu->GetItemCount(); - m_nLastId = nCount ? pMenu->GetItemId(nCount-1) : 0; + m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0; m_xMenu->SetSelectHdl(LINK(this, SalInstanceMenu, SelectMenuHdl)); } - virtual OString popup_at_rect(weld::Widget* pParent, const tools::Rectangle &rRect) override + virtual OString popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect) override { SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pParent); assert(pVclWidget); - m_xMenu->Execute(pVclWidget->getWidget(), rRect, PopupMenuFlags::ExecuteDown | PopupMenuFlags::NoMouseUpClose); + m_xMenu->Execute(pVclWidget->getWidget(), rRect, + PopupMenuFlags::ExecuteDown | PopupMenuFlags::NoMouseUpClose); return m_xMenu->GetCurItemIdent(); } virtual void set_sensitive(const OString& rIdent, bool bSensitive) override @@ -921,28 +710,21 @@ public: { m_xMenu->ShowItem(m_xMenu->GetItemId(rIdent), bShow); } - virtual void clear() override - { - m_xMenu->Clear(); - } + virtual void clear() override { m_xMenu->Clear(); } virtual void insert(int pos, const OUString& rId, const OUString& rStr, - const OUString* pIconName, VirtualDevice* pImageSurface, bool bCheck) override + const OUString* pIconName, VirtualDevice* pImageSurface, + bool bCheck) override { - m_nLastId = insert_to_menu(m_nLastId, m_xMenu, pos, rId, rStr, pIconName, pImageSurface, bCheck); + m_nLastId + = insert_to_menu(m_nLastId, m_xMenu, pos, rId, rStr, pIconName, pImageSurface, bCheck); } virtual void insert_separator(int pos, const OUString& rId) override { auto nInsertPos = pos == -1 ? MENU_APPEND : pos; m_xMenu->InsertSeparator(rId.toUtf8(), nInsertPos); } - virtual int n_children() const override - { - return m_xMenu->GetItemCount(); - } - PopupMenu* getMenu() const - { - return m_xMenu.get(); - } + virtual int n_children() const override { return m_xMenu->GetItemCount(); } + PopupMenu* getMenu() const { return m_xMenu.get(); } virtual ~SalInstanceMenu() override { m_xMenu->SetSelectHdl(Link<::Menu*, bool>()); @@ -959,8 +741,8 @@ IMPL_LINK_NOARG(SalInstanceMenu, SelectMenuHdl, ::Menu*, bool) return true; } -namespace { - +namespace +{ class SalInstanceToolbar : public SalInstanceWidget, public virtual weld::Toolbar { private: @@ -1022,7 +804,7 @@ public: void set_menu_item_active(const OString& rIdent, bool bActive) override { sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); - assert (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN); + assert(m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN); if (bActive) { @@ -1034,7 +816,8 @@ public: if (pFloat) { if (bActive) - vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, FloatWinPopupFlags::GrabFocus); + vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, + FloatWinPopupFlags::GrabFocus); else vcl::Window::GetDockingManager()->EndPopupMode(pFloat); } @@ -1056,7 +839,7 @@ public: bool get_menu_item_active(const OString& rIdent) const override { sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); - assert (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN); + assert(m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN); if (rIdent == m_sStartShowIdent) return true; @@ -1101,7 +884,7 @@ public: { SalInstanceMenu* pInstanceMenu = dynamic_cast<SalInstanceMenu*>(pMenu); - PopupMenu* pPopup = pInstanceMenu? pInstanceMenu->getMenu() : nullptr; + PopupMenu* pPopup = pInstanceMenu ? pInstanceMenu->getMenu() : nullptr; sal_uInt16 nId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); m_aMenus[nId] = pPopup; @@ -1114,10 +897,7 @@ public: m_xToolBox->InsertSeparator(nInsertPos, 5); } - virtual int get_n_items() const override - { - return m_xToolBox->GetItemCount(); - } + virtual int get_n_items() const override { return m_xToolBox->GetItemCount(); } virtual OString get_item_ident(int nIndex) const override { @@ -1126,7 +906,8 @@ public: virtual void set_item_ident(int nIndex, const OString& rIdent) override { - return m_xToolBox->SetItemCommand(m_xToolBox->GetItemId(nIndex), OUString::fromUtf8(rIdent)); + return m_xToolBox->SetItemCommand(m_xToolBox->GetItemId(nIndex), + OUString::fromUtf8(rIdent)); } virtual void set_item_label(int nIndex, const OUString& rLabel) override @@ -1146,10 +927,12 @@ public: virtual void set_item_icon_name(const OString& rIdent, const OUString& rIconName) override { - m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), Image(StockImage::Yes, rIconName)); + m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), + Image(StockImage::Yes, rIconName)); } - virtual void set_item_image(const OString& rIdent, const css::uno::Reference<css::graphic::XGraphic>& rIcon) override + virtual void set_item_image(const OString& rIdent, + const css::uno::Reference<css::graphic::XGraphic>& rIcon) override { m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), Image(rIcon)); } @@ -1157,12 +940,14 @@ public: virtual void set_item_image(const OString& rIdent, VirtualDevice* pDevice) override { if (pDevice) - m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), createImage(*pDevice)); + m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), + createImage(*pDevice)); else m_xToolBox->SetItemImage(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), Image()); } - virtual void set_item_image(int nIndex, const css::uno::Reference<css::graphic::XGraphic>& rIcon) override + virtual void set_item_image(int nIndex, + const css::uno::Reference<css::graphic::XGraphic>& rIcon) override { m_xToolBox->SetItemImage(m_xToolBox->GetItemId(nIndex), Image(rIcon)); } @@ -1182,10 +967,7 @@ public: return m_xToolBox->GetQuickHelpText(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); } - virtual vcl::ImageType get_icon_size() const override - { - return m_xToolBox->GetImageSize(); - } + virtual vcl::ImageType get_icon_size() const override { return m_xToolBox->GetImageSize(); } virtual void set_icon_size(vcl::ImageType eType) override { @@ -1246,12 +1028,13 @@ IMPL_LINK(SalInstanceToolbar, MenuToggleListener, VclWindowEvent&, rEvent, void) } } -namespace { - +namespace +{ class SalInstanceSizeGroup : public weld::SizeGroup { private: std::shared_ptr<VclSizeGroup> m_xGroup; + public: SalInstanceSizeGroup() : m_xGroup(std::make_shared<VclSizeGroup>()) @@ -1263,73 +1046,62 @@ public: assert(pVclWidget && pVclWidget->getWidget()); pVclWidget->getWidget()->add_to_size_group(m_xGroup); } - virtual void set_mode(VclSizeGroupMode eMode) override - { - m_xGroup->set_mode(eMode); - } + virtual void set_mode(VclSizeGroupMode eMode) override { m_xGroup->set_mode(eMode); } }; +} -class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Container +void SalInstanceContainer::implResetDefault(const vcl::Window* _pWindow) { -protected: - VclPtr<vcl::Window> m_xContainer; - -private: - void 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) - ) - { - pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON); - } - - // the next one ... - pChildLoop = pChildLoop->GetWindow(GetWindowType::Next); - } - } - -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 + vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); + while (pChildLoop) { - 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); + // 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); } -}; +} + +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 @@ -1340,8 +1112,8 @@ std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const return std::make_unique<SalInstanceContainer>(pParent, m_pBuilder, false); } -namespace { - +namespace +{ class SalInstanceBox : public SalInstanceContainer, public virtual weld::Box { public: @@ -1357,441 +1129,386 @@ public: } }; - void CollectChildren(const vcl::Window& rCurrent, const basegfx::B2IPoint& rTopLeft, weld::ScreenShotCollection& rControlDataCollection) +void CollectChildren(const vcl::Window& rCurrent, const basegfx::B2IPoint& rTopLeft, + weld::ScreenShotCollection& rControlDataCollection) +{ + if (rCurrent.IsVisible()) { - if (rCurrent.IsVisible()) - { - const Point aCurrentPos(rCurrent.GetPosPixel()); - const Size aCurrentSize(rCurrent.GetSizePixel()); - const basegfx::B2IPoint aCurrentTopLeft(rTopLeft.getX() + aCurrentPos.X(), rTopLeft.getY() + aCurrentPos.Y()); - const basegfx::B2IRange aCurrentRange(aCurrentTopLeft, aCurrentTopLeft + basegfx::B2IPoint(aCurrentSize.Width(), aCurrentSize.Height())); + const Point aCurrentPos(rCurrent.GetPosPixel()); + const Size aCurrentSize(rCurrent.GetSizePixel()); + const basegfx::B2IPoint aCurrentTopLeft(rTopLeft.getX() + aCurrentPos.X(), + rTopLeft.getY() + aCurrentPos.Y()); + const basegfx::B2IRange aCurrentRange( + aCurrentTopLeft, + aCurrentTopLeft + basegfx::B2IPoint(aCurrentSize.Width(), aCurrentSize.Height())); - if (!aCurrentRange.isEmpty()) - { - rControlDataCollection.emplace_back(rCurrent.GetHelpId(), aCurrentRange); - } + if (!aCurrentRange.isEmpty()) + { + rControlDataCollection.emplace_back(rCurrent.GetHelpId(), aCurrentRange); + } - for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++) + for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++) + { + vcl::Window* pChild = rCurrent.GetChild(a); + if (nullptr != pChild) { - vcl::Window* pChild = rCurrent.GetChild(a); - if (nullptr != pChild) - { - CollectChildren(*pChild, aCurrentTopLeft, rControlDataCollection); - } + CollectChildren(*pChild, aCurrentTopLeft, rControlDataCollection); } } } +} -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) - { - 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::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)); +} -public: - SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership) - , m_xWindow(pWindow) - { - override_child_help(m_xWindow); - } +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>()); +} - virtual void set_title(const OUString& rTitle) override - { - m_xWindow->SetText(rTitle); - } +SalInstanceWindow::SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership) + , m_xWindow(pWindow) +{ + override_child_help(m_xWindow); +} - virtual OUString get_title() const override - { - return m_xWindow->GetText(); - } +void SalInstanceWindow::set_title(const OUString& rTitle) { m_xWindow->SetText(rTitle); } - void help(); +OUString SalInstanceWindow::get_title() const { return m_xWindow->GetText(); } - virtual void set_busy_cursor(bool bBusy) override - { - if (bBusy) - m_xWindow->EnterWait(); - else - m_xWindow->LeaveWait(); - } +void SalInstanceWindow::set_busy_cursor(bool bBusy) +{ + if (bBusy) + m_xWindow->EnterWait(); + else + m_xWindow->LeaveWait(); +} - virtual css::uno::Reference<css::awt::XWindow> GetXWindow() override - { - css::uno::Reference<css::awt::XWindow> xWindow(m_xWindow->GetComponentInterface(), css::uno::UNO_QUERY); - return xWindow; - } +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 void resize_to_request() override +void SalInstanceWindow::resize_to_request() +{ + if (SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(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"); + pSysWin->setOptimalLayoutSize(); + return; } - - virtual void set_modal(bool bModal) override + if (DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(m_xWindow.get())) { - m_xWindow->ImplGetFrame()->SetModal(bModal); + pDockWin->setOptimalLayoutSize(); + return; } + assert(false && "must be system or docking window"); +} - virtual bool get_modal() const override - { - return m_xWindow->ImplGetFrame()->GetModal(); - } +void SalInstanceWindow::set_modal(bool bModal) { m_xWindow->ImplGetFrame()->SetModal(bModal); } - virtual void window_move(int x, int y) override - { - m_xWindow->SetPosPixel(Point(x, y)); - } +bool SalInstanceWindow::get_modal() const { return m_xWindow->ImplGetFrame()->GetModal(); } - virtual Size get_size() const override - { - return m_xWindow->GetSizePixel(); - } +void SalInstanceWindow::window_move(int x, int y) { m_xWindow->SetPosPixel(Point(x, y)); } - virtual Point get_position() const override - { - return m_xWindow->GetPosPixel(); - } +Size SalInstanceWindow::get_size() const { return m_xWindow->GetSizePixel(); } - virtual tools::Rectangle get_monitor_workarea() const override - { - return m_xWindow->GetDesktopRectPixel(); - } +Point SalInstanceWindow::get_position() const { return m_xWindow->GetPosPixel(); } - virtual void set_centered_on_parent(bool /*bTrackGeometryRequests*/) override - { - 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)); - } - } +tools::Rectangle SalInstanceWindow::get_monitor_workarea() const +{ + return m_xWindow->GetDesktopRectPixel(); +} - virtual bool get_resizable() const override +void SalInstanceWindow::set_centered_on_parent(bool /*bTrackGeometryRequests*/) +{ + if (vcl::Window* pParent = m_xWidget->GetParent()) { - return m_xWindow->GetStyle() & WB_SIZEABLE; + 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 has_toplevel_focus() const override - { - return m_xWindow->HasChildPathFocus(); - } +bool SalInstanceWindow::get_resizable() const { return m_xWindow->GetStyle() & WB_SIZEABLE; } - virtual void present() override - { - m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask); - } +bool SalInstanceWindow::has_toplevel_focus() const { return m_xWindow->HasChildPathFocus(); } - virtual void set_window_state(const OString& rStr) override - { - SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); - assert(pSysWin); - pSysWin->SetWindowState(rStr); - } +void SalInstanceWindow::present() +{ + m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask); +} - virtual OString get_window_state(WindowStateMask nMask) const override - { - SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); - assert(pSysWin); - return pSysWin->GetWindowState(nMask); - } +void SalInstanceWindow::set_window_state(const OString& rStr) +{ + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); + assert(pSysWin); + pSysWin->SetWindowState(rStr); +} - virtual SystemEnvData get_system_data() const override - { - return *m_xWindow->GetSystemData(); - } +OString SalInstanceWindow::get_window_state(WindowStateMask nMask) const +{ + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); + assert(pSysWin); + return pSysWin->GetWindowState(nMask); +} - virtual void connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) override - { - ensure_event_listener(); - weld::Window::connect_toplevel_focus_changed(rLink); - } +SystemEnvData SalInstanceWindow::get_system_data() const { return *m_xWindow->GetSystemData(); } - virtual void HandleEventListener(VclWindowEvent& rEvent) override - { - if (rEvent.GetId() == VclEventId::WindowActivate || rEvent.GetId() == VclEventId::WindowDeactivate) - { - signal_toplevel_focus_changed(); - return; - } - SalInstanceContainer::HandleEventListener(rEvent); - } +void SalInstanceWindow::connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) +{ + ensure_event_listener(); + weld::Window::connect_toplevel_focus_changed(rLink); +} - virtual void draw(VirtualDevice& rOutput) override +void SalInstanceWindow::HandleEventListener(VclWindowEvent& rEvent) +{ + if (rEvent.GetId() == VclEventId::WindowActivate + || rEvent.GetId() == VclEventId::WindowDeactivate) { - SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); - assert(pSysWin); - pSysWin->createScreenshot(rOutput); + signal_toplevel_focus_changed(); + return; } + SalInstanceContainer::HandleEventListener(rEvent); +} - virtual weld::ScreenShotCollection collect_screenshot_data() override - { - 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); +void SalInstanceWindow::draw(VirtualDevice& rOutput) +{ + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get()); + assert(pSysWin); + pSysWin->createScreenshot(rOutput); +} - return aRet; - } +weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data() +{ + weld::ScreenShotCollection aRet; - virtual ~SalInstanceWindow() override - { - clear_child_help(m_xWindow); - } -}; + // 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; } +SalInstanceWindow::~SalInstanceWindow() { clear_child_help(m_xWindow); } + IMPL_LINK_NOARG(SalInstanceWindow, HelpHdl, vcl::Window&, bool) { help(); return false; } -typedef std::set<VclPtr<vcl::Window> > winset; +typedef std::set<VclPtr<vcl::Window>> winset; namespace { - void hideUnless(const vcl::Window *pTop, const winset& rVisibleWidgets, - std::vector<VclPtr<vcl::Window> > &rWasVisibleWidgets) +void hideUnless(const vcl::Window* pTop, const winset& rVisibleWidgets, + std::vector<VclPtr<vcl::Window>>& rWasVisibleWidgets) +{ + for (vcl::Window* pChild = pTop->GetWindow(GetWindowType::FirstChild); pChild; + pChild = pChild->GetWindow(GetWindowType::Next)) { - for (vcl::Window* pChild = pTop->GetWindow(GetWindowType::FirstChild); pChild; - pChild = pChild->GetWindow(GetWindowType::Next)) + if (!pChild->IsVisible()) + continue; + if (rVisibleWidgets.find(pChild) == rVisibleWidgets.end()) { - if (!pChild->IsVisible()) - continue; - if (rVisibleWidgets.find(pChild) == rVisibleWidgets.end()) - { - rWasVisibleWidgets.emplace_back(pChild); - pChild->Hide(); - } - else if (isContainerWindow(pChild)) - { - hideUnless(pChild, rVisibleWidgets, rWasVisibleWidgets); - } + rWasVisibleWidgets.emplace_back(pChild); + pChild->Hide(); } - } - -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) - : SalInstanceWindow(pDialog, pBuilder, bTakeOwnership) - , m_xDialog(pDialog) - , m_nOldEditWidthReq(0) - , m_nOldBorderWidth(0) - { - const bool bScreenshotMode(officecfg::Office::Common::Misc::ScreenshotMode::get()); - if (bScreenshotMode) + else if (isContainerWindow(pChild)) { - m_xDialog->SetPopupMenuHdl(LINK(this, SalInstanceDialog, PopupScreenShotMenuHdl)); + hideUnless(pChild, rVisibleWidgets, rWasVisibleWidgets); } } +} +} - 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 +SalInstanceDialog::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) { - 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 ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits