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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 3 10:14:28 UTC 2020


 desktop/source/lib/init.cxx                    |    4 ++++
 include/vcl/WeldedTabbedNotebookbar.hxx        |    3 ++-
 include/vcl/jsdialog/builder.hxx               |    2 +-
 sfx2/source/notebookbar/SfxNotebookBar.cxx     |    4 +++-
 vcl/inc/jsdialog/jsdialogbuilder.hxx           |   12 +++++++-----
 vcl/jsdialog/jsdialogbuilder.cxx               |   16 +++++++++-------
 vcl/source/control/WeldedTabbedNotebookbar.cxx |    4 ++--
 7 files changed, 28 insertions(+), 17 deletions(-)

New commits:
commit 9eaaf3b7e1d55d064c0518cbbb7bb724e219e10a
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jun 23 12:49:17 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jul 3 12:13:39 2020 +0200

    jsdialog: get widget depending on viewshell
    
    Notebookbar always gets window id 0 what causes
    conflict in map and some widgets doesn't work
    
    Change-Id: I15b4e83d385e83bcf898148a871ddf540257cc81
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97099
    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/+/97816
    Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2f14c8ab2518..6e25e8c71b7a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3623,6 +3623,10 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
         {
             OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US);
             weld::Widget* pWidget = jsdialog::FindWeldWidgetsMap(nWindowId, sControlId);
+            if (!pWidget && nWindowId == 0)
+            {
+                pWidget = jsdialog::FindWeldWidgetsMap(reinterpret_cast<sal_uInt64>(SfxViewShell::Current()), sControlId);
+            }
 
             bIsWeldedDialog = pWidget != nullptr;
             bool bContinueWithLOKWindow = false;
diff --git a/include/vcl/WeldedTabbedNotebookbar.hxx b/include/vcl/WeldedTabbedNotebookbar.hxx
index b6d29e846ac1..d0549d25d019 100644
--- a/include/vcl/WeldedTabbedNotebookbar.hxx
+++ b/include/vcl/WeldedTabbedNotebookbar.hxx
@@ -26,7 +26,8 @@ class VCL_DLLPUBLIC WeldedTabbedNotebookbar
 
 public:
     WeldedTabbedNotebookbar(VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath,
-                            const css::uno::Reference<css::frame::XFrame>& rFrame);
+                            const css::uno::Reference<css::frame::XFrame>& rFrame,
+                            sal_uInt64 nWindowId);
 };
 
 #endif // INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX
diff --git a/include/vcl/jsdialog/builder.hxx b/include/vcl/jsdialog/builder.hxx
index ac4c8925cb87..b054b1d00a08 100644
--- a/include/vcl/jsdialog/builder.hxx
+++ b/include/vcl/jsdialog/builder.hxx
@@ -15,7 +15,7 @@
 
 namespace jsdialog
 {
-VCL_DLLPUBLIC weld::Widget* FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, const OString& rWidget);
+VCL_DLLPUBLIC weld::Widget* FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index ad8d22dc9f77..ab2bc145f7de 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -388,10 +388,12 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
             bool hasWeldedWrapper = m_pNotebookBarWeldedWrapper.find(pViewShell) != m_pNotebookBarWeldedWrapper.end();
             if ((!hasWeldedWrapper || bReloadNotebookbar) && pNotebookBar->IsWelded())
             {
+                sal_uInt64 nWindowId = reinterpret_cast<sal_uInt64>(pViewShell);
                 m_pNotebookBarWeldedWrapper.emplace(std::make_pair(pViewShell,
                         new WeldedTabbedNotebookbar(pNotebookBar->GetMainContainer(),
                                                     pNotebookBar->GetUIFilePath(),
-                                                    xFrame)));
+                                                    xFrame,
+                                                    nWindowId)));
                 pNotebookBar->SetDisposeCallback(LINK(nullptr, SfxNotebookBar, VclDisposeHdl), pViewShell);
             }
 
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 0e907fe03a59..ba4641171a2c 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -49,22 +49,24 @@ public:
 
 class JSInstanceBuilder : public SalInstanceBuilder
 {
-    vcl::LOKWindowId m_nWindowId;
+    sal_uInt64 m_nWindowId;
     /// used in case of tab pages where dialog is not a direct top level
     VclPtr<vcl::Window> m_aParentDialog;
     bool m_bHasTopLevelDialog;
 
-    friend VCL_DLLPUBLIC weld::Widget* jsdialog::FindWeldWidgetsMap(vcl::LOKWindowId nWindowId,
+    friend VCL_DLLPUBLIC weld::Widget* jsdialog::FindWeldWidgetsMap(sal_uInt64 nWindowId,
                                                                     const OString& rWidget);
 
-    static std::map<vcl::LOKWindowId, WidgetMap>& GetLOKWeldWidgetsMap();
-    static void InsertWindowToMap(int nWindowId);
+    static std::map<sal_uInt64, WidgetMap>& GetLOKWeldWidgetsMap();
+    static void InsertWindowToMap(sal_uInt64 nWindowId);
     void RememberWidget(const OString& id, weld::Widget* pWidget);
 
 public:
     JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
+    /// 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);
+                      const css::uno::Reference<css::frame::XFrame>& rFrame,
+                      sal_uInt64 nWindowId = 0);
     virtual ~JSInstanceBuilder() override;
     virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id,
                                                       bool bTakeOwnership = true) override;
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 1932bcbd7d02..767a465c5f3f 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -85,7 +85,8 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR
 
 JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot,
                                      const OUString& rUIFile,
-                                     const css::uno::Reference<css::frame::XFrame>& rFrame)
+                                     const css::uno::Reference<css::frame::XFrame>& rFrame,
+                                     sal_uInt64 nWindowId)
     : SalInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame)
     , m_nWindowId(0)
     , m_aParentDialog(nullptr)
@@ -97,23 +98,25 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRo
         m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
         if (m_aParentDialog)
             m_nWindowId = m_aParentDialog->GetLOKWindowId();
+        if (!m_nWindowId && nWindowId)
+            m_nWindowId = nWindowId;
         InsertWindowToMap(m_nWindowId);
     }
 }
 
 JSInstanceBuilder::~JSInstanceBuilder() { GetLOKWeldWidgetsMap().erase(m_nWindowId); }
 
-std::map<vcl::LOKWindowId, WidgetMap>& JSInstanceBuilder::GetLOKWeldWidgetsMap()
+std::map<sal_uInt64, WidgetMap>& JSInstanceBuilder::GetLOKWeldWidgetsMap()
 {
     // Map to remember the LOKWindowId <-> weld widgets binding.
-    static std::map<vcl::LOKWindowId, WidgetMap> s_aLOKWeldBuildersMap;
+    static std::map<sal_uInt64, WidgetMap> s_aLOKWeldBuildersMap;
 
     return s_aLOKWeldBuildersMap;
 }
 
 namespace jsdialog
 {
-weld::Widget* FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, const OString& rWidget)
+weld::Widget* FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget)
 {
     const auto it = JSInstanceBuilder::GetLOKWeldWidgetsMap().find(nWindowId);
 
@@ -128,13 +131,12 @@ weld::Widget* FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, const OString& rWid
 }
 }
 
-void JSInstanceBuilder::InsertWindowToMap(int nWindowId)
+void JSInstanceBuilder::InsertWindowToMap(sal_uInt64 nWindowId)
 {
     WidgetMap map;
     auto it = GetLOKWeldWidgetsMap().find(nWindowId);
     if (it == GetLOKWeldWidgetsMap().end())
-        GetLOKWeldWidgetsMap().insert(
-            std::map<vcl::LOKWindowId, WidgetMap>::value_type(nWindowId, map));
+        GetLOKWeldWidgetsMap().insert(std::map<sal_uInt64, WidgetMap>::value_type(nWindowId, map));
 }
 
 void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget)
diff --git a/vcl/source/control/WeldedTabbedNotebookbar.cxx b/vcl/source/control/WeldedTabbedNotebookbar.cxx
index 9b3c2a849808..2ecab57b267e 100644
--- a/vcl/source/control/WeldedTabbedNotebookbar.cxx
+++ b/vcl/source/control/WeldedTabbedNotebookbar.cxx
@@ -13,9 +13,9 @@
 
 WeldedTabbedNotebookbar::WeldedTabbedNotebookbar(
     VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath,
-    const css::uno::Reference<css::frame::XFrame>& rFrame)
+    const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId)
     : m_xBuilder(new JSInstanceBuilder(pContainerWindow, VclBuilderContainer::getUIRootDir(),
-                                       rUIFilePath, rFrame))
+                                       rUIFilePath, rFrame, nWindowId))
 {
     m_xContainer = m_xBuilder->weld_container("NotebookBar");
     m_xNotebook = m_xBuilder->weld_notebook("ContextContainer");


More information about the Libreoffice-commits mailing list