LCOV - code coverage report
Current view: top level - filter/source/placeware - filter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 17 46 37.0 %
Date: 2015-06-13 12:38:46 Functions: 8 13 61.5 %
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             : #include <com/sun/star/document/XFilter.hpp>
      21             : #include <com/sun/star/document/XExporter.hpp>
      22             : #include <com/sun/star/lang/XInitialization.hpp>
      23             : #include <com/sun/star/lang/XServiceInfo.hpp>
      24             : #include <cppuhelper/implbase4.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include <osl/diagnose.h>
      27             : #include <comphelper/processfactory.hxx>
      28             : 
      29             : #include "exporter.hxx"
      30             : #include "filter.hxx"
      31             : 
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::lang;
      34             : 
      35             : using ::com::sun::star::lang::XComponent;
      36             : using ::com::sun::star::beans::PropertyValue;
      37             : using ::com::sun::star::io::XOutputStream;
      38             : using ::com::sun::star::task::XStatusIndicator;
      39             : 
      40             : namespace pwp {
      41             : 
      42             : 
      43             : 
      44           2 : class PlaceWareExportFilter : public cppu::WeakImplHelper4
      45             : <
      46             :     com::sun::star::document::XFilter,
      47             :     com::sun::star::document::XExporter,
      48             :     com::sun::star::lang::XInitialization,
      49             :     com::sun::star::lang::XServiceInfo
      50             : >
      51             : {
      52             :     Reference< XComponent > mxDoc;
      53             :     Reference< XComponentContext > mxContext;
      54             : 
      55             : public:
      56             :     PlaceWareExportFilter( const Reference< XComponentContext > &rxContext);
      57             : 
      58             :     // XFilter
      59             :     virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
      60             :     virtual void SAL_CALL cancel( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      61             : 
      62             :     // XExporter
      63             :     virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException, std::exception) SAL_OVERRIDE;
      64             : 
      65             :     // XInitialization
      66             :     virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
      67             : 
      68             :     // XServiceInfo
      69             :     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      70             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
      71             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()  throw(RuntimeException, std::exception) SAL_OVERRIDE;
      72             : };
      73             : 
      74             : 
      75             : 
      76           1 : PlaceWareExportFilter::PlaceWareExportFilter(const Reference< XComponentContext > &rxContext)
      77           1 : :   mxContext( rxContext )
      78             : {
      79           1 : }
      80             : 
      81             : 
      82             : 
      83           0 : sal_Bool SAL_CALL PlaceWareExportFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
      84             :     throw (RuntimeException, std::exception)
      85             : {
      86           0 :     sal_Int32 nLength = aDescriptor.getLength();
      87           0 :     const PropertyValue * pValue = aDescriptor.getConstArray();
      88           0 :     OUString sURL;
      89           0 :     Reference < XInterface > xInteractionHandler;
      90           0 :     Reference < XOutputStream > xOutputStream;
      91           0 :     Reference < XStatusIndicator > xStatusIndicator;
      92           0 :     for ( sal_Int32 i = 0 ; i < nLength; i++)
      93             :     {
      94           0 :         if ( pValue[i].Name == "OutputStream" )
      95             :         {
      96           0 :             pValue[i].Value >>= xOutputStream;
      97             :         }
      98           0 :         else if( pValue[i].Name == "URL" )
      99             :         {
     100           0 :             pValue[i].Value >>= sURL;
     101             :         }
     102           0 :         else if( pValue[i].Name == "InteractionHandler" )
     103             :         {
     104           0 :             pValue[i].Value >>= xInteractionHandler;
     105             :         }
     106           0 :         else if ( pValue[i].Name == "StatusIndicator" )
     107             :         {
     108           0 :             pValue[i].Value >>= xStatusIndicator;
     109             :         }
     110             :     }
     111           0 :     if ( !xOutputStream.is() )
     112             :     {
     113             :         OSL_ASSERT ( false );
     114           0 :         return sal_False;
     115             :     }
     116             : 
     117           0 :     PlaceWareExporter aExporter( mxContext );
     118           0 :     return aExporter.doExport( mxDoc, xOutputStream, sURL, xInteractionHandler, xStatusIndicator );
     119             : }
     120             : 
     121             : 
     122             : 
     123           0 : void SAL_CALL PlaceWareExportFilter::cancel(  )
     124             :     throw (RuntimeException, std::exception)
     125             : {
     126           0 : }
     127             : 
     128             : 
     129             : 
     130             : // XExporter
     131           0 : void SAL_CALL PlaceWareExportFilter::setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
     132             :     throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
     133             : {
     134           0 :     mxDoc = xDoc;
     135           0 : }
     136             : 
     137             : 
     138             : 
     139             : // XInitialization
     140           0 : void SAL_CALL PlaceWareExportFilter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& /* aArguments */ )
     141             :     throw (Exception, RuntimeException, std::exception)
     142             : {
     143           0 : }
     144             : 
     145           2 : OUString PlaceWareExportFilter_getImplementationName ()
     146             :     throw (RuntimeException)
     147             : {
     148           2 :     return OUString( "com.sun.star.comp.Impress.PlaceWareExportFilter" );
     149             : }
     150             : 
     151           2 : Sequence< OUString > SAL_CALL PlaceWareExportFilter_getSupportedServiceNames(  )
     152             :     throw (RuntimeException)
     153             : {
     154           2 :     Sequence < OUString > aRet(1);
     155           2 :     OUString* pArray = aRet.getArray();
     156           2 :     pArray[0] =  "com.sun.star.document.ExportFilter";
     157           2 :     return aRet;
     158             : }
     159             : 
     160           1 : Reference< XInterface > SAL_CALL PlaceWareExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
     161             :     throw( Exception )
     162             : {
     163           1 :     return static_cast<cppu::OWeakObject*>(new PlaceWareExportFilter( comphelper::getComponentContext(rSMgr) ));
     164             : }
     165             : 
     166             : // XServiceInfo
     167           1 : OUString SAL_CALL PlaceWareExportFilter::getImplementationName(  )
     168             :     throw (RuntimeException, std::exception)
     169             : {
     170           1 :     return PlaceWareExportFilter_getImplementationName();
     171             : }
     172             : 
     173           0 : sal_Bool SAL_CALL PlaceWareExportFilter::supportsService( const OUString& rServiceName )
     174             :     throw (RuntimeException, std::exception)
     175             : {
     176           0 :     return cppu::supportsService( this, rServiceName );
     177             : }
     178             : 
     179           1 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL PlaceWareExportFilter::getSupportedServiceNames(  )
     180             :     throw (RuntimeException, std::exception)
     181             : {
     182           1 :     return PlaceWareExportFilter_getSupportedServiceNames();
     183             : }
     184             : 
     185             : 
     186             : 
     187             : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11