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
This commit is contained in:
Miklos Vajna 2012-06-11 12:17:10 +02:00
parent c5c3ce5e62
commit e08ab74b91
2 changed files with 11 additions and 0 deletions

View file

@ -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();

View file

@ -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.