vcl/inc/jsdialog/jsdialogbuilder.hxx |  140 +++++++++++----------
 vcl/jsdialog/jsdialogbuilder.cxx     |  230 +++++++++++++++--------------------
 2 files changed, 177 insertions(+), 193 deletions(-)

New commits:
commit 83d5bf410912f00dd6fb2ecca4fa18db88e772f9
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Jan 12 14:30:05 2021 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Feb 5 05:24:50 2021 +0100

    jsdialog: use shared sender
    
    Change-Id: I6d1047715cf6c29e9281c66d266ed4b888ed784c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109171
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109906
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx 
b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 08218512fa2b..0119f6a5c8c0 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -65,10 +65,11 @@ class VCL_DLLPUBLIC JSDialogSender
     std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify;
 
 public:
+    JSDialogSender() = default;
     JSDialogSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
                    std::string sTypeOfJSON)
-        : mpIdleNotify(new JSDialogNotifyIdle(aNotifierWindow, aContentWindow, 
sTypeOfJSON))
     {
+        initializeSender(aNotifierWindow, aContentWindow, sTypeOfJSON);
     }
 
     virtual ~JSDialogSender() = default;
@@ -76,6 +77,13 @@ public:
     virtual void notifyDialogState(bool bForce = false);
     void sendClose();
     virtual void sendUpdate(VclPtr<vcl::Window> pWindow);
+
+protected:
+    void initializeSender(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
+                          std::string sTypeOfJSON)
+    {
+        mpIdleNotify.reset(new JSDialogNotifyIdle(aNotifierWindow, 
aContentWindow, sTypeOfJSON));
+    }
 };
 
 class JSDropTarget final
@@ -112,7 +120,7 @@ public:
     void fire_dragEnter(const 
css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
 };
 
-class JSInstanceBuilder : public SalInstanceBuilder
+class JSInstanceBuilder : public SalInstanceBuilder, public JSDialogSender
 {
     sal_uInt64 m_nWindowId;
     /// used in case of tab pages where dialog is not a direct top level
@@ -191,24 +199,36 @@ public:
                                                     const OUString& 
rPrimaryMessage);
 
 private:
+    const std::string& GetTypeOfJSON();
     VclPtr<vcl::Window>& GetContentWindow();
     VclPtr<vcl::Window>& GetNotifierWindow();
 };
 
-template <class BaseInstanceClass, class VclClass>
-class JSWidget : public BaseInstanceClass, public JSDialogSender
+template <class BaseInstanceClass, class VclClass> class JSWidget : public 
BaseInstanceClass
 {
 protected:
     rtl::Reference<JSDropTarget> m_xDropTarget;
     bool m_bIsFreezed;
 
+    JSDialogSender* m_pSender;
+
 public:
-    JSWidget(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-             VclClass* pObject, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-             std::string sTypeOfJSON)
+    JSWidget(JSDialogSender* pSender, VclClass* pObject, SalInstanceBuilder* 
pBuilder,
+             bool bTakeOwnership)
         : BaseInstanceClass(pObject, pBuilder, bTakeOwnership)
-        , JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON)
         , m_bIsFreezed(false)
+        , m_pSender(pSender)
+    {
+    }
+
+    template <class T>
+    JSWidget(JSDialogSender* pSender, T* pObject, SalInstanceBuilder* pBuilder,
+             const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, 
void* pUserData,
+             bool bTakeOwnership)
+        : BaseInstanceClass(pObject, pBuilder, rAlly, pUITestFactoryFunction, 
pUserData,
+                            bTakeOwnership)
+        , m_bIsFreezed(false)
+        , m_pSender(pSender)
     {
     }
 
@@ -251,25 +271,30 @@ public:
         m_bIsFreezed = false;
     }
 
-    virtual void sendUpdate(VclPtr<vcl::Window> pWindow) override
+    void sendClose()
+    {
+        if (m_pSender)
+            m_pSender->sendClose();
+    }
+
+    void sendUpdate(VclPtr<vcl::Window> pWindow)
     {
-        if (!m_bIsFreezed)
-            JSDialogSender::sendUpdate(pWindow);
+        if (!m_bIsFreezed && m_pSender)
+            m_pSender->sendUpdate(pWindow);
     }
 
