From 133f4d750a46dc67797d2f23f25a1bb39620d59f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 20 Dec 2011 12:37:21 +0100 Subject: fdo#42109 fix RTF import of fields inside tables --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 53 +++++++++++++++++++++----- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 + 2 files changed, 45 insertions(+), 9 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 3f1deb698dcb..4c9f8a3b5efe 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -933,6 +933,11 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer) } else if (aPair.first == BUFFER_STARTRUN) Mapper().startCharacterGroup(); + else if (aPair.first == BUFFER_TEXT) + { + sal_uInt8 nValue = aPair.second->getInt(); + Mapper().text(&nValue, 1); + } else if (aPair.first == BUFFER_UTEXT) { OUString aString(aPair.second->getString()); @@ -1000,9 +1005,19 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) else { sal_uInt8 sFieldStart[] = { 0x13 }; - Mapper().startCharacterGroup(); - Mapper().text(sFieldStart, 1); - Mapper().endCharacterGroup(); + if (!m_pCurrentBuffer) + { + Mapper().startCharacterGroup(); + Mapper().text(sFieldStart, 1); + Mapper().endCharacterGroup(); + } + else + { + m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t())); + RTFValue::Pointer_t pValue(new RTFValue(*sFieldStart)); + m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue)); + m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t())); + } } m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION; } @@ -2782,9 +2797,19 @@ int RTFDocumentImpl::popState() if (!m_bEq) { sal_uInt8 sFieldSep[] = { 0x14 }; - Mapper().startCharacterGroup(); - Mapper().text(sFieldSep, 1); - Mapper().endCharacterGroup(); + if (!m_pCurrentBuffer) + { + Mapper().startCharacterGroup(); + Mapper().text(sFieldSep, 1); + Mapper().endCharacterGroup(); + } + else + { + m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t())); + RTFValue::Pointer_t pValue(new RTFValue(*sFieldSep)); + m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue)); + m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t())); + } } } else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT) @@ -2792,9 +2817,19 @@ int RTFDocumentImpl::popState() if (!m_bEq) { sal_uInt8 sFieldEnd[] = { 0x15 }; - Mapper().startCharacterGroup(); - Mapper().text(sFieldEnd, 1); - Mapper().endCharacterGroup(); + if (!m_pCurrentBuffer) + { + Mapper().startCharacterGroup(); + Mapper().text(sFieldEnd, 1); + Mapper().endCharacterGroup(); + } + else + { + m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t())); + RTFValue::Pointer_t pValue(new RTFValue(*sFieldEnd)); + m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue)); + m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t())); + } } else m_bEq = false; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 4370d9a8c832..80136771dd86 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -135,6 +135,7 @@ namespace writerfilter { BUFFER_PROPS, BUFFER_CELLEND, BUFFER_STARTRUN, + BUFFER_TEXT, BUFFER_UTEXT, BUFFER_ENDRUN, BUFFER_PAR -- cgit v1.2.1