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
24#include <o3tl/make_shared.hxx>
25#include <tools/fract.hxx>
26#include <tools/vcompat.hxx>
27#include <tools/urlobj.hxx>
28#include <tools/stream.hxx>
31#include <unotools/tempfile.hxx>
32#include <utility>
35#include <vcl/outdev.hxx>
36#include <vcl/graphicfilter.hxx>
37#include <vcl/virdev.hxx>
38#include <vcl/gfxlink.hxx>
39#include <vcl/cvtgrf.hxx>
40#include <vcl/graph.hxx>
41#include <vcl/metaact.hxx>
42#include <impgraph.hxx>
43#include <com/sun/star/graphic/XPrimitive2D.hpp>
45#include <vcl/dibtools.hxx>
46#include <map>
47#include <memory>
50#include <vcl/pdfread.hxx>
52
53#define GRAPHIC_MTFTOBMP_MAXEXT 2048
54#define GRAPHIC_STREAMBUFSIZE 8192UL
55
56#define SWAP_FORMAT_ID COMPAT_FORMAT( 'S', 'W', 'A', 'P' )
57
58using namespace com::sun::star;
59
60
62{
63private:
65 OUString maOriginURL;
66
67public:
68 ImpSwapFile(OUString aOriginURL)
69 : maOriginURL(std::move(aOriginURL))
70 {
71 }
72
73 SvStream* getStream() { return maTempFile.GetStream(StreamMode::READWRITE); }
74 OUString const & getOriginURL() const { return maOriginURL; }
75};
76
78{
79 if (mpSwapFile)
80 return mpSwapFile->getStream();
81 return nullptr;
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 maVectorGraphicData->getBinaryDataContainer().writeToStream(rStream);
1234 }
1235 else if (mpAnimation)
1236 {
1237 rStream.WriteInt32(sal_Int32(GraphicContentType::Animation));
1238 WriteAnimation(rStream, *mpAnimation);
1239 }
1240 else
1241 {
1242 rStream.WriteInt32(sal_Int32(GraphicContentType::Bitmap));
1243 WriteDIBBitmapEx(maBitmapEx, rStream);
1244 }
1245 }
1246 break;
1247
1248 case GraphicType::NONE:
1250 break;
1251 }
1252
1253 if (mpGfxLink)
1254 mpGfxLink->getDataContainer().swapOut();
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 swap file
1324 auto pSwapFile = o3tl::make_shared<ImpSwapFile>(getOriginURL());
1325
1326 // Open a stream to write the swap file to
1327 {
1328 SvStream* pOutputStream = pSwapFile->getStream();
1329
1330 if (!pOutputStream)
1331 return false;
1332
1333 // Write to stream
1334 pOutputStream->SetVersion(SOFFICE_FILEFORMAT_50);
1335 pOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
1336 pOutputStream->SetBufferSize(GRAPHIC_STREAMBUFSIZE);
1337
1338 if (!pOutputStream->GetError() && swapOutContent(*pOutputStream))
1339 {
1340 pOutputStream->FlushBuffer();
1341 bResult = !pOutputStream->GetError();
1342 }
1343 }
1344
1345 // Check if writing was successful
1346 if (bResult)
1347 {
1348 // We have swapped out, so can clean memory and prepare swap info
1350 clearGraphics();
1351
1352 mpSwapFile = std::move(pSwapFile);
1353 mbSwapOut = true;
1354 }
1355 }
1356
1357 if (bResult)
1358 {
1359 // Signal to manager that we have swapped out
1360 vcl::graphic::Manager::get().swappedOut(this, nByteSize);
1361 }
1362
1363 return bResult;
1364}
1365
1367{
1368 auto pThis = const_cast<ImpGraphic*>(this);
1369
1370 bool bResult = true;
1371
1372 if (isSwappedOut())
1373 bResult = pThis->swapIn();
1374
1375 pThis->maLastUsed = std::chrono::high_resolution_clock::now();
1376 return bResult;
1377}
1378
1380{
1381 if (mbPrepared)
1382 {
1384 Size aPrefSize = maSwapInfo.maPrefSize;
1385 MapMode aPrefMapMode = maSwapInfo.maPrefMapMode;
1386 *this = *pGraphic;
1387 if (aPrefSize.getWidth() && aPrefSize.getHeight() && aPrefMapMode == getPrefMapMode())
1388 {
1389 // Use custom preferred size if it was set when the graphic was still unloaded.
1390 // Only set the size in case the unloaded and loaded unit matches.
1391 setPrefSize(aPrefSize);
1392 }
1393 maGraphicExternalLink = aLink;
1394 }
1395 else
1396 {
1397 // Move over only graphic content
1398 mpAnimation.reset();
1399 if (pGraphic->mpAnimation)
1400 {
1401 mpAnimation = std::make_unique<Animation>(*pGraphic->mpAnimation);
1402 maBitmapEx = mpAnimation->GetBitmapEx();
1403 }
1404 else
1405 {
1406 maBitmapEx = pGraphic->maBitmapEx;
1407 }
1408
1409 maMetaFile = pGraphic->maMetaFile;
1411
1412 // Set to 0, to force recalculation
1413 mnSizeBytes = 0;
1414 mnChecksum = 0;
1415
1417
1418 mbSwapOut = false;
1419 }
1420}
1421
1422void ImpGraphic::dumpState(rtl::OStringBuffer &rState)
1423{
1424 if (meType == GraphicType::NONE && mnSizeBytes == 0)
1425 return; // uninteresting.
1426
1427 rState.append("\n\t");
1428
1429 if (mbSwapOut)
1430 rState.append("swapped\t");
1431 else
1432 rState.append("loaded\t");
1433
1434 rState.append(static_cast<sal_Int32>(meType));
1435 rState.append("\tsize:\t");
1436 rState.append(static_cast<sal_Int64>(mnSizeBytes));
1437 rState.append("\tgfxl:\t");
1438 rState.append(static_cast<sal_Int64>(mpGfxLink ? mpGfxLink->getSizeBytes() : -1));
1439 rState.append("\t");
1440 rState.append(static_cast<sal_Int32>(maSwapInfo.maSizePixel.Width()));
1441 rState.append("x");
1442 rState.append(static_cast<sal_Int32>(maSwapInfo.maSizePixel.Height()));
1443 rState.append("\t");
1444 rState.append(static_cast<sal_Int32>(maExPrefSize.Width()));
1445 rState.append("x");
1446 rState.append(static_cast<sal_Int32>(maExPrefSize.Height()));
1447}
1448
1450{
1453
1455 {
1457 }
1458}
1459
1460namespace
1461{
1462
1463std::optional<VectorGraphicDataType> lclConvertToVectorGraphicType(GfxLink const & rLink)
1464{
1465 switch(rLink.GetType())
1466 {
1469
1471 if (rLink.IsEMF())
1473 else
1475
1478
1479 default:
1480 break;
1481 }
1482 return std::optional<VectorGraphicDataType>();
1483}
1484
1485} // end namespace
1486
1488{
1489 if (!isSwappedOut())
1490 return false;
1491
1492 bool bReturn = false;
1493
1494 if (mbPrepared)
1495 {
1496 Graphic aGraphic;
1497 if (!mpGfxLink->LoadNative(aGraphic))
1498 return false;
1499
1501
1502 maLastUsed = std::chrono::high_resolution_clock::now();
1503 bReturn = true;
1504 }
1505 else if (mpGfxLink && mpGfxLink->IsNative())
1506 {
1507 std::optional<VectorGraphicDataType> oType = lclConvertToVectorGraphicType(*mpGfxLink);
1508 if (oType)
1509 {
1510 maVectorGraphicData = vcl::loadVectorGraphic(mpGfxLink->getDataContainer(), *oType);
1511
1512 // Set to 0, to force recalculation
1513 mnSizeBytes = 0;
1514 mnChecksum = 0;
1515
1517
1518 mbSwapOut = false;
1519 }
1520 else
1521 {
1522 Graphic aGraphic;
1523 if (!mpGfxLink->LoadNative(aGraphic))
1524 return false;
1525
1526 ImpGraphic* pImpGraphic = aGraphic.ImplGetImpGraphic();
1527 if (meType != pImpGraphic->meType)
1528 return false;
1529
1530 updateFromLoadedGraphic(pImpGraphic);
1531 }
1532
1533 maLastUsed = std::chrono::high_resolution_clock::now();
1534 bReturn = true;
1535 }
1536 else
1537 {
1538 SvStream* pStream = nullptr;
1539
1540 if (mpSwapFile)
1541 pStream = mpSwapFile->getStream();
1542
1543 if (pStream)
1544 {
1546 pStream->SetCompressMode(SvStreamCompressFlags::NATIVE);
1548 pStream->Seek(STREAM_SEEK_TO_BEGIN);
1549
1550 bReturn = swapInFromStream(*pStream);
1551
1553
1554 setOriginURL(mpSwapFile->getOriginURL());
1555
1556 mpSwapFile.reset();
1557 }
1558 }
1559
1560 if (bReturn)
1561 {
1563 }
1564
1565 return bReturn;
1566}
1567
1569{
1570 bool bRet = false;
1571
1572 if (rStream.GetError())
1573 return false;
1574
1575 clearGraphics();
1576 mnSizeBytes = 0;
1577 mnChecksum = 0;
1578
1579 bRet = swapInContent(rStream);
1580
1581 if (!bRet)
1582 {
1583 //throw away swapfile, etc.
1584 clear();
1585 }
1586
1587 mbSwapOut = false;
1588
1589 return bRet;
1590}
1591
1593{
1594 bool bReturn = false;
1595
1596 if (rStream.GetError())
1597 return bReturn;
1598
1600 {
1601 sal_Int32 nContentType = -1;
1602 rStream.ReadInt32(nContentType);
1603 if (nContentType < 0)
1604 return false;
1605
1606 auto eContentType = static_cast<GraphicContentType>(nContentType);
1607
1608 switch (eContentType)
1609 {
1611 {
1612 BitmapEx aBitmapEx;
1613 ReadDIBBitmapEx(aBitmapEx, rStream);
1614 if (!rStream.GetError())
1615 {
1616 maBitmapEx = aBitmapEx;
1617 bReturn = true;
1618 }
1619 }
1620 break;
1621
1623 {
1624 auto pAnimation = std::make_unique<Animation>();
1625 ReadAnimation(rStream, *pAnimation);
1626 if (!rStream.GetError())
1627 {
1628 mpAnimation = std::move(pAnimation);
1629 maBitmapEx = mpAnimation->GetBitmapEx();
1630 bReturn = true;
1631 }
1632 }
1633 break;
1634
1636 {
1637 // try to stream in Svg defining data (length, byte array and evtl. path)
1638 // See below (operator<<) for more information
1639 sal_uInt32 nMagic;
1640 rStream.ReadUInt32(nMagic);
1641
1643 {
1644 sal_uInt32 nVectorGraphicDataSize(0);
1645 rStream.ReadUInt32(nVectorGraphicDataSize);
1646
1647 if (nVectorGraphicDataSize)
1648 {
1649 BinaryDataContainer aDataContainer(rStream, nVectorGraphicDataSize);
1650
1651 if (rStream.GetError())
1652 return false;
1653
1654 VectorGraphicDataType aDataType;
1655
1656 switch (nMagic)
1657 {
1658 case constSvgMagic:
1659 aDataType = VectorGraphicDataType::Svg;
1660 break;
1661 case constWmfMagic:
1662 aDataType = VectorGraphicDataType::Wmf;
1663 break;
1664 case constEmfMagic:
1665 aDataType = VectorGraphicDataType::Emf;
1666 break;
1667 case constPdfMagic:
1668 aDataType = VectorGraphicDataType::Pdf;
1669 break;
1670 default:
1671 return false;
1672 }
1673
1674 auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, aDataType);
1675
1676 if (!rStream.GetError())
1677 {
1678 maVectorGraphicData = aVectorGraphicDataPtr;
1679 bReturn = true;
1680 }
1681 }
1682 }
1683 }
1684 break;
1685 }
1686 }
1687 else if (meType == GraphicType::GdiMetafile)
1688 {
1689 GDIMetaFile aMetaFile;
1690 SvmReader aReader(rStream);
1691 aReader.Read(aMetaFile);
1692 if (!rStream.GetError())
1693 {
1694 maMetaFile = aMetaFile;
1695 bReturn = true;
1696 }
1697 }
1698 return bReturn;
1699}
1700
1701void ImpGraphic::setGfxLink(const std::shared_ptr<GfxLink>& rGfxLink)
1702{
1704
1705 mpGfxLink = rGfxLink;
1706}
1707
1708const std::shared_ptr<GfxLink> & ImpGraphic::getSharedGfxLink() const
1709{
1710 return mpGfxLink;
1711}
1712
1714{
1716
1717 return( mpGfxLink ? *mpGfxLink : GfxLink() );
1718}
1719
1721{
1722 return ( bool(mpGfxLink) );
1723}
1724
1726{
1727 if (mnChecksum != 0)
1728 return mnChecksum;
1729
1731
1732 switch (meType)
1733 {
1734 case GraphicType::NONE:
1736 break;
1737
1739 {
1741 mnChecksum = maVectorGraphicData->GetChecksum();
1742 else if (mpAnimation)
1743 mnChecksum = mpAnimation->GetChecksum();
1744 else
1746 }
1747 break;
1748
1750 {
1752 }
1753 break;
1754 }
1755 return mnChecksum;
1756}
1757
1759{
1760 if (isSwappedOut())
1761 return maSwapInfo.mnPageIndex;
1762
1764 return maVectorGraphicData->getPageIndex();
1765 return -1;
1766}
1767/* 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
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:229
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: BitmapEx.cxx:305
void SetPrefMapMode(const MapMode &rPrefMapMode)
Definition: bitmapex.hxx:80
void Clear()
Definition: BitmapEx.cxx:197
void SetPrefSize(const Size &rPrefSize)
Definition: bitmapex.hxx:77
bool IsAlpha() const
Definition: BitmapEx.cxx:207
BitmapChecksum GetChecksum() const
Definition: BitmapEx.cxx:239
bool IsEmpty() const
Definition: BitmapEx.cxx:186
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:217
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:79
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
Definition: BitmapEx.cxx:503
const Size & GetPrefSize() const
Definition: bitmapex.hxx:76
const Size & GetSizePixel() const
Definition: bitmapex.hxx:73
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:181
void WindStart()
Definition: gdimtf.cxx:572
void Stop()
Definition: gdimtf.cxx:559
const Size & GetPrefSize() const
Definition: gdimtf.hxx:176
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:186
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:585
sal_uLong GetSizeBytes() const
Definition: gdimtf.cxx:2213
void Clear()
Definition: gdimtf.cxx:273
GDIMetaFile GetMonochromeMtf(const Color &rCol) const
Definition: gdimtf.cxx:2198
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:325
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:180
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:179
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:177
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:1592
std::shared_ptr< ImpSwapFile > mpSwapFile
Definition: impgraph.hxx:74
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:219
void setPrefSize(const Size &rPrefSize)
Definition: impgraph.cxx:870
BitmapChecksum mnChecksum
Definition: impgraph.hxx:82
GraphicType meType
Definition: impgraph.hxx:76
BitmapEx getBitmapEx(const GraphicConversionParameters &rParameters) const
Definition: impgraph.cxx:638
BitmapChecksum getChecksum() const
Definition: impgraph.cxx:1725
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:77
void draw(OutputDevice &rOutDev, const Point &rDestPt) const
Definition: impgraph.cxx:1005
bool swapInFromStream(SvStream &rStream)
Definition: impgraph.cxx:1568
std::chrono::high_resolution_clock::time_point maLastUsed
Definition: impgraph.hxx:87
GraphicExternalLink maGraphicExternalLink
Definition: impgraph.hxx:85
GDIMetaFile maMetaFile
Definition: impgraph.hxx:67
const std::shared_ptr< GfxLink > & getSharedGfxLink() const
Definition: impgraph.cxx:1708
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
bool isGfxLink() const
Definition: impgraph.cxx:1720
void setPrepared(bool bAnimated, const Size *pSizeHint)
Definition: impgraph.cxx:381
bool mbPrepared
Definition: impgraph.hxx:88
void dumpState(rtl::OStringBuffer &rState)
Definition: impgraph.cxx:1422
bool swapOut()
Definition: impgraph.cxx:1297
sal_uLong getSizeBytes() const
Definition: impgraph.cxx:963
GfxLink getGfxLink() const
Definition: impgraph.cxx:1713
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:111
bool swapIn()
Definition: impgraph.cxx:1487
bool mbDummyContext
Definition: impgraph.hxx:79
std::shared_ptr< GfxLink > mpGfxLink
Definition: impgraph.hxx:75
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:70
void setGfxLink(const std::shared_ptr< GfxLink > &)
Definition: impgraph.cxx:1701
Link< Animation *, void > getAnimationNotifyHdl() const
Definition: impgraph.cxx:1114
void updateFromLoadedGraphic(const ImpGraphic *graphic)
Definition: impgraph.cxx:1379
bool mbSwapOut
Definition: impgraph.hxx:78
bool isSupportedGraphic() const
Definition: impgraph.cxx:458
void setPrefMapMode(const MapMode &rPrefMapMode)
Definition: impgraph.cxx:957
std::unique_ptr< Animation > mpAnimation
Definition: impgraph.hxx:72
std::shared_ptr< VectorGraphicData > maVectorGraphicData
Definition: impgraph.hxx:80
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:1366
SvStream * getSwapFileStream() const
Definition: impgraph.cxx:77
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:71
void setValuesForPrefSize(const Size &rPrefSize)
Definition: impgraph.cxx:830
const GDIMetaFile & getGDIMetaFile() const
Definition: impgraph.cxx:694
GraphicType getType() const
Definition: impgraph.hxx:134
void setOriginURL(OUString const &rOriginURL)
Definition: impgraph.hxx:116
std::shared_ptr< GraphicReader > mpContext
Definition: impgraph.hxx:73
BitmapEx getVectorGraphicReplacement() const
Gets the bitmap replacement for a vector graphic.
Definition: impgraph.cxx:524
void restoreFromSwapInfo()
Definition: impgraph.cxx:1449
sal_Int32 getPageNumber() const
Definition: impgraph.cxx:1758
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:68
SvStream * getStream()
Definition: impgraph.cxx:73
ImpSwapFile(OUString aOriginURL)
Definition: impgraph.cxx:68
utl::TempFileFast maTempFile
Definition: impgraph.cxx:64
OUString maOriginURL
Definition: impgraph.cxx:65
OUString const & getOriginURL() const
Definition: impgraph.cxx:74
MetaActionType GetType() const
Definition: metaact.hxx:96
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
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
void SetCompressMode(SvStreamCompressFlags nNewMode)
void SetBufferSize(sal_uInt16 m_nBufSize)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
void SetError(ErrCode nErrorCode)
void SetVersion(sal_Int32 n)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadInt32(sal_Int32 &rInt32)
ErrCode GetError() const
void FlushBuffer()
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
SvStream * GetStream(StreamMode eMode)
void changeExisting(const ImpGraphic *pImpGraphic, sal_Int64 nOldSize)
Definition: Manager.cxx:308
static Manager & get()
Definition: Manager.cxx:54
void swappedOut(const ImpGraphic *pImpGraphic, sal_Int64 nSizeBytes)
Definition: Manager.cxx:299
void unregisterGraphic(ImpGraphic *pImpGraphic)
Definition: Manager.cxx:224
void swappedIn(const ImpGraphic *pImpGraphic, sal_Int64 nSizeBytes)
Definition: Manager.cxx:290
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
bool WriteDIBBitmapEx(const BitmapEx &rSource, SvStream &rOStm)
Definition: dibtools.cxx:1742
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1623
#define SVSTREAM_GENERALERROR
#define SOFFICE_FILEFORMAT_50
GraphicType
Definition: graph.hxx:35
#define GRAPHIC_STREAMBUFSIZE
Definition: impgraph.cxx:54
#define SWAP_FORMAT_ID
Definition: impgraph.cxx:56
#define GRAPHIC_MTFTOBMP_MAXEXT
Definition: impgraph.cxx:53
GraphicContentType
Definition: impgraph.hxx:53
#define SAL_WARN(area, stream)
DateTime now
NONE
B2IRange fround(const B2DRange &rRange)
long Long
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
#define STREAM_SEEK_TO_BEGIN
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