-    virtual void notifyDialogState(bool bForce = false) override
+    void notifyDialogState(bool bForce = false)
     {
-        if (!m_bIsFreezed || bForce)
-            JSDialogSender::notifyDialogState(bForce);
+        if ((!m_bIsFreezed || bForce) && m_pSender)
+            m_pSender->notifyDialogState(bForce);
     }
 };
 
 class VCL_DLLPUBLIC JSDialog : public JSWidget<SalInstanceDialog, ::Dialog>
 {
 public:
-    JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-             ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-             std::string sTypeOfJSON);
+    JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* 
pBuilder,
+             bool bTakeOwnership);
 
     virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override;
     virtual void undo_collapse() override;
@@ -279,34 +304,31 @@ public:
 class JSLabel : public JSWidget<SalInstanceLabel, FixedText>
 {
 public:
-    JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-            FixedText* pLabel, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-            std::string sTypeOfJSON);
+    JSLabel(JSDialogSender* pSender, FixedText* pLabel, SalInstanceBuilder* 
pBuilder,
+            bool bTakeOwnership);
     virtual void set_label(const OUString& rText) override;
 };
 
 class JSButton : public JSWidget<SalInstanceButton, ::Button>
 {
 public:
-    JSButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-             ::Button* pButton, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-             std::string sTypeOfJSON);
+    JSButton(JSDialogSender* pSender, ::Button* pButton, SalInstanceBuilder* 
pBuilder,
+             bool bTakeOwnership);
 };
 
 class JSEntry : public JSWidget<SalInstanceEntry, ::Edit>
 {
 public:
-    JSEntry(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow, ::Edit* pEntry,
-            SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string 
sTypeOfJSON);
+    JSEntry(JSDialogSender* pSender, ::Edit* pEntry, SalInstanceBuilder* 
pBuilder,
+            bool bTakeOwnership);
     virtual void set_text(const OUString& rText) override;
 };
 
 class JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>
 {
 public:
-    JSListBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-              ::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-              std::string sTypeOfJSON);
+    JSListBox(JSDialogSender* pSender, ::ListBox* pListBox, 
SalInstanceBuilder* pBuilder,
+              bool bTakeOwnership);
     virtual void insert(int pos, const OUString& rStr, const OUString* pId,
                         const OUString* pIconName, VirtualDevice* 
pImageSurface) override;
     virtual void remove(int pos) override;
@@ -316,9 +338,8 @@ public:
 class JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>
 {
 public:
-    JSComboBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-               ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-               std::string sTypeOfJSON);
+    JSComboBox(JSDialogSender* pSender, ::ComboBox* pComboBox, 
SalInstanceBuilder* pBuilder,
+               bool bTakeOwnership);
     virtual void insert(int pos, const OUString& rStr, const OUString* pId,
                         const OUString* pIconName, VirtualDevice* 
pImageSurface) override;
     virtual void remove(int pos) override;
@@ -329,9 +350,8 @@ public:
 class JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl>
 {
 public:
-    JSNotebook(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-               ::TabControl* pControl, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-               std::string sTypeOfJSON);
+    JSNotebook(JSDialogSender* pSender, ::TabControl* pControl, 
SalInstanceBuilder* pBuilder,
+               bool bTakeOwnership);
 
     virtual void set_current_page(int nPage) override;
 
@@ -345,18 +365,20 @@ public:
 class JSSpinButton : public JSWidget<SalInstanceSpinButton, ::FormattedField>
 {
 public:
-    JSSpinButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                 ::FormattedField* pSpin, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                 std::string sTypeOfJSON);
+    JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin, 
SalInstanceBuilder* pBuilder,
+                 bool bTakeOwnership);
 
     virtual void set_value(int value) override;
 };
 
-class JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender
+class JSMessageDialog : public JSWidget<SalInstanceMessageDialog, 
::MessageDialog>
 {
+    std::unique_ptr<JSDialogSender> m_pOwnedSender;
+
 public:
-    JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> 
aContentWindow,
-                    SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* pDialog, 
SalInstanceBuilder* pBuilder,
+                    bool bTakeOwnership);
+    JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership);
 
     virtual void set_primary_text(const OUString& rText) override;
 
@@ -366,19 +388,18 @@ public:
 class JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox>
 {
 public:
-    JSCheckButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                  ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                  std::string sTypeOfJSON);
+    JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox, 
SalInstanceBuilder* pBuilder,
+                  bool bTakeOwnership);
 
     virtual void set_active(bool active) override;
 };
 
