1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/filter/SvmWriter.hxx>
21 #include <vcl/TypeSerializer.hxx>
22 #include <vcl/dibtools.hxx>
24 #include <tools/vcompat.hxx>
26 #include <osl/thread.h>
28 SvmWriter::SvmWriter(SvStream
& rIStm
)
33 void SvmWriter::WriteColor(::Color aColor
)
35 mrStream
.WriteUInt32(static_cast<sal_uInt32
>(aColor
));
38 SvStream
& SvmWriter::Write(const GDIMetaFile
& rMetaFile
)
40 const SvStreamCompressFlags nStmCompressMode
= mrStream
.GetCompressMode();
41 SvStreamEndian nOldFormat
= mrStream
.GetEndian();
43 mrStream
.SetEndian(SvStreamEndian::LITTLE
);
44 mrStream
.WriteBytes("VCLMTF", 6);
47 VersionCompatWrite
aCompat(mrStream
, 1);
49 mrStream
.WriteUInt32(static_cast<sal_uInt32
>(nStmCompressMode
));
50 TypeSerializer
aSerializer(mrStream
);
51 aSerializer
.writeMapMode(rMetaFile
.GetPrefMapMode());
52 aSerializer
.writeSize(rMetaFile
.GetPrefSize());
53 mrStream
.WriteUInt32(rMetaFile
.GetActionSize());
54 } // VersionCompatWrite dtor writes stuff into the header
56 ImplMetaWriteData aWriteData
;
58 aWriteData
.meActualCharSet
= mrStream
.GetStreamCharSet();
60 MetaAction
* pAct
= const_cast<GDIMetaFile
&>(rMetaFile
).FirstAction();
63 MetaActionHandler(pAct
, &aWriteData
);
64 pAct
= const_cast<GDIMetaFile
&>(rMetaFile
).NextAction();
67 mrStream
.SetEndian(nOldFormat
);
72 BitmapChecksum
SvmWriter::GetChecksum(const GDIMetaFile
& rMetaFile
)
74 SvMemoryStream
aMemStm(65535, 65535);
75 ImplMetaWriteData aWriteData
;
78 BitmapChecksumOctetArray aBCOA
;
79 BitmapChecksum nCrc
= 0;
81 aWriteData
.meActualCharSet
= aMemStm
.GetStreamCharSet();
83 for (size_t i
= 0, nObjCount
= rMetaFile
.GetActionSize(); i
< nObjCount
; i
++)
85 MetaAction
* pAction
= rMetaFile
.GetAction(i
);
87 switch (pAction
->GetType())
89 case MetaActionType::BMP
:
91 MetaBmpAction
* pAct
= static_cast<MetaBmpAction
*>(pAction
);
93 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
94 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
96 BCToBCOA(pAct
->GetBitmap().GetChecksum(), aBCOA
);
97 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
99 Int32ToSVBT32(pAct
->GetPoint().X(), aBT32
);
100 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
102 Int32ToSVBT32(pAct
->GetPoint().Y(), aBT32
);
103 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
107 case MetaActionType::BMPSCALE
:
109 MetaBmpScaleAction
* pAct
= static_cast<MetaBmpScaleAction
*>(pAction
);
111 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
112 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
114 BCToBCOA(pAct
->GetBitmap().GetChecksum(), aBCOA
);
115 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
117 Int32ToSVBT32(pAct
->GetPoint().X(), aBT32
);
118 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
120 Int32ToSVBT32(pAct
->GetPoint().Y(), aBT32
);
121 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
123 Int32ToSVBT32(pAct
->GetSize().Width(), aBT32
);
124 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
126 Int32ToSVBT32(pAct
->GetSize().Height(), aBT32
);
127 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
131 case MetaActionType::BMPSCALEPART
:
133 MetaBmpScalePartAction
* pAct
= static_cast<MetaBmpScalePartAction
*>(pAction
);
135 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
136 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
138 BCToBCOA(pAct
->GetBitmap().GetChecksum(), aBCOA
);
139 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
141 Int32ToSVBT32(pAct
->GetDestPoint().X(), aBT32
);
142 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
144 Int32ToSVBT32(pAct
->GetDestPoint().Y(), aBT32
);
145 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
147 Int32ToSVBT32(pAct
->GetDestSize().Width(), aBT32
);
148 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
150 Int32ToSVBT32(pAct
->GetDestSize().Height(), aBT32
);
151 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
153 Int32ToSVBT32(pAct
->GetSrcPoint().X(), aBT32
);
154 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
156 Int32ToSVBT32(pAct
->GetSrcPoint().Y(), aBT32
);
157 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
159 Int32ToSVBT32(pAct
->GetSrcSize().Width(), aBT32
);
160 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
162 Int32ToSVBT32(pAct
->GetSrcSize().Height(), aBT32
);
163 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
167 case MetaActionType::BMPEX
:
169 MetaBmpExAction
* pAct
= static_cast<MetaBmpExAction
*>(pAction
);
171 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
172 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
174 BCToBCOA(pAct
->GetBitmapEx().GetChecksum(), aBCOA
);
175 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
177 Int32ToSVBT32(pAct
->GetPoint().X(), aBT32
);
178 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
180 Int32ToSVBT32(pAct
->GetPoint().Y(), aBT32
);
181 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
185 case MetaActionType::BMPEXSCALE
:
187 MetaBmpExScaleAction
* pAct
= static_cast<MetaBmpExScaleAction
*>(pAction
);
189 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
190 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
192 BCToBCOA(pAct
->GetBitmapEx().GetChecksum(), aBCOA
);
193 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
195 Int32ToSVBT32(pAct
->GetPoint().X(), aBT32
);
196 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
198 Int32ToSVBT32(pAct
->GetPoint().Y(), aBT32
);
199 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
201 Int32ToSVBT32(pAct
->GetSize().Width(), aBT32
);
202 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
204 Int32ToSVBT32(pAct
->GetSize().Height(), aBT32
);
205 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
209 case MetaActionType::BMPEXSCALEPART
:
211 MetaBmpExScalePartAction
* pAct
= static_cast<MetaBmpExScalePartAction
*>(pAction
);
213 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
214 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
216 BCToBCOA(pAct
->GetBitmapEx().GetChecksum(), aBCOA
);
217 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
219 Int32ToSVBT32(pAct
->GetDestPoint().X(), aBT32
);
220 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
222 Int32ToSVBT32(pAct
->GetDestPoint().Y(), aBT32
);
223 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
225 Int32ToSVBT32(pAct
->GetDestSize().Width(), aBT32
);
226 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
228 Int32ToSVBT32(pAct
->GetDestSize().Height(), aBT32
);
229 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
231 Int32ToSVBT32(pAct
->GetSrcPoint().X(), aBT32
);
232 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
234 Int32ToSVBT32(pAct
->GetSrcPoint().Y(), aBT32
);
235 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
237 Int32ToSVBT32(pAct
->GetSrcSize().Width(), aBT32
);
238 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
240 Int32ToSVBT32(pAct
->GetSrcSize().Height(), aBT32
);
241 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
245 case MetaActionType::MASK
:
247 MetaMaskAction
* pAct
= static_cast<MetaMaskAction
*>(pAction
);
249 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
250 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
252 BCToBCOA(pAct
->GetBitmap().GetChecksum(), aBCOA
);
253 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
255 UInt32ToSVBT32(sal_uInt32(pAct
->GetColor()), aBT32
);
256 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
258 Int32ToSVBT32(pAct
->GetPoint().X(), aBT32
);
259 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
261 Int32ToSVBT32(pAct
->GetPoint().Y(), aBT32
);
262 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
266 case MetaActionType::MASKSCALE
:
268 MetaMaskScaleAction
* pAct
= static_cast<MetaMaskScaleAction
*>(pAction
);
270 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
271 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
273 BCToBCOA(pAct
->GetBitmap().GetChecksum(), aBCOA
);
274 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
276 UInt32ToSVBT32(sal_uInt32(pAct
->GetColor()), aBT32
);
277 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
279 Int32ToSVBT32(pAct
->GetPoint().X(), aBT32
);
280 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
282 Int32ToSVBT32(pAct
->GetPoint().Y(), aBT32
);
283 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
285 Int32ToSVBT32(pAct
->GetSize().Width(), aBT32
);
286 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
288 Int32ToSVBT32(pAct
->GetSize().Height(), aBT32
);
289 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
293 case MetaActionType::MASKSCALEPART
:
295 MetaMaskScalePartAction
* pAct
= static_cast<MetaMaskScalePartAction
*>(pAction
);
297 ShortToSVBT16(static_cast<sal_uInt16
>(pAct
->GetType()), aBT16
);
298 nCrc
= rtl_crc32(nCrc
, aBT16
, 2);
300 BCToBCOA(pAct
->GetBitmap().GetChecksum(), aBCOA
);
301 nCrc
= rtl_crc32(nCrc
, aBCOA
, BITMAP_CHECKSUM_SIZE
);
303 UInt32ToSVBT32(sal_uInt32(pAct
->GetColor()), aBT32
);
304 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
306 Int32ToSVBT32(pAct
->GetDestPoint().X(), aBT32
);
307 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
309 Int32ToSVBT32(pAct
->GetDestPoint().Y(), aBT32
);
310 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
312 Int32ToSVBT32(pAct
->GetDestSize().Width(), aBT32
);
313 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
315 Int32ToSVBT32(pAct
->GetDestSize().Height(), aBT32
);
316 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
318 Int32ToSVBT32(pAct
->GetSrcPoint().X(), aBT32
);
319 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
321 Int32ToSVBT32(pAct
->GetSrcPoint().Y(), aBT32
);
322 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
324 Int32ToSVBT32(pAct
->GetSrcSize().Width(), aBT32
);
325 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
327 Int32ToSVBT32(pAct
->GetSrcSize().Height(), aBT32
);
328 nCrc
= rtl_crc32(nCrc
, aBT32
, 4);
332 case MetaActionType::EPS
:
334 MetaEPSAction
* pAct
= static_cast<MetaEPSAction
*>(pAction
);
335 nCrc
= rtl_crc32(nCrc
, pAct
->GetLink().GetData(), pAct
->GetLink().GetDataSize());
339 case MetaActionType::CLIPREGION
:
341 MetaClipRegionAction
& rAct
= static_cast<MetaClipRegionAction
&>(*pAction
);
342 const vcl::Region
& rRegion
= rAct
.GetRegion();
344 if (rRegion
.HasPolyPolygonOrB2DPolyPolygon())
346 // It has shown that this is a possible bottleneck for checksum calculation.
347 // In worst case a very expensive RegionHandle representation gets created.
348 // In this case it's cheaper to use the PolyPolygon
349 const basegfx::B2DPolyPolygon
aPolyPolygon(rRegion
.GetAsB2DPolyPolygon());
352 for (auto const& rPolygon
: aPolyPolygon
)
354 const sal_uInt32
nPointCount(rPolygon
.count());
355 const bool bControl(rPolygon
.areControlPointsUsed());
357 for (sal_uInt32
b(0); b
< nPointCount
; b
++)
359 const basegfx::B2DPoint
aPoint(rPolygon
.getB2DPoint(b
));
361 DoubleToSVBT64(aPoint
.getX(), aSVBT64
);
362 nCrc
= rtl_crc32(nCrc
, aSVBT64
, 8);
363 DoubleToSVBT64(aPoint
.getY(), aSVBT64
);
364 nCrc
= rtl_crc32(nCrc
, aSVBT64
, 8);
368 if (rPolygon
.isPrevControlPointUsed(b
))
370 const basegfx::B2DPoint
aCtrl(rPolygon
.getPrevControlPoint(b
));
372 DoubleToSVBT64(aCtrl
.getX(), aSVBT64
);
373 nCrc
= rtl_crc32(nCrc
, aSVBT64
, 8);
374 DoubleToSVBT64(aCtrl
.getY(), aSVBT64
);
375 nCrc
= rtl_crc32(nCrc
, aSVBT64
, 8);
378 if (rPolygon
.isNextControlPointUsed(b
))
380 const basegfx::B2DPoint
aCtrl(rPolygon
.getNextControlPoint(b
));
382 DoubleToSVBT64(aCtrl
.getX(), aSVBT64
);
383 nCrc
= rtl_crc32(nCrc
, aSVBT64
, 8);
384 DoubleToSVBT64(aCtrl
.getY(), aSVBT64
);
385 nCrc
= rtl_crc32(nCrc
, aSVBT64
, 8);
391 sal_uInt8 tmp
= static_cast<sal_uInt8
>(rAct
.IsClipping());
392 nCrc
= rtl_crc32(nCrc
, &tmp
, 1);
396 SvmWriter
aWriter(aMemStm
);
397 aWriter
.MetaActionHandler(pAction
, &aWriteData
);
398 nCrc
= rtl_crc32(nCrc
, aMemStm
.GetData(), aMemStm
.Tell());
406 SvmWriter
aWriter(aMemStm
);
407 aWriter
.MetaActionHandler(pAction
, &aWriteData
);
408 nCrc
= rtl_crc32(nCrc
, aMemStm
.GetData(), aMemStm
.Tell());
418 void SvmWriter::MetaActionHandler(MetaAction
* pAction
, ImplMetaWriteData
* pData
)
420 MetaActionType nType
= pAction
->GetType();
424 case MetaActionType::NONE
:
426 ActionHandler(pAction
);
430 case MetaActionType::PIXEL
:
432 auto* pMetaAction
= static_cast<MetaPixelAction
*>(pAction
);
433 PixelHandler(pMetaAction
);
437 case MetaActionType::POINT
:
439 auto pMetaAction
= static_cast<MetaPointAction
*>(pAction
);
440 PointHandler(pMetaAction
);
444 case MetaActionType::LINE
:
446 auto* pMetaAction
= static_cast<MetaLineAction
*>(pAction
);
447 LineHandler(pMetaAction
);
451 case MetaActionType::RECT
:
453 auto* pMetaAction
= static_cast<MetaRectAction
*>(pAction
);
454 RectHandler(pMetaAction
);
458 case MetaActionType::ROUNDRECT
:
460 auto* pMetaAction
= static_cast<MetaRoundRectAction
*>(pAction
);
461 RoundRectHandler(pMetaAction
);
465 case MetaActionType::ELLIPSE
:
467 auto* pMetaAction
= static_cast<MetaEllipseAction
*>(pAction
);
468 EllipseHandler(pMetaAction
);
472 case MetaActionType::ARC
:
474 auto* pMetaAction
= static_cast<MetaArcAction
*>(pAction
);
475 ArcHandler(pMetaAction
);
479 case MetaActionType::PIE
:
481 auto* pMetaAction
= static_cast<MetaPieAction
*>(pAction
);
482 PieHandler(pMetaAction
);
486 case MetaActionType::CHORD
:
488 auto* pMetaAction
= static_cast<MetaChordAction
*>(pAction
);
489 ChordHandler(pMetaAction
);
493 case MetaActionType::POLYLINE
:
495 auto* pMetaAction
= static_cast<MetaPolyLineAction
*>(pAction
);
496 PolyLineHandler(pMetaAction
);
500 case MetaActionType::POLYGON
:
502 auto* pMetaAction
= static_cast<MetaPolygonAction
*>(pAction
);
503 PolygonHandler(pMetaAction
);
507 case MetaActionType::POLYPOLYGON
:
509 auto* pMetaAction
= static_cast<MetaPolyPolygonAction
*>(pAction
);
510 PolyPolygonHandler(pMetaAction
);
514 case MetaActionType::TEXT
:
516 auto* pMetaAction
= static_cast<MetaTextAction
*>(pAction
);
517 TextHandler(pMetaAction
, pData
);
521 case MetaActionType::TEXTARRAY
:
523 auto* pMetaAction
= static_cast<MetaTextArrayAction
*>(pAction
);
524 TextArrayHandler(pMetaAction
, pData
);
528 case MetaActionType::STRETCHTEXT
:
530 auto* pMetaAction
= static_cast<MetaStretchTextAction
*>(pAction
);
531 StretchTextHandler(pMetaAction
, pData
);
535 case MetaActionType::TEXTRECT
:
537 auto* pMetaAction
= static_cast<MetaTextRectAction
*>(pAction
);
538 TextRectHandler(pMetaAction
, pData
);
542 case MetaActionType::TEXTLINE
:
544 auto* pMetaAction
= static_cast<MetaTextLineAction
*>(pAction
);
545 TextLineHandler(pMetaAction
);
549 case MetaActionType::BMP
:
551 auto* pMetaAction
= static_cast<MetaBmpAction
*>(pAction
);
552 BmpHandler(pMetaAction
);
556 case MetaActionType::BMPSCALE
:
558 auto* pMetaAction
= static_cast<MetaBmpScaleAction
*>(pAction
);
559 BmpScaleHandler(pMetaAction
);
563 case MetaActionType::BMPSCALEPART
:
565 auto* pMetaAction
= static_cast<MetaBmpScalePartAction
*>(pAction
);
566 BmpScalePartHandler(pMetaAction
);
570 case MetaActionType::BMPEX
:
572 auto* pMetaAction
= static_cast<MetaBmpExAction
*>(pAction
);
573 BmpExHandler(pMetaAction
);
577 case MetaActionType::BMPEXSCALE
:
579 auto* pMetaAction
= static_cast<MetaBmpExScaleAction
*>(pAction
);
580 BmpExScaleHandler(pMetaAction
);
584 case MetaActionType::BMPEXSCALEPART
:
586 auto* pMetaAction
= static_cast<MetaBmpExScalePartAction
*>(pAction
);
587 BmpExScalePartHandler(pMetaAction
);
591 case MetaActionType::MASK
:
593 auto* pMetaAction
= static_cast<MetaMaskAction
*>(pAction
);
594 MaskHandler(pMetaAction
);
598 case MetaActionType::MASKSCALE
:
600 auto* pMetaAction
= static_cast<MetaMaskScaleAction
*>(pAction
);
601 MaskScaleHandler(pMetaAction
);
605 case MetaActionType::MASKSCALEPART
:
607 auto* pMetaAction
= static_cast<MetaMaskScalePartAction
*>(pAction
);
608 MaskScalePartHandler(pMetaAction
);
612 case MetaActionType::GRADIENT
:
614 auto* pMetaAction
= static_cast<MetaGradientAction
*>(pAction
);
615 GradientHandler(pMetaAction
);
619 case MetaActionType::GRADIENTEX
:
621 auto* pMetaAction
= static_cast<MetaGradientExAction
*>(pAction
);
622 GradientExHandler(pMetaAction
);
626 case MetaActionType::HATCH
:
628 auto* pMetaAction
= static_cast<MetaHatchAction
*>(pAction
);
629 HatchHandler(pMetaAction
);
633 case MetaActionType::WALLPAPER
:
635 auto* pMetaAction
= static_cast<MetaWallpaperAction
*>(pAction
);
636 WallpaperHandler(pMetaAction
);
640 case MetaActionType::CLIPREGION
:
642 auto* pMetaAction
= static_cast<MetaClipRegionAction
*>(pAction
);
643 ClipRegionHandler(pMetaAction
);
647 case MetaActionType::ISECTRECTCLIPREGION
:
649 auto* pMetaAction
= static_cast<MetaISectRectClipRegionAction
*>(pAction
);
650 ISectRectClipRegionHandler(pMetaAction
);
654 case MetaActionType::ISECTREGIONCLIPREGION
:
656 auto* pMetaAction
= static_cast<MetaISectRegionClipRegionAction
*>(pAction
);
657 ISectRegionClipRegionHandler(pMetaAction
);
661 case MetaActionType::MOVECLIPREGION
:
663 auto* pMetaAction
= static_cast<MetaMoveClipRegionAction
*>(pAction
);
664 MoveClipRegionHandler(pMetaAction
);
668 case MetaActionType::LINECOLOR
:
670 auto* pMetaAction
= static_cast<MetaLineColorAction
*>(pAction
);
671 LineColorHandler(pMetaAction
);
675 case MetaActionType::FILLCOLOR
:
677 auto* pMetaAction
= static_cast<MetaFillColorAction
*>(pAction
);
678 FillColorHandler(pMetaAction
);
682 case MetaActionType::TEXTCOLOR
:
684 auto* pMetaAction
= static_cast<MetaTextColorAction
*>(pAction
);
685 TextColorHandler(pMetaAction
);
689 case MetaActionType::TEXTFILLCOLOR
:
691 auto* pMetaAction
= static_cast<MetaTextFillColorAction
*>(pAction
);
692 TextFillColorHandler(pMetaAction
);
696 case MetaActionType::TEXTLINECOLOR
:
698 auto* pMetaAction
= static_cast<MetaTextLineColorAction
*>(pAction
);
699 TextLineColorHandler(pMetaAction
);
703 case MetaActionType::OVERLINECOLOR
:
705 auto* pMetaAction
= static_cast<MetaOverlineColorAction
*>(pAction
);
706 OverlineColorHandler(pMetaAction
);
710 case MetaActionType::TEXTALIGN
:
712 auto* pMetaAction
= static_cast<MetaTextAlignAction
*>(pAction
);
713 TextAlignHandler(pMetaAction
);
717 case MetaActionType::MAPMODE
:
719 auto* pMetaAction
= static_cast<MetaMapModeAction
*>(pAction
);
720 MapModeHandler(pMetaAction
);
724 case MetaActionType::FONT
:
726 auto* pMetaAction
= static_cast<MetaFontAction
*>(pAction
);
727 FontHandler(pMetaAction
, pData
);
731 case MetaActionType::PUSH
:
733 auto* pMetaAction
= static_cast<MetaPushAction
*>(pAction
);
734 PushHandler(pMetaAction
);
738 case MetaActionType::POP
:
740 auto* pMetaAction
= static_cast<MetaPopAction
*>(pAction
);
741 PopHandler(pMetaAction
);
745 case MetaActionType::RASTEROP
:
747 auto* pMetaAction
= static_cast<MetaRasterOpAction
*>(pAction
);
748 RasterOpHandler(pMetaAction
);
752 case MetaActionType::Transparent
:
754 auto* pMetaAction
= static_cast<MetaTransparentAction
*>(pAction
);
755 TransparentHandler(pMetaAction
);
759 case MetaActionType::FLOATTRANSPARENT
:
761 auto* pMetaAction
= static_cast<MetaFloatTransparentAction
*>(pAction
);
762 FloatTransparentHandler(pMetaAction
);
766 case MetaActionType::EPS
:
768 auto* pMetaAction
= static_cast<MetaEPSAction
*>(pAction
);
769 EPSHandler(pMetaAction
);
773 case MetaActionType::REFPOINT
:
775 auto* pMetaAction
= static_cast<MetaRefPointAction
*>(pAction
);
776 RefPointHandler(pMetaAction
);
780 case MetaActionType::COMMENT
:
782 auto* pMetaAction
= static_cast<MetaCommentAction
*>(pAction
);
783 CommentHandler(pMetaAction
);
787 case MetaActionType::LAYOUTMODE
:
789 auto* pMetaAction
= static_cast<MetaLayoutModeAction
*>(pAction
);
790 LayoutModeHandler(pMetaAction
);
794 case MetaActionType::TEXTLANGUAGE
:
796 auto* pMetaAction
= static_cast<MetaTextLanguageAction
*>(pAction
);
797 TextLanguageHandler(pMetaAction
);
803 void SvmWriter::ActionHandler(const MetaAction
* pAction
)
805 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
808 void SvmWriter::PixelHandler(const MetaPixelAction
* pAction
)
810 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
811 VersionCompatWrite
aCompat(mrStream
, 1);
812 TypeSerializer
aSerializer(mrStream
);
813 aSerializer
.writePoint(pAction
->GetPoint());
814 WriteColor(pAction
->GetColor());
817 void SvmWriter::PointHandler(const MetaPointAction
* pAction
)
819 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
820 VersionCompatWrite
aCompat(mrStream
, 1);
821 TypeSerializer
aSerializer(mrStream
);
822 aSerializer
.writePoint(pAction
->GetPoint());
825 void SvmWriter::LineHandler(const MetaLineAction
* pAction
)
827 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
829 VersionCompatWrite
aCompat(mrStream
, 2);
832 TypeSerializer
aSerializer(mrStream
);
833 aSerializer
.writePoint(pAction
->GetStartPoint());
834 aSerializer
.writePoint(pAction
->GetEndPoint());
836 WriteLineInfo(mrStream
, pAction
->GetLineInfo());
839 void SvmWriter::RectHandler(const MetaRectAction
* pAction
)
841 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
843 VersionCompatWrite
aCompat(mrStream
, 1);
844 TypeSerializer
aSerializer(mrStream
);
845 aSerializer
.writeRectangle(pAction
->GetRect());
848 void SvmWriter::RoundRectHandler(const MetaRoundRectAction
* pAction
)
850 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
852 VersionCompatWrite
aCompat(mrStream
, 1);
853 TypeSerializer
aSerializer(mrStream
);
854 aSerializer
.writeRectangle(pAction
->GetRect());
855 mrStream
.WriteUInt32(pAction
->GetHorzRound()).WriteUInt32(pAction
->GetVertRound());
858 void SvmWriter::EllipseHandler(const MetaEllipseAction
* pAction
)
860 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
862 VersionCompatWrite
aCompat(mrStream
, 1);
863 TypeSerializer
aSerializer(mrStream
);
864 aSerializer
.writeRectangle(pAction
->GetRect());
867 void SvmWriter::ArcHandler(const MetaArcAction
* pAction
)
869 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
871 VersionCompatWrite
aCompat(mrStream
, 1);
872 TypeSerializer
aSerializer(mrStream
);
873 aSerializer
.writeRectangle(pAction
->GetRect());
874 aSerializer
.writePoint(pAction
->GetStartPoint());
875 aSerializer
.writePoint(pAction
->GetEndPoint());
878 void SvmWriter::PieHandler(const MetaPieAction
* pAction
)
880 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
882 VersionCompatWrite
aCompat(mrStream
, 1);
883 TypeSerializer
aSerializer(mrStream
);
884 aSerializer
.writeRectangle(pAction
->GetRect());
885 aSerializer
.writePoint(pAction
->GetStartPoint());
886 aSerializer
.writePoint(pAction
->GetEndPoint());
889 void SvmWriter::ChordHandler(const MetaChordAction
* pAction
)
891 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
893 VersionCompatWrite
aCompat(mrStream
, 1);
894 TypeSerializer
aSerializer(mrStream
);
895 aSerializer
.writeRectangle(pAction
->GetRect());
896 aSerializer
.writePoint(pAction
->GetStartPoint());
897 aSerializer
.writePoint(pAction
->GetEndPoint());
900 void SvmWriter::PolyLineHandler(const MetaPolyLineAction
* pAction
)
902 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
904 VersionCompatWrite
aCompat(mrStream
, 3);
906 tools::Polygon aSimplePoly
;
907 pAction
->GetPolygon().AdaptiveSubdivide(aSimplePoly
);
909 WritePolygon(mrStream
, aSimplePoly
); // Version 1
910 WriteLineInfo(mrStream
, pAction
->GetLineInfo()); // Version 2
912 bool bHasPolyFlags
= pAction
->GetPolygon().HasFlags(); // Version 3
913 mrStream
.WriteBool(bHasPolyFlags
);
915 pAction
->GetPolygon().Write(mrStream
);
918 void SvmWriter::PolygonHandler(const MetaPolygonAction
* pAction
)
920 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
922 VersionCompatWrite
aCompat(mrStream
, 2);
924 tools::Polygon aSimplePoly
; // Version 1
925 pAction
->GetPolygon().AdaptiveSubdivide(aSimplePoly
);
926 WritePolygon(mrStream
, aSimplePoly
);
928 bool bHasPolyFlags
= pAction
->GetPolygon().HasFlags(); // Version 2
929 mrStream
.WriteBool(bHasPolyFlags
);
931 pAction
->GetPolygon().Write(mrStream
);
934 void SvmWriter::PolyPolygonHandler(const MetaPolyPolygonAction
* pAction
)
936 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
938 VersionCompatWrite
aCompat(mrStream
, 2);
940 sal_uInt16 nNumberOfComplexPolygons
= 0;
941 sal_uInt16 i
, nPolyCount
= pAction
->GetPolyPolygon().Count();
943 tools::Polygon aSimplePoly
; // Version 1
944 mrStream
.WriteUInt16(nPolyCount
);
945 for (i
= 0; i
< nPolyCount
; i
++)
947 const tools::Polygon
& rPoly
= pAction
->GetPolyPolygon().GetObject(i
);
948 if (rPoly
.HasFlags())
949 nNumberOfComplexPolygons
++;
950 rPoly
.AdaptiveSubdivide(aSimplePoly
);
951 WritePolygon(mrStream
, aSimplePoly
);
954 mrStream
.WriteUInt16(nNumberOfComplexPolygons
); // Version 2
955 for (i
= 0; nNumberOfComplexPolygons
&& (i
< nPolyCount
); i
++)
957 const tools::Polygon
& rPoly
= pAction
->GetPolyPolygon().GetObject(i
);
958 if (rPoly
.HasFlags())
960 mrStream
.WriteUInt16(i
);
961 rPoly
.Write(mrStream
);
963 nNumberOfComplexPolygons
--;
968 void SvmWriter::TextHandler(const MetaTextAction
* pAction
, const ImplMetaWriteData
* pData
)
970 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
972 VersionCompatWrite
aCompat(mrStream
, 2);
973 TypeSerializer
aSerializer(mrStream
);
974 aSerializer
.writePoint(pAction
->GetPoint());
975 mrStream
.WriteUniOrByteString(pAction
->GetText(), pData
->meActualCharSet
);
976 mrStream
.WriteUInt16(pAction
->GetIndex());
977 mrStream
.WriteUInt16(pAction
->GetLen());
979 write_uInt16_lenPrefixed_uInt16s_FromOUString(mrStream
, pAction
->GetText()); // version 2
982 void SvmWriter::TextArrayHandler(const MetaTextArrayAction
* pAction
, const ImplMetaWriteData
* pData
)
984 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
986 const KernArray
& rDXArray
= pAction
->GetDXArray();
988 const sal_Int32 nAryLen
= !rDXArray
.empty() ? pAction
->GetLen() : 0;
990 VersionCompatWrite
aCompat(mrStream
, 4);
991 TypeSerializer
aSerializer(mrStream
);
992 aSerializer
.writePoint(pAction
->GetPoint());
993 mrStream
.WriteUniOrByteString(pAction
->GetText(), pData
->meActualCharSet
);
994 mrStream
.WriteUInt16(pAction
->GetIndex());
995 mrStream
.WriteUInt16(pAction
->GetLen());
996 mrStream
.WriteInt32(nAryLen
);
998 for (sal_Int32 i
= 0; i
< nAryLen
; ++i
)
999 mrStream
.WriteInt32(rDXArray
[i
]);
1001 write_uInt16_lenPrefixed_uInt16s_FromOUString(mrStream
, pAction
->GetText()); // version 2
1004 const auto& rKashidaArray
= pAction
->GetKashidaArray();
1005 mrStream
.WriteUInt32(rKashidaArray
.size());
1006 for (const auto& val
: rKashidaArray
)
1007 mrStream
.WriteUChar(val
);
1010 bool bHasLayoutContext
= (pAction
->GetLayoutContextIndex() >= 0);
1011 mrStream
.WriteBool(bHasLayoutContext
);
1012 if (bHasLayoutContext
)
1014 mrStream
.WriteUInt16(pAction
->GetLayoutContextIndex());
1015 mrStream
.WriteUInt16(pAction
->GetLayoutContextLen());
1019 void SvmWriter::StretchTextHandler(const MetaStretchTextAction
* pAction
,
1020 const ImplMetaWriteData
* pData
)
1022 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1024 VersionCompatWrite
aCompat(mrStream
, 2);
1025 TypeSerializer
aSerializer(mrStream
);
1026 aSerializer
.writePoint(pAction
->GetPoint());
1027 mrStream
.WriteUniOrByteString(pAction
->GetText(), pData
->meActualCharSet
);
1028 mrStream
.WriteUInt32(pAction
->GetWidth());
1029 mrStream
.WriteUInt16(pAction
->GetIndex());
1030 mrStream
.WriteUInt16(pAction
->GetLen());
1032 write_uInt16_lenPrefixed_uInt16s_FromOUString(mrStream
, pAction
->GetText()); // version 2
1035 void SvmWriter::TextRectHandler(const MetaTextRectAction
* pAction
, const ImplMetaWriteData
* pData
)
1037 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1039 VersionCompatWrite
aCompat(mrStream
, 2);
1040 TypeSerializer
aSerializer(mrStream
);
1041 aSerializer
.writeRectangle(pAction
->GetRect());
1042 mrStream
.WriteUniOrByteString(pAction
->GetText(), pData
->meActualCharSet
);
1043 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetStyle()));
1045 write_uInt16_lenPrefixed_uInt16s_FromOUString(mrStream
, pAction
->GetText()); // version 2
1048 void SvmWriter::TextLineHandler(const MetaTextLineAction
* pAction
)
1050 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1052 VersionCompatWrite
aCompat(mrStream
, 2);
1054 TypeSerializer
aSerializer(mrStream
);
1055 aSerializer
.writePoint(pAction
->GetStartPoint());
1057 mrStream
.WriteInt32(pAction
->GetWidth());
1058 mrStream
.WriteUInt32(pAction
->GetStrikeout());
1059 mrStream
.WriteUInt32(pAction
->GetUnderline());
1061 mrStream
.WriteUInt32(pAction
->GetOverline());
1064 void SvmWriter::BmpHandler(const MetaBmpAction
* pAction
)
1066 if (!pAction
->GetBitmap().IsEmpty())
1068 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1069 VersionCompatWrite
aCompat(mrStream
, 1);
1070 WriteDIB(pAction
->GetBitmap(), mrStream
, false, true);
1071 TypeSerializer
aSerializer(mrStream
);
1072 aSerializer
.writePoint(pAction
->GetPoint());
1076 void SvmWriter::BmpScaleHandler(const MetaBmpScaleAction
* pAction
)
1078 if (!pAction
->GetBitmap().IsEmpty())
1080 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1081 VersionCompatWrite
aCompat(mrStream
, 1);
1082 WriteDIB(pAction
->GetBitmap(), mrStream
, false, true);
1083 TypeSerializer
aSerializer(mrStream
);
1084 aSerializer
.writePoint(pAction
->GetPoint());
1085 aSerializer
.writeSize(pAction
->GetSize());
1089 void SvmWriter::BmpScalePartHandler(const MetaBmpScalePartAction
* pAction
)
1091 if (!pAction
->GetBitmap().IsEmpty())
1093 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1094 VersionCompatWrite
aCompat(mrStream
, 1);
1095 WriteDIB(pAction
->GetBitmap(), mrStream
, false, true);
1096 TypeSerializer
aSerializer(mrStream
);
1097 aSerializer
.writePoint(pAction
->GetDestPoint());
1098 aSerializer
.writeSize(pAction
->GetDestSize());
1099 aSerializer
.writePoint(pAction
->GetSrcPoint());
1100 aSerializer
.writeSize(pAction
->GetSrcSize());
1104 void SvmWriter::BmpExHandler(const MetaBmpExAction
* pAction
)
1106 if (!pAction
->GetBitmapEx().GetBitmap().IsEmpty())
1108 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1109 VersionCompatWrite
aCompat(mrStream
, 1);
1110 WriteDIBBitmapEx(pAction
->GetBitmapEx(), mrStream
);
1111 TypeSerializer
aSerializer(mrStream
);
1112 aSerializer
.writePoint(pAction
->GetPoint());
1116 void SvmWriter::BmpExScaleHandler(const MetaBmpExScaleAction
* pAction
)
1118 if (!pAction
->GetBitmapEx().GetBitmap().IsEmpty())
1120 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1121 VersionCompatWrite
aCompat(mrStream
, 1);
1122 WriteDIBBitmapEx(pAction
->GetBitmapEx(), mrStream
);
1123 TypeSerializer
aSerializer(mrStream
);
1124 aSerializer
.writePoint(pAction
->GetPoint());
1125 aSerializer
.writeSize(pAction
->GetSize());
1129 void SvmWriter::BmpExScalePartHandler(const MetaBmpExScalePartAction
* pAction
)
1131 if (!pAction
->GetBitmapEx().GetBitmap().IsEmpty())
1133 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1134 VersionCompatWrite
aCompat(mrStream
, 1);
1135 WriteDIBBitmapEx(pAction
->GetBitmapEx(), mrStream
);
1136 TypeSerializer
aSerializer(mrStream
);
1137 aSerializer
.writePoint(pAction
->GetDestPoint());
1138 aSerializer
.writeSize(pAction
->GetDestSize());
1139 aSerializer
.writePoint(pAction
->GetSrcPoint());
1140 aSerializer
.writeSize(pAction
->GetSrcSize());
1144 void SvmWriter::MaskHandler(const MetaMaskAction
* pAction
)
1146 if (!pAction
->GetBitmap().IsEmpty())
1148 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1149 VersionCompatWrite
aCompat(mrStream
, 1);
1150 WriteDIB(pAction
->GetBitmap(), mrStream
, false, true);
1151 TypeSerializer
aSerializer(mrStream
);
1152 aSerializer
.writePoint(pAction
->GetPoint());
1156 void SvmWriter::MaskScaleHandler(const MetaMaskScaleAction
* pAction
)
1158 if (!pAction
->GetBitmap().IsEmpty())
1160 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1161 VersionCompatWrite
aCompat(mrStream
, 1);
1162 WriteDIB(pAction
->GetBitmap(), mrStream
, false, true);
1163 TypeSerializer
aSerializer(mrStream
);
1164 aSerializer
.writePoint(pAction
->GetPoint());
1165 aSerializer
.writeSize(pAction
->GetSize());
1169 void SvmWriter::MaskScalePartHandler(const MetaMaskScalePartAction
* pAction
)
1171 if (!pAction
->GetBitmap().IsEmpty())
1173 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1174 VersionCompatWrite
aCompat(mrStream
, 1);
1175 WriteDIB(pAction
->GetBitmap(), mrStream
, false, true);
1176 WriteColor(pAction
->GetColor());
1177 TypeSerializer
aSerializer(mrStream
);
1178 aSerializer
.writePoint(pAction
->GetDestPoint());
1179 aSerializer
.writeSize(pAction
->GetDestSize());
1180 aSerializer
.writePoint(pAction
->GetSrcPoint());
1181 aSerializer
.writeSize(pAction
->GetSrcSize());
1185 void SvmWriter::GradientHandler(const MetaGradientAction
* pAction
)
1187 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1188 VersionCompatWrite
aCompat(mrStream
, 1);
1189 TypeSerializer
aSerializer(mrStream
);
1190 aSerializer
.writeRectangle(pAction
->GetRect());
1191 aSerializer
.writeGradient(pAction
->GetGradient());
1194 void SvmWriter::GradientExHandler(const MetaGradientExAction
* pAction
)
1196 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1197 VersionCompatWrite
aCompat(mrStream
, 1);
1199 // #i105373# see comment at MetaTransparentAction::Write
1200 tools::PolyPolygon aNoCurvePolyPolygon
;
1201 pAction
->GetPolyPolygon().AdaptiveSubdivide(aNoCurvePolyPolygon
);
1203 WritePolyPolygon(mrStream
, aNoCurvePolyPolygon
);
1204 TypeSerializer
aSerializer(mrStream
);
1205 aSerializer
.writeGradient(pAction
->GetGradient());
1208 void SvmWriter::HatchHandler(const MetaHatchAction
* pAction
)
1210 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1211 VersionCompatWrite
aCompat(mrStream
, 1);
1213 // #i105373# see comment at MetaTransparentAction::Write
1214 tools::PolyPolygon aNoCurvePolyPolygon
;
1215 pAction
->GetPolyPolygon().AdaptiveSubdivide(aNoCurvePolyPolygon
);
1217 WritePolyPolygon(mrStream
, aNoCurvePolyPolygon
);
1218 WriteHatch(mrStream
, pAction
->GetHatch());
1221 void SvmWriter::WallpaperHandler(const MetaWallpaperAction
* pAction
)
1223 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1224 VersionCompatWrite
aCompat(mrStream
, 1);
1226 WriteWallpaper(mrStream
, pAction
->GetWallpaper());
1229 void SvmWriter::ClipRegionHandler(const MetaClipRegionAction
* pAction
)
1231 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1232 VersionCompatWrite
aCompat(mrStream
, 1);
1233 WriteRegion(mrStream
, pAction
->GetRegion());
1234 mrStream
.WriteBool(pAction
->IsClipping());
1237 void SvmWriter::ISectRectClipRegionHandler(const MetaISectRectClipRegionAction
* pAction
)
1239 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1240 VersionCompatWrite
aCompat(mrStream
, 1);
1241 TypeSerializer
aSerializer(mrStream
);
1242 aSerializer
.writeRectangle(pAction
->GetRect());
1245 void SvmWriter::ISectRegionClipRegionHandler(const MetaISectRegionClipRegionAction
* pAction
)
1247 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1248 VersionCompatWrite
aCompat(mrStream
, 1);
1249 WriteRegion(mrStream
, pAction
->GetRegion());
1252 void SvmWriter::MoveClipRegionHandler(const MetaMoveClipRegionAction
* pAction
)
1254 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1255 VersionCompatWrite
aCompat(mrStream
, 1);
1256 mrStream
.WriteInt32(pAction
->GetHorzMove()).WriteInt32(pAction
->GetVertMove());
1259 void SvmWriter::LineColorHandler(const MetaLineColorAction
* pAction
)
1261 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1262 VersionCompatWrite
aCompat(mrStream
, 1);
1263 WriteColor(pAction
->GetColor());
1264 mrStream
.WriteBool(pAction
->IsSetting());
1267 void SvmWriter::FillColorHandler(const MetaFillColorAction
* pAction
)
1269 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1270 VersionCompatWrite
aCompat(mrStream
, 1);
1271 WriteColor(pAction
->GetColor());
1272 mrStream
.WriteBool(pAction
->IsSetting());
1275 void SvmWriter::TextColorHandler(const MetaTextColorAction
* pAction
)
1277 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1278 VersionCompatWrite
aCompat(mrStream
, 1);
1279 WriteColor(pAction
->GetColor());
1282 void SvmWriter::TextFillColorHandler(const MetaTextFillColorAction
* pAction
)
1284 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1285 VersionCompatWrite
aCompat(mrStream
, 1);
1286 WriteColor(pAction
->GetColor());
1287 mrStream
.WriteBool(pAction
->IsSetting());
1290 void SvmWriter::TextLineColorHandler(const MetaTextLineColorAction
* pAction
)
1292 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1293 VersionCompatWrite
aCompat(mrStream
, 1);
1294 WriteColor(pAction
->GetColor());
1295 mrStream
.WriteBool(pAction
->IsSetting());
1298 void SvmWriter::OverlineColorHandler(const MetaOverlineColorAction
* pAction
)
1300 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1301 VersionCompatWrite
aCompat(mrStream
, 1);
1302 WriteColor(pAction
->GetColor());
1303 mrStream
.WriteBool(pAction
->IsSetting());
1306 void SvmWriter::TextAlignHandler(const MetaTextAlignAction
* pAction
)
1308 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1309 VersionCompatWrite
aCompat(mrStream
, 1);
1310 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetTextAlign()));
1313 void SvmWriter::MapModeHandler(const MetaMapModeAction
* pAction
)
1315 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1316 VersionCompatWrite
aCompat(mrStream
, 1);
1317 TypeSerializer
aSerializer(mrStream
);
1318 aSerializer
.writeMapMode(pAction
->GetMapMode());
1321 void SvmWriter::FontHandler(const MetaFontAction
* pAction
, ImplMetaWriteData
* pData
)
1323 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1324 VersionCompatWrite
aCompat(mrStream
, 1);
1325 WriteFont(mrStream
, pAction
->GetFont());
1326 pData
->meActualCharSet
= pAction
->GetFont().GetCharSet();
1327 if (pData
->meActualCharSet
== RTL_TEXTENCODING_DONTKNOW
)
1328 pData
->meActualCharSet
= osl_getThreadTextEncoding();
1331 void SvmWriter::PushHandler(const MetaPushAction
* pAction
)
1333 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1334 VersionCompatWrite
aCompat(mrStream
, 1);
1335 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetFlags()));
1338 void SvmWriter::PopHandler(const MetaPopAction
* pAction
)
1340 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1341 VersionCompatWrite
aCompat(mrStream
, 1);
1344 void SvmWriter::RasterOpHandler(const MetaRasterOpAction
* pAction
)
1346 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1347 VersionCompatWrite
aCompat(mrStream
, 1);
1348 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetRasterOp()));
1351 void SvmWriter::TransparentHandler(const MetaTransparentAction
* pAction
)
1353 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1354 VersionCompatWrite
aCompat(mrStream
, 1);
1356 // #i105373# The tools::PolyPolygon in this action may be a curve; this
1357 // was ignored until now what is an error. To make older office
1358 // versions work with MetaFiles, i opt for applying AdaptiveSubdivide
1359 // to the PolyPolygon.
1360 // The alternative would be to really write the curve information
1361 // like in MetaPolyPolygonAction::Write (where someone extended it
1362 // correctly, but not here :-( ).
1363 // The golden solution would be to combine both, but i think it's
1364 // not necessary; a good subdivision will be sufficient.
1365 tools::PolyPolygon aNoCurvePolyPolygon
;
1366 pAction
->GetPolyPolygon().AdaptiveSubdivide(aNoCurvePolyPolygon
);
1368 WritePolyPolygon(mrStream
, aNoCurvePolyPolygon
);
1369 mrStream
.WriteUInt16(pAction
->GetTransparence());
1372 void SvmWriter::FloatTransparentHandler(const MetaFloatTransparentAction
* pAction
)
1374 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1376 // tdf#155479 prep vars for MCGR
1377 const basegfx::BColorStops
* pSVGTransparencyColorStops(pAction
->getSVGTransparencyColorStops());
1378 const bool bSVG(nullptr != pSVGTransparencyColorStops
);
1380 VersionCompatWrite
aCompat(mrStream
, bSVG
? 2 : 1);
1382 SvmWriter
aWriter(mrStream
);
1383 const GDIMetaFile
& aMtf
= pAction
->GetGDIMetaFile();
1384 aWriter
.Write(aMtf
);
1385 TypeSerializer
aSerializer(mrStream
);
1386 aSerializer
.writePoint(pAction
->GetPoint());
1387 aSerializer
.writeSize(pAction
->GetSize());
1388 aSerializer
.writeGradient(pAction
->GetGradient());
1390 // tdf#155479 add support for MCGR and SVG export
1393 sal_uInt16
nTmp(sal::static_int_cast
<sal_uInt16
>(pSVGTransparencyColorStops
->size()));
1394 mrStream
.WriteUInt16(nTmp
);
1396 for (auto const& rCand
: *pSVGTransparencyColorStops
)
1398 mrStream
.WriteDouble(rCand
.getStopOffset());
1399 const basegfx::BColor
& rColor(rCand
.getStopColor());
1400 mrStream
.WriteDouble(rColor
.getRed());
1401 mrStream
.WriteDouble(rColor
.getGreen());
1402 mrStream
.WriteDouble(rColor
.getBlue());
1407 void SvmWriter::EPSHandler(const MetaEPSAction
* pAction
)
1409 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1410 VersionCompatWrite
aCompat(mrStream
, 1);
1412 TypeSerializer
aSerializer(mrStream
);
1413 aSerializer
.writeGfxLink(pAction
->GetLink());
1414 aSerializer
.writePoint(pAction
->GetPoint());
1415 aSerializer
.writeSize(pAction
->GetSize());
1417 SvmWriter
aWriter(mrStream
);
1418 const GDIMetaFile
& aMtf
= pAction
->GetSubstitute();
1419 aWriter
.Write(aMtf
);
1422 void SvmWriter::RefPointHandler(const MetaRefPointAction
* pAction
)
1424 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1425 VersionCompatWrite
aCompat(mrStream
, 1);
1427 TypeSerializer
aSerializer(mrStream
);
1428 aSerializer
.writePoint(pAction
->GetRefPoint());
1429 mrStream
.WriteBool(pAction
->IsSetting());
1432 void SvmWriter::CommentHandler(const MetaCommentAction
* pAction
)
1434 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1435 VersionCompatWrite
aCompat(mrStream
, 1);
1436 write_uInt16_lenPrefixed_uInt8s_FromOString(mrStream
, pAction
->GetComment());
1437 mrStream
.WriteInt32(pAction
->GetValue()).WriteUInt32(pAction
->GetDataSize());
1439 if (pAction
->GetDataSize())
1440 mrStream
.WriteBytes(pAction
->GetData(), pAction
->GetDataSize());
1443 void SvmWriter::LayoutModeHandler(const MetaLayoutModeAction
* pAction
)
1445 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1446 VersionCompatWrite
aCompat(mrStream
, 1);
1447 mrStream
.WriteUInt32(static_cast<sal_uInt32
>(pAction
->GetLayoutMode()));
1450 void SvmWriter::TextLanguageHandler(const MetaTextLanguageAction
* pAction
)
1452 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetType()));
1453 VersionCompatWrite
aCompat(mrStream
, 1);
1454 mrStream
.WriteUInt16(static_cast<sal_uInt16
>(pAction
->GetTextLanguage()));
1456 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */