40enum class MetafileType : sal_uInt16
45enum class MetafileVersion : sal_uInt16
54 aPathExt( rPath.GetFileExtension().toAsciiLowerCase() ),
61 pFileStm ( &rInStream ),
88 else if (
ImpDetectJPG( rStm, bExtendedInfo ) ) bRet =
true;
89 else if (
ImpDetectBMP( rStm, bExtendedInfo ) ) bRet =
true;
90 else if (
ImpDetectPNG( rStm, bExtendedInfo ) ) bRet =
true;
91 else if (
ImpDetectTIF( rStm, bExtendedInfo ) ) bRet =
true;
93 else if (
ImpDetectDXF( rStm, bExtendedInfo ) ) bRet =
true;
94 else if (
ImpDetectMET( rStm, bExtendedInfo ) ) bRet =
true;
95 else if (
ImpDetectSVM( rStm, bExtendedInfo ) ) bRet =
true;
96 else if (
ImpDetectWMF( rStm, bExtendedInfo ) ) bRet =
true;
97 else if (
ImpDetectEMF( rStm, bExtendedInfo ) ) bRet =
true;
98 else if (
ImpDetectSVG( rStm, bExtendedInfo ) ) bRet =
true;
99 else if (
ImpDetectPCT( rStm, bExtendedInfo ) ) bRet =
true;
100 else if (
ImpDetectXBM( rStm, bExtendedInfo ) ) bRet =
true;
101 else if (
ImpDetectXPM( rStm, bExtendedInfo ) ) bRet =
true;
102 else if (
ImpDetectPBM( rStm, bExtendedInfo ) ) bRet =
true;
103 else if (
ImpDetectPGM( rStm, bExtendedInfo ) ) bRet =
true;
104 else if (
ImpDetectPPM( rStm, bExtendedInfo ) ) bRet =
true;
105 else if (
ImpDetectRAS( rStm, bExtendedInfo ) ) bRet =
true;
106 else if (
ImpDetectTGA( rStm, bExtendedInfo ) ) bRet =
true;
107 else if (
ImpDetectPSD( rStm, bExtendedInfo ) ) bRet =
true;
108 else if (
ImpDetectEPS( rStm, bExtendedInfo ) ) bRet =
true;
109 else if (
ImpDetectPCD( rStm, bExtendedInfo ) ) bRet =
true;
110 else if (
ImpDetectWEBP( rStm, bExtendedInfo ) ) bRet =
true;
129 sal_uInt16 nTemp16 = 0;
131 sal_Int32 nStmPos = rStm.
Tell();
133 rStm.
SetEndian( SvStreamEndian::LITTLE );
137 if ( nTemp16 == 0x4142 )
144 if ( nTemp16 == 0x4d42 )
152 sal_uInt32 nCompression;
175 nCompression = nTemp32;
180 sal_uInt32 nXPelsPerMeter = 0;
184 nXPelsPerMeter = nTemp32;
189 sal_uInt32 nYPelsPerMeter = 0;
193 nYPelsPerMeter = nTemp32;
203 if (bRet && nXPelsPerMeter && nYPelsPerMeter)
213 rStm.
Seek( nStmPos );
222 sal_Int32 nStmPos = rStm.
Tell();
223 rStm.
SetEndian( SvStreamEndian::LITTLE );
226 if ( n32 == 0x38464947 )
230 if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) )
237 sal_uInt16 nTemp16 = 0;
254 rStm.
Seek( nStmPos );
270 while ( nByte != 0xff );
277 while( nByte == 0xff );
286 sal_uInt32 nTemp32 = 0;
289 sal_Int32 nStmPos = rStm.
Tell();
295 if( 0xffd8ff00 == ( nTemp32 & 0xffffff00 ) )
306 bool bScanFailure =
false;
307 bool bScanFinished =
false;
310 while (!bScanFailure && !bScanFinished && rStm.
good())
333 bScanFinished =
true;
346 sal_uInt32 nNextMarkerPos = rStm.
Tell() +
nLength - 2;
353 sal_Int32 nIdentifier = 0;
355 if ( nIdentifier == 0x4a464946 )
361 sal_uInt16 nHorizontalResolution = 0;
362 sal_uInt16 nVerticalResolution = 0;
376 if ( nUnits && nHorizontalResolution && nVerticalResolution )
378 aMap.SetMapUnit( nUnits == 1 ? MapUnit::MapInch : MapUnit::MapCM );
404 sal_uInt16 nNumberOfLines = 0;
405 sal_uInt16 nSamplesPerLine = 0;
409 sal_uInt8 nQuantizationTableDestinationSelector = 0;
416 .
ReadUChar( nQuantizationTableDestinationSelector );
424 nBitsPerPixel = ( nNumberOfImageComponents == 3 ? 24 : nNumberOfImageComponents == 1 ? 8 : 0 );
427 if (
aMap.GetMapUnit() != MapUnit::MapPixel)
434 bScanFinished =
true;
438 rStm.
Seek( nNextMarkerPos );
447 rStm.
Seek( nStmPos );
455 sal_Int32 nStmPos = rStm.
Tell();
456 rStm.
SetEndian( SvStreamEndian::LITTLE );
458 sal_uInt32 nTemp32 = 0;
459 sal_uInt16 nTemp16 = 0;
467 if ( ( nTemp32 == 0x5f444350 ) &&
468 ( nTemp16 == 0x5049 ) &&
474 rStm.
Seek( nStmPos );
488 sal_Int32 nStmPos = rStm.
Tell();
489 rStm.
SetEndian( SvStreamEndian::LITTLE );
501 bRet = (cByte==0 || cByte ==1);
539 MapMode( MapUnit::Map100thMM ) );
551 rStm.
Seek( nStmPos );
557 sal_uInt32 nTemp32 = 0;
560 sal_Int32 nStmPos = rStm.
Tell();
564 if ( nTemp32 == 0x89504e47 )
567 if ( nTemp32 == 0x0d0a1a0a )
609 sal_uInt32 nLen32 = 0;
617 while (rStm.
good() && nTemp32 != 0x49444154)
619 if ( nTemp32 == 0x70485973 )
649 else if ( nTemp32 == 0x74524e53 )
652 bIsAlpha = ( cColType != 0 && cColType != 2 );
664 rStm.
Seek( nStmPos );
674 sal_Int32 nStmPos = rStm.
Tell();
677 if ( cByte1 == cByte2 )
679 bool bDetectOk =
false;
681 if ( cByte1 == 0x49 )
683 rStm.
SetEndian( SvStreamEndian::LITTLE );
686 else if ( cByte1 == 0x4d )
694 sal_uInt16 nTemp16 = 0;
697 if ( nTemp16 == 0x2a )
706 sal_uInt32 nTemp32 = 0;
720 while ( nTemp16 != 256 )
767 if ( nTemp16 == 258 )
779 if ( nTemp16 == 259 )
793 rStm.
Seek( nStmPos );
799 bool bRet =
aPathExt.startsWith(
"xbm" );
808 bool bRet =
aPathExt.startsWith(
"xpm" );
824 sal_Int32 nStmPos = rStm.
Tell();
827 if ( nFirst ==
'P' && ( ( nSecond ==
'1' ) || ( nSecond ==
'4' ) ) )
829 rStm.
Seek( nStmPos );
847 sal_Int32 nStmPos = rStm.
Tell();
849 if ( nFirst ==
'P' && ( ( nSecond ==
'2' ) || ( nSecond ==
'5' ) ) )
851 rStm.
Seek( nStmPos );
869 sal_Int32 nStmPos = rStm.
Tell();
871 if ( nFirst ==
'P' && ( ( nSecond ==
'3' ) || ( nSecond ==
'6' ) ) )
873 rStm.
Seek( nStmPos );
884 sal_uInt32 nMagicNumber = 0;
886 sal_Int32 nStmPos = rStm.
Tell();
889 if ( nMagicNumber == 0x59a66a95 )
894 rStm.
Seek( nStmPos );
900 bool bRet =
aPathExt.startsWith(
"tga" );
911 sal_uInt32 nMagicNumber = 0;
912 sal_Int32 nStmPos = rStm.
Tell();
915 if ( nMagicNumber == 0x38425053 )
924 sal_uInt16 nChannels = 0;
925 sal_uInt32 nRows = 0;
926 sal_uInt32 nColumns = 0;
927 sal_uInt16 nDepth = 0;
928 sal_uInt16 nMode = 0;
931 if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) )
957 rStm.
Seek( nStmPos );
964 sal_uInt32 nFirstLong = 0;
968 sal_Int32 nStmPos = rStm.
Tell();
974 if ( ( nFirstLong == 0xC5D0D3C6 ) ||
aPathExt.startsWith(
"eps" ) ||
981 rStm.
Seek( nStmPos );
987 bool bRet =
aPathExt.startsWith(
"dxf" );
996 bool bRet =
aPathExt.startsWith(
"met" );
1005 bool bRet =
aPathExt.startsWith(
"pct" );
1010 sal_uInt64
const nStreamPos = rStm.
Tell();
1012 if (
isPCT(rStm, nStreamPos, nStreamLen))
1017 rStm.
Seek(nStreamPos);
1028 sal_Int32 nStmPos = rStm.
Tell();
1029 rStm.
SetEndian( SvStreamEndian::LITTLE );
1031 if ( n32 == 0x44475653 )
1035 if ( cByte == 0x49 )
1040 if ( bExtendedInfo )
1062 MapMode( MapUnit::Map100thMM ) );
1072 if( n32 == 0x4D4C4356 )
1074 sal_uInt16 nTmp16 = 0;
1078 if( nTmp16 == 0x4654 )
1095 rStm.
Seek( nStmPos );
1114 aNewStream = &aMemStream;
1116 sal_uInt32 nKey = 0;
1117 sal_Int32 nStmPos = rStm.
Tell();
1118 aNewStream->
SetEndian(SvStreamEndian::LITTLE);
1128 sal_uInt16 nKeyLSW = nKey & 0xFFFF;
1131 if ((nKeyLSW ==
static_cast<sal_uInt16
>(MetafileType::Memory)
1132 || nKeyLSW ==
static_cast<sal_uInt16
>(MetafileType::Disk))
1133 && (
nVersion ==
static_cast<sal_uInt16
>(MetafileVersion::Version100)
1134 ||
nVersion ==
static_cast<sal_uInt16
>(MetafileVersion::Version300)))
1159 aNewStream = &aMemStream;
1162 sal_uInt32 nRecordType = 0;
1164 sal_Int32 nStmPos = aNewStream->
Tell();
1165 aNewStream->
SetEndian(SvStreamEndian::LITTLE);
1169 sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0;
1170 sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0;
1171 sal_uInt32 nSignature = 0;
1208 bool bRet =
aPathExt.startsWith(
"svg" );
1217 sal_uInt32 nTemp32 = 0;
1220 sal_Int32 nStmPos = rStm.
Tell();
1224 if ( nTemp32 == 0x52494646 )
1228 if ( nTemp32 == 0x57454250 )
1233 if ( bExtendedInfo )
1241 rStm.
Seek( nStmPos );
1247 const char *pKeyName =
nullptr;
1275 default: assert(
false);
1278 return OUString::createFromAscii(pKeyName);
bool ImpDetectDXF(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectSVM(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectWMF(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPNG(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectTIF(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPGM(SvStream &rStm, bool bExtendedInfo)
GraphicDescriptor(const GraphicDescriptor &)=delete
static OUString GetImportFormatShortName(GraphicFileFormat nFormat)
bool Detect(bool bExtendedInfo=false)
starts the detection
bool ImpDetectMET(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectRAS(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPCD(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectEPS(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPPM(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPSD(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectWEBP(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectXPM(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPBM(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectXBM(SvStream &rStm, bool bExtendedInfo)
std::optional< Size > maPreferredLogSize
std::optional< MapMode > maPreferredMapMode
bool ImpDetectBMP(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectJPG(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectSVG(SvStream &rStm, bool bExtendedInfo)
sal_uInt8 mnNumberOfImageComponents
GraphicFileFormat nFormat
bool ImpDetectGIF(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPCX(SvStream &rStm)
bool ImpDetectEMF(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectTGA(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPCT(SvStream &rStm, bool bExtendedInfo)
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 SetBuffer(void *pBuf, std::size_t nSize, std::size_t nEOF)
void SetEndian(SvStreamEndian SvStreamEndian)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStreamEndian GetEndian() const
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)
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)
constexpr sal_uInt32 PLACEABLE_SIGNATURE
constexpr sal_uInt32 WMF_CHECK_SIZE
constexpr sal_uInt32 EMF_CHECK_SIZE
constexpr sal_uInt32 EMR_HEADER
constexpr sal_uInt32 ENHMETA_SIGNATURE
static sal_uInt8 ImpDetectJPG_GetNextMarker(SvStream &rStm)
bool isPCT(SvStream &rStream, sal_uLong nStreamPos, sal_uLong nStreamLen)
sal_uInt8 * ImplSearchEntry(sal_uInt8 *pSource, sal_uInt8 const *pDest, sal_uLong nComp, sal_uLong nSize)
HashMap_OWString_Interface aMap
bool ReadWebpInfo(SvStream &stream, Size &pixelSize, sal_uInt16 &bitsPerPixel, bool &hasAlpha)
#define ZCODEC_DEFAULT_COMPRESSION