[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - compilerplugins/clang include/sfx2 include/vcl sfx2/source vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 24 09:37:16 UTC 2020
compilerplugins/clang/badstatics.cxx | 1 +
include/sfx2/notebookbar/SfxNotebookBar.hxx | 7 +++++--
include/vcl/notebookbar.hxx | 6 ++++--
sfx2/source/notebookbar/SfxNotebookBar.cxx | 24 +++++++++++++++---------
vcl/source/control/notebookbar.cxx | 12 ++++++++++--
5 files changed, 35 insertions(+), 15 deletions(-)
New commits:
commit 0c61db374f90c78f5cb6984fae643437bc77541a
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Jun 18 12:15:13 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Jun 24 11:36:44 2020 +0200
notebookbar: allow to create multiple instances for online
Change-Id: Ic8a3d07ec6ec5a5d6d56a3958e91d3074ce1493e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96936
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 7c595f77207a..36a59e95d695 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -206,6 +206,7 @@ public:
.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 == "m_pNotebookBarWeldedWrapper" // LOK only, warning about map's key, no VCL cleanup performed
|| 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/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index 4fbda295cace..53d028bcd9b8 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -12,12 +12,14 @@
#include <sfx2/dllapi.h>
#include <rtl/ustring.hxx>
+#include <map>
namespace com::sun::star::frame { class XFrame; }
namespace com::sun::star::uno { template <typename > class Reference; }
class SfxBindings;
class SfxViewFrame;
+class SfxViewShell;
class SystemWindow;
class WeldedTabbedNotebookbar;
@@ -60,9 +62,10 @@ public:
private:
static bool m_bLock;
static bool m_bHide;
- static std::unique_ptr<WeldedTabbedNotebookbar> m_pNotebookBarWeldedWrapper;
- DECL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const void*, void);
+ static std::map<const SfxViewShell*, std::shared_ptr<WeldedTabbedNotebookbar>> m_pNotebookBarWeldedWrapper;
+
+ DECL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, void);
};
} // namespace sfx2
diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx
index 3b4fa740e779..b4a75e3325dc 100644
--- a/include/vcl/notebookbar.hxx
+++ b/include/vcl/notebookbar.hxx
@@ -21,6 +21,7 @@ namespace com { namespace sun { namespace star { namespace ui { class XContextCh
class NotebookbarContextControl;
class SystemWindow;
+class SfxViewShell;
/// This implements Widget Layout-based notebook-like menu bar.
class VCL_DLLPUBLIC NotebookBar final : public Control, public VclBuilderContainer
@@ -50,7 +51,7 @@ public:
bool IsWelded() { return m_bIsWelded; }
VclPtr<vcl::Window>& GetMainContainer() { return m_xVclContentArea; }
OUString GetUIFilePath() { return m_sUIXMLDescription; }
- void SetDisposeCallback(const Link<const void*, void> rDisposeCallback);
+ void SetDisposeCallback(const Link<const SfxViewShell*, void> rDisposeCallback, const SfxViewShell* pViewShell);
private:
VclPtr<SystemWindow> m_pSystemWindow;
@@ -58,11 +59,12 @@ private:
std::set<css::uno::Reference<css::frame::XController>> m_alisteningControllers;
std::vector<NotebookbarContextControl*> m_pContextContainers;
css::uno::Reference<css::frame::XFrame> mxFrame;
+ const SfxViewShell* m_pViewShell;
VclPtr<vcl::Window> m_xVclContentArea;
bool m_bIsWelded;
OUString m_sUIXMLDescription;
- Link<const void*, void> m_rDisposeLink;
+ Link<const SfxViewShell*, void> m_rDisposeLink;
AllSettings DefaultSettings;
AllSettings PersonaSettings;
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 29f47dbf9ce6..1d01cabcb968 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -11,6 +11,7 @@
#include <sfx2/viewsh.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
+#include <sfx2/viewsh.hxx>
#include <unotools/viewoptions.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <vcl/notebookbar.hxx>
@@ -18,6 +19,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/sfxsids.hrc>
#include <comphelper/processfactory.hxx>
+#include <comphelper/lok.hxx>
#include <com/sun/star/frame/UnknownModuleException.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
@@ -46,7 +48,7 @@ static const char MERGE_NOTEBOOKBAR_IMAGEID[] = "ImageIdentifier";
bool SfxNotebookBar::m_bLock = false;
bool SfxNotebookBar::m_bHide = false;
-std::unique_ptr<WeldedTabbedNotebookbar> SfxNotebookBar::m_pNotebookBarWeldedWrapper;
+std::map<const SfxViewShell*, std::shared_ptr<WeldedTabbedNotebookbar>> SfxNotebookBar::m_pNotebookBarWeldedWrapper;
static void NotebookbarAddonValues(
std::vector<Image>& aImageValues,
@@ -366,7 +368,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
bool bChangedFile = sNewFile != sCurrentFile;
if ((!sFile.isEmpty() && bChangedFile) || !pNotebookBar || !pNotebookBar->IsVisible()
- || bReloadNotebookbar)
+ || bReloadNotebookbar || comphelper::LibreOfficeKit::isActive())
{
RemoveListeners(pSysWindow);
@@ -385,12 +387,16 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
pNotebookBar = pSysWindow->GetNotebookBar();
pNotebookBar->Show();
- if ((!m_pNotebookBarWeldedWrapper || bReloadNotebookbar) && pNotebookBar->IsWelded())
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+
+ bool hasWeldedWrapper = m_pNotebookBarWeldedWrapper.find(pViewShell) != m_pNotebookBarWeldedWrapper.end();
+ if ((!hasWeldedWrapper || bReloadNotebookbar) && pNotebookBar->IsWelded())
{
- m_pNotebookBarWeldedWrapper.reset(new WeldedTabbedNotebookbar(pNotebookBar->GetMainContainer(),
- pNotebookBar->GetUIFilePath(),
- xFrame));
- pNotebookBar->SetDisposeCallback(LINK(nullptr, SfxNotebookBar, VclDisposeHdl));
+ m_pNotebookBarWeldedWrapper.emplace(std::make_pair(pViewShell,
+ new WeldedTabbedNotebookbar(pNotebookBar->GetMainContainer(),
+ pNotebookBar->GetUIFilePath(),
+ xFrame)));
+ pNotebookBar->SetDisposeCallback(LINK(nullptr, SfxNotebookBar, VclDisposeHdl), pViewShell);
}
pNotebookBar->GetParent()->Resize();
@@ -560,9 +566,9 @@ void SfxNotebookBar::ReloadNotebookBar(const OUString& sUIPath)
}
}
-IMPL_STATIC_LINK_NOARG(SfxNotebookBar, VclDisposeHdl, const void*, void)
+IMPL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, pViewShell, void)
{
- m_pNotebookBarWeldedWrapper.reset();
+ m_pNotebookBarWeldedWrapper.erase(pViewShell);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx
index c954c7d3b558..78e99e00c660 100644
--- a/vcl/source/control/notebookbar.cxx
+++ b/vcl/source/control/notebookbar.cxx
@@ -56,6 +56,7 @@ NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rU
const NotebookBarAddonsItem& aNotebookBarAddonsItem)
: Control(pParent)
, m_pEventListener(new NotebookBarContextChangeEventListener(this))
+ , m_pViewShell(nullptr)
, m_bIsWelded(false)
, m_sUIXMLDescription(rUIXMLDescription)
{
@@ -105,9 +106,10 @@ NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rU
UpdateBackground();
}
-void NotebookBar::SetDisposeCallback(const Link<const void*, void> rDisposeCallback)
+void NotebookBar::SetDisposeCallback(const Link<const SfxViewShell*, void> rDisposeCallback, const SfxViewShell* pViewShell)
{
m_rDisposeLink = rDisposeCallback;
+ m_pViewShell = pViewShell;
}
NotebookBar::~NotebookBar()
@@ -123,7 +125,7 @@ void NotebookBar::dispose()
m_pSystemWindow.clear();
if (m_rDisposeLink.IsSet())
- m_rDisposeLink.Call(nullptr);
+ m_rDisposeLink.Call(m_pViewShell);
if (m_bIsWelded)
m_xVclContentArea.disposeAndClear();
@@ -224,6 +226,9 @@ void SAL_CALL NotebookBarContextChangeEventListener::notifyContextChangeEvent(co
void NotebookBar::ControlListenerForCurrentController(bool bListen)
{
+ if (comphelper::LibreOfficeKit::isActive())
+ return;
+
auto xController = mxFrame->getController();
if(bListen)
{
@@ -251,6 +256,9 @@ void NotebookBar::ControlListenerForCurrentController(bool bListen)
void NotebookBar::StopListeningAllControllers()
{
+ if (comphelper::LibreOfficeKit::isActive())
+ return;
+
auto xMultiplexer(
css::ui::ContextChangeEventMultiplexer::get(comphelper::getProcessComponentContext()));
xMultiplexer->removeAllContextChangeEventListeners(m_pEventListener);
More information about the Libreoffice-commits
mailing list