LibreOffice Module vcl (master)  1
impgraph.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/config.h>
21 #include <sal/log.hxx>
22 
23 #include <comphelper/fileformat.h>
24 #include <o3tl/make_shared.hxx>
25 #include <tools/fract.hxx>
26 #include <tools/vcompat.hxx>
27 #include <tools/urlobj.hxx>
28 #include <tools/stream.hxx>
29 #include <unotools/ucbhelper.hxx>
31 #include <unotools/tempfile.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/graphicfilter.hxx>
34 #include <vcl/virdev.hxx>
35 #include <vcl/gfxlink.hxx>
36 #include <vcl/cvtgrf.hxx>
37 #include <vcl/graph.hxx>
38 #include <vcl/metaact.hxx>
39 #include <impgraph.hxx>
40 #include <com/sun/star/graphic/XPrimitive2D.hpp>
41 #include <vcl/dibtools.hxx>
42 #include <map>
43 #include <memory>
44 #include <vcl/gdimetafiletools.hxx>
45 #include <TypeSerializer.hxx>
46 #include <vcl/pdfread.hxx>
47 
48 #define GRAPHIC_MTFTOBMP_MAXEXT 2048
49 #define GRAPHIC_STREAMBUFSIZE 8192UL
50 
51 #define SYS_WINMETAFILE 0x00000003L
52 #define SYS_WNTMETAFILE 0x00000004L
53 #define SYS_OS2METAFILE 0x00000005L
54 #define SYS_MACMETAFILE 0x00000006L
55 
56 #define GRAPHIC_FORMAT_50 COMPAT_FORMAT( 'G', 'R', 'F', '5' )
57 #define NATIVE_FORMAT_50 COMPAT_FORMAT( 'N', 'A', 'T', '5' )
58 
59 namespace {
60 
61 constexpr sal_uInt32 constSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
62 constexpr sal_uInt32 constWmfMagic((sal_uInt32('w') << 24) | (sal_uInt32('m') << 16) | (sal_uInt32('f') << 8) | sal_uInt32('0'));
63 constexpr sal_uInt32 constEmfMagic((sal_uInt32('e') << 24) | (sal_uInt32('m') << 16) | (sal_uInt32('f') << 8) | sal_uInt32('0'));
64 constexpr sal_uInt32 constPdfMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
65 
66 }
67 
68 using namespace com::sun::star;
69 
71 {
72 private:
74  OUString maOriginURL;
75 
76 public:
77  ImpSwapFile(INetURLObject const & rSwapURL, OUString const & rOriginURL)
78  : maSwapURL(rSwapURL)
79  , maOriginURL(rOriginURL)
80  {
81  }
82 
83  ~ImpSwapFile() COVERITY_NOEXCEPT_FALSE
84  {
86  }
87 
89  {
90  return maSwapURL;
91  }
92 
93  OUString getSwapURLString()
94  {
96  }
97 
98  OUString const & getOriginURL() { return maOriginURL; }
99 
100  std::unique_ptr<SvStream> openOutputStream()
101  {
102  OUString sSwapURL = getSwapURLString();
103  if (!sSwapURL.isEmpty())
104  {
105  try
106  {
107  return utl::UcbStreamHelper::CreateStream(sSwapURL, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
108  }
109  catch (const css::uno::Exception&)
110  {
111  }
112  }
113  return std::unique_ptr<SvStream>();
114  }
115 };
116 
118 {
119  if (mpSwapFile)
120  return mpSwapFile->getSwapURL().GetMainURL(INetURLObject::DecodeMechanism::NONE);
121  return OUString();
122 }
123 
125  meType ( GraphicType::NONE ),
126  mnSizeBytes ( 0 ),
127  mbSwapOut ( false ),
128  mbDummyContext ( false ),
129  maLastUsed (std::chrono::high_resolution_clock::now()),
130  mbPrepared ( false )
131 {
132 }
133 
135  : maMetaFile(rImpGraphic.maMetaFile)
136  , maBitmapEx(rImpGraphic.maBitmapEx)
137  , maSwapInfo(rImpGraphic.maSwapInfo)
138  , mpContext(rImpGraphic.mpContext)
139  , mpSwapFile(rImpGraphic.mpSwapFile)
140  , mpGfxLink(rImpGraphic.mpGfxLink)
141  , meType(rImpGraphic.meType)
142  , mnSizeBytes(rImpGraphic.mnSizeBytes)
143  , mbSwapOut(rImpGraphic.mbSwapOut)
144  , mbDummyContext(rImpGraphic.mbDummyContext)
145  , maVectorGraphicData(rImpGraphic.maVectorGraphicData)
146  , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
147  , maLastUsed (std::chrono::high_resolution_clock::now())
148  , mbPrepared (rImpGraphic.mbPrepared)
149 {
150  if( rImpGraphic.mpAnimation )
151  {
152  mpAnimation = std::make_unique<Animation>( *rImpGraphic.mpAnimation );
153  maBitmapEx = mpAnimation->GetBitmapEx();
154  }
155 }
156 
157 ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
158  : maMetaFile(std::move(rImpGraphic.maMetaFile))
159  , maBitmapEx(std::move(rImpGraphic.maBitmapEx))
160  , maSwapInfo(std::move(rImpGraphic.maSwapInfo))
161  , mpAnimation(std::move(rImpGraphic.mpAnimation))
162  , mpContext(std::move(rImpGraphic.mpContext))
163  , mpSwapFile(std::move(rImpGraphic.mpSwapFile))
164  , mpGfxLink(std::move(rImpGraphic.mpGfxLink))
165  , meType(rImpGraphic.meType)
166  , mnSizeBytes(rImpGraphic.mnSizeBytes)
167  , mbSwapOut(rImpGraphic.mbSwapOut)
168  , mbDummyContext(rImpGraphic.mbDummyContext)
169  , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
170  , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
171  , maLastUsed (std::chrono::high_resolution_clock::now())
172  , mbPrepared (rImpGraphic.mbPrepared)
173 {
174  rImpGraphic.ImplClear();
175  rImpGraphic.mbDummyContext = false;
176 }
177 
178 ImpGraphic::ImpGraphic(GraphicExternalLink const & rGraphicExternalLink) :
180  mnSizeBytes ( 0 ),
181  mbSwapOut ( false ),
182  mbDummyContext ( false ),
183  maGraphicExternalLink(rGraphicExternalLink),
184  maLastUsed (std::chrono::high_resolution_clock::now()),
185  mbPrepared (false)
186 {
187 }
188 
189 ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
190  maBitmapEx ( rBitmap ),
191  meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
192  mnSizeBytes ( 0 ),
193  mbSwapOut ( false ),
194  mbDummyContext ( false ),
195  maLastUsed (std::chrono::high_resolution_clock::now()),
196  mbPrepared (false)
197 {
198 }
199 
200 ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
201  maBitmapEx ( rBitmapEx ),
202  meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
203  mnSizeBytes ( 0 ),
204  mbSwapOut ( false ),
205  mbDummyContext ( false ),
206  maLastUsed (std::chrono::high_resolution_clock::now()),
207  mbPrepared (false)
208 {
209 }
210 
211 ImpGraphic::ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr)
212 : meType( rVectorGraphicDataPtr ? GraphicType::Bitmap : GraphicType::NONE ),
213  mnSizeBytes( 0 ),
214  mbSwapOut( false ),
215  mbDummyContext ( false ),
216  maVectorGraphicData(rVectorGraphicDataPtr),
217  maLastUsed (std::chrono::high_resolution_clock::now()),
218  mbPrepared (false)
219 {
220 }
221 
222 ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
223  maBitmapEx ( rAnimation.GetBitmapEx() ),
224  mpAnimation ( std::make_unique<Animation>( rAnimation ) ),
226  mnSizeBytes ( 0 ),
227  mbSwapOut ( false ),
228  mbDummyContext ( false ),
229  maLastUsed (std::chrono::high_resolution_clock::now()),
230  mbPrepared (false)
231 {
232 }
233 
235  maMetaFile ( rMtf ),
237  mnSizeBytes ( 0 ),
238  mbSwapOut ( false ),
239  mbDummyContext ( false ),
240  maLastUsed (std::chrono::high_resolution_clock::now()),
241  mbPrepared (false)
242 {
243 }
244 
246 {
248 }
249 
251 {
252  if( &rImpGraphic != this )
253  {
254  sal_Int64 aOldSizeBytes = mnSizeBytes;
255 
256  maMetaFile = rImpGraphic.maMetaFile;
257  meType = rImpGraphic.meType;
258  mnSizeBytes = rImpGraphic.mnSizeBytes;
259 
260  maSwapInfo = rImpGraphic.maSwapInfo;
261  mpContext = rImpGraphic.mpContext;
262  mbDummyContext = rImpGraphic.mbDummyContext;
264 
265  mpAnimation.reset();
266 
267  if ( rImpGraphic.mpAnimation )
268  {
269  mpAnimation = std::make_unique<Animation>( *rImpGraphic.mpAnimation );
270  maBitmapEx = mpAnimation->GetBitmapEx();
271  }
272  else
273  {
274  maBitmapEx = rImpGraphic.maBitmapEx;
275  }
276 
277  mbSwapOut = rImpGraphic.mbSwapOut;
278  mpSwapFile = rImpGraphic.mpSwapFile;
279  mbPrepared = rImpGraphic.mbPrepared;
280 
281  mpGfxLink = rImpGraphic.mpGfxLink;
282 
284  maLastUsed = std::chrono::high_resolution_clock::now();
285 
286  vcl::graphic::Manager::get().changeExisting(this, aOldSizeBytes);
287  }
288 
289  return *this;
290 }
291 
293 {
294  sal_Int64 aOldSizeBytes = mnSizeBytes;
295 
296  maMetaFile = std::move(rImpGraphic.maMetaFile);
297  meType = rImpGraphic.meType;
298  mnSizeBytes = rImpGraphic.mnSizeBytes;
299  maSwapInfo = std::move(rImpGraphic.maSwapInfo);
300  mpContext = std::move(rImpGraphic.mpContext);
301  mbDummyContext = rImpGraphic.mbDummyContext;
302  mpAnimation = std::move(rImpGraphic.mpAnimation);
303  maBitmapEx = std::move(rImpGraphic.maBitmapEx);
304  mbSwapOut = rImpGraphic.mbSwapOut;
305  mpSwapFile = std::move(rImpGraphic.mpSwapFile);
306  mpGfxLink = std::move(rImpGraphic.mpGfxLink);
307  maVectorGraphicData = std::move(rImpGraphic.maVectorGraphicData);
308  maGraphicExternalLink = rImpGraphic.maGraphicExternalLink;
309  mbPrepared = rImpGraphic.mbPrepared;
310 
311  rImpGraphic.ImplClear();
312  rImpGraphic.mbDummyContext = false;
313  maLastUsed = std::chrono::high_resolution_clock::now();
314 
315  vcl::graphic::Manager::get().changeExisting(this, aOldSizeBytes);
316 
317  return *this;
318 }
319 
320 bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const
321 {
322  bool bRet = false;
323 
324  if( this == &rImpGraphic )
325  bRet = true;
326  else if (mbPrepared && rImpGraphic.mbPrepared)
327  {
328  bRet = (*mpGfxLink == *rImpGraphic.mpGfxLink);
329  }
330  else if (isAvailable() && rImpGraphic.isAvailable())
331  {
332  switch( meType )
333  {
334  case GraphicType::NONE:
335  bRet = true;
336  break;
337 
339  {
340  if( rImpGraphic.maMetaFile == maMetaFile )
341  bRet = true;
342  }
343  break;
344 
345  case GraphicType::Bitmap:
346  {
348  {
349  if(maVectorGraphicData == rImpGraphic.maVectorGraphicData)
350  {
351  // equal instances
352  bRet = true;
353  }
354  else if(rImpGraphic.maVectorGraphicData)
355  {
356  // equal content
357  bRet = (*maVectorGraphicData) == (*rImpGraphic.maVectorGraphicData);
358  }
359  }
360  else if( mpAnimation )
361  {
362  if( rImpGraphic.mpAnimation && ( *rImpGraphic.mpAnimation == *mpAnimation ) )
363  bRet = true;
364  }
365  else if( !rImpGraphic.mpAnimation && ( rImpGraphic.maBitmapEx == maBitmapEx ) )
366  {
367  bRet = true;
368  }
369  }
370  break;
371 
372  default:
373  break;
374  }
375  }
376 
377  return bRet;
378 }
379 
380 const std::shared_ptr<VectorGraphicData>& ImpGraphic::getVectorGraphicData() const
381 {
382  ensureAvailable();
383 
384  return maVectorGraphicData;
385 }
386 
388 {
389  if (isSwappedOut())
390  return;
391 
399 }
400 
402 {
403  maBitmapEx.Clear();
404  maMetaFile.Clear();
405  mpAnimation.reset();
406  mpGfxLink.reset();
407  maVectorGraphicData.reset();
408 }
409 
410 void ImpGraphic::ImplSetPrepared(bool bAnimated, const Size* pSizeHint)
411 {
412  mbPrepared = true;
413  mbSwapOut = true;
415 
416  SvMemoryStream aMemoryStream(const_cast<sal_uInt8*>(mpGfxLink->GetData()), mpGfxLink->GetDataSize(), StreamMode::READ | StreamMode::WRITE);
417 
418  if (pSizeHint)
419  {
420  maSwapInfo.maPrefSize = *pSizeHint;
421  maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
422  }
423 
424  GraphicDescriptor aDescriptor(aMemoryStream, nullptr);
425  if (aDescriptor.Detect(true))
426  {
427  if (!pSizeHint)
428  {
429  // If we have logic size, work with that, as later pixel -> logic
430  // conversion will work with the output device DPI, not the graphic
431  // DPI.
432  Size aLogSize = aDescriptor.GetSize_100TH_MM();
433  if (aLogSize.getWidth() && aLogSize.getHeight())
434  {
435  maSwapInfo.maPrefSize = aLogSize;
436  maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
437  }
438  else
439  {
440  maSwapInfo.maPrefSize = aDescriptor.GetSizePixel();
441  maSwapInfo.maPrefMapMode = MapMode(MapUnit::MapPixel);
442  }
443  }
444 
445  maSwapInfo.maSizePixel = aDescriptor.GetSizePixel();
446  maSwapInfo.mbIsTransparent = aDescriptor.IsTransparent();
447  maSwapInfo.mbIsAlpha = aDescriptor.IsAlpha();
448  } else {
449  maSwapInfo.mbIsTransparent = false;
450  maSwapInfo.mbIsAlpha = false;
451  }
452 
454  maSwapInfo.mbIsEPS = false;
455  maSwapInfo.mbIsAnimated = bAnimated;
456 }
457 
459 {
460  mpSwapFile.reset();
461  mbSwapOut = false;
462  mbPrepared = false;
463 
464  // cleanup
467  sal_Int64 nOldSize = mnSizeBytes;
468  mnSizeBytes = 0;
469  vcl::graphic::Manager::get().changeExisting(this, nOldSize);
471 }
472 
474 {
475  ImplClear();
477 }
478 
480 {
481  return( meType != GraphicType::NONE );
482 }
483 
485 {
486  bool bRet(true);
487 
488  if (mbSwapOut)
489  {
491  }
493  {
494  bRet = mpAnimation ? mpAnimation->IsTransparent() : maBitmapEx.IsTransparent();
495  }
496 
497  return bRet;
498 }
499 
501 {
502  bool bRet(false);
503 
504  if (mbSwapOut)
505  {
506  bRet = maSwapInfo.mbIsAlpha;
507  }
508  else if (maVectorGraphicData)
509  {
510  bRet = true;
511  }
512  else if (meType == GraphicType::Bitmap)
513  {
514  bRet = (nullptr == mpAnimation && maBitmapEx.IsAlpha());
515  }
516 
517  return bRet;
518 }
519 
521 {
522  return mbSwapOut ? maSwapInfo.mbIsAnimated : mpAnimation != nullptr;
523 }
524 
526 {
527  if (mbSwapOut)
528  return maSwapInfo.mbIsEPS;
529 
530  return( ( meType == GraphicType::GdiMetafile ) &&
531  ( maMetaFile.GetActionSize() > 0 ) &&
533 }
534 
536 {
537  return !mbPrepared && !mbSwapOut;
538 }
539 
541 {
542  return ensureAvailable();
543 }
544 
546 {
547  BitmapEx aRet = maVectorGraphicData->getReplacement();
548 
550  {
552  }
553 
554  return aRet;
555 }
556 
558 {
559  Bitmap aRetBmp;
560 
561  ensureAvailable();
562 
563  if( meType == GraphicType::Bitmap )
564  {
566  {
567  // use maBitmapEx as local buffer for rendered svg
568  const_cast< ImpGraphic* >(this)->maBitmapEx = getVectorGraphicReplacement();
569  }
570 
571  const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maBitmapEx );
572 
573  aRetBmp = rRetBmpEx.GetBitmap( COL_WHITE );
574 
575  if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
576  aRetBmp.Scale(rParameters.getSizePixel());
577  }
578  else if( ( meType != GraphicType::Default ) && ImplIsSupportedGraphic() )
579  {
580  if(maBitmapEx.IsEmpty())
581  {
582  // calculate size
584  Size aDrawSize(aVDev->LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
585 
586  if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
587  {
588  // apply given size if exists
589  aDrawSize = rParameters.getSizePixel();
590  }
591 
592  if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
593  && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
594  {
595  // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
596  double fWH(static_cast<double>(aDrawSize.Width()) / static_cast<double>(aDrawSize.Height()));
597 
598  if(fWH <= 1.0)
599  {
602  }
603  else
604  {
607  }
608  }
609 
610  // calculate pixel size. Normally, it's the same as aDrawSize, but may
611  // need to be extended when hairlines are on the right or bottom edge
612  Size aPixelSize(aDrawSize);
613 
615  {
616  // get hairline and full bound rect
617  tools::Rectangle aHairlineRect;
618  const tools::Rectangle aRect(maMetaFile.GetBoundRect(*aVDev, &aHairlineRect));
619 
620  if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
621  {
622  // expand if needed to allow bottom and right hairlines to be added
623  if(aRect.Right() == aHairlineRect.Right())
624  {
625  aPixelSize.setWidth(aPixelSize.getWidth() + 1);
626  }
627 
628  if(aRect.Bottom() == aHairlineRect.Bottom())
629  {
630  aPixelSize.setHeight(aPixelSize.getHeight() + 1);
631  }
632  }
633  }
634 
635  if(aVDev->SetOutputSizePixel(aPixelSize))
636  {
637  if(rParameters.getAntiAliase())
638  {
639  aVDev->SetAntialiasing(aVDev->GetAntialiasing() | AntialiasingFlags::EnableB2dDraw);
640  }
641 
642  if(rParameters.getSnapHorVerLines())
643  {
644  aVDev->SetAntialiasing(aVDev->GetAntialiasing() | AntialiasingFlags::PixelSnapHairline);
645  }
646 
647  ImplDraw( aVDev.get(), Point(), aDrawSize );
648 
649  // use maBitmapEx as local buffer for rendered metafile
650  const_cast< ImpGraphic* >(this)->maBitmapEx = aVDev->GetBitmapEx( Point(), aVDev->GetOutputSizePixel() );
651  }
652  }
653 
654  aRetBmp = maBitmapEx.GetBitmap();
655  }
656 
657  if( !!aRetBmp )
658  {
659  aRetBmp.SetPrefMapMode( ImplGetPrefMapMode() );
660  aRetBmp.SetPrefSize( ImplGetPrefSize() );
661  }
662 
663  return aRetBmp;
664 }
665 
667 {
668  BitmapEx aRetBmpEx;
669 
670  ensureAvailable();
671 
672  if( meType == GraphicType::Bitmap )
673  {
675  {
676  // use maBitmapEx as local buffer for rendered svg
677  const_cast< ImpGraphic* >(this)->maBitmapEx = getVectorGraphicReplacement();
678  }
679 
680  aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maBitmapEx );
681 
682  if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
683  {
684  aRetBmpEx.Scale(
685  rParameters.getSizePixel(),
687  }
688  }
689  else if( ( meType != GraphicType::Default ) && ImplIsSupportedGraphic() )
690  {
691  if(maBitmapEx.IsEmpty())
692  {
693  const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
694 
695  // use maBitmapEx as local buffer for rendered metafile
696  const_cast< ImpGraphic* >(this)->maBitmapEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters));
697  }
698 
699  aRetBmpEx = maBitmapEx;
700  }
701 
702  return aRetBmpEx;
703 }
704 
706 {
707  Animation aAnimation;
708 
709  ensureAvailable();
710  if( mpAnimation )
711  aAnimation = *mpAnimation;
712 
713  return aAnimation;
714 }
715 
717 {
718  ensureAvailable();
719  return maBitmapEx;
720 }
721 
723 {
724  ensureAvailable();
727  && (VectorGraphicDataType::Emf == maVectorGraphicData->getVectorGraphicDataType()
728  || VectorGraphicDataType::Wmf == maVectorGraphicData->getVectorGraphicDataType()))
729  {
730  // If we have a Emf/Wmf VectorGraphic object, we
731  // need a way to get the Metafile data out of the primitive
732  // representation. Use a strict virtual hook (MetafileAccessor)
733  // to access the MetafilePrimitive2D directly. Also see comments in
734  // XEmfParser about this.
735  const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > aSequence(maVectorGraphicData->getPrimitive2DSequence());
736 
737  if (1 == aSequence.size())
738  {
739  // try to cast to MetafileAccessor implementation
740  const css::uno::Reference< css::graphic::XPrimitive2D > xReference(aSequence[0]);
741  const MetafileAccessor* pMetafileAccessor = dynamic_cast< const MetafileAccessor* >(xReference.get());
742 
743  if (pMetafileAccessor)
744  {
745  // it is a MetafileAccessor implementation, get Metafile
746  pMetafileAccessor->accessMetafile(const_cast< ImpGraphic* >(this)->maMetaFile);
747  }
748  }
749  }
750 
752  {
753  // #i119735#
754  // Use the local maMetaFile as container for a metafile-representation
755  // of the bitmap graphic. This will be done only once, thus be buffered.
756  // I checked all usages of maMetaFile, it is only used when type is not
757  // GraphicType::Bitmap. In operator= it will get copied, thus buffering will
758  // survive copying (change this if not wanted)
759  ImpGraphic* pThat = const_cast< ImpGraphic* >(this);
760 
762  {
763  // use maBitmapEx as local buffer for rendered svg
765  }
766 
767  // #123983# directly create a metafile with the same PrefSize and PrefMapMode
768  // the bitmap has, this will be an always correct metafile
770  {
772  }
773  else
774  {
776  }
777 
778  pThat->maMetaFile.Stop();
779  pThat->maMetaFile.WindStart();
782  }
783 
784  return maMetaFile;
785 }
786 
788 {
789  Size aSize;
790 
791  if (isSwappedOut())
792  aSize = maSwapInfo.maSizePixel;
793  else
795 
796  return aSize;
797 }
798 
800 {
801  Size aSize;
802 
803  if (isSwappedOut())
804  {
805  aSize = maSwapInfo.maPrefSize;
806  }
807  else
808  {
809  switch( meType )
810  {
811  case GraphicType::NONE:
813  break;
814 
815  case GraphicType::Bitmap:
816  {
818  {
820  {
821  // svg not yet buffered in maBitmapEx, return size derived from range
822  const basegfx::B2DRange& rRange = maVectorGraphicData->getRange();
823 
824  aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
825  }
826  else
827  {
828  aSize = maExPrefSize;
829  }
830  }
831  else
832  {
833  aSize = maBitmapEx.GetPrefSize();
834 
835  if( !aSize.Width() || !aSize.Height() )
836  {
837  aSize = maBitmapEx.GetSizePixel();
838  }
839  }
840  }
841  break;
842 
843  default:
844  {
845  if( ImplIsSupportedGraphic() )
846  aSize = maMetaFile.GetPrefSize();
847  }
848  break;
849  }
850  }
851 
852  return aSize;
853 }
854 
855 void ImpGraphic::ImplSetPrefSize( const Size& rPrefSize )
856 {
857  ensureAvailable();
858 
859  switch( meType )
860  {
861  case GraphicType::NONE:
863  break;
864 
865  case GraphicType::Bitmap:
866  {
867  // used when importing a writer FlyFrame with SVG as graphic, added conversion
868  // to allow setting the PrefSize at the BitmapEx to hold it
870  {
871  maExPrefSize = rPrefSize;
872  }
873 
874  // #108077# Push through pref size to animation object,
875  // will be lost on copy otherwise
876  if( ImplIsAnimated() )
877  {
878  const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefSize( rPrefSize );
879  }
880 
882  {
883  maBitmapEx.SetPrefSize( rPrefSize );
884  }
885  }
886  break;
887 
888  default:
889  {
890  if( ImplIsSupportedGraphic() )
891  maMetaFile.SetPrefSize( rPrefSize );
892  }
893  break;
894  }
895 }
896 
898 {
899  MapMode aMapMode;
900 
901  if (isSwappedOut())
902  {
903  aMapMode = maSwapInfo.maPrefMapMode;
904  }
905  else
906  {
907  switch( meType )
908  {
909  case GraphicType::NONE:
911  break;
912 
913  case GraphicType::Bitmap:
914  {
916  {
917  // svg not yet buffered in maBitmapEx, return default PrefMapMode
918  aMapMode = MapMode(MapUnit::Map100thMM);
919  }
920  else
921  {
922  const Size aSize( maBitmapEx.GetPrefSize() );
923 
924  if ( aSize.Width() && aSize.Height() )
925  aMapMode = maBitmapEx.GetPrefMapMode();
926  }
927  }
928  break;
929 
930  default:
931  {
932  if( ImplIsSupportedGraphic() )
933  return maMetaFile.GetPrefMapMode();
934  }
935  break;
936  }
937  }
938 
939  return aMapMode;
940 }
941 
942 void ImpGraphic::ImplSetPrefMapMode( const MapMode& rPrefMapMode )
943 {
944  ensureAvailable();
945 
946  switch( meType )
947  {
948  case GraphicType::NONE:
950  break;
951 
952  case GraphicType::Bitmap:
953  {
955  {
956  // ignore for Vector Graphic Data. If this is really used (except the grfcache)
957  // it can be extended by using maBitmapEx as buffer for getVectorGraphicReplacement()
958  }
959  else
960  {
961  // #108077# Push through pref mapmode to animation object,
962  // will be lost on copy otherwise
963  if( ImplIsAnimated() )
964  {
965  const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefMapMode( rPrefMapMode );
966  }
967 
968  maBitmapEx.SetPrefMapMode( rPrefMapMode );
969  }
970  }
971  break;
972 
973  default:
974  {
975  if( ImplIsSupportedGraphic() )
976  maMetaFile.SetPrefMapMode( rPrefMapMode );
977  }
978  break;
979  }
980 }
981 
983 {
984  if( mnSizeBytes )
985  return mnSizeBytes;
986 
987  if (mbPrepared)
988  ensureAvailable();
989 
990  if( meType == GraphicType::Bitmap )
991  {
993  {
994  std::pair<VectorGraphicData::State, size_t> tmp(maVectorGraphicData->getSizeBytes());
995  if (VectorGraphicData::State::UNPARSED == tmp.first)
996  {
997  return tmp.second; // don't cache it until Vector Graphic Data is parsed
998  }
999  mnSizeBytes = tmp.second;
1000  }
1001  else
1002  {
1003  mnSizeBytes = mpAnimation ? mpAnimation->GetSizeBytes() : maBitmapEx.GetSizeBytes();
1004  }
1005  }
1006  else if( meType == GraphicType::GdiMetafile )
1007  {
1009  }
1010 
1011  return mnSizeBytes;
1012 }
1013 
1014 void ImpGraphic::ImplDraw( OutputDevice* pOutDev, const Point& rDestPt ) const
1015 {
1016  ensureAvailable();
1017  if( !ImplIsSupportedGraphic() || isSwappedOut() )
1018  return;
1019 
1020  switch( meType )
1021  {
1022  case GraphicType::Default:
1023  break;
1024 
1025  case GraphicType::Bitmap:
1026  {
1028  {
1029  // use maEx as local buffer for rendered svg
1030  const_cast< ImpGraphic* >(this)->maBitmapEx = getVectorGraphicReplacement();
1031  }
1032 
1033  if ( mpAnimation )
1034  {
1035  mpAnimation->Draw( pOutDev, rDestPt );
1036  }
1037  else
1038  {
1039  maBitmapEx.Draw( pOutDev, rDestPt );
1040  }
1041  }
1042  break;
1043 
1044  default:
1045  ImplDraw( pOutDev, rDestPt, maMetaFile.GetPrefSize() );
1046  break;
1047  }
1048 }
1049 
1051  const Point& rDestPt, const Size& rDestSize ) const
1052 {
1053  ensureAvailable();
1054  if( !ImplIsSupportedGraphic() || isSwappedOut() )
1055  return;
1056 
1057  switch( meType )
1058  {
1059  case GraphicType::Default:
1060  break;
1061 
1062  case GraphicType::Bitmap:
1063  {
1065  {
1066  // use maEx as local buffer for rendered svg
1067  const_cast< ImpGraphic* >(this)->maBitmapEx = getVectorGraphicReplacement();
1068  }
1069 
1070  if( mpAnimation )
1071  {
1072  mpAnimation->Draw( pOutDev, rDestPt, rDestSize );
1073  }
1074  else
1075  {
1076  maBitmapEx.Draw( pOutDev, rDestPt, rDestSize );
1077  }
1078  }
1079  break;
1080 
1081  default:
1082  {
1083  const_cast<ImpGraphic*>(this)->maMetaFile.WindStart();
1084  const_cast<ImpGraphic*>(this)->maMetaFile.Play( pOutDev, rDestPt, rDestSize );
1085  const_cast<ImpGraphic*>(this)->maMetaFile.WindStart();
1086  }
1087  break;
1088  }
1089 }
1090 
1091 void ImpGraphic::ImplStartAnimation( OutputDevice* pOutDev, const Point& rDestPt,
1092  const Size& rDestSize, long nExtraData,
1093  OutputDevice* pFirstFrameOutDev )
1094 {
1095  ensureAvailable();
1096 
1098  mpAnimation->Start( pOutDev, rDestPt, rDestSize, nExtraData, pFirstFrameOutDev );
1099 }
1100 
1101 void ImpGraphic::ImplStopAnimation( OutputDevice* pOutDev, long nExtraData )
1102 {
1103  ensureAvailable();
1104 
1106  mpAnimation->Stop( pOutDev, nExtraData );
1107 }
1108 
1110 {
1111  ensureAvailable();
1112 
1113  if( mpAnimation )
1114  mpAnimation->SetNotifyHdl( rLink );
1115 }
1116 
1118 {
1119  Link<Animation*,void> aLink;
1120 
1121  ensureAvailable();
1122 
1123  if( mpAnimation )
1124  aLink = mpAnimation->GetNotifyHdl();
1125 
1126  return aLink;
1127 }
1128 
1130 {
1131  if (mbSwapOut)
1133 
1134  return mpAnimation ? mpAnimation->GetLoopCount() : 0;
1135 }
1136 
1137 void ImpGraphic::ImplSetContext( const std::shared_ptr<GraphicReader>& pReader )
1138 {
1139  mpContext = pReader;
1140  mbDummyContext = false;
1141 }
1142 
1144 {
1145  ensureAvailable();
1146 
1147  MapMode aMapMode;
1148  Size aSize;
1149  sal_uInt32 nId;
1150  sal_Int32 nType;
1151  const SvStreamEndian nOldFormat = rIStm.GetEndian();
1152  bool bRet = false;
1153 
1154  rIStm.SetEndian( SvStreamEndian::LITTLE );
1155  rIStm.ReadUInt32( nId );
1156 
1157  // check version
1158  if( GRAPHIC_FORMAT_50 == nId )
1159  {
1160  // read new style header
1161  VersionCompat aCompat( rIStm, StreamMode::READ );
1162 
1163  rIStm.ReadInt32( nType );
1164  sal_Int32 nLen;
1165  rIStm.ReadInt32( nLen );
1166  TypeSerializer aSerializer(rIStm);
1167  aSerializer.readSize(aSize);
1168  ReadMapMode( rIStm, aMapMode );
1169  }
1170  else
1171  {
1172  // read old style header
1173  sal_Int32 nWidth, nHeight;
1174  sal_Int32 nMapMode, nScaleNumX, nScaleDenomX;
1175  sal_Int32 nScaleNumY, nScaleDenomY, nOffsX, nOffsY;
1176 
1177  rIStm.SeekRel( -4 );
1178 
1179  sal_Int32 nLen;
1180  rIStm.ReadInt32( nType ).ReadInt32( nLen ).ReadInt32( nWidth ).ReadInt32( nHeight );
1181  rIStm.ReadInt32( nMapMode ).ReadInt32( nScaleNumX ).ReadInt32( nScaleDenomX ).ReadInt32( nScaleNumY );
1182  rIStm.ReadInt32( nScaleDenomY ).ReadInt32( nOffsX ).ReadInt32( nOffsY );
1183 
1184  // swapped
1185  if( nType > 100 )
1186  {
1187  nType = OSL_SWAPDWORD( nType );
1188  nWidth = OSL_SWAPDWORD( nWidth );
1189  nHeight = OSL_SWAPDWORD( nHeight );
1190  nMapMode = OSL_SWAPDWORD( nMapMode );
1191  nScaleNumX = OSL_SWAPDWORD( nScaleNumX );
1192  nScaleDenomX = OSL_SWAPDWORD( nScaleDenomX );
1193  nScaleNumY = OSL_SWAPDWORD( nScaleNumY );
1194  nScaleDenomY = OSL_SWAPDWORD( nScaleDenomY );
1195  nOffsX = OSL_SWAPDWORD( nOffsX );
1196  nOffsY = OSL_SWAPDWORD( nOffsY );
1197  }
1198 
1199  aSize = Size( nWidth, nHeight );
1200  aMapMode = MapMode( static_cast<MapUnit>(nMapMode), Point( nOffsX, nOffsY ),
1201  Fraction( nScaleNumX, nScaleDenomX ),
1202  Fraction( nScaleNumY, nScaleDenomY ) );
1203  }
1204 
1205  meType = static_cast<GraphicType>(nType);
1206 
1207  if( meType != GraphicType::NONE )
1208  {
1209  if( meType == GraphicType::Bitmap )
1210  {
1212  {
1213  // use maBitmapEx as local buffer for rendered svg
1215  }
1216 
1217  maBitmapEx.SetSizePixel(aSize);
1218 
1219  if( aMapMode != MapMode() )
1220  {
1221  maBitmapEx.SetPrefMapMode( aMapMode );
1222  maBitmapEx.SetPrefSize( aSize );
1223  }
1224  }
1225  else
1226  {
1227  maMetaFile.SetPrefMapMode( aMapMode );
1228  maMetaFile.SetPrefSize( aSize );
1229  }
1230 
1232  {
1233  ReadImpGraphic( rIStm, *this );
1234  bRet = rIStm.GetError() == ERRCODE_NONE;
1235  }
1236  else if( sal::static_int_cast<sal_uLong>(meType) >= SYS_WINMETAFILE
1237  && sal::static_int_cast<sal_uLong>(meType) <= SYS_MACMETAFILE )
1238  {
1239  Graphic aSysGraphic;
1240  ConvertDataFormat nCvtType;
1241 
1242  switch( sal::static_int_cast<sal_uLong>(meType) )
1243  {
1244  case SYS_WINMETAFILE:
1245  case SYS_WNTMETAFILE: nCvtType = ConvertDataFormat::WMF; break;
1246  case SYS_OS2METAFILE: nCvtType = ConvertDataFormat::MET; break;
1247  case SYS_MACMETAFILE: nCvtType = ConvertDataFormat::PCT; break;
1248 
1249  default:
1250  nCvtType = ConvertDataFormat::Unknown;
1251  break;
1252  }
1253 
1254  if( nType && GraphicConverter::Import( rIStm, aSysGraphic, nCvtType ) == ERRCODE_NONE )
1255  {
1256  *this = ImpGraphic( aSysGraphic.GetGDIMetaFile() );
1257  bRet = rIStm.GetError() == ERRCODE_NONE;
1258  }
1259  else
1261  }
1262 
1263  if( bRet )
1264  {
1265  ImplSetPrefMapMode( aMapMode );
1266  ImplSetPrefSize( aSize );
1267  }
1268  }
1269  else
1270  bRet = true;
1271 
1272  rIStm.SetEndian( nOldFormat );
1273 
1274  return bRet;
1275 }
1276 
1278 {
1279  ensureAvailable();
1280 
1282  return false;
1283 
1284  const MapMode aMapMode( ImplGetPrefMapMode() );
1285  const Size aSize( ImplGetPrefSize() );
1286  const SvStreamEndian nOldFormat = rOStm.GetEndian();
1287  sal_uLong nDataFieldPos;
1288 
1289  rOStm.SetEndian( SvStreamEndian::LITTLE );
1290 
1291  // write correct version ( old style/new style header )
1292  if( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 )
1293  {
1294  // write ID for new format (5.0)
1295  rOStm.WriteUInt32( GRAPHIC_FORMAT_50 );
1296 
1297  // write new style header
1298  VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
1299 
1300  rOStm.WriteInt32( static_cast<sal_Int32>(meType) );
1301 
1302  // data size is updated later
1303  nDataFieldPos = rOStm.Tell();
1304  rOStm.WriteInt32( 0 );
1305 
1306  TypeSerializer aSerializer(rOStm);
1307  aSerializer.writeSize(aSize);
1308 
1309  WriteMapMode( rOStm, aMapMode );
1310  }
1311  else
1312  {
1313  // write old style (<=4.0) header
1314  rOStm.WriteInt32( static_cast<sal_Int32>(meType) );
1315 
1316  // data size is updated later
1317  nDataFieldPos = rOStm.Tell();
1318  rOStm.WriteInt32( 0 );
1319  rOStm.WriteInt32( aSize.Width() );
1320  rOStm.WriteInt32( aSize.Height() );
1321  rOStm.WriteInt32( static_cast<sal_uInt16>(aMapMode.GetMapUnit()) );
1322  rOStm.WriteInt32( aMapMode.GetScaleX().GetNumerator() );
1323  rOStm.WriteInt32( aMapMode.GetScaleX().GetDenominator() );
1324  rOStm.WriteInt32( aMapMode.GetScaleY().GetNumerator() );
1325  rOStm.WriteInt32( aMapMode.GetScaleY().GetDenominator() );
1326  rOStm.WriteInt32( aMapMode.GetOrigin().X() );
1327  rOStm.WriteInt32( aMapMode.GetOrigin().Y() );
1328  }
1329 
1330  bool bRet = false;
1331  // write data block
1332  if( !rOStm.GetError() )
1333  {
1334  const sal_uLong nDataStart = rOStm.Tell();
1335 
1336  if( ImplIsSupportedGraphic() )
1337  WriteImpGraphic( rOStm, *this );
1338 
1339  if( !rOStm.GetError() )
1340  {
1341  const sal_uLong nStmPos2 = rOStm.Tell();
1342  rOStm.Seek( nDataFieldPos );
1343  rOStm.WriteInt32( nStmPos2 - nDataStart );
1344  rOStm.Seek( nStmPos2 );
1345  bRet = true;
1346  }
1347  }
1348 
1349  rOStm.SetEndian( nOldFormat );
1350 
1351  return bRet;
1352 }
1353 
1355 {
1356  if (isSwappedOut())
1357  return false;
1358 
1359  // Create a temp filename for the swap file
1360  utl::TempFile aTempFile;
1361  const INetURLObject aTempFileURL(aTempFile.GetURL());
1362 
1363  // Create a swap file
1364  auto pSwapFile = o3tl::make_shared<ImpSwapFile>(aTempFileURL, getOriginURL());
1365 
1366  bool bResult = false;
1367 
1368  // Open a stream to write the swap file to
1369  {
1370  std::unique_ptr<SvStream> xOutputStream = pSwapFile->openOutputStream();
1371 
1372  if (!xOutputStream)
1373  return false;
1374 
1375  // Write to stream
1376  xOutputStream->SetVersion(SOFFICE_FILEFORMAT_50);
1377  xOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
1378  xOutputStream->SetBufferSize(GRAPHIC_STREAMBUFSIZE);
1379 
1380  if (!xOutputStream->GetError() && ImplWriteEmbedded(*xOutputStream))
1381  {
1382  xOutputStream->Flush();
1383  bResult = !xOutputStream->GetError();
1384  }
1385  }
1386 
1387  // Check if writing was successful
1388  if (bResult)
1389  {
1390  // We have swapped out, so can clean memory and prepare swap info
1391  createSwapInfo();
1393 
1394  mpSwapFile = std::move(pSwapFile);
1395  mbSwapOut = true;
1396 
1397  // Signal to manager that we have swapped out
1399  }
1400 
1401  return bResult;
1402 }
1403 
1405 {
1406  auto pThis = const_cast<ImpGraphic*>(this);
1407 
1408  if (isSwappedOut())
1409  return pThis->swapIn();
1410 
1411  pThis->maLastUsed = std::chrono::high_resolution_clock::now();
1412  return true;
1413 }
1414 
1416 {
1417  Graphic aGraphic;
1418  if (!mpGfxLink->LoadNative(aGraphic))
1419  return false;
1420 
1422 
1423  Size aPrefSize = maSwapInfo.maPrefSize;
1424  MapMode aPrefMapMode = maSwapInfo.maPrefMapMode;
1425  *this = *aGraphic.ImplGetImpGraphic();
1426  if (aPrefSize.getWidth() && aPrefSize.getHeight() && aPrefMapMode == ImplGetPrefMapMode())
1427  {
1428  // Use custom preferred size if it was set when the graphic was still unloaded.
1429  // Only set the size in case the unloaded and loaded unit matches.
1430  ImplSetPrefSize(aPrefSize);
1431  }
1432 
1433  maGraphicExternalLink = aLink;
1434 
1435  return true;
1436 }
1437 
1439 {
1440  bool bRet = false;
1441 
1442  if (!isSwappedOut())
1443  return bRet;
1444 
1445  if (mbPrepared)
1446  {
1447  bRet = loadPrepared();
1448  }
1449  else
1450  {
1451  OUString aSwapURL;
1452 
1453  if( mpSwapFile )
1454  aSwapURL = mpSwapFile->getSwapURL().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1455 
1456  if( !aSwapURL.isEmpty() )
1457  {
1458  std::unique_ptr<SvStream> xIStm;
1459  try
1460  {
1461  xIStm = ::utl::UcbStreamHelper::CreateStream( aSwapURL, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
1462  }
1463  catch( const css::uno::Exception& )
1464  {
1465  }
1466 
1467  if( xIStm )
1468  {
1469  xIStm->SetVersion( SOFFICE_FILEFORMAT_50 );
1470  xIStm->SetCompressMode( SvStreamCompressFlags::NATIVE );
1471 
1472  bRet = swapInFromStream(xIStm.get());
1473  xIStm.reset();
1474  if (mpSwapFile)
1475  setOriginURL(mpSwapFile->getOriginURL());
1476  mpSwapFile.reset();
1477  }
1478  }
1479  }
1480 
1481  if (bRet)
1483 
1484  return bRet;
1485 }
1486 
1488 {
1489  bool bRet = false;
1490 
1491  if( !xIStm )
1492  return false;
1493 
1495 
1496  if( xIStm->GetError() )
1497  return false;
1498 
1499  //keep the swap file alive, because its quite possibly the backing storage
1500  //for xIStm
1501  std::shared_ptr<ImpSwapFile> xSwapFile(std::move(mpSwapFile));
1502  assert(!mpSwapFile);
1503 
1504  std::shared_ptr<GraphicReader> xContext(std::move(mpContext));
1505  assert(!mpContext);
1506 
1507  bool bDummyContext = mbDummyContext;
1508  mbDummyContext = false;
1509 
1510  bRet = ImplReadEmbedded( *xIStm );
1511 
1512  //restore ownership of the swap file and context
1513  mpSwapFile = std::move(xSwapFile);
1514  mpContext = std::move(xContext);
1515  mbDummyContext = bDummyContext;
1516 
1517  if (!bRet)
1518  {
1519  //throw away swapfile, etc.
1520  ImplClear();
1521  }
1522 
1523  mbSwapOut = false;
1524 
1525  return bRet;
1526 }
1527 
1528 void ImpGraphic::ImplSetLink(const std::shared_ptr<GfxLink>& rGfxLink)
1529 {
1530  ensureAvailable();
1531 
1532  mpGfxLink = rGfxLink;
1533 }
1534 
1535 std::shared_ptr<GfxLink> ImpGraphic::ImplGetSharedGfxLink() const
1536 {
1537  return mpGfxLink;
1538 }
1539 
1541 {
1542  ensureAvailable();
1543 
1544  return( mpGfxLink ? *mpGfxLink : GfxLink() );
1545 }
1546 
1548 {
1549  return ( bool(mpGfxLink) );
1550 }
1551 
1553 {
1554  if (mnChecksum != 0)
1555  return mnChecksum;
1556 
1557  BitmapChecksum nRet = 0;
1558 
1559  ensureAvailable();
1560 
1561  if( ImplIsSupportedGraphic() && !isSwappedOut() )
1562  {
1563  switch( meType )
1564  {
1565  case GraphicType::Default:
1566  break;
1567 
1568  case GraphicType::Bitmap:
1569  {
1571  nRet = maVectorGraphicData->GetChecksum();
1572  else if( mpAnimation )
1573  nRet = mpAnimation->GetChecksum();
1574  else
1575  nRet = maBitmapEx.GetChecksum();
1576  }
1577  break;
1578 
1579  default:
1580  nRet = maMetaFile.GetChecksum();
1581  break;
1582  }
1583  }
1584 
1585  mnChecksum = nRet;
1586  return nRet;
1587 }
1588 
1590 {
1591  ensureAvailable();
1592 
1593  if( rOStm.GetError() )
1594  return false;
1595 
1596  bool bResult = false;
1597 
1598  if( !isSwappedOut() )
1599  {
1600  if( mpGfxLink && mpGfxLink->IsNative() )
1601  bResult = mpGfxLink->ExportNative( rOStm );
1602  else
1603  {
1604  WriteImpGraphic( rOStm, *this );
1605  bResult = ( rOStm.GetError() == ERRCODE_NONE );
1606  }
1607  }
1608  else
1610 
1611  return bResult;
1612 }
1613 
1614 sal_Int32 ImpGraphic::getPageNumber() const
1615 {
1616  if (maVectorGraphicData)
1617  return maVectorGraphicData->getPageIndex();
1618  return -1;
1619 }
1620 
1621 void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
1622 {
1623  if (rIStm.GetError())
1624  return;
1625 
1626  const sal_uLong nStmPos1 = rIStm.Tell();
1627  sal_uInt32 nTmp;
1628 
1629  rImpGraphic.ImplClear();
1630 
1631  // read Id
1632  rIStm.ReadUInt32( nTmp );
1633 
1634  // if there is no more data, avoid further expensive
1635  // reading which will create VDevs and other stuff, just to
1636  // read nothing. CAUTION: Eof is only true AFTER reading another
1637  // byte, a speciality of SvMemoryStream (!)
1638  if (!rIStm.good())
1639  return;
1640 
1641  if (NATIVE_FORMAT_50 == nTmp)
1642  {
1643  Graphic aGraphic;
1644  GfxLink aLink;
1645 
1646  // read compat info, destructor writes stuff into the header
1647  {
1648  VersionCompat aCompat( rIStm, StreamMode::READ );
1649  }
1650 
1651  TypeSerializer aSerializer(rIStm);
1652  aSerializer.readGfxLink(aLink);
1653 
1654  // set dummy link to avoid creation of additional link after filtering;
1655  // we set a default link to avoid unnecessary swapping of native data
1656  aGraphic.SetGfxLink(std::make_shared<GfxLink>());
1657 
1658  if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
1659  {
1660  // set link only, if no other link was set
1661  const bool bSetLink = !rImpGraphic.mpGfxLink;
1662 
1663  // assign graphic
1664  rImpGraphic = *aGraphic.ImplGetImpGraphic();
1665 
1666  if( aLink.IsPrefMapModeValid() )
1667  rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
1668 
1669  if( aLink.IsPrefSizeValid() )
1670  rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
1671 
1672  if( bSetLink )
1673  rImpGraphic.ImplSetLink(std::make_shared<GfxLink>(aLink));
1674  }
1675  else
1676  {
1677  rIStm.Seek( nStmPos1 );
1679  }
1680  return;
1681  }
1682 
1683  BitmapEx aBmpEx;
1684  const SvStreamEndian nOldFormat = rIStm.GetEndian();
1685 
1686  rIStm.SeekRel( -4 );
1687  rIStm.SetEndian( SvStreamEndian::LITTLE );
1688  ReadDIBBitmapEx(aBmpEx, rIStm);
1689 
1690  if( !rIStm.GetError() )
1691  {
1692  sal_uInt32 nMagic1(0), nMagic2(0);
1693  sal_uLong nActPos = rIStm.Tell();
1694 
1695  rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
1696  rIStm.Seek( nActPos );
1697 
1698  rImpGraphic = ImpGraphic( aBmpEx );
1699 
1700  if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
1701  {
1702  rImpGraphic.mpAnimation = std::make_unique<Animation>();
1703  ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
1704 
1705  // #108077# manually set loaded BmpEx to Animation
1706  // (which skips loading its BmpEx if already done)
1707  rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
1708  }
1709  else
1710  rIStm.ResetError();
1711  }
1712  else
1713  {
1714  GDIMetaFile aMtf;
1715 
1716  rIStm.Seek( nStmPos1 );
1717  rIStm.ResetError();
1718  ReadGDIMetaFile( rIStm, aMtf );
1719 
1720  if( !rIStm.GetError() )
1721  {
1722  rImpGraphic = aMtf;
1723  }
1724  else
1725  {
1726  ErrCode nOrigError = rIStm.GetErrorCode();
1727  // try to stream in Svg defining data (length, byte array and evtl. path)
1728  // See below (operator<<) for more information
1729  sal_uInt32 nMagic;
1730  rIStm.Seek(nStmPos1);
1731  rIStm.ResetError();
1732  rIStm.ReadUInt32( nMagic );
1733 
1734  if (constSvgMagic == nMagic || constWmfMagic == nMagic || constEmfMagic == nMagic || constPdfMagic == nMagic)
1735  {
1736  sal_uInt32 nVectorGraphicDataArrayLength(0);
1737  rIStm.ReadUInt32(nVectorGraphicDataArrayLength);
1738 
1739  if (nVectorGraphicDataArrayLength)
1740  {
1741  VectorGraphicDataArray aNewData(nVectorGraphicDataArrayLength);
1742 
1743  rIStm.ReadBytes(aNewData.getArray(), nVectorGraphicDataArrayLength);
1744  OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
1745 
1746  if (!rIStm.GetError())
1747  {
1749 
1750  if (constWmfMagic == nMagic)
1751  {
1752  aDataType = VectorGraphicDataType::Wmf;
1753  }
1754  else if (constEmfMagic == nMagic)
1755  {
1756  aDataType = VectorGraphicDataType::Emf;
1757  }
1758  else if (constPdfMagic == nMagic)
1759  {
1760  aDataType = VectorGraphicDataType::Pdf;
1761  }
1762 
1763  auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, aPath, aDataType);
1764  rImpGraphic = aVectorGraphicDataPtr;
1765  }
1766  }
1767  }
1768  else
1769  {
1770  rIStm.SetError(nOrigError);
1771  }
1772 
1773  rIStm.Seek(nStmPos1);
1774  }
1775  }
1776 
1777  rIStm.SetEndian( nOldFormat );
1778 }
1779 
1780 void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
1781 {
1782  if (rOStm.GetError())
1783  return;
1784 
1785  rImpGraphic.ensureAvailable();
1786 
1787  if (rImpGraphic.isSwappedOut())
1788  {
1790  return;
1791  }
1792 
1793  if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
1794  ( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
1795  rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative())
1796  {
1797  // native format
1798  rOStm.WriteUInt32( NATIVE_FORMAT_50 );
1799 
1800  // write compat info, destructor writes stuff into the header
1801  {
1802  VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
1803  }
1804  rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() );
1805  rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() );
1806  TypeSerializer aSerializer(rOStm);
1807  aSerializer.writeGfxLink(*rImpGraphic.mpGfxLink);
1808  }
1809  else
1810  {
1811  // own format
1812  const SvStreamEndian nOldFormat = rOStm.GetEndian();
1813  rOStm.SetEndian( SvStreamEndian::LITTLE );
1814 
1815  switch( rImpGraphic.ImplGetType() )
1816  {
1817  case GraphicType::NONE:
1818  case GraphicType::Default:
1819  break;
1820 
1821  case GraphicType::Bitmap:
1822  {
1823  if(rImpGraphic.getVectorGraphicData())
1824  {
1825  // stream out Vector Graphic defining data (length, byte array and evtl. path)
1826  // this is used e.g. in swapping out graphic data and in transporting it over UNO API
1827  // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
1828  // no problem to extend it; only used at runtime
1829  switch (rImpGraphic.getVectorGraphicData()->getVectorGraphicDataType())
1830  {
1832  {
1833  rOStm.WriteUInt32(constWmfMagic);
1834  break;
1835  }
1837  {
1838  rOStm.WriteUInt32(constEmfMagic);
1839  break;
1840  }
1842  {
1843  rOStm.WriteUInt32(constSvgMagic);
1844  break;
1845  }
1847  {
1848  rOStm.WriteUInt32(constPdfMagic);
1849  break;
1850  }
1851  }
1852 
1853  rOStm.WriteUInt32( rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength() );
1854  rOStm.WriteBytes(rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray(),
1855  rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
1856  rOStm.WriteUniOrByteString(rImpGraphic.getVectorGraphicData()->getPath(),
1857  rOStm.GetStreamCharSet());
1858  }
1859  else if( rImpGraphic.ImplIsAnimated())
1860  {
1861  WriteAnimation( rOStm, *rImpGraphic.mpAnimation );
1862  }
1863  else
1864  {
1865  WriteDIBBitmapEx(rImpGraphic.maBitmapEx, rOStm);
1866  }
1867  }
1868  break;
1869 
1870  default:
1871  {
1872  if( rImpGraphic.ImplIsSupportedGraphic() )
1873  WriteGDIMetaFile( rOStm, rImpGraphic.maMetaFile );
1874  }
1875  break;
1876  }
1877 
1878  rOStm.SetEndian( nOldFormat );
1879  }
1880 }
1881 
1882 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SYS_OS2METAFILE
Definition: impgraph.cxx:53
const Fraction & GetScaleX() const
Definition: mapmod.cxx:172
long Width() const
VectorGraphicDataType
ImpGraphic & operator=(const ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:250
bool mbDummyContext
Definition: impgraph.hxx:70
const GDIMetaFile & ImplGetGDIMetaFile() const
Definition: impgraph.cxx:722
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
std::shared_ptr< GraphicReader > mpContext
Definition: impgraph.hxx:64
bool swapInFromStream(SvStream *pIStm)
Definition: impgraph.cxx:1487
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
void SetSizePixel(const Size &rNewSize)
Definition: bitmapex.cxx:314
double getHeight() const
SvStream & WriteInt32(sal_Int32 nInt32)
Bitmap ImplGetBitmap(const GraphicConversionParameters &rParameters) const
Definition: impgraph.cxx:557
MapMode ImplGetPrefMapMode() const
Definition: impgraph.cxx:897
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:89
SvStream & WriteMapMode(SvStream &rOStm, const MapMode &rMapMode)
Definition: mapmod.cxx:152
sal_Int32 GetVersion() const
long Height() const
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:178
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmapex.cxx:371
const BitmapEx & ImplGetBitmapExRef() const
Gives direct access to the contained BitmapEx.
Definition: impgraph.cxx:716
bool mbIsTransparent
Definition: impgraph.hxx:38
void unregisterGraphic(ImpGraphic *pImpGraphic)
Definition: Manager.cxx:159
sal_uIntPtr sal_uLong
#define GRAPHIC_FORMAT_50
Definition: impgraph.cxx:56
void writeSize(const Size &rSize)
void ImplSetPrefMapMode(const MapMode &rPrefMapMode)
Definition: impgraph.cxx:942
void SetPrefMapMode(const MapMode &rPrefMapMode)
Definition: bitmapex.hxx:90
OUString maOriginURL
Definition: impgraph.cxx:74
GraphicType
Definition: graph.hxx:35
~ImpSwapFile() COVERITY_NOEXCEPT_FALSE
Definition: impgraph.cxx:83
bool mbIsAlpha
Definition: impgraph.hxx:39
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:176
bool ImplWriteEmbedded(SvStream &rOStream)
Definition: impgraph.cxx:1277
void Clear()
Definition: gdimtf.cxx:273
sal_Int16 nId
sal_uInt64 Seek(sal_uInt64 nPos)
#define ERRCODE_IO_WRONGFORMAT
Definition: errcode.hxx:219
bool ensureAvailable() const
Definition: impgraph.cxx:1404
ParserContextSharedPtr mpContext
bool swapIn()
Definition: impgraph.cxx:1438
bool mbSwapOut
Definition: impgraph.hxx:69
SvStreamCompressFlags GetCompressMode() const
void writeGfxLink(const GfxLink &rGfxLink)
SvStream & ReadAnimation(SvStream &rIStm, Animation &rAnimation)
Definition: Animation.cxx:600
#define SYS_WNTMETAFILE
Definition: impgraph.cxx:52
BitmapChecksum GetChecksum() const
Definition: bitmapex.cxx:293
sal_uInt64 SeekRel(sal_Int64 nPos)
std::shared_ptr< GfxLink > ImplGetSharedGfxLink() const
Definition: impgraph.cxx:1535
NONE
bool getUnlimitedSize() const
Definition: graph.hxx:77
bool IsEmpty() const
OUString const & getOriginURL() const
Definition: impgraph.hxx:102
bool IsAlpha() const
Definition: bitmapex.cxx:227
long Right() const
double getWidth() const
ErrCode GetError() const
bool ImplReadEmbedded(SvStream &rIStream)
Definition: impgraph.cxx:1143
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1743
bool IsAlpha() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const Fraction & GetScaleY() const
Definition: mapmod.cxx:174
SvStream & WriteGDIMetaFile(SvStream &rOStm, const GDIMetaFile &rGDIMetaFile)
Definition: gdimtf.cxx:2729
const sal_uInt16 nMagic
const Size & GetPrefSize() const
Definition: bitmapex.hxx:86
sal_uInt32 mnAnimationLoopCount
Definition: impgraph.hxx:41
SvStream & WriteUniOrByteString(const OUString &rStr, rtl_TextEncoding eDestCharSet)
const GDIMetaFile & GetGDIMetaFile() const
Definition: graph.cxx:340
SvStream & WriteUInt32(sal_uInt32 nUInt32)
void ImplStartAnimation(OutputDevice *pOutDev, const Point &rDestPt, const Size &rDestSize, long nExtraData, OutputDevice *pFirstFrameOutDev)
Definition: impgraph.cxx:1091
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:325
sal_uInt32 ImplGetAnimationLoopCount() const
Definition: impgraph.cxx:1129
GDIMetaFile GetMonochromeMtf(const Color &rCol) const
Definition: gdimtf.cxx:2206
GraphicType meType
Definition: impgraph.hxx:67
const Size & GetSize_100TH_MM() const
BitmapChecksum ImplGetChecksum() const
Definition: impgraph.cxx:1552
void SetGfxLink(const std::shared_ptr< GfxLink > &rGfxLink)
Definition: graph.cxx:497
void readSize(Size &rSize)
bool ImplIsTransparent() const
Definition: impgraph.cxx:484
Size maPrefSize
Definition: impgraph.hxx:33
B2IRange fround(const B2DRange &rRange)
void Clear()
Definition: bitmapex.cxx:217
#define NATIVE_FORMAT_50
Definition: impgraph.cxx:57
bool makeAvailable()
Definition: impgraph.cxx:540
const Size & getSizePixel() const
Definition: graph.hxx:76
std::unique_ptr< Animation > mpAnimation
Definition: impgraph.hxx:63
BitmapEx maBitmapEx
Definition: impgraph.hxx:59
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
bool isSwappedOut() const
Definition: impgraph.hxx:208
std::shared_ptr< ImpSwapFile > mpSwapFile
Definition: impgraph.hxx:65
bool IsEmpty() const
Definition: bitmapex.cxx:204
void SetPrefMapMode(const MapMode &rMapMode)
Definition: bitmap.hxx:561
void setOriginURL(OUString const &rOriginURL)
Definition: impgraph.hxx:107
#define SOFFICE_FILEFORMAT_50
OUString getSwapFileURL()
Definition: impgraph.cxx:117
bool WriteDIBBitmapEx(const BitmapEx &rSource, SvStream &rOStm)
Definition: dibtools.cxx:1874
SAL_DLLPRIVATE ImpGraphic * ImplGetImpGraphic() const
Definition: graph.hxx:90
bool getSnapHorVerLines() const
Definition: graph.hxx:79
SvStream & WriteAnimation(SvStream &rOStm, const Animation &rAnimation)
Definition: Animation.cxx:554
const Size & GetPrefSize() const
Definition: gdimtf.hxx:175
const Size & GetSizePixel() const
bool loadPrepared()
Definition: impgraph.cxx:1415
GDIMetaFile maMetaFile
Definition: impgraph.hxx:58
OUString const & GetURL() const
void ImplClear()
Definition: impgraph.cxx:458
BitmapEx ImplGetBitmapEx(const GraphicConversionParameters &rParameters) const
Definition: impgraph.cxx:666
void ImplSetPrepared(bool bAnimated, const Size *pSizeHint)
Definition: impgraph.cxx:410
ConvertDataFormat
Definition: salctype.hxx:27
void ReadImpGraphic(SvStream &rIStm, ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:1621
static Manager & get()
Definition: Manager.cxx:54
void ImplSetAnimationNotifyHdl(const Link< Animation *, void > &rLink)
Definition: impgraph.cxx:1109
BitmapChecksum mnChecksum
Definition: impgraph.hxx:73
friend void WriteImpGraphic(SvStream &rOStm, const ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:1780
BitmapEx getVectorGraphicReplacement() const
Gets the bitmap replacement for a vector graphic.
Definition: impgraph.cxx:545
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
std::size_t WriteBytes(const void *pData, std::size_t nSize)
sal_uLong GetSizeBytes() const
Definition: bitmapex.cxx:283
bool ImplExportNative(SvStream &rOStm) const
Definition: impgraph.cxx:1589
void changeExisting(const ImpGraphic *pImpGraphic, sal_Int64 nOldSize)
Definition: Manager.cxx:238
long Bottom() const
OUString const & getOriginURL()
Definition: impgraph.cxx:98
sal_uLong mnSizeBytes
Definition: impgraph.hxx:68
void SetPrefSize(const Size &rSize)
Definition: bitmap.hxx:571
void SetError(ErrCode nErrorCode)
GraphicType ImplGetType() const
Definition: impgraph.hxx:123
#define GRAPHIC_MTFTOBMP_MAXEXT
Definition: impgraph.cxx:48
void SetBufferSize(sal_uInt16 m_nBufSize)
MapUnit GetMapUnit() const
Definition: mapmod.cxx:168
ErrCode const & GetErrorCode() const
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
Definition: impgraph.cxx:380
bool ImplIsAnimated() const
Definition: impgraph.cxx:520
void WindStart()
Definition: gdimtf.cxx:553
bool IsTransparent() const
Definition: bitmapex.cxx:222
Link< Animation *, void > ImplGetAnimationNotifyHdl() const
Definition: impgraph.cxx:1117
void WriteImpGraphic(SvStream &rOStm, const ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:1780
static ErrCode Import(SvStream &rIStm, Graphic &rGraphic, ConvertDataFormat nFormat=ConvertDataFormat::Unknown)
Definition: cvtgrf.cxx:34
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
Definition: bitmapex.cxx:618
tools::Rectangle GetBoundRect(OutputDevice &i_rReference, tools::Rectangle *pHairline=nullptr) const
Definition: gdimtf.cxx:1307
bool ImplIsEPS() const
Definition: impgraph.cxx:525
#define SYS_MACMETAFILE
Definition: impgraph.cxx:54
bool mbPrepared
Definition: impgraph.hxx:79
SvStream & ReadInt32(sal_Int32 &rInt32)
Size maExPrefSize
If maBitmapEx is empty, this preferred size will be set on it when it gets initialized.
Definition: impgraph.hxx:61
std::shared_ptr< GfxLink > mpGfxLink
Definition: impgraph.hxx:66
std::size_t ReadBytes(void *pData, std::size_t nSize)
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: bitmapex.cxx:237
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
Size ImplGetPrefSize() const
Definition: impgraph.cxx:799
std::chrono::high_resolution_clock::time_point maLastUsed
Definition: impgraph.hxx:78
SvStreamEndian GetEndian() const
void Stop()
Definition: gdimtf.cxx:540
void swappedIn(const ImpGraphic *pImpGraphic)
Definition: Manager.cxx:224
css::uno::Sequence< sal_Int8 > VectorGraphicDataArray
void ImplSetLink(const std::shared_ptr< GfxLink > &)
Definition: impgraph.cxx:1528
void ImplDraw(OutputDevice *pOutDev, const Point &rDestPt) const
Definition: impgraph.cxx:1014
sal_Int32 GetDenominator() const
void ImplClearGraphics()
Definition: impgraph.cxx:401
BitmapChecksum GetChecksum() const
Definition: gdimtf.cxx:2221
#define ERRCODE_NONE
Definition: errcode.hxx:198
std::shared_ptr< VectorGraphicData > maVectorGraphicData
Definition: impgraph.hxx:71
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmap3.cxx:764
ImpSwapFile(INetURLObject const &rSwapURL, OUString const &rOriginURL)
Definition: impgraph.cxx:77
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:566
sal_uLong ImplGetSizeBytes() const
Definition: impgraph.cxx:982
bool IsTransparent() const
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:187
SvStream & ReadGDIMetaFile(SvStream &rIStm, GDIMetaFile &rGDIMetaFile, ImplMetaReadData *pData)
Definition: gdimtf.cxx:2645
void SetEndian(SvStreamEndian SvStreamEndian)
rtl_TextEncoding GetStreamCharSet() const
void SetPrefSize(const Size &rPrefSize)
Definition: bitmapex.hxx:87
sal_Int32 getPageNumber() const
Definition: impgraph.cxx:1614
ImpSwapInfo maSwapInfo
Definition: impgraph.hxx:62
sal_uInt64 Tell() const
size_t GetActionSize() const
Definition: gdimtf.cxx:182
QPRO_FUNC_TYPE nType
sal_Int32 GetNumerator() const
bool mbIsAnimated
Definition: impgraph.hxx:36
void swappedOut(const ImpGraphic *pImpGraphic)
Definition: Manager.cxx:231
Size ImplGetSizePixel() const
Definition: impgraph.cxx:787
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
const Point & GetOrigin() const
Definition: mapmod.cxx:170
Animation ImplGetAnimation() const
Definition: impgraph.cxx:705
OUString getSwapURLString()
Definition: impgraph.cxx:93
MetaActionType GetType() const
Definition: metaact.hxx:90
void ImplStopAnimation(OutputDevice *pOutputDevice, long nExtraData)
Definition: impgraph.cxx:1101
#define GRAPHIC_STREAMBUFSIZE
Definition: impgraph.cxx:49
void ImplSetDefaultType()
Definition: impgraph.cxx:473
bool isAvailable() const
Definition: impgraph.cxx:535
bool good() const
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
void readGfxLink(GfxLink &rGfxLink)
bool ImplIsLink() const
Definition: impgraph.cxx:1547
SvStreamEndian
SvStream & ReadMapMode(SvStream &rIStm, MapMode &rMapMode)
Definition: mapmod.cxx:136
void createSwapInfo()
Definition: impgraph.cxx:387
ColorAnimationSharedPtr mpAnimation
virtual void ResetError()
bool mbIsEPS
Definition: impgraph.hxx:37
long getHeight() const
void ImplSetContext(const std::shared_ptr< GraphicReader > &pReader)
Definition: impgraph.cxx:1137
bool getAntiAliase() const
Definition: graph.hxx:78
void ImplSetPrefSize(const Size &rPrefSize)
Definition: impgraph.cxx:855
GraphicExternalLink maGraphicExternalLink
Definition: impgraph.hxx:76
GfxLink ImplGetLink()
Definition: impgraph.cxx:1540
bool Detect(bool bExtendedInfo=false)
starts the detection
const Size & GetSizePixel() const
Definition: bitmapex.hxx:83
UNOTOOLS_DLLPUBLIC bool Kill(OUString const &url)
bool operator==(const ImpGraphic &rImpGraphic) const
Definition: impgraph.cxx:320
#define SVSTREAM_GENERALERROR
Definition: errcode.hxx:242
long getWidth() const
INetURLObject getSwapURL()
Definition: impgraph.cxx:88
void setWidth(long nWidth)
INetURLObject maSwapURL
Definition: impgraph.cxx:73
MapMode maPrefMapMode
Definition: impgraph.hxx:32
bool ImplIsSupportedGraphic() const
Definition: impgraph.cxx:479
#define SYS_WINMETAFILE
Definition: impgraph.cxx:51
RedlineType meType
friend void ReadImpGraphic(SvStream &rIStm, ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:1621
std::unique_ptr< SvStream > openOutputStream()
Definition: impgraph.cxx:100
bool swapOut()
Definition: impgraph.cxx:1354
bool ImplIsAlpha() const
Definition: impgraph.cxx:500
Size maSizePixel
Definition: impgraph.hxx:34
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:179
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
void setHeight(long nHeight)
sal_uLong GetSizeBytes() const
Definition: gdimtf.cxx:2564