diff options
author | Miklos Vajna <vmiklos@frugalware.org> | 2011-08-11 16:23:18 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@frugalware.org> | 2011-08-11 16:23:48 +0200 |
commit | 70569eb6d6e0a52b43858293bd989feca8ce22dd (patch) | |
tree | 4b7a04d3047dc3f2b3358cf0226dc987bbe01a6f /writerfilter | |
parent | d80ff1025bf1d3b7dcfea51fb8bea6fde6f84c4f (diff) |
fix the "last char is missing from footnote when Word produces the rtf" bug
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 15 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtftokenizer.cxx | 3 |
3 files changed, 21 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 97d38a0df2bd..2d9e15fa4b4d 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -264,6 +264,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_bFirstRun(true), m_bFirstRow(true), m_bNeedPap(false), + m_bNeedCr(false), m_aListTableSprms(), m_aSettingsTableSprms(), m_xStorage(), @@ -333,6 +334,18 @@ bool RTFDocumentImpl::isSubstream() return m_bIsSubstream; } +void RTFDocumentImpl::finishSubstream() +{ + // At the end of a footnote stream, we need to emit a run break when importing from Word. + // We can't do so unconditionally, as Writer already writes a \par at the end of the footnote. + if (m_bNeedCr) + { + Mapper().startCharacterGroup(); + runBreak(); + Mapper().endCharacterGroup(); + } +} + void RTFDocumentImpl::setIgnoreFirst(OUString& rIgnoreFirst) { m_aIgnoreFirst = rIgnoreFirst; @@ -390,6 +403,7 @@ void RTFDocumentImpl::runBreak() { sal_uInt8 sBreak[] = { 0xd }; Mapper().text(sBreak, 1); + m_bNeedCr = false; } void RTFDocumentImpl::tableBreak() @@ -832,6 +846,7 @@ void RTFDocumentImpl::text(OUString& rString) RTFValue::Pointer_t pValue(new RTFValue(rString)); m_pCurrentBuffer->push_back(make_pair(BUFFER_UTEXT, pValue)); } + m_bNeedCr = true; if (!m_pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE) Mapper().endCharacterGroup(); else if(m_pCurrentBuffer) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 958c8d5e661f..c85f655f74fa 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -273,6 +273,7 @@ namespace writerfilter { void setSubstream(bool bIsSubtream); void setAuthor(rtl::OUString& rAuthor); bool isSubstream(); + void finishSubstream(); void setIgnoreFirst(rtl::OUString& rIgnoreFirst); void seek(sal_uInt32 nPos); com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> getModelFactory(); @@ -342,6 +343,8 @@ namespace writerfilter { bool m_bFirstRow; /// If paragraph properties should be emitted on next run. bool m_bNeedPap; + /// If we need to emit a CR at the end of substream. + bool m_bNeedCr; /// The list table and list override table combined. RTFSprms m_aListTableSprms; /// The settings table. diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx index e1e42234b05d..7ddf0fcab83e 100644 --- a/writerfilter/source/rtftok/rtftokenizer.cxx +++ b/writerfilter/source/rtftok/rtftokenizer.cxx @@ -83,7 +83,10 @@ int RTFTokenizer::resolveParse() if ((ret = m_rImport.popState())) return ret; if (m_rImport.isSubstream() && m_rImport.getGroup() == 0) + { + m_rImport.finishSubstream(); return 0; + } break; case '\\': if ((ret = resolveKeyword())) |