~vauxoo/addons-vauxoo/7.0-fix-error-font-size-reports-dev_ernesto

« back to all changes in this revision

Viewing changes to commission_payment/report/tiny_sxw2rml/normalized_odt2rml.xsl

  • Committer: Miguel Delgado
  • Date: 2012-05-21 14:48:48 UTC
  • Revision ID: miguel.delgado07@gmail.com-20120521144848-v9lt237qbqh2cwdl

[ADD] se migraron los modulos de baremo, commission_payment y hr_salesman_commission
para que el proceso de calculo de comisiones funcionara igual que en version 5.0 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?>
 
2
<xsl:stylesheet
 
3
  version="1.0"
 
4
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
5
  xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
 
6
  xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
 
7
  xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
 
8
  xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
 
9
  xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
 
10
  xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
 
11
  xmlns:xlink="http://www.w3.org/1999/xlink"
 
12
  xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
 
13
  xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
 
14
  xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
 
15
  xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
 
16
  xmlns:math="http://www.w3.org/1998/Math/MathML"
 
17
  xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
 
18
  xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
 
19
  office:class="text" office:version="1.1"
 
20
  exclude-result-prefixes = "xsl fo office style text table draw xlink number svg chart dr3d math form script">
 
21
 
 
22
  <!--TODO's: indent, picture cache (trml2pdf) -->
 
23
 
 
24
<xsl:output method="xml" indent="yes" />
 
25
<xsl:strip-space elements="*"/>
 
26
 
 
27
<xsl:key name="text_style" match="style:style[@style:family='text']" use="@style:name" />
 
28
<xsl:key name="page_break_before" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-before='page']" use="@style:name" />
 
29
<xsl:key name="page_break_after" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-after='page']" use="@style:name" />
 
30
<xsl:key name="table_column_style" match="style:style[@style:family='table-column']" use="@style:name" />
 
31
<xsl:key name="table_cell_style" match="style:style[@style:family='table-cell']" use="@style:name" />
 
32
<xsl:key name="paragraph_style" match="style:style[@style:family='paragraph']" use="@style:name" />
 
33
 
 
34
<xsl:template match="office:document-content">
 
35
  <document filename="test.pdf">
 
36
    <xsl:apply-templates select="office:automatic-styles" />
 
37
    <xsl:apply-templates select="office:body" />
 
38
  </document>
 
39
</xsl:template>
 
40
 
 
41
<xsl:template name="page_size">
 
42
  <xsl:attribute name="pageSize">
 
43
    <xsl:text>(</xsl:text>
 
44
    <xsl:value-of select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:page-width" />
 
45
    <xsl:text>,</xsl:text>
 
46
    <xsl:value-of select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:page-height" />
 
47
    <xsl:text>)</xsl:text>
 
48
  </xsl:attribute>
 
49
</xsl:template>
 
50
 
 
51
<xsl:template name="fixed_frame">
 
52
        <xsl:for-each select="//draw:text-box">
 
53
                <frame>
 
54
                        <xsl:attribute name="id"><xsl:value-of select="./@draw:name" /></xsl:attribute>
 
55
                        <xsl:attribute name="x1"><xsl:value-of select="./@svg:x" /></xsl:attribute>
 
56
                        <xsl:attribute name="y1">
 
57
                                <xsl:value-of
 
58
                                        select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:page-height - ./@svg:y - ./@fo:min-height" />
 
59
                        </xsl:attribute>
 
60
                        <xsl:attribute name="width">
 
61
                                <xsl:value-of select="./@svg:width" />
 
62
                        </xsl:attribute>
 
63
                        <xsl:attribute name="height">
 
64
                                <xsl:value-of select="./@fo:min-height" />
 
65
                        </xsl:attribute>
 
66
                </frame>
 
67
        </xsl:for-each>
 
68
</xsl:template>
 
69
 
 
70
<xsl:template name="margin_sizes">
 
71
  <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:margin-left" />
 
72
  <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:margin-right" />
 
73
  <xsl:variable name="margin_top" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:margin-top" />
 
74
  <xsl:variable name="margin_bottom" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:margin-bottom" />
 
75
  <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:page-width" />
 
76
  <xsl:variable name="page_height" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:page-height" />
 
77
  <xsl:attribute name="x1"><xsl:value-of select="$margin_left" /></xsl:attribute>
 
