update dev300-m58
[ooovba.git] / extensions / source / svg / svguno.cxx
blob76fa6ccf690a94043a1b51f24af382661f024313
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: svguno.cxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
34 #include "svgcom.hxx"
35 #include "svgwriter.hxx"
36 #include "svgprinter.hxx"
38 #include <cppuhelper/factory.hxx>
39 #include <uno/mapping.hxx>
41 // -------------------
42 // - factory methods -
43 // -------------------
45 static REF( NMSP_UNO::XInterface ) SAL_CALL create_SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact )
47 return REF( NMSP_UNO::XInterface )( *new SVGWriter( rxFact ) );
50 // -----------------------------------------------------------------------------
52 static REF( NMSP_UNO::XInterface ) SAL_CALL create_SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact )
54 return REF( NMSP_UNO::XInterface )( *new SVGPrinter( rxFact ) );
57 // ------------------------------------------
58 // - component_getImplementationEnvironment -
59 // ------------------------------------------
61 extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
63 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
66 // -----------------------
67 // - component_writeInfo -
68 // -----------------------
70 extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
72 sal_Bool bRet = sal_False;
74 if( pRegistryKey )
76 try
78 REF( NMSP_REGISTRY::XRegistryKey ) xNewKey1(
79 static_cast< NMSP_REGISTRY::XRegistryKey* >( pRegistryKey )->createKey(
80 B2UCONST( "/com.sun.star.comp.extensions.SVGWriter/UNO/SERVICES/com.sun.star.svg.SVGWriter" ) ) );
81 REF( NMSP_REGISTRY::XRegistryKey ) xNewKey2(
82 static_cast< NMSP_REGISTRY::XRegistryKey* >( pRegistryKey )->createKey(
83 B2UCONST( "/com.sun.star.comp.extensions.SVGPrinter/UNO/SERVICES/com.sun.star.svg.SVGPrinter" ) ) );
85 bRet = sal_True;
87 catch( NMSP_REGISTRY::InvalidRegistryException& )
89 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
93 return bRet;
96 // ------------------------
97 // - component_getFactory -
98 // ------------------------
100 extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ )
102 REF( NMSP_LANG::XSingleServiceFactory ) xFactory;
103 void* pRet = 0;
105 if( rtl_str_compare( pImplName, "com.sun.star.comp.extensions.SVGWriter" ) == 0 )
107 const NMSP_RTL::OUString aServiceName( B2UCONST( "com.sun.star.svg.SVGWriter" ) );
109 xFactory = REF( NMSP_LANG::XSingleServiceFactory )( NMSP_CPPU::createSingleFactory(
110 reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ),
111 B2UCONST( "com.sun.star.comp.extensions.SVGWriter" ),
112 create_SVGWriter, SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) );
114 else if( rtl_str_compare( pImplName, "com.sun.star.comp.extensions.SVGPrinter" ) == 0 )
116 const NMSP_RTL::OUString aServiceName( B2UCONST( "com.sun.star.svg.SVGPrinter" ) );
118 xFactory = REF( NMSP_LANG::XSingleServiceFactory )( NMSP_CPPU::createSingleFactory(
119 reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ),
120 B2UCONST( "com.sun.star.comp.extensions.SVGPrinter" ),
121 create_SVGPrinter, SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) );
124 if( xFactory.is() )
126 xFactory->acquire();
127 pRet = xFactory.get();
130 return pRet;