PageRenderTime 62ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/libreoffice-3.6.0.2/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx

#
C++ | 1298 lines | 1084 code | 157 blank | 57 comment | 91 complexity | caab86f100c7278b67041ff6b1dfb931 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, AGPL-1.0, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, LGPL-3.0
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /*************************************************************************
  3. *
  4. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5. *
  6. * Copyright 2000, 2010 Oracle and/or its affiliates.
  7. *
  8. * OpenOffice.org - a multi-platform office productivity suite
  9. *
  10. * This file is part of OpenOffice.org.
  11. *
  12. * OpenOffice.org is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Lesser General Public License version 3
  14. * only, as published by the Free Software Foundation.
  15. *
  16. * OpenOffice.org is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Lesser General Public License version 3 for more details
  20. * (a copy is included in the LICENSE file that accompanied this code).
  21. *
  22. * You should have received a copy of the GNU Lesser General Public License
  23. * version 3 along with OpenOffice.org. If not, see
  24. * <http://www.openoffice.org/license.html>
  25. * for a copy of the LGPLv3 License.
  26. *
  27. ************************************************************************/
  28. #include "winmtf.hxx"
  29. #include <osl/endian.h>
  30. namespace binfilter
  31. {
  32. //=========================== GDI-Array ===================================
  33. #define EMR_HEADER 1
  34. #define EMR_POLYBEZIER 2
  35. #define EMR_POLYGON 3
  36. #define EMR_POLYLINE 4
  37. #define EMR_POLYBEZIERTO 5
  38. #define EMR_POLYLINETO 6
  39. #define EMR_POLYPOLYLINE 7
  40. #define EMR_POLYPOLYGON 8
  41. #define EMR_SETWINDOWEXTEX 9
  42. #define EMR_SETWINDOWORGEX 10
  43. #define EMR_SETVIEWPORTEXTEX 11
  44. #define EMR_SETVIEWPORTORGEX 12
  45. #define EMR_SETBRUSHORGEX 13
  46. #define EMR_EOF 14
  47. #define EMR_SETPIXELV 15
  48. #define EMR_SETMAPPERFLAGS 16
  49. #define EMR_SETMAPMODE 17
  50. #define EMR_SETBKMODE 18
  51. #define EMR_SETPOLYFILLMODE 19
  52. #define EMR_SETROP2 20
  53. #define EMR_SETSTRETCHBLTMODE 21
  54. #define EMR_SETTEXTALIGN 22
  55. #define EMR_SETCOLORADJUSTMENT 23
  56. #define EMR_SETTEXTCOLOR 24
  57. #define EMR_SETBKCOLOR 25
  58. #define EMR_OFFSETCLIPRGN 26
  59. #define EMR_MOVETOEX 27
  60. #define EMR_SETMETARGN 28
  61. #define EMR_EXCLUDECLIPRECT 29
  62. #define EMR_INTERSECTCLIPRECT 30
  63. #define EMR_SCALEVIEWPORTEXTEX 31
  64. #define EMR_SCALEWINDOWEXTEX 32
  65. #define EMR_SAVEDC 33
  66. #define EMR_RESTOREDC 34
  67. #define EMR_SETWORLDTRANSFORM 35
  68. #define EMR_MODIFYWORLDTRANSFORM 36
  69. #define EMR_SELECTOBJECT 37
  70. #define EMR_CREATEPEN 38
  71. #define EMR_CREATEBRUSHINDIRECT 39
  72. #define EMR_DELETEOBJECT 40
  73. #define EMR_ANGLEARC 41
  74. #define EMR_ELLIPSE 42
  75. #define EMR_RECTANGLE 43
  76. #define EMR_ROUNDRECT 44
  77. #define EMR_ARC 45
  78. #define EMR_CHORD 46
  79. #define EMR_PIE 47
  80. #define EMR_SELECTPALETTE 48
  81. #define EMR_CREATEPALETTE 49
  82. #define EMR_SETPALETTEENTRIES 50
  83. #define EMR_RESIZEPALETTE 51
  84. #define EMR_REALIZEPALETTE 52
  85. #define EMR_EXTFLOODFILL 53
  86. #define EMR_LINETO 54
  87. #define EMR_ARCTO 55
  88. #define EMR_POLYDRAW 56
  89. #define EMR_SETARCDIRECTION 57
  90. #define EMR_SETMITERLIMIT 58
  91. #define EMR_BEGINPATH 59
  92. #define EMR_ENDPATH 60
  93. #define EMR_CLOSEFIGURE 61
  94. #define EMR_FILLPATH 62
  95. #define EMR_STROKEANDFILLPATH 63
  96. #define EMR_STROKEPATH 64
  97. #define EMR_FLATTENPATH 65
  98. #define EMR_WIDENPATH 66
  99. #define EMR_SELECTCLIPPATH 67
  100. #define EMR_ABORTPATH 68
  101. #define EMR_GDICOMMENT 70
  102. #define EMR_FILLRGN 71
  103. #define EMR_FRAMERGN 72
  104. #define EMR_INVERTRGN 73
  105. #define EMR_PAINTRGN 74
  106. #define EMR_EXTSELECTCLIPRGN 75
  107. #define EMR_BITBLT 76
  108. #define EMR_STRETCHBLT 77
  109. #define EMR_MASKBLT 78
  110. #define EMR_PLGBLT 79
  111. #define EMR_SETDIBITSTODEVICE 80
  112. #define EMR_STRETCHDIBITS 81
  113. #define EMR_EXTCREATEFONTINDIRECTW 82
  114. #define EMR_EXTTEXTOUTA 83
  115. #define EMR_EXTTEXTOUTW 84
  116. #define EMR_POLYBEZIER16 85
  117. #define EMR_POLYGON16 86
  118. #define EMR_POLYLINE16 87
  119. #define EMR_POLYBEZIERTO16 88
  120. #define EMR_POLYLINETO16 89
  121. #define EMR_POLYPOLYLINE16 90
  122. #define EMR_POLYPOLYGON16 91
  123. #define EMR_POLYDRAW16 92
  124. #define EMR_CREATEMONOBRUSH 93
  125. #define EMR_CREATEDIBPATTERNBRUSHPT 94
  126. #define EMR_EXTCREATEPEN 95
  127. #define EMR_POLYTEXTOUTA 96
  128. #define EMR_POLYTEXTOUTW 97
  129. // WINDOWS VERSION >= 0x400
  130. #define EMR_SETICMMODE 98
  131. #define EMR_CREATECOLORSPACE 99
  132. #define EMR_SETCOLORSPACE 100
  133. #define EMR_DELETECOLORSPACE 101
  134. #define EMR_GLSRECORD 102
  135. #define EMR_GLSBOUNDEDRECORD 103
  136. #define EMR_PIXELFORMAT 104
  137. // WINDOWS VERSION >= 0x500
  138. #define EMR_DRAWESCAPE 105
  139. #define EMR_EXTESCAPE 106
  140. #define EMR_STARTDOC 107
  141. #define EMR_SMALLTEXTOUT 108
  142. #define EMR_FORCEUFIMAPPING 109
  143. #define EMR_NAMEDESCAPE 110
  144. #define EMR_COLORCORRECTPALETTE 111
  145. #define EMR_SETICMPROFILEA 112
  146. #define EMR_SETICMPROFILEW 113
  147. #define EMR_ALPHABLEND 114
  148. #define EMR_ALPHADIBBLEND 115
  149. #define EMR_TRANSPARENTBLT 116
  150. #define EMR_TRANSPARENTDIB 117
  151. #define EMR_GRADIENTFILL 118
  152. #define EMR_SETLINKEDUFIS 119
  153. #define EMR_SETTEXTJUSTIFICATION 120
  154. //-----------------------------------------------------------------------------------
  155. #ifdef OSL_BIGENDIAN
  156. // currently unused
  157. static float GetSwapFloat( SvStream& rSt )
  158. {
  159. float fTmp;
  160. sal_Int8* pPtr = (sal_Int8*)&fTmp;
  161. rSt >> pPtr[3] >> pPtr[2] >> pPtr[1] >> pPtr[0]; // Little Endian <-> Big Endian switch
  162. return fTmp;
  163. }
  164. #endif
  165. SvStream& operator>>( SvStream& rIn, XForm& rXForm )
  166. {
  167. if ( sizeof( float ) != 4 )
  168. {
  169. OSL_FAIL( "EnhWMFReader::sizeof( float ) != 4" );
  170. rXForm = XForm();
  171. }
  172. else
  173. {
  174. #ifdef OSL_BIGENDIAN
  175. rXForm.eM11 = GetSwapFloat( rIn );
  176. rXForm.eM12 = GetSwapFloat( rIn );
  177. rXForm.eM21 = GetSwapFloat( rIn );
  178. rXForm.eM22 = GetSwapFloat( rIn );
  179. rXForm.eDx = GetSwapFloat( rIn );
  180. rXForm.eDy = GetSwapFloat( rIn );
  181. #else
  182. rIn >> rXForm.eM11 >> rXForm.eM12 >> rXForm.eM21 >> rXForm.eM22
  183. >> rXForm.eDx >> rXForm.eDy;
  184. #endif
  185. }
  186. return rIn;
  187. }
  188. static sal_Bool ImplReadRegion( PolyPolygon& rPolyPoly, SvStream& rSt, sal_uInt32 nLen )
  189. {
  190. sal_Bool bOk = sal_False;
  191. if ( nLen )
  192. {
  193. sal_uInt32 nHdSize, nType, nCount, nRgnSize, i;
  194. rSt >> nHdSize
  195. >> nType
  196. >> nCount
  197. >> nRgnSize;
  198. if ( nCount && ( nType == RDH_RECTANGLES ) &&
  199. ( nLen >= ( ( nCount << 4 ) + ( nHdSize - 16 ) ) ) )
  200. {
  201. sal_Int32 nx1, ny1, nx2, ny2;
  202. for ( i = 0; i < nCount; i++ )
  203. {
  204. rSt >> nx1 >> ny1 >> nx2 >> ny2;
  205. Rectangle aRect( Point( nx1, ny1 ), Point( nx2, ny2 ) );
  206. Polygon aPolygon( aRect );
  207. PolyPolygon aPolyPolyOr1( aPolygon );
  208. PolyPolygon aPolyPolyOr2( rPolyPoly );
  209. rPolyPoly.GetUnion( aPolyPolyOr1, aPolyPolyOr2 );
  210. rPolyPoly = aPolyPolyOr2;
  211. }
  212. bOk = sal_True;
  213. }
  214. }
  215. return bOk;
  216. }
  217. BOOL EnhWMFReader::ReadEnhWMF()
  218. {
  219. sal_uInt32 nStretchBltMode = 0;
  220. sal_uInt32 nRecType, nRecSize, nNextPos,
  221. nW, nH, nPoints, nColor, nIndex,
  222. nDat32, nNom1, nDen1, nNom2, nDen2;
  223. sal_Int32 nX32, nY32, nx32, ny32;
  224. sal_Int16 nX16, nY16;
  225. sal_Bool bFlag, bStatus = ReadHeader();
  226. while( bStatus && nRecordCount-- )
  227. {
  228. *pWMF >> nRecType >> nRecSize;
  229. if ( ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameter sind immer durch 4 teilbar
  230. {
  231. bStatus = FALSE;
  232. break;
  233. }
  234. nNextPos = pWMF->Tell() + ( nRecSize - 8 );
  235. if ( nNextPos > nEndPos )
  236. {
  237. bStatus = FALSE;
  238. break;
  239. }
  240. if( aBmpSaveList.Count() && ( nRecType != EMR_STRETCHBLT ) && ( nRecType != EMR_STRETCHDIBITS ) )
  241. pOut->ResolveBitmapActions( aBmpSaveList );
  242. bFlag = sal_False;
  243. switch( nRecType )
  244. {
  245. case EMR_POLYBEZIERTO :
  246. bFlag = sal_True;
  247. case EMR_POLYBEZIER :
  248. {
  249. pWMF->SeekRel( 16 );
  250. *pWMF >> nPoints;
  251. sal_uInt16 i = 0;
  252. if ( bFlag )
  253. {
  254. i++;
  255. nPoints++;
  256. }
  257. Polygon aPoly( (sal_uInt16)nPoints );
  258. for( ; i < (sal_uInt16)nPoints; i++ )
  259. {
  260. *pWMF >> nX32 >> nY32;
  261. aPoly[ i ] = Point( nX32, nY32 );
  262. }
  263. pOut->DrawPolyBezier( aPoly, bFlag, bRecordPath );
  264. }
  265. break;
  266. case EMR_POLYGON :
  267. {
  268. pWMF->SeekRel( 16 );
  269. *pWMF >> nPoints;
  270. Polygon aPoly( (UINT16)nPoints );
  271. for( UINT16 k = 0; k < (UINT16)nPoints; k++ )
  272. {
  273. *pWMF >> nX32 >> nY32;
  274. aPoly[ k ] = Point( nX32, nY32 );
  275. }
  276. pOut->DrawPolygon( aPoly, bRecordPath );
  277. }
  278. break;
  279. case EMR_POLYLINETO :
  280. bFlag = sal_True;
  281. case EMR_POLYLINE :
  282. {
  283. pWMF->SeekRel( 0x10 );
  284. *pWMF >> nPoints;
  285. UINT16 i = 0;
  286. if ( bFlag )
  287. {
  288. i++;
  289. nPoints++;
  290. }
  291. Polygon aPolygon( (UINT16)nPoints );
  292. for ( ; i < (UINT16)nPoints; i++ )
  293. {
  294. *pWMF >> nX32 >> nY32;
  295. aPolygon[ i ] = Point( nX32, nY32 );
  296. }
  297. pOut->DrawPolyLine( aPolygon, bFlag, bRecordPath );
  298. }
  299. break;
  300. case EMR_POLYPOLYLINE :
  301. {
  302. UINT16* pnPoints;
  303. INT32 i, nPoly;
  304. pWMF->SeekRel( 0x10 );
  305. // Anzahl der Polygone:
  306. *pWMF >> nPoly >> i;
  307. // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
  308. pnPoints = new UINT16[ nPoly ];
  309. for ( i = 0; i < nPoly; i++ )
  310. {
  311. *pWMF >> nPoints;
  312. pnPoints[ i ] = (UINT16)nPoints;
  313. }
  314. // Polygonpunkte holen:
  315. for ( i = 0; i < nPoly; i++ )
  316. {
  317. Polygon aPoly( pnPoints[ i ] );
  318. for( UINT16 k = 0; k < pnPoints[ i ]; k++ )
  319. {
  320. *pWMF >> nX32 >> nY32;
  321. aPoly[ k ] = Point( nX32, nY32 );
  322. }
  323. pOut->DrawPolyLine( aPoly, sal_False, bRecordPath );
  324. }
  325. delete[] pnPoints;
  326. }
  327. break;
  328. case EMR_POLYPOLYGON :
  329. {
  330. UINT16* pnPoints;
  331. Point* pPtAry;
  332. UINT32 i, nPoly, nGesPoints;
  333. pWMF->SeekRel( 0x10 );
  334. // Anzahl der Polygone:
  335. *pWMF >> nPoly >> nGesPoints;
  336. if (nGesPoints < SAL_MAX_UINT32 / sizeof(Point))
  337. {
  338. // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
  339. pnPoints = new UINT16[ nPoly ];
  340. for ( i = 0; i < nPoly; i++ )
  341. {
  342. *pWMF >> nPoints;
  343. pnPoints[ i ] = (UINT16)nPoints;
  344. }
  345. // Polygonpunkte holen:
  346. pPtAry = (Point*) new char[ nGesPoints * sizeof(Point) ];
  347. for ( i = 0; i < nGesPoints; i++ )
  348. {
  349. *pWMF >> nX32 >> nY32;
  350. pPtAry[ i ] = Point( nX32, nY32 );
  351. }
  352. // PolyPolygon Actions erzeugen
  353. PolyPolygon aPolyPoly( (UINT16)nPoly, pnPoints, pPtAry );
  354. pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
  355. delete[] (char*) pPtAry;
  356. delete[] pnPoints;
  357. }
  358. }
  359. break;
  360. case EMR_SETWINDOWEXTEX :
  361. { // #75383#
  362. *pWMF >> nW >> nH;
  363. pOut->SetWinExt( Size( nW, nH ) );
  364. }
  365. break;
  366. case EMR_SETWINDOWORGEX :
  367. {
  368. *pWMF >> nX32 >> nY32;
  369. pOut->SetWinOrg( Point( nX32, nY32 ) );
  370. }
  371. break;
  372. case EMR_SCALEWINDOWEXTEX :
  373. {
  374. *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2;
  375. pOut->ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 );
  376. }
  377. break;
  378. case EMR_SETVIEWPORTORGEX :
  379. {
  380. *pWMF >> nX32 >> nY32;
  381. pOut->SetDevOrg( Point( nX32, nY32 ) );
  382. }
  383. break;
  384. case EMR_SCALEVIEWPORTEXTEX :
  385. {
  386. *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2;
  387. pOut->ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 );
  388. }
  389. break;
  390. case EMR_SETVIEWPORTEXTEX :
  391. {
  392. *pWMF >> nW >> nH;
  393. pOut->SetDevExt( Size( nW, nH ) );
  394. }
  395. break;
  396. case EMR_EOF :
  397. nRecordCount = 0; // #76846#
  398. break;
  399. case EMR_SETPIXELV :
  400. {
  401. *pWMF >> nX32 >> nY32;
  402. pOut->DrawPixel( Point( nX32, nY32 ), ReadColor() );
  403. }
  404. break;
  405. case EMR_SETMAPMODE :
  406. {
  407. sal_uInt32 nMapMode;
  408. *pWMF >> nMapMode;
  409. pOut->SetMapMode( nMapMode );
  410. }
  411. break;
  412. case EMR_SETBKMODE :
  413. {
  414. *pWMF >> nDat32;
  415. pOut->SetBkMode( nDat32 );
  416. }
  417. break;
  418. case EMR_SETPOLYFILLMODE :
  419. break;
  420. case EMR_SETROP2 :
  421. {
  422. *pWMF >> nDat32;
  423. pOut->SetRasterOp( nDat32 );
  424. }
  425. break;
  426. case EMR_SETSTRETCHBLTMODE :
  427. {
  428. *pWMF >> nStretchBltMode;
  429. }
  430. break;
  431. case EMR_SETTEXTALIGN :
  432. {
  433. *pWMF >> nDat32;
  434. pOut->SetTextAlign( nDat32 );
  435. }
  436. break;
  437. case EMR_SETTEXTCOLOR :
  438. {
  439. pOut->SetTextColor( ReadColor() );
  440. }
  441. break;
  442. case EMR_SETBKCOLOR :
  443. {
  444. pOut->SetBkColor( ReadColor() );
  445. }
  446. break;
  447. case EMR_OFFSETCLIPRGN :
  448. {
  449. *pWMF >> nX32 >> nY32;
  450. pOut->MoveClipRegion( Size( nX32, nY32 ) );
  451. }
  452. break;
  453. case EMR_MOVETOEX :
  454. {
  455. *pWMF >> nX32 >> nY32;
  456. pOut->MoveTo( Point( nX32, nY32 ), bRecordPath );
  457. }
  458. break;
  459. case EMR_INTERSECTCLIPRECT :
  460. {
  461. *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
  462. pOut->IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) );
  463. }
  464. break;
  465. case EMR_SAVEDC :
  466. {
  467. pOut->Push();
  468. }
  469. break;
  470. case EMR_RESTOREDC :
  471. {
  472. pOut->Pop();
  473. }
  474. break;
  475. case EMR_SETWORLDTRANSFORM :
  476. {
  477. XForm aTempXForm;
  478. *pWMF >> aTempXForm;
  479. pOut->SetWorldTransform( aTempXForm );
  480. }
  481. break;
  482. case EMR_MODIFYWORLDTRANSFORM :
  483. {
  484. UINT32 nMode;
  485. XForm aTempXForm;
  486. *pWMF >> aTempXForm >> nMode;
  487. pOut->ModifyWorldTransform( aTempXForm, nMode );
  488. }
  489. break;
  490. case EMR_SELECTOBJECT :
  491. {
  492. *pWMF >> nIndex;
  493. pOut->SelectObject( nIndex );
  494. }
  495. break;
  496. case EMR_CREATEPEN :
  497. {
  498. *pWMF >> nIndex;
  499. if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
  500. {
  501. LineInfo aLineInfo;
  502. UINT32 nStyle;
  503. Size aSize;
  504. *pWMF >> nStyle >> aSize.Width() >> aSize.Height();
  505. if ( aSize.Width() )
  506. aLineInfo.SetWidth( aSize.Width() );
  507. BOOL bTransparent = FALSE;
  508. UINT16 nDashCount = 0;
  509. UINT16 nDotCount = 0;
  510. switch( nStyle )
  511. {
  512. case PS_DASHDOTDOT :
  513. nDotCount++;
  514. case PS_DASHDOT :
  515. nDashCount++;
  516. case PS_DOT :
  517. nDotCount++;
  518. break;
  519. case PS_DASH :
  520. nDashCount++;
  521. break;
  522. case PS_NULL :
  523. bTransparent = TRUE;
  524. aLineInfo.SetStyle( LINE_NONE );
  525. break;
  526. default :
  527. case PS_INSIDEFRAME :
  528. case PS_SOLID :
  529. aLineInfo.SetStyle( LINE_SOLID );
  530. }
  531. if ( nDashCount | nDotCount )
  532. {
  533. aLineInfo.SetStyle( LINE_DASH );
  534. aLineInfo.SetDashCount( nDashCount );
  535. aLineInfo.SetDotCount( nDotCount );
  536. }
  537. pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( ReadColor(), aLineInfo, bTransparent ) );
  538. }
  539. }
  540. break;
  541. case EMR_EXTCREATEPEN :
  542. {
  543. sal_Int32 elpHatch;
  544. sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries;
  545. Color aColorRef;
  546. *pWMF >> nIndex;
  547. if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
  548. {
  549. *pWMF >> offBmi >> cbBmi >> offBits >> cbBits >> nStyle >> nWidth >> nBrushStyle;
  550. aColorRef = ReadColor();
  551. *pWMF >> elpHatch >> elpNumEntries;
  552. LineInfo aLineInfo;
  553. if ( nWidth )
  554. aLineInfo.SetWidth( nWidth );
  555. sal_Bool bTransparent = sal_False;
  556. sal_uInt16 nDashCount = 0;
  557. sal_uInt16 nDotCount = 0;
  558. switch( nStyle & PS_STYLE_MASK )
  559. {
  560. case PS_DASHDOTDOT :
  561. nDotCount++;
  562. case PS_DASHDOT :
  563. nDashCount++;
  564. case PS_DOT :
  565. nDotCount++;
  566. break;
  567. case PS_DASH :
  568. nDashCount++;
  569. break;
  570. case PS_NULL :
  571. bTransparent = sal_True;
  572. aLineInfo.SetStyle( LINE_NONE );
  573. break;
  574. default :
  575. case PS_INSIDEFRAME :
  576. case PS_SOLID :
  577. aLineInfo.SetStyle( LINE_SOLID );
  578. }
  579. if ( nDashCount | nDotCount )
  580. {
  581. aLineInfo.SetStyle( LINE_DASH );
  582. aLineInfo.SetDashCount( nDashCount );
  583. aLineInfo.SetDotCount( nDotCount );
  584. }
  585. pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( aColorRef, aLineInfo, bTransparent ) );
  586. }
  587. }
  588. break;
  589. case EMR_CREATEBRUSHINDIRECT :
  590. {
  591. UINT32 nStyle;
  592. *pWMF >> nIndex;
  593. if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
  594. {
  595. *pWMF >> nStyle;
  596. pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( ReadColor(), ( nStyle == BS_HOLLOW ) ? TRUE : FALSE ) );
  597. }
  598. }
  599. break;
  600. case EMR_DELETEOBJECT :
  601. {
  602. *pWMF >> nIndex;
  603. if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
  604. pOut->DeleteObject( nIndex );
  605. }
  606. break;
  607. case EMR_ELLIPSE :
  608. {
  609. *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
  610. pOut->DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) );
  611. }
  612. break;
  613. case EMR_RECTANGLE :
  614. {
  615. *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
  616. pOut->DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) );
  617. }
  618. break;
  619. case EMR_ROUNDRECT :
  620. {
  621. *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nW >> nH;
  622. Size aSize( Size( nW, nH ) );
  623. pOut->DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize );
  624. }
  625. break;
  626. case EMR_ARC :
  627. {
  628. UINT32 nStartX, nStartY, nEndX, nEndY;
  629. *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
  630. pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
  631. }
  632. break;
  633. case EMR_CHORD :
  634. {
  635. UINT32 nStartX, nStartY, nEndX, nEndY;
  636. *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
  637. pOut->DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
  638. }
  639. break;
  640. case EMR_PIE :
  641. {
  642. UINT32 nStartX, nStartY, nEndX, nEndY;
  643. *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
  644. const Rectangle aRect( ReadRectangle( nX32, nY32, nx32, ny32 ));
  645. // #i73608# OutputDevice deviates from WMF
  646. // semantics. start==end means full ellipse here.
  647. if( nStartX == nEndX && nStartY == nEndY )
  648. pOut->DrawEllipse( aRect );
  649. else
  650. pOut->DrawPie( aRect, Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
  651. }
  652. break;
  653. case EMR_LINETO :
  654. {
  655. *pWMF >> nX32 >> nY32;
  656. pOut->LineTo( Point( nX32, nY32 ), bRecordPath );
  657. }
  658. break;
  659. case EMR_ARCTO :
  660. {
  661. UINT32 nStartX, nStartY, nEndX, nEndY;
  662. *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
  663. pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), TRUE );
  664. }
  665. break;
  666. case EMR_BEGINPATH :
  667. {
  668. pOut->ClearPath();
  669. bRecordPath = sal_True;
  670. }
  671. break;
  672. case EMR_ABORTPATH :
  673. pOut->ClearPath();
  674. case EMR_ENDPATH :
  675. bRecordPath = sal_False;
  676. break;
  677. case EMR_CLOSEFIGURE :
  678. pOut->ClosePath();
  679. break;
  680. case EMR_FILLPATH :
  681. pOut->StrokeAndFillPath( sal_False, sal_True );
  682. break;
  683. case EMR_STROKEANDFILLPATH :
  684. pOut->StrokeAndFillPath( sal_True, sal_True );
  685. break;
  686. case EMR_STROKEPATH :
  687. pOut->StrokeAndFillPath( sal_True, sal_False );
  688. break;
  689. case EMR_SELECTCLIPPATH :
  690. {
  691. sal_Int32 nClippingMode;
  692. *pWMF >> nClippingMode;
  693. pOut->SetClipPath( pOut->GetPathObj(), nClippingMode, sal_True );
  694. }
  695. break;
  696. case EMR_EXTSELECTCLIPRGN :
  697. {
  698. sal_Int32 iMode, cbRgnData;
  699. *pWMF >> cbRgnData
  700. >> iMode;
  701. PolyPolygon aPolyPoly;
  702. if ( cbRgnData )
  703. ImplReadRegion( aPolyPoly, *pWMF, nRecSize );
  704. pOut->SetClipPath( aPolyPoly, iMode, sal_False );
  705. }
  706. break;
  707. case EMR_BITBLT : // PASSTHROUGH INTENDED
  708. case EMR_STRETCHBLT :
  709. {
  710. INT32 xDest, yDest, cxDest, cyDest, xSrc, ySrc, cxSrc, cySrc;
  711. UINT32 dwRop, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc;
  712. XForm xformSrc;
  713. UINT32 nStart = pWMF->Tell() - 8;
  714. pWMF->SeekRel( 0x10 );
  715. *pWMF >> xDest >> yDest >> cxDest >> cyDest >> dwRop >> xSrc >> ySrc
  716. >> xformSrc >> nColor >> iUsageSrc >> offBmiSrc >> cbBmiSrc
  717. >> offBitsSrc >> cbBitsSrc;
  718. if ( nRecType == EMR_STRETCHBLT )
  719. *pWMF >> cxSrc >> cySrc;
  720. else
  721. cxSrc = cySrc = 0;
  722. Bitmap aBitmap;
  723. Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) );
  724. cxDest = abs( (int)cxDest ); // sj: i37894, size can be negative
  725. cyDest = abs( (int)cyDest ); // and also 122889
  726. if ( offBmiSrc )
  727. {
  728. UINT32 nSize = cbBmiSrc + cbBitsSrc + 14;
  729. char* pBuf = new char[ nSize ];
  730. SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
  731. aTmp.ObjectOwnsMemory( TRUE );
  732. aTmp << (BYTE)'B'
  733. << (BYTE)'M'
  734. << (UINT32)cbBitsSrc
  735. << (UINT16)0
  736. << (UINT16)0
  737. << (UINT32)cbBmiSrc + 14;
  738. pWMF->Seek( nStart + offBmiSrc );
  739. pWMF->Read( pBuf + 14, cbBmiSrc );
  740. pWMF->Seek( nStart + offBitsSrc );
  741. pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc );
  742. aTmp.Seek( 0 );
  743. aBitmap.Read( aTmp, TRUE );
  744. // test if it is sensible to crop
  745. if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
  746. ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
  747. ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) &&
  748. ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) )
  749. {
  750. Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
  751. aBitmap.Crop( aCropRect );
  752. }
  753. }
  754. aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
  755. }
  756. break;
  757. case EMR_STRETCHDIBITS :
  758. {
  759. INT32 xDest, yDest, xSrc, ySrc, cxSrc, cySrc, cxDest, cyDest;
  760. UINT32 offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, iUsageSrc, dwRop;
  761. UINT32 nStart = pWMF->Tell() - 8;
  762. pWMF->SeekRel( 0x10 );
  763. *pWMF >> xDest >> yDest >> xSrc >> ySrc >> cxSrc >> cySrc >> offBmiSrc >> cbBmiSrc >> offBitsSrc
  764. >> cbBitsSrc >> iUsageSrc >> dwRop >> cxDest >> cyDest;
  765. Bitmap aBitmap;
  766. Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) );
  767. cxDest = abs( (int)cxDest ); // sj: i37894, size can be negative
  768. cyDest = abs( (int)cyDest ); // and also 122889
  769. UINT32 nSize = cbBmiSrc + cbBitsSrc + 14;
  770. char* pBuf = new char[ nSize ];
  771. SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
  772. aTmp.ObjectOwnsMemory( TRUE );
  773. aTmp << (BYTE)'B'
  774. << (BYTE)'M'
  775. << (UINT32)cbBitsSrc
  776. << (UINT16)0
  777. << (UINT16)0
  778. << (UINT32)cbBmiSrc + 14;
  779. pWMF->Seek( nStart + offBmiSrc );
  780. pWMF->Read( pBuf + 14, cbBmiSrc );
  781. pWMF->Seek( nStart + offBitsSrc );
  782. pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc );
  783. aTmp.Seek( 0 );
  784. aBitmap.Read( aTmp, TRUE );
  785. // test if it is sensible to crop
  786. if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
  787. ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
  788. ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) &&
  789. ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) )
  790. {
  791. Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
  792. aBitmap.Crop( aCropRect );
  793. }
  794. aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
  795. }
  796. break;
  797. case EMR_EXTCREATEFONTINDIRECTW :
  798. {
  799. *pWMF >> nIndex;
  800. if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
  801. {
  802. LOGFONTW aLogFont;
  803. *pWMF >> aLogFont.lfHeight >> aLogFont.lfWidth >> aLogFont.lfEscapement >> aLogFont.lfOrientation >> aLogFont.lfWeight >> aLogFont.lfItalic
  804. >> aLogFont.lfUnderline >> aLogFont.lfStrikeOut >> aLogFont.lfCharSet >> aLogFont.lfOutPrecision >> aLogFont.lfClipPrecision
  805. >> aLogFont.lfQuality >> aLogFont.lfPitchAndFamily;
  806. sal_Unicode lfFaceName[ LF_FACESIZE ];
  807. for ( int i = 0; i < LF_FACESIZE; i++ )
  808. {
  809. UINT16 nChar;
  810. *pWMF >> nChar;
  811. lfFaceName[ i ] = nChar;
  812. }
  813. aLogFont.alfFaceName = UniString( lfFaceName );
  814. pOut->CreateObject( nIndex, GDI_FONT, new WinMtfFontStyle( aLogFont ) );
  815. }
  816. }
  817. break;
  818. case EMR_EXTTEXTOUTA :
  819. bFlag = sal_True;
  820. case EMR_EXTTEXTOUTW :
  821. {
  822. sal_Int32 nLeft, nTop, nRight, nBottom, ptlReferenceX, ptlReferenceY, nGfxMode, nXScale, nYScale;
  823. sal_uInt32 nCurPos, nLen, nOffString, nOptions, offDx;
  824. sal_Int32* pDX = NULL;
  825. nCurPos = pWMF->Tell() - 8;
  826. *pWMF >> nLeft >> nTop >> nRight >> nBottom >> nGfxMode >> nXScale >> nYScale
  827. >> ptlReferenceX >> ptlReferenceY >> nLen >> nOffString >> nOptions;
  828. pWMF->SeekRel( 0x10 );
  829. *pWMF >> offDx;
  830. sal_Int32 nTextLayoutMode = TEXT_LAYOUT_DEFAULT;
  831. if ( nOptions & ETO_RTLREADING )
  832. nTextLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
  833. pOut->SetTextLayoutMode( nTextLayoutMode );
  834. DBG_ASSERT( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) == 0, "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" );
  835. Point aPos( ptlReferenceX, ptlReferenceY );
  836. if ( nLen )
  837. {
  838. if ( offDx && (( nCurPos + offDx + nLen * 4 ) <= nNextPos ) )
  839. {
  840. pWMF->Seek( nCurPos + offDx );
  841. pDX = new sal_Int32[ nLen ];
  842. sal_uInt32 i;
  843. for ( i = 0; i < nLen; i++ )
  844. *pWMF >> pDX[ i ];
  845. }
  846. pWMF->Seek( nCurPos + nOffString );
  847. String aText;
  848. if ( bFlag )
  849. {
  850. sal_Char* pBuf = new sal_Char[ nLen ];
  851. pWMF->Read( pBuf, nLen );
  852. aText = String( pBuf, (sal_uInt16)nLen, pOut->GetCharSet() );
  853. delete[] pBuf;
  854. if ( aText.Len() != nLen )
  855. {
  856. sal_uInt16 i, j, k;
  857. sal_Int32* pOldDx = pDX;
  858. pDX = new sal_Int32[ aText.Len() ];
  859. for ( i = 0, j = 0; i < aText.Len(); i++ )
  860. {
  861. sal_Unicode cUniChar = aText.GetChar(i);
  862. rtl::OString aCharacter(&cUniChar, 1, pOut->GetCharSet());
  863. pDX[ i ] = 0;
  864. for ( k = 0; ( k < aCharacter.getLength() ) && ( j < nLen ) && ( i < aText.Len() ); k++ )
  865. pDX[ i ] += pOldDx[ j++ ];
  866. }
  867. delete[] pOldDx;
  868. }
  869. }
  870. else
  871. {
  872. sal_Unicode* pBuf = new sal_Unicode[ nLen ];
  873. pWMF->Read( pBuf, nLen << 1 );
  874. #ifdef OSL_BIGENDIAN
  875. sal_Char nTmp, *pTmp = (sal_Char*)( pBuf + nLen );
  876. while ( pTmp-- != (sal_Char*)pBuf )
  877. {
  878. nTmp = *pTmp--;
  879. pTmp[ 1 ] = *pTmp;
  880. *pTmp = nTmp;
  881. }
  882. #endif
  883. aText = String( pBuf, (xub_StrLen)nLen );
  884. delete[] pBuf;
  885. }
  886. pOut->DrawText( aPos, aText, pDX, bRecordPath, nGfxMode );
  887. }
  888. delete[] pDX;
  889. }
  890. break;
  891. case EMR_POLYBEZIERTO16 :
  892. bFlag = sal_True;
  893. case EMR_POLYBEZIER16 :
  894. {
  895. pWMF->SeekRel( 16 );
  896. *pWMF >> nPoints;
  897. UINT16 i = 0;
  898. if ( bFlag )
  899. {
  900. i++;
  901. nPoints++;
  902. }
  903. Polygon aPoly( (UINT16)nPoints );
  904. for( ; i < (UINT16)nPoints; i++ )
  905. {
  906. *pWMF >> nX16 >> nY16;
  907. aPoly[ i ] = Point( nX16, nY16 );
  908. }
  909. pOut->DrawPolyBezier( aPoly, bFlag, bRecordPath ); // Line( aPoly, bFlag );
  910. }
  911. break;
  912. case EMR_POLYGON16 :
  913. {
  914. pWMF->SeekRel( 16 );
  915. *pWMF >> nPoints;
  916. Polygon aPoly( (UINT16)nPoints );
  917. for( UINT16 k = 0; k < (UINT16)nPoints; k++ )
  918. {
  919. *pWMF >> nX16 >> nY16;
  920. aPoly[ k ] = Point( nX16, nY16 );
  921. }
  922. pOut->DrawPolygon( aPoly, bRecordPath );
  923. }
  924. break;
  925. case EMR_POLYLINETO16 :
  926. bFlag = sal_True;
  927. case EMR_POLYLINE16 :
  928. {
  929. pWMF->SeekRel( 16 );
  930. *pWMF >> nPoints;
  931. UINT16 i = 0;
  932. if ( bFlag )
  933. {
  934. i++;
  935. nPoints++;
  936. }
  937. Polygon aPoly( (UINT16)nPoints );
  938. for( ; i < (UINT16)nPoints; i++ )
  939. {
  940. *pWMF >> nX16 >> nY16;
  941. aPoly[ i ] = Point( nX16, nY16 );
  942. }
  943. pOut->DrawPolyLine( aPoly, bFlag, bRecordPath );
  944. }
  945. break;
  946. case EMR_POLYPOLYLINE16 :
  947. {
  948. UINT16* pnPoints;
  949. INT32 i, nPoly, nGesPoints;
  950. pWMF->SeekRel( 0x10 );
  951. // Anzahl der Polygone:
  952. *pWMF >> nPoly >> nGesPoints;
  953. // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
  954. pnPoints = new UINT16[ nPoly ];
  955. for ( i = 0; i < nPoly; i++ )
  956. {
  957. *pWMF >> nPoints;
  958. pnPoints[ i ] = (UINT16)nPoints;
  959. }
  960. // Polygonpunkte holen:
  961. for ( i = 0; i < nPoly; i++ )
  962. {
  963. Polygon aPolygon( pnPoints[ i ] );
  964. for ( UINT16 k = 0; k < pnPoints[ i ]; k++ )
  965. {
  966. *pWMF >> nX16 >> nY16;
  967. aPolygon[ k ] = Point( nX16, nY16 );
  968. }
  969. pOut->DrawPolyLine( aPolygon, sal_False, bRecordPath );
  970. }
  971. delete[] pnPoints;
  972. }
  973. break;
  974. case EMR_POLYPOLYGON16 :
  975. {
  976. UINT16* pnPoints;
  977. Point* pPtAry;
  978. UINT32 i, nPoly, nGesPoints;
  979. pWMF->SeekRel( 0x10 );
  980. // Anzahl der Polygone:
  981. *pWMF >> nPoly >> nGesPoints;
  982. if (nGesPoints < SAL_MAX_UINT32 / sizeof(Point))
  983. {
  984. // Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln:
  985. pnPoints = new UINT16[ nPoly ];
  986. for ( i = 0; i < nPoly; i++ )
  987. {
  988. *pWMF >> nPoints;
  989. pnPoints[ i ] = (UINT16)nPoints;
  990. }
  991. // Polygonpunkte holen:
  992. pPtAry = (Point*) new char[ nGesPoints * sizeof(Point) ];
  993. for ( i = 0; i < nGesPoints; i++ )
  994. {
  995. *pWMF >> nX16 >> nY16;
  996. pPtAry[ i ] = Point( nX16, nY16 );
  997. }
  998. // PolyPolygon Actions erzeugen
  999. PolyPolygon aPolyPoly( (UINT16)nPoly, pnPoints, pPtAry );
  1000. pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
  1001. delete[] (char*) pPtAry;
  1002. delete[] pnPoints;
  1003. }
  1004. }
  1005. break;
  1006. case EMR_FILLRGN :
  1007. {
  1008. sal_uInt32 nLen;
  1009. PolyPolygon aPolyPoly;
  1010. pWMF->SeekRel( 0x10 );
  1011. *pWMF >> nLen >> nIndex;
  1012. if ( ImplReadRegion( aPolyPoly, *pWMF, nRecSize ) )
  1013. {
  1014. pOut->Push();
  1015. pOut->SelectObject( nIndex );
  1016. pOut->DrawPolyPolygon( aPolyPoly, sal_False );
  1017. pOut->Pop();
  1018. }
  1019. }
  1020. break;
  1021. #ifdef WIN_MTF_ASSERT
  1022. default : WinMtfAssertHandler( "Unknown Meta Action" ); break;
  1023. case EMR_MASKBLT : WinMtfAssertHandler( "MaskBlt" ); break;
  1024. case EMR_PLGBLT : WinMtfAssertHandler( "PlgBlt" ); break;
  1025. case EMR_SETDIBITSTODEVICE : WinMtfAssertHandler( "SetDIBitsToDevice" ); break;
  1026. case EMR_FRAMERGN : WinMtfAssertHandler( "FrameRgn" ); break;
  1027. case EMR_INVERTRGN : WinMtfAssertHandler( "InvertRgn" ); break;
  1028. case EMR_PAINTRGN : WinMtfAssertHandler( "PaintRgn" ); break;
  1029. case EMR_FLATTENPATH : WinMtfAssertHandler( "FlattenPath" ); break;
  1030. case EMR_WIDENPATH : WinMtfAssertHandler( "WidenPath" ); break;
  1031. case EMR_POLYDRAW : WinMtfAssertHandler( "Polydraw" ); break;
  1032. case EMR_SETARCDIRECTION : WinMtfAssertHandler( "SetArcDirection" ); break;
  1033. case EMR_SETPALETTEENTRIES : WinMtfAssertHandler( "SetPaletteEntries" ); break;
  1034. case EMR_RESIZEPALETTE : WinMtfAssertHandler( "ResizePalette" ); break;
  1035. case EMR_EXTFLOODFILL : WinMtfAssertHandler( "ExtFloodFill" ); break;
  1036. case EMR_ANGLEARC : WinMtfAssertHandler( "AngleArc" ); break;
  1037. case EMR_SETCOLORADJUSTMENT : WinMtfAssertHandler( "SetColorAdjustment" ); break;
  1038. case EMR_POLYDRAW16 : WinMtfAssertHandler( "PolyDraw16" ); break;
  1039. case EMR_CREATEDIBPATTERNBRUSHPT : WinMtfAssertHandler( "CreateDibPatternBrushPt" ); break;
  1040. case EMR_POLYTEXTOUTA : WinMtfAssertHandler( "PolyTextOutA" ); break;
  1041. case EMR_POLYTEXTOUTW : WinMtfAssertHandler( "PolyTextOutW" ); break;
  1042. case EMR_CREATECOLORSPACE : WinMtfAssertHandler( "CreateColorSpace" ); break;
  1043. case EMR_SETCOLORSPACE : WinMtfAssertHandler( "SetColorSpace" ); break;
  1044. case EMR_DELETECOLORSPACE : WinMtfAssertHandler( "DeleteColorSpace" ); break;
  1045. case EMR_GLSRECORD : WinMtfAssertHandler( "GlsRecord" ); break;
  1046. case EMR_GLSBOUNDEDRECORD : WinMtfAssertHandler( "GlsBoundRecord" ); break;
  1047. case EMR_PIXELFORMAT : WinMtfAssertHandler( "PixelFormat" ); break;
  1048. case EMR_DRAWESCAPE : WinMtfAssertHandler( "DrawEscape" ); break;
  1049. case EMR_EXTESCAPE : WinMtfAssertHandler( "ExtEscape" ); break;
  1050. case EMR_STARTDOC : WinMtfAssertHandler( "StartDoc" ); break;
  1051. case EMR_SMALLTEXTOUT : WinMtfAssertHandler( "SmallTextOut" ); break;
  1052. case EMR_FORCEUFIMAPPING : WinMtfAssertHandler( "ForceUFIMapping" ); break;
  1053. case EMR_NAMEDESCAPE : WinMtfAssertHandler( "NamedEscape" ); break;
  1054. case EMR_COLORCORRECTPALETTE : WinMtfAssertHandler( "ColorCorrectPalette" ); break;
  1055. case EMR_SETICMPROFILEA : WinMtfAssertHandler( "SetICMProfileA" ); break;
  1056. case EMR_SETICMPROFILEW : WinMtfAssertHandler( "SetICMProfileW" ); break;
  1057. case EMR_ALPHABLEND : WinMtfAssertHandler( "Alphablend" ); break;
  1058. case EMR_TRANSPARENTBLT : WinMtfAssertHandler( "TransparenBlt" ); break;
  1059. case EMR_TRANSPARENTDIB : WinMtfAssertHandler( "TransparenDib" ); break;
  1060. case EMR_GRADIENTFILL : WinMtfAssertHandler( "GradientFill" ); break;
  1061. case EMR_SETLINKEDUFIS : WinMtfAssertHandler( "SetLinkedUFIS" ); break;
  1062. case EMR_SETMAPPERFLAGS : WinMtfAssertHandler( "SetMapperFlags", 0 ); break;
  1063. case EMR_SETICMMODE : WinMtfAssertHandler( "SetICMMode", 0 ); break;
  1064. case EMR_CREATEMONOBRUSH : WinMtfAssertHandler( "CreateMonoBrush", 0 ); break;
  1065. case EMR_SETBRUSHORGEX : WinMtfAssertHandler( "SetBrushOrgEx", 0 ); break;
  1066. case EMR_SETMETARGN : WinMtfAssertHandler( "SetMetArgn", 0 ); break;
  1067. case EMR_SETMITERLIMIT : WinMtfAssertHandler( "SetMiterLimit", 0 ); break;
  1068. case EMR_EXCLUDECLIPRECT : WinMtfAssertHandler( "ExcludeClipRect", 0 ); break;
  1069. case EMR_REALIZEPALETTE : WinMtfAssertHandler( "RealizePalette", 0 ); break;
  1070. case EMR_SELECTPALETTE : WinMtfAssertHandler( "SelectPalette", 0 ); break;
  1071. case EMR_CREATEPALETTE : WinMtfAssertHandler( "CreatePalette", 0 ); break;
  1072. case EMR_ALPHADIBBLEND : WinMtfAssertHandler( "AlphaDibBlend", 0 ); break;
  1073. case EMR_SETTEXTJUSTIFICATION : WinMtfAssertHandler( "SetTextJustification", 0 ); break;
  1074. case EMR_GDICOMMENT :
  1075. case EMR_HEADER : // has already been read at ReadHeader()
  1076. break;
  1077. #endif
  1078. }
  1079. pWMF->Seek( nNextPos );
  1080. }
  1081. if( aBmpSaveList.Count() )
  1082. pOut->ResolveBitmapActions( aBmpSaveList );
  1083. if ( bStatus )
  1084. pWMF->Seek(nEndPos);
  1085. return bStatus;
  1086. };
  1087. //-----------------------------------------------------------------------------------
  1088. BOOL EnhWMFReader::ReadHeader()
  1089. {
  1090. UINT32 nUINT32, nHeaderSize, nPalEntries;
  1091. INT32 nLeft, nTop, nRight, nBottom;
  1092. // METAFILEHEADER SPARE ICH MIR HIER
  1093. // Einlesen des METAHEADER
  1094. *pWMF >> nUINT32 >> nHeaderSize;
  1095. if ( nUINT32 != 1 ) // Typ
  1096. return FALSE;
  1097. // bound size
  1098. Rectangle rclBounds; // rectangle in logical units 1/100th mm
  1099. *pWMF >> nLeft >> nTop >> nRight >> nBottom;
  1100. rclBounds.Left() = nLeft;
  1101. rclBounds.Top() = nTop;
  1102. rclBounds.Right() = nRight;
  1103. rclBounds.Bottom() = nBottom;
  1104. // picture frame size
  1105. Rectangle rclFrame; // rectangle in device units
  1106. *pWMF >> nLeft >> nTop >> nRight >> nBottom;
  1107. rclFrame.Left() = nLeft;
  1108. rclFrame.Top() = nTop;
  1109. rclFrame.Right() = nRight;
  1110. rclFrame.Bottom() = nBottom;
  1111. *pWMF >> nUINT32; // signature
  1112. if ( nUINT32 != 0x464d4520 )
  1113. return FALSE;
  1114. *pWMF >> nUINT32; // nVersion
  1115. *pWMF >> nEndPos; // size of metafile
  1116. nEndPos += nStartPos;
  1117. *pWMF >> nRecordCount;
  1118. if ( !nRecordCount )
  1119. return FALSE;
  1120. pWMF->SeekRel( 0xc );
  1121. sal_Int32 nPixX, nPixY, nMillX, nMillY;
  1122. *pWMF >> nPalEntries >> nPixX >> nPixY >> nMillX >> nMillY;
  1123. pOut->SetrclFrame( rclFrame );
  1124. pOut->SetrclBounds( rclBounds );
  1125. pOut->SetRefPix( Size( nPixX, nPixY ) );
  1126. pOut->SetRefMill( Size( nMillX, nMillY ) );
  1127. pWMF->Seek( nStartPos + nHeaderSize );
  1128. return TRUE;
  1129. }
  1130. //-----------------------------------------------------------------------------------
  1131. Rectangle EnhWMFReader::ReadRectangle( INT32 x1, INT32 y1, INT32 x2, INT32 y2 )
  1132. {
  1133. Point aTL ( Point( x1, y1 ) );
  1134. Point aBR( Point( --x2, --y2 ) );
  1135. return Rectangle( aTL, aBR );
  1136. }
  1137. EnhWMFReader::~EnhWMFReader()
  1138. {
  1139. };
  1140. }
  1141. /* vim:set shiftwidth=4 softtabstop=4 expandtab: */