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 <cppuhelper/compbase.hxx>
27 
28 #include <deque>
29 #include <list>
30 #include <mutex>
31 #include <unordered_map>
32 
33 #define ACTION_TYPE "action_type"
34 #define PARENT_ID "parent_id"
35 #define WINDOW_ID "id"
36 #define CLOSE_ID "close_id"
37 
38 class ToolBox;
39 class ComboBox;
40 class VclMultiLineEdit;
41 class SvTabListBox;
42 class IconView;
43 
44 typedef std::map<OString, weld::Widget*> WidgetMap;
45 typedef std::unordered_map<std::string, OUString> ActionDataMap;
46 
47 namespace jsdialog
48 {
50 {
57 };
58 }
59 
62 {
63 public:
66  std::unique_ptr<ActionDataMap> m_pData;
67 
68 private:
69  void copy(const JSDialogMessageInfo& rInfo)
70  {
71  this->m_eType = rInfo.m_eType;
72  this->m_pWindow = rInfo.m_pWindow;
73  if (rInfo.m_pData)
74  {
75  std::unique_ptr<ActionDataMap> pData(new ActionDataMap(*rInfo.m_pData));
76  this->m_pData = std::move(pData);
77  }
78  }
79 
80 public:
82  std::unique_ptr<ActionDataMap> pData)
83  : m_eType(eType)
84  , m_pWindow(pWindow)
85  , m_pData(std::move(pData))
86  {
87  }
88 
89  JSDialogMessageInfo(const JSDialogMessageInfo& rInfo) { copy(rInfo); }
90 
92  {
93  if (this == &aInfo)
94  return *this;
95 
96  copy(aInfo);
97  return *this;
98  }
99 };
100 
101 class JSDialogNotifyIdle final : public Idle
102 {
103  // used to send message
105  // used to generate JSON
107  std::string m_sTypeOfJSON;
109  bool m_bForce;
110 
111  std::deque<JSDialogMessageInfo> m_aMessageQueue;
112  std::mutex m_aQueueMutex;
113 
114 public:
115  JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
116  std::string sTypeOfJSON);
117 
118  void Invoke() override;
119 
120  void clearQueue();
121  void forceUpdate();
123  std::unique_ptr<ActionDataMap> pData = nullptr);
124 
125 private:
126  void send(tools::JsonWriter& aJsonWriter);
127  std::unique_ptr<tools::JsonWriter> generateFullUpdate() const;
128  std::unique_ptr<tools::JsonWriter> generateWidgetUpdate(VclPtr<vcl::Window> pWindow) const;
129  std::unique_ptr<tools::JsonWriter> generateCloseMessage() const;
130  std::unique_ptr<tools::JsonWriter>
131  generateActionMessage(VclPtr<vcl::Window> pWindow, std::unique_ptr<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 public:
142  JSDialogSender() = default;
143  JSDialogSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
144  std::string sTypeOfJSON)
145  {
146  initializeSender(aNotifierWindow, aContentWindow, sTypeOfJSON);
147  }
148 
149  virtual ~JSDialogSender() COVERITY_NOEXCEPT_FALSE;
150 
151  virtual void sendFullUpdate(bool bForce = false);
152  void sendClose();
153  void sendUpdate(VclPtr<vcl::Window> pWindow, bool bForce = false);
154  virtual void sendAction(VclPtr<vcl::Window> pWindow, std::unique_ptr<ActionDataMap> pData);
155  virtual void sendPopup(VclPtr<vcl::Window> pWindow, OUString sParentId, OUString sCloseId);
156  virtual void sendClosePopup(vcl::LOKWindowId nWindowId);
157  void flush() { mpIdleNotify->Invoke(); }
158 
159 protected:
160  void initializeSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
161  std::string sTypeOfJSON)
162  {
163  mpIdleNotify.reset(new JSDialogNotifyIdle(aNotifierWindow, aContentWindow, sTypeOfJSON));
164  }
165 };
166 
167 class JSDropTarget final
168  : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget,
169  css::lang::XInitialization, css::lang::XServiceInfo>
170 {
171  osl::Mutex m_aMutex;
172  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
173 
174 public:
175  JSDropTarget();
176 
177  // XInitialization
178  virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override;
179 
180  // XDropTarget
181  virtual void SAL_CALL addDropTargetListener(
182  const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
183  virtual void SAL_CALL removeDropTargetListener(
184  const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
185  virtual sal_Bool SAL_CALL isActive() override;
186  virtual void SAL_CALL setActive(sal_Bool active) override;
187  virtual sal_Int8 SAL_CALL getDefaultActions() override;
188  virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override;
189 
190  OUString SAL_CALL getImplementationName() override;
191 
192  sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
193 
194  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
195 
196  void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
197 
198  void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
199 };
200 
202 {
203  sal_uInt64 m_nWindowId;
207  std::list<std::string> m_aRememberedWidgets;
208  std::string m_sTypeOfJSON;
213 
214  friend VCL_DLLPUBLIC bool jsdialog::ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget,
215  StringMap& rData);
216  friend VCL_DLLPUBLIC void jsdialog::SendFullUpdate(sal_uInt64 nWindowId,
217  const OString& rWidget);
218 
219  static std::map<sal_uInt64, WidgetMap>& GetLOKWeldWidgetsMap();
220  static void InsertWindowToMap(sal_uInt64 nWindowId);
221  void RememberWidget(const OString& id, weld::Widget* pWidget);
222  static weld::Widget* FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget);
223 
224 public:
226  JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile,
227  bool bPopup = false);
229  JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile,
230  sal_uInt64 nLOKWindowId);
232  JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
233  const css::uno::Reference<css::frame::XFrame>& rFrame,
234  sal_uInt64 nWindowId = 0);
236  JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile);
237 
238  static std::unique_ptr<JSInstanceBuilder>
239  CreateDialogBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
240  static std::unique_ptr<JSInstanceBuilder>
241  CreateNotebookbarBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
242  const css::uno::Reference<css::frame::XFrame>& rFrame,
243  sal_uInt64 nWindowId = 0);
244  static std::unique_ptr<JSInstanceBuilder>
245  CreateAutofilterWindowBuilder(vcl::Window* pParent, const OUString& rUIRoot,
246  const OUString& rUIFile);
247  static std::unique_ptr<JSInstanceBuilder> CreateSidebarBuilder(weld::Widget* pParent,
248  const OUString& rUIRoot,
249  const OUString& rUIFile,
250  sal_uInt64 nLOKWindowId = 0);
251  static std::unique_ptr<JSInstanceBuilder>
252  CreatePopupBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
253 
254  virtual ~JSInstanceBuilder() override;
255  virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString& id) override;
256  virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id) override;
257  virtual std::unique_ptr<weld::Container> weld_container(const OString& id) override;
258  virtual std::unique_ptr<weld::Label> weld_label(const OString& id) override;
259  virtual std::unique_ptr<weld::Button> weld_button(const OString& id) override;
260  virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id) override;
261  virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id) override;
262  virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id) override;
263  virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString& id) override;
264  virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OString& id) override;
265  virtual std::unique_ptr<weld::DrawingArea>
266  weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr,
267  FactoryFunction pUITestFactoryFunction = nullptr,
268  void* pUserData = nullptr) override;
269  virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id) override;
270  virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id) override;
271  virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id) override;
272  virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id) override;
273  virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id) override;
274  virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString& id) override;
275  virtual std::unique_ptr<weld::Frame> weld_frame(const OString& id) override;
276  virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString& id) override;
277  virtual std::unique_ptr<weld::Popover> weld_popover(const OString& id) override;
278  virtual std::unique_ptr<weld::Box> weld_box(const OString& id) override;
279  virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id) override;
280 
282  VclMessageType eMessageType,
283  VclButtonsType eButtonType,
284  const OUString& rPrimaryMessage);
285 
286  static void AddChildWidget(sal_uInt64 nWindowId, const OString& id, weld::Widget* pWidget);
287  static void RemoveWindowWidget(sal_uInt64 nWindowId);
288 
289 private:
290  const std::string& GetTypeOfJSON() const;
293 };
294 
296 {
297 public:
298  virtual ~BaseJSWidget() = default;
299 
300  virtual void sendClose() = 0;
301 
302  virtual void sendUpdate(bool bForce = false) = 0;
303 
304  virtual void sendFullUpdate(bool bForce = false) = 0;
305 
306  virtual void sendAction(std::unique_ptr<ActionDataMap> pData) = 0;
307 
308  virtual void sendPopup(vcl::Window* pPopup, OUString sParentId, OUString sCloseId) = 0;
309 
310  virtual void sendClosePopup(vcl::LOKWindowId nWindowId) = 0;
311 };
312 
313 template <class BaseInstanceClass, class VclClass>
314 class JSWidget : public BaseInstanceClass, public BaseJSWidget
315 {
316 protected:
319 
321 
322 public:
323  JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
324  bool bTakeOwnership)
325  : BaseInstanceClass(pObject, pBuilder, bTakeOwnership)
326  , m_bIsFreezed(false)
327  , m_pSender(pSender)
328  {
329  }
330 
331  JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* pBuilder,
332  const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, void* pUserData,
333  bool bTakeOwnership)
334  : BaseInstanceClass(pObject, pBuilder, rAlly, pUITestFactoryFunction, pUserData,
335  bTakeOwnership)
336  , m_bIsFreezed(false)
337  , m_pSender(pSender)
338  {
339  }
340 
341  virtual void show() override
342  {
343  bool bWasVisible = BaseInstanceClass::get_visible();
344  BaseInstanceClass::show();
345  if (!bWasVisible)
346  {
347  std::unique_ptr<ActionDataMap> pMap = std::make_unique<ActionDataMap>();
348  (*pMap)[ACTION_TYPE] = "show";
349  sendAction(std::move(pMap));
350  }
351  }
352 
353  virtual void hide() override
354  {
355  bool bWasVisible = BaseInstanceClass::get_visible();
356  BaseInstanceClass::hide();
357  if (bWasVisible)
358  {
359  std::unique_ptr<ActionDataMap> pMap = std::make_unique<ActionDataMap>();
360  (*pMap)[ACTION_TYPE] = "hide";
361  sendAction(std::move(pMap));
362  }
363  }
364 
365  using BaseInstanceClass::set_sensitive;
366  virtual void set_sensitive(bool sensitive) override
367  {
368  bool bIsSensitive = BaseInstanceClass::get_sensitive();
369  BaseInstanceClass::set_sensitive(sensitive);
370  if (bIsSensitive != sensitive)
371  sendUpdate();
372  }
373 
374  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override
375  {
376  if (!m_xDropTarget)
377  m_xDropTarget.set(new JSDropTarget);
378 
379  return m_xDropTarget;
380  }
381 
382  virtual void freeze() override
383  {
384  BaseInstanceClass::freeze();
385  m_bIsFreezed = true;
386  }
387 
388  virtual void thaw() override
389  {
390  BaseInstanceClass::thaw();
391  m_bIsFreezed = false;
392  sendUpdate();
393  }
394 
395  virtual void sendClose() override
396  {
397  if (m_pSender)
398  m_pSender->sendClose();
399  }
400 
401  virtual void sendUpdate(bool bForce = false) override
402  {
403  if (!m_bIsFreezed && m_pSender)
404  m_pSender->sendUpdate(BaseInstanceClass::m_xWidget, bForce);
405  }
406 
407  virtual void sendFullUpdate(bool bForce = false) override
408  {
409  if ((!m_bIsFreezed || bForce) && m_pSender)
410  m_pSender->sendFullUpdate(bForce);
411  }
412 
413  virtual void sendAction(std::unique_ptr<ActionDataMap> pData) override
414  {
415  if (!m_bIsFreezed && m_pSender && pData)
416  m_pSender->sendAction(BaseInstanceClass::m_xWidget, std::move(pData));
417  }
418 
419  virtual void sendPopup(vcl::Window* pPopup, OUString sParentId, OUString sCloseId) override
420  {
421  if (!m_bIsFreezed && m_pSender)
422  m_pSender->sendPopup(pPopup, sParentId, sCloseId);
423  }
424 
425  virtual void sendClosePopup(vcl::LOKWindowId nWindowId) override
426  {
427  if (!m_bIsFreezed && m_pSender)
428  m_pSender->sendClosePopup(nWindowId);
429  }
430 };
431 
432 class JSDialog final : public JSWidget<SalInstanceDialog, ::Dialog>
433 {
434 public:
435  JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder,
436  bool bTakeOwnership);
437 
438  virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override;
439  virtual void undo_collapse() override;
440  virtual void response(int response) override;
441 };
442 
443 class JSContainer final : public JSWidget<SalInstanceContainer, vcl::Window>
444 {
445 public:
446  JSContainer(JSDialogSender* pSender, vcl::Window* pContainer, SalInstanceBuilder* pBuilder,
447  bool bTakeOwnership);
448 };
449 
450 class JSLabel final : public JSWidget<SalInstanceLabel, FixedText>
451 {
452 public:
453  JSLabel(JSDialogSender* pSender, FixedText* pLabel, SalInstanceBuilder* pBuilder,
454  bool bTakeOwnership);
455  virtual void set_label(const OUString& rText) override;
456 };
457 
458 class JSButton final : public JSWidget<SalInstanceButton, ::Button>
459 {
460 public:
461  JSButton(JSDialogSender* pSender, ::Button* pButton, SalInstanceBuilder* pBuilder,
462  bool bTakeOwnership);
463 };
464 
465 class JSEntry final : public JSWidget<SalInstanceEntry, ::Edit>
466 {
467 public:
468  JSEntry(JSDialogSender* pSender, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
469  bool bTakeOwnership);
470  virtual void set_text(const OUString& rText) override;
471  void set_text_without_notify(const OUString& rText);
472 };
473 
474 class JSListBox final : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>
475 {
476 public:
477  JSListBox(JSDialogSender* pSender, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
478  bool bTakeOwnership);
479  virtual void insert(int pos, const OUString& rStr, const OUString* pId,
480  const OUString* pIconName, VirtualDevice* pImageSurface) override;
481  virtual void remove(int pos) override;
482  virtual void set_active(int pos) override;
483 };
484 
485 class JSComboBox final : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>
486 {
487 public:
488  JSComboBox(JSDialogSender* pSender, ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder,
489  bool bTakeOwnership);
490  virtual void insert(int pos, const OUString& rStr, const OUString* pId,
491  const OUString* pIconName, VirtualDevice* pImageSurface) override;
492  virtual void remove(int pos) override;
493  virtual void set_entry_text(const OUString& rText) override;
494  virtual void set_active(int pos) override;
495  virtual bool changed_by_direct_pick() const override;
496 };
497 
498 class JSNotebook final : public JSWidget<SalInstanceNotebook, ::TabControl>
499 {
500 public:
501  JSNotebook(JSDialogSender* pSender, ::TabControl* pControl, SalInstanceBuilder* pBuilder,
502  bool bTakeOwnership);
503 
504  virtual void set_current_page(int nPage) override;
505 
506  virtual void set_current_page(const OString& rIdent) override;
507 
508  virtual void remove_page(const OString& rIdent) override;
509 
510  virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override;
511 };
512 
513 class JSSpinButton final : public JSWidget<SalInstanceSpinButton, ::FormattedField>
514 {
515 public:
516  JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin, SalInstanceBuilder* pBuilder,
517  bool bTakeOwnership);
518 
519  virtual void set_value(int value) override;
520 };
521 
522 class JSMessageDialog final : public JSWidget<SalInstanceMessageDialog, ::MessageDialog>
523 {
524  std::unique_ptr<JSDialogSender> m_pOwnedSender;
525  std::unique_ptr<JSButton> m_pOK;
526  std::unique_ptr<JSButton> m_pCancel;
527 
528  DECL_LINK(OKHdl, weld::Button&, void);
529  DECL_LINK(CancelHdl, weld::Button&, void);
530 
531 public:
532  JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* pDialog, SalInstanceBuilder* pBuilder,
533  bool bTakeOwnership);
534  JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
535  virtual ~JSMessageDialog();
536 
537  virtual void set_primary_text(const OUString& rText) override;
538 
539  virtual void set_secondary_text(const OUString& rText) override;
540 
541  virtual void response(int response) override;
542 };
543 
544 class JSCheckButton final : public JSWidget<SalInstanceCheckButton, ::CheckBox>
545 {
546 public:
547  JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder,
548  bool bTakeOwnership);
549 
550  virtual void set_active(bool active) override;
551 };
552 
553 class JSDrawingArea final : public JSWidget<SalInstanceDrawingArea, VclDrawingArea>
554 {
555 public:
556  JSDrawingArea(JSDialogSender* pSender, VclDrawingArea* pDrawingArea,
557  SalInstanceBuilder* pBuilder, const a11yref& rAlly,
558  FactoryFunction pUITestFactoryFunction, void* pUserData);
559 
560  virtual void queue_draw() override;
561  virtual void queue_draw_area(int x, int y, int width, int height) override;
562 };
563 
564 class JSToolbar final : public JSWidget<SalInstanceToolbar, ::ToolBox>
565 {
566  std::map<sal_uInt16, weld::Widget*> m_pPopovers;
567 
568 public:
569  JSToolbar(JSDialogSender* pSender, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder,
570  bool bTakeOwnership);
571 
572  virtual void set_menu_item_active(const OString& rIdent, bool bActive) override;
573  virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override;
574  virtual void set_item_icon_name(const OString& rIdent, const OUString& rIconName) override;
575 };
576 
577 class JSTextView final : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit>
578 {
579 public:
580  JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder,
581  bool bTakeOwnership);
582  virtual void set_text(const OUString& rText) override;
583 };
584 
585 class JSTreeView final : public JSWidget<SalInstanceTreeView, ::SvTabListBox>
586 {
587 public:
588  JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder,
589  bool bTakeOwnership);
590 
593  virtual void set_toggle(int pos, TriState eState, int col = -1) override;
594  virtual void set_toggle(const weld::TreeIter& rIter, TriState bOn, int col = -1) override;
595 
598  virtual void select(int pos) override;
599 
600  virtual weld::TreeView* get_drag_source() const override;
601 
603  virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
604  const OUString* pId, const OUString* pIconName,
605  VirtualDevice* pImageSurface, bool bChildrenOnDemand,
606  weld::TreeIter* pRet) override;
607 
608  virtual void set_text(int row, const OUString& rText, int col = -1) override;
609  virtual void set_text(const weld::TreeIter& rIter, const OUString& rStr, int col = -1) override;
610 
611  virtual void expand_row(const weld::TreeIter& rIter) override;
612  virtual void collapse_row(const weld::TreeIter& rIter) override;
613 
615  virtual void remove(int pos) override;
616  virtual void remove(const weld::TreeIter& rIter) override;
617 
618  virtual void clear() override;
619 
620  void drag_start();
621  void drag_end();
622 };
623 
624 class JSExpander final : public JSWidget<SalInstanceExpander, ::VclExpander>
625 {
626 public:
627  JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder,
628  bool bTakeOwnership);
629 
630  virtual void set_expanded(bool bExpand) override;
631 };
632 
633 class JSIconView final : public JSWidget<SalInstanceIconView, ::IconView>
634 {
635 public:
636  JSIconView(JSDialogSender* pSender, ::IconView* pIconView, SalInstanceBuilder* pBuilder,
637  bool bTakeOwnership);
638 
639  virtual void insert(int pos, const OUString* pStr, const OUString* pId,
640  const OUString* pIconName, weld::TreeIter* pRet) override;
641 
642  virtual void insert(int pos, const OUString* pStr, const OUString* pId,
643  const VirtualDevice* pIcon, weld::TreeIter* pRet) override;
644  virtual void clear() override;
645  virtual void select(int pos) override;
646  virtual void unselect(int pos) override;
647 };
648 
649 class JSRadioButton final : public JSWidget<SalInstanceRadioButton, ::RadioButton>
650 {
651 public:
652  JSRadioButton(JSDialogSender* pSender, ::RadioButton* pRadioButton,
653  SalInstanceBuilder* pBuilder, bool bTakeOwnership);
654 
655  virtual void set_active(bool active) override;
656 };
657 
658 class JSFrame : public JSWidget<SalInstanceFrame, ::VclFrame>
659 {
660 public:
661  JSFrame(JSDialogSender* pSender, ::VclFrame* pFrame, SalInstanceBuilder* pBuilder,
662  bool bTakeOwnership);
663 };
664 
665 class JSMenuButton : public JSWidget<SalInstanceMenuButton, ::MenuButton>
666 {
667 public:
668  JSMenuButton(JSDialogSender* pSender, ::MenuButton* pMenuButton, SalInstanceBuilder* pBuilder,
669  bool bTakeOwnership);
670 
671  virtual void set_label(const OUString& rText) override;
672  virtual void set_image(VirtualDevice* pDevice) override;
673  virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override;
674  virtual void set_active(bool active) override;
675 };
676 
677 class JSPopover : public JSWidget<SalInstancePopover, DockingWindow>
678 {
679 public:
680  JSPopover(JSDialogSender* pSender, DockingWindow* pPopover, SalInstanceBuilder* pBuilder,
681  bool bTakeOwnership);
682 };
683 
684 class JSBox : public JSWidget<SalInstanceBox, VclBox>
685 {
686 public:
687  JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
688 };
689 
690 class JSWidgetInstance : public JSWidget<SalInstanceWidget, vcl::Window>
691 {
692 public:
694  bool bTakeOwnership)
695  : JSWidget<SalInstanceWidget, vcl::Window>(pSender, pObject, pBuilder, bTakeOwnership)
696  {
697  }
698 };
699 
700 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
static std::unique_ptr< JSInstanceBuilder > CreateAutofilterWindowBuilder(vcl::Window *pParent, const OUString &rUIRoot, const OUString &rUIFile)
virtual void set_value(int value) override
osl::Mutex m_aMutex
VclPtr< vcl::Window > m_aWindowToRelease
When LOKNotifier is set by jsdialogs code we need to release it.
virtual void sendClosePopup(vcl::LOKWindowId nWindowId) override
std::unique_ptr< JSButton > m_pOK
std::unique_ptr< ActionDataMap > m_pData
JSIconView(JSDialogSender *pSender,::IconView *pIconView, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
void sendUpdate(VclPtr< vcl::Window > pWindow, bool bForce=false)
std::string m_LastNotificationMessage
VclPtr< vcl::Window > m_aNotifierWindow
virtual void clear() override
virtual void sendFullUpdate(bool bForce=false)
VclButtonsType
Definition: vclenum.hxx:242
std::unique_ptr< ContentProperties > pData
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
JSLabel(JSDialogSender *pSender, FixedText *pLabel, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
#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)
JSRadioButton(JSDialogSender *pSender,::RadioButton *pRadioButton, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void set_active(int pos) override
VclPtr< vcl::Window > m_pWindow
virtual void sendAction(std::unique_ptr< ActionDataMap > pData)=0
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
JSFrame(JSDialogSender *pSender,::VclFrame *pFrame, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
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
VCL_DLLPUBLIC void SendFullUpdate(sal_uInt64 nWindowId, const OString &rWidget)
virtual void set_current_page(int nPage) override
void copy(const JSDialogMessageInfo &rInfo)
virtual sal_Int8 SAL_CALL getDefaultActions() override
void send(tools::JsonWriter &aJsonWriter)
static void RemoveWindowWidget(sal_uInt64 nWindowId)
VclPtr< vcl::Window > m_aContentWindow
virtual std::unique_ptr< weld::RadioButton > weld_radio_button(const OString &id) override
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
static void InsertWindowToMap(sal_uInt64 nWindowId)
virtual std::unique_ptr< weld::Dialog > weld_dialog(const OString &id) override
static std::map< sal_uInt64, WidgetMap > & GetLOKWeldWidgetsMap()
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
VCL_DLLPUBLIC bool ExecuteAction(sal_uInt64 nWindowId, const OString &rWidget, StringMap &rData)
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
virtual void sendAction(VclPtr< vcl::Window > pWindow, std::unique_ptr< ActionDataMap > pData)
VclMessageType
Definition: vclenum.hxx:252
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
std::unordered_map< std::string, OUString > ActionDataMap
virtual void set_label(const OUString &rText) override
JSDialogSender * m_pSender
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 weld::Widget * FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString &rWidget)
virtual void sendAction(std::unique_ptr< ActionDataMap > pData) override
std::deque< JSDialogMessageInfo > m_aMessageQueue
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)
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)
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
void sendMessage(jsdialog::MessageType eType, VclPtr< vcl::Window > pWindow, std::unique_ptr< ActionDataMap > pData=nullptr)
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
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 drag_end()
std::map< sal_uInt16, weld::Widget * > m_pPopovers
static void AddChildWidget(sal_uInt64 nWindowId, const OString &id, weld::Widget *pWidget)
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)
JSDialogMessageInfo(jsdialog::MessageType eType, VclPtr< vcl::Window > pWindow, std::unique_ptr< ActionDataMap > pData)
JSEntry(JSDialogSender *pSender,::Edit *pEntry, SalInstanceBuilder *pBuilder, bool bTakeOwnership)
virtual void sendPopup(vcl::Window *pPopup, OUString sParentId, OUString sCloseId)=0
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
std::unique_ptr< tools::JsonWriter > generateActionMessage(VclPtr< vcl::Window > pWindow, std::unique_ptr< ActionDataMap > pData) const
virtual void response(int response) override
std::vector< css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > > m_aListeners
std::map< OUString, OUString > StringMap
void RememberWidget(const OString &id, weld::Widget *pWidget)
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 select(int pos) override
Any value
virtual void unselect(int pos) override
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)
JSDialogSender()=default
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
void Invoke() override
Calls the maInvokeHandler with the parameter this.
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 set_active(bool active) override
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
virtual void set_primary_text(const OUString &rText) override