[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - desktop/source include/sfx2 sfx2/source svx/source
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 19 12:57:54 UTC 2019
desktop/source/lib/init.cxx | 68 +++++++++++++++++++
include/sfx2/sidebar/AsynchronousCall.hxx | 1
include/sfx2/sidebar/SidebarController.hxx | 2
include/sfx2/sidebar/SidebarDockingWindow.hxx | 5 +
sfx2/source/sidebar/AsynchronousCall.cxx | 8 ++
sfx2/source/sidebar/SidebarController.cxx | 7 +
sfx2/source/sidebar/SidebarDockingWindow.cxx | 6 +
svx/source/sidebar/ContextChangeEventMultiplexer.cxx | 14 +--
8 files changed, 103 insertions(+), 8 deletions(-)
New commits:
commit 2d90583fb9026b3c8ee466029423dad3e957eb7e
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Dec 19 11:16:15 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Dec 19 12:53:14 2019 +0000
sidebar: bring new sidebar commands in-house & be more assertive with sfx2
Force the sidebar to do it's asynchronous things synchronously to help
keep things sane. Also emit our (in-process on Android / iOS) context
change notification after everyone else got it & updated their panels.
Change-Id: If94de6c83f1b783d7deee515fc2ee9a8d3754765
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c779682e1d71..5d369a996e0c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -108,6 +108,8 @@
#include <sfx2/lokcharthelper.hxx>
#include <sfx2/lokhelper.hxx>
#include <sfx2/DocumentSigner.hxx>
+#include <sfx2/sidebar/SidebarChildWindow.hxx>
+#include <sfx2/sidebar/SidebarDockingWindow.hxx>
#include <svx/dialmgr.hxx>
#include <svx/dialogs.hrc>
#include <svx/strings.hrc>
@@ -142,6 +144,7 @@
#include <osl/module.hxx>
#include <comphelper/sequence.hxx>
#include <sfx2/sfxbasemodel.hxx>
+#include <svl/eitem.hxx>
#include <svl/undo.hxx>
#include <unotools/datetime.hxx>
#include <i18nlangtag/mslangid.hxx>
@@ -3302,12 +3305,67 @@ public:
virtual void SAL_CALL disposing(const css::lang::EventObject&) override {}
};
+static void setupSidebar(bool bShow)
+{
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr;
+ if (pViewFrame)
+ {
+ if (bShow && !pViewFrame->GetChildWindow(SID_SIDEBAR))
+ pViewFrame->SetChildWindow(SID_SIDEBAR, false /* create it */, true /* focus */);
+
+ pViewFrame->ShowChildWindow(SID_SIDEBAR, bShow);
+
+ if (!bShow)
+ return;
+
+ // Force synchronous population of panels
+ SfxChildWindow *pChild = pViewFrame->GetChildWindow(SID_SIDEBAR);
+ if (!pChild)
+ return;
+
+ auto pDockingWin = dynamic_cast<sfx2::sidebar::SidebarDockingWindow *>(pChild->GetWindow());
+ if (!pDockingWin)
+ return;
+ pDockingWin->SyncUpdate();
+ }
+ else
+ SetLastExceptionMsg("No view shell or sidebar");
+}
+
+static VclPtr<Window> getSidebarWindow()
+{
+ VclPtr<Window> xRet;
+
+ setupSidebar(true);
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr;
+ if (!pViewFrame)
+ return xRet;
+
+ // really a SidebarChildWindow
+ SfxChildWindow *pChild = pViewFrame->GetChildWindow(SID_SIDEBAR);
+ if (!pChild)
+ return xRet;
+
+ // really a SidebarDockingWindow
+ vcl::Window *pWin = pChild->GetWindow();
+ if (!pWin)
+ return xRet;
+ xRet = pWin;
+ return xRet;
+}
+
static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWindowId, const char* pArguments)
{
SolarMutexGuard aGuard;
StringMap aMap(jsonToStringMap(pArguments));
VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nWindowId);
+
+ if (!pWindow && nWindowId >= 1000000000 /* why unsigned? */)
+ pWindow = getSidebarWindow();
+
if (!pWindow)
{
SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found.");
@@ -3515,6 +3573,16 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
return;
}
}
+ else if (gImpl && aCommand == ".uno:SidebarShow")
+ {
+ setupSidebar(true);
+ return;
+ }
+ else if (gImpl && aCommand == ".uno:SidebarHide")
+ {
+ setupSidebar(false);
+ return;
+ }
bool bResult = false;
LokChartHelper aChartHelper(SfxViewShell::Current());
diff --git a/include/sfx2/sidebar/AsynchronousCall.hxx b/include/sfx2/sidebar/AsynchronousCall.hxx
index b42caf50ed19..0b6464cb713f 100644
--- a/include/sfx2/sidebar/AsynchronousCall.hxx
+++ b/include/sfx2/sidebar/AsynchronousCall.hxx
@@ -41,6 +41,7 @@ public:
void RequestCall();
void CancelRequest();
+ void Sync();
private:
Action const maAction;
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index bad4220ce547..e65bbae42537 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -170,6 +170,8 @@ public:
css::uno::Reference<css::frame::XFrame> getXFrame() {return mxFrame;}
+ void SyncUpdate();
+
private:
SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame);
diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx
index a3297eb3afa8..049cf241aacd 100644
--- a/include/sfx2/sidebar/SidebarDockingWindow.hxx
+++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx
@@ -35,7 +35,7 @@ class SidebarController;
class SidebarNotifyIdle;
-class SidebarDockingWindow : public SfxDockingWindow
+class SFX2_DLLPUBLIC SidebarDockingWindow : public SfxDockingWindow
{
public:
SidebarDockingWindow(SfxBindings* pBindings, SidebarChildWindow& rChildWindow,
@@ -48,6 +48,9 @@ public:
void SetReadyToDrag( bool bStartDrag ) { mbIsReadyToDrag = bStartDrag; }
bool IsReadyToDrag() const { return mbIsReadyToDrag; }
+ /// Force generation of all panels by completion.
+ void SyncUpdate();
+
void NotifyResize();
using SfxDockingWindow::Close;
diff --git a/sfx2/source/sidebar/AsynchronousCall.cxx b/sfx2/source/sidebar/AsynchronousCall.cxx
index 495d62f8eb7b..0013ea5e5ceb 100644
--- a/sfx2/source/sidebar/AsynchronousCall.cxx
+++ b/sfx2/source/sidebar/AsynchronousCall.cxx
@@ -57,6 +57,14 @@ void AsynchronousCall::CancelRequest()
}
}
+void AsynchronousCall::Sync()
+{
+ if (mnCallId != nullptr) {
+ maAction();
+ CancelRequest();
+ }
+}
+
IMPL_LINK_NOARG(AsynchronousCall, HandleUserCall, void*, void )
{
mnCallId = nullptr;
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 72d6d216c5a2..91405791c727 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -498,6 +498,13 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth)
}
}
+void SidebarController::SyncUpdate()
+{
+ maPropertyChangeForwarder.Sync();
+ maContextChangeUpdate.Sync();
+ maAsynchronousDeckSwitch.Sync();
+}
+
void SidebarController::UpdateConfigurations()
{
if (maCurrentContext == maRequestedContext
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 5facecb2deb3..2bf4ea7258bb 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -182,6 +182,12 @@ void SidebarDockingWindow::Resize()
NotifyResize();
}
+void SidebarDockingWindow::SyncUpdate()
+{
+ if (mpSidebarController.is())
+ mpSidebarController->SyncUpdate();
+}
+
void SidebarDockingWindow::NotifyResize()
{
if (comphelper::LibreOfficeKit::isActive() && mpSidebarController.is() && SfxViewShell::Current())
diff --git a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx
index 0c53ae140629..845d96e0a935 100644
--- a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx
+++ b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx
@@ -39,13 +39,6 @@ void ContextChangeEventMultiplexer::NotifyContextChange (
{
if (rxController.is() && rxController->getFrame().is())
{
- // notify the LOK too
- if (comphelper::LibreOfficeKit::isActive())
- {
- if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController))
- SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext));
- }
-
const css::ui::ContextChangeEventObject aEvent(
rxController,
GetModuleName(rxController->getFrame()),
@@ -56,6 +49,13 @@ void ContextChangeEventMultiplexer::NotifyContextChange (
::comphelper::getProcessComponentContext()));
if (xMultiplexer.is())
xMultiplexer->broadcastContextChangeEvent(aEvent, rxController);
+
+ // notify the LOK too after all the change have taken effect.
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController))
+ SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext));
+ }
}
}
More information about the Libreoffice-commits
mailing list