diff options
author | Justin Luth <justin.luth@collabora.com> | 2020-08-28 15:32:11 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-10-28 10:37:15 +0100 |
commit | 28dddd4f7e255c74c17c0c6b263303f4567b5678 (patch) | |
tree | b01df5b135d6100df209178ae2af57549ea9ccc3 /sw/source/filter | |
parent | de1c4863ab993c80d8fea50ce420d568f75bf2e6 (diff) |
tdf#132149 ww8export: respect ginormous paragraphs
This handles the extremely unlikely case where
a single paragraph contains multiple soft-page-breaks
from spanning more than two pages.
But it makes the unit tests I designed look much
better, so I am happy. I think it might help to
make the code slightly more understandable too,
and it convinces me that I am understanding
this section as I write multiple fixes against it.
[Better evidence than all of this is that Michael Stahl
came the the same conclusion from a code read - I just
beat him to it.]
(P.S. It isn't enough to change CurrentPageDesc, because
that is reset from rNode.FindPageDesc on every WriteText.
So the effective pageDesc needs to be kept track of.)
Change-Id: I5852e90571a74f3df4362caf058f7960f413dad3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101545
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 0c04d094e505..96d12e8afe43 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2265,6 +2265,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) // Let's decide if we need to split the paragraph because of a section break bool bNeedParaSplit = NeedTextNodeSplit( rNode, softBreakList ) && !IsInTable(); + const SwPageDesc* pNextSplitParaPageDesc = m_pCurrentPageDesc; auto aBreakIt = softBreakList.begin(); // iterate through portions on different pages @@ -2273,7 +2274,13 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) sal_Int32 nCurrentPos = *aBreakIt; if( softBreakList.size() > 1 ) // not for empty paragraph - ++aBreakIt; + { + // no need to split again if the page style won't change anymore + if ( pNextSplitParaPageDesc == pNextSplitParaPageDesc->GetFollow() ) + aBreakIt = --softBreakList.end(); + else + ++aBreakIt; + } AttrOutput().StartParagraph( pTextNodeInfo ); @@ -2718,9 +2725,9 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) // if paragraph is split, put the section break between the parts if( bNeedParaSplit && *aBreakIt != rNode.GetText().getLength() ) { - const SwPageDesc* pNextPageDesc = m_pCurrentPageDesc->GetFollow(); - assert(pNextPageDesc); - PrepareNewPageDesc( rNode.GetpSwAttrSet(), rNode, nullptr , pNextPageDesc); + pNextSplitParaPageDesc = pNextSplitParaPageDesc->GetFollow(); + assert(pNextSplitParaPageDesc); + PrepareNewPageDesc( rNode.GetpSwAttrSet(), rNode, nullptr , pNextSplitParaPageDesc); } else { |