diff options
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 79 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 3 | ||||
-rw-r--r-- | writerfilter/source/ooxml/factoryimpl_ns.xsl | 4 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 12 |
4 files changed, 96 insertions, 2 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index a8ecda389d99..0506136769cf 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -1966,6 +1966,85 @@ void OOXMLFastContextHandlerTextTableRow::endRow() endParagraphGroup(); } +// 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( OOXMLValue::Pointer_t val ) +{ + int count = val->getInt(); + for( int i = 0; + i < count; + ++i ) + { + endOfParagraph(); + + if (isForwardEvents()) + { + // This whole part is OOXMLFastContextHandlerTextTableCell::endCell() . + OOXMLPropertySet * pProps = new OOXMLPropertySetImpl(); + { + OOXMLValue::Pointer_t pVal + (new OOXMLIntegerValue(mnTableDepth)); + OOXMLProperty::Pointer_t pProp + (new OOXMLPropertyImpl(NS_ooxml::LN_tblDepth, pVal, OOXMLPropertyImpl::SPRM)); + pProps->add(pProp); + } + { + OOXMLValue::Pointer_t pVal + (new OOXMLIntegerValue(1)); + OOXMLProperty::Pointer_t pProp + (new OOXMLPropertyImpl(NS_ooxml::LN_inTbl, pVal, OOXMLPropertyImpl::SPRM)); + pProps->add(pProp); + } + { + OOXMLValue::Pointer_t pVal + (new OOXMLBooleanValue(mnTableDepth > 0)); + OOXMLProperty::Pointer_t pProp + (new OOXMLPropertyImpl(NS_ooxml::LN_tblCell, pVal, OOXMLPropertyImpl::SPRM)); + pProps->add(pProp); + } + + #ifdef DEBUG_PROPERTIES + debug_logger->startElement("handlegridbefore"); + debug_logger->propertySet(OOXMLPropertySet::Pointer_t(pProps->clone()), + IdToString::Pointer_t(new OOXMLIdToString())); + debug_logger->endElement(); + #endif + mpStream->props(writerfilter::Reference<Properties>::Pointer_t(pProps)); + + // fake <w:tcBorders> with no border + OOXMLPropertySet::Pointer_t pCellProps( new OOXMLPropertySetImpl()); + { + OOXMLPropertySet::Pointer_t pBorderProps( new OOXMLPropertySetImpl()); + 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( size_t j = 0; j < SAL_N_ELEMENTS( borders ); ++j ) + pBorderProps->add( fakeNoBorder( borders[ j ] )); + OOXMLValue::Pointer_t pValue( new OOXMLPropertySetValue( pBorderProps )); + OOXMLProperty::Pointer_t pProp + (new OOXMLPropertyImpl(NS_ooxml::LN_CT_TcPrBase_tcBorders, pValue, OOXMLPropertyImpl::SPRM)); + pCellProps->add(pProp); + mpParserState->setCellProperties(pCellProps); + } + } + + sendCellProperties(); + endParagraphGroup(); + } +} + +OOXMLProperty::Pointer_t OOXMLFastContextHandlerTextTableRow::fakeNoBorder( Id id ) +{ + OOXMLPropertySet::Pointer_t pProps( new OOXMLPropertySetImpl()); + OOXMLValue::Pointer_t pVal(new OOXMLIntegerValue(0)); + OOXMLProperty::Pointer_t pPropVal + (new OOXMLPropertyImpl(NS_ooxml::LN_CT_Border_val, pVal, OOXMLPropertyImpl::ATTRIBUTE)); + pProps->add(pPropVal); + OOXMLValue::Pointer_t pValue( new OOXMLPropertySetValue( pProps )); + OOXMLProperty::Pointer_t pProp + (new OOXMLPropertyImpl(id, pValue, OOXMLPropertyImpl::SPRM)); + return pProp; +} + /* class OOXMLFastContextHandlerTextTable */ diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index dd8d99766d9b..799395f4be3e 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -491,6 +491,9 @@ public: void startRow(); void endRow(); + void handleGridBefore( OOXMLValue::Pointer_t val ); +private: + OOXMLProperty::Pointer_t fakeNoBorder( Id id ); }; class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler diff --git a/writerfilter/source/ooxml/factoryimpl_ns.xsl b/writerfilter/source/ooxml/factoryimpl_ns.xsl index 9cb8912dc72a..d932008eb5c8 100644 --- a/writerfilter/source/ooxml/factoryimpl_ns.xsl +++ b/writerfilter/source/ooxml/factoryimpl_ns.xsl @@ -476,6 +476,10 @@ CreateElementMapPointer </xsl:text> <xsl:value-of select="@action"/> <xsl:text>();</xsl:text> </xsl:when> + <xsl:when test="@action='handleGridBefore'"> + <xsl:text> + dynamic_cast<OOXMLFastContextHandlerTextTableRow*>(pHandler)->handleGridBefore();</xsl:text> + </xsl:when> <xsl:when test="@action='sendProperty' or @action='handleHyperlink'"> <xsl:text> dynamic_cast<OOXMLFastContextHandlerStream*>(pHandler)-></xsl:text> diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 16039bc63898..11ed808c5a8c 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -19563,7 +19563,7 @@ </optional> <optional> <element name="gridBefore"> - <ref name="CT_DecimalNumber"/> + <ref name="CT_TrPrBaseGridBefore"/> </element> </optional> <optional> @@ -19614,6 +19614,11 @@ </choice> </oneOrMore> </define> + <define name="CT_TrPrBaseGridBefore"> + <attribute name="val"> + <ref name="ST_DecimalNumber"/> + </attribute> + </define> <define name="CT_TrPr"> <ref name="CT_TrPrBase"/> <group> @@ -24766,7 +24771,7 @@ <kind name="table"/> <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="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"/> @@ -24777,6 +24782,9 @@ <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" action="handleGridBefore"/> + </resource> <resource name="CT_TrPr" resource="Properties" tag="table"> <kind name="table"/> <element name="ins" tokenid="ooxml:CT_TrPr_ins"/> |