LCOV - code coverage report
Current view: top level - libreoffice/filter/source/svg/test - svg2odf.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 43 0.0 %
Date: 2012-12-27 Functions: 0 8 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             :  *
       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 <comphelper/processfactory.hxx>
      30             : #include <comphelper/oslfile2streamwrap.hxx>
      31             : 
      32             : using namespace ::com::sun::star;
      33             : 
      34             : namespace
      35             : {
      36           0 :     class OutputWrap : public cppu::WeakImplHelper1<
      37             :         io::XOutputStream>
      38             :     {
      39             :         osl::File maFile;
      40             : 
      41             :     public:
      42             : 
      43           0 :         explicit OutputWrap( const rtl::OUString& rURL ) : maFile(rURL)
      44             :         {
      45           0 :             maFile.open( osl_File_OpenFlag_Create|osl_File_OpenFlag_Write );
      46           0 :         }
      47             : 
      48           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)
      49             : 
      50             :         {
      51           0 :             sal_uInt64 nBytesWritten(0);
      52           0 :             maFile.write(aData.getConstArray(),aData.getLength(),nBytesWritten);
      53           0 :         }
      54             : 
      55           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)
      56             :         {
      57           0 :         }
      58             : 
      59           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)
      60             :         {
      61           0 :             maFile.close();
      62           0 :         }
      63             :     };
      64             : }
      65             : 
      66           0 : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
      67             : {
      68           0 :     if( argc != 4 )
      69             :     {
      70             :         OSL_TRACE( "Invocation: svg2odf <base_url> <dst_url> <ini_file>. Exiting" );
      71           0 :         return 1;
      72             :     }
      73             : 
      74           0 :     ::rtl::OUString aBaseURL, aTmpURL, aSrcURL, aDstURL, aIniUrl;
      75             : 
      76           0 :     osl_getProcessWorkingDir(&aBaseURL.pData);
      77           0 :     osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv[1]).pData,
      78           0 :                                   &aTmpURL.pData );
      79           0 :     osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aSrcURL.pData);
      80             : 
      81           0 :     osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv[2]).pData,
      82           0 :                                   &aTmpURL.pData );
      83           0 :     osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aDstURL.pData);
      84             : 
      85           0 :     osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv[3]).pData,
      86           0 :                                 &aTmpURL.pData );
      87           0 :     osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aIniUrl.pData);
      88             : 
      89             :     // bootstrap UNO
      90           0 :     uno::Reference< lang::XMultiServiceFactory > xFactory;
      91           0 :     uno::Reference< uno::XComponentContext > xCtx;
      92             :     try
      93             :     {
      94           0 :         xCtx = ::cppu::defaultBootstrap_InitialComponentContext(aIniUrl);
      95           0 :         xFactory = uno::Reference< lang::XMultiServiceFactory >(xCtx->getServiceManager(),
      96           0 :                                                                 uno::UNO_QUERY);
      97           0 :         if( xFactory.is() )
      98           0 :             ::comphelper::setProcessServiceFactory( xFactory );
      99             :     }
     100           0 :     catch( const uno::Exception& )
     101             :     {
     102             :     }
     103             : 
     104           0 :     if( !xFactory.is() )
     105             :     {
     106             :         OSL_TRACE( "Could not bootstrap UNO, installation must be in disorder. Exiting." );
     107           0 :         return 1;
     108             :     }
     109             : 
     110           0 :     osl::File aInputFile(aSrcURL);
     111           0 :     if( osl::FileBase::E_None!=aInputFile.open(osl_File_OpenFlag_Read) )
     112             :     {
     113             :         OSL_TRACE( "Cannot open input file" );
     114           0 :         return 1;
     115             :     }
     116             : 
     117             :     svgi::SVGReader aReader(xFactory,
     118             :                             uno::Reference<io::XInputStream>(
     119           0 :                                 new comphelper::OSLInputStreamWrapper(aInputFile)),
     120           0 :                             svgi::createSerializer(new OutputWrap(aDstURL)));
     121           0 :     return aReader.parseAndConvert() ? 0 : 1;
     122             : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10