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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 19 09:17:22 UTC 2020


 compilerplugins/clang/badstatics.cxx     |    1 +
 include/vcl/jsdialog/jsdialogbuilder.hxx |   10 ++++++++--
 include/vcl/salvtables.hxx               |    2 +-
 vcl/inc/pch/precompiled_vcl.hxx          |    2 +-
 vcl/jsdialog/jsdialogbuilder.cxx         |   31 ++++++++++++++++++++++++++++++-
 vcl/source/app/salvtables.cxx            |    2 +-
 vcl/source/window/builder.cxx            |    2 +-
 7 files changed, 43 insertions(+), 7 deletions(-)

New commits:
commit 6bbc740b72f1629c82440b3b4f09849d3d49c01a
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Mar 5 12:18:38 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jun 19 11:16:48 2020 +0200

    jsdialog: Remember builder connected with LOK window id
    
    Change-Id: I9e38fe570b2296341c1694fe8128da30ba209494
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94184
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94616
    Tested-by: Jenkins

diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index e2a48f3462cc..0e9e6b36be54 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -207,6 +207,7 @@ public:
                 || (loplugin::DeclCheck(pVarDecl).Var("maThreadSpecific")
                     .Class("ScDocument").GlobalNamespace()) // not owning
                 || name == "s_aLOKWindowsMap" // LOK only, guarded by assert, and LOK never tries to perform a VCL cleanup
+                || name == "s_aLOKWeldBuildersMap" // LOK only, similar case as above
                 || name == "gStaticManager" // vcl/source/graphic/Manager.cxx - stores non-owning pointers
                 || name == "aThreadedInterpreterPool"    // ScInterpreterContext(Pool), not owning
                 || name == "aNonThreadedInterpreterPool" // ScInterpreterContext(Pool), not owning
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
similarity index 93%
rename from vcl/inc/jsdialog/jsdialogbuilder.hxx
rename to include/vcl/jsdialog/jsdialogbuilder.hxx
index d01521924170..0efd6c0d36ea 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -6,7 +6,7 @@
 #include <vcl/sysdata.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/builder.hxx>
-#include <salvtables.hxx>
+#include <vcl/salvtables.hxx>
 #include <vcl/toolkit/combobox.hxx>
 #include <vcl/button.hxx>
 
@@ -25,8 +25,11 @@ public:
 
 class VCL_DLLPUBLIC JSInstanceBuilder : public SalInstanceBuilder
 {
+    vcl::LOKWindowId m_nWindowId;
+
 public:
     JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
+    virtual ~JSInstanceBuilder() override;
     virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id,
                                                       bool bTakeOwnership = true) override;
     virtual std::unique_ptr<weld::Label> weld_label(const OString& id,
@@ -39,10 +42,13 @@ public:
                                                            bool bTakeOwnership = false) override;
     virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id,
                                                           bool bTakeOwnership = false) override;
+
+    static std::map<vcl::LOKWindowId, JSInstanceBuilder*>& GetLOKWeldBuilderMap();
+    static JSInstanceBuilder* FindLOKWeldBuilder(vcl::LOKWindowId nWindowId);
 };
 
 template <class BaseInstanceClass, class VclClass>
-class JSWidget : public BaseInstanceClass, public JSDialogSender
+class VCL_DLLPUBLIC JSWidget : public BaseInstanceClass, public JSDialogSender
 {
 public:
     JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder,
diff --git a/vcl/inc/salvtables.hxx b/include/vcl/salvtables.hxx
similarity index 99%
rename from vcl/inc/salvtables.hxx
rename to include/vcl/salvtables.hxx
index a71c31941d51..87d387f43257 100644
--- a/vcl/inc/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -22,7 +22,7 @@
 #include <vcl/toolkit/combobox.hxx>
 #include <vcl/tabctrl.hxx>
 #include <vcl/layout.hxx>
-#include "messagedialog.hxx"
+#include <messagedialog.hxx>
 
 class SalInstanceBuilder : public weld::Builder
 {
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index 2e94519a4aeb..db0a1d307c02 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -261,7 +261,7 @@
 #include <saltimer.hxx>
 #include <salusereventlist.hxx>
 #include <salvd.hxx>
-#include <salvtables.hxx>
+#include <vcl/salvtables.hxx>
 #include <svdata.hxx>
 #include <vcl/BitmapFilter.hxx>
 #include <vcl/BitmapTools.hxx>
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 759007ce46d1..938cf471cc76 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1,4 +1,4 @@
-#include <jsdialog/jsdialogbuilder.hxx>
+#include <vcl/jsdialog/jsdialogbuilder.hxx>
 #include <sal/log.hxx>
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/lok.hxx>
@@ -29,12 +29,41 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR
                              ? dynamic_cast<SalInstanceWidget*>(pParent)->getWidget()
                              : nullptr,
                          rUIRoot, rUIFile)
+    , m_nWindowId(0)
 {
 }
 
+JSInstanceBuilder::~JSInstanceBuilder()
+{
+    if (m_nWindowId)
+        GetLOKWeldBuilderMap().erase(m_nWindowId);
+}
+
+std::map<vcl::LOKWindowId, JSInstanceBuilder*>& JSInstanceBuilder::GetLOKWeldBuilderMap()
+{
+    // Map to remember the LOKWindowId <-> Builder binding.
+    static std::map<vcl::LOKWindowId, JSInstanceBuilder*> s_aLOKWeldBuildersMap;
+
+    return s_aLOKWeldBuildersMap;
+}
+
+JSInstanceBuilder* JSInstanceBuilder::FindLOKWeldBuilder(vcl::LOKWindowId nWindowId)
+{
+    const auto it = GetLOKWeldBuilderMap().find(nWindowId);
+    if (it != GetLOKWeldBuilderMap().end())
+        return it->second;
+
+    return nullptr;
+}
+
 std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, bool bTakeOwnership)
 {
     ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
+    m_nWindowId = pDialog->GetLOKWindowId();
+
+    GetLOKWeldBuilderMap().insert(
+        std::map<vcl::LOKWindowId, JSInstanceBuilder*>::value_type(m_nWindowId, this));
+
     std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false)
                                                : nullptr);
     if (bTakeOwnership && pDialog)
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 18a7bcd246d3..1759a1e83860 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -71,7 +71,7 @@
 #include <vcl/virdev.hxx>
 #include <bitmaps.hlst>
 #include <wizdlg.hxx>
-#include <salvtables.hxx>
+#include <vcl/salvtables.hxx>
 
 #include <boost/property_tree/ptree.hpp>
 
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 368b771068f3..76e287ecd240 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -68,7 +68,7 @@
 #include <tools/diagnose_ex.h>
 #include <wizdlg.hxx>
 #include <tools/svlibrary.h>
-#include <jsdialog/jsdialogbuilder.hxx>
+#include <vcl/jsdialog/jsdialogbuilder.hxx>
 
 #if defined(DISABLE_DYNLOADING) || defined(LINUX)
 #include <dlfcn.h>


More information about the Libreoffice-commits mailing list