sw/qa/extras/odfexport/data/tdf160518_auto_in_default_paragraph_style.fodt   | 
  42 ++++++++
 sw/qa/extras/odfexport/data/tdf160518_auto_in_text_body_style.fodt           | 
  42 ++++++++
 sw/qa/extras/odfexport/data/tdf160518_page_in_default_paragraph_style.fodt   | 
  42 ++++++++
 sw/qa/extras/odfexport/data/tdf160518_page_in_text_body_style.fodt           | 
  42 ++++++++
 sw/qa/extras/odfexport/odfexport2.cxx                                        | 
  48 +++++++++-
 sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_default_paragraph_style.fodt | 
  42 ++++++++
 sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_text_body_style.fodt         | 
  42 ++++++++
 sw/qa/extras/ooxmlexport/data/tdf160518_page_in_default_paragraph_style.fodt | 
  42 ++++++++
 sw/qa/extras/ooxmlexport/data/tdf160518_page_in_text_body_style.fodt         | 
  42 ++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx                                   | 
  48 +++++++---
 sw/source/filter/ww8/docxexport.cxx                                          | 
  26 +++++
 sw/source/writerfilter/dmapper/DomainMapper.cxx                              | 
  10 ++
 sw/source/writerfilter/dmapper/SettingsTable.cxx                             | 
  31 +++++-
 sw/source/writerfilter/dmapper/SettingsTable.hxx                             | 
   1 
 14 files changed, 479 insertions(+), 21 deletions(-)

New commits:
commit b538729c90af470c33aeb3002750321ac8ac88be
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu May 16 14:45:43 2024 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri May 17 01:49:36 2024 +0200

    tdf#160518 sw: fix DOCX import/export of hyphenation-keep
    
    – export hyphenation-page="page" setting of native ODF documents,
      if hyphenation is enabled in the default paragraph or in
      the text body style with this setting. It's lossless for
      hyphenation-keep-type="column", while the other values are
      converted to hyphenation-keep-type="column", which is
      the default layout of MSO 2013 and later.
    
    – fix LO roundtrip of DOCX documents which were created in MSO
      originally: while the roundtrip kept useWord2013TrackBottomHyphenation
      and allowHyphenationAtTrackBottom, the exported redundant
      suppressAutoHyphen = "false" settings of the paragraph
      resulted broken layout in Writer, because the repeated import
      overwrote every paragraphs with bad hyphenation setting
      (hyphenation-keep = "auto" instead of hyphenation-keep = "page").
    
    – export also "Hyphenate CAPS" and "Hyphenation zone" settings,
      if hyphenation is enabled in text body style with these settings,
      and not in the default paragraph style. Setting hyphenation only
      in "Text Body" is more common in documents created in LibreOffice.
    
    Follow-up to commit c8ee0e8f581b8a6e41b1a6b8aa4d40b442c1d463
    "tdf160518 DOCX: import hyphenation-keep to fix layout".
    
    Change-Id: I9dbaf1e37416758388e3b2b19db3317f3f5652b5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167749
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git 
a/sw/qa/extras/odfexport/data/tdf160518_auto_in_default_paragraph_style.fodt 
b/sw/qa/extras/odfexport/data/tdf160518_auto_in_default_paragraph_style.fodt
new file mode 100644
index 000000000000..6250cc0af3d5
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf160518_auto_in_default_paragraph_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="0pt" 
style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto"/>
+   <style:text-properties fo:hyphenate="true" fo:font-size="49pt" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/odfexport/data/tdf160518_auto_in_text_body_style.fodt 
b/sw/qa/extras/odfexport/data/tdf160518_auto_in_text_body_style.fodt
new file mode 100644
index 000000000000..ffdc5d628840
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf160518_auto_in_text_body_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true"/>
+  </style:default-style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:class="text">
+   <style:paragraph-properties fo:hyphenation-keep="auto" fo:margin-top="0pt" 
fo:margin-bottom="0pt" style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2"/>
+   <style:text-properties fo:font-size="49pt" fo:hyphenate="true"/>
+  </style:style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Text_20_body"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git 
a/sw/qa/extras/odfexport/data/tdf160518_page_in_default_paragraph_style.fodt 
b/sw/qa/extras/odfexport/data/tdf160518_page_in_default_paragraph_style.fodt
new file mode 100644
index 000000000000..776e51526803
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf160518_page_in_default_paragraph_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="0pt" 
style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="page"/>
+   <style:text-properties fo:hyphenate="true" fo:font-size="49pt" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/odfexport/data/tdf160518_page_in_text_body_style.fodt 
b/sw/qa/extras/odfexport/data/tdf160518_page_in_text_body_style.fodt
new file mode 100644
index 000000000000..263359c09952
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf160518_page_in_text_body_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true"/>
+  </style:default-style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:class="text">
+   <style:paragraph-properties fo:hyphenation-keep="page" fo:margin-top="0pt" 
fo:margin-bottom="0pt" style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2"/>
+   <style:text-properties fo:font-size="49pt" fo:hyphenate="true"/>
+  </style:style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Text_20_body"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx 
b/sw/qa/extras/odfexport/odfexport2.cxx
index 943f53d624d6..ff97098e7d8e 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -139,7 +139,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132599_page)
     if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
         return;
 
