44 SeekGuard(
SvStream& rStream, sal_uInt64 nStartPosition)
46 , mnStartPosition(nStartPosition)
49 ~SeekGuard() { mrStream.Seek(mnStartPosition); }
53 sal_uInt64 mnStartPosition;
67 bool bSomethingTested =
false;
77 if (!bTest || rFormatExtension.startsWith(
"MET"))
79 bSomethingTested =
true;
87 if (!bTest || rFormatExtension.startsWith(
"BMP"))
89 bSomethingTested =
true;
97 if (!bTest || rFormatExtension.startsWith(
"WMF") || rFormatExtension.startsWith(
"WMZ")
98 || rFormatExtension.startsWith(
"EMF") || rFormatExtension.startsWith(
"EMZ"))
100 bSomethingTested =
true;
108 if (!bTest || rFormatExtension.startsWith(
"PCX"))
110 bSomethingTested =
true;
118 if (!bTest || rFormatExtension.startsWith(
"TIF"))
120 bSomethingTested =
true;
128 if (!bTest || rFormatExtension.startsWith(
"GIF"))
130 bSomethingTested =
true;
138 if (!bTest || rFormatExtension.startsWith(
"APNG"))
140 bSomethingTested =
true;
148 if (!bTest || rFormatExtension.startsWith(
"PNG"))
150 bSomethingTested =
true;
158 if (!bTest || rFormatExtension.startsWith(
"JPG"))
160 bSomethingTested =
true;
168 if (!bTest || rFormatExtension.startsWith(
"SVM"))
170 bSomethingTested =
true;
178 if (!bTest || rFormatExtension.startsWith(
"PCD"))
180 bSomethingTested =
true;
188 if (!bTest || rFormatExtension.startsWith(
"PSD"))
190 bSomethingTested =
true;
198 if (!bTest || rFormatExtension.startsWith(
"EPS"))
200 bSomethingTested =
true;
208 if (!bTest || rFormatExtension.startsWith(
"DXF"))
217 if (!bTest || rFormatExtension.startsWith(
"PCT"))
219 bSomethingTested =
true;
227 if (!bTest || rFormatExtension.startsWith(
"PBM") || rFormatExtension.startsWith(
"PGM")
228 || rFormatExtension.startsWith(
"PPM"))
230 bSomethingTested =
true;
238 if (!bTest || rFormatExtension.startsWith(
"RAS"))
240 bSomethingTested =
true;
250 bSomethingTested =
true;
257 else if (rFormatExtension.startsWith(
"XPM"))
270 else if (rFormatExtension.startsWith(
"XBM"))
283 else if (rFormatExtension.startsWith(
"SVG"))
288 if (!bTest || rFormatExtension.startsWith(
"TGA"))
290 bSomethingTested =
true;
298 if (!bTest || rFormatExtension.startsWith(
"MOV"))
307 if (!bTest || rFormatExtension.startsWith(
"PDF"))
316 if (!bTest || rFormatExtension.startsWith(
"WEBP"))
318 bSomethingTested =
true;
326 return bTest && !bSomethingTested;
337 for (nOffset = 0; (nOffset <= 512) && ((nStreamPos + nOffset + 14) <= nStreamLen);
340 short y1, x1, y2, x2;
343 rStream.
Seek(nStreamPos + nOffset);
357 if (x1 > x2 || y1 > y2 ||
358 (x1 == x2 && y1 == y2) ||
359 x2 - x1 > 2048 || y2 - y1 > 2048)
364 if (sBuf[0] == 0x00 && sBuf[1] == 0x11 && sBuf[2] == 0x02)
367 else if (sBuf[0] == 0x11 && sBuf[1] == 0x01 && bdBoxOk)
378 , maExtension(
std::move(aFormatExtension))
381 , mnStreamPosition(0)
383 , mbExtendedInfo(bExtendedInfo)
384 , mbWasCompressed(false)
428 for (
int i = 0;
i < 4; ++
i)
443 sal_uInt16 nFieldSize;
447 for (
int i = 0;
i < 3;
i++)
497 sal_uInt32 nCompression;
523 nCompression = nTemp32;
528 sal_uInt32 nXPelsPerMeter = 0;
533 nXPelsPerMeter = nTemp32;
538 sal_uInt32 nYPelsPerMeter = 0;
543 nYPelsPerMeter = nTemp32;
553 if (bRet && nXPelsPerMeter && nYPelsPerMeter)
570 sal_uInt64 nCheckSize = std::min<sal_uInt64>(
mnStreamLength, 256);
572 sal_uInt64 nDecompressedSize = nCheckSize;
589 sal_uInt64 nCheckSize = std::min<sal_uInt64>(
mnStreamLength, 256);
591 sal_uInt64 nDecompressedSize = nCheckSize;
595 if (
mnFirstLong == 0x01000000 && pCheckArray[40] == 0x20 && pCheckArray[41] == 0x45
596 && pCheckArray[42] == 0x4d && pCheckArray[43] == 0x46)
604 sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0;
605 sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0;
606 nBoundLeft = pCheckArray[8] | (pCheckArray[9] << 8) | (pCheckArray[10] << 16)
607 | (pCheckArray[11] << 24);
608 nBoundTop = pCheckArray[12] | (pCheckArray[13] << 8) | (pCheckArray[14] << 16)
609 | (pCheckArray[15] << 24);
610 nBoundRight = pCheckArray[16] | (pCheckArray[17] << 8) | (pCheckArray[18] << 16)
611 | (pCheckArray[19] << 24);
612 nBoundBottom = pCheckArray[20] | (pCheckArray[21] << 8) | (pCheckArray[22] << 16)
613 | (pCheckArray[23] << 24);
614 nFrameLeft = pCheckArray[24] | (pCheckArray[25] << 8) | (pCheckArray[26] << 16)
615 | (pCheckArray[27] << 24);
616 nFrameTop = pCheckArray[28] | (pCheckArray[29] << 8) | (pCheckArray[30] << 16)
617 | (pCheckArray[31] << 24);
618 nFrameRight = pCheckArray[32] | (pCheckArray[33] << 8) | (pCheckArray[34] << 16)
619 | (pCheckArray[35] << 24);
620 nFrameBottom = pCheckArray[36] | (pCheckArray[37] << 8) | (pCheckArray[38] << 16)
621 | (pCheckArray[39] << 24);
651 bRet = (cByte == 0 || cByte == 1);
712 if (cByte1 == cByte2)
714 bool bDetectOk =
false;
721 else if (cByte1 == 0x4d)
729 sal_uInt16 nTemp16 = 0;
741 sal_uInt32 nTemp32 = 0;
755 while (nTemp16 != 256)
891 = (cColType == 4 || cColType == 6);
897 sal_uInt32 nLen32 = 0;
987 if (n32 == 0x44475653)
1018 MapMode(MapUnit::Map100thMM));
1028 if (n32 == 0x4D4C4356)
1030 sal_uInt16 nTmp16 = 0;
1034 if (nTmp16 == 0x4654)
1064 if (strncmp(sBuffer,
"PCD_IPI", 7) == 0)
1082 sal_uInt16 nChannels = 0;
1083 sal_uInt32 nRows = 0;
1084 sal_uInt32 nColumns = 0;
1085 sal_uInt16 nDepth = 0;
1086 sal_uInt16 nMode = 0;
1094 if ((nDepth == 1) || (nDepth == 8) || (nDepth == 16))
1121 const char* pFirstBytesAsCharArray =
reinterpret_cast<char*
>(
maFirstBytes.data());
1139 if (strncmp(
reinterpret_cast<char*
>(
maFirstBytes.data()),
"AutoCAD Binary DXF", 18) == 0)
1165 && (strncmp(
reinterpret_cast<char*
>(
maFirstBytes.data() +
i),
"SECTION", 7) == 0))
1188 sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
1190 if (nFirst ==
'P' && ((nSecond ==
'1') || (nSecond ==
'4')) && isspace(nThird))
1200 sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
1203 if (nFirst ==
'P' && ((nSecond ==
'2') || (nSecond ==
'5')) && isspace(nThird))
1213 sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
1216 if (nFirst ==
'P' && ((nSecond ==
'3') || (nSecond ==
'6')) && isspace(nThird))
1236 const char* pFirstBytesAsCharArray =
reinterpret_cast<char*
>(
maFirstBytes.data());
1248 std::unique_ptr<sal_uInt8[]> pBuffer(
new sal_uInt8[nSize]);
1254 const char* pBufferAsCharArray =
reinterpret_cast<char*
>(pBuffer.get());
1267 sal_uInt64 nCheckSize = std::min<sal_uInt64>(
mnStreamLength, 256);
1269 sal_uInt64 nDecompressedSize = nCheckSize;
1273 nCheckSize = std::min<sal_uInt64>(nDecompressedSize, 256);
1276 const char* pCheckArrayAsCharArray =
reinterpret_cast<char*
>(pCheckArray);
1281 {
"<?xml",
"version",
"DOCTYPE",
"svg" }))
1301 pCheckArrayAsCharArray =
reinterpret_cast<char*
>(sExtendedOrDecompressedFirstBytes);
1305 nCheckSize = std::min<sal_uInt64>(nDecompressedSize,
SVG_CHECK_SIZE);
1338 char sFooterBytes[18];
1343 && memcmp(sFooterBytes,
"TRUEVISION-XFILE.",
SAL_N_ELEMENTS(sFooterBytes)) == 0)
1405 sal_uInt32 nSize, sal_uInt64& nRetSize)
1413 auto nDecompressedOut = aCodec.
Read(
mrStream, aUncompressedBuffer, nSize);
1415 nRetSize = nDecompressedOut < 0 ? 0 : nDecompressedOut;
1418 for (
int i = 0;
i < 4; ++
i)
1424 return aUncompressedBuffer;
constexpr sal_uInt32 PNG_TRNS_SIGNATURE
constexpr sal_uInt64 PNG_SIGNATURE
constexpr sal_uInt32 PNG_IDAT_SIGNATURE
constexpr int PNG_SIGNATURE_SIZE
constexpr sal_uInt32 PNG_PHYS_SIGNATURE
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
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
void SetSynchronMode(bool bTheSync=true)
void SetEndian(SvStreamEndian SvStreamEndian)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStreamEndian GetEndian() const
SvLockBytes * GetLockBytes() const
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
void readMapMode(MapMode &rMapMode)
tools::Long Read(SvStream &rIStm, sal_uInt8 *pData, sal_uInt32 nSize)
static bool IsZCompressed(SvStream &rIStm)
tools::Long EndCompression()
void BeginCompression(int nCompressLevel=ZCODEC_DEFAULT_COMPRESSION, bool gzLib=false)
static bool isAPng(SvStream &rStream)
#define SAL_N_ELEMENTS(arr)
bool peekGraphicFormat(SvStream &rStream, OUString &rFormatExtension, bool bTest)
static OUString getImportFormatShortName(GraphicFileFormat nFormat)
bool checkArrayForMatchingStrings(const char *pSource, sal_Int32 nSourceSize, std::vector< OString > const &rStrings)
const char * matchArrayWithString(const char *pSource, sal_Int32 nSourceSize, OString const &rString)
HashMap_OWString_Interface aMap
bool ReadWebpInfo(SvStream &stream, Size &pixelSize, sal_uInt16 &bitsPerPixel, bool &hasAlpha)
#define STREAM_SEEK_TO_END
#define ZCODEC_DEFAULT_COMPRESSION