sw/source/filter/ww8/wrtw8nds.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
New commits: commit f8837995fab0a37e514fda53dd6c9cbcf34e5e6c Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Aug 12 17:07:18 2020 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Aug 14 20:24:23 2020 +0200 sw: MS Word export: don't insert section breaks in field instructions MSWordExportBase::NeedTextNodeSplit() simply uses the soft-page-break positions to potentially insert section breaks - but now that Writer can display field instructions, it's quite silly to insert section breaks inside them. Change-Id: Ie57e6281a0287aac36984e5467920852db19a8ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100661 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 68cc91cd2c461b7062c3f3b89b2c677e41c9a8d4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100529 Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 763e46000069..b520279b7345 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2162,7 +2162,29 @@ bool MSWordExportBase::NeedSectionBreak( const SwNode& rNd ) const bool MSWordExportBase::NeedTextNodeSplit( const SwTextNode& rNd, SwSoftPageBreakList& pList ) const { - rNd.fillSoftPageBreakList( pList ); + SwSoftPageBreakList tmp; + rNd.fillSoftPageBreakList(tmp); + // hack: move the break behind any field marks; currently we can't hide the + // field mark instruction so the layout position is quite meaningless + IDocumentMarkAccess const& rIDMA(*rNd.GetDoc()->getIDocumentMarkAccess()); + sal_Int32 pos(-1); + for (auto const& it : tmp) + { + if (pos < it) // previous one might have skipped over it + { + pos = it; + while (auto const*const pMark = rIDMA.getFieldmarkFor(SwPosition(const_cast<SwTextNode&>(rNd), pos))) + { + if (pMark->GetMarkEnd().nNode != rNd) + { + pos = rNd.Len(); // skip everything + break; + } + pos = pMark->GetMarkEnd().nContent.GetIndex(); // no +1, it's behind the char + } + pList.insert(pos); + } + } pList.insert(0); pList.insert( rNd.GetText().getLength() ); return pList.size() > 2 && NeedSectionBreak( rNd ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits