summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-01-15 14:59:38 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-01-15 15:11:59 +0100
commitdbd640e501b559e6910950d33b0cfd297d3a1cfd (patch)
tree915f85bf1ea86ef7fffa9844a59e714efb53da78 /sfx2
parent0791e661aeb4161d20828472845f20fa4d3772c9 (diff)
sfx: Use constructor feature for OwnSubFilterService.
Change-Id: I5bc7844c74043640494330fefc87914d4c02b768
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appuno.cxx2
-rw-r--r--sfx2/source/doc/ownsubfilterservice.cxx142
-rw-r--r--sfx2/source/inc/ownsubfilterservice.hxx81
-rw-r--r--sfx2/util/sfx.component3
4 files changed, 67 insertions, 161 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index db5aea6ca8d3..9f7b3e738ab7 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -59,7 +59,6 @@
#include <comphelper/sequence.hxx>
#include <framework/documentundoguard.hxx>
#include <osl/mutex.hxx>
-#include <ownsubfilterservice.hxx>
#include <rtl/ustrbuf.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
@@ -1799,7 +1798,6 @@ SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory(
IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler )
#endif
- IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService )
if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
OUString::createFromAscii( pImplementationName ) ) )
{
diff --git a/sfx2/source/doc/ownsubfilterservice.cxx b/sfx2/source/doc/ownsubfilterservice.cxx
index d3b85a660009..bb817db1e67a 100644
--- a/sfx2/source/doc/ownsubfilterservice.cxx
+++ b/sfx2/source/doc/ownsubfilterservice.cxx
@@ -19,63 +19,70 @@
#include <com/sun/star/frame/DoubleInitializationException.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/io/XStream.hpp>
-#include <ownsubfilterservice.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
#include <sfx2/objsh.hxx>
-using namespace ::com::sun::star;
+using namespace css;
-namespace sfx2 {
+namespace {
-//-------------------------------------------------------------------------
-OwnSubFilterService::OwnSubFilterService( const uno::Reference < lang::XMultiServiceFactory >& xFactory )
-: m_xFactory( xFactory )
-, m_pObjectShell( NULL )
+class OwnSubFilterService : public cppu::WeakImplHelper2 < document::XFilter
+ ,lang::XServiceInfo >
{
-}
-
-//-------------------------------------------------------------------------
-OwnSubFilterService::~OwnSubFilterService()
+ uno::Reference< frame::XModel > m_xModel;
+ uno::Reference< io::XStream > m_xStream;
+ SfxObjectShell* m_pObjectShell;
+
+public:
+ OwnSubFilterService( const uno::Sequence< uno::Any >& aArguments )
+ throw (uno::Exception, uno::RuntimeException);
+ virtual ~OwnSubFilterService();
+
+ // XFilter
+ virtual ::sal_Bool SAL_CALL filter( const uno::Sequence< beans::PropertyValue >& aDescriptor ) throw (uno::RuntimeException);
+ virtual void SAL_CALL cancel() throw (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);
+};
+
+OwnSubFilterService::OwnSubFilterService( const uno::Sequence< uno::Any >& aArguments )
+ throw (uno::Exception, uno::RuntimeException)
+ : m_pObjectShell( NULL )
{
-}
+ if ( aArguments.getLength() != 2 )
+ throw lang::IllegalArgumentException();
-//-------------------------------------------------------------------------
-uno::Sequence< OUString > SAL_CALL OwnSubFilterService::impl_getStaticSupportedServiceNames()
-{
- uno::Sequence< OUString > aRet(2);
- aRet[0] = "com.sun.star.document.OwnSubFilter";
- aRet[1] = "com.sun.star.comp.document.OwnSubFilter";
- return aRet;
-}
+ if ( m_pObjectShell )
+ throw frame::DoubleInitializationException();
-//-------------------------------------------------------------------------
-OUString SAL_CALL OwnSubFilterService::impl_getStaticImplementationName()
-{
- return OUString("com.sun.star.comp.document.OwnSubFilter");
-}
+ if ( ( aArguments[1] >>= m_xStream ) && m_xStream.is()
+ && ( aArguments[0] >>= m_xModel ) && m_xModel.is() )
+ {
+ ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( m_xModel, uno::UNO_QUERY_THROW );
+ ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
+ sal_Int64 nHandle = xObj->getSomething( aSeq );
+ if ( nHandle )
+ m_pObjectShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
+ }
-//-------------------------------------------------------------------------
-uno::Reference< uno::XInterface > SAL_CALL OwnSubFilterService::impl_staticCreateSelfInstance(
- const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
-{
- return uno::Reference< uno::XInterface >( *new OwnSubFilterService( xServiceManager ) );
+ if ( !m_pObjectShell )
+ throw lang::IllegalArgumentException();
}
-//-------------------------------------------------------------------------
-uno::Reference< lang::XSingleServiceFactory > SAL_CALL OwnSubFilterService::impl_createFactory(
- const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
+OwnSubFilterService::~OwnSubFilterService()
{
- return ::cppu::createSingleFactory( xServiceManager,
- OwnSubFilterService::impl_getStaticImplementationName(),
- OwnSubFilterService::impl_staticCreateSelfInstance,
- OwnSubFilterService::impl_getStaticSupportedServiceNames() );
}
-
-// XFilter
-
-//-------------------------------------------------------------------------
sal_Bool SAL_CALL OwnSubFilterService::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
throw (uno::RuntimeException)
{
@@ -85,48 +92,16 @@ sal_Bool SAL_CALL OwnSubFilterService::filter( const uno::Sequence< beans::Prope
return m_pObjectShell->ImportFromGeneratedStream_Impl( m_xStream, aDescriptor );
}
-//-------------------------------------------------------------------------
void SAL_CALL OwnSubFilterService::cancel()
throw (uno::RuntimeException)
{
// not implemented
}
-
-// XInitialization
-
-//-------------------------------------------------------------------------
-void SAL_CALL OwnSubFilterService::initialize( const uno::Sequence< uno::Any >& aArguments )
- throw (uno::Exception, uno::RuntimeException)
-{
- if ( !m_xFactory.is() )
- throw uno::RuntimeException();
-
- if ( aArguments.getLength() != 2 )
- throw lang::IllegalArgumentException();
-
- if ( m_pObjectShell )
- throw frame::DoubleInitializationException();
-
- if ( ( aArguments[1] >>= m_xStream ) && m_xStream.is()
- && ( aArguments[0] >>= m_xModel ) && m_xModel.is() )
- {
- ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( m_xModel, uno::UNO_QUERY_THROW );
- ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
- sal_Int64 nHandle = xObj->getSomething( aSeq );
- if ( nHandle )
- m_pObjectShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
- }
-
- if ( !m_pObjectShell )
- throw lang::IllegalArgumentException();
-}
-
-// XServiceInfo
OUString SAL_CALL OwnSubFilterService::getImplementationName()
throw ( uno::RuntimeException )
{
- return impl_getStaticImplementationName();
+ return OUString("com.sun.star.comp.document.OwnSubFilter");
}
sal_Bool SAL_CALL OwnSubFilterService::supportsService( const OUString& ServiceName )
@@ -138,9 +113,22 @@ sal_Bool SAL_CALL OwnSubFilterService::supportsService( const OUString& ServiceN
uno::Sequence< OUString > SAL_CALL OwnSubFilterService::getSupportedServiceNames()
throw ( uno::RuntimeException )
{
- return impl_getStaticSupportedServiceNames();
+ uno::Sequence< OUString > aRet(2);
+ aRet[0] = "com.sun.star.document.OwnSubFilter";
+ aRet[1] = "com.sun.star.comp.document.OwnSubFilter";
+ return aRet;
}
-} // namespace sfx2
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_document_OwnSubFilter_get_implementation(
+ css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &arguments)
+{
+ rtl::Reference<OwnSubFilterService> x(new OwnSubFilterService(arguments));
+ x->acquire();
+ return static_cast<cppu::OWeakObject *>(x.get());
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/ownsubfilterservice.hxx b/sfx2/source/inc/ownsubfilterservice.hxx
deleted file mode 100644
index 3a2be4f1685f..000000000000
--- a/sfx2/source/inc/ownsubfilterservice.hxx
+++ /dev/null
@@ -1,81 +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_INC_OWNSUBFILTERSERVICE_HXX
-#define INCLUDED_SFX2_SOURCE_INC_OWNSUBFILTERSERVICE_HXX
-
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/io/XStream.hpp>
-#include <cppuhelper/implbase3.hxx>
-
-class SfxObjectShell;
-
-namespace sfx2 {
-
-class OwnSubFilterService : public cppu::WeakImplHelper3 < ::com::sun::star::document::XFilter
- ,::com::sun::star::lang::XInitialization
- ,::com::sun::star::lang::XServiceInfo >
-{
- ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream;
- SfxObjectShell* m_pObjectShell;
-
-public:
-
- OwnSubFilterService(const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory);
- virtual ~OwnSubFilterService();
-
- 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::uno::XInterface > SAL_CALL
- impl_staticCreateSelfInstance(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
-
- 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 );
-
-
- // XFilter
- virtual ::sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL cancel() throw (::com::sun::star::uno::RuntimeException);
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::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);
-
-};
-
-} // namespace sfx2
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/util/sfx.component b/sfx2/util/sfx.component
index d1fee9b523ec..286c202897b0 100644
--- a/sfx2/util/sfx.component
+++ b/sfx2/util/sfx.component
@@ -32,7 +32,8 @@
<implementation name="com.sun.star.comp.desktop.QuickstartWrapper">
<service name="com.sun.star.office.Quickstart"/>
</implementation>
- <implementation name="com.sun.star.comp.document.OwnSubFilter">
+ <implementation name="com.sun.star.comp.document.OwnSubFilter"
+ constructor="com_sun_star_comp_document_OwnSubFilter_get_implementation">
<service name="com.sun.star.comp.document.OwnSubFilter"/>
<service name="com.sun.star.document.OwnSubFilter"/>
</implementation>