78
  <xsl:attribute name="y1"><xsl:value-of select="$margin_bottom" /></xsl:attribute>
 
79
  <xsl:attribute name="width"><xsl:value-of select="$page_width - $margin_left - $margin_right"/></xsl:attribute>
 
80
  <xsl:attribute name="height"><xsl:value-of select="$page_height - $margin_bottom - $margin_top"/></xsl:attribute>
 
81
</xsl:template>
 
82
 
 
83
<xsl:template name="text_width">
 
84
  <!-- You need this for the workaround to make primitive outlines-->
 
85
  <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:margin-left" />
 
86
  <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:margin-right" />
 
87
  <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-layout[1]/style:page-layout-properties/@fo:page-width" />
 
88
  <xsl:value-of select="$page_width - $margin_left - $margin_right - 18"/>
 
89
</xsl:template>
 
90
 
 
91
 
 
92
 
 
93
<xsl:template match="office:automatic-styles">
 
94
  <!--<template pageSize="(21cm, 29.7cm)" leftMargin="1.0cm" rightMargin="2.0cm" topMargin="1.0cm" bottomMargin="1.0cm" title="Test" author="Martin Simon" allowSplitting="20">-->
 
95
  <template pageSize="(21cm, 29.7cm)" title="Test" author="Martin Simon" allowSplitting="20">
 
96
    <xsl:call-template name="page_size" />
 
97
    <pageTemplate id="first">
 
98
          <xsl:call-template name="fixed_frame" />
 
99
      <frame id="first" x1="2cm" y1="2cm" width="17cm" height="26cm">
 
100
        <xsl:call-template name="margin_sizes" />
 
101
      </frame>
 
102
    </pageTemplate>
 
103
  </template>
 
104
  <stylesheet>
 
105
    <!--A table style to simulate primitive outlines -till the <addOutline> tag is implemented in trml2pdf -->
 
106
    <blockTableStyle id="Standard_Outline">
 
107
      <blockAlignment value="LEFT"/>
 
108
      <blockValign value="TOP"/>
 
109
    </blockTableStyle>
 
110
    <!--use two standard table grid styles like PyOpenOffice "Old Way": with and without a grid-->
 
111
    <!--TODO insert table cell colors here, not within the <td> tag - otherwise
 
112
         it will not work with flowables as cell content-->
 
113
    <xsl:call-template name="make_blocktablestyle" />
 
114
    <initialize>
 
115
      <paraStyle name="all" alignment="justify" />
 
116
    </initialize>
 
117
    <xsl:apply-templates select="style:style" />
 
118
  </stylesheet>
 
119
</xsl:template>
 
120
 
 
121
<xsl:template name="make_blocktablestyle">
 
122
  <xsl:for-each select="//table:table">
 
123
    <xsl:variable name="test">
 
124
      <xsl:value-of select="./@table:name" />
 
125
    </xsl:variable>
 
126
    <xsl:if test="not(boolean(count(preceding-sibling::table:table[@table:name=$test])))">
 
127
      <!--Test if this is the first table with this style, nested tables not counted-->
 
128
      <blockTableStyle id="{@table:name}">
 
129
            <xsl:if test=".//draw:image">
 
130
              <blockTopPadding value="0"/>
 
131
              <blockBottomPadding value="0"/>
 
132
            </xsl:if>
 
133
        <blockAlignment value="LEFT" />
 
134
        <blockValign value="TOP" />
 
135
        <xsl:call-template name="make_linestyle" />
 
136
        <xsl:call-template name="make_tablebackground" />
 
137
      </blockTableStyle>
 
138
    </xsl:if>
 
139
  </xsl:for-each>
 
140
</xsl:template>
 
141
 
 
142
<xsl:template name="make_linestyle">
 
143
        <xsl:for-each select=".//table:table-row">
 
144
                <xsl:variable name="row" select="position() - 1"/>
 
145
                <xsl:for-each select=".//table:table-cell">
 
146
                        <xsl:variable name="col" select="position() - 1"/>
 
147
                        <xsl:variable name="linebefore">
 
148
                                <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-left"/>
 
149
                        </xsl:variable>
 
150
                        <xsl:if test="not($linebefore='') and not($linebefore='none')">
 
151
                                <xsl:variable name="colorname">
 
152
                                        <xsl:value-of select="substring-after($linebefore,'#')"/>
 
