34 aPathExt( rPath.GetFileExtension().toAsciiLowerCase() ),
41 pFileStm ( &rInStream ),
68 else if (
ImpDetectJPG( rStm, bExtendedInfo ) ) bRet =
true;
69 else if (
ImpDetectBMP( rStm, bExtendedInfo ) ) bRet =
true;
70 else if (
ImpDetectPNG( rStm, bExtendedInfo ) ) bRet =
true;
71 else if (
ImpDetectTIF( rStm, bExtendedInfo ) ) bRet =
true;
73 else if (
ImpDetectDXF( rStm, bExtendedInfo ) ) bRet =
true;
74 else if (
ImpDetectMET( rStm, bExtendedInfo ) ) bRet =
true;
75 else if (
ImpDetectSVM( rStm, bExtendedInfo ) ) bRet =
true;
76 else if (
ImpDetectWMF( rStm, bExtendedInfo ) ) bRet =
true;
77 else if (
ImpDetectEMF( rStm, bExtendedInfo ) ) bRet =
true;
78 else if (
ImpDetectSVG( rStm, bExtendedInfo ) ) bRet =
true;
79 else if (
ImpDetectPCT( rStm, bExtendedInfo ) ) bRet =
true;
80 else if (
ImpDetectXBM( rStm, bExtendedInfo ) ) bRet =
true;
81 else if (
ImpDetectXPM( rStm, bExtendedInfo ) ) bRet =
true;
82 else if (
ImpDetectPBM( rStm, bExtendedInfo ) ) bRet =
true;
83 else if (
ImpDetectPGM( rStm, bExtendedInfo ) ) bRet =
true;
84 else if (
ImpDetectPPM( rStm, bExtendedInfo ) ) bRet =
true;
85 else if (
ImpDetectRAS( rStm, bExtendedInfo ) ) bRet =
true;
86 else if (
ImpDetectTGA( rStm, bExtendedInfo ) ) bRet =
true;
87 else if (
ImpDetectPSD( rStm, bExtendedInfo ) ) bRet =
true;
88 else if (
ImpDetectEPS( rStm, bExtendedInfo ) ) bRet =
true;
89 else if (
ImpDetectPCD( rStm, bExtendedInfo ) ) bRet =
true;
108 sal_uInt16 nTemp16 = 0;
110 sal_Int32 nStmPos = rStm.
Tell();
112 rStm.
SetEndian( SvStreamEndian::LITTLE );
116 if ( nTemp16 == 0x4142 )
123 if ( nTemp16 == 0x4d42 )
131 sal_uInt32 nCompression;
154 nCompression = nTemp32;
175 rStm.
Seek( nStmPos );
184 sal_Int32 nStmPos = rStm.
Tell();
185 rStm.
SetEndian( SvStreamEndian::LITTLE );
188 if ( n32 == 0x38464947 )
192 if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) )
199 sal_uInt16 nTemp16 = 0;
216 rStm.
Seek( nStmPos );
232 while ( nByte != 0xff );
239 while( nByte == 0xff );
248 sal_uInt32 nTemp32 = 0;
251 sal_Int32 nStmPos = rStm.
Tell();
257 if( 0xffd8ff00 == ( nTemp32 & 0xffffff00 ) )
268 bool bScanFailure =
false;
269 bool bScanFinished =
false;
272 while (!bScanFailure && !bScanFinished && rStm.
good())
295 bScanFinished =
true;
308 sal_uInt32 nNextMarkerPos = rStm.
Tell() + nLength - 2;
315 sal_Int32 nIdentifier = 0;
317 if ( nIdentifier == 0x4a464946 )
323 sal_uInt16 nHorizontalResolution = 0;
324 sal_uInt16 nVerticalResolution = 0;
338 if ( nUnits && nHorizontalResolution && nVerticalResolution )
340 aMap.
SetMapUnit( nUnits == 1 ? MapUnit::MapInch : MapUnit::MapCM );
366 sal_uInt16 nNumberOfLines = 0;
367 sal_uInt16 nSamplesPerLine = 0;
371 sal_uInt8 nQuantizationTableDestinationSelector = 0;
378 .
ReadUChar( nQuantizationTableDestinationSelector );
386 nBitsPerPixel = ( nNumberOfImageComponents == 3 ? 24 : nNumberOfImageComponents == 1 ? 8 : 0 );
396 bScanFinished =
true;
400 rStm.
Seek( nNextMarkerPos );
409 rStm.
Seek( nStmPos );
417 sal_Int32 nStmPos = rStm.
Tell();
418 rStm.
SetEndian( SvStreamEndian::LITTLE );
420 sal_uInt32 nTemp32 = 0;
421 sal_uInt16 nTemp16 = 0;
429 if ( ( nTemp32 == 0x5f444350 ) &&
430 ( nTemp16 == 0x5049 ) &&
436 rStm.
Seek( nStmPos );
450 sal_Int32 nStmPos = rStm.
Tell();
451 rStm.
SetEndian( SvStreamEndian::LITTLE );
463 bRet = (cByte==0 || cByte ==1);
501 MapMode( MapUnit::Map100thMM ) );
513 rStm.
Seek( nStmPos );
519 sal_uInt32 nTemp32 = 0;
522 sal_Int32 nStmPos = rStm.
Tell();
526 if ( nTemp32 == 0x89504e47 )
529 if ( nTemp32 == 0x0d0a1a0a )
571 sal_uInt32 nLen32 = 0;
579 while( ( nTemp32 != 0x49444154 ) && rStm.
good() )
581 if ( nTemp32 == 0x70485973 )
611 else if ( nTemp32 == 0x74524e53 )
614 bIsAlpha = ( cColType != 0 && cColType != 2 );
626 rStm.
Seek( nStmPos );
636 sal_Int32 nStmPos = rStm.
Tell();
639 if ( cByte1 == cByte2 )
641 bool bDetectOk =
false;
643 if ( cByte1 == 0x49 )
645 rStm.
SetEndian( SvStreamEndian::LITTLE );
648 else if ( cByte1 == 0x4d )
656 sal_uInt16 nTemp16 = 0;
659 if ( nTemp16 == 0x2a )
668 sal_uInt32 nTemp32 = 0;
672 nCount = nTemp32 + 2;
682 while ( nTemp16 != 256 )
729 if ( nTemp16 == 258 )
741 if ( nTemp16 == 259 )
755 rStm.
Seek( nStmPos );
761 bool bRet =
aPathExt.startsWith(
"xbm" );
770 bool bRet =
aPathExt.startsWith(
"xpm" );
786 sal_Int32 nStmPos = rStm.
Tell();
789 if ( nFirst ==
'P' && ( ( nSecond ==
'1' ) || ( nSecond ==
'4' ) ) )
791 rStm.
Seek( nStmPos );
809 sal_Int32 nStmPos = rStm.
Tell();
811 if ( nFirst ==
'P' && ( ( nSecond ==
'2' ) || ( nSecond ==
'5' ) ) )
813 rStm.
Seek( nStmPos );
831 sal_Int32 nStmPos = rStm.
Tell();
833 if ( nFirst ==
'P' && ( ( nSecond ==
'3' ) || ( nSecond ==
'6' ) ) )
835 rStm.
Seek( nStmPos );
846 sal_uInt32 nMagicNumber = 0;
848 sal_Int32 nStmPos = rStm.
Tell();
851 if ( nMagicNumber == 0x59a66a95 )
856 rStm.
Seek( nStmPos );
862 bool bRet =
aPathExt.startsWith(
"tga" );
873 sal_uInt32 nMagicNumber = 0;
874 sal_Int32 nStmPos = rStm.
Tell();
877 if ( nMagicNumber == 0x38425053 )
886 sal_uInt16 nChannels = 0;
887 sal_uInt32 nRows = 0;
888 sal_uInt32 nColumns = 0;
889 sal_uInt16 nDepth = 0;
890 sal_uInt16 nMode = 0;
893 if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) )
919 rStm.
Seek( nStmPos );
926 sal_uInt32 nFirstLong = 0;
930 sal_Int32 nStmPos = rStm.
Tell();
936 if ( ( nFirstLong == 0xC5D0D3C6 ) ||
aPathExt.startsWith(
"eps" ) ||
937 (
ImplSearchEntry( nFirstBytes, reinterpret_cast<sal_uInt8 const *>(
"%!PS-Adobe"), 10, 10 )
938 &&
ImplSearchEntry( &nFirstBytes[15], reinterpret_cast<sal_uInt8 const *>(
"EPS"), 3, 3 ) ) )
943 rStm.
Seek( nStmPos );
949 bool bRet =
aPathExt.startsWith(
"dxf" );
958 bool bRet =
aPathExt.startsWith(
"met" );
967 bool bRet =
aPathExt.startsWith(
"pct" );
972 sal_uInt64
const nStreamPos = rStm.
Tell();
974 if (
isPCT(rStm, nStreamPos, nStreamLen))
979 rStm.
Seek(nStreamPos);
990 sal_Int32 nStmPos = rStm.
Tell();
991 rStm.
SetEndian( SvStreamEndian::LITTLE );
993 if ( n32 == 0x44475653 )
1002 if ( bExtendedInfo )
1023 MapMode( static_cast<MapUnit>(nTemp16) ),
1024 MapMode( MapUnit::Map100thMM ) );
1034 if( n32 == 0x4D4C4356 )
1036 sal_uInt16 nTmp16 = 0;
1040 if( nTmp16 == 0x4654 )
1058 rStm.
Seek( nStmPos );
1064 bool bRet =
aPathExt.startsWith(
"wmf" );
1073 sal_uInt32 nRecordType = 0;
1076 sal_Int32 nStmPos = rStm.
Tell();
1077 rStm.
SetEndian( SvStreamEndian::LITTLE );
1080 if ( nRecordType == 0x00000001 )
1082 sal_uInt32 nHeaderSize = 0;
1083 sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0;
1084 sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0;
1085 sal_uInt32 nSignature = 0;
1098 if ( nSignature == 0x464d4520 )
1103 if ( bExtendedInfo )
1116 rStm.
Seek( nStmPos );
1122 bool bRet =
aPathExt.startsWith(
"svg" );
1131 const char *pKeyName =
nullptr;
1161 return OUString::createFromAscii(pKeyName);
GraphicDescriptor(const GraphicDescriptor &)=delete
bool ImpDetectPCX(SvStream &rStm)
void setWidth(tools::Long nWidth)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
bool ImpDetectEMF(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectBMP(SvStream &rStm, bool bExtendedInfo)
bool isPCT(SvStream &rStream, sal_uLong nStreamPos, sal_uLong nStreamLen)
sal_uInt64 Seek(sal_uInt64 nPos)
bool ImpDetectMET(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPSD(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectGIF(SvStream &rStm, bool bExtendedInfo)
sal_uInt64 SeekRel(sal_Int64 nPos)
bool ImpDetectPBM(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPGM(SvStream &rStm, bool bExtendedInfo)
static sal_uInt8 ImpDetectJPG_GetNextMarker(SvStream &rStm)
HashMap_OWString_Interface aMap
bool ImpDetectPCD(SvStream &rStm, bool bExtendedInfo)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uInt8 mnNumberOfImageComponents
sal_uInt8 * ImplSearchEntry(sal_uInt8 *pSource, sal_uInt8 const *pDest, sal_uLong nComp, sal_uLong nSize)
bool ImpDetectTGA(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPPM(SvStream &rStm, bool bExtendedInfo)
sal_uInt64 remainingSize()
bool ImpDetectEPS(SvStream &rStm, bool bExtendedInfo)
void SetMapUnit(MapUnit eUnit)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
bool ImpDetectDXF(SvStream &rStm, bool bExtendedInfo)
static OUString GetImportFormatShortName(GraphicFileFormat nFormat)
void SetScaleX(const Fraction &rScaleX)
bool ImpDetectPCT(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectXBM(SvStream &rStm, bool bExtendedInfo)
tools::Long Width() const
void SetScaleY(const Fraction &rScaleY)
void SetError(ErrCode nErrorCode)
SvStream & ReadUChar(unsigned char &rChar)
MapUnit GetMapUnit() const
bool ImpDetectWMF(SvStream &rStm, bool bExtendedInfo)
SvStream & ReadInt32(sal_Int32 &rInt32)
std::size_t ReadBytes(void *pData, std::size_t nSize)
SvStreamEndian GetEndian() const
bool ImpDetectSVM(SvStream &rStm, bool bExtendedInfo)
GraphicFileFormat nFormat
bool ImpDetectJPG(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectRAS(SvStream &rStm, bool bExtendedInfo)
void SetEndian(SvStreamEndian SvStreamEndian)
OUString GetFileExtension() const
tools::Long Height() const
bool ImpDetectXPM(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectTIF(SvStream &rStm, bool bExtendedInfo)
void setHeight(tools::Long nHeight)
SvStream & ReadMapMode(SvStream &rIStm, MapMode &rMapMode)
bool ImpDetectSVG(SvStream &rStm, bool bExtendedInfo)
bool ImpDetectPNG(SvStream &rStm, bool bExtendedInfo)
bool Detect(bool bExtendedInfo=false)
starts the detection