diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-12-13 12:37:00 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-12-13 12:50:34 +0100 |
commit | bcdea3b379637a98e5bbc304078149ca6c2b6e03 (patch) | |
tree | a3803df980a54ab1a03c740c3114a54ca7d12f27 /officecfg | |
parent | ddf1cf333174777e7923aa0d6126daf2c8645fed (diff) |
Simplified, type-safe C++ configuration access.
* New offapi com.sun.star.configuration entities to access the complete
configuration read-only or read/write...
* ...configmgr adapted to support those new services/singletons...
* ...new unotools/configuration.hxx is the type-safe C++ plumbing on top of
that...
* ...officecfg now generates C++ headers to access all the properties and sets
given in the .xcs files...
* ...and svl's asiancfg.cxx exemplarily makes use of the new
officecfg/Office/Common.hxx to access the configuration.
* There is still TODOs: For one, see those listed in
officecfg/registry/cppheader.xsl. For another, at least a notification
mechanism for the new read-only configuration access and the C++ wrapper is
missing.
Diffstat (limited to 'officecfg')
-rw-r--r-- | officecfg/Module_officecfg.mk | 1 | ||||
-rw-r--r-- | officecfg/Package_cppheader.mk | 45 | ||||
-rw-r--r-- | officecfg/registry/Makefile | 56 | ||||
-rw-r--r-- | officecfg/registry/cppheader.xsl | 275 | ||||
-rw-r--r-- | officecfg/registry/files.mk | 100 |
5 files changed, 477 insertions, 0 deletions
diff --git a/officecfg/Module_officecfg.mk b/officecfg/Module_officecfg.mk index 22d91c9692bc..6db580498ba3 100644 --- a/officecfg/Module_officecfg.mk +++ b/officecfg/Module_officecfg.mk @@ -20,6 +20,7 @@ $(eval $(call gb_Module_Module,officecfg)) $(eval $(call gb_Module_add_targets,officecfg,\ + Package_cppheader \ Package_misc \ Package_tools \ Configuration_officecfg \ diff --git a/officecfg/Package_cppheader.mk b/officecfg/Package_cppheader.mk new file mode 100644 index 000000000000..b90102b2168d --- /dev/null +++ b/officecfg/Package_cppheader.mk @@ -0,0 +1,45 @@ +## +## Version: MPL 1.1 / GPLv3+ / LGPLv3+ +## +## The contents of this file are subject to the Mozilla Public License Version +## 1.1 (the "License"); you may not use this file except in compliance with +## the License or as specified alternatively below. You may obtain a copy of +## the License at http://www.mozilla.org/MPL/ +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +## for the specific language governing rights and limitations under the +## License. +## +## Major Contributor(s): +## Copyright (C) 2011 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> +## (initial developer) +## +## All Rights Reserved. +## +## For minor contributions see the git repository. +## +## Alternatively, the contents of this file may be used under the terms of +## either the GNU General Public License Version 3 or later (the "GPLv3+"), or +## the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +## in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +## instead of those above. +## + +include $(SRCDIR)/officecfg/registry/files.mk + +$(eval $(call gb_Package_Package,officecfg_cppheader,$(WORKDIR)/CustomTarget/officecfg/registry)) + +$(eval $(call \ + gb_Package_add_customtarget,officecfg_cppheader,officecfg/registry)) + +$(eval $(call gb_CustomTarget_add_outdir_dependencies,officecfg/registry, \ + $(gb_XSLTPROCTARGET) \ +)) + +$(eval $(call gb_CustomTarget_add_dependencies,officecfg/registry, \ + officecfg/registry/cppheader.xsl \ + $(foreach i,$(FILES),officecfg/registry/schema/org/openoffice/$(i).xcs))) + +$(eval $(foreach i,$(FILES),$(call \ + gb_Package_add_file,officecfg_cppheader,inc/officecfg/$(i).hxx,$(i).hxx))) diff --git a/officecfg/registry/Makefile b/officecfg/registry/Makefile new file mode 100644 index 000000000000..3f748f0d0959 --- /dev/null +++ b/officecfg/registry/Makefile @@ -0,0 +1,56 @@ +## +## Version: MPL 1.1 / GPLv3+ / LGPLv3+ +## +## The contents of this file are subject to the Mozilla Public License Version +## 1.1 (the "License"); you may not use this file except in compliance with +## the License or as specified alternatively below. You may obtain a copy of +## the License at http://www.mozilla.org/MPL/ +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +## for the specific language governing rights and limitations under the +## License. +## +## Major Contributor(s): +## Copyright (C) 2011 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> +## (initial developer) +## +## All Rights Reserved. +## +## For minor contributions see the git repository. +## +## Alternatively, the contents of this file may be used under the terms of +## either the GNU General Public License Version 3 or later (the "GPLv3+"), or +## the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +## in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +## instead of those above. +## + +WFDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) +gb_PARTIALBUILD := T +include $(GBUILDDIR)/gbuild_simple.mk +include $(WFDIR)/files.mk + +.DEFAULT_GOAL := all +.PHONY: all +all: $(foreach i,$(FILES),$(i).hxx) + +define my_target +$(if $(1),$(1)/$(if $(2),$(2)/))%.hxx: \ + $(WFDIR)/schema/org/openoffice/$(if $(1),$(1)/$(if $(2),$(2)/))%.xcs \ + $(WFDIR)/cppheader.xsl + $$(call gb_Helper_abbreviate_dirs_native, \ + $$(gb_XSLTPROC) --nonet --stringparam ns1 \ + $(if $(1), \ + $(1) --stringparam ns2 $(if $(2),$(2) --stringparam ns3)) $$* \ + -o $$@ $$(WFDIR)/cppheader.xsl $$<) + +endef + +$(eval $(call my_target)) +$(eval $(call my_target,Office)) +$(eval $(call my_target,Office,DataAccess)) +$(eval $(call my_target,Office,OOoImprovement)) +$(eval $(call my_target,Office,UI)) +$(eval $(call my_target,TypeDetection)) +$(eval $(call my_target,ucb)) diff --git a/officecfg/registry/cppheader.xsl b/officecfg/registry/cppheader.xsl new file mode 100644 index 000000000000..2f8141d2ba70 --- /dev/null +++ b/officecfg/registry/cppheader.xsl @@ -0,0 +1,275 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> + * (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. +--> + +<!-- Generate a .hxx file with type-safe C++ abstractions (based on + unotools/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
</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
</xsl:text> + <xsl:text>
</xsl:text> + <xsl:text>#include "sal/config.h"
</xsl:text> + <xsl:text>
</xsl:text> + <xsl:if test=".//prop/@oor:nillable = 'true'"> + <xsl:text>#include "boost/optional.hpp"
</xsl:text> + </xsl:if> + <xsl:if test=".//prop/@oor:type = 'oor:any'"> + <xsl:text>#include "com/sun/star/uno/Any.hxx"
</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"
</xsl:text> + </xsl:if> + <xsl:if test=".//prop or .//set"> + <xsl:text>#include "rtl/ustring.h"
</xsl:text> + <xsl:text>#include "rtl/ustring.hxx"
</xsl:text> + </xsl:if> + <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"
</xsl:text> + </xsl:if> + <xsl:if test=".//prop or .//set"> + <xsl:text>#include "unotools/configuration.hxx"
</xsl:text> + </xsl:if> + <xsl:text>
</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> {
</xsl:text> + <xsl:text>
</xsl:text> + <xsl:apply-templates select="group"> + <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>} }
</xsl:text> + <xsl:text>
</xsl:text> + <xsl:text>#endif
</xsl:text> + </xsl:template> + + <xsl:template match="group"> + <xsl:param name="path"/> + <xsl:if test=".//prop or .//set"> + <xsl:text>namespace </xsl:text> + <xsl:value-of select="translate(@oor:name, '-', '_')"/> + <xsl:text> {
</xsl:text> + <xsl:text>
</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>}
</xsl:text> + <xsl:text>
</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 unotools::ConfigurationSet< </xsl:text> + <xsl:value-of select="$name"/> + <xsl:text>> {
</xsl:text> + <xsl:text> static rtl::OUString path() { return rtl::OUString(<!-- + -->RTL_CONSTASCII_USTRINGPARAM("</xsl:text> + <xsl:value-of select="$path"/> + <xsl:text>/</xsl:text> + <xsl:value-of select="@oor:name"/> + <xsl:text>")); }
</xsl:text> + <xsl:text>private:
</xsl:text> + <xsl:text> </xsl:text> + <xsl:value-of select="$name"/> + <xsl:text>(); // not defined
</xsl:text> + <xsl:text> ~</xsl:text> + <xsl:value-of select="$name"/> + <xsl:text>(); // not defined
</xsl:text> + <xsl:text>};
</xsl:text> + <xsl:text>
</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 unotools::</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><</xsl:text> + <xsl:value-of select="$name"/> + <xsl:text>, </xsl:text> + <xsl:if test="@oor:nillable = 'true'"> + <xsl:text>boost::optional<</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>rtl::OUString</xsl:text> + </xsl:when> + <xsl:when test="@oor:type='xs:hexBinary'"> + <xsl:text>com::sun::star::uno::Sequence<sal_Int8> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:boolean-list'"> + <xsl:text>com::sun::star::uno::Sequence<bool> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:short-list'"> + <xsl:text>com::sun::star::uno::Sequence<sal_Int16> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:int-list'"> + <xsl:text>com::sun::star::uno::Sequence<sal_Int32> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:long-list'"> + <xsl:text>com::sun::star::uno::Sequence<sal_Int64> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:double-list'"> + <xsl:text>com::sun::star::uno::Sequence<double> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:string-list'"> + <xsl:text>com::sun::star::uno::Sequence<rtl::OUString> </xsl:text> + </xsl:when> + <xsl:when test="@oor:type='oor:hexBinary-list'"> + <xsl:text>com::sun::star::uno::Sequence<<!-- + -->com::sun::star::uno::Sequence<sal_Int8> > </xsl:text> + </xsl:when> + </xsl:choose> + <xsl:if test="@oor:nillable = 'true'"> + <xsl:text>> </xsl:text> + </xsl:if> + <xsl:text>> {
</xsl:text> + <xsl:text> static rtl::OUString path() { return rtl::OUString(<!-- + -->RTL_CONSTASCII_USTRINGPARAM("</xsl:text> + <xsl:value-of select="$path"/> + <xsl:text>/</xsl:text> + <xsl:value-of select="@oor:name"/> + <xsl:text>")); }
</xsl:text> + <xsl:text>private:
</xsl:text> + <xsl:text> </xsl:text> + <xsl:value-of select="$name"/> + <xsl:text>(); // not defined
</xsl:text> + <xsl:text> ~</xsl:text> + <xsl:value-of select="$name"/> + <xsl:text>(); // not defined
</xsl:text> + <xsl:text>};
</xsl:text> + <xsl:text>
</xsl:text> + </xsl:template> +</xsl:stylesheet> diff --git a/officecfg/registry/files.mk b/officecfg/registry/files.mk new file mode 100644 index 000000000000..f4c72d7b9437 --- /dev/null +++ b/officecfg/registry/files.mk @@ -0,0 +1,100 @@ +FILES = \ + FirstStartWizard \ + Inet \ + Interaction \ + LDAP \ + Office/Accelerators \ + Office/Addons \ + Office/Calc \ + Office/CalcAddIns \ + Office/Canvas \ + Office/Chart \ + Office/Commands \ + Office/Common \ + Office/Compatibility \ + Office/DataAccess \ + Office/DataAccess/Drivers \ + Office/Draw \ + Office/Embedding \ + Office/Events \ + Office/ExtendedColorScheme \ + Office/ExtensionManager \ + Office/FormWizard \ + Office/Histories \ + Office/Impress \ + Office/Java \ + Office/Jobs \ + Office/Labels \ + Office/Linguistic \ + Office/Logging \ + Office/Math \ + Office/OOoImprovement/Settings \ + Office/OptionsDialog \ + Office/Paths \ + Office/ProtocolHandler \ + Office/Recovery \ + Office/SFX \ + Office/Scripting \ + Office/Security \ + Office/Substitution \ + Office/TabBrowse \ + Office/TableWizard \ + Office/TypeDetection \ + Office/UI \ + Office/UI/BaseWindowState \ + Office/UI/BasicIDECommands \ + Office/UI/BasicIDEWindowState \ + Office/UI/BibliographyCommands \ + Office/UI/BibliographyWindowState \ + Office/UI/CalcCommands \ + Office/UI/CalcWindowState \ + Office/UI/Category \ + Office/UI/ChartCommands \ + Office/UI/ChartWindowState \ + Office/UI/Commands \ + Office/UI/Controller \ + Office/UI/DbBrowserWindowState \ + Office/UI/DbQueryWindowState \ + Office/UI/DbRelationWindowState \ + Office/UI/DbTableDataWindowState \ + Office/UI/DbTableWindowState \ + Office/UI/DbuCommands \ + Office/UI/DrawImpressCommands \ + Office/UI/DrawWindowState \ + Office/UI/Effects \ + Office/UI/Factories \ + Office/UI/GenericCategories \ + Office/UI/GenericCommands \ + Office/UI/GlobalSettings \ + Office/UI/ImpressWindowState \ + Office/UI/MathCommands \ + Office/UI/MathWindowState \ + Office/UI/StartModuleCommands \ + Office/UI/StartModuleWindowState \ + Office/UI/WindowContentFactories \ + Office/UI/WindowState \ + Office/UI/WriterCommands \ + Office/UI/WriterFormWindowState \ + Office/UI/WriterGlobalWindowState \ + Office/UI/WriterReportWindowState \ + Office/UI/WriterWebWindowState \ + Office/UI/WriterWindowState \ + Office/UI/XFormsWindowState \ + Office/Views \ + Office/WebWizard \ + Office/Writer \ + Office/WriterWeb \ + Setup \ + System \ + TypeDetection/Filter \ + TypeDetection/GraphicFilter \ + TypeDetection/Misc \ + TypeDetection/Types \ + TypeDetection/UISort \ + UserProfile \ + VCL \ + ucb/Configuration \ + ucb/Hierarchy \ + ucb/InteractionHandler \ + ucb/Store \ + |