diff options
Diffstat (limited to '')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 1d0c2d7dde..e82674930b 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -653,6 +653,7 @@ void RTFDocumentImpl::runBreak() void RTFDocumentImpl::tableBreak() { + checkFirstRun(); // ooo113308-1.rtf has a header at offset 151084 that doesn't startParagraphGroup() without this runBreak(); Mapper().endParagraphGroup(); Mapper().startParagraphGroup(); @@ -671,7 +672,10 @@ void RTFDocumentImpl::parBreak() m_bHadPicture = false; // start new one - Mapper().startParagraphGroup(); + if (!m_bParAtEndOfSection) + { + Mapper().startParagraphGroup(); + } } void RTFDocumentImpl::sectBreak(bool bFinal) @@ -685,14 +689,26 @@ void RTFDocumentImpl::sectBreak(bool bFinal) // unless this is the end of the doc, we had nothing since the last section break and this is not a continuous one. // Also, when pasting, it's fine to not have any paragraph inside the document at all. if (m_bNeedPar && (!bFinal || m_bNeedSect || bContinuous) && !isSubstream() && m_bIsNewDoc) + { + m_bParAtEndOfSection = true; dispatchSymbol(RTFKeyword::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(RTFKeyword::PARD); + m_bParAtEndOfSection = true; dispatchSymbol(RTFKeyword::PAR); m_bNeedSect = bNeedSect; } + // testTdf148515, if RTF ends with \row, endParagraphGroup() must be called! + if (!m_bParAtEndOfSection || m_aStates.top().getCurrentBuffer()) + { + Mapper().endParagraphGroup(); // < top para context dies with page break + } + m_bParAtEndOfSection = false; + // paragraph properties are *done* now - only section properties following + while (!m_nHeaderFooterPositions.empty()) { std::pair<Id, std::size_t> aPair = m_nHeaderFooterPositions.front(); @@ -725,7 +741,6 @@ void RTFDocumentImpl::sectBreak(bool bFinal) // The trick is that we send properties of the previous section right now, which will be exactly what dmapper expects. Mapper().props(pProperties); - Mapper().endParagraphGroup(); // End Section if (!m_pSuperstream) @@ -2119,6 +2134,8 @@ RTFError RTFDocumentImpl::pushState() case Destination::FIELDRESULT: case Destination::SHAPETEXT: case Destination::FORMFIELD: + //TODO: if this is pushed then the font encoding is used which results in a broken command string + // if it is not pushed to NORMAL then it is not restored in time. case Destination::FIELDINSTRUCTION: case Destination::PICT: m_aStates.top().setDestination(Destination::NORMAL); @@ -2342,7 +2359,7 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState) if (m_aStates.top().isFieldLocked()) singleChar(cFieldLock); - singleChar(cFieldSep); + singleChar(cFieldSep, true); } break; case Destination::FIELDRESULT: @@ -2569,7 +2586,7 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState) str = OUString::Concat(field) + " \"" + str.replaceAll("\"", "\\\"") + "\""; singleChar(cFieldStart); Mapper().utext(str.getStr(), str.getLength()); - singleChar(cFieldSep); + singleChar(cFieldSep, true); // no result singleChar(cFieldEnd); } @@ -3654,8 +3671,15 @@ RTFError RTFDocumentImpl::popState() // \par means an empty paragraph at the end of footnotes/endnotes, but // not in case of other substreams, like headers. if (m_bNeedCr && m_nStreamType != NS_ooxml::LN_footnote - && m_nStreamType != NS_ooxml::LN_endnote && m_bIsNewDoc) + && m_nStreamType != NS_ooxml::LN_endnote) + { + if (!m_bIsNewDoc) + { + // Make sure all the paragraph settings are set, but do not add next paragraph + Mapper().markLastParagraph(); + } dispatchSymbol(RTFKeyword::PAR); + } if (m_bNeedSect) // may be set by dispatchSymbol above! sectBreak(true); else if (!m_pSuperstream) @@ -3782,8 +3806,11 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex) if (bHex && !m_aHexBuffer.isEmpty()) { rtl_TextEncoding nEncoding = m_aStates.top().getCurrentEncoding(); - if (m_aStates.top().getDestination() == Destination::FONTENTRY - && m_aStates.top().getCurrentEncoding() == RTL_TEXTENCODING_SYMBOL) + if (nEncoding == RTL_TEXTENCODING_SYMBOL + && (m_aStates.top().getDestination() == Destination::FONTENTRY + || (m_aStates.size() > 1 + && m_aStates[m_aStates.size() - 2].getDestination() + == Destination::FIELDINSTRUCTION))) nEncoding = RTL_TEXTENCODING_MS_1252; OUString aString = OStringToOUString(m_aHexBuffer, nEncoding); m_aHexBuffer.setLength(0); |