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 ad89e8557e81db6e9eff29cb7a446e734733b268 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Oct 21 18:34:21 2020 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 27 16:34:28 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/+/104884 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/source/ooxml/Handler.cxx b/writerfilter/source/ooxml/Handler.cxx index 290a4b749758..66c50581f31f 100644 --- a/writerfilter/source/ooxml/Handler.cxx +++ b/writerfilter/source/ooxml/Handler.cxx @@ -405,6 +405,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 5de41e351981..8746aa23ed47 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 cd0e19c7c1dd..c991f515e392 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 097214b8e049..0ae27191f590 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 2d4516fd732b..bed08faa5ccb 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"/> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits