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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 27 13:07:31 UTC 2020


 writerfilter/source/ooxml/Handler.cxx                 |   25 ++++++++++++++++++
 writerfilter/source/ooxml/Handler.hxx                 |   13 +++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    6 ++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    1 
 writerfilter/source/ooxml/factoryimpl_ns.py           |    2 -
 writerfilter/source/ooxml/model.xml                   |    7 +++++
 6 files changed, 53 insertions(+), 1 deletion(-)

New commits:
commit 48b3970d78fb8139ed4331477b0e06cdeec6f94e
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Oct 21 18:34:21 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Oct 27 14:06:56 2020 +0100

    writerfilter: add OOXML tokenizer for <w:altChunk r:id="..."/>
    
    This is just the tokenizer, the domain mapper part still has to be done.
    
    (cherry picked from commit 37a8142720b82d7ce6db0c09593de5cab11c51fd)
    
    Conflicts:
            writerfilter/source/ooxml/Handler.cxx
    
    Change-Id: Iba171edeac42f1fa62b49dd0d188d41a539bb0c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104868
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/writerfilter/source/ooxml/Handler.cxx b/writerfilter/source/ooxml/Handler.cxx
index 459e0adc480a..26b3caa57f56 100644
--- a/writerfilter/source/ooxml/Handler.cxx
+++ b/writerfilter/source/ooxml/Handler.cxx
@@ -399,6 +399,31 @@ void OOXMLHyperlinkURLHandler::sprm(Sprm & /*rSprm*/)
 {
 }
 
+OOXMLAltChunkHandler::OOXMLAltChunkHandler(OOXMLFastContextHandler* pContext)
+    : mpFastContext(pContext)
+{
+}
+
+OOXMLAltChunkHandler::~OOXMLAltChunkHandler()
+{
+    mpFastContext->clearProps();
+    mpFastContext->newProperty(NS_ooxml::LN_CT_AltChunk,
+                               OOXMLValue::Pointer_t(new OOXMLStringValue(m_aStreamName)));
+}
+
+void OOXMLAltChunkHandler::attribute(Id nName, Value& rValue)
+{
+    switch (nName)
+    {
+        case NS_ooxml::LN_CT_AltChunk:
+            m_aStreamName = mpFastContext->getTargetForId(rValue.getString());
+            break;
+        default:
+            break;
+    }
+}
+
+void OOXMLAltChunkHandler::sprm(Sprm& /*rSprm*/) {}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/ooxml/Handler.hxx b/writerfilter/source/ooxml/Handler.hxx
index 47ae7d562a53..5c4623c93c7e 100644
--- a/writerfilter/source/ooxml/Handler.hxx
+++ b/writerfilter/source/ooxml/Handler.hxx
@@ -156,6 +156,19 @@ public:
     virtual void sprm(Sprm & sprm) override;
 };
 
+/// Looks up the stream name for a '<w:altChunk r:id="..."/>' reference.
+class OOXMLAltChunkHandler : public Properties
+{
+    OOXMLFastContextHandler * mpFastContext;
+    OUString m_aStreamName;
+
+public:
+    explicit OOXMLAltChunkHandler(OOXMLFastContextHandler * pContext);
+    virtual ~OOXMLAltChunkHandler() override;
+
+    virtual void attribute(Id name, Value & val) override;
+    virtual void sprm(Sprm & sprm) override;
+};
 
 }}
 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_HANDLER_HXX
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 7d3c081b2676..d64192c115e4 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1099,6 +1099,12 @@ void OOXMLFastContextHandlerProperties::handleHyperlinkURL() {
     getPropertySet()->resolve(aHyperlinkURLHandler);
 }
 
+void OOXMLFastContextHandlerProperties::handleAltChunk()
+{
+    OOXMLAltChunkHandler aHandler(this);
+    getPropertySet()->resolve(aHandler);
+}
+
 void OOXMLFastContextHandlerProperties::setPropertySet
 (const OOXMLPropertySet::Pointer_t& pPropertySet)
 {
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 0cc3fb1791a9..4f2a070c85de 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -285,6 +285,7 @@ public:
     void handleOLE();
     void handleFontRel();
     void handleHyperlinkURL();
+    void handleAltChunk();
 
     virtual void setPropertySet(const OOXMLPropertySet::Pointer_t& pPropertySet) override;
     virtual OOXMLPropertySet::Pointer_t getPropertySet() const override;
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index 41fa714678c7..4375a2513682 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -429,7 +429,7 @@ def factoryChooseAction(actionNode):
         ret.append("        {")
         extra_space = "        "
 
-    if actionNode.getAttribute("action") in ("handleXNotes", "handleHdrFtr", "handleComment", "handlePicture", "handleBreak", "handleOutOfOrderBreak", "handleOLE", "handleFontRel", "handleHyperlinkURL"):
+    if actionNode.getAttribute("action") in ("handleXNotes", "handleHdrFtr", "handleComment", "handlePicture", "handleBreak", "handleOutOfOrderBreak", "handleOLE", "handleFontRel", "handleHyperlinkURL", "handleAltChunk"):
         ret.append("    %sif (OOXMLFastContextHandlerProperties* pProperties = dynamic_cast<OOXMLFastContextHandlerProperties*>(pHandler))" % extra_space)
         ret.append("    %s    pProperties->%s();" % (extra_space, actionNode.getAttribute("action")))
     elif actionNode.getAttribute("action") == "propagateCharacterPropertiesAsSet":
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index eb84d6e6a4e8..4ac953bacb1d 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -18110,6 +18110,10 @@
       <action name="start" action="sendPropertiesWithId" sendtokenid="ooxml:paratrackchange"/>
       <action name="start" action="clearProps"/>
     </resource>
+    <resource name="CT_AltChunk" resource="Properties">
+      <attribute name="r:id" tokenid="ooxml:CT_AltChunk"/>
+      <action name="start" action="handleAltChunk"/>
+    </resource>
     <resource name="ST_RubyAlign" resource="List">
       <value tokenid="ooxml:Value_ST_RubyAlign_center">center</value>
       <value tokenid="ooxml:Value_ST_RubyAlign_distributeLetter">distributeLetter</value>
@@ -19029,6 +19033,9 @@
       <attribute name="name" tokenid="ooxml:CT_Font_name"/>
     </resource>
     <resource name="CT_FontsList" resource="Table" tokenid="ooxml:FONTTABLE"/>
+    <resource name="EG_BlockLevelElts" resource="Properties">
+      <attribute name="name" tokenid="ooxml:EG_BlockLevelElts_altChunk"/>
+    </resource>
     <resource name="EG_RunLevelElts" resource="Stream">
       <element name="proofErr" tokenid="ooxml:EG_RunLevelElts_proofErr"/>
       <element name="permStart" tokenid="ooxml:EG_RunLevelElts_permStart"/>


More information about the Libreoffice-commits mailing list