-class JSDrawingArea : public SalInstanceDrawingArea, public JSDialogSender
+class JSDrawingArea : public JSWidget<SalInstanceDrawingArea, VclDrawingArea>
 {
 public:
-    JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                  VclDrawingArea* pDrawingArea, SalInstanceBuilder* pBuilder, 
const a11yref& rAlly,
-                  FactoryFunction pUITestFactoryFunction, void* pUserData, 
std::string sTypeOfJSON,
+    JSDrawingArea(JSDialogSender* pSender, VclDrawingArea* pDrawingArea,
+                  SalInstanceBuilder* pBuilder, const a11yref& rAlly,
+                  FactoryFunction pUITestFactoryFunction, void* pUserData,
                   bool bTakeOwnership = false);
 
     virtual void queue_draw() override;
@@ -388,9 +409,8 @@ public:
 class JSToolbar : public JSWidget<SalInstanceToolbar, ::ToolBox>
 {
 public:
-    JSToolbar(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-              ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-              std::string sTypeOfJSON);
+    JSToolbar(JSDialogSender* pSender, ::ToolBox* pToolbox, 
SalInstanceBuilder* pBuilder,
+              bool bTakeOwnership);
 
     virtual void signal_clicked(const OString& rIdent) override;
 };
@@ -398,18 +418,16 @@ public:
 class JSTextView : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit>
 {
 public:
-    JSTextView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-               ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership,
-               std::string sTypeOfJSON);
+    JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, 
SalInstanceBuilder* pBuilder,
+               bool bTakeOwnership);
     virtual void set_text(const OUString& rText) override;
 };
 
 class JSTreeView : public JSWidget<SalInstanceTreeView, ::SvTabListBox>
 {
 public:
-    JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-               ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-               std::string sTypeOfJSON);
+    JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTextView, 
SalInstanceBuilder* pBuilder,
+               bool bTakeOwnership);
 
     using SalInstanceTreeView::set_toggle;
     /// pos is used differently here, it defines how many steps of iterator we 
need to perform to take entry
@@ -440,9 +458,8 @@ public:
 class JSExpander : public JSWidget<SalInstanceExpander, ::VclExpander>
 {
 public:
-    JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-               ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-               std::string sTypeOfJSON);
+    JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander, 
SalInstanceBuilder* pBuilder,
+               bool bTakeOwnership);
 
     virtual void set_expanded(bool bExpand) override;
 };
@@ -450,9 +467,8 @@ public:
 class JSIconView : public JSWidget<SalInstanceIconView, ::IconView>
 {
 public:
-    JSIconView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-               ::IconView* pIconView, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-               std::string sTypeOfJSON);
+    JSIconView(JSDialogSender* pSender, ::IconView* pIconView, 
SalInstanceBuilder* pBuilder,
+               bool bTakeOwnership);
 
     virtual void insert(int pos, const OUString* pStr, const OUString* pId,
                         const OUString* pIconName, weld::TreeIter* pRet) 
override;
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index e096209828a6..576f2bba5b3b 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -293,6 +293,8 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, 
const OUString& rUIR
             m_nWindowId = m_aParentDialog->GetLOKWindowId();
         InsertWindowToMap(m_nWindowId);
     }
+
+    initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
 }
 
 // used for notebookbar
@@ -321,6 +323,8 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, 
const OUString& rUIRo
         }
         InsertWindowToMap(m_nWindowId);
     }
+
+    initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
 }
 
 // used for autofilter dropdown
@@ -343,6 +347,8 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, 
const OUString& rUIRo
             m_nWindowId = m_aParentDialog->GetLOKWindowId();
         InsertWindowToMap(m_nWindowId);
     }
+
+    initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
 }
 
 JSInstanceBuilder* JSInstanceBuilder::CreateDialogBuilder(weld::Widget* 
pParent,
@@ -424,6 +430,8 @@ void JSInstanceBuilder::RememberWidget(const OString& id, 
weld::Widget* pWidget)
     }
 }
 
