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

Mike Kaganski mike.kaganski at collabora.com
Tue Jul 18 09:11:36 UTC 2017


 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    8 +++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    4 +++
 writerfilter/source/ooxml/factoryimpl_ns.py           |    3 ++
 writerfilter/source/ooxml/model.xml                   |   20 ++++++++++++++++++
 4 files changed, 35 insertions(+)

New commits:
commit 0eb0c7308ad57f4a20b5691d450b5185e52475f6
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Jul 13 09:08:56 2017 +0300

    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 <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>

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"/>


More information about the Libreoffice-commits mailing list