update dev300-m58
[ooovba.git] / filter / source / pdf / pdfuno.cxx
blob363ac70e542d5db0d0a04cc2ea1d919230d1ea74
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: pdfuno.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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_filter.hxx"
34 #include <stdio.h>
35 #include <osl/mutex.hxx>
36 #include <osl/thread.h>
37 #include <cppuhelper/factory.hxx>
38 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 #include <pdffilter.hxx>
41 #include <pdfdialog.hxx>
43 using namespace ::rtl;
44 using namespace ::cppu;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::lang;
47 using namespace ::com::sun::star::registry;
49 extern "C"
51 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
52 const sal_Char ** ppEnvTypeName, uno_Environment ** )
54 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
57 // -------------------------------------------------------------------------
59 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
61 if (pRegistryKey)
63 try
65 Reference< XRegistryKey > xNewKey;
66 sal_Int32 nPos;
68 xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PDFFilter_getImplementationName() );
69 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
70 const Sequence< OUString > & rSNL1 = PDFFilter_getSupportedServiceNames();
71 const OUString * pArray1 = rSNL1.getConstArray();
72 for ( nPos = rSNL1.getLength(); nPos--; )
73 xNewKey->createKey( pArray1[nPos] );
75 xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PDFDialog_getImplementationName() );
76 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
77 const Sequence< OUString > & rSNL2 = PDFDialog_getSupportedServiceNames();
78 const OUString * pArray2 = rSNL2.getConstArray();
79 for ( nPos = rSNL2.getLength(); nPos--; )
80 xNewKey->createKey( pArray2[nPos] );
82 return sal_True;
84 catch (InvalidRegistryException &)
86 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
89 return sal_False;
92 // -------------------------------------------------------------------------
94 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
96 OUString aImplName( OUString::createFromAscii( pImplName ) );
97 void* pRet = 0;
99 if( pServiceManager )
101 Reference< XSingleServiceFactory > xFactory;
103 if( aImplName.equals( PDFFilter_getImplementationName() ) )
105 xFactory = createSingleFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ),
106 OUString::createFromAscii( pImplName ),
107 PDFFilter_createInstance, PDFFilter_getSupportedServiceNames() );
110 else if( aImplName.equals( PDFDialog_getImplementationName() ) )
112 xFactory = createSingleFactory( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ),
113 OUString::createFromAscii( pImplName ),
114 PDFDialog_createInstance, PDFDialog_getSupportedServiceNames() );
118 if( xFactory.is() )
120 xFactory->acquire();
121 pRet = xFactory.get();
125 return pRet;