summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-10-14 14:49:30 +0200
committerVladimir Glazunov <vg@openoffice.org>2010-10-14 14:49:30 +0200
commite21cf551ed6ec03facb14a2649c35886be9f022c (patch)
tree287173de99e1d2ab7acdd306dc2efb1202fc1ba6 /svtools
parentf330de104e33e41150d46578e786d522aa1d3822 (diff)
parent4b5108a2cb9a20f1eb45271000ec12dfeed85b84 (diff)
CWS-TOOLING: integrate CWS impress201
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/filter.vcl/filter/filter.cxx44
1 files changed, 38 insertions, 6 deletions
diff --git a/svtools/source/filter.vcl/filter/filter.cxx b/svtools/source/filter.vcl/filter/filter.cxx
index 65f51ce212f4..9c754a947fcd 100644
--- a/svtools/source/filter.vcl/filter/filter.cxx
+++ b/svtools/source/filter.vcl/filter/filter.cxx
@@ -552,16 +552,48 @@ static BOOL ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtension, B
if( !bTest || ( rFormatExtension.CompareToAscii( "PCT", 3 ) == COMPARE_EQUAL ) )
{
bSomethingTested = TRUE;
- BYTE sBuf[4];
+ BYTE sBuf[3];
+ // store number format
+ sal_uInt16 oldNumberFormat = rStream.GetNumberFormatInt();
sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes
- for ( nOffset = 10; ( nOffset <= 522 ) && ( ( nStreamPos + nOffset + 3 ) <= nStreamLen ); nOffset += 512 )
+ for ( nOffset = 0; ( nOffset <= 512 ) && ( ( nStreamPos + nOffset + 14 ) <= nStreamLen ); nOffset += 512 )
{
- rStream.Seek( nStreamPos + nOffset );
+ short y1,x1,y2,x2;
+ bool bdBoxOk = true;
+
+ rStream.Seek( nStreamPos + nOffset);
+ // size of the pict in version 1 pict ( 2bytes) : ignored
+ rStream.SeekRel(2);
+ // bounding box (bytes 2 -> 9)
+ rStream.SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
+ rStream >> y1 >> x1 >> y2 >> x2;
+ rStream.SetNumberFormatInt(oldNumberFormat); // reset format
+
+ if (x1 > x2 || y1 > y2 || // bad bdbox
+ (x1 == x2 && y1 == y2) || // 1 pixel picture
+ x2-x1 > 2048 || y2-y1 > 2048 ) // picture anormaly big
+ bdBoxOk = false;
+
+ // read version op
rStream.Read( sBuf,3 );
- if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && ( sBuf[ 2 ] == 0x01 || sBuf[ 2 ] == 0x02 ) )
+ // see http://developer.apple.com/legacy/mac/library/documentation/mac/pdf/Imaging_With_QuickDraw/Appendix_A.pdf
+ // normal version 2 - page A23 and A24
+ if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && sBuf[ 2 ] == 0x02)
{
- rFormatExtension = UniString::CreateFromAscii( "PCT", 3 );
- return TRUE;
+ rFormatExtension = UniString::CreateFromAscii( "PCT", 3 );
+ return TRUE;
+ }
+ // normal version 1 - page A25
+ else if (sBuf[ 0 ] == 0x11 && sBuf[ 1 ] == 0x01 && bdBoxOk) {
+ rFormatExtension = UniString::CreateFromAscii( "PCT", 3 );
+ return TRUE;
+ }
+ // previous code kept in order to do not break any compatibility
+ // probably eroneous
+ else if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && sBuf[ 2 ] == 0x01 && bdBoxOk)
+ {
+ rFormatExtension = UniString::CreateFromAscii( "PCT", 3 );
+ return TRUE;
}
}
}