summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-07-05 11:37:24 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-07-05 12:02:07 +0200
commit4108f285207ed4a60c8876a8206bc5f2d7f05620 (patch)
tree05ba7d02c0416021b1f06092cadc30db8d1b7e78 /writerfilter
parent303096c50c850b05a158a1a429c9fd5d0251a892 (diff)
fdo#39001 RTF import: fix fake empty page at the end of the doc
In case we have a \sect, there was no \sbknone (so it counts as a page break as well) and there is nothing after it, we should not make extra efforts to make that have some effect, but adding at least one empty paragraph to that new page. Change-Id: Ibcbecabcb590ed34ef96a97698e4ab8f638d3483
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 96bfce627633..56d8a1ba3345 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -505,8 +505,11 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
{
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": final? " << bFinal << ", needed? " << m_bNeedSect);
bool bNeedSect = m_bNeedSect;
- // If there is no paragraph in this section, then insert a dummy one, as required by Writer
- if (m_bNeedPar)
+ RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc);
+ bool bContinuous = pBreak.get() && pBreak->getInt() == 0;
+ // If there is no paragraph in this section, then insert a dummy one, as required by Writer,
+ // unless this is the end of the doc, we had nothing since the last section break and this is not a continuous one.
+ if (m_bNeedPar && !(bFinal && !m_bNeedSect && !bContinuous))
dispatchSymbol(RTF_PAR);
// It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
if (m_bNeedFinalPar && bFinal)
@@ -525,9 +528,8 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
// last control word in the document is a section break itself.
if (!bNeedSect || !m_bHadSect)
{
- RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc);
- // In case the last section is a continous one, we don't need to output a section break.
- if (bFinal && pBreak.get() && !pBreak->getInt())
+ // In case the last section is a continuous one, we don't need to output a section break.
+ if (bFinal && bContinuous)
m_aStates.top().aSectionSprms.erase(NS_sprm::LN_SBkc);
}