153
                                </xsl:variable>
 
154
                                <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
 
155
                        </xsl:if>
 
156
                        <xsl:variable name="lineafter">
 
157
                                <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-right"/>
 
158
                        </xsl:variable>
 
159
                        <xsl:if test="not($lineafter='') and not($lineafter='none')">
 
160
                                <xsl:variable name="colorname">
 
161
                                        <xsl:value-of select="substring-after($lineafter,'#')"/>
 
162
                                </xsl:variable>
 
163
                                <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
 
164
                        </xsl:if>
 
165
                        <xsl:variable name="lineabove">
 
166
                                <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-top"/>
 
167
                        </xsl:variable>
 
168
                        <xsl:if test="not($lineabove='') and not($lineabove='none')">
 
169
                                <xsl:variable name="colorname">
 
170
                                        <xsl:value-of select="substring-after($lineabove,'#')"/>
 
171
                                </xsl:variable>
 
172
                                <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/>
 
173
                        </xsl:if>
 
174
                        <xsl:variable name="linebelow">
 
175
                                <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-bottom"/>
 
176
                        </xsl:variable>
 
177
                        <xsl:if test="not($linebelow='') and not($linebelow='none')">
 
178
                                <xsl:variable name="colorname">
 
179
                                        <xsl:value-of select="substring-after($linebelow,'#')"/>
 
180
                                </xsl:variable>
 
181
                                <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/>
 
182
                        </xsl:if>
 
183
                        <xsl:variable name="grid">
 
184
                                <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border"/>
 
185
                        </xsl:variable>
 
186
                        <xsl:if test="not($grid='') and not($grid='none')">
 
187
                                <xsl:variable name="colorname">
 
188
                                        <xsl:value-of select="substring-after($grid,'#')"/>
 
189
                                </xsl:variable>
 
190
                                <!-- Don't use grid because we don't need a line between each rows -->
 
191
                                <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
 
192
                                <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
 
193
                                <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/>
 
194
                                <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/>
 
195
                        </xsl:if>
 
196
                </xsl:for-each>
 
197
        </xsl:for-each>
 
198
</xsl:template>
 
199
 
 
200
<!-- Was needed to simulate bulleted lists:
 
201
<xsl:template match="text:ordered-list|text:unordered-list">
 
202
  <xsl:variable name = "text_width">
 
203
    <xsl:call-template name="text_width" />
 
204
  </xsl:variable>
 
205
  <blockTable style="Standard_Outline" colWidths="18,{$text_width}">
 
206
  <xsl:apply-templates match="text:list-item" />
 
207
</blockTable>
 
208
</xsl:template>
 
209
 
 
210
<xsl:template match="text:list-item">
 
211
  <tr>
 
212
    <td><para><font face="Helvetica-Bold" size="10">*</font></para></td>
 
213
    <td>
 
214
      <xsl:apply-templates />
 
215
    </td>
 
216
  </tr>
 
217
</xsl:template>
 
218
 
 
219
-->
 
220
 
 
221
 
 
222
<xsl:template match="office:body">
 
223
  <story>
 
224
    <xsl:apply-templates />
 
225
        <xsl:for-each select="//draw:text-box">
 
226
                <currentFrame>
 
227
                        <xsl:attribute name="name">
 
228
                                <xsl:value-of select="./@draw:name" />
 
229
                        </xsl:attribute>
 
230
                </currentFrame>
 
231
                <xsl:apply-templates>
 
232
                        <xsl:with-param name="skip_draw" select="0" />
 
233
                </xsl:apply-templates>
 
234
                <frameEnd />
 
235
        </xsl:for-each>
 
236
        <xsl:for-each select="//text:ordered-list">
 
237
                <para><seqReset id="{./@text:style-name}"/></para>
 
238
        </xsl:for-each>
 
239
  </story>
 
240
</xsl:template>
 
241
 
 
242
<xsl:template match="table:table">
 
243
  <blockTable>
 
244
    <xsl:attribute name="colWidths">
 
245
      <xsl:call-template name="make_columns" />
 
246
    </xsl:attribute>
 
247
    <xsl:call-template name="make_tableheaders" />
 
248
    <xsl:attribute name="style">
 
249
      <xsl:value-of select="@table:name" />
 
250
    </xsl:attribute>
 
251
    <xsl:apply-templates />
 
