Update git submodules
[LibreOffice.git] / vcl / jsdialog / jsdialogbuilder.cxx
blob2ad31d0860a7d6f20e5bb96b6eeab3b30cb55463
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <jsdialog/jsdialogbuilder.hxx>
11 #include <sal/log.hxx>
12 #include <comphelper/base64.hxx>
13 #include <iconview.hxx>
14 #include <utility>
15 #include <vcl/menu.hxx>
16 #include <vcl/svapp.hxx>
17 #include <vcl/toolbox.hxx>
18 #include <vcl/toolkit/button.hxx>
19 #include <vcl/toolkit/combobox.hxx>
20 #include <vcl/toolkit/dialog.hxx>
21 #include <vcl/toolkit/treelistentry.hxx>
22 #include <vcl/toolkit/vclmedit.hxx>
23 #include <verticaltabctrl.hxx>
24 #include <messagedialog.hxx>
25 #include <tools/json_writer.hxx>
26 #include <memory>
27 #include <vcl/jsdialog/executor.hxx>
28 #include <cppuhelper/supportsservice.hxx>
29 #include <tools/stream.hxx>
30 #include <vcl/cvtgrf.hxx>
31 #include <wizdlg.hxx>
33 namespace
35 void response_help(vcl::Window* pWindow)
37 ::Dialog* pDialog = dynamic_cast<::Dialog*>(pWindow);
38 if (!pDialog)
39 return;
41 vcl::Window* pButtonWindow = pDialog->get_widget_for_response(RET_HELP);
42 ::Button* pButton = dynamic_cast<::Button*>(pButtonWindow);
43 if (!pButton)
45 // Is it a wizard dialog?
46 vcl::RoadmapWizard* pWizard = dynamic_cast<vcl::RoadmapWizard*>(pWindow);
47 if (!pWizard || !pWizard->m_pHelp)
48 return;
49 pWizard->m_pHelp->Click();
50 return;
53 pButton->Click();
57 namespace
59 vcl::Window* extract_sal_widget(weld::Widget* pParent)
61 SalInstanceWidget* pInstanceWidget = dynamic_cast<SalInstanceWidget*>(pParent);
62 return pInstanceWidget ? pInstanceWidget->getWidget() : nullptr;
66 // Drag and drop
68 namespace
70 class JSDropTargetDropContext
71 : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDropContext>
73 public:
74 JSDropTargetDropContext() {}
76 // XDropTargetDropContext
77 virtual void SAL_CALL acceptDrop(sal_Int8 /*dragOperation*/) override {}
79 virtual void SAL_CALL rejectDrop() override {}
81 virtual void SAL_CALL dropComplete(sal_Bool /*bSuccess*/) override {}
85 static JSTreeView* g_DragSource;
87 JSDropTarget::JSDropTarget() {}
89 void JSDropTarget::initialize(const css::uno::Sequence<css::uno::Any>& /*rArgs*/) {}
91 void JSDropTarget::addDropTargetListener(
92 const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener)
94 std::unique_lock aGuard(m_aMutex);
96 m_aListeners.push_back(xListener);
99 void JSDropTarget::removeDropTargetListener(
100 const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener)
102 std::unique_lock aGuard(m_aMutex);
104 std::erase(m_aListeners, xListener);
107 sal_Bool JSDropTarget::isActive() { return false; }
109 void JSDropTarget::setActive(sal_Bool /*active*/) {}
111 sal_Int8 JSDropTarget::getDefaultActions() { return 0; }
113 void JSDropTarget::setDefaultActions(sal_Int8 /*actions*/) {}
115 OUString JSDropTarget::getImplementationName()
117 return u"com.sun.star.datatransfer.dnd.JSDropTarget"_ustr;
120 sal_Bool JSDropTarget::supportsService(OUString const& ServiceName)
122 return cppu::supportsService(this, ServiceName);
125 css::uno::Sequence<OUString> JSDropTarget::getSupportedServiceNames()
127 css::uno::Sequence<OUString> aRet{ u"com.sun.star.datatransfer.dnd.JSDropTarget"_ustr };
128 return aRet;
131 void JSDropTarget::fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde)
133 std::unique_lock aGuard(m_aMutex);
134 std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(
135 m_aListeners);
136 aGuard.unlock();
138 for (auto const& listener : aListeners)
140 listener->drop(dtde);
144 void JSDropTarget::fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde)
146 std::unique_lock aGuard(m_aMutex);
147 std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(
148 m_aListeners);
149 aGuard.unlock();
151 for (auto const& listener : aListeners)
153 listener->dragEnter(dtde);
157 void JSInstanceBuilder::initializeDialogSender()
159 m_sTypeOfJSON = "dialog";
161 vcl::Window* pRoot = m_xBuilder->get_widget_root();
163 if (pRoot && pRoot->GetParent())
165 m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
166 if (m_aParentDialog)
167 m_nWindowId = m_aParentDialog->GetLOKWindowId();
168 InsertWindowToMap(getMapIdFromWindowId());
171 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
174 void JSInstanceBuilder::initializePopupSender()
176 // when it is a popup we initialize sender in weld_popover
177 m_sTypeOfJSON = "popup";
180 void JSInstanceBuilder::initializeSidebarSender(sal_uInt64 nLOKWindowId,
181 const std::u16string_view& rUIFile)
183 m_sTypeOfJSON = "sidebar";
184 m_nWindowId = nLOKWindowId;
186 vcl::Window* pRoot = m_xBuilder->get_widget_root();
188 m_aParentDialog = pRoot->GetParentWithLOKNotifier();
190 if (rUIFile == u"sfx/ui/panel.ui")
192 // builder for Panel, get SidebarDockingWindow as m_aContentWindow
193 m_aContentWindow = pRoot;
194 for (int i = 0; i < 7 && m_aContentWindow; i++)
195 m_aContentWindow = m_aContentWindow->GetParent();
197 else
199 // embedded fragments cannot send close message for whole sidebar
200 if (rUIFile == u"modules/simpress/ui/customanimationfragment.ui")
201 m_bCanClose = false;
203 // builder for PanelLayout, get SidebarDockingWindow as m_aContentWindow
204 m_aContentWindow = pRoot;
205 for (int i = 0; i < 9 && m_aContentWindow; i++)
206 m_aContentWindow = m_aContentWindow->GetParent();
209 InsertWindowToMap(getMapIdFromWindowId());
211 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
214 void JSInstanceBuilder::initializeNotebookbarSender(sal_uInt64 nLOKWindowId)
216 m_sTypeOfJSON = "notebookbar";
218 vcl::Window* pRoot = m_xBuilder->get_widget_root();
219 if (pRoot && pRoot->GetParent())
221 m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
222 if (m_aParentDialog)
223 m_nWindowId = m_aParentDialog->GetLOKWindowId();
224 if (!m_nWindowId && nLOKWindowId)
226 m_nWindowId = nLOKWindowId;
227 m_bIsNotebookbar = true;
229 InsertWindowToMap(getMapIdFromWindowId());
232 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
235 void JSInstanceBuilder::initializeFormulabarSender(sal_uInt64 nLOKWindowId,
236 const std::u16string_view& sTypeOfJSON,
237 vcl::Window* pVclParent)
239 m_sTypeOfJSON = sTypeOfJSON;
240 m_nWindowId = nLOKWindowId;
242 vcl::Window* pRoot = m_xBuilder->get_widget_root();
243 m_aContentWindow = pVclParent;
244 if (pRoot && pRoot->GetParent())
246 m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
247 InsertWindowToMap(getMapIdFromWindowId());
250 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
253 void JSInstanceBuilder::initializeMenuSender(weld::Widget* pParent)
255 m_sTypeOfJSON = "menu";
256 m_aParentDialog = extract_sal_widget(pParent)->GetParentWithLOKNotifier();
257 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
260 JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, vcl::Window* pVclParent,
261 std::u16string_view rUIRoot, const OUString& rUIFile,
262 JSInstanceBuilder::Type eBuilderType, sal_uInt64 nLOKWindowId,
263 const std::u16string_view& sTypeOfJSON,
264 const css::uno::Reference<css::frame::XFrame>& rFrame)
265 : SalInstanceBuilder(pVclParent ? pVclParent : extract_sal_widget(pParent), rUIRoot, rUIFile,
266 rFrame)
267 , m_nWindowId(0)
268 , m_aParentDialog(nullptr)
269 , m_aContentWindow(nullptr)
270 , m_sTypeOfJSON("unknown")
271 , m_bHasTopLevelDialog(false)
272 , m_bIsNotebookbar(false)
273 , m_bSentInitialUpdate(false)
274 , m_bIsNestedBuilder(false)
275 , m_aWindowToRelease(nullptr)
277 switch (eBuilderType)
279 case JSInstanceBuilder::Type::Dialog:
280 initializeDialogSender();
281 break;
283 case JSInstanceBuilder::Type::Popup:
284 initializePopupSender();
285 break;
287 case JSInstanceBuilder::Type::Sidebar:
288 initializeSidebarSender(nLOKWindowId, rUIFile);
289 break;
291 case JSInstanceBuilder::Type::Notebookbar:
292 initializeNotebookbarSender(nLOKWindowId);
293 break;
295 case JSInstanceBuilder::Type::Formulabar:
296 initializeFormulabarSender(nLOKWindowId, sTypeOfJSON, pVclParent);
297 break;
299 case JSInstanceBuilder::Type::Menu:
300 initializeMenuSender(pParent);
301 break;
303 default:
304 assert(false);
308 std::unique_ptr<JSInstanceBuilder> JSInstanceBuilder::CreateDialogBuilder(weld::Widget* pParent,
309 const OUString& rUIRoot,
310 const OUString& rUIFile)
312 return std::make_unique<JSInstanceBuilder>(pParent, nullptr, rUIRoot, rUIFile,
313 JSInstanceBuilder::Type::Dialog);
316 std::unique_ptr<JSInstanceBuilder> JSInstanceBuilder::CreateNotebookbarBuilder(
317 vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
318 const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId)
320 return std::make_unique<JSInstanceBuilder>(nullptr, pParent, rUIRoot, rUIFile,
321 JSInstanceBuilder::Type::Notebookbar, nWindowId, u"",
322 rFrame);
325 std::unique_ptr<JSInstanceBuilder> JSInstanceBuilder::CreateSidebarBuilder(weld::Widget* pParent,
326 const OUString& rUIRoot,
327 const OUString& rUIFile,
328 sal_uInt64 nLOKWindowId)
330 return std::make_unique<JSInstanceBuilder>(pParent, nullptr, rUIRoot, rUIFile,
331 JSInstanceBuilder::Type::Sidebar, nLOKWindowId);
334 std::unique_ptr<JSInstanceBuilder> JSInstanceBuilder::CreatePopupBuilder(weld::Widget* pParent,
335 const OUString& rUIRoot,
336 const OUString& rUIFile)
338 return std::make_unique<JSInstanceBuilder>(pParent, nullptr, rUIRoot, rUIFile,
339 JSInstanceBuilder::Type::Popup);
342 std::unique_ptr<JSInstanceBuilder> JSInstanceBuilder::CreateMenuBuilder(weld::Widget* pParent,
343 const OUString& rUIRoot,
344 const OUString& rUIFile)
346 return std::make_unique<JSInstanceBuilder>(pParent, nullptr, rUIRoot, rUIFile,
347 JSInstanceBuilder::Type::Menu);
350 std::unique_ptr<JSInstanceBuilder>
351 JSInstanceBuilder::CreateFormulabarBuilder(vcl::Window* pParent, const OUString& rUIRoot,
352 const OUString& rUIFile, sal_uInt64 nLOKWindowId)
354 return std::make_unique<JSInstanceBuilder>(nullptr, pParent, rUIRoot, rUIFile,
355 JSInstanceBuilder::Type::Formulabar, nLOKWindowId,
356 u"formulabar");
359 std::unique_ptr<JSInstanceBuilder>
360 JSInstanceBuilder::CreateAddressInputBuilder(vcl::Window* pParent, const OUString& rUIRoot,
361 const OUString& rUIFile, sal_uInt64 nLOKWindowId)
363 return std::make_unique<JSInstanceBuilder>(nullptr, pParent, rUIRoot, rUIFile,
364 JSInstanceBuilder::Type::Formulabar, nLOKWindowId,
365 u"addressinputfield");
368 JSInstanceBuilder::~JSInstanceBuilder()
370 // tab page closed -> refresh parent window
371 if (m_bIsNestedBuilder && m_sTypeOfJSON == "dialog")
373 jsdialog::SendFullUpdate(OUString::number(m_nWindowId), u"__DIALOG__"_ustr);
376 if (m_sTypeOfJSON == "popup" || m_sTypeOfJSON == "menu")
377 sendClosePopup(m_nWindowId);
379 if (m_aWindowToRelease)
381 m_aWindowToRelease->ReleaseLOKNotifier();
382 m_aWindowToRelease.clear();
385 if (m_nWindowId && (m_bHasTopLevelDialog || m_bIsNotebookbar))
387 JSInstanceBuilder::Widgets().Forget(getMapIdFromWindowId());
389 else
391 auto aWindowMap = JSInstanceBuilder::Widgets().Find(getMapIdFromWindowId());
392 if (aWindowMap)
394 std::for_each(m_aRememberedWidgets.begin(), m_aRememberedWidgets.end(),
395 [&aWindowMap](const OUString& sId) { aWindowMap->Forget(sId); });
399 JSInstanceBuilder::Popups().Forget(OUString::number(m_nWindowId));
400 JSInstanceBuilder::Menus().Forget(OUString::number(m_nWindowId));
403 const OUString& JSInstanceBuilder::GetTypeOfJSON() const { return m_sTypeOfJSON; }
405 VclPtr<vcl::Window>& JSInstanceBuilder::GetContentWindow()
407 if (m_aContentWindow)
408 return m_aContentWindow;
409 else
410 return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog;
413 VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow()
415 return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog;
418 std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OUString& id)
420 std::unique_ptr<weld::Dialog> pRet;
421 ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
423 if (pDialog)
425 if (!pDialog->GetLOKNotifier())
426 pDialog->SetLOKNotifier(GetpApp());
428 m_nWindowId = pDialog->GetLOKWindowId();
429 pDialog->SetLOKTunnelingState(false);
431 InsertWindowToMap(getMapIdFromWindowId());
433 assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
434 m_aOwnedToplevel.set(pDialog);
435 m_xBuilder->drop_ownership(pDialog);
436 m_bHasTopLevelDialog = true;
438 pRet.reset(new JSDialog(this, pDialog, this, false));
440 RememberWidget(u"__DIALOG__"_ustr, pRet.get());
442 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
443 m_bSentInitialUpdate = true;
446 return pRet;
449 std::unique_ptr<weld::Assistant> JSInstanceBuilder::weld_assistant(const OUString& id)
451 vcl::RoadmapWizard* pDialog = m_xBuilder->get<vcl::RoadmapWizard>(id);
452 std::unique_ptr<JSAssistant> pRet(pDialog ? new JSAssistant(this, pDialog, this, false)
453 : nullptr);
454 if (pDialog)
456 m_nWindowId = pDialog->GetLOKWindowId();
457 pDialog->SetLOKTunnelingState(false);
459 InsertWindowToMap(getMapIdFromWindowId());
461 assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
462 m_aOwnedToplevel.set(pDialog);
463 m_xBuilder->drop_ownership(pDialog);
464 m_bHasTopLevelDialog = true;
466 pRet.reset(new JSAssistant(this, pDialog, this, false));
468 RememberWidget(u"__DIALOG__"_ustr, pRet.get());
470 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
471 m_bSentInitialUpdate = true;
474 return pRet;
477 std::unique_ptr<weld::MessageDialog> JSInstanceBuilder::weld_message_dialog(const OUString& id)
479 std::unique_ptr<weld::MessageDialog> pRet;
480 ::MessageDialog* pMessageDialog = m_xBuilder->get<::MessageDialog>(id);
482 if (pMessageDialog)
484 m_nWindowId = pMessageDialog->GetLOKWindowId();
485 pMessageDialog->SetLOKTunnelingState(false);
487 InsertWindowToMap(getMapIdFromWindowId());
489 assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
490 m_aOwnedToplevel.set(pMessageDialog);
491 m_xBuilder->drop_ownership(pMessageDialog);
492 m_bHasTopLevelDialog = true;
494 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
495 m_bSentInitialUpdate = true;
498 pRet.reset(pMessageDialog ? new JSMessageDialog(this, pMessageDialog, this, false) : nullptr);
500 if (pRet)
501 RememberWidget(u"__DIALOG__"_ustr, pRet.get());
503 return pRet;
506 std::unique_ptr<weld::Container> JSInstanceBuilder::weld_container(const OUString& id)
508 vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id);
509 auto pWeldWidget
510 = pContainer ? std::make_unique<JSContainer>(this, pContainer, this, false) : nullptr;
512 if (pWeldWidget)
513 RememberWidget(id, pWeldWidget.get());
515 if (!m_bSentInitialUpdate && pContainer)
517 m_bSentInitialUpdate = true;
519 // use parent builder to send update - avoid multiple calls from many builders
520 vcl::Window* pParent = pContainer->GetParent();
521 OUString sId = OUString::number(m_nWindowId);
522 while (pParent)
524 auto aWidgetMap = Widgets().Find(sId);
525 if (!aWidgetMap || !aWidgetMap->Find(pParent->get_id()))
526 break;
527 pParent = pParent->GetParent();
530 if (pParent)
531 jsdialog::SendFullUpdate(sId, pParent->get_id());
533 // this is nested builder, don't close parent dialog on destroy (eg. single tab page is closed)
534 m_bCanClose = false;
535 m_bIsNestedBuilder = true;
538 return pWeldWidget;
541 std::unique_ptr<weld::ScrolledWindow>
542 JSInstanceBuilder::weld_scrolled_window(const OUString& id, bool bUserManagedScrolling)
544 VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id);
545 auto pWeldWidget = pScrolledWindow
546 ? std::make_unique<JSScrolledWindow>(this, pScrolledWindow, this, false,
547 bUserManagedScrolling)
548 : nullptr;
550 if (pWeldWidget)
551 RememberWidget(id, pWeldWidget.get());
553 return pWeldWidget;
556 std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OUString& id)
558 Control* pLabel = m_xBuilder->get<Control>(id);
559 auto pWeldWidget = std::make_unique<JSLabel>(this, pLabel, this, false);
561 if (pWeldWidget)
562 RememberWidget(id, pWeldWidget.get());
564 return pWeldWidget;
567 std::unique_ptr<weld::Button> JSInstanceBuilder::weld_button(const OUString& id)
569 ::Button* pButton = m_xBuilder->get<::Button>(id);
570 auto pWeldWidget = pButton ? std::make_unique<JSButton>(this, pButton, this, false) : nullptr;
572 if (pWeldWidget)
573 RememberWidget(id, pWeldWidget.get());
575 return pWeldWidget;
578 std::unique_ptr<weld::LinkButton> JSInstanceBuilder::weld_link_button(const OUString& id)
580 ::FixedHyperlink* pButton = m_xBuilder->get<::FixedHyperlink>(id);
581 auto pWeldWidget
582 = pButton ? std::make_unique<JSLinkButton>(this, pButton, this, false) : nullptr;
584 if (pWeldWidget)
585 RememberWidget(id, pWeldWidget.get());
587 return pWeldWidget;
590 std::unique_ptr<weld::ToggleButton> JSInstanceBuilder::weld_toggle_button(const OUString& id)
592 ::PushButton* pButton = m_xBuilder->get<::PushButton>(id);
593 auto pWeldWidget
594 = pButton ? std::make_unique<JSToggleButton>(this, pButton, this, false) : nullptr;
596 if (pWeldWidget)
597 RememberWidget(id, pWeldWidget.get());
599 return pWeldWidget;
602 std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OUString& id)
604 Edit* pEntry = m_xBuilder->get<Edit>(id);
605 auto pWeldWidget = pEntry ? std::make_unique<JSEntry>(this, pEntry, this, false) : nullptr;
607 if (pWeldWidget)
608 RememberWidget(id, pWeldWidget.get());
610 return pWeldWidget;
613 std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OUString& id)
615 vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id);
616 ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget);
617 std::unique_ptr<weld::ComboBox> pWeldWidget;
619 if (pComboBox)
621 pWeldWidget = std::make_unique<JSComboBox>(this, pComboBox, this, false);
623 else
625 ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
626 pWeldWidget = pListBox ? std::make_unique<JSListBox>(this, pListBox, this, false) : nullptr;
629 if (pWeldWidget)
630 RememberWidget(id, pWeldWidget.get());
632 return pWeldWidget;
635 std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OUString& id)
637 std::unique_ptr<weld::Notebook> pWeldWidget;
638 vcl::Window* pNotebook = m_xBuilder->get(id);
640 if (pNotebook && pNotebook->GetType() == WindowType::TABCONTROL)
641 pWeldWidget
642 = std::make_unique<JSNotebook>(this, static_cast<TabControl*>(pNotebook), this, false);
643 else if (pNotebook && pNotebook->GetType() == WindowType::VERTICALTABCONTROL)
644 pWeldWidget = std::make_unique<JSVerticalNotebook>(
645 this, static_cast<VerticalTabControl*>(pNotebook), this, false);
647 if (pWeldWidget)
648 RememberWidget(id, pWeldWidget.get());
650 return pWeldWidget;
653 std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OUString& id)
655 FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
656 auto pWeldWidget
657 = pSpinButton ? std::make_unique<JSSpinButton>(this, pSpinButton, this, false) : nullptr;
659 if (pWeldWidget)
660 RememberWidget(id, pWeldWidget.get());
662 return pWeldWidget;
665 std::unique_ptr<weld::FormattedSpinButton>
666 JSInstanceBuilder::weld_formatted_spin_button(const OUString& id)
668 FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
669 auto pWeldWidget = pSpinButton
670 ? std::make_unique<JSFormattedSpinButton>(this, pSpinButton, this, false)
671 : nullptr;
673 if (pWeldWidget)
674 RememberWidget(id, pWeldWidget.get());
676 return pWeldWidget;
679 std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const OUString& id)
681 CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
682 auto pWeldWidget
683 = pCheckButton ? std::make_unique<JSCheckButton>(this, pCheckButton, this, false) : nullptr;
685 if (pWeldWidget)
686 RememberWidget(id, pWeldWidget.get());
688 return pWeldWidget;
691 std::unique_ptr<weld::DrawingArea>
692 JSInstanceBuilder::weld_drawing_area(const OUString& id, const a11yref& rA11yImpl,
693 FactoryFunction pUITestFactoryFunction, void* pUserData)
695 VclDrawingArea* pArea = m_xBuilder->get<VclDrawingArea>(id);
696 auto pWeldWidget = pArea ? std::make_unique<JSDrawingArea>(this, pArea, this, rA11yImpl,
697 pUITestFactoryFunction, pUserData)
698 : nullptr;
700 if (pWeldWidget)
701 RememberWidget(id, pWeldWidget.get());
703 return pWeldWidget;
706 std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OUString& id)
708 ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);
709 auto pWeldWidget
710 = pToolBox ? std::make_unique<JSToolbar>(this, pToolBox, this, false) : nullptr;
712 if (pWeldWidget)
713 RememberWidget(id, pWeldWidget.get());
715 return pWeldWidget;
718 std::unique_ptr<weld::TextView> JSInstanceBuilder::weld_text_view(const OUString& id)
720 VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
721 auto pWeldWidget
722 = pTextView ? std::make_unique<JSTextView>(this, pTextView, this, false) : nullptr;
724 if (pWeldWidget)
725 RememberWidget(id, pWeldWidget.get());
727 return pWeldWidget;
730 std::unique_ptr<weld::TreeView> JSInstanceBuilder::weld_tree_view(const OUString& id)
732 SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id);
733 auto pWeldWidget
734 = pTreeView ? std::make_unique<JSTreeView>(this, pTreeView, this, false) : nullptr;
736 if (pWeldWidget)
737 RememberWidget(id, pWeldWidget.get());
739 return pWeldWidget;
742 std::unique_ptr<weld::Expander> JSInstanceBuilder::weld_expander(const OUString& id)
744 VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
745 auto pWeldWidget
746 = pExpander ? std::make_unique<JSExpander>(this, pExpander, this, false) : nullptr;
748 if (pWeldWidget)
749 RememberWidget(id, pWeldWidget.get());
751 return pWeldWidget;
754 std::unique_ptr<weld::IconView> JSInstanceBuilder::weld_icon_view(const OUString& id)
756 ::IconView* pIconView = m_xBuilder->get<::IconView>(id);
757 auto pWeldWidget
758 = pIconView ? std::make_unique<JSIconView>(this, pIconView, this, false) : nullptr;
760 if (pWeldWidget)
761 RememberWidget(id, pWeldWidget.get());
763 return pWeldWidget;
766 std::unique_ptr<weld::RadioButton> JSInstanceBuilder::weld_radio_button(const OUString& id)
768 ::RadioButton* pRadioButton = m_xBuilder->get<::RadioButton>(id);
769 auto pWeldWidget
770 = pRadioButton ? std::make_unique<JSRadioButton>(this, pRadioButton, this, false) : nullptr;
772 if (pWeldWidget)
773 RememberWidget(id, pWeldWidget.get());
775 return pWeldWidget;
778 std::unique_ptr<weld::Frame> JSInstanceBuilder::weld_frame(const OUString& id)
780 ::VclFrame* pFrame = m_xBuilder->get<::VclFrame>(id);
781 auto pWeldWidget = pFrame ? std::make_unique<JSFrame>(this, pFrame, this, false) : nullptr;
783 if (pWeldWidget)
784 RememberWidget(id, pWeldWidget.get());
786 return pWeldWidget;
789 std::unique_ptr<weld::MenuButton> JSInstanceBuilder::weld_menu_button(const OUString& id)
791 ::MenuButton* pMenuButton = m_xBuilder->get<::MenuButton>(id);
792 auto pWeldWidget
793 = pMenuButton ? std::make_unique<JSMenuButton>(this, pMenuButton, this, false) : nullptr;
795 if (pWeldWidget)
796 RememberWidget(id, pWeldWidget.get());
798 return pWeldWidget;
801 std::unique_ptr<weld::Menu> JSInstanceBuilder::weld_menu(const OUString& id)
803 PopupMenu* pPopupMenu = m_xBuilder->get_menu(id);
805 JSMenu* pMenu = pPopupMenu ? new JSMenu(this, pPopupMenu, this, false) : nullptr;
807 std::unique_ptr<weld::Menu> pWeldWidget(pMenu);
809 if (pWeldWidget)
810 JSInstanceBuilder::Menus().Remember(getMapIdFromWindowId(), pWeldWidget.get());
812 return pWeldWidget;
815 std::unique_ptr<weld::Popover> JSInstanceBuilder::weld_popover(const OUString& id)
817 DockingWindow* pDockingWindow = m_xBuilder->get<DockingWindow>(id);
818 JSPopover* pPopover
819 = pDockingWindow ? new JSPopover(this, pDockingWindow, this, false) : nullptr;
820 std::unique_ptr<weld::Popover> pWeldWidget(pPopover);
821 if (pDockingWindow)
823 assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
824 m_aOwnedToplevel.set(pDockingWindow);
825 m_xBuilder->drop_ownership(pDockingWindow);
827 if (VclPtr<vcl::Window> pWin = pDockingWindow->GetParentWithLOKNotifier())
829 vcl::Window* pPopupRoot = pDockingWindow->GetChild(0);
830 pPopupRoot->SetLOKNotifier(pWin->GetLOKNotifier());
831 m_aParentDialog = pPopupRoot;
832 m_aWindowToRelease = pPopupRoot;
833 m_nWindowId = m_aParentDialog->GetLOKWindowId();
835 pPopover->set_window_id(m_nWindowId);
836 JSInstanceBuilder::Popups().Remember(OUString::number(m_nWindowId), pDockingWindow);
838 InsertWindowToMap(getMapIdFromWindowId());
839 initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
843 if (pWeldWidget)
844 RememberWidget(u"__POPOVER__"_ustr, pWeldWidget.get());
846 return pWeldWidget;
849 std::unique_ptr<weld::Box> JSInstanceBuilder::weld_box(const OUString& id)
851 VclBox* pContainer = m_xBuilder->get<VclBox>(id);
852 auto pWeldWidget
853 = pContainer ? std::make_unique<JSBox>(this, pContainer, this, false) : nullptr;
855 if (pWeldWidget)
856 RememberWidget(id, pWeldWidget.get());
858 return pWeldWidget;
861 std::unique_ptr<weld::Widget> JSInstanceBuilder::weld_widget(const OUString& id)
863 vcl::Window* pWidget = m_xBuilder->get(id);
864 auto pWeldWidget
865 = pWidget ? std::make_unique<JSWidgetInstance>(this, pWidget, this, false) : nullptr;
867 if (pWeldWidget)
868 RememberWidget(id, pWeldWidget.get());
870 return pWeldWidget;
873 std::unique_ptr<weld::Image> JSInstanceBuilder::weld_image(const OUString& id)
875 FixedImage* pImage = m_xBuilder->get<FixedImage>(id);
877 auto pWeldWidget = pImage ? std::make_unique<JSImage>(this, pImage, this, false) : nullptr;
879 if (pWeldWidget)
880 RememberWidget(id, pWeldWidget.get());
882 return pWeldWidget;
885 std::unique_ptr<weld::LevelBar> JSInstanceBuilder::weld_level_bar(const OUString& id)
887 ::ProgressBar* pLevelBar = m_xBuilder->get<::ProgressBar>(id);
889 auto pWeldWidget
890 = pLevelBar ? std::make_unique<JSLevelBar>(this, pLevelBar, this, false) : nullptr;
892 if (pWeldWidget)
893 RememberWidget(id, pWeldWidget.get());
895 return pWeldWidget;
898 std::unique_ptr<weld::Calendar> JSInstanceBuilder::weld_calendar(const OUString& id)
900 ::Calendar* pCalendar = m_xBuilder->get<::Calendar>(id);
902 auto pWeldWidget
903 = pCalendar ? std::make_unique<JSCalendar>(this, pCalendar, this, false) : nullptr;
905 if (pWeldWidget)
906 RememberWidget(id, pWeldWidget.get());
908 return pWeldWidget;
911 weld::MessageDialog*
912 JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
913 VclButtonsType eButtonType, const OUString& rPrimaryMessage,
914 const vcl::ILibreOfficeKitNotifier* pNotifier)
916 SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent);
917 SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr;
918 VclPtrInstance<::MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType,
919 eButtonType);
921 if (pNotifier)
922 xMessageDialog->SetLOKNotifier(pNotifier);
924 pNotifier = xMessageDialog->GetLOKNotifier();
925 if (pNotifier)
927 OUString sWindowId = OUString::number(xMessageDialog->GetLOKWindowId());
928 InsertWindowToMap(sWindowId);
929 xMessageDialog->SetLOKTunnelingState(false);
931 return new JSMessageDialog(xMessageDialog, nullptr, true);
933 else
934 SAL_WARN("vcl", "No notifier in JSInstanceBuilder::CreateMessageDialog");
936 return new JSMessageDialog(xMessageDialog, nullptr, true);
939 JSDialog::JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder,
940 bool bTakeOwnership)
941 : JSWidget<SalInstanceDialog, ::Dialog>(pSender, pDialog, pBuilder, bTakeOwnership)
945 void JSDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton)
947 SalInstanceDialog::collapse(pEdit, pButton);
948 sendFullUpdate();
951 void JSDialog::undo_collapse()
953 SalInstanceDialog::undo_collapse();
954 sendFullUpdate();
957 void JSDialog::response(int response)
959 if (response == RET_HELP)
961 response_help(m_xWidget.get());
962 return;
965 sendClose();
966 SalInstanceDialog::response(response);
969 void JSAssistant::response(int response)
971 if (response == RET_HELP)
973 response_help(m_xWidget.get());
974 return;
977 sendClose();
978 SalInstanceAssistant::response(response);
981 int JSDialog::run()
983 sendFullUpdate(true);
984 int ret = SalInstanceDialog::run();
985 return ret;
988 bool JSDialog::runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
989 const std::function<void(sal_Int32)>& rEndDialogFn)
991 bool ret = SalInstanceDialog::runAsync(rxOwner, rEndDialogFn);
992 sendFullUpdate();
993 return ret;
996 bool JSDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
997 const std::function<void(sal_Int32)>& func)
999 bool ret = SalInstanceDialog::runAsync(rxSelf, func);
1000 sendFullUpdate();
1001 return ret;
1004 int JSAssistant::run()
1006 sendFullUpdate(true);
1007 int ret = SalInstanceDialog::run();
1008 return ret;
1011 bool JSAssistant::runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
1012 const std::function<void(sal_Int32)>& rEndDialogFn)
1014 bool ret = SalInstanceDialog::runAsync(rxOwner, rEndDialogFn);
1015 sendFullUpdate();
1016 return ret;
1019 bool JSAssistant::runAsync(std::shared_ptr<Dialog> const& rxSelf,
1020 const std::function<void(sal_Int32)>& func)
1022 bool ret = SalInstanceDialog::runAsync(rxSelf, func);
1023 sendFullUpdate();
1024 return ret;
1027 std::unique_ptr<weld::Button> JSDialog::weld_button_for_response(int nResponse)
1029 std::unique_ptr<weld::Button> xWeldWidget;
1030 if (PushButton* pButton
1031 = dynamic_cast<::PushButton*>(m_xDialog->get_widget_for_response(nResponse)))
1033 xWeldWidget = std::make_unique<JSButton>(m_pSender, pButton, nullptr, false);
1035 auto pParentDialog = m_xDialog->GetParentWithLOKNotifier();
1036 if (pParentDialog)
1037 JSInstanceBuilder::RememberWidget(OUString::number(pParentDialog->GetLOKWindowId()),
1038 pButton->get_id(), xWeldWidget.get());
1041 return xWeldWidget;
1044 std::unique_ptr<weld::Button> JSAssistant::weld_button_for_response(int nResponse)
1046 ::PushButton* pButton = nullptr;
1047 std::unique_ptr<JSButton> xWeldWidget;
1048 if (nResponse == RET_YES)
1049 pButton = m_xWizard->m_pNextPage;
1050 else if (nResponse == RET_NO)
1051 pButton = m_xWizard->m_pPrevPage;
1052 else if (nResponse == RET_OK)
1053 pButton = m_xWizard->m_pFinish;
1054 else if (nResponse == RET_CANCEL)
1055 pButton = m_xWizard->m_pCancel;
1056 else if (nResponse == RET_HELP)
1057 pButton = m_xWizard->m_pHelp;
1059 if (pButton)
1061 xWeldWidget = std::make_unique<JSButton>(m_pSender, pButton, nullptr, false);
1063 auto pParentDialog = m_xWizard->GetParentWithLOKNotifier();
1064 if (pParentDialog)
1065 JSInstanceBuilder::RememberWidget(OUString::number(pParentDialog->GetLOKWindowId()),
1066 pButton->get_id(), xWeldWidget.get());
1069 return xWeldWidget;
1072 JSAssistant::JSAssistant(JSDialogSender* pSender, vcl::RoadmapWizard* pDialog,
1073 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1074 : JSWidget<SalInstanceAssistant, vcl::RoadmapWizard>(pSender, pDialog, pBuilder, bTakeOwnership)
1078 void JSAssistant::set_current_page(int nPage)
1080 SalInstanceAssistant::set_current_page(nPage);
1081 sendFullUpdate();
1084 void JSAssistant::set_current_page(const OUString& rIdent)
1086 SalInstanceAssistant::set_current_page(rIdent);
1087 sendFullUpdate();
1090 JSContainer::JSContainer(JSDialogSender* pSender, vcl::Window* pContainer,
1091 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1092 : JSWidget<SalInstanceContainer, vcl::Window>(pSender, pContainer, pBuilder, bTakeOwnership)
1096 void JSContainer::move(weld::Widget* pWidget, weld::Container* pNewParent)
1098 SalInstanceContainer::move(pWidget, pNewParent);
1099 sendFullUpdate();
1102 JSScrolledWindow::JSScrolledWindow(JSDialogSender* pSender, ::VclScrolledWindow* pContainer,
1103 SalInstanceBuilder* pBuilder, bool bTakeOwnership,
1104 bool bUserManagedScrolling)
1105 : JSWidget<SalInstanceScrolledWindow, ::VclScrolledWindow>(
1106 pSender, pContainer, pBuilder, bTakeOwnership, bUserManagedScrolling)
1110 void JSScrolledWindow::vadjustment_configure(int value, int lower, int upper, int step_increment,
1111 int page_increment, int page_size)
1113 SalInstanceScrolledWindow::vadjustment_configure(value, lower, upper, step_increment,
1114 page_increment, page_size);
1115 sendUpdate();
1118 void JSScrolledWindow::vadjustment_set_value(int value)
1120 SalInstanceScrolledWindow::vadjustment_set_value(value);
1121 sendUpdate();
1124 void JSScrolledWindow::vadjustment_set_value_no_notification(int value)
1126 SalInstanceScrolledWindow::vadjustment_set_value(value);
1129 void JSScrolledWindow::vadjustment_set_page_size(int size)
1131 SalInstanceScrolledWindow::vadjustment_set_page_size(size);
1132 sendUpdate();
1135 void JSScrolledWindow::set_vpolicy(VclPolicyType eVPolicy)
1137 SalInstanceScrolledWindow::set_vpolicy(eVPolicy);
1138 sendUpdate();
1141 void JSScrolledWindow::hadjustment_configure(int value, int lower, int upper, int step_increment,
1142 int page_increment, int page_size)
1144 SalInstanceScrolledWindow::hadjustment_configure(value, lower, upper, step_increment,
1145 page_increment, page_size);
1146 sendUpdate();
1149 void JSScrolledWindow::hadjustment_set_value(int value)
1151 SalInstanceScrolledWindow::hadjustment_set_value(value);
1152 sendUpdate();
1155 void JSScrolledWindow::hadjustment_set_value_no_notification(int value)
1157 SalInstanceScrolledWindow::hadjustment_set_value(value);
1160 void JSScrolledWindow::hadjustment_set_page_size(int size)
1162 SalInstanceScrolledWindow::hadjustment_set_page_size(size);
1163 sendUpdate();
1166 void JSScrolledWindow::set_hpolicy(VclPolicyType eVPolicy)
1168 SalInstanceScrolledWindow::set_hpolicy(eVPolicy);
1169 sendUpdate();
1172 JSLabel::JSLabel(JSDialogSender* pSender, Control* pLabel, SalInstanceBuilder* pBuilder,
1173 bool bTakeOwnership)
1174 : JSWidget<SalInstanceLabel, Control>(pSender, pLabel, pBuilder, bTakeOwnership)
1178 void JSLabel::set_label(const OUString& rText)
1180 SalInstanceLabel::set_label(rText);
1181 sendUpdate();
1184 JSButton::JSButton(JSDialogSender* pSender, ::Button* pButton, SalInstanceBuilder* pBuilder,
1185 bool bTakeOwnership)
1186 : JSWidget<SalInstanceButton, ::Button>(pSender, pButton, pBuilder, bTakeOwnership)
1190 JSLinkButton::JSLinkButton(JSDialogSender* pSender, ::FixedHyperlink* pButton,
1191 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1192 : JSWidget<SalInstanceLinkButton, ::FixedHyperlink>(pSender, pButton, pBuilder, bTakeOwnership)
1196 JSToggleButton::JSToggleButton(JSDialogSender* pSender, ::PushButton* pButton,
1197 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1198 : JSWidget<SalInstanceToggleButton, ::PushButton>(pSender, pButton, pBuilder, bTakeOwnership)
1202 JSEntry::JSEntry(JSDialogSender* pSender, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
1203 bool bTakeOwnership)
1204 : JSWidget<SalInstanceEntry, ::Edit>(pSender, pEntry, pBuilder, bTakeOwnership)
1208 void JSEntry::set_text(const OUString& rText)
1210 SalInstanceEntry::set_text(rText);
1211 sendUpdate();
1214 void JSEntry::set_text_without_notify(const OUString& rText) { SalInstanceEntry::set_text(rText); }
1216 void JSEntry::replace_selection(const OUString& rText)
1218 SalInstanceEntry::replace_selection(rText);
1219 sendUpdate();
1222 JSListBox::JSListBox(JSDialogSender* pSender, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
1223 bool bTakeOwnership)
1224 : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(pSender, pListBox, pBuilder,
1225 bTakeOwnership)
1229 void JSListBox::insert(int pos, const OUString& rStr, const OUString* pId,
1230 const OUString* pIconName, VirtualDevice* pImageSurface)
1232 SalInstanceComboBoxWithoutEdit::insert(pos, rStr, pId, pIconName, pImageSurface);
1233 sendUpdate();
1236 void JSListBox::remove(int pos)
1238 SalInstanceComboBoxWithoutEdit::remove(pos);
1239 sendUpdate();
1242 void JSListBox::set_active(int pos)
1244 SalInstanceComboBoxWithoutEdit::set_active(pos);
1245 sendUpdate();
1248 JSComboBox::JSComboBox(JSDialogSender* pSender, ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder,
1249 bool bTakeOwnership)
1250 : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(pSender, pComboBox, pBuilder,
1251 bTakeOwnership)
1255 void JSComboBox::insert(int pos, const OUString& rStr, const OUString* pId,
1256 const OUString* pIconName, VirtualDevice* pImageSurface)
1258 SalInstanceComboBoxWithEdit::insert(pos, rStr, pId, pIconName, pImageSurface);
1259 sendUpdate();
1262 void JSComboBox::remove(int pos)
1264 SalInstanceComboBoxWithEdit::remove(pos);
1265 sendUpdate();
1268 void JSComboBox::set_entry_text_without_notify(const OUString& rText)
1270 SalInstanceComboBoxWithEdit::set_entry_text(rText);
1273 void JSComboBox::set_entry_text(const OUString& rText)
1275 SalInstanceComboBoxWithEdit::set_entry_text(rText);
1277 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1278 (*pMap)[ACTION_TYPE ""_ostr] = "setText";
1279 (*pMap)["text"_ostr] = rText;
1280 sendAction(std::move(pMap));
1283 void JSComboBox::set_active(int pos)
1285 if (pos == get_active())
1286 return;
1288 SalInstanceComboBoxWithEdit::set_active(pos);
1290 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1291 (*pMap)[ACTION_TYPE ""_ostr] = "select";
1292 (*pMap)["position"_ostr] = OUString::number(pos);
1293 sendAction(std::move(pMap));
1296 void JSComboBox::set_active_id(const OUString& rStr)
1298 sal_uInt16 nPos = find_id(rStr);
1299 set_active(nPos);
1302 bool JSComboBox::changed_by_direct_pick() const { return true; }
1304 void JSComboBox::render_entry(int pos, int dpix, int dpiy)
1306 ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::WITH_ALPHA);
1307 pDevice->SetDPIX(96.0 * dpix / 100);
1308 pDevice->SetDPIY(96.0 * dpiy / 100);
1310 Size aRenderSize = signal_custom_get_size(*pDevice);
1311 pDevice->SetOutputSize(aRenderSize);
1313 signal_custom_render(*pDevice, tools::Rectangle(Point(0, 0), aRenderSize), false, get_id(pos));
1315 BitmapEx aImage = pDevice->GetBitmapEx(Point(0, 0), aRenderSize);
1317 SvMemoryStream aOStm(65535, 65535);
1318 if (GraphicConverter::Export(aOStm, aImage, ConvertDataFormat::PNG) == ERRCODE_NONE)
1320 css::uno::Sequence<sal_Int8> aSeq(static_cast<sal_Int8 const*>(aOStm.GetData()),
1321 aOStm.Tell());
1322 OUStringBuffer aBuffer("data:image/png;base64,");
1323 ::comphelper::Base64::encode(aBuffer, aSeq);
1325 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1326 (*pMap)[ACTION_TYPE ""_ostr] = "rendered_entry";
1327 (*pMap)["pos"_ostr] = OUString::number(pos);
1328 (*pMap)["image"_ostr] = aBuffer;
1329 sendAction(std::move(pMap));
1333 JSNotebook::JSNotebook(JSDialogSender* pSender, ::TabControl* pControl,
1334 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1335 : JSWidget<SalInstanceNotebook, ::TabControl>(pSender, pControl, pBuilder, bTakeOwnership)
1339 void JSNotebook::remove_page(const OUString& rIdent)
1341 SalInstanceNotebook::remove_page(rIdent);
1342 sendFullUpdate();
1345 void JSNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, int nPos)
1347 SalInstanceNotebook::insert_page(rIdent, rLabel, nPos);
1348 sendFullUpdate();
1351 JSVerticalNotebook::JSVerticalNotebook(JSDialogSender* pSender, ::VerticalTabControl* pControl,
1352 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1353 : JSWidget<SalInstanceVerticalNotebook, ::VerticalTabControl>(pSender, pControl, pBuilder,
1354 bTakeOwnership)
1358 void JSVerticalNotebook::remove_page(const OUString& rIdent)
1360 SalInstanceVerticalNotebook::remove_page(rIdent);
1361 sendFullUpdate();
1364 void JSVerticalNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, int nPos)
1366 SalInstanceVerticalNotebook::insert_page(rIdent, rLabel, nPos);
1367 sendFullUpdate();
1370 JSSpinButton::JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin,
1371 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1372 : JSWidget<SalInstanceSpinButton, ::FormattedField>(pSender, pSpin, pBuilder, bTakeOwnership)
1376 void JSSpinButton::set_value(sal_Int64 value)
1378 SalInstanceSpinButton::set_value(value);
1380 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1381 (*pMap)[ACTION_TYPE ""_ostr] = "setText";
1382 (*pMap)["text"_ostr] = OUString::number(m_rFormatter.GetValue());
1383 sendAction(std::move(pMap));
1386 void JSSpinButton::set_range(sal_Int64 min, sal_Int64 max)
1388 SalInstanceSpinButton::set_range(min, max);
1389 sendUpdate();
1392 JSFormattedSpinButton::JSFormattedSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin,
1393 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1394 : JSWidget<SalInstanceFormattedSpinButton, ::FormattedField>(pSender, pSpin, pBuilder,
1395 bTakeOwnership)
1399 void JSFormattedSpinButton::set_text(const OUString& rText)
1401 SalInstanceFormattedSpinButton::set_text(rText);
1402 sendUpdate();
1405 void JSFormattedSpinButton::set_text_without_notify(const OUString& rText)
1407 SalInstanceFormattedSpinButton::set_text(rText);
1410 JSMessageDialog::JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* pDialog,
1411 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1412 : JSWidget<SalInstanceMessageDialog, ::MessageDialog>(pSender, pDialog, pBuilder,
1413 bTakeOwnership)
1417 JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder,
1418 bool bTakeOwnership)
1419 : JSWidget<SalInstanceMessageDialog, ::MessageDialog>(nullptr, pDialog, pBuilder,
1420 bTakeOwnership)
1421 , m_pOwnedSender(new JSDialogSender(pDialog, pDialog, u"dialog"_ustr))
1423 m_pSender = m_pOwnedSender.get();
1425 if (pBuilder)
1426 return;
1428 m_sWindowId = OUString::number(m_xMessageDialog->GetLOKWindowId());
1430 if (::OKButton* pOKBtn
1431 = dynamic_cast<::OKButton*>(m_xMessageDialog->get_widget_for_response(RET_OK)))
1433 m_pOK.reset(new JSButton(m_pSender, pOKBtn, nullptr, false));
1434 JSInstanceBuilder::RememberWidget(m_sWindowId, pOKBtn->get_id(), m_pOK.get());
1435 m_pOK->connect_clicked(LINK(this, JSMessageDialog, OKHdl));
1438 if (::CancelButton* pCancelBtn
1439 = dynamic_cast<::CancelButton*>(m_xMessageDialog->get_widget_for_response(RET_CANCEL)))
1441 m_pCancel.reset(new JSButton(m_pSender, pCancelBtn, nullptr, false));
1442 JSInstanceBuilder::RememberWidget(m_sWindowId, pCancelBtn->get_id(), m_pCancel.get());
1443 m_pCancel->connect_clicked(LINK(this, JSMessageDialog, CancelHdl));
1447 JSMessageDialog::~JSMessageDialog()
1449 if (!m_pBuilder)
1451 // For Message Dialogs created from Application::CreateMessageDialog
1452 // (where there is no builder to take care of this for us) explicitly
1453 // remove this window id on tear down
1454 JSInstanceBuilder::Widgets().Forget(m_sWindowId);
1458 void JSMessageDialog::RememberMessageDialog()
1460 static constexpr OUString sWidgetName = u"__DIALOG__"_ustr;
1461 OUString sWindowId = OUString::number(m_xMessageDialog->GetLOKWindowId());
1462 auto aWidgetMap = JSInstanceBuilder::Widgets().Find(sWindowId);
1463 if (aWidgetMap && aWidgetMap->Find(sWidgetName))
1464 return;
1466 JSInstanceBuilder::InsertWindowToMap(sWindowId);
1467 JSInstanceBuilder::RememberWidget(sWindowId, sWidgetName, this);
1470 int JSMessageDialog::run()
1472 if (GetLOKNotifier())
1474 RememberMessageDialog();
1475 sendFullUpdate();
1478 int bRet = SalInstanceMessageDialog::run();
1479 return bRet;
1482 bool JSMessageDialog::runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
1483 const std::function<void(sal_Int32)>& rEndDialogFn)
1485 bool bRet = SalInstanceMessageDialog::runAsync(rxOwner, rEndDialogFn);
1487 RememberMessageDialog();
1488 sendFullUpdate();
1490 return bRet;
1493 bool JSMessageDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
1494 const std::function<void(sal_Int32)>& rEndDialogFn)
1496 bool bRet = SalInstanceMessageDialog::runAsync(rxSelf, rEndDialogFn);
1498 RememberMessageDialog();
1499 sendFullUpdate();
1501 return bRet;
1504 IMPL_LINK_NOARG(JSMessageDialog, OKHdl, weld::Button&, void) { response(RET_OK); }
1506 IMPL_LINK_NOARG(JSMessageDialog, CancelHdl, weld::Button&, void) { response(RET_CANCEL); }
1508 void JSMessageDialog::set_primary_text(const OUString& rText)
1510 SalInstanceMessageDialog::set_primary_text(rText);
1511 sendFullUpdate();
1514 void JSMessageDialog::set_secondary_text(const OUString& rText)
1516 SalInstanceMessageDialog::set_secondary_text(rText);
1517 sendFullUpdate();
1520 void JSMessageDialog::response(int response)
1522 if (response == RET_HELP)
1524 response_help(m_xWidget.get());
1525 return;
1528 sendClose();
1529 SalInstanceMessageDialog::response(response);
1532 JSCheckButton::JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox,
1533 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1534 : JSWidget<SalInstanceCheckButton, ::CheckBox>(pSender, pCheckBox, pBuilder, bTakeOwnership)
1538 void JSCheckButton::set_active(bool active)
1540 bool bWasActive = get_active();
1541 SalInstanceCheckButton::set_active(active);
1542 if (bWasActive != active)
1543 sendUpdate();
1546 JSDrawingArea::JSDrawingArea(JSDialogSender* pSender, VclDrawingArea* pDrawingArea,
1547 SalInstanceBuilder* pBuilder, const a11yref& rAlly,
1548 FactoryFunction pUITestFactoryFunction, void* pUserData)
1549 : JSWidget<SalInstanceDrawingArea, VclDrawingArea>(pSender, pDrawingArea, pBuilder, rAlly,
1550 std::move(pUITestFactoryFunction), pUserData,
1551 false)
1555 void JSDrawingArea::queue_draw()
1557 SalInstanceDrawingArea::queue_draw();
1558 sendUpdate();
1561 void JSDrawingArea::queue_draw_area(int x, int y, int width, int height)
1563 SalInstanceDrawingArea::queue_draw_area(x, y, width, height);
1564 sendUpdate();
1567 JSToolbar::JSToolbar(JSDialogSender* pSender, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder,
1568 bool bTakeOwnership)
1569 : JSWidget<SalInstanceToolbar, ::ToolBox>(pSender, pToolbox, pBuilder, bTakeOwnership)
1573 void JSToolbar::set_menu_item_active(const OUString& rIdent, bool bActive)
1575 bool bWasActive = get_menu_item_active(rIdent);
1576 SalInstanceToolbar::set_menu_item_active(rIdent, bActive);
1578 ToolBoxItemId nItemId = m_xToolBox->GetItemId(rIdent);
1579 VclPtr<vcl::Window> pFloat = m_aFloats[nItemId];
1581 if (!pFloat)
1582 return;
1584 // See WeldToolbarPopup : include/svtools/toolbarmenu.hxx
1585 // TopLevel (Popover) -> Container -> main container of the popup
1586 vcl::Window* pPopupRoot = pFloat->GetChild(0);
1587 if (pPopupRoot)
1588 pPopupRoot = pPopupRoot->GetChild(0);
1590 if (pPopupRoot)
1592 if (bActive)
1594 JSInstanceBuilder::Popups().Remember(OUString::number(pPopupRoot->GetLOKWindowId()),
1595 pFloat);
1596 sendPopup(pPopupRoot, m_xToolBox->get_id(), rIdent);
1598 else if (bWasActive)
1600 JSInstanceBuilder::Popups().Forget(OUString::number(pPopupRoot->GetLOKWindowId()));
1601 sendClosePopup(pPopupRoot->GetLOKWindowId());
1606 void JSToolbar::set_item_sensitive(const OUString& rIdent, bool bSensitive)
1608 bool bWasSensitive = get_item_sensitive(rIdent);
1609 SalInstanceToolbar::set_item_sensitive(rIdent, bSensitive);
1610 if (bWasSensitive != bSensitive)
1611 sendUpdate();
1614 void JSToolbar::set_item_icon_name(const OUString& rIdent, const OUString& rIconName)
1616 SalInstanceToolbar::set_item_icon_name(rIdent, rIconName);
1617 sendUpdate();
1620 JSTextView::JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView,
1621 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1622 : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(pSender, pTextView, pBuilder,
1623 bTakeOwnership)
1627 void JSTextView::set_text(const OUString& rText)
1629 SalInstanceTextView::set_text(rText);
1630 sendUpdate();
1633 void JSTextView::set_text_without_notify(const OUString& rText)
1635 SalInstanceTextView::set_text(rText);
1638 void JSTextView::replace_selection(const OUString& rText)
1640 SalInstanceTextView::replace_selection(rText);
1641 sendUpdate();
1644 JSTreeView::JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTreeView,
1645 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1646 : JSWidget<SalInstanceTreeView, ::SvTabListBox>(pSender, pTreeView, pBuilder, bTakeOwnership)
1650 void JSTreeView::set_toggle(int pos, TriState eState, int col)
1652 SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, 0);
1654 while (pEntry && pos--)
1655 pEntry = m_xTreeView->Next(pEntry);
1657 if (pEntry)
1659 SalInstanceTreeView::set_toggle(pEntry, eState, col);
1660 signal_toggled(iter_col(SalInstanceTreeIter(pEntry), col));
1662 sendUpdate();
1666 void JSTreeView::set_toggle(const weld::TreeIter& rIter, TriState bOn, int col)
1668 SalInstanceTreeView::set_toggle(rIter, bOn, col);
1669 sendUpdate();
1672 void JSTreeView::set_sensitive(int pos, bool bSensitive, int col)
1674 SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, 0);
1676 while (pEntry && pos--)
1677 pEntry = m_xTreeView->Next(pEntry);
1679 if (pEntry)
1681 SalInstanceTreeView::set_sensitive(pEntry, bSensitive, col);
1682 sendUpdate();
1686 void JSTreeView::set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col)
1688 SalInstanceTreeView::set_sensitive(rIter, bSensitive, col);
1689 sendUpdate();
1692 void JSTreeView::select(int pos)
1694 assert(m_xTreeView->IsUpdateMode() && "don't select when frozen");
1695 disable_notify_events();
1696 if (pos == -1 || (pos == 0 && n_children() == 0))
1697 m_xTreeView->SelectAll(false);
1698 else
1700 SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, 0);
1702 while (pEntry && pos--)
1703 pEntry = m_xTreeView->Next(pEntry);
1705 if (pEntry)
1707 m_xTreeView->Select(pEntry, true);
1708 m_xTreeView->MakeVisible(pEntry);
1711 enable_notify_events();
1713 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1714 (*pMap)[ACTION_TYPE ""_ostr] = "select";
1715 (*pMap)["position"_ostr] = OUString::number(pos);
1716 sendAction(std::move(pMap));
1719 weld::TreeView* JSTreeView::get_drag_source() const { return g_DragSource; }
1721 void JSTreeView::drag_start() { g_DragSource = this; }
1723 void JSTreeView::drag_end()
1725 css::datatransfer::dnd::XDropTarget* xDropTarget = m_xDropTarget.get();
1726 if (xDropTarget)
1728 css::datatransfer::dnd::DropTargetDropEvent aEvent;
1729 aEvent.Source = xDropTarget;
1730 aEvent.Context = new JSDropTargetDropContext();
1731 // dummy values
1732 aEvent.LocationX = 50;
1733 aEvent.LocationY = 50;
1734 aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT;
1735 aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT;
1737 m_xDropTarget->fire_drop(aEvent);
1739 sendUpdate();
1740 if (g_DragSource)
1741 g_DragSource->sendUpdate();
1744 g_DragSource = nullptr;
1747 void JSTreeView::insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
1748 const OUString* pId, const OUString* pIconName,
1749 VirtualDevice* pImageSurface, bool bChildrenOnDemand, weld::TreeIter* pRet)
1751 SalInstanceTreeView::insert(pParent, pos, pStr, pId, pIconName, pImageSurface,
1752 bChildrenOnDemand, pRet);
1754 sendUpdate();
1757 void JSTreeView::set_text(int row, const OUString& rText, int col)
1759 SalInstanceTreeView::set_text(row, rText, col);
1760 sendUpdate();
1763 void JSTreeView::set_text(const weld::TreeIter& rIter, const OUString& rStr, int col)
1765 SalInstanceTreeView::set_text(rIter, rStr, col);
1766 sendUpdate();
1769 void JSTreeView::remove(int pos)
1771 SalInstanceTreeView::remove(pos);
1772 sendUpdate();
1775 void JSTreeView::remove(const weld::TreeIter& rIter)
1777 SalInstanceTreeView::remove(rIter);
1778 sendUpdate();
1781 void JSTreeView::clear()
1783 SalInstanceTreeView::clear();
1784 sendUpdate();
1787 void JSTreeView::set_cursor_without_notify(const weld::TreeIter& rIter)
1789 SalInstanceTreeView::set_cursor(rIter);
1792 void JSTreeView::set_cursor(const weld::TreeIter& rIter)
1794 SalInstanceTreeView::set_cursor(rIter);
1795 sendUpdate();
1798 void JSTreeView::set_cursor(int pos)
1800 SalInstanceTreeView::set_cursor(pos);
1801 sendUpdate();
1804 void JSTreeView::expand_row(const weld::TreeIter& rIter)
1806 bool bNotify = false;
1807 const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
1808 if (!m_xTreeView->IsExpanded(rVclIter.iter))
1809 bNotify = true;
1811 SalInstanceTreeView::expand_row(rIter);
1813 if (bNotify)
1814 sendUpdate();
1817 void JSTreeView::collapse_row(const weld::TreeIter& rIter)
1819 bool bNotify = false;
1820 const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
1821 if (m_xTreeView->IsExpanded(rVclIter.iter))
1822 bNotify = true;
1824 SalInstanceTreeView::collapse_row(rIter);
1826 if (bNotify)
1827 sendUpdate();
1830 JSExpander::JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander,
1831 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1832 : JSWidget<SalInstanceExpander, ::VclExpander>(pSender, pExpander, pBuilder, bTakeOwnership)
1836 void JSExpander::set_expanded(bool bExpand)
1838 SalInstanceExpander::set_expanded(bExpand);
1839 sendUpdate();
1842 JSIconView::JSIconView(JSDialogSender* pSender, ::IconView* pIconView, SalInstanceBuilder* pBuilder,
1843 bool bTakeOwnership)
1844 : JSWidget<SalInstanceIconView, ::IconView>(pSender, pIconView, pBuilder, bTakeOwnership)
1848 void JSIconView::insert(int pos, const OUString* pStr, const OUString* pId,
1849 const OUString* pIconName, weld::TreeIter* pRet)
1851 SalInstanceIconView::insert(pos, pStr, pId, pIconName, pRet);
1852 sendUpdate();
1855 void JSIconView::insert(int pos, const OUString* pStr, const OUString* pId,
1856 const VirtualDevice* pIcon, weld::TreeIter* pRet)
1858 SalInstanceIconView::insert(pos, pStr, pId, pIcon, pRet);
1859 sendUpdate();
1862 void JSIconView::insert_separator(int pos, const OUString* pId)
1864 SalInstanceIconView::insert_separator(pos, pId);
1865 sendUpdate();
1868 void JSIconView::clear()
1870 SalInstanceIconView::clear();
1871 sendUpdate();
1874 void JSIconView::select(int pos)
1876 SalInstanceIconView::select(pos);
1878 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1879 (*pMap)[ACTION_TYPE ""_ostr] = "select";
1880 (*pMap)["position"_ostr] = OUString::number(pos);
1881 sendAction(std::move(pMap));
1884 void JSIconView::unselect(int pos)
1886 SalInstanceIconView::unselect(pos);
1887 sendUpdate();
1890 void JSIconView::render_entry(int pos, int dpix, int dpiy)
1892 OUString sImage = m_xIconView->renderEntry(pos, dpix, dpiy);
1893 if (sImage.isEmpty())
1894 return;
1896 std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
1897 (*pMap)[ACTION_TYPE ""_ostr] = "rendered_entry";
1898 (*pMap)["pos"_ostr] = OUString::number(pos);
1899 (*pMap)["image"_ostr] = sImage;
1900 sendAction(std::move(pMap));
1903 JSRadioButton::JSRadioButton(JSDialogSender* pSender, ::RadioButton* pRadioButton,
1904 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1905 : JSWidget<SalInstanceRadioButton, ::RadioButton>(pSender, pRadioButton, pBuilder,
1906 bTakeOwnership)
1910 void JSRadioButton::set_active(bool active)
1912 SalInstanceRadioButton::set_active(active);
1913 sendUpdate();
1916 JSFrame::JSFrame(JSDialogSender* pSender, ::VclFrame* pFrame, SalInstanceBuilder* pBuilder,
1917 bool bTakeOwnership)
1918 : JSWidget<SalInstanceFrame, ::VclFrame>(pSender, pFrame, pBuilder, bTakeOwnership)
1922 JSMenuButton::JSMenuButton(JSDialogSender* pSender, ::MenuButton* pMenuButton,
1923 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1924 : JSWidget<SalInstanceMenuButton, ::MenuButton>(pSender, pMenuButton, pBuilder, bTakeOwnership)
1928 void JSMenuButton::set_label(const OUString& rText)
1930 OUString aPreviousLabel = get_label();
1931 SalInstanceMenuButton::set_label(rText);
1932 if (aPreviousLabel != rText)
1933 sendUpdate();
1936 void JSMenuButton::set_image(VirtualDevice* pDevice)
1938 SalInstanceMenuButton::set_image(pDevice);
1939 sendUpdate();
1942 void JSMenuButton::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage)
1944 SalInstanceMenuButton::set_image(rImage);
1945 sendUpdate();
1948 void JSMenuButton::set_active(bool bActive)
1950 SalInstanceMenuButton::set_active(bActive);
1952 VclPtr<vcl::Window> pPopup = m_xMenuButton->GetPopover();
1953 if (pPopup)
1955 if (bActive)
1956 sendPopup(pPopup->GetChild(0), m_xMenuButton->get_id(), m_xMenuButton->get_id());
1957 else
1958 sendClosePopup(pPopup->GetChild(0)->GetLOKWindowId());
1962 JSMenu::JSMenu(JSDialogSender* pSender, PopupMenu* pPopupMenu, SalInstanceBuilder* /*pBuilder*/,
1963 bool bTakeOwnership)
1964 : SalInstanceMenu(pPopupMenu, bTakeOwnership)
1965 , m_pPopupMenu(pPopupMenu)
1966 , m_pSender(pSender)
1970 OUString JSMenu::popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
1971 weld::Placement /*ePlace*/)
1973 // Do not block with SalInstanceMenu::popup_at_rect(pParent, rRect, ePlace);
1975 // we find position based on parent widget id and row text inside TreeView for context menu
1976 OUString sCancelId;
1977 weld::TreeView* pTree = dynamic_cast<weld::TreeView*>(pParent);
1978 if (pTree)
1980 std::unique_ptr<weld::TreeIter> itEntry(pTree->make_iterator());
1981 if (pTree->get_dest_row_at_pos(rRect.Center(), itEntry.get(), false, false))
1982 sCancelId = pTree->get_text(*itEntry);
1985 m_pSender->sendMenu(m_pPopupMenu, pParent ? pParent->get_buildable_name() : "", sCancelId);
1987 // Don't return any action - simulate canceled menu
1988 return "";
1991 JSPopover::JSPopover(JSDialogSender* pSender, DockingWindow* pDockingWindow,
1992 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1993 : JSWidget<SalInstancePopover, DockingWindow>(pSender, pDockingWindow, pBuilder, bTakeOwnership)
1994 , mnWindowId(0)
1998 void JSPopover::popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
1999 weld::Placement ePlace)
2001 SalInstancePopover::popup_at_rect(pParent, rRect, ePlace);
2002 sendPopup(getWidget()->GetChild(0), u"_POPOVER_"_ustr, u"_POPOVER_"_ustr);
2005 void JSPopover::popdown()
2007 VclPtr<vcl::Window> pPopup = JSInstanceBuilder::Popups().Find(OUString::number(mnWindowId));
2009 if (pPopup)
2011 sendClosePopup(mnWindowId);
2012 vcl::Window::GetDockingManager()->EndPopupMode(pPopup);
2015 if (getWidget() && getWidget()->GetChild(0))
2016 sendClosePopup(getWidget()->GetChild(0)->GetLOKWindowId());
2018 SalInstancePopover::popdown();
2021 JSBox::JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder,
2022 bool bTakeOwnership)
2023 : JSWidget<SalInstanceBox, VclBox>(pSender, pBox, pBuilder, bTakeOwnership)
2027 void JSBox::reorder_child(weld::Widget* pWidget, int nNewPosition)
2029 SalInstanceBox::reorder_child(pWidget, nNewPosition);
2030 sendFullUpdate();
2033 JSImage::JSImage(JSDialogSender* pSender, FixedImage* pImage, SalInstanceBuilder* pBuilder,
2034 bool bTakeOwnership)
2035 : JSWidget<SalInstanceImage, FixedImage>(pSender, pImage, pBuilder, bTakeOwnership)
2039 void JSImage::set_image(VirtualDevice* pDevice)
2041 SalInstanceImage::set_image(pDevice);
2042 sendUpdate();
2045 void JSImage::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage)
2047 SalInstanceImage::set_image(rImage);
2048 sendUpdate();
2051 JSLevelBar::JSLevelBar(JSDialogSender* pSender, ::ProgressBar* pProgressBar,
2052 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
2053 : JSWidget<SalInstanceLevelBar, ::ProgressBar>(pSender, pProgressBar, pBuilder, bTakeOwnership)
2057 void JSLevelBar::set_percentage(double fPercentage)
2059 SalInstanceLevelBar::set_percentage(fPercentage);
2060 sendUpdate();
2063 JSCalendar::JSCalendar(JSDialogSender* pSender, ::Calendar* pCalendar, SalInstanceBuilder* pBuilder,
2064 bool bTakeOwnership)
2065 : JSWidget<SalInstanceCalendar, ::Calendar>(pSender, pCalendar, pBuilder, bTakeOwnership)
2069 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */