You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(31) |
Jul
(37) |
Aug
(20) |
Sep
(20) |
Oct
(16) |
Nov
(10) |
Dec
(16) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(11) |
May
(136) |
Jun
(61) |
Jul
(42) |
Aug
(21) |
Sep
(25) |
Oct
(43) |
Nov
(5) |
Dec
(24) |
2008 |
Jan
|
Feb
|
Mar
(2) |
Apr
(11) |
May
|
Jun
|
Jul
(51) |
Aug
(6) |
Sep
|
Oct
|
Nov
(21) |
Dec
(35) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(10) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(35) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
From: Fridrich S. <str...@us...> - 2007-12-11 14:59:04
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv31190/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp Log Message: fix being overkeen :-) Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.6 retrieving revision 1.58.2.7 diff -u -d -r1.58.2.6 -r1.58.2.7 --- WPG2Parser.cpp 11 Dec 2007 14:50:02 -0000 1.58.2.6 +++ WPG2Parser.cpp 11 Dec 2007 14:58:52 -0000 1.58.2.7 @@ -1357,17 +1357,9 @@ if (objCh.scale) { if (objCh.sxcos < 0) - { m_hFlipped = true; - objCh.sxcos = -objCh.sxcos; - objCh.matrix.element[0][0] = -objCh.matrix.element[0][0]; - } if (objCh.sycos < 0) - { m_vFlipped = true; - objCh.sycos = -objCh.sycos; - objCh.matrix.element[1][1] = -objCh.matrix.element[1][1]; - } } m_matrix = objCh.matrix; |
From: Fridrich S. <str...@us...> - 2007-12-11 14:50:07
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27601/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp Log Message: fix a little warning Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.5 retrieving revision 1.58.2.6 diff -u -d -r1.58.2.5 -r1.58.2.6 --- WPG2Parser.cpp 11 Dec 2007 14:46:31 -0000 1.58.2.5 +++ WPG2Parser.cpp 11 Dec 2007 14:50:02 -0000 1.58.2.6 @@ -226,8 +226,8 @@ m_compoundClosed(false), m_bitmap(), m_binaryData(), - m_vFlipped(false), - m_hFlipped(false) + m_hFlipped(false), + m_vFlipped(false) { } |
From: Fridrich S. <str...@us...> - 2007-12-11 14:49:24
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27566/src/lib Modified Files: WPG2Parser.cpp Log Message: fix a little warning Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- WPG2Parser.cpp 11 Dec 2007 14:46:49 -0000 1.63 +++ WPG2Parser.cpp 11 Dec 2007 14:49:21 -0000 1.64 @@ -226,8 +226,8 @@ m_compoundClosed(false), m_bitmap(), m_binaryData(), - m_vFlipped(false), - m_hFlipped(false) + m_hFlipped(false), + m_vFlipped(false) { } |
From: Fridrich S. <str...@us...> - 2007-12-11 14:46:56
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26412/src/lib Modified Files: WPG2Parser.cpp WPG2Parser.h WPGBitmap.cpp WPGBitmap.h Log Message: Flip native bitmaps if the corresponding scale parameter is negative Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- WPG2Parser.cpp 11 Dec 2007 12:45:12 -0000 1.62 +++ WPG2Parser.cpp 11 Dec 2007 14:46:49 -0000 1.63 @@ -225,7 +225,9 @@ m_compoundFramed(false), m_compoundClosed(false), m_bitmap(), - m_binaryData() + m_binaryData(), + m_vFlipped(false), + m_hFlipped(false) { } @@ -1351,6 +1353,22 @@ return; ObjectCharacterization objCh; parseCharacterization(&objCh); + + if (objCh.scale) + { + if (objCh.sxcos < 0) + { + m_hFlipped = true; + objCh.sxcos = -objCh.sxcos; + objCh.matrix.element[0][0] = -objCh.matrix.element[0][0]; + } + if (objCh.sycos < 0) + { + m_vFlipped = true; + objCh.sycos = -objCh.sycos; + objCh.matrix.element[1][1] = -objCh.matrix.element[1][1]; + } + } m_matrix = objCh.matrix; long x1 = (m_doublePrecision) ? readS32() : readS16(); @@ -1580,7 +1598,7 @@ if(!buffer) return; // prepare the bitmap structure for the listener - libwpg::WPGBitmap bitmap(width, height); + libwpg::WPGBitmap bitmap(width, height, m_vFlipped, m_hFlipped); bitmap.rect.x1 = m_bitmap.x1; bitmap.rect.y1 = m_bitmap.y1; bitmap.rect.x2 = m_bitmap.x2; Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- WPGBitmap.cpp 10 Dec 2007 09:58:11 -0000 1.13 +++ WPGBitmap.cpp 11 Dec 2007 14:46:49 -0000 1.14 @@ -32,9 +32,11 @@ public: int width; int height; + bool vFlip; + bool hFlip; WPGColor* pixels; - Private(int w, int h): width(w), height(h), pixels(0) {} + Private(int w, int h): width(w), height(h), vFlip(false), hFlip(false), pixels(0) {} }; libwpg::WPGBitmap::WPGBitmap(int width, int height): rect(), d(new Private(width, height)) @@ -42,6 +44,15 @@ d->pixels = new WPGColor[width*height]; } +libwpg::WPGBitmap::WPGBitmap(int width, int height, bool verticalFlip, bool horizontalFlip) : + rect(), + d(new Private(width, height)) +{ + d->vFlip = verticalFlip; + d->hFlip = horizontalFlip; + d->pixels = new WPGColor[width*height]; +} + libwpg::WPGBitmap::~WPGBitmap() { delete [] d->pixels; @@ -142,16 +153,48 @@ WPG_DEBUG_MSG(("WPGBitmap: DIB info header end = %i\n", tmpBufferPosition - 1)); // Write DIB Image data - for (int i = d->height - 1; i >= 0 && tmpBufferPosition < tmpDIBFileSize; i--) - { - for (int j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++) + + int i = 0; int j = 0; + if (d->vFlip) + for (i = 0; i < d->height && tmpBufferPosition < tmpDIBFileSize; i++) { - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + if (d->hFlip) + for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } + else + for (int j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } + } + else + for (int i = d->height - 1; i >= 0 && tmpBufferPosition < tmpDIBFileSize; i--) + { + if (d->hFlip) + for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } + else + for (int j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } } - } WPG_DEBUG_MSG(("WPGBitmap: DIB file size = %i\n", tmpBufferPosition - 1)); Index: WPGBitmap.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- WPGBitmap.h 16 Nov 2007 20:19:26 -0000 1.7 +++ WPGBitmap.h 11 Dec 2007 14:46:49 -0000 1.8 @@ -40,6 +40,8 @@ WPGRect rect; WPGBitmap(int width, int height); + + WPGBitmap(int width, int height, bool verticalFlip, bool horizontalFlip); WPGBitmap(const WPGBitmap&); Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- WPG2Parser.h 16 Jul 2007 12:03:33 -0000 1.21 +++ WPG2Parser.h 11 Dec 2007 14:46:49 -0000 1.22 @@ -217,6 +217,7 @@ bool m_compoundClosed; WPGBitmapContext m_bitmap; WPGBinaryDataContext m_binaryData; + bool m_hFlipped, m_vFlipped; class ObjectCharacterization; void parseCharacterization(ObjectCharacterization*); |
From: Fridrich S. <str...@us...> - 2007-12-11 14:46:39
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26390/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp WPG2Parser.h WPGBitmap.cpp WPGBitmap.h Log Message: Flip native bitmaps if the corresponding scale parameter is negative Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.4 retrieving revision 1.58.2.5 diff -u -d -r1.58.2.4 -r1.58.2.5 --- WPG2Parser.cpp 11 Dec 2007 12:57:06 -0000 1.58.2.4 +++ WPG2Parser.cpp 11 Dec 2007 14:46:31 -0000 1.58.2.5 @@ -225,7 +225,9 @@ m_compoundFramed(false), m_compoundClosed(false), m_bitmap(), - m_binaryData() + m_binaryData(), + m_vFlipped(false), + m_hFlipped(false) { } @@ -1351,6 +1353,22 @@ return; ObjectCharacterization objCh; parseCharacterization(&objCh); + + if (objCh.scale) + { + if (objCh.sxcos < 0) + { + m_hFlipped = true; + objCh.sxcos = -objCh.sxcos; + objCh.matrix.element[0][0] = -objCh.matrix.element[0][0]; + } + if (objCh.sycos < 0) + { + m_vFlipped = true; + objCh.sycos = -objCh.sycos; + objCh.matrix.element[1][1] = -objCh.matrix.element[1][1]; + } + } m_matrix = objCh.matrix; long x1 = (m_doublePrecision) ? readS32() : readS16(); @@ -1580,7 +1598,7 @@ if(!buffer) return; // prepare the bitmap structure for the listener - libwpg::WPGBitmap bitmap(width, height); + libwpg::WPGBitmap bitmap(width, height, m_vFlipped, m_hFlipped); bitmap.rect.x1 = m_bitmap.x1; bitmap.rect.y1 = m_bitmap.y1; bitmap.rect.x2 = m_bitmap.x2; Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.11.2.2 retrieving revision 1.11.2.3 diff -u -d -r1.11.2.2 -r1.11.2.3 --- WPGBitmap.cpp 10 Dec 2007 09:57:53 -0000 1.11.2.2 +++ WPGBitmap.cpp 11 Dec 2007 14:46:31 -0000 1.11.2.3 @@ -32,9 +32,11 @@ public: int width; int height; + bool vFlip; + bool hFlip; WPGColor* pixels; - Private(int w, int h): width(w), height(h), pixels(0) {} + Private(int w, int h): width(w), height(h), vFlip(false), hFlip(false), pixels(0) {} }; libwpg::WPGBitmap::WPGBitmap(int width, int height): rect(), d(new Private(width, height)) @@ -42,6 +44,15 @@ d->pixels = new WPGColor[width*height]; } +libwpg::WPGBitmap::WPGBitmap(int width, int height, bool verticalFlip, bool horizontalFlip) : + rect(), + d(new Private(width, height)) +{ + d->vFlip = verticalFlip; + d->hFlip = horizontalFlip; + d->pixels = new WPGColor[width*height]; +} + libwpg::WPGBitmap::~WPGBitmap() { delete [] d->pixels; @@ -142,16 +153,48 @@ WPG_DEBUG_MSG(("WPGBitmap: DIB info header end = %i\n", tmpBufferPosition - 1)); // Write DIB Image data - for (int i = d->height - 1; i >= 0 && tmpBufferPosition < tmpDIBFileSize; i--) - { - for (int j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++) + + int i = 0; int j = 0; + if (d->vFlip) + for (i = 0; i < d->height && tmpBufferPosition < tmpDIBFileSize; i++) { - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); - writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + if (d->hFlip) + for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } + else + for (int j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } + } + else + for (int i = d->height - 1; i >= 0 && tmpBufferPosition < tmpDIBFileSize; i--) + { + if (d->hFlip) + for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } + else + for (int j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++) + { + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red); + writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha); + } } - } WPG_DEBUG_MSG(("WPGBitmap: DIB file size = %i\n", tmpBufferPosition - 1)); Index: WPGBitmap.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.h,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -d -r1.6.2.1 -r1.6.2.2 --- WPGBitmap.h 16 Nov 2007 20:20:05 -0000 1.6.2.1 +++ WPGBitmap.h 11 Dec 2007 14:46:31 -0000 1.6.2.2 @@ -40,6 +40,8 @@ WPGRect rect; WPGBitmap(int width, int height); + + WPGBitmap(int width, int height, bool verticalFlip, bool horizontalFlip); WPGBitmap(const WPGBitmap&); Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -d -r1.21 -r1.21.2.1 --- WPG2Parser.h 16 Jul 2007 12:03:33 -0000 1.21 +++ WPG2Parser.h 11 Dec 2007 14:46:31 -0000 1.21.2.1 @@ -217,6 +217,7 @@ bool m_compoundClosed; WPGBitmapContext m_bitmap; WPGBinaryDataContext m_binaryData; + bool m_hFlipped, m_vFlipped; class ObjectCharacterization; void parseCharacterization(ObjectCharacterization*); |
From: Fridrich S. <str...@us...> - 2007-12-11 14:44:58
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25613/src/lib Modified Files: Tag: STABLE-0-1-0 WPGXParser.cpp WPGXParser.h Log Message: int is 32 bits on both x86 and x86_64 Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.13.4.2 retrieving revision 1.13.4.3 diff -u -d -r1.13.4.2 -r1.13.4.3 --- WPGXParser.cpp 10 Dec 2007 09:57:53 -0000 1.13.4.2 +++ WPGXParser.cpp 11 Dec 2007 14:44:53 -0000 1.13.4.3 @@ -57,12 +57,12 @@ return (unsigned short)(p0|(p1<<8)); } -unsigned long WPGXParser::readU32() +unsigned int WPGXParser::readU32() { - unsigned long p0 = (unsigned short)readU8(); - unsigned long p1 = (unsigned short)readU8(); - unsigned long p2 = (unsigned short)readU8(); - unsigned long p3 = (unsigned short)readU8(); + unsigned int p0 = (unsigned int)readU8(); + unsigned int p1 = (unsigned int)readU8(); + unsigned int p2 = (unsigned int)readU8(); + unsigned int p3 = (unsigned int)readU8(); return (unsigned long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } @@ -76,9 +76,9 @@ return (short)readU16(); } -long WPGXParser::readS32() +int WPGXParser::readS32() { - return (long)readU32(); + return (int)readU32(); } unsigned int WPGXParser::readVariableLengthInteger() Index: WPGXParser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.h,v retrieving revision 1.12.4.1 retrieving revision 1.12.4.2 diff -u -d -r1.12.4.1 -r1.12.4.2 --- WPGXParser.h 10 Dec 2007 09:57:53 -0000 1.12.4.1 +++ WPGXParser.h 11 Dec 2007 14:44:53 -0000 1.12.4.2 @@ -44,10 +44,10 @@ unsigned char readU8(); unsigned short readU16(); - unsigned long readU32(); + unsigned int readU32(); signed char readS8(); short readS16(); - long readS32(); + int readS32(); unsigned int readVariableLengthInteger(); WPGXParser& operator=(const WPGXParser& parser); |
From: Fridrich S. <str...@us...> - 2007-12-11 14:44:38
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25581/src/lib Modified Files: WPGXParser.cpp WPGXParser.h Log Message: int is 32 bits on both x86 and x86_64 Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- WPGXParser.cpp 10 Dec 2007 09:58:11 -0000 1.15 +++ WPGXParser.cpp 11 Dec 2007 14:44:32 -0000 1.16 @@ -57,12 +57,12 @@ return (unsigned short)(p0|(p1<<8)); } -unsigned long WPGXParser::readU32() +unsigned int WPGXParser::readU32() { - unsigned long p0 = (unsigned short)readU8(); - unsigned long p1 = (unsigned short)readU8(); - unsigned long p2 = (unsigned short)readU8(); - unsigned long p3 = (unsigned short)readU8(); + unsigned int p0 = (unsigned int)readU8(); + unsigned int p1 = (unsigned int)readU8(); + unsigned int p2 = (unsigned int)readU8(); + unsigned int p3 = (unsigned int)readU8(); return (unsigned long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } @@ -76,9 +76,9 @@ return (short)readU16(); } -long WPGXParser::readS32() +int WPGXParser::readS32() { - return (long)readU32(); + return (int)readU32(); } unsigned int WPGXParser::readVariableLengthInteger() Index: WPGXParser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- WPGXParser.h 10 Dec 2007 09:58:11 -0000 1.14 +++ WPGXParser.h 11 Dec 2007 14:44:32 -0000 1.15 @@ -44,10 +44,10 @@ unsigned char readU8(); unsigned short readU16(); - unsigned long readU32(); + unsigned int readU32(); signed char readS8(); short readS16(); - long readS32(); + int readS32(); unsigned int readVariableLengthInteger(); WPGXParser& operator=(const WPGXParser& parser); |
From: Fridrich S. <str...@us...> - 2007-12-11 12:57:10
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15115/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp Log Message: trailing <cr> gone Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.3 retrieving revision 1.58.2.4 diff -u -d -r1.58.2.3 -r1.58.2.4 --- WPG2Parser.cpp 10 Dec 2007 19:24:34 -0000 1.58.2.3 +++ WPG2Parser.cpp 11 Dec 2007 12:57:06 -0000 1.58.2.4 @@ -1126,7 +1126,7 @@ if(ch->editLock) WPG_DEBUG_MSG((" lock flags : 0x%x\n", (unsigned)ch->lockFlags)); if(ch->hasObjectId) WPG_DEBUG_MSG((" object ID : 0x%x\n", (unsigned)ch->objectId)); if(ch->translate) WPG_DEBUG_MSG((" tx : %li %d\n", ch->txinteger, ch->txfraction)); - if(ch->translate) WPG_DEBUG_MSG((" ty : %li %d\n", ch->tyinteger, ch->tyfraction)); + if(ch->translate) WPG_DEBUG_MSG((" ty : %li %d\n", ch->tyinteger, ch->tyfraction)); #endif WPG_DEBUG_MSG(("transform matrix:\n")); WPG_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[0][0], ch->matrix.element[0][1],ch->matrix.element[0][2])); |
From: Fridrich S. <str...@us...> - 2007-12-11 12:45:27
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10514/src/lib Modified Files: WPG2Parser.cpp Log Message: a trailing <cr> Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- WPG2Parser.cpp 10 Dec 2007 20:19:00 -0000 1.61 +++ WPG2Parser.cpp 11 Dec 2007 12:45:12 -0000 1.62 @@ -1126,7 +1126,7 @@ if(ch->editLock) WPG_DEBUG_MSG((" lock flags : 0x%x\n", (unsigned)ch->lockFlags)); if(ch->hasObjectId) WPG_DEBUG_MSG((" object ID : 0x%x\n", (unsigned)ch->objectId)); if(ch->translate) WPG_DEBUG_MSG((" tx : %li %d\n", ch->txinteger, ch->txfraction)); - if(ch->translate) WPG_DEBUG_MSG((" ty : %li %d\n", ch->tyinteger, ch->tyfraction)); + if(ch->translate) WPG_DEBUG_MSG((" ty : %li %d\n", ch->tyinteger, ch->tyfraction)); #endif WPG_DEBUG_MSG(("transform matrix:\n")); WPG_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[0][0], ch->matrix.element[0][1],ch->matrix.element[0][2])); |
From: Fridrich S. <str...@us...> - 2007-12-10 20:19:20
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24122/src/lib Modified Files: WPG2Parser.cpp Log Message: fixing some issues (forward-port from STABLE-0-1-0) Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- WPG2Parser.cpp 7 Dec 2007 16:10:18 -0000 1.60 +++ WPG2Parser.cpp 10 Dec 2007 20:19:00 -0000 1.61 @@ -1387,9 +1387,9 @@ { if (!m_graphicsStarted) return; - unsigned long width = (m_doublePrecision) ? readU32() : readU16(); - unsigned long height = (m_doublePrecision) ? readU32() : readU16(); - unsigned color_format = (readU8()); + unsigned long width = readU16(); + unsigned long height = readU16(); + unsigned color_format = readU8(); unsigned compression_format = readU8(); WPG_DEBUG_MSG((" dimension : %g, %g %g, %g\n", m_bitmap.x1, m_bitmap.y1, m_bitmap.x2, m_bitmap.y2)); |
From: Fridrich S. <str...@us...> - 2007-12-10 19:25:37
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2326/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp Log Message: fixing bitmap dimension reading and thus std::bad_alloc exceptions with some documents Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.2 retrieving revision 1.58.2.3 diff -u -d -r1.58.2.2 -r1.58.2.3 --- WPG2Parser.cpp 7 Dec 2007 16:22:07 -0000 1.58.2.2 +++ WPG2Parser.cpp 10 Dec 2007 19:24:34 -0000 1.58.2.3 @@ -1387,9 +1387,9 @@ { if (!m_graphicsStarted) return; - unsigned long width = (m_doublePrecision) ? readU32() : readU16(); - unsigned long height = (m_doublePrecision) ? readU32() : readU16(); - unsigned color_format = (readU8()); + unsigned long width = readU16(); + unsigned long height = readU16(); + unsigned color_format = readU8(); unsigned compression_format = readU8(); WPG_DEBUG_MSG((" dimension : %g, %g %g, %g\n", m_bitmap.x1, m_bitmap.y1, m_bitmap.x2, m_bitmap.y2)); |
From: Fridrich S. <str...@us...> - 2007-12-10 09:58:16
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6891/src/lib Modified Files: WPG1Parser.cpp WPGBitmap.cpp WPGXParser.cpp WPGXParser.h Log Message: trying to be a little bit more defensive in the code. To be really rock solid, this needs a lot a lot of refactoring Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- WPGBitmap.cpp 16 Nov 2007 20:19:26 -0000 1.12 +++ WPGBitmap.cpp 10 Dec 2007 09:58:11 -0000 1.13 @@ -98,7 +98,7 @@ void libwpg::WPGBitmap::generateBase64DIB(libwpg::WPGString& bmp) const { - if (d->height < 0 || d->width < 0) + if (d->height <= 0 || d->width <= 0) return; unsigned tmpPixelSize = (unsigned)(d->height * d->width); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- WPG1Parser.cpp 8 Oct 2007 20:47:26 -0000 1.34 +++ WPG1Parser.cpp 10 Dec 2007 09:58:11 -0000 1.35 @@ -453,20 +453,24 @@ // NOTE: delete the buffer by yourself! unsigned char* WPG1Parser::decodeRLE(int width, int height, int depth) { + if (depth <= 0 || width <= 0 || height <= 0) + return 0; + // round to the next byte - int scanline_width = (width * depth + 7)/8; - int buffer_size = scanline_width * height; + unsigned scanline_width = (width * depth + 7)/8; + unsigned buffer_size = scanline_width * height; WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); WPG_DEBUG_MSG(("Output size: %d\n", buffer_size)); // buffer for the result unsigned char* buffer = new unsigned char[buffer_size]; + + if (!buffer) + return 0; // pointer to write decoded data unsigned char* ptr = buffer; - // Decode the RLE bitmap buffer - // FIXME check for ptr, it should not go out of bound!! WPG_DEBUG_MSG(("Decoding RLE data\n")); for(; m_input->tell() < m_recordEnd; ) { @@ -479,7 +483,7 @@ unsigned char pixel = (count > 0) ? readU8() : 0xff; if(count == 0) count = (int)readU8(); - for( ; count; --count) + for( ; count && ptr < buffer + buffer_size; --count) *ptr++ = pixel; } else @@ -488,7 +492,7 @@ if(count > 0) { // literal byte copy - for( ; count; --count) + for( ; count && ptr < buffer + buffer_size; --count) *ptr++ = readU8(); } else @@ -496,8 +500,10 @@ // copy entire scan line count = (int)readU8(); unsigned char* raster_source = ptr - scanline_width; + if (!raster_source || raster_source < buffer) + return 0; for( ; count; --count) - for(int r = 0; r < scanline_width; r++) + for(unsigned r = 0; r < scanline_width && ptr < buffer + buffer_size; r++) *ptr++ = raster_source[r]; } } @@ -515,7 +521,7 @@ return; // round to the next byte - int scanline_width = (width * depth + 7)/8; + unsigned scanline_width = (width * depth + 7)/8; // 1-bit image: black and white if(depth == 1) @@ -582,6 +588,12 @@ hres = 1200; if(vres <= 0) vres = 1200; + if (width < 0) + width = 0; + if (height < 0) + height = 0; + if (depth < 0) + depth = 0; // Bitmap Type 1 does not specify position // Assume on the corner (0,0) @@ -592,10 +604,13 @@ bitmap.rect.y2 = (double)height/(double)vres; unsigned char* buffer = decodeRLE(width, height, depth); - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; + if (buffer) + { + fillPixels(bitmap, buffer, width, height, depth); + delete [] buffer; - m_painter->drawBitmap(bitmap); + m_painter->drawBitmap(bitmap); + } } void WPG1Parser::handleBitmapTypeTwo() @@ -632,6 +647,12 @@ hres = 1200; if(vres <= 0) vres = 1200; + if (width < 0) + width = 0; + if (height < 0) + height = 0; + if (depth < 0) + depth = 0; y1 = m_height - y1; y2 = m_height - y2; @@ -649,10 +670,13 @@ bitmap.rect.y2 = (double)(ys2)/1200.0; unsigned char* buffer = decodeRLE(width, height, depth); - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; + if (buffer) + { + fillPixels(bitmap, buffer, width, height, depth); + delete [] buffer; - m_painter->drawBitmap(bitmap); + m_painter->drawBitmap(bitmap); + } } void WPG1Parser::resetPalette() Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- WPGXParser.cpp 16 Nov 2007 20:19:27 -0000 1.14 +++ WPGXParser.cpp 10 Dec 2007 09:58:11 -0000 1.15 @@ -40,10 +40,14 @@ unsigned char WPGXParser::readU8() { + if (!m_input || m_input->atEOS()) + return (unsigned char)0; size_t numBytesRead; unsigned char const * p = m_input->read(sizeof(unsigned char), numBytesRead); - return *(unsigned char const *)(p); + if (p && numBytesRead == 1) + return *(unsigned char const *)(p); + return (unsigned char)0; } unsigned short WPGXParser::readU16() @@ -62,28 +66,19 @@ return (unsigned long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } -char WPGXParser::readS8() +signed char WPGXParser::readS8() { - size_t numBytesRead; - unsigned char const * p = m_input->read(sizeof(unsigned char), numBytesRead); - - return *(signed char const *)(p); + return (signed char)readU8(); } short WPGXParser::readS16() { - short p0 = readU8(); - short p1 = readS8(); - return (short)(p0|(p1<<8)); + return (short)readU16(); } long WPGXParser::readS32() { - long p0 = readU8(); - long p1 = readU8(); - long p2 = readU8(); - long p3 = readS8(); - return (long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); + return (long)readU32(); } unsigned int WPGXParser::readVariableLengthInteger() Index: WPGXParser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- WPGXParser.h 19 Oct 2007 19:09:09 -0000 1.13 +++ WPGXParser.h 10 Dec 2007 09:58:11 -0000 1.14 @@ -45,7 +45,7 @@ unsigned char readU8(); unsigned short readU16(); unsigned long readU32(); - char readS8(); + signed char readS8(); short readS16(); long readS32(); unsigned int readVariableLengthInteger(); |
From: Fridrich S. <str...@us...> - 2007-12-10 09:57:59
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6512/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp WPGBitmap.cpp WPGXParser.cpp WPGXParser.h Log Message: trying to be a little bit more defensive in the code. To be really rock solid, this needs a lot a lot of refactoring Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.11.2.1 retrieving revision 1.11.2.2 diff -u -d -r1.11.2.1 -r1.11.2.2 --- WPGBitmap.cpp 16 Nov 2007 20:20:04 -0000 1.11.2.1 +++ WPGBitmap.cpp 10 Dec 2007 09:57:53 -0000 1.11.2.2 @@ -98,7 +98,7 @@ void libwpg::WPGBitmap::generateBase64DIB(libwpg::WPGString& bmp) const { - if (d->height < 0 || d->width < 0) + if (d->height <= 0 || d->width <= 0) return; unsigned tmpPixelSize = (unsigned)(d->height * d->width); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.33.2.1 retrieving revision 1.33.2.2 diff -u -d -r1.33.2.1 -r1.33.2.2 --- WPG1Parser.cpp 7 Dec 2007 16:22:07 -0000 1.33.2.1 +++ WPG1Parser.cpp 10 Dec 2007 09:57:53 -0000 1.33.2.2 @@ -453,20 +453,24 @@ // NOTE: delete the buffer by yourself! unsigned char* WPG1Parser::decodeRLE(int width, int height, int depth) { + if (depth <= 0 || width <= 0 || height <= 0) + return 0; + // round to the next byte - int scanline_width = (width * depth + 7)/8; - int buffer_size = scanline_width * height; + unsigned scanline_width = (width * depth + 7)/8; + unsigned buffer_size = scanline_width * height; WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); WPG_DEBUG_MSG(("Output size: %d\n", buffer_size)); // buffer for the result unsigned char* buffer = new unsigned char[buffer_size]; + + if (!buffer) + return 0; // pointer to write decoded data unsigned char* ptr = buffer; - // Decode the RLE bitmap buffer - // FIXME check for ptr, it should not go out of bound!! WPG_DEBUG_MSG(("Decoding RLE data\n")); for(; m_input->tell() < m_recordEnd; ) { @@ -479,7 +483,7 @@ unsigned char pixel = (count > 0) ? readU8() : 0xff; if(count == 0) count = (int)readU8(); - for( ; count; --count) + for( ; count && ptr < buffer + buffer_size; --count) *ptr++ = pixel; } else @@ -488,7 +492,7 @@ if(count > 0) { // literal byte copy - for( ; count; --count) + for( ; count && ptr < buffer + buffer_size; --count) *ptr++ = readU8(); } else @@ -496,8 +500,10 @@ // copy entire scan line count = (int)readU8(); unsigned char* raster_source = ptr - scanline_width; + if (!raster_source || raster_source < buffer) + return 0; for( ; count; --count) - for(int r = 0; r < scanline_width; r++) + for(unsigned r = 0; r < scanline_width && ptr < buffer + buffer_size; r++) *ptr++ = raster_source[r]; } } @@ -515,7 +521,7 @@ return; // round to the next byte - int scanline_width = (width * depth + 7)/8; + unsigned scanline_width = (width * depth + 7)/8; // 1-bit image: black and white if(depth == 1) @@ -582,6 +588,12 @@ hres = 1200; if(vres <= 0) vres = 1200; + if (width < 0) + width = 0; + if (height < 0) + height = 0; + if (depth < 0) + depth = 0; // Bitmap Type 1 does not specify position // Assume on the corner (0,0) @@ -592,10 +604,13 @@ bitmap.rect.y2 = (double)height/(double)vres; unsigned char* buffer = decodeRLE(width, height, depth); - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; + if (buffer) + { + fillPixels(bitmap, buffer, width, height, depth); + delete [] buffer; - m_painter->drawBitmap(bitmap); + m_painter->drawBitmap(bitmap); + } } void WPG1Parser::handleBitmapTypeTwo() @@ -632,6 +647,12 @@ hres = 1200; if(vres <= 0) vres = 1200; + if (width < 0) + width = 0; + if (height < 0) + height = 0; + if (depth < 0) + depth = 0; y1 = m_height - y1; y2 = m_height - y2; @@ -649,10 +670,13 @@ bitmap.rect.y2 = (double)(ys2)/1200.0; unsigned char* buffer = decodeRLE(width, height, depth); - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; + if (buffer) + { + fillPixels(bitmap, buffer, width, height, depth); + delete [] buffer; - m_painter->drawBitmap(bitmap); + m_painter->drawBitmap(bitmap); + } } void WPG1Parser::resetPalette() Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.13.4.1 retrieving revision 1.13.4.2 diff -u -d -r1.13.4.1 -r1.13.4.2 --- WPGXParser.cpp 16 Nov 2007 20:20:05 -0000 1.13.4.1 +++ WPGXParser.cpp 10 Dec 2007 09:57:53 -0000 1.13.4.2 @@ -40,10 +40,14 @@ unsigned char WPGXParser::readU8() { + if (!m_input || m_input->atEOS()) + return (unsigned char)0; size_t numBytesRead; unsigned char const * p = m_input->read(sizeof(unsigned char), numBytesRead); - return *(unsigned char const *)(p); + if (p && numBytesRead == 1) + return *(unsigned char const *)(p); + return (unsigned char)0; } unsigned short WPGXParser::readU16() @@ -62,28 +66,19 @@ return (unsigned long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } -char WPGXParser::readS8() +signed char WPGXParser::readS8() { - size_t numBytesRead; - unsigned char const * p = m_input->read(sizeof(unsigned char), numBytesRead); - - return *(signed char const *)(p); + return (signed char)readU8(); } short WPGXParser::readS16() { - short p0 = readU8(); - short p1 = readS8(); - return (short)(p0|(p1<<8)); + return (short)readU16(); } long WPGXParser::readS32() { - long p0 = readU8(); - long p1 = readU8(); - long p2 = readU8(); - long p3 = readS8(); - return (long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); + return (long)readU32(); } unsigned int WPGXParser::readVariableLengthInteger() Index: WPGXParser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.h,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -u -d -r1.12 -r1.12.4.1 --- WPGXParser.h 9 May 2007 22:34:09 -0000 1.12 +++ WPGXParser.h 10 Dec 2007 09:57:53 -0000 1.12.4.1 @@ -45,7 +45,7 @@ unsigned char readU8(); unsigned short readU16(); unsigned long readU32(); - char readS8(); + signed char readS8(); short readS16(); long readS32(); unsigned int readVariableLengthInteger(); |
From: Fridrich S. <str...@us...> - 2007-12-07 16:22:13
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv7913/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp WPG2Parser.cpp Log Message: fix a crasher bug in run-length decoding + some integer signed/unsigned and width issues Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.1 retrieving revision 1.58.2.2 diff -u -d -r1.58.2.1 -r1.58.2.2 --- WPG2Parser.cpp 16 Nov 2007 20:20:04 -0000 1.58.2.1 +++ WPG2Parser.cpp 7 Dec 2007 16:22:07 -0000 1.58.2.2 @@ -1435,6 +1435,7 @@ // prepare the bitmap actual data unsigned char* buffer = 0; + unsigned char* ptr = 0; // plain data, uncompression if(compression_format==0) @@ -1446,12 +1447,12 @@ // run-length encoding else if(compression_format==1) { - unsigned char * ptr = buffer; unsigned char data[256]; bool xor_raster = false; unsigned char* next_scanline = buffer; - int data_size = 1; + unsigned data_size = 1; buffer = new unsigned char[tmpBufferSize]; + ptr = buffer; WPG_DEBUG_MSG(("Decoding RLE data\n")); @@ -1462,7 +1463,7 @@ // specify data size if(opcode == 0x7d) { - int new_data_size = (int)readU8(); + unsigned new_data_size = readU8(); if(new_data_size != data_size) { data_size = new_data_size; @@ -1482,9 +1483,9 @@ // a run of black (index #0) else if(opcode == 0x7f) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); for( ; count ; --count ) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = 0; } @@ -1492,26 +1493,26 @@ // a run of white (index #255) else if(opcode == 0xff) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); for( ; count ; --count ) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = 255; } // extend previous run else if(opcode == 0xfd) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); for( ; count; --count) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = data[j]; } // repeat raster else if(opcode == 0xfe) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); unsigned char* raster_source = ptr - raster_len; for( ; count; --count) for(unsigned long r = 0; r < raster_len; r++) @@ -1524,7 +1525,6 @@ // Xor-ing will happen when about to enter next raster // see after the last if down below xor_raster = true; - raster_len = data_size * width; next_scanline = ptr + raster_len; } @@ -1533,20 +1533,20 @@ // a run of data else if(opcode >= 0x80) { - int count = 1 + (opcode & 0x7f); - for(int i = 0; i < data_size; i++) + unsigned count = 1 + (opcode & 0x7f); + for(unsigned i = 0; i < data_size; i++) data[i] = readU8(); for( ; count; --count) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = data[j]; } // simple copy else if(opcode <= 0x7f) { - int count = opcode + 1; + unsigned count = opcode + 1; for( ; count; --count) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = readU8(); } @@ -1564,7 +1564,6 @@ xor_raster = false; // current raster must be XORed with previous raster - raster_len = data_size * width; unsigned char* current = next_scanline - raster_len; unsigned char* previous = current - raster_len; for( unsigned long r = 0; r < raster_len; r++) Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.33 retrieving revision 1.33.2.1 diff -u -d -r1.33 -r1.33.2.1 --- WPG1Parser.cpp 6 Aug 2007 20:58:08 -0000 1.33 +++ WPG1Parser.cpp 7 Dec 2007 16:22:07 -0000 1.33.2.1 @@ -211,17 +211,17 @@ WPG_DEBUG_MSG(("\n")); if(index < 0) - WPG_DEBUG_MSG(("Unknown record type 0x%02x at %d size %d\n", + WPG_DEBUG_MSG(("Unknown record type 0x%02x at %li size %d\n", recordType, recordPos, m_recordLength)); else { Method recordHandler = handlers[index].handler; if(!recordHandler) - WPG_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %d size %d\n", + WPG_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %li size %d\n", handlers[index].name, recordType, recordPos, m_recordLength)); else { - WPG_DEBUG_MSG(("Record '%s' type 0x%02x at %d size %d\n", + WPG_DEBUG_MSG(("Record '%s' type 0x%02x at %li size %d\n", handlers[index].name, recordType, recordPos, m_recordLength)); // invoke the handler for this record @@ -232,7 +232,7 @@ //if(m_input->tell() > m_recordEnd+1) { //WPG_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType)); - WPG_DEBUG_MSG(("Current stream position: %d\n", m_input->tell())); + WPG_DEBUG_MSG(("Current stream position: %li\n", m_input->tell())); } if(m_exit) break; @@ -640,7 +640,7 @@ long xs2 = (x1 <= x2) ? x2 : x1; long ys1 = (y1 <= y2) ? y1 : y2; long ys2 = (y1 <= y2) ? y2 : y1; - WPG_DEBUG_MSG(("%d %d %d %d\n", xs1, ys1, xs2, ys2)); + WPG_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2)); libwpg::WPGBitmap bitmap(width, height); bitmap.rect.x1 = (double)xs1/1200.0; |
From: Fridrich S. <str...@us...> - 2007-12-07 16:15:35
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4978/src/lib Modified Files: Tag: STABLE-0-1-0 WPGStreamImplementation.cpp Log Message: fix a bug in the bufferred stream due to a forgetful nature of human being Index: WPGStreamImplementation.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/Attic/WPGStreamImplementation.cpp,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -u -d -r1.12.2.2 -r1.12.2.3 --- WPGStreamImplementation.cpp 5 Dec 2007 22:32:14 -0000 1.12.2.2 +++ WPGStreamImplementation.cpp 7 Dec 2007 16:15:29 -0000 1.12.2.3 @@ -186,7 +186,7 @@ long WPGFileStream::tell() { - return d->file.good() ? (long)d->file.tellg() : -1L; + return d->file.good() ? (long)((long)d->file.tellg() - d->readBufferLength + d->readBufferPos) : -1L; } int WPGFileStream::seek(long offset, WPX_SEEK_TYPE seekType) @@ -224,7 +224,7 @@ bool WPGFileStream::atEOS() { - return (d->file.tellg() >= (long)d->streamSize); + return (tell() >= (long)d->streamSize); } bool WPGFileStream::isOLEStream() |
From: Fridrich S. <str...@us...> - 2007-12-07 16:14:15
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv4520/src/lib Modified Files: Tag: STABLE-0-1-0 WPGraphics.cpp Log Message: handle ole in the WPGraphics class Index: WPGraphics.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGraphics.cpp,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -d -r1.10 -r1.10.2.1 --- WPGraphics.cpp 3 Jul 2007 13:03:19 -0000 1.10 +++ WPGraphics.cpp 7 Dec 2007 16:14:10 -0000 1.10.2.1 @@ -1,5 +1,6 @@ /* libwpg * Copyright (C) 2006 Ariya Hidayat (ar...@kd...) + * Copyright (C) 2007 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -42,11 +43,34 @@ */ bool libwpg::WPGraphics::isSupported(WPXInputStream* input) { + input->seek(0, WPX_SEEK_SET); + WPXInputStream *graphics = 0; + bool isDocumentOLE = false; + + if (input->isOLEStream()) + { + graphics = input->getDocumentOLEStream(); + if (graphics) + isDocumentOLE = true; + else + return false; + } + else + graphics = input; + WPGHeader header; - if(!header.load(input)) + if(!header.load(graphics)) + { + if (graphics && isDocumentOLE) + delete graphics; return false; + } - return header.isSupported(); + bool retVal = header.isSupported(); + + if (graphics && isDocumentOLE) + delete graphics; + return retVal; } /** @@ -57,43 +81,67 @@ \param painter A WPGPainterInterface implementation \return A value that indicates whether the parsing was successful */ -bool libwpg::WPGraphics::parse(WPXInputStream* input, libwpg::WPGPaintInterface* painter) +bool libwpg::WPGraphics::parse(::WPXInputStream* input, libwpg::WPGPaintInterface* painter) { + input->seek(0, WPX_SEEK_CUR); WPGXParser *parser = 0; + WPXInputStream *graphics = 0; + bool isDocumentOLE = false; + + if (input->isOLEStream()) + { + graphics = input->getDocumentOLEStream(); + if (graphics) + isDocumentOLE = true; + else + return false; + } + else + graphics = input; + WPG_DEBUG_MSG(("Loading header...\n")); WPGHeader header; - if(!header.load(input)) + if(!header.load(graphics)) + { + if (graphics && isDocumentOLE) + delete graphics; return false; + } if(!header.isSupported()) { WPG_DEBUG_MSG(("Unsupported file format!\n")); + if (graphics && isDocumentOLE) + delete graphics; return false; } - - // seek to the start of document - input->seek(header.startOfDocument(), WPX_SEEK_SET); + + graphics->seek(header.startOfDocument(), WPX_SEEK_SET); bool retval; switch (header.majorVersion()) { case 0x01: // WPG1 WPG_DEBUG_MSG(("Parsing WPG1\n")); - parser = new WPG1Parser(input, painter); + parser = new WPG1Parser(graphics, painter); retval = parser->parse(); break; case 0x02: // WPG2 WPG_DEBUG_MSG(("Parsing WPG2\n")); - parser = new WPG2Parser(input, painter); + parser = new WPG2Parser(graphics, painter); retval = parser->parse(); break; default: // other :-) WPG_DEBUG_MSG(("Unknown format\n")); + if (graphics && isDocumentOLE) + delete graphics; return false; } if (parser) delete parser; + if (graphics && isDocumentOLE) + delete graphics; return retval; } |
From: Fridrich S. <str...@us...> - 2007-12-07 16:12:20
|
Update of /cvsroot/libwpg/libwpg/src/conv/svg In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3653/svg Modified Files: Tag: STABLE-0-1-0 wpg2svg.cpp Log Message: avoid allocating objects on the heap when not necessary Index: wpg2svg.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/svg/wpg2svg.cpp,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -u -d -r1.1 -r1.1.4.1 --- wpg2svg.cpp 24 May 2007 08:06:49 -0000 1.1 +++ wpg2svg.cpp 7 Dec 2007 16:12:16 -0000 1.1.4.1 @@ -38,25 +38,16 @@ } const char* filename = argv[1]; - WPXInputStream* input = new libwpg::WPGFileStream(filename); - if (input->isOLEStream()) - { - WPXInputStream* olestream = input->getDocumentOLEStream(); - if (olestream) - { - delete input; - input = olestream; - } - } + libwpg::WPGFileStream input(filename); - if (!libwpg::WPGraphics::isSupported(input)) + if (!libwpg::WPGraphics::isSupported(&input)) { std::cerr << "ERROR: Unsupported file format (unsupported version) or file is encrypted!" << std::endl; return 1; } libwpg::WPGString output; - if (!libwpg::WPGraphics::generateSVG(input, output)) + if (!libwpg::WPGraphics::generateSVG(&input, output)) { std::cerr << "ERROR: SVG Generation failed!" << std::endl; return 1; |
From: Fridrich S. <str...@us...> - 2007-12-07 16:12:20
|
Update of /cvsroot/libwpg/libwpg/src/conv/raw In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3653/raw Modified Files: Tag: STABLE-0-1-0 wpg2raw.cpp Log Message: avoid allocating objects on the heap when not necessary Index: wpg2raw.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/raw/wpg2raw.cpp,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -d -r1.3.2.1 -r1.3.2.2 --- wpg2raw.cpp 16 Nov 2007 20:20:03 -0000 1.3.2.1 +++ wpg2raw.cpp 7 Dec 2007 16:12:16 -0000 1.3.2.2 @@ -156,27 +156,17 @@ } const char* filename = argv[1]; - WPXInputStream* input = new libwpg::WPGFileStream(filename); - if (input->isOLEStream()) - { - WPXInputStream* olestream = input->getDocumentOLEStream(); - if (olestream) - { - delete input; - input = olestream; - } - } + libwpg::WPGFileStream input(filename); - if (!libwpg::WPGraphics::isSupported(input)) + if (!libwpg::WPGraphics::isSupported(&input)) { fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n"); return 1; } RawPainter painter; - libwpg::WPGraphics::parse(input, &painter); + libwpg::WPGraphics::parse(&input, &painter); - delete input; return 0; } |
From: Fridrich S. <str...@us...> - 2007-12-07 16:10:23
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2718/src/lib Modified Files: WPG2Parser.cpp Log Message: fix some crashes with bitmap run-length decoding Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- WPG2Parser.cpp 16 Nov 2007 20:19:26 -0000 1.59 +++ WPG2Parser.cpp 7 Dec 2007 16:10:18 -0000 1.60 @@ -1435,6 +1435,7 @@ // prepare the bitmap actual data unsigned char* buffer = 0; + unsigned char* ptr = 0; // plain data, uncompression if(compression_format==0) @@ -1446,12 +1447,12 @@ // run-length encoding else if(compression_format==1) { - unsigned char * ptr = buffer; unsigned char data[256]; bool xor_raster = false; unsigned char* next_scanline = buffer; - int data_size = 1; + unsigned data_size = 1; buffer = new unsigned char[tmpBufferSize]; + ptr = buffer; WPG_DEBUG_MSG(("Decoding RLE data\n")); @@ -1462,7 +1463,7 @@ // specify data size if(opcode == 0x7d) { - int new_data_size = (int)readU8(); + unsigned new_data_size = readU8(); if(new_data_size != data_size) { data_size = new_data_size; @@ -1482,9 +1483,9 @@ // a run of black (index #0) else if(opcode == 0x7f) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); for( ; count ; --count ) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = 0; } @@ -1492,26 +1493,26 @@ // a run of white (index #255) else if(opcode == 0xff) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); for( ; count ; --count ) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = 255; } // extend previous run else if(opcode == 0xfd) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); for( ; count; --count) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = data[j]; } // repeat raster else if(opcode == 0xfe) { - int count = 1 + (int)readU8(); + unsigned count = 1 + readU8(); unsigned char* raster_source = ptr - raster_len; for( ; count; --count) for(unsigned long r = 0; r < raster_len; r++) @@ -1524,7 +1525,6 @@ // Xor-ing will happen when about to enter next raster // see after the last if down below xor_raster = true; - raster_len = data_size * width; next_scanline = ptr + raster_len; } @@ -1533,20 +1533,20 @@ // a run of data else if(opcode >= 0x80) { - int count = 1 + (opcode & 0x7f); - for(int i = 0; i < data_size; i++) + unsigned count = 1 + (opcode & 0x7f); + for(unsigned i = 0; i < data_size; i++) data[i] = readU8(); for( ; count; --count) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = data[j]; } // simple copy else if(opcode <= 0x7f) { - int count = opcode + 1; + unsigned count = opcode + 1; for( ; count; --count) - for(int j = 0; j < data_size; j++) + for(unsigned j = 0; j < data_size; j++) *ptr++ = readU8(); } @@ -1564,7 +1564,6 @@ xor_raster = false; // current raster must be XORed with previous raster - raster_len = data_size * width; unsigned char* current = next_scanline - raster_len; unsigned char* previous = current - raster_len; for( unsigned long r = 0; r < raster_len; r++) |
From: Fridrich S. <str...@us...> - 2007-12-05 22:32:22
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8398/src/lib Modified Files: Tag: STABLE-0-1-0 WPGStreamImplementation.cpp Log Message: work around a problem with some libstdc++ implementations and bufferred stream implementation Index: WPGStreamImplementation.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/Attic/WPGStreamImplementation.cpp,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -u -d -r1.12.2.1 -r1.12.2.2 --- WPGStreamImplementation.cpp 3 Dec 2007 14:44:48 -0000 1.12.2.1 +++ WPGStreamImplementation.cpp 5 Dec 2007 22:32:14 -0000 1.12.2.2 @@ -140,7 +140,8 @@ // hmm, we cannot: go back by the bytes we read ahead && invalidate the buffer if (d->readBuffer) { - d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + d->file.seekg((unsigned long)d->file.tellg() - d->readBufferLength, std::ios::beg); + d->file.seekg(d->readBufferPos, std::ios::cur); delete [] d->readBuffer; d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; } @@ -206,7 +207,8 @@ if (d->readBuffer) // seeking outside of the buffer, so invalidate the buffer { - d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + d->file.seekg((unsigned long)d->file.tellg() - d->readBufferLength, std::ios::beg); + d->file.seekg(d->readBufferPos, std::ios::cur); delete [] d->readBuffer; d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; } @@ -232,7 +234,8 @@ if (d->readBuffer) { - d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + d->file.seekg((unsigned long)d->file.tellg() - d->readBufferLength, std::ios::beg); + d->file.seekg(d->readBufferPos, std::ios::cur); delete [] d->readBuffer; d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; } @@ -240,12 +243,9 @@ if (d->buffer.str().empty()) d->buffer << d->file.rdbuf(); Storage tmpStorage( d->buffer ); + seek(0, WPX_SEEK_SET); if (tmpStorage.isOLEStream()) - { - seek(0, WPX_SEEK_SET); return true; - } - seek(0, WPX_SEEK_SET); return false; } @@ -256,7 +256,8 @@ if (d->readBuffer) { - d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + d->file.seekg((unsigned long)d->file.tellg() - d->readBufferLength, std::ios::beg); + d->file.seekg(d->readBufferPos, std::ios::cur); delete [] d->readBuffer; d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; } |
From: Fridrich S. <str...@us...> - 2007-12-03 14:44:53
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22769/src/lib Modified Files: Tag: STABLE-0-1-0 WPGSVGGenerator.cpp WPGStreamImplementation.cpp Log Message: some fixes and preparation for a bugfix release Index: WPGStreamImplementation.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/Attic/WPGStreamImplementation.cpp,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -d -r1.12 -r1.12.2.1 --- WPGStreamImplementation.cpp 3 Sep 2007 21:38:39 -0000 1.12 +++ WPGStreamImplementation.cpp 3 Dec 2007 14:44:48 -0000 1.12.2.1 @@ -40,6 +40,9 @@ std::stringstream buffer; unsigned long streamSize; uint8_t *buf; + uint8_t *readBuffer; + unsigned long readBufferLength; + unsigned long readBufferPos; private: WPGFileStreamPrivate(const WPGFileStreamPrivate&); WPGFileStreamPrivate& operator=(const WPGFileStreamPrivate&); @@ -66,7 +69,10 @@ file(), buffer(std::ios::binary | std::ios::in | std::ios::out), streamSize(0), - buf(0) + buf(0), + readBuffer(0), + readBufferLength(0), + readBufferPos(0) { } @@ -74,6 +80,8 @@ { if (buf) delete [] buf; + if (readBuffer) + delete [] readBuffer; } WPGMemoryStreamPrivate::WPGMemoryStreamPrivate(const std::string str) : @@ -109,37 +117,70 @@ delete d; } +#define BUFFER_MAX 65536 + const uint8_t *WPGFileStream::read(size_t numBytes, size_t &numBytesRead) { numBytesRead = 0; - if (0 == numBytes) - return 0; - - if (numBytes < 0 || atEOS() || numBytes > (std::numeric_limits<unsigned long>::max)()/2) + if (numBytes == 0 || /* atEOS() || */ numBytes > (std::numeric_limits<unsigned long>::max)()/2 + || !d->file.good()) return 0; - unsigned long curpos = d->file.tellg(); + // can we read from the buffer? + if (d->readBuffer && (d->readBufferPos + numBytes > d->readBufferPos) + && (d->readBufferPos + numBytes <= d->readBufferLength)) + { + const uint8_t *pTmp = d->readBuffer + d->readBufferPos; + d->readBufferPos += numBytes; + numBytesRead = numBytes; + return pTmp; + } + + // hmm, we cannot: go back by the bytes we read ahead && invalidate the buffer + if (d->readBuffer) + { + d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + delete [] d->readBuffer; + d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; + } + + unsigned long curpos = tell(); if (curpos == (unsigned long)-1) // tellg() returned ERROR return 0; if ( (curpos + numBytes < curpos) /*overflow*/ || - (curpos + numBytes > d->streamSize) ) /*reading more than available*/ + (curpos + numBytes >= d->streamSize) ) /*reading more than available*/ { numBytes = d->streamSize - curpos; } - if (d->buf) - delete [] d->buf; - d->buf = new uint8_t[numBytes]; - - if(d->file.good()) + if (numBytes < BUFFER_MAX) { - d->file.read((char *)(d->buf), numBytes); - numBytesRead = (long)d->file.tellg() - curpos; + if (BUFFER_MAX < d->streamSize - curpos) + d->readBufferLength = BUFFER_MAX; + else /* BUFFER_MAX >= d->streamSize - curpos */ + d->readBufferLength = d->streamSize - curpos; } + else + d->readBufferLength = numBytes; - return d->buf; + d->file.seekg(d->readBufferLength, std::ios::cur); + d->file.seekg(curpos, std::ios::beg); + + d->readBuffer = new uint8_t[d->readBufferLength]; + d->file.read((char *)(d->readBuffer), d->readBufferLength); + + if (!d->file.good()) + d->file.clear(); + d->readBufferPos = 0; + if (d->readBufferLength == 0) + return 0; + + numBytesRead = numBytes; + + d->readBufferPos += numBytesRead; + return const_cast<const uint8_t*>( d->readBuffer ); } long WPGFileStream::tell() @@ -149,26 +190,31 @@ int WPGFileStream::seek(long offset, WPX_SEEK_TYPE seekType) { - if (seekType == WPX_SEEK_SET) + if (seekType == WPX_SEEK_CUR) + offset += tell(); + + if (offset < 0) + offset = 0; + if (offset > (long)d->streamSize) + offset = (long)d->streamSize; + + if (d->file.good() && offset < d->file.tellg() && (unsigned long)offset >= (unsigned long)d->file.tellg() - d->readBufferLength) { - if (offset < 0) - offset = 0; - if (offset > (long)d->streamSize) - offset = (long)d->streamSize; + d->readBufferPos = offset + d->readBufferLength - d->file.tellg(); + return 0; } - - if (seekType == WPX_SEEK_CUR) + + if (d->readBuffer) // seeking outside of the buffer, so invalidate the buffer { - if (tell() + offset < 0) - offset = -tell(); - if (tell() + offset > (long)d->streamSize) - offset = d->streamSize - tell(); + d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + delete [] d->readBuffer; + d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; } - + if(d->file.good()) { - d->file.seekg(offset, ((seekType == WPX_SEEK_SET) ? std::ios::beg : std::ios::cur)); - return (int) ((long)d->file.tellg() == -1); + d->file.seekg(offset, std::ios::beg); + return (int) ((long)d->file.tellg() == -1) ; } else return -1; @@ -181,6 +227,16 @@ bool WPGFileStream::isOLEStream() { + if (!d->file.good()) + return false; + + if (d->readBuffer) + { + d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + delete [] d->readBuffer; + d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; + } + if (d->buffer.str().empty()) d->buffer << d->file.rdbuf(); Storage tmpStorage( d->buffer ); @@ -195,6 +251,16 @@ ::WPXInputStream* WPGFileStream::getDocumentOLEStream(const char * name) { + if (!d->file.good()) + return (WPXInputStream*)0; + + if (d->readBuffer) + { + d->file.seekg(d->readBufferPos - d->readBufferLength, std::ios::cur); + delete [] d->readBuffer; + d->readBuffer = 0; d->readBufferPos = 0; d->readBufferLength = 0; + } + if (d->buffer.str().empty()) d->buffer << d->file.rdbuf(); Storage *tmpStorage = new Storage( d->buffer ); @@ -203,12 +269,13 @@ { if (tmpStorage) delete tmpStorage; - return (::WPXInputStream*)0; + return (WPXInputStream*)0; } if (d->buf) delete [] d->buf; - d->buf = new uint8_t[tmpStream.size()]; + d->buf = new unsigned char[tmpStream.size()]; + unsigned long tmpLength; tmpLength = tmpStream.read((unsigned char *)(d->buf), tmpStream.size()); @@ -219,7 +286,7 @@ { if (tmpStorage) delete tmpStorage; - return (::WPXInputStream*)0; + return (WPXInputStream*)0; } delete tmpStorage; Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -d -r1.11 -r1.11.2.1 --- WPGSVGGenerator.cpp 7 Jul 2007 17:30:22 -0000 1.11 +++ WPGSVGGenerator.cpp 3 Dec 2007 14:44:48 -0000 1.11.2.1 @@ -31,22 +31,21 @@ static std::string doubleToString(const double value) { - std::ostringstream tempStream; - tempStream << value; - std::string decimalPoint(localeconv()->decimal_point); - if ((decimalPoint.size() == 0) || (decimalPoint == ".")) - return tempStream.str(); - std::string stringValue(tempStream.str()); - if (!stringValue.empty()) - { - std::string::size_type pos; - while ((pos = stringValue.find(decimalPoint)) != std::string::npos) - stringValue.replace(pos,decimalPoint.size(),"."); - } - return stringValue; + std::ostringstream tempStream; + tempStream << value; + std::string decimalPoint(localeconv()->decimal_point); + if ((decimalPoint.size() == 0) || (decimalPoint == ".")) + return tempStream.str(); + std::string stringValue(tempStream.str()); + if (!stringValue.empty()) + { + std::string::size_type pos; + while ((pos = stringValue.find(decimalPoint)) != std::string::npos) + stringValue.replace(pos,decimalPoint.size(),"."); + } + return stringValue; } - libwpg::WPGSVGGenerator::WPGSVGGenerator(std::ostream & output_sink): m_pen(libwpg::WPGPen()), m_brush(libwpg::WPGBrush()), m_fillRule(AlternatingFill), m_gradientIndex(1), m_outputSink(output_sink) { } |
From: Fridrich S. <str...@us...> - 2007-12-03 14:44:53
|
Update of /cvsroot/libwpg/libwpg In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22769 Modified Files: Tag: STABLE-0-1-0 ChangeLog autogen.sh configure.in Log Message: some fixes and preparation for a bugfix release Index: ChangeLog =================================================================== RCS file: /cvsroot/libwpg/libwpg/ChangeLog,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- ChangeLog 24 Aug 2007 11:11:45 -0000 1.2 +++ ChangeLog 3 Dec 2007 14:44:48 -0000 1.2.2.1 @@ -1,5 +1,11 @@ -0.1.0 - 0.1.0 +0.1.0 - 0.1.1 - Make win32 crosscompilation very smooth (Fridrich) +- Implement win32 binary packaging using Makefile +- Compile fixes for gcc 4.3 +- Fix a load of compiler warnings with Intel compiler, with Sun + Studio,... +- Backport the bufferred file stream implementation from libwpd. +- Make autogen.sh accept glibtoolize as a valid incarnation of libtoolize 0.1.0 --> initial release - proper recognition of WPG files from WPD files (headers are practically the same) Index: autogen.sh =================================================================== RCS file: /cvsroot/libwpg/libwpg/autogen.sh,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- autogen.sh 2 Oct 2007 08:58:26 -0000 1.4 +++ autogen.sh 3 Dec 2007 14:44:48 -0000 1.4.2.1 @@ -27,7 +27,7 @@ done if [ "$LIBTOOLIZEFOUND" = "0" ]; then - echo "$0: need libtoolize tool to build writerperfect" >&2 + echo "$0: need libtoolize tool to build libwpg" >&2 exit 1 fi Index: configure.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/configure.in,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -d -r1.15 -r1.15.2.1 --- configure.in 3 Sep 2007 21:38:39 -0000 1.15 +++ configure.in 3 Dec 2007 14:44:48 -0000 1.15.2.1 @@ -4,7 +4,7 @@ WPG_MAJOR_VERSION=0 WPG_MINOR_VERSION=1 -WPG_MICRO_VERSION=0 +WPG_MICRO_VERSION=1 WPG_VERSION="$WPG_MAJOR_VERSION.$WPG_MINOR_VERSION.$WPG_MICRO_VERSION" |
From: Fridrich S. <str...@us...> - 2007-11-23 21:32:42
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19526/src/lib Modified Files: WPGInternalStream.cpp Log Message: adapt to the new shape of the WPXInputStream interface Index: WPGInternalStream.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGInternalStream.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- WPGInternalStream.cpp 19 Oct 2007 13:12:49 -0000 1.5 +++ WPGInternalStream.cpp 23 Nov 2007 21:32:38 -0000 1.6 @@ -26,7 +26,7 @@ #include "WPGInternalStream.h" WPGInternalInputStream::WPGInternalInputStream(const unsigned char *data, const size_t size) : - WPXInputStream(false), + WPXInputStream(), m_offset(0), m_size(size), m_data(data), |
From: Fridrich S. <str...@us...> - 2007-11-16 20:20:13
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9049/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp WPGBinaryData.cpp WPGBinaryData.h WPGBitmap.cpp WPGBitmap.h WPGHeader.cpp WPGRect.cpp WPGRect.h WPGString.cpp WPGString.h WPGXParser.cpp Log Message: some warnings gone Index: WPGString.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGString.cpp,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -u -d -r1.4 -r1.4.4.1 --- WPGString.cpp 8 Jun 2007 11:57:41 -0000 1.4 +++ WPGString.cpp 16 Nov 2007 20:20:05 -0000 1.4.4.1 @@ -60,7 +60,7 @@ delete d; } -const bool libwpg::WPGString::empty() const +bool libwpg::WPGString::empty() const { return d->str.empty(); } @@ -70,7 +70,7 @@ return d->str.c_str(); } -const long libwpg::WPGString::length() const +long libwpg::WPGString::length() const { return d->str.length(); } Index: WPGBitmap.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.h,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- WPGBitmap.h 3 Jul 2007 13:03:19 -0000 1.6 +++ WPGBitmap.h 16 Nov 2007 20:20:05 -0000 1.6.2.1 @@ -50,10 +50,10 @@ ~WPGBitmap(); // return width in pixel - const int width() const; + int width() const; // return height in pixel - const int height() const; + int height() const; WPGColor pixel(int x, int y) const; Index: WPGXParser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGXParser.cpp,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -d -r1.13 -r1.13.4.1 --- WPGXParser.cpp 21 Jun 2007 10:31:03 -0000 1.13 +++ WPGXParser.cpp 16 Nov 2007 20:20:05 -0000 1.13.4.1 @@ -50,7 +50,7 @@ { unsigned short p0 = (unsigned short)readU8(); unsigned short p1 = (unsigned short)readU8(); - return p0|(p1<<8); + return (unsigned short)(p0|(p1<<8)); } unsigned long WPGXParser::readU32() @@ -59,7 +59,7 @@ unsigned long p1 = (unsigned short)readU8(); unsigned long p2 = (unsigned short)readU8(); unsigned long p3 = (unsigned short)readU8(); - return p0|(p1<<8)|(p2<<16)|(p3<<24); + return (unsigned long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } char WPGXParser::readS8() @@ -74,7 +74,7 @@ { short p0 = readU8(); short p1 = readS8(); - return p0|(p1<<8); + return (short)(p0|(p1<<8)); } long WPGXParser::readS32() @@ -83,7 +83,7 @@ long p1 = readU8(); long p2 = readU8(); long p3 = readS8(); - return p0|(p1<<8)|(p2<<16)|(p3<<24); + return (long)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } unsigned int WPGXParser::readVariableLengthInteger() Index: WPGHeader.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGHeader.cpp,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -u -d -r1.5 -r1.5.4.1 --- WPGHeader.cpp 9 May 2007 22:34:09 -0000 1.5 +++ WPGHeader.cpp 16 Nov 2007 20:20:05 -0000 1.5.4.1 @@ -32,7 +32,7 @@ static inline unsigned short readU16( const void* p ) { const unsigned char* ptr = (const unsigned char*) p; - return ptr[0]+(ptr[1]<<8); + return (unsigned short)(ptr[0]+(ptr[1]<<8)); } static inline unsigned long readU32( const void* p ) Index: WPGRect.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGRect.cpp,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -u -d -r1.1 -r1.1.4.1 --- WPGRect.cpp 14 Dec 2006 14:39:58 -0000 1.1 +++ WPGRect.cpp 16 Nov 2007 20:20:05 -0000 1.1.4.1 @@ -55,12 +55,12 @@ return *this; } -const double libwpg::WPGRect::width() const +double libwpg::WPGRect::width() const { return x2-x1; } -const double libwpg::WPGRect::height() const +double libwpg::WPGRect::height() const { return y2-y1; } Index: WPGRect.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGRect.h,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -d -r1.3 -r1.3.4.1 --- WPGRect.h 14 Dec 2006 14:39:58 -0000 1.3 +++ WPGRect.h 16 Nov 2007 20:20:05 -0000 1.3.4.1 @@ -47,8 +47,8 @@ WPGRect& operator=(const WPGRect& rect); - const double width() const; - const double height() const; + double width() const; + double height() const; }; } // namespace libwpg Index: WPGBinaryData.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBinaryData.cpp,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- WPGBinaryData.cpp 3 Jul 2007 13:03:19 -0000 1.2 +++ WPGBinaryData.cpp 16 Nov 2007 20:20:04 -0000 1.2.2.1 @@ -89,9 +89,9 @@ m_binaryDataImpl->m_buf.clear(); } -const size_t libwpg::WPGBinaryData::size() const +size_t libwpg::WPGBinaryData::size() const { - return (const size_t)m_binaryDataImpl->m_buf.size(); + return (size_t)m_binaryDataImpl->m_buf.size(); } libwpg::WPGBinaryData& libwpg::WPGBinaryData::operator=(const WPGBinaryData &dataBuf) Index: WPGBinaryData.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBinaryData.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- WPGBinaryData.h 3 Jul 2007 13:03:19 -0000 1.2 +++ WPGBinaryData.h 16 Nov 2007 20:20:04 -0000 1.2.2.1 @@ -49,7 +49,7 @@ void append(const char c); void clear(); - const size_t size() const; + size_t size() const; const char *getDataBuffer() const; const WPGString getBase64Data() const; Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -d -r1.11 -r1.11.2.1 --- WPGBitmap.cpp 3 Jul 2007 13:03:19 -0000 1.11 +++ WPGBitmap.cpp 16 Nov 2007 20:20:04 -0000 1.11.2.1 @@ -70,12 +70,12 @@ d->pixels[i] = bitmap.d->pixels[i]; } -const int libwpg::WPGBitmap::width() const +int libwpg::WPGBitmap::width() const { return d->width; } -const int libwpg::WPGBitmap::height() const +int libwpg::WPGBitmap::height() const { return d->height; } Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58 retrieving revision 1.58.2.1 diff -u -d -r1.58 -r1.58.2.1 --- WPG2Parser.cpp 17 Jul 2007 09:34:33 -0000 1.58 +++ WPG2Parser.cpp 16 Nov 2007 20:20:04 -0000 1.58.2.1 @@ -1514,7 +1514,7 @@ int count = 1 + (int)readU8(); unsigned char* raster_source = ptr - raster_len; for( ; count; --count) - for(unsigned r = 0; r < raster_len; r++) + for(unsigned long r = 0; r < raster_len; r++) *ptr++ = *raster_source++; } @@ -1524,7 +1524,7 @@ // Xor-ing will happen when about to enter next raster // see after the last if down below xor_raster = true; - int raster_len = data_size * width; + raster_len = data_size * width; next_scanline = ptr + raster_len; } @@ -1564,10 +1564,10 @@ xor_raster = false; // current raster must be XORed with previous raster - int raster_len = data_size * width; + raster_len = data_size * width; unsigned char* current = next_scanline - raster_len; unsigned char* previous = current - raster_len; - for( int r = 0; r < raster_len; r++) + for( unsigned long r = 0; r < raster_len; r++) current[r] ^= previous[r]; } @@ -1666,7 +1666,7 @@ for (unsigned long y = 0; y < height; y++) for (unsigned long x = 0; x < width; x++, i++) { - unsigned short tmpColor = buffer[2*i] | (buffer[2*i+1] << 8); + unsigned short tmpColor = (unsigned short)(buffer[2*i] | (buffer[2*i+1] << 8)); const libwpg::WPGColor color((tmpColor >> 10) & 0x1f, (tmpColor >> 5) & 0x1f, tmpColor & 0x1f); bitmap.setPixel(x, y, color); } @@ -1680,7 +1680,7 @@ for (unsigned long y = 0; y < height; y++) for (unsigned long x = 0; x < width; x++, i++) { - unsigned short tmpColor = buffer[2*i] | (buffer[2*i+1] << 8); + unsigned short tmpColor = (unsigned short)(buffer[2*i] | (buffer[2*i+1] << 8)); const libwpg::WPGColor color(tmpColor & 0x0f, (tmpColor >> 4) & 0x0f, (tmpColor >> 8) & 0x0f, (tmpColor >> 12) & 0x0f); bitmap.setPixel(x, y, color); } @@ -1726,7 +1726,7 @@ } - +#ifdef DEBUG // debugging only if(buffer && 0) { @@ -1737,6 +1737,7 @@ WPG_DEBUG_MSG((" pixel at %li, %li: %3d %3d %3d\n", x, y, color.red, color.green, color.blue)); } } +#endif // discard delete [] buffer; Index: WPGString.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGString.h,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -u -d -r1.4 -r1.4.4.1 --- WPGString.h 8 Jun 2007 11:57:41 -0000 1.4 +++ WPGString.h 16 Nov 2007 20:20:05 -0000 1.4.4.1 @@ -38,11 +38,11 @@ ~WPGString(); - const bool empty() const; + bool empty() const; const char * cstr() const; - const long length() const; + long length() const; void append(const char c); |
From: Fridrich S. <str...@us...> - 2007-11-16 20:20:12
|
Update of /cvsroot/libwpg/libwpg/src/conv/raw In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9049/src/conv/raw Modified Files: Tag: STABLE-0-1-0 wpg2raw.cpp Log Message: some warnings gone Index: wpg2raw.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/raw/wpg2raw.cpp,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- wpg2raw.cpp 3 Jul 2007 13:03:19 -0000 1.3 +++ wpg2raw.cpp 16 Nov 2007 20:20:03 -0000 1.3.2.1 @@ -75,7 +75,7 @@ printf("RawPainter::endLayer %d\n", id); } -void RawPainter::setPen(const libwpg::WPGPen& pen) +void RawPainter::setPen(const libwpg::WPGPen& /*pen*/) { printf("RawPainter::setPen\n"); } @@ -107,7 +107,7 @@ brush.gradient.stopColor(c).green, brush.gradient.stopColor(c).blue); } -void RawPainter::setFillRule(FillRule rule) +void RawPainter::setFillRule(FillRule /*rule*/) { printf("RawPainter::setFillRule\n"); } @@ -119,7 +119,7 @@ printf(" Roundndess: %g %g\n", rx, ry); } -void RawPainter::drawEllipse(const libwpg::WPGPoint& center, double rx, double ry) +void RawPainter::drawEllipse(const libwpg::WPGPoint& /*center*/s, double rx, double ry) { printf("RawPainter::drawEllipse "); printf(" Radius: %g %g\n", rx, ry); @@ -137,12 +137,12 @@ printf("RawPainter::drawPath %d elements\n", path.count()); } -void RawPainter::drawBitmap(const libwpg::WPGBitmap& bitmap) +void RawPainter::drawBitmap(const libwpg::WPGBitmap& /*bitmap*/) { printf("RawPainter::drawBitmap\n"); } -void RawPainter::drawImageObject(const libwpg::WPGBinaryData& binaryData) +void RawPainter::drawImageObject(const libwpg::WPGBinaryData& /*binaryData*/) { printf("RawPainter::drawBinaryData\n"); } |