252
  </blockTable>
 
253
</xsl:template>
 
254
 
 
255
<xsl:template name="make_tableheaders">
 
256
  <xsl:if test="boolean(count(table:table-header-rows))">
 
257
    <xsl:attribute name="repeatRows">1</xsl:attribute>
 
258
  </xsl:if>
 
259
</xsl:template>
 
260
 
 
261
<xsl:template name="make_tablebackground">
 
262
  <xsl:for-each select=".//table:table-row">
 
263
    <!--Be careful when there are table:table-header-rows as
 
264
         parent node of table:table-row -->
 
265
    <xsl:variable name="row" select="position() - 1" />
 
266
    <xsl:for-each select="./table:table-cell">
 
267
      <xsl:variable name="col" select="position() - 1" />
 
268
      <xsl:variable name="background">
 
269
        <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:background-color" />
 
270
      </xsl:variable>
 
271
      <xsl:if test="not($background='') and boolean(key('table_cell_style',@table:style-name)/style:properties/@fo:background-color) and starts-with($background,'#')">
 
272
        <!--only RGB hexcolors are accepted -->
 
273
                <blockBackground colorName="{$background}" start="{$col},{$row}" stop="{$col},-1" />
 
274
      </xsl:if>
 
275
     </xsl:for-each>
 
276
   </xsl:for-each>
 
277
</xsl:template>
 
278
 
 
279
<xsl:template name="make_columns">
 
280
  <xsl:variable name="columns" >
 
281
    <xsl:for-each select="table:table-column">
 
282
      <xsl:value-of select="key('table_column_style',@table:style-name)/style:properties/@style:column-width" />
 
283
      <xsl:text>,</xsl:text>
 
284
    </xsl:for-each>
 
285
  </xsl:variable>
 
286
  <xsl:value-of select="substring($columns,1,string-length($columns) - 1)" />
 
287
  <!--strip the last comma-->
 
288
</xsl:template>
 
289
 
 
290
<xsl:template match="table:table-row">
 
291
  <tr>
 
292
    <xsl:apply-templates />
 
293
  </tr>
 
294
</xsl:template>
 
295
 
 
296
<xsl:template match="table:table-cell">
 
297
  <td>
 
298
    <xsl:apply-templates />
 
299
  </td>
 
300
</xsl:template>
 
301
 
 
302
<xsl:template match="text:section">
 
303
  <section>
 
304
    <xsl:apply-templates />
 
305
  </section>
 
306
</xsl:template>
 
307
 
 
308
 
 
309
<xsl:template match="text:span">
 
310
  <font>
 
311
    <xsl:call-template name="make_fontnames_span" />
 
312
    <xsl:call-template name="make_fontsize_span" />
 
313
    <xsl:apply-templates />
 
314
  </font>
 
315
</xsl:template>
 
316
 
 
317
<xsl:template name="make_fontsize_span">
 
318
  <xsl:variable name ="fontsize">
 
319
    <xsl:value-of select="key('text_style',@text:style-name)/style:properties/@fo:font-size" />
 
320
  </xsl:variable>
 
321
  <xsl:if test="not($fontsize='') and boolean(key('text_style',@text:style-name)/style:properties/@fo:font-size)" >
 
322
    <xsl:attribute name="size">
 
323
      <xsl:value-of select="$fontsize" />
 
324
    </xsl:attribute>
 
325
  </xsl:if>
 
326
</xsl:template>
 
327
 
 
328
<xsl:template name="make_fontnames_span">
 
329
  <xsl:attribute name="face">
 
330
    <xsl:call-template name="make_fontnames">
 
331
      <xsl:with-param name="fontName" select="key('text_style',@text:style-name)/style:properties/@style:font-name"  />
 
332
      <xsl:with-param name="fontWeight" select="key('text_style',@text:style-name)/style:properties/@fo:font-weight"  />
 
333
      <xsl:with-param name="fontStyle" select="key('text_style',@text:style-name)/style:properties/@fo:font-style" />
 
334
    </xsl:call-template>
 
335
  </xsl:attribute>
 
336
</xsl:template>
 
337
 
 
338
<xsl:template name="make_image">
 
339
  <illustration height="{.//draw:frame/@svg:height}" width="{.//draw:frame/@svg:width}">
 
