summaryrefslogtreecommitdiff
path: root/writerfilter/source/ooxml
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-12-05 09:47:18 +0100
committerLászló Németh <nemeth@numbertext.org>2019-12-08 15:54:01 +0100
commitb2c6d2d961a6113d0f111fab45ae12a40d389a23 (patch)
tree316cf6e0472f5c57a4d49d61d40ca5f3cc52e84d /writerfilter/source/ooxml
parentda1f71edfc72928b07a569b98e2766a8a7de9d2a (diff)
fdo#38414 tdf#44986: DOCX table import: handle gridBefore/After
without serious regressions, ie. losing the import of complex forms with multiple or nested tables. Complete the fix for tdf#116194 (DOCX import: fix missing tables with w:gridBefore) with handling gridAfter on DomainMapper level. This consists of also rejections (except their unit tests) of commit cf33af732ed0d3d553bb74636e3b14c55d44c153 (handle w:gridBefore by faking cells (fdo#38414)) and commit 1d1748d143ab4270a2ca1b5117852b1b1bb4c526 (Related: tdf#44986 DOCX import: handle w:gridAfter by faking cells) Change-Id: I31fa1de03bcdf42424fa5507fb5a3e06aa47107d Reviewed-on: https://gerrit.libreoffice.org/84517 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter/source/ooxml')
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx83
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.hxx5
-rw-r--r--writerfilter/source/ooxml/factoryimpl_ns.py3
-rw-r--r--writerfilter/source/ooxml/model.xml19
4 files changed, 2 insertions, 108 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 6f7839d0512b..31fb07774552 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1397,14 +1397,6 @@ 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())
@@ -1435,81 +1427,6 @@ 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);
- }
-}
-
-namespace {
-OOXMLValue::Pointer_t fakeNoBorder()
-{
- OOXMLPropertySet::Pointer_t pProps( new OOXMLPropertySet );
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(0);
- pProps->add(NS_ooxml::LN_CT_Border_val, pVal, OOXMLProperty::ATTRIBUTE);
- OOXMLValue::Pointer_t pValue( new OOXMLPropertySetValue( pProps ));
- return pValue;
-}
-}
-
-// 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 )
-{
- // start removing: disable for w:gridBefore
- if (!mpGridAfter)
- return;
-
- int count = val->getInt();
- for( int i = 0;
- i < count;
- ++i )
- {
- endOfParagraph();
-
- if (isForwardEvents())
- {
- // This whole part is OOXMLFastContextHandlerTextTableCell::endCell() .
- OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
- {
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(mnTableDepth);
- pProps->add(NS_ooxml::LN_tblDepth, pVal, OOXMLProperty::SPRM);
- }
- {
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(1);
- pProps->add(NS_ooxml::LN_inTbl, pVal, OOXMLProperty::SPRM);
- }
- {
- OOXMLValue::Pointer_t pVal = OOXMLBooleanValue::Create(mnTableDepth > 0);
- pProps->add(NS_ooxml::LN_tblCell, pVal, OOXMLProperty::SPRM);
- }
-
- mpStream->props(pProps.get());
-
- // fake <w:tcBorders> with no border
- OOXMLPropertySet::Pointer_t pCellProps( new OOXMLPropertySet );
- {
- OOXMLPropertySet::Pointer_t pBorderProps( new OOXMLPropertySet );
- static Id borders[] = { NS_ooxml::LN_CT_TcBorders_top, NS_ooxml::LN_CT_TcBorders_bottom,
- NS_ooxml::LN_CT_TcBorders_start, NS_ooxml::LN_CT_TcBorders_end };
- for(sal_uInt32 border : borders)
- pBorderProps->add(border, fakeNoBorder(), OOXMLProperty::SPRM);
- OOXMLValue::Pointer_t pValue( new OOXMLPropertySetValue( pBorderProps ));
- pCellProps->add(NS_ooxml::LN_CT_TcPrBase_tcBorders, pValue, OOXMLProperty::SPRM);
- mpParserState->setCellProperties(pCellProps);
- }
- }
-
- sendCellProperties();
- endParagraphGroup();
- }
-}
-
/*
class OOXMLFastContextHandlerTextTable
*/
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index d5de5a778ee0..0da8b9cdff9c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -186,8 +186,6 @@ public:
virtual void setDefaultStringValue();
void sendPropertyToParent();
- OOXMLFastContextHandler* getParent() const { return mpParent; }
- void setGridAfter(const OOXMLValue::Pointer_t& pGridAfter) { mpGridAfter = pGridAfter; }
protected:
OOXMLFastContextHandler * mpParent;
@@ -226,7 +224,6 @@ protected:
const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const { return m_xContext;}
bool inPositionV;
- OOXMLValue::Pointer_t mpGridAfter;
private:
void operator =(OOXMLFastContextHandler const &) = delete;
@@ -407,8 +404,6 @@ public:
static void startRow();
void endRow();
- void handleGridBefore( const OOXMLValue::Pointer_t& val );
- void handleGridAfter(const OOXMLValue::Pointer_t& rValue);
};
class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index 41fa714678c7..5bdf25c91478 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -440,9 +440,6 @@ 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" 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")))
# tdf#111550
elif actionNode.getAttribute("action") in ("start_P_Tbl"):
ret.append(" %sif (OOXMLFastContextHandlerTextTable* pTextTable = dynamic_cast<OOXMLFastContextHandlerTextTable*>(pHandler))" % extra_space)
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 17c8f5217fec..4c712e0b71fb 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -14445,7 +14445,7 @@
<ref name="CT_DecimalNumber"/>
</element>
<element name="gridAfter">
- <ref name="CT_TrPrBaseGridAfter"/>
+ <ref name="CT_DecimalNumber"/>
</element>
<element name="wBefore">
<ref name="CT_TblWidth"/>
@@ -14473,16 +14473,6 @@
</element>
</choice>
</define>
- <define name="CT_TrPrBaseGridBefore">
- <attribute name="val">
- <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">
@@ -18405,6 +18395,7 @@
<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"/>
@@ -18414,12 +18405,6 @@
<element name="jc" tokenid="ooxml:CT_TrPrBase_jc"/>
<element name="hidden" tokenid="ooxml:CT_TrPrBase_hidden"/>
</resource>
- <resource name="CT_TrPrBaseGridBefore" resource="TextTableRow">
- <attribute name="val" tokenid="ooxml:CT_TrPrBase_gridBefore"/>
- </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"/>