diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-05-17 21:38:48 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-05-20 10:04:44 +0200 |
commit | 3370752deb902df86cf625c4bc8e63728b5eb27d (patch) | |
tree | 0125c37a05612236d3deb00319ed9d815814f212 /writerfilter/source | |
parent | b81004e95638da19cbcaa7a61f9edd094a9eac31 (diff) |
writerfilter: make RTFParserState members private, part 1
Change-Id: Iae4d454e0b160ee7f5b39d252505748c693a9c9e
Reviewed-on: https://gerrit.libreoffice.org/72554
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter/source')
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchdestination.cxx | 26 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchflag.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchsymbol.cxx | 32 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 120 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 67 |
6 files changed, 155 insertions, 122 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx index 71bec66ba057..7b1f84fbe6ae 100644 --- a/writerfilter/source/rtftok/rtfdispatchdestination.cxx +++ b/writerfilter/source/rtftok/rtfdispatchdestination.cxx @@ -122,7 +122,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) break; case RTF_LISTPICTURE: m_aStates.top().eDestination = Destination::LISTPICTURE; - m_aStates.top().bInListpicture = true; + m_aStates.top().setInListpicture(true); break; case RTF_LIST: m_aStates.top().eDestination = Destination::LISTENTRY; @@ -176,7 +176,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) case RTF_SHP: m_bNeedCrOrig = m_bNeedCr; m_aStates.top().eDestination = Destination::SHAPE; - m_aStates.top().bInShape = true; + m_aStates.top().setInShape(true); break; case RTF_SHPINST: m_aStates.top().eDestination = Destination::SHAPEINSTRUCTION; @@ -274,8 +274,8 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) if (aKeyword == "\\ftnalt") nId = NS_ooxml::LN_endnote; - if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer) - m_aStates.top().pCurrentBuffer = nullptr; + if (m_aStates.top().getCurrentBuffer() == &m_aSuperBuffer) + m_aStates.top().setCurrentBuffer(nullptr); bool bCustomMark = false; OUString aCustomMark; for (auto const& elem : m_aSuperBuffer) @@ -290,7 +290,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_aStates.top().eDestination = Destination::FOOTNOTE; Mapper().startCharacterGroup(); runProps(); - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark); else { @@ -298,7 +298,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) aAttributes.set(Id(0), new RTFValue(m_nGroupStartPos - 1)); aAttributes.set(Id(1), new RTFValue(nId)); aAttributes.set(Id(2), new RTFValue(aCustomMark)); - m_aStates.top().pCurrentBuffer->push_back( + m_aStates.top().getCurrentBuffer()->push_back( Buf_t(BUFFER_RESOLVESUBSTREAM, new RTFValue(aAttributes), nullptr)); } if (bCustomMark) @@ -382,13 +382,13 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_bNeedPap = true; if (nKeyword == RTF_SHPTXT) { - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) m_pSdrImport->resolve(m_aStates.top().aShape, false, RTFSdrImport::SHAPE); else { auto pValue = new RTFValue(m_aStates.top().aShape); - m_aStates.top().pCurrentBuffer->push_back( + m_aStates.top().getCurrentBuffer()->push_back( Buf_t(BUFFER_STARTSHAPE, pValue, nullptr)); } } @@ -441,7 +441,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_aStates.top().eDestination = Destination::OBJECT; // check if the object is in a special container (e.g. a table) - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) { // the object is in a table or another container. // Don't try to treat it as an OLE object (fdo#53594). @@ -453,7 +453,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) break; case RTF_OBJDATA: // check if the object is in a special container (e.g. a table) - if (m_aStates.top().pCurrentBuffer) + if (m_aStates.top().getCurrentBuffer()) { // the object is in a table or another container. // Use the \result (RTF_RESULT) element of the object instead, @@ -585,7 +585,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) break; case RTF_BACKGROUND: m_aStates.top().eDestination = Destination::BACKGROUND; - m_aStates.top().bInBackground = true; + m_aStates.top().setInBackground(true); break; case RTF_SHPGRP: { @@ -607,10 +607,10 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) xDrawSupplier->getDrawPage()->add(xShape); } m_pSdrImport->pushParent(xGroupShape); - m_aStates.top().bCreatedShapeGroup = true; + m_aStates.top().setCreatedShapeGroup(true); } m_aStates.top().eDestination = Destination::SHAPEGROUP; - m_aStates.top().bInShapeGroup = true; + m_aStates.top().setInShapeGroup(true); } break; case RTF_FTNSEP: diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 44dff92778ca..34e8401bc368 100644 --- a/writerfilter/source/rtftok/rtfdispatchflag.cxx +++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx @@ -411,16 +411,16 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) switch (nKeyword) { case RTF_KEEP: - if (m_aStates.top().pCurrentBuffer != &m_aTableBufferStack.back()) + if (m_aStates.top().getCurrentBuffer() != &m_aTableBufferStack.back()) nParam = NS_ooxml::LN_CT_PPrBase_keepLines; break; case RTF_KEEPN: - if (m_aStates.top().pCurrentBuffer != &m_aTableBufferStack.back()) + if (m_aStates.top().getCurrentBuffer() != &m_aTableBufferStack.back()) nParam = NS_ooxml::LN_CT_PPrBase_keepNext; break; case RTF_INTBL: { - m_aStates.top().pCurrentBuffer = &m_aTableBufferStack.back(); + m_aStates.top().setCurrentBuffer(&m_aTableBufferStack.back()); nParam = NS_ooxml::LN_inTbl; } break; @@ -489,7 +489,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) if (m_nTopLevelCells == 0 && m_nNestedCells == 0) { // Reset that we're in a table. - m_aStates.top().pCurrentBuffer = nullptr; + m_aStates.top().setCurrentBuffer(nullptr); } else { @@ -781,8 +781,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) checkNeedPap(); } - if (!m_aStates.top().pCurrentBuffer) - m_aStates.top().pCurrentBuffer = &m_aSuperBuffer; + if (!m_aStates.top().getCurrentBuffer()) + m_aStates.top().setCurrentBuffer(&m_aSuperBuffer); auto pValue = new RTFValue("superscript"); m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue); @@ -796,10 +796,10 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) break; case RTF_NOSUPERSUB: { - if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer) + if (m_aStates.top().getCurrentBuffer() == &m_aSuperBuffer) { replayBuffer(m_aSuperBuffer, nullptr, nullptr); - m_aStates.top().pCurrentBuffer = nullptr; + m_aStates.top().setCurrentBuffer(nullptr); } m_aStates.top().aCharacterSprms.erase(NS_ooxml::LN_EG_RPrBase_vertAlign); } diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx index 6d7d9cefabaa..61099ba7baae 100644 --- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx +++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx @@ -105,7 +105,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) checkNeedPap(); if (bNeedPap) runProps(); - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) { parBreak(); // Not in table? Reset max width. @@ -124,7 +124,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) else if (m_aStates.top().eDestination != Destination::SHAPETEXT) { RTFValue::Pointer_t pValue; - m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PAR, pValue, nullptr)); + m_aStates.top().getCurrentBuffer()->push_back(Buf_t(BUFFER_PAR, pValue, nullptr)); } // but don't emit properties yet, since they may change till the first text token arrives m_bNeedPap = true; @@ -204,19 +204,19 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) pBuffer->GetFrameProperties(), pBuffer->GetRowProperties(), m_nNestedCells, m_nNestedCurrentCellX - m_nNestedTRLeft); - if (m_aTableBufferStack.size() == 1 || !m_aStates.top().pCurrentBuffer) + if (m_aTableBufferStack.size() == 1 || !m_aStates.top().getCurrentBuffer()) { throw io::WrongFormatException("mismatch between \\itap and number of \\nestrow", nullptr); } - assert(m_aStates.top().pCurrentBuffer == &m_aTableBufferStack.back()); + assert(m_aStates.top().getCurrentBuffer() == &m_aTableBufferStack.back()); // note: there may be several states pointing to table buffer! for (std::size_t i = 0; i < m_aStates.size(); ++i) { - if (m_aStates[i].pCurrentBuffer == &m_aTableBufferStack.back()) + if (m_aStates[i].getCurrentBuffer() == &m_aTableBufferStack.back()) { - m_aStates[i].pCurrentBuffer - = &m_aTableBufferStack[m_aTableBufferStack.size() - 2]; + m_aStates[i].setCurrentBuffer( + &m_aTableBufferStack[m_aTableBufferStack.size() - 2]); } } m_aTableBufferStack.pop_back(); @@ -232,19 +232,19 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) case RTF_ROW: { m_bAfterCellBeforeRow = false; - if (m_aStates.top().nTableRowWidthAfter > 0) + if (m_aStates.top().getTableRowWidthAfter() > 0) { // Add fake cellx / cell, RTF equivalent of // OOXMLFastContextHandlerTextTableRow::handleGridAfter(). - auto pXValue = new RTFValue(m_aStates.top().nTableRowWidthAfter); + auto pXValue = new RTFValue(m_aStates.top().getTableRowWidthAfter()); m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, RTFOverwrite::NO_APPEND); dispatchSymbol(RTF_CELL); // Adjust total width, which is done in the \cellx handler for normal cells. - m_nTopLevelCurrentCellX += m_aStates.top().nTableRowWidthAfter; + m_nTopLevelCurrentCellX += m_aStates.top().getTableRowWidthAfter(); - m_aStates.top().nTableRowWidthAfter = 0; + m_aStates.top().setTableRowWidthAfter(0); } bool bRestored = false; @@ -291,9 +291,9 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) // note: there may be several states pointing to table buffer! for (std::size_t i = 0; i < m_aStates.size(); ++i) { - if (m_aStates[i].pCurrentBuffer == &m_aTableBufferStack.back()) + if (m_aStates[i].getCurrentBuffer() == &m_aTableBufferStack.back()) { - m_aStates[i].pCurrentBuffer = &m_aTableBufferStack.front(); + m_aStates[i].setCurrentBuffer(&m_aTableBufferStack.front()); } } m_aTableBufferStack.pop_back(); @@ -350,15 +350,15 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) break; case RTF_CHFTN: { - if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer) + if (m_aStates.top().getCurrentBuffer() == &m_aSuperBuffer) // Stop buffering, there will be no custom mark for this footnote or endnote. - m_aStates.top().pCurrentBuffer = nullptr; + m_aStates.top().setCurrentBuffer(nullptr); break; } case RTF_PAGE: { // Ignore page breaks inside tables. - if (m_aStates.top().pCurrentBuffer == &m_aTableBufferStack.back()) + if (m_aStates.top().getCurrentBuffer() == &m_aTableBufferStack.back()) break; // If we're inside a continuous section, we should send a section break, not a page one. diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index 6c6079949213..7f662812cc43 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -251,7 +251,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) } // Invalid tables may omit INTBL after ITAP dispatchFlag(RTF_INTBL); // sets newly pushed buffer as current - assert(m_aStates.top().pCurrentBuffer == &m_aTableBufferStack.back()); + assert(m_aStates.top().getCurrentBuffer() == &m_aTableBufferStack.back()); } return RTFError::OK; } @@ -325,7 +325,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) { m_bNeedPap = true; // Don't try to support text frames inside tables for now. - if (m_aStates.top().pCurrentBuffer != &m_aTableBufferStack.back()) + if (m_aStates.top().getCurrentBuffer() != &m_aTableBufferStack.back()) m_aStates.top().aFrame.setSprm(nId, nParam); return RTFError::OK; @@ -1557,19 +1557,19 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) switch (nParam) { case 3: - m_aStates.top().aPropType = cppu::UnoType<sal_Int32>::get(); + m_aStates.top().setPropType(cppu::UnoType<sal_Int32>::get()); break; case 5: - m_aStates.top().aPropType = cppu::UnoType<double>::get(); + m_aStates.top().setPropType(cppu::UnoType<double>::get()); break; case 11: - m_aStates.top().aPropType = cppu::UnoType<bool>::get(); + m_aStates.top().setPropType(cppu::UnoType<bool>::get()); break; case 30: - m_aStates.top().aPropType = cppu::UnoType<OUString>::get(); + m_aStates.top().setPropType(cppu::UnoType<OUString>::get()); break; case 64: - m_aStates.top().aPropType = cppu::UnoType<util::DateTime>::get(); + m_aStates.top().setPropType(cppu::UnoType<util::DateTime>::get()); break; } } @@ -1578,7 +1578,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aPicture.eStyle = RTFBmpStyle::DIBITMAP; break; case RTF_TRWWIDTHA: - m_aStates.top().nTableRowWidthAfter = nParam; + m_aStates.top().setTableRowWidthAfter(nParam); break; case RTF_ANIMTEXT: { diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index d11275b3bc63..764bbf28e960 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -544,7 +544,7 @@ void RTFDocumentImpl::checkNeedPap() if (m_aStates.empty()) return; - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) { writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties( getProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms, @@ -576,14 +576,14 @@ void RTFDocumentImpl::checkNeedPap() { auto pValue = new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms); - bufferProperties(*m_aStates.top().pCurrentBuffer, pValue, nullptr); + bufferProperties(*m_aStates.top().getCurrentBuffer(), pValue, nullptr); } } } void RTFDocumentImpl::runProps() { - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) { Reference<Properties>::Pointer_t const pProperties = getProperties(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms, @@ -594,7 +594,7 @@ void RTFDocumentImpl::runProps() { auto pValue = new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms); - bufferProperties(*m_aStates.top().pCurrentBuffer, pValue, nullptr); + bufferProperties(*m_aStates.top().getCurrentBuffer(), pValue, nullptr); } // Delete the sprm, so the trackchange range will be started only once. @@ -603,7 +603,7 @@ void RTFDocumentImpl::runProps() = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange); if (pTrackchange) { - m_aStates.top().bStartedTrackchange = true; + m_aStates.top().setStartedTrackchange(true); m_aStates.top().aCharacterSprms.erase(NS_ooxml::LN_trackchange); } } @@ -981,7 +981,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS return; } - if (m_aStates.top().bInListpicture) + if (m_aStates.top().getInListpicture()) { // Send the shape directly, no section is started, to additional properties will be ignored anyway. Mapper().startShape(xShape); @@ -1023,7 +1023,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS nYExt = (static_cast<long>(m_aStates.top().aPicture.nScaleY) * (nYExt - (m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB))) / 100L; - if (m_aStates.top().bInShape) + if (m_aStates.top().getInShape()) { // Picture in shape: it looks like pib picture, so we will stretch the picture to shape size (tdf#49893) nXExt = m_aStates.top().aShape.getRight() - m_aStates.top().aShape.getLeft(); @@ -1140,7 +1140,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS = new RTFReferenceProperties(aAttributes, aSprms); checkFirstRun(); - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) { Mapper().props(pProperties); // Make sure we don't lose these properties with a too early reset. @@ -1149,7 +1149,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS else { auto pValue = new RTFValue(aAttributes, aSprms); - bufferProperties(*m_aStates.top().pCurrentBuffer, pValue, nullptr); + bufferProperties(*m_aStates.top().getCurrentBuffer(), pValue, nullptr); } } @@ -1282,7 +1282,7 @@ bool RTFFrame::inFrame() { return m_nW > 0 || m_nH > 0 || m_nX > 0 || m_nY > 0; void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps) { sal_uInt8 sValue[] = { nValue }; - RTFBuffer_t* pCurrentBuffer = m_aStates.top().pCurrentBuffer; + RTFBuffer_t* pCurrentBuffer = m_aStates.top().getCurrentBuffer(); if (!pCurrentBuffer) { @@ -1481,7 +1481,7 @@ void RTFDocumentImpl::text(OUString& rString) return; } - RTFBuffer_t* pCurrentBuffer = m_aStates.top().pCurrentBuffer; + RTFBuffer_t* pCurrentBuffer = m_aStates.top().getCurrentBuffer(); if (!pCurrentBuffer && m_aStates.top().eDestination != Destination::FOOTNOTE) Mapper().startCharacterGroup(); @@ -1656,15 +1656,15 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* const pSprms, { // Make sure there is no current buffer while replaying the shape, // otherwise it gets re-buffered. - RTFBuffer_t* pCurrentBuffer = m_aStates.top().pCurrentBuffer; - m_aStates.top().pCurrentBuffer = nullptr; + RTFBuffer_t* pCurrentBuffer = m_aStates.top().getCurrentBuffer(); + m_aStates.top().setCurrentBuffer(nullptr); // Set current shape during replay, needed by e.g. wrap in // background. m_aStates.top().aShape = std::get<1>(aTuple)->getShape(); m_pSdrImport->resolve(std::get<1>(aTuple)->getShape(), true, RTFSdrImport::SHAPE); - m_aStates.top().pCurrentBuffer = pCurrentBuffer; + m_aStates.top().setCurrentBuffer(pCurrentBuffer); } else if (std::get<0>(aTuple) == BUFFER_ENDSHAPE) m_pSdrImport->close(); @@ -1991,7 +1991,7 @@ RTFError RTFDocumentImpl::pushState() // If this is true, then ooxml:endtrackchange will be generated. Make sure // we don't generate more ooxml:endtrackchange than ooxml:trackchange: new // state does not inherit this flag. - m_aStates.top().bStartedTrackchange = false; + m_aStates.top().setStartedTrackchange(false); return RTFError::OK; } @@ -2179,7 +2179,7 @@ RTFError RTFDocumentImpl::popState() RTFSprms aFFAttributes; RTFSprms aFFSprms; aFFSprms.set(NS_ooxml::LN_ffdata, pValue); - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) { writerfilter::Reference<Properties>::Pointer_t pProperties = new RTFReferenceProperties(aFFAttributes, aFFSprms); @@ -2188,7 +2188,7 @@ RTFError RTFDocumentImpl::popState() else { auto pFFValue = new RTFValue(aFFAttributes, aFFSprms); - bufferProperties(*m_aStates.top().pCurrentBuffer, pFFValue, nullptr); + bufferProperties(*m_aStates.top().getCurrentBuffer(), pFFValue, nullptr); } m_aFormfieldAttributes.clear(); m_aFormfieldSprms.clear(); @@ -2309,10 +2309,10 @@ RTFError RTFDocumentImpl::popState() { aState.aShape.getProperties().back().second = m_aStates.top().pDestinationText->makeStringAndClear(); - if (m_aStates.top().bHadShapeText) + if (m_aStates.top().getHadShapeText()) m_pSdrImport->append(aState.aShape.getProperties().back().first, aState.aShape.getProperties().back().second); - else if (aState.bInShapeGroup && !aState.bInShape + else if (aState.getInShapeGroup() && !aState.getInShape() && aState.aShape.getProperties().back().first == "rotation") { // Rotation should be applied on the groupshape itself, not on each shape. @@ -2329,14 +2329,14 @@ RTFError RTFDocumentImpl::popState() { // Do not resolve shape if shape instruction destination is inside other shape instruction } - else if (!m_bObject && !aState.bInListpicture && !aState.bHadShapeText - && !(aState.bInShapeGroup && !aState.bInShape)) + else if (!m_bObject && !aState.getInListpicture() && !aState.getHadShapeText() + && !(aState.getInShapeGroup() && !aState.getInShape())) { // Don't trigger a shape import in case we're only leaving the \shpinst of the groupshape itself. RTFSdrImport::ShapeOrPict eType = (aState.eDestination == Destination::SHAPEINSTRUCTION) ? RTFSdrImport::SHAPE : RTFSdrImport::PICT; - if (!m_aStates.top().pCurrentBuffer || eType != RTFSdrImport::SHAPE) + if (!m_aStates.top().getCurrentBuffer() || eType != RTFSdrImport::SHAPE) m_pSdrImport->resolve(m_aStates.top().aShape, true, eType); else { @@ -2344,7 +2344,7 @@ RTFError RTFDocumentImpl::popState() // Also buffer the RTFPicture of the state stack as it contains // the shape size. auto pPictureValue = new RTFValue(m_aStates.top().aPicture); - m_aStates.top().pCurrentBuffer->push_back( + m_aStates.top().getCurrentBuffer()->push_back( Buf_t(BUFFER_PICTURE, pPictureValue, nullptr)); auto pValue = new RTFValue(m_aStates.top().aShape); @@ -2359,11 +2359,11 @@ RTFError RTFDocumentImpl::popState() } } - m_aStates.top().pCurrentBuffer->push_back( + m_aStates.top().getCurrentBuffer()->push_back( Buf_t(BUFFER_RESOLVESHAPE, pValue, nullptr)); } } - else if (aState.bInShapeGroup && !aState.bInShape) + else if (aState.getInShapeGroup() && !aState.getInShape()) { // End of a groupshape, as we're in shapegroup, but not in a real shape. for (auto& rGroupProperty : aState.aShape.getGroupProperties()) @@ -2378,10 +2378,10 @@ RTFError RTFDocumentImpl::popState() OUString aStr = m_aStates.top().pDestinationText->makeStringAndClear(); int nPos = m_aBookmarks.size(); m_aBookmarks[aStr] = nPos; - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) Mapper().props(new RTFReferenceProperties(lcl_getBookmarkProperties(nPos, aStr))); else - bufferProperties(*m_aStates.top().pCurrentBuffer, + bufferProperties(*m_aStates.top().getCurrentBuffer(), new RTFValue(lcl_getBookmarkProperties(nPos, aStr)), nullptr); } break; @@ -2390,11 +2390,11 @@ RTFError RTFDocumentImpl::popState() if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText) break; // not for nested group OUString aStr = m_aStates.top().pDestinationText->makeStringAndClear(); - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) Mapper().props(new RTFReferenceProperties( lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr))); else - bufferProperties(*m_aStates.top().pCurrentBuffer, + bufferProperties(*m_aStates.top().getCurrentBuffer(), new RTFValue(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr)), nullptr); } @@ -2990,13 +2990,13 @@ RTFError RTFDocumentImpl::popState() m_aMathBuffer.appendClosingTag(M_TOKEN(eqArr)); break; case Destination::SHAPEGROUP: - if (aState.bCreatedShapeGroup) + if (aState.getCreatedShapeGroup()) m_pSdrImport->popParent(); break; case Destination::PROPNAME: if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText) break; // not for nested group - aState.aPropName = m_aStates.top().pDestinationText->makeStringAndClear(); + aState.setPropName(m_aStates.top().pDestinationText->makeStringAndClear()); break; case Destination::STATICVAL: if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText) @@ -3006,18 +3006,18 @@ RTFError RTFDocumentImpl::popState() // Find out what is the key, value type and value we want to set. uno::Reference<beans::XPropertyContainer> xPropertyContainer = m_xDocumentProperties->getUserDefinedProperties(); - const OUString& rKey = m_aStates.top().aPropName; + const OUString& rKey = m_aStates.top().getPropName(); OUString aStaticVal = m_aStates.top().pDestinationText->makeStringAndClear(); uno::Any aAny; - if (m_aStates.top().aPropType == cppu::UnoType<OUString>::get()) + if (m_aStates.top().getPropType() == cppu::UnoType<OUString>::get()) aAny <<= aStaticVal; - else if (m_aStates.top().aPropType == cppu::UnoType<sal_Int32>::get()) + else if (m_aStates.top().getPropType() == cppu::UnoType<sal_Int32>::get()) aAny <<= aStaticVal.toInt32(); - else if (m_aStates.top().aPropType == cppu::UnoType<bool>::get()) + else if (m_aStates.top().getPropType() == cppu::UnoType<bool>::get()) aAny <<= aStaticVal.toBoolean(); - else if (m_aStates.top().aPropType == cppu::UnoType<util::DateTime>::get()) + else if (m_aStates.top().getPropType() == cppu::UnoType<util::DateTime>::get()) aAny <<= getDateTimeFromUserProp(aStaticVal); - else if (m_aStates.top().aPropType == cppu::UnoType<double>::get()) + else if (m_aStates.top().getPropType() == cppu::UnoType<double>::get()) aAny <<= aStaticVal.toDouble(); xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny); @@ -3090,16 +3090,16 @@ RTFError RTFDocumentImpl::popState() } // See if we need to end a track change - if (aState.bStartedTrackchange) + if (aState.getStartedTrackchange()) { RTFSprms aTCSprms; auto pValue = new RTFValue(0); aTCSprms.set(NS_ooxml::LN_endtrackchange, pValue); - if (!m_aStates.top().pCurrentBuffer) + if (!m_aStates.top().getCurrentBuffer()) Mapper().props(new RTFReferenceProperties(RTFSprms(), aTCSprms)); else - bufferProperties(*m_aStates.top().pCurrentBuffer, new RTFValue(RTFSprms(), aTCSprms), - nullptr); + bufferProperties(*m_aStates.top().getCurrentBuffer(), + new RTFValue(RTFSprms(), aTCSprms), nullptr); } // This is the end of the doc, see if we need to close the last section. @@ -3370,11 +3370,11 @@ RTFError RTFDocumentImpl::popState() if (m_aStates.top().eDestination != Destination::SHAPETEXT && !m_aStates.top().aDrawingObject.getHadShapeText()) { - m_aStates.top().bHadShapeText = true; - if (!m_aStates.top().pCurrentBuffer) + m_aStates.top().setHadShapeText(true); + if (!m_aStates.top().getCurrentBuffer()) m_pSdrImport->close(); else - m_aStates.top().pCurrentBuffer->push_back( + m_aStates.top().getCurrentBuffer()->push_back( Buf_t(BUFFER_ENDSHAPE, nullptr, nullptr)); } @@ -3392,7 +3392,7 @@ RTFError RTFDocumentImpl::popState() break; case Destination::PROPNAME: if (m_aStates.top().eDestination == Destination::USERPROPS) - m_aStates.top().aPropName = aState.aPropName; + m_aStates.top().setPropName(aState.getPropName()); break; default: { @@ -3402,19 +3402,19 @@ RTFError RTFDocumentImpl::popState() break; } - if (aState.pCurrentBuffer == &m_aSuperBuffer) + if (aState.getCurrentBuffer() == &m_aSuperBuffer) { - OSL_ASSERT(!m_aStates.empty() && m_aStates.top().pCurrentBuffer == nullptr); + OSL_ASSERT(!m_aStates.empty() && m_aStates.top().getCurrentBuffer() == nullptr); if (!m_aSuperBuffer.empty()) replayBuffer(m_aSuperBuffer, nullptr, nullptr); } - if (!m_aStates.empty() && m_aStates.top().nTableRowWidthAfter > 0 - && aState.nTableRowWidthAfter == 0) + if (!m_aStates.empty() && m_aStates.top().getTableRowWidthAfter() > 0 + && aState.getTableRowWidthAfter() == 0) // An RTF_ROW in the inner group already parsed nTableRowWidthAfter, // don't do it again in the outer state later. - m_aStates.top().nTableRowWidthAfter = 0; + m_aStates.top().setTableRowWidthAfter(0); if (m_nResetBreakOnSectBreak != RTF_invalid && !m_aStates.empty()) { @@ -3444,7 +3444,7 @@ RTFError RTFDocumentImpl::handleEmbeddedObject() return RTFError::OK; } -bool RTFDocumentImpl::isInBackground() { return m_aStates.top().bInBackground; } +bool RTFDocumentImpl::isInBackground() { return m_aStates.top().getInBackground(); } RTFInternalState RTFDocumentImpl::getInternalState() { return m_aStates.top().nInternalState; } @@ -3513,15 +3513,15 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl) , pDestinationText(nullptr) , nCurrentStyleIndex(-1) , nCurrentCharacterStyleIndex(-1) - , pCurrentBuffer(nullptr) - , bInListpicture(false) - , bInBackground(false) - , bHadShapeText(false) - , bInShapeGroup(false) - , bInShape(false) - , bCreatedShapeGroup(false) - , bStartedTrackchange(false) - , nTableRowWidthAfter(0) + , m_pCurrentBuffer(nullptr) + , m_bInListpicture(false) + , m_bInBackground(false) + , m_bHadShapeText(false) + , m_bInShapeGroup(false) + , m_bInShape(false) + , m_bCreatedShapeGroup(false) + , m_bStartedTrackchange(false) + , m_nTableRowWidthAfter(0) { } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 1e5178fdc7c8..2fbf158038c4 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -400,6 +400,44 @@ class RTFParserState public: explicit RTFParserState(RTFDocumentImpl* pDocumentImpl); + void appendDestinationText(const OUString& rString) + { + if (pDestinationText) + pDestinationText->append(rString); + } + + void setPropName(const OUString& rPropName) { m_aPropName = rPropName; } + OUString getPropName() const { return m_aPropName; } + void setPropType(const css::uno::Type& rPropType) { m_aPropType = rPropType; } + css::uno::Type getPropType() const { return m_aPropType; } + void setTableRowWidthAfter(int nTableRowWidthAfter) + { + m_nTableRowWidthAfter = nTableRowWidthAfter; + } + int getTableRowWidthAfter() const { return m_nTableRowWidthAfter; } + void setStartedTrackchange(bool bStartedTrackchange) + { + m_bStartedTrackchange = bStartedTrackchange; + } + bool getStartedTrackchange() const { return m_bStartedTrackchange; } + void setCreatedShapeGroup(bool bCreatedShapeGroup) + { + m_bCreatedShapeGroup = bCreatedShapeGroup; + } + bool getCreatedShapeGroup() const { return m_bCreatedShapeGroup; } + void setInShape(bool bInShape) { m_bInShape = bInShape; } + bool getInShape() const { return m_bInShape; } + void setInShapeGroup(bool bInShapeGroup) { m_bInShapeGroup = bInShapeGroup; } + bool getInShapeGroup() const { return m_bInShapeGroup; } + void setHadShapeText(bool bHadShapeText) { m_bHadShapeText = bHadShapeText; } + bool getHadShapeText() const { return m_bHadShapeText; } + void setInBackground(bool bInBackground) { m_bInBackground = bInBackground; } + bool getInBackground() const { return m_bInBackground; } + void setInListpicture(bool bInListpicture) { m_bInListpicture = bInListpicture; } + bool getInListpicture() const { return m_bInListpicture; } + void setCurrentBuffer(RTFBuffer_t* pCurrentBuffer) { m_pCurrentBuffer = pCurrentBuffer; } + RTFBuffer_t* getCurrentBuffer() const { return m_pCurrentBuffer; } + RTFDocumentImpl* m_pDocumentImpl; RTFInternalState nInternalState; Destination eDestination; @@ -475,12 +513,6 @@ public: /// point to the buffer of the current destination OUStringBuffer* pDestinationText; - void appendDestinationText(const OUString& rString) - { - if (pDestinationText) - pDestinationText->append(rString); - } - /// Index of the current style. int nCurrentStyleIndex; /// Index of the current character style. @@ -490,28 +522,29 @@ public: /// Current ls, points to a listoverridetable entry. int nCurrentListOverrideIndex = -1; +private: /// Points to the active buffer, if there is one. - RTFBuffer_t* pCurrentBuffer; + RTFBuffer_t* m_pCurrentBuffer; /// If we're inside a \listpicture group. - bool bInListpicture; + bool m_bInListpicture; /// If we're inside a \background group. - bool bInBackground; + bool m_bInBackground; - bool bHadShapeText; - bool bInShapeGroup; ///< If we're inside a \shpgrp group. - bool bInShape; ///< If we're inside a \shp group. - bool bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack. - bool bStartedTrackchange; ///< Track change is started, need to end it before popping. + bool m_bHadShapeText; + bool m_bInShapeGroup; ///< If we're inside a \shpgrp group. + bool m_bInShape; ///< If we're inside a \shp group. + bool m_bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack. + bool m_bStartedTrackchange; ///< Track change is started, need to end it before popping. /// User-defined property: key name. - OUString aPropName; + OUString m_aPropName; /// User-defined property: value type. - css::uno::Type aPropType; + css::uno::Type m_aPropType; /// Width of invisible cell at the end of the row. - int nTableRowWidthAfter; + int m_nTableRowWidthAfter; }; /// An RTF stack is similar to std::stack, except that it has an operator[]. |