340
    <image x="0" y="0" file="{substring-after(.//draw:image/@xlink:href,'Pictures/')}" height="{.//draw:frame/@svg:height}" width="{.//draw:frame/@svg:width}" />
 
341
  </illustration>
 
342
</xsl:template>
 
343
 
 
344
<xsl:template name="empty_paragraph">
 
345
  <xsl:if test="not(boolean(count(descendant::node())))">
 
346
    <xsl:call-template name="distance_point">
 
347
      <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" />
 
348
    </xsl:call-template>
 
349
  </xsl:if>
 
350
</xsl:template>
 
351
 
 
352
<xsl:template name="distance_point">
 
353
  <xsl:param name="background" />
 
354
  <xsl:param name="tab_stop"></xsl:param>
 
355
  <xsl:variable name="local_back">
 
356
    <xsl:choose>
 
357
      <xsl:when test="not(boolean($background)) or not(contains($background,'#'))">
 
358
        <!-- Do not accept OO colors like "transparent", only hex-colors -->
 
359
        <xsl:text>white</xsl:text>
 
360
      </xsl:when>
 
361
      <xsl:otherwise>
 
362
        <xsl:value-of select="$background" />
 
363
      </xsl:otherwise>
 
364
    </xsl:choose>
 
365
  </xsl:variable>
 
366
  <font color="{$local_back}">
 
367
    <xsl:text> </xsl:text>
 
368
    <xsl:if test="boolean($tab_stop)">
 
369
      <!-- simulate a tabstop with white/background-color points -->
 
370
      <xsl:text>.........</xsl:text>
 
371
    </xsl:if>
 
372
  </font>
 
373
</xsl:template>
 
374
 
 
375
<xsl:template match="text:ordered-list">
 
376
  <xsl:apply-templates />
 
377
 
 
378
  <!-- Reset the counter. seqreset is not a trml2pdf tag, but a Platypus Intra Paragraph Markup,
 
379
       so it needs a dummy paragraph to enclose it -->
 
380
</xsl:template>
 
381
 
 
382
<xsl:template name="make_listitem">
 
383
  <xsl:if test="(name(..)='text:list-item')">
 
384
    <xsl:attribute name="leftIndent">15</xsl:attribute>
 
385
    <xsl:attribute name="bulletIndent">0</xsl:attribute>
 
386
    <xsl:choose>
 
387
      <xsl:when test="(name(../..)='text:unordered-list')">
 
388
        <xsl:variable name="fontsize">
 
389
          <xsl:value-of select="number(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)" />
 
390
        </xsl:variable>
 
391
        <xsl:choose>
 
392
          <xsl:when test="$fontsize='NaN'">
 
393
            <!-- you should exclude non-numerical values for bulletFontSize. <== Sometimes the preprocessing went wrong.-->
 
394
            <!--use a default bullet font size-->
 
395
            <xsl:attribute name="bulletFontSize">6</xsl:attribute>
 
396
          </xsl:when>
 
397
          <xsl:otherwise>
 
398
            <xsl:attribute name="bulletFontSize"><xsl:value-of select="floor(($fontsize div 2) + 1)" /></xsl:attribute>
 
399
          </xsl:otherwise>
 
400
        </xsl:choose>
 
401
        <xsl:attribute name="bulletFontName">ZapfDingbats</xsl:attribute>
 
402
        <xsl:attribute name="bulletText">l</xsl:attribute>
 
403
      </xsl:when>
 
404
      <xsl:otherwise>
 
405
        <!-- Generate the numbers for an ordered list -->
 
406
        <xsl:variable name="size">
 
407
          <xsl:value-of select="key('paragraph_style',@text:style-name)/style:properties/@fo:font-size" />
 
408
        </xsl:variable>
 
409
        <!-- For ordered lists we use the bullet tag from Platypus Intra Paragraph Markup -->
 
410
        <bullet>
 
411
          <xsl:if test="not($size='') and boolean(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)">
 
412
            <xsl:attribute name="size">
 
413
              <!-- adapt the fontsize to the fontsize of the current paragraph -->
 
414
              <xsl:value-of select="$size" />
 
415
            </xsl:attribute>
 
416
          </xsl:if>
 
417
          <seq id="{../../@text:style-name}"/>.</bullet>
 
418
      </xsl:otherwise>
 
419
    </xsl:choose>
 
420
  </xsl:if>
 
421
</xsl:template>
 
