tdf#161643 sw DOCX import/export of maximum consecutive hyphenated lines
Fix line break interoperability by importing w:consecutiveHyphenLimit to
ParaHyphenationMaxHyphens, and exporting ParaHyphenationMacHyphens to
w:consecutiveHyphenLimit in OOXML import/export filters.
Change-Id: I5f40bcff34ebebeabc0de9898955abda4dc34cde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169127
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index d1e3647..9a19ca8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -801,6 +801,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf161628, "tdf132599_frames_on_right_pages_no_hyph
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(0), getProperty<sal_Int16>(xStyle, u"ParaHyphenationZone"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf161643)
{
loadAndSave("fdo76163.docx");
xmlDocUniquePtr pXmlSettings = parseExport(u"word/settings.xml"_ustr);
assertXPath(pXmlSettings, "/w:settings/w:consecutiveHyphenLimit"_ostr, "val"_ostr, u"1"_ustr);
uno::Reference<beans::XPropertySet> xStyle(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
// This was false (value 0)
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(1), getProperty<sal_Int16>(xStyle, u"ParaHyphenationMaxHyphens"_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 149c52f4..911b2cd 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1220,6 +1220,10 @@ void DocxExport::WriteSettings()
bHyphenationZone = true;
}
if ( sal_Int16 nMaxHyphens = pZoneItem->GetMaxHyphens() )
pFS->singleElementNS(XML_w, XML_consecutiveHyphenLimit, FSNS(XML_w, XML_val),
OString::number(nMaxHyphens));
if ( pZoneItem->IsKeep() && pZoneItem->GetKeepType() )
bHyphenationKeep = true;
}
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx b/sw/source/writerfilter/dmapper/SettingsTable.cxx
index 5d4642f..fa67518 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.cxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx
@@ -93,6 +93,7 @@ struct SettingsTable_Impl
bool m_bAutoHyphenation;
bool m_bNoHyphenateCaps;
sal_Int16 m_nHyphenationZone;
sal_Int16 m_nConsecutiveHyphenLimit;
sal_Int16 m_nUseWord2013TrackBottomHyphenation;
sal_Int16 m_nAllowHyphenationAtTrackBottom;
bool m_bWidowControl;
@@ -142,6 +143,7 @@ struct SettingsTable_Impl
, m_bAutoHyphenation(false)
, m_bNoHyphenateCaps(false)
, m_nHyphenationZone( 360 ) // default is 1/4 in
, m_nConsecutiveHyphenLimit(0)
, m_nUseWord2013TrackBottomHyphenation(-1)
, m_nAllowHyphenationAtTrackBottom(-1)
, m_bWidowControl(false)
@@ -298,6 +300,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
m_pImpl->m_nHyphenationZone = nIntValue;
break;
case NS_ooxml::LN_CT_Settings_consecutiveHyphenLimit:
m_pImpl->m_nConsecutiveHyphenLimit = nIntValue;
break;
case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
// useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
break;
@@ -556,6 +561,11 @@ sal_Int16 SettingsTable::GetHyphenationZone() const
return m_pImpl->m_nHyphenationZone;
}
sal_Int16 SettingsTable::GetConsecutiveHyphenLimit() const
{
return m_pImpl->m_nConsecutiveHyphenLimit;
}
bool SettingsTable::GetHyphenationKeep() const
{
// if allowHyphenationAtTrackBottom is not true and useWord2013TrackBottomHyphenation is
@@ -716,6 +726,11 @@ void SettingsTable::ApplyProperties(rtl::Reference<SwXTextDocument> const& xDoc)
uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
xPropertySet->setPropertyValue(u"ParaHyphenationZone"_ustr, uno::Any(GetHyphenationZone()));
}
if (m_pImpl->m_nConsecutiveHyphenLimit)
{
uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
xPropertySet->setPropertyValue(u"ParaHyphenationMaxHyphens"_ustr, uno::Any(GetConsecutiveHyphenLimit()));
}
if (m_pImpl->m_bWidowControl && lcl_isDefault(xPropertyState, u"ParaWidows"_ustr) && lcl_isDefault(xPropertyState, u"ParaOrphans"_ustr))
{
uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.hxx b/sw/source/writerfilter/dmapper/SettingsTable.hxx
index c71f4bd..e8fd9c3a 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.hxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.hxx
@@ -79,6 +79,7 @@ public:
bool GetNoLeading() const;
bool GetNoHyphenateCaps() const;
sal_Int16 GetHyphenationZone() const;
sal_Int16 GetConsecutiveHyphenLimit() const;
bool GetHyphenationKeep() const;
const OUString& GetDecimalSymbol() const;