Merge lp:~igudym/openobject-addons/table-styles-addons into lp:openobject-addons/5.0

Proposed by Ivan Gudym
Status: Needs review
Proposed branch: lp:~igudym/openobject-addons/table-styles-addons
Merge into: lp:openobject-addons/5.0
Diff against target: 138 lines (+46/-11)
1 file modified
base_report_designer/wizard/tiny_sxw2rml/normalized_oo2rml.xsl (+46/-11)
To merge this branch: bzr merge lp:~igudym/openobject-addons/table-styles-addons
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+23617@code.launchpad.net

Description of the change

Report engine improvement:
More accurate table cell style - lines before/after, background color
Added column span support.

Needed server support - corresponding branch:
  lp:~igudym/openobject-server/table-styles-server

To post a comment you must log in.

Unmerged revisions

2715. By Ivan Gudym

BlockTable background fixes

2714. By Ivan Gudym

Collumn span added

2713. By Ivan Gudym

Add rowspan support

2712. By Ivan Gudym

Add span support

2711. By Ivan Gudym

Table style fix

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_report_designer/wizard/tiny_sxw2rml/normalized_oo2rml.xsl'
2--- base_report_designer/wizard/tiny_sxw2rml/normalized_oo2rml.xsl 2009-02-17 11:38:59 +0000
3+++ base_report_designer/wizard/tiny_sxw2rml/normalized_oo2rml.xsl 2010-04-17 19:30:31 +0000
4@@ -29,6 +29,7 @@
5 <xsl:key name="page_break_after" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-after='page']" use="@style:name" />
6 <xsl:key name="table_column_style" match="style:style[@style:family='table-column']" use="@style:name" />
7 <xsl:key name="table_cell_style" match="style:style[@style:family='table-cell']" use="@style:name" />
8+<xsl:key name="table_row_style" match="style:style[@style:family='table-row']" use="@style:name" />
9 <xsl:key name="paragraph_style" match="style:style[@style:family='paragraph']" use="@style:name" />
10
11 <xsl:template match="office:document-content">
12@@ -134,16 +135,39 @@
13 <blockValign value="TOP" />
14 <xsl:call-template name="make_linestyle" />
15 <xsl:call-template name="make_tablebackground" />
16+ <xsl:call-template name="make_colspan" />
17 </blockTableStyle>
18 </xsl:if>
19 </xsl:for-each>
20 </xsl:template>
21
22+<xsl:template name="make_colspan">
23+ <xsl:for-each select=".//table:table-row">
24+ <xsl:variable name="row" select="position() - 1"/>
25+ <xsl:for-each select=".//table:table-cell[@table:number-columns-spanned]">
26+ <xsl:variable name="col" select="position() - 1"/>
27+ <xsl:variable name="span" select="@table:number-columns-spanned"/>
28+ <blockSpan span="{$span}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
29+ </xsl:for-each>
30+ </xsl:for-each>
31+</xsl:template>
32+
33+<xsl:template name="get_colspan">
34+ <xsl:variable name="span">
35+ <xsl:value-of select="@table:number-columns-spanned"/>
36+ </xsl:variable>
37+ <xsl:if test="not($span='') and not($span='none')"><xsl:value-of select="$span"/></xsl:if>
38+ <xsl:if test="($span='') or ($span='none')">1</xsl:if>
39+</xsl:template>
40+
41 <xsl:template name="make_linestyle">
42 <xsl:for-each select=".//table:table-row">
43 <xsl:variable name="row" select="position() - 1"/>
44- <xsl:for-each select=".//table:table-cell">
45+ <xsl:for-each select=".//table:table-cell|table:covered-table-cell">
46 <xsl:variable name="col" select="position() - 1"/>
47+ <xsl:variable name="span">
48+ <xsl:call-template name="get_colspan"/>
49+ </xsl:variable>
50 <xsl:variable name="linebefore">
51 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-left"/>
52 </xsl:variable>
53@@ -151,7 +175,7 @@
54 <xsl:variable name="colorname">
55 <xsl:value-of select="substring-after($linebefore,'#')"/>
56 </xsl:variable>
57- <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
58+ <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
59 </xsl:if>
60 <xsl:variable name="lineafter">
61 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-right"/>
62@@ -160,7 +184,7 @@
63 <xsl:variable name="colorname">
64 <xsl:value-of select="substring-after($lineafter,'#')"/>
65 </xsl:variable>
66- <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
67+ <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
68 </xsl:if>
69 <xsl:variable name="lineabove">
70 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-top"/>
71@@ -169,7 +193,7 @@
72 <xsl:variable name="colorname">
73 <xsl:value-of select="substring-after($lineabove,'#')"/>
74 </xsl:variable>
75- <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/>
76+ <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
77 </xsl:if>
78 <xsl:variable name="linebelow">
79 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-bottom"/>
80@@ -178,7 +202,7 @@
81 <xsl:variable name="colorname">
82 <xsl:value-of select="substring-after($linebelow,'#')"/>
83 </xsl:variable>
84- <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/>
85+ <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
86 </xsl:if>
87 <xsl:variable name="grid">
88 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border"/>
89@@ -188,10 +212,10 @@
90 <xsl:value-of select="substring-after($grid,'#')"/>
91 </xsl:variable>
92 <!-- Don't use grid because we don't need a line between each rows -->
93- <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
94- <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
95- <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/>
96- <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/>
97+ <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
98+ <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
99+ <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
100+ <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col + $span - 1},{$row}"/>
101 </xsl:if>
102 </xsl:for-each>
103 </xsl:for-each>
104@@ -263,14 +287,21 @@
105 <!--Be careful when there are table:table-header-rows as
106 parent node of table:table-row -->
107 <xsl:variable name="row" select="position() - 1" />
108- <xsl:for-each select="./table:table-cell">
109+ <xsl:variable name="bkground">
110+ <xsl:value-of select="key('table_row_style',@table:style-name)/style:properties/@fo:background-color" />
111+ </xsl:variable>
112+ <xsl:if test="not($bkground='') and boolean(key('table_row_style',@table:style-name)/style:properties/@fo:background-color) and starts-with($bkground,'#')">
113+ <!--only RGB hexcolors are accepted -->
114+ <blockBackground colorName="{$bkground}" start="0,{$row}" stop="-1,{$row}" />
115+ </xsl:if>
116+ <xsl:for-each select="./table:table-cell|table:covered-table-cell">
117 <xsl:variable name="col" select="position() - 1" />
118 <xsl:variable name="background">
119 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:background-color" />
120 </xsl:variable>
121 <xsl:if test="not($background='') and boolean(key('table_cell_style',@table:style-name)/style:properties/@fo:background-color) and starts-with($background,'#')">
122 <!--only RGB hexcolors are accepted -->
123- <blockBackground colorName="{$background}" start="{$col},{$row}" stop="{$col},-1" />
124+ <blockBackground colorName="{$background}" start="{$col},{$row}" stop="{$col},{$row}" />
125 </xsl:if>
126 </xsl:for-each>
127 </xsl:for-each>
128@@ -299,6 +330,10 @@
129 </td>
130 </xsl:template>
131
132+<xsl:template match="table:covered-table-cell">
133+ <td/>
134+</xsl:template>
135+
136 <xsl:template match="text:section">
137 <section>
138 <xsl:apply-templates />