summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-11-24 15:05:25 +0100
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-11-24 16:08:46 +0100
commitf4f4a899f0d5520a497bbd07ccfef9086c54ca1c (patch)
tree06c378dc6f5596f90dbfb3f1508c1630be838d2a
parent616db52655b65201e60f53deb3a063b0fdd7cc6b (diff)
RTF import: partly fixed the WMF images scaling.
-rw-r--r--editeng/source/rtf/rtfgrf.cxx9
-rw-r--r--oox/inc/oox/helper/graphichelper.hxx8
-rw-r--r--oox/source/helper/graphichelper.cxx65
-rw-r--r--svtools/inc/svtools/filter.hxx6
-rw-r--r--svtools/inc/svtools/wmf.hxx48
-rw-r--r--svtools/source/filter/filter.cxx8
-rw-r--r--svtools/source/filter/wmf/winmtf.hxx14
-rw-r--r--svtools/source/filter/wmf/winwmf.cxx62
-rw-r--r--svtools/source/filter/wmf/wmf.cxx4
-rw-r--r--svtools/source/graphic/provider.cxx42
-rw-r--r--writerfilter/source/rtftok/rtfcontrolwords.cxx2
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx19
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx1
13 files changed, 187 insertions, 101 deletions
diff --git a/editeng/source/rtf/rtfgrf.cxx b/editeng/source/rtf/rtfgrf.cxx
index 4ff9f3506f2b..2906caa4ae5e 100644
--- a/editeng/source/rtf/rtfgrf.cxx
+++ b/editeng/source/rtf/rtfgrf.cxx
@@ -495,15 +495,8 @@ sal_Bool SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType )
}
String sTmpStr;
- WMF_APMFILEHEADER aAPMHeader;
- aAPMHeader.left=0;
- aAPMHeader.top=0;
- aAPMHeader.right=rPicType.nWidth;
- aAPMHeader.bottom=rPicType.nHeight;
-
- WMF_APMFILEHEADER *pAPMHeader=(aAPMHeader.right>0 && aAPMHeader.bottom>0?&aAPMHeader:NULL);
pTmpFile->Seek( STREAM_SEEK_TO_BEGIN );
- bValidBmp = 0 == rGF.ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter, NULL, 0, pAPMHeader );
+ bValidBmp = 0 == rGF.ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter );
}
}
diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx
index f144cd17fd38..d3507fa1a519 100644
--- a/oox/inc/oox/helper/graphichelper.hxx
+++ b/oox/inc/oox/helper/graphichelper.hxx
@@ -37,6 +37,8 @@
#include "oox/helper/binarystreambase.hxx"
#include "oox/helper/storagebase.hxx"
+struct WMF_EXTERNALHEADER;
+
namespace com { namespace sun { namespace star {
namespace awt { struct Point; }
namespace awt { struct Size; }
@@ -115,7 +117,8 @@ public:
/** Imports a graphic from the passed input stream. */
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
importGraphic(
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
+ const WMF_EXTERNALHEADER* pExtHeader = NULL ) const;
/** Imports a graphic from the passed binary memory block. */
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
@@ -133,7 +136,8 @@ public:
/** Creates a persistent graphic object from the passed input stream.
@return The URL of the created and internally cached graphic object. */
::rtl::OUString importGraphicObject(
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
+ const WMF_EXTERNALHEADER* pExtHeader = NULL ) const;
/** Creates a persistent graphic object from the passed binary memory block.
@return The URL of the created and internally cached graphic object. */
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 941cc80f49f3..fd3046e025bb 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/util/MeasureUnit.hpp>
#include <comphelper/seqstream.hxx>
+#include <svtools/wmf.hxx>
#include "oox/helper/containerhelper.hxx"
#include "oox/helper/propertyset.hxx"
#include "oox/token/tokens.hxx"
@@ -47,7 +48,8 @@ namespace oox {
// ============================================================================
-using namespace ::com::sun::star::awt;
+
+using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::graphic;
@@ -130,7 +132,7 @@ GraphicHelper::GraphicHelper( const Reference< XComponentContext >& rxContext, c
maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case
if( xFrame.is() ) try
{
- Reference< XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ Reference< awt::XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW );
mxUnitConversion.set( xDevice, UNO_QUERY );
OSL_ENSURE( mxUnitConversion.is(), "GraphicHelper::GraphicHelper - cannot get unit converter" );
maDeviceInfo = xDevice->getInfo();
@@ -168,7 +170,7 @@ sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const
// Device info and device dependent unit conversion ---------------------------
-const DeviceInfo& GraphicHelper::getDeviceInfo() const
+const awt::DeviceInfo& GraphicHelper::getDeviceInfo() const
{
return maDeviceInfo;
}
@@ -183,14 +185,14 @@ sal_Int32 GraphicHelper::convertScreenPixelYToHmm( double fPixelY ) const
return lclConvertScreenPixelToHmm( fPixelY, mfPixelPerHmmY );
}
-Point GraphicHelper::convertScreenPixelToHmm( const Point& rPixel ) const
+awt::Point GraphicHelper::convertScreenPixelToHmm( const awt::Point& rPixel ) const
{
- return Point( convertScreenPixelXToHmm( rPixel.X ), convertScreenPixelYToHmm( rPixel.Y ) );
+ return awt::Point( convertScreenPixelXToHmm( rPixel.X ), convertScreenPixelYToHmm( rPixel.Y ) );
}
-Size GraphicHelper::convertScreenPixelToHmm( const Size& rPixel ) const
+awt::Size GraphicHelper::convertScreenPixelToHmm( const awt::Size& rPixel ) const
{
- return Size( convertScreenPixelXToHmm( rPixel.Width ), convertScreenPixelYToHmm( rPixel.Height ) );
+ return awt::Size( convertScreenPixelXToHmm( rPixel.Width ), convertScreenPixelYToHmm( rPixel.Height ) );
}
double GraphicHelper::convertHmmToScreenPixelX( sal_Int32 nHmmX ) const
@@ -203,49 +205,50 @@ double GraphicHelper::convertHmmToScreenPixelY( sal_Int32 nHmmY ) const
return nHmmY * mfPixelPerHmmY;
}
-Point GraphicHelper::convertHmmToScreenPixel( const Point& rHmm ) const
+awt::Point GraphicHelper::convertHmmToScreenPixel( const awt::Point& rHmm ) const
{
- return Point(
+ return awt::Point(
static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.X ) + 0.5 ),
static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Y ) + 0.5 ) );
}
-Size GraphicHelper::convertHmmToScreenPixel( const Size& rHmm ) const
+awt::Size GraphicHelper::convertHmmToScreenPixel( const awt::Size& rHmm ) const
{
- return Size(
+ return awt::Size(
static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.Width ) + 0.5 ),
static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Height ) + 0.5 ) );
}
-Point GraphicHelper::convertHmmToAppFont( const Point& rHmm ) const
+awt::Point GraphicHelper::convertHmmToAppFont( const awt::Point& rHmm ) const
{
if( mxUnitConversion.is() ) try
{
- Point aPixel = convertHmmToScreenPixel( rHmm );
+ awt::Point aPixel = convertHmmToScreenPixel( rHmm );
return mxUnitConversion->convertPointToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT );
}
catch( Exception& )
{
}
- return Point( 0, 0 );
+ return awt::Point( 0, 0 );
}
-Size GraphicHelper::convertHmmToAppFont( const Size& rHmm ) const
+awt::Size GraphicHelper::convertHmmToAppFont( const awt::Size& rHmm ) const
{
if( mxUnitConversion.is() ) try
{
- Size aPixel = convertHmmToScreenPixel( rHmm );
+ awt::Size aPixel = convertHmmToScreenPixel( rHmm );
return mxUnitConversion->convertSizeToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT );
}
catch( Exception& )
{
}
- return Size( 0, 0 );
+ return awt::Size( 0, 0 );
}
// Graphics and graphic objects ----------------------------------------------
-Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm ) const
+Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm,
+ const WMF_EXTERNALHEADER* pExtHeader ) const
{
Reference< XGraphic > xGraphic;
if( rxInStrm.is() && mxGraphicProvider.is() ) try
@@ -253,6 +256,21 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
Sequence< PropertyValue > aArgs( 1 );
aArgs[ 0 ].Name = CREATE_OUSTRING( "InputStream" );
aArgs[ 0 ].Value <<= rxInStrm;
+
+ if ( pExtHeader->mapMode > 0 )
+ {
+ aArgs.realloc( aArgs.getLength() + 1 );
+ Sequence< PropertyValue > aFilterData( 3 );
+ aFilterData[ 0 ].Name = CREATE_OUSTRING( "ExternalWidth" );
+ aFilterData[ 0 ].Value <<= pExtHeader->xExt;
+ aFilterData[ 1 ].Name = CREATE_OUSTRING( "ExternalHeight" );
+ aFilterData[ 1 ].Value <<= pExtHeader->yExt;
+ aFilterData[ 2 ].Name = CREATE_OUSTRING( "ExternalMapMode" );
+ aFilterData[ 2 ].Value <<= pExtHeader->mapMode;
+ aArgs[ 1 ].Name = CREATE_OUSTRING( "FilterData" );
+ aArgs[ 1 ].Value <<= aFilterData;
+ }
+
xGraphic = mxGraphicProvider->queryGraphic( aArgs );
}
catch( Exception& )
@@ -307,9 +325,10 @@ OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGrap
return aGraphicObjUrl;
}
-OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm ) const
+OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm,
+ const WMF_EXTERNALHEADER* pExtHeader ) const
{
- return createGraphicObject( importGraphic( rxInStrm ) );
+ return createGraphicObject( importGraphic( rxInStrm, pExtHeader ) );
}
OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData ) const
@@ -323,13 +342,13 @@ OUString GraphicHelper::importEmbeddedGraphicObject( const OUString& rStreamName
return xGraphic.is() ? createGraphicObject( xGraphic ) : OUString();
}
-Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic ) const
+awt::Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic ) const
{
- Size aSizeHmm;
+ awt::Size aSizeHmm;
PropertySet aPropSet( xGraphic );
if( aPropSet.getProperty( aSizeHmm, PROP_Size100thMM ) && (aSizeHmm.Width == 0) && (aSizeHmm.Height == 0) ) // MAPMODE_PIXEL used?
{
- Size aSizePixel( 0, 0 );
+ awt::Size aSizePixel( 0, 0 );
if( aPropSet.getProperty( aSizePixel, PROP_SizePixel ) )
aSizeHmm = convertScreenPixelToHmm( aSizePixel );
}
diff --git a/svtools/inc/svtools/filter.hxx b/svtools/inc/svtools/filter.hxx
index da3a7cb036c8..7defa39b48a5 100644
--- a/svtools/inc/svtools/filter.hxx
+++ b/svtools/inc/svtools/filter.hxx
@@ -39,7 +39,7 @@
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/beans/PropertyValue.hpp>
-struct WMF_APMFILEHEADER;
+struct WMF_EXTERNALHEADER;
// -----------------------
// - GraphicFilter-Types -
// -----------------------
@@ -347,14 +347,14 @@ public:
SvStream& rStream,
sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW,
sal_uInt16 * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0,
- WMF_APMFILEHEADER *pAPMHeader = NULL );
+ WMF_EXTERNALHEADER *pExtHeader = 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,
- WMF_APMFILEHEADER *pAPMHeader = NULL );
+ WMF_EXTERNALHEADER *pExtHeader = NULL );
sal_Bool Setup( sal_uInt16 nFormat );
diff --git a/svtools/inc/svtools/wmf.hxx b/svtools/inc/svtools/wmf.hxx
index a455f443e26e..986ccfb0d785 100644
--- a/svtools/inc/svtools/wmf.hxx
+++ b/svtools/inc/svtools/wmf.hxx
@@ -32,30 +32,36 @@
#include "svtools/svtdllapi.h"
#include <svtools/fltcall.hxx>
-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;
+struct WMF_EXTERNALHEADER
+{
+ sal_uInt16 xExt;
+ sal_uInt16 yExt;
- WMF_APMFILEHEADER() : key(0x9ac6cdd7L),
- hmf(0),
- left(0),
- top(0),
- right(0),
- bottom(0),
- inch(96),
- reserved(0),
- checksum(0) {
- }
+ /** One of the following values:
+ <ul>
+ <li>MM_TEXT</li>
+ <li>MM_LOMETRIC</li>
+ <li>MM_HIMETRIC</li>
+ <li>MM_LOENGLISH</li>
+ <li>MM_HIENGLISH</li>
+ <li>MM_TWIPS</li>
+ <li>MM_ISOTROPIC</li>
+ <li>MM_ANISOTROPIC</li>
+ </ul>
+ If this value is 0, then no external mapmode has been defined,
+ the internal one should then be used.
+ */
+ sal_uInt16 mapMode;
+
+ WMF_EXTERNALHEADER() :
+ xExt( 0 ),
+ yExt( 0 ),
+ mapMode( 0 )
+ {
+ }
};
-sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL, WMF_APMFILEHEADER *pAPMHeader = NULL );
+sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL, WMF_EXTERNALHEADER *pExtHeader = NULL );
SVT_DLLPUBLIC sal_Bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pConfigItem );
diff --git a/svtools/source/filter/filter.cxx b/svtools/source/filter/filter.cxx
index 4cdd34d8c862..8548364e5e46 100644
--- a/svtools/source/filter/filter.cxx
+++ b/svtools/source/filter/filter.cxx
@@ -1329,9 +1329,9 @@ 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, WMF_APMFILEHEADER *pAPMHeader )
+ sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, sal_uInt32 nImportFlags, WMF_EXTERNALHEADER *pExtHeader )
{
- return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL, pAPMHeader );
+ return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL, pExtHeader );
}
//-------------------------------------------------------------------------
@@ -1339,7 +1339,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath,
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,
- WMF_APMFILEHEADER *pAPMHeader )
+ WMF_EXTERNALHEADER *pExtHeader )
{
String aFilterName;
sal_uLong nStmBegin;
@@ -1554,7 +1554,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath,
aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
{
GDIMetaFile aMtf;
- if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL, pAPMHeader ) )
+ if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL, pExtHeader ) )
nStatus = GRFILTER_FORMATERROR;
else
{
diff --git a/svtools/source/filter/wmf/winmtf.hxx b/svtools/source/filter/wmf/winmtf.hxx
index 58bb5bf25153..28c19c061eab 100644
--- a/svtools/source/filter/wmf/winmtf.hxx
+++ b/svtools/source/filter/wmf/winmtf.hxx
@@ -156,7 +156,7 @@ struct LOGFONTW
sal_uInt8 lfPitchAndFamily;
String alfFaceName;
};
-struct WMF_APMFILEHEADER;
+struct WMF_EXTERNALHEADER;
#define TA_NOUPDATECP 0x0000
#define TA_UPDATECP 0x0001
@@ -872,8 +872,10 @@ private:
sal_uInt32 nCurrentAction;
sal_uInt32 nUnicodeEscapeAction;
+ WMF_EXTERNALHEADER* pExternalHeader;
+
// Liesst den Kopf der WMF-Datei
- sal_Bool ReadHeader( WMF_APMFILEHEADER *pAPMHeader );
+ sal_Bool ReadHeader();
// Liesst die Parameter des Rocords mit der Funktionsnummer nFunction.
void ReadRecordParams( sal_uInt16 nFunction );
@@ -889,16 +891,18 @@ public:
WMFReader(
SvStream& rStreamWMF,
GDIMetaFile& rGDIMetaFile,
- FilterConfigItem* pConfigItem = NULL
+ FilterConfigItem* pConfigItem = NULL,
+ WMF_EXTERNALHEADER* pExtHeader = NULL
)
: WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem )
- , pEMFStream(NULL)
+ , pEMFStream(NULL),
+ pExternalHeader(pExtHeader)
{}
~WMFReader();
// Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile
- void ReadWMF(WMF_APMFILEHEADER *pAPMHeader=NULL);
+ void ReadWMF();
};
#endif
diff --git a/svtools/source/filter/wmf/winwmf.cxx b/svtools/source/filter/wmf/winwmf.cxx
index c08f6e108f76..d1727fb51634 100644
--- a/svtools/source/filter/wmf/winwmf.cxx
+++ b/svtools/source/filter/wmf/winwmf.cxx
@@ -117,6 +117,27 @@
#define W_META_CREATEBITMAP 0x06FE
#define W_META_CREATEREGION 0x06FF
+static void GetWinExtMax( const Point& rSource, Rectangle& rPlaceableBound, const sal_Int16 nMapMode )
+{
+ Point aSource( rSource );
+ if ( nMapMode == MM_HIMETRIC )
+ aSource.Y() = -rSource.Y();
+ if ( aSource.X() < rPlaceableBound.Left() )
+ rPlaceableBound.Left() = aSource.X();
+ if ( aSource.X() > rPlaceableBound.Right() )
+ rPlaceableBound.Right() = aSource.X();
+ if ( aSource.Y() < rPlaceableBound.Top() )
+ rPlaceableBound.Top() = aSource.Y();
+ if ( aSource.Y() > rPlaceableBound.Bottom() )
+ rPlaceableBound.Bottom() = aSource.Y();
+}
+
+static void GetWinExtMax( const Rectangle& rSource, Rectangle& rPlaceableBound, const sal_Int16 nMapMode )
+{
+ GetWinExtMax( rSource.TopLeft(), rPlaceableBound, nMapMode );
+ GetWinExtMax( rSource.BottomRight(), rPlaceableBound, nMapMode );
+}
+
//=================== Methods of WMFReader ==============================
inline Point WMFReader::ReadPoint()
@@ -998,7 +1019,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
// ------------------------------------------------------------------------
-sal_Bool WMFReader::ReadHeader(WMF_APMFILEHEADER *pAPMHeader)
+sal_Bool WMFReader::ReadHeader()
{
sal_Size nStrmPos = pWMF->Tell();
@@ -1038,17 +1059,19 @@ sal_Bool WMFReader::ReadHeader(WMF_APMFILEHEADER *pAPMHeader)
}
else
{
- nUnitsPerInch = (pAPMHeader!=NULL?pAPMHeader->inch:96);
+ nUnitsPerInch = 96;
pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the the metaactions
GetPlaceableBound( aPlaceableBound, pWMF );
pWMF->Seek( nStrmPos );
- if (pAPMHeader!=NULL)
+ if ( pExternalHeader != NULL && ( pExternalHeader->mapMode == MM_ISOTROPIC
+ || pExternalHeader->mapMode == MM_ANISOTROPIC ) )
{
// #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);
+ Rectangle aExtRect(0, 0,
+ pExternalHeader->xExt*567*nUnitsPerInch/1440/1000,
+ pExternalHeader->yExt*567*nUnitsPerInch/1440/1000);
+ GetWinExtMax( aExtRect, aPlaceableBound, pExternalHeader->mapMode );
+ pOut->SetMapMode( pExternalHeader->mapMode );
}
}
@@ -1087,7 +1110,7 @@ sal_Bool WMFReader::ReadHeader(WMF_APMFILEHEADER *pAPMHeader)
return pWMF->good();
}
-void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
+void WMFReader::ReadWMF()
{
sal_uInt16 nFunction;
sal_uLong nPos, nPercent, nLastPercent;
@@ -1112,7 +1135,7 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
pWMF->Seek( nStartPos );
Callback( (sal_uInt16) ( nLastPercent = 0 ) );
- if ( ReadHeader( pAPMHeader ) )
+ if ( ReadHeader( ) )
{
nPos = pWMF->Tell();
@@ -1207,27 +1230,6 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
// ------------------------------------------------------------------------
-static void GetWinExtMax( const Point& rSource, Rectangle& rPlaceableBound, const sal_Int16 nMapMode )
-{
- Point aSource( rSource );
- if ( nMapMode == MM_HIMETRIC )
- aSource.Y() = -rSource.Y();
- if ( aSource.X() < rPlaceableBound.Left() )
- rPlaceableBound.Left() = aSource.X();
- if ( aSource.X() > rPlaceableBound.Right() )
- rPlaceableBound.Right() = aSource.X();
- if ( aSource.Y() < rPlaceableBound.Top() )
- rPlaceableBound.Top() = aSource.Y();
- if ( aSource.Y() > rPlaceableBound.Bottom() )
- rPlaceableBound.Bottom() = aSource.Y();
-}
-
-static void GetWinExtMax( const Rectangle& rSource, Rectangle& rPlaceableBound, const sal_Int16 nMapMode )
-{
- GetWinExtMax( rSource.TopLeft(), rPlaceableBound, nMapMode );
- GetWinExtMax( rSource.BottomRight(), rPlaceableBound, nMapMode );
-}
-
sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
{
sal_Bool bRet = sal_True;
diff --git a/svtools/source/filter/wmf/wmf.cxx b/svtools/source/filter/wmf/wmf.cxx
index 479ec5b30f86..3f3e5157855f 100644
--- a/svtools/source/filter/wmf/wmf.cxx
+++ b/svtools/source/filter/wmf/wmf.cxx
@@ -37,7 +37,7 @@
// -----------------------------------------------------------------------------
-sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_APMFILEHEADER *pAPMHeader )
+sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER *pExtHeader )
{
sal_uInt32 nMetaType;
sal_uInt32 nOrgPos = rStreamWMF.Tell();
@@ -53,7 +53,7 @@ sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaF
}
else
{
- WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF( pAPMHeader );
+ WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem, pExtHeader ).ReadWMF( );
}
rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
return !rStreamWMF.GetError();
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx
index 7807ffe24733..1bdc632e6310 100644
--- a/svtools/source/graphic/provider.cxx
+++ b/svtools/source/graphic/provider.cxx
@@ -40,6 +40,7 @@
#include <tools/resmgr.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <svtools/filter.hxx>
+#include <svtools/wmf.hxx>
#include <svl/solar.hrc>
#include <vcl/salbtype.hxx>
#include <vcl/virdev.hxx>
@@ -443,6 +444,8 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
uno::Reference< io::XInputStream > xIStm;
uno::Reference< awt::XBitmap >xBtm;
+ uno::Sequence< ::beans::PropertyValue > aFilterData;
+
for( sal_Int32 i = 0; ( i < rMediaProperties.getLength() ) && !pIStm && !xRet.is(); ++i )
{
const ::rtl::OUString aName( rMediaProperties[ i ].Name );
@@ -462,6 +465,33 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
{
aValue >>= xBtm;
}
+ else if( COMPARE_EQUAL == aName.compareToAscii( "FilterData" ) )
+ {
+ aValue >>= aFilterData;
+ }
+ }
+
+ // Check for the goal width and height if they are defined
+ sal_uInt16 nExtWidth = 0;
+ sal_uInt16 nExtHeight = 0;
+ sal_uInt16 nExtMapMode = 0;
+ for( sal_Int32 i = 0; i < aFilterData.getLength(); ++i )
+ {
+ const ::rtl::OUString aName( aFilterData[ i ].Name );
+ const uno::Any aValue( aFilterData[ i ].Value );
+
+ if( COMPARE_EQUAL == aName.compareToAscii( "ExternalWidth" ) )
+ {
+ aValue >>= nExtWidth;
+ }
+ else if( COMPARE_EQUAL == aName.compareToAscii( "ExternalHeight" ) )
+ {
+ aValue >>= nExtHeight;
+ }
+ else if( COMPARE_EQUAL == aName.compareToAscii( "ExternalMapMode" ) )
+ {
+ aValue >>= nExtMapMode;
+ }
}
if( xIStm.is() )
@@ -499,7 +529,17 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
{
::Graphic aVCLGraphic;
- if( ( rFilter.ImportGraphic( aVCLGraphic, aPath, *pIStm ) == GRFILTER_OK ) &&
+ // Define APM Header if goal height and width are defined
+ WMF_EXTERNALHEADER aExtHeader;
+ aExtHeader.xExt = nExtWidth;
+ aExtHeader.yExt = nExtHeight;
+ aExtHeader.mapMode = nExtMapMode;
+ WMF_EXTERNALHEADER *pExtHeader = NULL;
+ if ( nExtMapMode > 0 )
+ pExtHeader = &aExtHeader;
+
+ if( ( rFilter.ImportGraphic( aVCLGraphic, aPath, *pIStm,
+ GRFILTER_FORMAT_DONTKNOW, NULL, 0, pExtHeader ) == GRFILTER_OK ) &&
( aVCLGraphic.GetType() != GRAPHIC_NONE ) )
{
::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic;
diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx
index aef56ab77962..3b82e8065f50 100644
--- a/writerfilter/source/rtftok/rtfcontrolwords.cxx
+++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx
@@ -1184,6 +1184,7 @@ RTFSymbol aRTFControlWords[] = {
{"piccropt", CONTROL_VALUE, RTF_PICCROPT},
{"pich", CONTROL_VALUE, RTF_PICH},
{"pichgoal", CONTROL_VALUE, RTF_PICHGOAL},
+ {"pichGoal", CONTROL_VALUE, RTF_PICHGOAL},
{"picprop", CONTROL_DESTINATION, RTF_PICPROP},
{"picscaled", CONTROL_FLAG, RTF_PICSCALED},
{"picscalex", CONTROL_VALUE, RTF_PICSCALEX},
@@ -1191,6 +1192,7 @@ RTFSymbol aRTFControlWords[] = {
{"pict", CONTROL_DESTINATION, RTF_PICT},
{"picw", CONTROL_VALUE, RTF_PICW},
{"picwgoal", CONTROL_VALUE, RTF_PICWGOAL},
+ {"picwGoal", CONTROL_VALUE, RTF_PICWGOAL},
{"pindtabqc", CONTROL_FLAG, RTF_PINDTABQC},
{"pindtabql", CONTROL_FLAG, RTF_PINDTABQL},
{"pindtabqr", CONTROL_FLAG, RTF_PINDTABQR},
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2e31bc7f32bf..bd1636d46fc5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/text/RelOrientation.hpp>
#include <editeng/borderline.hxx>
#include <rtl/tencinfo.h>
+#include <svtools/wmf.hxx>
#include <svl/lngmisc.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/streamwrap.hxx>
@@ -570,7 +571,11 @@ int RTFDocumentImpl::resolvePict(bool bInline)
// Store, and get its URL.
aStream.Seek(0);
uno::Reference<io::XInputStream> xInputStream(new utl::OInputStreamWrapper(&aStream));
- OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream);
+ WMF_EXTERNALHEADER aExtHeader;
+ aExtHeader.mapMode = m_aStates.top().aPicture.eWMetafile;
+ aExtHeader.xExt = m_aStates.top().aPicture.nWidth;
+ aExtHeader.yExt = m_aStates.top().aPicture.nHeight;
+ OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, &aExtHeader);
// Wrap it in an XShape.
uno::Reference<drawing::XShape> xShape;
@@ -599,6 +604,12 @@ int RTFDocumentImpl::resolvePict(bool bInline)
uno::Reference<graphic::XGraphic> xGraphic = xGraphicProvider->queryGraphic(aMediaProperties);
xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Graphic")), uno::Any(xGraphic));
+ // Set the object size
+ awt::Size aSize;
+ aSize.Width = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth);
+ aSize.Height = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight);
+ xShape->setSize( aSize );
+
RTFValue::Pointer_t pShapeValue(new RTFValue(xShape));
m_aObjectAttributes->push_back(make_pair(NS_ooxml::LN_shape, pShapeValue));
return 0;
@@ -2524,6 +2535,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_FLYANCHOR:
m_aStates.top().aFrame.nAnchorType = nParam;
break;
+ case RTF_WMETAFILE:
+ m_aStates.top().aPicture.eWMetafile = nParam;
+ break;
default:
#if OSL_DEBUG_LEVEL > 1
OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -3227,7 +3241,8 @@ RTFPicture::RTFPicture()
nCropT(0),
nCropB(0),
nCropL(0),
- nCropR(0)
+ nCropR(0),
+ eWMetafile(0)
{
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index ef333596d5c7..d0aa294e7f3d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -182,6 +182,7 @@ namespace writerfilter {
sal_uInt16 nGoalWidth, nGoalHeight;
sal_uInt16 nScaleX, nScaleY;
short nCropT, nCropB, nCropL, nCropR;
+ sal_uInt16 eWMetafile;
};
/// Stores the properties of a frame