LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/filter/wmf - wmf.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 38 52.6 %
Date: 2012-12-27 Functions: 5 7 71.4 %
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 "winmtf.hxx"
      22             : #include "emfwr.hxx"
      23             : #include "wmfwr.hxx"
      24             : #include <svtools/wmf.hxx>
      25             : #include <comphelper/scopeguard.hxx>
      26             : 
      27             : // -----------------------------------------------------------------------------
      28             : 
      29          28 : sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER *pExtHeader )
      30             : {
      31             :     sal_uInt32 nMetaType;
      32          28 :     sal_uInt32 nOrgPos = rStreamWMF.Tell();
      33          28 :     sal_uInt16 nOrigNumberFormat = rStreamWMF.GetNumberFormatInt();
      34          28 :     rStreamWMF.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
      35          28 :     rStreamWMF.Seek( 0x28 );
      36          28 :     rStreamWMF >> nMetaType;
      37          28 :     rStreamWMF.Seek( nOrgPos );
      38          28 :     if ( nMetaType == 0x464d4520 )
      39             :     {
      40          15 :         if ( EnhWMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadEnhWMF() == sal_False )
      41           3 :             rStreamWMF.SetError( SVSTREAM_FILEFORMAT_ERROR );
      42             :     }
      43             :     else
      44             :     {
      45          13 :         WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem, pExtHeader ).ReadWMF( );
      46             :     }
      47          28 :     rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
      48          28 :     return !rStreamWMF.GetError();
      49             : }
      50             : 
      51             : // -----------------------------------------------------------------------------
      52             : 
      53           0 : sal_Bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pFilterConfigItem )
      54             : {
      55           0 :     sal_uInt32 nMetaType(0);
      56           0 :     sal_uInt32 nOrgPos = rStream.Tell();
      57             : 
      58           0 :     sal_uInt16 nOrigNumberFormat = rStream.GetNumberFormatInt();
      59           0 :     rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
      60             :     //exception-safe reset nOrigNumberFormat at end of scope
      61             :     const ::comphelper::ScopeGuard aScopeGuard(
      62             :         boost::bind(&SvStream::SetNumberFormatInt, ::boost::ref(rStream),
      63           0 :           nOrigNumberFormat));
      64             : 
      65           0 :     rStream.Seek( 0x28 );
      66           0 :     rStream >> nMetaType;
      67           0 :     rStream.Seek( nOrgPos );
      68             : 
      69           0 :     if (!rStream.good())
      70           0 :         return false;
      71             : 
      72           0 :     if ( nMetaType == 0x464d4520 )
      73             :     {
      74           0 :         if ( EnhWMFReader( rStream, rMTF, NULL ).ReadEnhWMF() == sal_False )
      75           0 :             rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
      76             :     }
      77             :     else
      78             :     {
      79           0 :         WMFReader( rStream, rMTF, pFilterConfigItem ).ReadWMF();
      80             :     }
      81             : 
      82           0 :     return rStream.good();
      83             : }
      84             : 
      85             : // -----------------------------------------------------------------------------
      86             : 
      87          29 : sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
      88             :                               FilterConfigItem* pConfigItem, sal_Bool bPlaceable)
      89             : {
      90          29 :     WMFWriter aWMFWriter;
      91          29 :     return aWMFWriter.WriteWMF( rMTF, rTargetStream, pConfigItem, bPlaceable );
      92             : }
      93             : 
      94             : // -----------------------------------------------------------------------------
      95             : 
      96           1 : sal_Bool ConvertGDIMetaFileToEMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
      97             :                               FilterConfigItem* pConfigItem )
      98             : {
      99           1 :     EMFWriter aEMFWriter(rTargetStream);
     100           1 :     return aEMFWriter.WriteEMF( rMTF, pConfigItem );
     101             : }
     102             : 
     103             : // -----------------------------------------------------------------------------
     104             : 
     105           0 : sal_Bool WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF )
     106             : {
     107           0 :     return WMFWriter().WriteWMF( rMTF, rStream, NULL, sal_False );
     108         108 : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10