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

writerfilter: make RTFParserState members private, part 6

Change-Id: I4a2c89afc38f9df8a956a2fb38a1dc1ea73aea18
Reviewed-on: https://gerrit.libreoffice.org/72559
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 558c6c11
......@@ -184,7 +184,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_NESTTABLEPROPS:
// do not set any properties of outer table at nested table!
m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
m_aStates.top().getTableCellAttributes() = m_aDefaultState.getTableCellAttributes();
m_aNestedTableCellsSprms.clear();
m_aNestedTableCellsAttributes.clear();
m_nNestedCells = 0;
......
......@@ -133,7 +133,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
if (nParam >= 0)
{
auto pValue = new RTFValue(nParam);
m_aStates.top().aTabAttributes.set(NS_ooxml::LN_CT_TabStop_val, pValue);
m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_val, pValue);
return RTFError::OK;
}
......@@ -164,7 +164,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
if (nParam >= 0)
{
auto pValue = new RTFValue(nParam);
m_aStates.top().aTabAttributes.set(NS_ooxml::LN_CT_TabStop_leader, pValue);
m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_leader, pValue);
return RTFError::OK;
}
......@@ -451,24 +451,24 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
// TODO ooxml:CT_Font_family seems to be ignored by the domain mapper
break;
case RTF_ANSI:
m_aStates.top().nCurrentEncoding = RTL_TEXTENCODING_MS_1252;
m_aStates.top().setCurrentEncoding(RTL_TEXTENCODING_MS_1252);
break;
case RTF_MAC:
m_aDefaultState.nCurrentEncoding = RTL_TEXTENCODING_APPLE_ROMAN;
m_aStates.top().nCurrentEncoding = m_aDefaultState.nCurrentEncoding;
m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_APPLE_ROMAN);
m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
break;
case RTF_PC:
m_aDefaultState.nCurrentEncoding = RTL_TEXTENCODING_IBM_437;
m_aStates.top().nCurrentEncoding = m_aDefaultState.nCurrentEncoding;
m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_IBM_437);
m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
break;
case RTF_PCA:
m_aDefaultState.nCurrentEncoding = RTL_TEXTENCODING_IBM_850;
m_aStates.top().nCurrentEncoding = m_aDefaultState.nCurrentEncoding;
m_aDefaultState.setCurrentEncoding(RTL_TEXTENCODING_IBM_850);
m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
break;
case RTF_PLAIN:
{
m_aStates.top().aCharacterSprms = getDefaultState().aCharacterSprms;
m_aStates.top().nCurrentEncoding = getEncoding(getFontIndex(m_nDefaultFontIndex));
m_aStates.top().setCurrentEncoding(getEncoding(getFontIndex(m_nDefaultFontIndex)));
m_aStates.top().aCharacterAttributes = getDefaultState().aCharacterAttributes;
m_aStates.top().setCurrentCharacterStyleIndex(-1);
m_aStates.top().setIsRightToLeft(false);
......@@ -583,8 +583,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
break;
case RTF_RTLCH:
m_aStates.top().setIsRightToLeft(true);
if (m_aDefaultState.nCurrentEncoding == RTL_TEXTENCODING_MS_1255)
m_aStates.top().nCurrentEncoding = m_aDefaultState.nCurrentEncoding;
if (m_aDefaultState.getCurrentEncoding() == RTL_TEXTENCODING_MS_1255)
m_aStates.top().setCurrentEncoding(m_aDefaultState.getCurrentEncoding());
break;
case RTF_ULNONE:
{
......
......@@ -305,7 +305,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
// The scope of the table cell defaults is one row.
m_aDefaultState.aTableCellSprms.clear();
m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
m_aStates.top().getTableCellAttributes() = m_aDefaultState.getTableCellAttributes();
writerfilter::Reference<Properties>::Pointer_t paraProperties;
writerfilter::Reference<Properties>::Pointer_t frameProperties;
......
......@@ -373,17 +373,17 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
putNestedAttribute(m_aStates.top().aCharacterSprms, NS_ooxml::LN_EG_RPrBase_rFonts,
nSprm, pValue);
if (nKeyword == RTF_F)
m_aStates.top().nCurrentEncoding = getEncoding(m_nCurrentFontIndex);
m_aStates.top().setCurrentEncoding(getEncoding(m_nCurrentFontIndex));
}
break;
case RTF_RED:
m_aStates.top().aCurrentColor.SetRed(nParam);
m_aStates.top().getCurrentColor().SetRed(nParam);
break;
case RTF_GREEN:
m_aStates.top().aCurrentColor.SetGreen(nParam);
m_aStates.top().getCurrentColor().SetGreen(nParam);
break;
case RTF_BLUE:
m_aStates.top().aCurrentColor.SetBlue(nParam);
m_aStates.top().getCurrentColor().SetBlue(nParam);
break;
case RTF_FCHARSET:
{
......@@ -403,7 +403,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
= aRTFEncodings[i].codepage == 0 // Default (CP_ACP)
? osl_getThreadTextEncoding()
: rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings[i].codepage);
m_aStates.top().nCurrentEncoding = m_nCurrentEncoding;
m_aStates.top().setCurrentEncoding(m_nCurrentEncoding);
}
break;
case RTF_ANSICPG:
......@@ -414,10 +414,10 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
? utl_getWinTextEncodingFromLangStr(getLODefaultLanguage().toUtf8().getStr())
: rtl_getTextEncodingFromWindowsCodePage(nParam);
if (nKeyword == RTF_ANSICPG)
m_aDefaultState.nCurrentEncoding = nEncoding;
m_aDefaultState.setCurrentEncoding(nEncoding);
else
m_nCurrentEncoding = nEncoding;
m_aStates.top().nCurrentEncoding = nEncoding;
m_aStates.top().setCurrentEncoding(nEncoding);
}
break;
case RTF_CF:
......@@ -642,15 +642,15 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
break;
case RTF_TX:
{
m_aStates.top().aTabAttributes.set(NS_ooxml::LN_CT_TabStop_pos, pIntValue);
auto pValue = new RTFValue(m_aStates.top().aTabAttributes);
m_aStates.top().getTabAttributes().set(NS_ooxml::LN_CT_TabStop_pos, pIntValue);
auto pValue = new RTFValue(m_aStates.top().getTabAttributes());
if (m_aStates.top().eDestination == Destination::LISTLEVEL)
putNestedSprm(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_PPrBase_tabs,
NS_ooxml::LN_CT_Tabs_tab, pValue);
else
putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_tabs,
NS_ooxml::LN_CT_Tabs_tab, pValue);
m_aStates.top().aTabAttributes.clear();
m_aStates.top().getTabAttributes().clear();
}
break;
case RTF_ILVL:
......@@ -690,7 +690,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
break;
case RTF_UC:
if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_INT16))
m_aStates.top().nUc = nParam;
m_aStates.top().setUc(nParam);
break;
case RTF_U:
// sal_Unicode is unsigned 16-bit, RTF may represent that as a
......@@ -701,14 +701,14 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
if (m_aStates.top().eDestination == Destination::LEVELNUMBERS)
{
if (nParam != ';')
m_aStates.top().aLevelNumbers.push_back(sal_Int32(nParam));
m_aStates.top().getLevelNumbers().push_back(sal_Int32(nParam));
else
// ';' in \u form is not considered valid.
m_aStates.top().bLevelNumbersValid = false;
m_aStates.top().setLevelNumbersValid(false);
}
else
m_aUnicodeBuffer.append(static_cast<sal_Unicode>(nParam));
m_aStates.top().nCharsToSkip = m_aStates.top().nUc;
m_aStates.top().getCharsToSkip() = m_aStates.top().getUc();
}
break;
case RTF_LEVELFOLLOW:
......@@ -874,18 +874,18 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
m_nNestedCells++;
// Push cell properties.
m_aNestedTableCellsSprms.push_back(m_aStates.top().aTableCellSprms);
m_aNestedTableCellsAttributes.push_back(m_aStates.top().aTableCellAttributes);
m_aNestedTableCellsAttributes.push_back(m_aStates.top().getTableCellAttributes());
}
else
{
m_nTopLevelCells++;
// Push cell properties.
m_aTopLevelTableCellsSprms.push_back(m_aStates.top().aTableCellSprms);
m_aTopLevelTableCellsAttributes.push_back(m_aStates.top().aTableCellAttributes);
m_aTopLevelTableCellsAttributes.push_back(m_aStates.top().getTableCellAttributes());
}
m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
m_aStates.top().getTableCellAttributes() = m_aDefaultState.getTableCellAttributes();
// We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
dispatchFlag(RTF_INTBL);
if (!m_nCellxMax)
......@@ -1053,7 +1053,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_REVDTTMDEL:
{
OUString aStr(
OStringToOUString(DTTM22OString(nParam), m_aStates.top().nCurrentEncoding));
OStringToOUString(DTTM22OString(nParam), m_aStates.top().getCurrentEncoding()));
auto pValue = new RTFValue(aStr);
putNestedAttribute(m_aStates.top().aCharacterSprms, NS_ooxml::LN_trackchange,
NS_ooxml::LN_CT_TrackChange_date, pValue);
......@@ -1235,7 +1235,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_BIN:
{
m_aStates.top().nInternalState = RTFInternalState::BIN;
m_aStates.top().nBinaryToRead = nParam;
m_aStates.top().setBinaryToRead(nParam);
}
break;
case RTF_DPLINECOR:
......@@ -1486,7 +1486,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
{
if (m_aStates.top().eDestination == Destination::LISTLEVEL)
{
if (m_aStates.top().bLevelNumbersValid)
if (m_aStates.top().getLevelNumbersValid())
putNestedAttribute(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_PPrBase_ind,
NS_ooxml::LN_CT_Ind_firstLine, pIntValue);
else
......@@ -1501,7 +1501,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
{
if (m_aStates.top().eDestination == Destination::LISTLEVEL)
{
if (m_aStates.top().bLevelNumbersValid)
if (m_aStates.top().getLevelNumbersValid())
putNestedAttribute(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_PPrBase_ind,
NS_ooxml::LN_CT_Ind_left, pIntValue);
}
......
......@@ -483,6 +483,27 @@ public:
RTFDrawingObject& getDrawingObject() { return m_aDrawingObject; }
RTFShape& getShape() { return m_aShape; }
RTFPicture& getPicture() { return m_aPicture; }
void setLevelNumbersValid(bool bLevelNumbersValid)
{
m_bLevelNumbersValid = bLevelNumbersValid;
}
bool getLevelNumbersValid() const { return m_bLevelNumbersValid; }
std::vector<sal_Int32>& getLevelNumbers() { return m_aLevelNumbers; }
RTFSprms& getListLevelEntries() { return m_aListLevelEntries; }
int& getListLevelNum() { return m_nListLevelNum; }
void setBinaryToRead(int nBinaryToRead) { m_nBinaryToRead = nBinaryToRead; }
int getBinaryToRead() const { return m_nBinaryToRead; }
int& getCharsToSkip() { return m_nCharsToSkip; }
void setUc(int nUc) { m_nUc = nUc; }
int getUc() const { return m_nUc; }
void setCurrentEncoding(rtl_TextEncoding nCurrentEncoding)
{
m_nCurrentEncoding = nCurrentEncoding;
}
rtl_TextEncoding getCurrentEncoding() const { return m_nCurrentEncoding; }
RTFColorTableEntry& getCurrentColor() { return m_aCurrentColor; }
RTFSprms& getTabAttributes() { return m_aTabAttributes; }
RTFSprms& getTableCellAttributes() { return m_aTableCellAttributes; }
RTFDocumentImpl* m_pDocumentImpl;
RTFInternalState nInternalState;
......@@ -506,32 +527,32 @@ public:
RTFSprms aTableRowAttributes;
// reset by cellx
RTFSprms aTableCellSprms;
RTFSprms aTableCellAttributes;
private:
RTFSprms m_aTableCellAttributes;
// reset by tx
RTFSprms aTabAttributes;
RTFSprms m_aTabAttributes;
RTFColorTableEntry aCurrentColor;
RTFColorTableEntry m_aCurrentColor;
rtl_TextEncoding nCurrentEncoding;
rtl_TextEncoding m_nCurrentEncoding;
/// Current \uc value.
int nUc;
int m_nUc;
/// Characters to skip, set to nUc by \u.
int nCharsToSkip;
int m_nCharsToSkip;
/// Characters to read, once in binary mode.
int nBinaryToRead;
int m_nBinaryToRead;
/// Next list level index to use when parsing list table.
int nListLevelNum;
int m_nListLevelNum;
/// List level entries, which will form a list entry later.
RTFSprms aListLevelEntries;
RTFSprms m_aListLevelEntries;
/// List of character positions in leveltext to replace.
std::vector<sal_Int32> aLevelNumbers;
std::vector<sal_Int32> m_aLevelNumbers;
/// If aLevelNumbers should be read at all.
bool bLevelNumbersValid;
bool m_bLevelNumbersValid;
private:
RTFPicture m_aPicture;
RTFShape m_aShape;
RTFDrawingObject m_aDrawingObject;
......
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