summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorRadek Doulik <rodo@novell.com>2010-09-15 12:09:15 +0200
committerRadek Doulik <rodo@novell.com>2010-09-15 17:54:14 +0200
commite687e92c88498bdd4c64b10625c7663d982dd072 (patch)
tree084ae847a7950abc1f64854a00463ce5a4ec64a0 /svtools
parent4386aa5455376e366ae012d69bff816dafaf4b08 (diff)
wmf-pattern-brush.diff: emf+ import - added pattern brushes support to wmf
n#232232
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/filter.vcl/wmf/enhwmf.cxx57
-rw-r--r--svtools/source/filter.vcl/wmf/winmtf.cxx36
-rw-r--r--svtools/source/filter.vcl/wmf/winmtf.hxx40
-rw-r--r--svtools/source/filter.vcl/wmf/winwmf.cxx4
4 files changed, 117 insertions, 20 deletions
diff --git a/svtools/source/filter.vcl/wmf/enhwmf.cxx b/svtools/source/filter.vcl/wmf/enhwmf.cxx
index a11c739022e5..a81fcab66db0 100644
--- a/svtools/source/filter.vcl/wmf/enhwmf.cxx
+++ b/svtools/source/filter.vcl/wmf/enhwmf.cxx
@@ -1008,7 +1008,10 @@ BOOL EnhWMFReader::ReadEnhWMF()
Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
aBitmap.Crop( aCropRect );
}
- aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
+ /* Pseudocomment to add more context so that make patch.unapply
+ * works better. Ha!
+ */
+ aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ), LIST_APPEND );
}
}
}
@@ -1062,7 +1065,8 @@ BOOL EnhWMFReader::ReadEnhWMF()
Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
aBitmap.Crop( aCropRect );
}
- aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
+ /* Another pseudocomment to make make patch.unapply work better */
+ aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ), LIST_APPEND );
}
}
}
@@ -1333,6 +1337,54 @@ BOOL EnhWMFReader::ReadEnhWMF()
}
break;
+ case EMR_CREATEDIBPATTERNBRUSHPT :
+ {
+ static int count = 0;
+ UINT32 nStart = pWMF->Tell() - 8;
+ Bitmap aBitmap;
+
+ *pWMF >> nIndex;
+
+ if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+ {
+ UINT32 usage, offBmi, cbBmi, offBits, cbBits;
+
+ *pWMF >> usage;
+ *pWMF >> offBmi;
+ *pWMF >> cbBmi;
+ *pWMF >> offBits;
+ *pWMF >> cbBits;
+
+ if ( (cbBits > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBits < cbBmi) )
+ bStatus = FALSE;
+ else if ( offBmi )
+ {
+ UINT32 nSize = cbBmi + cbBits + 14;
+ if ( nSize <= ( nEndPos - nStartPos ) )
+ {
+ char* pBuf = new char[ nSize ];
+
+ SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
+ aTmp.ObjectOwnsMemory( TRUE );
+ aTmp << (BYTE)'B'
+ << (BYTE)'M'
+ << (UINT32)cbBits
+ << (UINT16)0
+ << (UINT16)0
+ << (UINT32)cbBmi + 14;
+ pWMF->Seek( nStart + offBmi );
+ pWMF->Read( pBuf + 14, cbBmi );
+ pWMF->Seek( nStart + offBits );
+ pWMF->Read( pBuf + 14 + cbBmi, cbBits );
+ aTmp.Seek( 0 );
+ aBitmap.Read( aTmp, TRUE );
+ }
+ }
+ }
+
+ pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( aBitmap ) );
+ }
+ break;
#ifdef WIN_MTF_ASSERT
default : WinMtfAssertHandler( "Unknown Meta Action" ); break;
@@ -1352,7 +1404,6 @@ BOOL EnhWMFReader::ReadEnhWMF()
case EMR_ANGLEARC : WinMtfAssertHandler( "AngleArc" ); break;
case EMR_SETCOLORADJUSTMENT : WinMtfAssertHandler( "SetColorAdjustment" ); break;
case EMR_POLYDRAW16 : WinMtfAssertHandler( "PolyDraw16" ); break;
- case EMR_CREATEDIBPATTERNBRUSHPT : WinMtfAssertHandler( "CreateDibPatternBrushPt" ); break;
case EMR_POLYTEXTOUTA : WinMtfAssertHandler( "PolyTextOutA" ); break;
case EMR_POLYTEXTOUTW : WinMtfAssertHandler( "PolyTextOutW" ); break;
case EMR_CREATECOLORSPACE : WinMtfAssertHandler( "CreateColorSpace" ); break;
diff --git a/svtools/source/filter.vcl/wmf/winmtf.cxx b/svtools/source/filter.vcl/wmf/winmtf.cxx
index eba616f2fea4..a2619bc967f8 100644
--- a/svtools/source/filter.vcl/wmf/winmtf.cxx
+++ b/svtools/source/filter.vcl/wmf/winmtf.cxx
@@ -31,6 +31,7 @@
#include "winmtf.hxx"
#include <vcl/metaact.hxx>
+#include <vcl/graphictools.hxx>
#include <vcl/metric.hxx>
#include <rtl/tencinfo.h>
@@ -1041,7 +1042,8 @@ void WinMtfOutput::UpdateFillStyle()
if (!( maLatestFillStyle == maFillStyle ) )
{
maLatestFillStyle = maFillStyle;
- mpGDIMetaFile->AddAction( new MetaFillColorAction( maFillStyle.aFillColor, !maFillStyle.bTransparent ) );
+ if (maFillStyle.aType == FillStyleSolid)
+ mpGDIMetaFile->AddAction( new MetaFillColorAction( maFillStyle.aFillColor, !maFillStyle.bTransparent ) );
}
}
@@ -1369,7 +1371,35 @@ void WinMtfOutput::DrawPolygon( Polygon& rPolygon, sal_Bool bRecordPath )
else
{
UpdateLineStyle();
- mpGDIMetaFile->AddAction( new MetaPolygonAction( rPolygon ) );
+
+ if (maLatestFillStyle.aType != FillStylePattern)
+ mpGDIMetaFile->AddAction( new MetaPolygonAction( rPolygon ) );
+ else {
+ SvtGraphicFill aFill = SvtGraphicFill( PolyPolygon( rPolygon ),
+ Color(),
+ 0.0,
+ SvtGraphicFill::fillNonZero,
+ SvtGraphicFill::fillTexture,
+ SvtGraphicFill::Transform(),
+ true,
+ SvtGraphicFill::hatchSingle,
+ Color(),
+ SvtGraphicFill::gradientLinear,
+ Color(),
+ Color(),
+ 0,
+ Graphic (maLatestFillStyle.aBmp) );
+
+ SvMemoryStream aMemStm;
+
+ aMemStm << aFill;
+
+ mpGDIMetaFile->AddAction( new MetaCommentAction( "XPATHFILL_SEQ_BEGIN", 0,
+ static_cast<const BYTE*>(aMemStm.GetData()),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) ) );
+ mpGDIMetaFile->AddAction( new MetaCommentAction( "XPATHFILL_SEQ_END" ) );
+ }
+
}
}
}
@@ -1712,7 +1742,7 @@ void WinMtfOutput::ResolveBitmapActions( List& rSaveList )
if ( ( nRasterOperation & 0xaa ) != ( ( nRasterOperation & 0x55 ) << 1 ) )
nUsed |= 4; // destination is used
- if ( (nUsed & 1) && (( nUsed & 2 ) == 0) )
+ if ( (nUsed & 1) && (( nUsed & 2 ) == 0) && nWinRop != PATINVERT )
{ // patterns aren't well supported yet
sal_uInt32 nOldRop = SetRasterOp( ROP_OVERPAINT ); // in this case nRasterOperation is either 0 or 0xff
UpdateFillStyle();
diff --git a/svtools/source/filter.vcl/wmf/winmtf.hxx b/svtools/source/filter.vcl/wmf/winmtf.hxx
index aa630d6ebfa4..a9903a641014 100644
--- a/svtools/source/filter.vcl/wmf/winmtf.hxx
+++ b/svtools/source/filter.vcl/wmf/winmtf.hxx
@@ -364,10 +364,17 @@ struct WinMtfFontStyle
// -----------------------------------------------------------------------------
+typedef enum {
+ FillStyleSolid,
+ FillStylePattern
+} WinMtfFillStyleType;
+
struct WinMtfFillStyle
{
- Color aFillColor;
- BOOL bTransparent;
+ Color aFillColor;
+ BOOL bTransparent;
+ WinMtfFillStyleType aType;
+ Bitmap aBmp;
WinMtfFillStyle() :
aFillColor ( Color( COL_BLACK ) ),
@@ -377,16 +384,23 @@ struct WinMtfFillStyle
WinMtfFillStyle( const Color& rColor, BOOL bTrans = FALSE ) :
aFillColor ( rColor ),
- bTransparent( bTrans )
+ bTransparent( bTrans ),
+ aType ( FillStyleSolid )
+ {
+ };
+
+ WinMtfFillStyle( Bitmap& rBmp ) :
+ aBmp ( rBmp ),
+ aType( FillStylePattern )
{
};
BOOL operator==( const WinMtfFillStyle& rStyle )
- { return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) ); };
+ { return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) && ( aType == rStyle.aType ) ); };
BOOL operator==( WinMtfFillStyle* pStyle )
- { return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) ); };
- void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; };
- void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; };
+ { return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) && ( aType == pStyle->aType ) ); };
+ void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; aBmp = rStyle.aBmp; aType = rStyle.aType; };
+ void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; aBmp = pStyle->aBmp; aType = pStyle->aType; };
};
// -----------------------------------------------------------------------------
@@ -478,12 +492,13 @@ typedef ::boost::shared_ptr< SaveStruct > SaveStructPtr;
struct BSaveStruct
{
- Bitmap aBmp;
- Rectangle aOutRect;
- UINT32 nWinRop;
+ Bitmap aBmp;
+ Rectangle aOutRect;
+ UINT32 nWinRop;
+ WinMtfFillStyle aStyle;
- BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, UINT32 nRop ) :
- aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ){};
+ BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, UINT32 nRop, WinMtfFillStyle& rStyle ) :
+ aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ), aStyle ( rStyle ){};
};
// -----------------------------------------------------------------------------
@@ -638,6 +653,7 @@ class WinMtfOutput
void DeleteObject( INT32 nIndex );
void SelectObject( INT32 nIndex );
CharSet GetCharSet(){ return maFont.GetCharSet(); };
+ WinMtfFillStyle& GetFillStyle () { return maFillStyle; }
void SetFont( const Font& rFont );
const Font& GetFont() const;
void SetTextLayoutMode( const sal_uInt32 nLayoutMode );
diff --git a/svtools/source/filter.vcl/wmf/winwmf.cxx b/svtools/source/filter.vcl/wmf/winwmf.cxx
index cea1ab490b04..a8fdc86604fc 100644
--- a/svtools/source/filter.vcl/wmf/winwmf.cxx
+++ b/svtools/source/filter.vcl/wmf/winwmf.cxx
@@ -569,7 +569,7 @@ void WMFReader::ReadRecordParams( USHORT nFunc )
aBmp.Crop( aCropRect );
}
Rectangle aDestRect( aPoint, Size( nSxe, nSye ) );
- aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND );
+ aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ), LIST_APPEND );
}
}
}
@@ -619,7 +619,7 @@ void WMFReader::ReadRecordParams( USHORT nFunc )
Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
aBmp.Crop( aCropRect );
}
- aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND );
+ aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ), LIST_APPEND );
}
}
}