-    // fo:hyphenation-keep="page"
+    // fo:hyphenation-keep="page" defined in direct paragraph formatting
     loadAndReload("tdf132599_page.fodt");
     // This was 2 (not truncated hyphenated line)
     CPPUNIT_ASSERT_EQUAL(3, getPages());
@@ -151,7 +151,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132599_auto)
     if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
         return;
 
-    // fo:hyphenation-keep="auto"
+    // fo:hyphenation-keep="auto" defined in direct paragraph formatting
     loadAndReload("tdf132599_auto.fodt");
     // not truncated hyphenated line
     CPPUNIT_ASSERT_EQUAL(2, getPages());
@@ -252,6 +252,50 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132599_page_in_table)
     assertXPath(pXmlDoc, 
"//style:style[@style:family='paragraph']/style:paragraph-properties[@loext:hyphenation-keep-type='page']"_ostr,
 1);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf132599_page_in_default_paragraph_style)
+{
+    uno::Reference<linguistic2::XHyphenator> xHyphenator = 
LinguMgr::GetHyphenator();
+    if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
+        return;
+
+    // fo:hyphenation-keep="page" defined in default paragraph style
+    loadAndReload("tdf160518_page_in_default_paragraph_style.fodt");
+    CPPUNIT_ASSERT_EQUAL(3, getPages());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf132599_auto_in_default_paragraph_style)
+{
+    uno::Reference<linguistic2::XHyphenator> xHyphenator = 
LinguMgr::GetHyphenator();
+    if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
+        return;
+
+    // fo:hyphenation-keep="auto" defined in default paragraph style
+    loadAndReload("tdf160518_auto_in_default_paragraph_style.fodt");
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf132599_page_in_text_body_style)
+{
+    uno::Reference<linguistic2::XHyphenator> xHyphenator = 
LinguMgr::GetHyphenator();
+    if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
+        return;
+
+    // fo:hyphenation-keep="page" defined in text body style
+    loadAndReload("tdf160518_page_in_text_body_style.fodt");
+    CPPUNIT_ASSERT_EQUAL(3, getPages());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf132599_auto_in_text_body_style)
+{
+    uno::Reference<linguistic2::XHyphenator> xHyphenator = 
LinguMgr::GetHyphenator();
+    if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
+        return;
+
+    // fo:hyphenation-keep="auto" defined in text body style
+    loadAndReload("tdf160518_auto_in_text_body_style.fodt");
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf158885_compound_remain)
 {
     loadAndReload("tdf158885_compound-remain.fodt");
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_default_paragraph_style.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_default_paragraph_style.fodt
new file mode 100644
index 000000000000..6250cc0af3d5
--- /dev/null
+++ 
b/sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_default_paragraph_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="0pt" 
style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto"/>
+   <style:text-properties fo:hyphenate="true" fo:font-size="49pt" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_text_body_style.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_text_body_style.fodt
new file mode 100644
index 000000000000..ffdc5d628840
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf160518_auto_in_text_body_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true"/>
+  </style:default-style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:class="text">
+   <style:paragraph-properties fo:hyphenation-keep="auto" fo:margin-top="0pt" 
fo:margin-bottom="0pt" style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2"/>
+   <style:text-properties fo:font-size="49pt" fo:hyphenate="true"/>
+  </style:style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Text_20_body"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf160518_page_in_default_paragraph_style.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf160518_page_in_default_paragraph_style.fodt
new file mode 100644
index 000000000000..776e51526803
--- /dev/null
+++ 
b/sw/qa/extras/ooxmlexport/data/tdf160518_page_in_default_paragraph_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="0pt" 
style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="page"/>
+   <style:text-properties fo:hyphenate="true" fo:font-size="49pt" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf160518_page_in_text_body_style.fodt 
b/sw/qa/extras/ooxmlexport/data/tdf160518_page_in_text_body_style.fodt
new file mode 100644
index 000000000000..263359c09952
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf160518_page_in_text_body_style.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oas
 is:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times 
New Roman&apos;" style:font-family-generic="swiss"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true"/>
+  </style:default-style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:class="text">
+   <style:paragraph-properties fo:hyphenation-keep="page" fo:margin-top="0pt" 
fo:margin-bottom="0pt" style:contextual-spacing="false" fo:text-align="start" 
style:justify-single-word="false" fo:orphans="2" fo:widows="2"/>
+   <style:text-properties fo:font-size="49pt" fo:hyphenate="true"/>
+  </style:style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" 
style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" 
style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" 
style:family="paragraph" style:parent-style-name="Heading" 
style:next-style-name="Text_20_body" style:class="text">
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Text_20_body"/>
+  <style:style style:name="P3" style:family="paragraph" 
style:parent-style-name="Heading_20_1">
+   <style:text-properties fo:font-size="49pt"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" 
style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" 
fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt">
+   </style:page-layout-properties>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text text:use-soft-page-breaks="true">
+   <text:h text:style-name="P3" text:outline-level="1">Hyphenate last word of 
the page</text:h>
+   <text:p text:style-name="P1">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…</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index ba70a335ca09..c68ec274f6ab 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1436,9 +1436,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160518, 
"tdf160518_useWord2013TrackBottomHyphena
     if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
         return;
 
-    // TODO: fix export too
-    if (isExported())
-        return;
     // This was 2 (without shifting last hyphenated line of the page)
     CPPUNIT_ASSERT_EQUAL(3, getPages());
 }
