LibreOffice Module vcl (master) 1
wmfwr.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21#include <osl/diagnose.h>
22
23#include <algorithm>
24
25#include "wmfwr.hxx"
26#include "emfwr.hxx"
27#include <rtl/crc.h>
28#include <rtl/tencinfo.h>
29#include <tools/bigint.hxx>
30#include <tools/helpers.hxx>
31#include <tools/tenccvt.hxx>
32#include <tools/fract.hxx>
33#include <tools/stream.hxx>
34#include <vcl/dibtools.hxx>
35#include <vcl/metaact.hxx>
39#include <memory>
40#include <vcl/fontcharmap.hxx>
42
43// MS Windows defines
44
45#define W_META_SETBKMODE 0x0102
46#define W_META_SETROP2 0x0104
47#define W_META_SETSTRETCHBLTMODE 0x0107
48#define W_META_SETTEXTCOLOR 0x0209
49#define W_META_SETWINDOWORG 0x020B
50#define W_META_SETWINDOWEXT 0x020C
51#define W_META_LINETO 0x0213
52#define W_META_MOVETO 0x0214
53#define W_META_INTERSECTCLIPRECT 0x0416
54#define W_META_ARC 0x0817
55#define W_META_ELLIPSE 0x0418
56#define W_META_PIE 0x081A
57#define W_META_RECTANGLE 0x041B
58#define W_META_ROUNDRECT 0x061C
59#define W_META_SAVEDC 0x001E
60#define W_META_SETPIXEL 0x041F
61#define W_META_TEXTOUT 0x0521
62#define W_META_POLYGON 0x0324
63#define W_META_POLYLINE 0x0325
64#define W_META_ESCAPE 0x0626
65#define W_META_RESTOREDC 0x0127
66#define W_META_SELECTOBJECT 0x012D
67#define W_META_SETTEXTALIGN 0x012E
68#define W_META_CHORD 0x0830
69#define W_META_EXTTEXTOUT 0x0a32
70#define W_META_POLYPOLYGON 0x0538
71#define W_META_STRETCHDIB 0x0f43
72#define W_META_DELETEOBJECT 0x01f0
73#define W_META_CREATEPENINDIRECT 0x02FA
74#define W_META_CREATEFONTINDIRECT 0x02FB
75#define W_META_CREATEBRUSHINDIRECT 0x02FC
76
77#define W_TRANSPARENT 1
78#define W_OPAQUE 2
79
80#define W_R2_NOT 6
81#define W_R2_XORPEN 7
82#define W_R2_COPYPEN 13
83
84#define W_TA_NOUPDATECP 0x0000
85#define W_TA_LEFT 0x0000
86#define W_TA_RIGHT 0x0002
87#define W_TA_TOP 0x0000
88#define W_TA_BOTTOM 0x0008
89#define W_TA_BASELINE 0x0018
90#define W_TA_RTLREADING 0x0100
91
92#define W_SRCCOPY 0x00CC0020L
93#define W_SRCPAINT 0x00EE0086L
94#define W_SRCAND 0x008800C6L
95#define W_SRCINVERT 0x00660046L
96#define W_DSTINVERT 0x00550009L
97
98#define W_PS_SOLID 0
99#define W_PS_DASH 1
100#define W_PS_DOT 2
101#define W_PS_DASHDOT 3
102#define W_PS_DASHDOTDOT 4
103#define W_PS_NULL 5
104
105#define W_LF_FACESIZE 32
106
107#define W_ANSI_CHARSET 0
108
109#define W_DEFAULT_PITCH 0x00
110#define W_FIXED_PITCH 0x01
111#define W_VARIABLE_PITCH 0x02
112
113#define W_FF_DONTCARE 0x00
114#define W_FF_ROMAN 0x10
115#define W_FF_SWISS 0x20
116#define W_FF_MODERN 0x30
117#define W_FF_SCRIPT 0x40
118#define W_FF_DECORATIVE 0x50
119
120#define W_FW_DONTCARE 0
121#define W_FW_THIN 100
122#define W_FW_LIGHT 300
123#define W_FW_NORMAL 400
124#define W_FW_MEDIUM 500
125#define W_FW_SEMIBOLD 600
126#define W_FW_BOLD 700
127#define W_FW_ULTRALIGHT 200
128#define W_FW_ULTRABOLD 800
129#define W_FW_BLACK 900
130
131#define W_BS_SOLID 0
132#define W_BS_HOLLOW 1
133
134#define W_MFCOMMENT 15
135
136#define PRIVATE_ESCAPE_UNICODE 2
137
139 : bStatus(false)
140 , nLastPercent(0)
141 , pWMF(nullptr)
142 , pVirDev(nullptr)
143 , nMetafileHeaderPos(0)
144 , nMaxRecordSize(0)
145 , nActRecordPos(0)
146 , eSrcRasterOp(RasterOp::OverPaint)
147 , eSrcTextAlign(ALIGN_BASELINE)
148 , pAttrStack(nullptr)
149 , eSrcHorTextAlign(W_TA_LEFT)
150 , eDstROP2(RasterOp::OverPaint)
151 , eDstTextAlign(ALIGN_BASELINE)
152 , eDstHorTextAlign(W_TA_LEFT)
153 , bHandleAllocated{}
154 , nDstPenHandle(0)
155 , nDstFontHandle(0)
156 , nDstBrushHandle(0)
157 , nNumberOfActions(0)
158 , nNumberOfBitmaps(0)
159 , nWrittenActions(0)
160 , nWrittenBitmaps(0)
161 , nActBitmapPercent(0)
162 , bEmbedEMF(false)
163{
164}
165
167{
168 if ( !xStatusIndicator.is() )
169 return;
170
171 sal_uLong nPercent;
172
173 // we simply assume that 16386 actions match to a bitmap
174 // (normally a metafile either contains only actions or some bitmaps and
175 // almost no actions. In which case the ratio is less important)
176
177 nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions)
178 *100
180
181 if ( nPercent >= nLastPercent + 3 )
182 {
183 nLastPercent = nPercent;
184 if( nPercent <= 100 )
185 xStatusIndicator->setValue( nPercent );
186 }
187}
188
190{
191 size_t nAction, nActionCount;
192
193 nActionCount = rMTF.GetActionSize();
194
195 for ( nAction=0; nAction < nActionCount; nAction++ )
196 {
197 MetaAction* pMA = rMTF.GetAction( nAction );
198
199 switch( pMA->GetType() )
200 {
208 break;
209 default: break;
210 }
212 }
213}
214
215void WMFWriter::WritePointXY(const Point & rPoint)
216{
218 pWMF->WriteInt16( aPt.X() ).WriteInt16( aPt.Y() );
219}
220
221void WMFWriter::WritePointYX(const Point & rPoint)
222{
224 pWMF->WriteInt16( aPt.Y() ).WriteInt16( aPt.X() );
225}
226
227sal_Int32 WMFWriter::ScaleWidth( sal_Int32 nDX )
228{
230 return aSz.Width();
231}
232
233void WMFWriter::WriteSize(const Size & rSize)
234{
236 pWMF->WriteInt16( aSz.Width() ).WriteInt16( aSz.Height() );
237}
238
240{
242 pWMF->WriteInt16( aSz.Height() ).WriteInt16( aSz.Width() );
243}
244
246{
247 WritePointYX(Point(rRect.Right()+1,rRect.Bottom()+1));
248 WritePointYX(rRect.TopLeft());
249}
250
251void WMFWriter::WriteColor(const Color & rColor)
252{
253 pWMF->WriteUChar( rColor.GetRed() ).WriteUChar( rColor.GetGreen() ).WriteUChar( rColor.GetBlue() ).WriteUChar( 0 );
254}
255
256void WMFWriter::WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
257{
259 if (nSizeWords>nMaxRecordSize) nMaxRecordSize=nSizeWords;
260 pWMF->WriteUInt32( nSizeWords ).WriteUInt16( nType );
261}
262
264{
266 sal_uInt32 nSize;
267
268 nPos=pWMF->Tell(); nSize=nPos-nActRecordPos;
269 if ((nSize & 1)!=0) {
270 pWMF->WriteUChar( 0 );
271 nPos++; nSize++;
272 }
273 nSize/=2;
274 if (nSize>nMaxRecordSize) nMaxRecordSize=nSize;
276 pWMF->WriteUInt32( nSize );
277 pWMF->Seek(nPos);
278}
279
280void WMFWriter::WMFRecord_Arc(const tools::Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
281{
282 WriteRecordHeader(0x0000000b,W_META_ARC);
283 WritePointYX(rEndPt);
284 WritePointYX(rStartPt);
285 WriteRectangle(rRect);
286}
287
288void WMFWriter::WMFRecord_Chord(const tools::Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
289{
291 WritePointYX(rEndPt);
292 WritePointYX(rStartPt);
293 WriteRectangle(rRect);
294}
295
297{
299
300 if( rColor==COL_TRANSPARENT )
302 else
304
305 WriteColor( rColor );
306 pWMF->WriteUInt16( 0 );
307}
308
310{
311 sal_uInt16 nWeight,i;
312 sal_uInt8 nPitchFamily;
313
316 pWMF->WriteInt16( rFont.GetOrientation().get() ).WriteInt16( rFont.GetOrientation().get() );
317
318 switch (rFont.GetWeight()) {
319 case WEIGHT_THIN: nWeight=W_FW_THIN; break;
320 case WEIGHT_ULTRALIGHT: nWeight=W_FW_ULTRALIGHT; break;
321 case WEIGHT_LIGHT: nWeight=W_FW_LIGHT; break;
322 case WEIGHT_SEMILIGHT: nWeight=W_FW_LIGHT; break;
323 case WEIGHT_NORMAL: nWeight=W_FW_NORMAL; break;
324 case WEIGHT_MEDIUM: nWeight=W_FW_MEDIUM; break;
325 case WEIGHT_SEMIBOLD: nWeight=W_FW_SEMIBOLD; break;
326 case WEIGHT_BOLD: nWeight=W_FW_BOLD; break;
327 case WEIGHT_ULTRABOLD: nWeight=W_FW_ULTRABOLD; break;
328 case WEIGHT_BLACK: nWeight=W_FW_BLACK; break;
329 default: nWeight=W_FW_DONTCARE;
330 }
331 pWMF->WriteUInt16( nWeight );
332
333 if (rFont.GetItalic()==ITALIC_NONE) pWMF->WriteUChar( 0 ); else pWMF->WriteUChar( 1 );
334 if (rFont.GetUnderline()==LINESTYLE_NONE) pWMF->WriteUChar( 0 ); else pWMF->WriteUChar( 1 );
335 if (rFont.GetStrikeout()==STRIKEOUT_NONE) pWMF->WriteUChar( 0 ); else pWMF->WriteUChar( 1 );
336
337 rtl_TextEncoding eFontNameEncoding = rFont.GetCharSet();
338 sal_uInt8 nCharSet = rtl_getBestWindowsCharsetFromTextEncoding( eFontNameEncoding );
339 if ( eFontNameEncoding == RTL_TEXTENCODING_SYMBOL )
340 eFontNameEncoding = RTL_TEXTENCODING_MS_1252;
341 if ( nCharSet == 1 )
342 nCharSet = W_ANSI_CHARSET;
343 pWMF->WriteUChar( nCharSet );
344
345 pWMF->WriteUChar( 0 ).WriteUChar( 0 ).WriteUChar( 0 );
346
347 switch (rFont.GetPitch()) {
348 case PITCH_FIXED: nPitchFamily=W_FIXED_PITCH; break;
349 case PITCH_VARIABLE: nPitchFamily=W_VARIABLE_PITCH; break;
350 default: nPitchFamily=W_DEFAULT_PITCH;
351 }
352 switch (rFont.GetFamilyType()) {
353 case FAMILY_DECORATIVE: nPitchFamily|=W_FF_DECORATIVE; break;
354 case FAMILY_MODERN: nPitchFamily|=W_FF_MODERN; break;
355 case FAMILY_ROMAN: nPitchFamily|=W_FF_ROMAN; break;
356 case FAMILY_SCRIPT: nPitchFamily|=W_FF_SCRIPT; break;
357 case FAMILY_SWISS: nPitchFamily|=W_FF_SWISS; break;
358 default: nPitchFamily|=W_FF_DONTCARE;
359 }
360 pWMF->WriteUChar( nPitchFamily );
361
362 OString aFontName(OUStringToOString(rFont.GetFamilyName(), eFontNameEncoding));
363 for ( i = 0; i < W_LF_FACESIZE; i++ )
364 {
365 char nChar = ( i < aFontName.getLength() ) ? aFontName[i] : 0;
366 pWMF->WriteChar( nChar );
367 }
369}
370
371void WMFWriter::WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo )
372{
374 sal_uInt16 nStyle = rColor == COL_TRANSPARENT ? W_PS_NULL : W_PS_SOLID;
375 switch( rLineInfo.GetStyle() )
376 {
377 case LineStyle::Dash :
378 {
379 if ( rLineInfo.GetDotCount() )
380 {
381 if ( !rLineInfo.GetDashCount() )
382 nStyle = W_PS_DOT;
383 else
384 {
385 if ( rLineInfo.GetDotCount() == 1 )
386 nStyle = W_PS_DASHDOT;
387 else
388 nStyle = W_PS_DASHDOTDOT;
389 }
390 }
391 else
392 nStyle = W_PS_DASH;
393 }
394 break;
395 case LineStyle::NONE :
396 nStyle = W_PS_NULL;
397 break;
398 default:
399 break;
400 }
401 pWMF->WriteUInt16( nStyle );
402
403 WriteSize( Size( rLineInfo.GetWidth(), 0 ) );
404 WriteColor( rColor );
405}
406
407void WMFWriter::WMFRecord_DeleteObject(sal_uInt16 nObjectHandle)
408{
410 pWMF->WriteUInt16( nObjectHandle );
411}
412
414{
416 WriteRectangle(rRect);
417}
418
419void WMFWriter::WMFRecord_Escape( sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8* pData )
420{
421#ifdef OSL_BIGENDIAN
422 sal_uInt32 nTmp = OSL_SWAPDWORD( nEsc );
423 sal_uInt32 nCheckSum = rtl_crc32( 0, &nTmp, 4 );
424#else
425 sal_uInt32 nCheckSum = rtl_crc32( 0, &nEsc, 4 );
426#endif
427 if ( nLen )
428 nCheckSum = rtl_crc32( nCheckSum, pData, nLen );
429
430 WriteRecordHeader( 3 + 9 + ( ( nLen + 1 ) >> 1 ), W_META_ESCAPE );
432 .WriteUInt16( nLen + 14 ) // we will always have a fourteen byte escape header:
433 .WriteUInt16( 0x4f4f ) // OO
434 .WriteUInt32( 0xa2c2a ) // evil magic number
435 .WriteUInt32( nCheckSum ) // crc32 checksum about nEsc & pData
436 .WriteUInt32( nEsc ); // escape number
437 pWMF->WriteBytes( pData, nLen );
438 if ( nLen & 1 )
439 pWMF->WriteUChar( 0 ); // pad byte
440}
441
442/* if return value is true, then a complete unicode string and also a polygon replacement has been written,
443 so there is no more action necessary
444*/
445bool WMFWriter::WMFRecord_Escape_Unicode( const Point& rPoint, const OUString& rUniStr, o3tl::span<const sal_Int32> pDXAry )
446{
447 bool bEscapeUsed = false;
448
449 sal_uInt32 i, nStringLen = rUniStr.getLength();
450 if ( nStringLen )
451 {
452 // first we will check if a comment is necessary
453 if ( aSrcFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) // symbol is always byte character, so there is no unicode loss
454 {
455 const sal_Unicode* pBuf = rUniStr.getStr();
456 const rtl_TextEncoding aTextEncodingOrg = aSrcFont.GetCharSet();
457 OString aByteStr(OUStringToOString(rUniStr, aTextEncodingOrg));
458 OUString aUniStr2(OStringToOUString(aByteStr, aTextEncodingOrg));
459 const sal_Unicode* pConversion = aUniStr2.getStr(); // this is the unicode array after bytestring <-> unistring conversion
460 for ( i = 0; i < nStringLen; i++ )
461 {
462 if ( *pBuf++ != *pConversion++ )
463 break;
464 }
465
466 if ( i != nStringLen ) // after conversion the characters are not original,
467 { // try again, with determining a better charset from unicode char
468 pBuf = rUniStr.getStr();
469 const sal_Unicode* pCheckChar = pBuf;
470 rtl_TextEncoding aTextEncoding = getBestMSEncodingByChar(*pCheckChar); // try the first character
471 if (aTextEncoding == RTL_TEXTENCODING_DONTKNOW) {
472 aTextEncoding = aTextEncodingOrg;
473 }
474 for ( i = 1; i < nStringLen; i++)
475 {
476 if (aTextEncoding != aTextEncodingOrg) // found something
477 break;
478 pCheckChar++;
479 aTextEncoding = getBestMSEncodingByChar(*pCheckChar); // try the next character
480 if (aTextEncoding == RTL_TEXTENCODING_DONTKNOW) {
481 aTextEncoding = aTextEncodingOrg;
482 }
483 }
484
485 aByteStr = OUStringToOString(rUniStr, aTextEncoding);
486 aUniStr2 = OStringToOUString(aByteStr, aTextEncoding);
487 pConversion = aUniStr2.getStr(); // this is the unicode array after bytestring <-> unistring conversion
488 for ( i = 0; i < nStringLen; i++ )
489 {
490 if ( *pBuf++ != *pConversion++ )
491 break;
492 }
493 if (i == nStringLen)
494 {
495 aSrcFont.SetCharSet (aTextEncoding);
496 SetAllAttr();
497 }
498 }
499
500 if ( ( i != nStringLen ) || IsStarSymbol( aSrcFont.GetFamilyName() ) ) // after conversion the characters are not original, so we
501 { // will store the unicode string and a polypoly replacement
502 Color aOldFillColor( aSrcFillColor );
503 Color aOldLineColor( aSrcLineColor );
509 std::vector<tools::PolyPolygon> aPolyPolyVec;
510 if ( pVirDev->GetTextOutlines( aPolyPolyVec, rUniStr ) )
511 {
512 sal_uInt32 nDXCount = !pDXAry.empty() ? nStringLen : 0;
513 sal_uInt32 nSkipActions = aPolyPolyVec.size();
514 sal_Int32 nStrmLen = 8 +
515 + sizeof( nStringLen ) + ( nStringLen * 2 )
516 + sizeof( nDXCount ) + ( nDXCount * 4 )
517 + sizeof( nSkipActions );
518
519 SvMemoryStream aMemoryStream( nStrmLen );
521 aMemoryStream.WriteInt32( aPt.X() )
522 .WriteInt32( aPt.Y() )
523 .WriteUInt32( nStringLen );
524 for ( i = 0; i < nStringLen; i++ )
525 aMemoryStream.WriteUInt16( rUniStr[ i ] );
526 aMemoryStream.WriteUInt32( nDXCount );
527 for ( i = 0; i < nDXCount; i++ )
528 aMemoryStream.WriteInt32( pDXAry[ i ] );
529 aMemoryStream.WriteUInt32( nSkipActions );
530 WMFRecord_Escape( PRIVATE_ESCAPE_UNICODE, nStrmLen, static_cast<const sal_Int8*>(aMemoryStream.GetData()) );
531
532 for ( const auto& rPolyPoly : aPolyPolyVec )
533 {
534 tools::PolyPolygon aPolyPoly( rPolyPoly );
535 aPolyPoly.Move( rPoint.X(), rPoint.Y() );
536 WMFRecord_PolyPolygon( aPolyPoly );
537 }
538 aSrcFillColor = aOldFillColor;
539 aSrcLineColor = aOldLineColor;
540 bEscapeUsed = true;
541 }
542 }
543 }
544 }
545 return bEscapeUsed;
546}
547
548void WMFWriter::WMFRecord_ExtTextOut( const Point& rPoint,
549 const OUString& rString,
551{
552 sal_Int32 nOriginalTextLen = rString.getLength();
553
554 if ( (nOriginalTextLen <= 1) || pDXAry.empty() )
555 {
556 WMFRecord_TextOut(rPoint, rString);
557 return;
558 }
559 rtl_TextEncoding eChrSet = aSrcFont.GetCharSet();
560 OString aByteString(OUStringToOString(rString, eChrSet));
561 TrueExtTextOut(rPoint, rString, aByteString, pDXAry);
562}
563
564void WMFWriter::TrueExtTextOut( const Point& rPoint, const OUString& rString,
565 const OString& rByteString, o3tl::span<const sal_Int32> pDXAry )
566{
568 WritePointYX( rPoint );
569 sal_uInt16 nNewTextLen = static_cast<sal_uInt16>(rByteString.getLength());
570 pWMF->WriteUInt16( nNewTextLen ).WriteUInt16( 0 );
571 write_uInt8s_FromOString(*pWMF, rByteString, nNewTextLen);
572 if ( nNewTextLen & 1 )
573 pWMF->WriteUChar( 0 );
574
575 sal_Int32 nOriginalTextLen = rString.getLength();
576 std::unique_ptr<sal_Int16[]> pConvertedDXAry(new sal_Int16[ nOriginalTextLen ]);
577 sal_Int32 j = 0;
578 pConvertedDXAry[ j++ ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ 0 ] ));
579 for (sal_Int32 i = 1; i < ( nOriginalTextLen - 1 ); ++i)
580 pConvertedDXAry[ j++ ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ i ] - pDXAry[ i - 1 ] ));
581 pConvertedDXAry[ j ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) ));
582
583 for (sal_Int32 i = 0; i < nOriginalTextLen; ++i)
584 {
585 sal_Int16 nDx = pConvertedDXAry[ i ];
586 pWMF->WriteInt16( nDx );
587 if ( nOriginalTextLen < nNewTextLen )
588 {
589 sal_Unicode nUniChar = rString[i];
590 OString aTemp(&nUniChar, 1, aSrcFont.GetCharSet());
591 j = aTemp.getLength();
592 while ( --j > 0 )
593 pWMF->WriteUInt16( 0 );
594 }
595 }
596 pConvertedDXAry.reset();
598}
599
600void WMFWriter::WMFRecord_LineTo(const Point & rPoint)
601{
603 WritePointYX(rPoint);
604}
605
606void WMFWriter::WMFRecord_MoveTo(const Point & rPoint)
607{
609 WritePointYX(rPoint);
610}
611
612void WMFWriter::WMFRecord_Pie(const tools::Rectangle & rRect, const Point & rStartPt, const Point & rEndPt)
613{
614 WriteRecordHeader(0x0000000b,W_META_PIE);
615 WritePointYX(rEndPt);
616 WritePointYX(rStartPt);
617 WriteRectangle(rRect);
618}
619
621{
622 tools::Polygon aSimplePoly;
623 if ( rPoly.HasFlags() )
624 rPoly.AdaptiveSubdivide( aSimplePoly );
625 else
626 aSimplePoly = rPoly;
627 const sal_uInt16 nSize = aSimplePoly.GetSize();
628 WriteRecordHeader(static_cast<sal_uInt32>(nSize)*2+4,W_META_POLYGON);
629 pWMF->WriteUInt16( nSize );
630 for (sal_uInt16 i=0; i<nSize; ++i)
631 WritePointXY(aSimplePoly.GetPoint(i));
632}
633
635{
636 tools::Polygon aSimplePoly;
637 if ( rPoly.HasFlags() )
638 rPoly.AdaptiveSubdivide( aSimplePoly );
639 else
640 aSimplePoly = rPoly;
641 const sal_uInt16 nSize = aSimplePoly.GetSize();
642 WriteRecordHeader(static_cast<sal_uInt32>(nSize)*2+4,W_META_POLYLINE);
643 pWMF->WriteUInt16( nSize );
644 for (sal_uInt16 i=0; i<nSize; ++i)
645 WritePointXY(aSimplePoly.GetPoint(i));
646}
647
649{
650 const tools::Polygon * pPoly;
651 sal_uInt16 nCount,nSize,i,j;
652
653 nCount=rPolyPoly.Count();
654 tools::PolyPolygon aSimplePolyPoly( rPolyPoly );
655 for ( i = 0; i < nCount; i++ )
656 {
657 if ( aSimplePolyPoly[ i ].HasFlags() )
658 {
659 tools::Polygon aSimplePoly;
660 aSimplePolyPoly[ i ].AdaptiveSubdivide( aSimplePoly );
661 aSimplePolyPoly[ i ] = aSimplePoly;
662 }
663 }
666 for (i=0; i<nCount; i++) pWMF->WriteUInt16( aSimplePolyPoly.GetObject(i).GetSize() );
667 for (i=0; i<nCount; i++) {
668 pPoly=&(aSimplePolyPoly.GetObject(i));
669 nSize=pPoly->GetSize();
670 for (j=0; j<nSize; j++) WritePointXY(pPoly->GetPoint(j));
671 }
673}
674
676{
678 WriteRectangle( rRect );
679}
680
682{
684 pWMF->WriteInt16( -1 );
685}
686
688{
690 WriteHeightWidth(Size(nHorzRound,nVertRound));
691 WriteRectangle(rRect);
692}
693
695{
697}
698
699void WMFWriter::WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
700{
702 pWMF->WriteUInt16( nObjectHandle );
703}
704
705void WMFWriter::WMFRecord_SetBkMode(bool bTransparent)
706{
708 if (bTransparent) pWMF->WriteUInt16( W_TRANSPARENT );
709 else pWMF->WriteUInt16( W_OPAQUE );
710}
711
713{
715 pWMF->WriteUInt16( 3 ); // STRETCH_DELETESCANS
716}
717
718void WMFWriter::WMFRecord_SetPixel(const Point & rPoint, const Color & rColor)
719{
721 WriteColor(rColor);
722 WritePointYX(rPoint);
723}
724
726{
727 sal_uInt16 nROP2;
728
729 switch (eROP) {
730 case RasterOp::Invert: nROP2=W_R2_NOT; break;
731 case RasterOp::Xor: nROP2=W_R2_XORPEN; break;
732 default: nROP2=W_R2_COPYPEN;
733 }
735 pWMF->WriteUInt16( nROP2 );
736}
737
738void WMFWriter::WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorTextAlign)
739{
740 sal_uInt16 nAlign;
741
742 switch (eFontAlign) {
743 case ALIGN_TOP: nAlign=W_TA_TOP; break;
744 case ALIGN_BOTTOM: nAlign=W_TA_BOTTOM; break;
745 default: nAlign=W_TA_BASELINE;
746 }
747 nAlign|=eHorTextAlign;
748 nAlign|=W_TA_NOUPDATECP;
749
751 pWMF->WriteUInt16( nAlign );
752}
753
755{
757 WriteColor(rColor);
758}
759
761{
763 WriteHeightWidth(rSize);
764}
765
766void WMFWriter::WMFRecord_SetWindowOrg(const Point & rPoint)
767{
769 WritePointYX(rPoint);
770}
771
772void WMFWriter::WMFRecord_StretchDIB( const Point & rPoint, const Size & rSize,
773 const Bitmap & rBitmap, sal_uInt32 nROP )
774{
775 sal_uLong nPosAnf,nPosEnd;
776
778 MayCallback();
779
781
782 // The sequence in the metafile should be:
783 // some parameters (length 22), then the bitmap without FILEHEADER.
784 // As *pWMF << rBitmap generates a FILEHEADER of size 14,
785 // we first write the bitmap at the right position
786 // and overwrite later the FILEHEADER with the parameters.
787 nPosAnf=pWMF->Tell(); // remember position, where parameters should be stored
788 pWMF->WriteInt32( 0 ).WriteInt32( 0 ); // replenish 8 bytes (these 8 bytes +
789 // 14 bytes superfluous FILEHEADER
790 // = 22 bytes parameter)
791
792 // write bitmap
793 WriteDIB(rBitmap, *pWMF, false, true);
794
795 // write the parameters:
796 nPosEnd=pWMF->Tell();
797 pWMF->Seek(nPosAnf);
798
799 // determine raster-op, if nothing was passed
800 if( !nROP )
801 {
802 switch( eSrcRasterOp )
803 {
804 case RasterOp::Invert: nROP = W_DSTINVERT; break;
805 case RasterOp::Xor: nROP = W_SRCINVERT; break;
806 default: nROP = W_SRCCOPY;
807 }
808 }
809
810 pWMF->WriteUInt32( nROP ).
811 WriteInt16( 0 ).
812 WriteInt16( rBitmap.GetSizePixel().Height() ).
813 WriteInt16( rBitmap.GetSizePixel().Width() ).
814 WriteInt16( 0 ).
815 WriteInt16( 0 );
816
817 WriteHeightWidth(rSize);
818 WritePointYX(rPoint);
819 pWMF->Seek(nPosEnd);
820
822
825}
826
827void WMFWriter::WMFRecord_TextOut(const Point & rPoint, std::u16string_view rStr)
828{
829 rtl_TextEncoding eChrSet = aSrcFont.GetCharSet();
830 OString aString(OUStringToOString(rStr, eChrSet));
831 TrueTextOut(rPoint, aString);
832}
833
834void WMFWriter::TrueTextOut(const Point & rPoint, const OString& rString)
835{
837
839 sal_Int32 nLen = rString.getLength();
840 if ((nLen&1)!=0) pWMF->WriteUChar( 0 );
841 WritePointYX(rPoint);
843}
844
846{
848 WriteRectangle(rRect);
849}
850
852{
853 sal_uInt16 i;
854
855 for (i=0; i<MAXOBJECTHANDLES; i++) {
856 if (!bHandleAllocated[i]) {
857 bHandleAllocated[i]=true;
858 return i;
859 }
860 }
861 bStatus=false;
862 return 0xffff;
863}
864
865void WMFWriter::FreeHandle(sal_uInt16 nObjectHandle)
866{
867 if (nObjectHandle<MAXOBJECTHANDLES) bHandleAllocated[nObjectHandle]=false;
868}
869
870void WMFWriter::CreateSelectDeletePen( const Color& rColor, const LineInfo& rLineInfo )
871{
872 sal_uInt16 nOldHandle;
873
874 nOldHandle=nDstPenHandle;
876 WMFRecord_CreatePenIndirect( rColor, rLineInfo );
878 if (nOldHandle<MAXOBJECTHANDLES) {
879 WMFRecord_DeleteObject(nOldHandle);
880 FreeHandle(nOldHandle);
881 }
882}
883
885{
886 sal_uInt16 nOldHandle;
887
888 nOldHandle=nDstFontHandle;
892 if (nOldHandle<MAXOBJECTHANDLES) {
893 WMFRecord_DeleteObject(nOldHandle);
894 FreeHandle(nOldHandle);
895 }
896}
897
899{
900 sal_uInt16 nOldHandle;
901
902 nOldHandle=nDstBrushHandle;
906 if (nOldHandle<MAXOBJECTHANDLES) {
907 WMFRecord_DeleteObject(nOldHandle);
908 FreeHandle(nOldHandle);
909 }
910}
911
913{
914 if ( eDstROP2 != eSrcRasterOp )
915 {
918 }
920 {
924 }
926 {
929 }
930}
931
933{
936 {
939 }
941 {
945 }
946 if ( aDstFont == aSrcFont )
947 return;
948
951 {
952 FontCharMapRef xFontCharMap;
953 if ( pVirDev->GetFontCharMap( xFontCharMap ) )
954 {
955 if ( ( xFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 )
956 aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
957 else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
958 aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 );
959 }
960 }
961
964}
965
967{
968 if(!rLinePolygon.count())
969 return;
970
971 basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon);
972 basegfx::B2DPolyPolygon aFillPolyPolygon;
973
974 rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon);
975
976 if(aLinePolyPolygon.count())
977 {
978 aSrcLineInfo = rInfo;
980
981 for(auto const& rB2DPolygon : std::as_const(aLinePolyPolygon))
982 {
983 WMFRecord_PolyLine( tools::Polygon(rB2DPolygon) );
984 }
985 }
986
987 if(!aFillPolyPolygon.count())
988 return;
989
990 const Color aOldLineColor(aSrcLineColor);
991 const Color aOldFillColor(aSrcFillColor);
992
994 aSrcFillColor = aOldLineColor;
996
997 for(auto const& rB2DPolygon : std::as_const(aFillPolyPolygon))
998 {
999 WMFRecord_Polygon( tools::Polygon(rB2DPolygon) );
1000 }
1001
1002 aSrcLineColor = aOldLineColor;
1003 aSrcFillColor = aOldFillColor;
1005}
1006
1008{
1009 if( !bStatus )
1010 return;
1011
1012 size_t nACount = rMTF.GetActionSize();
1013
1015
1016 for( size_t nA = 0; nA < nACount; nA++ )
1017 {
1018 MetaAction* pMA = rMTF.GetAction( nA );
1019
1020 switch( pMA->GetType() )
1021 {
1023 {
1024 const MetaPixelAction* pA = static_cast<const MetaPixelAction *>(pMA);
1027 WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() );
1028 }
1029 break;
1030
1032 {
1033 const MetaPointAction* pA = static_cast<const MetaPointAction*>(pMA);
1034 const Point& rPt = pA->GetPoint();
1037 WMFRecord_MoveTo( rPt);
1038 WMFRecord_LineTo( rPt );
1039 }
1040 break;
1041
1043 {
1044 const MetaLineAction* pA = static_cast<const MetaLineAction *>(pMA);
1045 if(pA->GetLineInfo().IsDefault())
1046 {
1047 aSrcLineInfo = pA->GetLineInfo();
1051 }
1052 else
1053 {
1054 // LineInfo used; handle Dash/Dot and fat lines
1055 basegfx::B2DPolygon aPolygon;
1056 aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y()));
1057 aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y()));
1058 HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon);
1059 }
1060 }
1061 break;
1062
1064 {
1065 const MetaRectAction* pA = static_cast<const MetaRectAction*>(pMA);
1069 }
1070 break;
1071
1073 {
1074 const MetaRoundRectAction* pA = static_cast<const MetaRoundRectAction*>(pMA);
1078 }
1079 break;
1080
1082 {
1083 const MetaEllipseAction* pA = static_cast<const MetaEllipseAction*>(pMA);
1086 WMFRecord_Ellipse( pA->GetRect() );
1087 }
1088 break;
1089
1091 {
1092 const MetaArcAction* pA = static_cast<const MetaArcAction*>(pMA);
1095 WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() );
1096 }
1097 break;
1098
1100 {
1101 const MetaPieAction* pA = static_cast<const MetaPieAction*>(pMA);
1104 WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
1105 }
1106 break;
1107
1109 {
1110 const MetaChordAction* pA = static_cast<const MetaChordAction*>(pMA);
1113 WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
1114 }
1115 break;
1116
1118 {
1119 const MetaPolyLineAction* pA = static_cast<const MetaPolyLineAction*>(pMA);
1120 const tools::Polygon& rPoly = pA->GetPolygon();
1121
1122 if( rPoly.GetSize() )
1123 {
1124 if(pA->GetLineInfo().IsDefault())
1125 {
1126 aSrcLineInfo = pA->GetLineInfo();
1128 WMFRecord_PolyLine( rPoly );
1129 }
1130 else
1131 {
1132 // LineInfo used; handle Dash/Dot and fat lines
1134 }
1135 }
1136 }
1137 break;
1138
1140 {
1141 const MetaPolygonAction* pA = static_cast<const MetaPolygonAction*>(pMA);
1145 }
1146 break;
1147
1149 {
1150 const MetaPolyPolygonAction* pA = static_cast<const MetaPolyPolygonAction*>(pMA);
1154 }
1155 break;
1156
1158 {
1159 const MetaTextRectAction * pA = static_cast<const MetaTextRectAction*>(pMA);
1160 OUString aTemp( pA->GetText() );
1162 SetAllAttr();
1163
1164 Point aPos( pA->GetRect().TopLeft() );
1165 if ( !WMFRecord_Escape_Unicode( aPos, aTemp, {} ) )
1166 WMFRecord_TextOut( aPos, aTemp );
1167 }
1168 break;
1169
1171 {
1172 const MetaTextAction * pA = static_cast<const MetaTextAction*>(pMA);
1173 OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
1175 SetAllAttr();
1176 if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, {} ) )
1177 WMFRecord_TextOut( pA->GetPoint(), aTemp );
1178 }
1179 break;
1180
1182 {
1183 const MetaTextArrayAction* pA = static_cast<const MetaTextArrayAction*>(pMA);
1184
1185 OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
1187 SetAllAttr();
1188 if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) )
1189 WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pA->GetDXArray() );
1190 }
1191 break;
1192
1194 {
1195 const MetaStretchTextAction* pA = static_cast<const MetaStretchTextAction *>(pMA);
1196 OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) );
1197
1199 const sal_Int32 nLen = aTemp.getLength();
1200 std::vector<sal_Int32> aDXAry;
1201 const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, nLen ? &aDXAry : nullptr );
1202 if (nLen && nNormSize == 0)
1203 {
1204 OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!");
1205 }
1206 else
1207 {
1208 for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ )
1209 aDXAry[ i ] = aDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize;
1210 if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) )
1211 aDXAry.clear();
1213 SetAllAttr();
1214 if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, aDXAry ) )
1215 WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, aDXAry );
1216 }
1217 }
1218 break;
1219
1221 {
1222 const MetaBmpAction* pA = static_cast<const MetaBmpAction *>(pMA);
1224 }
1225 break;
1226
1228 {
1229 const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pMA);
1230 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() );
1231 }
1232 break;
1233
1235 {
1236 const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pMA);
1237 Bitmap aTmp( pA->GetBitmap() );
1238
1239 if( aTmp.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) )
1240 WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp );
1241 }
1242 break;
1243
1245 {
1246 const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA);
1247 Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
1248 Bitmap aMsk( pA->GetBitmapEx().GetAlpha() );
1249
1250 if( !aMsk.IsEmpty() )
1251 {
1252 aBmp.Replace( aMsk, COL_WHITE );
1253 aMsk.Invert();
1254 WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT );
1255 WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND );
1256 }
1257 else
1258 WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp );
1259 }
1260 break;
1261
1263 {
1264 const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA);
1265 Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
1266 Bitmap aMsk( pA->GetBitmapEx().GetAlpha() );
1267
1268 if( !aMsk.IsEmpty() )
1269 {
1270 aBmp.Replace( aMsk, COL_WHITE );
1271 aMsk.Invert();
1272 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT );
1273 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND );
1274 }
1275 else
1276 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp );
1277 }
1278 break;
1279
1281 {
1282 const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pMA);
1283 BitmapEx aBmpEx( pA->GetBitmapEx() );
1284 aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
1285 Bitmap aBmp( aBmpEx.GetBitmap() );
1286 Bitmap aMsk( aBmpEx.GetAlpha() );
1287
1288 if( !aMsk.IsEmpty() )
1289 {
1290 aBmp.Replace( aMsk, COL_WHITE );
1291 aMsk.Invert();
1292 WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT );
1293 WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND );
1294 }
1295 else
1296 WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp );
1297 }
1298 break;
1299
1301 {
1302 const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pMA);
1303 GDIMetaFile aTmpMtf;
1304
1305 Gradient aGradient = pA->GetGradient();
1306 aGradient.AddGradientActions( pA->GetRect(), aTmpMtf );
1307 WriteRecords( aTmpMtf );
1308 }
1309 break;
1310
1312 {
1313 const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pMA);
1314 GDIMetaFile aTmpMtf;
1315
1316 pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
1317 WriteRecords( aTmpMtf );
1318 }
1319 break;
1320
1322 {
1323 const MetaWallpaperAction* pA = static_cast<const MetaWallpaperAction*>(pMA);
1324 const Color& rColor = pA->GetWallpaper().GetColor();
1325 const Color aOldLineColor( aSrcLineColor );
1326 const Color aOldFillColor( aSrcFillColor );
1327
1328 aSrcLineColor = rColor;
1329 aSrcFillColor = rColor;
1332 WMFRecord_Rectangle( pA->GetRect() );
1333 aSrcLineColor = aOldLineColor;
1334 aSrcFillColor = aOldFillColor;
1335 }
1336 break;
1337
1339 {
1340 const MetaISectRectClipRegionAction* pA = static_cast<const MetaISectRectClipRegionAction*>(pMA);
1342 }
1343 break;
1344
1346 {
1347 const MetaLineColorAction* pA = static_cast<const MetaLineColorAction*>(pMA);
1348
1349 if( pA->IsSetting() )
1350 aSrcLineColor = pA->GetColor();
1351 else
1353 }
1354 break;
1355
1357 {
1358 const MetaFillColorAction* pA = static_cast<const MetaFillColorAction*>(pMA);
1359
1360 if( pA->IsSetting() )
1361 aSrcFillColor = pA->GetColor();
1362 else
1364 }
1365 break;
1366
1368 {
1369 const MetaTextColorAction* pA = static_cast<const MetaTextColorAction*>(pMA);
1370 aSrcTextColor = pA->GetColor();
1371 }
1372 break;
1373
1375 {
1376 const MetaTextFillColorAction* pA = static_cast<const MetaTextFillColorAction*>(pMA);
1377 if( pA->IsSetting() )
1379 else
1381 }
1382 break;
1383
1385 {
1386 const MetaTextAlignAction* pA = static_cast<const MetaTextAlignAction*>(pMA);
1388 }
1389 break;
1390
1392 {
1393 const MetaMapModeAction* pA = static_cast<const MetaMapModeAction*>(pMA);
1394
1395 if (aSrcMapMode!=pA->GetMapMode())
1396 {
1397 if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative )
1398 {
1399 const MapMode& aMM = pA->GetMapMode();
1400 Fraction aScaleX = aMM.GetScaleX();
1401 Fraction aScaleY = aMM.GetScaleY();
1402
1403 Point aOrigin = aSrcMapMode.GetOrigin();
1404 BigInt aX( aOrigin.X() );
1405 aX *= BigInt( aScaleX.GetDenominator() );
1406 if( aOrigin.X() >= 0 )
1407 if( aScaleX.GetNumerator() >= 0 )
1408 aX += BigInt( aScaleX.GetNumerator()/2 );
1409 else
1410 aX -= BigInt( (aScaleX.GetNumerator()+1)/2 );
1411 else
1412 if( aScaleX.GetNumerator() >= 0 )
1413 aX -= BigInt( (aScaleX.GetNumerator()-1)/2 );
1414 else
1415 aX += BigInt( aScaleX.GetNumerator()/2 );
1416 aX /= BigInt( aScaleX.GetNumerator() );
1417 aOrigin.setX( static_cast<tools::Long>(aX) + aMM.GetOrigin().X() );
1418 BigInt aY( aOrigin.Y() );
1419 aY *= BigInt( aScaleY.GetDenominator() );
1420 if( aOrigin.Y() >= 0 )
1421 if( aScaleY.GetNumerator() >= 0 )
1422 aY += BigInt( aScaleY.GetNumerator()/2 );
1423 else
1424 aY -= BigInt( (aScaleY.GetNumerator()+1)/2 );
1425 else
1426 if( aScaleY.GetNumerator() >= 0 )
1427 aY -= BigInt( (aScaleY.GetNumerator()-1)/2 );
1428 else
1429 aY += BigInt( aScaleY.GetNumerator()/2 );
1430 aY /= BigInt( aScaleY.GetNumerator() );
1431 aOrigin.setY( static_cast<tools::Long>(aY) + aMM.GetOrigin().Y() );
1432 aSrcMapMode.SetOrigin( aOrigin );
1433
1434 aScaleX *= aSrcMapMode.GetScaleX();
1435 aScaleY *= aSrcMapMode.GetScaleY();
1436 aSrcMapMode.SetScaleX( aScaleX );
1437 aSrcMapMode.SetScaleY( aScaleY );
1438 }
1439 else
1440 aSrcMapMode=pA->GetMapMode();
1441 }
1442 }
1443 break;
1444
1446 {
1447 const MetaFontAction* pA = static_cast<const MetaFontAction*>(pMA);
1448 aSrcFont = pA->GetFont();
1449
1450 if ( (aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW)
1451 || (aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE) )
1452 {
1453 aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 );
1454 }
1459 }
1460 break;
1461
1463 {
1464 const MetaPushAction* pA = static_cast<const MetaPushAction*>(pMA);
1465
1467 pAt->nFlags = pA->GetFlags();
1472 pAt->aFont=aSrcFont;
1475 pAt->aMapMode=aSrcMapMode;
1477 pAt->pSucc=pAttrStack;
1478 pAttrStack=pAt;
1479
1480 SetAllAttr(); // update ( now all source attributes are equal to the destination attributes )
1482
1483 }
1484 break;
1485
1487 {
1489
1490 if( pAt )
1491 {
1492 aDstLineInfo = pAt->aLineInfo;
1494 if ( pAt->nFlags & vcl::PushFlags::LINECOLOR )
1497 if ( pAt->nFlags & vcl::PushFlags::FILLCOLOR )
1499 eDstROP2 = pAt->eRasterOp;
1500 if ( pAt->nFlags & vcl::PushFlags::RASTEROP )
1501 eSrcRasterOp = pAt->eRasterOp;
1502 aDstFont = pAt->aFont;
1503 if ( pAt->nFlags & vcl::PushFlags::FONT )
1504 aSrcFont = pAt->aFont;
1511 if ( pAt->nFlags & vcl::PushFlags::MAPMODE )
1512 aSrcMapMode = pAt->aMapMode;
1516
1518 pAttrStack = pAt->pSucc;
1519 delete pAt;
1520 }
1521 }
1522 break;
1523
1524 case MetaActionType::EPS :
1525 {
1526 const MetaEPSAction* pA = static_cast<const MetaEPSAction*>(pMA);
1527 const GDIMetaFile& aGDIMetaFile( pA->GetSubstitute() );
1528
1529 size_t nCount = aGDIMetaFile.GetActionSize();
1530 for ( size_t i = 0; i < nCount; i++ )
1531 {
1532 const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i );
1533 if ( pMetaAct->GetType() == MetaActionType::BMPSCALE )
1534 {
1535 const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pMetaAct);
1536 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() );
1537 break;
1538 }
1539 }
1540 }
1541 break;
1542
1544 {
1545 const MetaRasterOpAction* pA = static_cast<const MetaRasterOpAction*>(pMA);
1547 }
1548 break;
1549
1551 {
1554 WMFRecord_PolyPolygon( static_cast<const MetaTransparentAction*>(pMA)->GetPolyPolygon() );
1555 }
1556 break;
1557
1559 {
1560 const MetaFloatTransparentAction* pA = static_cast<const MetaFloatTransparentAction*>(pMA);
1561
1562 GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
1563 Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
1564 const Size aSrcSize( aTmpMtf.GetPrefSize() );
1565 const Point aDestPt( pA->GetPoint() );
1566 const Size aDestSize( pA->GetSize() );
1567 const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0;
1568 const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0;
1569 tools::Long nMoveX, nMoveY;
1570
1572 SetAllAttr();
1573
1574 if( fScaleX != 1.0 || fScaleY != 1.0 )
1575 {
1576 aTmpMtf.Scale( fScaleX, fScaleY );
1577 aSrcPt.setX( FRound( aSrcPt.X() * fScaleX ) );
1578 aSrcPt.setY( FRound( aSrcPt.Y() * fScaleY ) );
1579 }
1580
1581 nMoveX = aDestPt.X() - aSrcPt.X();
1582 nMoveY = aDestPt.Y() - aSrcPt.Y();
1583
1584 if( nMoveX || nMoveY )
1585 aTmpMtf.Move( nMoveX, nMoveY );
1586
1587 WriteRecords( aTmpMtf );
1588 }
1589 break;
1590
1592 {
1593 vcl::text::ComplexTextLayoutFlags nLayoutMode = static_cast<const MetaLayoutModeAction*>(pMA)->GetLayoutMode();
1594 eSrcHorTextAlign = 0; // TA_LEFT
1596 {
1598 }
1603 break;
1604 }
1605
1609 // Explicitly ignored cases
1610 break;
1611
1612 default:
1613 // TODO: Implement more cases as necessary. Let's not bother with a warning.
1614 break;
1615 }
1616
1618 MayCallback();
1619
1620 if (pWMF->GetError())
1621 bStatus=false;
1622
1623 if(!bStatus)
1624 break;
1625 }
1626}
1627
1628void WMFWriter::WriteHeader( bool bPlaceable )
1629{
1630 if( bPlaceable )
1631 {
1632 sal_uInt16 nCheckSum, nValue;
1633 Size aSize( OutputDevice::LogicToLogic(Size(1,1),MapMode(MapUnit::MapInch), aTargetMapMode) );
1634 sal_uInt16 nUnitsPerInch = static_cast<sal_uInt16>( ( aSize.Width() + aSize.Height() ) >> 1 );
1635
1636 nCheckSum=0;
1637 nValue=0xcdd7; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1638 nValue=0x9ac6; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1639 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1640 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1641 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1642 nValue=static_cast<sal_uInt16>(aTargetSize.Width()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1643 nValue=static_cast<sal_uInt16>(aTargetSize.Height()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1644 nValue=nUnitsPerInch; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1645 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1646 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1647 pWMF->WriteUInt16( nCheckSum );
1648 }
1649
1651 pWMF->WriteUInt16( 0x0001 ) // type: file
1652 .WriteUInt16( 0x0009 ) // header length in words
1653 .WriteUInt16( 0x0300 ) // Version as BCD number
1654 .WriteUInt32( 0x00000000 ) // file length (without 1st header), is later corrected by UpdateHeader()
1655 .WriteUInt16( MAXOBJECTHANDLES ) // maximum number of simultaneous objects
1656 .WriteUInt32( 0x00000000 ) // maximum record length, is later corrected by UpdateHeader()
1657 .WriteUInt16( 0x0000 ); // reserved
1658}
1659
1661{
1663 sal_uInt32 nFileSize;
1664
1665 nPos=pWMF->Tell(); // endposition = total size of file
1666 nFileSize=nPos-nMetafileHeaderPos; // subtract size of 1st header
1667 if ((nFileSize&1)!=0) { // if needed round to words
1668 pWMF->WriteUChar( 0 );
1669 nPos++;
1670 nFileSize++;
1671 }
1672 nFileSize>>=1; // convert to number of words
1673 pWMF->Seek(nMetafileHeaderPos+6); // to filesize entry in second header
1674 pWMF->WriteUInt32( nFileSize ); // rectify file size
1675 pWMF->SeekRel(2); // to max-record-length-entry in second header
1676 pWMF->WriteUInt32( nMaxRecordSize ); // and rectify
1677 pWMF->Seek(nPos);
1678}
1679
1680bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream,
1681 FilterConfigItem const * pFConfigItem, bool bPlaceable )
1682{
1684
1685 bEmbedEMF = true;
1686 bStatus=true;
1688
1689 if (pFConfigItem)
1690 {
1691 xStatusIndicator = pFConfigItem->GetStatusIndicator();
1692 if ( xStatusIndicator.is() )
1693 {
1694 xStatusIndicator->start( OUString(), 100 );
1695 }
1696
1698 auto it = aMap.find("EmbedEMF");
1699 if (it != aMap.end())
1700 {
1701 it->second >>= bEmbedEMF;
1702 }
1703 }
1704 nLastPercent=0;
1705
1706 pWMF=&rTargetStream;
1707 pWMF->SetEndian(SvStreamEndian::LITTLE);
1708
1710
1712
1713 if( bPlaceable )
1714 {
1716 aTargetSize = rMTF.GetPrefSize();
1717 sal_uInt16 nTargetDivisor = CalcSaveTargetMapMode(aTargetMapMode, aTargetSize);
1718 aTargetSize.setWidth( aTargetSize.Width() / nTargetDivisor );
1719 aTargetSize.setHeight( aTargetSize.Height() / nTargetDivisor );
1720 }
1721 else
1722 {
1723 aTargetMapMode = MapMode( MapUnit::MapInch );
1724
1725 const tools::Long nUnit = pVirDev->LogicToPixel( Size( 1, 1 ), aTargetMapMode ).Width();
1726 const Fraction aFrac( 1, nUnit );
1727
1728 aTargetMapMode.SetScaleX( aFrac );
1729 aTargetMapMode.SetScaleY( aFrac );
1731 }
1732
1734
1735 pAttrStack=nullptr;
1736
1737 for (bool & rn : bHandleAllocated)
1738 rn=false;
1739
1740 nDstPenHandle=0xffff;
1741 nDstFontHandle=0xffff;
1742 nDstBrushHandle=0xffff;
1743
1749
1751
1752 WriteHeader(bPlaceable);
1753 if( bEmbedEMF )
1754 WriteEmbeddedEMF( rMTF );
1757 WMFRecord_SetBkMode( true );
1758
1761
1765
1768
1770
1771 vcl::Font aFont;
1772 aFont.SetCharSet( GetExtendedTextEncoding( RTL_TEXTENCODING_MS_1252 ) );
1773 aFont.SetColor( COL_WHITE );
1775 aDstFont = aSrcFont = aFont;
1777
1781
1784
1785 // Write records
1786 WriteRecords(rMTF);
1787
1788 WriteRecordHeader(0x00000003,0x0000); // end of file
1789 UpdateHeader();
1790
1791 while(pAttrStack)
1792 {
1793 pAt=pAttrStack;
1794 pAttrStack=pAt->pSucc;
1795 delete pAt;
1796 }
1797
1799
1800 if ( xStatusIndicator.is() )
1801 xStatusIndicator->end();
1802
1803 return bStatus;
1804}
1805
1807 const Size& rPrefSize)
1808{
1809 Fraction aDivFrac(2, 1);
1810 sal_uInt16 nDivisor = 1;
1811
1812 Size aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
1813
1814 while( nDivisor <= 64 && (aSize.Width() > 32767 || aSize.Height() > 32767) )
1815 {
1816 Fraction aFrac = rMapMode.GetScaleX();
1817
1818 aFrac *= aDivFrac;
1819 rMapMode.SetScaleX(aFrac);
1820 aFrac = rMapMode.GetScaleY();
1821 aFrac *= aDivFrac;
1822 rMapMode.SetScaleY(aFrac);
1823 nDivisor <<= 1;
1824 aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
1825 }
1826
1827 return nDivisor;
1828}
1829
1831{
1832 SvMemoryStream aStream;
1833 EMFWriter aEMFWriter(aStream);
1834
1835 if( !aEMFWriter.WriteEMF( rMTF ) )
1836 return;
1837
1838 sal_uInt64 const nTotalSize = aStream.Tell();
1839 if( nTotalSize > SAL_MAX_UINT32 )
1840 return;
1841 aStream.Seek( 0 );
1842 sal_uInt32 nRemainingSize = static_cast< sal_uInt32 >( nTotalSize );
1843 sal_uInt32 nRecCounts = ( (nTotalSize - 1) / 0x2000 ) + 1;
1844 sal_uInt16 nCheckSum = 0, nWord;
1845
1846 sal_uInt32 nPos = 0;
1847
1848 while( nPos + 1 < nTotalSize )
1849 {
1850 aStream.ReadUInt16( nWord );
1851 nCheckSum ^= nWord;
1852 nPos += 2;
1853 }
1854
1855 nCheckSum = static_cast< sal_uInt16 >( nCheckSum * -1 );
1856
1857 aStream.Seek( 0 );
1858 while( nRemainingSize > 0 )
1859 {
1860 sal_uInt32 nCurSize;
1861 if( nRemainingSize > 0x2000 )
1862 {
1863 nCurSize = 0x2000;
1864 nRemainingSize -= 0x2000;
1865 }
1866 else
1867 {
1868 nCurSize = nRemainingSize;
1869 nRemainingSize = 0;
1870 }
1871 WriteEMFRecord( aStream,
1872 nCurSize,
1873 nRemainingSize,
1874 nTotalSize,
1875 nRecCounts,
1876 nCheckSum );
1877 nCheckSum = 0;
1878 }
1879
1880}
1881
1882void WMFWriter::WriteEMFRecord( SvMemoryStream& rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize,
1883 sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum )
1884{
1885 // according to http://msdn.microsoft.com/en-us/library/dd366152%28PROT.13%29.aspx
1887 pWMF->WriteUInt16( W_MFCOMMENT ) // same as META_ESCAPE_ENHANCED_METAFILE
1888 .WriteUInt16( nCurSize + 34 ) // we will always have a 34 byte escape header:
1889 .WriteUInt32( 0x43464D57 ) // WMFC
1890 .WriteUInt32( 0x00000001 ) // Comment type
1891 .WriteUInt32( 0x00010000 ) // version
1892 .WriteUInt16( nCheckSum ) // check sum
1893 .WriteUInt32( 0 ) // flags = 0
1894 .WriteUInt32( nRecCounts ) // total number of records
1895 .WriteUInt32( nCurSize ) // size of this record's data
1896 .WriteUInt32( nRemainingSize ) // remaining size of data in following records, missing in MSDN documentation
1897 .WriteUInt32( nTotalSize ); // total size of EMF stream
1898
1899 pWMF->WriteBytes(static_cast<const char*>(rStream.GetData()) + rStream.Tell(), nCurSize);
1900 rStream.SeekRel( nCurSize );
1902}
1903
1904/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RasterOp
Definition: RasterOp.hxx:23
AlphaMask GetAlpha() const
Definition: BitmapEx.cxx:215
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:203
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
Definition: BitmapEx.cxx:354
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
Size GetSizePixel() const
bool IsEmpty() const
bool Invert()
Perform the Invert operation on every pixel.
Definition: bitmappaint.cxx:61
bool Replace(const Bitmap &rMask, const Color &rReplaceColor)
Replace all pixel where the given mask is on with the specified color.
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
bool WriteEMF(const GDIMetaFile &rMtf)
Definition: emfwr.cxx:239
css::uno::Reference< css::task::XStatusIndicator > GetStatusIndicator() const
const css::uno::Sequence< css::beans::PropertyValue > & GetFilterData() const
sal_Int32 GetNumerator() const
sal_Int32 GetDenominator() const
size_t GetActionSize() const
Definition: gdimtf.cxx:179
void Move(tools::Long nX, tools::Long nY)
Definition: gdimtf.cxx:649
void Scale(double fScaleX, double fScaleY)
Definition: gdimtf.cxx:726
const Size & GetPrefSize() const
Definition: gdimtf.hxx:172
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:184
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:175
void AddGradientActions(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile)
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:105
void SetScaleY(const Fraction &rScaleY)
Definition: mapmod.cxx:118
const Fraction & GetScaleX() const
Definition: mapmod.cxx:154
MapUnit GetMapUnit() const
Definition: mapmod.cxx:150
const Point & GetOrigin() const
Definition: mapmod.cxx:152
const Fraction & GetScaleY() const
Definition: mapmod.cxx:156
void SetScaleX(const Fraction &rScaleX)
Definition: mapmod.cxx:111
MetaActionType GetType() const
Definition: metaact.hxx:94
const Point & GetStartPoint() const
Definition: metaact.hxx:306
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:305
const Point & GetEndPoint() const
Definition: metaact.hxx:307
const Bitmap & GetBitmap() const
Definition: metaact.hxx:684
const Point & GetPoint() const
Definition: metaact.hxx:685
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:789
const Point & GetPoint() const
Definition: metaact.hxx:790
const Size & GetSize() const
Definition: metaact.hxx:824
const Point & GetPoint() const
Definition: metaact.hxx:823
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:822
const Point & GetPoint() const
Definition: metaact.hxx:717
const Size & GetSize() const
Definition: metaact.hxx:718
const Bitmap & GetBitmap() const
Definition: metaact.hxx:716
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:373
const Point & GetStartPoint() const
Definition: metaact.hxx:374
const Point & GetEndPoint() const
Definition: metaact.hxx:375
const GDIMetaFile & GetSubstitute() const
Definition: metaact.hxx:1630
const Point & GetPoint() const
Definition: metaact.hxx:1631
const Size & GetSize() const
Definition: metaact.hxx:1632
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:275
const Color & GetColor() const
Definition: metaact.hxx:1270
bool IsSetting() const
Definition: metaact.hxx:1271
const Size & GetSize() const
Definition: metaact.hxx:1593
const GDIMetaFile & GetGDIMetaFile() const
Definition: metaact.hxx:1591
const Point & GetPoint() const
Definition: metaact.hxx:1592
const vcl::Font & GetFont() const
Definition: metaact.hxx:1463
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1013
const Gradient & GetGradient() const
Definition: metaact.hxx:1014
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1073
const Hatch & GetHatch() const
Definition: metaact.hxx:1074
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1162
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:185
const Point & GetEndPoint() const
Definition: metaact.hxx:184
const Point & GetStartPoint() const
Definition: metaact.hxx:183
bool IsSetting() const
Definition: metaact.hxx:1244
const Color & GetColor() const
Definition: metaact.hxx:1243
const MapMode & GetMapMode() const
Definition: metaact.hxx:1429
const Point & GetEndPoint() const
Definition: metaact.hxx:341
const Point & GetStartPoint() const
Definition: metaact.hxx:340
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:339
const Point & GetPoint() const
Definition: metaact.hxx:124
const Color & GetColor() const
Definition: metaact.hxx:125
const Point & GetPoint() const
Definition: metaact.hxx:152
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:407
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:406
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:462
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:435
vcl::PushFlags GetFlags() const
Definition: metaact.hxx:1488
RasterOp GetRasterOp() const
Definition: metaact.hxx:1528
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:214
sal_uInt32 GetHorzRound() const
Definition: metaact.hxx:245
sal_uInt32 GetVertRound() const
Definition: metaact.hxx:246
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:244
sal_uInt32 GetWidth() const
Definition: metaact.hxx:575
sal_Int32 GetLen() const
Definition: metaact.hxx:577
sal_Int32 GetIndex() const
Definition: metaact.hxx:576
const OUString & GetText() const
Definition: metaact.hxx:574
const Point & GetPoint() const
Definition: metaact.hxx:573
const Point & GetPoint() const
Definition: metaact.hxx:493
sal_Int32 GetLen() const
Definition: metaact.hxx:496
const OUString & GetText() const
Definition: metaact.hxx:494
sal_Int32 GetIndex() const
Definition: metaact.hxx:495
TextAlign GetTextAlign() const
Definition: metaact.hxx:1403
const Color & GetColor() const
Definition: metaact.hxx:1297
bool IsSetting() const
Definition: metaact.hxx:1325
const Color & GetColor() const
Definition: metaact.hxx:1322
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:611
const OUString & GetText() const
Definition: metaact.hxx:612
tools::Long GetTextArray(const OUString &rStr, std::vector< sal_Int32 > *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Definition: text.cxx:956
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:53
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1619
void AddHatchActions(const tools::PolyPolygon &rPolyPoly, const Hatch &rHatch, GDIMetaFile &rMtf)
void SetMapMode()
Definition: map.cxx:649
bool GetTextOutlines(PolyPolyVector &, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, o3tl::span< const sal_Int32 > pDXArray={}) const
Definition: text.cxx:2537
bool GetFontCharMap(FontCharMapRef &rxFontCharMap) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:933
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const void * GetData()
SvStream & WriteInt32(sal_Int32 nInt32)
sal_uInt64 Tell() const
void SetEndian(SvStreamEndian SvStreamEndian)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteChar(char nChar)
sal_uInt64 SeekRel(sal_Int64 nPos)
ErrCode GetError() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
void disposeAndClear()
Definition: vclptr.hxx:200
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
void WriteRecords(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1007
void SetAllAttr()
Definition: wmfwr.cxx:932
sal_uInt16 nDstFontHandle
Definition: wmfwr.hxx:97
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:634
Color aSrcLineColor
Definition: wmfwr.hxx:71
void HandleLineInfoPolyPolygons(const LineInfo &rInfo, const basegfx::B2DPolygon &rLinePolygon)
Definition: wmfwr.cxx:966
void WMFRecord_SaveDC()
Definition: wmfwr.cxx:694
void WMFRecord_LineTo(const Point &rPoint)
Definition: wmfwr.cxx:600
void WMFRecord_StretchDIB(const Point &rPoint, const Size &rSize, const Bitmap &rBitmap, sal_uInt32 nROP=0)
Definition: wmfwr.cxx:772
bool bStatus
Definition: wmfwr.hxx:55
void WMFRecord_CreatePenIndirect(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:371
void WMFRecord_SetBkMode(bool bTransparent)
Definition: wmfwr.cxx:705
void WriteEMFRecord(SvMemoryStream &rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize, sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum)
Definition: wmfwr.cxx:1882
void WMFRecord_ExtTextOut(const Point &rPoint, const OUString &rString, o3tl::span< const sal_Int32 > pDXAry)
Definition: wmfwr.cxx:548
sal_uLong nWrittenBitmaps
Definition: wmfwr.hxx:106
bool bHandleAllocated[MAXOBJECTHANDLES]
Definition: wmfwr.hxx:96
vcl::Font aDstFont
Definition: wmfwr.hxx:91
void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
Definition: wmfwr.cxx:256
void WritePointXY(const Point &rPoint)
Definition: wmfwr.cxx:215
void WMFRecord_SetWindowExt(const Size &rSize)
Definition: wmfwr.cxx:760
sal_uInt16 nDstPenHandle
Definition: wmfwr.hxx:97
void UpdateHeader()
Definition: wmfwr.cxx:1660
void WriteHeader(bool bPlaceable)
Definition: wmfwr.cxx:1628
void CreateSelectDeleteBrush(const Color &rColor)
Definition: wmfwr.cxx:898
void WMFRecord_CreateFontIndirect(const vcl::Font &rFont)
Definition: wmfwr.cxx:309
Color aDstLineColor
Definition: wmfwr.hxx:85
LineInfo aDstLineInfo
Definition: wmfwr.hxx:88
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
Definition: wmfwr.cxx:1680
sal_uLong nWrittenActions
Definition: wmfwr.hxx:105
SvStream * pWMF
Definition: wmfwr.hxx:61
TextAlign eDstTextAlign
Definition: wmfwr.hxx:90
void WMFRecord_SetWindowOrg(const Point &rPoint)
Definition: wmfwr.cxx:766
sal_uLong nLastPercent
Definition: wmfwr.hxx:57
void MayCallback()
Definition: wmfwr.cxx:166
RasterOp eDstROP2
Definition: wmfwr.hxx:89
Color aDstFillColor
Definition: wmfwr.hxx:86
void UpdateRecordHeader()
Definition: wmfwr.cxx:263
void WMFRecord_RoundRect(const tools::Rectangle &rRect, tools::Long nHorzRound, tools::Long nVertRound)
Definition: wmfwr.cxx:687
sal_uInt16 eSrcHorTextAlign
Definition: wmfwr.hxx:82
WMFWriter()
Definition: wmfwr.cxx:138
void WMFRecord_Chord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:288
css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator
Definition: wmfwr.hxx:59
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
Definition: wmfwr.cxx:1806
Color aSrcTextColor
Definition: wmfwr.hxx:73
sal_uInt16 AllocHandle()
Definition: wmfwr.cxx:851
sal_uLong nNumberOfBitmaps
Definition: wmfwr.hxx:104
sal_uLong nMetafileHeaderPos
Definition: wmfwr.hxx:66
VclPtr< VirtualDevice > pVirDev
Definition: wmfwr.hxx:62
void SetLineAndFillAttr()
Definition: wmfwr.cxx:912
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:413
void CreateSelectDeleteFont(const vcl::Font &rFont)
Definition: wmfwr.cxx:884
void TrueExtTextOut(const Point &rPoint, const OUString &rString, const OString &rByteString, o3tl::span< const sal_Int32 > pDXAry)
Definition: wmfwr.cxx:564
void WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorTextAlign)
Definition: wmfwr.cxx:738
void WMFRecord_TextOut(const Point &rPoint, std::u16string_view rString)
Definition: wmfwr.cxx:827
vcl::Region aSrcClipRegion
Definition: wmfwr.hxx:79
vcl::Region aDstClipRegion
Definition: wmfwr.hxx:95
bool bEmbedEMF
Definition: wmfwr.hxx:109
void WMFRecord_SetPixel(const Point &rPoint, const Color &rColor)
Definition: wmfwr.cxx:718
void CreateSelectDeletePen(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:870
void WMFRecord_MoveTo(const Point &rPoint)
Definition: wmfwr.cxx:606
void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:407
void WMFRecord_SetStretchBltMode()
Definition: wmfwr.cxx:712
void WriteHeightWidth(const Size &rSize)
Definition: wmfwr.cxx:239
Color aDstTextColor
Definition: wmfwr.hxx:87
sal_uLong nActBitmapPercent
Definition: wmfwr.hxx:107
void WriteSize(const Size &rSize)
Definition: wmfwr.cxx:233
sal_uLong nNumberOfActions
Definition: wmfwr.hxx:103
void WMFRecord_SetROP2(RasterOp eROP)
Definition: wmfwr.cxx:725
void WMFRecord_Pie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:612
void WMFRecord_RestoreDC()
Definition: wmfwr.cxx:681
void WMFRecord_IntersectClipRect(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:845
void WMFRecord_Arc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:280
void WriteColor(const Color &rColor)
Definition: wmfwr.cxx:251
void WMFRecord_Rectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:675
void TrueTextOut(const Point &rPoint, const OString &rString)
Definition: wmfwr.cxx:834
void FreeHandle(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:865
void WMFRecord_Polygon(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:620
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1830
void WMFRecord_PolyPolygon(const tools::PolyPolygon &rPolyPoly)
Definition: wmfwr.cxx:648
void WriteRectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:245
sal_uInt32 nMaxRecordSize
Definition: wmfwr.hxx:67
void WritePointYX(const Point &rPoint)
Definition: wmfwr.cxx:221
vcl::Font aSrcFont
Definition: wmfwr.hxx:77
void WMFRecord_CreateBrushIndirect(const Color &rColor)
Definition: wmfwr.cxx:296
sal_uInt16 eDstHorTextAlign
Definition: wmfwr.hxx:93
Color aSrcFillColor
Definition: wmfwr.hxx:72
MapMode aTargetMapMode
Definition: wmfwr.hxx:63
void WMFRecord_SetTextColor(const Color &rColor)
Definition: wmfwr.cxx:754
TextAlign eSrcTextAlign
Definition: wmfwr.hxx:76
LineInfo aSrcLineInfo
Definition: wmfwr.hxx:74
MapMode aSrcMapMode
Definition: wmfwr.hxx:78
void CountActionsAndBitmaps(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:189
sal_Int32 ScaleWidth(sal_Int32 nDX)
Definition: wmfwr.cxx:227
sal_uLong nActRecordPos
Definition: wmfwr.hxx:68
sal_uInt16 nDstBrushHandle
Definition: wmfwr.hxx:97
Size aTargetSize
Definition: wmfwr.hxx:64
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, o3tl::span< const sal_Int32 > pDXAry)
Definition: wmfwr.cxx:445
RasterOp eSrcRasterOp
Definition: wmfwr.hxx:75
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
Definition: wmfwr.cxx:419
WMFWriterAttrStackMember * pAttrStack
Definition: wmfwr.hxx:80
void WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:699
sal_uInt32 count() const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
sal_uInt32 count() const
constexpr bool empty() const noexcept
sal_uInt16 Count() const
void AdaptiveSubdivide(tools::PolyPolygon &rResult) const
void Move(tools::Long nHorzMove, tools::Long nVertMove)
const tools::Polygon & GetObject(sal_uInt16 nPos) const
::basegfx::B2DPolygon getB2DPolygon() const
bool HasFlags() const
sal_uInt16 GetSize() const
const Point & GetPoint(sal_uInt16 nPos) const
void AdaptiveSubdivide(tools::Polygon &rResult, const double d=1.0) const
constexpr Point TopLeft() const
constexpr tools::Long Right() const
constexpr tools::Long Bottom() const
FontFamily GetFamilyType()
Definition: font/font.cxx:902
void SetFillColor(const Color &)
Definition: font/font.cxx:114
void SetColor(const Color &)
Definition: font/font.cxx:106
FontStrikeout GetStrikeout() const
Definition: font/font.cxx:920
FontItalic GetItalic()
Definition: font/font.cxx:901
const OUString & GetFamilyName() const
Definition: font/font.cxx:878
TextAlign GetAlignment() const
Definition: font/font.cxx:876
void SetCharSet(rtl_TextEncoding)
Definition: font/font.cxx:160
const Size & GetFontSize() const
Definition: font/font.cxx:881
const Color & GetColor() const
Definition: font/font.cxx:872
void SetAlignment(TextAlign)
Definition: font/font.cxx:130
FontPitch GetPitch()
Definition: font/font.cxx:898
FontWeight GetWeight()
Definition: font/font.cxx:899
FontLineStyle GetUnderline() const
Definition: font/font.cxx:918
rtl_TextEncoding GetCharSet() const
Definition: font/font.cxx:887
Degree10 GetOrientation() const
Definition: font/font.cxx:894
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
int nCount
bool WriteDIB(const Bitmap &rSource, SvStream &rOStm, bool bCompressed, bool bFileHeader)
Definition: dibtools.cxx:1832
sal_Int16 nValue
UNOTOOLS_DLLPUBLIC bool IsStarSymbol(std::u16string_view rFontName)
LINESTYLE_NONE
STRIKEOUT_NONE
PITCH_VARIABLE
PITCH_FIXED
ITALIC_NONE
ALIGN_BOTTOM
ALIGN_TOP
ALIGN_BASELINE
FAMILY_DECORATIVE
FAMILY_SCRIPT
FAMILY_SWISS
FAMILY_MODERN
FAMILY_ROMAN
WEIGHT_ULTRALIGHT
WEIGHT_ULTRABOLD
WEIGHT_THIN
WEIGHT_BOLD
WEIGHT_NORMAL
WEIGHT_LIGHT
WEIGHT_SEMIBOLD
WEIGHT_SEMILIGHT
WEIGHT_MEDIUM
WEIGHT_BLACK
tools::Long FRound(double fVal)
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
int i
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
TextAlign
long Long
ComplexTextLayoutFlags
Definition: State.hxx:76
HashMap_OWString_Interface aMap
QPRO_FUNC_TYPE nType
sal_uIntPtr sal_uLong
std::size_t write_uInt8s_FromOString(SvStream &rStrm, std::string_view rStr, std::size_t nUnits)
TOOLS_DLLPUBLIC std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream &rStrm, std::string_view rStr)
TextAlign eTextAlign
Definition: wmfwr.hxx:39
struct WMFWriterAttrStackMember * pSucc
Definition: wmfwr.hxx:34
vcl::Region aClipRegion
Definition: wmfwr.hxx:43
vcl::PushFlags nFlags
Definition: wmfwr.hxx:44
UNDERLYING_TYPE get() const
TOOLS_DLLPUBLIC rtl_TextEncoding getBestMSEncodingByChar(sal_Unicode c)
TOOLS_DLLPUBLIC rtl_TextEncoding GetExtendedTextEncoding(rtl_TextEncoding eEncoding)
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
signed char sal_Int8
#define SAL_MAX_UINT32
#define W_META_MOVETO
Definition: wmfwr.cxx:52
#define PRIVATE_ESCAPE_UNICODE
Definition: wmfwr.cxx:136
#define W_FW_SEMIBOLD
Definition: wmfwr.cxx:125
#define W_META_SELECTOBJECT
Definition: wmfwr.cxx:66
#define W_TRANSPARENT
Definition: wmfwr.cxx:77
#define W_SRCAND
Definition: wmfwr.cxx:94
#define W_META_LINETO
Definition: wmfwr.cxx:51
#define W_FF_ROMAN
Definition: wmfwr.cxx:114
#define W_FF_SCRIPT
Definition: wmfwr.cxx:117
#define W_FW_DONTCARE
Definition: wmfwr.cxx:120
#define W_META_RESTOREDC
Definition: wmfwr.cxx:65
#define W_META_ROUNDRECT
Definition: wmfwr.cxx:58
#define W_META_POLYGON
Definition: wmfwr.cxx:62
#define W_FW_NORMAL
Definition: wmfwr.cxx:123
#define W_META_EXTTEXTOUT
Definition: wmfwr.cxx:69
#define W_FF_DONTCARE
Definition: wmfwr.cxx:113
#define W_META_SETTEXTALIGN
Definition: wmfwr.cxx:67
#define W_FIXED_PITCH
Definition: wmfwr.cxx:110
#define W_LF_FACESIZE
Definition: wmfwr.cxx:105
#define W_MFCOMMENT
Definition: wmfwr.cxx:134
#define W_META_SETSTRETCHBLTMODE
Definition: wmfwr.cxx:47
#define W_TA_BASELINE
Definition: wmfwr.cxx:89
#define W_R2_COPYPEN
Definition: wmfwr.cxx:82
#define W_FW_ULTRABOLD
Definition: wmfwr.cxx:128
#define W_META_POLYPOLYGON
Definition: wmfwr.cxx:70
#define W_DSTINVERT
Definition: wmfwr.cxx:96
#define W_META_ESCAPE
Definition: wmfwr.cxx:64
#define W_PS_DOT
Definition: wmfwr.cxx:100
#define W_META_CREATEPENINDIRECT
Definition: wmfwr.cxx:73
#define W_TA_NOUPDATECP
Definition: wmfwr.cxx:84
#define W_META_SETWINDOWEXT
Definition: wmfwr.cxx:50
#define W_FF_MODERN
Definition: wmfwr.cxx:116
#define W_SRCCOPY
Definition: wmfwr.cxx:92
#define W_SRCPAINT
Definition: wmfwr.cxx:93
#define W_META_SETTEXTCOLOR
Definition: wmfwr.cxx:48
#define W_PS_NULL
Definition: wmfwr.cxx:103
#define W_TA_BOTTOM
Definition: wmfwr.cxx:88
#define W_PS_DASH
Definition: wmfwr.cxx:99
#define W_ANSI_CHARSET
Definition: wmfwr.cxx:107
#define W_OPAQUE
Definition: wmfwr.cxx:78
#define W_TA_LEFT
Definition: wmfwr.cxx:85
#define W_META_SETWINDOWORG
Definition: wmfwr.cxx:49
#define W_VARIABLE_PITCH
Definition: wmfwr.cxx:111
#define W_TA_RIGHT
Definition: wmfwr.cxx:86
#define W_META_CREATEFONTINDIRECT
Definition: wmfwr.cxx:74
#define W_PS_DASHDOT
Definition: wmfwr.cxx:101
#define W_FW_MEDIUM
Definition: wmfwr.cxx:124
#define W_META_DELETEOBJECT
Definition: wmfwr.cxx:72
#define W_FW_ULTRALIGHT
Definition: wmfwr.cxx:127
#define W_BS_HOLLOW
Definition: wmfwr.cxx:132
#define W_META_ARC
Definition: wmfwr.cxx:54
#define W_META_PIE
Definition: wmfwr.cxx:56
#define W_META_STRETCHDIB
Definition: wmfwr.cxx:71
#define W_TA_TOP
Definition: wmfwr.cxx:87
#define W_META_SETPIXEL
Definition: wmfwr.cxx:60
#define W_PS_SOLID
Definition: wmfwr.cxx:98
#define W_META_SAVEDC
Definition: wmfwr.cxx:59
#define W_META_CREATEBRUSHINDIRECT
Definition: wmfwr.cxx:75
#define W_META_ELLIPSE
Definition: wmfwr.cxx:55
#define W_META_SETROP2
Definition: wmfwr.cxx:46
#define W_META_TEXTOUT
Definition: wmfwr.cxx:61
#define W_BS_SOLID
Definition: wmfwr.cxx:131
#define W_META_POLYLINE
Definition: wmfwr.cxx:63
#define W_META_RECTANGLE
Definition: wmfwr.cxx:57
#define W_FW_BLACK
Definition: wmfwr.cxx:129
#define W_FF_DECORATIVE
Definition: wmfwr.cxx:118
#define W_R2_XORPEN
Definition: wmfwr.cxx:81
#define W_META_CHORD
Definition: wmfwr.cxx:68
#define W_FW_LIGHT
Definition: wmfwr.cxx:122
#define W_FW_BOLD
Definition: wmfwr.cxx:126
#define W_FW_THIN
Definition: wmfwr.cxx:121
#define W_DEFAULT_PITCH
Definition: wmfwr.cxx:109
#define W_R2_NOT
Definition: wmfwr.cxx:80
#define W_PS_DASHDOTDOT
Definition: wmfwr.cxx:102
#define W_TA_RTLREADING
Definition: wmfwr.cxx:90
#define W_META_INTERSECTCLIPRECT
Definition: wmfwr.cxx:53
#define W_META_SETBKMODE
Definition: wmfwr.cxx:45
#define W_FF_SWISS
Definition: wmfwr.cxx:115
#define W_SRCINVERT
Definition: wmfwr.cxx:95
#define MAXOBJECTHANDLES
Definition: wmfwr.hxx:30