43 SeekGuard(
SvStream& rStream, sal_uInt64 nStartPosition)
45 , mnStartPosition(nStartPosition)
48 ~SeekGuard() { mrStream.Seek(mnStartPosition); }
52 sal_uInt64 mnStartPosition;
66 bool bSomethingTested =
false;
76 if (!bTest || rFormatExtension.startsWith(
"MET"))
78 bSomethingTested =
true;
86 if (!bTest || rFormatExtension.startsWith(
"BMP"))
88 bSomethingTested =
true;
96 if (!bTest || rFormatExtension.startsWith(
"WMF") || rFormatExtension.startsWith(
"WMZ")
97 || rFormatExtension.startsWith(
"EMF") || rFormatExtension.startsWith(
"EMZ"))
99 bSomethingTested =
true;
107 if (!bTest || rFormatExtension.startsWith(
"PCX"))
109 bSomethingTested =
true;
117 if (!bTest || rFormatExtension.startsWith(
"TIF"))
119 bSomethingTested =
true;
127 if (!bTest || rFormatExtension.startsWith(
"GIF"))
129 bSomethingTested =
true;
137 if (!bTest || rFormatExtension.startsWith(
"PNG"))
139 bSomethingTested =
true;
147 if (!bTest || rFormatExtension.startsWith(
"JPG"))
149 bSomethingTested =
true;
157 if (!bTest || rFormatExtension.startsWith(
"SVM"))
159 bSomethingTested =
true;
167 if (!bTest || rFormatExtension.startsWith(
"PCD"))
169 bSomethingTested =
true;
177 if (!bTest || rFormatExtension.startsWith(
"PSD"))
179 bSomethingTested =
true;
187 if (!bTest || rFormatExtension.startsWith(
"EPS"))
189 bSomethingTested =
true;
197 if (!bTest || rFormatExtension.startsWith(
"DXF"))
206 if (!bTest || rFormatExtension.startsWith(
"PCT"))
208 bSomethingTested =
true;
216 if (!bTest || rFormatExtension.startsWith(
"PBM") || rFormatExtension.startsWith(
"PGM")
217 || rFormatExtension.startsWith(
"PPM"))
219 bSomethingTested =
true;
227 if (!bTest || rFormatExtension.startsWith(
"RAS"))
229 bSomethingTested =
true;
239 bSomethingTested =
true;
246 else if (rFormatExtension.startsWith(
"XPM"))
259 else if (rFormatExtension.startsWith(
"XBM"))
272 else if (rFormatExtension.startsWith(
"SVG"))
277 if (!bTest || rFormatExtension.startsWith(
"TGA"))
279 bSomethingTested =
true;
287 if (!bTest || rFormatExtension.startsWith(
"MOV"))
296 if (!bTest || rFormatExtension.startsWith(
"PDF"))
305 if (!bTest || rFormatExtension.startsWith(
"WEBP"))
307 bSomethingTested =
true;
315 return bTest && !bSomethingTested;
326 for (nOffset = 0; (nOffset <= 512) && ((nStreamPos + nOffset + 14) <= nStreamLen);
329 short y1, x1, y2, x2;
332 rStream.
Seek(nStreamPos + nOffset);
346 if (x1 > x2 || y1 > y2 ||
347 (x1 == x2 && y1 == y2) ||
348 x2 - x1 > 2048 || y2 - y1 > 2048)
353 if (sBuf[0] == 0x00 && sBuf[1] == 0x11 && sBuf[2] == 0x02)
356 else if (sBuf[0] == 0x11 && sBuf[1] == 0x01 && bdBoxOk)
367 , maExtension(
std::move(aFormatExtension))
370 , mnStreamPosition(0)
372 , mbExtendedInfo(bExtendedInfo)
373 , mbWasCompressed(false)
417 for (
int i = 0;
i < 4; ++
i)
432 sal_uInt16 nFieldSize;
436 for (
int i = 0;
i < 3;
i++)
486 sal_uInt32 nCompression;
512 nCompression = nTemp32;
517 sal_uInt32 nXPelsPerMeter = 0;
522 nXPelsPerMeter = nTemp32;
527 sal_uInt32 nYPelsPerMeter = 0;
532 nYPelsPerMeter = nTemp32;
542 if (bRet && nXPelsPerMeter && nYPelsPerMeter)
559 sal_uInt64 nCheckSize = std::min<sal_uInt64>(
mnStreamLength, 256);
561 sal_uInt64 nDecompressedSize = nCheckSize;
578 sal_uInt64 nCheckSize = std::min<sal_uInt64>(
mnStreamLength, 256);
580 sal_uInt64 nDecompressedSize = nCheckSize;
584 if (
mnFirstLong == 0x01000000 && pCheckArray[40] == 0x20 && pCheckArray[41] == 0x45
585 && pCheckArray[42] == 0x4d && pCheckArray[43] == 0x46)
593 sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0;
594 sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0;
595 nBoundLeft = pCheckArray[8] | (pCheckArray[9] << 8) | (pCheckArray[10] << 16)
596 | (pCheckArray[11] << 24);
597 nBoundTop = pCheckArray[12] | (pCheckArray[13] << 8) | (pCheckArray[14] << 16)
598 | (pCheckArray[15] << 24);
599 nBoundRight = pCheckArray[16] | (pCheckArray[17] << 8) | (pCheckArray[18] << 16)
600 | (pCheckArray[19] << 24);
601 nBoundBottom = pCheckArray[20] | (pCheckArray[21] << 8) | (pCheckArray[22] << 16)
602 | (pCheckArray[23] << 24);
603 nFrameLeft = pCheckArray[24] | (pCheckArray[25] << 8) | (pCheckArray[26] << 16)
604 | (pCheckArray[27] << 24);
605 nFrameTop = pCheckArray[28] | (pCheckArray[29] << 8) | (pCheckArray[30] << 16)
606 | (pCheckArray[31] << 24);
607 nFrameRight = pCheckArray[32] | (pCheckArray[33] << 8) | (pCheckArray[34] << 16)
608 | (pCheckArray[35] << 24);
609 nFrameBottom = pCheckArray[36] | (pCheckArray[37] << 8) | (pCheckArray[38] << 16)
610 | (pCheckArray[39] << 24);
640 bRet = (cByte == 0 || cByte == 1);
701 if (cByte1 == cByte2)
703 bool bDetectOk =
false;
710 else if (cByte1 == 0x4d)
718 sal_uInt16 nTemp16 = 0;
730 sal_uInt32 nTemp32 = 0;
744 while (nTemp16 != 256)
879 = (cColType == 4 || cColType == 6);
885 sal_uInt32 nLen32 = 0;
895 if (nTemp32 == 0x70485973)
927 else if (nTemp32 == 0x74524e53)
964 if (n32 == 0x44475653)
1005 if (n32 == 0x4D4C4356)
1007 sal_uInt16 nTmp16 = 0;
1011 if (nTmp16 == 0x4654)
1041 if (strncmp(sBuffer,
"PCD_IPI", 7) == 0)
1059 sal_uInt16 nChannels = 0;
1060 sal_uInt32 nRows = 0;
1061 sal_uInt32 nColumns = 0;
1062 sal_uInt16 nDepth = 0;
1063 sal_uInt16 nMode = 0;
1071 if ((nDepth == 1) || (nDepth == 8) || (nDepth == 16))
1098 const char* pFirstBytesAsCharArray =
reinterpret_cast<char*
>(
maFirstBytes.data());
1116 if (strncmp(
reinterpret_cast<char*
>(
maFirstBytes.data()),
"AutoCAD Binary DXF", 18) == 0)
1142 && (strncmp(
reinterpret_cast<char*
>(
maFirstBytes.data() +
i),
"SECTION", 7) == 0))
1165 sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
1167 if (nFirst ==
'P' && ((nSecond ==
'1') || (nSecond ==
'4')) && isspace(nThird))
1177 sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
1180 if (nFirst ==
'P' && ((nSecond ==
'2') || (nSecond ==
'5')) && isspace(nThird))
1190 sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
1193 if (nFirst ==
'P' && ((nSecond ==
'3') || (nSecond ==
'6')) && isspace(nThird))
1213 const char* pFirstBytesAsCharArray =
reinterpret_cast<char*
>(
maFirstBytes.data());
1225 std::unique_ptr<sal_uInt8[]> pBuffer(
new sal_uInt8[nSize]);
1231 const char* pBufferAsCharArray =
reinterpret_cast<char*
>(pBuffer.get());
1244 sal_uInt64 nCheckSize = std::min<sal_uInt64>(
mnStreamLength, 256);
1246 sal_uInt64 nDecompressedSize = nCheckSize;
1250 nCheckSize = std::min<sal_uInt64>(nDecompressedSize, 256);
1252 bool bIsGZip = (nDecompressedSize > 0);
1253 const char* pCheckArrayAsCharArray =
reinterpret_cast<char*
>(pCheckArray);
1258 {
"<?xml",
"version",
"DOCTYPE",
"svg" }))
1278 pCheckArrayAsCharArray =
reinterpret_cast<char*
>(sExtendedOrDecompressedFirstBytes);
1282 nCheckSize = std::min<sal_uInt64>(nDecompressedSize, 2048);
1315 char sFooterBytes[18];
1320 && memcmp(sFooterBytes,
"TRUEVISION-XFILE.",
SAL_N_ELEMENTS(sFooterBytes)) == 0)
1382 sal_uInt32 nSize, sal_uInt64& nRetSize)
1390 auto nDecompressedOut = aCodec.
Read(
mrStream, aUncompressedBuffer, nSize);
1392 nRetSize = nDecompressedOut < 0 ? 0 : nDecompressedOut;
1395 for (
int i = 0;
i < 4; ++
i)
1401 return aUncompressedBuffer;
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)
#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