[Libreoffice-commits] core.git: vcl/inc vcl/jsdialog vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 24 17:23:35 UTC 2020


 vcl/inc/jsdialog/jsdialogbuilder.hxx           |  108 ++++++----
 vcl/jsdialog/jsdialogbuilder.cxx               |  264 ++++++++++++++++---------
 vcl/source/control/WeldedTabbedNotebookbar.cxx |    4 
 vcl/source/window/builder.cxx                  |   10 
 4 files changed, 257 insertions(+), 129 deletions(-)

New commits:
commit 5814084f02f3d660fc28afd6a053050073944b81
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Oct 21 15:45:19 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Nov 24 18:22:57 2020 +0100

    jsdialog: use separate content and notificator windows
    
    Change-Id: I42208dd69bc790d136637253d7f1ae39a6306820
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106503
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index f486685c7dd9..91640f7a4ccd 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -27,12 +27,17 @@ typedef std::map<OString, weld::Widget*> WidgetMap;
 
 class JSDialogNotifyIdle : public Idle
 {
-    VclPtr<vcl::Window> m_aWindow;
+    // used to send message
+    VclPtr<vcl::Window> m_aNotifierWindow;
+    // used to generate JSON
+    VclPtr<vcl::Window> m_aContentWindow;
+    std::string m_sTypeOfJSON;
     std::string m_LastNotificationMessage;
     bool m_bForce;
 
 public:
-    JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow);
+    JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                       std::string sTypeOfJSON);
 
     void Invoke() override;
     void ForceUpdate();
@@ -43,8 +48,9 @@ class JSDialogSender
     std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify;
 
 public:
-    JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel)
-        : mpIdleNotify(new JSDialogNotifyIdle(aOwnedToplevel))
+    JSDialogSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                   std::string sTypeOfJSON)
+        : mpIdleNotify(new JSDialogNotifyIdle(aNotifierWindow, aContentWindow, sTypeOfJSON))
     {
     }
 
@@ -56,6 +62,8 @@ class JSInstanceBuilder : public SalInstanceBuilder
     sal_uInt64 m_nWindowId;
     /// used in case of tab pages where dialog is not a direct top level
     VclPtr<vcl::Window> m_aParentDialog;
+    VclPtr<vcl::Window> m_aContentWindow;
+    std::string m_sTypeOfJSON;
     bool m_bHasTopLevelDialog;
     bool m_bIsNotebookbar;
 
@@ -67,12 +75,26 @@ class JSInstanceBuilder : public SalInstanceBuilder
     void RememberWidget(const OString& id, weld::Widget* pWidget);
     static weld::Widget* FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget);
 
-public:
+    /// used for dialogs
     JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
-    /// optional nWindowId is used if getting parent id failed
+    /// used for notebookbar, optional nWindowId is used if getting parent id failed
     JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
                       const css::uno::Reference<css::frame::XFrame>& rFrame,
                       sal_uInt64 nWindowId = 0);
+    /// for autofilter dropdown
+    JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile);
+
+public:
+    static JSInstanceBuilder* CreateDialogBuilder(weld::Widget* pParent, const OUString& rUIRoot,
+                                                  const OUString& rUIFile);
+    static JSInstanceBuilder*
+    CreateNotebookbarBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
+                             const css::uno::Reference<css::frame::XFrame>& rFrame,
+                             sal_uInt64 nWindowId = 0);
+    static JSInstanceBuilder* CreateAutofilterWindowBuilder(vcl::Window* pParent,
+                                                            const OUString& rUIRoot,
+                                                            const OUString& rUIFile);
+
     virtual ~JSInstanceBuilder() override;
     virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id) override;
     virtual std::unique_ptr<weld::Label> weld_label(const OString& id) override;
@@ -93,16 +115,21 @@ public:
                                                     VclMessageType eMessageType,
                                                     VclButtonsType eButtonType,
                                                     const OUString& rPrimaryMessage);
