Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "winmtf.hxx"
31 : : #include "emfwr.hxx"
32 : : #include "wmfwr.hxx"
33 : : #include <svtools/wmf.hxx>
34 : : #include <comphelper/scopeguard.hxx>
35 : :
36 : : // -----------------------------------------------------------------------------
37 : :
38 : 74 : sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER *pExtHeader )
39 : : {
40 : : sal_uInt32 nMetaType;
41 : 74 : sal_uInt32 nOrgPos = rStreamWMF.Tell();
42 : 74 : sal_uInt16 nOrigNumberFormat = rStreamWMF.GetNumberFormatInt();
43 [ + - ]: 74 : rStreamWMF.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
44 [ + - ]: 74 : rStreamWMF.Seek( 0x28 );
45 [ + - ]: 74 : rStreamWMF >> nMetaType;
46 [ + - ]: 74 : rStreamWMF.Seek( nOrgPos );
47 [ + + ]: 74 : if ( nMetaType == 0x464d4520 )
48 : : {
49 [ + - ][ + - ]: 44 : if ( EnhWMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadEnhWMF() == sal_False )
[ + - ][ + + ]
50 [ + - ]: 9 : rStreamWMF.SetError( SVSTREAM_FILEFORMAT_ERROR );
51 : : }
52 : : else
53 : : {
54 [ + - ][ + - ]: 30 : WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem, pExtHeader ).ReadWMF( );
[ + - ]
55 : : }
56 [ + - ]: 74 : rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
57 : 74 : return !rStreamWMF.GetError();
58 : : }
59 : :
60 : : // -----------------------------------------------------------------------------
61 : :
62 : 0 : sal_Bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pFilterConfigItem )
63 : : {
64 : 0 : sal_uInt32 nMetaType(0);
65 : 0 : sal_uInt32 nOrgPos = rStream.Tell();
66 : :
67 : 0 : sal_uInt16 nOrigNumberFormat = rStream.GetNumberFormatInt();
68 [ # # ]: 0 : rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
69 : : //exception-safe reset nOrigNumberFormat at end of scope
70 : : const ::comphelper::ScopeGuard aScopeGuard(
71 : : boost::bind(&SvStream::SetNumberFormatInt, ::boost::ref(rStream),
72 [ # # ][ # # ]: 0 : nOrigNumberFormat));
[ # # ]
73 : :
74 [ # # ]: 0 : rStream.Seek( 0x28 );
75 [ # # ]: 0 : rStream >> nMetaType;
76 [ # # ]: 0 : rStream.Seek( nOrgPos );
77 : :
78 [ # # ]: 0 : if (!rStream.good())
79 : 0 : return false;
80 : :
81 [ # # ]: 0 : if ( nMetaType == 0x464d4520 )
82 : : {
83 [ # # ][ # # ]: 0 : if ( EnhWMFReader( rStream, rMTF, NULL ).ReadEnhWMF() == sal_False )
[ # # ][ # # ]
84 [ # # ]: 0 : rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
85 : : }
86 : : else
87 : : {
88 [ # # ][ # # ]: 0 : WMFReader( rStream, rMTF, pFilterConfigItem ).ReadWMF();
[ # # ]
89 : : }
90 : :
91 [ # # ]: 0 : return rStream.good();
92 : : }
93 : :
94 : : // -----------------------------------------------------------------------------
95 : :
96 : 87 : sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
97 : : FilterConfigItem* pConfigItem, sal_Bool bPlaceable)
98 : : {
99 [ + - ]: 87 : WMFWriter aWMFWriter;
100 [ + - ][ + - ]: 87 : return aWMFWriter.WriteWMF( rMTF, rTargetStream, pConfigItem, bPlaceable );
101 : : }
102 : :
103 : : // -----------------------------------------------------------------------------
104 : :
105 : 3 : sal_Bool ConvertGDIMetaFileToEMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
106 : : FilterConfigItem* pConfigItem )
107 : : {
108 [ + - ]: 3 : EMFWriter aEMFWriter(rTargetStream);
109 [ + - ][ + - ]: 3 : return aEMFWriter.WriteEMF( rMTF, pConfigItem );
110 : : }
111 : :
112 : : // -----------------------------------------------------------------------------
113 : :
114 : 0 : sal_Bool WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF )
115 : : {
116 [ # # ]: 0 : return WMFWriter().WriteWMF( rMTF, rStream, NULL, sal_False );
117 [ + - ][ + - ]: 843 : }
118 : :
119 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|