Issue 65447 - WordML import does not set style:master-page-name attribut for tables
Summary: WordML import does not set style:master-page-name attribut for tables
Status: CLOSED FIXED
Alias: None
Product: xml
Classification: Code
Component: external filters (show other issues)
Version: OOo 2.0.2
Hardware: All All
: P3 Trivial (vote)
Target Milestone: OOo 2.1
Assignee: svante.schubert
QA Contact: issues@xml
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-16 14:43 UTC by stefan_ziel
Modified: 2007-05-25 13:39 UTC (History)
2 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
patch also for 65441 (4.72 KB, text/plain)
2006-06-13 21:23 UTC, stefan_ziel
no flags Details
a header that disapears after import (23.81 KB, text/xml)
2006-06-13 21:24 UTC, stefan_ziel
no flags Details
that patch does it right (6.29 KB, text/plain)
2006-06-14 18:42 UTC, stefan_ziel
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description stefan_ziel 2006-05-16 14:43:52 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,'
~`!@#$%^*(&#x26;)+/,;?&lt;&gt;{}[]:','_'))" />
        </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".
Comment 1 stefan_ziel 2006-05-16 22:35:16 UTC
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'">
Comment 2 jogi 2006-05-26 09:36:40 UTC
-> SUS; PATCH set
Comment 3 svante.schubert 2006-06-13 18:13:06 UTC
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
Comment 4 stefan_ziel 2006-06-13 21:23:57 UTC
Created attachment 37123 [details]
patch also for 65441
Comment 5 stefan_ziel 2006-06-13 21:24:52 UTC
Created attachment 37124 [details]
a header that disapears after import
Comment 6 stefan_ziel 2006-06-14 17:30:26 UTC
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.
Comment 7 stefan_ziel 2006-06-14 18:42:16 UTC
Created attachment 37157 [details]
that patch does it right
Comment 8 svante.schubert 2006-07-17 12:23:05 UTC
This patch can be reproduced upon the attached document.
Therefore it is accepted.
Comment 9 svante.schubert 2006-07-31 20:16:56 UTC
patched checked in and tested..
Comment 10 jack.warchold 2006-08-16 15:31:26 UTC
seen good in cws wordml02
set to verified
Comment 11 Martin Hollmichel 2006-09-05 07:33:21 UTC
set target to 2.1
Comment 12 svante.schubert 2007-05-25 13:39:56 UTC
Closing long ago verified issues