422
 
 
423
<xsl:template match="text:drop-down">
 
424
    <xsl:value-of select="text:label[2]/@text:value" />
 
425
</xsl:template>
 
426
 
 
427
 
 
428
<xsl:template match="text:p|text:h">
 
429
        <xsl:param name="skip_draw" select="1" />
 
430
  <xsl:if test="boolean(key('page_break_before',@text:style-name))" >
 
431
    <pageBreak />
 
432
  </xsl:if>
 
433
  <xsl:choose>
 
434
    <xsl:when test="boolean(.//draw:image)">
 
435
      <xsl:call-template name="make_image" />
 
436
    </xsl:when>
 
437
        <xsl:when test="boolean(name(..) = 'draw:text-box') and boolean($skip_draw)">
 
438
        </xsl:when>
 
439
    <xsl:otherwise>
 
440
      <para>
 
441
        <xsl:attribute name="style">
 
442
          <xsl:value-of select="@text:style-name" />
 
443
        </xsl:attribute>
 
444
        <xsl:call-template name="make_listitem" />
 
445
        <xsl:apply-templates />
 
446
        <xsl:call-template name="empty_paragraph" />
 
447
      </para>
 
448
    </xsl:otherwise>
 
449
  </xsl:choose>
 
450
  <xsl:if test="boolean(key('page_break_after',@text:style-name))" >
 
451
    <pageBreak />
 
452
  </xsl:if>
 
453
</xsl:template>
 
454
 
 
455
<xsl:template match="text:p/text:tab-stop">
 
456
  <!-- simulate a tabstop -->
 
457
  <xsl:call-template name="distance_point">
 
458
    <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" />
 
459
    <xsl:with-param name="tab_stop">yes</xsl:with-param>
 
460
  </xsl:call-template>
 
461
</xsl:template>
 
462
 
 
463
<!-- experimental - switched off
 
464
<xsl:template match="text:h">
 
465
  <para>
 
466
    <xsl:attribute name="style">
 
467
      <xsl:value-of select="@text:style-name" />
 
468
    </xsl:attribute>
 
469
    <xsl:call-template name="make_number" />
 
470
    <xsl:apply-templates />
 
471
    <xsl:call-template name="empty_paragraph" />
 
472
  </para>
 
473
</xsl:template>
 
474
 
 
475
<xsl:template name="make_number">
 
476
  <xsl:choose>
 
477
    <xsl:when test="@text:level='1'">
 
478
      <xsl:number format="1. " />
 
479
    </xsl:when>
 
480
    <xsl:when test="@text:level='2'">
 
481
      <xsl:number count="text:h[@text:level='1']|text:h[text:level='2']" level="any" format="1.1." />
 
482
    </xsl:when>
 
483
  </xsl:choose>
 
484
</xsl:template>
 
485
 
 
486
-->
 
487
 
 
488
<xsl:template match="style:style[@style:family='paragraph']">
 
489
  <paraStyle>
 
490
    <xsl:attribute name="name">
 
491
      <xsl:value-of select="@style:name" />
 
492
    </xsl:attribute>
 
493
    <xsl:call-template name="make_indent_paragraph" />
 
494
    <xsl:call-template name="make_fontnames_paragraph" />
 
495
    <xsl:call-template name="make_fontsize" />
 
496
    <!--<xsl:call-template name="make_parent" /> not necessary -
 
497
         parent styles processed by PyOpenOffice -->
 
498
    <xsl:call-template name="make_alignment" />
 
499
    <xsl:call-template name="make_background" />
 
500
    <xsl:call-template name="make_space_beforeafter" />
 
501
    <xsl:call-template name="make_fontcolor" />
 
502
  </paraStyle>
 
503
</xsl:template>
 
504
 
 
505
<xsl:template name="make_indent_paragraph">
 
506
  <xsl:variable name="right_indent"><xsl:value-of select="style:properties/@fo:margin-right" /></xsl:variable>
 
507
  <xsl:variable name="left_indent"><xsl:value-of select="style:properties/@fo:margin-left" /></xsl:variable>
 
508
  <xsl:if test="not($right_indent='') and boolean(style:properties/@fo:margin-right)">
 
509
    <xsl:attribute name="rightIndent">
 
510
      <xsl:value-of select="$right_indent" />
 
511
    </xsl:attribute>
 
512
  </xsl:if>
 
