[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang desktop/source include/sfx2 include/vcl sfx2/source vcl/inc vcl/jsdialog vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 3 07:51:23 UTC 2020
compilerplugins/clang/badstatics.cxx | 1 +
desktop/source/lib/init.cxx | 13 +++++++++++++
include/sfx2/notebookbar/SfxNotebookBar.hxx | 7 +++++--
include/vcl/notebookbar.hxx | 6 ++++--
include/vcl/weld.hxx | 2 +-
sfx2/source/notebookbar/SfxNotebookBar.cxx | 23 ++++++++++++++---------
vcl/inc/jsdialog/jsdialogbuilder.hxx | 12 ++++++++++++
vcl/jsdialog/jsdialogbuilder.cxx | 28 ++++++++++++++++++++++++++++
vcl/source/control/notebookbar.cxx | 12 ++++++++++--
9 files changed, 88 insertions(+), 16 deletions(-)
New commits:
commit e2b50a956cd34179d4f1e7f87834a94188011843
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jun 16 14:07:32 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jul 3 09:50:41 2020 +0200
jsdialog: weld toolbar
Change-Id: If105d6716fc43f471f63f4eb60fa85498cb3dcc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96934
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/+/97789
Tested-by: Jenkins
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 792b6f8f5419..1ced81cb6ea2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3716,6 +3716,19 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
bContinueWithLOKWindow = true;
}
}
+ else if (sControlType == "toolbox")
+ {
+ auto pToolbar = dynamic_cast<weld::Toolbar*>(pWidget);
+ if (pToolbar)
+ {
+ if (sAction == "click")
+ {
+ pToolbar->signal_clicked(OUStringToOString(aMap["data"], RTL_TEXTENCODING_ASCII_US));
+ }
+ else
+ bContinueWithLOKWindow = true;
+ }
+ }
else
{
bContinueWithLOKWindow = true;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 8f2008598b80..cf4abaf5011d 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -2187,7 +2187,6 @@ protected:
Link<const OString&, void> m_aClickHdl;
Link<const OString&, void> m_aToggleMenuHdl;
- void signal_clicked(const OString& rIdent) { m_aClickHdl.Call(rIdent); }
void signal_toggle_menu(const OString& rIdent) { m_aToggleMenuHdl.Call(rIdent); }
public:
@@ -2236,6 +2235,7 @@ public:
void connect_clicked(const Link<const OString&, void>& rLink) { m_aClickHdl = rLink; }
void connect_menu_toggled(const Link<const OString&, void>& rLink) { m_aToggleMenuHdl = rLink; }
+ virtual void signal_clicked(const OString& rIdent) { m_aClickHdl.Call(rIdent); }
};
class VCL_DLLPUBLIC SizeGroup
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index f68853d34037..0e907fe03a59 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -19,6 +19,7 @@
#include <vcl/button.hxx>
#include <vcl/fmtfield.hxx>
+class ToolBox;
class ComboBox;
typedef std::map<OString, weld::Widget*> WidgetMap;
@@ -85,6 +86,8 @@ public:
weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr,
FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr,
bool bTakeOwnership = false) override;
+ std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id,
+ bool bTakeOwnership = false) override;
static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent,
VclMessageType eMessageType,
@@ -223,4 +226,13 @@ public:
virtual void queue_draw_area(int x, int y, int width, int height) override;
};
+class VCL_DLLPUBLIC JSToolbar : public JSWidget<SalInstanceToolbar, ::ToolBox>
+{
+public:
+ JSToolbar(VclPtr<vcl::Window> aOwnedToplevel, ::ToolBox* pToolbox, SalInstanceBuilder* pBuilder,
+ bool bTakeOwnership);
+
+ void signal_clicked(const OString& rIdent) override;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index b678c34333b2..9f566b7c7434 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -18,6 +18,7 @@
#include <tools/json_writer.hxx>
#include <o3tl/deleter.hxx>
#include <memory>
+#include <vcl/toolbox.hxx>
JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow)
: Idle("JSDialog notify")
@@ -309,6 +310,21 @@ JSInstanceBuilder::weld_drawing_area(const OString& id, const a11yref& rA11yImpl
return pWeldWidget;
}
+std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OString& id,
+ bool bTakeOwnership)
+{
+ ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);
+ auto pWeldWidget = pToolBox ? std::make_unique<JSToolbar>(
+ m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
+ pToolBox, this, bTakeOwnership)
+ : nullptr;
+
+ if (pWeldWidget)
+ RememberWidget(id, pWeldWidget.get());
+
+ return pWeldWidget;
+}
+
weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent,
VclMessageType eMessageType,
VclButtonsType eButtonType,
@@ -518,4 +534,16 @@ void JSDrawingArea::queue_draw_area(int x, int y, int width, int height)
notifyDialogState();
}
+JSToolbar::JSToolbar(VclPtr<vcl::Window> aOwnedToplevel, ::ToolBox* pToolbox,
+ SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : JSWidget<SalInstanceToolbar, ::ToolBox>(aOwnedToplevel, pToolbox, pBuilder, bTakeOwnership)
+{
+}
+
+void JSToolbar::signal_clicked(const OString& rIdent)
+{
+ SalInstanceToolbar::signal_clicked(rIdent);
+ notifyDialogState();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
commit 004512d87ab70587d95a708116a5c2f4b870565c
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: Fri Jul 3 09:50:28 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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97788
Tested-by: Jenkins
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 0e9e6b36be54..e50a8df3ccda 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -208,6 +208,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 5086b263c6ab..75383b9d2d7c 100644
--- a/include/vcl/notebookbar.hxx
+++ b/include/vcl/notebookbar.hxx
@@ -21,6 +21,7 @@ namespace com::sun::star::ui { class XContextChangeEventListener; }
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 78a8d0edc4bf..ad8d22dc9f77 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -16,6 +16,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>
@@ -43,7 +44,7 @@ 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,
@@ -363,7 +364,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
bool bChangedFile = sNewFile != sCurrentFile;
if ((!sFile.isEmpty() && bChangedFile) || !pNotebookBar || !pNotebookBar->IsVisible()
- || bReloadNotebookbar)
+ || bReloadNotebookbar || comphelper::LibreOfficeKit::isActive())
{
RemoveListeners(pSysWindow);
@@ -382,12 +383,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();
@@ -550,9 +555,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 7f4922c54212..3dd4f889ee71 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