diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-08-12 17:07:18 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-08-13 16:58:17 +0200 |
commit | 68cc91cd2c461b7062c3f3b89b2c677e41c9a8d4 (patch) | |
tree | fb5ffbff4a03034e6f57ce6fb445f02fd6dca0f5 /sw/source/filter/ww8/wrtw8nds.cxx | |
parent | 5364c0815734d864e3c26090f1219d58a4022f8b (diff) |
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.stahl@cib.de>
Diffstat (limited to 'sw/source/filter/ww8/wrtw8nds.cxx')
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 4dd1f15395bb..3492549c6d73 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2149,7 +2149,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 ); |