sc/qa/unit/tiledrendering/data/numlocale.xlsx |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx  |   73 ++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)

New commits:
commit f957dfbde79238d0f49f31763baad9d0c8f93bd3
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Apr 30 09:51:18 2024 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed May 1 16:40:45 2024 +0200

    lok: test number formats with different locale
    
    This is followup for the fix in commit 
7836cb7e90d0214cac08228f5e527322ed6f955c
    lok: save correct number format in multi-lang session
    
    Change-Id: I6016425d37b1ee1707ed8920811e8741c9267ee7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166912
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/qa/unit/tiledrendering/data/numlocale.xlsx 
b/sc/qa/unit/tiledrendering/data/numlocale.xlsx
new file mode 100644
index 000000000000..c69f74e32301
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/numlocale.xlsx 
differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 1c183521b605..17048a4ca8df 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -26,6 +26,8 @@
 #include <sfx2/dispatch.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <svl/stritem.hxx>
+#include <svl/numformat.hxx>
+#include <svl/zformat.hxx>
 
 #include <comphelper/lok.hxx>
 #include <comphelper/propertyvalue.hxx>
@@ -45,6 +47,7 @@
 #include <test/lokcallback.hxx>
 #include <osl/file.hxx>
 #include <unotools/tempfile.hxx>
+#include <unotools/syslocaleoptions.hxx>
 
 #include <chrono>
 #include <cstddef>
@@ -3934,6 +3937,76 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testCopyMultiSelection)
     CPPUNIT_ASSERT(!xTransferable2->isComplex());
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testNumberFormatLocaleMultiUser)
+{
+    {
+        // setup core language to FR as it will be the first session
+        SvtSysLocaleOptions aLocalOptions;
+        aLocalOptions.SetLocaleConfigString("fr-FR");
+        aLocalOptions.SetUILocaleConfigString("fr-FR");
+        aLocalOptions.Commit();
+
+        loadFromFile(u"numlocale.xlsx");
+
+        ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+        CPPUNIT_ASSERT(pModelObj);
+
+        
pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+        ScDocument* pDoc = pModelObj->GetDocument();
+
+        int nViewFR = SfxLokHelper::getView();
+        ViewCallback aView1;
+        SfxViewShell* pViewFR = SfxViewShell::Current();
+        pViewFR->SetLOKLocale("fr-FR");
+
+        // modify G12 with FR and use French keywords in the format
+        SfxLokHelper::setView(nViewFR);
+
+        sal_Int32 nCheckPos;
+        SvNumFormatType nType;
+        sal_uInt32 nFormat;
+        OUString aNumberFormat("JJ/MM/AAAA");
+        SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+        pFormatter->PutEntry(aNumberFormat, nCheckPos, nType, nFormat);
+        ScAddress aCellPos1(/*nColP=*/6, /*nRowP=*/11, /*nTabP=*/0);
+        pDoc->SetNumberFormat(aCellPos1, nFormat);
+
+        Scheduler::ProcessEventsToIdle();
+    }
+
+    {
+        // now setup DE language in core
+        SvtSysLocaleOptions aLocalOptions;
+        aLocalOptions.SetLocaleConfigString("de-DE");
+        aLocalOptions.SetUILocaleConfigString("de-DE");
+        aLocalOptions.Commit();
+
+        // save and reopen
+        // .uno:Save modifies the original file, make a copy first
+        saveAndReload("Calc MS Excel 2007 VBA XML");
+
+        ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+        CPPUNIT_ASSERT(pModelObj);
+
+        ScTabViewShell* pView = 
dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+        CPPUNIT_ASSERT(pView);
+
+        Scheduler::ProcessEventsToIdle();
+
+        uno::Sequence<beans::PropertyValue> aArgs;
+        dispatchCommand(mxComponent, ".uno:Save", aArgs);
+
+        Scheduler::ProcessEventsToIdle();
+
+        ScDocument* pDoc = pModelObj->GetDocument();
+
+        // verify that format is correct (German), doesn't have any "string" 
inside
+        sal_uInt32 nNumberFormat = pDoc->GetNumberFormat(/*col=*/6, 
/*row=*/11, /*tab=*/0);
+        const SvNumberformat* pNumberFormat = 
pDoc->GetFormatTable()->GetEntry(nNumberFormat);
+        CPPUNIT_ASSERT_EQUAL(OUString("TT.MM.JJ"), 
pNumberFormat->GetFormatstring());
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to