sw/CppunitTest_sw_cjk.mk | 77 ++++++++++++++++++ sw/Module_sw.mk | 1 sw/qa/extras/cjk/cjk.cxx | 120 +++++++++++++++++++++++++++++ sw/qa/extras/odfimport/odfimport.cxx | 25 ------ sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 26 ------ sw/qa/extras/ww8export/ww8export.cxx | 31 ------- sw/qa/extras/ww8export/ww8export4.cxx | 7 - 7 files changed, 198 insertions(+), 89 deletions(-)
New commits: commit b0c864687a98ce731cb794746628a809e6a4deb8 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Dec 12 11:52:10 2025 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Dec 16 08:29:30 2025 +0100 move writer tests using CJK fonts to new target where adding a new cjk font to the bundled fonts triggers an abort from: gb_CppunitTest_set_non_application_font_use,...,abort because the docs require glyph fallback to render, but without a CJK font in the application fonts glyph fallback doesn't actually happen. But once one is added, then the fallback is detected and the check fires. Change-Id: If02a2c1eefd6f5b6e4a19ca46f359cce466662f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195560 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/CppunitTest_sw_cjk.mk b/sw/CppunitTest_sw_cjk.mk new file mode 100644 index 000000000000..2324d58ffc10 --- /dev/null +++ b/sw/CppunitTest_sw_cjk.mk @@ -0,0 +1,77 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_cjk)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_cjk)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_cjk, \ + sw/qa/extras/cjk/cjk \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_cjk, \ + comphelper \ + editeng \ + cppu \ + cppuhelper \ + sal \ + svt \ + sfx \ + subsequenttest \ + svl \ + sw \ + swqahelper \ + test \ + unotest \ + vcl \ + tl \ + utl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_cjk,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_cjk,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_system_win32_libs,sw_cjk,\ + ole32 \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_cjk,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_cjk)) +$(eval $(call gb_CppunitTest_use_vcl,sw_cjk)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_cjk,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_cjk)) + +$(eval $(call gb_CppunitTest_add_arguments,sw_cjk, \ + -env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \ +)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_cjk,\ + officecfg/registry \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index ecf07db0661d..1619849e9057 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -62,6 +62,7 @@ $(eval $(call gb_Module_add_check_targets,sw,\ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ $(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \ CppunitTest_sw_uwriter) \ + CppunitTest_sw_cjk \ CppunitTest_sw_rtfexport \ CppunitTest_sw_rtfexport2 \ CppunitTest_sw_rtfexport3 \ diff --git a/sw/qa/extras/cjk/cjk.cxx b/sw/qa/extras/cjk/cjk.cxx new file mode 100644 index 000000000000..63c4a9e7ec75 --- /dev/null +++ b/sw/qa/extras/cjk/cjk.cxx @@ -0,0 +1,120 @@ +/* -*- 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 <swmodeltestbase.hxx> + +#include <config_features.h> + +namespace +{ +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase(u"/sw/qa/extras/cjk/data/"_ustr, u"writer8"_ustr) + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testTdf101729) +{ + createSwDoc("tdf101729.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 l + = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "left").toInt32(); + sal_Int32 w + = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32(); + sal_Int32 x + = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt/infos/bounds", "left").toInt32(); + // Make sure the text does not go outside and verify it is centered roughly + CPPUNIT_ASSERT(l + w / 4 < x); + CPPUNIT_ASSERT(x < l + 3 * w / 4); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf115079) +{ + createSwDoc("tdf115079.odt"); + // This document caused segfault when layouting +} + +CPPUNIT_TEST_FIXTURE(Test, testMsWordUlTrailSpace) +{ + createSwDoc("UnderlineTrailingSpace.docx"); + { + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(true), + xSettings->getPropertyValue(u"MsWordUlTrailSpace"_ustr)); + } + + // Test also after save-and-reload: + saveAndReload(u"Office Open XML Text"_ustr); + { + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xSettings( + xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(true), + xSettings->getPropertyValue(u"MsWordUlTrailSpace"_ustr)); + } + + // Check that the compat setting is exported in OOXML + xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); + assertXPath(pXmlSettings, "/w:settings/w:compat/w:ulTrailSpace"); +} + +DECLARE_WW8EXPORT_TEST(testWw8Cjklist30, "cjklist30.doc") +{ + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat); +} + +DECLARE_WW8EXPORT_TEST(testWw8Cjklist31, "cjklist31.doc") +{ + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat); +} + +DECLARE_WW8EXPORT_TEST(testWw8Cjklist34, "cjklist34.doc") +{ + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat); +} + +DECLARE_WW8EXPORT_TEST(testWw8Cjklist35, "cjklist35.doc") +{ + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat); +} + +DECLARE_WW8EXPORT_TEST(testTdf118564, "tdf118564.doc") +{ + sal_Int16 numFormat = getNumberingTypeOfParagraph(3); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf77964) +{ + loadAndReload("tdf77964.doc"); + // both images were loading as AT_PARA instead of AS_CHAR. Image2 visually had text wrapping. + CPPUNIT_ASSERT_EQUAL( + text::TextContentAnchorType_AS_CHARACTER, + getProperty<text::TextContentAnchorType>(getShapeByName(u"Image2"), u"AnchorType"_ustr)); +} + +CPPUNIT_TEST_FIXTURE(Test, tdf167455) +{ + // crashes at import time on macOS + createSwDoc("tdf167455.odt"); + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + +} // end of anonymous namespace +CPPUNIT_PLUGIN_IMPLEMENT(); +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/data/UnderlineTrailingSpace.docx b/sw/qa/extras/cjk/data/UnderlineTrailingSpace.docx similarity index 100% rename from sw/qa/extras/ooxmlexport/data/UnderlineTrailingSpace.docx rename to sw/qa/extras/cjk/data/UnderlineTrailingSpace.docx diff --git a/sw/qa/extras/ww8export/data/cjklist30.doc b/sw/qa/extras/cjk/data/cjklist30.doc similarity index 100% rename from sw/qa/extras/ww8export/data/cjklist30.doc rename to sw/qa/extras/cjk/data/cjklist30.doc diff --git a/sw/qa/extras/ww8export/data/cjklist31.doc b/sw/qa/extras/cjk/data/cjklist31.doc similarity index 100% rename from sw/qa/extras/ww8export/data/cjklist31.doc rename to sw/qa/extras/cjk/data/cjklist31.doc diff --git a/sw/qa/extras/ww8export/data/cjklist34.doc b/sw/qa/extras/cjk/data/cjklist34.doc similarity index 100% rename from sw/qa/extras/ww8export/data/cjklist34.doc rename to sw/qa/extras/cjk/data/cjklist34.doc diff --git a/sw/qa/extras/ww8export/data/cjklist35.doc b/sw/qa/extras/cjk/data/cjklist35.doc similarity index 100% rename from sw/qa/extras/ww8export/data/cjklist35.doc rename to sw/qa/extras/cjk/data/cjklist35.doc diff --git a/sw/qa/extras/odfimport/data/tdf101729.odt b/sw/qa/extras/cjk/data/tdf101729.odt similarity index 100% rename from sw/qa/extras/odfimport/data/tdf101729.odt rename to sw/qa/extras/cjk/data/tdf101729.odt diff --git a/sw/qa/extras/odfimport/data/tdf115079.odt b/sw/qa/extras/cjk/data/tdf115079.odt similarity index 100% rename from sw/qa/extras/odfimport/data/tdf115079.odt rename to sw/qa/extras/cjk/data/tdf115079.odt diff --git a/sw/qa/extras/ww8export/data/tdf118564.doc b/sw/qa/extras/cjk/data/tdf118564.doc similarity index 100% rename from sw/qa/extras/ww8export/data/tdf118564.doc rename to sw/qa/extras/cjk/data/tdf118564.doc diff --git a/sw/qa/extras/odfimport/data/tdf167455.odt b/sw/qa/extras/cjk/data/tdf167455.odt similarity index 100% rename from sw/qa/extras/odfimport/data/tdf167455.odt rename to sw/qa/extras/cjk/data/tdf167455.odt diff --git a/sw/qa/extras/ww8export/data/tdf77964.doc b/sw/qa/extras/cjk/data/tdf77964.doc similarity index 100% rename from sw/qa/extras/ww8export/data/tdf77964.doc rename to sw/qa/extras/cjk/data/tdf77964.doc diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 8dcbc2776b5d..c3c72a44d4b7 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -620,13 +620,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf128737) CPPUNIT_ASSERT_EQUAL(8, getShapes()); } -CPPUNIT_TEST_FIXTURE(Test, tdf167455) -{ - // crashes at import time on macOS - createSwDoc("tdf167455.odt"); - CPPUNIT_ASSERT_EQUAL(1, getPages()); -} - CPPUNIT_TEST_FIXTURE(Test, testCalcFootnoteContent) { createSwDoc("ooo32780-1.odt"); @@ -965,18 +958,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf75221) CPPUNIT_ASSERT(top.toInt32() > 0); } -CPPUNIT_TEST_FIXTURE(Test, testTdf101729) -{ - createSwDoc("tdf101729.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - sal_Int32 l = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "left").toInt32(); - sal_Int32 w = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32(); - sal_Int32 x = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt/infos/bounds", "left").toInt32(); - // Make sure the text does not go outside and verify it is centered roughly - CPPUNIT_ASSERT( l + w / 4 < x ); - CPPUNIT_ASSERT( x < l + 3 * w / 4); -} - CPPUNIT_TEST_FIXTURE(Test, testTdf107392) { createSwDoc("tdf107392.odt"); @@ -1090,12 +1071,6 @@ CPPUNIT_TEST_FIXTURE(Test, testBlankBeforeFirstPage) ); } -CPPUNIT_TEST_FIXTURE(Test, testTdf115079) -{ - createSwDoc("tdf115079.odt"); - // This document caused segfault when layouting -} - CPPUNIT_TEST_FIXTURE(Test, testTdf108482) { createSwDoc("tdf108482.odt"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 16d0eeeb4a55..90eeb788cccb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -1242,32 +1242,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf164176, "tdf164176.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), sPresentation.indexOf("_x000a_")); } -CPPUNIT_TEST_FIXTURE(Test, testMsWordUlTrailSpace) -{ - createSwDoc("UnderlineTrailingSpace.docx"); - { - uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY_THROW); - uno::Reference<beans::XPropertySet> xSettings( - xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(uno::Any(true), - xSettings->getPropertyValue(u"MsWordUlTrailSpace"_ustr)); - } - - // Test also after save-and-reload: - saveAndReload(u"Office Open XML Text"_ustr); - { - uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY_THROW); - uno::Reference<beans::XPropertySet> xSettings( - xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(uno::Any(true), - xSettings->getPropertyValue(u"MsWordUlTrailSpace"_ustr)); - } - - // Check that the compat setting is exported in OOXML - xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); - assertXPath(pXmlSettings, "/w:settings/w:compat/w:ulTrailSpace"); -} - CPPUNIT_TEST_FIXTURE(Test, testTdf165059_moveFromTo) { loadAndSave("tdf165059_broken.docx"); diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 16eff873137a..c0b2aa029217 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -1262,37 +1262,6 @@ DECLARE_WW8EXPORT_TEST(testBnc636128, "bnc636128.doc") CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), xParameters->getByName(u"MaxLength"_ustr).get<sal_uInt16>()); } - -DECLARE_WW8EXPORT_TEST(testWw8Cjklist30, "cjklist30.doc") -{ - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat); -} - -DECLARE_WW8EXPORT_TEST(testWw8Cjklist31, "cjklist31.doc") -{ - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat); -} - -DECLARE_WW8EXPORT_TEST(testWw8Cjklist34, "cjklist34.doc") -{ - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat); -} - -DECLARE_WW8EXPORT_TEST(testWw8Cjklist35, "cjklist35.doc") -{ - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat); -} - -DECLARE_WW8EXPORT_TEST(testTdf118564, "tdf118564.doc") -{ - sal_Int16 numFormat = getNumberingTypeOfParagraph(3); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat); -} - DECLARE_WW8EXPORT_TEST(testTdf92281, "tdf92281.doc") { uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index 858515a312f8..7ed1f4d3e6d6 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -51,13 +51,6 @@ public: } }; -CPPUNIT_TEST_FIXTURE(Test, testTdf77964) -{ - loadAndReload("tdf77964.doc"); - // both images were loading as AT_PARA instead of AS_CHAR. Image2 visually had text wrapping. - CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty<text::TextContentAnchorType>(getShapeByName(u"Image2"), u"AnchorType"_ustr)); -} - DECLARE_WW8EXPORT_TEST(testTdf72511_editengLRSpace, "tdf72511_editengLRSpace.doc") { // given a default paragraph style with a left indent of 2 inches,
