[Libreoffice-commits] core.git: writerfilter/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 16 17:08:31 UTC 2020
writerfilter/source/dmapper/DomainMapper.cxx | 43 +++++++++++++++++++++--
writerfilter/source/dmapper/NumberingManager.cxx | 21 +++++++++--
writerfilter/source/ooxml/model.xml | 10 ++++-
writerfilter/source/rtftok/rtfdispatchflag.cxx | 23 ++++++++----
writerfilter/source/rtftok/rtfdispatchvalue.cxx | 11 +++--
5 files changed, 88 insertions(+), 20 deletions(-)
New commits:
commit 496197fe4dff2cd94ceeb42fc04d0263ac8d8971
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 16 17:25:31 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Mar 16 18:07:54 2020 +0100
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 at collabora.com>
Tested-by: Jenkins
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index cd21f22d6acd..d84c94b2fbfe 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1179,6 +1179,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);
}
@@ -2279,10 +2310,18 @@ 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
{
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 7084547c4d1a..9c337708d255 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:
@@ -738,6 +738,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( ) )
@@ -960,18 +962,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 9c0610715218..b3899472d5e3 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -12886,6 +12886,7 @@
<value>thaiNumbers</value>
<!-- Thai Counting System -->
<value>thaiCounting</value>
+ <value>custom</value>
</choice>
</define>
<define name="ST_PageOrientation">
@@ -14801,6 +14802,9 @@
</attribute>
</define>
<define name="CT_NumFmt">
+ <attribute name="format">
+ <data type="string"/>
+ </attribute>
<attribute name="val">
<ref name="ST_NumberFormat"/>
</attribute>
@@ -17756,6 +17760,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>
@@ -18529,8 +18534,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 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;
}
More information about the Libreoffice-commits
mailing list