diff options
author | sb <sb@openoffice.org> | 2009-09-25 14:47:45 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2009-09-25 14:47:45 +0200 |
commit | 42345be352f413b571b83d262cc96025a9e8618d (patch) | |
tree | fa50c6a6765b86f986255e12a13d2e8f0daa5177 /shell/source | |
parent | 5743ea3fcb44965bf27004c747a5a5233b15dd4d (diff) |
#i101955# configmgr2 support for platform backends (with a new interface); adapted locale backend, rest to follow
Diffstat (limited to 'shell/source')
-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 |
6 files changed, 71 insertions, 305 deletions
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 |