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

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

Change-Id: I7407aeba6ddcfd783cee508faa6731c59d0b9759
üst 7bdb5894
...@@ -997,7 +997,7 @@ RTFError RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing ...@@ -997,7 +997,7 @@ RTFError RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing
RTFError RTFDocumentImpl::resolveChars(char ch) RTFError RTFDocumentImpl::resolveChars(char ch)
{ {
if (m_aStates.top().nInternalState == INTERNAL_BIN) if (m_aStates.top().nInternalState == RTFInternalState::BIN)
{ {
m_pBinaryData.reset(new SvMemoryStream()); m_pBinaryData.reset(new SvMemoryStream());
m_pBinaryData->WriteChar(ch); m_pBinaryData->WriteChar(ch);
...@@ -1006,7 +1006,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch) ...@@ -1006,7 +1006,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
Strm().ReadChar(ch); Strm().ReadChar(ch);
m_pBinaryData->WriteChar(ch); m_pBinaryData->WriteChar(ch);
} }
m_aStates.top().nInternalState = INTERNAL_NORMAL; m_aStates.top().nInternalState = RTFInternalState::NORMAL;
return RTFError::OK; return RTFError::OK;
} }
...@@ -1016,10 +1016,9 @@ RTFError RTFDocumentImpl::resolveChars(char ch) ...@@ -1016,10 +1016,9 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
bool bUnicodeChecked = false; bool bUnicodeChecked = false;
bool bSkipped = false; bool bSkipped = false;
while (!Strm().IsEof() && (m_aStates.top().nInternalState == INTERNAL_HEX while (!Strm().IsEof() && (m_aStates.top().nInternalState == RTFInternalState::HEX || (ch != '{' && ch != '}' && ch != '\\')))
|| (ch != '{' && ch != '}' && ch != '\\')))
{ {
if (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != 0x0d && ch != 0x0a)) if (m_aStates.top().nInternalState == RTFInternalState::HEX || (ch != 0x0d && ch != 0x0a))
{ {
if (m_aStates.top().nCharsToSkip == 0) if (m_aStates.top().nCharsToSkip == 0)
{ {
...@@ -1038,7 +1037,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch) ...@@ -1038,7 +1037,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
} }
// read a single char if we're in hex mode // read a single char if we're in hex mode
if (m_aStates.top().nInternalState == INTERNAL_HEX) if (m_aStates.top().nInternalState == RTFInternalState::HEX)
break; break;
if (RTL_TEXTENCODING_MS_932 == m_aStates.top().nCurrentEncoding) if (RTL_TEXTENCODING_MS_932 == m_aStates.top().nCurrentEncoding)
...@@ -1067,10 +1066,10 @@ RTFError RTFDocumentImpl::resolveChars(char ch) ...@@ -1067,10 +1066,10 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
Strm().ReadChar(ch); Strm().ReadChar(ch);
} }
if (m_aStates.top().nInternalState != INTERNAL_HEX && !Strm().IsEof()) if (m_aStates.top().nInternalState != RTFInternalState::HEX && !Strm().IsEof())
Strm().SeekRel(-1); Strm().SeekRel(-1);
if (m_aStates.top().nInternalState == INTERNAL_HEX && m_aStates.top().nDestinationState != DESTINATION_LEVELNUMBERS) if (m_aStates.top().nInternalState == RTFInternalState::HEX && m_aStates.top().nDestinationState != DESTINATION_LEVELNUMBERS)
{ {
if (!bSkipped) if (!bSkipped)
m_aHexBuffer.append(ch); m_aHexBuffer.append(ch);
...@@ -2185,7 +2184,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) ...@@ -2185,7 +2184,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
} }
break; break;
case RTF_HEXCHAR: case RTF_HEXCHAR:
m_aStates.top().nInternalState = INTERNAL_HEX; m_aStates.top().nInternalState = RTFInternalState::HEX;
break; break;
case RTF_CELL: case RTF_CELL:
case RTF_NESTCELL: case RTF_NESTCELL:
...@@ -4526,7 +4525,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) ...@@ -4526,7 +4525,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
break; break;
case RTF_BIN: case RTF_BIN:
{ {
m_aStates.top().nInternalState = INTERNAL_BIN; m_aStates.top().nInternalState = RTFInternalState::BIN;
m_aStates.top().nBinaryToRead = nParam; m_aStates.top().nBinaryToRead = nParam;
} }
break; break;
...@@ -6135,7 +6134,7 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex) ...@@ -6135,7 +6134,7 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex)
RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl) RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl)
: m_pDocumentImpl(pDocumentImpl), : m_pDocumentImpl(pDocumentImpl),
nInternalState(INTERNAL_NORMAL), nInternalState(RTFInternalState::NORMAL),
nDestinationState(DESTINATION_NORMAL), nDestinationState(DESTINATION_NORMAL),
nFieldStatus(FIELD_NONE), nFieldStatus(FIELD_NONE),
nBorderState(BORDER_NONE), nBorderState(BORDER_NONE),
......
...@@ -16,11 +16,11 @@ namespace writerfilter ...@@ -16,11 +16,11 @@ namespace writerfilter
{ {
namespace rtftok namespace rtftok
{ {
enum RTFInternalState enum class RTFInternalState
{ {
INTERNAL_NORMAL, NORMAL,
INTERNAL_BIN, BIN,
INTERNAL_HEX HEX
}; };
enum class RTFError enum class RTFError
......
...@@ -93,7 +93,7 @@ void RTFLookahead::setDestinationState(RTFDestinationState /*nDestinationState*/ ...@@ -93,7 +93,7 @@ void RTFLookahead::setDestinationState(RTFDestinationState /*nDestinationState*/
RTFInternalState RTFLookahead::getInternalState() RTFInternalState RTFLookahead::getInternalState()
{ {
return INTERNAL_NORMAL; return RTFInternalState::NORMAL;
} }
void RTFLookahead::setInternalState(RTFInternalState /*nInternalState*/) void RTFLookahead::setInternalState(RTFInternalState /*nInternalState*/)
......
...@@ -88,7 +88,7 @@ RTFError RTFTokenizer::resolveParse() ...@@ -88,7 +88,7 @@ RTFError RTFTokenizer::resolveParse()
if (m_nGroup < 0) if (m_nGroup < 0)
return RTFError::GROUP_UNDER; return RTFError::GROUP_UNDER;
if (m_nGroup > 0 && m_rImport.getInternalState() == INTERNAL_BIN) if (m_nGroup > 0 && m_rImport.getInternalState() == RTFInternalState::BIN)
{ {
ret = m_rImport.resolveChars(ch); ret = m_rImport.resolveChars(ch);
if (ret != RTFError::OK) if (ret != RTFError::OK)
...@@ -129,7 +129,7 @@ RTFError RTFTokenizer::resolveParse() ...@@ -129,7 +129,7 @@ RTFError RTFTokenizer::resolveParse()
default: default:
if (m_nGroup == 0) if (m_nGroup == 0)
return RTFError::CHAR_OVER; return RTFError::CHAR_OVER;
if (m_rImport.getInternalState() == INTERNAL_NORMAL) if (m_rImport.getInternalState() == RTFInternalState::NORMAL)
{ {
ret = m_rImport.resolveChars(ch); ret = m_rImport.resolveChars(ch);
if (ret != RTFError::OK) if (ret != RTFError::OK)
...@@ -151,7 +151,7 @@ RTFError RTFTokenizer::resolveParse() ...@@ -151,7 +151,7 @@ RTFError RTFTokenizer::resolveParse()
return ret; return ret;
count = 2; count = 2;
b = 0; b = 0;
m_rImport.setInternalState(INTERNAL_NORMAL); m_rImport.setInternalState(RTFInternalState::NORMAL);
} }
} }
break; break;
......
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