Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "pdfiadaptor.hxx"
31 : : #include "filterdet.hxx"
32 : : #include "treevisitorfactory.hxx"
33 : :
34 : : #include <cppuhelper/factory.hxx>
35 : : #include <cppuhelper/implementationentry.hxx>
36 : :
37 : : using namespace ::com::sun::star;
38 : : using namespace ::com::sun::star::uno;
39 : : using namespace ::com::sun::star::lang;
40 : : using namespace ::com::sun::star::registry;
41 : :
42 : :
43 : : namespace
44 : : {
45 : 0 : static Reference< XInterface > Create_PDFIHybridAdaptor( const Reference< XComponentContext >& _rxContext )
46 : : {
47 [ # # ]: 0 : return *(new pdfi::PDFIHybridAdaptor( _rxContext ));
48 : : }
49 : :
50 : 0 : static Reference< XInterface > Create_PDFIRawAdaptor_Writer( const Reference< XComponentContext >& _rxContext )
51 : : {
52 [ # # ]: 0 : pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( _rxContext );
53 : :
54 [ # # ]: 0 : pAdaptor->setTreeVisitorFactory(pdfi::createWriterTreeVisitorFactory());
55 : 0 : pAdaptor->enableToplevelText(); // TEMP! TEMP!
56 : :
57 [ # # ]: 0 : return uno::Reference<uno::XInterface>(static_cast<xml::XImportFilter*>(pAdaptor));
58 : : }
59 : :
60 : 0 : static Reference< XInterface > Create_PDFIRawAdaptor_Draw( const Reference< XComponentContext >& _rxContext )
61 : : {
62 [ # # ]: 0 : pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( _rxContext );
63 : :
64 [ # # ]: 0 : pAdaptor->setTreeVisitorFactory(pdfi::createDrawTreeVisitorFactory());
65 : :
66 [ # # ]: 0 : return uno::Reference<uno::XInterface>(static_cast<xml::XImportFilter*>(pAdaptor));
67 : : }
68 : :
69 : 0 : static Reference< XInterface > Create_PDFIRawAdaptor_Impress( const Reference< XComponentContext >& _rxContext )
70 : : {
71 [ # # ]: 0 : pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( _rxContext );
72 : :
73 [ # # ]: 0 : pAdaptor->setTreeVisitorFactory(pdfi::createImpressTreeVisitorFactory());
74 : :
75 [ # # ]: 0 : return uno::Reference<uno::XInterface>(static_cast<xml::XImportFilter*>(pAdaptor));
76 : : }
77 : :
78 : 10 : static Reference< XInterface > Create_PDFDetector( const Reference< XComponentContext >& _rxContext )
79 : : {
80 [ + - ]: 10 : return *(new pdfi::PDFDetector( _rxContext ) );
81 : : }
82 : : }
83 : :
84 : : namespace
85 : : {
86 : : typedef Reference< XInterface > (SAL_CALL * ComponentFactory)( const Reference< XComponentContext >& );
87 : :
88 : : struct ComponentDescription
89 : : {
90 : : const sal_Char* pAsciiServiceName;
91 : : const sal_Char* pAsciiImplementationName;
92 : : ComponentFactory pFactory;
93 : :
94 : 6 : ComponentDescription()
95 : : :pAsciiServiceName( NULL )
96 : : ,pAsciiImplementationName( NULL )
97 : 6 : ,pFactory( NULL )
98 : : {
99 : 6 : }
100 : 30 : ComponentDescription( const sal_Char* _pAsciiServiceName, const sal_Char* _pAsciiImplementationName, ComponentFactory _pFactory )
101 : : :pAsciiServiceName( _pAsciiServiceName )
102 : : ,pAsciiImplementationName( _pAsciiImplementationName )
103 : 30 : ,pFactory( _pFactory )
104 : : {
105 : 30 : }
106 : : };
107 : :
108 : 6 : static const ComponentDescription* lcl_getComponents()
109 : : {
110 : : static const ComponentDescription aDescriptions[] = {
111 : : ComponentDescription( "com.sun.star.document.ImportFilter", "com.sun.star.comp.documents.HybridPDFImport", Create_PDFIHybridAdaptor ),
112 : : ComponentDescription( "com.sun.star.document.ImportFilter", "com.sun.star.comp.documents.WriterPDFImport", Create_PDFIRawAdaptor_Writer ),
113 : : ComponentDescription( "com.sun.star.document.ImportFilter", "com.sun.star.comp.documents.DrawPDFImport", Create_PDFIRawAdaptor_Draw ),
114 : : ComponentDescription( "com.sun.star.document.ImportFilter", "com.sun.star.comp.documents.ImpressPDFImport", Create_PDFIRawAdaptor_Impress ),
115 : : ComponentDescription( "com.sun.star.document.ImportFilter", "com.sun.star.comp.documents.PDFDetector", Create_PDFDetector ),
116 : : ComponentDescription()
117 [ + - ][ + - ]: 6 : };
118 : 6 : return aDescriptions;
119 : : }
120 : : }
121 : :
122 : 6 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
123 : : const sal_Char* pImplementationName,
124 : : SAL_UNUSED_PARAMETER void* /*pServiceManager*/,
125 : : SAL_UNUSED_PARAMETER void* /*pRegistryKey*/ )
126 : : {
127 : 6 : ::rtl::OUString sImplementationName( ::rtl::OUString::createFromAscii( pImplementationName ) );
128 : :
129 : 6 : Reference< XSingleComponentFactory > xFactory;
130 : :
131 : 6 : const ComponentDescription* pComponents = lcl_getComponents();
132 [ + - ]: 30 : while ( pComponents->pAsciiServiceName != NULL )
133 : : {
134 [ + + ]: 30 : if ( 0 == sImplementationName.compareToAscii( pComponents->pAsciiImplementationName ) )
135 : : {
136 [ + - ]: 6 : Sequence< ::rtl::OUString > sServices(1);
137 [ + - ]: 6 : sServices[0] = ::rtl::OUString::createFromAscii( pComponents->pAsciiServiceName );
138 : :
139 : : xFactory = ::cppu::createSingleComponentFactory(
140 : : pComponents->pFactory,
141 : : sImplementationName,
142 : : sServices,
143 : : NULL
144 [ + - ][ + - ]: 6 : );
145 [ + - ]: 6 : break;
146 : : }
147 : :
148 : 24 : ++pComponents;
149 : : }
150 : :
151 : : // by definition, objects returned via this C API need to ber acquired once
152 [ + - ]: 6 : xFactory->acquire();
153 [ + - ]: 6 : return xFactory.get();
154 : : }
155 : :
156 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|