43#include <com/sun/star/graphic/XPrimitive2D.hpp>
53#define GRAPHIC_MTFTOBMP_MAXEXT 2048
54#define GRAPHIC_STREAMBUFSIZE 8192UL
56#define SWAP_FORMAT_ID COMPAT_FORMAT( 'S', 'W', 'A', 'P' )
88 mbDummyContext ( false ),
89 maLastUsed (
std::chrono::high_resolution_clock::
now()),
95 : maMetaFile(rImpGraphic.maMetaFile)
96 , maBitmapEx(rImpGraphic.maBitmapEx)
97 , maSwapInfo(rImpGraphic.maSwapInfo)
99 , mpSwapFile(rImpGraphic.mpSwapFile)
100 , mpGfxLink(rImpGraphic.mpGfxLink)
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)
118 : maMetaFile(std::move(rImpGraphic.maMetaFile))
119 , maBitmapEx(std::move(rImpGraphic.maBitmapEx))
120 , maSwapInfo(std::move(rImpGraphic.maSwapInfo))
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)
135 rImpGraphic.mbDummyContext =
false;
139 : mpGfxLink(
std::move(xGfxLink))
143 , mbDummyContext(false)
144 , maLastUsed (
std::chrono::high_resolution_clock::
now())
159 mbDummyContext ( false ),
160 maGraphicExternalLink(
std::move(aGraphicExternalLink)),
161 maLastUsed (
std::chrono::high_resolution_clock::
now()),
167 maBitmapEx ( rBitmapEx ),
171 mbDummyContext ( false ),
172 maLastUsed (
std::chrono::high_resolution_clock::
now()),
181 mbDummyContext ( false ),
182 maVectorGraphicData(rVectorGraphicDataPtr),
183 maLastUsed (
std::chrono::high_resolution_clock::
now()),
194 mbDummyContext ( false ),
195 maLastUsed (
std::chrono::high_resolution_clock::
now()),
205 mbDummyContext ( false ),
206 maLastUsed (
std::chrono::high_resolution_clock::
now()),
218 if( &rImpGraphic !=
this )
250 maLastUsed = std::chrono::high_resolution_clock::now();
262 maMetaFile = std::move(rImpGraphic.maMetaFile);
263 meType = rImpGraphic.meType;
265 maSwapInfo = std::move(rImpGraphic.maSwapInfo);
266 mpContext = std::move(rImpGraphic.mpContext);
269 maBitmapEx = std::move(rImpGraphic.maBitmapEx);
271 mpSwapFile = std::move(rImpGraphic.mpSwapFile);
272 mpGfxLink = std::move(rImpGraphic.mpGfxLink);
278 rImpGraphic.mbDummyContext =
false;
279 maLastUsed = std::chrono::high_resolution_clock::now();
290 if(
this == &rImpGraphic )
396 if (aDescriptor.
Detect(
true))
575 double fWH(
static_cast<double>(aDrawSize.
Width()) /
static_cast<double>(aDrawSize.
Height()));
591 Size aPixelSize(aDrawSize);
607 if(aVDev->SetOutputSizePixel(aPixelSize))
707 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > aSequence(
maVectorGraphicData->getPrimitive2DSequence());
709 if (1 == aSequence.size())
712 const css::uno::Reference< css::graphic::XPrimitive2D > xReference(aSequence[0]);
716 const MetafileAccessor* pMetafileAccessor =
dynamic_cast< const MetafileAccessor*
>(pUnoPrimitive->getBasePrimitive2D().get());
718 if (pMetafileAccessor)
893 aMapMode =
MapMode(MapUnit::Map100thMM);
1046 const Point& rDestPt,
const Size& rDestSize)
const
1095 mpAnimation->Start(rOutDev, rDestPt, rDestSize, nRendererId, pFirstFrameOutDev);
1153 SAL_WARN(
"vcl",
"Incompatible swap file!");
1254 mpGfxLink->getDataContainer().swapOut();
1276 nDataFieldPos = rStream.
Tell();
1280 const sal_uInt64 nDataStart = rStream.
Tell();
1287 const sal_uInt64 nCurrentPosition = rStream.
Tell();
1288 rStream.
Seek(nDataFieldPos);
1289 rStream.
WriteInt32(nCurrentPosition - nDataStart);
1290 rStream.
Seek(nCurrentPosition);
1302 bool bResult =
false;
1324 auto pSwapFile = o3tl::make_shared<ImpSwapFile>(
getOriginURL());
1328 SvStream* pOutputStream = pSwapFile->getStream();
1341 bResult = !pOutputStream->
GetError();
1370 bool bResult =
true;
1373 bResult = pThis->
swapIn();
1375 pThis->maLastUsed = std::chrono::high_resolution_clock::now();
1427 rState.append(
"\n\t");
1430 rState.append(
"swapped\t");
1432 rState.append(
"loaded\t");
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");
1439 rState.append(
"\t");
1443 rState.append(
"\t");
1463std::optional<VectorGraphicDataType> lclConvertToVectorGraphicType(
GfxLink const & rLink)
1482 return std::optional<VectorGraphicDataType>();
1492 bool bReturn =
false;
1502 maLastUsed = std::chrono::high_resolution_clock::now();
1507 std::optional<VectorGraphicDataType> oType = lclConvertToVectorGraphicType(*
mpGfxLink);
1533 maLastUsed = std::chrono::high_resolution_clock::now();
1594 bool bReturn =
false;
1601 sal_Int32 nContentType = -1;
1603 if (nContentType < 0)
1608 switch (eContentType)
1624 auto pAnimation = std::make_unique<Animation>();
1644 sal_uInt32 nVectorGraphicDataSize(0);
1647 if (nVectorGraphicDataSize)
1674 auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, aDataType);
1691 aReader.
Read(aMetaFile);
SvStream & ReadAnimation(SvStream &rIStm, Animation &rAnimation)
SvStream & WriteAnimation(SvStream &rOStm, const Animation &rAnimation)
constexpr sal_uInt32 constPdfMagic
constexpr sal_uInt32 constSvgMagic
constexpr sal_uInt32 constEmfMagic
constexpr sal_uInt32 constWmfMagic
ColorAnimationSharedPtr mpAnimation
sal_uInt64 BitmapChecksum
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
sal_Int64 GetSizeBytes() const
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
void SetPrefMapMode(const MapMode &rPrefMapMode)
void SetPrefSize(const Size &rPrefSize)
BitmapChecksum GetChecksum() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
const MapMode & GetPrefMapMode() const
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
const Size & GetPrefSize() const
const Size & GetSizePixel() const
void SetPrefMapMode(const MapMode &rMapMode)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
void SetPrefSize(const Size &rSize)
GfxLinkType GetType() const
bool getAntiAliase() const
bool getUnlimitedSize() const
const Size & getSizePixel() const
bool getSnapHorVerLines() const
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...
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
bool swapInGraphic(SvStream &rStream)
std::shared_ptr< ImpSwapFile > mpSwapFile
bool operator==(const ImpGraphic &rImpGraphic) const
void setContext(const std::shared_ptr< GraphicReader > &pReader)
bool isSwappedOut() const
void setPrefSize(const Size &rPrefSize)
BitmapChecksum mnChecksum
BitmapEx getBitmapEx(const GraphicConversionParameters &rParameters) const
BitmapChecksum getChecksum() const
void setAnimationNotifyHdl(const Link< Animation *, void > &rLink)
void startAnimation(OutputDevice &rOutDev, const Point &rDestPt, const Size &rDestSize, tools::Long nRendererId, OutputDevice *pFirstFrameOutDev)
void draw(OutputDevice &rOutDev, const Point &rDestPt) const
bool swapInFromStream(SvStream &rStream)
std::chrono::high_resolution_clock::time_point maLastUsed
GraphicExternalLink maGraphicExternalLink
const std::shared_ptr< GfxLink > & getSharedGfxLink() const
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
void stopAnimation(const OutputDevice *pOutputDevice, tools::Long nRendererId)
void setPrepared(bool bAnimated, const Size *pSizeHint)
void dumpState(rtl::OStringBuffer &rState)
sal_uLong getSizeBytes() const
GfxLink getGfxLink() const
Animation getAnimation() const
bool swapOutContent(SvStream &rStream)
MapMode getPrefMapMode() const
Size getSizePixel() const
OUString const & getOriginURL() const
std::shared_ptr< GfxLink > mpGfxLink
bool isTransparent() const
Size maExPrefSize
If maBitmapEx is empty, this preferred size will be set on it when it gets initialized.
void setGfxLink(const std::shared_ptr< GfxLink > &)
Link< Animation *, void > getAnimationNotifyHdl() const
void updateFromLoadedGraphic(const ImpGraphic *graphic)
bool isSupportedGraphic() const
void setPrefMapMode(const MapMode &rPrefMapMode)
std::unique_ptr< Animation > mpAnimation
std::shared_ptr< VectorGraphicData > maVectorGraphicData
Bitmap getBitmap(const GraphicConversionParameters &rParameters) const
bool swapInContent(SvStream &rStream)
bool ensureAvailable() const
SvStream * getSwapFileStream() const
ImpGraphic & operator=(const ImpGraphic &rImpGraphic)
const BitmapEx & getBitmapExRef() const
Gives direct access to the contained BitmapEx.
void setValuesForPrefSize(const Size &rPrefSize)
const GDIMetaFile & getGDIMetaFile() const
GraphicType getType() const
void setOriginURL(OUString const &rOriginURL)
std::shared_ptr< GraphicReader > mpContext
BitmapEx getVectorGraphicReplacement() const
Gets the bitmap replacement for a vector graphic.
void restoreFromSwapInfo()
sal_Int32 getPageNumber() const
void setValuesForPrefMapMod(const MapMode &rPrefMapMode)
sal_uInt32 getAnimationLoopCount() const
bool swapOutGraphic(SvStream &rStream)
ImpSwapFile(OUString aOriginURL)
utl::TempFileFast maTempFile
OUString const & getOriginURL() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
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)
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)
SvStream & Read(GDIMetaFile &rMetaFile, ImplMetaReadData *pData=nullptr)
SvStream & Write(const GDIMetaFile &rMetaFile)
static BitmapChecksum GetChecksum(const GDIMetaFile &rMetaFile)
SvStream * GetStream(StreamMode eMode)
void changeExisting(const ImpGraphic *pImpGraphic, sal_Int64 nOldSize)
void swappedOut(const ImpGraphic *pImpGraphic, sal_Int64 nSizeBytes)
void unregisterGraphic(ImpGraphic *pImpGraphic)
void swappedIn(const ImpGraphic *pImpGraphic, sal_Int64 nSizeBytes)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define SVSTREAM_GENERALERROR
#define GRAPHIC_STREAMBUFSIZE
#define GRAPHIC_MTFTOBMP_MAXEXT
#define SAL_WARN(area, stream)
B2IRange fround(const B2DRange &rRange)
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
std::shared_ptr< VectorGraphicData > loadVectorGraphic(BinaryDataContainer const &rDataContainer, VectorGraphicDataType eType)
ParserContextSharedPtr mpContext
#define STREAM_SEEK_TO_BEGIN
sal_uInt32 mnAnimationLoopCount