mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-28 02:43:22 +01:00
Better handling of HTML tables when merging.
Fixes table within table broke format parsing.
This commit is contained in:
parent
55784ec703
commit
0d5bb226bf
@ -602,14 +602,6 @@ abstract class Merge
|
||||
case 'application/vnd.oasis.opendocument.text-template':
|
||||
case 'application/vnd.oasis.opendocument.spreadsheet-template':
|
||||
case 'application/vnd.oasis.opendocument.presentation-template':
|
||||
// It seems easier to split the parent tags here
|
||||
$replace_tags = array(
|
||||
'/<(ol|ul|table)( [^>]*)?>/' => '</text:p><$1$2>',
|
||||
'/<\/(ol|ul|table)>/' => '</$1><text:p>',
|
||||
//'/<(li)(.*?)>(.*?)<\/\1>/' => '<$1 $2>$3</$1>',
|
||||
);
|
||||
$content = preg_replace(array_keys($replace_tags),array_values($replace_tags),$content);
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$xslt = new XSLTProcessor();
|
||||
$doc->load(EGW_INCLUDE_ROOT.'/api/templates/default/Merge/openoffice.xslt');
|
||||
@ -669,7 +661,7 @@ abstract class Merge
|
||||
throw new Api\Exception('Unable to parse merged document for styles. Check warnings in log for details.');
|
||||
}
|
||||
$content = $xslt->transformToXml($element);
|
||||
|
||||
//echo $content;die();
|
||||
// Word 2003 needs two declarations, add extra declaration back in
|
||||
if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) {
|
||||
$content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$content;
|
||||
|
@ -16,7 +16,7 @@
|
||||
<xsl:variable name="custom-styles">
|
||||
<style:style style:name="Custom" style:family="text" />
|
||||
</xsl:variable>
|
||||
<xsl:template match="node()|@*">
|
||||
<xsl:template match="node()|@*" name="identity">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
</xsl:copy>
|
||||
@ -261,7 +261,27 @@
|
||||
</text:p></text:list-item>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="table[ancestor::office:text]">
|
||||
<!-- This section to deal with tables, which need to be outside the text:p tag -->
|
||||
<xsl:template match="text:p[table]">
|
||||
<xsl:apply-templates select="node()[1]"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:p/table">
|
||||
<xsl:call-template name="tableator"/>
|
||||
<xsl:apply-templates select="following-sibling::node()[1]"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:p[table]/node()[not(self::table)]">
|
||||
<text:p>
|
||||
<xsl:value-of select="node()"/>
|
||||
<xsl:apply-templates select="following-sibling::node()[1][not(self::table)]" mode="copy"/>
|
||||
</text:p>
|
||||
<xsl:apply-templates select="following-sibling::node()[self::table][1]"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:p[table]/node()[not(self::table)]" mode="copy">
|
||||
<xsl:call-template name="identity"/>
|
||||
<xsl:apply-templates select="following-sibling::node()[1][not(self::table)]" mode="copy"/>
|
||||
</xsl:template>
|
||||
<!-- Actually swap the HTML table tag for openoffice table tags -->
|
||||
<xsl:template match="table" name="tableator">
|
||||
<table:table table:name="Table{generate-id(.)}" table:style-name="TableX">
|
||||
<table:table-column table:style-name="TableX.A" table:number-columns-repeated="{count(tr[position() = 1]/td | tr[position() = 1]/th)}"/>
|
||||
<xsl:apply-templates/>
|
||||
@ -287,11 +307,16 @@
|
||||
</table:table-cell>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="td">
|
||||
<xsl:template match="td[not(table:table)]">
|
||||
<table:table-cell table:style-name="TableX.A1">
|
||||
<text:p><xsl:apply-templates/></text:p>
|
||||
</table:table-cell>
|
||||
</xsl:template>
|
||||
<xsl:template match="td[table]">
|
||||
<table:table-cell table:style-name="TableX.A1">
|
||||
<xsl:apply-templates/>
|
||||
</table:table-cell>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="tr">
|
||||
<table:table-row>
|
||||
|
Loading…
Reference in New Issue
Block a user