summaryrefslogtreecommitdiff
path: root/vcl/source/filter/wmf/wmf.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/filter/wmf/wmf.cxx')
-rw-r--r--vcl/source/filter/wmf/wmf.cxx73
1 files changed, 23 insertions, 50 deletions
diff --git a/vcl/source/filter/wmf/wmf.cxx b/vcl/source/filter/wmf/wmf.cxx
index ad9d1536d1d5..f620a8e00303 100644
--- a/vcl/source/filter/wmf/wmf.cxx
+++ b/vcl/source/filter/wmf/wmf.cxx
@@ -17,65 +17,38 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "winmtf.hxx"
#include "emfwr.hxx"
#include "wmfwr.hxx"
#include <vcl/wmf.hxx>
#include <vcl/gdimetafiletools.hxx>
#include <comphelper/scopeguard.hxx>
-bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER *pExtHeader )
-{
- sal_uInt32 nMetaType;
- sal_uInt32 nOrgPos = rStreamWMF.Tell();
- SvStreamEndian nOrigNumberFormat = rStreamWMF.GetEndian();
- rStreamWMF.SetEndian( SvStreamEndian::LITTLE );
- rStreamWMF.Seek( 0x28 );
- rStreamWMF.ReadUInt32( nMetaType );
- rStreamWMF.Seek( nOrgPos );
- if ( nMetaType == 0x464d4520 )
- {
- if ( !EnhWMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadEnhWMF() )
- rStreamWMF.SetError( SVSTREAM_FILEFORMAT_ERROR );
- }
- else
- {
- WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem, pExtHeader ).ReadWMF( );
- }
-
- // #i123216# allow a look at CheckSum and ByteSize for debugging
- SAL_INFO("vcl.emf", "\t\t\tchecksum: 0x" << std::hex << rGDIMetaFile.GetChecksum() << std::dec);
- SAL_INFO("vcl.emf", "\t\t\tsize: " << rGDIMetaFile.GetSizeBytes());
-
- rStreamWMF.SetEndian( nOrigNumberFormat );
- return !rStreamWMF.GetError();
-}
-
bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF )
{
- sal_uInt32 nMetaType(0);
- sal_uInt32 nOrgPos = rStream.Tell();
-
- SvStreamEndian nOrigNumberFormat = rStream.GetEndian();
- rStream.SetEndian( SvStreamEndian::LITTLE );
- //exception-safe reset nOrigNumberFormat at end of scope
- const ::comphelper::ScopeGuard aScopeGuard( [&rStream, nOrigNumberFormat] () { rStream.SetEndian( nOrigNumberFormat ); } );
-
- rStream.Seek( 0x28 );
- rStream.ReadUInt32( nMetaType );
- rStream.Seek( nOrgPos );
-
- if (!rStream.good())
- return false;
-
- if ( nMetaType == 0x464d4520 )
- {
- if ( !EnhWMFReader( rStream, rMTF, nullptr ).ReadEnhWMF() )
- rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
- }
- else
+ // Use new method to import Metafile. First, read binary data to mem array
+ const sal_uInt32 nStreamLength(rStream.Seek(STREAM_SEEK_TO_END));
+ VectorGraphicDataArray aNewData(nStreamLength);
+ rStream.Seek(0);
+ rStream.ReadBytes(aNewData.begin(), nStreamLength);
+ rStream.Seek(0);
+
+ if (rStream.good())
{
- WMFReader( rStream, rMTF, nullptr ).ReadWMF();
+ // Throw into VectorGraphicData to get the import. Do not care
+ // too much for type, this will be checked there. Also no path
+ // needed, it is a temporary object
+ VectorGraphicDataPtr aVectorGraphicDataPtr(
+ new VectorGraphicData(
+ aNewData,
+ OUString(),
+ VectorGraphicDataType::Emf));
+
+ // create a Graphic and grep Metafile from it
+ const Graphic aGraphic(aVectorGraphicDataPtr);
+
+ // get the Metafile from it, done
+ rMTF = aGraphic.GetGDIMetaFile();
+ return true;
}
return rStream.good();