Kaydet (Commit) 66dd28f2 authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: turn RTFBorderState into a C++11 scoped enumeration

Change-Id: I7d608238a72dd71eb22dd72ddb5c6c47cc0150f5
Reviewed-on: https://gerrit.libreoffice.org/14153Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 533f390e
...@@ -119,7 +119,7 @@ static void ...@@ -119,7 +119,7 @@ static void
lcl_putBorderProperty(RTFStack& aStates, Id nId, RTFValue::Pointer_t pValue) lcl_putBorderProperty(RTFStack& aStates, Id nId, RTFValue::Pointer_t pValue)
{ {
RTFSprms* pAttributes = nullptr; RTFSprms* pAttributes = nullptr;
if (aStates.top().nBorderState == BORDER_PARAGRAPH_BOX) if (aStates.top().nBorderState == RTFBorderState::PARAGRAPH_BOX)
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
RTFValue::Pointer_t p = aStates.top().aParagraphSprms.find(lcl_getParagraphBorder(i)); RTFValue::Pointer_t p = aStates.top().aParagraphSprms.find(lcl_getParagraphBorder(i));
...@@ -129,7 +129,7 @@ lcl_putBorderProperty(RTFStack& aStates, Id nId, RTFValue::Pointer_t pValue) ...@@ -129,7 +129,7 @@ lcl_putBorderProperty(RTFStack& aStates, Id nId, RTFValue::Pointer_t pValue)
rAttributes.set(nId, pValue); rAttributes.set(nId, pValue);
} }
} }
else if (aStates.top().nBorderState == BORDER_CHARACTER) else if (aStates.top().nBorderState == RTFBorderState::CHARACTER)
{ {
RTFValue::Pointer_t pPointer = aStates.top().aCharacterSprms.find(NS_ooxml::LN_EG_RPrBase_bdr); RTFValue::Pointer_t pPointer = aStates.top().aCharacterSprms.find(NS_ooxml::LN_EG_RPrBase_bdr);
if (pPointer.get()) if (pPointer.get())
...@@ -139,11 +139,11 @@ lcl_putBorderProperty(RTFStack& aStates, Id nId, RTFValue::Pointer_t pValue) ...@@ -139,11 +139,11 @@ lcl_putBorderProperty(RTFStack& aStates, Id nId, RTFValue::Pointer_t pValue)
} }
} }
// Attributes of the last border type // Attributes of the last border type
else if (aStates.top().nBorderState == BORDER_PARAGRAPH) else if (aStates.top().nBorderState == RTFBorderState::PARAGRAPH)
pAttributes = &lcl_getLastAttributes(aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PrBase_pBdr); pAttributes = &lcl_getLastAttributes(aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PrBase_pBdr);
else if (aStates.top().nBorderState == BORDER_CELL) else if (aStates.top().nBorderState == RTFBorderState::CELL)
pAttributes = &lcl_getLastAttributes(aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcBorders); pAttributes = &lcl_getLastAttributes(aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcBorders);
else if (aStates.top().nBorderState == BORDER_PAGE) else if (aStates.top().nBorderState == RTFBorderState::PAGE)
pAttributes = &lcl_getLastAttributes(aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgBorders); pAttributes = &lcl_getLastAttributes(aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgBorders);
if (pAttributes) if (pAttributes)
pAttributes->set(nId, pValue); pAttributes->set(nId, pValue);
...@@ -2992,7 +2992,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -2992,7 +2992,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
auto pValue = std::make_shared<RTFValue>(aAttributes); auto pValue = std::make_shared<RTFValue>(aAttributes);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
m_aStates.top().aParagraphSprms.set(lcl_getParagraphBorder(i), pValue); m_aStates.top().aParagraphSprms.set(lcl_getParagraphBorder(i), pValue);
m_aStates.top().nBorderState = BORDER_PARAGRAPH_BOX; m_aStates.top().nBorderState = RTFBorderState::PARAGRAPH_BOX;
} }
break; break;
case RTF_LTRSECT: case RTF_LTRSECT:
...@@ -3058,7 +3058,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -3058,7 +3058,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break; break;
} }
lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcBorders, nParam, pValue); lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcBorders, nParam, pValue);
m_aStates.top().nBorderState = BORDER_CELL; m_aStates.top().nBorderState = RTFBorderState::CELL;
} }
break; break;
case RTF_PGBRDRT: case RTF_PGBRDRT:
...@@ -3087,7 +3087,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -3087,7 +3087,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break; break;
} }
lcl_putNestedSprm(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgBorders, nParam, pValue); lcl_putNestedSprm(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgBorders, nParam, pValue);
m_aStates.top().nBorderState = BORDER_PAGE; m_aStates.top().nBorderState = RTFBorderState::PAGE;
} }
break; break;
case RTF_BRDRT: case RTF_BRDRT:
...@@ -3116,7 +3116,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -3116,7 +3116,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break; break;
} }
lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PrBase_pBdr, nParam, pValue); lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PrBase_pBdr, nParam, pValue);
m_aStates.top().nBorderState = BORDER_PARAGRAPH; m_aStates.top().nBorderState = RTFBorderState::PARAGRAPH;
} }
break; break;
case RTF_CHBRDR: case RTF_CHBRDR:
...@@ -3124,7 +3124,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -3124,7 +3124,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
RTFSprms aAttributes; RTFSprms aAttributes;
auto pValue = std::make_shared<RTFValue>(aAttributes); auto pValue = std::make_shared<RTFValue>(aAttributes);
m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_bdr, pValue); m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_bdr, pValue);
m_aStates.top().nBorderState = BORDER_CHARACTER; m_aStates.top().nBorderState = RTFBorderState::CHARACTER;
} }
break; break;
case RTF_CLMGF: case RTF_CLMGF:
...@@ -6100,7 +6100,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl) ...@@ -6100,7 +6100,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl)
nInternalState(RTFInternalState::NORMAL), nInternalState(RTFInternalState::NORMAL),
nDestinationState(DESTINATION_NORMAL), nDestinationState(DESTINATION_NORMAL),
eFieldStatus(RTFFieldStatus::NONE), eFieldStatus(RTFFieldStatus::NONE),
nBorderState(BORDER_NONE), nBorderState(RTFBorderState::NONE),
aTableSprms(), aTableSprms(),
aTableAttributes(), aTableAttributes(),
aCharacterSprms(), aCharacterSprms(),
......
...@@ -34,14 +34,14 @@ namespace writerfilter ...@@ -34,14 +34,14 @@ namespace writerfilter
{ {
namespace rtftok namespace rtftok
{ {
enum RTFBorderState enum class RTFBorderState
{ {
BORDER_NONE, NONE,
BORDER_PARAGRAPH, PARAGRAPH,
BORDER_PARAGRAPH_BOX, PARAGRAPH_BOX,
BORDER_CELL, CELL,
BORDER_PAGE, PAGE,
BORDER_CHARACTER CHARACTER
}; };
/// Minimalistic buffer of elements for nested cells. /// Minimalistic buffer of elements for nested cells.
......
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