+
+private:
+    VclPtr<vcl::Window>& GetContentWindow();
+    VclPtr<vcl::Window>& GetNotifierWindow();
 };
 
 template <class BaseInstanceClass, class VclClass>
 class JSWidget : public BaseInstanceClass, public JSDialogSender
 {
 public:
-    JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder,
-             bool bTakeOwnership)
+    JSWidget(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+             VclClass* pObject, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+             std::string sTypeOfJSON)
         : BaseInstanceClass(pObject, pBuilder, bTakeOwnership)
-        , JSDialogSender(aOwnedToplevel)
+        , JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON)
     {
     }
 
@@ -128,8 +155,9 @@ public:
 class JSDialog : public JSWidget<SalInstanceDialog, ::Dialog>
 {
 public:
-    JSDialog(VclPtr<vcl::Window> aOwnedToplevel, ::Dialog* pDialog, SalInstanceBuilder* pBuilder,
-             bool bTakeOwnership);
+    JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+             ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+             std::string sTypeOfJSON);
 
     virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) override;
     virtual void undo_collapse() override;
@@ -138,31 +166,34 @@ public:
 class JSLabel : public JSWidget<SalInstanceLabel, FixedText>
 {
 public:
-    JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder,
-            bool bTakeOwnership);
+    JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+            FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+            std::string sTypeOfJSON);
     virtual void set_label(const OUString& rText) override;
 };
 
 class JSButton : public JSWidget<SalInstanceButton, ::Button>
 {
 public:
-    JSButton(VclPtr<vcl::Window> aOwnedToplevel, ::Button* pButton, SalInstanceBuilder* pBuilder,
-             bool bTakeOwnership);
+    JSButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+             ::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+             std::string sTypeOfJSON);
 };
 
 class JSEntry : public JSWidget<SalInstanceEntry, ::Edit>
 {
 public:
-    JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
-            bool bTakeOwnership);
+    JSEntry(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::Edit* pEntry,
+            SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON);
     virtual void set_text(const OUString& rText) override;
 };
 
 class JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>
 {
 public:
-    JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder,
-              bool bTakeOwnership);
+    JSListBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+              ::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+              std::string sTypeOfJSON);
     virtual void insert(int pos, const OUString& rStr, const OUString* pId,
                         const OUString* pIconName, VirtualDevice* pImageSurface) override;
     virtual void remove(int pos) override;
@@ -172,8 +203,9 @@ public:
 class JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>
 {
 public:
-    JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
-               SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSComboBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+               ::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+               std::string sTypeOfJSON);
     virtual void insert(int pos, const OUString& rStr, const OUString* pId,
                         const OUString* pIconName, VirtualDevice* pImageSurface) override;
     virtual void remove(int pos) override;
@@ -184,8 +216,9 @@ public:
 class JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl>
 {
 public:
-    JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl,
-               SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSNotebook(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+               ::TabControl* pControl, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+               std::string sTypeOfJSON);
 
     virtual void set_current_page(int nPage) override;
 
@@ -199,8 +232,9 @@ public:
 class JSSpinButton : public JSWidget<SalInstanceSpinButton, ::FormattedField>
 {
 public:
-    JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin,
-                 SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSSpinButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                 ::FormattedField* pSpin, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+                 std::string sTypeOfJSON);
 
     virtual void set_value(int value) override;
 };
@@ -208,7 +242,8 @@ public:
 class JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender
 {
 public:
-    JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow,
+                    SalInstanceBuilder* pBuilder, bool bTakeOwnership);
 
     virtual void set_primary_text(const OUString& rText) override;
 
@@ -218,8 +253,9 @@ public:
 class JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox>
 {
 public:
-    JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox,
-                  SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSCheckButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                  ::CheckBox* pCheckBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+                  std::string sTypeOfJSON);
 
     virtual void set_active(bool active) override;
 };
@@ -227,9 +263,9 @@ public:
 class JSDrawingArea : public SalInstanceDrawingArea, public JSDialogSender
 {
 public:
-    JSDrawingArea(VclPtr<vcl::Window> aOwnedToplevel, VclDrawingArea* pDrawingArea,
-                  SalInstanceBuilder* pBuilder, const a11yref& rAlly,
-                  FactoryFunction pUITestFactoryFunction, void* pUserData);
+    JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                  VclDrawingArea* pDrawingArea, SalInstanceBuilder* pBuilder, const a11yref& rAlly,
+                  FactoryFunction pUITestFactoryFunction, void* pUserData, std::string sTypeOfJSON);
 
     virtual void queue_draw() override;
     virtual void queue_draw_area(int x, int y, int width, int height) override;
@@ -238,8 +274,9 @@ public:
 class JSToolbar : public JSWidget<SalInstanceToolbar, ::ToolBox>
 {
 public:
-    JSToolbar(VclPtr<vcl::Window> aOwnedToplevel, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder,
-              bool bTakeOwnership);
+    JSToolbar(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+              ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+              std::string sTypeOfJSON);
 
     virtual void signal_clicked(const OString& rIdent) override;
 };
@@ -247,8 +284,9 @@ public:
 class JSTextView : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit>
 {
 public:
-    JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView,
-               SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    JSTextView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+               ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+               std::string sTypeOfJSON);
     virtual void set_text(const OUString& rText) override;
 };
 
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index d18561d80e3b..88e2b9cc6eee 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -23,9 +23,12 @@
 #include <vcl/toolkit/vclmedit.hxx>
 #include <boost/property_tree/json_parser.hpp>
 
-JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow)
+JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow,
+                                       VclPtr<vcl::Window> aContentWindow, std::string sTypeOfJSON)
     : Idle("JSDialog notify")
-    , m_aWindow(aWindow)
+    , m_aNotifierWindow(aNotifierWindow)
+    , m_aContentWindow(aContentWindow)
+    , m_sTypeOfJSON(sTypeOfJSON)
     , m_LastNotificationMessage()
     , m_bForce(false)
 {
@@ -38,15 +41,16 @@ void JSDialogNotifyIdle::Invoke()
 {
     try
     {
-        if (!m_aWindow)
+        if (!m_aNotifierWindow)
             return;
 
-        const vcl::ILibreOfficeKitNotifier* pNotifier = m_aWindow->GetLOKNotifier();
+        const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier();
         if (pNotifier)
         {
             tools::JsonWriter aJsonWriter;
-            m_aWindow->DumpAsPropertyTree(aJsonWriter);
-            aJsonWriter.put("id", m_aWindow->GetLOKWindowId());
+            m_aContentWindow->DumpAsPropertyTree(aJsonWriter);
+            aJsonWriter.put("id", m_aNotifierWindow->GetLOKWindowId());
+            aJsonWriter.put("jsontype", m_sTypeOfJSON);
             if (m_bForce || !aJsonWriter.isDataEquals(m_LastNotificationMessage))
             {
                 m_bForce = false;
@@ -83,6 +87,8 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR
     : SalInstanceBuilder(extract_sal_widget(pParent), rUIRoot, rUIFile)
     , m_nWindowId(0)
     , m_aParentDialog(nullptr)
+    , m_aContentWindow(nullptr)
+    , m_sTypeOfJSON("dialog")
     , m_bHasTopLevelDialog(false)
     , m_bIsNotebookbar(false)
 {
@@ -96,6 +102,7 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR
     }
 }
 
+// used for notebookbar
 JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot,
                                      const OUString& rUIFile,
                                      const css::uno::Reference<css::frame::XFrame>& rFrame,
@@ -103,6 +110,8 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRo
     : SalInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame)
     , m_nWindowId(0)
     , m_aParentDialog(nullptr)
+    , m_aContentWindow(nullptr)
+    , m_sTypeOfJSON("notebookbar")
     , m_bHasTopLevelDialog(false)
     , m_bIsNotebookbar(false)
 {
@@ -121,6 +130,49 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRo
     }
 }
 
+// used for autofilter dropdown
+JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot,
+                                     const OUString& rUIFile)
+    : SalInstanceBuilder(pParent, rUIRoot, rUIFile)
+    , m_nWindowId(0)
+    , m_aParentDialog(nullptr)
+    , m_aContentWindow(nullptr)
+    , m_sTypeOfJSON("autofilter")
+    , m_bHasTopLevelDialog(false)
+    , m_bIsNotebookbar(false)
+{
+    vcl::Window* pRoot = m_xBuilder->get_widget_root();
+    m_aContentWindow = pParent;
+    if (pRoot && pRoot->GetParent())
+    {
+        m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
+        if (m_aParentDialog)
+            m_nWindowId = m_aParentDialog->GetLOKWindowId();
+        InsertWindowToMap(m_nWindowId);
+    }
+}
+
+JSInstanceBuilder* JSInstanceBuilder::CreateDialogBuilder(weld::Widget* pParent,
+                                                          const OUString& rUIRoot,
+                                                          const OUString& rUIFile)
+{
+    return new JSInstanceBuilder(pParent, rUIRoot, rUIFile);
+}
+
+JSInstanceBuilder* JSInstanceBuilder::CreateNotebookbarBuilder(
+    vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
+    const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId)
+{
+    return new JSInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame, nWindowId);
+}
+
+JSInstanceBuilder* JSInstanceBuilder::CreateAutofilterWindowBuilder(vcl::Window* pParent,
+                                                                    const OUString& rUIRoot,
+                                                                    const OUString& rUIFile)
+{
+    return new JSInstanceBuilder(pParent, rUIRoot, rUIFile);
+}
+
 JSInstanceBuilder::~JSInstanceBuilder()
 {
     if (m_nWindowId && (m_bHasTopLevelDialog || m_bIsNotebookbar))
@@ -167,6 +219,19 @@ void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget)
     }
 }
 