513
  <xsl:if test="not($left_indent='') and boolean(style:properties/@fo:margin-left)">
 
514
    <xsl:attribute name="leftIndent">
 
515
      <xsl:value-of select="$left_indent" />
 
516
    </xsl:attribute>
 
517
  </xsl:if>
 
518
</xsl:template>
 
519
 
 
520
<xsl:template name="make_background">
 
521
  <xsl:variable name="background">
 
522
    <xsl:value-of select="style:properties/@fo:background-color" />
 
523
  </xsl:variable>
 
524
  <xsl:if test="not($background='') and boolean(style:properties/@fo:background-color) and starts-with($background,'#')" >
 
525
    <xsl:attribute name="backColor">
 
526
      <xsl:value-of select="$background" />
 
527
    </xsl:attribute>
 
528
  </xsl:if>
 
529
</xsl:template>
 
530
 
 
531
<xsl:template name="make_space_beforeafter">
 
532
  <xsl:variable name="before">
 
533
    <xsl:value-of select="style:properties/@fo:margin-top" />
 
534
  </xsl:variable>
 
535
  <xsl:variable name="after">
 
536
    <xsl:value-of select="style:properties/@fo:margin-bottom" />
 
537
  </xsl:variable>
 
538
  <xsl:if test="not($before='') and boolean(style:properties/@fo:margin-top)" >
 
539
    <xsl:attribute name="spaceBefore">
 
540
      <xsl:value-of select="$before" />
 
541
    </xsl:attribute>
 
542
  </xsl:if>
 
543
  <xsl:if test="not($after='') and boolean(style:properties/@fo:margin-bottom)" >
 
544
    <xsl:attribute name="spaceAfter">
 
545
      <xsl:value-of select="$after" />
 
546
    </xsl:attribute>
 
547
  </xsl:if>
 
548
</xsl:template>
 
549
 
 
550
<xsl:template name="make_fontsize">
 
551
  <xsl:variable name="fontSize">
 
552
    <xsl:value-of select="style:properties/@fo:font-size" />
 
553
  </xsl:variable>
 
554
  <xsl:if test="not($fontSize='') and boolean(style:properties/@fo:font-size)">
 
555
    <xsl:attribute name="fontSize">
 
556
      <xsl:value-of select="$fontSize" />
 
557
    </xsl:attribute>
 
558
    <xsl:attribute name="leading">
 
559
      <xsl:value-of select="$fontSize + floor($fontSize div 5) + 1" />
 
560
      <!--use a standard leading related to the font size -->
 
561
    </xsl:attribute>
 
562
  </xsl:if>
 
563
</xsl:template>
 
564
 
 
565
<!--this template is not needed anymore for "normalized" sxw files -->
 
566
<xsl:template name="make_parent">
 
567
  <xsl:variable name="parent">
 
568
    <xsl:value-of select="@style:parent-style-name" />
 
569
  </xsl:variable>
 
570
  <xsl:if test="not($parent='') and boolean(@style:parent-style-name)">
 
571
    <xsl:attribute name="parent">
 
572
      <xsl:value-of select="$parent" />
 
573
    </xsl:attribute>
 
574
  </xsl:if>
 
575
</xsl:template>
 
576
 
 
577
<xsl:template name="make_alignment">
 
578
  <xsl:variable name="alignment">
 
579
    <xsl:value-of select="style:properties/@fo:text-align" />
 
580
  </xsl:variable>
 
581
  <xsl:if test="not($alignment='') and boolean(style:properties/@fo:text-align)">
 
582
    <xsl:choose>
 
583
      <xsl:when test="$alignment='start'">
 
584
        <xsl:attribute name="alignment">LEFT</xsl:attribute>
 
585
      </xsl:when>
 
586
      <xsl:when test="$alignment='center'">
 
587
        <xsl:attribute name="alignment">CENTER</xsl:attribute>
 
588
      </xsl:when>
 
589
      <xsl:when test="$alignment='end'">
 
590
        <xsl:attribute name="alignment">RIGHT</xsl:attribute>
 
591
      </xsl:when>
 
592
      <xsl:when test="$alignment='justify'">
 
593
        <xsl:attribute name="alignment">JUSTIFY</xsl:attribute>
 
594
      </xsl:when>
 
595
    </xsl:choose>
 
596
  </xsl:if>
 
597
</xsl:template>
 
