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 <SwapFile.hxx>
24
26#include <o3tl/make_shared.hxx>
27#include <tools/fract.hxx>
28#include <tools/vcompat.hxx>
29#include <tools/urlobj.hxx>
30#include <tools/stream.hxx>
33#include <unotools/tempfile.hxx>
34#include <utility>
37#include <vcl/outdev.hxx>
38#include <vcl/graphicfilter.hxx>
39#include <vcl/virdev.hxx>
40#include <vcl/gfxlink.hxx>
41#include <vcl/cvtgrf.hxx>
42#include <vcl/graph.hxx>
43#include <vcl/metaact.hxx>
44#include <impgraph.hxx>
45#include <com/sun/star/graphic/XPrimitive2D.hpp>
47#include <vcl/dibtools.hxx>
48#include <map>
49#include <memory>
52#include <vcl/pdfread.hxx>
54
55#define GRAPHIC_MTFTOBMP_MAXEXT 2048
56#define GRAPHIC_STREAMBUFSIZE 8192UL
57
58#define SWAP_FORMAT_ID COMPAT_FORMAT( 'S', 'W', 'A', 'P' )
59
60using namespace com::sun::star;
61
63{
64private:
65 OUString maOriginURL;
66
67public:
68 ImpSwapFile(INetURLObject const & rSwapURL, OUString aOriginURL)
69 : SwapFile(rSwapURL)
70 , maOriginURL(std::move(aOriginURL))
71 {
72 }
73
74 OUString const & getOriginURL() const { return maOriginURL; }
75};
76
78{
79 if (mpSwapFile)
80 return mpSwapFile->getSwapURL().GetMainURL(INetURLObject::DecodeMechanism::NONE);
81 return OUString();
82}
83
86 mnSizeBytes ( 0 ),
87 mbSwapOut ( false ),
88 mbDummyContext ( false ),
89 maLastUsed (std::chrono::high_resolution_clock::now()),
90 mbPrepared ( false )
91{
92}
93
95 : maMetaFile(rImpGraphic.maMetaFile)
96 , maBitmapEx(rImpGraphic.maBitmapEx)
97 , maSwapInfo(rImpGraphic.maSwapInfo)
98 , mpContext(rImpGraphic.mpContext)
99 , mpSwapFile(rImpGraphic.mpSwapFile)
100 , mpGfxLink(rImpGraphic.mpGfxLink)
101 , meType(rImpGraphic.meType)
102 , mnSizeBytes(rImpGraphic.mnSizeBytes)
103 , mbSwapOut(rImpGraphic.mbSwapOut)
104 , mbDummyContext(rImpGraphic.mbDummyContext)
105 , maVectorGraphicData(rImpGraphic.maVectorGraphicData)
106 , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
107 , maLastUsed (std::chrono::high_resolution_clock::now())
108 , mbPrepared (rImpGraphic.mbPrepared)
109{
110 if( rImpGraphic.mpAnimation )
111 {
112 mpAnimation = std::make_unique<Animation>( *rImpGraphic.mpAnimation );
113 maBitmapEx = mpAnimation->GetBitmapEx();
114 }
115}
116
117ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
118 : maMetaFile(std::move(rImpGraphic.maMetaFile))
119 , maBitmapEx(std::move(rImpGraphic.maBitmapEx))
120 , maSwapInfo(std::move(rImpGraphic.maSwapInfo))
121 , mpAnimation(std::move(rImpGraphic.mpAnimation))
122 , mpContext(std::move(rImpGraphic.mpContext))
123 , mpSwapFile(std::move(rImpGraphic.mpSwapFile))
124 , mpGfxLink(std::move(rImpGraphic.mpGfxLink))
125 , meType(rImpGraphic.meType)
126 , mnSizeBytes(rImpGraphic.mnSizeBytes)
127 , mbSwapOut(rImpGraphic.mbSwapOut)
128 , mbDummyContext(rImpGraphic.mbDummyContext)
129 , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
130 , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
131 , maLastUsed (std::chrono::high_resolution_clock::now())
132 , mbPrepared (rImpGraphic.mbPrepared)
133{
134 rImpGraphic.clear();
135 rImpGraphic.mbDummyContext = false;
136}
137
138ImpGraphic::ImpGraphic(std::shared_ptr<GfxLink> xGfxLink, sal_Int32 nPageIndex)
139 : mpGfxLink(std::move(xGfxLink))
141 , mnSizeBytes(0)
142 , mbSwapOut(true)
143 , mbDummyContext(false)
144 , maLastUsed (std::chrono::high_resolution_clock::now())
145 , mbPrepared (false)
146{
148 maSwapInfo.mbIsAlpha = true;
149 maSwapInfo.mbIsEPS = false;
150 maSwapInfo.mbIsAnimated = false;
152 maSwapInfo.mnPageIndex = nPageIndex;
153}
154
157 mnSizeBytes ( 0 ),
158 mbSwapOut ( false ),
159 mbDummyContext ( false ),
160 maGraphicExternalLink(std::move(aGraphicExternalLink)),
161 maLastUsed (std::chrono::high_resolution_clock::now()),
162 mbPrepared (false)
163{
164}
165
166ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
167 maBitmapEx ( rBitmapEx ),
168 meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
169 mnSizeBytes ( 0 ),
170 mbSwapOut ( false ),
171 mbDummyContext ( false ),
172 maLastUsed (std::chrono::high_resolution_clock::now()),
173 mbPrepared (false)
174{
175}
176
177ImpGraphic::ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr)
178: meType( rVectorGraphicDataPtr ? GraphicType::Bitmap : GraphicType::NONE ),
179 mnSizeBytes( 0 ),
180 mbSwapOut( false ),
181 mbDummyContext ( false ),
182 maVectorGraphicData(rVectorGraphicDataPtr),
183 maLastUsed (std::chrono::high_resolution_clock::now()),
184 mbPrepared (false)
185{
186}
187
188ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
189 maBitmapEx ( rAnimation.GetBitmapEx() ),
190 mpAnimation ( std::make_unique<Animation>( rAnimation ) ),
192 mnSizeBytes ( 0 ),
193 mbSwapOut ( false ),
194 mbDummyContext ( false ),
195 maLastUsed (std::chrono::high_resolution_clock::now()),
196 mbPrepared (false)
197{
198}
199
201 maMetaFile ( rMtf ),
203 mnSizeBytes ( 0 ),
204 mbSwapOut ( false ),
205 mbDummyContext ( false ),
206 maLastUsed (std::chrono::high_resolution_clock::now()),
207 mbPrepared (false)
208{
209}
210
212{
214}
215
217{
218 if( &rImpGraphic != this )
219 {
220 sal_Int64 aOldSizeBytes = mnSizeBytes;
221
222 maMetaFile = rImpGraphic.maMetaFile;
223 meType = rImpGraphic.meType;
224 mnSizeBytes = rImpGraphic.mnSizeBytes;
225
226 maSwapInfo = rImpGraphic.maSwapInfo;
227 mpContext = rImpGraphic.mpContext;
228 mbDummyContext = rImpGraphic.mbDummyContext;
230
231 mpAnimation.reset();
232
233 if ( rImpGraphic.mpAnimation )
234 {
235 mpAnimation = std::make_unique<Animation>( *rImpGraphic.mpAnimation );
236 maBitmapEx = mpAnimation->GetBitmapEx();
237 }
238 else
239 {
240 maBitmapEx = rImpGraphic.maBitmapEx;
241 }
242
243 mbSwapOut = rImpGraphic.mbSwapOut;
244 mpSwapFile = rImpGraphic.mpSwapFile;
245 mbPrepared = rImpGraphic.mbPrepared;
246
247 mpGfxLink = rImpGraphic.mpGfxLink;
248
250 maLastUsed = std::chrono::high_resolution_clock::now();
251
252 vcl::graphic::Manager::get().changeExisting(this, aOldSizeBytes);
253 }
254
255 return *this;
256}
257
259{
260 sal_Int64 aOldSizeBytes = mnSizeBytes;
261
262 maMetaFile = std::move(rImpGraphic.maMetaFile);
263 meType = rImpGraphic.meType;
264 mnSizeBytes = rImpGraphic.mnSizeBytes;
265 maSwapInfo = std::move(rImpGraphic.maSwapInfo);
266 mpContext = std::move(rImpGraphic.mpContext);
267 mbDummyContext = rImpGraphic.mbDummyContext;
268 mpAnimation = std::move(rImpGraphic.mpAnimation);
269 maBitmapEx = std::move(rImpGraphic.maBitmapEx);
270 mbSwapOut = rImpGraphic.mbSwapOut;
271 mpSwapFile = std::move(rImpGraphic.mpSwapFile);
272 mpGfxLink = std::move(rImpGraphic.mpGfxLink);
273 maVectorGraphicData = std::move(rImpGraphic.maVectorGraphicData);
274 maGraphicExternalLink = rImpGraphic.maGraphicExternalLink;
275 mbPrepared = rImpGraphic.mbPrepared;
276
277 rImpGraphic.clear();
278 rImpGraphic.mbDummyContext = false;
279 maLastUsed = std::chrono::high_resolution_clock::now();
280
281 vcl::graphic::Manager::get().changeExisting(this, aOldSizeBytes);
282
283 return *this;
284}
285
286bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const
287{
288 bool bRet = false;
289
290 if( this == &rImpGraphic )
291 bRet = true;
292 else if (mbPrepared && rImpGraphic.mbPrepared)
293 {
294 bRet = (*mpGfxLink == *rImpGraphic.mpGfxLink);
295 }
296 else if (isAvailable() && rImpGraphic.isAvailable())
297 {
298 switch( meType )
299 {
301 bRet = true;
302 break;
303
305 {
306 if( rImpGraphic.maMetaFile == maMetaFile )
307 bRet = true;
308 }
309 break;
310
312 {
314 {
316 {
317 // equal instances
318 bRet = true;
319 }
320 else if(rImpGraphic.maVectorGraphicData)
321 {
322 // equal content
323 bRet = (*maVectorGraphicData) == (*rImpGraphic.maVectorGraphicData);
324 }
325 }
326 else if( mpAnimation )
327 {
328 if( rImpGraphic.mpAnimation && ( *rImpGraphic.mpAnimation == *mpAnimation ) )
329 bRet = true;
330 }
331 else if( !rImpGraphic.mpAnimation && ( rImpGraphic.maBitmapEx == maBitmapEx ) )
332 {
333 bRet = true;
334 }
335 }
336 break;
337
339 break;
340 }
341 }
342
343 return bRet;
344}
345
346const std::shared_ptr<VectorGraphicData>& ImpGraphic::getVectorGraphicData() const
347{
349
350 return maVectorGraphicData;
351}
352
354{
355 if (isSwappedOut())
356 return;
357
358 if (!maBitmapEx.IsEmpty())
360 else
362
371}
372
374{
377 mpAnimation.reset();
378 maVectorGraphicData.reset();
379}
380
381void ImpGraphic::setPrepared(bool bAnimated, const Size* pSizeHint)
382{
383 mbPrepared = true;
384 mbSwapOut = true;
386
387 SvMemoryStream aMemoryStream(const_cast<sal_uInt8*>(mpGfxLink->GetData()), mpGfxLink->GetDataSize(), StreamMode::READ | StreamMode::WRITE);
388
389 if (pSizeHint)
390 {
391 maSwapInfo.maPrefSize = *pSizeHint;
392 maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
393 }
394
395 GraphicDescriptor aDescriptor(aMemoryStream, nullptr);
396 if (aDescriptor.Detect(true))
397 {
398 if (!pSizeHint)
399 {
400 // If we have logic size, work with that, as later pixel -> logic
401 // conversion will work with the output device DPI, not the graphic
402 // DPI.
403 Size aLogSize = aDescriptor.GetSize_100TH_MM();
404 if (aDescriptor.GetPreferredLogSize() && aDescriptor.GetPreferredMapMode())
405 {
408 }
409 else if (aLogSize.getWidth() && aLogSize.getHeight())
410 {
411 maSwapInfo.maPrefSize = aLogSize;
412 maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM);
413 }
414 else
415 {
416 maSwapInfo.maPrefSize = aDescriptor.GetSizePixel();
417 maSwapInfo.maPrefMapMode = MapMode(MapUnit::MapPixel);
418 }
419 }
420
421 maSwapInfo.maSizePixel = aDescriptor.GetSizePixel();
423 maSwapInfo.mbIsAlpha = aDescriptor.IsAlpha();
424 } else {
426 maSwapInfo.mbIsAlpha = false;
427 }
428
430 maSwapInfo.mbIsEPS = false;
431 maSwapInfo.mbIsAnimated = bAnimated;
432
435}
436
438{
439 mpSwapFile.reset();
440 mbSwapOut = false;
441 mbPrepared = false;
442
443 // cleanup
446 sal_Int64 nOldSize = mnSizeBytes;
447 mnSizeBytes = 0;
450}
451
453{
454 clear();
456}
457
459{
460 return( meType != GraphicType::NONE );
461}
462
464{
465 bool bRet(true);
466
467 if (mbSwapOut)
468 {
470 }
472 {
473 bRet = mpAnimation ? mpAnimation->IsTransparent() : maBitmapEx.IsAlpha();
474 }
475
476 return bRet;
477}
478
480{
481 bool bRet(false);
482
483 if (mbSwapOut)
484 {
485 bRet = maSwapInfo.mbIsAlpha;
486 }
487 else if (maVectorGraphicData)
488 {
489 bRet = true;
490 }
491 else if (meType == GraphicType::Bitmap)
492 {
493 bRet = (nullptr == mpAnimation && maBitmapEx.IsAlpha());
494 }
495
496 return bRet;
497}
498
500{
501 return mbSwapOut ? maSwapInfo.mbIsAnimated : mpAnimation != nullptr;
502}
503
505{
506 if (mbSwapOut)
507 return maSwapInfo.mbIsEPS;
508
509 return( ( meType == GraphicType::GdiMetafile ) &&
510 ( maMetaFile.GetActionSize() > 0 ) &&
512}
513
515{
516 return !mbPrepared && !mbSwapOut;
517}
518
520{
521 return ensureAvailable();
522}
523
525{
526 BitmapEx aRet = maVectorGraphicData->getReplacement();
527
529 {
531 }
532
533 return aRet;
534}
535
537{
538 Bitmap aRetBmp;
539
541
543 {
545 {
546 // use maBitmapEx as local buffer for rendered svg
547 const_cast< ImpGraphic* >(this)->maBitmapEx = getVectorGraphicReplacement();
548 }
549
550 const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maBitmapEx );
551
552 aRetBmp = rRetBmpEx.GetBitmap( COL_WHITE );
553
554 if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
555 aRetBmp.Scale(rParameters.getSizePixel());
556 }
557 else if( ( meType != GraphicType::Default ) && isSupportedGraphic() )
558 {
559 if(maBitmapEx.IsEmpty())
560 {
561 // calculate size
563 Size aDrawSize(aVDev->LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
564
565 if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
566 {
567 // apply given size if exists
568 aDrawSize = rParameters.getSizePixel();
569 }
570
571 if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
572 && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
573 {
574 // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
575 double fWH(static_cast<double>(aDrawSize.Width()) / static_cast<double>(aDrawSize.Height()));
576
577 if(fWH <= 1.0)
578 {
581 }
582 else
583 {
586 }
587 }
588
589 // calculate pixel size. Normally, it's the same as aDrawSize, but may
590 // need to be extended when hairlines are on the right or bottom edge
591 Size aPixelSize(aDrawSize);
592
594 {
595 // tdf#126319 Removed correction based on hairline-at-the-extremes of
596 // the metafile. The task shows that this is no longer sufficient since
597 // less hairlines get used in general - what is good, but breaks that
598 // old fix. Anyways, hairlines are a left-over from non-AA times
599 // when it was not possible to paint lines taller than one pixel.
600 // This might need to be corrected further using primitives and
601 // the possibility to get better-quality ranges for correction. For
602 // now, always add that one pixel.
603 aPixelSize.setWidth(aPixelSize.getWidth() + 1);
604 aPixelSize.setHeight(aPixelSize.getHeight() + 1);
605 }
606
607 if(aVDev->SetOutputSizePixel(aPixelSize))
608 {
609 if(rParameters.getAntiAliase())
610 {
611 aVDev->SetAntialiasing(aVDev->GetAntialiasing() | AntialiasingFlags::Enable);
612 }
613
614 if(rParameters.getSnapHorVerLines())
615 {
616 aVDev->SetAntialiasing(aVDev->GetAntialiasing() | AntialiasingFlags::PixelSnapHairline);
617 }
618
619 draw(*aVDev, Point(), aDrawSize);
620
621 // use maBitmapEx as local buffer for rendered metafile
622 const_cast< ImpGraphic* >(this)->maBitmapEx = aVDev->GetBitmapEx( Point(), aVDev->GetOutputSizePixel() );
623 }
624 }
625
626 aRetBmp = maBitmapEx.GetBitmap();
627 }
628
629 if( !aRetBmp.IsEmpty() )
630 {
632 aRetBmp.SetPrefSize(getPrefSize());
633 }
634
635 return aRetBmp;
636}
637
639{
640 BitmapEx aRetBmpEx;
641
643
645 {
647 {
648 // use maBitmapEx as local buffer for rendered svg
649 const_cast< ImpGraphic* >(this)->maBitmapEx = getVectorGraphicReplacement();
650 }
651
652 aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maBitmapEx );
653
654 if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
655 {
656 aRetBmpEx.Scale(
657 rParameters.getSizePixel(),
659 }
660 }
661 else if( ( meType != GraphicType::Default ) && isSupportedGraphic() )
662 {
663 if(maBitmapEx.IsEmpty())
664 {
665 const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
666
667 // use maBitmapEx as local buffer for rendered metafile
668 const_cast< ImpGraphic* >(this)->maBitmapEx = BitmapEx(getBitmap(rParameters), aMonoMask.getBitmap(rParameters));
669 }
670
671 aRetBmpEx = maBitmapEx;
672 }
673
674 return aRetBmpEx;
675}
676
678{
679 Animation aAnimation;
680
682 if( mpAnimation )
683 aAnimation = *mpAnimation;
684
685 return aAnimation;
686}
687
689{
691 return maBitmapEx;
692}
693
695{
701 {
702 // If we have a Emf/Wmf VectorGraphic object, we
703 // need a way to get the Metafile data out of the primitive
704 // representation. Use a strict virtual hook (MetafileAccessor)
705 // to access the MetafilePrimitive2D directly. Also see comments in
706 // XEmfParser about this.
707 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > aSequence(maVectorGraphicData->getPrimitive2DSequence());
708
709 if (1 == aSequence.size())
710 {
711 // try to cast to MetafileAccessor implementation
712 const css::uno::Reference< css::graphic::XPrimitive2D > xReference(aSequence[0]);
713 auto pUnoPrimitive = static_cast< const drawinglayer::primitive2d::UnoPrimitive2D* >(xReference.get());
714 if (pUnoPrimitive)
715 {
716 const MetafileAccessor* pMetafileAccessor = dynamic_cast< const MetafileAccessor* >(pUnoPrimitive->getBasePrimitive2D().get());
717
718 if (pMetafileAccessor)
719 {
720 // it is a MetafileAccessor implementation, get Metafile
721 pMetafileAccessor->accessMetafile(const_cast< ImpGraphic* >(this)->maMetaFile);
722 }
723 }
724 }
725 }
726
728 {
729 // #i119735#
730 // Use the local maMetaFile as container for a metafile-representation
731 // of the bitmap graphic. This will be done only once, thus be buffered.
732 // I checked all usages of maMetaFile, it is only used when type is not
733 // GraphicType::Bitmap. In operator= it will get copied, thus buffering will
734 // survive copying (change this if not wanted)
735 ImpGraphic* pThat = const_cast< ImpGraphic* >(this);
736
738 {
739 // use maBitmapEx as local buffer for rendered svg
741 }
742
743 // #123983# directly create a metafile with the same PrefSize and PrefMapMode
744 // the bitmap has, this will be an always correct metafile
745 if(maBitmapEx.IsAlpha())
746 {
748 }
749 else
750 {
752 }
753
754 pThat->maMetaFile.Stop();
755 pThat->maMetaFile.WindStart();
758 }
759
760 return maMetaFile;
761}
762
764{
765 Size aSize;
766
767 if (isSwappedOut())
768 aSize = maSwapInfo.maSizePixel;
769 else
771
772 return aSize;
773}
774
776{
777 Size aSize;
778
779 if (isSwappedOut())
780 {
781 aSize = maSwapInfo.maPrefSize;
782 }
783 else
784 {
785 switch (meType)
786 {
788 {
790 {
792 {
793 // svg not yet buffered in maBitmapEx, return size derived from range
794 const basegfx::B2DRange& rRange = maVectorGraphicData->getRange();
795
796 aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
797 }
798 else
799 {
800 aSize = maExPrefSize;
801 }
802 }
803 else
804 {
805 aSize = maBitmapEx.GetPrefSize();
806
807 if( !aSize.Width() || !aSize.Height() )
808 {
809 aSize = maBitmapEx.GetSizePixel();
810 }
811 }
812 }
813 break;
814
816 {
817 aSize = maMetaFile.GetPrefSize();
818 }
819 break;
820
823 break;
824 }
825 }
826
827 return aSize;
828}
829
831{
832 switch (meType)
833 {
835 {
836 // used when importing a writer FlyFrame with SVG as graphic, added conversion
837 // to allow setting the PrefSize at the BitmapEx to hold it
839 {
840 maExPrefSize = rPrefSize;
841 }
842
843 // #108077# Push through pref size to animation object,
844 // will be lost on copy otherwise
845 if (mpAnimation)
846 {
847 const_cast< BitmapEx& >(mpAnimation->GetBitmapEx()).SetPrefSize(rPrefSize);
848 }
849
851 {
852 maBitmapEx.SetPrefSize(rPrefSize);
853 }
854 }
855 break;
856
858 {
859 if (isSupportedGraphic())
860 maMetaFile.SetPrefSize(rPrefSize);
861 }
862 break;
863
866 break;
867 }
868}
869
870void ImpGraphic::setPrefSize(const Size& rPrefSize)
871{
873 setValuesForPrefSize(rPrefSize);
874}
875
877{
878 MapMode aMapMode;
879
880 if (isSwappedOut())
881 {
882 aMapMode = maSwapInfo.maPrefMapMode;
883 }
884 else
885 {
886 switch (meType)
887 {
889 {
891 {
892 // svg not yet buffered in maBitmapEx, return default PrefMapMode
893 aMapMode = MapMode(MapUnit::Map100thMM);
894 }
895 else
896 {
897 const Size aSize(maBitmapEx.GetPrefSize());
898
899 if (aSize.Width() && aSize.Height())
900 aMapMode = maBitmapEx.GetPrefMapMode();
901 }
902 }
903 break;
904
906 {
907 return maMetaFile.GetPrefMapMode();
908 }
909 break;
910
913 break;
914 }
915 }
916
917 return aMapMode;
918}
919
921{
922 switch (meType)
923 {
925 {
927 {
928 // ignore for Vector Graphic Data. If this is really used (except the grfcache)
929 // it can be extended by using maBitmapEx as buffer for getVectorGraphicReplacement()
930 }
931 else
932 {
933 // #108077# Push through pref mapmode to animation object,
934 // will be lost on copy otherwise
935 if (mpAnimation)
936 {
937 const_cast<BitmapEx&>(mpAnimation->GetBitmapEx()).SetPrefMapMode(rPrefMapMode);
938 }
939
940 maBitmapEx.SetPrefMapMode(rPrefMapMode);
941 }
942 }
943 break;
944
946 {
947 maMetaFile.SetPrefMapMode(rPrefMapMode);
948 }
949 break;
950
953 break;
954 }
955}
956
957void ImpGraphic::setPrefMapMode(const MapMode& rPrefMapMode)
958{
960 setValuesForPrefMapMod(rPrefMapMode);
961}
962
964{
965 if (mnSizeBytes > 0)
966 return mnSizeBytes;
967
968 if (mbPrepared)
970
971 switch (meType)
972 {
974 {
976 {
977 std::pair<VectorGraphicData::State, size_t> aPair(maVectorGraphicData->getSizeBytes());
978 if (VectorGraphicData::State::UNPARSED == aPair.first)
979 {
980 return aPair.second; // don't cache it until Vector Graphic Data is parsed
981 }
982 mnSizeBytes = aPair.second;
983 }
984 else
985 {
987 }
988 }
989 break;
990
992 {
994 }
995 break;
996
999 break;
1000 }
1001
1002 return mnSizeBytes;
1003}
1004
1005void ImpGraphic::draw(OutputDevice& rOutDev, const Point& rDestPt) const
1006{
1008
1009 if (isSwappedOut())
1010 return;
1011
1012 switch (meType)
1013 {
1015 {
1017 {
1018 // use maBitmapEx as local buffer for rendered svg
1019 const_cast<ImpGraphic*>(this)->maBitmapEx = getVectorGraphicReplacement();
1020 }
1021
1022 if (mpAnimation)
1023 {
1024 mpAnimation->Draw(rOutDev, rDestPt);
1025 }
1026 else
1027 {
1028 maBitmapEx.Draw(&rOutDev, rDestPt);
1029 }
1030 }
1031 break;
1032
1034 {
1035 draw(rOutDev, rDestPt, maMetaFile.GetPrefSize());
1036 }
1037 break;
1038
1040 case GraphicType::NONE:
1041 break;
1042 }
1043}
1044
1046 const Point& rDestPt, const Size& rDestSize) const
1047{
1049
1050 if (isSwappedOut())
1051 return;
1052
1053 switch (meType)
1054 {
1056 {
1058 {
1059 // use maBitmapEx as local buffer for rendered svg
1060 const_cast<ImpGraphic*>(this)->maBitmapEx = getVectorGraphicReplacement();
1061 }
1062
1063 if (mpAnimation)
1064 {
1065 mpAnimation->Draw(rOutDev, rDestPt, rDestSize);
1066 }
1067 else
1068 {
1069 maBitmapEx.Draw(&rOutDev, rDestPt, rDestSize);
1070 }
1071 }
1072 break;
1073
1075 {
1076 const_cast<ImpGraphic*>(this)->maMetaFile.WindStart();
1077 const_cast<ImpGraphic*>(this)->maMetaFile.Play(rOutDev, rDestPt, rDestSize);
1078 const_cast<ImpGraphic*>(this)->maMetaFile.WindStart();
1079 }
1080 break;
1081
1083 case GraphicType::NONE:
1084 break;
1085 }
1086}
1087
1088void ImpGraphic::startAnimation(OutputDevice& rOutDev, const Point& rDestPt,
1089 const Size& rDestSize, tools::Long nRendererId,
1090 OutputDevice* pFirstFrameOutDev )
1091{
1093
1095 mpAnimation->Start(rOutDev, rDestPt, rDestSize, nRendererId, pFirstFrameOutDev);
1096}
1097
1098void ImpGraphic::stopAnimation( const OutputDevice* pOutDev, tools::Long nRendererId )
1099{
1101
1103 mpAnimation->Stop( pOutDev, nRendererId );
1104}
1105
1107{
1109
1110 if( mpAnimation )
1111 mpAnimation->SetNotifyHdl( rLink );
1112}
1113
1115{
1117
1119
1120 if( mpAnimation )
1121 aLink = mpAnimation->GetNotifyHdl();
1122
1123 return aLink;
1124}
1125
1127{
1128 if (mbSwapOut)
1130
1131 return mpAnimation ? mpAnimation->GetLoopCount() : 0;
1132}
1133
1134void ImpGraphic::setContext( const std::shared_ptr<GraphicReader>& pReader )
1135{
1136 mpContext = pReader;
1137 mbDummyContext = false;
1138}
1139
1141{
1142 bool bRet = false;
1143
1144 sal_uInt32 nId;
1145 sal_Int32 nType;
1146 sal_Int32 nLength;
1147
1148 rStream.ReadUInt32(nId);
1149
1150 // check version
1151 if (SWAP_FORMAT_ID != nId)
1152 {
1153 SAL_WARN("vcl", "Incompatible swap file!");
1154 return false;
1155 }
1156
1157 rStream.ReadInt32(nType);
1158 rStream.ReadInt32(nLength);
1159
1160 meType = static_cast<GraphicType>(nType);
1161
1163 {
1164 return true;
1165 }
1166 else
1167 {
1168 bRet = swapInGraphic(rStream);
1169 }
1170
1171 return bRet;
1172}
1173
1175{
1176 if (rStream.GetError())
1177 return false;
1178
1180
1181 if (isSwappedOut())
1182 {
1184 return false;
1185 }
1186
1187 switch (meType)
1188 {
1190 {
1191 if(!rStream.GetError())
1192 {
1193 SvmWriter aWriter(rStream);
1194 aWriter.Write(maMetaFile);
1195 }
1196 }
1197 break;
1198
1200 {
1202 {
1203 rStream.WriteInt32(sal_Int32(GraphicContentType::Vector));
1204 // stream out Vector Graphic defining data (length, byte array and evtl. path)
1205 // this is used e.g. in swapping out graphic data and in transporting it over UNO API
1206 // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
1207 // no problem to extend it; only used at runtime
1208 switch (maVectorGraphicData->getType())
1209 {
1211 {
1212 rStream.WriteUInt32(constWmfMagic);
1213 break;
1214 }
1216 {
1217 rStream.WriteUInt32(constEmfMagic);
1218 break;
1219 }
1221 {
1222 rStream.WriteUInt32(constSvgMagic);
1223 break;
1224 }
1226 {
1227 rStream.WriteUInt32(constPdfMagic);
1228 break;
1229 }
1230 }
1231
1232 rStream.WriteUInt32(maVectorGraphicData->getBinaryDataContainer().getSize());
1233
1234 rStream.WriteBytes(
1235 maVectorGraphicData->getBinaryDataContainer().getData(),
1236 maVectorGraphicData->getBinaryDataContainer().getSize());
1237 }
1238 else if (mpAnimation)
1239 {
1240 rStream.WriteInt32(sal_Int32(GraphicContentType::Animation));
1241 WriteAnimation(rStream, *mpAnimation);
1242 }
1243 else
1244 {
1245 rStream.WriteInt32(sal_Int32(GraphicContentType::Bitmap));
1246 WriteDIBBitmapEx(maBitmapEx, rStream);
1247 }
1248 }
1249 break;
1250
1251 case GraphicType::NONE:
1253 break;
1254 }
1255
1256 return true;
1257}
1258
1260{
1262
1263 bool bRet = false;
1264
1266 return false;
1267
1268 sal_uLong nDataFieldPos;
1269
1270 // Write the SWAP ID
1271 rStream.WriteUInt32(SWAP_FORMAT_ID);
1272
1273 rStream.WriteInt32(static_cast<sal_Int32>(meType));
1274
1275 // data size is updated later
1276 nDataFieldPos = rStream.Tell();
1277 rStream.WriteInt32(0);
1278
1279 // write data block
1280 const sal_uInt64 nDataStart = rStream.Tell();
1281
1282 swapOutGraphic(rStream);
1283
1284 if (!rStream.GetError())
1285 {
1286 // Write the written length th the header
1287 const sal_uInt64 nCurrentPosition = rStream.Tell();
1288 rStream.Seek(nDataFieldPos);
1289 rStream.WriteInt32(nCurrentPosition - nDataStart);
1290 rStream.Seek(nCurrentPosition);
1291 bRet = true;
1292 }
1293
1294 return bRet;
1295}
1296
1298{
1299 if (isSwappedOut())
1300 return false;
1301
1302 bool bResult = false;
1303
1304 sal_Int64 nByteSize = getSizeBytes();
1305
1306 // We have GfxLink so we have the source available
1307 if (mpGfxLink && mpGfxLink->IsNative())
1308 {
1310
1311 clearGraphics();
1312
1313 // reset the swap file
1314 mpSwapFile.reset();
1315
1316 // mark as swapped out
1317 mbSwapOut = true;
1318
1319 bResult = true;
1320 }
1321 else
1322 {
1323 // Create a temp filename for the swap file
1324 const INetURLObject aTempFileURL(utl::CreateTempURL());
1325
1326 // Create a swap file
1327 auto pSwapFile = o3tl::make_shared<ImpSwapFile>(aTempFileURL, getOriginURL());
1328
1329 // Open a stream to write the swap file to
1330 {
1331 std::unique_ptr<SvStream> xOutputStream = pSwapFile->openOutputStream();
1332
1333 if (!xOutputStream)
1334 return false;
1335
1336 // Write to stream
1337 xOutputStream->SetVersion(SOFFICE_FILEFORMAT_50);
1338 xOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
1339 xOutputStream->SetBufferSize(GRAPHIC_STREAMBUFSIZE);
1340
1341 if (!xOutputStream->GetError() && swapOutContent(*xOutputStream))
1342 {
1343 xOutputStream->FlushBuffer();
1344 bResult = !xOutputStream->GetError();
1345 }
1346 }
1347
1348 // Check if writing was successful
1349 if (bResult)
1350 {
1351 // We have swapped out, so can clean memory and prepare swap info
1353 clearGraphics();
1354
1355 mpSwapFile = std::move(pSwapFile);
1356 mbSwapOut = true;
1357 }
1358 }
1359
1360 if (bResult)
1361 {
1362 // Signal to manager that we have swapped out
1363 vcl::graphic::Manager::get().swappedOut(this, nByteSize);
1364 }
1365
1366 return bResult;
1367}
1368
1370{
1371 auto pThis = const_cast<ImpGraphic*>(this);
1372
1373 bool bResult = true;
1374
1375 if (isSwappedOut())
1376 bResult = pThis->swapIn();
1377
1378 pThis->maLastUsed = std::chrono::high_resolution_clock::now();
1379 return bResult;
1380}
1381
1383{
1384 if (mbPrepared)
1385 {
1387 Size aPrefSize = maSwapInfo.maPrefSize;
1388 MapMode aPrefMapMode = maSwapInfo.maPrefMapMode;
1389 *this = *pGraphic;
1390 if (aPrefSize.getWidth() && aPrefSize.getHeight() && aPrefMapMode == getPrefMapMode())
1391 {
1392 // Use custom preferred size if it was set when the graphic was still unloaded.
1393 // Only set the size in case the unloaded and loaded unit matches.
1394 setPrefSize(aPrefSize);
1395 }
1396 maGraphicExternalLink = aLink;
1397 }
1398 else
1399 {
1400 // Move over only graphic content
1401 mpAnimation.reset();
1402 if (pGraphic->mpAnimation)
1403 {
1404 mpAnimation = std::make_unique<Animation>(*pGraphic->mpAnimation);
1405 maBitmapEx = mpAnimation->GetBitmapEx();
1406 }
1407 else
1408 {
1409 maBitmapEx = pGraphic->maBitmapEx;
1410 }
1411
1412 maMetaFile = pGraphic->maMetaFile;
1414
1415 // Set to 0, to force recalculation
1416 mnSizeBytes = 0;
1417 mnChecksum = 0;
1418
1420
1421 mbSwapOut = false;
1422 }
1423}
1424
1426{
1429
1431 {
1433 }
1434}
1435
1436namespace
1437{
1438
1439std::optional<VectorGraphicDataType> lclConvertToVectorGraphicType(GfxLink const & rLink)
1440{
1441 switch(rLink.GetType())
1442 {
1445
1447 if (rLink.IsEMF())
1449 else
1451
1454
1455 default:
1456 break;
1457 }
1458 return std::optional<VectorGraphicDataType>();
1459}
1460
1461} // end namespace
1462
1464{
1465 if (!isSwappedOut())
1466 return false;
1467
1468 bool bReturn = false;
1469
1470 if (mbPrepared)
1471 {
1472 Graphic aGraphic;
1473 if (!mpGfxLink->LoadNative(aGraphic))
1474 return false;
1475
1477
1478 maLastUsed = std::chrono::high_resolution_clock::now();
1479 bReturn = true;
1480 }
1481 else if (mpGfxLink && mpGfxLink->IsNative())
1482 {
1483 std::optional<VectorGraphicDataType> oType = lclConvertToVectorGraphicType(*mpGfxLink);
1484 if (oType)
1485 {
1486 maVectorGraphicData = vcl::loadVectorGraphic(mpGfxLink->getDataContainer(), *oType);
1487
1488 // Set to 0, to force recalculation
1489 mnSizeBytes = 0;
1490 mnChecksum = 0;
1491
1493
1494 mbSwapOut = false;
1495 }
1496 else
1497 {
1498 Graphic aGraphic;
1499 if (!mpGfxLink->LoadNative(aGraphic))
1500 return false;
1501
1502 ImpGraphic* pImpGraphic = aGraphic.ImplGetImpGraphic();
1503 if (meType != pImpGraphic->meType)
1504 return false;
1505
1506 updateFromLoadedGraphic(pImpGraphic);
1507 }
1508
1509 maLastUsed = std::chrono::high_resolution_clock::now();
1510 bReturn = true;
1511 }
1512 else
1513 {
1514 OUString aSwapURL;
1515
1516 if (mpSwapFile)
1517 aSwapURL = mpSwapFile->getSwapURL().GetMainURL(INetURLObject::DecodeMechanism::NONE);
1518
1519 if (!aSwapURL.isEmpty())
1520 {
1521 std::unique_ptr<SvStream> xStream;
1522 try
1523 {
1524 xStream = ::utl::UcbStreamHelper::CreateStream(aSwapURL, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
1525 }
1526 catch( const css::uno::Exception& )
1527 {
1528 }
1529
1530 if (xStream)
1531 {
1532 xStream->SetVersion(SOFFICE_FILEFORMAT_50);
1533 xStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
1534 xStream->SetBufferSize(GRAPHIC_STREAMBUFSIZE);
1535
1536 bReturn = swapInFromStream(*xStream);
1537
1538 xStream.reset();
1539
1541
1542 if (mpSwapFile)
1543 setOriginURL(mpSwapFile->getOriginURL());
1544
1545 mpSwapFile.reset();
1546 }
1547 }
1548 }
1549
1550 if (bReturn)
1551 {
1553 }
1554
1555 return bReturn;
1556}
1557
1559{
1560 bool bRet = false;
1561
1562 if (rStream.GetError())
1563 return false;
1564
1565 clearGraphics();
1566 mnSizeBytes = 0;
1567 mnChecksum = 0;
1568
1569 bRet = swapInContent(rStream);
1570
1571 if (!bRet)
1572 {
1573 //throw away swapfile, etc.
1574 clear();
1575 }
1576
1577 mbSwapOut = false;
1578
1579 return bRet;
1580}
1581
1583{
1584 bool bReturn = false;
1585
1586 if (rStream.GetError())
1587 return bReturn;
1588
1590 {
1591 sal_Int32 nContentType = -1;
1592 rStream.ReadInt32(nContentType);
1593 if (nContentType < 0)
1594 return false;
1595
1596 auto eContentType = static_cast<GraphicContentType>(nContentType);
1597
1598 switch (eContentType)
1599 {
1601 {
1602 BitmapEx aBitmapEx;
1603 ReadDIBBitmapEx(aBitmapEx, rStream);
1604 if (!rStream.GetError())
1605 {
1606 maBitmapEx = aBitmapEx;
1607 bReturn = true;
1608 }
1609 }
1610 break;
1611
1613 {
1614 auto pAnimation = std::make_unique<Animation>();
1615 ReadAnimation(rStream, *pAnimation);
1616 if (!rStream.GetError())
1617 {
1618 mpAnimation = std::move(pAnimation);
1619 maBitmapEx = mpAnimation->GetBitmapEx();
1620 bReturn = true;
1621 }
1622 }
1623 break;
1624
1626 {
1627 // try to stream in Svg defining data (length, byte array and evtl. path)
1628 // See below (operator<<) for more information
1629 sal_uInt32 nMagic;
1630 rStream.ReadUInt32(nMagic);
1631
1633 {
1634 sal_uInt32 nVectorGraphicDataSize(0);
1635 rStream.ReadUInt32(nVectorGraphicDataSize);
1636
1637 if (nVectorGraphicDataSize)
1638 {
1639 auto rData = std::make_unique<std::vector<sal_uInt8>>(nVectorGraphicDataSize);
1640 rStream.ReadBytes(rData->data(), nVectorGraphicDataSize);
1641 BinaryDataContainer aDataContainer(std::move(rData));
1642
1643 if (rStream.GetError())
1644 return false;
1645
1646 VectorGraphicDataType aDataType;
1647
1648 switch (nMagic)
1649 {
1650 case constSvgMagic:
1651 aDataType = VectorGraphicDataType::Svg;
1652 break;
1653 case constWmfMagic:
1654 aDataType = VectorGraphicDataType::Wmf;
1655 break;
1656 case constEmfMagic:
1657 aDataType = VectorGraphicDataType::Emf;
1658 break;
1659 case constPdfMagic:
1660 aDataType = VectorGraphicDataType::Pdf;
1661 break;
1662 default:
1663 return false;
1664 }
1665
1666 auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, aDataType);
1667
1668 if (!rStream.GetError())
1669 {
1670 maVectorGraphicData = aVectorGraphicDataPtr;
1671 bReturn = true;
1672 }
1673 }
1674 }
1675 }
1676 break;
1677 }
1678 }
1679 else if (meType == GraphicType::GdiMetafile)
1680 {
1681 GDIMetaFile aMetaFile;
1682 SvmReader aReader(rStream);
1683 aReader.Read(aMetaFile);
1684 if (!rStream.GetError())
1685 {
1686 maMetaFile = aMetaFile;
1687 bReturn = true;
1688 }
1689 }
1690 return bReturn;
1691}
1692
1693void ImpGraphic::setGfxLink(const std::shared_ptr<GfxLink>& rGfxLink)
1694{
1696
1697 mpGfxLink = rGfxLink;
1698}
1699
1700const std::shared_ptr<GfxLink> & ImpGraphic::getSharedGfxLink() const
1701{
1702 return mpGfxLink;
1703}
1704
1706{
1708
1709 return( mpGfxLink ? *mpGfxLink : GfxLink() );
1710}
1711
1713{
1714 return ( bool(mpGfxLink) );
1715}
1716
1718{
1719 if (mnChecksum != 0)
1720 return mnChecksum;
1721
1723
1724 switch (meType)
1725 {
1726 case GraphicType::NONE:
1728 break;
1729
1731 {
1733 mnChecksum = maVectorGraphicData->GetChecksum();
1734 else if (mpAnimation)
1735 mnChecksum = mpAnimation->GetChecksum();
1736 else
1738 }
1739 break;
1740
1742 {
1744 }
1745 break;
1746 }
1747 return mnChecksum;
1748}
1749
1751{
1752 if (isSwappedOut())
1753 return maSwapInfo.mnPageIndex;
1754
1756 return maVectorGraphicData->getPageIndex();
1757 return -1;
1758}
1759/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvStream & ReadAnimation(SvStream &rIStm, Animation &rAnimation)
Definition: Animation.cxx:634
SvStream & WriteAnimation(SvStream &rOStm, const Animation &rAnimation)
Definition: Animation.cxx:588
constexpr sal_uInt32 constPdfMagic
constexpr sal_uInt32 constSvgMagic
constexpr sal_uInt32 constEmfMagic
constexpr sal_uInt32 constWmfMagic
Reference< XInputStream > xStream
ColorAnimationSharedPtr mpAnimation
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
sal_Int64 GetSizeBytes() const
Definition: BitmapEx.cxx:220
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: BitmapEx.cxx:296
void SetPrefMapMode(const MapMode &rPrefMapMode)
Definition: bitmapex.hxx:79
void Clear()
Definition: BitmapEx.cxx:188
void SetPrefSize(const Size &rPrefSize)
Definition: bitmapex.hxx:76
bool IsAlpha() const
Definition: BitmapEx.cxx:193
BitmapChecksum GetChecksum() const
Definition: BitmapEx.cxx:230
bool IsEmpty() const
Definition: BitmapEx.cxx:177
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:203
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:78
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
Definition: BitmapEx.cxx:500
const Size & GetPrefSize() const
Definition: bitmapex.hxx:75
const Size & GetSizePixel() const
Definition: bitmapex.hxx:72
void SetPrefMapMode(const MapMode &rMapMode)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
bool IsEmpty() const
void SetPrefSize(const Size &rSize)
size_t GetActionSize() const
Definition: gdimtf.cxx:179
void WindStart()
Definition: gdimtf.cxx:568
void Stop()
Definition: gdimtf.cxx:555
const Size & GetPrefSize() const
Definition: gdimtf.hxx:172
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:184
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:581
sal_uLong GetSizeBytes() const
Definition: gdimtf.cxx:2203
void Clear()
Definition: gdimtf.cxx:270
GDIMetaFile GetMonochromeMtf(const Color &rCol) const
Definition: gdimtf.cxx:2188
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:322
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:176
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:175
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:173
bool getAntiAliase() const
Definition: graph.hxx:77
bool getUnlimitedSize() const
Definition: graph.hxx:76
const Size & getSizePixel() const
Definition: graph.hxx:75
bool getSnapHorVerLines() const
Definition: graph.hxx:78
const std::optional< MapMode > & GetPreferredMapMode() const
If available, this returns the map mode the graphic prefers, which may be other than pixel or 100th m...
bool IsAlpha() const
const std::optional< Size > & GetPreferredLogSize() const
Returns the logic size, according to the map mode available via GetPreferredMapMode().
bool Detect(bool bExtendedInfo=false)
starts the detection
const Size & GetSize_100TH_MM() const
bool IsTransparent() const
const Size & GetSizePixel() const
SAL_DLLPRIVATE ImpGraphic * ImplGetImpGraphic() const
Definition: graph.hxx:89
void createSwapInfo()
Definition: impgraph.cxx:353
bool swapInGraphic(SvStream &rStream)
Definition: impgraph.cxx:1582
std::shared_ptr< ImpSwapFile > mpSwapFile
Definition: impgraph.hxx:73
void setDefaultType()
Definition: impgraph.cxx:452
bool operator==(const ImpGraphic &rImpGraphic) const
Definition: impgraph.cxx:286
bool isEPS() const
Definition: impgraph.cxx:504
void setContext(const std::shared_ptr< GraphicReader > &pReader)
Definition: impgraph.cxx:1134
bool isSwappedOut() const
Definition: impgraph.hxx:218
void setPrefSize(const Size &rPrefSize)
Definition: impgraph.cxx:870
BitmapChecksum mnChecksum
Definition: impgraph.hxx:81
GraphicType meType
Definition: impgraph.hxx:75
BitmapEx getBitmapEx(const GraphicConversionParameters &rParameters) const
Definition: impgraph.cxx:638
BitmapChecksum getChecksum() const
Definition: impgraph.cxx:1717
void setAnimationNotifyHdl(const Link< Animation *, void > &rLink)
Definition: impgraph.cxx:1106
void startAnimation(OutputDevice &rOutDev, const Point &rDestPt, const Size &rDestSize, tools::Long nRendererId, OutputDevice *pFirstFrameOutDev)
Definition: impgraph.cxx:1088
sal_uLong mnSizeBytes
Definition: impgraph.hxx:76
void draw(OutputDevice &rOutDev, const Point &rDestPt) const
Definition: impgraph.cxx:1005
bool swapInFromStream(SvStream &rStream)
Definition: impgraph.cxx:1558
std::chrono::high_resolution_clock::time_point maLastUsed
Definition: impgraph.hxx:86
GraphicExternalLink maGraphicExternalLink
Definition: impgraph.hxx:84
GDIMetaFile maMetaFile
Definition: impgraph.hxx:66
const std::shared_ptr< GfxLink > & getSharedGfxLink() const
Definition: impgraph.cxx:1700
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
Definition: impgraph.cxx:346
bool makeAvailable()
Definition: impgraph.cxx:519
void stopAnimation(const OutputDevice *pOutputDevice, tools::Long nRendererId)
Definition: impgraph.cxx:1098
void clear()
Definition: impgraph.cxx:437
OUString getSwapFileURL() const
Definition: impgraph.cxx:77
bool isGfxLink() const
Definition: impgraph.cxx:1712
void setPrepared(bool bAnimated, const Size *pSizeHint)
Definition: impgraph.cxx:381
bool mbPrepared
Definition: impgraph.hxx:87
bool swapOut()
Definition: impgraph.cxx:1297
sal_uLong getSizeBytes() const
Definition: impgraph.cxx:963
GfxLink getGfxLink() const
Definition: impgraph.cxx:1705
Animation getAnimation() const
Definition: impgraph.cxx:677
bool swapOutContent(SvStream &rStream)
Definition: impgraph.cxx:1259
void clearGraphics()
Definition: impgraph.cxx:373
MapMode getPrefMapMode() const
Definition: impgraph.cxx:876
Size getSizePixel() const
Definition: impgraph.cxx:763
OUString const & getOriginURL() const
Definition: impgraph.hxx:110
bool swapIn()
Definition: impgraph.cxx:1463
bool mbDummyContext
Definition: impgraph.hxx:78
std::shared_ptr< GfxLink > mpGfxLink
Definition: impgraph.hxx:74
bool isTransparent() const
Definition: impgraph.cxx:463
Size maExPrefSize
If maBitmapEx is empty, this preferred size will be set on it when it gets initialized.
Definition: impgraph.hxx:69
void setGfxLink(const std::shared_ptr< GfxLink > &)
Definition: impgraph.cxx:1693
Link< Animation *, void > getAnimationNotifyHdl() const
Definition: impgraph.cxx:1114
void updateFromLoadedGraphic(const ImpGraphic *graphic)
Definition: impgraph.cxx:1382
bool mbSwapOut
Definition: impgraph.hxx:77
bool isSupportedGraphic() const
Definition: impgraph.cxx:458
void setPrefMapMode(const MapMode &rPrefMapMode)
Definition: impgraph.cxx:957
std::unique_ptr< Animation > mpAnimation
Definition: impgraph.hxx:71
std::shared_ptr< VectorGraphicData > maVectorGraphicData
Definition: impgraph.hxx:79
Bitmap getBitmap(const GraphicConversionParameters &rParameters) const
Definition: impgraph.cxx:536
bool swapInContent(SvStream &rStream)
Definition: impgraph.cxx:1140
bool isAlpha() const
Definition: impgraph.cxx:479
bool isAvailable() const
Definition: impgraph.cxx:514
bool ensureAvailable() const
Definition: impgraph.cxx:1369
ImpGraphic & operator=(const ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:216
const BitmapEx & getBitmapExRef() const
Gives direct access to the contained BitmapEx.
Definition: impgraph.cxx:688
ImpSwapInfo maSwapInfo
Definition: impgraph.hxx:70
void setValuesForPrefSize(const Size &rPrefSize)
Definition: impgraph.cxx:830
const GDIMetaFile & getGDIMetaFile() const
Definition: impgraph.cxx:694
GraphicType getType() const
Definition: impgraph.hxx:133
void setOriginURL(OUString const &rOriginURL)
Definition: impgraph.hxx:115
std::shared_ptr< GraphicReader > mpContext
Definition: impgraph.hxx:72
BitmapEx getVectorGraphicReplacement() const
Gets the bitmap replacement for a vector graphic.
Definition: impgraph.cxx:524
void restoreFromSwapInfo()
Definition: impgraph.cxx:1425
sal_Int32 getPageNumber() const
Definition: impgraph.cxx:1750
void setValuesForPrefMapMod(const MapMode &rPrefMapMode)
Definition: impgraph.cxx:920
sal_uInt32 getAnimationLoopCount() const
Definition: impgraph.cxx:1126
bool isAnimated() const
Definition: impgraph.cxx:499
Size getPrefSize() const
Definition: impgraph.cxx:775
bool swapOutGraphic(SvStream &rStream)
Definition: impgraph.cxx:1174
BitmapEx maBitmapEx
Definition: impgraph.hxx:67
OUString maOriginURL
Definition: impgraph.cxx:65
OUString const & getOriginURL() const
Definition: impgraph.cxx:74
ImpSwapFile(INetURLObject const &rSwapURL, OUString aOriginURL)
Definition: impgraph.cxx:68
MetaActionType GetType() const
Definition: metaact.hxx:94
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:171
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvStream & WriteInt32(sal_Int32 nInt32)
sal_uInt64 Tell() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
void SetError(ErrCode nErrorCode)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadInt32(sal_Int32 &rInt32)
std::size_t ReadBytes(void *pData, std::size_t nSize)
ErrCode GetError() const
SvStream & Read(GDIMetaFile &rMetaFile, ImplMetaReadData *pData=nullptr)
Definition: SvmReader.cxx:65
SvStream & Write(const GDIMetaFile &rMetaFile)
Definition: SvmWriter.cxx:38
static BitmapChecksum GetChecksum(const GDIMetaFile &rMetaFile)
Definition: SvmWriter.cxx:72
TYPE getWidth() const
TYPE getHeight() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
SwapFile(INetURLObject aSwapURL)
Definition: SwapFile.hxx:37
void changeExisting(const ImpGraphic *pImpGraphic, sal_Int64 nOldSize)
Definition: Manager.cxx:284
static Manager & get()
Definition: Manager.cxx:54
void swappedOut(const ImpGraphic *pImpGraphic, sal_Int64 nSizeBytes)
Definition: Manager.cxx:275
void unregisterGraphic(ImpGraphic *pImpGraphic)
Definition: Manager.cxx:200
void swappedIn(const ImpGraphic *pImpGraphic, sal_Int64 nSizeBytes)
Definition: Manager.cxx:266
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
bool WriteDIBBitmapEx(const BitmapEx &rSource, SvStream &rOStm)
Definition: dibtools.cxx:1849
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1718
#define SVSTREAM_GENERALERROR
#define SOFFICE_FILEFORMAT_50
GraphicType
Definition: graph.hxx:35
#define GRAPHIC_STREAMBUFSIZE
Definition: impgraph.cxx:56
#define SWAP_FORMAT_ID
Definition: impgraph.cxx:58
#define GRAPHIC_MTFTOBMP_MAXEXT
Definition: impgraph.cxx:55
GraphicContentType
Definition: impgraph.hxx:52
#define SAL_WARN(area, stream)
DateTime now
NONE
B2IRange fround(const B2DRange &rRange)
long Long
OUString CreateTempURL(const OUString *pParent, bool bDirectory)
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
Definition: drawmode.cxx:242
std::shared_ptr< VectorGraphicData > loadVectorGraphic(BinaryDataContainer const &rDataContainer, VectorGraphicDataType eType)
sal_Int16 nId
const sal_uInt16 nMagic
QPRO_FUNC_TYPE nType
ParserContextSharedPtr mpContext
sal_uIntPtr sal_uLong
MapMode maPrefMapMode
Definition: impgraph.hxx:32
Size maPrefSize
Definition: impgraph.hxx:33
bool mbIsTransparent
Definition: impgraph.hxx:38
bool mbIsAlpha
Definition: impgraph.hxx:39
Size maSizePixel
Definition: impgraph.hxx:34
sal_uInt32 mnAnimationLoopCount
Definition: impgraph.hxx:41
bool mbIsEPS
Definition: impgraph.hxx:37
bool mbIsAnimated
Definition: impgraph.hxx:36
sal_Int32 mnPageIndex
Definition: impgraph.hxx:42
unsigned char sal_uInt8
VectorGraphicDataType
RedlineType meType
sal_Int32 nLength