From 0eb0c7308ad57f4a20b5691d450b5185e52475f6 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 13 Jul 2017 09:08:56 +0300 Subject: A temporary workaround for out-of-order (in-paragraph) tbl on OOXML This allows for import the data in such tables (previously, this text was simply dropped, causing dataloss). Layout problems are not fixed yet. Change-Id: Id7422adfe0998d1e2adcd4bf0b0e0a1dd7ed37bf Reviewed-on: https://gerrit.libreoffice.org/40105 Reviewed-by: Aron Budea Tested-by: Aron Budea --- .../source/ooxml/OOXMLFastContextHandler.cxx | 8 ++++++++ .../source/ooxml/OOXMLFastContextHandler.hxx | 4 ++++ writerfilter/source/ooxml/factoryimpl_ns.py | 3 +++ writerfilter/source/ooxml/model.xml | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index bb59ed9bebdc..29843a64a7af 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -1614,6 +1614,14 @@ void OOXMLFastContextHandlerTextTable::lcl_endFastElement mpParserState->endTable(); } +void OOXMLFastContextHandlerTextTable::start_P_Tbl() +{ +} + +void OOXMLFastContextHandlerTextTable::end_P_Tbl() +{ +} + /* class OOXMLFastContextHandlerShape */ diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index eaf40e27f47b..8a9c10c74ca0 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -433,6 +433,10 @@ public: virtual std::string getType() const override { return "TextTable"; } + // when appears as direct child of , we need to rearrange this paragraph + // to merge with the table's first paragraph (that's what Word does in this case) + void start_P_Tbl(); + void end_P_Tbl(); protected: virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) override; diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py index 74ee6e8e3d25..b37a468b5330 100644 --- a/writerfilter/source/ooxml/factoryimpl_ns.py +++ b/writerfilter/source/ooxml/factoryimpl_ns.py @@ -442,6 +442,9 @@ def factoryChooseAction(actionNode): elif actionNode.getAttribute("action") == "handleGridBefore" or actionNode.getAttribute("action") == "handleGridAfter": ret.append(" %sif (OOXMLFastContextHandlerTextTableRow* pTextTableRow = dynamic_cast(pHandler))" % extra_space) ret.append(" %s pTextTableRow->%s();" % (extra_space, actionNode.getAttribute("action"))) + elif actionNode.getAttribute("action") in ("start_P_Tbl", "end_P_Tbl"): + ret.append(" %sif (OOXMLFastContextHandlerTextTable* pTextTable = dynamic_cast(pHandler))" % extra_space) + ret.append(" %s pTextTable->%s();" % (extra_space, actionNode.getAttribute("action"))) elif actionNode.getAttribute("action") in ("sendProperty", "handleHyperlink"): ret.append(" %sif (OOXMLFastContextHandlerStream* pStream = dynamic_cast(pHandler))" % extra_space) ret.append(" %s pStream->%s();" % (extra_space, actionNode.getAttribute("action"))) diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 56aff376c8f9..a5c9a8afabc9 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -14183,6 +14183,10 @@ + + + + @@ -14696,6 +14700,17 @@ + + + + + + + + + + + @@ -18426,6 +18441,11 @@ + + + + + -- cgit