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, KernArraySpan 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 ) || IsOpenSymbol( 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
549 std::u16string_view rString,
550 KernArraySpan pDXAry )
551{
552 sal_Int32 nOriginalTextLen = rString.size();
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, std::u16string_view rString,
565 const OString& rByteString, KernArraySpan 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.size();
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
601{
603 WritePointYX(rPoint);
604}
605
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
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 KernArray 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.set(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 AlphaMask aMsk( pA->GetBitmapEx().GetAlphaMask() );
1249
1250 if( !aMsk.IsEmpty() )
1251 {
1252 aBmp.Replace( aMsk, COL_WHITE );
1253 WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT );
1254 WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND );
1255 }
1256 else
1257 WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp );
1258 }
1259 break;
1260
1262 {
1263 const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA);
1264 Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
1265 AlphaMask aMsk( pA->GetBitmapEx().GetAlphaMask() );
1266
1267 if( !aMsk.IsEmpty() )
1268 {
1269 aBmp.Replace( aMsk, COL_WHITE );
1270 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT );
1271 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND );
1272 }
1273 else
1274 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp );
1275 }
1276 break;
1277
1279 {
1280 const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pMA);
1281 BitmapEx aBmpEx( pA->GetBitmapEx() );
1282 aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
1283 Bitmap aBmp( aBmpEx.GetBitmap() );
1284 AlphaMask aMsk( aBmpEx.GetAlphaMask() );
1285
1286 if( !aMsk.IsEmpty() )
1287 {
1288 aBmp.Replace( aMsk, COL_WHITE );
1291 }
1292 else
1293 WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp );
1294 }
1295 break;
1296
1298 {
1299 const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pMA);
1300 GDIMetaFile aTmpMtf;
1301
1302 Gradient aGradient = pA->GetGradient();
1303 aGradient.AddGradientActions( pA->GetRect(), aTmpMtf );
1304 WriteRecords( aTmpMtf );
1305 }
1306 break;
1307
1309 {
1310 const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pMA);
1311 GDIMetaFile aTmpMtf;
1312
1313 pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
1314 WriteRecords( aTmpMtf );
1315 }
1316 break;
1317
1319 {
1320 const MetaWallpaperAction* pA = static_cast<const MetaWallpaperAction*>(pMA);
1321 const Color& rColor = pA->GetWallpaper().GetColor();
1322 const Color aOldLineColor( aSrcLineColor );
1323 const Color aOldFillColor( aSrcFillColor );
1324
1325 aSrcLineColor = rColor;
1326 aSrcFillColor = rColor;
1330 aSrcLineColor = aOldLineColor;
1331 aSrcFillColor = aOldFillColor;
1332 }
1333 break;
1334
1336 {
1337 const MetaISectRectClipRegionAction* pA = static_cast<const MetaISectRectClipRegionAction*>(pMA);
1339 }
1340 break;
1341
1343 {
1344 const MetaLineColorAction* pA = static_cast<const MetaLineColorAction*>(pMA);
1345
1346 if( pA->IsSetting() )
1347 aSrcLineColor = pA->GetColor();
1348 else
1350 }
1351 break;
1352
1354 {
1355 const MetaFillColorAction* pA = static_cast<const MetaFillColorAction*>(pMA);
1356
1357 if( pA->IsSetting() )
1358 aSrcFillColor = pA->GetColor();
1359 else
1361 }
1362 break;
1363
1365 {
1366 const MetaTextColorAction* pA = static_cast<const MetaTextColorAction*>(pMA);
1367 aSrcTextColor = pA->GetColor();
1368 }
1369 break;
1370
1372 {
1373 const MetaTextFillColorAction* pA = static_cast<const MetaTextFillColorAction*>(pMA);
1374 if( pA->IsSetting() )
1376 else
1378 }
1379 break;
1380
1382 {
1383 const MetaTextAlignAction* pA = static_cast<const MetaTextAlignAction*>(pMA);
1385 }
1386 break;
1387
1389 {
1390 const MetaMapModeAction* pA = static_cast<const MetaMapModeAction*>(pMA);
1391
1392 if (aSrcMapMode!=pA->GetMapMode())
1393 {
1394 if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative )
1395 {
1396 const MapMode& aMM = pA->GetMapMode();
1397 Fraction aScaleX = aMM.GetScaleX();
1398 Fraction aScaleY = aMM.GetScaleY();
1399
1400 Point aOrigin = aSrcMapMode.GetOrigin();
1401 BigInt aX( aOrigin.X() );
1402 aX *= BigInt( aScaleX.GetDenominator() );
1403 if( aOrigin.X() >= 0 )
1404 if( aScaleX.GetNumerator() >= 0 )
1405 aX += BigInt( aScaleX.GetNumerator()/2 );
1406 else
1407 aX -= BigInt( (aScaleX.GetNumerator()+1)/2 );
1408 else
1409 if( aScaleX.GetNumerator() >= 0 )
1410 aX -= BigInt( (aScaleX.GetNumerator()-1)/2 );
1411 else
1412 aX += BigInt( aScaleX.GetNumerator()/2 );
1413 aX /= BigInt( aScaleX.GetNumerator() );
1414 aOrigin.setX( static_cast<tools::Long>(aX) + aMM.GetOrigin().X() );
1415 BigInt aY( aOrigin.Y() );
1416 aY *= BigInt( aScaleY.GetDenominator() );
1417 if( aOrigin.Y() >= 0 )
1418 if( aScaleY.GetNumerator() >= 0 )
1419 aY += BigInt( aScaleY.GetNumerator()/2 );
1420 else
1421 aY -= BigInt( (aScaleY.GetNumerator()+1)/2 );
1422 else
1423 if( aScaleY.GetNumerator() >= 0 )
1424 aY -= BigInt( (aScaleY.GetNumerator()-1)/2 );
1425 else
1426 aY += BigInt( aScaleY.GetNumerator()/2 );
1427 aY /= BigInt( aScaleY.GetNumerator() );
1428 aOrigin.setY( static_cast<tools::Long>(aY) + aMM.GetOrigin().Y() );
1429 aSrcMapMode.SetOrigin( aOrigin );
1430
1431 aScaleX *= aSrcMapMode.GetScaleX();
1432 aScaleY *= aSrcMapMode.GetScaleY();
1433 aSrcMapMode.SetScaleX( aScaleX );
1434 aSrcMapMode.SetScaleY( aScaleY );
1435 }
1436 else
1437 aSrcMapMode=pA->GetMapMode();
1438 }
1439 }
1440 break;
1441
1443 {
1444 const MetaFontAction* pA = static_cast<const MetaFontAction*>(pMA);
1445 aSrcFont = pA->GetFont();
1446
1447 if ( (aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW)
1448 || (aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE) )
1449 {
1450 aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 );
1451 }
1456 }
1457 break;
1458
1460 {
1461 const MetaPushAction* pA = static_cast<const MetaPushAction*>(pMA);
1462
1464 pAt->nFlags = pA->GetFlags();
1469 pAt->aFont=aSrcFont;
1472 pAt->aMapMode=aSrcMapMode;
1474 pAt->pSucc=pAttrStack;
1475 pAttrStack=pAt;
1476
1477 SetAllAttr(); // update ( now all source attributes are equal to the destination attributes )
1479
1480 }
1481 break;
1482
1484 {
1486
1487 if( pAt )
1488 {
1489 aDstLineInfo = pAt->aLineInfo;
1491 if ( pAt->nFlags & vcl::PushFlags::LINECOLOR )
1494 if ( pAt->nFlags & vcl::PushFlags::FILLCOLOR )
1496 eDstROP2 = pAt->eRasterOp;
1497 if ( pAt->nFlags & vcl::PushFlags::RASTEROP )
1498 eSrcRasterOp = pAt->eRasterOp;
1499 aDstFont = pAt->aFont;
1500 if ( pAt->nFlags & vcl::PushFlags::FONT )
1501 aSrcFont = pAt->aFont;
1508 if ( pAt->nFlags & vcl::PushFlags::MAPMODE )
1509 aSrcMapMode = pAt->aMapMode;
1513
1515 pAttrStack = pAt->pSucc;
1516 delete pAt;
1517 }
1518 }
1519 break;
1520
1521 case MetaActionType::EPS :
1522 {
1523 const MetaEPSAction* pA = static_cast<const MetaEPSAction*>(pMA);
1524 const GDIMetaFile& aGDIMetaFile( pA->GetSubstitute() );
1525
1526 size_t nCount = aGDIMetaFile.GetActionSize();
1527 for ( size_t i = 0; i < nCount; i++ )
1528 {
1529 const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i );
1530 if ( pMetaAct->GetType() == MetaActionType::BMPSCALE )
1531 {
1532 const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pMetaAct);
1533 WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() );
1534 break;
1535 }
1536 }
1537 }
1538 break;
1539
1541 {
1542 const MetaRasterOpAction* pA = static_cast<const MetaRasterOpAction*>(pMA);
1544 }
1545 break;
1546
1548 {
1551 WMFRecord_PolyPolygon( static_cast<const MetaTransparentAction*>(pMA)->GetPolyPolygon() );
1552 }
1553 break;
1554
1556 {
1557 const MetaFloatTransparentAction* pA = static_cast<const MetaFloatTransparentAction*>(pMA);
1558
1559 GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
1560 Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
1561 const Size aSrcSize( aTmpMtf.GetPrefSize() );
1562 const Point aDestPt( pA->GetPoint() );
1563 const Size aDestSize( pA->GetSize() );
1564 const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0;
1565 const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0;
1566 tools::Long nMoveX, nMoveY;
1567
1569 SetAllAttr();
1570
1571 if( fScaleX != 1.0 || fScaleY != 1.0 )
1572 {
1573 aTmpMtf.Scale( fScaleX, fScaleY );
1574 aSrcPt.setX( FRound( aSrcPt.X() * fScaleX ) );
1575 aSrcPt.setY( FRound( aSrcPt.Y() * fScaleY ) );
1576 }
1577
1578 nMoveX = aDestPt.X() - aSrcPt.X();
1579 nMoveY = aDestPt.Y() - aSrcPt.Y();
1580
1581 if( nMoveX || nMoveY )
1582 aTmpMtf.Move( nMoveX, nMoveY );
1583
1584 WriteRecords( aTmpMtf );
1585 }
1586 break;
1587
1589 {
1590 vcl::text::ComplexTextLayoutFlags nLayoutMode = static_cast<const MetaLayoutModeAction*>(pMA)->GetLayoutMode();
1591 eSrcHorTextAlign = 0; // TA_LEFT
1593 {
1595 }
1600 break;
1601 }
1602
1606 // Explicitly ignored cases
1607 break;
1608
1609 default:
1610 // TODO: Implement more cases as necessary. Let's not bother with a warning.
1611 break;
1612 }
1613
1615 MayCallback();
1616
1617 if (pWMF->GetError())
1618 bStatus=false;
1619
1620 if(!bStatus)
1621 break;
1622 }
1623}
1624
1625void WMFWriter::WriteHeader( bool bPlaceable )
1626{
1627 if( bPlaceable )
1628 {
1629 sal_uInt16 nCheckSum, nValue;
1630 Size aSize( OutputDevice::LogicToLogic(Size(1,1),MapMode(MapUnit::MapInch), aTargetMapMode) );
1631 sal_uInt16 nUnitsPerInch = static_cast<sal_uInt16>( ( aSize.Width() + aSize.Height() ) >> 1 );
1632
1633 nCheckSum=0;
1634 nValue=0xcdd7; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1635 nValue=0x9ac6; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1636 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1637 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1638 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1639 nValue=static_cast<sal_uInt16>(aTargetSize.Width()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1640 nValue=static_cast<sal_uInt16>(aTargetSize.Height()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1641 nValue=nUnitsPerInch; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1642 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1643 nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue );
1644 pWMF->WriteUInt16( nCheckSum );
1645 }
1646
1648 pWMF->WriteUInt16( 0x0001 ) // type: file
1649 .WriteUInt16( 0x0009 ) // header length in words
1650 .WriteUInt16( 0x0300 ) // Version as BCD number
1651 .WriteUInt32( 0x00000000 ) // file length (without 1st header), is later corrected by UpdateHeader()
1652 .WriteUInt16( MAXOBJECTHANDLES ) // maximum number of simultaneous objects
1653 .WriteUInt32( 0x00000000 ) // maximum record length, is later corrected by UpdateHeader()
1654 .WriteUInt16( 0x0000 ); // reserved
1655}
1656
1658{
1660 sal_uInt32 nFileSize;
1661
1662 nPos=pWMF->Tell(); // endposition = total size of file
1663 nFileSize=nPos-nMetafileHeaderPos; // subtract size of 1st header
1664 if ((nFileSize&1)!=0) { // if needed round to words
1665 pWMF->WriteUChar( 0 );
1666 nPos++;
1667 nFileSize++;
1668 }
1669 nFileSize>>=1; // convert to number of words
1670 pWMF->Seek(nMetafileHeaderPos+6); // to filesize entry in second header
1671 pWMF->WriteUInt32( nFileSize ); // rectify file size
1672 pWMF->SeekRel(2); // to max-record-length-entry in second header
1673 pWMF->WriteUInt32( nMaxRecordSize ); // and rectify
1674 pWMF->Seek(nPos);
1675}
1676
1677bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream,
1678 FilterConfigItem const * pFConfigItem, bool bPlaceable )
1679{
1681
1682 bEmbedEMF = true;
1683 bStatus=true;
1685
1686 if (pFConfigItem)
1687 {
1688 xStatusIndicator = pFConfigItem->GetStatusIndicator();
1689 if ( xStatusIndicator.is() )
1690 {
1691 xStatusIndicator->start( OUString(), 100 );
1692 }
1693
1695 auto it = aMap.find("EmbedEMF");
1696 if (it != aMap.end())
1697 {
1698 it->second >>= bEmbedEMF;
1699 }
1700 }
1701 nLastPercent=0;
1702
1703 pWMF=&rTargetStream;
1704 pWMF->SetEndian(SvStreamEndian::LITTLE);
1705
1707
1709
1710 if( bPlaceable )
1711 {
1713 aTargetSize = rMTF.GetPrefSize();
1714 sal_uInt16 nTargetDivisor = CalcSaveTargetMapMode(aTargetMapMode, aTargetSize);
1715 aTargetSize.setWidth( aTargetSize.Width() / nTargetDivisor );
1716 aTargetSize.setHeight( aTargetSize.Height() / nTargetDivisor );
1717 }
1718 else
1719 {
1720 aTargetMapMode = MapMode( MapUnit::MapInch );
1721
1722 const tools::Long nUnit = pVirDev->LogicToPixel( Size( 1, 1 ), aTargetMapMode ).Width();
1723 const Fraction aFrac( 1, nUnit );
1724
1725 aTargetMapMode.SetScaleX( aFrac );
1726 aTargetMapMode.SetScaleY( aFrac );
1728 }
1729
1731
1732 pAttrStack=nullptr;
1733
1734 for (bool & rn : bHandleAllocated)
1735 rn=false;
1736
1737 nDstPenHandle=0xffff;
1738 nDstFontHandle=0xffff;
1739 nDstBrushHandle=0xffff;
1740
1746
1748
1749 WriteHeader(bPlaceable);
1750 if( bEmbedEMF )
1751 WriteEmbeddedEMF( rMTF );
1754 WMFRecord_SetBkMode( true );
1755
1758
1762
1765
1767
1768 vcl::Font aFont;
1769 aFont.SetCharSet( GetExtendedTextEncoding( RTL_TEXTENCODING_MS_1252 ) );
1770 aFont.SetColor( COL_WHITE );
1772 aDstFont = aSrcFont = aFont;
1774
1778
1781
1782 // Write records
1783 WriteRecords(rMTF);
1784
1785 WriteRecordHeader(0x00000003,0x0000); // end of file
1786 UpdateHeader();
1787
1788 while(pAttrStack)
1789 {
1790 pAt=pAttrStack;
1791 pAttrStack=pAt->pSucc;
1792 delete pAt;
1793 }
1794
1796
1797 if ( xStatusIndicator.is() )
1798 xStatusIndicator->end();
1799
1800 return bStatus;
1801}
1802
1804 const Size& rPrefSize)
1805{
1806 Fraction aDivFrac(2, 1);
1807 sal_uInt16 nDivisor = 1;
1808
1809 Size aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
1810
1811 while( nDivisor <= 64 && (aSize.Width() > 32767 || aSize.Height() > 32767) )
1812 {
1813 Fraction aFrac = rMapMode.GetScaleX();
1814
1815 aFrac *= aDivFrac;
1816 rMapMode.SetScaleX(aFrac);
1817 aFrac = rMapMode.GetScaleY();
1818 aFrac *= aDivFrac;
1819 rMapMode.SetScaleY(aFrac);
1820 nDivisor <<= 1;
1821 aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
1822 }
1823
1824 return nDivisor;
1825}
1826
1828{
1829 SvMemoryStream aStream;
1830 EMFWriter aEMFWriter(aStream);
1831
1832 if( !aEMFWriter.WriteEMF( rMTF ) )
1833 return;
1834
1835 sal_uInt64 const nTotalSize = aStream.Tell();
1836 if( nTotalSize > SAL_MAX_UINT32 )
1837 return;
1838 aStream.Seek( 0 );
1839 sal_uInt32 nRemainingSize = static_cast< sal_uInt32 >( nTotalSize );
1840 sal_uInt32 nRecCounts = ( (nTotalSize - 1) / 0x2000 ) + 1;
1841 sal_uInt16 nCheckSum = 0, nWord;
1842
1843 sal_uInt32 nPos = 0;
1844
1845 while( nPos + 1 < nTotalSize )
1846 {
1847 aStream.ReadUInt16( nWord );
1848 nCheckSum ^= nWord;
1849 nPos += 2;
1850 }
1851
1852 nCheckSum = static_cast< sal_uInt16 >( nCheckSum * -1 );
1853
1854 aStream.Seek( 0 );
1855 while( nRemainingSize > 0 )
1856 {
1857 sal_uInt32 nCurSize;
1858 if( nRemainingSize > 0x2000 )
1859 {
1860 nCurSize = 0x2000;
1861 nRemainingSize -= 0x2000;
1862 }
1863 else
1864 {
1865 nCurSize = nRemainingSize;
1866 nRemainingSize = 0;
1867 }
1868 WriteEMFRecord( aStream,
1869 nCurSize,
1870 nRemainingSize,
1871 nTotalSize,
1872 nRecCounts,
1873 nCheckSum );
1874 nCheckSum = 0;
1875 }
1876
1877}
1878
1879void WMFWriter::WriteEMFRecord( SvMemoryStream& rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize,
1880 sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum )
1881{
1882 // according to http://msdn.microsoft.com/en-us/library/dd366152%28PROT.13%29.aspx
1884 pWMF->WriteUInt16( W_MFCOMMENT ) // same as META_ESCAPE_ENHANCED_METAFILE
1885 .WriteUInt16( nCurSize + 34 ) // we will always have a 34 byte escape header:
1886 .WriteUInt32( 0x43464D57 ) // WMFC
1887 .WriteUInt32( 0x00000001 ) // Comment type
1888 .WriteUInt32( 0x00010000 ) // version
1889 .WriteUInt16( nCheckSum ) // check sum
1890 .WriteUInt32( 0 ) // flags = 0
1891 .WriteUInt32( nRecCounts ) // total number of records
1892 .WriteUInt32( nCurSize ) // size of this record's data
1893 .WriteUInt32( nRemainingSize ) // remaining size of data in following records, missing in MSDN documentation
1894 .WriteUInt32( nTotalSize ); // total size of EMF stream
1895
1896 pWMF->WriteBytes(static_cast<const char*>(rStream.GetData()) + rStream.Tell(), nCurSize);
1897 rStream.SeekRel( nCurSize );
1899}
1900
1901/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RasterOp
Definition: RasterOp.hxx:23
bool IsEmpty() const
const AlphaMask & GetAlphaMask() const
Definition: bitmapex.hxx:71
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:217
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
Definition: BitmapEx.cxx:363
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
bool Replace(const AlphaMask &rAlpha, const Color &rMergeColor)
Merge bitmap with given background color according to specified alpha mask.
Size GetSizePixel() const
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:181
void Move(tools::Long nX, tools::Long nY)
Definition: gdimtf.cxx:653
void Scale(double fScaleX, double fScaleY)
Definition: gdimtf.cxx:748
const Size & GetPrefSize() const
Definition: gdimtf.hxx:176
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:186
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:179
void AddGradientActions(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile)
bool empty() const
Definition: kernarray.hxx:34
void clear()
Definition: kernarray.hxx:75
void set(size_t nIndex, sal_Int32 nValue)
Definition: kernarray.hxx:70
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:138
void SetScaleY(const Fraction &rScaleY)
Definition: mapmod.cxx:150
const Fraction & GetScaleX() const
Definition: mapmod.cxx:185
MapUnit GetMapUnit() const
Definition: mapmod.cxx:181
const Point & GetOrigin() const
Definition: mapmod.cxx:183
const Fraction & GetScaleY() const
Definition: mapmod.cxx:187
void SetScaleX(const Fraction &rScaleX)
Definition: mapmod.cxx:144
MetaActionType GetType() const
Definition: metaact.hxx:96
const Point & GetStartPoint() const
Definition: metaact.hxx:308
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:307
const Point & GetEndPoint() const
Definition: metaact.hxx:309
const Bitmap & GetBitmap() const
Definition: metaact.hxx:693
const Point & GetPoint() const
Definition: metaact.hxx:694
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:798
const Point & GetPoint() const
Definition: metaact.hxx:799
const Size & GetSize() const
Definition: metaact.hxx:833
const Point & GetPoint() const
Definition: metaact.hxx:832
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:831
const Point & GetSrcPoint() const
Definition: metaact.hxx:872
const Size & GetDestSize() const
Definition: metaact.hxx:871
const Point & GetDestPoint() const
Definition: metaact.hxx:870
const Size & GetSrcSize() const
Definition: metaact.hxx:873
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:869
const Point & GetPoint() const
Definition: metaact.hxx:726
const Size & GetSize() const
Definition: metaact.hxx:727
const Bitmap & GetBitmap() const
Definition: metaact.hxx:725
const Bitmap & GetBitmap() const
Definition: metaact.hxx:762
const Point & GetDestPoint() const
Definition: metaact.hxx:763
const Point & GetSrcPoint() const
Definition: metaact.hxx:765
const Size & GetSrcSize() const
Definition: metaact.hxx:766
const Size & GetDestSize() const
Definition: metaact.hxx:764
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:375
const Point & GetStartPoint() const
Definition: metaact.hxx:376
const Point & GetEndPoint() const
Definition: metaact.hxx:377
const GDIMetaFile & GetSubstitute() const
Definition: metaact.hxx:1647
const Point & GetPoint() const
Definition: metaact.hxx:1648
const Size & GetSize() const
Definition: metaact.hxx:1649
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:277
const Color & GetColor() const
Definition: metaact.hxx:1279
bool IsSetting() const
Definition: metaact.hxx:1280
const Size & GetSize() const
Definition: metaact.hxx:1605
const GDIMetaFile & GetGDIMetaFile() const
Definition: metaact.hxx:1603
const Point & GetPoint() const
Definition: metaact.hxx:1604
const vcl::Font & GetFont() const
Definition: metaact.hxx:1472
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1022
const Gradient & GetGradient() const
Definition: metaact.hxx:1023
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1082
const Hatch & GetHatch() const
Definition: metaact.hxx:1083
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1171
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:187
const Point & GetEndPoint() const
Definition: metaact.hxx:186
const Point & GetStartPoint() const
Definition: metaact.hxx:185
bool IsSetting() const
Definition: metaact.hxx:1253
const Color & GetColor() const
Definition: metaact.hxx:1252
const MapMode & GetMapMode() const
Definition: metaact.hxx:1438
const Point & GetEndPoint() const
Definition: metaact.hxx:343
const Point & GetStartPoint() const
Definition: metaact.hxx:342
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:341
const Point & GetPoint() const
Definition: metaact.hxx:126
const Color & GetColor() const
Definition: metaact.hxx:127
const Point & GetPoint() const
Definition: metaact.hxx:154
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:409
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:408
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:464
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:437
vcl::PushFlags GetFlags() const
Definition: metaact.hxx:1497
RasterOp GetRasterOp() const
Definition: metaact.hxx:1537
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:216
sal_uInt32 GetHorzRound() const
Definition: metaact.hxx:247
sal_uInt32 GetVertRound() const
Definition: metaact.hxx:248
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:246
sal_uInt32 GetWidth() const
Definition: metaact.hxx:584
sal_Int32 GetLen() const
Definition: metaact.hxx:586
sal_Int32 GetIndex() const
Definition: metaact.hxx:585
const OUString & GetText() const
Definition: metaact.hxx:583
const Point & GetPoint() const
Definition: metaact.hxx:582
const Point & GetPoint() const
Definition: metaact.hxx:495
sal_Int32 GetLen() const
Definition: metaact.hxx:498
const OUString & GetText() const
Definition: metaact.hxx:496
sal_Int32 GetIndex() const
Definition: metaact.hxx:497
TextAlign GetTextAlign() const
Definition: metaact.hxx:1412
sal_Int32 GetIndex() const
Definition: metaact.hxx:541
const KernArray & GetDXArray() const
Definition: metaact.hxx:543
sal_Int32 GetLen() const
Definition: metaact.hxx:542
const OUString & GetText() const
Definition: metaact.hxx:540
const Point & GetPoint() const
Definition: metaact.hxx:539
const Color & GetColor() const
Definition: metaact.hxx:1306
bool IsSetting() const
Definition: metaact.hxx:1334
const Color & GetColor() const
Definition: metaact.hxx:1331
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:620
const OUString & GetText() const
Definition: metaact.hxx:621
const Wallpaper & GetWallpaper() const
Definition: metaact.hxx:1114
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1113
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1580
void AddHatchActions(const tools::PolyPolygon &rPolyPoly, const Hatch &rHatch, GDIMetaFile &rMtf)
void SetMapMode()
Definition: map.cxx:597
bool GetFontCharMap(FontCharMapRef &rxFontCharMap) const
tools::Long GetTextArray(const OUString &rStr, KernArray *pDXAry, sal_Int32 nIndex=0, sal_Int32 nLen=-1, bool bCaret=false, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Definition: text.cxx:958
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:879
bool GetTextOutlines(PolyPolyVector &, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}) const
Definition: text.cxx:2439
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
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:96
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:634
Color aSrcLineColor
Definition: wmfwr.hxx:70
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:54
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:1879
sal_uLong nWrittenBitmaps
Definition: wmfwr.hxx:105
bool bHandleAllocated[MAXOBJECTHANDLES]
Definition: wmfwr.hxx:95
vcl::Font aDstFont
Definition: wmfwr.hxx:90
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:96
void UpdateHeader()
Definition: wmfwr.cxx:1657
void WriteHeader(bool bPlaceable)
Definition: wmfwr.cxx:1625
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:84
LineInfo aDstLineInfo
Definition: wmfwr.hxx:87
void WMFRecord_ExtTextOut(const Point &rPoint, std::u16string_view rString, KernArraySpan pDXAry)
Definition: wmfwr.cxx:548
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
Definition: wmfwr.cxx:1677
sal_uLong nWrittenActions
Definition: wmfwr.hxx:104
SvStream * pWMF
Definition: wmfwr.hxx:60
TextAlign eDstTextAlign
Definition: wmfwr.hxx:89
void WMFRecord_SetWindowOrg(const Point &rPoint)
Definition: wmfwr.cxx:766
sal_uLong nLastPercent
Definition: wmfwr.hxx:56
void MayCallback()
Definition: wmfwr.cxx:166
RasterOp eDstROP2
Definition: wmfwr.hxx:88
Color aDstFillColor
Definition: wmfwr.hxx:85
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:81
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:58
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
Definition: wmfwr.cxx:1803
Color aSrcTextColor
Definition: wmfwr.hxx:72
sal_uInt16 AllocHandle()
Definition: wmfwr.cxx:851
sal_uLong nNumberOfBitmaps
Definition: wmfwr.hxx:103
sal_uLong nMetafileHeaderPos
Definition: wmfwr.hxx:65
VclPtr< VirtualDevice > pVirDev
Definition: wmfwr.hxx:61
void SetLineAndFillAttr()
Definition: wmfwr.cxx:912
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:413
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, KernArraySpan pDXAry)
Definition: wmfwr.cxx:445
void CreateSelectDeleteFont(const vcl::Font &rFont)
Definition: wmfwr.cxx:884
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:78
vcl::Region aDstClipRegion
Definition: wmfwr.hxx:94
bool bEmbedEMF
Definition: wmfwr.hxx:108
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:86
sal_uLong nActBitmapPercent
Definition: wmfwr.hxx:106
void WriteSize(const Size &rSize)
Definition: wmfwr.cxx:233
sal_uLong nNumberOfActions
Definition: wmfwr.hxx:102
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 TrueExtTextOut(const Point &rPoint, std::u16string_view rString, const OString &rByteString, KernArraySpan pDXAry)
Definition: wmfwr.cxx:564
void WMFRecord_Polygon(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:620
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1827
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:66
void WritePointYX(const Point &rPoint)
Definition: wmfwr.cxx:221
vcl::Font aSrcFont
Definition: wmfwr.hxx:76
void WMFRecord_CreateBrushIndirect(const Color &rColor)
Definition: wmfwr.cxx:296
sal_uInt16 eDstHorTextAlign
Definition: wmfwr.hxx:92
Color aSrcFillColor
Definition: wmfwr.hxx:71
MapMode aTargetMapMode
Definition: wmfwr.hxx:62
void WMFRecord_SetTextColor(const Color &rColor)
Definition: wmfwr.cxx:754
TextAlign eSrcTextAlign
Definition: wmfwr.hxx:75
LineInfo aSrcLineInfo
Definition: wmfwr.hxx:73
MapMode aSrcMapMode
Definition: wmfwr.hxx:77
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:67
sal_uInt16 nDstBrushHandle
Definition: wmfwr.hxx:96
Size aTargetSize
Definition: wmfwr.hxx:63
RasterOp eSrcRasterOp
Definition: wmfwr.hxx:74
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
Definition: wmfwr.cxx:419
WMFWriterAttrStackMember * pAttrStack
Definition: wmfwr.hxx:79
void WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:699
const Color & GetColor() const
Definition: wall.hxx:71
sal_uInt32 count() const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
sal_uInt32 count() const
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:928
void SetFillColor(const Color &)
Definition: font/font.cxx:115
void SetColor(const Color &)
Definition: font/font.cxx:107
FontStrikeout GetStrikeout() const
Definition: font/font.cxx:946
FontItalic GetItalic()
Definition: font/font.cxx:927
const OUString & GetFamilyName() const
Definition: font/font.cxx:904
TextAlign GetAlignment() const
Definition: font/font.cxx:902
void SetCharSet(rtl_TextEncoding)
Definition: font/font.cxx:161
const Size & GetFontSize() const
Definition: font/font.cxx:907
const Color & GetColor() const
Definition: font/font.cxx:898
void SetAlignment(TextAlign)
Definition: font/font.cxx:131
FontPitch GetPitch()
Definition: font/font.cxx:924
FontWeight GetWeight()
Definition: font/font.cxx:925
FontLineStyle GetUnderline() const
Definition: font/font.cxx:944
rtl_TextEncoding GetCharSet() const
Definition: font/font.cxx:913
Degree10 GetOrientation() const
Definition: font/font.cxx:920
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:1725
sal_Int16 nValue
UNOTOOLS_DLLPUBLIC bool IsOpenSymbol(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:38
struct WMFWriterAttrStackMember * pSucc
Definition: wmfwr.hxx:33
vcl::Region aClipRegion
Definition: wmfwr.hxx:42
vcl::PushFlags nFlags
Definition: wmfwr.hxx:43
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:29