summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-01-05 16:51:42 +0100
committerMiklos Vajna <vmiklos@collabora.com>2024-01-16 11:14:30 +0100
commita1d1a5a27302742a62dff986ee831b4bad39d316 (patch)
tree60b4712e2490c5884660a5b960b360bbcf2ddb4e /sfx2
parent1be2495ab0b2ff531988294c692d639b9af40d34 (diff)
cool#7492 sfx2 lok: fix bad view id / statusbar string on async binding update
With two Calc views (first is an English one, second is a German one), type in the English view and in parallel to that, create a cell selection in the German view. Sometimes the status bar update about the selected cells arrives in English, in the German view. The root of the problem is that SfxBindings has a timer that does the expensive update of all the UNO commands only after a delay, but by the time this timer runs, possibly the current view is no longer the German one, which leads to English strings in the German view. Fix the problem somewhat similar to what commit ee7ca8e4ea8ed93655f99e77a9e77032ac830c46 (cool#7865 sfx2 lok: fix bad view id on async command dispatch, 2023-12-20) did in SfxHintPoster::DoEvent_Impl() by restoring the original view for the duration of the timer job execution. The test works even in case '--with-lang=en-US de' is not used, because it asserts the locale, which is not downgraded to English when translations are not available. This required turning the payload of the .uno:RowColSelCount status update into JSON, which is meant to be mostly backwards-compatible, given that we already have a mix of plain text and JSON for the various UNO commands. Another trouble is that the SfxBindings lazy update is a timer, so processing idles won't help and sleeping in test code is not ideal, either. Solve that by exposing the timer of SfxBindings, so test code can explicitly invoke the timer without waiting. (cherry picked from commit 51d8a2ef54751403fa707816e27ddb4e7faa8231) Conflicts: sc/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: Iacf17f81c28b95ce41a0ee29ad25eb576db0d62a
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/bindings.cxx28
-rw-r--r--sfx2/source/control/unoctitm.cxx21
2 files changed, 48 insertions, 1 deletions
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 47ddda28136f..3f50bfd289be 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -50,6 +50,8 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/msgpool.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <comphelper/lok.hxx>
#include <cstddef>
#include <memory>
@@ -1212,7 +1214,28 @@ void SfxBindings::UpdateControllers_Impl
IMPL_LINK( SfxBindings, NextJob, Timer *, pTimer, void )
{
+ bool bSetView = false;
+ int nOldId = -1;
+ if (comphelper::LibreOfficeKit::isActive() && pDispatcher)
+ {
+ SfxViewFrame* pFrame = pDispatcher->GetFrame();
+ SfxViewShell* pShell = pFrame ? pFrame->GetViewShell() : nullptr;
+ int nNewId = SfxLokHelper::getView(pShell);
+ nOldId = SfxLokHelper::getView();
+ if (nNewId != -1 && nNewId != nOldId)
+ {
+ // The current view ID is not the one that belongs to this frame, switch to it.
+ SfxLokHelper::setView(nNewId);
+ bSetView = true;
+ }
+ }
+
NextJob_Impl(pTimer);
+
+ if (bSetView)
+ {
+ SfxLokHelper::setView(nOldId);
+ }
}
bool SfxBindings::NextJob_Impl(Timer const * pTimer)
@@ -1771,4 +1794,9 @@ uno::Reference < frame::XDispatch > SfxBindings::GetDispatch( const SfxSlot* pSl
return xRet;
}
+Timer& SfxBindings::GetTimer()
+{
+ return pImpl->aAutoTimer;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index c37544b2ecbd..54c2424ff249 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1151,7 +1151,6 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
}
}
else if (aEvent.FeatureURL.Path == "StatusDocPos" ||
- aEvent.FeatureURL.Path == "RowColSelCount" ||
aEvent.FeatureURL.Path == "StatusPageStyle" ||
aEvent.FeatureURL.Path == "StateWordCount" ||
aEvent.FeatureURL.Path == "PageStyleName" ||
@@ -1167,6 +1166,26 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
aBuffer.append(aString);
}
}
+ else if (aEvent.FeatureURL.Path == "RowColSelCount")
+ {
+ OUString aString;
+ if (aEvent.IsEnabled)
+ {
+ aEvent.State >>= aString;
+ }
+ boost::property_tree::ptree aTree;
+ aTree.put("commandName", aEvent.FeatureURL.Complete);
+ aTree.put("locale", comphelper::LibreOfficeKit::getLocale().getBcp47());
+ aTree.put("state", aString);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ const SfxViewShell* pShell = pViewFrame->GetViewShell();
+ if (pShell)
+ {
+ pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, OString(aStream.str()));
+ }
+ return;
+ }
else if (aEvent.FeatureURL.Path == "StateTableCell")
{
if (aEvent.IsEnabled)