diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-23 09:40:48 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-23 10:28:40 +0100 |
commit | c04f3c0f794e8c608fade8c6142db13c32e6f4e7 (patch) | |
tree | 31a137a18863dbb39740c56a5b44d8b9d943086e /svtools | |
parent | a587899cb340d2a5bc05392e1817ba72718706f1 (diff) |
svt: use constructor feature for HatchWindowFactory.
Change-Id: I0881c0994342816b8f0ac0281d884ce618d5e285
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/hatchwindow/hatchwindowfactory.cxx | 58 | ||||
-rw-r--r-- | svtools/source/inc/hatchwindowfactory.hxx | 39 | ||||
-rw-r--r-- | svtools/source/uno/miscservices.cxx | 8 | ||||
-rw-r--r-- | svtools/util/svt.component | 3 |
4 files changed, 39 insertions, 69 deletions
diff --git a/svtools/source/hatchwindow/hatchwindowfactory.cxx b/svtools/source/hatchwindow/hatchwindowfactory.cxx index f728add78d14..ea87180098f4 100644 --- a/svtools/source/hatchwindow/hatchwindowfactory.cxx +++ b/svtools/source/hatchwindow/hatchwindowfactory.cxx @@ -17,34 +17,33 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "hatchwindowfactory.hxx" -#include "hatchwindow.hxx" -#include "cppuhelper/factory.hxx" +#include <com/sun/star/embed/XHatchWindowFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase2.hxx> #include <cppuhelper/supportsservice.hxx> #include <vcl/svapp.hxx> -#include "documentcloser.hxx" +#include <hatchwindow.hxx> using namespace ::com::sun::star; -uno::Sequence< OUString > SAL_CALL OHatchWindowFactory::impl_staticGetSupportedServiceNames() -{ - uno::Sequence< OUString > aRet(2); - aRet[0] = "com.sun.star.embed.HatchWindowFactory"; - aRet[1] = "com.sun.star.comp.embed.HatchWindowFactory"; - return aRet; -} +namespace { -OUString SAL_CALL OHatchWindowFactory::impl_staticGetImplementationName() +class OHatchWindowFactory : public ::cppu::WeakImplHelper2< + embed::XHatchWindowFactory, + lang::XServiceInfo > { - return OUString( "com.sun.star.comp.embed.HatchWindowFactory" ); -} +public: + OHatchWindowFactory() {} -uno::Reference< uno::XInterface > SAL_CALL OHatchWindowFactory::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new OHatchWindowFactory( xServiceManager ) ); -} + // XHatchWindowFactory + virtual uno::Reference< embed::XHatchWindow > SAL_CALL createHatchWindowInstance( const uno::Reference< awt::XWindowPeer >& xParent, const awt::Rectangle& aBounds, const awt::Size& aSize ) 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); +}; uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchWindowInstance( const uno::Reference< awt::XWindowPeer >& xParent, @@ -64,7 +63,7 @@ uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchW OUString SAL_CALL OHatchWindowFactory::getImplementationName() throw ( uno::RuntimeException ) { - return impl_staticGetImplementationName(); + return OUString( "com.sun.star.comp.embed.HatchWindowFactory" ); } sal_Bool SAL_CALL OHatchWindowFactory::supportsService( const OUString& ServiceName ) @@ -76,7 +75,24 @@ sal_Bool SAL_CALL OHatchWindowFactory::supportsService( const OUString& ServiceN uno::Sequence< OUString > SAL_CALL OHatchWindowFactory::getSupportedServiceNames() throw ( uno::RuntimeException ) { - return impl_staticGetSupportedServiceNames(); + uno::Sequence< OUString > aRet(2); + aRet[0] = "com.sun.star.embed.HatchWindowFactory"; + aRet[1] = "com.sun.star.comp.embed.HatchWindowFactory"; + return aRet; +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_embed_HatchWindowFactory_get_implementation( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) +{ + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + css::uno::Reference<css::uno::XInterface> x( + static_cast<cppu::OWeakObject *>(new OHatchWindowFactory)); + x->acquire(); + return x.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/inc/hatchwindowfactory.hxx b/svtools/source/inc/hatchwindowfactory.hxx index ed8d35c6c264..af11bd05c03b 100644 --- a/svtools/source/inc/hatchwindowfactory.hxx +++ b/svtools/source/inc/hatchwindowfactory.hxx @@ -20,45 +20,6 @@ #ifndef INCLUDED_SVTOOLS_SOURCE_HATCHWINDOW_HATCHWINDOWFACTORY_HXX #define INCLUDED_SVTOOLS_SOURCE_HATCHWINDOW_HATCHWINDOWFACTORY_HXX -#include <com/sun/star/embed/XHatchWindowFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> - - -#include <cppuhelper/implbase2.hxx> - - -class OHatchWindowFactory : public ::cppu::WeakImplHelper2< - ::com::sun::star::embed::XHatchWindowFactory, - ::com::sun::star::lang::XServiceInfo > -{ - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; - -public: - OHatchWindowFactory( - 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_staticGetSupportedServiceNames(); - - static OUString SAL_CALL impl_staticGetImplementationName(); - - 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 ); - - - // XHatchWindowFactory - virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XHatchWindow > SAL_CALL createHatchWindowInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, const ::com::sun::star::awt::Rectangle& aBounds, const ::com::sun::star::awt::Size& aSize ) throw (::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 diff --git a/svtools/source/uno/miscservices.cxx b/svtools/source/uno/miscservices.cxx index 60154934b78e..62f60cbccc50 100644 --- a/svtools/source/uno/miscservices.cxx +++ b/svtools/source/uno/miscservices.cxx @@ -27,7 +27,6 @@ #include <osl/diagnose.h> #include <uno/mapping.hxx> #include "documentcloser.hxx" -#include "hatchwindowfactory.hxx" #include "hatchwindow.hxx" #include "provider.hxx" #include "unowizard.hxx" @@ -127,13 +126,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory ( ODocumentCloser::impl_staticCreateSelfInstance, ODocumentCloser::impl_staticGetSupportedServiceNames()); } - else if (rtl_str_compare (pImplementationName, "com.sun.star.comp.embed.HatchWindowFactory") == 0) - { - xFactory = ::cppu::createOneInstanceFactory(xSMgr, - OHatchWindowFactory::impl_staticGetImplementationName(), - OHatchWindowFactory::impl_staticCreateSelfInstance, - OHatchWindowFactory::impl_staticGetSupportedServiceNames()); - } else { pResult = comphelper::service_decl::component_getFactoryHelper( diff --git a/svtools/util/svt.component b/svtools/util/svt.component index 021d23f462de..dbba9e74d708 100644 --- a/svtools/util/svt.component +++ b/svtools/util/svt.component @@ -49,7 +49,8 @@ <implementation name="com.sun.star.comp.embed.DocumentCloser"> <service name="com.sun.star.embed.DocumentCloser"/> </implementation> - <implementation name="com.sun.star.comp.embed.HatchWindowFactory"> + <implementation name="com.sun.star.comp.embed.HatchWindowFactory" + constructor="com_sun_star_comp_embed_HatchWindowFactory_get_implementation"> <service name="com.sun.star.comp.embed.HatchWindowFactory"/> <service name="com.sun.star.embed.HatchWindowFactory"/> </implementation> |