+VclPtr<vcl::Window>& JSInstanceBuilder::GetContentWindow()
+{
+    if (m_aContentWindow)
+        return m_aContentWindow;
+    else
+        return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog;
+}
+
+VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow()
+{
+    return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog;
+}
+
 std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id)
 {
     ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
@@ -174,8 +239,9 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id)
 
     InsertWindowToMap(m_nWindowId);
 
-    std::unique_ptr<weld::Dialog> pRet(
-        pDialog ? new JSDialog(m_aOwnedToplevel, pDialog, this, false) : nullptr);
+    std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel,
+                                                              pDialog, this, false, m_sTypeOfJSON)
+                                               : nullptr);
     if (pDialog)
     {
         assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
@@ -199,8 +265,8 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id)
 std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id)
 {
     ::FixedText* pLabel = m_xBuilder->get<FixedText>(id);
-    auto pWeldWidget = std::make_unique<JSLabel>(
-        m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, pLabel, this, false);
+    auto pWeldWidget = std::make_unique<JSLabel>(GetNotifierWindow(), GetContentWindow(), pLabel,
+                                                 this, false, m_sTypeOfJSON);
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -211,9 +277,8 @@ std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id)
 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>(m_bHasTopLevelDialog ? m_aOwnedToplevel
-                                                                                 : m_aParentDialog,
-                                                            pButton, this, false)
+    auto pWeldWidget = pButton ? std::make_unique<JSButton>(GetNotifierWindow(), GetContentWindow(),
+                                                            pButton, this, false, m_sTypeOfJSON)
                                : nullptr;
 
     if (pWeldWidget)
