LCOV - code coverage report
Current view: top level - sdext/source/pdfimport - services.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "pdfiadaptor.hxx"
      22             : #include "filterdet.hxx"
      23             : #include "treevisitorfactory.hxx"
      24             : 
      25             : #include <cppuhelper/factory.hxx>
      26             : #include <cppuhelper/implementationentry.hxx>
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::lang;
      31             : using namespace ::com::sun::star::registry;
      32             : 
      33             : 
      34             : namespace
      35             : {
      36           0 :     static Reference< XInterface > Create_PDFIHybridAdaptor( const Reference< XComponentContext >& _rxContext )
      37             :     {
      38           0 :         return *(new pdfi::PDFIHybridAdaptor( _rxContext ));
      39             :     }
      40             : 
      41           0 :     static Reference< XInterface > Create_PDFIRawAdaptor_Writer( const Reference< XComponentContext >& _rxContext )
      42             :     {
      43           0 :         pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( _rxContext );
      44             : 
      45           0 :         pAdaptor->setTreeVisitorFactory(pdfi::createWriterTreeVisitorFactory());
      46           0 :         pAdaptor->enableToplevelText(); // TEMP! TEMP!
      47             : 
      48           0 :         return uno::Reference<uno::XInterface>(static_cast<xml::XImportFilter*>(pAdaptor));
      49             :     }
      50             : 
      51           0 :     static Reference< XInterface > Create_PDFIRawAdaptor_Draw( const Reference< XComponentContext >& _rxContext )
      52             :     {
      53           0 :         pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( _rxContext );
      54             : 
      55           0 :         pAdaptor->setTreeVisitorFactory(pdfi::createDrawTreeVisitorFactory());
      56             : 
      57           0 :         return uno::Reference<uno::XInterface>(static_cast<xml::XImportFilter*>(pAdaptor));
      58             :     }
      59             : 
      60           0 :     static Reference< XInterface > Create_PDFIRawAdaptor_Impress( const Reference< XComponentContext >& _rxContext )
      61             :     {
      62           0 :         pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( _rxContext );
      63             : 
      64           0 :         pAdaptor->setTreeVisitorFactory(pdfi::createImpressTreeVisitorFactory());
      65             : 
      66           0 :         return uno::Reference<uno::XInterface>(static_cast<xml::XImportFilter*>(pAdaptor));
      67             :     }
      68             : 
      69           0 :     static Reference< XInterface > Create_PDFDetector( const Reference< XComponentContext >& _rxContext )
      70             :     {
      71           0 :         return *(new pdfi::PDFDetector( _rxContext ) );
      72             :     }
      73             : }
      74             : 
      75             : namespace
      76             : {
      77             :     typedef Reference< XInterface > (SAL_CALL * ComponentFactory)( const Reference< XComponentContext >& );
      78             : 
      79             :     struct ComponentDescription
      80             :     {
      81             :         const sal_Char*     pAsciiServiceName;
      82             :         const sal_Char*     pAsciiImplementationName;
      83             :         ComponentFactory    pFactory;
      84             : 
      85           0 :         ComponentDescription()
      86             :             :pAsciiServiceName( NULL )
      87             :             ,pAsciiImplementationName( NULL )
      88           0 :             ,pFactory( NULL )
      89             :         {
      90           0 :         }
      91           0 :         ComponentDescription( const sal_Char* _pAsciiServiceName, const sal_Char* _pAsciiImplementationName, ComponentFactory _pFactory )
      92             :             :pAsciiServiceName( _pAsciiServiceName )
      93             :             ,pAsciiImplementationName( _pAsciiImplementationName )
      94           0 :             ,pFactory( _pFactory )
      95             :         {
      96           0 :         }
      97             :     };
      98             : 
      99           0 :     static const ComponentDescription* lcl_getComponents()
     100             :     {
     101             :         static const ComponentDescription aDescriptions[] = {
     102             :             ComponentDescription( "com.sun.star.document.ImportFilter", "org.libreoffice.comp.documents.HybridPDFImport", Create_PDFIHybridAdaptor ),
     103             :             ComponentDescription( "com.sun.star.document.ImportFilter", "org.libreoffice.comp.documents.WriterPDFImport", Create_PDFIRawAdaptor_Writer ),
     104             :             ComponentDescription( "com.sun.star.document.ImportFilter", "org.libreoffice.comp.documents.DrawPDFImport", Create_PDFIRawAdaptor_Draw ),
     105             :             ComponentDescription( "com.sun.star.document.ImportFilter", "org.libreoffice.comp.documents.ImpressPDFImport", Create_PDFIRawAdaptor_Impress ),
     106             :             ComponentDescription( "com.sun.star.document.ImportFilter", "org.libreoffice.comp.documents.PDFDetector", Create_PDFDetector ),
     107             :             ComponentDescription()
     108           0 :         };
     109           0 :         return aDescriptions;
     110             :     }
     111             : }
     112             : 
     113           0 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL pdfimport_component_getFactory(
     114             :     const sal_Char* pImplementationName,
     115             :     SAL_UNUSED_PARAMETER void* /*pServiceManager*/,
     116             :     SAL_UNUSED_PARAMETER void* /*pRegistryKey*/ )
     117             : {
     118           0 :     OUString sImplementationName( OUString::createFromAscii( pImplementationName ) );
     119             : 
     120           0 :     Reference< XSingleComponentFactory > xFactory;
     121             : 
     122           0 :     const ComponentDescription* pComponents = lcl_getComponents();
     123           0 :     while ( pComponents->pAsciiServiceName != NULL )
     124             :     {
     125           0 :         if ( sImplementationName.equalsAscii( pComponents->pAsciiImplementationName ) )
     126             :         {
     127           0 :             Sequence< OUString > sServices(1);
     128           0 :             sServices[0] = OUString::createFromAscii( pComponents->pAsciiServiceName );
     129             : 
     130           0 :             xFactory = ::cppu::createSingleComponentFactory(
     131             :                 pComponents->pFactory,
     132             :                 sImplementationName,
     133             :                 sServices,
     134             :                 NULL
     135           0 :             );
     136           0 :             break;
     137             :         }
     138             : 
     139           0 :         ++pComponents;
     140             :     }
     141             : 
     142             :     // by definition, objects returned via this C API need to ber acquired once
     143           0 :     xFactory->acquire();
     144           0 :     return xFactory.get();
     145             : }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10