+const std::string& JSInstanceBuilder::GetTypeOfJSON() { return m_sTypeOfJSON; }
+
 VclPtr<vcl::Window>& JSInstanceBuilder::GetContentWindow()
 {
     if (m_aContentWindow)
@@ -454,8 +462,7 @@ std::unique_ptr<weld::Dialog> 
JSInstanceBuilder::weld_dialog(const OString& id,
         m_xBuilder->drop_ownership(pDialog);
         m_bHasTopLevelDialog = true;
 
-        pRet.reset(
-            new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, 
false, m_sTypeOfJSON));
+        pRet.reset(new JSDialog(this, pDialog, this, false));
 
         RememberWidget("__DIALOG__", pRet.get());
 
@@ -469,6 +476,8 @@ std::unique_ptr<weld::Dialog> 
JSInstanceBuilder::weld_dialog(const OString& id,
             const std::string message = aStream.str();
             pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, 
message.c_str());
         }
+
+        initializeSender(GetNotifierWindow(), GetContentWindow(), 
GetTypeOfJSON());
     }
 
     return pRet;
@@ -490,10 +499,12 @@ std::unique_ptr<weld::MessageDialog> 
JSInstanceBuilder::weld_message_dialog(cons
         assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
         m_aOwnedToplevel.set(pMessageDialog);
         m_xBuilder->drop_ownership(pMessageDialog);
+        m_bHasTopLevelDialog = true;
+
+        initializeSender(GetNotifierWindow(), GetContentWindow(), 
GetTypeOfJSON());
     }
 
-    pRet.reset(pMessageDialog ? new JSMessageDialog(pMessageDialog, 
m_aOwnedToplevel, this, false)
-                              : nullptr);
+    pRet.reset(pMessageDialog ? new JSMessageDialog(this, pMessageDialog, 
this, false) : nullptr);
 
     if (pRet)
         RememberWidget("__DIALOG__", pRet.get());