@@ -225,9 +290,8 @@ std::unique_ptr<weld::Button> JSInstanceBuilder::weld_button(const OString& id)
 std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id)
 {
     Edit* pEntry = m_xBuilder->get<Edit>(id);
-    auto pWeldWidget = pEntry ? std::make_unique<JSEntry>(m_bHasTopLevelDialog ? m_aOwnedToplevel
-                                                                               : m_aParentDialog,
-                                                          pEntry, this, false)
+    auto pWeldWidget = pEntry ? std::make_unique<JSEntry>(GetNotifierWindow(), GetContentWindow(),
+                                                          pEntry, this, false, m_sTypeOfJSON)
                               : nullptr;
 
     if (pWeldWidget)
@@ -244,16 +308,16 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString&
 
     if (pComboBox)
     {
-        pWeldWidget = std::make_unique<JSComboBox>(
-            m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, pComboBox, this, false);
+        pWeldWidget = std::make_unique<JSComboBox>(GetNotifierWindow(), GetContentWindow(),
+                                                   pComboBox, this, false, m_sTypeOfJSON);
     }
     else
     {
         ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
-        pWeldWidget = pListBox ? std::make_unique<JSListBox>(m_bHasTopLevelDialog ? m_aOwnedToplevel
-                                                                                  : m_aParentDialog,
-                                                             pListBox, this, false)
-                               : nullptr;
+        pWeldWidget = pListBox
+                          ? std::make_unique<JSListBox>(GetNotifierWindow(), GetContentWindow(),
+                                                        pListBox, this, false, m_sTypeOfJSON)
+                          : nullptr;
     }
 
     if (pWeldWidget)
@@ -265,10 +329,10 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString&
 std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& id)
 {
     TabControl* pNotebook = m_xBuilder->get<TabControl>(id);
-    auto pWeldWidget = pNotebook ? std::make_unique<JSNotebook>(
-                                       m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
-                                       pNotebook, this, false)
-                                 : nullptr;
+    auto pWeldWidget = pNotebook
+                           ? std::make_unique<JSNotebook>(GetNotifierWindow(), GetContentWindow(),
+                                                          pNotebook, this, false, m_sTypeOfJSON)
+                           : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -279,10 +343,10 @@ std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString&
 std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OString& id)
 {
     FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
-    auto pWeldWidget = pSpinButton ? std::make_unique<JSSpinButton>(
-                                         m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
-                                         pSpinButton, this, false)
-                                   : nullptr;
+    auto pWeldWidget = pSpinButton
+                           ? std::make_unique<JSSpinButton>(GetNotifierWindow(), GetContentWindow(),
+                                                            pSpinButton, this, false, m_sTypeOfJSON)
+                           : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -293,10 +357,10 @@ std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OStr
 std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const OString& id)
 {
     CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
-    auto pWeldWidget = pCheckButton ? std::make_unique<JSCheckButton>(
-                                          m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
-                                          pCheckButton, this, false)
-                                    : nullptr;
+    auto pWeldWidget
+        = pCheckButton ? std::make_unique<JSCheckButton>(GetNotifierWindow(), GetContentWindow(),
+                                                         pCheckButton, this, false, m_sTypeOfJSON)
+                       : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -310,8 +374,8 @@ JSInstanceBuilder::weld_drawing_area(const OString& id, const a11yref& rA11yImpl
 {
     VclDrawingArea* pArea = m_xBuilder->get<VclDrawingArea>(id);
     auto pWeldWidget = pArea ? std::make_unique<JSDrawingArea>(
-                                   m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, pArea,
-                                   this, rA11yImpl, pUITestFactoryFunction, pUserData)
+                                   GetNotifierWindow(), GetContentWindow(), pArea, this, rA11yImpl,
+                                   pUITestFactoryFunction, pUserData, m_sTypeOfJSON)
                              : nullptr;
 
     if (pWeldWidget)
@@ -323,10 +387,10 @@ JSInstanceBuilder::weld_drawing_area(const OString& id, const a11yref& rA11yImpl
 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>(
-                                      m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
-                                      pToolBox, this, false)
-                                : nullptr;
+    auto pWeldWidget = pToolBox
+                           ? std::make_unique<JSToolbar>(GetNotifierWindow(), GetContentWindow(),
+                                                         pToolBox, this, false, m_sTypeOfJSON)
+                           : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -337,10 +401,10 @@ std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OString& id
 std::unique_ptr<weld::TextView> JSInstanceBuilder::weld_text_view(const OString& id)
 {
     VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
-    auto pWeldWidget = pTextView ? std::make_unique<JSTextView>(
-                                       m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
-                                       pTextView, this, false)
-                                 : nullptr;
+    auto pWeldWidget = pTextView
+                           ? std::make_unique<JSTextView>(GetNotifierWindow(), GetContentWindow(),
+                                                          pTextView, this, false, m_sTypeOfJSON)
+                           : nullptr;
 
     if (pWeldWidget)
         RememberWidget(id, pWeldWidget.get());
@@ -364,16 +428,19 @@ weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen
         tools::JsonWriter aJsonWriter;
         xMessageDialog->DumpAsPropertyTree(aJsonWriter);
         aJsonWriter.put("id", xMessageDialog->GetLOKWindowId());
+        aJsonWriter.put("jsontype", "dialog");
         std::unique_ptr<char[], o3tl::free_delete> message(aJsonWriter.extractData());
         pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.get());
     }
 
-    return new JSMessageDialog(xMessageDialog, nullptr, true);
+    return new JSMessageDialog(xMessageDialog, xMessageDialog, nullptr, true);
 }
 
-JSDialog::JSDialog(VclPtr<vcl::Window> aOwnedToplevel, ::Dialog* pDialog,
-                   SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceDialog, ::Dialog>(aOwnedToplevel, pDialog, pBuilder, bTakeOwnership)
+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)
 {
 }
 
@@ -389,9 +456,11 @@ void JSDialog::undo_collapse()
     notifyDialogState();
 }
 
-JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel,
-                 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership)
+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)
 {
 }
 
@@ -401,15 +470,19 @@ void JSLabel::set_label(const OUString& rText)
     notifyDialogState();
 };
 
-JSButton::JSButton(VclPtr<vcl::Window> aOwnedToplevel, ::Button* pButton,
-                   SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceButton, ::Button>(aOwnedToplevel, pButton, pBuilder, bTakeOwnership)
+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)
 {
 }
 
-JSEntry::JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder,
-                 bool bTakeOwnership)
-    : JSWidget<SalInstanceEntry, ::Edit>(aOwnedToplevel, pEntry, 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)
 {
 }
 
@@ -419,10 +492,11 @@ void JSEntry::set_text(const OUString& rText)
     notifyDialogState();
 }
 
-JSListBox::JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox,
-                     SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(aOwnedToplevel, pListBox, pBuilder,
-                                                          bTakeOwnership)
+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)
 {
 }
 
@@ -445,10 +519,11 @@ void JSListBox::set_active(int pos)
     notifyDialogState();
 }
 
-JSComboBox::JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox,
-                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aOwnedToplevel, pComboBox, pBuilder,
-                                                        bTakeOwnership)
+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)
 {
 }
 
@@ -477,10 +552,11 @@ void JSComboBox::set_active(int pos)
     notifyDialogState();
 }
 
-JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl,
-                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceNotebook, ::TabControl>(aOwnedToplevel, pControl, pBuilder,
-                                                  bTakeOwnership)
+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)
 {
 }
 
@@ -518,10 +594,11 @@ void JSNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int
     notifyDialogState();
 }
 
-JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin,
-                           SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceSpinButton, ::FormattedField>(aOwnedToplevel, pSpin, pBuilder,
-                                                        bTakeOwnership)
+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)
 {
 }
 
@@ -531,10 +608,10 @@ void JSSpinButton::set_value(int value)
     notifyDialogState();
 }
 
-JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder,
-                                 bool bTakeOwnership)
+JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow,
+                                 SalInstanceBuilder* pBuilder, bool bTakeOwnership)
     : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership)
-    , JSDialogSender(m_xMessageDialog)
+    , JSDialogSender(m_xMessageDialog, aContentWindow, "dialog")
 {
 }
 
@@ -550,10 +627,12 @@ void JSMessageDialog::set_secondary_text(const OUString& rText)
     notifyDialogState();
 }
 
-JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox,
-                             SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceCheckButton, ::CheckBox>(aOwnedToplevel, pCheckBox, pBuilder,
-                                                   bTakeOwnership)
+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)
 {
 }
 
