summaryrefslogtreecommitdiffstats
path: root/officecfg/registry/cppheader.xsl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /officecfg/registry/cppheader.xsl
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--officecfg/registry/cppheader.xsl271
1 files changed, 271 insertions, 0 deletions
diff --git a/officecfg/registry/cppheader.xsl b/officecfg/registry/cppheader.xsl
new file mode 100644
index 000000000..2cabcf330
--- /dev/null
+++ b/officecfg/registry/cppheader.xsl
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+
+<!-- Generate a .hxx file with type-safe C++ abstractions (based on
+ comphelper/configuration.hxx) for all the <prop> and <set> elements in an
+ .xcs file.
+
+ Takes up to three parameters ns1, ns2, ns3 that represent the .xcs file's
+ nesting within the org/openoffice hierarchy (e.g., for
+ officecfg/registry/schema/org/openoffice/Office/Common.xcs, ns1 would be
+ "Office", ns2 would be "Common", and ns3 would remain unset.
+
+ TODO: Does not yet handle <node-ref> indirections (as, e.g., used in
+ officecfg/registry/schema/org/openoffice/Office/Common.xcs as
+ "ApplicationControlLayout"). Also, the available abstractions can still be
+ improved (e.g., for extensible groups or for set element types).
+-->
+
+<xsl:stylesheet
+ version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:oor="http://openoffice.org/2001/registry">
+ <xsl:param name="ns1"/>
+ <xsl:param name="ns2"/>
+ <xsl:param name="ns3"/>
+ <xsl:output method="text"/>
+
+ <xsl:template match="/oor:component-schema">
+ <xsl:apply-templates select="component">
+ <xsl:with-param name="path">
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="@oor:package"/>
+ <xsl:text>.</xsl:text>
+ <xsl:value-of select="@oor:name"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="component">
+ <xsl:param name="path"/>
+ <xsl:text>#ifndef INCLUDED_OFFICECFG_</xsl:text>
+ <xsl:value-of
+ select="translate($ns1, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ <xsl:if test="$ns2">
+ <xsl:text>_</xsl:text>
+ <xsl:value-of
+ select="translate($ns2, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ <xsl:if test="$ns3">
+ <xsl:text>_</xsl:text>
+ <xsl:value-of
+ select="translate($ns3, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:text>_HXX&#xA;</xsl:text>
+ <xsl:text>#define INCLUDED_OFFICECFG_</xsl:text>
+ <xsl:value-of
+ select="translate($ns1, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ <xsl:if test="$ns2">
+ <xsl:text>_</xsl:text>
+ <xsl:value-of
+ select="translate($ns2, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ <xsl:if test="$ns3">
+ <xsl:text>_</xsl:text>
+ <xsl:value-of
+ select="translate($ns3, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:text>_HXX&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ <xsl:text>#include "sal/config.h"&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ <xsl:if test=".//prop or .//set">
+ <xsl:if
+ test=".//prop[count(@oor:nillable) = 0 or @oor:nillable = 'true']">
+ <xsl:text>#include &lt;optional&gt;&#xA;</xsl:text>
+ </xsl:if>
+ <xsl:if test=".//prop/@oor:type = 'oor:any'">
+ <xsl:text>#include "com/sun/star/uno/Any.hxx"&#xA;</xsl:text>
+ </xsl:if>
+ <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'">
+ <xsl:text>#include "com/sun/star/uno/Sequence.hxx"&#xA;</xsl:text>
+ </xsl:if>
+ <xsl:text>#include "rtl/ustring.h"&#xA;</xsl:text>
+ <xsl:text>#include "rtl/ustring.hxx"&#xA;</xsl:text>
+ <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'">
+ <xsl:text>#include "sal/types.h"&#xA;</xsl:text>
+ </xsl:if>
+ <xsl:text>#include "comphelper/configuration.hxx"&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ <xsl:text>namespace officecfg { namespace </xsl:text>
+ <xsl:value-of select="$ns1"/>
+ <xsl:if test="$ns2">
+ <xsl:text> { namespace </xsl:text>
+ <xsl:value-of select="$ns2"/>
+ <xsl:if test="$ns3">
+ <xsl:text> { namespace </xsl:text>
+ <xsl:value-of select="$ns3"/>
+ </xsl:if>
+ </xsl:if>
+ <xsl:text> {&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ <xsl:apply-templates select="group|set|prop">
+ <xsl:with-param name="path" select="$path"/>
+ </xsl:apply-templates>
+ <xsl:if test="$ns2">
+ <xsl:text>} </xsl:text>
+ <xsl:if test="$ns3">
+ <xsl:text>} </xsl:text>
+ </xsl:if>
+ </xsl:if>
+ <xsl:text>} }&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ </xsl:if>
+ <xsl:text>#endif&#xA;</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="group">
+ <xsl:param name="path"/>
+ <xsl:if test=".//prop or .//set">
+ <xsl:variable name="name" select="translate(@oor:name, '-.', '__')"/>
+ <xsl:text>struct </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>: public comphelper::ConfigurationGroup&lt; </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>&gt; {&#xA;</xsl:text>
+ <xsl:text> static OUString path() { return OUString(<!--
+ -->"</xsl:text>
+ <xsl:value-of select="$path"/>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="@oor:name"/>
+ <xsl:text>"); }&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ <xsl:apply-templates select="group|set|prop">
+ <xsl:with-param name="path">
+ <xsl:value-of select="$path"/>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="@oor:name"/>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ <xsl:text>private:&#xA;</xsl:text>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined&#xA;</xsl:text>
+ <xsl:text> ~</xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined&#xA;</xsl:text>
+ <xsl:text>};&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="set">
+ <xsl:param name="path"/>
+ <xsl:variable name="name" select="translate(@oor:name, '-.', '__')"/>
+ <xsl:text>struct </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>: public comphelper::ConfigurationSet&lt; </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>&gt; {&#xA;</xsl:text>
+ <xsl:text> static OUString path() { return OUString(<!--
+ -->"</xsl:text>
+ <xsl:value-of select="$path"/>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="@oor:name"/>
+ <xsl:text>"); }&#xA;</xsl:text>
+ <xsl:text>private:&#xA;</xsl:text>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined&#xA;</xsl:text>
+ <xsl:text> ~</xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined&#xA;</xsl:text>
+ <xsl:text>};&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="prop">
+ <xsl:param name="path"/>
+ <xsl:variable name="name" select="translate(@oor:name, '-.', '__')"/>
+ <xsl:text>struct </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>: public comphelper::</xsl:text>
+ <xsl:choose>
+ <xsl:when test="@oor:localized = 'true'">
+ <xsl:text>ConfigurationLocalizedProperty</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>ConfigurationProperty</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>&lt;</xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>, </xsl:text>
+ <xsl:if test="not(@oor:nillable = 'false')">
+ <xsl:text>std::optional&lt;</xsl:text>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@oor:type='oor:any'">
+ <xsl:text>com::sun::star::uno::Any</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:boolean'">
+ <xsl:text>bool</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:short'">
+ <xsl:text>sal_Int16</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:int'">
+ <xsl:text>sal_Int32</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:long'">
+ <xsl:text>sal_Int64</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:double'">
+ <xsl:text>double</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:string'">
+ <xsl:text>OUString</xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='xs:hexBinary'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;sal_Int8&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:boolean-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;bool&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:short-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;sal_Int16&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:int-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;sal_Int32&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:long-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;sal_Int64&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:double-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;double&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:string-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;OUString&gt; </xsl:text>
+ </xsl:when>
+ <xsl:when test="@oor:type='oor:hexBinary-list'">
+ <xsl:text>com::sun::star::uno::Sequence&lt;<!--
+ -->com::sun::star::uno::Sequence&lt;sal_Int8&gt; &gt; </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:if test="not(@oor:nillable = 'false')">
+ <xsl:text>&gt; </xsl:text>
+ </xsl:if>
+ <xsl:text>&gt; {&#xA;</xsl:text>
+ <xsl:text> static OUString path() { return OUString(<!--
+ -->"</xsl:text>
+ <xsl:value-of select="$path"/>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="@oor:name"/>
+ <xsl:text>"); }&#xA;</xsl:text>
+ <xsl:text>private:&#xA;</xsl:text>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined&#xA;</xsl:text>
+ <xsl:text> ~</xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined&#xA;</xsl:text>
+ <xsl:text>};&#xA;</xsl:text>
+ <xsl:text>&#xA;</xsl:text>
+ </xsl:template>
+</xsl:stylesheet>