diff options
-rw-r--r-- | configmgr2/source/components.cxx | 69 | ||||
-rw-r--r-- | configmgr2/source/components.hxx | 27 | ||||
-rw-r--r-- | configmgr2/source/configurationprovider.cxx | 8 | ||||
-rw-r--r-- | configmgr2/source/update.cxx | 4 | ||||
-rw-r--r-- | configmgr2/source/xcdparser.cxx | 11 | ||||
-rw-r--r-- | configmgr2/source/xcdparser.hxx | 12 | ||||
-rw-r--r-- | configmgr2/source/xcuparser.cxx | 81 | ||||
-rw-r--r-- | configmgr2/source/xcuparser.hxx | 12 | ||||
-rw-r--r-- | officecfg/registry/data/org/openoffice/System.xcu | 48 | ||||
-rw-r--r-- | officecfg/registry/data/org/openoffice/makefile.mk | 1 | ||||
-rw-r--r-- | officecfg/util/alllang.xsl | 3 | ||||
-rw-r--r-- | shell/source/backends/localebe/localebackend.cxx | 110 | ||||
-rw-r--r-- | shell/source/backends/localebe/localebackend.hxx | 65 | ||||
-rw-r--r-- | shell/source/backends/localebe/localebecdef.cxx | 44 | ||||
-rw-r--r-- | shell/source/backends/localebe/localelayer.cxx | 88 | ||||
-rw-r--r-- | shell/source/backends/localebe/localelayer.hxx | 64 | ||||
-rw-r--r-- | shell/source/backends/localebe/makefile.mk | 5 |
17 files changed, 317 insertions, 335 deletions
diff --git a/configmgr2/source/components.cxx b/configmgr2/source/components.cxx index b4b442fd9731..3a7edffe274c 100644 --- a/configmgr2/source/components.cxx +++ b/configmgr2/source/components.cxx @@ -36,6 +36,7 @@ #include "com/sun/star/container/NoSuchElementException.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" #include "osl/diagnose.h" #include "osl/file.hxx" @@ -79,7 +80,9 @@ void parseSystemLayer() { //TODO } -void parseXcsFile(rtl::OUString const & url, int layer, Data * data) +void parseXcsFile( + css::uno::Reference< css::uno::XComponentContext > const &, + rtl::OUString const & url, int layer, Data * data) SAL_THROW(( css::container::NoSuchElementException, css::uno::UnoRuntimeException)) { @@ -88,13 +91,16 @@ void parseXcsFile(rtl::OUString const & url, int layer, Data * data) new ParseManager(url, new XcsParser(layer, data)))->parse()); } -void parseXcuFile(rtl::OUString const & url, int layer, Data * data) +void parseXcuFile( + css::uno::Reference< css::uno::XComponentContext > const & context, + rtl::OUString const & url, int layer, Data * data) SAL_THROW(( css::container::NoSuchElementException, css::uno::UnoRuntimeException)) { OSL_VERIFY( rtl::Reference< ParseManager >( - new ParseManager(url, new XcuParser(layer, data)))->parse()); + new ParseManager(url, new XcuParser(context, layer, data)))-> + parse()); } rtl::OUString expand(rtl::OUString const & str) { @@ -103,11 +109,31 @@ rtl::OUString expand(rtl::OUString const & str) { return s; } +static bool singletonCreated = false; +static Components * singleton; // leaks + } -Components & Components::singleton() { - static Components * c = new Components(); // leaks - return *c; +void Components::initSingleton( + css::uno::Reference< css::uno::XComponentContext > const & context) +{ + OSL_ASSERT(context.is()); + if (!singletonCreated) { + singletonCreated = true; + singleton = new Components(context); + } +} + +Components & Components::getSingleton() { + OSL_ASSERT(singletonCreated); + if (singleton == 0) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "configmgr no Components singleton")), + css::uno::Reference< css::uno::XInterface >()); + } + return *singleton; } bool Components::allLocales(rtl::OUString const & locale) { @@ -181,7 +207,9 @@ void Components::writeModifications() { void Components::insertXcsFile(int layer, rtl::OUString const & fileUri) { try { - parseXcsFile(fileUri, layer, &data_); + parseXcsFile( + css::uno::Reference< css::uno::XComponentContext >(), fileUri, + layer, &data_); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( (rtl::OUString( @@ -193,7 +221,7 @@ void Components::insertXcsFile(int layer, rtl::OUString const & fileUri) { void Components::insertXcuFile(int layer, rtl::OUString const & fileUri) { try { - parseXcuFile(fileUri, layer + 1, &data_); + parseXcuFile(context_, fileUri, layer + 1, &data_); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( (rtl::OUString( @@ -203,7 +231,11 @@ void Components::insertXcuFile(int layer, rtl::OUString const & fileUri) { } } -Components::Components() { +Components::Components( + css::uno::Reference< css::uno::XComponentContext > const & context): + context_(context) +{ + OSL_ASSERT(context.is()); parseXcsXcuLayer( 0, expand( @@ -281,7 +313,9 @@ Components::~Components() {} void Components::parseFiles( int layer, rtl::OUString const & extension, - void (* parseFile)(rtl::OUString const &, int, Data *), + void (* parseFile)( + css::uno::Reference< css::uno::XComponentContext > const &, + rtl::OUString const &, int, Data *), rtl::OUString const & url, bool recursive) { osl::Directory dir(url); @@ -331,7 +365,7 @@ void Components::parseFiles( file.match(extension, file.getLength() - extension.getLength())) { try { - (*parseFile)(stat.getFileURL(), layer, &data_); + (*parseFile)(context_, stat.getFileURL(), layer, &data_); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( (rtl::OUString( @@ -346,7 +380,10 @@ void Components::parseFiles( } void Components::parseFileList( - int layer, void (* parseFile)(rtl::OUString const &, int, Data *), + int layer, + void (* parseFile)( + css::uno::Reference< css::uno::XComponentContext > const &, + rtl::OUString const &, int, Data *), rtl::OUString const & urls, rtl::Bootstrap const & ini) { for (sal_Int32 i = 0;;) { @@ -354,7 +391,7 @@ void Components::parseFileList( if (url.getLength() != 0) { ini.expandMacrosFrom(url); //TODO: detect failure try { - (*parseFile)(url, layer, &data_); + (*parseFile)(context_, url, layer, &data_); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( (rtl::OUString( @@ -422,7 +459,8 @@ void Components::parseXcdFiles(int layer, rtl::OUString const & url) { rtl::Reference< ParseManager > manager; try { manager = new ParseManager( - stat.getFileURL(), new XcdParser(layer, deps, &data_)); + stat.getFileURL(), + new XcdParser(context_, layer, deps, &data_)); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( (rtl::OUString( @@ -513,7 +551,8 @@ rtl::OUString Components::getModificationFileUrl() const { void Components::parseModificationLayer() { try { - parseXcuFile(getModificationFileUrl(), Data::NO_LAYER, &data_); + parseXcuFile( + context_, getModificationFileUrl(), Data::NO_LAYER, &data_); } catch (css::container::NoSuchElementException &) { OSL_TRACE( "configmgr user registrymodifications.xcu does not (yet) exist"); diff --git a/configmgr2/source/components.hxx b/configmgr2/source/components.hxx index 02e68279aff4..089c96d9cd64 100644 --- a/configmgr2/source/components.hxx +++ b/configmgr2/source/components.hxx @@ -35,11 +35,15 @@ #include <set> #include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Reference.hxx" #include "rtl/ref.hxx" #include "data.hxx" #include "path.hxx" +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } namespace rtl { class Bootstrap; class OUString; @@ -54,7 +58,11 @@ class RootAccess; class Components: private boost::noncopyable { public: - static Components & singleton(); + static void initSingleton( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); + + static Components & getSingleton(); static bool allLocales(rtl::OUString const & locale); @@ -83,17 +91,26 @@ public: void insertXcuFile(int layer, rtl::OUString const & fileUri); private: - Components(); + Components( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); ~Components(); void parseFiles( int layer, rtl::OUString const & extension, - void (* parseFile)(rtl::OUString const &, int, Data *), + void (* parseFile)( + com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext > const &, + rtl::OUString const &, int, Data *), rtl::OUString const & url, bool recursive); void parseFileList( - int layer, void (* parseFile)(rtl::OUString const &, int, Data *), + int layer, + void (* parseFile)( + com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext > const &, + rtl::OUString const &, int, Data *), rtl::OUString const & urls, rtl::Bootstrap const & ini); void parseXcdFiles(int layer, rtl::OUString const & url); @@ -112,6 +129,8 @@ private: typedef std::set< RootAccess * > WeakRootSet; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + context_; Data data_; WeakRootSet roots_; }; diff --git a/configmgr2/source/configurationprovider.cxx b/configmgr2/source/configurationprovider.cxx index 93f0896b83f0..9e3ca52c4a8d 100644 --- a/configmgr2/source/configurationprovider.cxx +++ b/configmgr2/source/configurationprovider.cxx @@ -60,6 +60,7 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/interfacecontainer.hxx" #include "cppuhelper/weak.hxx" +#include "osl/diagnose.h" #include "osl/mutex.hxx" #include "sal/types.h" #include "rtl/ref.hxx" @@ -108,7 +109,9 @@ public: rtl::OUString const & locale): ServiceBase(*static_cast< osl::Mutex * >(this)), context_(context), locale_(locale) - {} + { + OSL_ASSERT(context.is()); + } private: virtual ~Service() {} @@ -272,7 +275,8 @@ Service::createInstanceWithArguments( static_cast< cppu::OWeakObject * >(this)); } osl::MutexGuard guard(lock); - Components & components = Components::singleton(); + Components::initSingleton(context_); + Components & components = Components::getSingleton(); rtl::Reference< RootAccess > root( new RootAccess(components, nodepath, locale, update)); if (root->isValue()) { diff --git a/configmgr2/source/update.cxx b/configmgr2/source/update.cxx index 74751eaf9bba..6ed052f87f04 100644 --- a/configmgr2/source/update.cxx +++ b/configmgr2/source/update.cxx @@ -43,12 +43,12 @@ namespace update { void insertXcsFile(int layer, rtl::OUString const & fileUri) { osl::MutexGuard g(lock); - Components::singleton().insertXcsFile(layer, fileUri); + Components::getSingleton().insertXcsFile(layer, fileUri); } void insertXcuFile(int layer, rtl::OUString const & fileUri) { osl::MutexGuard g(lock); - Components::singleton().insertXcuFile(layer, fileUri); + Components::getSingleton().insertXcuFile(layer, fileUri); } } diff --git a/configmgr2/source/xcdparser.cxx b/configmgr2/source/xcdparser.cxx index 46408060d0e7..c04c90a78931 100644 --- a/configmgr2/source/xcdparser.cxx +++ b/configmgr2/source/xcdparser.cxx @@ -34,6 +34,7 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" #include "osl/diagnose.hxx" #include "rtl/string.h" @@ -56,9 +57,13 @@ namespace css = com::sun::star; } XcdParser::XcdParser( + css::uno::Reference< css::uno::XComponentContext > const & context, int layer, Dependencies const & dependencies, Data * data): - layer_(layer), dependencies_(dependencies), data_(data), state_(STATE_START) -{} + context_(context), layer_(layer), dependencies_(dependencies), data_(data), + state_(STATE_START) +{ + OSL_ASSERT(context.is()); +} XcdParser::~XcdParser() {} @@ -140,7 +145,7 @@ bool XcdParser::startElement( if (ns == XmlReader::NAMESPACE_OOR && name.equals(RTL_CONSTASCII_STRINGPARAM("component-data"))) { - nestedParser_ = new XcuParser(layer_ + 1, data_); + nestedParser_ = new XcuParser(context_, layer_ + 1, data_); nesting_ = 1; return nestedParser_->startElement(reader, ns, name); } diff --git a/configmgr2/source/xcdparser.hxx b/configmgr2/source/xcdparser.hxx index 7a7d9994b404..b0dcd5d5a1a8 100644 --- a/configmgr2/source/xcdparser.hxx +++ b/configmgr2/source/xcdparser.hxx @@ -34,12 +34,17 @@ #include <set> +#include "com/sun/star/uno/Reference.hxx" #include "rtl/ref.hxx" #include "rtl/ustring.hxx" #include "parser.hxx" #include "xmlreader.hxx" +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + namespace configmgr { class Span; @@ -49,7 +54,10 @@ class XcdParser: public Parser { public: typedef std::set< rtl::OUString > Dependencies; - XcdParser(int layer, Dependencies const & dependencies, Data * data); + XcdParser( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context, + int layer, Dependencies const & dependencies, Data * data); private: virtual ~XcdParser(); @@ -66,6 +74,8 @@ private: enum State { STATE_START, STATE_DEPENDENCIES, STATE_DEPENDENCY, STATE_COMPONENTS }; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + context_; int layer_; Dependencies const & dependencies_; Data * data_; diff --git a/configmgr2/source/xcuparser.cxx b/configmgr2/source/xcuparser.cxx index 27b6ce662f48..58246c562972 100644 --- a/configmgr2/source/xcuparser.cxx +++ b/configmgr2/source/xcuparser.cxx @@ -32,9 +32,16 @@ #include <algorithm> +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/container/XNameAccess.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" #include "osl/diagnose.h" #include "rtl/ref.hxx" @@ -42,6 +49,7 @@ #include "rtl/string.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" +#include "sal/types.h" #include "data.hxx" #include "localizedpropertynode.hxx" @@ -66,8 +74,13 @@ namespace css = com::sun::star; } -XcuParser::XcuParser(int layer, Data * data): valueParser_(layer), data_(data) -{} +XcuParser::XcuParser( + css::uno::Reference< css::uno::XComponentContext > const & context, + int layer, Data * data): + context_(context), valueParser_(layer), data_(data) +{ + OSL_ASSERT(context.is()); +} XcuParser::~XcuParser() {} @@ -370,6 +383,7 @@ void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) { OSL_ASSERT(!state_.top().record); Span attrNil; Span attrSeparator; + Span attrExternal; for (;;) { XmlReader::Namespace attrNs; Span attrLn; @@ -384,6 +398,10 @@ void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) { attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator"))) { attrSeparator = reader.getAttributeValue(false); + } else if (attrNs == XmlReader::NAMESPACE_OOR && + attrLn.equals(RTL_CONSTASCII_STRINGPARAM("external"))) + { + attrExternal = reader.getAttributeValue(true); } } if (xmldata::parseBoolean(attrNil, false)) { @@ -395,8 +413,67 @@ void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) { reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } + if (attrExternal.is()) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "xsi:nil and oor:external attributes for prop in ")) + + reader.getUrl()), + css::uno::Reference< css::uno::XInterface >()); + } prop->setValue(valueParser_.getLayer(), css::uno::Any()); state_.push(State()); + } else if (attrExternal.is()) { + rtl::OUString external(xmldata::convertFromUtf8(attrExternal)); + sal_Int32 i = external.indexOf(' '); + if (i <= 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "bad oor:external attribute value in ")) + + reader.getUrl()), + css::uno::Reference< css::uno::XInterface >()); + } + css::uno::Reference< css::container::XNameAccess > service; + try { + service = css::uno::Reference< css::container::XNameAccess >( + (css::uno::Reference< css::lang::XMultiComponentFactory >( + context_->getServiceManager(), css::uno::UNO_SET_THROW)-> + createInstanceWithContext(external.copy(0, i), context_)), + css::uno::UNO_QUERY_THROW); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "cannot instantiate oor:external service: ")) + + e.Message), + css::uno::Reference< css::uno::XInterface >()); + } + css::uno::Any value; + try { + value = service->getByName(external.copy(i + 1)); + } catch (css::container::NoSuchElementException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("unknwon oor:external ID: ")) + + e.Message), + css::uno::Reference< css::uno::XInterface >()); + } catch (css::lang::WrappedTargetException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "cannot obtain oor:external value: ")) + + e.Message), + css::uno::Reference< css::uno::XInterface >()); + } + css::uno::Type t; + if (!(value >>= t) || t != cppu::UnoType< cppu::UnoVoidType >::get()) { + //TODO: check value type + prop->setValue(valueParser_.getLayer(), value); + } + state_.push(State()); } else { valueParser_.separator_ = attrSeparator; valueParser_.start(prop); diff --git a/configmgr2/source/xcuparser.hxx b/configmgr2/source/xcuparser.hxx index 46eb2fd1edbc..2150c157b14c 100644 --- a/configmgr2/source/xcuparser.hxx +++ b/configmgr2/source/xcuparser.hxx @@ -34,6 +34,7 @@ #include <stack> +#include "com/sun/star/uno/Reference.hxx" #include "rtl/ref.hxx" #include "rtl/ustring.hxx" @@ -46,6 +47,10 @@ #include "xmldata.hxx" #include "xmlreader.hxx" +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + namespace configmgr { class GroupNode; @@ -57,7 +62,10 @@ struct Data; class XcuParser: public Parser { public: - XcuParser(int layer, Data * data); + XcuParser( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context, + int layer, Data * data); private: virtual ~XcuParser(); @@ -132,6 +140,8 @@ private: typedef std::stack< State > StateStack; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + context_; ValueParser valueParser_; Data * data_; rtl::OUString componentName_; diff --git a/officecfg/registry/data/org/openoffice/System.xcu b/officecfg/registry/data/org/openoffice/System.xcu new file mode 100644 index 000000000000..53d8e4ead960 --- /dev/null +++ b/officecfg/registry/data/org/openoffice/System.xcu @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +**********************************************************************--> + +<!DOCTYPE oor:component-data SYSTEM "../../../component-update.dtd"> +<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" + oor:package="org.openoffice" oor:name="System"> + <node oor:name="L10N"> + <prop oor:name="Locale"> + <value oor:external= + "com.sun.star.configuration.backend.LocaleBackend Locale"/> + </prop> + <prop oor:name="UILocale"> + <value oor:external= + "com.sun.star.configuration.backend.LocaleBackend UILocale"/> + </prop> + <prop oor:name="SystemLocale"> + <value oor:external= + "com.sun.star.configuration.backend.LocaleBackend SystemLocale"/> + </prop> + </node> +</oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/makefile.mk b/officecfg/registry/data/org/openoffice/makefile.mk index 6d5a1b264d8c..c4739df22ee9 100644 --- a/officecfg/registry/data/org/openoffice/makefile.mk +++ b/officecfg/registry/data/org/openoffice/makefile.mk @@ -42,6 +42,7 @@ PACKAGE=org.openoffice XCUFILES= \ Inet.xcu \ Setup.xcu \ + System.xcu \ VCL.xcu \ FirstStartWizard.xcu \ UserProfile.xcu diff --git a/officecfg/util/alllang.xsl b/officecfg/util/alllang.xsl index 47ae08165928..86b2dbe752b8 100644 --- a/officecfg/util/alllang.xsl +++ b/officecfg/util/alllang.xsl @@ -316,6 +316,9 @@ <xsl:when test="not ($dataval)"> <xsl:value-of select="true()"/> </xsl:when> + <xsl:when test="$dataval/@oor:external"> + <xsl:value-of select="false()"/> + </xsl:when> <xsl:when test="not ($schemaval)"> <xsl:choose> <xsl:when test="$dataval/@xsi:nil='true'"> diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx index d8e2f05c0332..5df54b055929 100644 --- a/shell/source/backends/localebe/localebackend.cxx +++ b/shell/source/backends/localebe/localebackend.cxx @@ -32,9 +32,6 @@ #include "precompiled_shell.hxx" #include "localebackend.hxx" -#include "localelayer.hxx" -#include <com/sun/star/configuration/backend/ComponentChangeEvent.hpp> -#include <uno/current_context.hxx> #include <osl/time.h> #include <stdio.h> @@ -229,11 +226,7 @@ rtl::OUString ImplGetLocale(LCID lcid) // ------------------------------------------------------------------------------- -LocaleBackend::LocaleBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException) : - ::cppu::WeakImplHelper2 < backend::XSingleLayerStratum, lang::XServiceInfo > (), - m_xContext(xContext) - +LocaleBackend::LocaleBackend() { } @@ -245,11 +238,9 @@ LocaleBackend::~LocaleBackend(void) //------------------------------------------------------------------------------ -LocaleBackend* LocaleBackend::createInstance( - const uno::Reference<uno::XComponentContext>& xContext -) +LocaleBackend* LocaleBackend::createInstance() { - return new LocaleBackend(xContext); + return new LocaleBackend; } // --------------------------------------------------------------------------------------- @@ -291,61 +282,49 @@ rtl::OUString LocaleBackend::getSystemLocale(void) } //------------------------------------------------------------------------------ -rtl::OUString LocaleBackend::createTimeStamp() +css::uno::Type LocaleBackend::getElementType() throw(css::uno::RuntimeException) { - // the time stamp is free text, so just returning the values here. - return getLocale() + getUILocale() + getSystemLocale(); + return cppu::UnoType< cppu::UnoVoidType >::get(); } -//------------------------------------------------------------------------------ - -uno::Reference<backend::XLayer> SAL_CALL LocaleBackend::getLayer( - const rtl::OUString& aComponent, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException) +sal_Bool LocaleBackend::hasElements() throw(css::uno::RuntimeException) { + return true; +} - uno::Sequence<rtl::OUString> aComps( getSupportedComponents() ); - if( aComponent.equals( aComps[0]) ) - { - if( ! m_xSystemLayer.is() ) - { - uno::Sequence<backend::PropertyInfo> aPropInfoList(3); - - aPropInfoList[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.System/L10N/UILocale") ); - aPropInfoList[0].Type = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" ) ); - aPropInfoList[0].Protected = sal_False; - aPropInfoList[0].Value = uno::makeAny( getUILocale() ); - - aPropInfoList[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.System/L10N/Locale") ); - aPropInfoList[1].Type = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" )); - aPropInfoList[1].Protected = sal_False; - aPropInfoList[1].Value = uno::makeAny( getLocale() ); - - aPropInfoList[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.System/L10N/SystemLocale") ); - aPropInfoList[2].Type = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" )); - aPropInfoList[2].Protected = sal_False; - aPropInfoList[2].Value = uno::makeAny( getSystemLocale() ); - - m_xSystemLayer = new LocaleLayer(aPropInfoList, createTimeStamp(), m_xContext); - } - - return m_xSystemLayer; +css::uno::Any LocaleBackend::getByName(rtl::OUString const & aName) + throw ( + css::container::NoSuchElementException, + css::lang::WrappedTargetException, css::uno::RuntimeException) +{ + if (aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Locale"))) { + return css::uno::makeAny(getLocale()); + } else if (aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SystemLocale"))) { + return css::uno::makeAny(getSystemLocale()); + } else if (aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UILocale"))) { + return css::uno::makeAny(getUILocale()); + } else { + throw css::container::NoSuchElementException( + aName, static_cast< cppu::OWeakObject * >(this)); } - - return uno::Reference<backend::XLayer>(); } -//------------------------------------------------------------------------------ +css::uno::Sequence< rtl::OUString > LocaleBackend::getElementNames() + throw (css::uno::RuntimeException) +{ + css::uno::Sequence< rtl::OUString > names(3); + names[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale")); + names[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemLocale")); + names[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UILocale")); + return names; +} -uno::Reference<backend::XUpdatableLayer> SAL_CALL -LocaleBackend::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException) +sal_Bool LocaleBackend::hasByName(rtl::OUString const & aName) + throw (css::uno::RuntimeException) { - throw lang::NoSupportException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "LocaleBackend: No Update Operation allowed, Read Only access") ), - *this) ; + return aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Locale")) || + aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SystemLocale")) || + aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UILocale")); } //------------------------------------------------------------------------------ @@ -366,10 +345,8 @@ rtl::OUString SAL_CALL LocaleBackend::getImplementationName(void) uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getBackendServiceNames(void) { - uno::Sequence<rtl::OUString> aServiceNameList(2); + uno::Sequence<rtl::OUString> aServiceNameList(1); aServiceNameList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.LocaleBackend")) ; - aServiceNameList[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; - return aServiceNameList ; } @@ -394,16 +371,3 @@ uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getSupportedServiceNames(vo { return getBackendServiceNames() ; } - -// --------------------------------------------------------------------------------------- - -uno::Sequence<rtl::OUString> SAL_CALL LocaleBackend::getSupportedComponents(void) -{ - uno::Sequence<rtl::OUString> aSupportedComponentList(1); - aSupportedComponentList[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.System" ) - ); - - return aSupportedComponentList; -} - diff --git a/shell/source/backends/localebe/localebackend.hxx b/shell/source/backends/localebe/localebackend.hxx index 7546a0385cf0..5e5083694325 100644 --- a/shell/source/backends/localebe/localebackend.hxx +++ b/shell/source/backends/localebe/localebackend.hxx @@ -31,10 +31,8 @@ #ifndef _FIXEDVALUEBACKEND_HXX_ #define _FIXEDVALUEBACKEND_HXX_ -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp> #include <cppuhelper/implbase2.hxx> #include <rtl/string.hxx> @@ -42,19 +40,14 @@ namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace backend = css::configuration::backend ; - -/** - Implements the SingleLayerStratum service. - */ class LocaleBackend : public ::cppu::WeakImplHelper2 < - backend::XSingleLayerStratum, + css::container::XNameAccess, lang::XServiceInfo > { public : - static LocaleBackend* createInstance(const uno::Reference<uno::XComponentContext>& xContext); + static LocaleBackend* createInstance(); // XServiceInfo virtual rtl::OUString SAL_CALL @@ -81,45 +74,41 @@ class LocaleBackend : public ::cppu::WeakImplHelper2 < @return service names */ static uno::Sequence<rtl::OUString> SAL_CALL getBackendServiceNames(void) ; - /** - Provides the supported component nodes - - @return supported component nodes - */ - static uno::Sequence<rtl::OUString> SAL_CALL getSupportedComponents(void) ; - - //XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL - getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp ) - throw (backend::BackendAccessException, - lang::IllegalArgumentException) ; - - virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL - getUpdatableLayer( const rtl::OUString& aLayerId ) - throw (backend::BackendAccessException, - lang::NoSupportException, - lang::IllegalArgumentException) ; + + //XNameAccess + virtual uno::Type SAL_CALL + getElementType() + throw (uno::RuntimeException); + + virtual sal_Bool SAL_CALL + hasElements() + throw (uno::RuntimeException); + + virtual uno::Any SAL_CALL + getByName( const rtl::OUString& aName ) + throw (css::container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException); + + virtual uno::Sequence<rtl::OUString> SAL_CALL + getElementNames() + throw (uno::RuntimeException); + + virtual sal_Bool SAL_CALL + hasByName( const rtl::OUString& aName ) + throw (uno::RuntimeException); + protected: /** Service constructor from a service factory. @param xContext component context */ - LocaleBackend(const uno::Reference<uno::XComponentContext>& xContext) - throw (backend::BackendAccessException); + LocaleBackend(); /** Destructor */ ~LocaleBackend(void) ; private: - - uno::Reference<uno::XComponentContext> m_xContext ; - uno::Reference<backend::XLayer> m_xSystemLayer ; - - // Returns a time stamp in the appropriate format - // for configuration layers. - static rtl::OUString createTimeStamp(void); - // Returns the user locale static rtl::OUString getLocale(void); diff --git a/shell/source/backends/localebe/localebecdef.cxx b/shell/source/backends/localebe/localebecdef.cxx index c9211543a283..cefa6c8d542d 100644 --- a/shell/source/backends/localebe/localebecdef.cxx +++ b/shell/source/backends/localebe/localebecdef.cxx @@ -32,7 +32,6 @@ #include "precompiled_shell.hxx" #include <localebackend.hxx> -#include <com/sun/star/registry/XRegistryKey.hpp> #ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ #include <cppuhelper/implementationentry.hxx> @@ -42,14 +41,13 @@ namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace backend = css::configuration::backend ; //------------------------------------------------------------------------------ static uno::Reference<uno::XInterface> SAL_CALL createLocaleBackend( - const uno::Reference<uno::XComponentContext>& xContext){ + const uno::Reference<uno::XComponentContext>&){ - return * LocaleBackend::createInstance(xContext); + return * LocaleBackend::createInstance(); } //------------------------------------------------------------------------------ @@ -77,41 +75,9 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( //------------------------------------------------------------------------------ -extern "C" sal_Bool SAL_CALL component_writeInfo(void * /*pServiceManager*/, void *pRegistryKey) { - - using namespace ::com::sun::star::registry; - if (pRegistryKey) - { - try - { - uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + LocaleBackend::getBackendName() - ); - - // Register associated service names - uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) - ); - - uno::Sequence<rtl::OUString> sServiceNames = LocaleBackend::getBackendServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - xServicesKey->createKey(sServiceNames[i]); - - // Register supported components - uno::Reference<XRegistryKey> xComponentKey = xImplKey->createKey( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/DATA/SupportedComponents") ) - ); - - xComponentKey->setAsciiListValue( LocaleBackend::getSupportedComponents() ); - - return sal_True; - } - catch( InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "InvalidRegistryException caught"); - } - } - return sal_False; +extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *pRegistryKey) { + return cppu::component_writeInfoHelper( + pServiceManager, pRegistryKey, kImplementations_entries); } //------------------------------------------------------------------------------ diff --git a/shell/source/backends/localebe/localelayer.cxx b/shell/source/backends/localebe/localelayer.cxx deleted file mode 100644 index 74253e9d9187..000000000000 --- a/shell/source/backends/localebe/localelayer.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: localelayer.cxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_shell.hxx" -#include "localelayer.hxx" - -//------------------------------------------------------------------------------ - -LocaleLayer::LocaleLayer( const uno::Sequence<backend::PropertyInfo>& aPropInfoList, - const rtl::OUString& aTimestamp, - const uno::Reference<uno::XComponentContext>& xContext) - : m_aTimestamp(aTimestamp), m_aPropInfoList(aPropInfoList) -{ - //Create instance of LayerContentDescriber Service - rtl::OUString const k_sLayerDescriberService(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.configuration.backend.LayerDescriber")); - - typedef uno::Reference<backend::XLayerContentDescriber> LayerDescriber; - uno::Reference< lang::XMultiComponentFactory > xServiceManager = xContext->getServiceManager(); - if( xServiceManager.is() ) - { - m_xLayerContentDescriber = LayerDescriber::query( - xServiceManager->createInstanceWithContext(k_sLayerDescriberService, xContext)); - } - else - { - OSL_TRACE("Could not retrieve ServiceManager"); - } - -} - -//------------------------------------------------------------------------------ - -void SAL_CALL LocaleLayer::readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - - if (m_xLayerContentDescriber.is()) - { - m_xLayerContentDescriber->describeLayer(xHandler, m_aPropInfoList); - } - else - { - OSL_TRACE("Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"); - } -} - -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL LocaleLayer::getTimestamp(void) - throw (uno::RuntimeException) -{ - return m_aTimestamp; -} - -//------------------------------------------------------------------------------ diff --git a/shell/source/backends/localebe/localelayer.hxx b/shell/source/backends/localebe/localelayer.hxx deleted file mode 100644 index 69b305079d33..000000000000 --- a/shell/source/backends/localebe/localelayer.hxx +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _LOCALELAYER_HXX_ -#define _LOCALELAYER_HXX_ - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <cppuhelper/implbase2.hxx> - - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -/** - Implementation of the XLayer interfaces for fixed values - */ - -class LocaleLayer : public cppu::WeakImplHelper2<backend::XLayer, util::XTimeStamped> -{ - public : - /** - Constructor given the requested component name - - @param aPropInfoListyMap Gconf->OO key map - @param aCompoentName Requested Component Name - @param sTimestamp timestamp indicating last modifictaion - */ - LocaleLayer(const uno::Sequence<backend::PropertyInfo>& aPropInfoList, - const rtl::OUString& aTimestamp, - const uno::Reference<uno::XComponentContext>& xContext); - - /** Destructor */ - ~LocaleLayer(void) {} - - // XLayer - virtual void SAL_CALL readData(const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException); - - private : - - rtl::OUString m_aTimestamp ; - rtl::OUString m_aComponent ; - - uno::Reference<backend::XLayerContentDescriber> m_xLayerContentDescriber ; - uno::Sequence<backend::PropertyInfo> m_aPropInfoList ; -} ; - -#endif // _LOCALELAYER_HXX_ diff --git a/shell/source/backends/localebe/makefile.mk b/shell/source/backends/localebe/makefile.mk index 76767264a831..f320b2978524 100644 --- a/shell/source/backends/localebe/makefile.mk +++ b/shell/source/backends/localebe/makefile.mk @@ -49,9 +49,8 @@ DLLPRE = SLOFILES=\ $(SLO)$/localebecdef.obj \ - $(SLO)$/localebackend.obj \ - $(SLO)$/localelayer.obj - + $(SLO)$/localebackend.obj + SHL1TARGET=$(TARGET)1.uno SHL1OBJS=$(SLOFILES) SHL1DEF=$(MISC)$/$(SHL1TARGET).def |