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 pAction->SetWidth(nTempWidth);
822
823 sal_uInt32 nTempStrikeout(0);
824 mrStream.ReadUInt32(nTempStrikeout);
825 sal_uInt32 nTempUnderline(0);
826 mrStream.ReadUInt32(nTempUnderline);
827
828 pAction->SetStrikeout(static_cast<FontStrikeout>(nTempStrikeout & SAL_MAX_ENUM));
829 pAction->SetUnderline(static_cast<FontLineStyle>(nTempUnderline & SAL_MAX_ENUM));
830
831 if (aCompat.GetVersion() >= 2)
832 {
833 sal_uInt32 nTempOverline(0);
834 mrStream.ReadUInt32(nTempOverline);
835 pAction->SetOverline(static_cast<FontLineStyle>(nTempOverline & SAL_MAX_ENUM));
836 }
837
838 return pAction;
839}
840
842{
844
846 Bitmap aBmp;
847 ReadDIB(aBmp, mrStream, true);
848 TypeSerializer aSerializer(mrStream);
849 Point aPoint;
850 aSerializer.readPoint(aPoint);
851
852 pAction->SetBitmap(aBmp);
853 pAction->SetPoint(aPoint);
854
855 return pAction;
856}
857
859{
861
863 Bitmap aBmp;
864 ReadDIB(aBmp, mrStream, true);
865 TypeSerializer aSerializer(mrStream);
866 Point aPoint;
867 aSerializer.readPoint(aPoint);
868
869 Size aSz;
870 aSerializer.readSize(aSz);
871
872 pAction->SetBitmap(aBmp);
873 pAction->SetPoint(aPoint);
874 pAction->SetSize(aSz);
875
876 return pAction;
877}
878
880{
882
884 Bitmap aBmp;
885 ReadDIB(aBmp, mrStream, true);
886 TypeSerializer aSerializer(mrStream);
887 Point aDestPoint;
888 aSerializer.readPoint(aDestPoint);
889 Size aDestSize;
890 aSerializer.readSize(aDestSize);
891 Point aSrcPoint;
892 aSerializer.readPoint(aSrcPoint);
893 Size aSrcSize;
894 aSerializer.readSize(aSrcSize);
895
896 pAction->SetBitmap(aBmp);
897 pAction->SetDestPoint(aDestPoint);
898 pAction->SetDestSize(aDestSize);
899 pAction->SetSrcPoint(aSrcPoint);
900 pAction->SetSrcSize(aSrcSize);
901
902 return pAction;
903}
904
906{
908
910 BitmapEx aBmpEx;
911 ReadDIBBitmapEx(aBmpEx, mrStream);
912 TypeSerializer aSerializer(mrStream);
913 Point aPoint;
914 aSerializer.readPoint(aPoint);
915
916 pAction->SetPoint(aPoint);
917 pAction->SetBitmapEx(aBmpEx);
918
919 return pAction;
920}
921
923{
925
927 BitmapEx aBmpEx;
928 ReadDIBBitmapEx(aBmpEx, mrStream);
929 TypeSerializer aSerializer(mrStream);
930 Point aPoint;
931 aSerializer.readPoint(aPoint);
932
933 Size aSize;
934 aSerializer.readSize(aSize);
935
936 pAction->SetBitmapEx(aBmpEx);
937 pAction->SetPoint(aPoint);
938 pAction->SetSize(aSize);
939
940 return pAction;
941}
942
944{
946
948 BitmapEx aBmpEx;
949 ReadDIBBitmapEx(aBmpEx, mrStream);
950 TypeSerializer aSerializer(mrStream);
951 Point aDstPoint;
952 aSerializer.readPoint(aDstPoint);
953 Size aDstSize;
954 aSerializer.readSize(aDstSize);
955 Point aSrcPoint;
956 aSerializer.readPoint(aSrcPoint);
957 Size aSrcSize;
958 aSerializer.readSize(aSrcSize);
959
960 pAction->SetBitmapEx(aBmpEx);
961 pAction->SetDestPoint(aDstPoint);
962 pAction->SetDestSize(aDstSize);
963 pAction->SetSrcPoint(aSrcPoint);
964 pAction->SetSrcSize(aSrcSize);
965
966 return pAction;
967}
968
970{
972
974 Bitmap aBmp;
975 ReadDIB(aBmp, mrStream, true);
976 TypeSerializer aSerializer(mrStream);
977 Point aPoint;
978 aSerializer.readPoint(aPoint);
979
980 pAction->SetBitmap(aBmp);
981 pAction->SetPoint(aPoint);
982
983 return pAction;
984}
985
987{
989
991 Bitmap aBmp;
992 ReadDIB(aBmp, mrStream, true);
993 TypeSerializer aSerializer(mrStream);
994 Point aPoint;
995 aSerializer.readPoint(aPoint);
996 Size aSize;
997 aSerializer.readSize(aSize);
998
999 pAction->SetBitmap(aBmp);
1000 pAction->SetPoint(aPoint);
1001 pAction->SetSize(aSize);
1002
1003 return pAction;
1004}
1005
1007{
1009
1010 VersionCompatRead aCompat(mrStream);
1011 Bitmap aBmp;
1012 ReadDIB(aBmp, mrStream, true);
1013 Color aColor;
1014 ReadColor(aColor);
1015 TypeSerializer aSerializer(mrStream);
1016 Point aDstPt;
1017 aSerializer.readPoint(aDstPt);
1018 Size aDstSz;
1019 aSerializer.readSize(aDstSz);
1020 Point aSrcPt;
1021 aSerializer.readPoint(aSrcPt);
1022 Size aSrcSz;
1023 aSerializer.readSize(aSrcSz);
1024
1025 pAction->SetBitmap(aBmp);
1026 pAction->SetColor(aColor);
1027 pAction->SetDestPoint(aDstPt);
1028 pAction->SetDestSize(aDstSz);
1029 pAction->SetSrcPoint(aSrcPt);
1030 pAction->SetSrcSize(aSrcSz);
1031
1032 return pAction;
1033}
1034
1036{
1038
1039 VersionCompatRead aCompat(mrStream);
1040 TypeSerializer aSerializer(mrStream);
1041
1042 tools::Rectangle aRect;
1043 aSerializer.readRectangle(aRect);
1044 Gradient aGradient;
1045 aSerializer.readGradient(aGradient);
1046
1047 pAction->SetRect(aRect);
1048 pAction->SetGradient(aGradient);
1049
1050 return pAction;
1051}
1052
1054{
1056
1057 VersionCompatRead aCompat(mrStream);
1058 tools::PolyPolygon aPolyPoly;
1059 ReadPolyPolygon(mrStream, aPolyPoly);
1060 TypeSerializer aSerializer(mrStream);
1061 Gradient aGradient;
1062 aSerializer.readGradient(aGradient);
1063
1064 pAction->SetGradient(aGradient);
1065 pAction->SetPolyPolygon(aPolyPoly);
1066
1067 return pAction;
1068}
1069
1071{
1073
1074 VersionCompatRead aCompat(mrStream);
1075 tools::PolyPolygon aPolyPoly;
1076 ReadPolyPolygon(mrStream, aPolyPoly);
1077 Hatch aHatch;
1078 ReadHatch(mrStream, aHatch);
1079
1080 pAction->SetPolyPolygon(aPolyPoly);
1081 pAction->SetHatch(aHatch);
1082
1083 return pAction;
1084}
1085
1087{
1089
1090 VersionCompatRead aCompat(mrStream);
1091 Wallpaper aWallpaper;
1092 ReadWallpaper(mrStream, aWallpaper);
1093
1094 pAction->SetWallpaper(aWallpaper);
1095
1096 return pAction;
1097}
1098
1100{
1102
1103 VersionCompatRead aCompat(mrStream);
1104 vcl::Region aRegion;
1105 ReadRegion(mrStream, aRegion);
1106 bool aClip(false);
1107 mrStream.ReadCharAsBool(aClip);
1108
1109 pAction->SetRegion(aRegion);
1110 pAction->SetClipping(aClip);
1111
1112 return pAction;
1113}
1114
1116{
1118
1119 VersionCompatRead aCompat(mrStream);
1120 TypeSerializer aSerializer(mrStream);
1121 tools::Rectangle aRect;
1122 aSerializer.readRectangle(aRect);
1123
1124 pAction->SetRect(aRect);
1125
1126 return pAction;
1127}
1128
1130{
1132
1133 VersionCompatRead aCompat(mrStream);
1134 vcl::Region aRegion;
1135 ReadRegion(mrStream, aRegion);
1136 pAction->SetRegion(aRegion);
1137
1138 return pAction;
1139}
1140
1142{
1144
1145 VersionCompatRead aCompat(mrStream);
1146 sal_Int32 nTmpHM(0), nTmpVM(0);
1147 mrStream.ReadInt32(nTmpHM).ReadInt32(nTmpVM);
1148
1149 pAction->SetHorzMove(nTmpHM);
1150 pAction->SetVertMove(nTmpVM);
1151
1152 return pAction;
1153}
1154
1156{
1158
1159 VersionCompatRead aCompat(mrStream);
1160 Color aColor;
1161 ReadColor(aColor);
1162
1163 pAction->SetColor(aColor);
1164
1165 return pAction;
1166}
1167
1169{
1171
1172 VersionCompatRead aCompat(mrStream);
1173 Color aColor;
1174 ReadColor(aColor);
1175 bool bSet(false);
1177
1178 pAction->SetColor(aColor);
1179 pAction->SetSetting(bSet);
1180
1181 return pAction;
1182}
1183
1185{
1187
1188 VersionCompatRead aCompat(mrStream);
1189 Color aColor;
1190 ReadColor(aColor);
1191 bool bSet(false);
1193
1194 pAction->SetColor(aColor);
1195 pAction->SetSetting(bSet);
1196
1197 return pAction;
1198}
1199
1201{
1203
1204 VersionCompatRead aCompat(mrStream);
1205 Color aColor;
1206 ReadColor(aColor);
1207 bool bSet(false);
1209
1210 pAction->SetColor(aColor);
1211 pAction->SetSetting(bSet);
1212
1213 return pAction;
1214}
1215
1217{
1219
1220 VersionCompatRead aCompat(mrStream);
1221 sal_uInt16 nTmp16(0);
1222 mrStream.ReadUInt16(nTmp16);
1223
1224 pAction->SetTextAlign(static_cast<TextAlign>(nTmp16));
1225
1226 return pAction;
1227}
1228
1230{
1232
1233 VersionCompatRead aCompat(mrStream);
1234 TypeSerializer aSerializer(mrStream);
1235 MapMode aMapMode;
1236 aSerializer.readMapMode(aMapMode);
1237
1238 pAction->SetMapMode(aMapMode);
1239
1240 return pAction;
1241}
1242
1244{
1246
1247 VersionCompatRead aCompat(mrStream);
1248 vcl::Font aFont;
1249 ReadFont(mrStream, aFont);
1250 pData->meActualCharSet = aFont.GetCharSet();
1251 if (pData->meActualCharSet == RTL_TEXTENCODING_DONTKNOW)
1252 pData->meActualCharSet = osl_getThreadTextEncoding();
1253
1254 pAction->SetFont(aFont);
1255
1256 return pAction;
1257}
1258
1260{
1262
1263 VersionCompatRead aCompat(mrStream);
1264 sal_uInt16 nTmp(0);
1265 mrStream.ReadUInt16(nTmp);
1266
1267 pAction->SetPushFlags(static_cast<vcl::PushFlags>(nTmp));
1268
1269 return pAction;
1270}
1271
1273{
1275
1276 VersionCompatRead aCompat(mrStream);
1277
1278 return pAction;
1279}
1280
1282{
1284
1285 sal_uInt16 nTmp16(0);
1286
1287 VersionCompatRead aCompat(mrStream);
1288 mrStream.ReadUInt16(nTmp16);
1289
1290 pAction->SetRasterOp(static_cast<RasterOp>(nTmp16));
1291
1292 return pAction;
1293}
1294
1296{
1298
1299 VersionCompatRead aCompat(mrStream);
1300 tools::PolyPolygon aPolyPoly;
1301 ReadPolyPolygon(mrStream, aPolyPoly);
1302 sal_uInt16 nTransPercent(0);
1303 mrStream.ReadUInt16(nTransPercent);
1304
1305 pAction->SetPolyPolygon(aPolyPoly);
1306 pAction->SetTransparence(nTransPercent);
1307
1308 return pAction;
1309}
1310
1312{
1314
1315 VersionCompatRead aCompat(mrStream);
1316 GDIMetaFile aMtf;
1317 SvmReader aReader(mrStream);
1318 aReader.Read(aMtf, pData);
1319 TypeSerializer aSerializer(mrStream);
1320 Point aPoint;
1321 aSerializer.readPoint(aPoint);
1322
1323 Size aSize;
1324 aSerializer.readSize(aSize);
1325
1326 Gradient aGradient;
1327 aSerializer.readGradient(aGradient);
1328
1329 pAction->SetGDIMetaFile(aMtf);
1330 pAction->SetPoint(aPoint);
1331 pAction->SetSize(aSize);
1332 pAction->SetGradient(aGradient);
1333
1334 return pAction;
1335}
1336
1338{
1340
1341 VersionCompatRead aCompat(mrStream);
1342 TypeSerializer aSerializer(mrStream);
1343 GfxLink aGfxLink;
1344 aSerializer.readGfxLink(aGfxLink);
1345 Point aPoint;
1346 aSerializer.readPoint(aPoint);
1347 Size aSize;
1348 aSerializer.readSize(aSize);
1349 GDIMetaFile aSubst;
1350 Read(aSubst);
1351
1352 pAction->SetLink(aGfxLink);
1353 pAction->SetPoint(aPoint);
1354 pAction->SetSize(aSize);
1355 pAction->SetSubstitute(aSubst);
1356
1357 return pAction;
1358}
1359
1361{
1363
1364 VersionCompatRead aCompat(mrStream);
1365 TypeSerializer aSerializer(mrStream);
1366
1367 Point aRefPoint;
1368 aSerializer.readPoint(aRefPoint);
1369 bool bSet(false);
1371
1372 pAction->SetRefPoint(aRefPoint);
1373 pAction->SetSetting(bSet);
1374
1375 return pAction;
1376}
1377
1379{
1381
1382 VersionCompatRead aCompat(mrStream);
1383 OString aComment;
1385 sal_Int32 nValue(0);
1386 sal_uInt32 nDataSize(0);
1387 mrStream.ReadInt32(nValue).ReadUInt32(nDataSize);
1388
1389 if (nDataSize > mrStream.remainingSize())
1390 {
1391 SAL_WARN("vcl.gdi", "Parsing error: " << mrStream.remainingSize() << " available data, but "
1392 << nDataSize << " claimed, truncating");
1393 nDataSize = mrStream.remainingSize();
1394 }
1395
1396 SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << aComment);
1397
1398 std::unique_ptr<sal_uInt8[]> pData;
1399 pData.reset();
1400
1401 if (nDataSize)
1402 {
1403 pData.reset(new sal_uInt8[nDataSize]);
1404 mrStream.ReadBytes(pData.get(), nDataSize);
1405 }
1406
1407 pAction->SetComment(aComment);
1408 pAction->SetDataSize(nDataSize);
1409 pAction->SetValue(nValue);
1410 pAction->SetData(pData.get(), nDataSize);
1411
1412 return pAction;
1413}
1414
1416{
1418
1419 VersionCompatRead aCompat(mrStream);
1420 sal_uInt32 tmp(0);
1421 mrStream.ReadUInt32(tmp);
1422
1423 pAction->SetLayoutMode(static_cast<vcl::text::ComplexTextLayoutFlags>(tmp));
1424
1425 return pAction;
1426}
1427
1429{
1431
1432 VersionCompatRead aCompat(mrStream);
1433 sal_uInt16 nTmp = 0;
1434 mrStream.ReadUInt16(nTmp);
1435
1436 pAction->SetTextLanguage(static_cast<LanguageType>(nTmp));
1437
1438 return pAction;
1439}
1440
1442{
1444}
1445/* 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
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:1700
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)
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:1184
rtl::Reference< MetaAction > PieHandler()
Definition: SvmReader.cxx:451
rtl::Reference< MetaAction > TextColorHandler()
Definition: SvmReader.cxx:1155
rtl::Reference< MetaAction > PolyPolygonHandler()
Definition: SvmReader.cxx:544
rtl::Reference< MetaAction > ClipRegionHandler()
Definition: SvmReader.cxx:1099
rtl::Reference< MetaAction > PointHandler()
Definition: SvmReader.cxx:336
rtl::Reference< MetaAction > ArcHandler()
Definition: SvmReader.cxx:430
rtl::Reference< MetaAction > RefPointHandler()
Definition: SvmReader.cxx:1360
rtl::Reference< MetaAction > GradientHandler()
Definition: SvmReader.cxx:1035
rtl::Reference< MetaAction > BmpExScalePartHandler()
Definition: SvmReader.cxx:943
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:905
rtl::Reference< MetaAction > TextArrayHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:630
rtl::Reference< MetaAction > MapModeHandler()
Definition: SvmReader.cxx:1229
SvStream & mrStream
Definition: SvmReader.hxx:29
rtl::Reference< MetaAction > MaskHandler()
Definition: SvmReader.cxx:969
rtl::Reference< MetaAction > LineColorHandler()
Definition: SvmReader.cxx:289
rtl::Reference< MetaAction > HatchHandler()
Definition: SvmReader.cxx:1070
rtl::Reference< MetaAction > TextAlignHandler()
Definition: SvmReader.cxx:1216
rtl::Reference< MetaAction > RasterOpHandler()
Definition: SvmReader.cxx:1281
rtl::Reference< MetaAction > ISectRegionClipRegionHandler()
Definition: SvmReader.cxx:1129
rtl::Reference< MetaAction > BmpHandler()
Definition: SvmReader.cxx:841
rtl::Reference< MetaAction > CommentHandler()
Definition: SvmReader.cxx:1378
rtl::Reference< MetaAction > PopHandler()
Definition: SvmReader.cxx:1272
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:1295
rtl::Reference< MetaAction > EllipseHandler()
Definition: SvmReader.cxx:415
rtl::Reference< MetaAction > PolyLineHandler()
Definition: SvmReader.cxx:493
rtl::Reference< MetaAction > MoveClipRegionHandler()
Definition: SvmReader.cxx:1141
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:1311
rtl::Reference< MetaAction > PolygonHandler()
Definition: SvmReader.cxx:522
rtl::Reference< MetaAction > PushHandler()
Definition: SvmReader.cxx:1259
rtl::Reference< MetaAction > TextFillColorHandler()
Definition: SvmReader.cxx:1168
rtl::Reference< MetaAction > TextLanguageHandler()
Definition: SvmReader.cxx:1428
rtl::Reference< MetaAction > ISectRectClipRegionHandler()
Definition: SvmReader.cxx:1115
rtl::Reference< MetaAction > BmpScalePartHandler()
Definition: SvmReader.cxx:879
rtl::Reference< MetaAction > TextRectHandler(const ImplMetaReadData *pData)
Definition: SvmReader.cxx:778
static rtl::Reference< MetaAction > DefaultHandler()
Definition: SvmReader.cxx:1441
rtl::Reference< MetaAction > MaskScalePartHandler()
Definition: SvmReader.cxx:1006
rtl::Reference< MetaAction > MetaActionHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:154
rtl::Reference< MetaAction > EPSHandler()
Definition: SvmReader.cxx:1337
rtl::Reference< MetaAction > RectHandler()
Definition: SvmReader.cxx:322
rtl::Reference< MetaAction > OverlineColorHandler()
Definition: SvmReader.cxx:1200
rtl::Reference< MetaAction > RoundRectHandler()
Definition: SvmReader.cxx:395
rtl::Reference< MetaAction > BmpScaleHandler()
Definition: SvmReader.cxx:858
rtl::Reference< MetaAction > WallpaperHandler()
Definition: SvmReader.cxx:1086
rtl::Reference< MetaAction > MaskScaleHandler()
Definition: SvmReader.cxx:986
rtl::Reference< MetaAction > BmpExScaleHandler()
Definition: SvmReader.cxx:922
rtl::Reference< MetaAction > LineHandler()
Definition: SvmReader.cxx:368
rtl::Reference< MetaAction > GradientExHandler()
Definition: SvmReader.cxx:1053
rtl::Reference< MetaAction > FontHandler(ImplMetaReadData *pData)
Definition: SvmReader.cxx:1243
rtl::Reference< MetaAction > LayoutModeHandler()
Definition: SvmReader.cxx:1415
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:1676
bool ReadDIB(Bitmap &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1667
#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
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