@@ -1449,9 +1446,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160518_compatible, 
"tdf160518_allowHyphenationAt
     if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
         return;
 
-    // TODO: fix export too
-    if (isExported())
-        return;
     // This is still 2
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
@@ -1462,9 +1456,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160518_ODT, 
"tdf160518_useWord2013TrackBottomHyp
     if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
         return;
 
-    // TODO: fix export too
-    if (isExported())
-        return;
     // This was 2 (without shifting last hyphenated line of the page)
     CPPUNIT_ASSERT_EQUAL(3, getPages());
 
@@ -1480,9 +1471,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160518_ODT_compatible, 
"tdf160518_allowHyphenati
     if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString())))
         return;
 
-    // TODO: fix export too
-    if (isExported())
-        return;
     // This is still 2
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 
@@ -1492,6 +1480,42 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160518_ODT_compatible, 
"tdf160518_allowHyphenati
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf160518_page_in_default_paragraph_style)
+{
+    // default paragraph style contains hyphenation settings
+    loadAndReload("tdf160518_page_in_default_paragraph_style.fodt");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/settings.xml");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='useWord2013TrackBottomHyphenation']"_ostr,
 "val"_ostr, "1");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='allowHyphenationAtTrackBottom']"_ostr,
 0);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf160518_auto_in_default_paragraph_style)
+{
+    // default paragraph style contains hyphenation settings
+    loadAndReload("tdf160518_auto_in_default_paragraph_style.fodt");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/settings.xml");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='useWord2013TrackBottomHyphenation']"_ostr,
 "val"_ostr, "1");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='allowHyphenationAtTrackBottom']"_ostr,
 "val"_ostr, "1");
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf160518_page_in_text_body_style)
+{
+    // text body style contains hyphenation settings
+    loadAndReload("tdf160518_page_in_text_body_style.fodt");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/settings.xml");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='useWord2013TrackBottomHyphenation']"_ostr,
 "val"_ostr, "1");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='allowHyphenationAtTrackBottom']"_ostr,
 0);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf160518_auto_in_text_body_style)
+{
+    // text body  style contains hyphenation settings
+    loadAndReload("tdf160518_auto_in_text_body_style.fodt");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/settings.xml");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='useWord2013TrackBottomHyphenation']"_ostr,
 "val"_ostr, "1");
+    assertXPath(pXmlDoc, 
"/w:settings/w:compat/w:compatSetting[@w:name='allowHyphenationAtTrackBottom']"_ostr,
 "val"_ostr, "1");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testHyphenationAuto)
 {
     loadAndReload("hyphenation.odt");
diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index f1331ce4141e..fe72e357e376 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1201,9 +1201,12 @@ void DocxExport::WriteSettings()
     // 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
+    // Hyphenation details set depending on default style, otherwise on body 
style
     SwTextFormatColl* pColl = 
m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD, 
/*bRegardLanguage=*/false);
+    if (!pColl || !pColl->GetItemIfSet(RES_PARATR_HYPHENZONE, false))
+        pColl = 
m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_TEXT, 
/*bRegardLanguage=*/false);
     const SvxHyphenZoneItem* pZoneItem;
+    bool bHyphenationKeep = false;
     if (pColl && (pZoneItem = pColl->GetItemIfSet(RES_PARATR_HYPHENZONE, 
false)))
     {
         if (pZoneItem->IsNoCapsHyphenation())
@@ -1212,6 +1215,9 @@ void DocxExport::WriteSettings()
         if ( sal_Int16 nHyphenZone = pZoneItem->GetTextHyphenZone() )
             pFS->singleElementNS(XML_w, XML_hyphenationZone, FSNS(XML_w, 
XML_val),
                                          OString::number(nHyphenZone));
+
+        if ( pZoneItem->IsKeep() && pZoneItem->GetKeepType() )
+            bHyphenationKeep = true;
     }
 
     // Even and Odd Headers
@@ -1449,6 +1455,24 @@ void DocxExport::WriteSettings()
                     FSNS(XML_w, XML_val), "1");
         }
 
+        // export useWord2013TrackBottomHyphenation and
+        // allowHyphenationAtTrackBottom for Word 2013/2016/2019
+        if ( nTargetCompatibilityMode >= 12 )
+        {
+            pFS->singleElementNS(XML_w, XML_compatSetting,
+                    FSNS(XML_w, XML_name), "useWord2013TrackBottomHyphenation",
+                    FSNS(XML_w, XML_uri), 
"http://schemas.microsoft.com/office/word";,
+                    FSNS(XML_w, XML_val), "1");
+
+            if ( !bHyphenationKeep )
+            {
+                pFS->singleElementNS(XML_w, XML_compatSetting,
+                    FSNS(XML_w, XML_name), "allowHyphenationAtTrackBottom",
+                    FSNS(XML_w, XML_uri), 
"http://schemas.microsoft.com/office/word";,
+                    FSNS(XML_w, XML_val), "1");
+            }
+        }
+
         pFS->endElementNS( XML_w, XML_compat );
     }
 
diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index 57712a349681..2912f403234c 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -41,6 +41,7 @@
 #include <com/sun/star/table/BorderLineStyle.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/ParagraphHyphenationKeepType.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
@@ -1718,6 +1719,15 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
         break;
     case NS_ooxml::LN_CT_PPrBase_suppressAutoHyphens:
         rContext->Insert(PROP_PARA_IS_HYPHENATION, uno::Any( nIntValue == 0 ));
+        // if hyphenation is enabled, don't lose other paragraph-level
+        // hyphenation settings of SvxHyphenZoneItem
+        if ( nIntValue == 0 )
+        {
+            rContext->Insert(PROP_PARA_HYPHENATION_KEEP,
+                            
uno::Any(m_pImpl->GetSettingsTable()->GetHyphenationKeep()));
+            rContext->Insert(PROP_PARA_HYPHENATION_KEEP_TYPE,
+                            
uno::Any(text::ParagraphHyphenationKeepType::COLUMN));
+        }
         break;
     case NS_ooxml::LN_CT_FramePr_h:
         break;
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx 
b/sw/source/writerfilter/dmapper/SettingsTable.cxx
index 61db2bb03e18..4d6fe6b13441 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.cxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx
@@ -93,6 +93,8 @@ struct SettingsTable_Impl
     bool                m_bAutoHyphenation;
     bool                m_bNoHyphenateCaps;
     sal_Int16           m_nHyphenationZone;
