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