summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-11-19 13:49:01 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-11-25 16:16:20 +0100
commit4eeff4a8d51ce51318b0db9ad0f9377ace55b79b (patch)
tree8bafa8acb4c70d8f9a8b7941601d09860de488bb /sw
parent8b5783266357b600e58bd757fef1f34f942b2d58 (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> (cherry picked from commit a8beb8c08886ac6eef7fcc6a8881a77156e05d4e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125457 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/list_notcounted_indent.fodt141
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx26
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx33
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 bb2ab0a3a2b4..8d2ea810624b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -462,6 +462,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 0c83a6a728bd..5f6ba5c41ab7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8946,16 +8946,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())
+ {
+ SfxItemSet temp(m_rExport.m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE, RES_LR_SPACE>{});
+ 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