[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 3 17:21:53 UTC 2020


 writerfilter/source/dmapper/DomainMapper.cxx          |   43 +++++++++++++++++-
 writerfilter/source/dmapper/NumberingManager.cxx      |   21 +++++++-
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    1 
 writerfilter/source/ooxml/model.xml                   |   10 +++-
 writerfilter/source/rtftok/rtfdispatchflag.cxx        |   23 ++++++---
 writerfilter/source/rtftok/rtfdispatchvalue.cxx       |   11 ++--
 6 files changed, 89 insertions(+), 20 deletions(-)

New commits:
commit 1b03ca23961c5661adfbcae5fe705001d649ea30
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 16 13:45:20 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Apr 3 19:21:35 2020 +0200

    DOCX import: declare w14 as a supported feature
    
    This is needed (but not enough) to support markup like this:
    
          <mc:AlternateContent>
            <mc:Choice Requires="w14">
              <w:numFmt w:val="custom" w:format="001, 002, 003, ..."/>
            </mc:Choice>
            <mc:Fallback>
              <w:numFmt w:val="decimal"/>
            </mc:Fallback>
          </mc:AlternateContent>
    
    Change-Id: I598b0452b5d29624ed0a6795682c29a09fd0dcfe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90564
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit b0887393ceb0bf283841fe212baf5be3571782b9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91635
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index be825d2f01d3..906320088987 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -116,6 +116,7 @@ bool OOXMLFastContextHandler::prepareMceContext(Token_t nElement, const uno::Ref
             static const char* aFeatures[] = {
                 "wps",
                 "wpg",
+                "w14",
             };
             for (const char *p : aFeatures)
             {
commit e677f2724c9a6838f90542881457029eaffc11cd
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 16 17:25:31 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Apr 3 19:21:20 2020 +0200

    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 at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

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,10 +2252,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 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)
     {


More information about the Libreoffice-commits mailing list