@@ -504,8 +515,7 @@ std::unique_ptr<weld::MessageDialog> 
JSInstanceBuilder::weld_message_dialog(cons
 std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id, 
bool bTakeOwnership)
 {
     ::FixedText* pLabel = m_xBuilder->get<FixedText>(id);
-    auto pWeldWidget = std::make_unique<JSLabel>(GetNotifierWindow(), 
GetContentWindow(), pLabel,
-                                                 this, bTakeOwnership, 
m_sTypeOfJSON);
+    auto pWeldWidget = std::make_unique<JSLabel>(this, pLabel, this, 
bTakeOwnership);
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -517,9 +527,7 @@ std::unique_ptr<weld::Button> 
JSInstanceBuilder::weld_button(const OString& id,
 {
     ::Button* pButton = m_xBuilder->get<::Button>(id);
     auto pWeldWidget
-        = pButton ? std::make_unique<JSButton>(GetNotifierWindow(), 
GetContentWindow(), pButton,
-                                               this, bTakeOwnership, 
m_sTypeOfJSON)
-                  : nullptr;
+        = pButton ? std::make_unique<JSButton>(this, pButton, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -530,10 +538,8 @@ std::unique_ptr<weld::Button> 
JSInstanceBuilder::weld_button(const OString& id,
 std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id, 
bool bTakeOwnership)
 {
     Edit* pEntry = m_xBuilder->get<Edit>(id);
-    auto pWeldWidget = pEntry
-                           ? std::make_unique<JSEntry>(GetNotifierWindow(), 
GetContentWindow(),
-                                                       pEntry, this, 
bTakeOwnership, m_sTypeOfJSON)
-                           : nullptr;
+    auto pWeldWidget
+        = pEntry ? std::make_unique<JSEntry>(this, pEntry, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -550,16 +556,13 @@ std::unique_ptr<weld::ComboBox> 
JSInstanceBuilder::weld_combo_box(const OString&
 
     if (pComboBox)
     {
-        pWeldWidget = std::make_unique<JSComboBox>(GetNotifierWindow(), 
GetContentWindow(),
-                                                   pComboBox, this, 
bTakeOwnership, m_sTypeOfJSON);
+        pWeldWidget = std::make_unique<JSComboBox>(this, pComboBox, this, 
bTakeOwnership);
     }
     else
     {
         ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
-        pWeldWidget
-            = pListBox ? std::make_unique<JSListBox>(GetNotifierWindow(), 
GetContentWindow(),
-                                                     pListBox, this, 
bTakeOwnership, m_sTypeOfJSON)
-                       : nullptr;
+        pWeldWidget = pListBox ? std::make_unique<JSListBox>(this, pListBox, 
this, bTakeOwnership)
+                               : nullptr;
     }
 
     if (pWeldWidget)
@@ -573,9 +576,7 @@ std::unique_ptr<weld::Notebook> 
JSInstanceBuilder::weld_notebook(const OString&
 {
     TabControl* pNotebook = m_xBuilder->get<TabControl>(id);
     auto pWeldWidget
-        = pNotebook ? std::make_unique<JSNotebook>(GetNotifierWindow(), 
GetContentWindow(),
-                                                   pNotebook, this, 
bTakeOwnership, m_sTypeOfJSON)
-                    : nullptr;
+        = pNotebook ? std::make_unique<JSNotebook>(this, pNotebook, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -587,11 +588,9 @@ std::unique_ptr<weld::SpinButton> 
JSInstanceBuilder::weld_spin_button(const OStr
                                                                       bool 
bTakeOwnership)
 {
     FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
-    auto pWeldWidget
-        = pSpinButton
-              ? std::make_unique<JSSpinButton>(GetNotifierWindow(), 
GetContentWindow(), pSpinButton,
-                                               this, bTakeOwnership, 
m_sTypeOfJSON)
-              : nullptr;
+    auto pWeldWidget = pSpinButton
+                           ? std::make_unique<JSSpinButton>(this, pSpinButton, 
this, bTakeOwnership)
+                           : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -604,10 +603,8 @@ std::unique_ptr<weld::CheckButton> 
JSInstanceBuilder::weld_check_button(const OS
 {
     CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
     auto pWeldWidget
-        = pCheckButton
-              ? std::make_unique<JSCheckButton>(GetNotifierWindow(), 
GetContentWindow(),
-                                                pCheckButton, this, 
bTakeOwnership, m_sTypeOfJSON)
-              : nullptr;
+        = pCheckButton ? std::make_unique<JSCheckButton>(this, pCheckButton, 
this, bTakeOwnership)
+                       : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -621,10 +618,10 @@ JSInstanceBuilder::weld_drawing_area(const OString& id, 
const a11yref& rA11yImpl
                                      bool bTakeOwnership)
 {
     VclDrawingArea* pArea = m_xBuilder->get<VclDrawingArea>(id);
-    auto pWeldWidget = pArea ? std::make_unique<JSDrawingArea>(
-                                   GetNotifierWindow(), GetContentWindow(), 
pArea, this, rA11yImpl,
-                                   pUITestFactoryFunction, pUserData, 
m_sTypeOfJSON, bTakeOwnership)
-                             : nullptr;
+    auto pWeldWidget
+        = pArea ? std::make_unique<JSDrawingArea>(this, pArea, this, rA11yImpl,
+                                                  pUITestFactoryFunction, 
pUserData, bTakeOwnership)
+                : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -637,9 +634,7 @@ std::unique_ptr<weld::Toolbar> 
JSInstanceBuilder::weld_toolbar(const OString& id
 {
     ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);
     auto pWeldWidget
-        = pToolBox ? std::make_unique<JSToolbar>(GetNotifierWindow(), 
GetContentWindow(), pToolBox,
-                                                 this, bTakeOwnership, 
m_sTypeOfJSON)
-                   : nullptr;
+        = pToolBox ? std::make_unique<JSToolbar>(this, pToolBox, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -652,9 +647,7 @@ std::unique_ptr<weld::TextView> 
JSInstanceBuilder::weld_text_view(const OString&
 {
     VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
     auto pWeldWidget
-        = pTextView ? std::make_unique<JSTextView>(GetNotifierWindow(), 
GetContentWindow(),
-                                                   pTextView, this, 
bTakeOwnership, m_sTypeOfJSON)
-                    : nullptr;
+        = pTextView ? std::make_unique<JSTextView>(this, pTextView, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -667,9 +660,7 @@ std::unique_ptr<weld::TreeView> 
JSInstanceBuilder::weld_tree_view(const OString&
 {
     SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id);
     auto pWeldWidget
-        = pTreeView ? std::make_unique<JSTreeView>(GetNotifierWindow(), 
GetContentWindow(),
-                                                   pTreeView, this, 
bTakeOwnership, m_sTypeOfJSON)
-                    : nullptr;
+        = pTreeView ? std::make_unique<JSTreeView>(this, pTreeView, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -682,9 +673,7 @@ std::unique_ptr<weld::Expander> 
JSInstanceBuilder::weld_expander(const OString&
 {
     VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
     auto pWeldWidget
-        = pExpander ? std::make_unique<JSExpander>(GetNotifierWindow(), 
GetContentWindow(),
-                                                   pExpander, this, 
bTakeOwnership, m_sTypeOfJSON)
-                    : nullptr;
+        = pExpander ? std::make_unique<JSExpander>(this, pExpander, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -697,9 +686,7 @@ std::unique_ptr<weld::IconView> 
JSInstanceBuilder::weld_icon_view(const OString&
 {
     ::IconView* pIconView = m_xBuilder->get<::IconView>(id);
     auto pWeldWidget
-        = pIconView ? std::make_unique<JSIconView>(GetNotifierWindow(), 
GetContentWindow(),
-                                                   pIconView, this, 
bTakeOwnership, m_sTypeOfJSON)
-                    : nullptr;
+        = pIconView ? std::make_unique<JSIconView>(this, pIconView, this, 
bTakeOwnership) : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -729,14 +716,12 @@ weld::MessageDialog* 
JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen
         pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, 
message.c_str());
     }
 
-    return new JSMessageDialog(xMessageDialog, xMessageDialog, nullptr, true);
+    return new JSMessageDialog(xMessageDialog, nullptr, true);
 }
 
-JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                   ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                   std::string sTypeOfJSON)
-    : JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, 
pDialog, pBuilder,
-                                            bTakeOwnership, sTypeOfJSON)
+JSDialog::JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, 
SalInstanceBuilder* pBuilder,
+                   bool bTakeOwnership)
+    : JSWidget<SalInstanceDialog, ::Dialog>(pSender, pDialog, pBuilder, 
bTakeOwnership)
 {
 }
 
@@ -758,11 +743,9 @@ void JSDialog::response(int response)
     SalInstanceDialog::response(response);
 }
 
-JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                 FixedText* pLabel, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                 std::string sTypeOfJSON)
-    : JSWidget<SalInstanceLabel, FixedText>(aNotifierWindow, aContentWindow, 
pLabel, pBuilder,
-                                            bTakeOwnership, sTypeOfJSON)
+JSLabel::JSLabel(JSDialogSender* pSender, FixedText* pLabel, 
SalInstanceBuilder* pBuilder,
+                 bool bTakeOwnership)
+    : JSWidget<SalInstanceLabel, FixedText>(pSender, pLabel, pBuilder, 
bTakeOwnership)
 {
 }
 
@@ -772,19 +755,15 @@ void JSLabel::set_label(const OUString& rText)
     notifyDialogState();
 };
 
-JSButton::JSButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                   ::Button* pButton, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                   std::string sTypeOfJSON)
-    : JSWidget<SalInstanceButton, ::Button>(aNotifierWindow, aContentWindow, 
pButton, pBuilder,
-                                            bTakeOwnership, sTypeOfJSON)
+JSButton::JSButton(JSDialogSender* pSender, ::Button* pButton, 
SalInstanceBuilder* pBuilder,
+                   bool bTakeOwnership)
+    : JSWidget<SalInstanceButton, ::Button>(pSender, pButton, pBuilder, 
bTakeOwnership)
 {
 }
 
-JSEntry::JSEntry(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                 ::Edit* pEntry, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                 std::string sTypeOfJSON)
-    : JSWidget<SalInstanceEntry, ::Edit>(aNotifierWindow, aContentWindow, 
pEntry, pBuilder,
-                                         bTakeOwnership, sTypeOfJSON)
+JSEntry::JSEntry(JSDialogSender* pSender, ::Edit* pEntry, SalInstanceBuilder* 
pBuilder,
+                 bool bTakeOwnership)
+    : JSWidget<SalInstanceEntry, ::Edit>(pSender, pEntry, pBuilder, 
bTakeOwnership)
 {
 }
 
@@ -794,11 +773,10 @@ void JSEntry::set_text(const OUString& rText)
     notifyDialogState();
 }
 
-JSListBox::JSListBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                     ::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                     std::string sTypeOfJSON)
-    : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(aNotifierWindow, 
aContentWindow, pListBox,
-                                                          pBuilder, 
bTakeOwnership, sTypeOfJSON)
+JSListBox::JSListBox(JSDialogSender* pSender, ::ListBox* pListBox, 
SalInstanceBuilder* pBuilder,
+                     bool bTakeOwnership)
+    : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(pSender, pListBox, 
pBuilder,
+                                                          bTakeOwnership)
 {
 }
 
@@ -821,11 +799,10 @@ void JSListBox::set_active(int pos)
     notifyDialogState();
 }
 
-JSComboBox::JSComboBox(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                       ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership,
-                       std::string sTypeOfJSON)
-    : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aNotifierWindow, 
aContentWindow, pComboBox,
-                                                        pBuilder, 
bTakeOwnership, sTypeOfJSON)
+JSComboBox::JSComboBox(JSDialogSender* pSender, ::ComboBox* pComboBox, 
SalInstanceBuilder* pBuilder,
+                       bool bTakeOwnership)
+    : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(pSender, pComboBox, 
pBuilder,
+                                                        bTakeOwnership)
 {
 }
 
@@ -854,11 +831,9 @@ void JSComboBox::set_active(int pos)
     notifyDialogState();
 }
 
-JSNotebook::JSNotebook(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                       ::TabControl* pControl, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership,
-                       std::string sTypeOfJSON)
-    : JSWidget<SalInstanceNotebook, ::TabControl>(aNotifierWindow, 
aContentWindow, pControl,
-                                                  pBuilder, bTakeOwnership, 
sTypeOfJSON)
+JSNotebook::JSNotebook(JSDialogSender* pSender, ::TabControl* pControl,
+                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceNotebook, ::TabControl>(pSender, pControl, pBuilder, 
bTakeOwnership)
 {
 }
 
@@ -896,11 +871,9 @@ void JSNotebook::append_page(const OString& rIdent, const 
OUString& rLabel)
     notifyDialogState();
 }
 
-JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                           ::FormattedField* pSpin, SalInstanceBuilder* 
pBuilder,
-                           bool bTakeOwnership, std::string sTypeOfJSON)
-    : JSWidget<SalInstanceSpinButton, ::FormattedField>(aNotifierWindow, 
aContentWindow, pSpin,
-                                                        pBuilder, 
bTakeOwnership, sTypeOfJSON)
+JSSpinButton::JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin,
+                           SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceSpinButton, ::FormattedField>(pSender, pSpin, 
pBuilder, bTakeOwnership)
 {
 }
 
@@ -910,11 +883,20 @@ void JSSpinButton::set_value(int value)
     notifyDialogState(true); // if input is limited we can receive the same 
JSON
 }
 
-JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> 
aContentWindow,
+JSMessageDialog::JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* 
pDialog,
                                  SalInstanceBuilder* pBuilder, bool 
bTakeOwnership)
-    : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership)
-    , JSDialogSender(m_xMessageDialog, aContentWindow, "dialog")
+    : JSWidget<SalInstanceMessageDialog, ::MessageDialog>(pSender, pDialog, 
pBuilder,
+                                                          bTakeOwnership)
+{
+}
+
+JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* 
pBuilder,
+                                 bool bTakeOwnership)
+    : JSWidget<SalInstanceMessageDialog, ::MessageDialog>(nullptr, pDialog, 
pBuilder,
+                                                          bTakeOwnership)
+    , m_pOwnedSender(new JSDialogSender(pDialog, pDialog, "dialog"))
 {
+    m_pSender = m_pOwnedSender.get();
 }
 
 void JSMessageDialog::set_primary_text(const OUString& rText)
@@ -929,12 +911,9 @@ void JSMessageDialog::set_secondary_text(const OUString& 
rText)
     notifyDialogState();
 }
 
-JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aNotifierWindow,
-                             VclPtr<vcl::Window> aContentWindow, ::CheckBox* 
pCheckBox,
-                             SalInstanceBuilder* pBuilder, bool bTakeOwnership,
-                             std::string sTypeOfJSON)
-    : JSWidget<SalInstanceCheckButton, ::CheckBox>(aNotifierWindow, 
aContentWindow, pCheckBox,
-                                                   pBuilder, bTakeOwnership, 
sTypeOfJSON)
+JSCheckButton::JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox,
+                             SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceCheckButton, ::CheckBox>(pSender, pCheckBox, 
pBuilder, bTakeOwnership)
 {
 }
 
@@ -944,14 +923,12 @@ void JSCheckButton::set_active(bool active)
     notifyDialogState();
 }
 
-JSDrawingArea::JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow,
-                             VclPtr<vcl::Window> aContentWindow, 
VclDrawingArea* pDrawingArea,
+JSDrawingArea::JSDrawingArea(JSDialogSender* pSender, VclDrawingArea* 
pDrawingArea,
                              SalInstanceBuilder* pBuilder, const a11yref& 
rAlly,
                              FactoryFunction pUITestFactoryFunction, void* 
pUserData,
-                             std::string sTypeOfJSON, bool bTakeOwnership)
-    : SalInstanceDrawingArea(pDrawingArea, pBuilder, rAlly, 
pUITestFactoryFunction, pUserData,
-                             bTakeOwnership)
-    , JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON)
+                             bool bTakeOwnership)
+    : JSWidget<SalInstanceDrawingArea, VclDrawingArea>(
+          pSender, pDrawingArea, pBuilder, rAlly, pUITestFactoryFunction, 
pUserData, bTakeOwnership)
 {
 }
 
@@ -967,11 +944,9 @@ void JSDrawingArea::queue_draw_area(int x, int y, int 
width, int height)
     notifyDialogState();
 }
 
