Kaydet (Commit) 0791e661 authored tarafından Matúš Kukan's avatar Matúš Kukan

sfx: Use constructor feature for OPackageStructureCreator.

Change-Id: I604132c35cf95ecb3a4dad0bfef5ec50dfa58645
üst a16bf89a
......@@ -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 ) ) )
......
......@@ -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: */
/* -*- 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: */
......@@ -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>
......
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