diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-10-28 16:39:31 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-28 17:19:19 +0200 |
commit | f546f7573158e52359bbeae6194a83a1ff8ac52c (patch) | |
tree | 32f70ba4ca9e48ad305ef797e019a3b1a1b7f7b4 /sw/source/filter | |
parent | ab24b70ca0ea80a4655c71762f628e86a76fefa0 (diff) |
DOCX export, numbering portion format: consider full-para char formats as well
The bugdoc had a single paragraph with direct formatting (24pt font
size), numbering enabled and a bookmark covering half of the paragraph.
The numbering had default font size in the DOCX export result, not
inheriting from the paragraph.
In case the bookmark is removed, then the custom font size is not an
autoformat set on the whole text of the paragraph but rather a format on
the paragraph level, which does influence the formatting of the
numbering portion via the paragraph marker formatting, as expected.
Fix the problem in a way similar to what was done in commit
cb0e1b52d68aa6d5b505f91cb4ce577f7f3b2a8f (sw, numbering portion format:
consider full-para char formats as well, 2022-10-20), except that was
for the rendering and this is for the DOCX export.
This also required filtering out grab-bags in
lcl_writeParagraphMarkerProperties(), otherwise citation SDTs show up in
the export result at unexpected places, as shown by
CppunitTest_sw_ooxmlexport14's testTdf129353.
Change-Id: I7bb88e290f2a370d78ecc894f306bcb0a403545f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141995
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 15 |
2 files changed, 14 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index dd6210566bfa..a88049e31c09 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1369,7 +1369,7 @@ void lcl_writeParagraphMarkerProperties(DocxAttributeOutput& rAttributeOutput, c bool bFontSizeWritten = false; while (nWhichId) { - if (aIter.GetItemState(true, &pItem) == SfxItemState::SET) + if (aIter.GetItemState(true, &pItem) == SfxItemState::SET && nWhichId != RES_CHRATR_GRABBAG) { if (isCHRATR(nWhichId) || nWhichId == RES_TXTATR_CHARFMT) { diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index a9ff9a6b9b56..927ed91bf876 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -3164,6 +3164,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) } else if (const SwpHints* pTextAttrs = rNode.GetpSwpHints()) { + bool bFoundAtEnd = false; for( size_t i = 0; i < pTextAttrs->Count(); ++i ) { const SwTextAttr* pHt = pTextAttrs->Get(i); @@ -3172,13 +3173,23 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) // Check if these attributes are for the last character in the paragraph // - which means the paragraph marker. If a paragraph has 7 characters, // then properties on character 8 are for the paragraph marker - if( endPos && (startPos == *endPos ) && (*endPos == rNode.GetText().getLength()) ) + if (!endPos) + { + continue; + } + bool bAtEnd = (startPos == *endPos ) && (*endPos == rNode.GetText().getLength()); + if (bAtEnd) + { + bFoundAtEnd = true; + } + bool bWholePara = startPos == 0 && *endPos == rNode.GetText().getLength(); + if (bAtEnd || (!bFoundAtEnd && bWholePara)) { SAL_INFO( "sw.ww8", startPos << "startPos == endPos" << *endPos); sal_uInt16 nWhich = pHt->GetAttr().Which(); SAL_INFO( "sw.ww8", "nWhich" << nWhich); if ((nWhich == RES_TXTATR_AUTOFMT && bCharFormatOnly) - || nWhich == RES_TXTATR_CHARFMT) + || (nWhich == RES_TXTATR_CHARFMT && !bWholePara)) { aParagraphMarkerProperties.Put(pHt->GetAttr()); } |