From e616b9f5e47bb06200e88eb376b3d57e9b5e3898 Mon Sep 17 00:00:00 2001 From: sb Date: Tue, 4 May 2010 16:29:02 +0200 Subject: sb122: #i110491# turned configmgr API from C++ to UNO --- configmgr/inc/configmgr/detail/configmgrdllapi.hxx | 41 ------ configmgr/inc/configmgr/update.hxx | 58 --------- configmgr/prj/d.lst | 11 +- configmgr/source/makefile.mk | 4 +- configmgr/source/services.cxx | 17 +++ configmgr/source/update.cxx | 143 +++++++++++++++++++-- configmgr/source/update.hxx | 59 +++++++++ 7 files changed, 215 insertions(+), 118 deletions(-) delete mode 100644 configmgr/inc/configmgr/detail/configmgrdllapi.hxx delete mode 100644 configmgr/inc/configmgr/update.hxx create mode 100644 configmgr/source/update.hxx (limited to 'configmgr') diff --git a/configmgr/inc/configmgr/detail/configmgrdllapi.hxx b/configmgr/inc/configmgr/detail/configmgrdllapi.hxx deleted file mode 100644 index 6eb2ea7bc9..0000000000 --- a/configmgr/inc/configmgr/detail/configmgrdllapi.hxx +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************* -* -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* Copyright 2000, 2010 Oracle and/or its affiliates. -* -* OpenOffice.org - a multi-platform office productivity suite -* -* 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 -* -* for a copy of the LGPLv3 License. -* -************************************************************************/ - -#ifndef INCLUDED_CONFIGMGR_DETAIL_CONFIGMGRDLLAPI_HXX -#define INCLUDED_CONFIGMGR_DETAIL_CONFIGMGRDLLAPI_HXX - -#include "sal/config.h" - -#include "sal/types.h" - -#if defined OOO_DLLIMPLEMENTATION_CONFIGMGR -#define OOO_DLLPUBLIC_CONFIGMGR SAL_DLLPUBLIC_EXPORT -#else -#define OOO_DLLPUBLIC_CONFIGMGR SAL_DLLPUBLIC_IMPORT -#endif - -#endif diff --git a/configmgr/inc/configmgr/update.hxx b/configmgr/inc/configmgr/update.hxx deleted file mode 100644 index 3a15295934..0000000000 --- a/configmgr/inc/configmgr/update.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************* -* -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* Copyright 2000, 2010 Oracle and/or its affiliates. -* -* OpenOffice.org - a multi-platform office productivity suite -* -* 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 -* -* for a copy of the LGPLv3 License. -* -************************************************************************/ - -#ifndef INCLUDED_CONFIGMGR_UPDATE_HXX -#define INCLUDED_CONFIGMGR_UPDATE_HXX - -#include "sal/config.h" - -#include - -#include "configmgr/detail/configmgrdllapi.hxx" - -namespace rtl { class OUString; } - -namespace configmgr { - -namespace update { - -OOO_DLLPUBLIC_CONFIGMGR void insertExtensionXcsFile( - bool shared, rtl::OUString const & fileUri); - -OOO_DLLPUBLIC_CONFIGMGR void insertExtensionXcuFile( - bool shared, rtl::OUString const & fileUri); - -OOO_DLLPUBLIC_CONFIGMGR void insertModificationXcuFile( - rtl::OUString const & fileUri, - std::set< rtl::OUString > const & includedPaths, - std::set< rtl::OUString > const & excludedPaths); - -} - -} - -#endif diff --git a/configmgr/prj/d.lst b/configmgr/prj/d.lst index a9d91980b2..17ccdbe86a 100644 --- a/configmgr/prj/d.lst +++ b/configmgr/prj/d.lst @@ -1,8 +1,3 @@ -mkdir: %_DEST%\inc%_EXT%\configmgr -mkdir: %_DEST%\inc%_EXT%\configmgr\detail -..\%__SRC%\bin\configmgr.dll %_DEST%\bin%_EXT%\configmgr.dll -..\%__SRC%\lib\iconfigmgr.lib %_DEST%\lib%_EXT%\iconfigmgr.lib -..\%__SRC%\lib\libconfigmgr.dylib %_DEST%\lib%_EXT%\libconfigmgr.dylib -..\%__SRC%\lib\libconfigmgr.so %_DEST%\lib%_EXT%\libconfigmgr.so -..\inc\configmgr\detail\configmgrdllapi.hxx %_DEST%\inc%_EXT%\configmgr\detail\configmgrdllapi.hxx -..\inc\configmgr\update.hxx %_DEST%\inc%_EXT%\configmgr\update.hxx +..\%__SRC%\bin\configmgr.uno.dll %_DEST%\bin%_EXT%\configmgr.uno.dll +..\%__SRC%\lib\configmgr.uno.dylib %_DEST%\lib%_EXT%\configmgr.uno.dylib +..\%__SRC%\lib\configmgr.uno.so %_DEST%\lib%_EXT%\configmgr.uno.so diff --git a/configmgr/source/makefile.mk b/configmgr/source/makefile.mk index 317e08bdf4..777fed3323 100644 --- a/configmgr/source/makefile.mk +++ b/configmgr/source/makefile.mk @@ -34,7 +34,7 @@ VISIBILITY_HIDDEN = TRUE .INCLUDE: settings.mk -CDEFS += -DOOO_DLLIMPLEMENTATION_CONFIGMGR +DLLPRE = SLOFILES = \ $(SLO)/access.obj \ @@ -77,7 +77,7 @@ SHL1STDLIBS = \ $(CPPULIB) \ $(SALHELPERLIB) \ $(SALLIB) -SHL1TARGET = configmgr +SHL1TARGET = configmgr.uno SHL1USE_EXPORTS = name DEF1NAME = $(SHL1TARGET) diff --git a/configmgr/source/services.cxx b/configmgr/source/services.cxx index 3a009b3cee..f8c3289664 100644 --- a/configmgr/source/services.cxx +++ b/configmgr/source/services.cxx @@ -44,6 +44,7 @@ #include "configurationprovider.hxx" #include "configurationregistry.hxx" #include "defaultprovider.hxx" +#include "update.hxx" namespace { @@ -67,6 +68,9 @@ static cppu::ImplementationEntry const services[] = { { &dummy, &configmgr::configuration_registry::getImplementationName, &configmgr::configuration_registry::getSupportedServiceNames, &configmgr::configuration_registry::createFactory, 0, 0 }, + { &dummy, &configmgr::update::getImplementationName, + &configmgr::update::getSupportedServiceNames, + &configmgr::update::createFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; @@ -107,6 +111,19 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.DefaultProvider"))); + css::uno::Reference< css::registry::XRegistryKey >( + (css::uno::Reference< css::registry::XRegistryKey >( + static_cast< css::registry::XRegistryKey * >(pRegistryKey))-> + createKey( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "/com.sun.star.comp.configuration.Update/UNO/" + "SINGLETONS/com.sun.star.configuration.Update")))), + css::uno::UNO_SET_THROW)-> + setStringValue( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.Update_Service"))); } catch (css::uno::Exception & e) { (void) e; OSL_TRACE( diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx index 57f45068d9..4c1d59d5d0 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -30,27 +30,84 @@ #include -#include "configmgr/update.hxx" +#include "boost/noncopyable.hpp" +#include "com/sun/star/configuration/XUpdate.hpp" +#include "com/sun/star/lang/XSingleComponentFactory.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/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/weak.hxx" #include "osl/mutex.hxx" #include "rtl/ref.hxx" +#include "rtl/unload.h" +#include "rtl/ustring.h" #include "rtl/ustring.hxx" +#include "sal/types.h" #include "broadcaster.hxx" #include "components.hxx" #include "lock.hxx" #include "modifications.hxx" #include "rootaccess.hxx" +#include "update.hxx" -namespace configmgr { +namespace configmgr { namespace update { -namespace update { +namespace { -void insertExtensionXcsFile(bool shared, rtl::OUString const & fileUri) { +namespace css = com::sun::star; + +std::set< rtl::OUString > seqToSet( + css::uno::Sequence< rtl::OUString > const & sequence) +{ + return std::set< rtl::OUString >( + sequence.getConstArray(), + sequence.getConstArray() + sequence.getLength()); +} + +class Service: + public cppu::WeakImplHelper1< css::configuration::XUpdate >, + private boost::noncopyable +{ +public: + Service() {} + +private: + virtual ~Service() {} + + virtual void SAL_CALL insertExtensionXcsFile( + sal_Bool shared, rtl::OUString const & fileUri) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL insertExtensionXcuFile( + sal_Bool shared, rtl::OUString const & fileUri) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL insertModificationXcuFile( + rtl::OUString const & fileUri, + css::uno::Sequence< rtl::OUString > const & includedPaths, + css::uno::Sequence< rtl::OUString > const & excludedPaths) + throw (css::uno::RuntimeException); +}; + +void Service::insertExtensionXcsFile( + sal_Bool shared, rtl::OUString const & fileUri) + throw (css::uno::RuntimeException) +{ osl::MutexGuard g(lock); Components::getSingleton().insertExtensionXcsFile(shared, fileUri); } -void insertExtensionXcuFile(bool shared, rtl::OUString const & fileUri) { +void Service::insertExtensionXcuFile( + sal_Bool shared, rtl::OUString const & fileUri) + throw (css::uno::RuntimeException) +{ Broadcaster bc; { osl::MutexGuard g(lock); @@ -63,23 +120,91 @@ void insertExtensionXcuFile(bool shared, rtl::OUString const & fileUri) { bc.send(); } -void insertModificationXcuFile( +void Service::insertModificationXcuFile( rtl::OUString const & fileUri, - std::set< rtl::OUString > const & includedPaths, - std::set< rtl::OUString > const & excludedPaths) + css::uno::Sequence< rtl::OUString > const & includedPaths, + css::uno::Sequence< rtl::OUString > const & excludedPaths) + throw (css::uno::RuntimeException) { Broadcaster bc; { osl::MutexGuard g(lock); Modifications mods; Components::getSingleton().insertModificationXcuFile( - fileUri, includedPaths, excludedPaths, &mods); + fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); Components::getSingleton().initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); } +class Factory: + public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, + private boost::noncopyable +{ +public: + Factory() {} + +private: + virtual ~Factory() {} + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + createInstanceWithContext( + css::uno::Reference< css::uno::XComponentContext > const & Context) + throw (css::uno::Exception, css::uno::RuntimeException); + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + createInstanceWithArgumentsAndContext( + css::uno::Sequence< css::uno::Any > const & Arguments, + css::uno::Reference< css::uno::XComponentContext > const & Context) + throw (css::uno::Exception, css::uno::RuntimeException); +}; + +css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( + css::uno::Reference< css::uno::XComponentContext > const & Context) + throw (css::uno::Exception, css::uno::RuntimeException) +{ + return createInstanceWithArgumentsAndContext( + css::uno::Sequence< css::uno::Any >(), Context); +} + +css::uno::Reference< css::uno::XInterface > +Factory::createInstanceWithArgumentsAndContext( + css::uno::Sequence< css::uno::Any > const & Arguments, + css::uno::Reference< css::uno::XComponentContext > const &) + throw (css::uno::Exception, css::uno::RuntimeException) +{ + if (Arguments.getLength() != 0) { + throw css::uno::Exception( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.Update must be" + " instantiated without arguments")), + static_cast< cppu::OWeakObject * >(this)); + } + return static_cast< cppu::OWeakObject * >(new Service); } } + +rtl::OUString getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update")); +} + +css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.Update_Service")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} + +css::uno::Reference< css::lang::XSingleComponentFactory > createFactory( + cppu::ComponentFactoryFunc, rtl::OUString const &, + css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) + SAL_THROW(()) +{ + return new Factory; +} + +} } diff --git a/configmgr/source/update.hxx b/configmgr/source/update.hxx new file mode 100644 index 0000000000..faa5c86b15 --- /dev/null +++ b/configmgr/source/update.hxx @@ -0,0 +1,59 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* 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 +* +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_CONFIGMGR_SOURCE_UPDATE_HXX +#define INCLUDED_CONFIGMGR_SOURCE_UPDATE_HXX + +#include "sal/config.h" + +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/Sequence.hxx" +#include "cppuhelper/factory.hxx" +#include "rtl/unload.h" +#include "sal/types.h" + +namespace com { namespace sun { namespace star { namespace lang { + class XSingleComponentFactory; +} } } } +namespace rtl { class OUString; } + +namespace configmgr { namespace update { + +rtl::OUString SAL_CALL getImplementationName(); + +com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL +getSupportedServiceNames(); + +com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > +SAL_CALL createFactory( + cppu::ComponentFactoryFunc, rtl::OUString const &, + com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) + SAL_THROW(()); + +} } + +#endif -- cgit v1.2.3