merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / filter.vcl / wmf / wmf.cxx
blob8e1f41446a045cd7cd1262ea6659f78f93e2ca0c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wmf.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "winmtf.hxx"
35 #include "emfwr.hxx"
36 #include "wmfwr.hxx"
37 #include <svtools/wmf.hxx>
39 // -----------------------------------------------------------------------------
41 BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_APMFILEHEADER *pAPMHeader )
43 UINT32 nMetaType;
44 UINT32 nOrgPos = rStreamWMF.Tell();
45 UINT16 nOrigNumberFormat = rStreamWMF.GetNumberFormatInt();
46 rStreamWMF.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
47 rStreamWMF.Seek( 0x28 );
48 rStreamWMF >> nMetaType;
49 rStreamWMF.Seek( nOrgPos );
50 if ( nMetaType == 0x464d4520 )
52 if ( EnhWMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadEnhWMF() == FALSE )
53 rStreamWMF.SetError( SVSTREAM_FILEFORMAT_ERROR );
55 else
57 WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF( pAPMHeader );
59 rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
60 return !rStreamWMF.GetError();
63 // -----------------------------------------------------------------------------
65 BOOL ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pFilterConfigItem )
67 UINT32 nMetaType;
68 UINT32 nOrgPos = rStream.Tell();
69 UINT16 nOrigNumberFormat = rStream.GetNumberFormatInt();
70 rStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
71 rStream.Seek( 0x28 );
72 rStream >> nMetaType;
73 rStream.Seek( nOrgPos );
74 if ( nMetaType == 0x464d4520 )
76 if ( EnhWMFReader( rStream, rMTF, NULL ).ReadEnhWMF() == FALSE )
77 rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
79 else
81 WMFReader( rStream, rMTF, pFilterConfigItem ).ReadWMF();
83 rStream.SetNumberFormatInt( nOrigNumberFormat );
84 return !rStream.GetError();
87 // -----------------------------------------------------------------------------
89 BOOL ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
90 FilterConfigItem* pConfigItem, BOOL bPlaceable)
92 WMFWriter aWMFWriter;
93 return aWMFWriter.WriteWMF( rMTF, rTargetStream, pConfigItem, bPlaceable );
96 // -----------------------------------------------------------------------------
98 BOOL ConvertGDIMetaFileToEMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
99 FilterConfigItem* pConfigItem )
101 EMFWriter aEMFWriter;
102 return aEMFWriter.WriteEMF( rMTF, rTargetStream, pConfigItem );
105 // -----------------------------------------------------------------------------
107 BOOL WriteWindowMetafile( SvStream& rStream, const GDIMetaFile& rMTF )
109 return WMFWriter().WriteWMF( rMTF, rStream, NULL );
112 // -----------------------------------------------------------------------------
114 BOOL WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF )
116 return WMFWriter().WriteWMF( rMTF, rStream, NULL, FALSE );