tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / vcl / inc / jsdialog / jsdialogbuilder.hxx
blobd7fd64388b4b25beac7fc277cd9a1c65721330f1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include <jsdialog/jsdialogregister.hxx>
13 #include <jsdialog/jsdialogmessages.hxx>
14 #include <jsdialog/jsdialogsender.hxx>
16 #include <utility>
17 #include <vcl/weld.hxx>
18 #include <vcl/virdev.hxx>
19 #include <salvtables.hxx>
20 #include <vcl/toolkit/button.hxx>
21 #include <vcl/toolkit/fmtfield.hxx>
22 #include <vcl/toolkit/prgsbar.hxx>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
27 #include <comphelper/compbase.hxx>
29 #include <list>
30 #include <mutex>
32 class ToolBox;
33 class ComboBox;
34 class VclMultiLineEdit;
35 class SvTabListBox;
36 class IconView;
37 class VclScrolledWindow;
39 typedef jsdialog::WidgetRegister<weld::Widget*> WidgetMap;
41 class JSDropTarget final
42 : public comphelper::WeakComponentImplHelper<
43 css::datatransfer::dnd::XDropTarget, css::lang::XInitialization, css::lang::XServiceInfo>
45 std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
47 public:
48 JSDropTarget();
50 // XInitialization
51 virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override;
53 // XDropTarget
54 virtual void SAL_CALL addDropTargetListener(
55 const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
56 virtual void SAL_CALL removeDropTargetListener(
57 const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
58 virtual sal_Bool SAL_CALL isActive() override;
59 virtual void SAL_CALL setActive(sal_Bool active) override;
60 virtual sal_Int8 SAL_CALL getDefaultActions() override;
61 virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override;
63 OUString SAL_CALL getImplementationName() override;
65 sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
67 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
69 void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
71 void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
74 class JSInstanceBuilder final : public SalInstanceBuilder, public JSDialogSender
76 enum Type
78 Dialog,
79 Popup,
80 Sidebar,
81 Notebookbar,
82 Formulabar,
83 Menu,
86 void initializeDialogSender();
87 void initializePopupSender();
88 void initializeSidebarSender(sal_uInt64 nLOKWindowId, const std::u16string_view& rUIFile);
89 void initializeNotebookbarSender(sal_uInt64 nLOKWindowId);
90 void initializeFormulabarSender(sal_uInt64 nLOKWindowId, const std::u16string_view& sTypeOfJSON,
91 vcl::Window* pVclParent);
92 void initializeMenuSender(weld::Widget* pParent);
94 static jsdialog::WidgetRegister<std::shared_ptr<WidgetMap>> m_aWidgets;
95 static jsdialog::WidgetRegister<VclPtr<vcl::Window>> m_aPopups;
96 static jsdialog::WidgetRegister<weld::Menu*> m_aMenus;
98 sal_uInt64 m_nWindowId;
99 /// used in case of tab pages where dialog is not a direct top level
100 VclPtr<vcl::Window> m_aParentDialog;
101 VclPtr<vcl::Window> m_aContentWindow;
102 std::list<OUString> m_aRememberedWidgets;
103 OUString m_sTypeOfJSON;
104 bool m_bHasTopLevelDialog;
105 bool m_bIsNotebookbar;
106 /// used to detect when we have to send Full Update in container handler
107 bool m_bSentInitialUpdate;
108 /// is true for tabpages, prevents from closing parent window on destroy
109 bool m_bIsNestedBuilder;
110 /// When LOKNotifier is set by jsdialogs code we need to release it
111 VclPtr<vcl::Window> m_aWindowToRelease;
113 friend class JSMessageDialog; // static message boxes have to be registered outside
114 friend class JSDialog;
115 friend class JSAssistant;
117 friend VCL_DLLPUBLIC bool jsdialog::ExecuteAction(const OUString& nWindowId,
118 const OUString& rWidget, StringMap& rData);
119 friend VCL_DLLPUBLIC void jsdialog::SendFullUpdate(const OUString& nWindowId,
120 const OUString& rWidget);
121 friend VCL_DLLPUBLIC void jsdialog::SendAction(const OUString& nWindowId,
122 const OUString& rWidget,
123 std::unique_ptr<jsdialog::ActionDataMap> pData);
125 static void InsertWindowToMap(const OUString& nWindowId);
126 void RememberWidget(OUString id, weld::Widget* pWidget);
127 static void RememberWidget(const OUString& nWindowId, const OUString& id,
128 weld::Widget* pWidget);
130 OUString getMapIdFromWindowId() const;
132 public:
133 JSInstanceBuilder(weld::Widget* pParent, vcl::Window* pVclParent, std::u16string_view rUIRoot,
134 const OUString& rUIFile, Type eBuilderType, sal_uInt64 nLOKWindowId = 0,
135 const std::u16string_view& sTypeOfJSON = u"",
136 const css::uno::Reference<css::frame::XFrame>& rFrame
137 = css::uno::Reference<css::frame::XFrame>());
139 static std::unique_ptr<JSInstanceBuilder>
140 CreateDialogBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
142 static std::unique_ptr<JSInstanceBuilder>
143 CreateNotebookbarBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
144 const css::uno::Reference<css::frame::XFrame>& rFrame,
145 sal_uInt64 nWindowId = 0);
146 static std::unique_ptr<JSInstanceBuilder> CreateSidebarBuilder(weld::Widget* pParent,
147 const OUString& rUIRoot,
148 const OUString& rUIFile,
149 sal_uInt64 nLOKWindowId = 0);
151 static std::unique_ptr<JSInstanceBuilder>
152 CreatePopupBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
154 static std::unique_ptr<JSInstanceBuilder>
155 CreateMenuBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
157 static std::unique_ptr<JSInstanceBuilder> CreateFormulabarBuilder(vcl::Window* pParent,
158 const OUString& rUIRoot,
159 const OUString& rUIFile,
160 sal_uInt64 nLOKWindowId);
162 virtual ~JSInstanceBuilder() override;
163 virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OUString& id) override;
164 virtual std::unique_ptr<weld::Dialog> weld_dialog(const OUString& id) override;
165 virtual std::unique_ptr<weld::Assistant> weld_assistant(const OUString& id) override;
166 virtual std::unique_ptr<weld::Container> weld_container(const OUString& id) override;
167 virtual std::unique_ptr<weld::Label> weld_label(const OUString& id) override;
168 virtual std::unique_ptr<weld::Button> weld_button(const OUString& id) override;
169 virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OUString& id) override;
170 virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OUString& id) override;
171 virtual std::unique_ptr<weld::Entry> weld_entry(const OUString& id) override;
172 virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OUString& id) override;
173 virtual std::unique_ptr<weld::Notebook> weld_notebook(const OUString& id) override;
174 virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OUString& id) override;
175 virtual std::unique_ptr<weld::FormattedSpinButton>
176 weld_formatted_spin_button(const OUString& id) override;
177 virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OUString& id) override;
178 virtual std::unique_ptr<weld::DrawingArea>
179 weld_drawing_area(const OUString& id, const a11yref& rA11yImpl = nullptr,
180 FactoryFunction pUITestFactoryFunction = nullptr,
181 void* pUserData = nullptr) override;
182 virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OUString& id) override;
183 virtual std::unique_ptr<weld::TextView> weld_text_view(const OUString& id) override;
184 virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OUString& id) override;
185 virtual std::unique_ptr<weld::Expander> weld_expander(const OUString& id) override;
186 virtual std::unique_ptr<weld::IconView> weld_icon_view(const OUString& id) override;
187 virtual std::unique_ptr<weld::ScrolledWindow>
188 weld_scrolled_window(const OUString& id, bool bUserManagedScrolling = false) override;
189 virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OUString& id) override;
190 virtual std::unique_ptr<weld::Frame> weld_frame(const OUString& id) override;
191 virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OUString& id) override;
192 virtual std::unique_ptr<weld::Menu> weld_menu(const OUString& id) override;
193 virtual std::unique_ptr<weld::Popover> weld_popover(const OUString& id) override;
194 virtual std::unique_ptr<weld::Box> weld_box(const OUString& id) override;
195 virtual std::unique_ptr<weld::Widget> weld_widget(const OUString& id) override;
196 virtual std::unique_ptr<weld::Image> weld_image(const OUString& id) override;
197 virtual std::unique_ptr<weld::LevelBar> weld_level_bar(const OUString& id) override;
198 virtual std::unique_ptr<weld::Calendar> weld_calendar(const OUString& id) override;
200 static weld::MessageDialog*
201 CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
202 VclButtonsType eButtonType, const OUString& rPrimaryMessage,
203 const vcl::ILibreOfficeKitNotifier* pNotifier = nullptr);
205 // regular widgets
206 static jsdialog::WidgetRegister<std::shared_ptr<WidgetMap>>& Widgets() { return m_aWidgets; };
208 // we need to remember original popup window to close it properly (its handled by vcl)
209 static jsdialog::WidgetRegister<VclPtr<vcl::Window>>& Popups() { return m_aPopups; }
211 // menus in separate container as they don't share base class with weld::Widget
212 static jsdialog::WidgetRegister<weld::Menu*>& Menus() { return m_aMenus; }
214 private:
215 const OUString& GetTypeOfJSON() const;
216 VclPtr<vcl::Window>& GetContentWindow();
217 VclPtr<vcl::Window>& GetNotifierWindow();
220 class SAL_LOPLUGIN_ANNOTATE("crosscast") BaseJSWidget
222 public:
223 virtual ~BaseJSWidget() = default;
225 virtual void sendClose() = 0;
227 virtual void sendUpdate(bool bForce = false) = 0;
229 virtual void sendFullUpdate(bool bForce = false) = 0;
231 virtual void sendAction(std::unique_ptr<jsdialog::ActionDataMap> pData) = 0;
233 virtual void sendPopup(vcl::Window* pPopup, const OUString& rParentId, const OUString& rCloseId)
234 = 0;
236 virtual void sendClosePopup(vcl::LOKWindowId nWindowId) = 0;
239 class SAL_LOPLUGIN_ANNOTATE("crosscast") OnDemandRenderingHandler
241 public:
242 virtual void render_entry(int pos, int dpix, int dpiy) = 0;
245 template <class BaseInstanceClass, class VclClass>
246 class JSWidget : public BaseInstanceClass, public BaseJSWidget
248 protected:
249 rtl::Reference<JSDropTarget> m_xDropTarget;
250 bool m_bIsFreezed;
252 JSDialogSender* m_pSender;
254 public:
255 JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
256 bool bTakeOwnership)
257 : BaseInstanceClass(pObject, pBuilder, bTakeOwnership)
258 , m_bIsFreezed(false)
259 , m_pSender(pSender)
263 JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
264 bool bTakeOwnership, bool bUserManagedScrolling)
265 : BaseInstanceClass(pObject, pBuilder, bTakeOwnership, bUserManagedScrolling)
266 , m_bIsFreezed(false)
267 , m_pSender(pSender)
271 JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
272 const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, void* pUserData,
273 bool bTakeOwnership)
274 : BaseInstanceClass(pObject, pBuilder, rAlly, std::move(pUITestFactoryFunction), pUserData,
275 bTakeOwnership)
276 , m_bIsFreezed(false)
277 , m_pSender(pSender)
281 virtual void show() override
283 bool bWasVisible = BaseInstanceClass::get_visible();
284 BaseInstanceClass::show();
285 if (!bWasVisible)
287 std::unique_ptr<jsdialog::ActionDataMap> pMap
288 = std::make_unique<jsdialog::ActionDataMap>();
289 (*pMap)[ACTION_TYPE ""_ostr] = "show";
290 sendAction(std::move(pMap));
294 virtual void hide() override
296 bool bWasVisible = BaseInstanceClass::get_visible();
297 BaseInstanceClass::hide();
298 if (bWasVisible)
300 std::unique_ptr<jsdialog::ActionDataMap> pMap
301 = std::make_unique<jsdialog::ActionDataMap>();
302 (*pMap)[ACTION_TYPE ""_ostr] = "hide";
303 sendAction(std::move(pMap));
307 using BaseInstanceClass::set_sensitive;
308 virtual void set_sensitive(bool sensitive) override
310 bool bIsSensitive = BaseInstanceClass::get_sensitive();
311 BaseInstanceClass::set_sensitive(sensitive);
312 if (bIsSensitive != sensitive)
314 std::unique_ptr<jsdialog::ActionDataMap> pMap
315 = std::make_unique<jsdialog::ActionDataMap>();
316 (*pMap)[ACTION_TYPE ""_ostr] = (sensitive ? u"enable" : u"disable");
317 sendAction(std::move(pMap));
321 virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override
323 if (!m_xDropTarget)
324 m_xDropTarget.set(new JSDropTarget);
326 return m_xDropTarget;
329 virtual void freeze() override
331 BaseInstanceClass::freeze();
332 m_bIsFreezed = true;
335 virtual void thaw() override
337 BaseInstanceClass::thaw();
338 m_bIsFreezed = false;
339 sendUpdate();
342 virtual void grab_focus() override
344 BaseInstanceClass::grab_focus();
345 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
346 (*pMap)[ACTION_TYPE ""_ostr] = "grab_focus";
347 sendAction(std::move(pMap));
350 virtual void sendClose() override
352 if (m_pSender)
353 m_pSender->sendClose();
356 virtual void sendUpdate(bool bForce = false) override
358 if (!m_bIsFreezed && m_pSender)
359 m_pSender->sendUpdate(BaseInstanceClass::m_xWidget, bForce);
362 virtual void sendFullUpdate(bool bForce = false) override
364 if ((!m_bIsFreezed || bForce) && m_pSender)
365 m_pSender->sendFullUpdate(bForce);
368 virtual void sendAction(std::unique_ptr<jsdialog::ActionDataMap> pData) override
370 if (!m_bIsFreezed && m_pSender && pData)
371 m_pSender->sendAction(BaseInstanceClass::m_xWidget, std::move(pData));
374 virtual void sendPopup(vcl::Window* pPopup, const OUString& rParentId,
375 const OUString& rCloseId) override
377 if (!m_bIsFreezed && m_pSender)
378 m_pSender->sendPopup(pPopup, rParentId, rCloseId);
381 virtual void sendClosePopup(vcl::LOKWindowId nWindowId) override
383 if (!m_bIsFreezed && m_pSender)
384 m_pSender->sendClosePopup(nWindowId);
387 virtual void set_buildable_name(const OUString& rName) override
389 SalInstanceWidget::set_buildable_name(rName);
390 assert(false); // we remember old name in GetLOKWeldWidgetsMap()
391 // TODO: implement renaming or avoid it for LOK
395 class JSDialog final : public JSWidget<SalInstanceDialog, ::Dialog>
397 public:
398 JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder,
399 bool bTakeOwnership);
401 virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override;
402 virtual void undo_collapse() override;
403 virtual void response(int response) override;
404 virtual std::unique_ptr<weld::Button> weld_button_for_response(int response) override;
405 virtual int run() override;
406 virtual bool runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
407 const std::function<void(sal_Int32)>& rEndDialogFn) override;
408 virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf,
409 const std::function<void(sal_Int32)>& func) override;
412 class JSAssistant final : public JSWidget<SalInstanceAssistant, vcl::RoadmapWizard>
414 public:
415 JSAssistant(JSDialogSender* pSender, vcl::RoadmapWizard* pDialog, SalInstanceBuilder* pBuilder,
416 bool bTakeOwnership);
418 virtual void set_current_page(int nPage) override;
419 virtual void set_current_page(const OUString& rIdent) override;
420 virtual void response(int response) override;
421 virtual std::unique_ptr<weld::Button> weld_button_for_response(int response) override;
422 virtual int run() override;
423 virtual bool runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
424 const std::function<void(sal_Int32)>& rEndDialogFn) override;
425 virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf,
426 const std::function<void(sal_Int32)>& func) override;
429 class JSContainer final : public JSWidget<SalInstanceContainer, vcl::Window>
431 public:
432 JSContainer(JSDialogSender* pSender, vcl::Window* pContainer, SalInstanceBuilder* pBuilder,
433 bool bTakeOwnership);
435 void move(weld::Widget* pWidget, weld::Container* pNewParent) override;
438 class JSScrolledWindow final : public JSWidget<SalInstanceScrolledWindow, ::VclScrolledWindow>
440 public:
441 JSScrolledWindow(JSDialogSender* pSender, ::VclScrolledWindow* pWindow,
442 SalInstanceBuilder* pBuilder, bool bTakeOwnership, bool bUserManagedScrolling);
444 virtual void vadjustment_configure(int value, int lower, int upper, int step_increment,
445 int page_increment, int page_size) override;
446 virtual void vadjustment_set_value(int value) override;
447 void vadjustment_set_value_no_notification(int value);
448 virtual void vadjustment_set_page_size(int size) override;
449 virtual void set_vpolicy(VclPolicyType eVPolicy) override;
451 virtual void hadjustment_configure(int value, int lower, int upper, int step_increment,
452 int page_increment, int page_size) override;
453 virtual void hadjustment_set_value(int value) override;
454 void hadjustment_set_value_no_notification(int value);
455 virtual void hadjustment_set_page_size(int size) override;
456 virtual void set_hpolicy(VclPolicyType eVPolicy) override;
459 class JSLabel final : public JSWidget<SalInstanceLabel, Control>
461 public:
462 JSLabel(JSDialogSender* pSender, Control* pLabel, SalInstanceBuilder* pBuilder,
463 bool bTakeOwnership);
464 virtual void set_label(const OUString& rText) override;
467 class JSButton final : public JSWidget<SalInstanceButton, ::Button>
469 public:
470 JSButton(JSDialogSender* pSender, ::Button* pButton, SalInstanceBuilder* pBuilder,
471 bool bTakeOwnership);
474 class JSLinkButton final : public JSWidget<SalInstanceLinkButton, ::FixedHyperlink>
476 public:
477 JSLinkButton(JSDialogSender* pSender, ::FixedHyperlink* pButton, SalInstanceBuilder* pBuilder,
478 bool bTakeOwnership);
481 class JSToggleButton final : public JSWidget<SalInstanceToggleButton, ::PushButton>
483 public:
484 JSToggleButton(JSDialogSender* pSender, ::PushButton* pButton, SalInstanceBuilder* pBuilder,
485 bool bTakeOwnership);
488 class JSEntry final : public JSWidget<SalInstanceEntry, ::Edit>
490 public:
491 JSEntry(JSDialogSender* pSender, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
492 bool bTakeOwnership);
493 virtual void set_text(const OUString& rText) override;
494 void set_text_without_notify(const OUString& rText);
495 virtual void replace_selection(const OUString& rText) override;
498 class JSListBox final : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>
500 public:
501 JSListBox(JSDialogSender* pSender, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
502 bool bTakeOwnership);
503 virtual void insert(int pos, const OUString& rStr, const OUString* pId,
504 const OUString* pIconName, VirtualDevice* pImageSurface) override;
505 virtual void remove(int pos) override;
506 virtual void set_active(int pos) override;
509 class JSComboBox final : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>,
510 public OnDemandRenderingHandler
512 public:
513 JSComboBox(JSDialogSender* pSender, ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder,
514 bool bTakeOwnership);
515 virtual void insert(int pos, const OUString& rStr, const OUString* pId,
516 const OUString* pIconName, VirtualDevice* pImageSurface) override;
517 virtual void remove(int pos) override;
518 virtual void set_entry_text_without_notify(const OUString& rText);
519 virtual void set_entry_text(const OUString& rText) override;
520 virtual void set_active(int pos) override;
521 virtual void set_active_id(const OUString& rText) override;
522 virtual bool changed_by_direct_pick() const override;
524 // OnDemandRenderingHandler
525 virtual void render_entry(int pos, int dpix, int dpiy) override;
528 class JSNotebook final : public JSWidget<SalInstanceNotebook, ::TabControl>
530 public:
531 JSNotebook(JSDialogSender* pSender, ::TabControl* pControl, SalInstanceBuilder* pBuilder,
532 bool bTakeOwnership);
534 virtual void remove_page(const OUString& rIdent) override;
535 virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override;
538 class JSVerticalNotebook final : public JSWidget<SalInstanceVerticalNotebook, ::VerticalTabControl>
540 public:
541 JSVerticalNotebook(JSDialogSender* pSender, ::VerticalTabControl* pControl,
542 SalInstanceBuilder* pBuilder, bool bTakeOwnership);
544 virtual void remove_page(const OUString& rIdent) override;
545 virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override;
548 class JSSpinButton final : public JSWidget<SalInstanceSpinButton, ::FormattedField>
550 public:
551 JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin, SalInstanceBuilder* pBuilder,
552 bool bTakeOwnership);
554 virtual void set_value(sal_Int64 value) override;
555 virtual void set_range(sal_Int64 min, sal_Int64 max) override;
558 class JSFormattedSpinButton final
559 : public JSWidget<SalInstanceFormattedSpinButton, ::FormattedField>
561 public:
562 JSFormattedSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin,
563 SalInstanceBuilder* pBuilder, bool bTakeOwnership);
565 virtual void set_text(const OUString& rText) override;
566 void set_text_without_notify(const OUString& rText);
569 class JSMessageDialog final : public JSWidget<SalInstanceMessageDialog, ::MessageDialog>
571 std::unique_ptr<JSDialogSender> m_pOwnedSender;
572 std::unique_ptr<JSButton> m_pOK;
573 std::unique_ptr<JSButton> m_pCancel;
575 // used for message dialogs created using static functions
576 OUString m_sWindowId;
578 DECL_LINK(OKHdl, weld::Button&, void);
579 DECL_LINK(CancelHdl, weld::Button&, void);
581 void RememberMessageDialog();
583 public:
584 JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* pDialog, SalInstanceBuilder* pBuilder,
585 bool bTakeOwnership);
586 JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
587 virtual ~JSMessageDialog();
589 virtual void set_primary_text(const OUString& rText) override;
591 virtual void set_secondary_text(const OUString& rText) override;
593 virtual void response(int response) override;
595 virtual int run() override;
596 // TODO: move to dialog class so we will not send json when built but on run
597 bool runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
598 const std::function<void(sal_Int32)>& rEndDialogFn) override;
600 bool runAsync(std::shared_ptr<Dialog> const& rxSelf,
601 const std::function<void(sal_Int32)>& rEndDialogFn) override;
604 class JSCheckButton final : public JSWidget<SalInstanceCheckButton, ::CheckBox>
606 public:
607 JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder,
608 bool bTakeOwnership);
610 virtual void set_active(bool active) override;
613 class JSDrawingArea final : public JSWidget<SalInstanceDrawingArea, VclDrawingArea>
615 public:
616 JSDrawingArea(JSDialogSender* pSender, VclDrawingArea* pDrawingArea,
617 SalInstanceBuilder* pBuilder, const a11yref& rAlly,
618 FactoryFunction pUITestFactoryFunction, void* pUserData);
620 virtual void queue_draw() override;
621 virtual void queue_draw_area(int x, int y, int width, int height) override;
624 class JSToolbar final : public JSWidget<SalInstanceToolbar, ::ToolBox>
626 std::map<sal_uInt16, weld::Widget*> m_pPopovers;
628 public:
629 JSToolbar(JSDialogSender* pSender, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder,
630 bool bTakeOwnership);
632 virtual void set_menu_item_active(const OUString& rIdent, bool bActive) override;
633 virtual void set_item_sensitive(const OUString& rIdent, bool bSensitive) override;
634 virtual void set_item_icon_name(const OUString& rIdent, const OUString& rIconName) override;
637 class JSTextView final : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit>
639 public:
640 JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder,
641 bool bTakeOwnership);
642 virtual void set_text(const OUString& rText) override;
643 void set_text_without_notify(const OUString& rText);
644 virtual void replace_selection(const OUString& rText) override;
647 class JSTreeView final : public JSWidget<SalInstanceTreeView, ::SvTabListBox>
649 public:
650 JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder,
651 bool bTakeOwnership);
653 using SalInstanceTreeView::set_toggle;
654 /// pos is used differently here, it defines how many steps of iterator we need to perform to take entry
655 virtual void set_toggle(int pos, TriState eState, int col = -1) override;
656 virtual void set_toggle(const weld::TreeIter& rIter, TriState bOn, int col = -1) override;
658 using SalInstanceTreeView::set_sensitive;
659 /// pos is used differently here, it defines how many steps of iterator we need to perform to take entry
660 virtual void set_sensitive(int pos, bool bSensitive, int col = -1) override;
661 virtual void set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col = -1) override;
663 using SalInstanceTreeView::select;
664 /// pos is used differently here, it defines how many steps of iterator we need to perform to take entry
665 virtual void select(int pos) override;
667 virtual weld::TreeView* get_drag_source() const override;
669 using SalInstanceTreeView::insert;
670 virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
671 const OUString* pId, const OUString* pIconName,
672 VirtualDevice* pImageSurface, bool bChildrenOnDemand,
673 weld::TreeIter* pRet) override;
675 virtual void set_text(int row, const OUString& rText, int col = -1) override;
676 virtual void set_text(const weld::TreeIter& rIter, const OUString& rStr, int col = -1) override;
678 virtual void expand_row(const weld::TreeIter& rIter) override;
679 virtual void collapse_row(const weld::TreeIter& rIter) override;
681 virtual void set_cursor(const weld::TreeIter& rIter) override;
682 void set_cursor_without_notify(const weld::TreeIter& rIter);
683 virtual void set_cursor(int pos) override;
685 using SalInstanceTreeView::remove;
686 virtual void remove(int pos) override;
687 virtual void remove(const weld::TreeIter& rIter) override;
689 virtual void clear() override;
691 void drag_start();
692 void drag_end();
695 class JSExpander final : public JSWidget<SalInstanceExpander, ::VclExpander>
697 public:
698 JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder,
699 bool bTakeOwnership);
701 virtual void set_expanded(bool bExpand) override;
704 class JSIconView final : public JSWidget<SalInstanceIconView, ::IconView>,
705 public OnDemandRenderingHandler
707 public:
708 JSIconView(JSDialogSender* pSender, ::IconView* pIconView, SalInstanceBuilder* pBuilder,
709 bool bTakeOwnership);
711 virtual void insert(int pos, const OUString* pStr, const OUString* pId,
712 const OUString* pIconName, weld::TreeIter* pRet) override;
714 virtual void insert(int pos, const OUString* pStr, const OUString* pId,
715 const VirtualDevice* pIcon, weld::TreeIter* pRet) override;
717 virtual void insert_separator(int pos, const OUString* pId) override;
719 virtual void clear() override;
720 virtual void select(int pos) override;
721 virtual void unselect(int pos) override;
723 // OnDemandRenderingHandler
724 virtual void render_entry(int pos, int dpix, int dpiy) override;
727 class JSRadioButton final : public JSWidget<SalInstanceRadioButton, ::RadioButton>
729 public:
730 JSRadioButton(JSDialogSender* pSender, ::RadioButton* pRadioButton,
731 SalInstanceBuilder* pBuilder, bool bTakeOwnership);
733 virtual void set_active(bool active) override;
736 class JSFrame : public JSWidget<SalInstanceFrame, ::VclFrame>
738 public:
739 JSFrame(JSDialogSender* pSender, ::VclFrame* pFrame, SalInstanceBuilder* pBuilder,
740 bool bTakeOwnership);
743 class JSMenuButton : public JSWidget<SalInstanceMenuButton, ::MenuButton>
745 public:
746 JSMenuButton(JSDialogSender* pSender, ::MenuButton* pMenuButton, SalInstanceBuilder* pBuilder,
747 bool bTakeOwnership);
749 virtual void set_label(const OUString& rText) override;
750 virtual void set_image(VirtualDevice* pDevice) override;
751 virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override;
752 virtual void set_active(bool active) override;
755 class JSMenu final : public SalInstanceMenu
757 VclPtr<PopupMenu> m_pPopupMenu;
758 JSDialogSender* m_pSender;
760 public:
761 JSMenu(JSDialogSender* pSender, PopupMenu* pMenu, SalInstanceBuilder* pBuilder,
762 bool bTakeOwnership);
764 virtual OUString popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
765 weld::Placement ePlace = weld::Placement::Under) override;
768 class JSPopover : public JSWidget<SalInstancePopover, DockingWindow>
770 vcl::LOKWindowId mnWindowId;
772 public:
773 JSPopover(JSDialogSender* pSender, DockingWindow* pPopover, SalInstanceBuilder* pBuilder,
774 bool bTakeOwnership);
776 virtual void popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
777 weld::Placement ePlace = weld::Placement::Under) override;
778 virtual void popdown() override;
780 void set_window_id(vcl::LOKWindowId nWindowId) { mnWindowId = nWindowId; }
783 class JSBox : public JSWidget<SalInstanceBox, VclBox>
785 public:
786 JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
788 void reorder_child(weld::Widget* pWidget, int nNewPosition) override;
791 class JSWidgetInstance : public JSWidget<SalInstanceWidget, vcl::Window>
793 public:
794 JSWidgetInstance(JSDialogSender* pSender, vcl::Window* pObject, SalInstanceBuilder* pBuilder,
795 bool bTakeOwnership)
796 : JSWidget<SalInstanceWidget, vcl::Window>(pSender, pObject, pBuilder, bTakeOwnership)
801 class JSImage : public JSWidget<SalInstanceImage, FixedImage>
803 public:
804 JSImage(JSDialogSender* pSender, FixedImage* pImage, SalInstanceBuilder* pBuilder,
805 bool bTakeOwnership);
806 virtual void set_image(VirtualDevice* pDevice) override;
807 virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override;
810 class JSLevelBar : public JSWidget<SalInstanceLevelBar, ::ProgressBar>
812 public:
813 JSLevelBar(JSDialogSender* pSender, ::ProgressBar* pProgressBar, SalInstanceBuilder* pBuilder,
814 bool bTakeOwnership);
815 virtual void set_percentage(double fPercentage) override;
818 class JSCalendar : public JSWidget<SalInstanceCalendar, ::Calendar>
820 public:
821 JSCalendar(JSDialogSender* pSender, ::Calendar* pCalendar, SalInstanceBuilder* pBuilder,
822 bool bTakeOwnership);
825 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */