Don't fail if table has properties, support table borders in docx files

This commit is contained in:
Nathan Gray 2011-08-24 17:29:03 +00:00
parent a11abf6412
commit bb00c4217d
2 changed files with 23 additions and 3 deletions

View File

@ -357,7 +357,7 @@ abstract class bo_merge
case 'application/vnd.oasis.opendocument.spreadsheet': case 'application/vnd.oasis.opendocument.spreadsheet':
// It seems easier to split the parent tags here // It seems easier to split the parent tags here
$replace_tags = array( $replace_tags = array(
'/<(ol|ul|table)>/' => '</text:p><$1>', '/<(ol|ul|table)( [^>]*)?>/' => '</text:p><$1$2>',
'/<\/(ol|ul|table)>/' => '</$1><text:p>', '/<\/(ol|ul|table)>/' => '</$1><text:p>',
//'/<(li)(.*?)>(.*?)<\/\1>/' => '<$1 $2>$3</$1>', //'/<(li)(.*?)>(.*?)<\/\1>/' => '<$1 $2>$3</$1>',
); );
@ -378,7 +378,7 @@ abstract class bo_merge
); );
// It seems easier to split the parent tags here // It seems easier to split the parent tags here
$replace_tags = array( $replace_tags = array(
'/<(ol|ul|table)(.*?)>/' => '</w:t></w:r></w:p><$1$2>', '/<(ol|ul|table)( [^>]*)?>/' => '</w:t></w:r></w:p><$1$2>',
'/<\/(ol|ul|table)>/' => '</$1><w:p><w:r><w:t>', '/<\/(ol|ul|table)>/' => '</$1><w:p><w:r><w:t>',
'/<(li)(.*?)>(.*?)<\/\1>/' => '<$1 $2>$3</$1>', '/<(li)(.*?)>(.*?)<\/\1>/' => '<$1 $2>$3</$1>',
/* /*

View File

@ -223,6 +223,15 @@ Breakers
<w:tblPr> <w:tblPr>
<w:tblW w:type="dxa" w:w="9972"/> <w:tblW w:type="dxa" w:w="9972"/>
<w:jc w:value="left"/> <w:jc w:value="left"/>
<xsl:if test="@border &gt; 0">
<w:tblBorders>
<xsl:variable name="width" select="number(@border)*2"/>
<w:top w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
<w:left w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
<w:bottom w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
<w:right w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
</w:tblBorders>
</xsl:if>
</w:tblPr> </w:tblPr>
<w:tblGrid> <w:tblGrid>
<xsl:for-each select="./tr[1]/td"> <xsl:for-each select="./tr[1]/td">
@ -232,7 +241,18 @@ Breakers
<xsl:for-each select="./tr"> <xsl:for-each select="./tr">
<w:tr> <w:tr>
<xsl:for-each select="./td"> <xsl:for-each select="./td">
<w:tc><w:p><w:r><w:t><xsl:apply-templates select="child::node()" /></w:t></w:r></w:p></w:tc> <w:tc>
<xsl:if test="../../@border &gt; 0">
<w:tcPr><w:tcBorders>
<xsl:variable name="width" select="number(../../@border)*2"/>
<w:top w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
<w:left w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
<w:bottom w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
<w:right w:color="000000" w:space="0" w:sz="{$width}" w:val="single"/>
</w:tcBorders></w:tcPr>
</xsl:if>
<w:p><w:r><w:t><xsl:apply-templates select="child::node()" /></w:t></w:r></w:p>
</w:tc>
</xsl:for-each> </xsl:for-each>
</w:tr> </w:tr>
</xsl:for-each> </xsl:for-each>