LCOV - code coverage report
Current view: top level - filter/source/pdf - pdffilter.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 111 0.0 %
Date: 2014-04-11 Functions: 0 18 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             : #include "pdffilter.hxx"
      21             : #include "pdfexport.hxx"
      22             : #include <cppuhelper/supportsservice.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/window.hxx>
      25             : #include <svl/outstrm.hxx>
      26             : #include <vcl/FilterConfigItem.hxx>
      27             : 
      28             : // - PDFFilter -
      29           0 : PDFFilter::PDFFilter( const Reference< XComponentContext > &rxContext ) :
      30           0 :     mxContext( rxContext )
      31             : {
      32           0 : }
      33             : 
      34           0 : PDFFilter::~PDFFilter()
      35             : {
      36           0 : }
      37             : 
      38           0 : sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
      39             : {
      40           0 :     Reference< XOutputStream >  xOStm;
      41           0 :     Sequence< PropertyValue >   aFilterData;
      42           0 :     sal_Int32                   nLength = rDescriptor.getLength();
      43           0 :     const PropertyValue*        pValue = rDescriptor.getConstArray();
      44           0 :     sal_Bool                    bRet = sal_False;
      45           0 :     Reference< task::XStatusIndicator > xStatusIndicator;
      46           0 :     Reference< task::XInteractionHandler > xIH;
      47             : 
      48           0 :     for ( sal_Int32 i = 0 ; ( i < nLength ) && !xOStm.is(); ++i)
      49             :     {
      50           0 :         if ( pValue[ i ].Name == "OutputStream" )
      51           0 :             pValue[ i ].Value >>= xOStm;
      52           0 :         else if ( pValue[ i ].Name == "FilterData" )
      53           0 :             pValue[ i ].Value >>= aFilterData;
      54           0 :         else if ( pValue[ i ].Name == "StatusIndicator" )
      55           0 :             pValue[ i ].Value >>= xStatusIndicator;
      56           0 :         else if ( pValue[i].Name == "InteractionHandler" )
      57           0 :             pValue[i].Value >>= xIH;
      58             :     }
      59             : 
      60             :     /* we don't get FilterData if we are exporting directly
      61             :      to pdf, but we have to use the last user settings (especially for the CompressMode) */
      62           0 :     if ( !aFilterData.getLength() )
      63             :     {
      64           0 :         FilterConfigItem aCfgItem( "Office.Common/Filter/PDF/Export/" );
      65           0 :         aCfgItem.ReadBool(  "UseLosslessCompression", false );
      66           0 :         aCfgItem.ReadInt32( "Quality", 90 );
      67           0 :         aCfgItem.ReadBool(  "ReduceImageResolution", false );
      68           0 :         aCfgItem.ReadInt32( "MaxImageResolution", 300 );
      69           0 :         aCfgItem.ReadBool(  "UseTaggedPDF", false );
      70           0 :         aCfgItem.ReadInt32( "SelectPdfVersion", 0 );
      71           0 :         aCfgItem.ReadBool(  "ExportNotes", false );
      72           0 :         aCfgItem.ReadBool(  "ExportNotesPages", false );
      73           0 :         aCfgItem.ReadBool(  "UseTransitionEffects", true );
      74           0 :         aCfgItem.ReadBool(  "IsSkipEmptyPages", false );
      75           0 :         aCfgItem.ReadBool(  "ExportFormFields", true );
      76           0 :         aCfgItem.ReadInt32( "FormsType", 0 );
      77           0 :         aCfgItem.ReadBool(  "HideViewerToolbar", false );
      78           0 :         aCfgItem.ReadBool(  "HideViewerMenubar", false );
      79           0 :         aCfgItem.ReadBool(  "HideViewerWindowControls", false );
      80           0 :         aCfgItem.ReadBool(  "ResizeWindowToInitialPage", false );
      81           0 :         aCfgItem.ReadBool(  "CenterWindow", false );
      82           0 :         aCfgItem.ReadBool(  "OpenInFullScreenMode", false );
      83           0 :         aCfgItem.ReadBool(  "DisplayPDFDocumentTitle", true );
      84           0 :         aCfgItem.ReadInt32( "InitialView", 0 );
      85           0 :         aCfgItem.ReadInt32( "Magnification", 0 );
      86           0 :         aCfgItem.ReadInt32( "PageLayout", 0 );
      87           0 :         aCfgItem.ReadBool(  "FirstPageOnLeft", false );
      88           0 :         aCfgItem.ReadBool(  "IsAddStream", false );
      89             : //
      90             : // the encryption is not available when exporting directly, since the encryption is off by default and the selection
      91             : // (encrypt or not) is not persistent; it's available through macro though,
      92             : // provided the correct property values are set, see help
      93             : //
      94             : // now, the relative link stuff
      95           0 :         aCfgItem.ReadBool( "ExportLinksRelativeFsys", false );
      96           0 :         aCfgItem.ReadInt32("PDFViewSelection", 0 );
      97           0 :         aCfgItem.ReadBool( "ConvertOOoTargetToPDFTarget", false );
      98           0 :         aCfgItem.ReadBool( "ExportBookmarksToPDFDestination", false );
      99             : 
     100           0 :         aCfgItem.ReadBool(  "ExportBookmarks", true );
     101           0 :         aCfgItem.ReadBool(  "ExportHiddenSlides", false );
     102           0 :         aCfgItem.ReadInt32( "OpenBookmarkLevels", -1 );
     103           0 :         aFilterData = aCfgItem.GetFilterData();
     104             :     }
     105           0 :     if( mxSrcDoc.is() && xOStm.is() )
     106             :     {
     107           0 :         PDFExport       aExport( mxSrcDoc, xStatusIndicator, xIH, mxContext );
     108           0 :         ::utl::TempFile aTempFile;
     109             : 
     110           0 :         aTempFile.EnableKillingFile();
     111           0 :         bRet = aExport.Export( aTempFile.GetURL(), aFilterData );
     112             : 
     113           0 :         if( bRet )
     114             :         {
     115           0 :             SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
     116             : 
     117           0 :             if( pIStm )
     118             :             {
     119           0 :                 SvOutputStream aOStm( xOStm );
     120             : 
     121           0 :                 aOStm.WriteStream( *pIStm );
     122           0 :                 bRet = ( aOStm.Tell() && ( aOStm.GetError() == ERRCODE_NONE ) );
     123             : 
     124           0 :                 delete pIStm;
     125             :             }
     126           0 :         }
     127             :     }
     128             : 
     129           0 :     return bRet;
     130             : }
     131             : 
     132             : 
     133             : class FocusWindowWaitCursor
     134             : {
     135             :     Window*         m_pFocusWindow;
     136             :     public:
     137           0 :     FocusWindowWaitCursor() :
     138           0 :         m_pFocusWindow( Application::GetFocusWindow() )
     139             :     {
     140           0 :         if( m_pFocusWindow )
     141             :         {
     142           0 :             m_pFocusWindow->AddEventListener( LINK( this, FocusWindowWaitCursor, DestroyedLink ) );
     143           0 :             m_pFocusWindow->EnterWait();
     144             :         }
     145           0 :     }
     146           0 :     ~FocusWindowWaitCursor()
     147             :     {
     148           0 :         if( m_pFocusWindow )
     149             :         {
     150           0 :             m_pFocusWindow->LeaveWait();
     151           0 :             m_pFocusWindow->RemoveEventListener( LINK( this, FocusWindowWaitCursor, DestroyedLink ) );
     152             :         }
     153           0 :     }
     154             : 
     155             :     DECL_LINK( DestroyedLink, VclWindowEvent* );
     156             : };
     157             : 
     158           0 : IMPL_LINK( FocusWindowWaitCursor, DestroyedLink, VclWindowEvent*, pEvent )
     159             : {
     160           0 :     if( pEvent->GetId() == VCLEVENT_OBJECT_DYING )
     161           0 :         m_pFocusWindow = NULL;
     162           0 :     return 0;
     163             : }
     164             : 
     165           0 : sal_Bool SAL_CALL PDFFilter::filter( const Sequence< PropertyValue >& rDescriptor )
     166             :     throw (RuntimeException, std::exception)
     167             : {
     168           0 :     FocusWindowWaitCursor aCur;
     169             : 
     170           0 :     const sal_Bool bRet = implExport( rDescriptor );
     171             : 
     172           0 :     return bRet;
     173             : }
     174             : 
     175             : 
     176             : 
     177           0 : void SAL_CALL PDFFilter::cancel( ) throw (RuntimeException, std::exception)
     178             : {
     179           0 : }
     180             : 
     181             : 
     182             : 
     183           0 : void SAL_CALL PDFFilter::setSourceDocument( const Reference< XComponent >& xDoc )
     184             :     throw (IllegalArgumentException, RuntimeException, std::exception)
     185             : {
     186           0 :     mxSrcDoc = xDoc;
     187           0 : }
     188             : 
     189             : 
     190             : 
     191           0 : void SAL_CALL PDFFilter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& )
     192             :     throw (Exception, RuntimeException, std::exception)
     193             : {
     194           0 : }
     195             : 
     196           0 : OUString PDFFilter_getImplementationName ()
     197             :     throw (RuntimeException)
     198             : {
     199           0 :     return OUString ( "com.sun.star.comp.PDF.PDFFilter" );
     200             : }
     201             : 
     202           0 : Sequence< OUString > SAL_CALL PDFFilter_getSupportedServiceNames(  ) throw (RuntimeException)
     203             : {
     204           0 :     Sequence < OUString > aRet(1);
     205           0 :     OUString* pArray = aRet.getArray();
     206           0 :     pArray[0] = "com.sun.star.document.PDFFilter";
     207           0 :     return aRet;
     208             : }
     209             : 
     210           0 : Reference< XInterface > SAL_CALL PDFFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) throw( Exception )
     211             : {
     212           0 :     return (cppu::OWeakObject*) new PDFFilter( comphelper::getComponentContext(rSMgr) );
     213             : }
     214             : 
     215             : 
     216             : 
     217           0 : OUString SAL_CALL PDFFilter::getImplementationName()
     218             :     throw (RuntimeException, std::exception)
     219             : {
     220           0 :     return PDFFilter_getImplementationName();
     221             : }
     222             : 
     223             : 
     224             : 
     225           0 : sal_Bool SAL_CALL PDFFilter::supportsService( const OUString& rServiceName )
     226             :     throw (RuntimeException, std::exception)
     227             : {
     228           0 :     return cppu::supportsService( this, rServiceName );
     229             : }
     230             : 
     231             : 
     232             : 
     233           0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL PDFFilter::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     234             : {
     235           0 :     return PDFFilter_getSupportedServiceNames();
     236             : }
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10