summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-16 17:25:31 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-03-16 18:07:54 +0100
commit496197fe4dff2cd94ceeb42fc04d0263ac8d8971 (patch)
treeb9fa3ef13de8e6f1ebecd07b4c62d83ae8b653cd /writerfilter/source/rtftok
parent3741d70743c297029f54b20b0ca711f40cff7097 (diff)
DOCX import: tokenize <w:numFmt w:val="custom" w:format="...">
Which means CT_NumFmt has to be a property resource, not a single value, and also ST_NumberFormat needs to recognize "custom" as a valid value. Adapt the RTF tokenizer to emit the new token format. This is needed (but not enough) to support markup like this: <w:numFmt w:val="custom" w:format="001, 002, 003, ..."/> Change-Id: I767e4b92fc41f9425f446d6eaad1d875e2233964 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90578 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'writerfilter/source/rtftok')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchflag.cxx23
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx11
2 files changed, 22 insertions, 12 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 58d4eecf5c26..7265d7c424a9 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -292,10 +292,13 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
}
if (nParam >= 0)
{
- auto pValue = new RTFValue(nParam);
+ auto pInner = new RTFValue(nParam);
+ RTFSprms aAttributes;
+ aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
+ auto pOuter = new RTFValue(aAttributes);
putNestedSprm(m_aDefaultState.getParagraphSprms(),
NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_CT_FtnProps_numFmt,
- pValue);
+ pOuter);
return RTFError::OK;
}
@@ -349,9 +352,12 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
}
if (nParam >= 0)
{
- auto pValue = new RTFValue(nParam);
+ auto pInner = new RTFValue(nParam);
+ RTFSprms aAttributes;
+ aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
+ auto pOuter = new RTFValue(aAttributes);
putNestedSprm(m_aDefaultState.getParagraphSprms(), NS_ooxml::LN_EG_SectPrContents_endnotePr,
- NS_ooxml::LN_CT_EdnProps_numFmt, pValue);
+ NS_ooxml::LN_CT_EdnProps_numFmt, pOuter);
return RTFError::OK;
}
@@ -1085,16 +1091,17 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_PNDEC:
{
auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
- m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_numFmt, pValue);
+ putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
+ NS_ooxml::LN_CT_NumFmt_val, pValue);
}
break;
case RTF_PNLVLBLT:
{
m_aStates.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid,
new RTFValue(1));
- m_aStates.top().getTableSprms().set(
- NS_ooxml::LN_CT_Lvl_numFmt,
- new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
+ putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
+ NS_ooxml::LN_CT_NumFmt_val,
+ new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
}
break;
case RTF_LANDSCAPE:
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index cc880a195e20..990bfad976ae 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -133,10 +133,6 @@ bool RTFDocumentImpl::dispatchTableSprmValue(RTFKeyword nKeyword, int nParam)
pIntValue = new RTFValue(nValue);
break;
}
- case RTF_LEVELNFC:
- nSprm = NS_ooxml::LN_CT_Lvl_numFmt;
- pIntValue = new RTFValue(getNumberFormat(nParam));
- break;
case RTF_LEVELSTARTAT:
nSprm = NS_ooxml::LN_CT_Lvl_start;
break;
@@ -155,6 +151,13 @@ bool RTFDocumentImpl::dispatchTableSprmValue(RTFKeyword nKeyword, int nParam)
m_aStates.top().getTableSprms().set(nSprm, pIntValue);
return true;
}
+ if (nKeyword == RTF_LEVELNFC)
+ {
+ pIntValue = new RTFValue(getNumberFormat(nParam));
+ putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
+ NS_ooxml::LN_CT_NumFmt_val, pIntValue);
+ return true;
+ }
return false;
}