download.lst | 4 external/hunspell/0001-Resolves-rhbz-2158548-allow-longer-words-for-hunspel.patch | 77 external/hunspell/0001-fix-LibreOffice-build-problem-with-basic_string-appe.patch | 84 external/hunspell/0001-invalid-read-memory-access-624.patch | 25 external/hunspell/UnpackedTarball_hunspell.mk | 3 solenv/clang-format/blacklist | 2 sw/CppunitTest_sw_layoutwriter2.mk | 81 sw/CppunitTest_sw_layoutwriter3.mk | 81 sw/Module_sw.mk | 2 sw/qa/extras/layout/layout.cxx | 2569 ---------- sw/qa/extras/layout/layout2.cxx | 955 +++ sw/qa/extras/layout/layout3.cxx | 1532 +++++ 12 files changed, 2962 insertions(+), 2453 deletions(-)
New commits: commit 0ef99664ff0b4f1a1cebf0ec8e02306d9c6180ce Author: Caolán McNamara <[email protected]> AuthorDate: Fri Jan 6 16:28:03 2023 +0000 Commit: Michael Stahl <[email protected]> CommitDate: Wed Sep 25 13:42:49 2024 +0200 Related: rhbz#2158548 allow longer words for hunspell-ko https://github.com/hunspell/hunspell/issues/903 A problem since the sanity check added in: commit 05e44e069e4cfaa9ce1264bf13f23fc9abd7ed05 Author: Caolán McNamara <[email protected]> Date: Thu Sep 1 13:46:40 2022 +0100 Check word limit (#813) * check against hentry blen max Change-Id: Iab2c062584da076260c3262537690435eae7f396 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145154 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 2a8660c6d36a2015c37c65b6bc21c6decd96cf8e) diff --git a/external/hunspell/0001-Resolves-rhbz-2158548-allow-longer-words-for-hunspel.patch b/external/hunspell/0001-Resolves-rhbz-2158548-allow-longer-words-for-hunspel.patch new file mode 100644 index 000000000000..c0225fbd70a4 --- /dev/null +++ b/external/hunspell/0001-Resolves-rhbz-2158548-allow-longer-words-for-hunspel.patch @@ -0,0 +1,77 @@ +From e2fe9f86e1769b440972971240e9b8fb1cd53b97 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> +Date: Fri, 6 Jan 2023 16:20:45 +0000 +Subject: [PATCH] Resolves: rhbz#2158548 allow longer words for hunspell-ko +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +https://github.com/hunspell/hunspell/issues/903 + +A problem since the sanity check added in: + +commit 05e44e069e4cfaa9ce1264bf13f23fc9abd7ed05 +Author: Caolán McNamara <[email protected]> +Date: Thu Sep 1 13:46:40 2022 +0100 + + Check word limit (#813) + + * check against hentry blen max +--- + src/hunspell/hashmgr.cxx | 6 +++--- + src/hunspell/htypes.hxx | 4 ++-- + tests/korean.dic | 3 ++- + 3 files changed, 7 insertions(+), 6 deletions(-) + +diff --git a/src/hunspell/hashmgr.cxx b/src/hunspell/hashmgr.cxx +index 100916d..14201e9 100644 +--- a/src/hunspell/hashmgr.cxx ++++ b/src/hunspell/hashmgr.cxx +@@ -209,7 +209,7 @@ int HashMgr::add_word(const std::string& in_word, + } + + // limit of hp->blen +- if (word->size() > std::numeric_limits<unsigned char>::max()) { ++ if (word->size() > std::numeric_limits<unsigned short>::max()) { + HUNSPELL_WARNING(stderr, "error: word len %ld is over max limit ", word->size()); + delete desc_copy; + delete word_copy; +@@ -235,8 +235,8 @@ int HashMgr::add_word(const std::string& in_word, + + int i = hash(hpw, word->size()); + +- hp->blen = (unsigned char)word->size(); +- hp->clen = (unsigned char)wcl; ++ hp->blen = (unsigned short)word->size(); ++ hp->clen = (unsigned short)wcl; + hp->alen = (short)al; + hp->astr = aff; + hp->next = NULL; +diff --git a/src/hunspell/htypes.hxx b/src/hunspell/htypes.hxx +index 44366b1..2b896fb 100644 +--- a/src/hunspell/htypes.hxx ++++ b/src/hunspell/htypes.hxx +@@ -62,8 +62,8 @@ + #endif + + struct hentry { +- unsigned char blen; // word length in bytes +- unsigned char clen; // word length in characters (different for UTF-8 enc.) ++ unsigned short blen; // word length in bytes ++ unsigned short clen; // word length in characters (different for UTF-8 enc.) + short alen; // length of affix flag vector + unsigned short* astr; // affix flag vector + struct hentry* next; // next word with same hash code +diff --git a/tests/korean.dic b/tests/korean.dic +index 95cb450..d76ea05 100644 +--- a/tests/korean.dic ++++ b/tests/korean.dic +@@ -1,3 +1,4 @@ +-2 ++3 + 들어오세요 + 안녕하세요 ++김수한무거북이와두루미삼천갑자동방삭치치카포사리사리세ᅡ워리워리세브리캉무드셀ᅡ구름위허ᅵ케ᅵᆫᅦ담벼락서생원에ᄀ양 +-- +2.38.1 + diff --git a/external/hunspell/UnpackedTarball_hunspell.mk b/external/hunspell/UnpackedTarball_hunspell.mk index 2b8823021998..4667a3642bcc 100644 --- a/external/hunspell/UnpackedTarball_hunspell.mk +++ b/external/hunspell/UnpackedTarball_hunspell.mk @@ -23,6 +23,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,hunspell,1)) $(eval $(call gb_UnpackedTarball_add_patches,hunspell, \ external/hunspell/0001-fix-LibreOffice-build-problem-with-basic_string-appe.patch \ + external/hunspell/0001-Resolves-rhbz-2158548-allow-longer-words-for-hunspel.patch \ )) # vim: set noet sw=4 ts=4: commit 5f14c31d2a953dd5089ea2e5001aa7f197c84f14 Author: László Németh <[email protected]> AuthorDate: Thu Dec 29 22:09:55 2022 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Wed Sep 25 13:41:49 2024 +0200 upgrade to hunspell 1.7.2 Change-Id: If969eccc73926911a4a09440623adf83b8e2c520 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144869 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit 247e161cf1dca6811998b67d1138062fa4e14381) diff --git a/download.lst b/download.lst index fff9377ad763..f219bbded558 100644 --- a/download.lst +++ b/download.lst @@ -239,8 +239,8 @@ HSQLDB_TARBALL := 17410483b5b5f267aa18b7e00b65e6e0-hsqldb_1_8_0.zip # three static lines # so that git cherry-pick # will not run into conflicts -HUNSPELL_SHA256SUM := b2d9c5369c2cc7f321cb5983fda2dbf007dce3d9e17519746840a6f0c4bf7444 -HUNSPELL_TARBALL := hunspell-1.7.1.tar.gz +HUNSPELL_SHA256SUM := 11ddfa39afe28c28539fe65fc4f1592d410c1e9b6dd7d8a91ca25d85e9ec65b8 +HUNSPELL_TARBALL := hunspell-1.7.2.tar.gz # three static lines # so that git cherry-pick # will not run into conflicts diff --git a/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch b/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch deleted file mode 100644 index 58b68d0dda43..000000000000 --- a/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 56ad6310c95695d25f936d3f89f6ee3d787df274 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> -Date: Mon, 22 Aug 2022 21:21:36 +0100 -Subject: [PATCH] check 'len' in cpdpat_check like 'r1->blen' is checked (#633) - (#780) - -we should check len against pos like we do r1->blen in the line above ---- - src/hunspell/affixmgr.cxx | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx -index 7ea1ea5..c2432c0 100644 ---- a/src/hunspell/affixmgr.cxx -+++ b/src/hunspell/affixmgr.cxx -@@ -1330,7 +1330,7 @@ int AffixMgr::cpdpat_check(const char* word, - ((checkcpdtable[i].pattern[0] == '0' && r1->blen <= pos && - strncmp(word + pos - r1->blen, r1->word, r1->blen) == 0) || - (checkcpdtable[i].pattern[0] != '0' && -- ((len = checkcpdtable[i].pattern.size()) != 0) && -+ ((len = checkcpdtable[i].pattern.size()) != 0) && len <= pos && - strncmp(word + pos - len, checkcpdtable[i].pattern.c_str(), len) == 0)))) { - return 1; - } --- -2.37.2 - diff --git a/external/hunspell/0001-fix-LibreOffice-build-problem-with-basic_string-appe.patch b/external/hunspell/0001-fix-LibreOffice-build-problem-with-basic_string-appe.patch new file mode 100644 index 000000000000..3c6f9831b2b4 --- /dev/null +++ b/external/hunspell/0001-fix-LibreOffice-build-problem-with-basic_string-appe.patch @@ -0,0 +1,84 @@ +From 1587ea4ab5e8d94c9c0d552f7ab61c217ebdcbeb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?L=C3=A1szl=C3=B3=20N=C3=A9meth?= <[email protected]> +Date: Fri, 30 Dec 2022 12:20:02 +0100 +Subject: [PATCH] fix LibreOffice build problem with basic_string::append() + +--- + src/hunspell/affentry.cxx | 6 +++--- + src/hunspell/affixmgr.cxx | 8 ++++---- + 2 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/src/hunspell/affentry.cxx b/src/hunspell/affentry.cxx +index 46e8b58..6ee23be 100644 +--- a/src/hunspell/affentry.cxx ++++ b/src/hunspell/affentry.cxx +@@ -290,7 +290,7 @@ struct hentry* PfxEntry::check_twosfx(const std::string& word, + // back any characters that would have been stripped + + std::string tmpword(strip); +- tmpword.append(word, start + appnd.size()); ++ tmpword.append(word, start + appnd.size(), tmpl); + + // now make sure all of the conditions on characters + // are met. Please see the appendix at the end of +@@ -338,7 +338,7 @@ std::string PfxEntry::check_twosfx_morph(const std::string& word, + // back any characters that would have been stripped + + std::string tmpword(strip); +- tmpword.append(word, start + appnd.size()); ++ tmpword.append(word, start + appnd.size(), tmpl); + + // now make sure all of the conditions on characters + // are met. Please see the appendix at the end of +@@ -386,7 +386,7 @@ std::string PfxEntry::check_morph(const std::string& word, + // back any characters that would have been stripped + + std::string tmpword(strip); +- tmpword.append(word, start + appnd.size()); ++ tmpword.append(word, start + appnd.size(), tmpl); + + // now make sure all of the conditions on characters + // are met. Please see the appendix at the end of +diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx +index 4d1ad2f..a8931c1 100644 +--- a/src/hunspell/affixmgr.cxx ++++ b/src/hunspell/affixmgr.cxx +@@ -2465,7 +2465,7 @@ int AffixMgr::compound_check_morph(const std::string& word, + result.append(presult); + result.push_back(MSEP_FLD); + result.append(MORPH_PART); +- result.append(word, i); ++ result.append(word, i, word.size()); + if (complexprefixes && HENTRY_DATA(rv)) + result.append(HENTRY_DATA2(rv)); + if (!HENTRY_FIND(rv, MORPH_STEM)) { +@@ -2522,7 +2522,7 @@ int AffixMgr::compound_check_morph(const std::string& word, + result.append(presult); + result.push_back(MSEP_FLD); + result.append(MORPH_PART); +- result.append(word, i); ++ result.append(word, i, word.size()); + + if (HENTRY_DATA(rv)) { + if (complexprefixes) +@@ -2573,7 +2573,7 @@ int AffixMgr::compound_check_morph(const std::string& word, + if (!m.empty()) { + result.push_back(MSEP_FLD); + result.append(MORPH_PART); +- result.append(word, i); ++ result.append(word, i, word.size()); + line_uniq_app(m, MSEP_REC); + result.append(m); + } +@@ -2665,7 +2665,7 @@ int AffixMgr::compound_check_morph(const std::string& word, + if (!m.empty()) { + result.push_back(MSEP_FLD); + result.append(MORPH_PART); +- result.append(word, i); ++ result.append(word, i, word.size()); + line_uniq_app(m, MSEP_REC); + result.push_back(MSEP_FLD); + result.append(m); +-- +2.17.1 + diff --git a/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch b/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch deleted file mode 100644 index a42d38f5153a..000000000000 --- a/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 75ebf084f941c0fe72904b6167079d9190f885e5 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> -Date: Tue, 23 Aug 2022 11:44:36 +0100 -Subject: [PATCH] improve #630 test case from 0m1.836s -> 0m1.223s (#785) - ---- - src/hunspell/csutil.cxx | 16 ++++++++++------ - 1 file changed, 10 insertions(+), 6 deletions(-) - -diff --git a/src/hunspell/csutil.cxx b/src/hunspell/csutil.cxx -index e9cce47..5caa771 100644 ---- a/src/hunspell/csutil.cxx -+++ b/src/hunspell/csutil.cxx -@@ -171,8 +171,10 @@ std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { - } - - int u8_u16(std::vector<w_char>& dest, const std::string& src) { -- dest.clear(); -- dest.reserve(src.size()); -+ // faster to oversize initially, assign to elements and resize to what's used -+ // than to reserve and push_back -+ dest.resize(src.size()); -+ std::vector<w_char>::iterator u16 = dest.begin(); - std::string::const_iterator u8 = src.begin(); - std::string::const_iterator u8_max = src.end(); - -@@ -254,16 +256,18 @@ int u8_u16(std::vector<w_char>& dest, const std::string& src) { - src.c_str()); - u2.h = 0xff; - u2.l = 0xfd; -- dest.push_back(u2); -+ *u16++ = u2; -+ dest.resize(u16 - dest.begin()); - return -1; - } - } -- dest.push_back(u2); -+ *u16++ = u2; - ++u8; - } - -- dest.shrink_to_fit(); -- return dest.size(); -+ int size = u16 - dest.begin(); -+ dest.resize(size); -+ return size; - } - - namespace { --- -2.37.2 - diff --git a/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch b/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch deleted file mode 100644 index c3de49178ada..000000000000 --- a/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 211e1e6f36756579b86fa12891af3e5843cd8907 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> -Date: Tue, 23 Aug 2022 10:18:31 +0100 -Subject: [PATCH] improve #630 test case from 0m2.427s -> 0m1.836s (#781) - ---- - src/hunspell/csutil.cxx | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/src/hunspell/csutil.cxx b/src/hunspell/csutil.cxx -index fbaa768..e9cce47 100644 ---- a/src/hunspell/csutil.cxx -+++ b/src/hunspell/csutil.cxx -@@ -134,6 +134,7 @@ void myopen(std::ifstream& stream, const char* path, std::ios_base::openmode mod - - std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { - dest.clear(); -+ dest.reserve(src.size()); - std::vector<w_char>::const_iterator u2 = src.begin(); - std::vector<w_char>::const_iterator u2_max = src.end(); - while (u2 < u2_max) { -@@ -171,6 +172,7 @@ std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { - - int u8_u16(std::vector<w_char>& dest, const std::string& src) { - dest.clear(); -+ dest.reserve(src.size()); - std::string::const_iterator u8 = src.begin(); - std::string::const_iterator u8_max = src.end(); - -@@ -260,6 +262,7 @@ int u8_u16(std::vector<w_char>& dest, const std::string& src) { - ++u8; - } - -+ dest.shrink_to_fit(); - return dest.size(); - } - --- -2.37.2 - diff --git a/external/hunspell/UnpackedTarball_hunspell.mk b/external/hunspell/UnpackedTarball_hunspell.mk index 33614a39292d..2b8823021998 100644 --- a/external/hunspell/UnpackedTarball_hunspell.mk +++ b/external/hunspell/UnpackedTarball_hunspell.mk @@ -22,9 +22,7 @@ endif $(eval $(call gb_UnpackedTarball_set_patchlevel,hunspell,1)) $(eval $(call gb_UnpackedTarball_add_patches,hunspell, \ - external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch \ - external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch \ - external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch \ + external/hunspell/0001-fix-LibreOffice-build-problem-with-basic_string-appe.patch \ )) # vim: set noet sw=4 ts=4: commit b0dee7f726b7e5dde5d9967cbb5ebe775809b702 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Aug 23 15:25:54 2022 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Wed Sep 25 13:41:18 2024 +0200 backport some upstream hunspell commits Change-Id: I0c2b94a27af8c25c69579b367b944a4f77036487 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138735 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 9fda7a0c938fdae3e57c7a8121a94459f2749dc2) diff --git a/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch b/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch new file mode 100644 index 000000000000..58b68d0dda43 --- /dev/null +++ b/external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch @@ -0,0 +1,27 @@ +From 56ad6310c95695d25f936d3f89f6ee3d787df274 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> +Date: Mon, 22 Aug 2022 21:21:36 +0100 +Subject: [PATCH] check 'len' in cpdpat_check like 'r1->blen' is checked (#633) + (#780) + +we should check len against pos like we do r1->blen in the line above +--- + src/hunspell/affixmgr.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx +index 7ea1ea5..c2432c0 100644 +--- a/src/hunspell/affixmgr.cxx ++++ b/src/hunspell/affixmgr.cxx +@@ -1330,7 +1330,7 @@ int AffixMgr::cpdpat_check(const char* word, + ((checkcpdtable[i].pattern[0] == '0' && r1->blen <= pos && + strncmp(word + pos - r1->blen, r1->word, r1->blen) == 0) || + (checkcpdtable[i].pattern[0] != '0' && +- ((len = checkcpdtable[i].pattern.size()) != 0) && ++ ((len = checkcpdtable[i].pattern.size()) != 0) && len <= pos && + strncmp(word + pos - len, checkcpdtable[i].pattern.c_str(), len) == 0)))) { + return 1; + } +-- +2.37.2 + diff --git a/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch b/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch new file mode 100644 index 000000000000..a42d38f5153a --- /dev/null +++ b/external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch @@ -0,0 +1,52 @@ +From 75ebf084f941c0fe72904b6167079d9190f885e5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> +Date: Tue, 23 Aug 2022 11:44:36 +0100 +Subject: [PATCH] improve #630 test case from 0m1.836s -> 0m1.223s (#785) + +--- + src/hunspell/csutil.cxx | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/hunspell/csutil.cxx b/src/hunspell/csutil.cxx +index e9cce47..5caa771 100644 +--- a/src/hunspell/csutil.cxx ++++ b/src/hunspell/csutil.cxx +@@ -171,8 +171,10 @@ std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { + } + + int u8_u16(std::vector<w_char>& dest, const std::string& src) { +- dest.clear(); +- dest.reserve(src.size()); ++ // faster to oversize initially, assign to elements and resize to what's used ++ // than to reserve and push_back ++ dest.resize(src.size()); ++ std::vector<w_char>::iterator u16 = dest.begin(); + std::string::const_iterator u8 = src.begin(); + std::string::const_iterator u8_max = src.end(); + +@@ -254,16 +256,18 @@ int u8_u16(std::vector<w_char>& dest, const std::string& src) { + src.c_str()); + u2.h = 0xff; + u2.l = 0xfd; +- dest.push_back(u2); ++ *u16++ = u2; ++ dest.resize(u16 - dest.begin()); + return -1; + } + } +- dest.push_back(u2); ++ *u16++ = u2; + ++u8; + } + +- dest.shrink_to_fit(); +- return dest.size(); ++ int size = u16 - dest.begin(); ++ dest.resize(size); ++ return size; + } + + namespace { +-- +2.37.2 + diff --git a/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch b/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch new file mode 100644 index 000000000000..c3de49178ada --- /dev/null +++ b/external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch @@ -0,0 +1,40 @@ +From 211e1e6f36756579b86fa12891af3e5843cd8907 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> +Date: Tue, 23 Aug 2022 10:18:31 +0100 +Subject: [PATCH] improve #630 test case from 0m2.427s -> 0m1.836s (#781) + +--- + src/hunspell/csutil.cxx | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/hunspell/csutil.cxx b/src/hunspell/csutil.cxx +index fbaa768..e9cce47 100644 +--- a/src/hunspell/csutil.cxx ++++ b/src/hunspell/csutil.cxx +@@ -134,6 +134,7 @@ void myopen(std::ifstream& stream, const char* path, std::ios_base::openmode mod + + std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { + dest.clear(); ++ dest.reserve(src.size()); + std::vector<w_char>::const_iterator u2 = src.begin(); + std::vector<w_char>::const_iterator u2_max = src.end(); + while (u2 < u2_max) { +@@ -171,6 +172,7 @@ std::string& u16_u8(std::string& dest, const std::vector<w_char>& src) { + + int u8_u16(std::vector<w_char>& dest, const std::string& src) { + dest.clear(); ++ dest.reserve(src.size()); + std::string::const_iterator u8 = src.begin(); + std::string::const_iterator u8_max = src.end(); + +@@ -260,6 +262,7 @@ int u8_u16(std::vector<w_char>& dest, const std::string& src) { + ++u8; + } + ++ dest.shrink_to_fit(); + return dest.size(); + } + +-- +2.37.2 + diff --git a/external/hunspell/UnpackedTarball_hunspell.mk b/external/hunspell/UnpackedTarball_hunspell.mk index 37a2d196fbf5..33614a39292d 100644 --- a/external/hunspell/UnpackedTarball_hunspell.mk +++ b/external/hunspell/UnpackedTarball_hunspell.mk @@ -22,6 +22,9 @@ endif $(eval $(call gb_UnpackedTarball_set_patchlevel,hunspell,1)) $(eval $(call gb_UnpackedTarball_add_patches,hunspell, \ + external/hunspell/0001-check-len-in-cpdpat_check-like-r1-blen-is-checked-63.patch \ + external/hunspell/0001-improve-630-test-case-from-0m2.427s-0m1.836s-781.patch \ + external/hunspell/0001-improve-630-test-case-from-0m1.836s-0m1.223s-785.patch \ )) # vim: set noet sw=4 ts=4: commit 7280ea32d5ca37f57d4c3afc120fb1c288a1d471 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Aug 22 15:05:40 2022 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Wed Sep 25 13:40:03 2024 +0200 upgrade to hunspell 1.7.1 Change-Id: Ifff2f17d17ab2764f3703b008fcb096ff08c9315 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138690 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 46003cb1c4c770a9ba4eb9b2a55561c2ebeb3519) diff --git a/download.lst b/download.lst index cce64419a825..fff9377ad763 100644 --- a/download.lst +++ b/download.lst @@ -239,8 +239,8 @@ HSQLDB_TARBALL := 17410483b5b5f267aa18b7e00b65e6e0-hsqldb_1_8_0.zip # three static lines # so that git cherry-pick # will not run into conflicts -HUNSPELL_SHA256SUM := 57be4e03ae9dd62c3471f667a0d81a14513e314d4d92081292b90435944ff951 -HUNSPELL_TARBALL := hunspell-1.7.0.tar.gz +HUNSPELL_SHA256SUM := b2d9c5369c2cc7f321cb5983fda2dbf007dce3d9e17519746840a6f0c4bf7444 +HUNSPELL_TARBALL := hunspell-1.7.1.tar.gz # three static lines # so that git cherry-pick # will not run into conflicts diff --git a/external/hunspell/0001-invalid-read-memory-access-624.patch b/external/hunspell/0001-invalid-read-memory-access-624.patch deleted file mode 100644 index 66b55e7555bd..000000000000 --- a/external/hunspell/0001-invalid-read-memory-access-624.patch +++ /dev/null @@ -1,25 +0,0 @@ -From ac938e2ecb48ab4dd21298126c7921689d60571b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]> -Date: Tue, 12 Nov 2019 20:03:15 +0000 -Subject: [PATCH] invalid read memory access #624 - ---- - src/hunspell/suggestmgr.cxx | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/hunspell/suggestmgr.cxx b/src/hunspell/suggestmgr.cxx -index dba084e..c23f165 100644 ---- a/src/hunspell/suggestmgr.cxx -+++ b/src/hunspell/suggestmgr.cxx -@@ -2040,7 +2040,7 @@ int SuggestMgr::leftcommonsubstring( - int l2 = su2.size(); - // decapitalize dictionary word - if (complexprefixes) { -- if (su1[l1 - 1] == su2[l2 - 1]) -+ if (l1 && l2 && su1[l1 - 1] == su2[l2 - 1]) - return 1; - } else { - unsigned short idx = su2.empty() ? 0 : (su2[0].h << 8) + su2[0].l; --- -2.23.0 - diff --git a/external/hunspell/UnpackedTarball_hunspell.mk b/external/hunspell/UnpackedTarball_hunspell.mk index 1cd24e225868..37a2d196fbf5 100644 --- a/external/hunspell/UnpackedTarball_hunspell.mk +++ b/external/hunspell/UnpackedTarball_hunspell.mk @@ -22,7 +22,6 @@ endif $(eval $(call gb_UnpackedTarball_set_patchlevel,hunspell,1)) $(eval $(call gb_UnpackedTarball_add_patches,hunspell, \ - external/hunspell/0001-invalid-read-memory-access-624.patch \ )) # vim: set noet sw=4 ts=4: commit 8c55a75da370ce7a780f1887b77b85e71a2b283f Author: Michael Stahl <[email protected]> AuthorDate: Wed Sep 25 12:55:35 2024 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Wed Sep 25 13:18:49 2024 +0200 sw: split layoutwriter test same as in master Getting error C1128: number of sections exceeded object file format limit Change-Id: I796f836af7e5f60f1732b515de9bb894b30828d2 diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index fd1e190ed427..a6bf1b526dfe 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -14765,6 +14765,8 @@ sw/qa/extras/globalfilter/globalfilter.cxx sw/qa/extras/htmlexport/htmlexport.cxx sw/qa/extras/htmlimport/htmlimport.cxx sw/qa/extras/layout/layout.cxx +sw/qa/extras/layout/layout2.cxx +sw/qa/extras/layout/layout3.cxx sw/qa/extras/mailmerge/mailmerge.cxx sw/qa/extras/odfexport/odfexport.cxx sw/qa/extras/odfimport/odfimport.cxx diff --git a/sw/CppunitTest_sw_layoutwriter2.mk b/sw/CppunitTest_sw_layoutwriter2.mk new file mode 100644 index 000000000000..5fb5a2e41401 --- /dev/null +++ b/sw/CppunitTest_sw_layoutwriter2.mk @@ -0,0 +1,81 @@ +# -*- 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_layoutwriter2)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_layoutwriter2)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_layoutwriter2, \ + sw/qa/extras/layout/layout2 \ +)) + +# note: this links msword only for the reason to have an order dependency, +# because "make sw.check" will not see the dependency through services.rdb +$(eval $(call gb_CppunitTest_use_libraries,sw_layoutwriter2, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + msword \ + sal \ + sfx \ + svl \ + svt \ + svxcore \ + sw \ + test \ + unotest \ + vcl \ + tl \ + utl \ + i18nlangtag \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_layoutwriter2,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_layoutwriter2,\ + -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_api,sw_layoutwriter2,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_layoutwriter2)) +$(eval $(call gb_CppunitTest_use_vcl,sw_layoutwriter2)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_layoutwriter2,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_layoutwriter2,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_layoutwriter2)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_layoutwriter2, \ + modules/swriter \ +)) + +$(call gb_CppunitTest_get_target,sw_layoutwriter2): \ + $(call gb_Library_get_target,textconv_dict) + +$(eval $(call gb_CppunitTest_use_more_fonts,sw_layoutwriter2)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/CppunitTest_sw_layoutwriter3.mk b/sw/CppunitTest_sw_layoutwriter3.mk new file mode 100644 index 000000000000..9eeb81b74dfe --- /dev/null +++ b/sw/CppunitTest_sw_layoutwriter3.mk @@ -0,0 +1,81 @@ +# -*- 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_layoutwriter3)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_layoutwriter3)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_layoutwriter3, \ + sw/qa/extras/layout/layout3 \ +)) + +# note: this links msword only for the reason to have an order dependency, +# because "make sw.check" will not see the dependency through services.rdb +$(eval $(call gb_CppunitTest_use_libraries,sw_layoutwriter3, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + msword \ + sal \ + sfx \ + svl \ + svt \ + svxcore \ + sw \ + test \ + unotest \ + vcl \ + tl \ + utl \ + i18nlangtag \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_layoutwriter3,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_layoutwriter3,\ + -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_api,sw_layoutwriter3,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_layoutwriter3)) +$(eval $(call gb_CppunitTest_use_vcl,sw_layoutwriter3)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_layoutwriter3,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_layoutwriter3,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_layoutwriter3)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_layoutwriter3, \ + modules/swriter \ +)) + +$(call gb_CppunitTest_get_target,sw_layoutwriter3): \ + $(call gb_Library_get_target,textconv_dict) + +$(eval $(call gb_CppunitTest_use_more_fonts,sw_layoutwriter3)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 943748922397..5a9187336e19 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -100,6 +100,8 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_uiwriter \ ) \ CppunitTest_sw_layoutwriter \ + CppunitTest_sw_layoutwriter2 \ + CppunitTest_sw_layoutwriter3 \ CppunitTest_sw_mailmerge \ CppunitTest_sw_globalfilter \ CppunitTest_sw_accessible_relation_set \ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 5bab734c67fe..6ae522c346c2 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -50,7 +50,6 @@ class SwLayoutWriter : public SwModelTestBase protected: void CheckRedlineFootnotesHidden(); void CheckRedlineSectionsHidden(); - void CheckRedlineCharAttributesHidden(); SwDoc* createDoc(const char* pName = nullptr); @@ -237,12 +236,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFootnotes) CheckRedlineFootnotesHidden(); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testOfz64109) -{ - //just care it doesn't assert - createDoc("ofz64109-1.fodt"); -} - CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) { loadURL("private:factory/swriter", nullptr); @@ -2236,2009 +2229,208 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables) assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foar"); } -// this mainly tests that splitting portions across redlines in SwAttrIter works -void SwLayoutWriter::CheckRedlineCharAttributesHidden() +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137) { - discardDumpedLayout(); + createDoc("tdf109137.docx"); + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({ + { "FilterName", uno::Any(OUString("writer8")) }, + })); + xStorable->storeToURL(aTempFile.GetURL(), aDescriptor); + loadURL(aTempFile.GetURL(), "tdf109137.odt"); xmlDocPtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "9"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foobaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/merged", "paraPropsNodeIndex", "10"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "foobaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/merged", "paraPropsNodeIndex", "11"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/merged", "paraPropsNodeIndex", "12"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/merged", "paraPropsNodeIndex", "13"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/merged", "paraPropsNodeIndex", "14"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/merged", "paraPropsNodeIndex", "15"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/merged", "paraPropsNodeIndex", "16"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/merged", "paraPropsNodeIndex", "17"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "Portion", "foobaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/merged", "paraPropsNodeIndex", "18"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "Portion", "ob"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/merged", "paraPropsNodeIndex", "19"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "Portion", "foobaz"); + // This was 0, the blue rectangle moved from the 1st to the 2nd page. + assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly/notxt", + /*nNumberOfNodes=*/1); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineCharAttributes) -{ - createDoc("redline_charatr.fodt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); - CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - - // verify after load - CheckRedlineCharAttributesHidden(); - - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); - CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - discardDumpedLayout(); - xmlDocPtr pXmlDoc = parseLayoutDump(); +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint72) { createDoc("forcepoint72-1.rtf"); } - // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "Portion", "ba"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[3]", "Portion", "r"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[4]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[4]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[4]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[4]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[5]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[5]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[2]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[3]", "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[4]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[4]", "Portion", "r"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[5]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[5]", "Portion", "baz"); +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint75) { createDoc("forcepoint75-1.rtf"); } - // verify after hide - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); - CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - CheckRedlineCharAttributesHidden(); -} +// FIXME: apparently infinite loop on Mac +#ifndef MACOSX +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testUXTSOREL) { createDoc("LIBREOFFICE-UXTSOREL.rtf"); } +#endif -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineShowHideFootnotePagination) +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepointFootnoteFrame) { - createDoc("redline_footnote_pagination.fodt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); - CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - - xmlDocPtr pXmlDoc = parseLayoutDump(); - - // check footnotes - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 6); - assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 3); - // check that first page ends with the y line and second page starts with z - assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/LineBreak[last()]", "Line", - "yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy "); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/LineBreak[1]", "Line", - "zzz. zzz zzzz zzzz7 zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); - - // hide redlines - all still visible footnotes move to page 1 - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); - - discardDumpedLayout(); - pXmlDoc = parseLayoutDump(); - - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 2); - assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 0); - - // show again - should now get the same result as on loading - lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); - - discardDumpedLayout(); - pXmlDoc = parseLayoutDump(); - - // check footnotes - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 6); - assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 3); - // check that first page ends with the y line and second page starts with z - assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/LineBreak[last()]", "Line", - "yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy "); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/LineBreak[1]", "Line", - "zzz. zzz zzzz zzzz7 zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); + createDoc("forcepoint-swfootnoteframe-1.rtf"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineNumberInNumbering) +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint76) { - SwDoc* pDoc = createDoc("tdf42748.fodt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; + createDoc("forcepoint76-1.rtf"); +} - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testN4LA0OHZ) { createDoc("LIBREOFFICE-N4LA0OHZ.rtf"); } - // Assert the tracked deletion of the number of joined list item and - // the tracked insertion of the number after a split list item as not black elements - assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[not(@color='#000000')]", 6); +//just care it doesn't crash/assert +#if 0 // no createSwWebDoc +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint89) +{ + createSwWebDoc(DATA_DIRECTORY, "forcepoint89.html"); } +#endif -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125300) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint90) { - SwDoc* pDoc = createDoc("tdf125300.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // Keep line spacing before bottom cell border (it was 1892) - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[5]/polyline/point[@y='2092']", 2); + createDoc("forcepoint90.rtf"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116830) +//just care it doesn't crash/assert +#if 0 // no createSwWebDoc +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint91) { - SwDoc* pDoc = createDoc("tdf116830.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwWebDoc(DATA_DIRECTORY, "forcepoint91.html"); +} +#endif - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { createDoc("forcepoint92.doc"); } - // Assert that the yellow rectangle (cell background) is painted after the - // polypolygon (background shape). - // Background shape: 1.1.1.2 - // Cell background: 1.1.1.3 - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/fillcolor[@color='#729fcf']", 1); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/polypolygon", - 1); - - // This failed: cell background was painted before the background shape. - assertXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/fillcolor[@color='#ffff00']", 1); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1); +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93) +{ +//fails to load createDoc("forcepoint93-1.rtf"); +//layout loop createDoc("forcepoint93-2.rtf"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf114163) +#if 0 // no createSwWebDoc +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) { - SwDoc* pDoc = createDoc("tdf114163.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[12]/text", - "Data3"); - // This failed, if the legend first label is not "Data3". The legend position is right. + createSwWebDoc(DATA_DIRECTORY, "forcepoint94.html"); } +#endif -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125335) +//just care it doesn't crash/assert +#if 0 // no createSwWebDoc +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint98) { - SwDoc* pDoc = createDoc("tdf125335.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[12]/text", - "Data3"); - // This failed, if the legend first label is not "Data3". The legend position is bottom. + createSwWebDoc(DATA_DIRECTORY, "forcepoint98.html"); } +#endif -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf75659) +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint102) { - SwDoc* pDoc = createDoc("tdf75659.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[17]/text", "Series1"); - - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[18]/text", "Series2"); - - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[19]/text", "Series3"); - // These failed, if the legend names are empty strings. + createDoc("forcepoint102.rtf"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf123268) +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf147485Forcepoint) { - SwDoc* pDoc = createDoc("tdf123268.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 41 - // - Actual : 0 - // i.e. the chart lost. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push", - 41); + createDoc("tdf147485-forcepoint.doc"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf115630) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118058) { - SwDoc* pDoc = createDoc("tdf115630.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // Test wide of inner chart area. - sal_Int32 nXRight - = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[1]", - "x") - .toInt32(); - sal_Int32 nXLeft - = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[2]", - "x") - .toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2895, nXRight - nXLeft, 50); + SwDoc* pDoc = createDoc("tdf118058.fodt"); + // This resulted in a layout loop. + pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf108021) +//just care it doesn't crash/assert +#if 0 // no createSwWebDoc +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint99) { - SwDoc* pDoc = createDoc("tdf108021.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='22']", - 8); - // This failed, if the textarray length of the first axis label not 22. + createSwWebDoc(DATA_DIRECTORY, "forcepoint99.html"); } +#endif -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125334) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128611) { - SwDoc* pDoc = createDoc("tdf125334.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + createDoc("tdf128611.fodt"); + xmlDocPtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT(pXmlDoc); - - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='17']", - 4); - // This failed, if the textarray length of the category axis label not 17. + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 14 + // i.e. there were multiple portions in the first paragraph of the A1 cell, which means that the + // rotated text was broken into multiple lines without a good reason. + assertXPath(pXmlDoc, "//tab/row/cell[1]/txt/Text", "Portion", "Abcd efghijkl"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122800) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testKeepWithNextPlusFlyFollowTextFlow) { - SwDoc* pDoc = createDoc("tdf122800.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createDoc("keep-with-next-fly.fodt"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + { + xmlDocPtr pXmlDoc = parseLayoutDump(); + // 3 text frames on page 1 + assertXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "bottom", "7540"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly/infos/bounds", "top", "1694"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page", 1); + discardDumpedLayout(); + } - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='22']", - 9); - // This failed, if the textarray length of the first axis label not 22. -} + lcl_dispatchCommand(mxComponent, ".uno:Fieldnames", {}); + Scheduler::ProcessEventsToIdle(); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTruncatedAxisLabel) -{ - SwDoc* pDoc = createDoc("testTruncatedAxisLabel.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + { + xmlDocPtr pXmlDoc = parseLayoutDump(); + // 1 text frame on page 1, and some empty space + assertXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "bottom", "7540"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", "5796"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "bottom", "7213"); + // 2 text frames on page 2 + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly/infos/bounds", "top", "10093"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page", 2); + discardDumpedLayout(); + } - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + lcl_dispatchCommand(mxComponent, ".uno:Fieldnames", {}); + Scheduler::ProcessEventsToIdle(); - // test the X axis label visibility - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[1]/text", - "Long axis label truncated 1"); - - // test the Y axis label visibility - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[3]/text", - "-5.00"); + { + xmlDocPtr pXmlDoc = parseLayoutDump(); + // 3 text frames on page 1 + assertXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "bottom", "7540"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly/infos/bounds", "top", "1694"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", "276"); + assertXPath(pXmlDoc, "/root/page", 1); + discardDumpedLayout(); + } } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128996) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrTableRowSpan) { - SwDoc* pDoc = createDoc("tdf128996.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. + // Load a document which has a table. The A1 cell has btlr text direction, and the A1..A3 cells + // are merged. + load(DATA_DIRECTORY, "btlr-table-row-span.odt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + MetafileXmlDump aDumper; + xmlDocPtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); - assertXPathContent(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[1]/text", - "A very long category name 1"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: USA + // - Actual : West + // i.e. the "USA" text completely disappeared. + assertXPathContent(pXmlDoc, "//textarray[1]/text", "USA"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf126244) -{ - SwDoc* pDoc = createDoc("tdf126244.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Test the first level of vertical category axis labels orientation. The first level orientation should be horizontal. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/font[1]", "orientation", - "0"); - // Test the second level of vertical category axis labels orientation. The second level orientation should be vertical. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/font[5]", "orientation", - "900"); - // Test the third level of vertical category axis labels orientation. The third level orientation should be vertical. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/font[7]", "orientation", - "900"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf127304) -{ - SwDoc* pDoc = createDoc("tdf127304.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Test the first level of horizontal category axis labels orientation. The first level orientation should be vertical. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/font[1]", "orientation", - "900"); - // Test the second level of horizontal category axis labels orientation. The second level orientation should be horizontal. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/font[5]", "orientation", - "0"); - // Test the third level of horizontal category axis labels orientation. The third level orientation should be horizontal. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/font[7]", "orientation", - "0"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testHorizontal_multilevel) -{ - SwDoc* pDoc = createDoc("horizontal_multilevel.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Test the Y position of horizontal category axis label. - sal_Int32 nYposition - = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/textarray[7]", "y") - .toInt32(); - CPPUNIT_ASSERT(nYposition > 7943 && nYposition < 7947); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124796) -{ - SwDoc* pDoc = createDoc("tdf124796.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // This failed, if the minimum value of Y axis is not -10. - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[5]/text", - "-10"); - - // This failed, if the maximum value of Y axis is not 15. - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[10]/text", - "15"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129054) -{ - SwDoc* pDoc = createDoc("tdf129054.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // Test the size of diameter of Pie chart. - sal_Int32 nYTop - = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[1]", - "y") - .toInt32(); - sal_Int32 nYBottom - = getXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[31]", - "y") - .toInt32(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4810), nYTop - nYBottom); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129173) -{ - SwDoc* pDoc = createDoc("testAreaChartNumberFormat.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // Check the first data label of area chart. - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[22]/text", "56"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129095) -{ - SwDoc* pDoc = createDoc("tdf129095.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // check the inner chart area (relative size) visibility with testing the X axis label - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray/text", - "Category 1"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf132956) -{ - SwDoc* pDoc = createDoc("tdf132956.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // check the inner chart area (default size) visibility with testing the X axis label - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray/text", - "Category 1"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925) -{ - SwDoc* pDoc = createDoc("tdf116925.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPathContent(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textarray/text", - "hello"); - // This failed, text color was #000000. - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textcolor[@color='#ffffff']", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117028) -{ - SwDoc* pDoc = createDoc("tdf117028.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // The only polypolygon in the rendering result was the white background we - // want to avoid. - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polypolygon"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - - // Make sure the text is still rendered. - assertXPathContent(pXmlDoc, "//textarray/text", "Hello"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106390) -{ - SwDoc* pDoc = createDoc("tdf106390.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nBottom = getXPath(pXmlDoc, "//sectrectclipregion", "bottom").toInt32(); - - // No end point of line segments shall go below the bottom of the clipping area. - const OString sXPath = "//polyline/point[@y>" + OString::number(nBottom) + "]"; - - assertXPath(pXmlDoc, sXPath, 0); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableExtrusion1) -{ - SwDoc* pDoc = createDoc("table-extrusion1.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nRight = getXPath(pXmlDoc, "//sectrectclipregion", "right").toInt32(); - sal_Int32 nLeft = static_cast<sal_Int32>(nRight * 0.95); - - // Expect table borders in right page margin. - const OString sXPath = "//polyline/point[@x>" + OString::number(nLeft) + " and @x<" - + OString::number(nRight) + "]"; - - assertXPath(pXmlDoc, sXPath, 4); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableExtrusion2) -{ - SwDoc* pDoc = createDoc("table-extrusion2.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // End point position of the outer table. - sal_Int32 nX = getXPath(pXmlDoc, "(//polyline[1]/point)[2]", "x").toInt32(); - - // Do not allow inner table extrude outer table. - const OString sXPath = "//polyline/point[@x>" + OString::number(nX) + "]"; - - assertXPath(pXmlDoc, sXPath, 0); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116848) -{ - SwDoc* pDoc = createDoc("tdf116848.odt"); - // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117245) -{ - createDoc("tdf117245.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // This was 2, TabOverMargin did not use a single line when there was - // enough space for the text. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1); - - // This was 2, same problem elsewhere due to code duplication. - assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118672) -{ - createDoc("tdf118672.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - - // Check if we have hyphenation support, otherwise can't test SwHyphPortion. - uno::Reference<linguistic2::XLinguServiceManager2> xLinguServiceManager - = linguistic2::LinguServiceManager::create(comphelper::getProcessComponentContext()); - uno::Sequence<lang::Locale> aLocales - = xLinguServiceManager->getAvailableLocales("com.sun.star.linguistic2.Hyphenator"); - if (std::none_of(aLocales.begin(), aLocales.end(), [](const lang::Locale& rLocale) { - return rLocale.Language == "en" && rLocale.Country == "US"; - })) - return; - - const OUString aLine1( - "He heard quiet steps behind him. That didn't bode well. Who could be fol*1 2 " - "3 4 5 6 7 8 9 10con-"); - // This ended as "fol*1 2 3 4 5 6 7 8 9", i.e. "10con-" was moved to the next line. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak[1]", "Line", aLine1); - const OUString aLine2("setetur"); - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak[2]", "Line", aLine2); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117923) -{ - createDoc("tdf117923.doc"); - // Ensure that all text portions are calculated before testing. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwViewShell* pViewShell - = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); - CPPUNIT_ASSERT(pViewShell); - pViewShell->Reformat(); - - xmlDocPtr pXmlDoc = parseLayoutDump(); - - // Check that we actually test the line we need - assertXPathContent(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]", "GHI GHI GHI GHI"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nType", - "PortionType::Number"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "rText", "2."); - // The numbering height was 960. - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf127606) -{ - createDoc("tdf117923.docx"); - // Ensure that all text portions are calculated before testing. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwViewShell* pViewShell - = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); - CPPUNIT_ASSERT(pViewShell); - pViewShell->Reformat(); - - xmlDocPtr pXmlDoc = parseLayoutDump(); - - // Check that we actually test the line we need - assertXPathContent(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]", "GHI GHI GHI GHI"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nType", - "PortionType::Number"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "rText", "2."); - // The numbering height was 960 in DOC format. - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220"); - - // tdf#127606: now it's possible to change formatting of numbering - // increase font size (220 -> 260) - lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); - lcl_dispatchCommand(mxComponent, ".uno:Grow", {}); - pViewShell->Reformat(); - discardDumpedLayout(); - pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "260"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109077) -{ - createDoc("tdf109077.docx"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - sal_Int32 nShapeTop - = getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds", "top").toInt32(); - sal_Int32 nTextBoxTop = getXPath(pXmlDoc, "//anchored/fly/infos/bounds", "top").toInt32(); - // This was 281: the top of the shape and its textbox should match, though - // tolerate differences <= 1px (about 15 twips). - CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(15), nTextBoxTop - nShapeTop); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testUserFieldTypeLanguage) -{ - // Set the system locale to German, the document will be English. - SvtSysLocaleOptions aOptions; - OUString sLocaleConfigString = aOptions.GetLanguageTag().getBcp47(); - aOptions.SetLocaleConfigString("de-DE"); - aOptions.Commit(); - comphelper::ScopeGuard g([&aOptions, &sLocaleConfigString] { - aOptions.SetLocaleConfigString(sLocaleConfigString); - aOptions.Commit(); - }); - - SwDoc* pDoc = createDoc("user-field-type-language.fodt"); - SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); - pViewShell->UpdateFields(); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // This was "123,456.00", via a buggy 1234.56 -> 1234,56 -> 123456 -> - // 123,456.00 transform chain. - assertXPath(pXmlDoc, "/root/page/body/txt/Special[@nType='PortionType::Field']", "rText", - "1,234.56"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137) -{ - createDoc("tdf109137.docx"); - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - })); - xStorable->storeToURL(aTempFile.GetURL(), aDescriptor); - loadURL(aTempFile.GetURL(), "tdf109137.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // This was 0, the blue rectangle moved from the 1st to the 2nd page. - assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly/notxt", - /*nNumberOfNodes=*/1); -} - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint72) { createDoc("forcepoint72-1.rtf"); } - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint75) { createDoc("forcepoint75-1.rtf"); } - -// FIXME: apparently infinite loop on Mac -#ifndef MACOSX -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testUXTSOREL) { createDoc("LIBREOFFICE-UXTSOREL.rtf"); } -#endif - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepointFootnoteFrame) -{ - createDoc("forcepoint-swfootnoteframe-1.rtf"); -} - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint76) -{ - createDoc("forcepoint76-1.rtf"); -} - -//just care it doesn't crash/assert -#if 0 // no createSwWebDoc -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint89) -{ - createSwWebDoc(DATA_DIRECTORY, "forcepoint89.html"); -} -#endif - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testN4LA0OHZ) { createDoc("LIBREOFFICE-N4LA0OHZ.rtf"); } - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint90) -{ - createDoc("forcepoint90.rtf"); -} - -//just care it doesn't crash/assert -#if 0 // no createSwWebDoc -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint91) -{ - createSwWebDoc(DATA_DIRECTORY, "forcepoint91.html"); -} -#endif - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { createDoc("forcepoint92.doc"); } - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93) -{ -//fails to load createDoc("forcepoint93-1.rtf"); -//layout loop createDoc("forcepoint93-2.rtf"); -} - -#if 0 // no createSwWebDoc -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) -{ - createSwWebDoc(DATA_DIRECTORY, "forcepoint94.html"); -} -#endif - -//just care it doesn't crash/assert -#if 0 // no createSwWebDoc -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint98) -{ - createSwWebDoc(DATA_DIRECTORY, "forcepoint98.html"); -} -#endif - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint102) -{ - createDoc("forcepoint102.rtf"); -} - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf147485Forcepoint) -{ - createDoc("tdf147485-forcepoint.doc"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118058) -{ - SwDoc* pDoc = createDoc("tdf118058.fodt"); - // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); -} - -//just care it doesn't crash/assert -#if 0 // no createSwWebDoc -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint99) -{ - createSwWebDoc(DATA_DIRECTORY, "forcepoint99.html"); -} -#endif - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128611) -{ - createDoc("tdf128611.fodt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 1 - // - Actual : 14 - // i.e. there were multiple portions in the first paragraph of the A1 cell, which means that the - // rotated text was broken into multiple lines without a good reason. - assertXPath(pXmlDoc, "//tab/row/cell[1]/txt/Text", "Portion", "Abcd efghijkl"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117188) -{ - createDoc("tdf117188.docx"); - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - })); - xStorable->storeToURL(aTempFile.GetURL(), aDescriptor); - loadURL(aTempFile.GetURL(), "tdf117188.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - OUString sWidth = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds", "width"); - OUString sHeight = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds", "height"); - // The text box must have zero border distances - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "left", "0"); - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "top", "0"); - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "width", sWidth); - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "height", sHeight); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117187) -{ - createDoc("tdf117187.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - - // there should be no fly portions - assertXPath(pXmlDoc, "/root/page/body/txt/Special[@nType='PortionType::Fly']", 0); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf119875) -{ - createDoc("tdf119875.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - - assertXPath(pXmlDoc, "//page[2]/body/section[1]", "formatName", u"S10"); - assertXPath(pXmlDoc, "//page[2]/body/section[2]", "formatName", u"S11"); - assertXPath(pXmlDoc, "//page[2]/body/section[3]", "formatName", u"S13"); - assertXPath(pXmlDoc, "//page[2]/body/section[4]", "formatName", u"S14"); - // Sections "S10" and "S13" are hidden -> their frames are zero-height - assertXPath(pXmlDoc, "//page[2]/body/section[1]/infos/bounds", "height", u"0"); - assertXPath(pXmlDoc, "//page[2]/body/section[3]/infos/bounds", "height", u"0"); - - OUString S10Top = getXPath(pXmlDoc, "//page[2]/body/section[1]/infos/bounds", "top"); - OUString S11Top = getXPath(pXmlDoc, "//page[2]/body/section[2]/infos/bounds", "top"); - OUString S13Top = getXPath(pXmlDoc, "//page[2]/body/section[3]/infos/bounds", "top"); - OUString S14Top = getXPath(pXmlDoc, "//page[2]/body/section[4]/infos/bounds", "top"); - - CPPUNIT_ASSERT_EQUAL(S10Top, S11Top); - CPPUNIT_ASSERT_EQUAL(S13Top, S14Top); - - // Section "S11" had the same top value as section "S14", so they overlapped. - CPPUNIT_ASSERT_LESS(S14Top.toInt32(), S11Top.toInt32()); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287) -{ - createDoc("tdf120287.fodt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // This was 2, TabOverMargin Word-specific compat flag did not imply - // default-in-Word printer-independent layout, resulting in an additional - // line break. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287b) -{ - createDoc("tdf120287b.fodt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // This was 1418, TabOverMargin did the right split of the paragraph to two - // lines, but then calculated a too large tab portion size on the first - // line. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/Text[@nType='PortionType::TabRight']", "nWidth", - "17"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287c) -{ - createDoc("tdf120287c.fodt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // This was 2, the second line was not broken into a 2nd and a 3rd one, - // rendering text outside the paragraph frame. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 3); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122878) -{ - createDoc("tdf122878.docx"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - // FIXME: the XPath should be adjusted when the proper floating table would be imported - const sal_Int32 nTblTop - = getXPath(pXmlDoc, "/root/page[1]/footer/txt/anchored/fly/tab/infos/bounds", "top") - .toInt32(); - const sal_Int32 nFirstPageParaCount - = getXPathContent(pXmlDoc, "count(/root/page[1]/body/txt)").toInt32(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(30), nFirstPageParaCount); - for (sal_Int32 i = 1; i <= nFirstPageParaCount; ++i) - { - const OString xPath = "/root/page[1]/body/txt[" + OString::number(i) + "]/infos/bounds"; - const sal_Int32 nTxtBottom = getXPath(pXmlDoc, xPath.getStr(), "top").toInt32() - + getXPath(pXmlDoc, xPath.getStr(), "height").toInt32(); - // No body paragraphs should overlap the table in the footer - CPPUNIT_ASSERT_MESSAGE(OString("testing paragraph #" + OString::number(i)).getStr(), - nTxtBottom <= nTblTop); - } -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf115094) -{ - createDoc("tdf115094.docx"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - - sal_Int32 nTopOfD1 - = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/tab/row[1]/cell[4]/infos/bounds", - "top") - .toInt32(); - sal_Int32 nTopOfD1Anchored = getXPath(pXmlDoc, - "/root/page/body/txt/anchored/fly/tab/row[1]/cell[4]/" - "txt[2]/anchored/fly/infos/bounds", - "top") - .toInt32(); - CPPUNIT_ASSERT_LESS(nTopOfD1Anchored, nTopOfD1); - sal_Int32 nTopOfB2 - = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/tab/row[2]/cell[2]/infos/bounds", - "top") - .toInt32(); - sal_Int32 nTopOfB2Anchored = getXPath(pXmlDoc, - "/root/page/body/txt/anchored/fly/tab/row[2]/cell[2]/" - "txt[1]/anchored/fly/infos/bounds", - "top") - .toInt32(); - CPPUNIT_ASSERT_LESS(nTopOfB2Anchored, nTopOfB2); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testKeepWithNextPlusFlyFollowTextFlow) -{ - createDoc("keep-with-next-fly.fodt"); - - { - xmlDocPtr pXmlDoc = parseLayoutDump(); - // 3 text frames on page 1 - assertXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "bottom", "7540"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly", 1); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly/infos/bounds", "top", "1694"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page", 1); - discardDumpedLayout(); - } - - lcl_dispatchCommand(mxComponent, ".uno:Fieldnames", {}); - Scheduler::ProcessEventsToIdle(); - - { - xmlDocPtr pXmlDoc = parseLayoutDump(); - // 1 text frame on page 1, and some empty space - assertXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "bottom", "7540"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", "5796"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "bottom", "7213"); - // 2 text frames on page 2 - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly/infos/bounds", "top", "10093"); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page", 2); - discardDumpedLayout(); - } - - lcl_dispatchCommand(mxComponent, ".uno:Fieldnames", {}); - Scheduler::ProcessEventsToIdle(); - - { - xmlDocPtr pXmlDoc = parseLayoutDump(); - // 3 text frames on page 1 - assertXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "bottom", "7540"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly", 1); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly/infos/bounds", "top", "1694"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", "276"); - assertXPath(pXmlDoc, "/root/page", 1); - discardDumpedLayout(); - } -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122607) -{ - createDoc("tdf122607.odt"); - xmlDocPtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, - "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" - "fly/txt/Text[1]", - "nHeight", "253"); - assertXPath(pXmlDoc, - "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" - "fly/txt/Text[1]", - "nWidth", "428"); - assertXPath(pXmlDoc, - "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" - "fly/txt/Text[1]", - "Portion", "Fax:"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122607_regression) -{ - discardDumpedLayout(); - if (mxComponent.is()) - mxComponent->dispose(); - - OUString const pName("tdf122607_leerzeile.odt"); - - OUString const url(m_directories.getURLFromSrc(DATA_DIRECTORY) + pName); - - // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() - // does *not* forward initial VCL Window Resize and thereby triggers a - // layout which does not happen on soffice --convert-to pdf. - std::vector<beans::PropertyValue> aFilterOptions = { - { beans::PropertyValue("Hidden", -1, uno::Any(true), beans::PropertyState_DIRECT_VALUE) }, - }; - - std::cout << pName << ": "; - - // inline the loading because currently properties can't be passed... - mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument", - comphelper::containerToSequence(aFilterOptions)); - - CPPUNIT_ASSERT(mxComponent.is()); - - uno::Sequence<beans::PropertyValue> props(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer_pdf_Export")) }, - })); - utl::TempFile aTempFile; - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - xStorable->storeToURL(aTempFile.GetURL(), props); - - xmlDocPtr pXmlDoc = parseLayoutDump(); - // somehow these 2 rows overlapped in the PDF unless CalcLayout() runs - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "mbFixSize", - "false"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "top", "2977"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "height", "241"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "mbFixSize", - "true"); - // this was 3034, causing the overlap - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "top", "3218"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "height", "164"); - - aTempFile.EnableKillingFile(); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrCell) -{ - SwDoc* pDoc = createDoc("btlr-cell.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - - // Without the accompanying fix in place, this test would have failed, as - // the orientation was 0 (layout did not take btlr direction request from - // doc model). - assertXPath(pXmlDoc, "//font[1]", "orientation", "900"); - -#if !defined(MACOSX) && !defined(_WIN32) // macOS fails with x == 2662 for some reason. - // Without the accompanying fix in place, this test would have failed with 'Expected: 1915; - // Actual : 1756', i.e. the AAA1 text was too close to the left cell border due to an ascent vs - // descent mismatch when calculating the baseline offset of the text portion. - assertXPath(pXmlDoc, "//textarray[1]", "x", "1915"); - assertXPath(pXmlDoc, "//textarray[1]", "y", "2707"); - - // Without the accompanying fix in place, this test would have failed with 'Expected: 1979; - // Actual : 2129', i.e. the gray background of the "AAA2." text was too close to the right edge - // of the text portion. Now it's exactly behind the text portion. - assertXPath(pXmlDoc, "//rect[@top='2159']", "left", "1979"); - - // Without the accompanying fix in place, this test would have failed with 'Expected: 269; - // Actual : 0', i.e. the AAA2 frame was not visible due to 0 width. - pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "width", "269"); - - // Test the position of the cursor after doc load. - // We expect that it's inside the first text frame in the first cell. - // More precisely, this is a bottom to top vertical frame, so we expect it's at the start, which - // means it's at the lower half of the text frame rectangle (vertically). - SwWrtShell* pWrtShell = pShell->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - - const SwRect& rCharRect = pWrtShell->GetCharRect(); - SwTwips nFirstParaTop - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[1]/infos/bounds", "top").toInt32(); - SwTwips nFirstParaHeight - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[1]/infos/bounds", "height") - .toInt32(); - SwTwips nFirstParaMiddle = nFirstParaTop + nFirstParaHeight / 2; - SwTwips nFirstParaBottom = nFirstParaTop + nFirstParaHeight; - // Without the accompanying fix in place, this test would have failed: the lower half (vertical) - // range was 2273 -> 2835, the good vertical position is 2730, the bad one was 1830. - CPPUNIT_ASSERT_GREATER(nFirstParaMiddle, rCharRect.Top()); - CPPUNIT_ASSERT_LESS(nFirstParaBottom, rCharRect.Top()); - - // Save initial cursor position. - SwPosition aCellStart = *pWrtShell->GetCursor()->Start(); - - // Test that pressing "up" at the start of the cell goes to the next character position. - sal_uLong nNodeIndex = pWrtShell->GetCursor()->Start()->nNode.GetIndex(); - sal_Int32 nIndex = pWrtShell->GetCursor()->Start()->nContent.GetIndex(); - KeyEvent aKeyEvent(0, KEY_UP); - SwEditWin& rEditWin = pShell->GetView()->GetEditWin(); - rEditWin.KeyInput(aKeyEvent); - Scheduler::ProcessEventsToIdle(); - // Without the accompanying fix in place, this test would have failed: "up" was interpreted as - // logical "left", which does nothing if you're at the start of the text anyway. - CPPUNIT_ASSERT_EQUAL(nIndex + 1, pWrtShell->GetCursor()->Start()->nContent.GetIndex()); - -e ... etc. - the rest is truncated
