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 37a8142720b82d7ce6db0c09593de5cab11c51fd
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Oct 21 18:34:21 2020 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Oct 22 09:07:14 2020 +0200

    writerfilter: add OOXML tokenizer for <w:altChunk r:id="..."/>
    
    This is just the tokenizer, the domain mapper part still has to be done.
    
    Change-Id: Iba171edeac42f1fa62b49dd0d188d41a539bb0c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104640
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/writerfilter/source/ooxml/Handler.cxx 
b/writerfilter/source/ooxml/Handler.cxx
index 92c74e78e63a..3b49b5218148 100644
--- a/writerfilter/source/ooxml/Handler.cxx
+++ b/writerfilter/source/ooxml/Handler.cxx
@@ -398,6 +398,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 5e18db73a494..111b92aae5e3 100644
--- a/writerfilter/source/ooxml/Handler.hxx
+++ b/writerfilter/source/ooxml/Handler.hxx
@@ -155,6 +155,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 104d3ad6a660..3b62c912967e 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1120,6 +1120,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 1dd93f82de5c..ac8346d3dad2 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -295,6 +295,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 52ccf36fdc17..73d2022902d6 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -428,7 +428,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 4f0ba4a7c432..3f45394d5d88 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -18116,6 +18116,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>
@@ -19035,6 +19039,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"/>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to