LibreOffice Module vcl (master) 1
SvmReader.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/log.hxx>
21#include <osl/thread.h>
22#include <tools/stream.hxx>
23#include <tools/vcompat.hxx>
25
29#include <vcl/dibtools.hxx>
30#include <vcl/gdimtf.hxx>
31#include <vcl/metaact.hxx>
32
33#include "SvmConverter.hxx"
34
35namespace
36{
37class DepthGuard
38{
39private:
41 rtl_TextEncoding m_eOrigCharSet;
42
43public:
44 DepthGuard(ImplMetaReadData& rData, SvStream const& rIStm)
45 : m_rData(rData)
46 , m_eOrigCharSet(m_rData.meActualCharSet)
47 {
48 ++m_rData.mnParseDepth;
49 m_rData.meActualCharSet = rIStm.GetStreamCharSet();
50 }
51 bool TooDeep() const { return m_rData.mnParseDepth > 1024; }
53 {
54 --m_rData.mnParseDepth;
55 m_rData.meActualCharSet = m_eOrigCharSet;
56 }
57};
58}
59
61 : mrStream(rIStm)
62{
63}
64
66{
67 if (mrStream.GetError())
68 {
69 SAL_WARN("vcl.gdi", "Stream error: " << mrStream.GetError());
70 return mrStream;
71 }
72
73 sal_uInt64 nStmPos = mrStream.Tell();
74 SvStreamEndian nOldFormat = mrStream.GetEndian();
75
76 mrStream.SetEndian(SvStreamEndian::LITTLE);
77
78 try
79 {
80 char aId[7];
81 aId[0] = 0;
82 aId[6] = 0;
83 mrStream.ReadBytes(aId, 6);
84 if (mrStream.good() && !strcmp(aId, "VCLMTF"))
85 {
86 // new format
87 sal_uInt32 nStmCompressMode = 0;
88 sal_uInt32 nCount = 0;
89 std::unique_ptr<VersionCompatRead> pCompat(new VersionCompatRead(mrStream));
90
91 mrStream.ReadUInt32(nStmCompressMode);
92 TypeSerializer aSerializer(mrStream);
93 MapMode aMapMode;
94 aSerializer.readMapMode(aMapMode);
95 rMetaFile.SetPrefMapMode(aMapMode);
96 Size aSize;
97 aSerializer.readSize(aSize);
98 rMetaFile.SetPrefSize(aSize);
100
101 pCompat.reset(); // destructor writes stuff into the header
102
103 std::unique_ptr<ImplMetaReadData> xReadData;
104 if (!pData)
105 {
106 xReadData.reset(new ImplMetaReadData);
107 pData = xReadData.get();
108 }
109 DepthGuard aDepthGuard(*pData, mrStream);
110
111 if (aDepthGuard.TooDeep())
112 throw std::runtime_error("too much recursion");
113
114 for (sal_uInt32 nAction = 0; (nAction < nCount) && !mrStream.eof(); nAction++)
115 {
117 if (pAction)
118 {
119 if (pAction->GetType() == MetaActionType::COMMENT)
120 {
121 MetaCommentAction* pCommentAct
122 = static_cast<MetaCommentAction*>(pAction.get());
123
124 if (pCommentAct->GetComment() == "EMF_PLUS")
125 rMetaFile.UseCanvas(true);
126 }
127 rMetaFile.AddAction(pAction);
128 }
129 }
130 }
131 else
132 {
133 mrStream.Seek(nStmPos);
134 SVMConverter(mrStream, rMetaFile);
135 }
136 }
137 catch (...)
138 {
139 SAL_WARN("vcl", "GDIMetaFile exception during load");
141 };
142
143 // check for errors
144 if (mrStream.GetError())
145 {
146 rMetaFile.Clear();
147 mrStream.Seek(nStmPos);
148 }
149
150 mrStream.SetEndian(nOldFormat);
151 return mrStream;
152}
153
155{
157 sal_uInt16 nTmp = 0;
158 mrStream.ReadUInt16(nTmp);
159 MetaActionType nType = static_cast<MetaActionType>(nTmp);
160
161 switch (nType)
162 {
164 return DefaultHandler();
166 return PixelHandler();
168 return PointHandler();
170 return LineHandler();
172 return RectHandler();
174 return RoundRectHandler();
176 return EllipseHandler();
178 return ArcHandler();
180 return PieHandler();
182 return ChordHandler();
184 return PolyLineHandler();
186 return PolygonHandler();
188 return PolyPolygonHandler();
190 return TextHandler(pData);
192 return TextArrayHandler(pData);
196 return TextRectHandler(pData);
198 return TextLineHandler();
200 return BmpHandler();
202 return BmpScaleHandler();
204 return BmpScalePartHandler();
206 return BmpExHandler();
208 return BmpExScaleHandler();
210 return BmpExScalePartHandler();
212 return MaskHandler();
214 return MaskScaleHandler();
216 return MaskScalePartHandler();
218 return GradientHandler();
220 return GradientExHandler();
222 return HatchHandler();
224 return WallpaperHandler();
226 return ClipRegionHandler();
232 return MoveClipRegionHandler();
234 return LineColorHandler();
236 return FillColorHandler();
238 return TextColorHandler();
240 return TextFillColorHandler();
242 return TextLineColorHandler();
244 return OverlineColorHandler();
246 return TextAlignHandler();
248 return MapModeHandler();
250 return FontHandler(pData);
252 return PushHandler();
254 return PopHandler();
256 return RasterOpHandler();
258 return TransparentHandler();
262 return EPSHandler();
264 return RefPointHandler();
266 return CommentHandler();
268 return LayoutModeHandler();
270 return TextLanguageHandler();
271
272 default:
273 {
275 }
276 break;
277 }
278
279 return pAction;
280}
281
283{
284 sal_uInt32 nTmp(0);
285 mrStream.ReadUInt32(nTmp);
286 rColor = ::Color(ColorTransparency, nTmp);
287}
288
290{
292
294 Color aColor;
295 ReadColor(aColor);
296 bool aBool(false);
298
299 pAction->SetSetting(aBool);
300 pAction->SetColor(aColor);
301
302 return pAction;
303}
304
306{
308
310
311 Color aColor;
312 ReadColor(aColor);
313 bool aBool(false);
315
316 pAction->SetColor(aColor);
317 pAction->SetSetting(aBool);
318
319 return pAction;
320}
321
323{
325
327 TypeSerializer aSerializer(mrStream);
328
329 tools::Rectangle aRectangle;
330 aSerializer.readRectangle(aRectangle);
331 pAction->SetRect(aRectangle);
332
333 return pAction;
334}
335
337{
339
341 TypeSerializer aSerializer(mrStream);
342
343 Point aPoint;
344 aSerializer.readPoint(aPoint);
345 pAction->SetPoint(aPoint);
346
347 return pAction;
348}
349
351{
353
355 TypeSerializer aSerializer(mrStream);
356
357 Point aPoint;
358 aSerializer.readPoint(aPoint);
359 Color aColor;
360 ReadColor(aColor);
361
362 pAction->SetPoint(aPoint);
363 pAction->SetColor(aColor);
364
365 return pAction;
366}
367
369{
371
373
374 // Version 1
375 TypeSerializer aSerializer(mrStream);
376 Point aPoint;
377 Point aEndPoint;
378 aSerializer.readPoint(aPoint);
379 aSerializer.readPoint(aEndPoint);
380
381 pAction->SetStartPoint(aPoint);
382 pAction->SetEndPoint(aEndPoint);
383
384 // Version 2
385 if (aCompat.GetVersion() >= 2)
386 {
387 LineInfo aLineInfo;
388 ReadLineInfo(mrStream, aLineInfo);
389 pAction->SetLineInfo(aLineInfo);
390 }
391
392 return pAction;
393}
394
396{
398
400 TypeSerializer aSerializer(mrStream);
401
402 tools::Rectangle aRectangle;
403 aSerializer.readRectangle(aRectangle);
404 sal_uInt32 HorzRound(0);
405 sal_uInt32 VertRound(0);
406 mrStream.ReadUInt32(HorzRound).ReadUInt32(VertRound);
407
408 pAction->SetRect(aRectangle);
409 pAction->SetHorzRound(HorzRound);
410 pAction->SetVertRound(VertRound);
411
412 return pAction;
413}
414
416{
418
420 TypeSerializer aSerializer(mrStream);
421
422 tools::Rectangle aRectangle;
423 aSerializer.readRectangle(aRectangle);
424
425 pAction->SetRect(aRectangle);
426
427 return pAction;
428}
429
431{
433
435 TypeSerializer aSerializer(mrStream);
436
437 tools::Rectangle aRectangle;
438 aSerializer.readRectangle(aRectangle);
439 Point aPoint;
440 aSerializer.readPoint(aPoint);
441 Point aEndPoint;
442 aSerializer.readPoint(aEndPoint);
443
444 pAction->SetRect(aRectangle);
445 pAction->SetStartPoint(aPoint);
446 pAction->SetEndPoint(aEndPoint);
447
448 return pAction;
449}
450
452{
454
456 TypeSerializer aSerializer(mrStream);
457
458 tools::Rectangle aRectangle;
459 aSerializer.readRectangle(aRectangle);
460 Point aPoint;
461 aSerializer.readPoint(aPoint);
462 Point aEndPoint;
463 aSerializer.readPoint(aEndPoint);
464
465 pAction->SetRect(aRectangle);
466 pAction->SetStartPoint(aPoint);
467 pAction->SetEndPoint(aEndPoint);
468
469 return pAction;
470}
471
473{
475
477 TypeSerializer aSerializer(mrStream);
478
479 tools::Rectangle aRectangle;
480 aSerializer.readRectangle(aRectangle);
481 Point aPoint;
482 aSerializer.readPoint(aPoint);
483 Point aEndPoint;
484 aSerializer.readPoint(aEndPoint);
485
486 pAction->SetRect(aRectangle);
487 pAction->SetStartPoint(aPoint);
488 pAction->SetEndPoint(aEndPoint);
489
490 return pAction;
491}
492
494{
496
498
499 // Version 1
500 tools::Polygon aPolygon;
501 ReadPolygon(mrStream, aPolygon);
502
503 // Version 2
504 if (aCompat.GetVersion() >= 2)
505 {
506 LineInfo aLineInfo;
507 ReadLineInfo(mrStream, aLineInfo);
508 pAction->SetLineInfo(aLineInfo);
509 }
510 if (aCompat.GetVersion() >= 3)
511 {
512 sal_uInt8 bHasPolyFlags(0);
513 mrStream.ReadUChar(bHasPolyFlags);
514 if (bHasPolyFlags)
515 aPolygon.Read(mrStream);
516 }
517 pAction->SetPolygon(aPolygon);
518
519 return pAction;
520}
521
523{
525
527
528 tools::Polygon aPolygon;
529 ReadPolygon(mrStream, aPolygon); // Version 1
530
531 if (aCompat.GetVersion() >= 2) // Version 2
532 {
533 sal_uInt8 bHasPolyFlags(0);
534 mrStream.ReadUChar(bHasPolyFlags);
535 if (bHasPolyFlags)
536 aPolygon.Read(mrStream);
537 }
538
539 pAction->SetPolygon(aPolygon);
540
541 return pAction;
542}
543
545{
547
549 tools::PolyPolygon aPolyPolygon;
550 ReadPolyPolygon(mrStream, aPolyPolygon); // Version 1
551
552 if (aCompat.GetVersion() < 2) // Version 2
553 {
554 pAction->SetPolyPolygon(aPolyPolygon);
555 return pAction;
556 }
557
558 sal_uInt16 nNumberOfComplexPolygons(0);
559 mrStream.ReadUInt16(nNumberOfComplexPolygons);
560 const size_t nMinRecordSize = sizeof(sal_uInt16);
561 const size_t nMaxRecords = mrStream.remainingSize() / nMinRecordSize;
562 if (nNumberOfComplexPolygons > nMaxRecords)
563 {
564 SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords << " max possible entries, but "
565 << nNumberOfComplexPolygons
566 << " claimed, truncating");
567 nNumberOfComplexPolygons = nMaxRecords;
568 }
569 for (sal_uInt16 i = 0; i < nNumberOfComplexPolygons; ++i)
570 {
571 sal_uInt16 nIndex(0);
573 tools::Polygon aPoly;
574 aPoly.Read(mrStream);
575 if (nIndex >= aPolyPolygon.Count())
576 {
577 SAL_WARN("vcl.gdi", "svm contains polygon index " << nIndex
578 << " outside possible range "
579 << aPolyPolygon.Count());
580 continue;
581 }
582 aPolyPolygon.Replace(aPoly, nIndex);
583 }
584
585 pAction->SetPolyPolygon(aPolyPolygon);
586
587 return pAction;
588}
589
591{
593
595 TypeSerializer aSerializer(mrStream);
596
597 Point aPoint;
598 aSerializer.readPoint(aPoint);
599 OUString aStr = mrStream.ReadUniOrByteString(pData->meActualCharSet);
600 sal_uInt16 nTmpIndex(0);
601 mrStream.ReadUInt16(nTmpIndex);
602 sal_uInt16 nTmpLen(0);
603 mrStream.ReadUInt16(nTmpLen);
604
605 pAction->SetPoint(aPoint);
606
607 if (aCompat.GetVersion() >= 2) // Version 2
609
610 if (nTmpIndex > aStr.getLength())
611 {
612 SAL_WARN("vcl.gdi", "inconsistent offset");
613 nTmpIndex = aStr.getLength();
614 }
615
616 if (nTmpLen > aStr.getLength() - nTmpIndex)
617 {
618 SAL_WARN("vcl.gdi", "inconsistent len");
619 nTmpLen = aStr.getLength() - nTmpIndex;
620 }
621
622 pAction->SetIndex(nTmpIndex);
623 pAction->SetLen(nTmpLen);
624
625 pAction->SetText(aStr);
626
627 return pAction;
628}
629
631{
632 rtl::Reference<MetaTextArrayAction> pAction(new MetaTextArrayAction);
633
634 std::vector<sal_Int32> aArray;
635
637 TypeSerializer aSerializer(mrStream);
638
639 Point aPoint;
640 aSerializer.readPoint(aPoint);
641 pAction->SetPoint(aPoint);
642
643 OUString aStr = mrStream.ReadUniOrByteString(pData->meActualCharSet);
644 pAction->SetText(aStr);
645
646 sal_uInt16 nTmpIndex(0);
647 mrStream.ReadUInt16(nTmpIndex);
648
649 sal_uInt16 nTmpLen(0);
650 mrStream.ReadUInt16(nTmpLen);
651
652 sal_Int32 nAryLen(0);
653 mrStream.ReadInt32(nAryLen);
654
655 if (nTmpLen > aStr.getLength() - nTmpIndex)
656 {
657 SAL_WARN("vcl.gdi", "inconsistent offset and len");
658 pAction->SetIndex(0);
659 pAction->SetLen(aStr.getLength());
660 return pAction;
661 }
662
663 pAction->SetIndex(nTmpIndex);
664 pAction->SetLen(nTmpLen);
665
666 if (nAryLen)
667 {
668 // #i9762#, #106172# Ensure that DX array is at least mnLen entries long
669 if (nTmpLen >= nAryLen)
670 {
671 try
672 {
673 aArray.resize(nTmpLen);
674 sal_Int32 i;
675 sal_Int32 val(0);
676 for (i = 0; i < nAryLen; i++)
677 {
678 mrStream.ReadInt32(val);
679 aArray[i] = val;
680 }
681 // #106172# setup remainder
682 for (; i < nTmpLen; i++)
683 aArray[i] = 0;
684 }
685 catch (std::bad_alloc&)
686 {
687 }
688 }
689 else
690 {
691 return pAction;
692 }
693 }
694
695 if (aCompat.GetVersion() >= 2) // Version 2
696 {
698 pAction->SetText(aStr);
699
700 if (nTmpLen > aStr.getLength() - nTmpIndex)
701 {
702 SAL_WARN("vcl.gdi", "inconsistent offset and len");
703 pAction->SetIndex(0);
704 pAction->SetLen(aStr.getLength());
705 aArray.clear();
706 }
707 }
708
709 if (!aArray.empty())
710 pAction->SetDXArray(std::move(aArray));
711
712 if (aCompat.GetVersion() >= 3) // Version 3
713 {
714 sal_uInt32 nKashidaAryLen(0);
715 mrStream.ReadUInt32(nKashidaAryLen);
716 nTmpLen = std::min(nKashidaAryLen, static_cast<sal_uInt32>(pAction->GetDXArray().size()));
717 if (nTmpLen)
718 {
719 // aKashidaArray, if not empty, must be the same size as aArray
720 std::vector<sal_Bool> aKashidaArray(pAction->GetDXArray().size(), 0);
721
722 // [-loplugin:fakebool] false positive:
723 sal_Bool val(sal_False);
724 for (sal_uInt32 i = 0; i < nTmpLen; i++)
725 {
726 mrStream.ReadUChar(val);
727 aKashidaArray[i] = val;
728 }
729 pAction->SetKashidaArray(std::move(aKashidaArray));
730 }
731 }
732
733 return pAction;
734}
735
737{
739
741 TypeSerializer aSerializer(mrStream);
742
743 Point aPoint;
744 aSerializer.readPoint(aPoint);
745 OUString aStr = mrStream.ReadUniOrByteString(pData->meActualCharSet);
746 sal_uInt32 nTmpWidth(0);
747 mrStream.ReadUInt32(nTmpWidth);
748 sal_uInt16 nTmpIndex(0);
749 mrStream.ReadUInt16(nTmpIndex);
750 sal_uInt16 nTmpLen(0);
751 mrStream.ReadUInt16(nTmpLen);
752
753 pAction->SetPoint(aPoint);
754 pAction->SetWidth(nTmpWidth);
755
756 if (aCompat.GetVersion() >= 2) // Version 2
758
759 if (nTmpIndex > aStr.getLength())
760 {
761 SAL_WARN("vcl.gdi", "inconsistent offset");
762 nTmpIndex = aStr.getLength();
763 }
764
765 if (nTmpLen > aStr.getLength() - nTmpIndex)
766 {
767 SAL_WARN("vcl.gdi", "inconsistent len");
768 nTmpLen = aStr.getLength() - nTmpIndex;
769 }
770
771 pAction->SetIndex(nTmpIndex);
772 pAction->SetLen(nTmpLen);
773
774 pAction->SetText(aStr);
775
776 return pAction;
777}
778
780{
782
784 TypeSerializer aSerializer(mrStream);
785
786 tools::Rectangle aRect;
787 aSerializer.readRectangle(aRect);
788 OUString aStr = mrStream.ReadUniOrByteString(pData->meActualCharSet);
789 sal_uInt16 nTmp(0);
790 mrStream.ReadUInt16(nTmp);
791
792 pAction->SetRect(aRect);
793
794 DrawTextFlags nFlags(static_cast<DrawTextFlags>(nTmp));
795 const static bool bFuzzing = utl::ConfigManager::IsFuzzing();
796 if (bFuzzing)
797 nFlags = nFlags & ~DrawTextFlags::MultiLine;
798
799 pAction->SetStyle(nFlags);
800
801 if (aCompat.GetVersion() >= 2) // Version 2
803
804 pAction->SetText(aStr);
805
806 return pAction;
807}
808
810{
812
814 TypeSerializer aSerializer(mrStream);
815
816 Point aPos;
817 aSerializer.readPoint(aPos);
818 sal_Int32 nTempWidth(0);
819 mrStream.ReadInt32(nTempWidth);
820
821 pAction->SetStartPoint(aPos);
822 pAction->SetWidth(nTempWidth);
823
824 sal_uInt32 nTempStrikeout(0);
825 mrStream.ReadUInt32(nTempStrikeout);
826 sal_uInt32 nTempUnderline(0);
827 mrStream.ReadUInt32(nTempUnderline);
828
829 pAction->SetStrikeout(static_cast<FontStrikeout>(nTempStrikeout & SAL_MAX_ENUM));
830 pAction->SetUnderline(static_cast<FontLineStyle>(nTempUnderline & SAL_MAX_ENUM));
831
832 if (aCompat.GetVersion() >= 2)
833 {
834 sal_uInt32 nTempOverline(0);
835 mrStream.ReadUInt32(nTempOverline);
836 pAction->SetOverline(static_cast<FontLineStyle>(nTempOverline & SAL_MAX_ENUM));
837 }
838
839 return pAction;
840}
841
843{
845
847 Bitmap aBmp;
848 ReadDIB(aBmp, mrStream, true);
849 TypeSerializer aSerializer(mrStream);
850 Point aPoint;
851 aSerializer.readPoint(aPoint);
852
853 pAction->SetBitmap(aBmp);
854 pAction->SetPoint(aPoint);
855
856 return pAction;
857}
858
859namespace
860{
861void sanitizeNegativeSizeDimensions(Size& rSize)
862{
863 if (rSize.Width() < 0)
864 {
865 SAL_WARN("vcl.gdi", "sanitizeNegativeSizeDimensions: negative width");
866 rSize.setWidth(0);
867 }
868
869 if (rSize.Height() < 0)
870 {
871 SAL_WARN("vcl.gdi", "sanitizeNegativeSizeDimensions: negative height");
872 rSize.setHeight(0);
873 }
874}
875}
876
878{
880
882 Bitmap aBmp;
883 ReadDIB(aBmp, mrStream, true);
884 TypeSerializer aSerializer(mrStream);
885 Point aPoint;
886 aSerializer.readPoint(aPoint);
887
888 Size aSz;
889 aSerializer.readSize(aSz);
890 sanitizeNegativeSizeDimensions(aSz);
891
892 pAction->SetBitmap(aBmp);
893 pAction->SetPoint(aPoint);
894 pAction->SetSize(aSz);
895
896 return pAction;
897}
898
900{
901 rtl::Reference<MetaBmpScalePartAction> pAction(new MetaBmpScalePartAction);
902
904 Bitmap aBmp;
905 ReadDIB(aBmp, mrStream, true);
906 TypeSerializer aSerializer(mrStream);
907 Point aDestPoint;
908 aSerializer.readPoint(aDestPoint);
909 Size aDestSize;
910 aSerializer.readSize(aDestSize);
911 Point aSrcPoint;
912 aSerializer.readPoint(aSrcPoint);
913 Size aSrcSize;
914 aSerializer.readSize(aSrcSize);
915
916 pAction->SetBitmap(aBmp);
917 pAction->SetDestPoint(aDestPoint);
918 pAction->SetDestSize(aDestSize);
919 pAction->SetSrcPoint(aSrcPoint);
920 pAction->SetSrcSize(aSrcSize);
921
922 return pAction;
923}
924
926{
928
930 BitmapEx aBmpEx;
931 ReadDIBBitmapEx(aBmpEx, mrStream);
932 TypeSerializer aSerializer(mrStream);
933 Point aPoint;
934 aSerializer.readPoint(aPoint);
935
936 pAction->SetPoint(aPoint);
937 pAction->SetBitmapEx(aBmpEx);
938
939 return pAction;
940}
941
943{
945
947 BitmapEx aBmpEx;
948 ReadDIBBitmapEx(aBmpEx, mrStream);
949 TypeSerializer aSerializer(mrStream);
950 Point aPoint;
951 aSerializer.readPoint(aPoint);
952
953 Size aSize;
954 aSerializer.readSize(aSize);
955 sanitizeNegativeSizeDimensions(aSize);
956
957 pAction->SetBitmapEx(aBmpEx);
958 pAction->SetPoint(aPoint);
959 pAction->SetSize(aSize);
960
961 return pAction;
962}
963
965{
966 rtl::Reference<MetaBmpExScalePartAction> pAction(new MetaBmpExScalePartAction);
967
969 BitmapEx aBmpEx;
970 ReadDIBBitmapEx(aBmpEx, mrStream);
971 TypeSerializer aSerializer(mrStream);
972 Point aDstPoint;
973 aSerializer.readPoint(aDstPoint);
974 Size aDstSize;
975 aSerializer.readSize(aDstSize);
976 Point aSrcPoint;
977 aSerializer.readPoint(aSrcPoint);
978 Size aSrcSize;
979 aSerializer.readSize(aSrcSize);
980
981 pAction->SetBitmapEx(aBmpEx);
982 pAction->SetDestPoint(aDstPoint);
983 pAction->SetDestSize(aDstSize);
984 pAction->SetSrcPoint(aSrcPoint);
985 pAction->SetSrcSize(aSrcSize);
986
987 return pAction;
988}
989
991{
993
995 Bitmap aBmp;
996 ReadDIB(aBmp, mrStream, true);
997 TypeSerializer aSerializer(mrStream);
998 Point aPoint;
999 aSerializer.readPoint(aPoint);
1000
1001 pAction->SetBitmap(aBmp);
1002 pAction->SetPoint(aPoint);
1003
1004 return pAction;
1005}
1006
1008{
1010
1011 VersionCompatRead aCompat(mrStream);
1012 Bitmap aBmp;
1013 ReadDIB(aBmp, mrStream, true);
1014 TypeSerializer aSerializer(mrStream);
1015 Point aPoint;
1016 aSerializer.readPoint(aPoint);
1017 Size aSize;
1018 aSerializer.readSize(aSize);
1019
1020 pAction->SetBitmap(aBmp);
1021 pAction->SetPoint(aPoint);
1022 pAction->SetSize(aSize);
1023
1024 return pAction;
1025}
1026
1028{
1030
1031 VersionCompatRead aCompat(mrStream);
1032 Bitmap aBmp;
1033 ReadDIB(aBmp, mrStream, true);
1034 Color aColor;
1035 ReadColor(aColor);
1036 TypeSerializer aSerializer(mrStream);
1037 Point aDstPt;
1038 aSerializer.readPoint(aDstPt);
1039 Size aDstSz;
1040 aSerializer.readSize(aDstSz);
1041 Point aSrcPt;
1042 aSerializer.readPoint(aSrcPt);
1043 Size aSrcSz;
1044 aSerializer.readSize(aSrcSz);
1045
1046 pAction->SetBitmap(aBmp);
1047 pAction->SetColor(aColor);
1048 pAction->SetDestPoint(aDstPt);
1049 pAction->SetDestSize(aDstSz);
1050 pAction->SetSrcPoint(aSrcPt);
1051 pAction->SetSrcSize(aSrcSz);
1052
1053 return pAction;
1054}
1055
1057{
1059
1060 VersionCompatRead aCompat(mrStream);
1061 TypeSerializer aSerializer(mrStream);
1062
1063 tools::Rectangle aRect;
1064 aSerializer.readRectangle(aRect);
1065 Gradient aGradient;
1066 aSerializer.readGradient(aGradient);
1067
1068 pAction->SetRect(aRect);
1069 pAction->SetGradient(aGradient);
1070
1071 return pAction;
1072}
1073
1075{
1077
1078 VersionCompatRead aCompat(mrStream);
1079 tools::PolyPolygon aPolyPoly;
1080 ReadPolyPolygon(mrStream, aPolyPoly);
1081 TypeSerializer aSerializer(mrStream);
1082 Gradient aGradient;
1083 aSerializer.readGradient(aGradient);
1084
1085 pAction->SetGradient(aGradient);
1086 pAction->SetPolyPolygon(aPolyPoly);
1087
1088 return pAction;
1089}
1090
1092{
1094
1095 VersionCompatRead aCompat(mrStream);
1096 tools::PolyPolygon aPolyPoly;
1097 ReadPolyPolygon(mrStream, aPolyPoly);
1098 Hatch aHatch;
1099 ReadHatch(mrStream, aHatch);
1100
1101 pAction->SetPolyPolygon(aPolyPoly);
1102 pAction->SetHatch(aHatch);
1103
1104 return pAction;
1105}
1106
1108{
1109 rtl::Reference<MetaWallpaperAction> pAction(new MetaWallpaperAction);
1110
1111 VersionCompatRead aCompat(mrStream);
1112 Wallpaper aWallpaper;
1113 ReadWallpaper(mrStream, aWallpaper);
1114
1115 pAction->SetWallpaper(aWallpaper);
1116
1117 return pAction;
1118}
1119
1121{
1123
1124 VersionCompatRead aCompat(mrStream);
1125 vcl::Region aRegion;
1126 ReadRegion(mrStream, aRegion);
1127 bool aClip(false);
1128 mrStream.ReadCharAsBool(aClip);
1129
1130 pAction->SetRegion(aRegion);
1131 pAction->SetClipping(aClip);
1132
1133 return pAction;
1134}
1135
1137{
1139
1140 VersionCompatRead aCompat(mrStream);
1141 TypeSerializer aSerializer(mrStream);
1142 tools::Rectangle aRect;
1143 aSerializer.readRectangle(aRect);
1144
1145 pAction->SetRect(aRect);
1146
1147 return pAction;
1148}
1149
1151{
1153
1154 VersionCompatRead aCompat(mrStream);
1155 vcl::Region aRegion;
1156 ReadRegion(mrStream, aRegion);
1157 pAction->SetRegion(aRegion);
1158
1159 return pAction;
1160}
1161
1163{
1165
1166 VersionCompatRead aCompat(mrStream);
1167 sal_Int32 nTmpHM(0), nTmpVM(0);
1168 mrStream.ReadInt32(nTmpHM).ReadInt32(nTmpVM);
1169
1170 pAction->SetHorzMove(nTmpHM);
1171 pAction->SetVertMove(nTmpVM);
1172
1173 return pAction;
1174}
1175
1177{
1179
1180 VersionCompatRead aCompat(mrStream);
1181 Color aColor;
1182 ReadColor(aColor);
1183
1184 pAction->SetColor(aColor);
1185
1186 return pAction;
1187}
1188
1190{
1192
1193 VersionCompatRead aCompat(mrStream);
1194 Color aColor;
1195 ReadColor(aColor);
1196 bool bSet(false);
1198
1199 pAction->SetColor(aColor);
1200 pAction->SetSetting(bSet);
1201
1202 return pAction;
1203}
1204
1206{
1208
1209 VersionCompatRead aCompat(mrStream);
1210 Color aColor;
1211 ReadColor(aColor);
1212 bool bSet(false);
1214
1215 pAction->SetColor(aColor);
1216 pAction->SetSetting(bSet);
1217
1218 return pAction;
1219}
1220
1222{
1224
1225 VersionCompatRead aCompat(mrStream);
1226 Color aColor;
1227 ReadColor(aColor);
1228 bool bSet(false);
1230
1231 pAction->SetColor(aColor);
1232 pAction->SetSetting(bSet);
1233
1234 return pAction;
1235}
1236
1238{
1240
1241 VersionCompatRead aCompat(mrStream);
1242 sal_uInt16 nTmp16(0);
1243 mrStream.ReadUInt16(nTmp16);
1244
1245 pAction->SetTextAlign(static_cast<TextAlign>(nTmp16));
1246
1247 return pAction;
1248}
1249
1251{
1253
1254 VersionCompatRead aCompat(mrStream);
1255 TypeSerializer aSerializer(mrStream);
1256 MapMode aMapMode;
1257 aSerializer.readMapMode(aMapMode);
1258
1259 pAction->SetMapMode(aMapMode);
1260
1261 return pAction;
1262}
1263
1265{
1267
1268 VersionCompatRead aCompat(mrStream);
1269 vcl::Font aFont;
1270 ReadFont(mrStream, aFont);
1271 pData->meActualCharSet = aFont.GetCharSet();
1272 if (pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW)
1273 pData->meActualCharSet = osl_getThreadTextEncoding();
1274
1275 pAction->SetFont(aFont);
1276
1277 return pAction;
1278}
1279
1281{
1283
1284 VersionCompatRead aCompat(mrStream);
1285 sal_uInt16 nTmp(0);
1286 mrStream.ReadUInt16(nTmp);
1287
1288 pAction->SetPushFlags(static_cast<vcl::PushFlags>(nTmp));
1289
1290 return pAction;
1291}
1292
1294{
1296
1297 VersionCompatRead aCompat(mrStream);
1298
1299 return pAction;
1300}
1301
1303{
1305
1306 sal_uInt16 nTmp16(0);
1307
1308 VersionCompatRead aCompat(mrStream);
1309 mrStream.ReadUInt16(nTmp16);
1310
1311 pAction->SetRasterOp(static_cast<RasterOp>(nTmp16));
1312
1313 return pAction;
1314}
1315
1317{
1319
1320 VersionCompatRead aCompat(mrStream);
1321 tools::PolyPolygon aPolyPoly;
1322 ReadPolyPolygon(mrStream, aPolyPoly);
1323 sal_uInt16 nTransPercent(0);
1324 mrStream.ReadUInt16(nTransPercent);
1325
1326 pAction->SetPolyPolygon(aPolyPoly);
1327 pAction->SetTransparence(nTransPercent);
1328
1329 return pAction;
1330}
1331
1333{
1335
1336 VersionCompatRead aCompat(mrStream);
1337 GDIMetaFile aMtf;
1338 SvmReader aReader(mrStream);
1339 aReader.Read(aMtf, pData);
1340 TypeSerializer aSerializer(mrStream);
1341 Point aPoint;
1342 aSerializer.readPoint(aPoint);
1343
1344 Size aSize;
1345 aSerializer.readSize(aSize);
1346 sanitizeNegativeSizeDimensions(aSize);
1347
1348 Gradient aGradient;
1349 aSerializer.readGradient(aGradient);
1350
1351 pAction->SetGDIMetaFile(aMtf);
1352 pAction->SetPoint(aPoint);
1353 pAction->SetSize(aSize);
1354 pAction->SetGradient(aGradient);
1355
1356 return pAction;
1357}
1358
1360{
1362
1363 VersionCompatRead aCompat(mrStream);
1364 TypeSerializer aSerializer(mrStream);
1365 GfxLink aGfxLink;
1366 aSerializer.readGfxLink(aGfxLink);
1367 Point aPoint;
1368 aSerializer.readPoint(aPoint);
1369 Size aSize;
1370 aSerializer.readSize(aSize);
1371 GDIMetaFile aSubst;
1372 Read(aSubst);
1373
1374 pAction->SetLink(aGfxLink);
1375 pAction->SetPoint(aPoint);
1376 pAction->SetSize(aSize);
1377 pAction->SetSubstitute(aSubst);
1378
1379 return pAction;
1380}
1381
1383{
1385
1386 VersionCompatRead aCompat(mrStream);
1387 TypeSerializer aSerializer(mrStream);
1388
1389 Point aRefPoint;
1390 aSerializer.readPoint(aRefPoint);
1391 bool bSet(false);
1393
1394 pAction->SetRefPoint(aRefPoint);
1395 pAction->SetSetting(bSet);
1396
1397 return pAction;
1398}
1399
1401{
1403
1404 VersionCompatRead aCompat(mrStream);
1405 OString aComment;
1407 sal_Int32 nValue(0);
1408 sal_uInt32 nDataSize(0);
1409 mrStream.ReadInt32(nValue).ReadUInt32(nDataSize);
1410
1411 if (nDataSize > mrStream.remainingSize())
1412 {
1413 SAL_WARN("vcl.gdi", "Parsing error: " << mrStream.remainingSize() << " available data, but "
1414 << nDataSize << " claimed, truncating");
1415 nDataSize = mrStream.remainingSize();
1416 }
1417
1418 SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << aComment);
1419
1420 std::unique_ptr<sal_uInt8[]> pData;
1421 pData.reset();
1422
1423 if (nDataSize)
1424 {
1425 pData.reset(new sal_uInt8[nDataSize]);
1426 mrStream.ReadBytes(pData.get(), nDataSize);
1427 }
1428
1429 pAction->SetComment(aComment);
1430 pAction->SetDataSize(nDataSize);
1431 pAction->SetValue(nValue);
1432 pAction->SetData(pData.get(), nDataSize);
1433
1434 return pAction;
1435}
1436
1438{
1440
1441 VersionCompatRead aCompat(mrStream);
1442 sal_uInt32 tmp(0);
1443 mrStream.ReadUInt32(tmp);
1444
1445 pAction->SetLayoutMode(static_cast<vcl::text::ComplexTextLayoutFlags>(tmp));
1446
1447 return pAction;
1448}
1449
1451{
1453
1454 VersionCompatRead aCompat(mrStream);
1455 sal_uInt16 nTmp = 0;
1456 mrStream.ReadUInt16(nTmp);
1457
1458 pAction->SetTextLanguage(static_cast<LanguageType>(nTmp));
1459
1460 return pAction;
1461}
1462
1464{
1466}
1467/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Sequence< Sequence< double > > & m_rData
DrawTextFlags
RasterOp
Definition: RasterOp.hxx:23
DepthGuard(HWPFile &rFile)
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:581
void UseCanvas(bool _bUseCanvas)
Definition: gdimtf.cxx:2333
void Clear()
Definition: gdimtf.cxx:270
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:176
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:173
Definition: hatch.hxx:47
const OString & GetComment() const
Definition: metaact.hxx:1699
Converts old SVGDI aka SVM1 format data to current VCLMTF aka SVM2 format metafile data.
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvStream & ReadCharAsBool(bool &rBool)
sal_uInt64 Tell() const
void SetEndian(SvStreamEndian SvStreamEndian)
bool good() const
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
bool eof() const
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStreamEndian GetEndian() const
void SetError(ErrCode nErrorCode)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadInt32(sal_Int32 &rInt32)
std::size_t ReadBytes(void *pData, std::size_t nSize)
rtl_TextEncoding GetStreamCharSet() const
ErrCode GetError() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
rtl::Reference< MetaAction > TextLineColorHandler()
Definition: SvmReader.cxx:1205
rtl::Reference< MetaAction > PieHandler()
Definition: SvmReader.cxx:451
rtl::Reference< MetaAction > TextColorHandler()
Definition: SvmReader.cxx:1176
rtl::Reference< MetaAction > PolyPolygonHandler()
Definition: SvmReader.cxx:544
rtl::Reference< MetaAction > ClipRegionHandler()
Definition: SvmReader.cxx:1120
rtl::Reference< MetaAction > PointHandler()
Definition: SvmReader.cxx:336
rtl::Reference< MetaAction > ArcHandler()
Definition: SvmReader.cxx:430
rtl::Reference< MetaAction > RefPointHandler()
Definition: SvmReader.cxx:1382
rtl::Reference< MetaAction > GradientHandler()
Definition: SvmReader.cxx:1056
rtl::Reference< MetaAction > BmpExScalePartHandler()
Definition: SvmReader.cxx:964
SvStream & Read(GDIMetaFile &rMetaFile, ImplMetaReadData *pData=nullptr)
Definition: SvmReader.cxx:65
void ReadColor(::Color &rColor)
Definition: SvmReader.cxx:282
rtl::Reference< MetaAction > BmpExHandler()
Definition: SvmReader.cxx:925
rtl::Reference< MetaAction > TextArrayHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:630
rtl::Reference< MetaAction > MapModeHandler()
Definition: SvmReader.cxx:1250
SvStream & mrStream
Definition: SvmReader.hxx:29
rtl::Reference< MetaAction > MaskHandler()
Definition: SvmReader.cxx:990
rtl::Reference< MetaAction > LineColorHandler()
Definition: SvmReader.cxx:289
rtl::Reference< MetaAction > HatchHandler()
Definition: SvmReader.cxx:1091
rtl::Reference< MetaAction > TextAlignHandler()
Definition: SvmReader.cxx:1237
rtl::Reference< MetaAction > RasterOpHandler()
Definition: SvmReader.cxx:1302
rtl::Reference< MetaAction > ISectRegionClipRegionHandler()
Definition: SvmReader.cxx:1150
rtl::Reference< MetaAction > BmpHandler()
Definition: SvmReader.cxx:842
rtl::Reference< MetaAction > CommentHandler()
Definition: SvmReader.cxx:1400
rtl::Reference< MetaAction > PopHandler()
Definition: SvmReader.cxx:1293
rtl::Reference< MetaAction > StretchTextHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:736
rtl::Reference< MetaAction > PixelHandler()
Definition: SvmReader.cxx:350
rtl::Reference< MetaAction > ChordHandler()
Definition: SvmReader.cxx:472
SvmReader(SvStream &rIStm)
Definition: SvmReader.cxx:60
rtl::Reference< MetaAction > TransparentHandler()
Definition: SvmReader.cxx:1316
rtl::Reference< MetaAction > EllipseHandler()
Definition: SvmReader.cxx:415
rtl::Reference< MetaAction > PolyLineHandler()
Definition: SvmReader.cxx:493
rtl::Reference< MetaAction > MoveClipRegionHandler()
Definition: SvmReader.cxx:1162
rtl::Reference< MetaAction > FillColorHandler()
Definition: SvmReader.cxx:305
rtl::Reference< MetaAction > TextHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:590
rtl::Reference< MetaAction > FloatTransparentHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:1332
rtl::Reference< MetaAction > PolygonHandler()
Definition: SvmReader.cxx:522
rtl::Reference< MetaAction > PushHandler()
Definition: SvmReader.cxx:1280
rtl::Reference< MetaAction > TextFillColorHandler()
Definition: SvmReader.cxx:1189
rtl::Reference< MetaAction > TextLanguageHandler()
Definition: SvmReader.cxx:1450
rtl::Reference< MetaAction > ISectRectClipRegionHandler()
Definition: SvmReader.cxx:1136
rtl::Reference< MetaAction > BmpScalePartHandler()
Definition: SvmReader.cxx:899
rtl::Reference< MetaAction > TextRectHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:779
static rtl::Reference< MetaAction > DefaultHandler()
Definition: SvmReader.cxx:1463
rtl::Reference< MetaAction > MaskScalePartHandler()
Definition: SvmReader.cxx:1027
rtl::Reference< MetaAction > MetaActionHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:154
rtl::Reference< MetaAction > EPSHandler()
Definition: SvmReader.cxx:1359
rtl::Reference< MetaAction > RectHandler()
Definition: SvmReader.cxx:322
rtl::Reference< MetaAction > OverlineColorHandler()
Definition: SvmReader.cxx:1221
rtl::Reference< MetaAction > RoundRectHandler()
Definition: SvmReader.cxx:395
rtl::Reference< MetaAction > BmpScaleHandler()
Definition: SvmReader.cxx:877
rtl::Reference< MetaAction > WallpaperHandler()
Definition: SvmReader.cxx:1107
rtl::Reference< MetaAction > MaskScaleHandler()
Definition: SvmReader.cxx:1007
rtl::Reference< MetaAction > BmpExScaleHandler()
Definition: SvmReader.cxx:942
rtl::Reference< MetaAction > LineHandler()
Definition: SvmReader.cxx:368
rtl::Reference< MetaAction > GradientExHandler()
Definition: SvmReader.cxx:1074
rtl::Reference< MetaAction > FontHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:1264
rtl::Reference< MetaAction > LayoutModeHandler()
Definition: SvmReader.cxx:1437
rtl::Reference< MetaAction > TextLineHandler()
Definition: SvmReader.cxx:809
void readMapMode(MapMode &rMapMode)
void readGradient(Gradient &rGradient)
void readGfxLink(GfxLink &rGfxLink)
sal_uInt16 GetVersion() const
void readPoint(Point &rPoint)
void readSize(Size &rSize)
void readRectangle(Rectangle &rRectangle)
sal_uInt16 Count() const
void Replace(const Polygon &rPoly, sal_uInt16 nPos)
void Read(SvStream &rIStream)
static bool IsFuzzing()
rtl_TextEncoding GetCharSet() const
Definition: font/font.cxx:912
ColorTransparency
int nCount
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1718
bool ReadDIB(Bitmap &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1709
#define SVSTREAM_FILEFORMAT_ERROR
sal_Int16 nValue
SvStream & ReadFont(SvStream &rIStm, vcl::Font &rFont)
Definition: font/font.cxx:590
FontLineStyle
FontStrikeout
SvStream & ReadHatch(SvStream &rIStm, Hatch &rHatch)
Definition: gdi/hatch.cxx:79
sal_Int32 nIndex
SvStream & ReadLineInfo(SvStream &rIStm, LineInfo &rLineInfo)
Definition: lineinfo.cxx:142
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
MetaActionType
aStr
std::unique_ptr< sal_Int32[]> pData
int i
TextAlign
SvStream & ReadPolyPolygon(SvStream &rIStream, tools::PolyPolygon &rPolyPoly)
SvStream & ReadPolygon(SvStream &rIStream, tools::Polygon &rPoly)
ComplexTextLayoutFlags
Definition: State.hxx:76
PushFlags
Definition: State.hxx:40
SvStream & ReadRegion(SvStream &rIStrm, vcl::Region &rRegion)
Definition: region.cxx:1531
QPRO_FUNC_TYPE nType
OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream &rStrm)
OUString read_uInt16_lenPrefixed_uInt16s_ToOUString(SvStream &rStrm)
SvStreamEndian
#define SAL_MAX_ENUM
unsigned char sal_uInt8
#define sal_False
unsigned char sal_Bool
SvStream & ReadWallpaper(SvStream &rIStm, Wallpaper &rImplWallpaper)
Definition: wall.cxx:30