+    sal_Int16           m_nUseWord2013TrackBottomHyphenation;
+    sal_Int16           m_nAllowHyphenationAtTrackBottom;
     bool                m_bWidowControl;
     bool                m_bLongerSpaceSequence;
     bool                m_bSplitPgBreakAndParaMark;
@@ -138,6 +140,8 @@ struct SettingsTable_Impl
     , m_bAutoHyphenation(false)
     , m_bNoHyphenateCaps(false)
     , m_nHyphenationZone(0)
+    , m_nUseWord2013TrackBottomHyphenation(-1)
+    , m_nAllowHyphenationAtTrackBottom(-1)
     , m_bWidowControl(false)
     , m_bLongerSpaceSequence(false)
     , m_bSplitPgBreakAndParaMark(false)
@@ -370,6 +374,18 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
             {
                 m_pImpl->m_bAllowTextAfterFloatingTableBreak = true;
             }
+            else if (m_pImpl->m_aCurrentCompatSettingName == 
"useWord2013TrackBottomHyphenation" &&
+                m_pImpl->m_aCurrentCompatSettingUri == 
"http://schemas.microsoft.com/office/word";)
+            {
+                m_pImpl->m_nUseWord2013TrackBottomHyphenation =
+                        
static_cast<int>(ooxml::GetBooleanValue(aCompatSettingValue));
+            }
+            else if (m_pImpl->m_aCurrentCompatSettingName == 
"allowHyphenationAtTrackBottom" &&
+                m_pImpl->m_aCurrentCompatSettingUri == 
"http://schemas.microsoft.com/office/word";)
+            {
+                m_pImpl->m_nAllowHyphenationAtTrackBottom =
+                        
static_cast<int>(ooxml::GetBooleanValue(aCompatSettingValue));
+            }
         }
     }
     break;
@@ -532,6 +548,14 @@ sal_Int16 SettingsTable::GetHyphenationZone() const
     return m_pImpl->m_nHyphenationZone;
 }
 
+bool SettingsTable::GetHyphenationKeep() const
+{
+    // if allowHyphenationAtTrackBottom is not true and 
useWord2013TrackBottomHyphenation is
+    // not present or it is true, set ParaHyphenationKeep to COLUMN
+    return m_pImpl->m_nAllowHyphenationAtTrackBottom != 1 &&
+                m_pImpl->m_nUseWord2013TrackBottomHyphenation != 0;
+}
+
 const OUString & SettingsTable::GetDecimalSymbol() const
 {
     return m_pImpl->m_sDecimalSymbol;
@@ -691,12 +715,7 @@ void 
SettingsTable::ApplyProperties(rtl::Reference<SwXTextDocument> const& xDoc)
         xPropertySet->setPropertyValue("ParaWidows", aAny);
         xPropertySet->setPropertyValue("ParaOrphans", aAny);
     }
-
-    std::pair<bool, bool> aAllow = 
GetCompatSettingHasAndValue(u"allowHyphenationAtTrackBottom");
-    std::pair<bool, bool> aUse = 
GetCompatSettingHasAndValue(u"useWord2013TrackBottomHyphenation");
-    // if allowHyphenationAtTrackBottom is not true and 
useWord2013TrackBottomHyphenation is
-    // not present or it is true, set ParaHyphenationKeep to COLUMN
-    if ( !aAllow.second && ( !aUse.first || aUse.second ) )
+    if ( GetHyphenationKeep() )
     {
         uno::Reference<beans::XPropertySet> xPropertySet(xDefault, 
uno::UNO_QUERY);
         xPropertySet->setPropertyValue("ParaHyphenationKeep", uno::Any(true));
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.hxx 
b/sw/source/writerfilter/dmapper/SettingsTable.hxx
index 7512a0cc25b9..df7cb96de7d1 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;
+    bool GetHyphenationKeep() const;
 
     const OUString& GetDecimalSymbol() const;
     const OUString& GetListSeparator() const;

Reply via email to