summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-01-12 08:35:23 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-12 12:12:50 +0100
commit59785bd8605f59860b24c40f04da04344c8df2c3 (patch)
tree58e462c086150f9e99135d19b9cf721b8701aff2 /test
parent9dd58f32e2a3b327f2a82387783d71af09d526bd (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. (cherry picked from commit aaf6ce108e91b1504befe19afcee471e3316ae7a) Conflicts: desktop/qa/desktop_lib/test_desktop_lib.cxx sc/qa/unit/tiledrendering/tiledrendering.cxx sfx2/source/sidebar/SidebarController.cxx Change-Id: I52724a24d93fb753175a3b9b99bc33178519d981 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161952 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'test')
-rw-r--r--test/source/lokcallback.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx
index 5af844f089ad..ef6ad4f37fcb 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")
@@ -186,4 +190,25 @@ 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* pViewFrame = pViewShell->GetViewFrame();
+ assert(pViewFrame);
+
+ SfxChildWindow* pSideBar = pViewFrame->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: */