summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-06-11 12:17:10 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-06-11 12:25:38 +0200
commite08ab74b918be1473d91ed234ee7870cab137c7e (patch)
tree22ff6f6deb4dede89ac39c972744ae9b6c5712bd
parentc5c3ce5e625a31d78a21fbbc339ee30ba99f3044 (diff)
fdo#49659 handle RTF import of tables at the very end of the document
If the documents ends with a table, both Word/Writer produces a non-table empty paragraph after that table. However, it's valid not to emit that empty paragraph, so handle the situation in the importer. Change-Id: I8ea163f2de62954f3891f8f48e81d89f6e29ce6f
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx9
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
2 files changed, 11 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c2c1b604e2b7..caff49110a1a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -249,6 +249,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_bNeedPap(true),
m_bNeedCr(false),
m_bNeedPar(true),
+ m_bNeedFinalPar(false),
m_aListTableSprms(),
m_aSettingsTableAttributes(),
m_aSettingsTableSprms(),
@@ -481,6 +482,12 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
// If there is no paragraph in this section, then insert a dummy one, as required by Writer
if (m_bNeedPar)
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)
+ {
+ dispatchFlag(RTF_PARD);
+ dispatchSymbol(RTF_PAR);
+ }
while (m_nHeaderFooterPositions.size())
{
std::pair<Id, sal_uInt32> aPair = m_nHeaderFooterPositions.front();
@@ -1437,6 +1444,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
m_bNeedPap = true;
if (!m_aStates.top().aFrame.inFrame())
m_bNeedPar = false;
+ m_bNeedFinalPar = false;
}
break;
case RTF_SECT:
@@ -1541,6 +1549,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
tableBreak();
m_bNeedPap = true;
+ m_bNeedFinalPar = true;
m_aTableBuffer.clear();
m_aStates.top().nCells = 0;
m_aStates.top().aTableCellsSprms.clear();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 93ed15d55398..9bb994d9fd35 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -444,6 +444,8 @@ namespace writerfilter {
/// If we need to emit a CR at the end of substream.
bool m_bNeedCr;
bool m_bNeedPar;
+ /// If set, an empty paragraph will be added at the end of the document.
+ bool m_bNeedFinalPar;
/// The list table and list override table combined.
RTFSprms m_aListTableSprms;
/// The settings table attributes.