[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/qa sw/source
Vasily Melenchuk (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 14 12:25:38 UTC 2020
sw/qa/extras/ooxmlexport/data/hyphenation.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 18 ++++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 4 ++--
sw/source/filter/ww8/docxattributeoutput.cxx | 2 +-
sw/source/filter/ww8/docxexport.cxx | 7 ++++---
sw/source/filter/ww8/rtfexport.cxx | 13 +++----------
6 files changed, 28 insertions(+), 16 deletions(-)
New commits:
commit cd4e5916347b4578d1dea77759386666d60a3ec8
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Wed Feb 12 16:34:47 2020 +0300
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Feb 14 13:25:06 2020 +0100
RTF/DOCX export: always set hyphenation to auto at document level
MS formats unlike ODT have also global setting for hyphenation
params. Previous approach was to set this global value depending
on default paragraph style settings. However, if hyphenation is
enabled ony for specific other paragraphs, hyphenation in MS Word
will not work.
Let's try to set global hyphenation value to "auto" and explicitly
enable/disable hyphenation on paragraph level.
Change-Id: I199fa80eb1204930e2640dac0e90802b6b98597b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88536
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
(cherry picked from commit 4e4ae855cb9976c3ef3bfdca23a0d706a56237c1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88681
diff --git a/sw/qa/extras/ooxmlexport/data/hyphenation.odt b/sw/qa/extras/ooxmlexport/data/hyphenation.odt
new file mode 100644
index 000000000000..13c1afaaa50e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/hyphenation.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 2ddc72515991..2365be2a5984 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -301,6 +301,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf129353, "tdf129353.docx")
aIndexString);
}
+DECLARE_OOXMLEXPORT_TEST(testHyphenationAuto, "hyphenation.odt")
+{
+ // Explicitly set hyphenation=auto on document level
+ xmlDocPtr pXmlSettings = parseExport("word/settings.xml");
+ CPPUNIT_ASSERT(pXmlSettings);
+ assertXPath(pXmlSettings, "/w:settings/w:autoHyphenation", "val", "true");
+
+ // Second paragraph has explicitly enabled hyphenation
+ xmlDocPtr pXml = parseExport("word/document.xml");
+ CPPUNIT_ASSERT(pXml);
+ assertXPath(pXml, "/w:document/w:body/w:p[2]/w:pPr/w:suppressAutoHyphens", "val", "false");
+
+ // Default paragraph style explicitly disables hyphens
+ xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
+ CPPUNIT_ASSERT(pXmlStyles);
+ assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/w:suppressAutoHyphens", "val", "true");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 55ac7efb2718..a87a0b2919f3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -184,8 +184,8 @@ DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx")
// Check that we output real content of rPrDefault
assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New Roman");
assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA");
- // pPrDefault is empty
- assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 0);
+ // pPrDefault contains only one hyphenation propery
+ assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 1);
// Check latent styles
uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, "InteropGrabBag");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f4bd60a5feda..553d4b907583 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4583,7 +4583,7 @@ void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt)
bMustWrite = static_cast< const SvxTabStopItem& >(rHt).Count() != 0;
break;
case RES_PARATR_HYPHENZONE:
- bMustWrite = static_cast< const SvxHyphenZoneItem& >(rHt).IsHyphen();
+ bMustWrite = true;
break;
case RES_PARATR_NUMRULE:
bMustWrite = !static_cast< const SwNumRuleItem& >(rHt).GetValue().isEmpty();
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 47db619b20c6..312500a4502c 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1006,13 +1006,14 @@ void DocxExport::WriteSettings()
}
// Automatic hyphenation: it's a global setting in Word, it's a paragraph setting in Writer.
- // Use the setting from the default style.
+ // Set it's value to "auto" and disable on paragraph level, if no hyphenation is used there.
+ pFS->singleElementNS(XML_w, XML_autoHyphenation, FSNS(XML_w, XML_val), "true");
+
+ // Hyphenation details set depending on default style
SwTextFormatColl* pColl = m_pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD, /*bRegardLanguage=*/false);
const SfxPoolItem* pItem;
if (pColl && SfxItemState::SET == pColl->GetItemState(RES_PARATR_HYPHENZONE, false, &pItem))
{
- pFS->singleElementNS(XML_w, XML_autoHyphenation,
- FSNS(XML_w, XML_val), OString::boolean(static_cast<const SvxHyphenZoneItem*>(pItem)->IsHyphen()));
if (static_cast<const SvxHyphenZoneItem*>(pItem)->IsNoCapsHyphenation())
pFS->singleElementNS(XML_w, XML_doNotHyphenateCaps);
}
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index f29268032ed0..366cc18b3b0c 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -711,16 +711,9 @@ ErrCode RtfExport::ExportDocument_Impl()
.WriteCharPtr(SAL_NEWLINE_STRING);
// Automatic hyphenation: it's a global setting in Word, it's a paragraph setting in Writer.
- // Use the setting from the default style.
- SwTextFormatColl* pTextFormatColl = m_pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(
- RES_POOLCOLL_STANDARD, /*bRegardLanguage=*/false);
- const SfxPoolItem* pItem;
- if (pTextFormatColl
- && pTextFormatColl->GetItemState(RES_PARATR_HYPHENZONE, false, &pItem) == SfxItemState::SET)
- {
- Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_HYPHAUTO);
- OutULong(int(static_cast<const SvxHyphenZoneItem*>(pItem)->IsHyphen()));
- }
+ // Set it's value to "auto" and disable on paragraph level, if no hyphenation is used there.
+ Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_HYPHAUTO);
+ OutULong(1);
// Zoom
SwViewShell* pViewShell(m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell());
More information about the Libreoffice-commits
mailing list