summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-16 17:25:31 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-04-03 19:21:20 +0200
commite677f2724c9a6838f90542881457029eaffc11cd (patch)
tree7a25304c78caa28bfcb6f409207b100dbe2c42f3
parent36b257b17c3a6d6b79f3b0488808398e1b034551 (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, ..."/> (cherry picked from commit 496197fe4dff2cd94ceeb42fc04d0263ac8d8971) Conflicts: writerfilter/source/rtftok/rtfdispatchflag.cxx writerfilter/source/rtftok/rtfdispatchvalue.cxx Change-Id: I767e4b92fc41f9425f446d6eaad1d875e2233964 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91634 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx43
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx21
-rw-r--r--writerfilter/source/ooxml/model.xml10
-rw-r--r--writerfilter/source/rtftok/rtfdispatchflag.cxx23
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx11
5 files changed, 88 insertions, 20 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 9e3080927a96..6c7af1c34b04 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1159,6 +1159,37 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
m_pImpl->startOrEndPermissionRange(nIntValue);
break;
}
+ case NS_ooxml::LN_CT_NumFmt_val:
+ {
+ try
+ {
+ uno::Reference<beans::XPropertySet> xFtnEdnSettings;
+ if (m_pImpl->IsInFootnoteProperties())
+ {
+ uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(
+ m_pImpl->GetTextDocument(), uno::UNO_QUERY);
+ if (xFootnotesSupplier.is())
+ xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings();
+ }
+ else
+ {
+ uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(
+ m_pImpl->GetTextDocument(), uno::UNO_QUERY);
+ if (xEndnotesSupplier.is())
+ xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings();
+ }
+ if (xFtnEdnSettings.is())
+ {
+ sal_Int16 nNumType = ConversionHelper::ConvertNumberingType(nIntValue);
+ xFtnEdnSettings->setPropertyValue(getPropertyName(PROP_NUMBERING_TYPE),
+ uno::makeAny(nNumType));
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ break;
default:
SAL_WARN("writerfilter", "DomainMapper::lcl_attribute: unhandled token: " << nName);
}
@@ -2221,11 +2252,19 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
//endnotes in word can be at section end or document end - writer supports only the latter
// -> so this property can be ignored
break;
- case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
- case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
case NS_ooxml::LN_CT_FtnProps_numFmt:
case NS_ooxml::LN_CT_EdnProps_numFmt:
{
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if (pProperties.get())
+ {
+ pProperties->resolve(*this);
+ }
+ }
+ break;
+ case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
+ case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
+ {
try
{
uno::Reference< beans::XPropertySet > xFtnEdnSettings;
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 2d5605a271dc..efbbf4efaea2 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -100,7 +100,7 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue )
case NS_ooxml::LN_CT_Lvl_start:
m_nIStartAt = nValue;
break;
- case NS_ooxml::LN_CT_Lvl_numFmt:
+ case NS_ooxml::LN_CT_NumFmt_val:
m_nNFC = nValue;
break;
case NS_ooxml::LN_CT_Lvl_isLgl:
@@ -719,6 +719,8 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal )
break;
case NS_ooxml::LN_CT_Lvl_start:
case NS_ooxml::LN_CT_Lvl_numFmt:
+ case NS_ooxml::LN_CT_NumFmt_format:
+ case NS_ooxml::LN_CT_NumFmt_val:
case NS_ooxml::LN_CT_Lvl_isLgl:
case NS_ooxml::LN_CT_Lvl_legacy:
if ( pCurrentLvl.get( ) )
@@ -941,18 +943,29 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
bIsStartVisited = true;
break;
case NS_ooxml::LN_CT_Lvl_numFmt:
- case NS_ooxml::LN_CT_Lvl_isLgl:
- case NS_ooxml::LN_CT_Lvl_legacy:
+ {
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if (pProperties.get())
+ {
+ pProperties->resolve(*this);
+ }
if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{
- pCurrentLevel->SetValue( nSprmId, nIntValue );
if( !bIsStartVisited )
{
pCurrentLevel->SetValue( NS_ooxml::LN_CT_Lvl_start, 0 );
bIsStartVisited = true;
}
}
+ }
break;
+ case NS_ooxml::LN_CT_Lvl_isLgl:
+ case NS_ooxml::LN_CT_Lvl_legacy:
+ if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
+ {
+ pCurrentLevel->SetValue(nSprmId, nIntValue);
+ }
+ break;
case NS_ooxml::LN_CT_Lvl_suff:
{
if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index a838c8bfde2c..cdc0f040fb34 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -12879,6 +12879,7 @@
<value>thaiNumbers</value>
<!-- Thai Counting System -->
<value>thaiCounting</value>
+ <value>custom</value>
</choice>
</define>
<define name="ST_PageOrientation">
@@ -14794,6 +14795,9 @@
</attribute>
</define>
<define name="CT_NumFmt">
+ <attribute name="format">
+ <data type="string"/>
+ </attribute>
<attribute name="val">
<ref name="ST_NumberFormat"/>
</attribute>
@@ -17750,6 +17754,7 @@
<value tokenid="ooxml:Value_ST_NumberFormat_thaiLetters">thaiLetters</value>
<value tokenid="ooxml:Value_ST_NumberFormat_thaiNumbers">thaiNumbers</value>
<value tokenid="ooxml:Value_ST_NumberFormat_thaiCounting">thaiCounting</value>
+ <value tokenid="ooxml:Value_ST_NumberFormat_custom">custom</value>
</resource>
<resource name="ST_PageOrientation" resource="List">
<value tokenid="ooxml:Value_ST_PageOrientation_portrait">portrait</value>
@@ -18521,8 +18526,9 @@
<resource name="CT_EdnPos" resource="Value">
<attribute name="val" tokenid="ooxml:CT_EdnPos_val" action="setValue"/>
</resource>
- <resource name="CT_NumFmt" resource="Value">
- <attribute name="val" tokenid="ooxml:CT_NumFmt_val" action="setValue"/>
+ <resource name="CT_NumFmt" resource="Properties">
+ <attribute name="format" tokenid="ooxml:CT_NumFmt_format"/>
+ <attribute name="val" tokenid="ooxml:CT_NumFmt_val"/>
</resource>
<resource name="ST_RestartNumber" resource="List">
<value tokenid="ooxml:Value_ST_RestartNumber_continuous">continuous</value>
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index b68262ff265e..a9c5e391f929 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -298,9 +298,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.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_footnotePr,
- NS_ooxml::LN_CT_FtnProps_numFmt, pValue);
+ NS_ooxml::LN_CT_FtnProps_numFmt, pOuter);
return RTFError::OK;
}
@@ -353,9 +356,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.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr,
- NS_ooxml::LN_CT_EdnProps_numFmt, pValue);
+ NS_ooxml::LN_CT_EdnProps_numFmt, pOuter);
return RTFError::OK;
}
@@ -1061,15 +1067,16 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_PNDEC:
{
auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
- m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_numFmt, pValue);
+ putNestedAttribute(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_Lvl_numFmt,
+ NS_ooxml::LN_CT_NumFmt_val, pValue);
}
break;
case RTF_PNLVLBLT:
{
m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_AbstractNum_nsid, new RTFValue(1));
- m_aStates.top().aTableSprms.set(
- NS_ooxml::LN_CT_Lvl_numFmt,
- new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
+ putNestedAttribute(m_aStates.top().aTableSprms, 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 72fd4802a601..24292838bd9b 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -137,10 +137,6 @@ RTFError RTFDocumentImpl::dispatchValue(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;
@@ -159,6 +155,13 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
m_aStates.top().aTableSprms.set(nSprm, pIntValue);
return RTFError::OK;
}
+ if (nKeyword == RTF_LEVELNFC)
+ {
+ pIntValue = new RTFValue(getNumberFormat(nParam));
+ putNestedAttribute(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_Lvl_numFmt,
+ NS_ooxml::LN_CT_NumFmt_val, pIntValue);
+ return RTFError::OK;
+ }
// Trivial character sprms.
switch (nKeyword)
{