sc/qa/unit/tiledrendering/tiledrendering2.cxx | 22 + sc/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx | 21 + sc/qa/unit/tiledrendering2/tiledrendering2.cxx | 183 -------------- 3 files changed, 43 insertions(+), 183 deletions(-)
New commits: commit fc69651f60d2d99df3c9295312a5caf17dbb46df Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Apr 9 13:20:55 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 9 14:26:02 2025 +0200 CppunitTest_sc_tiledrendering2, testDecimalSeparatorInfo: fix mismerge 18e206907713768366cff5ee385eafdf26255980 (Add a test for decimal separator info., 2025-02-05) was OK, but then the version on master was mismerged, restore the lost test. Change-Id: I289cc228f6a429a0065310389c89a312bf413277 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183918 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sc/qa/unit/tiledrendering/tiledrendering2.cxx b/sc/qa/unit/tiledrendering/tiledrendering2.cxx index 141c6f58985f..ccf2acd92e51 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering2.cxx @@ -119,6 +119,28 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testLocaleFormulaSeparator) CPPUNIT_ASSERT_EQUAL(u"0"_ustr, pDoc->GetString(addr)); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testDecimalSeparatorInfo) +{ + createDoc("decimal-separator.ods"); + + ViewCallback aView1; + + // Go to cell A1. + uno::Sequence<beans::PropertyValue> aPropertyValues + = { comphelper::makePropertyValue("ToPoint", OUString("$A$1")) }; + dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); + + // Cell A1 has language set to English. Decimal separator should be ".". + CPPUNIT_ASSERT_EQUAL(std::string("."), aView1.decimalSeparator); + + // Go to cell B1. + aPropertyValues = { comphelper::makePropertyValue("ToPoint", OUString("B$1")) }; + dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); + + // Cell B1 has language set to Turkish. Decimal separator should be ",". + CPPUNIT_ASSERT_EQUAL(std::string(","), aView1.decimalSeparator); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx b/sc/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx index 62187ad6a23b..5b92a884d25a 100644 --- a/sc/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx +++ b/sc/qa/unit/tiledrendering/tiledrenderingmodeltestbase.cxx @@ -271,6 +271,7 @@ public: OString m_aHyperlinkClicked; OString m_ShapeSelection; std::map<std::string, boost::property_tree::ptree> m_aStateChanges; + std::string decimalSeparator; TestLokCallbackWrapper m_callbackWrapper; ViewCallback(bool bDeleteListenerOnDestruct = true) @@ -451,6 +452,26 @@ public: m_aStateChanges[aCommandName] = aTree; } break; + case LOK_CALLBACK_JSDIALOG: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + if (aTree.get_child("jsontype").get_value<std::string>() == "formulabar") + { + if (aTree.find("data") != aTree.not_found()) + { + if (aTree.get_child("data").find("separator") + != aTree.get_child("data").not_found()) + { + decimalSeparator = aTree.get_child("data") + .get_child("separator") + .get_value<std::string>(); + } + } + } + } + break; } } diff --git a/sc/qa/unit/tiledrendering2/tiledrendering2.cxx b/sc/qa/unit/tiledrendering2/tiledrendering2.cxx deleted file mode 100644 index 5c9e8b539822..000000000000 --- a/sc/qa/unit/tiledrendering2/tiledrendering2.cxx +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <test/unoapixml_test.hxx> - -#include <boost/property_tree/json_parser.hpp> - -#include <LibreOfficeKit/LibreOfficeKitEnums.h> -#include <comphelper/lok.hxx> -#include <comphelper/servicehelper.hxx> -#include <comphelper/propertyvalue.hxx> -#include <sfx2/lokhelper.hxx> -#include <test/lokcallback.hxx> -#include <vcl/scheduler.hxx> -#include <tabvwsh.hxx> - -#include <docuno.hxx> - -using namespace com::sun::star; - -namespace -{ -class Test : public UnoApiXmlTest -{ -public: - Test(); - void setUp() override; - void tearDown() override; - - ScModelObj* createDoc(const char* pName); -}; - -Test::Test() - : UnoApiXmlTest("/sc/qa/unit/tiledrendering2/data/") -{ -} - -void Test::setUp() -{ - UnoApiXmlTest::setUp(); - - comphelper::LibreOfficeKit::setActive(true); -} - -void Test::tearDown() -{ - if (mxComponent.is()) - { - mxComponent->dispose(); - mxComponent.clear(); - } - - comphelper::LibreOfficeKit::resetCompatFlag(); - - comphelper::LibreOfficeKit::setActive(false); - - UnoApiXmlTest::tearDown(); -} - -ScModelObj* Test::createDoc(const char* pName) -{ - loadFromFile(OUString::createFromAscii(pName)); - - ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent); - CPPUNIT_ASSERT(pModelObj); - pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); - return pModelObj; -} - -/// A view callback tracks callbacks invoked on one specific view. -class ViewCallback final -{ - SfxViewShell* mpViewShell; - int mnView; - -public: - std::map<std::string, boost::property_tree::ptree> m_aStateChanges; - std::string decimalSeparator; - TestLokCallbackWrapper m_callbackWrapper; - - ViewCallback() - : m_callbackWrapper(&callback, this) - { - mpViewShell = SfxViewShell::Current(); - mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper); - mnView = SfxLokHelper::getView(); - m_callbackWrapper.setLOKViewId(mnView); - } - - ~ViewCallback() - { - if (mpViewShell) - { - SfxLokHelper::setView(mnView); - mpViewShell->setLibreOfficeKitViewCallback(nullptr); - } - } - - static void callback(int nType, const char* pPayload, void* pData) - { - static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); - } - - void callbackImpl(int nType, const char* pPayload) - { - switch (nType) - { - case LOK_CALLBACK_STATE_CHANGED: - { - std::stringstream aStream(pPayload); - if (!aStream.str().starts_with("{")) - { - break; - } - - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - auto it = aTree.find("commandName"); - if (it == aTree.not_found()) - { - break; - } - - std::string aCommandName = it->second.get_value<std::string>(); - m_aStateChanges[aCommandName] = aTree; - } - break; - case LOK_CALLBACK_JSDIALOG: - { - std::stringstream aStream(pPayload); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - if (aTree.get_child("jsontype").get_value<std::string>() == "formulabar") - { - if (aTree.find("data") != aTree.not_found()) - { - if (aTree.get_child("data").find("separator") - != aTree.get_child("data").not_found()) - { - decimalSeparator = aTree.get_child("data") - .get_child("separator") - .get_value<std::string>(); - } - } - } - } - break; - } - } -}; - -CPPUNIT_TEST_FIXTURE(Test, testDecimalSeparatorInfo) -{ - createDoc("decimal-separator.ods"); - - ViewCallback aView1; - - // Go to cell A1. - uno::Sequence<beans::PropertyValue> aPropertyValues - = { comphelper::makePropertyValue("ToPoint", OUString("$A$1")) }; - dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); - - // Cell A1 has language set to English. Decimal separator should be ".". - CPPUNIT_ASSERT_EQUAL(std::string("."), aView1.decimalSeparator); - - // Go to cell B1. - aPropertyValues = { comphelper::makePropertyValue("ToPoint", OUString("B$1")) }; - dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); - - // Cell B1 has language set to Turkish. Decimal separator should be ",". - CPPUNIT_ASSERT_EQUAL(std::string(","), aView1.decimalSeparator); -} -} - -CPPUNIT_PLUGIN_IMPLEMENT(); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */