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