writerfilter/source/rtftok/rtfdocumentimpl.cxx | 83 ++++++++++++------------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 5 - 2 files changed, 44 insertions(+), 44 deletions(-)
New commits: commit 1145265b3f4bac37939726b1f4bf430eb5ec2c54 Author: Maxime de Roucy <mdero...@linagora.com> Date: Mon Mar 25 16:33:55 2013 +0100 solve fdo#62805 move m_pCurrentBuffer to RTFParserState Change-Id: Ied16ee1704d35c6bd0368b26a210131b60bc91a3 Reviewed-on: https://gerrit.libreoffice.org/3082 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 3f18695..7e9c8b0 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -254,7 +254,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_aTableBuffer(), m_aSuperBuffer(), m_aShapetextBuffer(), - m_pCurrentBuffer(0), m_bHasFootnote(false), m_pSuperstream(0), m_nHeaderFooterPositions(), @@ -437,7 +436,7 @@ void RTFDocumentImpl::checkNeedPap() if (m_bNeedPap) { m_bNeedPap = false; // reset early, so we can avoid recursion when calling ourselves - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) { writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties( getProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms) @@ -465,14 +464,14 @@ void RTFDocumentImpl::checkNeedPap() else { RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)); - m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue)); } } } void RTFDocumentImpl::runProps() { - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) { writerfilter::Reference<Properties>::Pointer_t const pProperties = getProperties(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms); Mapper().props(pProperties); @@ -480,7 +479,7 @@ void RTFDocumentImpl::runProps() else { RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms)); - m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue)); } } @@ -839,7 +838,7 @@ int RTFDocumentImpl::resolvePict(bool bInline) } writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes, aSprms)); checkFirstRun(); - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) { Mapper().props(pProperties); // Make sure we don't loose these properties with a too early reset. @@ -848,7 +847,7 @@ int RTFDocumentImpl::resolvePict(bool bInline) else { RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms)); - m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue)); } return 0; } @@ -948,7 +947,7 @@ bool RTFFrame::inFrame() void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps) { sal_uInt8 sValue[] = { nValue }; - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) { Mapper().startCharacterGroup(); // Should we send run properties? @@ -959,10 +958,10 @@ void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps) } else { - m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t())); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t())); RTFValue::Pointer_t pValue(new RTFValue(*sValue)); - m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue)); - m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t())); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t())); } } @@ -1109,31 +1108,31 @@ void RTFDocumentImpl::text(OUString& rString) return; } - if (!m_pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE) + if (!m_aStates.top().pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE) Mapper().startCharacterGroup(); - else if (m_pCurrentBuffer) + else if (m_aStates.top().pCurrentBuffer) { RTFValue::Pointer_t pValue; - m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, pValue)); } if (m_aStates.top().nDestinationState == DESTINATION_NORMAL || m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT || m_aStates.top().nDestinationState == DESTINATION_SHAPETEXT) runProps(); - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) Mapper().utext(reinterpret_cast<sal_uInt8 const*>(rString.getStr()), rString.getLength()); else { RTFValue::Pointer_t pValue(new RTFValue(rString)); - m_pCurrentBuffer->push_back(make_pair(BUFFER_UTEXT, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_UTEXT, pValue)); } m_bNeedCr = true; - if (!m_pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE) + if (!m_aStates.top().pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE) Mapper().endCharacterGroup(); - else if(m_pCurrentBuffer) + else if(m_aStates.top().pCurrentBuffer) { RTFValue::Pointer_t pValue; - m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, pValue)); } } @@ -1289,7 +1288,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) break; case RTF_SHPINST: // Don't try to support shapes inside tables for now. - if (m_pCurrentBuffer != &m_aTableBuffer) + if (m_aStates.top().pCurrentBuffer != &m_aTableBuffer) m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION; else m_aStates.top().nDestinationState = DESTINATION_SKIP; @@ -1343,8 +1342,8 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) nId = NS_rtf::LN_endnote; m_bHasFootnote = true; - if (m_pCurrentBuffer == &m_aSuperBuffer) - m_pCurrentBuffer = 0; + if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer) + m_aStates.top().pCurrentBuffer = 0; bool bCustomMark = false; OUString aCustomMark; while (m_aSuperBuffer.size()) @@ -1415,7 +1414,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) dispatchFlag(RTF_PARD); m_bNeedPap = true; OSL_ENSURE(!m_aShapetextBuffer.size(), "shapetext buffer is not empty"); - m_pCurrentBuffer = &m_aShapetextBuffer; + m_aStates.top().pCurrentBuffer = &m_aShapetextBuffer; break; case RTF_FORMFIELD: if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION) @@ -1463,7 +1462,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_aStates.top().nDestinationState = DESTINATION_OBJECT; // check if the object is in a special container (e.g. a table) - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) { // the object is in a table or another container. // Don't try to treate it as an OLE object (fdo#53594). @@ -1475,7 +1474,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) break; case RTF_OBJDATA: // check if the object is in a special container (e.g. a table) - if (m_pCurrentBuffer) + if (m_aStates.top().pCurrentBuffer) { // the object is in a table or another container. // Use the \result (RTF_RESULT) element of the object instead, @@ -1695,7 +1694,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) checkNeedPap(); if (bNeedPap) runProps(); - if (!m_pCurrentBuffer) + if (!m_aStates.top().pCurrentBuffer) { parBreak(); // Not in table? Reset max width. @@ -1704,7 +1703,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT) { RTFValue::Pointer_t pValue; - m_pCurrentBuffer->push_back(make_pair(BUFFER_PAR, pValue)); + m_aStates.top().pCurrentBuffer->push_back(make_pair(BUFFER_PAR, pValue)); } // but don't emit properties yet, since they may change till the first text token arrives m_bNeedPap = true; @@ -2128,9 +2127,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) // Trivial paragraph flags switch (nKeyword) { - case RTF_KEEP: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeep; break; - case RTF_KEEPN: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeepFollow; break; - case RTF_INTBL: m_pCurrentBuffer = &m_aTableBuffer; nParam = NS_sprm::LN_PFInTable; break; + case RTF_KEEP: if (m_aStates.top().pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeep; break; + case RTF_KEEPN: if (m_aStates.top().pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeepFollow; break; + case RTF_INTBL: m_aStates.top().pCurrentBuffer = &m_aTableBuffer; nParam = NS_sprm::LN_PFInTable; break; case RTF_PAGEBB: nParam = NS_sprm::LN_PFPageBreakBefore; break; default: break; } @@ -2176,7 +2175,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms; m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes; if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT) - m_pCurrentBuffer = 0; + m_aStates.top().pCurrentBuffer = 0; } else { @@ -2378,8 +2377,8 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) break; case RTF_SUPER: { - if (!m_pCurrentBuffer) - m_pCurrentBuffer = &m_aSuperBuffer; + if (!m_aStates.top().pCurrentBuffer) + m_aStates.top().pCurrentBuffer = &m_aSuperBuffer; RTFValue::Pointer_t pValue(new RTFValue("superscript")); m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue); } @@ -2391,10 +2390,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) } break; case RTF_NOSUPERSUB: - if (m_pCurrentBuffer == &m_aSuperBuffer) + if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer) { replayBuffer(m_aSuperBuffer); - m_pCurrentBuffer = 0; + m_aStates.top().pCurrentBuffer = 0; } m_aStates.top().aCharacterSprms.erase(NS_ooxml::LN_EG_RPrBase_vertAlign); break; @@ -2720,7 +2719,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) { m_bNeedPap = true; // Don't try to support text frames inside tables for now. - if (m_pCurrentBuffer != &m_aTableBuffer) + if (m_aStates.top().pCurrentBuffer != &m_aTableBuffer) m_aStates.top().aFrame.setSprm(nId, nParam); return 0; } @@ -3761,9 +3760,6 @@ int RTFDocumentImpl::popState() case DESTINATION_PICT: resolvePict(true); break; - case DESTINATION_SHAPETEXT: - m_pCurrentBuffer = 0; // Just disable buffering, don't empty it yet. - break; case DESTINATION_FORMFIELDNAME: { RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear())); @@ -4288,11 +4284,13 @@ int RTFDocumentImpl::popState() else if (m_xDocumentProperties.is()) m_xDocumentProperties->setTitle(aState.aDestinationText.makeStringAndClear()); } - if (m_pCurrentBuffer == &m_aSuperBuffer) + if (aState.pCurrentBuffer == &m_aSuperBuffer) { + OSL_ASSERT(m_aStates.top().pCurrentBuffer == 0); + if (!m_bHasFootnote) replayBuffer(m_aSuperBuffer); - m_pCurrentBuffer = 0; + m_bHasFootnote = false; } if (m_aStates.size()) @@ -4405,7 +4403,8 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl) nDay(0), nHour(0), nMinute(0), - nCurrentStyleIndex(-1) + nCurrentStyleIndex(-1), + pCurrentBuffer(0) { } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 5ced019..a96ad9a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -407,6 +407,9 @@ namespace writerfilter { /// Same as the int value of NS_rtf::LN_ISTD in aParagraphAttributes, for performance reasons. int nCurrentStyleIndex; + + /// Points to the active buffer, if there is one. + RTFBuffer_t* pCurrentBuffer; }; class RTFTokenizer; @@ -540,8 +543,6 @@ namespace writerfilter { RTFBuffer_t m_aSuperBuffer; /// Buffered shape text. RTFBuffer_t m_aShapetextBuffer; - /// Points to the active buffer, if there is one. - RTFBuffer_t* m_pCurrentBuffer; bool m_bHasFootnote; /// Superstream of this substream. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits