diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-30 09:14:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-30 08:40:30 +0000 |
commit | 1d1748d143ab4270a2ca1b5117852b1b1bb4c526 (patch) | |
tree | ed1939265de131d1338d2d26657459a0aa2825e6 /writerfilter | |
parent | 11cc9bdc21be241f2feb3ab4822d9d365dba4f96 (diff) |
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@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 19 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 4 | ||||
-rw-r--r-- | writerfilter/source/ooxml/factoryimpl_ns.py | 2 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 12 |
4 files changed, 33 insertions, 4 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index a350fc73ef0d..a69cbc63b0a7 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 40f9d378cd54..47f363fd59ba 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 6ad9a83038a0..d9baaa1c3613 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 32935c98fb83..61438c3d1f58 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"/> |