summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-07-13 09:08:56 +0300
committerAron Budea <aron.budea@collabora.com>2017-07-18 11:10:59 +0200
commit0eb0c7308ad57f4a20b5691d450b5185e52475f6 (patch)
tree259c1ed94db27486dee1f1c39115533957510971
parente780090d115e26076203a86d8d30cc34cf29a020 (diff)
A temporary workaround for out-of-order (in-paragraph) tbl on OOXMLcp-5.3-20
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 <aron.budea@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com>
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx8
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.hxx4
-rw-r--r--writerfilter/source/ooxml/factoryimpl_ns.py3
-rw-r--r--writerfilter/source/ooxml/model.xml20
4 files changed, 35 insertions, 0 deletions
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 <w:tbl> appears as direct child of <w:p>, 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<OOXMLFastContextHandlerTextTableRow*>(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<OOXMLFastContextHandlerTextTable*>(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<OOXMLFastContextHandlerStream*>(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 @@
<ref name="CT_Br_OutOfOrder"/>
</element>
<!-- end tdf#108714 -->
+ <!-- allow <w:tbl> at paragraph level (despite this is illegal according to ECMA-376-1:2016) - bug-to-bug compatibility with Word -->
+ <element name="tbl">
+ <ref name="CT_P_Tbl"/>
+ </element>
</define>
<define name="ST_TblWidth">
<choice>
@@ -14696,6 +14700,17 @@
</element>
<ref name="EG_ContentRowContent"/>
</define>
+ <!-- Special element - copy of usual CT_Tbl, but only used as direct child of CT_P -->
+ <define name="CT_P_Tbl">
+ <ref name="EG_RangeMarkupElements"/>
+ <element name="tblPr">
+ <ref name="CT_TblPr"/>
+ </element>
+ <element name="tblGrid">
+ <ref name="CT_TblGrid"/>
+ </element>
+ <ref name="EG_ContentRowContent"/>
+ </define>
<define name="CT_TblLook">
<attribute name="firstRow">
<ref name="ST_OnOff"/>
@@ -18426,6 +18441,11 @@
<element name="tblPrExChange" tokenid="ooxml:CT_TblPrEx_tblPrExChange"/>
</resource>
<resource name="CT_Tbl" resource="TextTable"/>
+ <!-- allow <w:tbl> at paragraph level (despite this is illegal according to ECMA-376-1:2016) - bug-to-bug compatibility with Word -->
+ <resource name="CT_P_Tbl" resource="TextTable">
+ <action name="start" action="start_P_Tbl"/>
+ <action name="end" action="end_P_Tbl"/>
+ </resource>
<resource name="CT_TblLook" resource="Properties">
<attribute name="firstRow" tokenid="ooxml:CT_TblLook_firstRow"/>
<attribute name="lastRow" tokenid="ooxml:CT_TblLook_lastRow"/>