@@ -563,12 +642,14 @@ void JSCheckButton::set_active(bool active)
     notifyDialogState();
 }
 
-JSDrawingArea::JSDrawingArea(VclPtr<vcl::Window> aOwnedToplevel, VclDrawingArea* pDrawingArea,
+JSDrawingArea::JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow,
+                             VclPtr<vcl::Window> aContentWindow, VclDrawingArea* pDrawingArea,
                              SalInstanceBuilder* pBuilder, const a11yref& rAlly,
-                             FactoryFunction pUITestFactoryFunction, void* pUserData)
+                             FactoryFunction pUITestFactoryFunction, void* pUserData,
+                             std::string sTypeOfJSON)
     : SalInstanceDrawingArea(pDrawingArea, pBuilder, rAlly, pUITestFactoryFunction, pUserData,
                              false)
-    , JSDialogSender(aOwnedToplevel)
+    , JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON)
 {
 }
 
@@ -584,9 +665,11 @@ void JSDrawingArea::queue_draw_area(int x, int y, int width, int height)
     notifyDialogState();
 }
 
-JSToolbar::JSToolbar(VclPtr<vcl::Window> aOwnedToplevel, ::ToolBox* pToolbox,
-                     SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceToolbar, ::ToolBox>(aOwnedToplevel, pToolbox, pBuilder, bTakeOwnership)
+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)
 {
 }
 
@@ -596,10 +679,11 @@ void JSToolbar::signal_clicked(const OString& rIdent)
     notifyDialogState();
 }
 
-JSTextView::JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView,
-                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
-    : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aOwnedToplevel, pTextView, pBuilder,
-                                                        bTakeOwnership)
+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)
 {
 }
 
diff --git a/vcl/source/control/WeldedTabbedNotebookbar.cxx b/vcl/source/control/WeldedTabbedNotebookbar.cxx
index e0089c604271..eb40389733f7 100644
--- a/vcl/source/control/WeldedTabbedNotebookbar.cxx
+++ b/vcl/source/control/WeldedTabbedNotebookbar.cxx
@@ -14,8 +14,8 @@
 WeldedTabbedNotebookbar::WeldedTabbedNotebookbar(
     const VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath,
     const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId)
-    : m_xBuilder(new JSInstanceBuilder(pContainerWindow, AllSettings::GetUIRootDir(), rUIFilePath,
-                                       rFrame, nWindowId))
+    : m_xBuilder(JSInstanceBuilder::CreateNotebookbarBuilder(
+          pContainerWindow, AllSettings::GetUIRootDir(), rUIFilePath, rFrame, nWindowId))
 {
     m_xContainer = m_xBuilder->weld_container("NotebookBar");
     m_xNotebook = m_xBuilder->weld_notebook("ContextContainer");
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 9e322c3f1935..6e752daa88a4 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -179,18 +179,24 @@ weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString
     }
 
     if (bUseJSBuilder)
-        return new JSInstanceBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile);
+        return JSInstanceBuilder::CreateDialogBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile);
     else
         return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile);
 }
 
 weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId)
 {
+    // Notebookbar sub controls
     if (comphelper::LibreOfficeKit::isActive()
         && (rUIFile == "svx/ui/stylespreview.ui"
         || rUIFile == "modules/scalc/ui/numberbox.ui"))
     {
-        return new JSInstanceBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>(), nLOKWindowId);
+        return JSInstanceBuilder::CreateNotebookbarBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>(), nLOKWindowId);
+    }
+    else if (comphelper::LibreOfficeKit::isActive()
+        && (rUIFile == "modules/scalc/ui/filterdropdown.ui"))
+    {
+        return JSInstanceBuilder::CreateAutofilterWindowBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile);
     }
 
     return ImplGetSVData()->mpDefInst->CreateInterimBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, bAllowCycleFocusOut, nLOKWindowId);


More information about the Libreoffice-commits mailing list