Kaydet (Commit) 3370752d authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: make RTFParserState members private, part 1

Change-Id: Iae4d454e0b160ee7f5b39d252505748c693a9c9e
Reviewed-on: https://gerrit.libreoffice.org/72554
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst b81004e9
......@@ -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:
......
......@@ -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);
}
......
......@@ -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.
......
......@@ -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:
{
......
......@@ -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[].
......
......@@ -183,7 +183,8 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
{
for (const uno::Sequence<beans::PropertyValue>& entry : m_manifest)
{
OUString sPath, sMediaType;
OUString sPath;
OUString sMediaType;
bool bEncrypted = false;
for (const beans::PropertyValue& prop : entry)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment