From 89a80d637e2831d49cdf48921f961b04fd03cffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20N=C3=A9meth?= Date: Tue, 18 Jun 2024 09:32:24 +0200 Subject: [PATCH] tdf#161628 sw DOCX: export zero hyphenation zone, if it's not defined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To keep the layout of the document, export zero hyphenation zone instead of nothing, otherwise it would be 360 twips after importing the document with the default hyphenation zone. Follow-up to commit 8d8bc48b5efacde6f99d78a557cd052ce9e0ed07 "tdf#161628 DOCX import: set default hyphenation zone (1/4 inch)". Change-Id: I7be4a001f894bcdf10fff5f1b2e211a5a45566d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169078 Tested-by: Jenkins Reviewed-by: László Németh --- ..._frames_on_right_pages_no_hyphenation.fodt | 224 ++++++++++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 7 + sw/source/filter/ww8/docxexport.cxx | 8 + 3 files changed, 239 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf132599_frames_on_right_pages_no_hyphenation.fodt diff --git a/sw/qa/extras/ooxmlexport/data/tdf132599_frames_on_right_pages_no_hyphenation.fodt b/sw/qa/extras/ooxmlexport/data/tdf132599_frames_on_right_pages_no_hyphenation.fodt new file mode 100644 index 000000000000..c3df7b605f3a --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf132599_frames_on_right_pages_no_hyphenation.fodt @@ -0,0 +1,224 @@ + + + + + + false + true + true + + false + 0 + false + true + true + false + false + 0 + true + false + false + false + false + false + true + false + false + true + false + true + true + false + true + false + false + false + false + true + true + false + false + false + false + false + false + high-resolution + false + 595440 + false + true + false + + + true + + false + false + false + true + true + true + false + 0 + true + false + false + true + true + true + false + true + false + false + false + false + false + true + true + false + + true + false + false + 0 + false + true + + false + false + true + true + false + false + true + 1 + false + false + false + false + false + false + false + true + false + false + false + true + false + + true + 1131034 + true + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. Earth is. The Earth is no different to any other celestial body + + + + + + + + + + + diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index d0e84df71295..47ac22113db4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -794,6 +794,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf149421_default, "tdf146171.docx") CPPUNIT_ASSERT_EQUAL( static_cast(360), getProperty(xStyle, u"ParaHyphenationZone"_ustr)); } +DECLARE_OOXMLEXPORT_TEST(testTdf161628, "tdf132599_frames_on_right_pages_no_hyphenation.fodt") +{ + uno::Reference xStyle(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); + // This was 360 after the second import (missing export of zero hyphenation zone) + CPPUNIT_ASSERT_EQUAL( static_cast(0), getProperty(xStyle, u"ParaHyphenationZone"_ustr)); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf121658) { loadAndSave("tdf121658.docx"); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 622cc7b0fe6e..149c52f4d6fa 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1207,19 +1207,27 @@ void DocxExport::WriteSettings() pColl = m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_TEXT, /*bRegardLanguage=*/false); const SvxHyphenZoneItem* pZoneItem; bool bHyphenationKeep = false; + bool bHyphenationZone = false; if (pColl && (pZoneItem = pColl->GetItemIfSet(RES_PARATR_HYPHENZONE, false))) { if (pZoneItem->IsNoCapsHyphenation()) pFS->singleElementNS(XML_w, XML_doNotHyphenateCaps); if ( sal_Int16 nHyphenZone = pZoneItem->GetTextHyphenZone() ) + { pFS->singleElementNS(XML_w, XML_hyphenationZone, FSNS(XML_w, XML_val), OString::number(nHyphenZone)); + bHyphenationZone = true; + } if ( pZoneItem->IsKeep() && pZoneItem->GetKeepType() ) bHyphenationKeep = true; } + // export 0, if hyphenation zone is not defined (otherwise it would be the default 360 twips) + if ( !bHyphenationZone ) + pFS->singleElementNS(XML_w, XML_hyphenationZone, FSNS(XML_w, XML_val), "0"); + // Even and Odd Headers if( m_aSettings.evenAndOddHeaders ) pFS->singleElementNS(XML_w, XML_evenAndOddHeaders);