cui/source/tabpages/paragrph.cxx | 2 ++ sw/qa/extras/mailmerge/mailmerge.cxx | 2 +- sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 25 +++++++++++++++++++++++++ sw/source/filter/ww8/docxexport.cxx | 4 ++++ writerfilter/source/dmapper/DomainMapper.cxx | 3 --- writerfilter/source/dmapper/PropertyIds.cxx | 1 + writerfilter/source/dmapper/PropertyIds.hxx | 1 + writerfilter/source/dmapper/SettingsTable.cxx | 5 +++++ 8 files changed, 39 insertions(+), 4 deletions(-)
New commits: commit 5a079652c1b1f968a851f47995b0a65b84d2d192 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Jun 7 16:39:47 2022 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Jun 7 18:08:04 2022 +0200 tdf#149421 DOCX: import/export hyphenation zone Hyphenation is a document-level setting in OOXML (only disabling hyphenation is a paragraph-level setting), import/export hyphenation zone in Standard style, similar to IsHyphenation. Note: Remove HyphenationZone from grab bag to allow its modification in Writer. Fix also grayed out hyphenation zone input box in Text Flow, when enabling hyphenation. Follow-up to commit 7a1d4b7d1db93ca1f541856a8d00d621d50e7bd6 "tdf#149420 sw offapi xmloff: add hyphenation zone". Change-Id: Ic1a3f13ba4e80338227c3206a0ed619589809328 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135474 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index 4b9aaff94f85..0a0cb96487d8 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -2003,6 +2003,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia m_xMaxHyphenLabel->set_sensitive(false); m_xMaxHyphenEdit->set_sensitive(false); m_xMinWordLength->set_sensitive(false); + m_xHyphenZone->set_sensitive(false); m_xPageNumBox->set_sensitive(false); m_xPagenumEdit->set_sensitive(false); // no column break in HTML @@ -2137,6 +2138,7 @@ void SvxExtParagraphTabPage::HyphenClickHdl() m_xMaxHyphenLabel->set_sensitive(bEnable); m_xMaxHyphenEdit->set_sensitive(bEnable); m_xMinWordLength->set_sensitive(bEnable); + m_xHyphenZone->set_sensitive(bEnable); m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); } diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index c5b0a6cb16b8..a9e2c829c93d 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -1336,7 +1336,7 @@ DECLARE_MAILMERGE_TEST(testGrabBag, "grabbagtest.docx", "onecell.xlsx", "Sheet1" mxComponent, uno::UNO_QUERY_THROW); uno::Sequence<beans::PropertyValue> aInteropGrabBag; pTextDoc->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag; - CPPUNIT_ASSERT_EQUAL(sal_Int32(13), aInteropGrabBag.getLength()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(12), aInteropGrabBag.getLength()); // check table border - comes from table style "Tabellenraster" uno::Reference<text::XTextTable> const xTable(getParagraphOrTable(1, pTextDoc->getText()), uno::UNO_QUERY_THROW); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 8d7068e4faa2..f5b0438a5c80 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -752,6 +752,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf121661) loadAndSave("tdf121661.docx"); xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); assertXPath(pXmlSettings, "/w:settings/w:hyphenationZone", "val", "851"); + + // tdf#149421 + uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY); + // This was false + CPPUNIT_ASSERT_GREATER( static_cast<sal_Int16>(0), getProperty<sal_Int16>(xStyle, "ParaHyphenationZone")); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf149421, "tdf121661.docx") +{ + uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY); + // This was false + CPPUNIT_ASSERT_GREATER( static_cast<sal_Int16>(0), getProperty<sal_Int16>(xStyle, "ParaHyphenationZone")); + + if (!mbExported) + { + CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(851), getProperty<sal_Int16>(xStyle, "ParaHyphenationZone")); + // modify hyphenation zone (note: only hyphenation zone set in Standard paragraph style + // is exported, according to the document-level hyphenation settings of OOXML) + xStyle->setPropertyValue("ParaHyphenationZone", uno::Any(static_cast<sal_Int16>(2000))); + } + else + { + // check the export of the modified hyphenation zone + CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(2000), getProperty<sal_Int16>(xStyle, "ParaHyphenationZone")); + } } CPPUNIT_TEST_FIXTURE(Test, testTdf121658) diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index b86655365162..a31b51edda25 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1175,6 +1175,10 @@ void DocxExport::WriteSettings() { 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)); } // Even and Odd Headers diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c449296e5e2c..cd89b3d7d7ae 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -243,9 +243,6 @@ DomainMapper::~DomainMapper() // Add the saved DocumentProtection settings aProperties["DocumentProtection"] <<= m_pImpl->GetSettingsTable()->GetDocumentProtectionSettings(); - // Add the saved w:hyphenationZone setting - aProperties["HyphenationZone"] <<= m_pImpl->GetSettingsTable()->GetHyphenationZone(); - // Add the saved w:doNotHyphenateCaps setting aProperties["NoHyphenateCaps"] <<= m_pImpl->GetSettingsTable()->GetNoHyphenateCaps(); diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index 1189bc0b1410..658a73040f6d 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -91,6 +91,7 @@ OUString getPropertyName( PropertyIds eId ) case PROP_PARA_BOTTOM_MARGIN: sName = "ParaBottomMargin"; break; case PROP_PARA_IS_HYPHENATION: sName = "ParaIsHyphenation"; break; case PROP_PARA_HYPHENATION_NO_CAPS: sName = "ParaHyphenationNoCaps"; break; + case PROP_PARA_HYPHENATION_ZONE: sName = "ParaHyphenationZone"; break; case PROP_PARA_LINE_NUMBER_COUNT: sName = "ParaLineNumberCount"; break; case PROP_PARA_IS_HANGING_PUNCTUATION: sName = "ParaIsHangingPunctuation"; break; case PROP_PARA_LINE_SPACING: sName = "ParaLineSpacing"; break; diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index 7b6fe9a05275..20e4a1cc0947 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -228,6 +228,7 @@ enum PropertyIds ,PROP_PARA_IS_HANGING_PUNCTUATION ,PROP_PARA_IS_HYPHENATION ,PROP_PARA_HYPHENATION_NO_CAPS + ,PROP_PARA_HYPHENATION_ZONE ,PROP_PARA_KEEP_TOGETHER ,PROP_PARA_LAST_LINE_ADJUST ,PROP_PARA_LEFT_MARGIN diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 808994454985..45dc67b9f43b 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -595,6 +595,11 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY); xPropertySet->setPropertyValue("ParaHyphenationNoCaps", uno::Any(true)); } + if (m_pImpl->m_nHyphenationZone) + { + uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY); + xPropertySet->setPropertyValue("ParaHyphenationZone", uno::Any(GetHyphenationZone())); + } if (m_pImpl->m_bWidowControl && lcl_isDefault(xPropertyState, "ParaWidows") && lcl_isDefault(xPropertyState, "ParaOrphans")) { uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);