1 <?xml version=
"1.0" encoding=
"UTF-8"?>
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 <!-- Generate a .hxx file with type-safe C++ abstractions (based on
12 comphelper/configuration.hxx) for all the <prop> and <set> elements in an
15 Takes up to three parameters ns1, ns2, ns3 that represent the .xcs file's
16 nesting within the org/openoffice hierarchy (e.g., for
17 officecfg/registry/schema/org/openoffice/Office/Common.xcs, ns1 would be
18 "Office", ns2 would be "Common", and ns3 would remain unset.
20 TODO: Does not yet handle <node-ref> indirections (as, e.g., used in
21 officecfg/registry/schema/org/openoffice/Office/Common.xcs as
22 "ApplicationControlLayout"). Also, the available abstractions can still be
23 improved (e.g., for extensible groups or for set element types).
27 version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
28 xmlns:
oor=
"http://openoffice.org/2001/registry">
29 <xsl:param name=
"ns1"/>
30 <xsl:param name=
"ns2"/>
31 <xsl:param name=
"ns3"/>
32 <xsl:output method=
"text"/>
34 <xsl:template match=
"/oor:component-schema">
35 <xsl:apply-templates select=
"component">
36 <xsl:with-param name=
"path">
37 <xsl:text>/
</xsl:text>
38 <xsl:value-of select=
"@oor:package"/>
39 <xsl:text>.
</xsl:text>
40 <xsl:value-of select=
"@oor:name"/>
42 </xsl:apply-templates>
45 <xsl:template match=
"component">
46 <xsl:param name=
"path"/>
47 <xsl:text>#ifndef INCLUDED_OFFICECFG_
</xsl:text>
49 select=
"translate($ns1, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
51 <xsl:text>_
</xsl:text>
53 select=
"translate($ns2, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
55 <xsl:text>_
</xsl:text>
57 select=
"translate($ns3, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
60 <xsl:text>_HXX

</xsl:text>
61 <xsl:text>#define INCLUDED_OFFICECFG_
</xsl:text>
63 select=
"translate($ns1, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
65 <xsl:text>_
</xsl:text>
67 select=
"translate($ns2, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
69 <xsl:text>_
</xsl:text>
71 select=
"translate($ns3, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
74 <xsl:text>_HXX

</xsl:text>
75 <xsl:text>
</xsl:text>
76 <xsl:text>#include
"sal/config.h"
</xsl:text>
77 <xsl:text>
</xsl:text>
78 <xsl:if test=
".//prop or .//set">
80 test=
".//prop[count(@oor:nillable) = 0 or @oor:nillable = 'true']">
81 <xsl:text>#include
"o3tl/optional.hxx"
</xsl:text>
83 <xsl:if test=
".//prop/@oor:type = 'oor:any'">
84 <xsl:text>#include
"com/sun/star/uno/Any.hxx"
</xsl:text>
86 <xsl:if test=
".//prop/@oor:type = 'xs:hexBinary' or .//prop/@oor:type = 'oor:boolean-list' or .//prop/@oor:type = 'oor:short-list' or .//prop/@oor:type = 'oor:int-list' or .//prop/@oor:type = 'oor:long-list' or .//prop/@oor:type = 'oor:double-list' or .//prop/@oor:type = 'oor:string-list'">
87 <xsl:text>#include
"com/sun/star/uno/Sequence.hxx"
</xsl:text>
89 <xsl:text>#include
"rtl/ustring.h"
</xsl:text>
90 <xsl:text>#include
"rtl/ustring.hxx"
</xsl:text>
91 <xsl:if test=
".//prop/@oor:type = 'xs:short' or .//prop/@oor:type = 'xs:int' or .//prop/@oor:type = 'xs:long' or .//prop/@oor:type = 'xs:hexBinary'">
92 <xsl:text>#include
"sal/types.h"
</xsl:text>
94 <xsl:text>#include
"comphelper/configuration.hxx"
</xsl:text>
95 <xsl:text>
</xsl:text>
96 <xsl:text>namespace officecfg { namespace
</xsl:text>
97 <xsl:value-of select=
"$ns1"/>
99 <xsl:text> { namespace
</xsl:text>
100 <xsl:value-of select=
"$ns2"/>
102 <xsl:text> { namespace
</xsl:text>
103 <xsl:value-of select=
"$ns3"/>
106 <xsl:text> {

</xsl:text>
107 <xsl:text>
</xsl:text>
108 <xsl:apply-templates select=
"group|set|prop">
109 <xsl:with-param name=
"path" select=
"$path"/>
110 </xsl:apply-templates>
112 <xsl:text>}
</xsl:text>
114 <xsl:text>}
</xsl:text>
117 <xsl:text>} }

</xsl:text>
118 <xsl:text>
</xsl:text>
120 <xsl:text>#endif

</xsl:text>
123 <xsl:template match=
"group">
124 <xsl:param name=
"path"/>
125 <xsl:if test=
".//prop or .//set">
126 <xsl:variable name=
"name" select=
"translate(@oor:name, '-.', '__')"/>
127 <xsl:text>struct
</xsl:text>
128 <xsl:value-of select=
"$name"/>
129 <xsl:text>: public comphelper::ConfigurationGroup
< </xsl:text>
130 <xsl:value-of select=
"$name"/>
131 <xsl:text>> {

</xsl:text>
132 <xsl:text> static OUString path() { return OUString(
<!--
134 <xsl:value-of select="$path
"/>
135 <xsl:text>/</xsl:text>
136 <xsl:value-of select="@oor:name
"/>
137 <xsl:text>"); }

</xsl:text>
138 <xsl:text>
</xsl:text>
139 <xsl:apply-templates select=
"group|set|prop">
140 <xsl:with-param name=
"path">
141 <xsl:value-of select=
"$path"/>
142 <xsl:text>/
</xsl:text>
143 <xsl:value-of select=
"@oor:name"/>
145 </xsl:apply-templates>
146 <xsl:text>private:

</xsl:text>
147 <xsl:text> </xsl:text>
148 <xsl:value-of select=
"$name"/>
149 <xsl:text>(); // not defined

</xsl:text>
150 <xsl:text> ~
</xsl:text>
151 <xsl:value-of select=
"$name"/>
152 <xsl:text>(); // not defined

</xsl:text>
153 <xsl:text>};

</xsl:text>
154 <xsl:text>
</xsl:text>
158 <xsl:template match=
"set">
159 <xsl:param name=
"path"/>
160 <xsl:variable name=
"name" select=
"translate(@oor:name, '-.', '__')"/>
161 <xsl:text>struct
</xsl:text>
162 <xsl:value-of select=
"$name"/>
163 <xsl:text>: public comphelper::ConfigurationSet
< </xsl:text>
164 <xsl:value-of select=
"$name"/>
165 <xsl:text>> {

</xsl:text>
166 <xsl:text> static OUString path() { return OUString(
<!--
168 <xsl:value-of select="$path
"/>
169 <xsl:text>/</xsl:text>
170 <xsl:value-of select="@oor:name
"/>
171 <xsl:text>"); }

</xsl:text>
172 <xsl:text>private:

</xsl:text>
173 <xsl:text> </xsl:text>
174 <xsl:value-of select=
"$name"/>
175 <xsl:text>(); // not defined

</xsl:text>
176 <xsl:text> ~
</xsl:text>
177 <xsl:value-of select=
"$name"/>
178 <xsl:text>(); // not defined

</xsl:text>
179 <xsl:text>};

</xsl:text>
180 <xsl:text>
</xsl:text>
183 <xsl:template match=
"prop">
184 <xsl:param name=
"path"/>
185 <xsl:variable name=
"name" select=
"translate(@oor:name, '-.', '__')"/>
186 <xsl:text>struct
</xsl:text>
187 <xsl:value-of select=
"$name"/>
188 <xsl:text>: public comphelper::
</xsl:text>
190 <xsl:when test=
"@oor:localized = 'true'">
191 <xsl:text>ConfigurationLocalizedProperty
</xsl:text>
194 <xsl:text>ConfigurationProperty
</xsl:text>
197 <xsl:text><</xsl:text>
198 <xsl:value-of select=
"$name"/>
199 <xsl:text>,
</xsl:text>
200 <xsl:if test=
"not(@oor:nillable = 'false')">
201 <xsl:text>o3tl::optional
<</xsl:text>
204 <xsl:when test=
"@oor:type='oor:any'">
205 <xsl:text>com::sun::star::uno::Any
</xsl:text>
207 <xsl:when test=
"@oor:type='xs:boolean'">
208 <xsl:text>bool
</xsl:text>
210 <xsl:when test=
"@oor:type='xs:short'">
211 <xsl:text>sal_Int16
</xsl:text>
213 <xsl:when test=
"@oor:type='xs:int'">
214 <xsl:text>sal_Int32
</xsl:text>
216 <xsl:when test=
"@oor:type='xs:long'">
217 <xsl:text>sal_Int64
</xsl:text>
219 <xsl:when test=
"@oor:type='xs:double'">
220 <xsl:text>double
</xsl:text>
222 <xsl:when test=
"@oor:type='xs:string'">
223 <xsl:text>OUString
</xsl:text>
225 <xsl:when test=
"@oor:type='xs:hexBinary'">
226 <xsl:text>com::sun::star::uno::Sequence
<sal_Int8
> </xsl:text>
228 <xsl:when test=
"@oor:type='oor:boolean-list'">
229 <xsl:text>com::sun::star::uno::Sequence
<bool
> </xsl:text>
231 <xsl:when test=
"@oor:type='oor:short-list'">
232 <xsl:text>com::sun::star::uno::Sequence
<sal_Int16
> </xsl:text>
234 <xsl:when test=
"@oor:type='oor:int-list'">
235 <xsl:text>com::sun::star::uno::Sequence
<sal_Int32
> </xsl:text>
237 <xsl:when test=
"@oor:type='oor:long-list'">
238 <xsl:text>com::sun::star::uno::Sequence
<sal_Int64
> </xsl:text>
240 <xsl:when test=
"@oor:type='oor:double-list'">
241 <xsl:text>com::sun::star::uno::Sequence
<double
> </xsl:text>
243 <xsl:when test=
"@oor:type='oor:string-list'">
244 <xsl:text>com::sun::star::uno::Sequence
<OUString
> </xsl:text>
246 <xsl:when test=
"@oor:type='oor:hexBinary-list'">
247 <xsl:text>com::sun::star::uno::Sequence
<<!--
248 -->com::sun::star::uno::Sequence
<sal_Int8
> > </xsl:text>
251 <xsl:if test=
"not(@oor:nillable = 'false')">
252 <xsl:text>> </xsl:text>
254 <xsl:text>> {

</xsl:text>
255 <xsl:text> static OUString path() { return OUString(
<!--
257 <xsl:value-of select="$path
"/>
258 <xsl:text>/</xsl:text>
259 <xsl:value-of select="@oor:name
"/>
260 <xsl:text>"); }

</xsl:text>
261 <xsl:text>private:

</xsl:text>
262 <xsl:text> </xsl:text>
263 <xsl:value-of select=
"$name"/>
264 <xsl:text>(); // not defined

</xsl:text>
265 <xsl:text> ~
</xsl:text>
266 <xsl:value-of select=
"$name"/>
267 <xsl:text>(); // not defined

</xsl:text>
268 <xsl:text>};

</xsl:text>
269 <xsl:text>
</xsl:text>