[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/source include/sfx2 include/vcl sfx2/source vcl/jsdialog
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 25 10:53:22 UTC 2020
desktop/source/lib/init.cxx | 4 ++++
include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx | 4 ++--
include/vcl/jsdialog/jsdialogbuilder.hxx | 13 ++++++++-----
sfx2/source/notebookbar/SfxNotebookBar.cxx | 4 +++-
sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx | 4 ++--
vcl/jsdialog/jsdialogbuilder.cxx | 17 +++++++++--------
6 files changed, 28 insertions(+), 18 deletions(-)
New commits:
commit e9123adc14068b57943da087f377a5c60e82c9c7
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: Thu Jun 25 12:52:50 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>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a0767ad4c301..f5631188a841 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3604,6 +3604,10 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
{
OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US);
weld::Widget* pWidget = JSInstanceBuilder::FindWeldWidgetsMap(nWindowId, sControlId);
+ if (!pWidget && nWindowId == 0)
+ {
+ pWidget = JSInstanceBuilder::FindWeldWidgetsMap(reinterpret_cast<sal_uInt64>(SfxViewShell::Current()), sControlId);
+ }
bIsWeldedDialog = pWidget != nullptr;
bool bContinueWithLOKWindow = false;
diff --git a/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx b/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx
index d709fc64fcf1..b5ae5dcfb517 100644
--- a/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx
+++ b/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx
@@ -13,7 +13,6 @@
#include <sfx2/dllapi.h>
#include <rtl/ustring.hxx>
#include <vcl/weld.hxx>
-#include <sfx2/weldutils.hxx>
#include <com/sun/star/frame/XFrame.hpp>
/** Tabbed implementation of NotebookBar for Writer
@@ -27,7 +26,8 @@ class SFX2_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/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index 380226e43937..8ca5a3919093 100644
--- a/include/vcl/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -21,6 +21,7 @@
#include <vcl/fmtfield.hxx>
class ToolBox;
+class SfxViewShell;
typedef std::map<OString, weld::Widget*> WidgetMap;
@@ -50,19 +51,21 @@ public:
class VCL_DLLPUBLIC 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;
- 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;
@@ -91,7 +94,7 @@ public:
VclMessageType eMessageType,
VclButtonsType eButtonType,
const OUString& rPrimaryMessage);
- static weld::Widget* FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, const OString& rWidget);
+ static weld::Widget* FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget);
};
template <class BaseInstanceClass, class VclClass>
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 1d01cabcb968..1e33810e552d 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -392,10 +392,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/sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx b/sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx
index f5bb4ee99a6e..baa4e598a554 100644
--- a/sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx
+++ b/sfx2/source/notebookbar/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");
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 5a972da6c9ab..83670466ef31 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -77,7 +77,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)
@@ -89,22 +90,23 @@ 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;
}
-weld::Widget* JSInstanceBuilder::FindWeldWidgetsMap(vcl::LOKWindowId nWindowId,
- const OString& rWidget)
+weld::Widget* JSInstanceBuilder::FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget)
{
const auto it = GetLOKWeldWidgetsMap().find(nWindowId);
@@ -118,13 +120,12 @@ weld::Widget* JSInstanceBuilder::FindWeldWidgetsMap(vcl::LOKWindowId nWindowId,
return nullptr;
}
-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)
More information about the Libreoffice-commits
mailing list