From 9574a62add8e4901405e12117e75c86c2d2c2f21 Mon Sep 17 00:00:00 2001 From: László Németh Date: Thu, 29 Feb 2024 14:07:34 +0100 Subject: tdf#132599 cui offapi sw xmloff: implement hyphenate-keep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both parts of a hyphenated word shall lie within a single page with ODF paragraph setting fo:hyphenation-keep="page". The implementation follows the default page layout of MSO 2016 and newer by shifting the bottom hyphenated line to the next page (and to the next column, see last note). Note: this is a MSO DOCX interoperability feature, used also in DTP software, XSL and CSS. * Add checkbox/combobox to Text Flow in paragraph dialog * Store property in paragraph model (com::sun::star::style::ParagraphProperties::ParaHyphenationKeep) * Add ODF import/export * Add ODF unit tests New constants of com::sun::star::text::ParagraphHyphenationKeepType, containing ODF AUTO and PAGE (borrowed from XSL), and for the planned extension ParaHyphenationKeepType of ParagraphProperties: – COLUMN (standard XSL value, defined in https://www.w3.org/TR/2001/REC-xsl-20011015/slice7.html#hyphenation-keep) – SPREAD and ALWAYS (CSS 4 values of hyphenate-limit-last, equivalent of hyphenation-keep, defined in https://www.w3.org/TR/css-text-4/#hyphenate-line-limits). Note: the implementation truncates only a single hyphenated line, like MSO does: the pages can end in hyphenated lines (i.e. in the case of consecutive hyphenated lines), but less often, than before. Clean-up hyphenation dialog by collecting "Don't hyphenate" options at the end of the hyphenation settings, and negating them (similar to MSO and DTP), adding also the new option "Hyphenate across column and page": [x] Hyphenate words in CAPS [x] Hyphenate last word [x] Hyphenate across column and page Note: ODF fo:hyphenation-keep has got only "auto" and "page" attributes, while XSL defines also "column". Because of the interoperability with MSO and DTP, fo:hyphenation-keep="page" is interpreted as XSL "column", avoiding hyphenation at the end of column, not only at the end of page. Change-Id: I5c6b7adc0671a5a790568e7bf1d33256e607f85f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164158 Tested-by: László Németh Reviewed-by: László Németh --- sw/qa/extras/odfexport/data/tdf132599_auto.fodt | 49 +++++++++++++++++++++++++ sw/qa/extras/odfexport/data/tdf132599_page.fodt | 49 +++++++++++++++++++++++++ sw/qa/extras/odfexport/odfexport2.cxx | 27 ++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 sw/qa/extras/odfexport/data/tdf132599_auto.fodt create mode 100644 sw/qa/extras/odfexport/data/tdf132599_page.fodt (limited to 'sw/qa/extras/odfexport') diff --git a/sw/qa/extras/odfexport/data/tdf132599_auto.fodt b/sw/qa/extras/odfexport/data/tdf132599_auto.fodt new file mode 100644 index 000000000000..65b6ddccc295 --- /dev/null +++ b/sw/qa/extras/odfexport/data/tdf132599_auto.fodt @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hyphenate last word of the page + The Earth is no different to any other celestial body out there in space. It merely moves along in space inertially. Even just one inch above the surface of the Earth is space, except that it has an atmosphere. The Earth is no different to any other celestial body out there in space. It merely moves along in space inertially. Even just one inch above the surface of the Earth is space, except that it has an atmosphere. The Earth is no different to any other celestial body out… + + + diff --git a/sw/qa/extras/odfexport/data/tdf132599_page.fodt b/sw/qa/extras/odfexport/data/tdf132599_page.fodt new file mode 100644 index 000000000000..45393ad7dc43 --- /dev/null +++ b/sw/qa/extras/odfexport/data/tdf132599_page.fodt @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hyphenate last word of the page + The Earth is no different to any other celestial body out there in space. It merely moves along in space inertially. Even just one inch above the surface of the Earth is space, except that it has an atmosphere. The Earth is no different to any other celestial body out there in space. It merely moves along in space inertially. Even just one inch above the surface of the Earth is space, except that it has an atmosphere. The Earth is no different to any other celestial body out… + + + diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index 53431d985e1a..eea133b1d274 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -126,6 +128,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf106733) "hyphenate"_ostr, "false"); } + +CPPUNIT_TEST_FIXTURE(Test, testTdf132599_page) +{ + uno::Reference xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString()))) + return; + + // fo:hyphenation-keep="page" + loadAndReload("tdf132599_page.fodt"); + // This was 2 (not truncated hyphenated line) + CPPUNIT_ASSERT_EQUAL(3, getPages()); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf132599_auto) +{ + uno::Reference xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString()))) + return; + + // fo:hyphenation-keep="auto" + loadAndReload("tdf132599_auto.fodt"); + // not truncated hyphenated line + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt") { CPPUNIT_ASSERT_EQUAL(2, getPages()); -- cgit v1.2.3