sw/inc/hintids.hxx | 2 sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx |binary sw/qa/extras/ooxmlexport/data/tdf167297.fodt | 112 ++++ sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 7 sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 18 sw/qa/extras/ww8export/data/tdf167297.fodt | 112 ++++ sw/qa/extras/ww8export/data/tdf92281.doc |binary sw/qa/extras/ww8export/ww8export4.cxx | 19 sw/source/core/bastyp/init.cxx | 2 sw/source/core/text/atrstck.cxx | 2 sw/source/filter/html/css1atr.cxx | 2 sw/source/filter/html/htmlatr.cxx | 2 sw/source/filter/ww8/attributeoutputbase.hxx | 7 sw/source/filter/ww8/docxattributeoutput.cxx | 22 sw/source/filter/ww8/docxattributeoutput.hxx | 6 sw/source/filter/ww8/rtfattributeoutput.cxx | 7 sw/source/filter/ww8/rtfattributeoutput.hxx | 6 sw/source/filter/ww8/ww8atr.cxx | 33 + sw/source/filter/ww8/ww8attributeoutput.hxx | 6 sw/source/filter/ww8/ww8par.cxx | 225 ---------- sw/source/filter/ww8/ww8par.hxx | 1 sw/source/filter/ww8/ww8par6.cxx | 26 - sw/source/writerfilter/dmapper/DomainMapper.cxx | 26 - sw/source/writerfilter/dmapper/PropertyIds.cxx | 1 sw/source/writerfilter/dmapper/PropertyIds.hxx | 1 25 files changed, 376 insertions(+), 269 deletions(-)
New commits: commit 38ae7a6e1cb9adfd3fe67be409fb7b5bcaba3c82 Author: Jonathan Clark <jonat...@libreoffice.org> AuthorDate: Thu Jul 10 13:51:18 2025 -0600 Commit: Jonathan Clark <jonat...@libreoffice.org> CommitDate: Sat Jul 12 06:28:51 2025 +0200 tdf#167297 sw: Add support for DOC/DOCX script type hinting Extends the Writer script type hinting mechanism to natively support DOC/DOCX script type hinting. Implements the OOXML w:hint attribute, in both import and export. Implements the DOC sprmCIdctHint property, in both import and export. This change also removes the previously-implemented IdctHint emulation, based on breaking the input text into smaller spans. Writer's script type hinting mechanism is sufficient to replace this code. Change-Id: I08f934358164dc5814bfac010d4fac9b3334f947 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187755 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonat...@libreoffice.org> diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 61d5d546f079..9636779a1cc6 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -241,7 +241,7 @@ inline constexpr TypedWhichId<SvxShadowItem> RES_CHRATR_SHADOW(RES_CHRATR_BEGIN inline constexpr TypedWhichId<SvxBrushItem> RES_CHRATR_HIGHLIGHT(RES_CHRATR_BEGIN + 41); inline constexpr TypedWhichId<SfxGrabBagItem> RES_CHRATR_GRABBAG(RES_CHRATR_BEGIN + 42); inline constexpr TypedWhichId<SfxInt16Item> RES_CHRATR_BIDIRTL(RES_CHRATR_BEGIN + 43); -inline constexpr TypedWhichId<SfxInt16Item> RES_CHRATR_IDCTHINT(RES_CHRATR_BEGIN + 44); +inline constexpr TypedWhichId<SfxInt16Item> RES_CHRATR_UNUSED3(RES_CHRATR_BEGIN + 44); inline constexpr TypedWhichId<SvxScriptHintItem> RES_CHRATR_SCRIPT_HINT(RES_CHRATR_BEGIN + 45); inline constexpr sal_uInt16 RES_CHRATR_END(RES_CHRATR_BEGIN + 46); diff --git a/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx b/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx index a44ff4047111..f556c31b10ed 100644 Binary files a/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx and b/sw/qa/extras/layout/data/tdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf167297.fodt b/sw/qa/extras/ooxmlexport/data/tdf167297.fodt new file mode 100644 index 000000000000..7916f4ee3e86 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf167297.fodt @@ -0,0 +1,112 @@ +<?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:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" 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:c alcext="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:oasis: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" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:creation-date>2025-07-10T10:43:25.466383450</meta:creation-date><dc:date>2025-07-10T10:46:44.511772180</dc:date><meta:editing-duration>PT3M19S</meta:editing-duration><meta:editing-cycles>3</meta:editing-cycles><meta:generator>LibreOfficeDev/26.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/dda0d793705749007aae0a3b8728760d86874aca</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="2" meta:character-count="15" meta:non-whitespace-character-count="14"/></office:meta> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Serif1" svg:font-family="'Liberation Serif'" style:font-adornments="Regular" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Noto Sans1" svg:font-family="'Noto Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif CJK SC'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" loext:tab-stop-distance="0cm" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="CA" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Noto Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="CA" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Noto Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <text:outline-style style:name="Outline"> + <text:outline-level-style text:level="1" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="2" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="3" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="4" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="5" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="6" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="7" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="8" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="9" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="10" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + </text:outline-style> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties style:font-name-complex="Liberation Serif1" style:font-size-complex="96pt" style:script-type="complex"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.59cm" fo:page-height="27.94cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="P1">“Hello, World!”</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx index 5d5069886b1e..20c65ae8a637 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -304,10 +304,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf139418, "tdf139418.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPorLen1); sal_Int32 nPorLen2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "length").toInt32(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(42), nPorLen2); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nPorLen2); sal_Int32 nPorLen3 = getXPath(pXmlDoc, "(//SwLinePortion)[3]", "length").toInt32(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPorLen3); + CPPUNIT_ASSERT_EQUAL(sal_Int32(41), nPorLen3); + + sal_Int32 nPorLen4 = getXPath(pXmlDoc, "(//SwLinePortion)[4]", "length").toInt32(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPorLen4); } CPPUNIT_TEST_FIXTURE(Test, testAnnotationRef) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index 637d8a17773f..41de7a9c4925 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -195,6 +195,24 @@ CPPUNIT_TEST_FIXTURE(Test, testFloatingTableAnchorPosExport) CPPUNIT_ASSERT_EQUAL(u"D"_ustr, getXPathContent(pXmlDoc, "//w:body/w:p/w:r/w:t")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf167297) +{ + createSwDoc("tdf167297.fodt"); + + auto fnVerify = [this] { + auto pXmlDoc = parseLayoutDump(); + + // The test document uses style:script-type to replace 12pt characters + // with 96pt characters. Round-trip is confirmed by checking height. + sal_Int32 nHeight = getXPath(pXmlDoc, "//txt/infos/bounds", "height").toInt32(); + CPPUNIT_ASSERT_GREATER(sal_Int32(2000), nHeight); + }; + + fnVerify(); + saveAndReload(mpFilter); + fnVerify(); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ww8export/data/tdf167297.fodt b/sw/qa/extras/ww8export/data/tdf167297.fodt new file mode 100644 index 000000000000..7916f4ee3e86 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf167297.fodt @@ -0,0 +1,112 @@ +<?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:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" 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:c alcext="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:oasis: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" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:creation-date>2025-07-10T10:43:25.466383450</meta:creation-date><dc:date>2025-07-10T10:46:44.511772180</dc:date><meta:editing-duration>PT3M19S</meta:editing-duration><meta:editing-cycles>3</meta:editing-cycles><meta:generator>LibreOfficeDev/26.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/dda0d793705749007aae0a3b8728760d86874aca</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="2" meta:character-count="15" meta:non-whitespace-character-count="14"/></office:meta> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Serif1" svg:font-family="'Liberation Serif'" style:font-adornments="Regular" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Noto Sans1" svg:font-family="'Noto Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif CJK SC'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" loext:tab-stop-distance="0cm" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="CA" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Noto Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="CA" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Noto Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <text:outline-style style:name="Outline"> + <text:outline-level-style text:level="1" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="2" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="3" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="4" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="5" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="6" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="7" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="8" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="9" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="10" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + </text:outline-style> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties style:font-name-complex="Liberation Serif1" style:font-size-complex="96pt" style:script-type="complex"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.59cm" fo:page-height="27.94cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="P1">“Hello, World!”</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/ww8export/data/tdf92281.doc b/sw/qa/extras/ww8export/data/tdf92281.doc index 68be334c54ea..39a9dc129e94 100644 Binary files a/sw/qa/extras/ww8export/data/tdf92281.doc and b/sw/qa/extras/ww8export/data/tdf92281.doc differ diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index cc290716e95d..f9aad0a27f1a 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -776,6 +776,25 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf166620) } } +CPPUNIT_TEST_FIXTURE(Test, testTdf167297) +{ + createSwDoc("tdf167297.fodt"); + + auto fnVerify = [this] + { + auto pXmlDoc = parseLayoutDump(); + + // The test document uses style:script-type to replace 12pt characters + // with 96pt characters. Round-trip is confirmed by checking height. + sal_Int32 nHeight = getXPath(pXmlDoc, "//txt/infos/bounds", "height").toInt32(); + CPPUNIT_ASSERT_GREATER(sal_Int32(2000), nHeight); + }; + + fnVerify(); + saveAndReload(mpFilter); + fnVerify(); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index a8630342da52..ab482bfda115 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -329,7 +329,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes() // CharacterAttr - MSWord weak char direction/script override emulation { RES_CHRATR_BIDIRTL, new SfxInt16Item( RES_CHRATR_BIDIRTL, sal_Int16(-1) ), 0, SFX_ITEMINFOFLAG_NONE }, - { RES_CHRATR_IDCTHINT, new SfxInt16Item( RES_CHRATR_IDCTHINT, sal_Int16(-1) ), 0, SFX_ITEMINFOFLAG_NONE }, + { RES_CHRATR_UNUSED3, new SfxVoidItem( RES_CHRATR_UNUSED3 ), 0, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_SCRIPT_HINT, new SvxScriptHintItem( RES_CHRATR_SCRIPT_HINT ), SID_ATTR_CHAR_SCRIPT_HINT, SFX_ITEMINFOFLAG_NONE }, { RES_TXTATR_REFMARK, new SwFormatRefMark( SwMarkName() ), 0, SFX_ITEMINFOFLAG_NONE }, diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index c0d7ce784d4d..1af5e50d8550 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -114,7 +114,7 @@ const sal_uInt8 StackPos[ RES_TXTATR_WITHEND_END - RES_CHRATR_BEGIN + 1 ] = 38, // RES_CHRATR_HIGHLIGHT, // 42 0, // RES_CHRATR_GRABBAG, // 43 0, // RES_CHRATR_BIDIRTL, // 44 - 0, // RES_CHRATR_IDCTHINT, // 45 + 0, // RES_CHRATR_UNUSED3, // 45 39, // RES_CHRATR_SCRIPT_HINT, // 46 40, // RES_TXTATR_REFMARK, // 47 41, // RES_TXTATR_TOXMARK, // 48 diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 0a0740625859..85d5368a3dfb 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -3445,7 +3445,7 @@ SwAttrFnTab const aCSS1AttrFnTab = { /* RES_CHRATR_HIGHLIGHT */ nullptr, /* RES_CHRATR_GRABBAG */ nullptr, /* RES_CHRATR_BIDIRTL */ nullptr, -/* RES_CHRATR_IDCTHINT */ nullptr, +/* RES_CHRATR_UNUSED3 */ nullptr, /* RES_CHRATR_SCRIPT_HINT */ nullptr, /* RES_TXTATR_REFMARK */ nullptr, diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index c80542007564..047860778628 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -3322,7 +3322,7 @@ SwAttrFnTab aHTMLAttrFnTab = { /* RES_CHRATR_HIGHLIGHT */ nullptr, /* RES_CHRATR_GRABBAG */ nullptr, /* RES_CHRATR_BIDIRTL */ nullptr, -/* RES_CHRATR_IDCTHINT */ nullptr, +/* RES_CHRATR_UNUSED3 */ nullptr, /* RES_CHRATR_SCRIPT_HINT */ nullptr, /* RES_TXTATR_REFMARK */ nullptr, diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index 6739c577b823..8318470f3959 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -58,6 +58,7 @@ class SvxCharScaleWidthItem; class SvxCharReliefItem; class SvxCharHiddenItem; class SvxBoxItem; +class SvxScriptHintItem; class SwFormatINetFormat; class SwFormatCharFormat; class SwFormatField; @@ -439,9 +440,6 @@ protected: /// Sfx item RES_CHRATR_BidiRTL virtual void CharBidiRTL( const SfxPoolItem& ) = 0; - /// Sfx item RES_CHRATR_IdctHint - virtual void CharIdctHint( const SfxPoolItem& ) = 0; - /// Sfx item RES_CHRATR_ROTATE virtual void CharRotate( const SvxCharRotateItem& ) = 0; @@ -467,6 +465,9 @@ protected: /// Sfx item RES_CHRATR_HIGHLIGHT virtual void CharHighlight( const SvxBrushItem& ) = 0; + /// Sfx item RES_CHRATR_SCRIPT_HINT + virtual void CharScriptHint(const SvxScriptHintItem&) = 0; + /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFormatINetFormat& ) = 0; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 0b428374334c..083df7151523 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -90,6 +90,7 @@ #include <editeng/editobj.hxx> #include <editeng/keepitem.hxx> #include <editeng/borderline.hxx> +#include <editeng/scripthintitem.hxx> #include <sax/tools/converter.hxx> #include <svx/xdef.hxx> #include <svx/xfillit0.hxx> @@ -8363,10 +8364,6 @@ void DocxAttributeOutput::CharBidiRTL( const SfxPoolItem& ) { } -void DocxAttributeOutput::CharIdctHint( const SfxPoolItem& ) -{ -} - void DocxAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate) { // Not rotated? @@ -8496,6 +8493,23 @@ void DocxAttributeOutput::CharHighlight( const SvxBrushItem& rHighlight ) } } +void DocxAttributeOutput::CharScriptHint(const SvxScriptHintItem& rHint) +{ + switch (rHint.GetValue()) + { + case i18nutil::ScriptHintType::Asian: + AddToAttrList(m_pFontsAttrList, FSNS(XML_w, XML_hint), "eastAsia"); + break; + + case i18nutil::ScriptHintType::Complex: + AddToAttrList(m_pFontsAttrList, FSNS(XML_w, XML_hint), "cs"); + break; + + default: + break; + } +} + void DocxAttributeOutput::TextINetFormat( const SwFormatINetFormat& rLink ) { const SwCharFormat* pFormat = m_rExport.m_rDoc.FindCharFormatByName(rLink.GetINetFormat()); diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 3b5d3897e215..c09fc2f646b3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -609,9 +609,6 @@ protected: /// Sfx item RES_CHRATR_BidiRTL virtual void CharBidiRTL( const SfxPoolItem& ) override; - /// Sfx item RES_CHRATR_IdctHint - virtual void CharIdctHint( const SfxPoolItem& ) override; - /// Sfx item RES_CHRATR_ROTATE virtual void CharRotate( const SvxCharRotateItem& rRotate ) override; @@ -636,6 +633,9 @@ protected: /// Sfx item RES_CHRATR_HIGHLIGHT virtual void CharHighlight( const SvxBrushItem& rHighlight ) override; + /// SfxItem RES_CHRATR_SCRIPT_HINT + virtual void CharScriptHint(const SvxScriptHintItem& rHint) override; + /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFormatINetFormat& ) override; diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index b92c76debfe1..5a846b59308c 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2952,8 +2952,6 @@ void RtfAttributeOutput::CharWeightCTL(const SvxWeightItem& rWeight) void RtfAttributeOutput::CharBidiRTL(const SfxPoolItem& /*rItem*/) {} -void RtfAttributeOutput::CharIdctHint(const SfxPoolItem& /*rItem*/) {} - void RtfAttributeOutput::CharRotate(const SvxCharRotateItem& rRotate) { m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HORZVERT); @@ -3046,6 +3044,11 @@ void RtfAttributeOutput::CharHighlight(const SvxBrushItem& rBrush) m_aStyles.append(static_cast<sal_Int32>(msfilter::util::TransColToIco(rBrush.GetColor()))); } +void RtfAttributeOutput::CharScriptHint(const SvxScriptHintItem&) +{ + SAL_INFO("sw.rtf", "TODO: " << __func__); +} + void RtfAttributeOutput::TextINetFormat(const SwFormatINetFormat& rURL) { if (rURL.GetValue().isEmpty()) diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index f743d44f147e..6f9e2b2d107b 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -334,9 +334,6 @@ protected: /// Sfx item RES_CHRATR_BidiRTL void CharBidiRTL(const SfxPoolItem& rItem) override; - /// Sfx item RES_CHRATR_IdctHint - void CharIdctHint(const SfxPoolItem& rItem) override; - /// Sfx item RES_CHRATR_ROTATE void CharRotate(const SvxCharRotateItem& rRotate) override; @@ -362,6 +359,9 @@ protected: /// Sfx item RES_CHRATR_HIGHLIGHT void CharHighlight(const SvxBrushItem& rBrush) override; + /// Sfx item RES_CHRATR_SCRIPT_HINT + void CharScriptHint(const SvxScriptHintItem& rHint) override; + /// Sfx item RES_TXTATR_INETFMT void TextINetFormat(const SwFormatINetFormat& rURL) override; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 2fe1708ee153..327c4e263422 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -76,6 +76,7 @@ #include <editeng/blinkitem.hxx> #include <editeng/charhiddenitem.hxx> #include <editeng/paperinf.hxx> +#include <editeng/scripthintitem.hxx> #include <svx/xfillit0.hxx> #include <svx/xflgrit.hxx> #include <o3tl/string_view.hxx> @@ -1397,6 +1398,27 @@ void WW8AttributeOutput::CharHighlight( const SvxBrushItem& rBrush ) m_rWW8Export.m_pO->push_back( nColor ); } +void WW8AttributeOutput::CharScriptHint(const SvxScriptHintItem& rHint) +{ + sal_uInt8 nHint = 0; + switch (rHint.GetValue()) + { + case i18nutil::ScriptHintType::Asian: + nHint = 1; + break; + + case i18nutil::ScriptHintType::Complex: + nHint = 2; + break; + + default: + break; + } + + m_rWW8Export.InsUInt16(NS_sprm::CIdctHint::val); + m_rWW8Export.m_pO->push_back(nHint); +} + void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline ) { m_rWW8Export.InsUInt16( NS_sprm::CKul::val ); @@ -1642,13 +1664,6 @@ void WW8AttributeOutput::CharBidiRTL( const SfxPoolItem& rHt ) } } -void WW8AttributeOutput::CharIdctHint( const SfxPoolItem& rHt ) -{ - const SfxInt16Item& rAttr = static_cast<const SfxInt16Item&>(rHt); - m_rWW8Export.InsUInt16(0x286F); - m_rWW8Export.m_pO->push_back(static_cast<sal_uInt8>(rAttr.GetValue())); -} - void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate ) { // #i28331# - check that a Value is set @@ -5818,8 +5833,8 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) case RES_CHRATR_BIDIRTL: CharBidiRTL( rHt ); break; - case RES_CHRATR_IDCTHINT: - CharIdctHint( rHt ); + case RES_CHRATR_SCRIPT_HINT: + CharScriptHint(rHt.StaticWhichCast(RES_CHRATR_SCRIPT_HINT)); break; case RES_TXTATR_INETFMT: TextINetFormat( static_cast< const SwFormatINetFormat& >( rHt ) ); diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index 232d9be56bcf..ec44310b01fd 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -290,9 +290,6 @@ protected: /// Sfx item RES_CHRATR_BidiRTL virtual void CharBidiRTL( const SfxPoolItem& rHt ) override; - /// Sfx item RES_CHRATR_IdctHint - virtual void CharIdctHint( const SfxPoolItem& rHt ) override; - /// Sfx item RES_CHRATR_ROTATE virtual void CharRotate( const SvxCharRotateItem& ) override; @@ -317,6 +314,9 @@ protected: /// Sfx item RES_CHRATR_HIGHLIGHT virtual void CharHighlight( const SvxBrushItem& ) override; + /// Sfx item RES_CHRATR_SCRIPT_HINT + virtual void CharScriptHint(const SvxScriptHintItem&) override; + /// Sfx item RES_TXTATR_INETFMT virtual void TextINetFormat( const SwFormatINetFormat& ) override; diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 200609660766..d75c81056e37 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -3225,7 +3225,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp xStr->buffer[nEndUsed] = 0; xStr->length = nEndUsed; - emulateMSWordAddTextToParagraph(makeOUString(xStr.release(), nStrLen)); + simpleAddTextToParagraph(makeOUString(xStr.release(), nStrLen)); rPos += nL2; if (!m_aApos.back()) // a para end in apo doesn't count m_bWasParaEnd = false; // No CR @@ -3236,227 +3236,6 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCp return nL2 >= nStrLen; } -#define MSASCII SAL_MAX_INT16 - -namespace -{ - // We want to force weak chars inside 0x0020 to 0x007F to LATIN - sal_Int16 lcl_getScriptType( - const uno::Reference<i18n::XBreakIterator>& rBI, - const OUString &rString, sal_Int32 nPos) - { - sal_Int16 nScript = rBI->getScriptType(rString, nPos); - if (nScript == i18n::ScriptType::WEAK && rString[nPos] >= 0x0020 && rString[nPos] <= 0x007F) - nScript = MSASCII; - return nScript; - } - - // We want to know about WEAK segments, so endOfScript isn't - // useful, and see lcl_getScriptType anyway - sal_Int32 lcl_endOfScript( - const uno::Reference<i18n::XBreakIterator>& rBI, - const OUString &rString, sal_Int32 nPos, sal_Int16 nScript) - { - while (nPos < rString.getLength()) - { - sal_Int16 nNewScript = lcl_getScriptType(rBI, rString, nPos); - if (nScript != nNewScript) - break; - ++nPos; - } - return nPos; - } - - sal_Int32 lcl_getWriterScriptType( - const uno::Reference<i18n::XBreakIterator>& rBI, - const OUString &rString, sal_Int32 nPos) - { - sal_Int16 nScript = i18n::ScriptType::WEAK; - - if (rString.isEmpty()) - return nScript; - - while (nPos >= 0) - { - nScript = rBI->getScriptType(rString, nPos); - if (nScript != i18n::ScriptType::WEAK) - break; - --nPos; - } - - return nScript; - } - - bool samePitchIgnoreUnknown(FontPitch eA, FontPitch eB) - { - return (eA == eB || eA == PITCH_DONTKNOW || eB == PITCH_DONTKNOW); - } - - bool sameFontIgnoringIrrelevantFields(const SvxFontItem &rA, const SvxFontItem &rB) - { - // Ignoring CharSet, and ignoring unknown pitch - return rA.GetFamilyName() == rB.GetFamilyName() && - rA.GetStyleName() == rB.GetStyleName() && - rA.GetFamily() == rB.GetFamily() && - samePitchIgnoreUnknown(rA.GetPitch(), rB.GetPitch()); - } -} - -// In writer we categorize text into CJK, CTL and "Western" for everything else. -// Microsoft Word basically categorizes text into East Asian, Complex, ASCII, -// NonEastAsian/HighAnsi, with some shared characters and some properties to -// hint as to which way to bias those shared characters. - -// That's four categories, we however have three categories. Given that problem -// here we would ideally find out "what would word do" to see what font/language -// word would assign to characters based on the unicode range they fall into and -// hack the word one onto the range we use. However it's unclear what word's -// categorization is. So we don't do that here yet. - -// Additional to the categorization, when word encounters weak text for ambiguous -// chars it uses idcthint to indicate which way to bias. We don't have an idcthint -// feature in writer. - -// So what we currently do here then is to split our text into non-weak/weak -// sections and uses word's idcthint to determine what font it would use and -// force that on for the segment. Following what we *do* know about word's -// categorization, we know that the range 0x0020 and 0x007F is sprmCRgFtc0 in -// word, something we map to LATIN, so we consider all weak chars in that range -// to auto-bias to LATIN. - -// See https://bugs.libreoffice.org/show_bug.cgi?id=34319 for an example -void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString) -{ - if (rAddString.isEmpty()) - return; - - if (m_bFuzzing) - { - simpleAddTextToParagraph(rAddString); - return; - } - - const uno::Reference<i18n::XBreakIterator>& xBI(g_pBreakIt->GetBreakIter()); - assert(xBI.is()); - - sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0); - sal_Int32 nLen = rAddString.getLength(); - - OUString sParagraphText; - const SwContentNode *pCntNd = m_pPaM->GetPointContentNode(); - const SwTextNode* pNd = pCntNd ? pCntNd->GetTextNode() : nullptr; - if (pNd) - sParagraphText = pNd->GetText(); - sal_Int32 nParaOffset = sParagraphText.getLength(); - sParagraphText = sParagraphText + rAddString; - - sal_Int32 nPos = 0; - while (nPos < nLen) - { - sal_Int32 nEnd = lcl_endOfScript(xBI, rAddString, nPos, nScript); - if (nEnd < 0) - break; - - OUString sChunk(rAddString.copy(nPos, nEnd-nPos)); - const TypedWhichId<SvxFontItem> aIds[] = {RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT}; - const SvxFontItem *pOverriddenItems[] = {nullptr, nullptr, nullptr}; - bool aForced[] = {false, false, false}; - - int nLclIdctHint = 0xFF; - if (nScript == i18n::ScriptType::WEAK) - { - const SfxInt16Item *pIdctHint = GetFormatAttr(RES_CHRATR_IDCTHINT); - nLclIdctHint = pIdctHint->GetValue(); - } - - TypedWhichId<SvxFontItem> nForceFromFontId(0); - if (nLclIdctHint != 0xFF) - { - switch (nLclIdctHint) - { - case 0: - nForceFromFontId = RES_CHRATR_FONT; - break; - case 1: - nForceFromFontId = RES_CHRATR_CJK_FONT; - break; - case 2: - nForceFromFontId = RES_CHRATR_CTL_FONT; - break; - default: - break; - } - } - - if (sal_uInt16(nForceFromFontId) != 0) - { - // Now we know that word would use the nForceFromFontId font for this range - // Try and determine what script writer would assign this range to - - sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText, - nPos + nParaOffset); - - bool bWriterWillUseSameFontAsWordAutomatically = false; - - if (nWriterScript != i18n::ScriptType::WEAK) - { - if ( - (nWriterScript == i18n::ScriptType::ASIAN && nForceFromFontId == RES_CHRATR_CJK_FONT) || - (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId == RES_CHRATR_CTL_FONT) || - (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId == RES_CHRATR_FONT) - ) - { - bWriterWillUseSameFontAsWordAutomatically = true; - } - else - { - const SvxFontItem *pSourceFont = GetFormatAttr(nForceFromFontId); - TypedWhichId<SvxFontItem> nDestId = aIds[nWriterScript-1]; - const SvxFontItem *pDestFont = GetFormatAttr(nDestId); - bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont); - } - } - - // Writer won't use the same font as word, so force the issue - if (!bWriterWillUseSameFontAsWordAutomatically) - { - const SvxFontItem *pSourceFont = GetFormatAttr(nForceFromFontId); - - for (size_t i = 0; i < std::size(aIds); ++i) - { - const SvxFontItem *pDestFont = GetFormatAttr(aIds[i]); - aForced[i] = aIds[i] != nForceFromFontId && *pSourceFont != *pDestFont; - if (aForced[i]) - { - pOverriddenItems[i] = - static_cast<const SvxFontItem*>(m_xCtrlStck->GetStackAttr(*m_pPaM->GetPoint(), aIds[i])); - - SvxFontItem aForceFont(*pSourceFont); - aForceFont.SetWhich(aIds[i]); - m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), aForceFont); - } - } - } - } - - simpleAddTextToParagraph(sChunk); - - for (size_t i = 0; i < std::size(aIds); ++i) - { - if (aForced[i]) - { - m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), aIds[i]); - if (pOverriddenItems[i]) - m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *(pOverriddenItems[i])); - } - } - - nPos = nEnd; - if (nPos < nLen) - nScript = lcl_getScriptType(xBI, rAddString, nPos); - } -} - namespace sw { auto FilterControlChars(std::u16string_view aString) -> OUString @@ -3841,7 +3620,7 @@ bool SwWW8ImplReader::ReadChar(tools::Long nPosCp, tools::Long nCpOfs) if( '\x0' != cInsert ) { OUString sInsert(cInsert); - emulateMSWordAddTextToParagraph(sInsert); + simpleAddTextToParagraph(sInsert); } if (!m_aApos.back()) // a para end in apo doesn't count m_bWasParaEnd = bNewParaEnd; diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 0e4125c82dfb..7176c6bc9dc9 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1453,7 +1453,6 @@ private: { DeleteStack(std::move(m_xAnchorStck)); } - void emulateMSWordAddTextToParagraph(const OUString& rAddString); void simpleAddTextToParagraph(std::u16string_view aAddString); bool HandlePageBreakChar(); bool ReadChar(tools::Long nPosCp, tools::Long nCpOfs); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index ff9dfafccd91..bf1c0698f9d9 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -65,6 +65,7 @@ #include <editeng/pgrditem.hxx> #include <editeng/frmdiritem.hxx> #include <editeng/charhiddenitem.hxx> +#include <editeng/scripthintitem.hxx> #include <i18nlangtag/mslangid.hxx> #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> @@ -4745,7 +4746,7 @@ void SwWW8ImplReader::Read_LineBreakClear(sal_uInt16 /*nId*/, const sal_uInt8* p m_oLineBreakClear = eClear; } -void SwWW8ImplReader::Read_IdctHint( sal_uInt16, const sal_uInt8* pData, short nLen ) +void SwWW8ImplReader::Read_IdctHint(sal_uInt16, const sal_uInt8* pData, short nLen) { // sprmcidcthint (opcode 0x286f) specifies a script bias for the text in the run. // for unicode characters that are shared between far east and non-far east scripts, @@ -4753,13 +4754,28 @@ void SwWW8ImplReader::Read_IdctHint( sal_uInt16, const sal_uInt8* pData, short n // when this value is 0, text properties bias towards non-far east properties. // when this value is 1, text properties bias towards far east properties. // when this value is 2, text properties bias towards complex properties. - if (nLen < 1) //Property end + if (nLen < 1) //Property end { - m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(),RES_CHRATR_IDCTHINT); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_CHRATR_SCRIPT_HINT); } - else //Property start + else //Property start { - NewAttr(SfxInt16Item(RES_CHRATR_IDCTHINT, *pData)); + auto eHint = i18nutil::ScriptHintType::Automatic; + switch (*pData) + { + default: + break; + + case 1: + eHint = i18nutil::ScriptHintType::Asian; + break; + + case 2: + eHint = i18nutil::ScriptHintType::Complex; + break; + } + + NewAttr(SvxScriptHintItem(eHint, RES_CHRATR_SCRIPT_HINT)); } } diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index 45fce6c6bdf2..e3d5655b33c3 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -69,6 +69,7 @@ #include <com/sun/star/text/XFootnote.hpp> #include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/RubyPosition.hpp> +#include <com/sun/star/text/ScriptHintType.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/text/FontEmphasis.hpp> #include <com/sun/star/awt/CharSet.hpp> @@ -821,12 +822,25 @@ void DomainMapper::lcl_attribute(Id nName, const Value & val) m_pImpl->HandleLineBreakClear(val.getInt()); break; case NS_ooxml::LN_CT_Fonts_hint : - /* assigns script type to ambiguous characters, values can be: - NS_ooxml::LN_Value_ST_Hint_default - NS_ooxml::LN_Value_ST_Hint_eastAsia - NS_ooxml::LN_Value_ST_Hint_cs - */ - //TODO: unsupported? + { + auto eHint = css::text::ScriptHintType::AUTOMATIC; + switch (nIntValue) + { + case NS_ooxml::LN_Value_ST_Hint_eastAsia: + eHint = css::text::ScriptHintType::ASIAN; + break; + + case NS_ooxml::LN_Value_ST_Hint_cs: + eHint = css::text::ScriptHintType::COMPLEX; + break; + + default: + case NS_ooxml::LN_Value_ST_Hint_default: + break; + } + + m_pImpl->GetTopContext()->Insert(PROP_CHAR_SCRIPT_HINT, uno::Any(eHint)); + } break; case NS_ooxml::LN_CT_TblBorders_right: case NS_ooxml::LN_CT_TblBorders_top: diff --git a/sw/source/writerfilter/dmapper/PropertyIds.cxx b/sw/source/writerfilter/dmapper/PropertyIds.cxx index b3ca6ce2d6fa..592e5c61f54a 100644 --- a/sw/source/writerfilter/dmapper/PropertyIds.cxx +++ b/sw/source/writerfilter/dmapper/PropertyIds.cxx @@ -369,6 +369,7 @@ const OUString & getPropertyName( PropertyIds eId ) { PROP_CHAR_NUMSPACING_TEXT_EFFECT, u"CharNumSpacingTextEffect"_ustr}, { PROP_CHAR_STYLISTICSETS_TEXT_EFFECT, u"CharStylisticSetsTextEffect"_ustr}, { PROP_CHAR_CNTXTALTS_TEXT_EFFECT, u"CharCntxtAltsTextEffect"_ustr}, + { PROP_CHAR_SCRIPT_HINT, u"CharScriptHint"_ustr}, { PROP_SDTPR, u"SdtPr"_ustr}, { PROP_CELL_INTEROP_GRAB_BAG, u"CellInteropGrabBag"_ustr}, { PROP_TABLE_INTEROP_GRAB_BAG, u"TableInteropGrabBag"_ustr}, diff --git a/sw/source/writerfilter/dmapper/PropertyIds.hxx b/sw/source/writerfilter/dmapper/PropertyIds.hxx index 80dcafcb8501..aecabacf7865 100644 --- a/sw/source/writerfilter/dmapper/PropertyIds.hxx +++ b/sw/source/writerfilter/dmapper/PropertyIds.hxx @@ -143,6 +143,7 @@ enum PropertyIds ,PROP_CHAR_NUMSPACING_TEXT_EFFECT ,PROP_CHAR_STYLISTICSETS_TEXT_EFFECT ,PROP_CHAR_CNTXTALTS_TEXT_EFFECT + ,PROP_CHAR_SCRIPT_HINT ,PROP_CHARACTER_END ,PROP_CONTENT = PROP_CHARACTER_END ,PROP_CONTOUR_OUTSIDE