merge the formfield patch from ooo-build
[ooovba.git] / oovbaapi / genconstidl / oovbaconsts.xsl
blobe4bfc61d40c7eab8803e9f6b2b9b8ffb48763a73
1 <?xml version='1.0' encoding="UTF-8"?>
2 <!-- =====================================================================
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 Copyright 2008 by Sun Microsystems, Inc.
8 OpenOffice.org - a multi-platform office productivity suite
10 $RCSfile: oovbaconsts.xsl,v $
12 $Revision: 1.3 $
14 This file is part of OpenOffice.org.
16 OpenOffice.org is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License version 3
18 only, as published by the Free Software Foundation.
20 OpenOffice.org 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
23 GNU Lesser General Public License version 3 for more details
24 (a copy is included in the LICENSE file that accompanied this code).
26 You should have received a copy of the GNU Lesser General Public License
27 version 3 along with OpenOffice.org. If not, see
28 <http://www.openoffice.org/license.html>
29 for a copy of the LGPLv3 License.
31 ====================================================================== -->
32 <xsl:stylesheet version="1.0"
33 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
34 xmlns:redirect="http://xml.apache.org/xalan/redirect"
35 extension-element-prefixes="redirect">
36 <xsl:output method="text" indent="no" omit-xml-declaration="no" version="1.0" encoding="UTF-8" />
38 <!-- OPTIONAL: output directory for the IDL
39 Have to end with path separator -->
40 <xsl:param name="IDL_DIRECTORY" />
42 <xsl:key name="same-context-elements"
43 match="/api/element[@type='constant']"
44 use="normalize-space(source/context)" />
46 <xsl:template match="/">
47 <!-- once for each enumeration -->
48 <xsl:for-each select="/api/element[@type='enumeration']">
49 <xsl:sort select="normalize-space(source/name)" />
51 <redirect:write select="concat($IDL_DIRECTORY, normalize-space(source/name),'.idl')">
52 <xsl:call-template name="write-idl-prefix-1" />
53 <xsl:call-template name="write-idl-prefix-2" />
54 <!-- write IDL content -->
55 <xsl:for-each select="key('same-context-elements', normalize-space(source/name))">
56 <xsl:call-template name="write-idl-content" />
57 </xsl:for-each>
58 <xsl:call-template name="write-idl-suffix" />
59 </redirect:write>
60 </xsl:for-each>
61 </xsl:template>
64 <!-- writing the IDL prefix -->
65 <xsl:template name="write-idl-prefix-1">
66 <xsl:variable name="submod" select="source/@id"/>
67 <xsl:variable name="period" select="'.'"/>
68 <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
69 <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
70 <xsl:text>
71 module org { module openoffice { module </xsl:text><xsl:value-of select="translate(substring-before($submod,$period),$ucletters,$lcletters)"/>
72 </xsl:template>
73 <xsl:template name="write-idl-prefix-2">
74 <xsl:text> {
75 constants </xsl:text><xsl:value-of select="normalize-space(source/name)" /><xsl:text> {</xsl:text>
76 </xsl:template>
78 <!-- writing the IDL content -->
79 <xsl:template name="write-idl-content">
80 <xsl:text>
81 const long </xsl:text><xsl:value-of select="source/name" /><xsl:text> = </xsl:text><xsl:value-of select="source/value" /><xsl:text>;</xsl:text>
82 </xsl:template>
84 <!-- writing the IDL suffix -->
85 <xsl:template name="write-idl-suffix">
86 <xsl:text>
88 }; }; };
89 </xsl:text>
90 </xsl:template>
91 </xsl:stylesheet>