LibreOffice Module vcl (master)  1
jsdialogbuilder.hxx
Go to the documentation of this file.
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.
4  *
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  */
9 
10 #pragma once
11 
12 #include <comphelper/string.hxx>
13 #include <osl/mutex.hxx>
14 #include <vcl/weld.hxx>
16 #include <vcl/sysdata.hxx>
17 #include <vcl/virdev.hxx>
18 #include <vcl/builder.hxx>
19 #include <salvtables.hxx>
20 #include <vcl/toolkit/button.hxx>
21 #include <vcl/toolkit/fmtfield.hxx>
22 
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
26 #include <comphelper/compbase.hxx>
27 
28 #include <deque>
29 #include <list>
30 #include <mutex>
31 
32 #define ACTION_TYPE "action_type"
33 #define PARENT_ID "parent_id"
34 #define WINDOW_ID "id"
35 #define CLOSE_ID "close_id"
36 
37 class ToolBox;
38 class ComboBox;
39 class VclMultiLineEdit;
40 class SvTabListBox;
41 class IconView;
42 
43 typedef std::map<OString, weld::Widget*> WidgetMap;
44 
45 namespace jsdialog
46 {
48 {
55 };
56 }
57 
60 {
61 public:
64  std::unique_ptr<jsdialog::ActionDataMap> m_pData;
65 
66 private:
67  void copy(const JSDialogMessageInfo& rInfo)
68  {
69  this->m_eType = rInfo.m_eType;
70  this->m_pWindow = rInfo.m_pWindow;
71  if (rInfo.m_pData)
72  {
73  std::unique_ptr<jsdialog::ActionDataMap> pData(
74  new jsdialog::ActionDataMap(*rInfo.m_pData));
75  this->m_pData = std::move(pData);
76  }
77  }
78 
79 public:
81  std::unique_ptr<jsdialog::ActionDataMap> pData)
82  : m_eType(eType)
83  , m_pWindow(pWindow)
84  , m_pData(std::move(pData))
85  {
86  }
87 
88  JSDialogMessageInfo(const JSDialogMessageInfo& rInfo) { copy(rInfo); }
89 
91  {
92  if (this == &aInfo)
93  return *this;
94 
95  copy(aInfo);
96  return *this;
97  }
98 };
99 
100 class JSDialogNotifyIdle final : public Idle
101 {
102  // used to send message
104  // used to generate JSON
106  std::string m_sTypeOfJSON;
108  bool m_bForce;
109 
110  std::deque<JSDialogMessageInfo> m_aMessageQueue;
111  std::mutex m_aQueueMutex;
112 
113 public:
114  JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
115  std::string sTypeOfJSON);
116 
117  void Invoke() override;
118 
119  void clearQueue();
120  void forceUpdate();
122  std::unique_ptr<jsdialog::ActionDataMap> pData = nullptr);
123 
124 private:
125  void send(tools::JsonWriter& aJsonWriter);
126  std::unique_ptr<tools::JsonWriter> generateFullUpdate() const;
127  std::unique_ptr<tools::JsonWriter> generateWidgetUpdate(VclPtr<vcl::Window> pWindow) const;
128  std::unique_ptr<tools::JsonWriter> generateCloseMessage() const;
129  std::unique_ptr<tools::JsonWriter>
131  std::unique_ptr<jsdialog::ActionDataMap> pData) const;
132  std::unique_ptr<tools::JsonWriter>
133  generatePopupMessage(VclPtr<vcl::Window> pWindow, OUString sParentId, OUString sCloseId) const;
134  std::unique_ptr<tools::JsonWriter> generateClosePopupMessage(OUString sWindowId) const;
135 };
136 
138 {
139  std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify;
140 
141 protected:
142  bool m_bCanClose; // specifies if can send a close message
143 
144 public:
146  : m_bCanClose(true)
147  {
148  }
149  JSDialogSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
150  std::string sTypeOfJSON)
151  : m_bCanClose(true)
152  {
153  initializeSender(aNotifierWindow, aContentWindow, sTypeOfJSON);
154  }
155 
156  virtual ~JSDialogSender() COVERITY_NOEXCEPT_FALSE;
157 
158  virtual void sendFullUpdate(bool bForce = false);
159  void sendClose();
160  void sendUpdate(VclPtr<vcl::Window> pWindow, bool bForce = false);
161  virtual void sendAction(VclPtr<vcl::Window> pWindow,
162  std::unique_ptr<jsdialog::ActionDataMap> pData);
163  virtual void sendPopup(VclPtr<vcl::Window> pWindow, OUString sParentId, OUString sCloseId);
164  virtual void sendClosePopup(vcl::LOKWindowId nWindowId);
165  void flush() { mpIdleNotify->Invoke(); }
166 
167 protected:
168  void initializeSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
169  std::string sTypeOfJSON)
170  {
171  mpIdleNotify.reset(new JSDialogNotifyIdle(aNotifierWindow, aContentWindow, sTypeOfJSON));
172  }
173 };
174 
175 class JSDropTarget final
177  css::datatransfer::dnd::XDropTarget, css::lang::XInitialization, css::lang::XServiceInfo>
178 {
179  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
180 
181 public:
182  JSDropTarget();
183 
184  // XInitialization
185  virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override;
186 
187  // XDropTarget
188  virtual void SAL_CALL addDropTargetListener(
189  const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
190  virtual void SAL_CALL removeDropTargetListener(
191  const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
192  virtual sal_Bool SAL_CALL isActive() override;
193  virtual void SAL_CALL setActive(sal_Bool active) override;
194  virtual sal_Int8 SAL_CALL getDefaultActions() override;
195  virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override;
196 
197  OUString SAL_CALL getImplementationName() override;
198 
199  sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
200 
201  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
202 
203  void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
204 
205  void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
206 };
207 
209 {
210  sal_uInt64 m_nWindowId;
214  std::list<std::string> m_aRememberedWidgets;
215  std::string m_sTypeOfJSON;
220 
221  friend VCL_DLLPUBLIC bool jsdialog::ExecuteAction(const std::string& nWindowId,
222  const OString& rWidget, StringMap& rData);
223  friend VCL_DLLPUBLIC void jsdialog::SendFullUpdate(const std::string& nWindowId,
224  const OString& rWidget);
225  friend VCL_DLLPUBLIC void jsdialog::SendAction(const std::string& nWindowId,
226  const OString& rWidget,
227  std::unique_ptr<jsdialog::ActionDataMap> pData);
228 
229  static std::map<std::string, WidgetMap>& GetLOKWeldWidgetsMap();
230  static void InsertWindowToMap(const std::string& nWindowId);
231  void RememberWidget(OString id, weld::Widget* pWidget);
232  static void RememberWidget(const std::string& nWindowId, const OString& id,
233  weld::Widget* pWidget);
234  static weld::Widget* FindWeldWidgetsMap(const std::string& nWindowId, const OString& rWidget);
235 
236  std::string getMapIdFromWindowId() const;
237 
238 public:
240  JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile,
241  bool bPopup = false);
243  JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile,
244  sal_uInt64 nLOKWindowId);
246  JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
247  const css::uno::Reference<css::frame::XFrame>& rFrame,
248  sal_uInt64 nWindowId = 0);
250  JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
251  sal_uInt64 nLOKWindowId);
252 
253  static std::unique_ptr<JSInstanceBuilder>
254  CreateDialogBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
255  static std::unique_ptr<JSInstanceBuilder>
256  CreateNotebookbarBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
257  const css::uno::Reference<css::frame::XFrame>& rFrame,
258  sal_uInt64 nWindowId = 0);
259  static std::unique_ptr<JSInstanceBuilder> CreateSidebarBuilder(weld::Widget* pParent,
260  const OUString& rUIRoot,
261  const OUString& rUIFile,
262  sal_uInt64 nLOKWindowId = 0);
263  static std::unique_ptr<JSInstanceBuilder>
264  CreatePopupBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
265  static std::unique_ptr<JSInstanceBuilder> CreateFormulabarBuilder(vcl::Window* pParent,
266  const OUString& rUIRoot,
267  const OUString& rUIFile,
268  sal_uInt64 nLOKWindowId);
269 
270  virtual ~JSInstanceBuilder() override;
271  virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString& id) override;
272  virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id) override;
273  virtual std::unique_ptr<weld::Container> weld_container(const OString& id) override;
274  virtual std::unique_ptr<weld::Label> weld_label(const OString& id) override;
275  virtual std::unique_ptr<weld::Button> weld_button(const OString& id) override;
276  virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id) override;
277  virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id) override;
278  virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id) override;
279  virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString& id) override;
280  virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OString& id) override;
281  virtual std::unique_ptr<weld::DrawingArea>
282  weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr,
283  FactoryFunction pUITestFactoryFunction = nullptr,
284  void* pUserData = nullptr) override;
285  virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id) override;
286  virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id) override;
287  virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id) override;
288  virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id) override;
289  virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id) override;
290  virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString& id) override;
291  virtual std::unique_ptr<weld::Frame> weld_frame(const OString& id) override;
292  virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString& id) override;
293  virtual std::unique_ptr<weld::Popover> weld_popover(const OString& id) override;
294  virtual std::unique_ptr<weld::Box> weld_box(const OString& id) override;
295  virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id) override;
296  virtual std::unique_ptr<weld::Image> weld_image(const OString& id) override;
297 
299  VclMessageType eMessageType,
300  VclButtonsType eButtonType,
301  const OUString& rPrimaryMessage);
302 
303  static void AddChildWidget(const std::string& nWindowId, const OString& id,
304  weld::Widget* pWidget);
305  static void RemoveWindowWidget(const std::string& nWindowId);
306 
307 private:
308  const std::string& GetTypeOfJSON() const;
311 };
312 
314 {
315 public:
316  virtual ~BaseJSWidget() = default;
317 
318  virtual void sendClose() = 0;
319 
320  virtual void sendUpdate(bool bForce = false) = 0;
321 
322  virtual void sendFullUpdate(bool bForce = false) = 0;
323 
324  virtual void sendAction(std::unique_ptr<jsdialog::ActionDataMap> pData) = 0;
325 
326  virtual void sendPopup(vcl::Window* pPopup, OUString sParentId, OUString sCloseId) = 0;
327 
328  virtual void sendClosePopup(vcl::LOKWindowId nWindowId) = 0;
329 };
330 
331 template <class BaseInstanceClass, class VclClass>
332 class JSWidget : public BaseInstanceClass, public BaseJSWidget
333 {
334 protected:
337 
339 
340 public:
341  JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
342  bool bTakeOwnership)
343  : BaseInstanceClass(pObject, pBuilder, bTakeOwnership)
344  , m_bIsFreezed(false)
345  , m_pSender(pSender)
346  {
347  }
348 
349  JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
350  const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, void* pUserData,
351  bool bTakeOwnership)
352  : BaseInstanceClass(pObject, pBuilder, rAlly, pUITestFactoryFunction, pUserData,
353  bTakeOwnership)
354  , m_bIsFreezed(false)
355  , m_pSender(pSender)
356  {
357  }
358 
359  virtual void show() override
360  {
361  bool bWasVisible = BaseInstanceClass::get_visible();
362  BaseInstanceClass::show();
363  if (!bWasVisible)
364  {
365  std::unique_ptr<jsdialog::ActionDataMap> pMap
366  = std::make_unique<jsdialog::ActionDataMap>();
367  (*pMap)[ACTION_TYPE] = "show";
368  sendAction(std::move(pMap));
369  }
370  }
371 
372  virtual void hide() override
373  {
374  bool bWasVisible = BaseInstanceClass::get_visible();
375  BaseInstanceClass::hide();
376  if (bWasVisible)
377  {
378  std::unique_ptr<jsdialog::ActionDataMap> pMap
379  = std::make_unique<jsdialog::ActionDataMap>();
380  (*pMap)[ACTION_TYPE] = "hide";
381  sendAction(std::move(pMap));
382  }
383  }
384 
385  using BaseInstanceClass::set_sensitive;
386  virtual void set_sensitive(bool sensitive) override
387  {
388  bool bIsSensitive = BaseInstanceClass::get_sensitive();
389  BaseInstanceClass::set_sensitive(sensitive);
390  if (bIsSensitive != sensitive)
391  sendUpdate();
392  }
393 
394  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override
395  {
396  if (!m_xDropTarget)
397  m_xDropTarget.set(new JSDropTarget);
398 
399  return m_xDropTarget;
400  }
401 
402  virtual void freeze() override
403  {
404  BaseInstanceClass::freeze();
405  m_bIsFreezed = true;
406  }
407 
408  virtual void thaw() override
409  {
410  BaseInstanceClass::thaw();
411  m_bIsFreezed = false;
412  sendUpdate();
413  }
414 
415  virtual void sendClose() override
416  {
417  if (m_pSender)
418  m_pSender->sendClose();
419  }
420 
421  virtual void sendUpdate(bool bForce = false) override
422  {
423  if (!m_bIsFreezed && m_pSender)
424  m_pSender->sendUpdate(BaseInstanceClass::m_xWidget, bForce);
425  }
426 
427  virtual void sendFullUpdate(bool bForce = false) override
428  {
429  if ((!m_bIsFreezed || bForce) && m_pSender)
430  m_pSender->sendFullUpdate(bForce);
431  }
432 
433  virtual void sendAction(std::unique_ptr<jsdialog::ActionDataMap> pData) override
434  {
435  if (!m_bIsFreezed && m_pSender && pData)
436  m_pSender->sendAction(BaseInstanceClass::m_xWidget, std::move(pData));
437  }
438 
439  virtual void sendPopup(vcl::Window* pPopup, OUString sParentId, OUString sCloseId) override
440  {
441  if (!m_bIsFreezed && m_pSender)
442  m_pSender->sendPopup(pPopup, sParentId, sCloseId);
443  }
444 
445  virtual void sendClosePopup(vcl::LOKWindowId nWindowId) override
446  {
447  if (!m_bIsFreezed && m_pSender)
448  m_pSender->sendClosePopup(nWindowId);
449  }
450 };
451 
452 class JSDialog final : public JSWidget<SalInstanceDialog, ::Dialog>
453 {
454 public:
455  JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder,
456  bool bTakeOwnership);
457 
458  virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override;
459  virtual void undo_collapse() override;
460  virtual void response(int response) override;
461 };
462 
463 class JSContainer final : public JSWidget<SalInstanceContainer, vcl::Window>
464 {
465 public:
466  JSContainer(JSDialogSender* pSender, vcl::Window* pContainer, SalInstanceBuilder* pBuilder,
467  bool bTakeOwnership);
468 };
469 
470 class JSLabel final : public JSWidget<SalInstanceLabel, Control>
471 {
472 public:
473  JSLabel(JSDialogSender* pSender, Control* pLabel, SalInstanceBuilder* pBuilder,
474  bool bTakeOwnership);
475  virtual void set_label(const OUString& rText) override;
476 };
477 
478 class JSButton final : public JSWidget<SalInstanceButton, ::Button>
479 {
480 public:
481  JSButton(JSDialogSender* pSender, ::Button* pButton, SalInstanceBuilder* pBuilder,
482  bool bTakeOwnership);
483 };
484 
485 class JSEntry final : public JSWidget<SalInstanceEntry, ::Edit>
486 {
487 public:
488  JSEntry(JSDialogSender* pSender, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
489  bool bTakeOwnership);
490  virtual void set_text(const OUString& rText) override;
491  void set_text_without_notify(const OUString& rText);
492 };
493 
494 class JSListBox final : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>
495 {
496 public:
497  JSListBox(JSDialogSender* pSender, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
498  bool bTakeOwnership);
499  virtual void insert(int pos, const OUString& rStr, const OUString* pId,
500  const OUString* pIconName, VirtualDevice* pImageSurface) override;
501  virtual void remove(int pos) override;
502  virtual void set_active(int pos) override;
503 };
504 
505 class JSComboBox final : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>
506 {
507 public:
508  JSComboBox(JSDialogSender* pSender, ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder,
509  bool bTakeOwnership);
510  virtual void insert(int pos, const OUString& rStr, const OUString* pId,
511  const OUString* pIconName, VirtualDevice* pImageSurface) override;
512  virtual void remove(int pos) override;
513  virtual void set_entry_text_without_notify(const OUString& rText);
514  virtual void set_entry_text(const OUString& rText) override;
515  virtual void set_active(int pos) override;
516  virtual bool changed_by_direct_pick() const override;
517 };
518 
519 class JSNotebook final : public JSWidget<SalInstanceNotebook, ::TabControl>
520 {
521 public:
522  JSNotebook(JSDialogSender* pSender, ::TabControl* pControl, SalInstanceBuilder* pBuilder,
523  bool bTakeOwnership);
524 
525  virtual void set_current_page(int nPage) override;
526 
527  virtual void set_current_page(const OString& rIdent) override;
528 
529  virtual void remove_page(const OString& rIdent) override;
530 
531  virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override;
532 };
533 
534 class JSSpinButton final : public JSWidget<SalInstanceSpinButton, ::FormattedField>
535 {
536 public:
537  JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin, SalInstanceBuilder* pBuilder,
538  bool bTakeOwnership);
539 
540  virtual void set_value(sal_Int64 value) override;
541 };
542 
543 class JSMessageDialog final : public JSWidget<SalInstanceMessageDialog, ::MessageDialog>
544 {
545  std::unique_ptr<JSDialogSender> m_pOwnedSender;
546  std::unique_ptr<JSButton> m_pOK;
547  std::unique_ptr<JSButton> m_pCancel;
548 
549  // used for message dialogs created using static functions
550  std::string m_sWindowId;
551 
552  DECL_LINK(OKHdl, weld::Button&, void);
553  DECL_LINK(CancelHdl, weld::Button&, void);
554 
555 public:
556  JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* pDialog, SalInstanceBuilder* pBuilder,
557  bool bTakeOwnership);
558  JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
559  virtual ~JSMessageDialog();
560 
561  virtual void set_primary_text(const OUString& rText) override;
562 
563  virtual void set_secondary_text(const OUString& rText) override;
564 
565  virtual void response(int response) override;
566 };
567 
568 class JSCheckButton final : public JSWidget<SalInstanceCheckButton, ::CheckBox>
569 {
570 public:
571  JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder,
572  bool bTakeOwnership);
573 
574  virtual void set_active(bool active) override;
575 };
576 
577 class JSDrawingArea final : public JSWidget<SalInstanceDrawingArea, VclDrawingArea>
578 {
579 public:
580  JSDrawingArea(JSDialogSender* pSender, VclDrawingArea* pDrawingArea,
581  SalInstanceBuilder* pBuilder, const a11yref& rAlly,
582  FactoryFunction pUITestFactoryFunction, void* pUserData);
583 
584  virtual void queue_draw() override;
585  virtual void queue_draw_area(int x, int y, int width, int height) override;
586 };
587 
588 class JSToolbar final : public JSWidget<SalInstanceToolbar, ::ToolBox>
589 {
590  std::map<sal_uInt16, weld::Widget*> m_pPopovers;
591 
592 public:
593  JSToolbar(JSDialogSender* pSender, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder,
594  bool bTakeOwnership);
595 
596  virtual void set_menu_item_active(const OString& rIdent, bool bActive) override;
597  virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override;
598  virtual void set_item_icon_name(const OString& rIdent, const OUString& rIconName) override;
599 };
600 
601 class JSTextView final : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit>
602 {
603 public:
604  JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder,
605  bool bTakeOwnership);
606  virtual void set_text(const OUString& rText) override;
607 };
608 
609 class JSTreeView final : public JSWidget<SalInstanceTreeView, ::SvTabListBox>
610 {
611 public:
612  JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder,
613  bool bTakeOwnership);
614 
617  virtual void set_toggle(int pos, TriState eState, int col = -1) override;
618  virtual void set_toggle(const weld::TreeIter& rIter, TriState bOn, int col = -1) override;
619 
622  virtual void select(int pos) override;
623 
624  virtual weld::TreeView* get_drag_source() const override;
625 
627  virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
628  const OUString* pId, const OUString* pIconName,
629  VirtualDevice* pImageSurface, bool bChildrenOnDemand,
630  weld::TreeIter* pRet) override;
631 
632  virtual void set_text(int row, const OUString& rText, int col = -1) override;
633  virtual void set_text(const weld::TreeIter& rIter, const OUString& rStr, int col = -1) override;
634 
635  virtual void expand_row(const weld::TreeIter& rIter) override;
636  virtual void collapse_row(const weld::TreeIter& rIter) override;
637 
639  virtual void remove(int pos) override;
640  virtual void remove(const weld::TreeIter& rIter) override;
641 
642  virtual void clear() override;
643 
644  void drag_start();
645  void drag_end();
646 };
647 
648 class JSExpander final : public JSWidget<SalInstanceExpander, ::VclExpander>
649 {
650 public:
651  JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder,
652  bool bTakeOwnership);
653 
654  virtual void set_expanded(bool bExpand) override;
655 };
656 
657 class JSIconView final : public JSWidget<SalInstanceIconView, ::IconView>
658 {
659 public:
660  JSIconView(JSDialogSender* pSender, ::IconView* pIconView, SalInstanceBuilder* pBuilder,
661  bool bTakeOwnership);
662 
663  virtual void insert(int pos, const OUString* pStr, const OUString* pId,
664  const OUString* pIconName, weld::TreeIter* pRet) override;
665 
666  virtual void insert(int pos, const OUString* pStr, const OUString* pId,
667  const VirtualDevice* pIcon, weld::TreeIter* pRet) override;
668  virtual void clear() override;
669  virtual void select(int pos) override;
670  virtual void unselect(int pos) override;
671 };
672 
673 class JSRadioButton final : public JSWidget<SalInstanceRadioButton, ::RadioButton>
674 {
675 public:
676  JSRadioButton(JSDialogSender* pSender, ::RadioButton* pRadioButton,
677  SalInstanceBuilder* pBuilder, bool bTakeOwnership);
678 
679  virtual void set_active(bool active) override;
680 };
681 
682 class JSFrame : public JSWidget<SalInstanceFrame, ::VclFrame>
683 {
684 public:
685  JSFrame(JSDialogSender* pSender, ::VclFrame* pFrame, SalInstanceBuilder* pBuilder,
686  bool bTakeOwnership);
687 };
688 
689 class JSMenuButton : public JSWidget<SalInstanceMenuButton, ::MenuButton>
690 {
691 public:
692  JSMenuButton(JSDialogSender* pSender, ::MenuButton* pMenuButton, SalInstanceBuilder* pBuilder,
693  bool bTakeOwnership);
694 
695  virtual void set_label(const OUString& rText) override;
696  virtual void set_image(VirtualDevice* pDevice) override;
697  virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override;
698  virtual void set_active(bool active) override;
699 };
700 
701 class JSPopover : public JSWidget<SalInstancePopover, DockingWindow>
702 {
703 public:
704  JSPopover(JSDialogSender* pSender, DockingWindow* pPopover, SalInstanceBuilder* pBuilder,
705  bool bTakeOwnership);
706 
707  virtual void popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
708  weld::Placement ePlace = weld::Placement::Under) override;
709  virtual void popdown() override;
710 };
711 
712 class JSBox : public JSWidget<SalInstanceBox, VclBox>
713 {
714 public:
715  JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
716 
717  void reorder_child(weld::Widget* pWidget, int nNewPosition) override;
718 };
719 
720 class JSWidgetInstance : public JSWidget<SalInstanceWidget, vcl::Window>
721 {
722 public:
724  bool bTakeOwnership)
725  : JSWidget<SalInstanceWidget, vcl::Window>(pSender, pObject, pBuilder, bTakeOwnership)
726  {
727  }
728 };
729 
730 class JSImage : public JSWidget<SalInstanceImage, FixedImage>
731 {
732 public:
733  JSImage(JSDialogSender* pSender, FixedImage* pImage, SalInstanceBuilder* pBuilder,
734  bool bTakeOwnership);
735 };
736 
737 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
VclPtr< vcl::Window > m_aWindowToRelease
When LOKNotifier is set by jsdialogs code we need to release it.
std::string m_sWindowId
virtual void sendClosePopup(vcl::LOKWindowId nWindowId) override
std::unique_ptr< JSButton > m_pOK
JSIconView(JSDialogSender *pSender,::IconView *pIconView, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
void reorder_child(weld::Widget *pWidget, int nNewPosition) override
void sendUpdate(VclPtr< vcl::Window > pWindow, bool bForce=false)
std::string m_LastNotificationMessage
VclPtr< vcl::Window > m_aNotifierWindow
virtual std::unique_ptr< weld::Image > weld_image(const OString &id) override
virtual void clear() override
virtual void sendFullUpdate(bool bForce=false)
VclButtonsType
Definition: vclenum.hxx:243
virtual void popdown() override
virtual void sendUpdate(bool bForce=false)=0
signed char sal_Int8
A widget used to choose from a list of items and which has no entry.
Definition: lstbox.hxx:82
virtual std::unique_ptr< weld::Button > weld_button(const OString &id) override
virtual void set_toggle(int pos, TriState eState, int col=-1) override
pos is used differently here, it defines how many steps of iterator we need to perform to take entry ...
virtual ~BaseJSWidget()=default
void sendMessage(jsdialog::MessageType eType, VclPtr< vcl::Window > pWindow, std::unique_ptr< jsdialog::ActionDataMap > pData=nullptr)
std::unique_ptr< sal_Int32[]> pData
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
virtual sal_Bool SAL_CALL isActive() override
JSWidgetInstance(JSDialogSender *pSender, vcl::Window *pObject, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
css::uno::Reference< css::accessibility::XAccessible > a11yref
Definition: weld.hxx:49
std::unique_ptr< tools::JsonWriter > generateClosePopupMessage(OUString sWindowId) const
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual void set_menu_item_active(const OString &rIdent, bool bActive) override
virtual void thaw() override
virtual ~JSMessageDialog()
JSCheckButton(JSDialogSender *pSender,::CheckBox *pCheckBox, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
static void InsertWindowToMap(const std::string &nWindowId)
JSRadioButton(JSDialogSender *pSender,::RadioButton *pRadioButton, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void set_active(int pos) override
VclPtr< vcl::Window > m_pWindow
JSNotebook(JSDialogSender *pSender,::TabControl *pControl, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
void initializeSender(VclPtr< vcl::Window > aNotifierWindow, VclPtr< vcl::Window > aContentWindow, std::string sTypeOfJSON)
virtual void hide() override
std::unique_ptr< tools::JsonWriter > generateCloseMessage() const
std::unique_ptr< tools::JsonWriter > generateActionMessage(VclPtr< vcl::Window > pWindow, std::unique_ptr< jsdialog::ActionDataMap > pData) const
JSFrame(JSDialogSender *pSender,::VclFrame *pFrame, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
static std::map< std::string, WidgetMap > & GetLOKWeldWidgetsMap()
virtual std::unique_ptr< weld::MenuButton > weld_menu_button(const OString &id) override
virtual void sendFullUpdate(bool bForce=false)=0
std::unique_ptr< tools::JsonWriter > generateWidgetUpdate(VclPtr< vcl::Window > pWindow) const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
float x
static std::unique_ptr< JSInstanceBuilder > CreateNotebookbarBuilder(vcl::Window *pParent, const OUString &rUIRoot, const OUString &rUIFile, const css::uno::Reference< css::frame::XFrame > &rFrame, sal_uInt64 nWindowId=0)
virtual void set_secondary_text(const OUString &rText) override
virtual void set_current_page(int nPage) override
void copy(const JSDialogMessageInfo &rInfo)
virtual sal_Int8 SAL_CALL getDefaultActions() override
virtual void sendAction(std::unique_ptr< jsdialog::ActionDataMap > pData) override
void send(tools::JsonWriter &aJsonWriter)
VclPtr< vcl::Window > m_aContentWindow
virtual std::unique_ptr< weld::RadioButton > weld_radio_button(const OString &id) override
static void RemoveWindowWidget(const std::string &nWindowId)
virtual std::unique_ptr< weld::Entry > weld_entry(const OString &id) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArgs) override
virtual std::unique_ptr< weld::Dialog > weld_dialog(const OString &id) override
size_t pos
JSTextView(JSDialogSender *pSender,::VclMultiLineEdit *pTextView, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual ~JSDialogSender() COVERITY_NOEXCEPT_FALSE
virtual void remove(int pos) override
void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtde)
JSInstanceBuilder(weld::Widget *pParent, const OUString &rUIRoot, const OUString &rUIFile, bool bPopup=false)
used for dialogs or popups
virtual std::unique_ptr< weld::TextView > weld_text_view(const OString &id) override
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > get_drop_target() override
virtual void show() override
void set_toggle(SvTreeListEntry *pEntry, TriState eState, int col)
OUString SAL_CALL getImplementationName() override
JSDialog(JSDialogSender *pSender,::Dialog *pDialog, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
JSExpander(JSDialogSender *pSender,::VclExpander *pExpander, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual std::unique_ptr< weld::DrawingArea > weld_drawing_area(const OString &id, const a11yref &rA11yImpl=nullptr, FactoryFunction pUITestFactoryFunction=nullptr, void *pUserData=nullptr) override
virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override
VclMessageType
Definition: vclenum.hxx:253
virtual void set_value(sal_Int64 value) override
VCL_DLLPUBLIC void SendAction(const std::string &nWindowId, const OString &rWidget, std::unique_ptr< ActionDataMap > pData)
send action message to the client
Definition: edit.hxx:55
virtual std::unique_ptr< weld::CheckButton > weld_check_button(const OString &id) override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
std::unique_ptr< JSButton > m_pCancel
virtual void insert(const weld::TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, weld::TreeIter *pRet) override
virtual std::unique_ptr< weld::Popover > weld_popover(const OString &id) override
virtual void select(int pos) override
virtual void collapse(weld::Widget *pEdit, weld::Widget *pButton) override
VclPtr< vcl::Window > & GetContentWindow()
static std::unique_ptr< JSInstanceBuilder > CreateSidebarBuilder(weld::Widget *pParent, const OUString &rUIRoot, const OUString &rUIFile, sal_uInt64 nLOKWindowId=0)
virtual void sendFullUpdate(bool bForce=false) override
float y
JSPopover(JSDialogSender *pSender, DockingWindow *pPopover, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void set_expanded(bool bExpand) override
JSLabel(JSDialogSender *pSender, Control *pLabel, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void set_label(const OUString &rText) override
JSDialogSender * m_pSender
std::string getMapIdFromWindowId() const
virtual std::unique_ptr< weld::Widget > weld_widget(const OString &id) override
virtual std::unique_ptr< weld::Expander > weld_expander(const OString &id) override
static void AddChildWidget(const std::string &nWindowId, const OString &id, weld::Widget *pWidget)
std::deque< JSDialogMessageInfo > m_aMessageQueue
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:75
JSTreeView(JSDialogSender *pSender,::SvTabListBox *pTextView, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void remove_page(const OString &rIdent) override
JSWidget(JSDialogSender *pSender, VclClass *pObject, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
JSDialogMessageInfo(jsdialog::MessageType eType, VclPtr< vcl::Window > pWindow, std::unique_ptr< jsdialog::ActionDataMap > pData)
void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde)
JSDialogNotifyIdle(VclPtr< vcl::Window > aNotifierWindow, VclPtr< vcl::Window > aContentWindow, std::string sTypeOfJSON)
virtual std::unique_ptr< weld::IconView > weld_icon_view(const OString &id) override
JSDrawingArea(JSDialogSender *pSender, VclDrawingArea *pDrawingArea, SalInstanceBuilder *pBuilder, const a11yref &rAlly, FactoryFunction pUITestFactoryFunction, void *pUserData)
std::string m_sTypeOfJSON
virtual void insert_page(const OString &rIdent, const OUString &rLabel, int nPos) override
virtual void sendClose() override
VclPtr< vcl::Window > m_aParentDialog
used in case of tab pages where dialog is not a direct top level
JSToolbar(JSDialogSender *pSender,::ToolBox *pToolbox, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void sendClose()=0
unsigned char sal_Bool
virtual std::unique_ptr< weld::Container > weld_container(const OString &id) override
virtual void queue_draw() override
VclPtr< vcl::Window > m_aContentWindow
JSSpinButton(JSDialogSender *pSender,::FormattedField *pSpin, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
Placement
Definition: weld.hxx:2301
virtual void clear() override
void drag_start()
jsdialog::MessageType m_eType
virtual void undo_collapse() override
virtual std::unique_ptr< weld::Notebook > weld_notebook(const OString &id) override
virtual void select(int pos) override
pos is used differently here, it defines how many steps of iterator we need to perform to take entry ...
VclPtr< vcl::Window > & GetNotifierWindow()
std::unique_ptr< JSDialogNotifyIdle > mpIdleNotify
JSMenuButton(JSDialogSender *pSender,::MenuButton *pMenuButton, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void set_active(bool active) override
std::list< std::string > m_aRememberedWidgets
std::unordered_map< std::string, OUString > ActionDataMap
Definition: executor.hxx:80
virtual void set_sensitive(bool sensitive) override
virtual void sendClosePopup(vcl::LOKWindowId nWindowId)=0
virtual void set_image(VirtualDevice *pDevice) override
virtual std::unique_ptr< weld::ComboBox > weld_combo_box(const OString &id) override
virtual void set_text(int row, const OUString &rText, int col=-1) override
virtual bool changed_by_direct_pick() const override
virtual void set_entry_text(const OUString &rText) override
std::unique_ptr< tools::JsonWriter > generatePopupMessage(VclPtr< vcl::Window > pWindow, OUString sParentId, OUString sCloseId) const
sal_uInt32 LOKWindowId
JSComboBox(JSDialogSender *pSender,::ComboBox *pComboBox, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void response(int response) override
virtual void SAL_CALL setActive(sal_Bool active) override
void set_text_without_notify(const OUString &rText)
virtual void sendPopup(VclPtr< vcl::Window > pWindow, OUString sParentId, OUString sCloseId)
virtual void set_active(int pos) override
virtual void set_active(bool active) override
virtual ~JSInstanceBuilder() override
virtual void set_label(const OUString &rText) override
JSContainer(JSDialogSender *pSender, vcl::Window *pContainer, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > &) override
JSMessageDialog(JSDialogSender *pSender,::MessageDialog *pDialog, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
void RememberWidget(OString id, weld::Widget *pWidget)
void drag_end()
std::map< sal_uInt16, weld::Widget * > m_pPopovers
std::map< OString, weld::Widget * > WidgetMap
Class with the message description for storing in the queue.
virtual void freeze() override
virtual std::unique_ptr< weld::TreeView > weld_tree_view(const OString &id) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
DECL_LINK(OKHdl, weld::Button &, void)
JSBox(JSDialogSender *pSender, VclBox *pBox, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
Definition: ctrl.hxx:81
JSEntry(JSDialogSender *pSender,::Edit *pEntry, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void sendPopup(vcl::Window *pPopup, OUString sParentId, OUString sCloseId)=0
virtual void sendAction(VclPtr< vcl::Window > pWindow, std::unique_ptr< jsdialog::ActionDataMap > pData)
JSDialogMessageInfo(const JSDialogMessageInfo &rInfo)
virtual void queue_draw_area(int x, int y, int width, int height) override
virtual std::unique_ptr< weld::Toolbar > weld_toolbar(const OString &id) override
#define ACTION_TYPE
virtual std::unique_ptr< weld::Frame > weld_frame(const OString &id) override
virtual void response(int response) override
VCL_DLLPUBLIC bool ExecuteAction(const std::string &nWindowId, const OString &rWidget, StringMap &rData)
execute action on a widget
std::vector< css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > > m_aListeners
std::map< OUString, OUString > StringMap
std::unique_ptr< JSDialogSender > m_pOwnedSender
JSDialogSender(VclPtr< vcl::Window > aNotifierWindow, VclPtr< vcl::Window > aContentWindow, std::string sTypeOfJSON)
virtual std::unique_ptr< weld::MessageDialog > weld_message_dialog(const OString &id) override
virtual void set_item_sensitive(const OString &rIdent, bool bSensitive) override
virtual void set_text(const OUString &rText) override
virtual void collapse_row(const weld::TreeIter &rIter) override
virtual void sendUpdate(bool bForce=false) override
virtual void SAL_CALL addDropTargetListener(const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > &) override
virtual void set_text(const OUString &rText) override
virtual void set_entry_text_without_notify(const OUString &rText)
virtual void select(int pos) override
Any value
virtual void unselect(int pos) override
virtual void sendAction(std::unique_ptr< jsdialog::ActionDataMap > pData)=0
virtual std::unique_ptr< weld::Box > weld_box(const OString &id) override
A widget used to choose from a list of items and which has an entry.
Definition: combobox.hxx:38
static std::unique_ptr< JSInstanceBuilder > CreatePopupBuilder(weld::Widget *pParent, const OUString &rUIRoot, const OUString &rUIFile)
static std::unique_ptr< JSInstanceBuilder > CreateDialogBuilder(weld::Widget *pParent, const OUString &rUIRoot, const OUString &rUIFile)
rtl::Reference< JSDropTarget > m_xDropTarget
virtual void insert(const weld::TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, weld::TreeIter *pRet) override
virtual void sendPopup(vcl::Window *pPopup, OUString sParentId, OUString sCloseId) override
JSDialogMessageInfo & operator=(JSDialogMessageInfo aInfo)
virtual void insert(int pos, const OUString &rStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface) override
JSWidget(JSDialogSender *pSender, VclClass *pObject, SalInstanceBuilder *pBuilder, const a11yref &rAlly, FactoryFunction pUITestFactoryFunction, void *pUserData, bool bTakeOwnership)
virtual void insert(int pos, const OUString &rStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface) override
virtual std::unique_ptr< weld::SpinButton > weld_spin_button(const OString &id) override
virtual weld::TreeView * get_drag_source() const override
virtual void set_item_icon_name(const OString &rIdent, const OUString &rIconName) override
JSButton(JSDialogSender *pSender,::Button *pButton, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
TriState
virtual void expand_row(const weld::TreeIter &rIter) override
std::unique_ptr< jsdialog::ActionDataMap > m_pData
void Invoke() override
Calls the maInvokeHandler with the parameter this.
JSImage(JSDialogSender *pSender, FixedImage *pImage, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void sendClosePopup(vcl::LOKWindowId nWindowId)
virtual std::unique_ptr< weld::Label > weld_label(const OString &id) override
virtual void insert(int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, weld::TreeIter *pRet) override
JSListBox(JSDialogSender *pSender,::ListBox *pListBox, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void popup_at_rect(weld::Widget *pParent, const tools::Rectangle &rRect, weld::Placement ePlace=weld::Placement::Under) override
virtual void set_active(bool active) override
static std::unique_ptr< JSInstanceBuilder > CreateFormulabarBuilder(vcl::Window *pParent, const OUString &rUIRoot, const OUString &rUIFile, sal_uInt64 nLOKWindowId)
const std::string & GetTypeOfJSON() const
std::unique_ptr< tools::JsonWriter > generateFullUpdate() const
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
sal_uInt16 nPos
VCL_DLLPUBLIC void SendFullUpdate(const std::string &nWindowId, const OString &rWidget)
send full update message to the client
virtual void set_primary_text(const OUString &rText) override
static weld::Widget * FindWeldWidgetsMap(const std::string &nWindowId, const OString &rWidget)
bool m_bDetectedRangeSegmentation false