Kaydet (Commit) d70aa23c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Add configuration wrappers for groups, too (to add listeners etc.).

üst 866df124
...@@ -141,9 +141,18 @@ ...@@ -141,9 +141,18 @@
<xsl:template match="group"> <xsl:template match="group">
<xsl:param name="path"/> <xsl:param name="path"/>
<xsl:if test=".//prop or .//set"> <xsl:if test=".//prop or .//set">
<xsl:text>namespace </xsl:text> <xsl:variable name="name" select="translate(@oor:name, '-.', '__')"/>
<xsl:value-of select="translate(@oor:name, '-.', '__')"/> <xsl:text>struct </xsl:text>
<xsl:text> {&#xA;</xsl:text> <xsl:value-of select="$name"/>
<xsl:text>: public unotools::ConfigurationGroup&lt; </xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>&gt; {&#xA;</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>")); }&#xA;</xsl:text>
<xsl:text>&#xA;</xsl:text> <xsl:text>&#xA;</xsl:text>
<xsl:apply-templates select="group|set|prop"> <xsl:apply-templates select="group|set|prop">
<xsl:with-param name="path"> <xsl:with-param name="path">
...@@ -152,7 +161,14 @@ ...@@ -152,7 +161,14 @@
<xsl:value-of select="@oor:name"/> <xsl:value-of select="@oor:name"/>
</xsl:with-param> </xsl:with-param>
</xsl:apply-templates> </xsl:apply-templates>
<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:text>&#xA;</xsl:text>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
......
...@@ -43,6 +43,7 @@ namespace com { namespace sun { namespace star { ...@@ -43,6 +43,7 @@ namespace com { namespace sun { namespace star {
namespace configuration { class XReadWriteAccess; } namespace configuration { class XReadWriteAccess; }
namespace container { namespace container {
class XHierarchicalNameAccess; class XHierarchicalNameAccess;
class XHierarchicalNameReplace;
class XNameAccess; class XNameAccess;
class XNameContainer; class XNameContainer;
} }
...@@ -80,6 +81,10 @@ private: ...@@ -80,6 +81,10 @@ private:
rtl::OUString const & path, com::sun::star::uno::Any const & value) rtl::OUString const & path, com::sun::star::uno::Any const & value)
const; const;
SAL_DLLPRIVATE com::sun::star::uno::Reference<
com::sun::star::container::XHierarchicalNameReplace >
getGroup(rtl::OUString const & path) const;
SAL_DLLPRIVATE SAL_DLLPRIVATE
com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >
getSet(rtl::OUString const & path) const; getSet(rtl::OUString const & path) const;
...@@ -120,6 +125,16 @@ public: ...@@ -120,6 +125,16 @@ public:
rtl::OUString const & path, com::sun::star::uno::Any const & value) rtl::OUString const & path, com::sun::star::uno::Any const & value)
const; const;
com::sun::star::uno::Reference<
com::sun::star::container::XHierarchicalNameAccess >
getGroupReadOnly(rtl::OUString const & path) const;
com::sun::star::uno::Reference<
com::sun::star::container::XHierarchicalNameReplace >
getGroupReadWrite(
boost::shared_ptr< ConfigurationChanges > const & batch,
rtl::OUString const & path) const;
com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >
getSetReadOnly(rtl::OUString const & path) const; getSetReadOnly(rtl::OUString const & path) const;
...@@ -230,6 +245,39 @@ private: ...@@ -230,6 +245,39 @@ private:
~ConfigurationLocalizedProperty(); // not defined ~ConfigurationLocalizedProperty(); // not defined
}; };
/// A type-safe wrapper around a configuration group.
///
/// Automatically generated headers for the various configuration groups derive
/// from this template and make available its member functions to access each
/// given configuration group.
template< typename T > struct ConfigurationGroup: private boost::noncopyable {
/// Get read-only access to the given configuration group.
static com::sun::star::uno::Reference<
com::sun::star::container::XHierarchicalNameAccess >
get(com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
const & context)
{
return detail::ConfigurationWrapper::get(context).getGroupReadOnly(
T::path());
}
/// Get read/write access to the given configuration group, storing any
/// modifications via the given changes batch.
static com::sun::star::uno::Reference<
com::sun::star::container::XHierarchicalNameReplace >
get(com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
const & context,
boost::shared_ptr< ConfigurationChanges > const & batch)
{
return detail::ConfigurationWrapper::get(context).getGroupReadWrite(
batch, T::path());
}
private:
ConfigurationGroup(); // not defined
~ConfigurationGroup(); // not defined
};
/// A type-safe wrapper around a configuration set. /// A type-safe wrapper around a configuration set.
/// ///
/// Automatically generated headers for the various configuration sets derive /// Automatically generated headers for the various configuration sets derive
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "com/sun/star/configuration/XReadWriteAccess.hpp" #include "com/sun/star/configuration/XReadWriteAccess.hpp"
#include "com/sun/star/configuration/theDefaultProvider.hpp" #include "com/sun/star/configuration/theDefaultProvider.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp" #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XHierarchicalNameReplace.hpp"
#include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/container/XNameAccess.hpp"
#include "com/sun/star/container/XNameContainer.hpp" #include "com/sun/star/container/XNameContainer.hpp"
#include "com/sun/star/lang/Locale.hpp" #include "com/sun/star/lang/Locale.hpp"
...@@ -90,6 +91,13 @@ void unotools::ConfigurationChanges::setPropertyValue( ...@@ -90,6 +91,13 @@ void unotools::ConfigurationChanges::setPropertyValue(
access_->replaceByHierarchicalName(path, value); access_->replaceByHierarchicalName(path, value);
} }
css::uno::Reference< css::container::XHierarchicalNameReplace >
unotools::ConfigurationChanges::getGroup(rtl::OUString const & path) const
{
return css::uno::Reference< css::container::XHierarchicalNameReplace >(
access_->getByHierarchicalName(path), css::uno::UNO_QUERY_THROW);
}
css::uno::Reference< css::container::XNameContainer > css::uno::Reference< css::container::XNameContainer >
unotools::ConfigurationChanges::getSet(rtl::OUString const & path) const unotools::ConfigurationChanges::getSet(rtl::OUString const & path) const
{ {
...@@ -139,6 +147,23 @@ void unotools::detail::ConfigurationWrapper::setLocalizedPropertyValue( ...@@ -139,6 +147,23 @@ void unotools::detail::ConfigurationWrapper::setLocalizedPropertyValue(
batch->setPropertyValue(extendLocalizedPath(path), value); batch->setPropertyValue(extendLocalizedPath(path), value);
} }
css::uno::Reference< css::container::XHierarchicalNameAccess >
unotools::detail::ConfigurationWrapper::getGroupReadOnly(
rtl::OUString const & path) const
{
return css::uno::Reference< css::container::XHierarchicalNameAccess >(
access_->getByHierarchicalName(path), css::uno::UNO_QUERY_THROW);
}
css::uno::Reference< css::container::XHierarchicalNameReplace >
unotools::detail::ConfigurationWrapper::getGroupReadWrite(
boost::shared_ptr< ConfigurationChanges > const & batch,
rtl::OUString const & path) const
{
assert(batch.get() != 0);
return batch->getGroup(path);
}
css::uno::Reference< css::container::XNameAccess > css::uno::Reference< css::container::XNameAccess >
unotools::detail::ConfigurationWrapper::getSetReadOnly( unotools::detail::ConfigurationWrapper::getSetReadOnly(
rtl::OUString const & path) const rtl::OUString const & path) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment