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