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{
633
634 KernArray 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 sal_Int32 i;
674 sal_Int32 val(0);
675 for (i = 0; i < nAryLen; i++)
676 {
677 mrStream.ReadInt32(val);
678 aArray.push_back(val);
679 }
680 // #106172# setup remainder
681 for (; i < nTmpLen; i++)
682 aArray.push_back(0);
683 }
684 catch (std::bad_alloc&)
685 {
686 }
687 }
688 else
689 {
690 return pAction;
691 }
692 }
693
694 if (aCompat.GetVersion() >= 2) // Version 2
695 {
697 pAction->SetText(aStr);
698
699 if (nTmpLen > aStr.getLength() - nTmpIndex)
700 {
701 SAL_WARN("vcl.gdi", "inconsistent offset and len");
702 pAction->SetIndex(0);
703 pAction->SetLen(aStr.getLength());
704 aArray.clear();
705 }
706 }
707
708 if (!aArray.empty())
709 pAction->SetDXArray(std::move(aArray));
710
711 if (aCompat.GetVersion() >= 3) // Version 3
712 {
713 sal_uInt32 nKashidaAryLen(0);
714 mrStream.ReadUInt32(nKashidaAryLen);
715 nTmpLen = std::min(nKashidaAryLen, static_cast<sal_uInt32>(pAction->GetDXArray().size()));
716 if (nTmpLen)
717 {
718 // aKashidaArray, if not empty, must be the same size as aArray
719 std::vector<sal_Bool> aKashidaArray(pAction->GetDXArray().size(), 0);
720
721 // [-loplugin:fakebool] false positive:
722 sal_Bool val(sal_False);
723 for (sal_uInt32 i = 0; i < nTmpLen; i++)
724 {
725 mrStream.ReadUChar(val);
726 aKashidaArray[i] = val;
727 }
728 pAction->SetKashidaArray(std::move(aKashidaArray));
729 }
730 }
731
732 return pAction;
733}
734
736{
738
740 TypeSerializer aSerializer(mrStream);
741
742 Point aPoint;
743 aSerializer.readPoint(aPoint);
744 OUString aStr = mrStream.ReadUniOrByteString(pData->meActualCharSet);
745 sal_uInt32 nTmpWidth(0);
746 mrStream.ReadUInt32(nTmpWidth);
747 sal_uInt16 nTmpIndex(0);
748 mrStream.ReadUInt16(nTmpIndex);
749 sal_uInt16 nTmpLen(0);
750 mrStream.ReadUInt16(nTmpLen);
751
752 pAction->SetPoint(aPoint);
753 pAction->SetWidth(nTmpWidth);
754
755 if (aCompat.GetVersion() >= 2) // Version 2
757
758 if (nTmpIndex > aStr.getLength())
759 {
760 SAL_WARN("vcl.gdi", "inconsistent offset");
761 nTmpIndex = aStr.getLength();
762 }
763
764 if (nTmpLen > aStr.getLength() - nTmpIndex)
765 {
766 SAL_WARN("vcl.gdi", "inconsistent len");
767 nTmpLen = aStr.getLength() - nTmpIndex;
768 }
769
770 pAction->SetIndex(nTmpIndex);
771 pAction->SetLen(nTmpLen);
772
773 pAction->SetText(aStr);
774
775 return pAction;
776}
777
779{
781
783 TypeSerializer aSerializer(mrStream);
784
785 tools::Rectangle aRect;
786 aSerializer.readRectangle(aRect);
787 OUString aStr = mrStream.ReadUniOrByteString(pData->meActualCharSet);
788 sal_uInt16 nTmp(0);
789 mrStream.ReadUInt16(nTmp);
790
791 pAction->SetRect(aRect);
792
793 DrawTextFlags nFlags(static_cast<DrawTextFlags>(nTmp));
794 const static bool bFuzzing = utl::ConfigManager::IsFuzzing();
795 if (bFuzzing)
796 nFlags = nFlags & ~DrawTextFlags::MultiLine;
797
798 pAction->SetStyle(nFlags);
799
800 if (aCompat.GetVersion() >= 2) // Version 2
802
803 pAction->SetText(aStr);
804
805 return pAction;
806}
807
809{
811
813 TypeSerializer aSerializer(mrStream);
814
815 Point aPos;
816 aSerializer.readPoint(aPos);
817 sal_Int32 nTempWidth(0);
818 mrStream.ReadInt32(nTempWidth);
819
820 pAction->SetStartPoint(aPos);
821 if (nTempWidth < 0)
822 {
823 SAL_WARN("vcl.gdi", "negative width");
824 nTempWidth = 0;
825 }
826 pAction->SetWidth(nTempWidth);
827
828 sal_uInt32 nTempStrikeout(0);
829 mrStream.ReadUInt32(nTempStrikeout);
830 sal_uInt32 nTempUnderline(0);
831 mrStream.ReadUInt32(nTempUnderline);
832
833 pAction->SetStrikeout(static_cast<FontStrikeout>(nTempStrikeout & SAL_MAX_ENUM));
834 pAction->SetUnderline(static_cast<FontLineStyle>(nTempUnderline & SAL_MAX_ENUM));
835
836 if (aCompat.GetVersion() >= 2)
837 {
838 sal_uInt32 nTempOverline(0);
839 mrStream.ReadUInt32(nTempOverline);
840 pAction->SetOverline(static_cast<FontLineStyle>(nTempOverline & SAL_MAX_ENUM));
841 }
842
843 return pAction;
844}
845
847{
849
851 Bitmap aBmp;
852 ReadDIB(aBmp, mrStream, true);
853 TypeSerializer aSerializer(mrStream);
854 Point aPoint;
855 aSerializer.readPoint(aPoint);
856
857 pAction->SetBitmap(aBmp);
858 pAction->SetPoint(aPoint);
859
860 return pAction;
861}
862
864{
866
868 Bitmap aBmp;
869 ReadDIB(aBmp, mrStream, true);
870 TypeSerializer aSerializer(mrStream);
871 Point aPoint;
872 aSerializer.readPoint(aPoint);
873
874 Size aSz;
875 aSerializer.readSize(aSz);
876
877 pAction->SetBitmap(aBmp);
878 pAction->SetPoint(aPoint);
879 pAction->SetSize(aSz);
880
881 return pAction;
882}
883
885{
887
889 Bitmap aBmp;
890 ReadDIB(aBmp, mrStream, true);
891 TypeSerializer aSerializer(mrStream);
892 Point aDestPoint;
893 aSerializer.readPoint(aDestPoint);
894 Size aDestSize;
895 aSerializer.readSize(aDestSize);
896 Point aSrcPoint;
897 aSerializer.readPoint(aSrcPoint);
898 Size aSrcSize;
899 aSerializer.readSize(aSrcSize);
900
901 pAction->SetBitmap(aBmp);
902 pAction->SetDestPoint(aDestPoint);
903 pAction->SetDestSize(aDestSize);
904 pAction->SetSrcPoint(aSrcPoint);
905 pAction->SetSrcSize(aSrcSize);
906
907 return pAction;
908}
909
911{
913
915 BitmapEx aBmpEx;
916 ReadDIBBitmapEx(aBmpEx, mrStream);
917 TypeSerializer aSerializer(mrStream);
918 Point aPoint;
919 aSerializer.readPoint(aPoint);
920
921 pAction->SetPoint(aPoint);
922 pAction->SetBitmapEx(aBmpEx);
923
924 return pAction;
925}
926
928{
930
932 BitmapEx aBmpEx;
933 ReadDIBBitmapEx(aBmpEx, mrStream);
934 TypeSerializer aSerializer(mrStream);
935 Point aPoint;
936 aSerializer.readPoint(aPoint);
937
938 Size aSize;
939 aSerializer.readSize(aSize);
940
941 pAction->SetBitmapEx(aBmpEx);
942 pAction->SetPoint(aPoint);
943 pAction->SetSize(aSize);
944
945 return pAction;
946}
947
949{
951
953 BitmapEx aBmpEx;
954 ReadDIBBitmapEx(aBmpEx, mrStream);
955 TypeSerializer aSerializer(mrStream);
956 Point aDstPoint;
957 aSerializer.readPoint(aDstPoint);
958 Size aDstSize;
959 aSerializer.readSize(aDstSize);
960 Point aSrcPoint;
961 aSerializer.readPoint(aSrcPoint);
962 Size aSrcSize;
963 aSerializer.readSize(aSrcSize);
964
965 pAction->SetBitmapEx(aBmpEx);
966 pAction->SetDestPoint(aDstPoint);
967 pAction->SetDestSize(aDstSize);
968 pAction->SetSrcPoint(aSrcPoint);
969 pAction->SetSrcSize(aSrcSize);
970
971 return pAction;
972}
973
975{
977
979 Bitmap aBmp;
980 ReadDIB(aBmp, mrStream, true);
981 TypeSerializer aSerializer(mrStream);
982 Point aPoint;
983 aSerializer.readPoint(aPoint);
984
985 pAction->SetBitmap(aBmp);
986 pAction->SetPoint(aPoint);
987
988 return pAction;
989}
990
992{
994
996 Bitmap aBmp;
997 ReadDIB(aBmp, mrStream, true);
998 TypeSerializer aSerializer(mrStream);
999 Point aPoint;
1000 aSerializer.readPoint(aPoint);
1001 Size aSize;
1002 aSerializer.readSize(aSize);
1003
1004 pAction->SetBitmap(aBmp);
1005 pAction->SetPoint(aPoint);
1006 pAction->SetSize(aSize);
1007
1008 return pAction;
1009}
1010
1012{
1014
1015 VersionCompatRead aCompat(mrStream);
1016 Bitmap aBmp;
1017 ReadDIB(aBmp, mrStream, true);
1018 Color aColor;
1019 ReadColor(aColor);
1020 TypeSerializer aSerializer(mrStream);
1021 Point aDstPt;
1022 aSerializer.readPoint(aDstPt);
1023 Size aDstSz;
1024 aSerializer.readSize(aDstSz);
1025 Point aSrcPt;
1026 aSerializer.readPoint(aSrcPt);
1027 Size aSrcSz;
1028 aSerializer.readSize(aSrcSz);
1029
1030 pAction->SetBitmap(aBmp);
1031 pAction->SetColor(aColor);
1032 pAction->SetDestPoint(aDstPt);
1033 pAction->SetDestSize(aDstSz);
1034 pAction->SetSrcPoint(aSrcPt);
1035 pAction->SetSrcSize(aSrcSz);
1036
1037 return pAction;
1038}
1039
1041{
1043
1044 VersionCompatRead aCompat(mrStream);
1045 TypeSerializer aSerializer(mrStream);
1046
1047 tools::Rectangle aRect;
1048 aSerializer.readRectangle(aRect);
1049 Gradient aGradient;
1050 aSerializer.readGradient(aGradient);
1051
1052 pAction->SetRect(aRect);
1053 pAction->SetGradient(aGradient);
1054
1055 return pAction;
1056}
1057
1059{
1061
1062 VersionCompatRead aCompat(mrStream);
1063 tools::PolyPolygon aPolyPoly;
1064 ReadPolyPolygon(mrStream, aPolyPoly);
1065 TypeSerializer aSerializer(mrStream);
1066 Gradient aGradient;
1067 aSerializer.readGradient(aGradient);
1068
1069 pAction->SetGradient(aGradient);
1070 pAction->SetPolyPolygon(aPolyPoly);
1071
1072 return pAction;
1073}
1074
1076{
1078
1079 VersionCompatRead aCompat(mrStream);
1080 tools::PolyPolygon aPolyPoly;
1081 ReadPolyPolygon(mrStream, aPolyPoly);
1082 Hatch aHatch;
1083 ReadHatch(mrStream, aHatch);
1084
1085 pAction->SetPolyPolygon(aPolyPoly);
1086 pAction->SetHatch(aHatch);
1087
1088 return pAction;
1089}
1090
1092{
1094
1095 VersionCompatRead aCompat(mrStream);
1096 Wallpaper aWallpaper;
1097 ReadWallpaper(mrStream, aWallpaper);
1098
1099 pAction->SetWallpaper(aWallpaper);
1100
1101 return pAction;
1102}
1103
1105{
1107
1108 VersionCompatRead aCompat(mrStream);
1109 vcl::Region aRegion;
1110 ReadRegion(mrStream, aRegion);
1111 bool aClip(false);
1112 mrStream.ReadCharAsBool(aClip);
1113
1114 pAction->SetRegion(aRegion);
1115 pAction->SetClipping(aClip);
1116
1117 return pAction;
1118}
1119
1121{
1123
1124 VersionCompatRead aCompat(mrStream);
1125 TypeSerializer aSerializer(mrStream);
1126 tools::Rectangle aRect;
1127 aSerializer.readRectangle(aRect);
1128
1129 pAction->SetRect(aRect);
1130
1131 return pAction;
1132}
1133
1135{
1137
1138 VersionCompatRead aCompat(mrStream);
1139 vcl::Region aRegion;
1140 ReadRegion(mrStream, aRegion);
1141 pAction->SetRegion(aRegion);
1142
1143 return pAction;
1144}
1145
1147{
1149
1150 VersionCompatRead aCompat(mrStream);
1151 sal_Int32 nTmpHM(0), nTmpVM(0);
1152 mrStream.ReadInt32(nTmpHM).ReadInt32(nTmpVM);
1153
1154 pAction->SetHorzMove(nTmpHM);
1155 pAction->SetVertMove(nTmpVM);
1156
1157 return pAction;
1158}
1159
1161{
1163
1164 VersionCompatRead aCompat(mrStream);
1165 Color aColor;
1166 ReadColor(aColor);
1167
1168 pAction->SetColor(aColor);
1169
1170 return pAction;
1171}
1172
1174{
1176
1177 VersionCompatRead aCompat(mrStream);
1178 Color aColor;
1179 ReadColor(aColor);
1180 bool bSet(false);
1182
1183 pAction->SetColor(aColor);
1184 pAction->SetSetting(bSet);
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 sal_uInt16 nTmp16(0);
1227 mrStream.ReadUInt16(nTmp16);
1228
1229 pAction->SetTextAlign(static_cast<TextAlign>(nTmp16));
1230
1231 return pAction;
1232}
1233
1235{
1237
1238 VersionCompatRead aCompat(mrStream);
1239 TypeSerializer aSerializer(mrStream);
1240 MapMode aMapMode;
1241 aSerializer.readMapMode(aMapMode);
1242
1243 pAction->SetMapMode(aMapMode);
1244
1245 return pAction;
1246}
1247
1249{
1251
1252 VersionCompatRead aCompat(mrStream);
1253 vcl::Font aFont;
1254 ReadFont(mrStream, aFont);
1255 pData->meActualCharSet = aFont.GetCharSet();
1256 if (pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW)
1257 pData->meActualCharSet = osl_getThreadTextEncoding();
1258
1259 pAction->SetFont(aFont);
1260
1261 return pAction;
1262}
1263
1265{
1267
1268 VersionCompatRead aCompat(mrStream);
1269 sal_uInt16 nTmp(0);
1270 mrStream.ReadUInt16(nTmp);
1271
1272 pAction->SetPushFlags(static_cast<vcl::PushFlags>(nTmp));
1273
1274 return pAction;
1275}
1276
1278{
1280
1281 VersionCompatRead aCompat(mrStream);
1282
1283 return pAction;
1284}
1285
1287{
1289
1290 sal_uInt16 nTmp16(0);
1291
1292 VersionCompatRead aCompat(mrStream);
1293 mrStream.ReadUInt16(nTmp16);
1294
1295 pAction->SetRasterOp(static_cast<RasterOp>(nTmp16));
1296
1297 return pAction;
1298}
1299
1301{
1303
1304 VersionCompatRead aCompat(mrStream);
1305 tools::PolyPolygon aPolyPoly;
1306 ReadPolyPolygon(mrStream, aPolyPoly);
1307 sal_uInt16 nTransPercent(0);
1308 mrStream.ReadUInt16(nTransPercent);
1309
1310 pAction->SetPolyPolygon(aPolyPoly);
1311 pAction->SetTransparence(nTransPercent);
1312
1313 return pAction;
1314}
1315
1317{
1319
1320 VersionCompatRead aCompat(mrStream);
1321 GDIMetaFile aMtf;
1322 SvmReader aReader(mrStream);
1323 aReader.Read(aMtf, pData);
1324 TypeSerializer aSerializer(mrStream);
1325 Point aPoint;
1326 aSerializer.readPoint(aPoint);
1327
1328 Size aSize;
1329 aSerializer.readSize(aSize);
1330
1331 Gradient aGradient;
1332 aSerializer.readGradient(aGradient);
1333
1334 pAction->SetGDIMetaFile(aMtf);
1335 pAction->SetPoint(aPoint);
1336 pAction->SetSize(aSize);
1337 pAction->SetGradient(aGradient);
1338
1339 // tdf#155479 add support for MCGR and SVG export
1340 if (aCompat.GetVersion() > 1)
1341 {
1342 basegfx::BColorStops aColorStops;
1343 sal_uInt16 nTmp(0);
1344 double fOff, fR, fG, fB;
1345 mrStream.ReadUInt16(nTmp);
1346
1347 const size_t nMaxPossibleEntries = mrStream.remainingSize() / 4 * sizeof(double);
1348 if (nTmp > nMaxPossibleEntries)
1349 {
1350 SAL_WARN("vcl.gdi", "gradient record claims to have: " << nTmp << " entries, but only "
1351 << nMaxPossibleEntries
1352 << " possible, clamping");
1353 nTmp = nMaxPossibleEntries;
1354 }
1355
1356 for (sal_uInt16 a(0); a < nTmp; a++)
1357 {
1358 mrStream.ReadDouble(fOff);
1359 mrStream.ReadDouble(fR);
1360 mrStream.ReadDouble(fG);
1361 mrStream.ReadDouble(fB);
1362
1363 aColorStops.emplace_back(fOff, basegfx::BColor(fR, fG, fB));
1364 }
1365
1366 pAction->addSVGTransparencyColorStops(aColorStops);
1367 }
1368
1369 return pAction;
1370}
1371
1373{
1375
1376 VersionCompatRead aCompat(mrStream);
1377 TypeSerializer aSerializer(mrStream);
1378 GfxLink aGfxLink;
1379 aSerializer.readGfxLink(aGfxLink);
1380 Point aPoint;
1381 aSerializer.readPoint(aPoint);
1382 Size aSize;
1383 aSerializer.readSize(aSize);
1384 GDIMetaFile aSubst;
1385 Read(aSubst);
1386
1387 pAction->SetLink(aGfxLink);
1388 pAction->SetPoint(aPoint);
1389 pAction->SetSize(aSize);
1390 pAction->SetSubstitute(aSubst);
1391
1392 return pAction;
1393}
1394
1396{
1398
1399 VersionCompatRead aCompat(mrStream);
1400 TypeSerializer aSerializer(mrStream);
1401
1402 Point aRefPoint;
1403 aSerializer.readPoint(aRefPoint);
1404 bool bSet(false);
1406
1407 pAction->SetRefPoint(aRefPoint);
1408 pAction->SetSetting(bSet);
1409
1410 return pAction;
1411}
1412
1414{
1416
1417 VersionCompatRead aCompat(mrStream);
1418 OString aComment;
1420 sal_Int32 nValue(0);
1421 sal_uInt32 nDataSize(0);
1422 mrStream.ReadInt32(nValue).ReadUInt32(nDataSize);
1423
1424 if (nDataSize > mrStream.remainingSize())
1425 {
1426 SAL_WARN("vcl.gdi", "Parsing error: " << mrStream.remainingSize() << " available data, but "
1427 << nDataSize << " claimed, truncating");
1428 nDataSize = mrStream.remainingSize();
1429 }
1430
1431 SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << aComment);
1432
1433 std::unique_ptr<sal_uInt8[]> pData;
1434 pData.reset();
1435
1436 if (nDataSize)
1437 {
1438 pData.reset(new sal_uInt8[nDataSize]);
1439 mrStream.ReadBytes(pData.get(), nDataSize);
1440 }
1441
1442 pAction->SetComment(aComment);
1443 pAction->SetDataSize(nDataSize);
1444 pAction->SetValue(nValue);
1445 pAction->SetData(pData.get(), nDataSize);
1446
1447 return pAction;
1448}
1449
1451{
1453
1454 VersionCompatRead aCompat(mrStream);
1455 sal_uInt32 tmp(0);
1456 mrStream.ReadUInt32(tmp);
1457
1458 pAction->SetLayoutMode(static_cast<vcl::text::ComplexTextLayoutFlags>(tmp));
1459
1460 return pAction;
1461}
1462
1464{
1466
1467 VersionCompatRead aCompat(mrStream);
1468 sal_uInt16 nTmp = 0;
1469 mrStream.ReadUInt16(nTmp);
1470
1471 pAction->SetTextLanguage(static_cast<LanguageType>(nTmp));
1472
1473 return pAction;
1474}
1475
1477{
1479}
1480/* 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:585
void UseCanvas(bool _bUseCanvas)
Definition: gdimtf.cxx:2343
void Clear()
Definition: gdimtf.cxx:273
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:180
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:177
Definition: hatch.hxx:47
void clear()
Definition: kernarray.hxx:75
bool empty() const
Definition: kernarray.hxx:74
void push_back(sal_Int32 nUnit)
Definition: kernarray.hxx:71
const OString & GetComment() const
Definition: metaact.hxx:1709
Converts old SVGDI aka SVM1 format data to current VCLMTF aka SVM2 format metafile data.
SvStream & ReadCharAsBool(bool &rBool)
sal_uInt64 Tell() const
void SetEndian(SvStreamEndian SvStreamEndian)
bool good() const
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & ReadDouble(double &rDouble)
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:1189
rtl::Reference< MetaAction > PieHandler()
Definition: SvmReader.cxx:451
rtl::Reference< MetaAction > TextColorHandler()
Definition: SvmReader.cxx:1160
rtl::Reference< MetaAction > PolyPolygonHandler()
Definition: SvmReader.cxx:544
rtl::Reference< MetaAction > ClipRegionHandler()
Definition: SvmReader.cxx:1104
rtl::Reference< MetaAction > PointHandler()
Definition: SvmReader.cxx:336
rtl::Reference< MetaAction > ArcHandler()
Definition: SvmReader.cxx:430
rtl::Reference< MetaAction > RefPointHandler()
Definition: SvmReader.cxx:1395
rtl::Reference< MetaAction > GradientHandler()
Definition: SvmReader.cxx:1040
rtl::Reference< MetaAction > BmpExScalePartHandler()
Definition: SvmReader.cxx:948
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:910
rtl::Reference< MetaAction > TextArrayHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:630
rtl::Reference< MetaAction > MapModeHandler()
Definition: SvmReader.cxx:1234
SvStream & mrStream
Definition: SvmReader.hxx:29
rtl::Reference< MetaAction > MaskHandler()
Definition: SvmReader.cxx:974
rtl::Reference< MetaAction > LineColorHandler()
Definition: SvmReader.cxx:289
rtl::Reference< MetaAction > HatchHandler()
Definition: SvmReader.cxx:1075
rtl::Reference< MetaAction > TextAlignHandler()
Definition: SvmReader.cxx:1221
rtl::Reference< MetaAction > RasterOpHandler()
Definition: SvmReader.cxx:1286
rtl::Reference< MetaAction > ISectRegionClipRegionHandler()
Definition: SvmReader.cxx:1134
rtl::Reference< MetaAction > BmpHandler()
Definition: SvmReader.cxx:846
rtl::Reference< MetaAction > CommentHandler()
Definition: SvmReader.cxx:1413
rtl::Reference< MetaAction > PopHandler()
Definition: SvmReader.cxx:1277
rtl::Reference< MetaAction > StretchTextHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:735
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:1300
rtl::Reference< MetaAction > EllipseHandler()
Definition: SvmReader.cxx:415
rtl::Reference< MetaAction > PolyLineHandler()
Definition: SvmReader.cxx:493
rtl::Reference< MetaAction > MoveClipRegionHandler()
Definition: SvmReader.cxx:1146
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:1316
rtl::Reference< MetaAction > PolygonHandler()
Definition: SvmReader.cxx:522
rtl::Reference< MetaAction > PushHandler()
Definition: SvmReader.cxx:1264
rtl::Reference< MetaAction > TextFillColorHandler()
Definition: SvmReader.cxx:1173
rtl::Reference< MetaAction > TextLanguageHandler()
Definition: SvmReader.cxx:1463
rtl::Reference< MetaAction > ISectRectClipRegionHandler()
Definition: SvmReader.cxx:1120
rtl::Reference< MetaAction > BmpScalePartHandler()
Definition: SvmReader.cxx:884
rtl::Reference< MetaAction > TextRectHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:778
static rtl::Reference< MetaAction > DefaultHandler()
Definition: SvmReader.cxx:1476
rtl::Reference< MetaAction > MaskScalePartHandler()
Definition: SvmReader.cxx:1011
rtl::Reference< MetaAction > MetaActionHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:154
rtl::Reference< MetaAction > EPSHandler()
Definition: SvmReader.cxx:1372
rtl::Reference< MetaAction > RectHandler()
Definition: SvmReader.cxx:322
rtl::Reference< MetaAction > OverlineColorHandler()
Definition: SvmReader.cxx:1205
rtl::Reference< MetaAction > RoundRectHandler()
Definition: SvmReader.cxx:395
rtl::Reference< MetaAction > BmpScaleHandler()
Definition: SvmReader.cxx:863
rtl::Reference< MetaAction > WallpaperHandler()
Definition: SvmReader.cxx:1091
rtl::Reference< MetaAction > MaskScaleHandler()
Definition: SvmReader.cxx:991
rtl::Reference< MetaAction > BmpExScaleHandler()
Definition: SvmReader.cxx:927
rtl::Reference< MetaAction > LineHandler()
Definition: SvmReader.cxx:368
rtl::Reference< MetaAction > GradientExHandler()
Definition: SvmReader.cxx:1058
rtl::Reference< MetaAction > FontHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:1248
rtl::Reference< MetaAction > LayoutModeHandler()
Definition: SvmReader.cxx:1450
rtl::Reference< MetaAction > TextLineHandler()
Definition: SvmReader.cxx:808
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:913
ColorTransparency
int nCount
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1623
bool ReadDIB(Bitmap &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1614
#define SVSTREAM_FILEFORMAT_ERROR
sal_Int16 nValue
SvStream & ReadFont(SvStream &rIStm, vcl::Font &rFont)
Definition: font/font.cxx:591
FontLineStyle
FontStrikeout
SvStream & ReadHatch(SvStream &rIStm, Hatch &rHatch)
Definition: gdi/hatch.cxx:79
sal_Int32 nIndex
uno_Any a
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