[Libreoffice-commits] .: 3 commits - svtools/inc svtools/source
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Wed May 4 08:58:54 PDT 2011
svtools/inc/svtools/filter.hxx | 7 +++-
svtools/inc/svtools/wmf.hxx | 25 +++++++++++++++++
svtools/source/filter.vcl/filter/exportdialog.cxx | 2 -
svtools/source/filter.vcl/filter/filter.cxx | 9 +++---
svtools/source/filter.vcl/wmf/winmtf.cxx | 31 ++++++++++++++++++++++
svtools/source/filter.vcl/wmf/winmtf.hxx | 8 ++++-
svtools/source/filter.vcl/wmf/winwmf.cxx | 23 +++++++++++-----
svtools/source/filter.vcl/wmf/wmf.cxx | 4 +-
8 files changed, 90 insertions(+), 19 deletions(-)
New commits:
commit 72ea8cc3087a48f5bee75becb161ee8219e2871a
Author: Radek Doulik <rodo at novell.com>
Date: Wed May 4 17:38:19 2011 +0200
wmf-mm-text-1.diff: Fix WMF rendering, n#417818
diff --git a/svtools/source/filter.vcl/wmf/winmtf.cxx b/svtools/source/filter.vcl/wmf/winmtf.cxx
index cd3145d..91c0d2f 100644
--- a/svtools/source/filter.vcl/wmf/winmtf.cxx
+++ b/svtools/source/filter.vcl/wmf/winmtf.cxx
@@ -380,10 +380,15 @@ Point WinMtfOutput::ImplMap( const Point& rPt )
case MM_TEXT:
fX2 -= mnWinOrgX;
fY2 -= mnWinOrgY;
- fX2 *= 2540.0/mnUnitsPerInch;
- fY2 *= 2540.0/mnUnitsPerInch;
+ if( mnDevWidth != 1 || mnDevHeight != 1 ) {
+ fX2 *= 2540.0/mnUnitsPerInch;
+ fY2 *= 2540.0/mnUnitsPerInch;
+ }
fX2 += mnDevOrgX;
fY2 += mnDevOrgY;
+ fX2 *= (double)mnMillX * 100.0 / (double)mnPixX;
+ fY2 *= (double)mnMillY * 100.0 / (double)mnPixY;
+
break;
case MM_LOENGLISH :
{
@@ -461,8 +466,13 @@ Size WinMtfOutput::ImplMap( const Size& rSz )
switch( mnMapMode )
{
case MM_TEXT:
+ if( mnDevWidth != 1 && mnDevHeight != 1 ) {
fWidth *= 2540.0/mnUnitsPerInch;
fHeight*= 2540.0/mnUnitsPerInch;
+ } else {
+ fWidth *= (double)mnMillX * 100 / (double)mnPixX;
+ fHeight *= (double)mnMillY * 100 / (double)mnPixY;
+ }
break;
case MM_LOENGLISH :
{
commit 0920878d5f7965b8ea072f51d21bb9d21de5ba5c
Author: Radek Doulik <rodo at novell.com>
Date: Wed May 4 17:37:26 2011 +0200
wmf-mm-text.diff: Fix WMF rendering, n#417818
diff --git a/svtools/source/filter.vcl/wmf/winmtf.cxx b/svtools/source/filter.vcl/wmf/winmtf.cxx
index 40635d9..cd3145d 100644
--- a/svtools/source/filter.vcl/wmf/winmtf.cxx
+++ b/svtools/source/filter.vcl/wmf/winmtf.cxx
@@ -377,6 +377,14 @@ Point WinMtfOutput::ImplMap( const Point& rPt )
{
switch( mnMapMode )
{
+ case MM_TEXT:
+ fX2 -= mnWinOrgX;
+ fY2 -= mnWinOrgY;
+ fX2 *= 2540.0/mnUnitsPerInch;
+ fY2 *= 2540.0/mnUnitsPerInch;
+ fX2 += mnDevOrgX;
+ fY2 += mnDevOrgY;
+ break;
case MM_LOENGLISH :
{
fX2 -= mnWinOrgX;
@@ -452,6 +460,10 @@ Size WinMtfOutput::ImplMap( const Size& rSz )
{
switch( mnMapMode )
{
+ case MM_TEXT:
+ fWidth *= 2540.0/mnUnitsPerInch;
+ fHeight*= 2540.0/mnUnitsPerInch;
+ break;
case MM_LOENGLISH :
{
fWidth *= 25.40;
@@ -894,6 +906,7 @@ WinMtfOutput::WinMtfOutput( GDIMetaFile& rGDIMetaFile ) :
mbComplexClip ( false ),
mnGfxMode ( GM_COMPATIBLE ),
mnMapMode ( MM_TEXT ),
+ mnUnitsPerInch ( 96 ),
mnDevOrgX ( 0 ),
mnDevOrgY ( 0 ),
mnDevWidth ( 1 ),
@@ -2014,6 +2027,14 @@ void WinMtfOutput::SetMapMode( sal_uInt32 nMapMode )
//-----------------------------------------------------------------------------------
+void WinMtfOutput::SetUnitsPerInch( sal_uInt16 nUnitsPerInch )
+{
+ if( nUnitsPerInch != 0 )
+ mnUnitsPerInch = nUnitsPerInch;
+}
+
+//-----------------------------------------------------------------------------------
+
void WinMtfOutput::SetWorldTransform( const XForm& rXForm )
{
maXForm.eM11 = rXForm.eM11;
diff --git a/svtools/source/filter.vcl/wmf/winmtf.hxx b/svtools/source/filter.vcl/wmf/winmtf.hxx
index 76dcfd6..d1f4e5b 100644
--- a/svtools/source/filter.vcl/wmf/winmtf.hxx
+++ b/svtools/source/filter.vcl/wmf/winmtf.hxx
@@ -582,6 +582,8 @@ class WinMtfOutput
sal_uInt32 mnGfxMode;
sal_uInt32 mnMapMode;
+ sal_uInt16 mnUnitsPerInch;
+
XForm maXForm;
sal_Int32 mnDevOrgX, mnDevOrgY;
sal_Int32 mnDevWidth, mnDevHeight;
@@ -628,6 +630,7 @@ class WinMtfOutput
sal_uInt32 GetMapMode() const { return mnMapMode; };
void SetMapMode( sal_uInt32 mnMapMode );
+ void SetUnitsPerInch( sal_uInt16 nUnitsPerInch );
void SetWorldTransform( const XForm& rXForm );
void ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode );
diff --git a/svtools/source/filter.vcl/wmf/winwmf.cxx b/svtools/source/filter.vcl/wmf/winwmf.cxx
index c532633..42da2ac 100644
--- a/svtools/source/filter.vcl/wmf/winwmf.cxx
+++ b/svtools/source/filter.vcl/wmf/winwmf.cxx
@@ -1044,6 +1044,7 @@ sal_Bool WMFReader::ReadHeader(WMF_APMFILEHEADER *pAPMHeader)
}
}
+ pOut->SetUnitsPerInch( nUnitsPerInch );
pOut->SetWinOrg( aPlaceableBound.TopLeft() );
aWMFSize = Size( labs( aPlaceableBound.GetWidth() ), labs( aPlaceableBound.GetHeight() ) );
pOut->SetWinExt( aWMFSize );
commit ac9fbf25dad680195005524902daeb5d48dc6c28
Author: Florian Reuter <freuter at novell.com>
Date: Wed May 4 11:39:43 2011 +0200
external-apm-header.diff: fix WMF scaling in RTF import, n#417818
diff --git a/svtools/inc/svtools/filter.hxx b/svtools/inc/svtools/filter.hxx
index 4380eb3..256e934 100644
--- a/svtools/inc/svtools/filter.hxx
+++ b/svtools/inc/svtools/filter.hxx
@@ -39,6 +39,7 @@
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/beans/PropertyValue.hpp>
+struct WMF_APMFILEHEADER;
// -----------------------
// - GraphicFilter-Types -
// -----------------------
@@ -341,13 +342,15 @@ public:
sal_uInt16 ImportGraphic( Graphic& rGraphic, const String& rPath,
SvStream& rStream,
sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW,
- sal_uInt16 * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0 );
+ sal_uInt16 * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0,
+ WMF_APMFILEHEADER *pAPMHeader = NULL );
sal_uInt16 ImportGraphic( Graphic& rGraphic, const String& rPath,
SvStream& rStream,
sal_uInt16 nFormat,
sal_uInt16 * pDeterminedFormat, sal_uInt32 nImportFlags,
- com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData );
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData,
+ WMF_APMFILEHEADER *pAPMHeader = NULL );
sal_Bool Setup( sal_uInt16 nFormat );
diff --git a/svtools/inc/svtools/wmf.hxx b/svtools/inc/svtools/wmf.hxx
index ef0cbaf..335e178 100644
--- a/svtools/inc/svtools/wmf.hxx
+++ b/svtools/inc/svtools/wmf.hxx
@@ -32,7 +32,30 @@
#include "svtools/svtdllapi.h"
#include <svtools/fltcall.hxx>
-sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL );
+struct WMF_APMFILEHEADER {
+ sal_uInt32 key;
+ sal_uInt16 hmf;
+ sal_uInt16 left;
+ sal_uInt16 top;
+ sal_uInt16 right;
+ sal_uInt16 bottom;
+ sal_uInt16 inch;
+ sal_uInt32 reserved;
+ sal_uInt16 checksum;
+
+ WMF_APMFILEHEADER() : key(0x9ac6cdd7L),
+ hmf(0),
+ left(0),
+ top(0),
+ right(0),
+ bottom(0),
+ inch(96),
+ reserved(0),
+ checksum(0) {
+ }
+};
+
+sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL, WMF_APMFILEHEADER *pAPMHeader = NULL );
SVT_DLLPUBLIC sal_Bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pConfigItem );
diff --git a/svtools/source/filter.vcl/filter/exportdialog.cxx b/svtools/source/filter.vcl/filter/exportdialog.cxx
index 860f065..37e091e 100644
--- a/svtools/source/filter.vcl/filter/exportdialog.cxx
+++ b/svtools/source/filter.vcl/filter/exportdialog.cxx
@@ -522,7 +522,7 @@ Bitmap ExportDialog::GetGraphicBitmap( SvStream& rInputStream )
Bitmap aRet;
Graphic aGraphic;
GraphicFilter aFilter( sal_False );
- if ( aFilter.ImportGraphic( aGraphic, String(), rInputStream, GRFILTER_FORMAT_NOTFOUND, NULL, 0, NULL ) == GRFILTER_OK )
+ if ( aFilter.ImportGraphic( aGraphic, String(), rInputStream, GRFILTER_FORMAT_NOTFOUND, NULL, 0, NULL, NULL ) == GRFILTER_OK )
{
aRet = aGraphic.GetBitmap();
}
diff --git a/svtools/source/filter.vcl/filter/filter.cxx b/svtools/source/filter.vcl/filter/filter.cxx
index 211ea6b..14832b2 100644
--- a/svtools/source/filter.vcl/filter/filter.cxx
+++ b/svtools/source/filter.vcl/filter/filter.cxx
@@ -1304,16 +1304,17 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject&
}
sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
- sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, sal_uInt32 nImportFlags )
+ sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, sal_uInt32 nImportFlags, WMF_APMFILEHEADER *pAPMHeader )
{
- return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL );
+ return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL, pAPMHeader );
}
//-------------------------------------------------------------------------
sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, sal_uInt32 nImportFlags,
- com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData )
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData,
+ WMF_APMFILEHEADER *pAPMHeader )
{
String aFilterName;
sal_uLong nStmBegin;
@@ -1510,7 +1511,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath,
aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
{
GDIMetaFile aMtf;
- if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL ) )
+ if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL, pAPMHeader ) )
nStatus = GRFILTER_FORMATERROR;
else
{
diff --git a/svtools/source/filter.vcl/wmf/winmtf.hxx b/svtools/source/filter.vcl/wmf/winmtf.hxx
index 0db1d65..76dcfd6 100644
--- a/svtools/source/filter.vcl/wmf/winmtf.hxx
+++ b/svtools/source/filter.vcl/wmf/winmtf.hxx
@@ -157,6 +157,7 @@ struct LOGFONTW
sal_uInt8 lfPitchAndFamily;
String alfFaceName;
};
+struct WMF_APMFILEHEADER;
#define TA_NOUPDATECP 0x0000
#define TA_UPDATECP 0x0001
@@ -767,7 +768,7 @@ private:
sal_uInt32 nUnicodeEscapeAction;
// Liesst den Kopf der WMF-Datei
- sal_Bool ReadHeader();
+ sal_Bool ReadHeader(WMF_APMFILEHEADER *pAPMHeader);
// Liesst die Parameter des Rocords mit der Funktionsnummer nFunction.
void ReadRecordParams( sal_uInt16 nFunction );
@@ -788,7 +789,7 @@ public:
~WMFReader();
// Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile
- void ReadWMF();
+ void ReadWMF(WMF_APMFILEHEADER *pAPMHeader=NULL);
};
#endif
diff --git a/svtools/source/filter.vcl/wmf/winwmf.cxx b/svtools/source/filter.vcl/wmf/winwmf.cxx
index 00bcd95..c532633 100644
--- a/svtools/source/filter.vcl/wmf/winwmf.cxx
+++ b/svtools/source/filter.vcl/wmf/winwmf.cxx
@@ -31,6 +31,7 @@
#include "winmtf.hxx"
#include <vcl/gdimtf.hxx>
+#include <svtools/wmf.hxx>
#include <rtl/crc.h>
#include <rtl/tencinfo.h>
#include <osl/endian.h>
@@ -997,7 +998,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
// ------------------------------------------------------------------------
-sal_Bool WMFReader::ReadHeader()
+sal_Bool WMFReader::ReadHeader(WMF_APMFILEHEADER *pAPMHeader)
{
Rectangle aPlaceableBound;
sal_uInt32 nl, nStrmPos = pWMF->Tell();
@@ -1030,10 +1031,17 @@ sal_Bool WMFReader::ReadHeader()
}
else
{
- nUnitsPerInch = 96;
- pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the the metaactions
- GetPlaceableBound( aPlaceableBound, pWMF );
- pWMF->Seek( nStrmPos );
+ nUnitsPerInch = (pAPMHeader!=NULL?pAPMHeader->inch:96);
+ pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the the metaactions
+ GetPlaceableBound( aPlaceableBound, pWMF );
+ pWMF->Seek( nStrmPos );
+ if (pAPMHeader!=NULL) {
+ // #n417818#: If we have an external header then overwrite the bounds!
+ aPlaceableBound=Rectangle(pAPMHeader->left*567*nUnitsPerInch/1440/1000,
+ pAPMHeader->top*567*nUnitsPerInch/1440/1000,
+ pAPMHeader->right*567*nUnitsPerInch/1440/1000,
+ pAPMHeader->bottom*567*nUnitsPerInch/1440/1000);
+ }
}
pOut->SetWinOrg( aPlaceableBound.TopLeft() );
@@ -1068,7 +1076,7 @@ sal_Bool WMFReader::ReadHeader()
return sal_True;
}
-void WMFReader::ReadWMF()
+void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
{
sal_uInt16 nFunction;
sal_uLong nPos, nPercent, nLastPercent;
@@ -1093,7 +1101,7 @@ void WMFReader::ReadWMF()
pWMF->Seek( nStartPos );
Callback( (sal_uInt16) ( nLastPercent = 0 ) );
- if ( ReadHeader() )
+ if ( ReadHeader( pAPMHeader ) )
{
nPos = pWMF->Tell();
diff --git a/svtools/source/filter.vcl/wmf/wmf.cxx b/svtools/source/filter.vcl/wmf/wmf.cxx
index 256b2e2..c65c691 100644
--- a/svtools/source/filter.vcl/wmf/wmf.cxx
+++ b/svtools/source/filter.vcl/wmf/wmf.cxx
@@ -36,7 +36,7 @@
// -----------------------------------------------------------------------------
-sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem )
+sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_APMFILEHEADER *pAPMHeader )
{
sal_uInt32 nMetaType;
sal_uInt32 nOrgPos = rStreamWMF.Tell();
@@ -52,7 +52,7 @@ sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaF
}
else
{
- WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF();
+ WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF( pAPMHeader );
}
rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
return !rStreamWMF.GetError();
More information about the Libreoffice-commits
mailing list