[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Aug 30 08:40:54 UTC 2016
sw/qa/extras/ooxmlexport/data/tdf44986.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 +++++++++
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 19 ++++++++++++++++++
writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 4 +++
writerfilter/source/ooxml/factoryimpl_ns.py | 2 -
writerfilter/source/ooxml/model.xml | 12 ++++++++---
6 files changed, 43 insertions(+), 4 deletions(-)
New commits:
commit 1d1748d143ab4270a2ca1b5117852b1b1bb4c526
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 30 09:14:47 2016 +0200
Related: tdf#44986 DOCX import: handle w:gridAfter by faking cells
This is similar to the w:gridBefore handling code introduced in commit
cf33af732ed0d3d553bb74636e3b14c55d44c153 (handle w:gridBefore by faking
cells (fdo#38414), 2014-04-23), except that the fake cells here are
inserted after the real ones, not before.
Change-Id: I4c03bd49e52016a58e0e002ae85dede6a96e5f55
Reviewed-on: https://gerrit.libreoffice.org/28487
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf44986.docx b/sw/qa/extras/ooxmlexport/data/tdf44986.docx
new file mode 100644
index 0000000..7859ab4
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf44986.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index cb20af1..90cef9f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -17,6 +17,7 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/XTextRangeCompare.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/text/TableColumnSeparator.hpp>
#include <oox/drawingml/drawingmltypes.hxx>
#include <config_features.h>
#include <string>
@@ -821,6 +822,15 @@ DECLARE_OOXMLEXPORT_TEST(testTDF99434, "protectedform.docx")
CPPUNIT_ASSERT(bProt);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf44986, "tdf44986.docx")
+{
+ // Check that the table at the second paragraph.
+ uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ // Check the first row of the table, it should have two cells (one separator).
+ // This was 0: the first row had no separators, so it had only one cell, which was too wide.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
+}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index a350fc7..a69cbc6 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1331,6 +1331,14 @@ void OOXMLFastContextHandlerTextTableRow::startRow()
void OOXMLFastContextHandlerTextTableRow::endRow()
{
+ if (mpGridAfter)
+ {
+ // Grid after is the same as grid before, the empty cells are just
+ // inserted after the real ones, not before.
+ handleGridBefore(mpGridAfter);
+ mpGridAfter = nullptr;
+ }
+
startParagraphGroup();
if (isForwardEvents())
@@ -1364,6 +1372,17 @@ void OOXMLFastContextHandlerTextTableRow::endRow()
endParagraphGroup();
}
+void OOXMLFastContextHandlerTextTableRow::handleGridAfter(const OOXMLValue::Pointer_t& rValue)
+{
+ if (OOXMLFastContextHandler* pTableRowProperties = getParent())
+ {
+ if (OOXMLFastContextHandler* pTableRow = pTableRowProperties->getParent())
+ // Save the value into the table row context, so it can be handled
+ // right before the end of the row.
+ pTableRow->setGridAfter(rValue);
+ }
+}
+
// Handle w:gridBefore here by faking necessary input that'll fake cells. I'm apparently
// not insane enough to find out how to add cells in dmapper.
void OOXMLFastContextHandlerTextTableRow::handleGridBefore( const OOXMLValue::Pointer_t& val )
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 40f9d37..47f363f 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -188,6 +188,8 @@ public:
virtual void setDefaultStringValue();
void sendPropertyToParent();
+ OOXMLFastContextHandler* getParent() const { return mpParent; }
+ void setGridAfter(const OOXMLValue::Pointer_t& pGridAfter) { mpGridAfter = pGridAfter; }
protected:
OOXMLFastContextHandler * mpParent;
@@ -222,6 +224,7 @@ protected:
const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() { return m_xContext;}
bool inPositionV;
+ OOXMLValue::Pointer_t mpGridAfter;
private:
void operator =(OOXMLFastContextHandler &) = delete;
@@ -403,6 +406,7 @@ public:
static void startRow();
void endRow();
void handleGridBefore( const OOXMLValue::Pointer_t& val );
+ void handleGridAfter(const OOXMLValue::Pointer_t& rValue);
private:
static OOXMLProperty::Pointer_t fakeNoBorder( Id id );
};
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index 6ad9a83..d9baaa1 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -439,7 +439,7 @@ def factoryChooseAction(actionNode):
elif actionNode.getAttribute("action") in ("startRow", "endRow"):
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") == "handleGridBefore":
+ 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 ("sendProperty", "handleHyperlink"):
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 32935c9..61438c3 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -14382,7 +14382,7 @@
<ref name="CT_TrPrBaseGridBefore"/>
</element>
<element name="gridAfter">
- <ref name="CT_DecimalNumber"/>
+ <ref name="CT_TrPrBaseGridAfter"/>
</element>
<element name="wBefore">
<ref name="CT_TblWidth"/>
@@ -14415,6 +14415,11 @@
<ref name="ST_DecimalNumber"/>
</attribute>
</define>
+ <define name="CT_TrPrBaseGridAfter">
+ <attribute name="val">
+ <ref name="ST_DecimalNumber"/>
+ </attribute>
+ </define>
<define name="CT_TrPr">
<ref name="CT_TrPrBase"/>
<element name="ins">
@@ -18298,8 +18303,6 @@
<resource name="CT_TrPrBase" resource="Properties">
<element name="cnfStyle" tokenid="ooxml:CT_TrPrBase_cnfStyle"/>
<element name="divId" tokenid="ooxml:CT_TrPrBase_divId"/>
-<!-- <element name="gridBefore" tokenid="ooxml:CT_TrPrBase_gridBefore"/> -->
- <element name="gridAfter" tokenid="ooxml:CT_TrPrBase_gridAfter"/>
<element name="wBefore" tokenid="ooxml:CT_TrPrBase_wBefore"/>
<element name="wAfter" tokenid="ooxml:CT_TrPrBase_wAfter"/>
<element name="cantSplit" tokenid="ooxml:CT_TrPrBase_cantSplit"/>
@@ -18312,6 +18315,9 @@
<resource name="CT_TrPrBaseGridBefore" resource="TextTableRow">
<attribute name="val" tokenid="ooxml:CT_TrPrBase_gridBefore" action="handleGridBefore"/>
</resource>
+ <resource name="CT_TrPrBaseGridAfter" resource="TextTableRow">
+ <attribute name="val" tokenid="ooxml:CT_TrPrBase_gridAfter" action="handleGridAfter"/>
+ </resource>
<resource name="CT_TrPr" resource="Properties">
<element name="ins" tokenid="ooxml:CT_TrPr_ins"/>
<element name="del" tokenid="ooxml:CT_TrPr_del"/>
More information about the Libreoffice-commits
mailing list