-JSToolbar::JSToolbar(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
-                     ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
-                     std::string sTypeOfJSON)
-    : JSWidget<SalInstanceToolbar, ::ToolBox>(aNotifierWindow, aContentWindow, 
pToolbox, pBuilder,
-                                              bTakeOwnership, sTypeOfJSON)
+JSToolbar::JSToolbar(JSDialogSender* pSender, ::ToolBox* pToolbox, 
SalInstanceBuilder* pBuilder,
+                     bool bTakeOwnership)
+    : JSWidget<SalInstanceToolbar, ::ToolBox>(pSender, pToolbox, pBuilder, 
bTakeOwnership)
 {
 }
 
@@ -981,11 +956,10 @@ void JSToolbar::signal_clicked(const OString& rIdent)
     notifyDialogState();
 }
 
-JSTextView::JSTextView(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                       ::VclMultiLineEdit* pTextView, SalInstanceBuilder* 
pBuilder,
-                       bool bTakeOwnership, std::string sTypeOfJSON)
-    : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aNotifierWindow, 
aContentWindow, pTextView,
-                                                        pBuilder, 
bTakeOwnership, sTypeOfJSON)
+JSTextView::JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView,
+                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(pSender, pTextView, 
pBuilder,
+                                                        bTakeOwnership)
 {
 }
 
