diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-06-23 12:49:17 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-07-03 12:13:39 +0200 |
commit | 9eaaf3b7e1d55d064c0518cbbb7bb724e219e10a (patch) | |
tree | 89f24ef15a4c0cf3e3707b2f305eb01d7454c60e /vcl | |
parent | 645021ad49628319423ad29d866d7adb3aee9d97 (diff) |
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@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97816
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 12 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 16 | ||||
-rw-r--r-- | vcl/source/control/WeldedTabbedNotebookbar.cxx | 4 |
3 files changed, 18 insertions, 14 deletions
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"); |