diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-15 16:48:16 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-01-16 10:24:58 +0100 |
commit | 2b30c5057800e39fb6129be4b175ee10bf5f0e5e (patch) | |
tree | 5c3013c6e8d6bbe85a85fba5de3663fd4a25868e /sfx2 | |
parent | a384b21cc40818bf3c918951a086a30b5d9d8022 (diff) |
sfx: Constructor feature for two more implementations.
Change-Id: Icd387ff97c5df3cea9b20b0b893616812457e493
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 17 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 78 | ||||
-rw-r--r-- | sfx2/source/inc/SfxDocumentMetaData.hxx | 49 | ||||
-rw-r--r-- | sfx2/util/sfx.component | 6 |
4 files changed, 28 insertions, 122 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index bb21a6ca863e..5bad955a2b7a 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -22,7 +22,6 @@ #endif #include "backingcomp.hxx" -#include "SfxDocumentMetaData.hxx" #include "eventsupplier.hxx" #include "fltoptint.hxx" #include "objshimp.hxx" @@ -1798,22 +1797,6 @@ SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory( IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler ) IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler ) #endif - if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals( - OUString::createFromAscii( pImplementationName ) ) ) - { - xFactory = ::cppu::createSingleComponentFactory( - ::comp_SfxDocumentMetaData::_create, - ::comp_SfxDocumentMetaData::_getImplementationName(), - ::comp_SfxDocumentMetaData::_getSupportedServiceNames()); - } - if ( ::comp_CompatWriterDocProps::_getImplementationName().equals( - OUString::createFromAscii( pImplementationName ) ) ) - { - xFactory = ::cppu::createSingleComponentFactory( - ::comp_CompatWriterDocProps::_create, - ::comp_CompatWriterDocProps::_getImplementationName(), - ::comp_CompatWriterDocProps::_getSupportedServiceNames()); - } // Factory is valid - service was found. diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 4f51051d1492..9e1d2f12ede5 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -56,7 +56,7 @@ #include <com/sun/star/util/DateTimeWithTimezone.hpp> #include <com/sun/star/util/Duration.hpp> -#include "SfxDocumentMetaData.hxx" +#include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> #include <tools/datetime.hxx> @@ -377,7 +377,7 @@ public: // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) { - return comp_CompatWriterDocProps::_getImplementationName(); + return OUString("CompatWriterDocPropsImpl"); } virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException) @@ -387,7 +387,9 @@ public: virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) { - return comp_CompatWriterDocProps::_getSupportedServiceNames(); + css::uno::Sequence< OUString > aServiceNames(1); + aServiceNames[ 0 ] = "com.sun.star.writer.DocumentProperties"; + return aServiceNames; } }; @@ -1384,27 +1386,23 @@ SfxDocumentMetaData::SfxDocumentMetaData( OUString SAL_CALL SfxDocumentMetaData::getImplementationName() throw (css::uno::RuntimeException) { - return comp_SfxDocumentMetaData::_getImplementationName(); + return OUString("SfxDocumentMetaData"); } ::sal_Bool SAL_CALL SfxDocumentMetaData::supportsService(OUString const & serviceName) throw (css::uno::RuntimeException) { - css::uno::Sequence< OUString > serviceNames = - comp_SfxDocumentMetaData::_getSupportedServiceNames(); - for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) { - if (serviceNames[i] == serviceName) - return sal_True; - } - return sal_False; + return cppu::supportsService(this, serviceName); } css::uno::Sequence< OUString > SAL_CALL SfxDocumentMetaData::getSupportedServiceNames() throw (css::uno::RuntimeException) { - return comp_SfxDocumentMetaData::_getSupportedServiceNames(); + css::uno::Sequence< OUString > s(1); + s[0] = "com.sun.star.document.DocumentProperties"; + return s; } @@ -2316,52 +2314,24 @@ void SfxDocumentMetaData::createUserDefined() } // closing anonymous implementation namespace - -// component helper namespace -namespace comp_CompatWriterDocProps { - - OUString SAL_CALL _getImplementationName() { - return OUString("CompatWriterDocPropsImpl"); - } - - css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames() - { - css::uno::Sequence< OUString > aServiceNames(1); - aServiceNames[ 0 ] = "com.sun.star.writer.DocumentProperties"; - return aServiceNames; - } - - css::uno::Reference< css::uno::XInterface > SAL_CALL _create( - const css::uno::Reference< css::uno::XComponentContext > & context) - SAL_THROW((css::uno::Exception)) - { - return static_cast< ::cppu::OWeakObject * > - (new CompatWriterDocPropsImpl(context)); - } - -} - -namespace comp_SfxDocumentMetaData { - -OUString SAL_CALL _getImplementationName() { - return OUString("SfxDocumentMetaData"); -} - -css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +CompatWriterDocPropsImpl_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) { - css::uno::Sequence< OUString > s(1); - s[0] = "com.sun.star.document.DocumentProperties"; - return s; + rtl::Reference<CompatWriterDocPropsImpl> x(new CompatWriterDocPropsImpl(context)); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); } -css::uno::Reference< css::uno::XInterface > SAL_CALL _create( - const css::uno::Reference< css::uno::XComponentContext > & context) - SAL_THROW((css::uno::Exception)) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +SfxDocumentMetaData_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) { - return static_cast< ::cppu::OWeakObject * > - (new SfxDocumentMetaData(context)); + rtl::Reference<SfxDocumentMetaData> x(new SfxDocumentMetaData(context)); + x->acquire(); + return static_cast<cppu::OWeakObject *>(x.get()); } -} // closing component helper namespace - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/SfxDocumentMetaData.hxx b/sfx2/source/inc/SfxDocumentMetaData.hxx deleted file mode 100644 index dd2ba065a982..000000000000 --- a/sfx2/source/inc/SfxDocumentMetaData.hxx +++ /dev/null @@ -1,49 +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_SFXDOCUMENTMETADATA_HXX -#define INCLUDED_SFX2_SOURCE_INC_SFXDOCUMENTMETADATA_HXX - -#include <sal/config.h> -#include <cppuhelper/factory.hxx> - - -// component helper namespace -namespace comp_SfxDocumentMetaData { - -// component and service helper functions: -OUString SAL_CALL _getImplementationName(); -css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames(); -css::uno::Reference< css::uno::XInterface > SAL_CALL _create( - css::uno::Reference< css::uno::XComponentContext > const & context ); - -} // closing component helper namespace - -namespace comp_CompatWriterDocProps { - -// component and service helper functions: -OUString SAL_CALL _getImplementationName(); -css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames(); -css::uno::Reference< css::uno::XInterface > SAL_CALL _create( - css::uno::Reference< css::uno::XComponentContext > const & context ); - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/util/sfx.component b/sfx2/util/sfx.component index f8b6839b39a2..09ab1328cafd 100644 --- a/sfx2/util/sfx.component +++ b/sfx2/util/sfx.component @@ -23,10 +23,12 @@ <service name="com.sun.star.frame.StartModule"/> <service name="com.sun.star.frame.ProtocolHandler"/> </implementation> - <implementation name="SfxDocumentMetaData"> + <implementation name="SfxDocumentMetaData" + constructor="SfxDocumentMetaData_get_implementation"> <service name="com.sun.star.document.DocumentProperties"/> </implementation> - <implementation name="CompatWriterDocPropsImpl"> + <implementation name="CompatWriterDocPropsImpl" + constructor="CompatWriterDocPropsImpl_get_implementation"> <service name="com.sun.star.writer.DocumentProperties"/> </implementation> <implementation name="com.sun.star.comp.desktop.QuickstartWrapper" |