@@ -995,11 +969,9 @@ void JSTextView::set_text(const OUString& rText)
     notifyDialogState();
 }
 
-JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                       ::SvTabListBox* pTreeView, SalInstanceBuilder* 
pBuilder, bool bTakeOwnership,
-                       std::string sTypeOfJSON)
-    : JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, 
aContentWindow, pTreeView,
-                                                    pBuilder, bTakeOwnership, 
sTypeOfJSON)
+JSTreeView::JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTreeView,
+                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceTreeView, ::SvTabListBox>(pSender, pTreeView, 
pBuilder, bTakeOwnership)
 {
 }
 
@@ -1102,11 +1074,9 @@ void JSTreeView::collapse_row(const weld::TreeIter& 
rIter)
     sendUpdate(m_xTreeView);
 }
 
-JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                       ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership,
-                       std::string sTypeOfJSON)
-    : JSWidget<SalInstanceExpander, ::VclExpander>(aNotifierWindow, 
aContentWindow, pExpander,
-                                                   pBuilder, bTakeOwnership, 
sTypeOfJSON)
+JSExpander::JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander,
+                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceExpander, ::VclExpander>(pSender, pExpander, 
pBuilder, bTakeOwnership)
 {
 }
 
@@ -1116,11 +1086,9 @@ void JSExpander::set_expanded(bool bExpand)
     notifyDialogState();
 }
 
-JSIconView::JSIconView(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aContentWindow,
-                       ::IconView* pIconView, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership,
-                       std::string sTypeOfJSON)
-    : JSWidget<SalInstanceIconView, ::IconView>(aNotifierWindow, 
aContentWindow, pIconView,
-                                                pBuilder, bTakeOwnership, 
sTypeOfJSON)
+JSIconView::JSIconView(JSDialogSender* pSender, ::IconView* pIconView, 
SalInstanceBuilder* pBuilder,
+                       bool bTakeOwnership)
+    : JSWidget<SalInstanceIconView, ::IconView>(pSender, pIconView, pBuilder, 
bTakeOwnership)
 {
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to