From 5bf7b06c937ef08478831bc42b344dc96986a881 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Mon, 30 Dec 2013 13:19:36 +0100 Subject: svx: Constructor feature for last implementations in svx component. Change-Id: Ifc021eabce9ae3dbd1a54edefda7d3ae3eb67b53 --- solenv/bin/native-code.py | 4 +- .../customshapes/EnhancedCustomShapeEngine.cxx | 102 +++++++++++++++++---- .../customshapes/EnhancedCustomShapeEngine.hxx | 96 ------------------- svx/source/unodraw/unoctabl.cxx | 87 +++--------------- svx/util/svx.component | 8 +- 5 files changed, 105 insertions(+), 192 deletions(-) delete mode 100644 svx/source/customshapes/EnhancedCustomShapeEngine.hxx diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index ebdd5dba9004..8edc9682c65d 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -45,7 +45,6 @@ core_factory_list = [ ("libspelllo.a", "spell_component_getFactory"), ("libsvllo.a", "svl_component_getFactory"), ("libsvtlo.a", "svt_component_getFactory"), - ("libsvxlo.a", "svx_component_getFactory"), ("libtklo.a", "tk_component_getFactory"), ("libucb1.a", "ucb_component_getFactory"), ("libucpexpand1lo.a", "ucpexpand1_component_getFactory"), @@ -143,6 +142,9 @@ core_constructor_list = [ "com_sun_star_comp_stoc_SimpleRegistry", "com_sun_star_security_comp_stoc_AccessController", "com_sun_star_security_comp_stoc_FilePolicy", +# svx/util/svx.component +# FIXME: what is missing ? + "com_sun_star_drawing_SvxShapeCollection_implementation_getFactory", ] # Components which are not in any group yet: diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index bfaa79119530..b9bc674c4d14 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -17,7 +17,14 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "EnhancedCustomShapeEngine.hxx" +#include +#include +#include +#include +#include +#include +#include +#include #include "svx/EnhancedCustomShape2d.hxx" #include "EnhancedCustomShape3d.hxx" #include "EnhancedCustomShapeFontWork.hxx" @@ -42,29 +49,61 @@ #include #include #include +#include #include using namespace css; using namespace css::uno; -// - EnhancedCustomShapeEngine - -OUString EnhancedCustomShapeEngine_getImplementationName() - throw( RuntimeException ) -{ - return OUString( "com.sun.star.drawing.EnhancedCustomShapeEngine" ); -} +class SdrObject; +class SdrObjCustomShape; -Sequence< OUString > SAL_CALL EnhancedCustomShapeEngine_getSupportedServiceNames() - throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.drawing.CustomShapeEngine"; - return aRet; -} +namespace { -EnhancedCustomShapeEngine::EnhancedCustomShapeEngine( const Reference< lang::XMultiServiceFactory >& rxMgr ) : - mxFact ( rxMgr ), +class EnhancedCustomShapeEngine : public cppu::WeakImplHelper3 +< + css::lang::XInitialization, + css::lang::XServiceInfo, + css::drawing::XCustomShapeEngine +> +{ + css::uno::Reference< css::drawing::XShape > mxShape; + sal_Bool mbForceGroupWithText; + + SdrObject* ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape ); + +public: + EnhancedCustomShapeEngine(); + virtual ~EnhancedCustomShapeEngine(); + + // XInterface + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) + throw ( css::uno::Exception, css::uno::RuntimeException ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() + throw ( css::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) + throw ( css::uno::RuntimeException ); + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() + throw ( css::uno::RuntimeException ); + + // XCustomShapeEngine + virtual css::uno::Reference< css::drawing::XShape > SAL_CALL render() + throw ( css::uno::RuntimeException ); + virtual css::awt::Rectangle SAL_CALL getTextBounds() + throw ( css::uno::RuntimeException ); + virtual css::drawing::PolyPolygonBezierCoords SAL_CALL getLineGeometry() + throw ( css::uno::RuntimeException ); + virtual css::uno::Sequence< css::uno::Reference< css::drawing::XCustomShapeHandle > > SAL_CALL getInteraction() + throw ( css::uno::RuntimeException ); +}; + +EnhancedCustomShapeEngine::EnhancedCustomShapeEngine() : mbForceGroupWithText ( sal_False ) { } @@ -109,7 +148,7 @@ void SAL_CALL EnhancedCustomShapeEngine::initialize( const Sequence< Any >& aArg OUString SAL_CALL EnhancedCustomShapeEngine::getImplementationName() throw( RuntimeException ) { - return EnhancedCustomShapeEngine_getImplementationName(); + return OUString( "com.sun.star.drawing.EnhancedCustomShapeEngine" ); } sal_Bool SAL_CALL EnhancedCustomShapeEngine::supportsService( const OUString& rServiceName ) throw( RuntimeException ) @@ -119,7 +158,10 @@ sal_Bool SAL_CALL EnhancedCustomShapeEngine::supportsService( const OUString& rS Sequence< OUString > SAL_CALL EnhancedCustomShapeEngine::getSupportedServiceNames() throw ( RuntimeException ) { - return EnhancedCustomShapeEngine_getSupportedServiceNames(); + Sequence< OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.drawing.CustomShapeEngine"; + return aRet; } // XCustomShapeEngine ----------------------------------------------------------- @@ -444,4 +486,26 @@ Sequence< Reference< drawing::XCustomShapeHandle > > SAL_CALL EnhancedCustomShap return aSeq; } +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_drawing_EnhancedCustomShapeEngine_implementation_getFactory( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) +{ + assert(arguments != 0); + css::uno::Reference x( + static_cast(new EnhancedCustomShapeEngine)); + x->acquire(); + css::uno::Reference< css::lang::XInitialization > xx(x, css::uno::UNO_QUERY); + if (xx.is()) + { + css::uno::Sequence aArgs( + reinterpret_cast(arguments->elements), + arguments->nElements); + xx->initialize(aArgs); + } + return x.get(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.hxx b/svx/source/customshapes/EnhancedCustomShapeEngine.hxx deleted file mode 100644 index ae90045a1f87..000000000000 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.hxx +++ /dev/null @@ -1,96 +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_SVX_SOURCE_CUSTOMSHAPES_ENHANCEDCUSTOMSHAPEENGINE_HXX -#define INCLUDED_SVX_SOURCE_CUSTOMSHAPES_ENHANCEDCUSTOMSHAPEENGINE_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// --------------------------- -// - EnhancedCustomShapeEngine - -// --------------------------- -// - -class SdrObject; -class SdrObjCustomShape; -class EnhancedCustomShapeEngine : public cppu::WeakImplHelper3 -< - css::lang::XInitialization, - css::lang::XServiceInfo, - css::drawing::XCustomShapeEngine -> -{ - css::uno::Reference< css::lang::XMultiServiceFactory > mxFact; - css::uno::Reference< css::drawing::XShape > mxShape; - sal_Bool mbForceGroupWithText; - - SdrObject* ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape ); - -public: - EnhancedCustomShapeEngine( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMgr ); - virtual ~EnhancedCustomShapeEngine(); - - // XInterface - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XInitialization - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) - throw ( css::uno::Exception, css::uno::RuntimeException ); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() - throw ( css::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) - throw ( css::uno::RuntimeException ); - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() - throw ( css::uno::RuntimeException ); - - // XCustomShapeEngine - virtual css::uno::Reference< css::drawing::XShape > SAL_CALL render() - throw ( css::uno::RuntimeException ); - virtual css::awt::Rectangle SAL_CALL getTextBounds() - throw ( css::uno::RuntimeException ); - virtual css::drawing::PolyPolygonBezierCoords SAL_CALL getLineGeometry() - throw ( css::uno::RuntimeException ); - virtual css::uno::Sequence< css::uno::Reference< css::drawing::XCustomShapeHandle > > SAL_CALL getInteraction() - throw ( css::uno::RuntimeException ); -}; - -OUString EnhancedCustomShapeEngine_getImplementationName() - throw ( css::uno::RuntimeException ); -sal_Bool SAL_CALL EnhancedCustomShapeEngine_supportsService( const OUString& rServiceName ) - throw( css::uno::RuntimeException ); -css::uno::Sequence< OUString > SAL_CALL EnhancedCustomShapeEngine_getSupportedServiceNames() - throw( css::uno::RuntimeException ); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index 1c952142427a..925265bff15c 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -20,17 +20,15 @@ #include #include #include +#include #include - -#include "../customshapes/EnhancedCustomShapeEngine.hxx" - #include using namespace ::com::sun::star; -using namespace ::rtl; -using namespace ::cppu; -class SvxUnoColorTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +namespace { + +class SvxUnoColorTable : public cppu::WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > { private: XColorListRef pList; @@ -44,13 +42,6 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString("com.sun.star.drawing.SvxUnoColorTable"); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - // XNameContainer virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); @@ -93,16 +84,11 @@ sal_Bool SAL_CALL SvxUnoColorTable::supportsService( const OUString& ServiceNam OUString SAL_CALL SvxUnoColorTable::getImplementationName() throw( uno::RuntimeException ) { - return OUString("SvxUnoColorTable"); + return OUString("com.sun.star.drawing.SvxUnoColorTable"); } uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getSupportedServiceNames() throw( uno::RuntimeException ) -{ - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoColorTable::getSupportedServiceNames_Static(void) throw() { uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = "com.sun.star.drawing.ColorTable"; @@ -202,63 +188,18 @@ sal_Bool SAL_CALL SvxUnoColorTable::hasElements() return pList.is() && pList->Count() != 0; } -/** - * Create a colortable - */ -uno::Reference< uno::XInterface > SAL_CALL SvxUnoColorTable_createInstance(const uno::Reference< lang::XMultiServiceFactory > & ) throw(uno::Exception) -{ - return *new SvxUnoColorTable(); } -uno::Reference< uno::XInterface > SAL_CALL create_EnhancedCustomShapeEngine( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) throw(uno::Exception) -{ - return *new EnhancedCustomShapeEngine( rxFact ); -} - -// -// export this service -// - -#include -#include "sal/types.h" -#include "osl/diagnose.h" -#include "cppuhelper/factory.hxx" - -extern "C" -{ -SAL_DLLPUBLIC_EXPORT void * SAL_CALL svx_component_getFactory ( - const sal_Char * pImplName, void * pServiceManager, void * ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_drawing_SvxUnoColorTable_implementation_getFactory( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) { - void * pRet = 0; - if( pServiceManager ) - { - uno::Reference< lang::XSingleServiceFactory > xFactory; - - if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxUnoColorTable" ) == 0 ) - { - xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), - SvxUnoColorTable::getImplementationName_Static(), - SvxUnoColorTable_createInstance, - SvxUnoColorTable::getSupportedServiceNames_Static() ); - } - else if ( rtl_str_compare( pImplName, "com.sun.star.drawing.EnhancedCustomShapeEngine" ) == 0 ) - { - xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), - EnhancedCustomShapeEngine_getImplementationName(), - create_EnhancedCustomShapeEngine, - EnhancedCustomShapeEngine_getSupportedServiceNames() ); - } - - if( xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; -} - + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + css::uno::Reference x( + static_cast(new SvxUnoColorTable)); + x->acquire(); + return x.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/util/svx.component b/svx/util/svx.component index da40ece83729..848b28e433cf 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -18,7 +18,7 @@ --> + xmlns="http://openoffice.org/2010/uno-components"> @@ -32,14 +32,16 @@ constructor="com_sun_star_comp_svx_RecoveryUI_implementation_getFactory"> - + - +