[ Index ] |
|
Code source de Horde 3.1.3 |
1 <!-- 2 3 The Contents of this file are made available subject to the terms of 4 either of the following licenses 5 6 - GNU Lesser General Public License Version 2.1 7 - Sun Industry Standards Source License Version 1.1 8 9 Sun Microsystems Inc., October, 2000 10 11 GNU Lesser General Public License Version 2.1 12 ============================================= 13 Copyright 2000 by Sun Microsystems, Inc. 14 901 San Antonio Road, Palo Alto, CA 94303, USA 15 16 This library is free software; you can redistribute it and/or 17 modify it under the terms of the GNU Lesser General Public 18 License version 2.1, as published by the Free Software Foundation. 19 20 This library is distributed in the hope that it will be useful, 21 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 Lesser General Public License for more details. 24 25 You should have received a copy of the GNU Lesser General Public 26 License along with this library; if not, write to the Free Software 27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, 28 MA 02111-1307 USA 29 30 31 Sun Industry Standards Source License Version 1.1 32 ================================================= 33 The contents of this file are subject to the Sun Industry Standards 34 Source License Version 1.1 (the "License"); You may not use this file 35 except in compliance with the License. You may obtain a copy of the 36 License at http://www.openoffice.org/license.html. 37 38 Software provided under this License is provided on an "AS IS" basis, 39 WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, 40 WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, 41 MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. 42 See the License for the specific provisions governing your rights and 43 obligations concerning the Software. 44 45 The Initial Developer of the Original Code is: Sun Microsystems, Inc. 46 47 Copyright © 2002 by Sun Microsystems, Inc. 48 49 All Rights Reserved. 50 51 Contributor(s): _______________________________________ 52 53 --> 54 <xsl:stylesheet version="1.0" 55 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 56 xmlns:office="http://openoffice.org/2000/office" 57 xmlns:style="http://openoffice.org/2000/style" 58 xmlns:text="http://openoffice.org/2000/text" 59 xmlns:table="http://openoffice.org/2000/table" 60 xmlns:draw="http://openoffice.org/2000/drawing" 61 xmlns:fo="http://www.w3.org/1999/XSL/Format" 62 xmlns:xlink="http://www.w3.org/1999/xlink" 63 xmlns:number="http://openoffice.org/2000/datastyle" 64 xmlns:svg="http://www.w3.org/2000/svg" 65 xmlns:chart="http://openoffice.org/2000/chart" 66 xmlns:dr3d="http://openoffice.org/2000/dr3d" 67 xmlns:math="http://www.w3.org/1998/Math/MathML" 68 xmlns:form="http://openoffice.org/2000/form" 69 xmlns:script="http://openoffice.org/2000/script" 70 office:class="text" 71 office:version="1.0" 72 xmlns:dc="http://purl.org/dc/elements/1.1/" 73 xmlns:meta="http://openoffice.org/2000/meta" 74 xmlns:config="http://openoffice.org/2001/config" 75 xmlns:help="http://openoffice.org/2000/help" 76 xmlns:xt="http://www.jclark.com/xt" 77 xmlns:system="http://www.jclark.com/xt/java/java.lang.System" 78 xmlns:xalan="http://xml.apache.org/xalan" 79 xmlns:java="http://xml.apache.org/xslt/java" 80 exclude-result-prefixes="java"> 81 82 83 84 <!-- ****************************** --> 85 <!-- *** style sheet processing *** --> 86 <!-- ****************************** --> 87 88 89 <xsl:template name='create-css-styleheader'> 90 <xsl:comment> 91 <xsl:text>The CSS style header method for setting styles</xsl:text> 92 </xsl:comment> 93 <xsl:element name="style"> 94 <xsl:attribute name="type">text/css</xsl:attribute> 95 <xsl:comment> 96 <xsl:text> 97 98 </xsl:text> 99 <xsl:call-template name="write-default-styles"/> 100 101 <!-- THE STYLE PROPERTIES OF THE FIRST WRITTEN STYLE (PARENT) IS GIVEN OUT --> 102 103 <!-- 1) styles from office:styles are possible parent from all (itself or office:automatic-styles). 104 Therefore they are created first. 105 Beginning with the top-level parents (the styles without any parent). --> 106 <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]"> 107 108 <xsl:call-template name="write-styleproperty-line"/> 109 <xsl:call-template name="write-styleproperty-lines-for-children"/> 110 </xsl:for-each> 111 112 <xsl:text> </xsl:text> 113 114 <!-- 2) styles from office:automatic-styles can only be parent of styles from the office:automatic-styles section. 115 Beginning with top-level styles, again, all children style will be recursivly traversed --> 116 <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]"> 117 <xsl:call-template name="write-styleproperty-line"> 118 <xsl:with-param name="searchOnlyInAutomaticStyles" select="true()"/> 119 </xsl:call-template> 120 <xsl:call-template name="write-styleproperty-lines-for-children"> 121 <xsl:with-param name="searchOnlyInAutomaticStyles"/> 122 </xsl:call-template> 123 </xsl:for-each> 124 //</xsl:comment> 125 </xsl:element> 126 </xsl:template> 127 128 129 <xsl:template name='write-styleproperty-line'> 130 <xsl:param name="searchOnlyInAutomaticStyles"/> 131 132 <xsl:variable name="styleProperties"> 133 <xsl:call-template name="write-style-properties"> 134 <xsl:with-param name="styleAttributePath" select="current()/style:properties/@*"/> 135 </xsl:call-template> 136 </xsl:variable> 137 138 <!-- do not write styles with no css property --> 139 <xsl:if test="not(string-length($styleProperties) = 0)"> 140 <!-- write out the name of the current (parent) style in the CSS headersection (e.g. "span.myStyle") --> 141 <xsl:call-template name="write-style-name"> 142 <xsl:with-param name="is-parent-style" select="true()"/> 143 </xsl:call-template> 144 145 <!-- the names of all styles children will be written out(office:style AND office:automatic-style) --> 146 <xsl:call-template name="write-children-style-names"> 147 <xsl:with-param name="parentStyleName" select="@style:name"/> 148 <xsl:with-param name="parentStyleFamily" select="@style:family"/> 149 <xsl:with-param name="searchOnlyInAutomaticStyles"/> 150 </xsl:call-template> 151 152 <!-- the style properties of the first written style (parent) is given out --> 153 <xsl:text> { 154 </xsl:text> 155 <xsl:value-of select="$styleProperties"/> 156 <xsl:text>} 157 </xsl:text> 158 159 </xsl:if> 160 161 162 163 </xsl:template> 164 165 166 167 168 <!-- RECURSION WITH ENDCONDITON: adding style classes for all existing childs --> 169 <xsl:template name='write-styleproperty-lines-for-children'> 170 <xsl:param name="searchOnlyInAutomaticStyles"/> 171 172 <xsl:variable name="parentStyleName" select="@style:name"/> 173 <xsl:variable name="parentStyleFamily" select="@style:family"/> 174 175 <xsl:if test="not(searchOnlyInAutomaticStyles)"> 176 <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]"> 177 <xsl:call-template name="write-styleproperty-line"/> 178 <xsl:call-template name="write-styleproperty-lines-for-children"/> 179 </xsl:for-each> 180 </xsl:if> 181 <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]"> 182 <xsl:call-template name="write-styleproperty-line"> 183 <xsl:with-param name="searchOnlyInAutomaticStyles"/> 184 </xsl:call-template> 185 <xsl:call-template name="write-styleproperty-lines-for-children"> 186 <xsl:with-param name="searchOnlyInAutomaticStyles"/> 187 </xsl:call-template> 188 </xsl:for-each> 189 </xsl:template> 190 191 192 <xsl:template name="write-default-styles"> 193 194 <!-- some default attributes in xml have to be explicitly set in HTML (e.g. margin-top="0") --> 195 <xsl:text>*.OOo_defaults</xsl:text> 196 197 <xsl:for-each select="$office:styles/style:style"> 198 <xsl:text>, </xsl:text> 199 <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/> 200 </xsl:for-each> 201 202 <xsl:for-each select="$office:automatic-styles/style:style"> 203 <xsl:text>, </xsl:text> 204 <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/> 205 </xsl:for-each> 206 <!-- 2DO: the defaults might be better collected and written in a separated (XML) file --> 207 <xsl:text> { 208 margin-top:0cm; margin-bottom:0cm; } 209 </xsl:text> 210 211 <xsl:for-each select="$office:styles/style:default-style"> 212 <xsl:call-template name="write-default-style"/> 213 </xsl:for-each> 214 215 <xsl:for-each select="$office:automatic-styles/style:default-style"> 216 <xsl:call-template name="write-default-style"/> 217 </xsl:for-each> 218 219 </xsl:template> 220 221 222 223 <xsl:template name="write-default-style"> 224 <xsl:variable name="family-style" select="@style:family"/> 225 226 <!-- some default attributes for format families (e.g. graphics, paragraphs, etc.) written as style:default-style --> 227 <xsl:value-of select="concat('*.', translate($family-style, '. %()/\', ''), '_defaults')"/> 228 229 <xsl:for-each select="$office:styles/style:style[@style:family = $family-style]"> 230 <xsl:text>, </xsl:text> 231 <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/> 232 </xsl:for-each> 233 234 <xsl:for-each select="$office:automatic-styles/style:style[@style:family = $family-style]"> 235 <xsl:text>, </xsl:text> 236 <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/> 237 </xsl:for-each> 238 239 240 <xsl:variable name="styleProperties"> 241 <xsl:call-template name="write-style-properties"> 242 <xsl:with-param name="styleAttributePath" select="current()/style:properties/@*"/> 243 </xsl:call-template> 244 </xsl:variable> 245 246 <!-- do not write styles with no css property --> 247 <xsl:if test="not(string-length($styleProperties) = 0)"> 248 <!-- the style properties of the first written style (parent) is given out --> 249 <xsl:text> { 250 </xsl:text> 251 <xsl:value-of select="$styleProperties"/> 252 <xsl:text>} 253 </xsl:text> 254 </xsl:if> 255 256 </xsl:template> 257 258 259 <!--++ 260 The parent style will be written out! 261 For each Style:family a prefix must be added 262 <!ENTITY % styleFamily 263 "(paragraph|text|section|table|table-column|table-row|table-cell|table-page|chart|graphics|default|drawing-page|presentation|control)"> 264 ++--> 265 <xsl:template name="write-style-name"> 266 <xsl:param name="is-parent-style"/> 267 268 <!-- This construct is for list elements. Whenever a paragraph element is being used as child of a list element the name paragraph style is been used for 269 the list item. This can be switched as the paragaph style-name and the list-style-name are in the same element. 270 Otherwise there would be formatting errors (e.g. margin-left will be used for the content in the list elment and not for the list element itself). --> 271 <xsl:variable name="style-name"> 272 <xsl:choose> 273 <xsl:when test="@style:list-style-name"> 274 <xsl:value-of select="@style:list-style-name"/> 275 </xsl:when> 276 <xsl:otherwise> 277 <xsl:value-of select="@style:name"/> 278 </xsl:otherwise> 279 </xsl:choose> 280 </xsl:variable> 281 282 <xsl:if test="not($is-parent-style)"> 283 <xsl:text>, </xsl:text> 284 </xsl:if> 285 286 <xsl:choose> 287 <!-- normally 'p.' would be used as CSS element, 288 but header (h1, h2,...) are also from the style:family paragraph --> 289 <xsl:when test="@style:family='paragraph'"> 290 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 291 </xsl:when> 292 <xsl:when test="@style:family='text'"> 293 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 294 </xsl:when> 295 <xsl:when test="@style:family='section'"> 296 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 297 </xsl:when> 298 <xsl:when test="@style:family='table'"> 299 <xsl:value-of select="concat('table.', translate($style-name, '. %()/\', ''))"/> 300 </xsl:when> 301 <xsl:when test="@style:family='table-column'"> 302 <!-- as column styles have to be included as span styles AFTER the table (no two class attributes in TD allowed --> 303 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 304 </xsl:when> 305 <xsl:when test="@style:family='table-row'"> 306 <xsl:value-of select="concat('tr.', translate($style-name, '. %()/\', ''))"/> 307 </xsl:when> 308 <xsl:when test="@style:family='table-cell'"> 309 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 310 </xsl:when> 311 <xsl:when test="@style:family='table-page'"> 312 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 313 </xsl:when> 314 <xsl:when test="@style:family='chart'"> 315 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 316 </xsl:when> 317 <xsl:when test="@style:family='graphics'"> 318 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 319 </xsl:when> 320 <xsl:when test="@style:family='default'"> 321 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 322 </xsl:when> 323 <xsl:when test="@style:family='drawing-page'"> 324 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 325 </xsl:when> 326 <xsl:when test="@style:family='presentation'"> 327 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 328 </xsl:when> 329 <xsl:when test="@style:family='control'"> 330 <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/> 331 </xsl:when> 332 </xsl:choose> 333 </xsl:template> 334 335 336 <!-- finding all style child of a section and give their styleIdentifier to the output --> 337 <xsl:template name='write-children-style-names'> 338 <xsl:param name="parentStyleName" select="@style:name"/> 339 <xsl:param name="parentStyleFamily" select="@style:family"/> 340 <xsl:param name="searchOnlyInAutomaticStyles"/> 341 342 343 <!--** the names of all office:styles children will be written out 344 ** (a automatic style can only have children in the office:automatic-style section) --> 345 346 <!-- if NOT called from a office:automatic-style parent --> 347 <xsl:if test="not(searchOnlyInAutomaticStyles)"> 348 <!-- for all children in the office:style section --> 349 <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]"> 350 <!-- write the style name in the css header --> 351 <xsl:call-template name="write-style-name"/> 352 353 <!-- search for child styles --> 354 <xsl:call-template name="write-children-style-names"> 355 <xsl:with-param name="parentStyleName" select="@style:name"/> 356 <xsl:with-param name="parentStyleFamily" select="@style:family"/> 357 </xsl:call-template> 358 359 </xsl:for-each> 360 </xsl:if> 361 362 <!--** the names of all office:automatic-styles children will be written out --> 363 364 <!-- for all children in the office:automatic-style section --> 365 <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]"> 366 <!-- write the style name in the css header --> 367 <xsl:call-template name="write-style-name"/> 368 369 <!-- search for child styles --> 370 <xsl:call-template name="write-children-style-names"> 371 <xsl:with-param name="parentStyleName" select="@style:name"/> 372 <xsl:with-param name="parentStyleFamily" select="@style:family"/> 373 <xsl:with-param name="searchOnlyInAutomaticStyles"/> 374 </xsl:call-template> 375 376 </xsl:for-each> 377 </xsl:template> 378 379 </xsl:stylesheet>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |