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