LCOV - code coverage report
Current view: top level - filter/source/svg/test - svg2odf.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 43 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *    OpenOffice.org - a multi-platform office productivity suite
       5                 :            :  *
       6                 :            :  *    Author:
       7                 :            :  *      Fridrich Strba  <fridrich.strba@bluewin.ch>
       8                 :            :  *      Thorsten Behrens <tbehrens@novell.com>
       9                 :            :  *
      10                 :            :  *      Copyright (C) 2008, Novell Inc.
      11                 :            :  *      Parts copyright 2005 by Sun Microsystems, Inc.
      12                 :            :  *
      13                 :            :  *   The Contents of this file are made available subject to
      14                 :            :  *   the terms of GNU Lesser General Public License Version 3.
      15                 :            :  *
      16                 :            :  ************************************************************************/
      17                 :            : 
      18                 :            : 
      19                 :            : #include "../svgreader.hxx"
      20                 :            : #include "odfserializer.hxx"
      21                 :            : 
      22                 :            : #include <sal/main.h>
      23                 :            : #include <osl/file.hxx>
      24                 :            : #include <osl/process.h>
      25                 :            : #include <rtl/bootstrap.hxx>
      26                 :            : 
      27                 :            : #include <cppuhelper/implbase1.hxx>
      28                 :            : #include <cppuhelper/bootstrap.hxx>
      29                 :            : #include <cppuhelper/servicefactory.hxx>
      30                 :            : #include <comphelper/processfactory.hxx>
      31                 :            : #include <comphelper/oslfile2streamwrap.hxx>
      32                 :            : 
      33                 :            : using namespace ::com::sun::star;
      34                 :            : 
      35                 :            : namespace
      36                 :            : {
      37                 :          0 :     class OutputWrap : public cppu::WeakImplHelper1<
      38                 :            :         io::XOutputStream>
      39                 :            :     {
      40                 :            :         osl::File maFile;
      41                 :            : 
      42                 :            :     public:
      43                 :            : 
      44                 :          0 :         explicit OutputWrap( const rtl::OUString& rURL ) : maFile(rURL)
      45                 :            :         {
      46                 :          0 :             maFile.open( osl_File_OpenFlag_Create|osl_File_OpenFlag_Write );
      47                 :          0 :         }
      48                 :            : 
      49                 :          0 :         virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (com::sun::star::io::NotConnectedException,com::sun::star::io::BufferSizeExceededException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException)
      50                 :            : 
      51                 :            :         {
      52                 :          0 :             sal_uInt64 nBytesWritten(0);
      53                 :          0 :             maFile.write(aData.getConstArray(),aData.getLength(),nBytesWritten);
      54                 :          0 :         }
      55                 :            : 
      56                 :          0 :         virtual void SAL_CALL flush() throw (com::sun::star::io::NotConnectedException, com::sun::star::io::BufferSizeExceededException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException)
      57                 :            :         {
      58                 :          0 :         }
      59                 :            : 
      60                 :          0 :         virtual void SAL_CALL closeOutput() throw (com::sun::star::io::NotConnectedException, com::sun::star::io::BufferSizeExceededException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException)
      61                 :            :         {
      62                 :          0 :             maFile.close();
      63                 :          0 :         }
      64                 :            :     };
      65                 :            : }
      66                 :            : 
      67                 :          0 : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
      68                 :            : {
      69                 :          0 :     if( argc != 4 )
      70                 :            :     {
      71                 :            :         OSL_TRACE( "Invocation: svg2odf <base_url> <dst_url> <ini_file>. Exiting" );
      72                 :          0 :         return 1;
      73                 :            :     }
      74                 :            : 
      75                 :          0 :     ::rtl::OUString aBaseURL, aTmpURL, aSrcURL, aDstURL, aIniUrl;
      76                 :            : 
      77                 :          0 :     osl_getProcessWorkingDir(&aBaseURL.pData);
      78                 :          0 :     osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv[1]).pData,
      79                 :          0 :                                   &aTmpURL.pData );
      80                 :          0 :     osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aSrcURL.pData);
      81                 :            : 
      82                 :          0 :     osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv[2]).pData,
      83                 :          0 :                                   &aTmpURL.pData );
      84                 :          0 :     osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aDstURL.pData);
      85                 :            : 
      86                 :          0 :     osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv[3]).pData,
      87                 :          0 :                                 &aTmpURL.pData );
      88                 :          0 :     osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aIniUrl.pData);
      89                 :            : 
      90                 :            :     // bootstrap UNO
      91                 :          0 :     uno::Reference< lang::XMultiServiceFactory > xFactory;
      92                 :          0 :     uno::Reference< uno::XComponentContext > xCtx;
      93                 :            :     try
      94                 :            :     {
      95                 :          0 :         xCtx = ::cppu::defaultBootstrap_InitialComponentContext(aIniUrl);
      96                 :          0 :         xFactory = uno::Reference< lang::XMultiServiceFactory >(xCtx->getServiceManager(),
      97                 :          0 :                                                                 uno::UNO_QUERY);
      98                 :          0 :         if( xFactory.is() )
      99                 :          0 :             ::comphelper::setProcessServiceFactory( xFactory );
     100                 :            :     }
     101                 :          0 :     catch( const uno::Exception& )
     102                 :            :     {
     103                 :            :     }
     104                 :            : 
     105                 :          0 :     if( !xFactory.is() )
     106                 :            :     {
     107                 :            :         OSL_TRACE( "Could not bootstrap UNO, installation must be in disorder. Exiting." );
     108                 :          0 :         return 1;
     109                 :            :     }
     110                 :            : 
     111                 :          0 :     osl::File aInputFile(aSrcURL);
     112                 :          0 :     if( osl::FileBase::E_None!=aInputFile.open(osl_File_OpenFlag_Read) )
     113                 :            :     {
     114                 :            :         OSL_TRACE( "Cannot open input file" );
     115                 :          0 :         return 1;
     116                 :            :     }
     117                 :            : 
     118                 :            :     svgi::SVGReader aReader(xFactory,
     119                 :            :                             uno::Reference<io::XInputStream>(
     120                 :          0 :                                 new comphelper::OSLInputStreamWrapper(aInputFile)),
     121                 :          0 :                             svgi::createSerializer(new OutputWrap(aDstURL)));
     122                 :          0 :     return aReader.parseAndConvert() ? 0 : 1;
     123                 :            : }
     124                 :            : 
     125                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10