diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-15 14:43:04 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-15 15:11:58 +0100 |
commit | 0791e661aeb4161d20828472845f20fa4d3772c9 (patch) | |
tree | f7a55c2dd67aa58019a65b26a16c0a02846b72fd /sfx2 | |
parent | a16bf89a1284246d53f397c33300164ce6027863 (diff) |
sfx: Use constructor feature for OPackageStructureCreator.
Change-Id: I604132c35cf95ecb3a4dad0bfef5ec50dfa58645
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/xpackcreator.cxx | 69 | ||||
-rw-r--r-- | sfx2/source/appl/xpackcreator.hxx | 68 | ||||
-rw-r--r-- | sfx2/util/sfx.component | 3 |
4 files changed, 37 insertions, 105 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 5fb2fb78e1aa..db5aea6ca8d3 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -44,7 +44,6 @@ #include "sfxslots.hxx" #include "sfxtypes.hxx" #include "shutdownicon.hxx" -#include "xpackcreator.hxx" #include <sal/config.h> #include <basic/basmgr.hxx> @@ -1800,7 +1799,6 @@ SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory( IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler ) IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler ) #endif - IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator ) IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService ) if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) diff --git a/sfx2/source/appl/xpackcreator.cxx b/sfx2/source/appl/xpackcreator.cxx index fbe0a40f7f2a..5fcc44550d0f 100644 --- a/sfx2/source/appl/xpackcreator.cxx +++ b/sfx2/source/appl/xpackcreator.cxx @@ -19,11 +19,13 @@ #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/io/XOutputStream.hpp> -#include <cppuhelper/supportsservice.hxx> - -#include "xpackcreator.hxx" +#include <com/sun/star/embed/XPackageStructureCreator.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/processfactory.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <rtl/ref.hxx> #include <sot/stg.hxx> #include <sot/storage.hxx> #include <tools/stream.hxx> @@ -32,40 +34,24 @@ #include <ucbhelper/content.hxx> #include <ucbhelper/commandenvironment.hxx> -using namespace ::com::sun::star; +using namespace css; -//------------------------------------------------------------------------- -uno::Sequence< OUString > SAL_CALL OPackageStructureCreator::impl_getStaticSupportedServiceNames() -{ - uno::Sequence< OUString > aRet(2); - aRet[0] = "com.sun.star.embed.PackageStructureCreator"; - aRet[1] = "com.sun.star.comp.embed.PackageStructureCreator"; - return aRet; -} - -//------------------------------------------------------------------------- -OUString SAL_CALL OPackageStructureCreator::impl_getStaticImplementationName() -{ - return OUString("com.sun.star.comp.embed.PackageStructureCreator"); -} +namespace { -//------------------------------------------------------------------------- -uno::Reference< lang::XSingleServiceFactory > SAL_CALL OPackageStructureCreator::impl_createFactory( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) +class OPackageStructureCreator : public ::cppu::WeakImplHelper2< embed::XPackageStructureCreator, + lang::XServiceInfo > { - return ::cppu::createOneInstanceFactory( xServiceManager, - OPackageStructureCreator::impl_getStaticImplementationName(), - OPackageStructureCreator::impl_staticCreateSelfInstance, - OPackageStructureCreator::impl_getStaticSupportedServiceNames() ); -} +public: + OPackageStructureCreator() {} -//------------------------------------------------------------------------- -uno::Reference< uno::XInterface > SAL_CALL OPackageStructureCreator::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new OPackageStructureCreator( xServiceManager ) ); -} + // XPackageStructureCreator + virtual void SAL_CALL convertToPackage( const OUString& aFolderUrl, const uno::Reference< io::XOutputStream >& xTargetStream ) throw (io::IOException, uno::RuntimeException); + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (uno::RuntimeException); + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException); +}; //------------------------------------------------------------------------- void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolderUrl, @@ -167,7 +153,7 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde OUString SAL_CALL OPackageStructureCreator::getImplementationName() throw ( uno::RuntimeException ) { - return impl_getStaticImplementationName(); + return OUString("com.sun.star.comp.embed.PackageStructureCreator"); } sal_Bool SAL_CALL OPackageStructureCreator::supportsService( const OUString& ServiceName ) @@ -179,7 +165,22 @@ sal_Bool SAL_CALL OPackageStructureCreator::supportsService( const OUString& Ser uno::Sequence< OUString > SAL_CALL OPackageStructureCreator::getSupportedServiceNames() throw ( uno::RuntimeException ) { - return impl_getStaticSupportedServiceNames(); + uno::Sequence< OUString > aRet(2); + aRet[0] = "com.sun.star.embed.PackageStructureCreator"; + aRet[1] = "com.sun.star.comp.embed.PackageStructureCreator"; + return aRet; +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_embed_PackageStructureCreator_get_implementation( + css::uno::XComponentContext *, + css::uno::Sequence<css::uno::Any> const &) +{ + rtl::Reference<OPackageStructureCreator> x(new OPackageStructureCreator()); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/xpackcreator.hxx b/sfx2/source/appl/xpackcreator.hxx deleted file mode 100644 index ca90b0cad7c5..000000000000 --- a/sfx2/source/appl/xpackcreator.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SFX2_SOURCE_APPL_XPACKCREATOR_HXX -#define INCLUDED_SFX2_SOURCE_APPL_XPACKCREATOR_HXX - -#include <com/sun/star/embed/XPackageStructureCreator.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> - - -#include <cppuhelper/implbase2.hxx> - - -class OPackageStructureCreator : public ::cppu::WeakImplHelper2< ::com::sun::star::embed::XPackageStructureCreator, - ::com::sun::star::lang::XServiceInfo > -{ - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; - -public: - OPackageStructureCreator( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ) - : m_xFactory( xFactory ) - { - OSL_ENSURE( xFactory.is(), "No service manager is provided!\n" ); - } - - static ::com::sun::star::uno::Sequence< OUString > SAL_CALL impl_getStaticSupportedServiceNames(); - - static OUString SAL_CALL impl_getStaticImplementationName(); - - static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL - impl_createFactory( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); - - static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL - impl_staticCreateSelfInstance( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); - - // XPackageStructureCreator - virtual void SAL_CALL convertToPackage( const OUString& aFolderUrl, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xTargetStream ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException); - -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/util/sfx.component b/sfx2/util/sfx.component index b12d30ca22e8..d1fee9b523ec 100644 --- a/sfx2/util/sfx.component +++ b/sfx2/util/sfx.component @@ -36,7 +36,8 @@ <service name="com.sun.star.comp.document.OwnSubFilter"/> <service name="com.sun.star.document.OwnSubFilter"/> </implementation> - <implementation name="com.sun.star.comp.embed.PackageStructureCreator"> + <implementation name="com.sun.star.comp.embed.PackageStructureCreator" + constructor="com_sun_star_comp_embed_PackageStructureCreator_get_implementation"> <service name="com.sun.star.comp.embed.PackageStructureCreator"/> <service name="com.sun.star.embed.PackageStructureCreator"/> </implementation> |