Apache OpenOffice (AOO) Bugzilla – Issue 65447
WordML import does not set style:master-page-name attribut for tables
Last modified: 2007-05-25 13:39:56 UTC
That problem is a little more tricky ;). the "style:master-page-name" attribute is not set in the table-style. but if the body of an document starts with a table (no paragraph before) it should so to apply the defined page-layout. a quick and dirty workarround uses code similar to wordml2ooo_text.xsl in wordml2ooo_table.xsl <xsl:template match="w:tblPr" mode="style"> <xsl:variable name="table-number"> <xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1" /> </xsl:variable> <xsl:element name="style:style"> <xsl:attribute name="style:name"> <xsl:text>Table</xsl:text> <xsl:value-of select="$table-number"/> </xsl:attribute> <xsl:attribute name="style:family">table</xsl:attribute> <xsl:if test="w:tblStyle"> <xsl:attribute name="style:parent-style-name"> <xsl:value-of select="concat('w',translate(w:tblStyle/@w:val,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))" /> </xsl:attribute> </xsl:if> <xsl:variable name="section-property-number" select="count(preceding::w:sectPr)" /> <xsl:variable name="last-section-property" select="preceding::w:pPr/w:sectPr[1]" /> <xsl:variable name="next-section-property" select="following::w:sectPr[1]" /> <xsl:variable name="last-next-p-tbl" select="$last-section-property[last()]/following::*[name()='w:p' or name()='w:tbl']" /> <xsl:choose> <xsl:when test="not($next-section-property/w:type/@w:val = 'continuous') and generate-id($last-next-p-tbl[1]) = generate-id(..) and not(ancestor::w:sectPr or ancestor::w:styles)"> <xsl:attribute name="style:master-page-name"> <xsl:text>Standard</xsl:text> <xsl:value-of select="$section-property-number + 1" /> </xsl:attribute> </xsl:when> <xsl:when test="$table-number = 1"> <xsl:attribute name="style:master-page-name">Standard1</xsl:attribute> </xsl:when> </xsl:choose> ... but both could probably disturb page formats. a second, related problem: the xpath "not($next-section-property/w:type/@w:val = 'continuous') and generate-id($last-next-p-tbl[1]) = generate-id(..) and not(ancestor::w:sectPr or ancestor::w:styles)" should consider the very last section property of the document even if marked as "continous".
finally found the source so here comes the patch: Index: wordml2ooo_table.xsl =================================================================== RCS file: /cvs/framework/filter/source/xslt/import/wordml/wordml2ooo_table.xsl,v retrieving revision 1.8 diff -u -r1.8 wordml2ooo_table.xsl --- wordml2ooo_table.xsl 8 Sep 2005 22:13:21 -0000 1.8 +++ wordml2ooo_table.xsl 16 May 2006 21:33:53 -0000 @@ -48,8 +48,13 @@ </style:style> </xsl:template> <xsl:template match="w:tblPr" mode="style"> + <xsl:variable name="table-number"> + <xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1" /> + </xsl:variable> <xsl:element name="style:style"> - <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/> + <xsl:attribute name="style:name"> + <xsl:text>Table</xsl:text> + <xsl:value-of select="$table-number"/> </xsl:attribute> <xsl:attribute name="style:family">table</xsl:attribute> <xsl:if test="w:tblStyle"> @@ -61,10 +66,17 @@ <xsl:variable name="last-section-property" select="preceding::w:pPr/w:sectPr[1]"/> <xsl:variable name="next-section-property" select="following::w:sectPr[1]"/> <xsl:variable name="last-next-p-tbl" select="$last-section-property[last()]/following::*[name()='w:p' or name()='w:tbl']"/> - <xsl:if test="not($next-section-property/w:type/@w:val = 'continuous') and generate-id($last-next-p-tbl[1]) = generate-id(..) and not(ancestor::w:sectPr or ancestor::w:styles)"> - <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="$section-property-number + 1"/> + <xsl:choose> + <xsl:when test="not($next-section-property/w:type/@w:val = 'continuous') and generate-id($last-next-p-tbl[1]) = generate-id(..) and not(ancestor::w:sectPr or ancestor::w:styles)"> + <xsl:attribute name="style:master-page-name"> + <xsl:text>Standard</xsl:text> + <xsl:value-of select="$section-property-number + 1" /> </xsl:attribute> - </xsl:if> + </xsl:when> + <xsl:when test="$table-number = 1"> + <xsl:attribute name="style:master-page-name">Standard1</xsl:attribute> + </xsl:when> + </xsl:choose> <xsl:element name="style:table-properties"> <xsl:choose> <xsl:when test="w:jc/@w:val = 'left' or w:jc/@w:val = 'center' or w:jc/@w:val = 'right'">
-> SUS; PATCH set
SUS->Stefan: Hi Stefan, I had problems with one of the patches, after copy/pasting it from the issue, could you please attach the patch as a file to this issue. If it is possilbe for you to attach some of your test documents as well, it would help us a lot to confirm and verify the correct fix of this issue. Many thanks in advance, Svante
Created attachment 37123 [details] patch also for 65441
Created attachment 37124 [details] a header that disapears after import
danger this patch will have the undesired side effekt to break the page on the first occurance of a table if the table is not the first element in the body.
Created attachment 37157 [details] that patch does it right
This patch can be reproduced upon the attached document. Therefore it is accepted.
patched checked in and tested..
seen good in cws wordml02 set to verified
set target to 2.1
Closing long ago verified issues