sync master with lastest vba changes
[ooovba.git] / goodies / source / unographic / graphicuno.cxx
blobb39f7a77c7f249fea9bb5adaf04da00373a19dc2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: graphicuno.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_goodies.hxx"
34 #include <osl/diagnose.h>
35 #include <cppuhelper/factory.hxx>
36 #include <uno/mapping.hxx>
37 #include "provider.hxx"
38 #include "renderer.hxx"
40 #include <com/sun/star/registry/XRegistryKey.hpp>
41 #include "comphelper/servicedecl.hxx"
43 using namespace com::sun::star;
44 namespace sdecl = comphelper::service_decl;
46 namespace unographic {
47 extern sdecl::ServiceDecl const serviceDecl;
48 // --------------------
49 // - *_createInstance -
50 // --------------------
52 static uno::Reference< uno::XInterface > SAL_CALL GraphicProvider_createInstance( const uno::Reference< lang::XMultiServiceFactory >& )
54 return SAL_STATIC_CAST( ::cppu::OWeakObject*, new GraphicProvider );
57 // -----------------------------------------------------------------------------
59 static uno::Reference< uno::XInterface > SAL_CALL GraphicRendererVCL_createInstance( const uno::Reference< lang::XMultiServiceFactory >&)
61 return SAL_STATIC_CAST( ::cppu::OWeakObject*, new GraphicRendererVCL );
64 // ------------------------------------------
65 // - component_getImplementationEnvironment -
66 // ------------------------------------------
68 extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvTypeName, uno_Environment** )
70 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
73 // -----------------------
74 // - component_writeInfo -
75 // -----------------------
77 extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
79 sal_Bool bRet = sal_False;
81 if( pRegistryKey )
83 try
85 uno::Reference< registry::XRegistryKey > xNewKey;
86 uno::Sequence< ::rtl::OUString > aServices;
88 // GraphicProvider
89 xNewKey = reinterpret_cast< registry::XRegistryKey * >( pRegistryKey )->createKey(
90 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
91 GraphicProvider::getImplementationName_Static() +
92 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
94 aServices = GraphicProvider::getSupportedServiceNames_Static();
96 int i;
97 for( i = 0; i < aServices.getLength(); i++ )
98 xNewKey->createKey( aServices.getConstArray()[ i ] );
100 // GraphicRendererVCL
101 xNewKey = reinterpret_cast< registry::XRegistryKey * >( pRegistryKey )->createKey(
102 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
103 GraphicRendererVCL::getImplementationName_Static() +
104 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
106 aServices = ( GraphicRendererVCL::getSupportedServiceNames_Static() );
108 for( i = 0; i < aServices.getLength(); i++ )
109 xNewKey->createKey( aServices.getConstArray()[ i ] );
111 if ( !component_writeInfoHelper( reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ), serviceDecl ) )
112 return false;
114 bRet = true;
116 catch (registry::InvalidRegistryException &)
118 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
122 return bRet;
125 // ------------------------
126 // - component_getFactory -
127 // ------------------------
129 extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
131 void * pRet = 0;
133 if( pServiceManager && ( 0 == GraphicProvider::getImplementationName_Static().compareToAscii( pImplName ) ) )
135 uno::Reference< lang::XSingleServiceFactory > xFactory( ::cppu::createOneInstanceFactory(
136 reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
137 GraphicProvider::getImplementationName_Static(),
138 GraphicProvider_createInstance,
139 GraphicProvider::getSupportedServiceNames_Static() ) );
141 if( xFactory.is())
143 xFactory->acquire();
144 pRet = xFactory.get();
147 else if( pServiceManager && ( 0 == GraphicRendererVCL::getImplementationName_Static().compareToAscii( pImplName ) ) )
149 uno::Reference< lang::XSingleServiceFactory > xFactory( ::cppu::createOneInstanceFactory(
150 reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
151 GraphicRendererVCL::getImplementationName_Static(),
152 GraphicRendererVCL_createInstance,
153 GraphicRendererVCL::getSupportedServiceNames_Static() ) );
155 if( xFactory.is())
157 xFactory->acquire();
158 pRet = xFactory.get();
161 else
163 pRet = component_getFactoryHelper( pImplName, reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ), serviceDecl );
166 return pRet;