summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-01-11 10:59:05 +0100
committerMiklos Vajna <vmiklos@collabora.com>2024-01-11 12:06:52 +0100
commitaaf6ce108e91b1504befe19afcee471e3316ae7a (patch)
tree5bcc7e3f2e20c5cca0babded633ec70f0feb5fe3 /test
parentd6996f399b82fb0482850829349a4bf1647529b2 (diff)
cool#7492 sfx2 lok: set language/locale on async sidebar update
Create two Calc views, set the first view language to English, second view language to German. Type in the English view, double-click on a chart in the German view. The sidebar in the German view will have English strings in it. This doesn't happen if there is no typing right after the chart activation in the English view. What happens is that the sidebar update is async, and sfx2::sidebar::SidebarController::notifyContextChangeEvent() gets called, which registers an aync event when it calls AsynchronousCall::RequestCall(). Then later this job gets scheduled, but possibly by that time the active view is the English one, leading to English strings when chart::ColumnChartDialogController::getName() calls SchResId(), which works from the language of the current view. Fix the problem similar to what commit fb7b0b944741e4efae8d92a6e305036aff906c7a (cool#7492 sfx2 lok: just set language/locale on async binding update, 2024-01-09), did: set the language/locale from the current view before executing the async job and restore the old value once we're done. Extract the now duplicated code to a new SfxLokLanguageGuard, so in case more places have a problem with incorrect l10n, then it's meant to be a one-liner to fix further places. Change-Id: I52724a24d93fb753175a3b9b99bc33178519d981 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161920 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'test')
-rw-r--r--test/source/lokcallback.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx
index 767448c771ca..a979b8b50582 100644
--- a/test/source/lokcallback.cxx
+++ b/test/source/lokcallback.cxx
@@ -14,6 +14,10 @@
#include <tools/gen.hxx>
#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/sidebar/SidebarDockingWindow.hxx>
TestLokCallbackWrapper::TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data)
: Idle("TestLokCallbackWrapper flush timer")
@@ -185,4 +189,23 @@ void TestLokCallbackWrapper::Invoke()
flushLOKData();
}
+SfxChildWindow* TestLokCallbackWrapper::InitializeSidebar()
+{
+ // in init.cxx we do setupSidebar which creates the controller, do it here
+
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ assert(pViewShell);
+
+ SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
+ SfxChildWindow* pSideBar = rViewFrame.GetChildWindow(SID_SIDEBAR);
+ assert(pSideBar);
+
+ auto pDockingWin = dynamic_cast<sfx2::sidebar::SidebarDockingWindow*>(pSideBar->GetWindow());
+ assert(pDockingWin);
+
+ pDockingWin->GetOrCreateSidebarController(); // just to create the controller
+
+ return pSideBar;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */