diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-19 13:49:01 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-19 15:31:49 +0100 |
commit | a8beb8c08886ac6eef7fcc6a8881a77156e05d4e (patch) | |
tree | 51b994606d191b65f5a9b45fff032e2302f22fdb /sw | |
parent | 32ae1ed7504d58f9216593cb87f25c480a0e623b (diff) |
sw: DOCX export: use list's indent if paragraph is not counted
Writer/ODF has a feature to have paragraphs in a list without having a
list label, but they do take the indent of the list level into account.
Word doesn't appear to have this feature, so the export forces such
paragraphs to refer to a non-existent numId 0, so they are not part of a
list.
Take the left indent from the list level and write it into the pPr.
Change-Id: I8ad56e51e2d4dfd691e3c38532f1a824f5276fd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125555
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/list_notcounted_indent.fodt | 141 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 33 |
3 files changed, 195 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/list_notcounted_indent.fodt b/sw/qa/extras/ooxmlexport/data/list_notcounted_indent.fodt new file mode 100644 index 000000000000..41a1f7d17a66 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/list_notcounted_indent.fodt @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office: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:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle: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:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + + <office:font-face-decls> + <style:font-face style:name="StarSymbol" svg:font-family="StarSymbol" style:font-charset="x-symbol"/> + <style:font-face style:name="Arial" svg:font-family="Arial"/> + <style:font-face style:name="Lucida Sans Unicode" svg:font-family="'Lucida Sans Unicode'" style:font-pitch="variable"/> + <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" 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" style:font-name="Arial" fo:font-size="12pt" fo:language="de" fo:country="DE" style:font-name-asian="Lucida Sans Unicode" style:font-size-asian="12pt" style:language-asian="de" style:country-asian="DE" style:font-name-complex="Tahoma" style:font-size-complex="12pt" style:language-complex="de" style:country-complex="DE" 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:text-properties fo:font-size="11pt"/> + </style:style> + + <style:style style:name="Bullet_20_Symbols" style:display-name="Bullet Symbols" style:family="text"> + <style:text-properties style:font-name="StarSymbol" fo:font-family="StarSymbol" style:font-charset="x-symbol" fo:font-size="9pt" style:font-name-asian="StarSymbol" style:font-family-asian="StarSymbol" style:font-charset-asian="x-symbol" style:font-size-asian="9pt" style:font-name-complex="StarSymbol" style:font-family-complex="StarSymbol" style:font-charset-complex="x-symbol" style:font-size-complex="9pt"/> + </style:style> + <style:style style:name="Style_20_2" style:display-name="Style 2" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level=""> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:line-height="0.476cm" fo:orphans="0" fo:widows="0" fo:text-indent="-0.953cm" style:auto-text-indent="false" fo:background-color="#ffffff"> + <style:background-image/> + </style:paragraph-properties> + </style:style> + <style:style style:name="Style_20_8" style:display-name="Style 8" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level="4" style:list-style-name=""> + <style:paragraph-properties fo:line-height="0.464cm" fo:orphans="0" fo:widows="0" fo:background-color="#ffffff"> + <style:background-image/> + </style:paragraph-properties> + </style:style> + + </office:styles> + <office:automatic-styles> + + <text:list-style style:name="L2"> + <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" text:bullet-char="➔"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/> + </style:list-level-properties> + <style:text-properties style:font-name="StarSymbol"/> + </text:list-level-style-bullet> + </text:list-style> + + <style:style style:name="P41" style:family="paragraph" style:parent-style-name="Style_20_8" style:list-style-name="L2"> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:line-height="0.413cm" fo:text-align="start" style:justify-single-word="false" fo:orphans="0" fo:widows="0" fo:hyphenation-ladder-count="no-limit" fo:text-indent="0cm" style:auto-text-indent="false" fo:background-color="#ffffff"> + <style:background-image/> + </style:paragraph-properties> + </style:style> + <style:style style:name="P42" style:family="paragraph" style:parent-style-name="Style_20_8" style:list-style-name="L2"> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:line-height="0.413cm" fo:text-align="start" style:justify-single-word="false" fo:keep-together="always" fo:orphans="0" fo:widows="0" fo:hyphenation-ladder-count="no-limit" fo:text-indent="0cm" style:auto-text-indent="false" fo:background-color="#ffffff" fo:keep-with-next="always"> + <style:background-image/> + </style:paragraph-properties> + </style:style> + <style:style style:name="P60" style:family="paragraph" style:parent-style-name="Style_20_2" style:list-style-name="L2"> + <style:paragraph-properties fo:line-height="0.437cm" fo:text-align="start" style:justify-single-word="false" fo:orphans="0" fo:widows="0" fo:hyphenation-ladder-count="no-limit" fo:background-color="#ffffff"> + <style:background-image/> + </style:paragraph-properties> + </style:style> + <style:style style:name="P62" style:family="paragraph" style:parent-style-name="Style_20_2" style:list-style-name="L2"> + <style:paragraph-properties fo:line-height="0.437cm" fo:text-align="start" style:justify-single-word="false" fo:keep-together="auto" fo:orphans="0" fo:widows="0" fo:hyphenation-ladder-count="no-limit" fo:background-color="#ffffff" fo:keep-with-next="auto"> + <style:background-image/> + </style:paragraph-properties> + </style:style> + + </office:automatic-styles> + <office:body> + <office:text> + + <text:list xml:id="list4504291082075752071" text:style-name="L2"> + <text:list-header> + <text:h text:style-name="P41" text:outline-level="4"/> + </text:list-header> + <text:list-item> + <text:p text:style-name="P62">Foo</text:p> + <text:p text:style-name="P60">Blah blah blah</text:p> + <text:h text:style-name="P42" text:outline-level="4"/> + <text:h text:style-name="P41" text:outline-level="4">Etc</text:h> + </text:list-item> + </text:list> + + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index d53ab0d36db3..23bebc3775ca 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -472,6 +472,32 @@ CPPUNIT_TEST_FIXTURE(Test, testChicagoNumberingFootnote) assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:footnotePr/w:numFmt", "val", "chicago"); } +DECLARE_OOXMLEXPORT_TEST(testListNotCountedIndent, "list_notcounted_indent.fodt") +{ + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId", "val", "0"); + // wrong: 720 + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "start", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "end", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "hanging", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:numPr/w:numId", "val", "2"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:ind", 0); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:numPr/w:numId", "val", "0"); + // wrong: 180 + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "start", "720"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:ind", "hanging", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:numPr/w:numId", "val", "0"); + // wrong: 720 + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "start", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "end", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:ind", "hanging", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:numPr/w:numId", "val", "0"); + // wrong: 720 + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "start", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "end", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:ind", "hanging", "0"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf87569d, "tdf87569_drawingml.docx") { //if the original tdf87569 sample is upgraded it will have drawingml shapes... diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 9dee5cbf5a5a..40656f6e3bf7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8962,16 +8962,39 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) } else { + SvxLRSpaceItem const* pLRSpace(&rLRSpace); + ::std::optional<SvxLRSpaceItem> oLRSpace; + if (dynamic_cast<SwContentNode const*>(GetExport().m_pOutFormatNode) != nullptr) + { + auto pTextNd(static_cast<SwTextNode const*>(GetExport().m_pOutFormatNode)); + // WW doesn't have a concept of a pararaph that's in a list but not + // counted in the list - see AttributeOutputBase::ParaNumRule() + // forcing non-existent numId="0" in this case. + // This means WW won't apply the indents from the numbering, + // so try to add them as paragraph properties here. + if (!pTextNd->IsCountedInList()) + { + SfxItemSetFixed<RES_LR_SPACE, RES_LR_SPACE> temp(m_rExport.m_rDoc.GetAttrPool()); + pTextNd->GetParaAttr(temp, 0, 0, false, true, true, nullptr); + if (auto *const pItem = temp.GetItem(RES_LR_SPACE)) + { + // but don't use first-line offset from list (should it be 0 or from node?) + oLRSpace.emplace(*pItem); + oLRSpace->SetTextFirstLineOffset(pLRSpace->GetTextFirstLineOffset()); + pLRSpace = &*oLRSpace; + } + } + } rtl::Reference<FastAttributeList> pLRSpaceAttrList = FastSerializerHelper::createAttrList(); - if((0 != rLRSpace.GetTextLeft()) || (rLRSpace.IsExplicitZeroMarginValLeft())) + if ((0 != pLRSpace->GetTextLeft()) || (pLRSpace->IsExplicitZeroMarginValLeft())) { - pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_left : XML_start ) ), OString::number( rLRSpace.GetTextLeft() ) ); + pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_left : XML_start)), OString::number(pLRSpace->GetTextLeft()) ); } - if((0 != rLRSpace.GetRight()) || (rLRSpace.IsExplicitZeroMarginValRight())) + if ((0 != pLRSpace->GetRight()) || (pLRSpace->IsExplicitZeroMarginValRight())) { - pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_right : XML_end ) ), OString::number( rLRSpace.GetRight() ) ); + pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_right : XML_end)), OString::number(pLRSpace->GetRight()) ); } - sal_Int32 nFirstLineAdjustment = rLRSpace.GetTextFirstLineOffset(); + sal_Int32 const nFirstLineAdjustment = pLRSpace->GetTextFirstLineOffset(); if (nFirstLineAdjustment > 0) pLRSpaceAttrList->add( FSNS( XML_w, XML_firstLine ), OString::number( nFirstLineAdjustment ) ); else |