598
 
 
599
<xsl:template name="make_fontnames_paragraph">
 
600
  <xsl:attribute name="fontName">
 
601
    <xsl:call-template name="make_fontnames">
 
602
      <xsl:with-param name="fontName" select="style:properties/@style:font-name" />
 
603
      <xsl:with-param name="fontWeight" select="style:properties/@fo:font-weight" />
 
604
      <xsl:with-param name="fontStyle" select="style:properties/@fo:font-style" />
 
605
    </xsl:call-template>
 
606
  </xsl:attribute>
 
607
</xsl:template>
 
608
 
 
609
<xsl:template name="make_fontnames">
 
610
  <!--much too verbose, needs improvement-->
 
611
<xsl:param name="fontName" />
 
612
<xsl:param name="fontWeight" />
 
613
<xsl:param name="fontStyle" />
 
614
<xsl:choose>
 
615
<xsl:when test="not($fontName='') and boolean($fontName)">
 
616
  <xsl:choose>
 
617
    <xsl:when test="contains($fontName,'Courier')">
 
618
      <xsl:choose>
 
619
        <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')">
 
620
          <xsl:text>Courier-BoldOblique</xsl:text>
 
621
        </xsl:when>
 
622
        <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')">
 
623
          <xsl:text>Courier-Bold</xsl:text>
 
624
        </xsl:when>
 
625
        <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')">
 
626
          <xsl:text>Courier-Oblique</xsl:text>
 
627
        </xsl:when>
 
628
        <xsl:otherwise>
 
629
          <xsl:text>Courier</xsl:text>
 
630
        </xsl:otherwise>
 
631
      </xsl:choose>
 
632
    </xsl:when>
 
633
    <xsl:when test="contains($fontName,'Helvetica') or contains($fontName,'Arial') or contains($fontName,'Sans')">
 
634
      <xsl:choose>
 
635
        <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')">
 
636
          <xsl:text>Helvetica-BoldOblique</xsl:text>
 
637
        </xsl:when>
 
638
        <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')">
 
639
          <xsl:text>Helvetica-Bold</xsl:text>
 
640
        </xsl:when>
 
641
        <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')">
 
642
          <xsl:text>Helvetica-Oblique</xsl:text>
 
643
        </xsl:when>
 
644
        <xsl:otherwise>
 
645
          <xsl:text>Helvetica</xsl:text>
 
646
        </xsl:otherwise>
 
647
      </xsl:choose>
 
648
    </xsl:when>
 
649
    <xsl:otherwise>
 
650
      <xsl:choose>
 
651
        <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')">
 
652
          <xsl:text>Times-BoldItalic</xsl:text>
 
653
        </xsl:when>
 
654
        <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')">
 
655
          <xsl:text>Times-Bold</xsl:text>
 
656
        </xsl:when>
 
657
        <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')">
 
658
          <xsl:text>Times-Italic</xsl:text>
 
659
        </xsl:when>
 
660
        <xsl:otherwise>
 
661
          <xsl:text>Times-Roman</xsl:text>
 
662
        </xsl:otherwise>
 
663
      </xsl:choose>
 
664
    </xsl:otherwise>
 
665
  </xsl:choose>
 
666
</xsl:when>
 
667
<xsl:otherwise>
 
668
  <!--Use this as default -->
 
669
  <xsl:text>Times-Roman</xsl:text>
 
670
</xsl:otherwise>
 
671
</xsl:choose>
 
672
</xsl:template>
 
673
 
 
674
<xsl:template name="make_fontcolor">
 
675
  <xsl:variable name="textColor">
 
676
    <xsl:value-of select="style:properties/@fo:color"/>
 
677
  </xsl:variable>
 
678
  <xsl:if test="not($textColor='') and boolean(style:properties/@fo:color)">
 
679
  <xsl:attribute name="textColor">
 
680
      <xsl:value-of select="$textColor" />
 
681
   </xsl:attribute>
 
682
  </xsl:if>
 
683
</xsl:template>
 
684
 
 
685
<!--
 
686
This stylesheet is part of:
 
687
PyOpenOffice Version 0.4
 
688
Copyright (C) 2005: Martin Simon
 
689
Homepage: www.bezirksreiter.de
 
690
 
 
691
GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999
 
692
-->
 
693
 
 
694
</xsl:stylesheet>
 
695
 
 
696