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...> - 2008-11-24 10:16:27
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12228/src/lib Modified Files: Makefile.am WPG1Parser.cpp WPG2Parser.cpp WPG2Parser.h WPGBitmap.cpp WPGBitmap.h WPGPaintInterface.h WPGSVGGenerator.cpp WPGSVGGenerator.h WPGraphics.cpp WPGraphics.h libwpg.h.in makefile.mk Removed Files: WPGBinaryData.cpp WPGBinaryData.h WPGString.cpp WPGString.h Log Message: first step in the struggle to simplify libwpg api Index: makefile.mk =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/makefile.mk,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- makefile.mk 4 Jul 2007 09:07:18 -0000 1.8 +++ makefile.mk 24 Nov 2008 10:16:19 -0000 1.9 @@ -25,7 +25,6 @@ SLOFILES= \ $(SLO)$/WPG1Parser.obj \ $(SLO)$/WPG2Parser.obj \ - $(SLO)$/WPGBinaryData.obj \ $(SLO)$/WPGBitmap.obj \ $(SLO)$/WPGBrush.obj \ $(SLO)$/WPGColor.obj \ @@ -37,7 +36,6 @@ $(SLO)$/WPGPoint.obj \ $(SLO)$/WPGraphics.obj \ $(SLO)$/WPGRect.obj \ - $(SLO)$/WPGString.obj \ $(SLO)$/WPGSVGGenerator.obj \ $(SLO)$/WPGXParser.obj --- WPGString.cpp DELETED --- Index: WPGBitmap.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- WPGBitmap.h 11 Dec 2007 14:46:49 -0000 1.8 +++ WPGBitmap.h 24 Nov 2008 10:16:19 -0000 1.9 @@ -29,7 +29,7 @@ #include "WPGRect.h" #include "WPGColor.h" -#include "WPGString.h" +#include <libwpd/WPXString.h> namespace libwpg { @@ -61,9 +61,9 @@ void setPixel(int x, int y, const WPGColor& color); - void generateBase64DIB(WPGString& bmp) const; + void generateBase64DIB(::WPXString& bmp) const; - static void base64Encode(WPGString& base64, const char *data, const int len); + static void base64Encode(::WPXString& base64, const char *data, const int len); private: class Private; Index: WPGSVGGenerator.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- WPGSVGGenerator.h 16 Jul 2008 14:10:59 -0000 1.10 +++ WPGSVGGenerator.h 24 Nov 2008 10:16:19 -0000 1.11 @@ -29,6 +29,7 @@ #include <stdio.h> #include <iostream> +#include <libwpd/libwpd.h> #include "libwpg.h" namespace libwpg @@ -56,7 +57,7 @@ void drawPolygon(const libwpg::WPGPointArray& vertices); void drawPath(const libwpg::WPGPath& path); void drawBitmap(const libwpg::WPGBitmap& bitmap); - void drawImageObject(const libwpg::WPGBinaryData& binaryData); + void drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData); private: libwpg::WPGPen m_pen; Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- WPG2Parser.h 22 Jul 2008 06:39:27 -0000 1.25 +++ WPG2Parser.h 24 Nov 2008 10:16:19 -0000 1.26 @@ -134,13 +134,13 @@ WPGBitmapContext(): x1(0), y1(0), x2(0), y2(0), hres(100), vres(100) {} }; -class WPGBinaryDataContext +class WPXBinaryDataContext { public: double x1, y1, x2, y2; int numObjects, objectIndex; - std::vector<libwpg::WPGString> mimeTypes; - WPGBinaryDataContext(): x1(0), y1(0), x2(0), y2(0), numObjects(0), objectIndex(0), mimeTypes() {} + std::vector<WPXString> mimeTypes; + WPXBinaryDataContext(): x1(0), y1(0), x2(0), y2(0), numObjects(0), objectIndex(0), mimeTypes() {} }; class WPG2Parser : public WPGXParser @@ -217,7 +217,7 @@ bool m_compoundFramed; bool m_compoundClosed; WPGBitmapContext m_bitmap; - WPGBinaryDataContext m_binaryData; + WPXBinaryDataContext m_binaryData; bool m_hFlipped, m_vFlipped; class ObjectCharacterization; Index: WPGraphics.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGraphics.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- WPGraphics.h 8 Oct 2007 20:47:26 -0000 1.12 +++ WPGraphics.h 24 Nov 2008 10:16:19 -0000 1.13 @@ -26,7 +26,7 @@ #ifndef __WPGRAPHICS_H__ #define __WPGRAPHICS_H__ -#include "WPGString.h" +#include <libwpd/WPXString.h> #include <stdio.h> class WPXInputStream; @@ -46,8 +46,8 @@ static bool parse(WPXInputStream* input, WPGPaintInterface* painter, WPGFileFormat fileFormat = WPG_AUTODETECT); static bool parse(const unsigned char* data, const size_t size, WPGPaintInterface* painter, WPGFileFormat fileFormat = WPG_AUTODETECT); - static bool generateSVG(WPXInputStream* input, WPGString& output, WPGFileFormat fileFormat = WPG_AUTODETECT); - static bool generateSVG(const unsigned char* data, const size_t size, WPGString& output, WPGFileFormat fileFormat = WPG_AUTODETECT); + static bool generateSVG(WPXInputStream* input, WPXString& output, WPGFileFormat fileFormat = WPG_AUTODETECT); + static bool generateSVG(const unsigned char* data, const size_t size, WPXString& output, WPGFileFormat fileFormat = WPG_AUTODETECT); }; } // namespace libwpg Index: WPGraphics.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGraphics.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- WPGraphics.cpp 8 Apr 2008 12:12:43 -0000 1.14 +++ WPGraphics.cpp 24 Nov 2008 10:16:19 -0000 1.15 @@ -168,19 +168,19 @@ \param output The output string whose content is the resulting SVG \return A value that indicates whether the SVG generation was successful. */ -bool libwpg::WPGraphics::generateSVG(::WPXInputStream* input, libwpg::WPGString& output, libwpg::WPGFileFormat fileFormat) +bool libwpg::WPGraphics::generateSVG(::WPXInputStream* input, WPXString& output, libwpg::WPGFileFormat fileFormat) { std::ostringstream tmpOutputStream; libwpg::WPGSVGGenerator generator(tmpOutputStream); bool result = libwpg::WPGraphics::parse(input, &generator, fileFormat); if (result) - output = WPGString(tmpOutputStream.str().c_str()); + output = WPXString(tmpOutputStream.str().c_str()); else - output = WPGString(""); + output = WPXString(""); return result; } -bool libwpg::WPGraphics::generateSVG(const unsigned char* data, const size_t size, libwpg::WPGString& output, libwpg::WPGFileFormat fileFormat) +bool libwpg::WPGraphics::generateSVG(const unsigned char* data, const size_t size, WPXString& output, libwpg::WPGFileFormat fileFormat) { WPGInternalInputStream tmpStream(data, size); return libwpg::WPGraphics::generateSVG(&tmpStream, output, fileFormat); --- WPGBinaryData.cpp DELETED --- --- WPGBinaryData.h DELETED --- Index: libwpg.h.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/libwpg.h.in,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- libwpg.h.in 4 Jul 2007 09:13:36 -0000 1.6 +++ libwpg.h.in 24 Nov 2008 10:16:19 -0000 1.7 @@ -43,6 +43,5 @@ #include "WPGPoint.h" #include "WPGRect.h" #include "WPGBitmap.h" -#include "WPGBinaryData.h" #endif Index: WPGPaintInterface.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGPaintInterface.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- WPGPaintInterface.h 16 Jul 2008 14:10:59 -0000 1.10 +++ WPGPaintInterface.h 24 Nov 2008 10:16:19 -0000 1.11 @@ -28,7 +28,7 @@ #define __WPGPAINTINTERFACE_H__ #include "WPGBitmap.h" -#include "WPGBinaryData.h" +#include <libwpd/libwpd.h> #include "WPGBrush.h" #include "WPGPath.h" #include "WPGPen.h" @@ -72,7 +72,7 @@ virtual void drawBitmap(const WPGBitmap& bitmap) = 0; - virtual void drawImageObject(const WPGBinaryData& binaryData) = 0; + virtual void drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData) = 0; // none of the other callback functions will be called after this function is called virtual void endGraphics() = 0; Index: Makefile.am =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/Makefile.am,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Makefile.am 8 Oct 2007 20:47:26 -0000 1.27 +++ Makefile.am 24 Nov 2008 10:16:19 -0000 1.28 @@ -30,9 +30,7 @@ WPGPoint.h \ WPGRect.h \ WPGPath.h \ - WPGString.h \ WPGBitmap.h \ - WPGBinaryData.h \ WPGPaintInterface.h AM_CXXFLAGS = $(LIBWPG_CXXFLAGS) $(DEBUG_CXXFLAGS) @@ -55,9 +53,7 @@ WPG1Parser.cpp \ WPG2Parser.cpp \ WPGBitmap.cpp \ - WPGBinaryData.cpp \ WPGInternalStream.cpp \ - WPGString.cpp \ libwpg.h \ libwpg_utils.h \ WPGColor.h \ Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- WPGBitmap.cpp 23 Jul 2008 14:42:47 -0000 1.21 +++ WPGBitmap.cpp 24 Nov 2008 10:16:19 -0000 1.22 @@ -118,7 +118,7 @@ d->pixels[y*d->width + x] = color; } -void libwpg::WPGBitmap::generateBase64DIB(libwpg::WPGString& bmp) const +void libwpg::WPGBitmap::generateBase64DIB(::WPXString& bmp) const { if (d->height <= 0 || d->width <= 0) return; @@ -247,7 +247,7 @@ buffer[position++] = (char)(value & 0xFF); } -void libwpg::WPGBitmap::base64Encode(WPGString& base64, const char *data, const int len) +void libwpg::WPGBitmap::base64Encode(::WPXString& base64, const char *data, const int len) { static const char* base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- WPG2Parser.cpp 21 Aug 2008 08:56:45 -0000 1.82 +++ WPG2Parser.cpp 24 Nov 2008 10:16:19 -0000 1.83 @@ -1832,7 +1832,7 @@ { unsigned char description = readU8(); if (description < 0x27) - m_binaryData.mimeTypes.push_back(libwpg::WPGString(mimeTypesMap[description])); + m_binaryData.mimeTypes.push_back(WPXString(mimeTypesMap[description])); m_input->seek(7, WPX_SEEK_CUR); } @@ -1853,15 +1853,17 @@ return; unsigned accessoryDataLength = readU16(); m_input->seek(accessoryDataLength, WPX_SEEK_CUR); - libwpg::WPGBinaryData binaryData; - binaryData.rect.x1 = m_binaryData.x1; - binaryData.rect.y1 = m_binaryData.y1; - binaryData.rect.x2 = m_binaryData.x2; - binaryData.rect.y2 = m_binaryData.y2; - binaryData.mimeType = m_binaryData.mimeTypes[m_binaryData.objectIndex]; + + ::WPXPropertyList propList; + propList.insert("svg:x", (float)m_binaryData.x1); + propList.insert("svg:y", (float)m_binaryData.y1); + propList.insert("svg:width", (float)(m_binaryData.x2 - m_binaryData.x1)); + propList.insert("svg:height", (float)(m_binaryData.y2 - m_binaryData.y1)); + propList.insert("libwpg:mime-type", m_binaryData.mimeTypes[m_binaryData.objectIndex]); WPG_DEBUG_MSG(("Image Object Mime Type : %s\n", binaryData.mimeType.cstr())); + ::WPXBinaryData binaryData; while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) binaryData.append((char)readU8()); WPG_DEBUG_MSG((" Image Object Size : %li\n", (unsigned long)binaryData.size())); @@ -1882,7 +1884,7 @@ #endif - m_painter->drawImageObject(binaryData); + m_painter->drawImageObject(propList, binaryData); m_binaryData.objectIndex++; } Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- WPG1Parser.cpp 13 Aug 2008 07:45:43 -0000 1.47 +++ WPG1Parser.cpp 24 Nov 2008 10:16:19 -0000 1.48 @@ -28,6 +28,8 @@ #include "WPG1Parser.h" #include "WPGPaintInterface.h" #include "libwpg_utils.h" +#include <libwpd/libwpd.h> +#include <libwpd/WPXPropertyList.h> static const unsigned char defaultWPG1PaletteRed[] = { 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, @@ -778,18 +780,21 @@ long y1 = readS16(); long x2 = readS16(); long y2 = readS16(); - libwpg::WPGBinaryData data; - data.rect.x1 = (double)x1/72.0; - data.rect.y1 = (double)m_height/1200.0 - (double)y1/72.0; - data.rect.x2 = (double)x2/72.0; - data.rect.y2 = (double)m_height/1200.0 - (double)y2/72.0; + ::WPXPropertyList propList; + + propList.insert("svg:x", (float)((double)x1/72.0)); + propList.insert("svg:y", (float)((double)m_height/1200.0 - (double)y1/72.0)); + propList.insert("svg:width", (float)(((double)x2 - (double)x1)/72.0)); + propList.insert("svg:height", (float)(((double)y1 - (double)y2)/72.0)); + propList.insert("libwpg:mime-type", "application/x-postscript"); + + ::WPXBinaryData data; data.clear(); while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) data.append((char)readU8()); - data.mimeType = "application/x-postscript"; if (data.size()) - m_painter->drawImageObject(data); + m_painter->drawImageObject(propList, data); } void WPG1Parser::handlePostscriptTypeTwo() @@ -823,21 +828,24 @@ long ys2 = (y1 <= y2) ? y2 : y1; WPG_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2)); - libwpg::WPGBinaryData data; - data.rect.x1 = (double)xs1/1200.0; - data.rect.y1 = (double)(ys1)/1200.0; - data.rect.x2 = (double)xs2/1200.0; - data.rect.y2 = (double)(ys2)/1200.0; + ::WPXPropertyList propList; - data.mimeType = "image/x-eps"; + propList.insert("svg:x", (float)((double)xs1/1200.0)); + propList.insert("svg:y", (float)((double)(ys1)/1200.0)); + + propList.insert("svg:width", (float)(((double)xs2 - (double)xs1)/1200.0)); + propList.insert("svg:height", (float)(((double)ys2 -(double)ys1)/1200.0)); + + propList.insert("libwpg:mime-type", "image/x-eps"); m_input->seek(48, WPX_SEEK_CUR); + ::WPXBinaryData data; data.clear(); while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) data.append((char)readU8()); if (data.size()) - m_painter->drawImageObject(data); + m_painter->drawImageObject(propList, data); } void WPG1Parser::resetPalette() Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- WPGSVGGenerator.cpp 16 Jul 2008 14:14:22 -0000 1.16 +++ WPGSVGGenerator.cpp 24 Nov 2008 10:16:19 -0000 1.17 @@ -249,7 +249,7 @@ void libwpg::WPGSVGGenerator::drawBitmap(const libwpg::WPGBitmap& bitmap) { - WPGString base64Bitmap; + WPXString base64Bitmap; bitmap.generateBase64DIB(base64Bitmap); m_outputSink << "<image "; m_outputSink << "x=\"" << doubleToString(72*bitmap.rect.x1) << "\" y=\"" << doubleToString(72*bitmap.rect.y1) << "\" "; @@ -259,15 +259,16 @@ m_outputSink << "\" />\n"; } -void libwpg::WPGSVGGenerator::drawImageObject(const libwpg::WPGBinaryData& binaryData) +void libwpg::WPGSVGGenerator::drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData) { - if (binaryData.mimeType.length() <= 0) + if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0) return; - WPGString base64 = binaryData.getBase64Data(); + WPXString base64 = binaryData.getBase64Data(); m_outputSink << "<image "; - m_outputSink << "x=\"" << doubleToString(72*binaryData.rect.x1) << "\" y=\"" << doubleToString(72*binaryData.rect.y1) << "\" "; - m_outputSink << "width=\"" << doubleToString(72*binaryData.rect.width()) << "\" height=\"" << doubleToString(72*binaryData.rect.height()) << "\" "; - m_outputSink << "xlink:href=\"data:" << binaryData.mimeType.cstr() << ";base64,"; + if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"]) + m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getFloat())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getFloat())) << "\" "; + m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getFloat())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getFloat())) << "\" "; + m_outputSink << "xlink:href=\"data:" << propList["libwpg:mime-type"]->getStr().cstr() << ";base64,"; m_outputSink << base64.cstr(); m_outputSink << "\" />\n"; } --- WPGString.h DELETED --- |
From: Fridrich S. <str...@us...> - 2008-11-24 10:16:26
|
Update of /cvsroot/libwpg/libwpg/src/conv/raw In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12228/src/conv/raw Modified Files: wpg2raw.cpp Log Message: first step in the struggle to simplify libwpg api Index: wpg2raw.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/raw/wpg2raw.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- wpg2raw.cpp 27 Jul 2008 20:56:16 -0000 1.11 +++ wpg2raw.cpp 24 Nov 2008 10:16:19 -0000 1.12 @@ -29,7 +29,8 @@ #include <string.h> #include "libwpg.h" -#include <libwpd-stream/WPXStreamImplementation.h> +#include <libwpd-stream/libwpd-stream.h> +#include <libwpd/libwpd.h> class RawPainter : public libwpg::WPGPaintInterface { public: @@ -52,7 +53,7 @@ void drawPolygon(const libwpg::WPGPointArray& vertices); void drawPath(const libwpg::WPGPath& path); void drawBitmap(const libwpg::WPGBitmap& bitmap); - void drawImageObject(const libwpg::WPGBinaryData& binaryData); + void drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData); }; RawPainter::RawPainter(): libwpg::WPGPaintInterface() @@ -153,7 +154,7 @@ printf("RawPainter::drawBitmap\n"); } -void RawPainter::drawImageObject(const libwpg::WPGBinaryData& /*binaryData*/) +void RawPainter::drawImageObject(const ::WPXPropertyList& /* propList */, const ::WPXBinaryData& /*binaryData*/) { printf("RawPainter::drawBinaryData\n"); } |
From: Fridrich S. <str...@us...> - 2008-11-11 09:36:41
|
Update of /cvsroot/libwpg/wpg2odg/cmdline In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2666/cmdline Modified Files: StdOutputHandler.cxx Log Message: an include to fix compilation with upcoming gcc-4.4.x Index: StdOutputHandler.cxx =================================================================== RCS file: /cvsroot/libwpg/wpg2odg/cmdline/StdOutputHandler.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- StdOutputHandler.cxx 26 Nov 2006 17:14:05 -0000 1.4 +++ StdOutputHandler.cxx 11 Nov 2008 09:36:34 -0000 1.5 @@ -24,6 +24,7 @@ */ #include "StdOutputHandler.hxx" +#include <stdio.h> StdOutputHandler::StdOutputHandler() : mbIsTagOpened(false) |
From: Fridrich S. <str...@us...> - 2008-08-21 08:57:09
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21463/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp Log Message: avoiding a signedness/unsignedness issue Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.16 retrieving revision 1.58.2.17 diff -u -d -r1.58.2.16 -r1.58.2.17 --- WPG2Parser.cpp 13 Aug 2008 07:44:19 -0000 1.58.2.16 +++ WPG2Parser.cpp 21 Aug 2008 08:57:04 -0000 1.58.2.17 @@ -899,22 +899,25 @@ std::vector<double> positions; WPG_DEBUG_MSG((" Gradient colors : %d\n", count)); - for(unsigned i = 0; i < count; i++) + if (count > 0) // try not to run into signedness/unsignedness issues in second for cycle { - unsigned char red = readU8(); - unsigned char green = readU8(); - unsigned char blue = readU8(); - unsigned char alpha = readU8(); - libwpg::WPGColor color(red, green, blue, alpha); - colors.push_back(color); - WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); - } + for(unsigned i = 0; i < count; i++) + { + unsigned char red = readU8(); + unsigned char green = readU8(); + unsigned char blue = readU8(); + unsigned char alpha = readU8(); + libwpg::WPGColor color(red, green, blue, alpha); + colors.push_back(color); + WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); + } - for(unsigned j = 0; j < count-1; j++) - { - unsigned pos = readU16(); - positions.push_back(TO_DOUBLE(pos)); - WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos)); + for(unsigned j = 0; j < count-1; j++) + { + unsigned pos = readU16(); + positions.push_back(TO_DOUBLE(pos)); + WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos)); + } } // looks like Corel Presentations only create 2 colors gradient |
From: Fridrich S. <str...@us...> - 2008-08-21 08:56:50
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21199/src/lib Modified Files: WPG2Parser.cpp Log Message: avoiding a signedness/unsignedness issue Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- WPG2Parser.cpp 13 Aug 2008 07:45:43 -0000 1.81 +++ WPG2Parser.cpp 21 Aug 2008 08:56:45 -0000 1.82 @@ -884,22 +884,25 @@ std::vector<double> positions; WPG_DEBUG_MSG((" Gradient colors : %d\n", count)); - for(unsigned i = 0; i < count; i++) + if (count > 0) // try not to run into signedness/unsignedness issues in second for cycle { - unsigned char red = readU8(); - unsigned char green = readU8(); - unsigned char blue = readU8(); - unsigned char alpha = readU8(); - libwpg::WPGColor color(red, green, blue, alpha); - colors.push_back(color); - WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); - } + for(unsigned i = 0; i < count; i++) + { + unsigned char red = readU8(); + unsigned char green = readU8(); + unsigned char blue = readU8(); + unsigned char alpha = readU8(); + libwpg::WPGColor color(red, green, blue, alpha); + colors.push_back(color); + WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); + } - for(unsigned j = 0; j < count-1; j++) - { - unsigned pos = readU16(); - positions.push_back(TO_DOUBLE(pos)); - WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos)); + for(unsigned j = 0; j < count-1; j++) + { + unsigned pos = readU16(); + positions.push_back(TO_DOUBLE(pos)); + WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos)); + } } // looks like Corel Presentations only create 2 colors gradient |
From: Fridrich S. <str...@us...> - 2008-08-15 12:16:33
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10690/src/lib Modified Files: Tag: STABLE-0-1-0 WPGBinaryData.cpp Log Message: Fix of some WPGBitmap::append methods Index: WPGBinaryData.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBinaryData.cpp,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -d -r1.2.2.1 -r1.2.2.2 --- WPGBinaryData.cpp 16 Nov 2007 20:20:04 -0000 1.2.2.1 +++ WPGBinaryData.cpp 15 Aug 2008 12:16:29 -0000 1.2.2.2 @@ -66,16 +66,16 @@ void libwpg::WPGBinaryData::append(const WPGBinaryData &data) { size_t previousSize = m_binaryDataImpl->m_buf.size(); - m_binaryDataImpl->m_buf.resize(previousSize + data.m_binaryDataImpl->m_buf.size()); - for (size_t i = previousSize; i < previousSize + data.m_binaryDataImpl->m_buf.size(); i++) - m_binaryDataImpl->m_buf[previousSize + i] = data.m_binaryDataImpl->m_buf[i]; + m_binaryDataImpl->m_buf.reserve(previousSize + data.m_binaryDataImpl->m_buf.size()); + for (size_t i = 0; i < data.m_binaryDataImpl->m_buf.size(); i++) + m_binaryDataImpl->m_buf.push_back(data.m_binaryDataImpl->m_buf[i]); } void libwpg::WPGBinaryData::append(const char *buffer, const size_t bufferSize ) { size_t previousSize = m_binaryDataImpl->m_buf.size(); - m_binaryDataImpl->m_buf.resize(previousSize + bufferSize); - for (size_t i = previousSize; i < previousSize + bufferSize; i++) + m_binaryDataImpl->m_buf.reserve(previousSize + bufferSize); + for (size_t i = 0; i < bufferSize; i++) m_binaryDataImpl->m_buf[previousSize + i] = buffer[i]; } |
From: Fridrich S. <str...@us...> - 2008-08-15 12:16:21
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10646/src/lib Modified Files: WPGBinaryData.cpp Log Message: Fix of some WPGBitmap::append methods Index: WPGBinaryData.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBinaryData.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- WPGBinaryData.cpp 16 Nov 2007 20:19:26 -0000 1.3 +++ WPGBinaryData.cpp 15 Aug 2008 12:16:13 -0000 1.4 @@ -66,16 +66,16 @@ void libwpg::WPGBinaryData::append(const WPGBinaryData &data) { size_t previousSize = m_binaryDataImpl->m_buf.size(); - m_binaryDataImpl->m_buf.resize(previousSize + data.m_binaryDataImpl->m_buf.size()); - for (size_t i = previousSize; i < previousSize + data.m_binaryDataImpl->m_buf.size(); i++) - m_binaryDataImpl->m_buf[previousSize + i] = data.m_binaryDataImpl->m_buf[i]; + m_binaryDataImpl->m_buf.reserve(previousSize + data.m_binaryDataImpl->m_buf.size()); + for (size_t i = 0; i < data.m_binaryDataImpl->m_buf.size(); i++) + m_binaryDataImpl->m_buf.push_back(data.m_binaryDataImpl->m_buf[i]); } void libwpg::WPGBinaryData::append(const char *buffer, const size_t bufferSize ) { size_t previousSize = m_binaryDataImpl->m_buf.size(); - m_binaryDataImpl->m_buf.resize(previousSize + bufferSize); - for (size_t i = previousSize; i < previousSize + bufferSize; i++) + m_binaryDataImpl->m_buf.reserve(previousSize + bufferSize); + for (size_t i = 0; i < bufferSize; i++) m_binaryDataImpl->m_buf[previousSize + i] = buffer[i]; } |
From: Fridrich S. <str...@us...> - 2008-08-13 07:45:47
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3479/src/lib Modified Files: WPG1Parser.cpp WPG2Parser.cpp Log Message: some more sanity checks due to sum1's tearing-down work. Thanks, dudie Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- WPG2Parser.cpp 24 Jul 2008 13:52:24 -0000 1.80 +++ WPG2Parser.cpp 13 Aug 2008 07:45:43 -0000 1.81 @@ -1451,7 +1451,7 @@ // plain data, uncompression if(compression_format==0) - for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++) + for(unsigned ii=0; ii < tmpBufferSize && !m_input->atEOS() && m_input->tell() <= m_recordEnd; ii++) buffer.push_back( readU8() ); // run-length encoding else if(compression_format==1) @@ -1859,7 +1859,7 @@ WPG_DEBUG_MSG(("Image Object Mime Type : %s\n", binaryData.mimeType.cstr())); - while (m_input->tell() <= m_recordEnd) + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) binaryData.append((char)readU8()); WPG_DEBUG_MSG((" Image Object Size : %li\n", (unsigned long)binaryData.size())); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- WPG1Parser.cpp 24 Jul 2008 15:35:55 -0000 1.46 +++ WPG1Parser.cpp 13 Aug 2008 07:45:43 -0000 1.47 @@ -785,7 +785,7 @@ data.rect.y2 = (double)m_height/1200.0 - (double)y2/72.0; data.clear(); - while (m_input->tell() <= m_recordEnd) + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) data.append((char)readU8()); data.mimeType = "application/x-postscript"; if (data.size()) @@ -834,7 +834,7 @@ m_input->seek(48, WPX_SEEK_CUR); data.clear(); - while (m_input->tell() <= m_recordEnd) + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) data.append((char)readU8()); if (data.size()) m_painter->drawImageObject(data); |
From: Fridrich S. <str...@us...> - 2008-08-13 07:44:24
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3015/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp WPG2Parser.cpp Log Message: some more sanity checks due to sum1's tearing-down work. Thanks, dudie Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.15 retrieving revision 1.58.2.16 diff -u -d -r1.58.2.15 -r1.58.2.16 --- WPG2Parser.cpp 24 Jul 2008 13:53:04 -0000 1.58.2.15 +++ WPG2Parser.cpp 13 Aug 2008 07:44:19 -0000 1.58.2.16 @@ -1461,7 +1461,7 @@ // plain data, uncompression if(compression_format==0) - for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++) + for(unsigned ii=0; ii < tmpBufferSize && !m_input->atEOS() && m_input->tell() <= m_recordEnd; ii++) buffer.push_back( readU8() ); // run-length encoding else if(compression_format==1) @@ -1869,7 +1869,7 @@ WPG_DEBUG_MSG(("Image Object Mime Type : %s\n", binaryData.mimeType.cstr())); - while (m_input->tell() <= m_recordEnd) + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) binaryData.append((char)readU8()); WPG_DEBUG_MSG((" Image Object Size : %li\n", (unsigned long)binaryData.size())); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.33.2.12 retrieving revision 1.33.2.13 diff -u -d -r1.33.2.12 -r1.33.2.13 --- WPG1Parser.cpp 24 Jul 2008 15:36:11 -0000 1.33.2.12 +++ WPG1Parser.cpp 13 Aug 2008 07:44:19 -0000 1.33.2.13 @@ -784,7 +784,7 @@ data.rect.y2 = (double)m_height/1200.0 - (double)y2/72.0; data.clear(); - while (m_input->tell() <= m_recordEnd) + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) data.append((char)readU8()); data.mimeType = "application/x-postscript"; if (data.size()) @@ -833,7 +833,7 @@ m_input->seek(48, WPX_SEEK_CUR); data.clear(); - while (m_input->tell() <= m_recordEnd) + while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) data.append((char)readU8()); if (data.size()) m_painter->drawImageObject(data); |
From: Fridrich S. <str...@us...> - 2008-07-27 20:56:20
|
Update of /cvsroot/libwpg/libwpg/src/conv/raw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11391/src/conv/raw Modified Files: wpg2raw.cpp Log Message: some anonymous namespaces here and there + some more verbose --help and --version output Index: wpg2raw.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/raw/wpg2raw.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- wpg2raw.cpp 16 Jul 2008 14:10:59 -0000 1.10 +++ wpg2raw.cpp 27 Jul 2008 20:56:16 -0000 1.11 @@ -26,6 +26,7 @@ */ #include <stdio.h> +#include <string.h> #include "libwpg.h" #include <libwpd-stream/WPXStreamImplementation.h> @@ -157,16 +158,47 @@ printf("RawPainter::drawBinaryData\n"); } +namespace { + +int printUsage() +{ + printf("Usage: wpg2raw [OPTION] <WordPerfect Graphics File>\n"); + printf("\n"); + printf("Options:\n"); + printf("--help Shows this help message\n"); + printf("--version Output wpg2raw version \n"); + return -1; +} + +int printVersion() +{ + printf("wpg2raw %s\n", LIBWPG_VERSION_STRING); + return 0; +} + +} // anonymous namespace + int main(int argc, char *argv[]) { if (argc < 2) + return printUsage(); + + char *file = 0; + + for (int i = 1; i < argc; i++) { - printf("usage: wpg2raw <WordPerfect Graphic>\n"); - return -1; + if (!strcmp(argv[i], "--version")) + return printVersion(); + else if (!file && strncmp(argv[i], "--", 2)) + file = argv[i]; + else + return printUsage(); } - const char* filename = argv[1]; - WPXFileStream input(filename); + if (!file) + return printUsage(); + + WPXFileStream input(file); if (!libwpg::WPGraphics::isSupported(&input)) { |
From: Fridrich S. <str...@us...> - 2008-07-27 20:56:20
|
Update of /cvsroot/libwpg/libwpg/src/conv/svg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11391/src/conv/svg Modified Files: wpg2svg.cpp Log Message: some anonymous namespaces here and there + some more verbose --help and --version output Index: wpg2svg.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/svg/wpg2svg.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- wpg2svg.cpp 26 Oct 2007 08:16:07 -0000 1.4 +++ wpg2svg.cpp 27 Jul 2008 20:56:16 -0000 1.5 @@ -25,20 +25,51 @@ #include <iostream> #include <sstream> +#include <string.h> #include "libwpg.h" #include <libwpd-stream/WPXStreamImplementation.h> +namespace { + +int printUsage() +{ + printf("Usage: wpg2svg [OPTION] <WordPerfect Graphics File>\n"); + printf("\n"); + printf("Options:\n"); + printf("--help Shows this help message\n"); + printf("--version Output wpg2svg version \n"); + return -1; +} + +int printVersion() +{ + printf("wpg2svg %s\n", LIBWPG_VERSION_STRING); + return 0; +} + +} // anonymous namespace int main(int argc, char *argv[]) { if (argc < 2) + return printUsage(); + + char *file = 0; + + for (int i = 1; i < argc; i++) { - std::cout << "usage: wpg2svg <WordPerfect Graphic>" << std::endl; - return -1; + if (!strcmp(argv[i], "--version")) + return printVersion(); + else if (!file && strncmp(argv[i], "--", 2)) + file = argv[i]; + else + return printUsage(); } - const char* filename = argv[1]; - WPXFileStream input(filename); + if (!file) + return printUsage(); + + WPXFileStream input(file); if (!libwpg::WPGraphics::isSupported(&input)) { |
From: Fridrich S. <str...@us...> - 2008-07-25 12:00:03
|
Update of /cvsroot/libwpg/libwpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27971 Modified Files: Tag: STABLE-0-1-0 ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/libwpg/libwpg/ChangeLog,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -u -d -r1.2.2.3 -r1.2.2.4 --- ChangeLog 25 Jul 2008 11:04:04 -0000 1.2.2.3 +++ ChangeLog 25 Jul 2008 11:59:58 -0000 1.2.2.4 @@ -1,5 +1,4 @@ 0.1.2 - 0.1.3 - - in WPG2, pseudo-handle polyspline: since we dont manage to generate it, we simply draw a polyline and wait for bug reports to give us some more information (Fridrich). |
From: Fridrich S. <str...@us...> - 2008-07-25 11:25:18
|
Update of /cvsroot/libwpg/libwpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15246 Modified Files: ChangeLog libwpg.spec.in Log Message: merging from stable branch Index: ChangeLog =================================================================== RCS file: /cvsroot/libwpg/libwpg/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ChangeLog 24 Aug 2007 11:11:45 -0000 1.2 +++ ChangeLog 25 Jul 2008 11:25:14 -0000 1.3 @@ -1,5 +1,48 @@ -0.1.0 - 0.1.0 +0.1.2 - 0.1.3 + +- in WPG2, pseudo-handle polyspline: since we dont manage to generate it, + we simply draw a polyline and wait for bug reports to give us some more + information (Fridrich). +- change run-lenth decoding of bitmap code from using a manually allocated + buffer to a std::vector based solution for both WPG1 and WP2 (Fridrich). +- robustness improvement of our bitmap parser when handling corrupted + documents (Fridrich, sum1). +- when dumping binary objects and bitmaps in debug mode, don't crash when + the current directory is not writable for the user (Fridrich). +- in WPG1 Bitmap decoding, handle also bitmaps with coulour depth 2 and 4, + which allows the FINGER.WPG test file to unveil its attractions (Fridrich). +- in WPG1, attempt to handle the embedded postscript (Fridrich). +- in WPG1, handle bezier curves (Fridrich). +- in WPG1, fix for pen styles (Fridrich). +- in WPG2, don't assume 1200 dpi for embedded objects if the document specifies + a different one (Fridrich). +- in WPG2, don't try to handle embedded WPG fragments as binary documents, since + nobody other out there handles them if we don't (Fridrich). +- in WPG2, add some useful dump and debug capabilities and fix a wrong seek. +- in spec file, require pkg-config (Fridrich). +- let autogen.sh not call configure at all (Fridrich). +- allow specifying the docdir and don't install documentation as executables (patch + Michal Marek <mm...@su...>) + +0.1.1 - 0.1.2 +- Work around an issue with relative seeks backward and certain versions of libstdc++ + in the buffered stream implementation (Fridrich, sum1) +- Fix regression in decoding of bitmap in WPG2 files (Fridrich, sum1). +- Fix a bug in reading bitmap size in double precision WPG2 files (Fridrich, sum1). +- Remove some abuse of pointers in wpg2foo tools (Fridrich). +- Fix some signedness problems (Fridrich). +- Fix some array-out-of-bond errors in decoding of bitmap with corrupted + WPG1 documents (Fridrich, sum1). +- Add some sanity checks (Fridrich). + +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: libwpg.spec.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/libwpg.spec.in,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- libwpg.spec.in 3 Apr 2008 09:28:35 -0000 1.11 +++ libwpg.spec.in 25 Jul 2008 11:25:14 -0000 1.12 @@ -84,7 +84,7 @@ %if %{!?_without_docs:1}%{?_without_docs:0} %files docs -%{_datadir}/doc/libwpg-@WPG_VERSION@/* +%{_datadir}/* %endif %changelog |
From: Fridrich S. <str...@us...> - 2008-07-25 11:04:13
|
Update of /cvsroot/libwpg/libwpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6910 Modified Files: Tag: STABLE-0-1-0 ChangeLog configure.in libwpg.spec.in Log Message: preparation of 0.1.3 release Index: ChangeLog =================================================================== RCS file: /cvsroot/libwpg/libwpg/ChangeLog,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -d -r1.2.2.2 -r1.2.2.3 --- ChangeLog 13 Dec 2007 14:03:41 -0000 1.2.2.2 +++ ChangeLog 25 Jul 2008 11:04:04 -0000 1.2.2.3 @@ -1,3 +1,29 @@ +0.1.2 - 0.1.3 + +- in WPG2, pseudo-handle polyspline: since we dont manage to generate it, + we simply draw a polyline and wait for bug reports to give us some more + information (Fridrich). +- change run-lenth decoding of bitmap code from using a manually allocated + buffer to a std::vector based solution for both WPG1 and WP2 (Fridrich). +- robustness improvement of our bitmap parser when handling corrupted + documents (Fridrich, sum1). +- when dumping binary objects and bitmaps in debug mode, don't crash when + the current directory is not writable for the user (Fridrich). +- in WPG1 Bitmap decoding, handle also bitmaps with coulour depth 2 and 4, + which allows the FINGER.WPG test file to unveil its attractions (Fridrich). +- in WPG1, attempt to handle the embedded postscript (Fridrich). +- in WPG1, handle bezier curves (Fridrich). +- in WPG1, fix for pen styles (Fridrich). +- in WPG2, don't assume 1200 dpi for embedded objects if the document specifies + a different one (Fridrich). +- in WPG2, don't try to handle embedded WPG fragments as binary documents, since + nobody other out there handles them if we don't (Fridrich). +- in WPG2, add some useful dump and debug capabilities and fix a wrong seek. +- in spec file, require pkg-config (Fridrich). +- let autogen.sh not call configure at all (Fridrich). +- allow specifying the docdir and don't install documentation as executables (patch + Michal Marek <mm...@su...>) + 0.1.1 - 0.1.2 - Work around an issue with relative seeks backward and certain versions of libstdc++ in the buffered stream implementation (Fridrich, sum1) Index: configure.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/configure.in,v retrieving revision 1.15.2.3 retrieving revision 1.15.2.4 diff -u -d -r1.15.2.3 -r1.15.2.4 --- configure.in 8 Apr 2008 12:13:10 -0000 1.15.2.3 +++ configure.in 25 Jul 2008 11:04:04 -0000 1.15.2.4 @@ -5,7 +5,7 @@ WPG_MAJOR_VERSION=0 WPG_MINOR_VERSION=1 -WPG_MICRO_VERSION=2 +WPG_MICRO_VERSION=3 WPG_VERSION="$WPG_MAJOR_VERSION.$WPG_MINOR_VERSION.$WPG_MICRO_VERSION" Index: libwpg.spec.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/libwpg.spec.in,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -u -d -r1.9.2.1 -r1.9.2.2 --- libwpg.spec.in 3 Apr 2008 09:25:39 -0000 1.9.2.1 +++ libwpg.spec.in 25 Jul 2008 11:04:04 -0000 1.9.2.2 @@ -86,7 +86,7 @@ %if %{!?_without_docs:1}%{?_without_docs:0} %files docs -%{_datadir}/doc/libwpg-@WPG_VERSION@/* +%{_datadir}/* %endif %changelog |
From: Fridrich S. <str...@us...> - 2008-07-24 15:36:15
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17211/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp Log Message: some more robustness checks Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.33.2.11 retrieving revision 1.33.2.12 diff -u -d -r1.33.2.11 -r1.33.2.12 --- WPG1Parser.cpp 24 Jul 2008 13:53:04 -0000 1.33.2.11 +++ WPG1Parser.cpp 24 Jul 2008 15:36:11 -0000 1.33.2.12 @@ -296,6 +296,8 @@ return; unsigned startIndex = readU16(); unsigned numEntries = readU16(); + if (startIndex > 255 || numEntries > 256 || startIndex + numEntries > 256) + return; WPG_DEBUG_MSG(("Colormap\n")); for(unsigned int i = 0; i < numEntries; i++) @@ -505,9 +507,7 @@ void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth) { buffer.clear(); - if (depth <= 0 || width <= 0 || height <= 0) - return; - + // This are the known depth values for WPG1, no point to try to decode others since they are likely to indicate corruption if (depth != 8 && depth != 4 && depth != 2 && depth != 1) return; @@ -576,6 +576,9 @@ if(!buffer) return; + if (depth != 8 && depth != 4 && depth != 2 && depth != 1) + return; + // round to the next byte unsigned scanline_width = (width * depth + 7)/8; @@ -666,6 +669,10 @@ WPG_DEBUG_MSG(("Horizontal resolution: %d\n", hres)); WPG_DEBUG_MSG((" Vertical resolution: %d\n", vres)); + // if this happens, likely corruption, bail out. + if (depth != 1 && depth != 2 && depth != 4 && depth != 8) + return; + // Sanity checks if(hres <= 0) hres = 1200; @@ -688,7 +695,7 @@ std::vector<unsigned char> buffer; decodeRLE(buffer, width, height, depth); - if (buffer.size()) + if (buffer.size() && buffer.size() == (size_t)((width*depth + 7)/8)*height) { fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); @@ -699,11 +706,7 @@ { if (!m_graphicsStarted) return; -#ifdef DEBUG int rotation = readS16(); -#else - readS16(); -#endif int x1 = readS16(); int y1 = readS16(); int x2 = readS16(); @@ -724,6 +727,12 @@ WPG_DEBUG_MSG(("Horizontal resolution: %d\n", hres)); WPG_DEBUG_MSG((" Vertical resolution: %d\n", vres)); + // if this happens, likely corruption, bail out. + if (rotation < 0 || rotation > 359) + return; + if (depth != 1 && depth != 2 && depth != 4 && depth != 8) + return; + // Sanity checks if(hres <= 0) hres = 1200; @@ -753,7 +762,7 @@ std::vector<unsigned char> buffer; decodeRLE(buffer, width, height, depth); - if (buffer.size()) + if (buffer.size() && buffer.size() == (size_t)((width*depth + 7)/8)*height) { fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); |
From: Fridrich S. <str...@us...> - 2008-07-24 15:36:02
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16840/src/lib Modified Files: WPG1Parser.cpp Log Message: some more robustness checks Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- WPG1Parser.cpp 24 Jul 2008 13:52:24 -0000 1.45 +++ WPG1Parser.cpp 24 Jul 2008 15:35:55 -0000 1.46 @@ -296,6 +296,8 @@ return; unsigned startIndex = readU16(); unsigned numEntries = readU16(); + if (startIndex > 255 || numEntries > 256 || startIndex + numEntries > 256) + return; WPG_DEBUG_MSG(("Colormap\n")); for(unsigned int i = 0; i < numEntries; i++) @@ -506,9 +508,7 @@ void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth) { buffer.clear(); - if (depth <= 0 || width <= 0 || height <= 0) - return; - + // This are the known depth values for WPG1, no point to try to decode others since they are likely to indicate corruption if (depth != 8 && depth != 4 && depth != 2 && depth != 1) return; @@ -577,6 +577,9 @@ if(!buffer) return; + if (depth != 8 && depth != 4 && depth != 2 && depth != 1) + return; + // round to the next byte unsigned scanline_width = (width * depth + 7)/8; @@ -667,6 +670,10 @@ WPG_DEBUG_MSG(("Horizontal resolution: %d\n", hres)); WPG_DEBUG_MSG((" Vertical resolution: %d\n", vres)); + // if this happens, likely corruption, bail out. + if (depth != 1 && depth != 2 && depth != 4 && depth != 8) + return; + // Sanity checks if(hres <= 0) hres = 1200; @@ -689,7 +696,7 @@ std::vector<unsigned char> buffer; decodeRLE(buffer, width, height, depth); - if (buffer.size()) + if (buffer.size() && buffer.size() == (size_t)((width*depth + 7)/8)*height) { fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); @@ -700,11 +707,7 @@ { if (!m_graphicsStarted) return; -#ifdef DEBUG int rotation = readS16(); -#else - readS16(); -#endif int x1 = readS16(); int y1 = readS16(); int x2 = readS16(); @@ -725,6 +728,12 @@ WPG_DEBUG_MSG(("Horizontal resolution: %d\n", hres)); WPG_DEBUG_MSG((" Vertical resolution: %d\n", vres)); + // if this happens, likely corruption, bail out. + if (rotation < 0 || rotation > 359) + return; + if (depth != 1 && depth != 2 && depth != 4 && depth != 8) + return; + // Sanity checks if(hres <= 0) hres = 1200; @@ -754,7 +763,7 @@ std::vector<unsigned char> buffer; decodeRLE(buffer, width, height, depth); - if (buffer.size()) + if (buffer.size() && buffer.size() == (size_t)((width*depth + 7)/8)*height) { fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); |
From: Fridrich S. <str...@us...> - 2008-07-24 13:53:08
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10197/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp WPG1Parser.h WPG2Parser.cpp Log Message: adding some more robustness to the parser Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.14 retrieving revision 1.58.2.15 diff -u -d -r1.58.2.14 -r1.58.2.15 --- WPG2Parser.cpp 23 Jul 2008 15:05:30 -0000 1.58.2.14 +++ WPG2Parser.cpp 24 Jul 2008 13:53:04 -0000 1.58.2.15 @@ -1410,14 +1410,14 @@ { if (!m_graphicsStarted) return; - unsigned long width = readU16(); - unsigned long height = readU16(); + unsigned width = readU16(); + unsigned 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)); - WPG_DEBUG_MSG((" width : %li pixels\n", width)); - WPG_DEBUG_MSG((" height : %li pixels\n", height)); + WPG_DEBUG_MSG((" width : %i pixels\n", width)); + WPG_DEBUG_MSG((" height : %i pixels\n", height)); WPG_DEBUG_MSG((" color format : %d\n", color_format)); WPG_DEBUG_MSG((" compression : %d (%s)\n", compression_format, (compression_format==0) ? "uncompressed": @@ -1425,8 +1425,8 @@ if (color_format > 12) // not documented and we are likely not knowing what to do with this return; - unsigned long tmpBufferSize; - unsigned long raster_len = width; + unsigned tmpBufferSize; + unsigned raster_len = width; if (color_format == 1) { tmpBufferSize = (width/8+1)*height; @@ -1474,7 +1474,7 @@ WPG_DEBUG_MSG(("Decoding RLE data\n")); // FIXME check for ptr, it should not go out of bound!! - while (m_input->tell() <= m_recordEnd && !m_input->atEOS()) + while (m_input->tell() <= m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize) { unsigned char opcode = readU8(); // specify data size @@ -1584,7 +1584,9 @@ // current raster must be XORed with previous raster unsigned current = next_scanline - raster_len; unsigned previous = current - raster_len; - for( unsigned long r = 0; r < raster_len; r++) + if (current >= buffer.size() || previous >= buffer.size()) + return; + for( unsigned r = 0; r < raster_len; r++) buffer[current++] ^= buffer[previous++]; } @@ -1597,7 +1599,7 @@ // no buffer? format is unknown if(!buffer.size()) return; - for ( ; buffer.size() < tmpBufferSize; ) + while (buffer.size() < tmpBufferSize) buffer.push_back(0); // prepare the bitmap structure for the listener Index: WPG1Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.h,v retrieving revision 1.15.2.3 retrieving revision 1.15.2.4 diff -u -d -r1.15.2.3 -r1.15.2.4 --- WPG1Parser.h 23 Jul 2008 09:54:17 -0000 1.15.2.3 +++ WPG1Parser.h 24 Jul 2008 13:53:04 -0000 1.15.2.4 @@ -55,8 +55,8 @@ void handleCurvedPolyline(); - void decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth); - void fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth); + void decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth); + void fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, unsigned width, unsigned height, unsigned depth); void handleBitmapTypeOne(); void handleBitmapTypeTwo(); void handlePostscriptTypeOne(); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.33.2.10 retrieving revision 1.33.2.11 diff -u -d -r1.33.2.10 -r1.33.2.11 --- WPG1Parser.cpp 23 Jul 2008 15:05:30 -0000 1.33.2.10 +++ WPG1Parser.cpp 24 Jul 2008 13:53:04 -0000 1.33.2.11 @@ -502,21 +502,26 @@ WPG_DEBUG_MSG(("Curved Polyline\n")); } -void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth) +void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth) { buffer.clear(); if (depth <= 0 || width <= 0 || height <= 0) return; + + // This are the known depth values for WPG1, no point to try to decode others since they are likely to indicate corruption + if (depth != 8 && depth != 4 && depth != 2 && depth != 1) + return; // round to the next byte unsigned scanline_width = (width * depth + 7)/8; unsigned tmpBufferSize = scanline_width * height; - buffer.reserve(tmpBufferSize); WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); WPG_DEBUG_MSG(("Decoding RLE data\n")); - for(; m_input->tell() < m_recordEnd; ) + + buffer.reserve(tmpBufferSize); + while (m_input->tell() < m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize) { unsigned char opcode = readU8(); @@ -561,11 +566,11 @@ WPG_DEBUG_MSG(("Finish decoding RLE data\n")); WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); - for ( ; buffer.size() < tmpBufferSize ; ) + while (buffer.size() < tmpBufferSize) buffer.push_back(0); } -void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth) +void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, unsigned width, unsigned height, unsigned depth) { // sanity if(!buffer) @@ -579,10 +584,10 @@ { libwpg::WPGColor black(0, 0, 0); libwpg::WPGColor white(255, 255, 255); - for(int y = 0; y < height; y++) + for(unsigned y = 0; y < height; y++) { const unsigned char* buf = buffer + y * scanline_width; - for(int x = 0; x < width; x++) + for(unsigned x = 0; x < width; x++) if(buf[x/8] & (0x80 >> (x & 7))) bitmap.setPixel(x, y, white); else @@ -592,9 +597,9 @@ // 2-bit image: 4-color bitmap (indexed) else if(depth == 2) { - int i = 0; - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++, i++) + unsigned i = 0; + for (unsigned y = 0; y < height; y++) + for (unsigned x = 0; x < width; x++, i++) { if ((x==0) && (i % 4 != 0)) i = (i/4 + 1) * 4; @@ -606,9 +611,9 @@ // 4 -bit image: 16-colour bitmap (indexed) else if(depth == 4) { - int i = 0; - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++, i++) + unsigned i = 0; + for (unsigned y = 0; y < height; y++) + for (unsigned x = 0; x < width; x++, i++) { if ((x==0) && (i % 2 != 0)) i = (i/2 + 1) * 2; @@ -620,10 +625,10 @@ // 8-bit image: 256-colour image (indexed) else if(depth == 8) { - for(int y = 0; y < height; y++) + for(unsigned y = 0; y < height; y++) { const unsigned char* buf = buffer + y * scanline_width; - for(int x = 0; x < width; x++) + for(unsigned x = 0; x < width; x++) { const libwpg::WPGColor& color = m_colorPalette[buf[x]]; bitmap.setPixel(x, y, color); @@ -635,8 +640,8 @@ // debugging only if(buffer && 0) { - for(int x = 0; x < width; x++) - for(int y = 0; y < height; y++) + for(unsigned x = 0; x < width; x++) + for(unsigned y = 0; y < height; y++) { libwpg::WPGColor color = bitmap.pixel(x,y); WPG_DEBUG_MSG((" pixel at %d, %d: %3d %3d %3d\n", x, y, color.red, color.green, color.blue)); |
From: Fridrich S. <str...@us...> - 2008-07-24 13:52:29
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9974/src/lib Modified Files: WPG1Parser.cpp WPG1Parser.h WPG2Parser.cpp Log Message: adding some more robustness to the parser Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -u -d -r1.79 -r1.80 --- WPG2Parser.cpp 23 Jul 2008 15:05:46 -0000 1.79 +++ WPG2Parser.cpp 24 Jul 2008 13:52:24 -0000 1.80 @@ -1400,14 +1400,14 @@ { if (!m_graphicsStarted) return; - unsigned long width = readU16(); - unsigned long height = readU16(); + unsigned width = readU16(); + unsigned 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)); - WPG_DEBUG_MSG((" width : %li pixels\n", width)); - WPG_DEBUG_MSG((" height : %li pixels\n", height)); + WPG_DEBUG_MSG((" width : %i pixels\n", width)); + WPG_DEBUG_MSG((" height : %i pixels\n", height)); WPG_DEBUG_MSG((" color format : %d\n", color_format)); WPG_DEBUG_MSG((" compression : %d (%s)\n", compression_format, (compression_format==0) ? "uncompressed": @@ -1415,8 +1415,8 @@ if (color_format > 12) // not documented and we are likely not knowing what to do with this return; - unsigned long tmpBufferSize; - unsigned long raster_len = width; + unsigned tmpBufferSize; + unsigned raster_len = width; if (color_format == 1) { tmpBufferSize = (width/8+1)*height; @@ -1464,7 +1464,7 @@ WPG_DEBUG_MSG(("Decoding RLE data\n")); // FIXME check for ptr, it should not go out of bound!! - while (m_input->tell() <= m_recordEnd && !m_input->atEOS()) + while (m_input->tell() <= m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize) { unsigned char opcode = readU8(); // specify data size @@ -1574,7 +1574,9 @@ // current raster must be XORed with previous raster unsigned current = next_scanline - raster_len; unsigned previous = current - raster_len; - for( unsigned long r = 0; r < raster_len; r++) + if (current >= buffer.size() || previous >= buffer.size()) + return; + for( unsigned r = 0; r < raster_len; r++) buffer[current++] ^= buffer[previous++]; } @@ -1587,7 +1589,7 @@ // no buffer? format is unknown if(!buffer.size()) return; - for ( ; buffer.size() < tmpBufferSize; ) + while (buffer.size() < tmpBufferSize) buffer.push_back(0); // prepare the bitmap structure for the listener Index: WPG1Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- WPG1Parser.h 23 Jul 2008 09:53:55 -0000 1.18 +++ WPG1Parser.h 24 Jul 2008 13:52:24 -0000 1.19 @@ -55,8 +55,8 @@ void handleCurvedPolyline(); - void decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth); - void fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth); + void decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth); + void fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, unsigned width, unsigned height, unsigned depth); void handleBitmapTypeOne(); void handleBitmapTypeTwo(); void handlePostscriptTypeOne(); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- WPG1Parser.cpp 23 Jul 2008 15:05:46 -0000 1.44 +++ WPG1Parser.cpp 24 Jul 2008 13:52:24 -0000 1.45 @@ -503,21 +503,26 @@ WPG_DEBUG_MSG(("Curved Polyline\n")); } -void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth) +void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth) { buffer.clear(); if (depth <= 0 || width <= 0 || height <= 0) return; + + // This are the known depth values for WPG1, no point to try to decode others since they are likely to indicate corruption + if (depth != 8 && depth != 4 && depth != 2 && depth != 1) + return; // round to the next byte unsigned scanline_width = (width * depth + 7)/8; unsigned tmpBufferSize = scanline_width * height; - buffer.reserve(tmpBufferSize); WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); WPG_DEBUG_MSG(("Decoding RLE data\n")); - for(; m_input->tell() < m_recordEnd; ) + + buffer.reserve(tmpBufferSize); + while (m_input->tell() < m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize) { unsigned char opcode = readU8(); @@ -562,11 +567,11 @@ WPG_DEBUG_MSG(("Finish decoding RLE data\n")); WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); - for ( ; buffer.size() < tmpBufferSize ; ) + while (buffer.size() < tmpBufferSize) buffer.push_back(0); } -void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth) +void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, unsigned width, unsigned height, unsigned depth) { // sanity if(!buffer) @@ -580,10 +585,10 @@ { libwpg::WPGColor black(0, 0, 0); libwpg::WPGColor white(255, 255, 255); - for(int y = 0; y < height; y++) + for(unsigned y = 0; y < height; y++) { const unsigned char* buf = buffer + y * scanline_width; - for(int x = 0; x < width; x++) + for(unsigned x = 0; x < width; x++) if(buf[x/8] & (0x80 >> (x & 7))) bitmap.setPixel(x, y, white); else @@ -593,9 +598,9 @@ // 2-bit image: 4-color bitmap (indexed) else if(depth == 2) { - int i = 0; - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++, i++) + unsigned i = 0; + for (unsigned y = 0; y < height; y++) + for (unsigned x = 0; x < width; x++, i++) { if ((x==0) && (i % 4 != 0)) i = (i/4 + 1) * 4; @@ -607,9 +612,9 @@ // 4 -bit image: 16-colour bitmap (indexed) else if(depth == 4) { - int i = 0; - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++, i++) + unsigned i = 0; + for (unsigned y = 0; y < height; y++) + for (unsigned x = 0; x < width; x++, i++) { if ((x==0) && (i % 2 != 0)) i = (i/2 + 1) * 2; @@ -621,10 +626,10 @@ // 8-bit image: 256-colour image (indexed) else if(depth == 8) { - for(int y = 0; y < height; y++) + for(unsigned y = 0; y < height; y++) { const unsigned char* buf = buffer + y * scanline_width; - for(int x = 0; x < width; x++) + for(unsigned x = 0; x < width; x++) { const libwpg::WPGColor& color = m_colorPalette[buf[x]]; bitmap.setPixel(x, y, color); @@ -636,8 +641,8 @@ // debugging only if(buffer && 0) { - for(int x = 0; x < width; x++) - for(int y = 0; y < height; y++) + for(unsigned x = 0; x < width; x++) + for(unsigned y = 0; y < height; y++) { libwpg::WPGColor color = bitmap.pixel(x,y); WPG_DEBUG_MSG((" pixel at %d, %d: %3d %3d %3d\n", x, y, color.red, color.green, color.blue)); |
From: Fridrich S. <str...@us...> - 2008-07-23 15:05:51
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2347/src/lib Modified Files: WPG1Parser.cpp WPG2Parser.cpp Log Message: some optimizations + change in handling corrupted bitmap Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- WPG2Parser.cpp 23 Jul 2008 14:42:47 -0000 1.78 +++ WPG2Parser.cpp 23 Jul 2008 15:05:46 -0000 1.79 @@ -1447,6 +1447,8 @@ std::vector<unsigned char> buffer; + buffer.reserve(tmpBufferSize); + // plain data, uncompression if(compression_format==0) for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++) @@ -1473,7 +1475,10 @@ { data_size = new_data_size; if (tmpBufferSize < data_size*width*height) + { tmpBufferSize = data_size*width*height; + buffer.reserve(tmpBufferSize); + } raster_len = data_size*width; } } @@ -1512,7 +1517,7 @@ { unsigned count = 1 + readU8(); if ( buffer.size() < raster_len ) - return; + break; unsigned raster_source = buffer.size() - raster_len; for( ; count; --count) 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.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- WPG1Parser.cpp 23 Jul 2008 09:53:55 -0000 1.43 +++ WPG1Parser.cpp 23 Jul 2008 15:05:46 -0000 1.44 @@ -511,6 +511,8 @@ // round to the next byte unsigned scanline_width = (width * depth + 7)/8; + unsigned tmpBufferSize = scanline_width * height; + buffer.reserve(tmpBufferSize); WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); @@ -545,8 +547,7 @@ if (buffer.size() < scanline_width ) { WPG_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size())); - buffer.clear(); - return; + break; } unsigned raster_source = buffer.size() - scanline_width; for( ; count; --count) @@ -560,6 +561,9 @@ } WPG_DEBUG_MSG(("Finish decoding RLE data\n")); WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); + + for ( ; buffer.size() < tmpBufferSize ; ) + buffer.push_back(0); } void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth) |
From: Fridrich S. <str...@us...> - 2008-07-23 15:05:35
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2314/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp WPG2Parser.cpp Log Message: some optimizations + change in handling corrupted bitmap Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.13 retrieving revision 1.58.2.14 diff -u -d -r1.58.2.13 -r1.58.2.14 --- WPG2Parser.cpp 23 Jul 2008 14:42:16 -0000 1.58.2.13 +++ WPG2Parser.cpp 23 Jul 2008 15:05:30 -0000 1.58.2.14 @@ -1457,6 +1457,8 @@ std::vector<unsigned char> buffer; + buffer.reserve(tmpBufferSize); + // plain data, uncompression if(compression_format==0) for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++) @@ -1483,7 +1485,10 @@ { data_size = new_data_size; if (tmpBufferSize < data_size*width*height) + { tmpBufferSize = data_size*width*height; + buffer.reserve(tmpBufferSize); + } raster_len = data_size*width; } } @@ -1522,7 +1527,7 @@ { unsigned count = 1 + readU8(); if ( buffer.size() < raster_len ) - return; + break; unsigned raster_source = buffer.size() - raster_len; for( ; count; --count) 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.2.9 retrieving revision 1.33.2.10 diff -u -d -r1.33.2.9 -r1.33.2.10 --- WPG1Parser.cpp 23 Jul 2008 09:54:17 -0000 1.33.2.9 +++ WPG1Parser.cpp 23 Jul 2008 15:05:30 -0000 1.33.2.10 @@ -510,6 +510,8 @@ // round to the next byte unsigned scanline_width = (width * depth + 7)/8; + unsigned tmpBufferSize = scanline_width * height; + buffer.reserve(tmpBufferSize); WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); @@ -544,8 +546,7 @@ if (buffer.size() < scanline_width ) { WPG_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size())); - buffer.clear(); - return; + break; } unsigned raster_source = buffer.size() - scanline_width; for( ; count; --count) @@ -559,6 +560,9 @@ } WPG_DEBUG_MSG(("Finish decoding RLE data\n")); WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); + + for ( ; buffer.size() < tmpBufferSize ; ) + buffer.push_back(0); } void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth) |
From: Fridrich S. <str...@us...> - 2008-07-23 14:42:51
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24920/src/lib Modified Files: WPG2Parser.cpp WPGBitmap.cpp Log Message: handle in the new std::vector-based RL decoding a broken bitmap the same way as the preallocated-buffer method was Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- WPG2Parser.cpp 23 Jul 2008 09:53:55 -0000 1.77 +++ WPG2Parser.cpp 23 Jul 2008 14:42:47 -0000 1.78 @@ -1581,6 +1581,9 @@ // no buffer? format is unknown if(!buffer.size()) return; + + for ( ; buffer.size() < tmpBufferSize; ) + buffer.push_back(0); // prepare the bitmap structure for the listener libwpg::WPGBitmap bitmap(width, height, m_vFlipped, m_hFlipped); Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- WPGBitmap.cpp 18 Jul 2008 13:11:57 -0000 1.20 +++ WPGBitmap.cpp 23 Jul 2008 14:42:47 -0000 1.21 @@ -62,8 +62,12 @@ libwpg::WPGBitmap::~WPGBitmap() { - delete [] d->pixels; - delete d; + if (d) + { + if (d->pixels) + delete [] d->pixels; + delete d; + } } libwpg::WPGBitmap::WPGBitmap(const WPGBitmap& bitmap): rect(), d(new Private(0,0)) |
From: Fridrich S. <str...@us...> - 2008-07-23 14:42:22
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24872/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp WPGBitmap.cpp Log Message: handle in the new std::vector-based RL decoding a broken bitmap the same way as the preallocated-buffer method was Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.12 retrieving revision 1.58.2.13 diff -u -d -r1.58.2.12 -r1.58.2.13 --- WPG2Parser.cpp 23 Jul 2008 09:54:17 -0000 1.58.2.12 +++ WPG2Parser.cpp 23 Jul 2008 14:42:16 -0000 1.58.2.13 @@ -1591,6 +1591,9 @@ // no buffer? format is unknown if(!buffer.size()) return; + + for ( ; buffer.size() < tmpBufferSize; ) + buffer.push_back(0); // prepare the bitmap structure for the listener libwpg::WPGBitmap bitmap(width, height, m_vFlipped, m_hFlipped); Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.11.2.6 retrieving revision 1.11.2.7 diff -u -d -r1.11.2.6 -r1.11.2.7 --- WPGBitmap.cpp 18 Jul 2008 13:12:17 -0000 1.11.2.6 +++ WPGBitmap.cpp 23 Jul 2008 14:42:16 -0000 1.11.2.7 @@ -63,8 +63,12 @@ libwpg::WPGBitmap::~WPGBitmap() { - delete [] d->pixels; - delete d; + if (d) + { + if (d->pixels) + delete [] d->pixels; + delete d; + } } libwpg::WPGBitmap::WPGBitmap(const WPGBitmap& bitmap): rect(), d(new Private(0,0)) |
From: Fridrich S. <str...@us...> - 2008-07-23 09:54:20
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2735/src/lib Modified Files: Tag: STABLE-0-1-0 WPG1Parser.cpp WPG1Parser.h WPG2Parser.cpp Log Message: rewrite the RLE decoding to not use manually allocated memory Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.11 retrieving revision 1.58.2.12 diff -u -d -r1.58.2.11 -r1.58.2.12 --- WPG2Parser.cpp 22 Jul 2008 06:39:43 -0000 1.58.2.11 +++ WPG2Parser.cpp 23 Jul 2008 09:54:17 -0000 1.58.2.12 @@ -168,9 +168,9 @@ long kxsin; long kysin; long txinteger; - short txfraction; + unsigned short txfraction; long tyinteger; - short tyfraction; + unsigned short tyfraction; long px; long py; @@ -1456,31 +1456,23 @@ tmpBufferSize = width*height; - // prepare the bitmap actual data - unsigned char* buffer = 0; - unsigned char* ptr = 0; - + std::vector<unsigned char> buffer; // plain data, uncompression if(compression_format==0) - { - buffer = new unsigned char[tmpBufferSize]; for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++) - buffer[ii] = readU8(); - } + buffer.push_back( readU8() ); // run-length encoding else if(compression_format==1) { unsigned char data[256]; bool xor_raster = false; - unsigned char* next_scanline = buffer; + unsigned next_scanline = 0; unsigned data_size = 1; - buffer = new unsigned char[tmpBufferSize]; - ptr = buffer; WPG_DEBUG_MSG(("Decoding RLE data\n")); // FIXME check for ptr, it should not go out of bound!! - while (m_input->tell() <= m_recordEnd) + while (m_input->tell() <= m_recordEnd && !m_input->atEOS()) { unsigned char opcode = readU8(); // specify data size @@ -1491,16 +1483,9 @@ { data_size = new_data_size; if (tmpBufferSize < data_size*width*height) - { tmpBufferSize = data_size*width*height; - if (buffer) - delete [] buffer; - buffer = new unsigned char[tmpBufferSize]; - } raster_len = data_size*width; } - ptr = buffer; - next_scanline = buffer; } // a run of black (index #0) @@ -1508,8 +1493,8 @@ { unsigned count = 1 + readU8(); for( ; count ; --count ) - for(unsigned j = 0; j < data_size; j++) - *ptr++ = 0; + for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) + buffer.push_back( 0 ); } @@ -1519,8 +1504,8 @@ unsigned count = 1 + readU8(); for( ; count ; --count ) - for(unsigned j = 0; j < data_size; j++) - *ptr++ = 255; + for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) + buffer.push_back( 255 ); } // extend previous run @@ -1528,18 +1513,23 @@ { unsigned count = 1 + readU8(); for( ; count; --count) - for(unsigned j = 0; j < data_size; j++) - *ptr++ = data[j]; + for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) + buffer.push_back( data[j] ); } // repeat raster else if(opcode == 0xfe) { unsigned count = 1 + readU8(); - unsigned char* raster_source = ptr - raster_len; + if ( buffer.size() < raster_len ) + return; + unsigned raster_source = buffer.size() - raster_len; for( ; count; --count) for(unsigned long r = 0; r < raster_len; r++) - *ptr++ = *raster_source++; + { + unsigned char pixel = buffer[raster_source + r]; + buffer.push_back( pixel ); + } } // XOR @@ -1548,7 +1538,7 @@ // Xor-ing will happen when about to enter next raster // see after the last if down below xor_raster = true; - next_scanline = ptr + raster_len; + next_scanline = buffer.size() + raster_len; } // NOTE: the following two IFs here must be the last ones @@ -1557,11 +1547,11 @@ else if(opcode >= 0x80) { unsigned count = 1 + (opcode & 0x7f); - for(unsigned i = 0; i < data_size; i++) + for(unsigned i = 0; i < data_size && !m_input->atEOS(); i++) data[i] = readU8(); for( ; count; --count) for(unsigned j = 0; j < data_size; j++) - *ptr++ = data[j]; + buffer.push_back( data[j] ); } // simple copy @@ -1569,8 +1559,8 @@ { unsigned count = opcode + 1; for( ; count; --count) - for(unsigned j = 0; j < data_size; j++) - *ptr++ = readU8(); + for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) + buffer.push_back( readU8() ); } // unreachable: only sentinel @@ -1581,16 +1571,16 @@ } // new raster/scanline? if necessary do the XOR now - if(xor_raster && (ptr >= next_scanline)) + if(xor_raster && buffer.size() >= next_scanline) { // reset, because XOR in one raster at a time xor_raster = false; // current raster must be XORed with previous raster - unsigned char* current = next_scanline - raster_len; - unsigned char* previous = current - raster_len; + unsigned current = next_scanline - raster_len; + unsigned previous = current - raster_len; for( unsigned long r = 0; r < raster_len; r++) - current[r] ^= previous[r]; + buffer[current++] ^= buffer[previous++]; } @@ -1600,7 +1590,7 @@ } // no buffer? format is unknown - if(!buffer) return; + if(!buffer.size()) return; // prepare the bitmap structure for the listener libwpg::WPGBitmap bitmap(width, height, m_vFlipped, m_hFlipped); @@ -1750,7 +1740,7 @@ #ifdef DEBUG // debugging only - if(buffer && 0) + if(buffer.size() && 0) { for(unsigned long x = 0; x < width; x++) for(unsigned long y = 0; y < height; y++) @@ -1760,9 +1750,6 @@ } } #endif - - // discard - delete [] buffer; } void WPG2Parser::handleObjectCapsule() Index: WPG1Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.h,v retrieving revision 1.15.2.2 retrieving revision 1.15.2.3 diff -u -d -r1.15.2.2 -r1.15.2.3 --- WPG1Parser.h 17 Jul 2008 14:41:39 -0000 1.15.2.2 +++ WPG1Parser.h 23 Jul 2008 09:54:17 -0000 1.15.2.3 @@ -31,6 +31,7 @@ #include "WPGXParser.h" #include "WPGBrush.h" #include "WPGPen.h" +#include <vector> class WPG1Parser : public WPGXParser { @@ -54,8 +55,8 @@ void handleCurvedPolyline(); - unsigned char* decodeRLE(int width, int height, int depth); - void fillPixels(libwpg::WPGBitmap& bitmap, unsigned char* buffer, int width, int height, int depth); + void decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth); + void fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth); void handleBitmapTypeOne(); void handleBitmapTypeTwo(); void handlePostscriptTypeOne(); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.33.2.8 retrieving revision 1.33.2.9 diff -u -d -r1.33.2.8 -r1.33.2.9 --- WPG1Parser.cpp 17 Jul 2008 15:38:53 -0000 1.33.2.8 +++ WPG1Parser.cpp 23 Jul 2008 09:54:17 -0000 1.33.2.9 @@ -502,28 +502,16 @@ WPG_DEBUG_MSG(("Curved Polyline\n")); } -// allocate a buffer (of specified bitmap size), then start decoding RLE data -// from the input stream to fill the buffer -// NOTE: delete the buffer by yourself! -unsigned char* WPG1Parser::decodeRLE(int width, int height, int depth) +void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth) { + buffer.clear(); if (depth <= 0 || width <= 0 || height <= 0) - return 0; + return; // round to the next byte 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; + WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); WPG_DEBUG_MSG(("Decoding RLE data\n")); for(; m_input->tell() < m_recordEnd; ) @@ -537,8 +525,8 @@ unsigned char pixel = (count > 0) ? readU8() : 0xff; if(count == 0) count = (int)readU8(); - for( ; count && ptr < buffer + buffer_size; --count) - *ptr++ = pixel; + for( ; count ; --count) + buffer.push_back( pixel ); } else { @@ -546,29 +534,34 @@ if(count > 0) { // literal byte copy - for( ; count && ptr < buffer + buffer_size; --count) - *ptr++ = readU8(); + for( ; count ; --count) + buffer.push_back( readU8() ); } else { // copy entire scan line count = (int)readU8(); - unsigned char* raster_source = ptr - scanline_width; - if (!raster_source || raster_source < buffer) - return 0; + if (buffer.size() < scanline_width ) + { + WPG_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size())); + buffer.clear(); + return; + } + unsigned raster_source = buffer.size() - scanline_width; for( ; count; --count) - for(unsigned r = 0; r < scanline_width && ptr < buffer + buffer_size;) - *ptr++ = raster_source[r++]; + for(unsigned r = 0; r < scanline_width ; r++) + { + unsigned char pixel = buffer[raster_source + r]; + buffer.push_back( pixel ); + } } } } WPG_DEBUG_MSG(("Finish decoding RLE data\n")); - - return buffer; + WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); } -void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, unsigned char* buffer, -int width, int height, int depth) +void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth) { // sanity if(!buffer) @@ -584,7 +577,7 @@ libwpg::WPGColor white(255, 255, 255); for(int y = 0; y < height; y++) { - unsigned char* buf = buffer + y * scanline_width; + const unsigned char* buf = buffer + y * scanline_width; for(int x = 0; x < width; x++) if(buf[x/8] & (0x80 >> (x & 7))) bitmap.setPixel(x, y, white); @@ -625,7 +618,7 @@ { for(int y = 0; y < height; y++) { - unsigned char* buf = buffer + y * scanline_width; + const unsigned char* buf = buffer + y * scanline_width; for(int x = 0; x < width; x++) { const libwpg::WPGColor& color = m_colorPalette[buf[x]]; @@ -684,12 +677,11 @@ bitmap.rect.x2 = (double)width/(double)hres; bitmap.rect.y2 = (double)height/(double)vres; - unsigned char* buffer = decodeRLE(width, height, depth); - if (buffer) + std::vector<unsigned char> buffer; + decodeRLE(buffer, width, height, depth); + if (buffer.size()) { - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; - + fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); } } @@ -750,12 +742,11 @@ bitmap.rect.x2 = (double)xs2/1200.0; bitmap.rect.y2 = (double)(ys2)/1200.0; - unsigned char* buffer = decodeRLE(width, height, depth); - if (buffer) + std::vector<unsigned char> buffer; + decodeRLE(buffer, width, height, depth); + if (buffer.size()) { - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; - + fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); } } |
From: Fridrich S. <str...@us...> - 2008-07-23 09:54:04
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2337/src/lib Modified Files: WPG1Parser.cpp WPG1Parser.h WPG2Parser.cpp Log Message: rewrite the RLE decoding to not use manually allocated memory Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- WPG2Parser.cpp 22 Jul 2008 15:36:49 -0000 1.76 +++ WPG2Parser.cpp 23 Jul 2008 09:53:55 -0000 1.77 @@ -171,9 +171,9 @@ long kxsin; long kysin; long txinteger; - short txfraction; + unsigned short txfraction; long tyinteger; - short tyfraction; + unsigned short tyfraction; long px; long py; @@ -1446,26 +1446,18 @@ tmpBufferSize = width*height; - // prepare the bitmap actual data - unsigned char* buffer = 0; - unsigned char* ptr = 0; - + std::vector<unsigned char> buffer; // plain data, uncompression if(compression_format==0) - { - buffer = new unsigned char[tmpBufferSize]; for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++) - buffer[ii] = readU8(); - } + buffer.push_back( readU8() ); // run-length encoding else if(compression_format==1) { unsigned char data[256]; bool xor_raster = false; - unsigned char* next_scanline = buffer; + unsigned next_scanline = 0; unsigned data_size = 1; - buffer = new unsigned char[tmpBufferSize]; - ptr = buffer; WPG_DEBUG_MSG(("Decoding RLE data\n")); @@ -1481,16 +1473,9 @@ { data_size = new_data_size; if (tmpBufferSize < data_size*width*height) - { tmpBufferSize = data_size*width*height; - if (buffer) - delete [] buffer; - buffer = new unsigned char[tmpBufferSize]; - } raster_len = data_size*width; } - ptr = buffer; - next_scanline = buffer; } // a run of black (index #0) @@ -1499,7 +1484,7 @@ unsigned count = 1 + readU8(); for( ; count ; --count ) for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) - *ptr++ = 0; + buffer.push_back( 0 ); } @@ -1510,7 +1495,7 @@ for( ; count ; --count ) for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) - *ptr++ = 255; + buffer.push_back( 255 ); } // extend previous run @@ -1519,17 +1504,22 @@ unsigned count = 1 + readU8(); for( ; count; --count) for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) - *ptr++ = data[j]; + buffer.push_back( data[j] ); } // repeat raster else if(opcode == 0xfe) { unsigned count = 1 + readU8(); - unsigned char* raster_source = ptr - raster_len; + if ( buffer.size() < raster_len ) + return; + unsigned raster_source = buffer.size() - raster_len; for( ; count; --count) for(unsigned long r = 0; r < raster_len; r++) - *ptr++ = *raster_source++; + { + unsigned char pixel = buffer[raster_source + r]; + buffer.push_back( pixel ); + } } // XOR @@ -1538,7 +1528,7 @@ // Xor-ing will happen when about to enter next raster // see after the last if down below xor_raster = true; - next_scanline = ptr + raster_len; + next_scanline = buffer.size() + raster_len; } // NOTE: the following two IFs here must be the last ones @@ -1551,7 +1541,7 @@ data[i] = readU8(); for( ; count; --count) for(unsigned j = 0; j < data_size; j++) - *ptr++ = data[j]; + buffer.push_back( data[j] ); } // simple copy @@ -1560,7 +1550,7 @@ unsigned count = opcode + 1; for( ; count; --count) for(unsigned j = 0; j < data_size && !m_input->atEOS(); j++) - *ptr++ = readU8(); + buffer.push_back( readU8() ); } // unreachable: only sentinel @@ -1571,16 +1561,16 @@ } // new raster/scanline? if necessary do the XOR now - if(xor_raster && (ptr >= next_scanline)) + if(xor_raster && buffer.size() >= next_scanline) { // reset, because XOR in one raster at a time xor_raster = false; // current raster must be XORed with previous raster - unsigned char* current = next_scanline - raster_len; - unsigned char* previous = current - raster_len; + unsigned current = next_scanline - raster_len; + unsigned previous = current - raster_len; for( unsigned long r = 0; r < raster_len; r++) - current[r] ^= previous[r]; + buffer[current++] ^= buffer[previous++]; } @@ -1590,7 +1580,7 @@ } // no buffer? format is unknown - if(!buffer) return; + if(!buffer.size()) return; // prepare the bitmap structure for the listener libwpg::WPGBitmap bitmap(width, height, m_vFlipped, m_hFlipped); @@ -1740,7 +1730,7 @@ #ifdef DEBUG // debugging only - if(buffer && 0) + if(buffer.size() && 0) { for(unsigned long x = 0; x < width; x++) for(unsigned long y = 0; y < height; y++) @@ -1750,9 +1740,6 @@ } } #endif - - // discard - delete [] buffer; } void WPG2Parser::handleObjectCapsule() Index: WPG1Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- WPG1Parser.h 17 Jul 2008 14:41:57 -0000 1.17 +++ WPG1Parser.h 23 Jul 2008 09:53:55 -0000 1.18 @@ -31,6 +31,7 @@ #include "WPGXParser.h" #include "WPGBrush.h" #include "WPGPen.h" +#include <vector> class WPG1Parser : public WPGXParser { @@ -54,8 +55,8 @@ void handleCurvedPolyline(); - unsigned char* decodeRLE(int width, int height, int depth); - void fillPixels(libwpg::WPGBitmap& bitmap, unsigned char* buffer, int width, int height, int depth); + void decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth); + void fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth); void handleBitmapTypeOne(); void handleBitmapTypeTwo(); void handlePostscriptTypeOne(); Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- WPG1Parser.cpp 17 Jul 2008 15:38:19 -0000 1.42 +++ WPG1Parser.cpp 23 Jul 2008 09:53:55 -0000 1.43 @@ -503,28 +503,16 @@ WPG_DEBUG_MSG(("Curved Polyline\n")); } -// allocate a buffer (of specified bitmap size), then start decoding RLE data -// from the input stream to fill the buffer -// NOTE: delete the buffer by yourself! -unsigned char* WPG1Parser::decodeRLE(int width, int height, int depth) +void WPG1Parser::decodeRLE(std::vector<unsigned char>& buffer, int width, int height, int depth) { + buffer.clear(); if (depth <= 0 || width <= 0 || height <= 0) - return 0; + return; // round to the next byte 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; + WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); WPG_DEBUG_MSG(("Decoding RLE data\n")); for(; m_input->tell() < m_recordEnd; ) @@ -538,8 +526,8 @@ unsigned char pixel = (count > 0) ? readU8() : 0xff; if(count == 0) count = (int)readU8(); - for( ; count && ptr < buffer + buffer_size; --count) - *ptr++ = pixel; + for( ; count ; --count) + buffer.push_back( pixel ); } else { @@ -547,29 +535,34 @@ if(count > 0) { // literal byte copy - for( ; count && ptr < buffer + buffer_size; --count) - *ptr++ = readU8(); + for( ; count ; --count) + buffer.push_back( readU8() ); } else { // copy entire scan line count = (int)readU8(); - unsigned char* raster_source = ptr - scanline_width; - if (!raster_source || raster_source < buffer) - return 0; + if (buffer.size() < scanline_width ) + { + WPG_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size())); + buffer.clear(); + return; + } + unsigned raster_source = buffer.size() - scanline_width; for( ; count; --count) - for(unsigned r = 0; r < scanline_width && ptr < buffer + buffer_size;) - *ptr++ = raster_source[r++]; + for(unsigned r = 0; r < scanline_width ; r++) + { + unsigned char pixel = buffer[raster_source + r]; + buffer.push_back( pixel ); + } } } } WPG_DEBUG_MSG(("Finish decoding RLE data\n")); - - return buffer; + WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); } -void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, unsigned char* buffer, -int width, int height, int depth) +void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth) { // sanity if(!buffer) @@ -585,7 +578,7 @@ libwpg::WPGColor white(255, 255, 255); for(int y = 0; y < height; y++) { - unsigned char* buf = buffer + y * scanline_width; + const unsigned char* buf = buffer + y * scanline_width; for(int x = 0; x < width; x++) if(buf[x/8] & (0x80 >> (x & 7))) bitmap.setPixel(x, y, white); @@ -626,7 +619,7 @@ { for(int y = 0; y < height; y++) { - unsigned char* buf = buffer + y * scanline_width; + const unsigned char* buf = buffer + y * scanline_width; for(int x = 0; x < width; x++) { const libwpg::WPGColor& color = m_colorPalette[buf[x]]; @@ -685,12 +678,11 @@ bitmap.rect.x2 = (double)width/(double)hres; bitmap.rect.y2 = (double)height/(double)vres; - unsigned char* buffer = decodeRLE(width, height, depth); - if (buffer) + std::vector<unsigned char> buffer; + decodeRLE(buffer, width, height, depth); + if (buffer.size()) { - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; - + fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); } } @@ -751,12 +743,11 @@ bitmap.rect.x2 = (double)xs2/1200.0; bitmap.rect.y2 = (double)(ys2)/1200.0; - unsigned char* buffer = decodeRLE(width, height, depth); - if (buffer) + std::vector<unsigned char> buffer; + decodeRLE(buffer, width, height, depth); + if (buffer.size()) { - fillPixels(bitmap, buffer, width, height, depth); - delete [] buffer; - + fillPixels(bitmap, &buffer[0], width, height, depth); m_painter->drawBitmap(bitmap); } } |
From: Fridrich S. <str...@us...> - 2008-07-22 15:46:26
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9806/src/lib Modified Files: WPG2Parser.cpp Log Message: another defensive condition, just to make sum1's waiting for Godot longer Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- WPG2Parser.cpp 22 Jul 2008 15:32:24 -0000 1.75 +++ WPG2Parser.cpp 22 Jul 2008 15:36:49 -0000 1.76 @@ -1470,7 +1470,7 @@ WPG_DEBUG_MSG(("Decoding RLE data\n")); // FIXME check for ptr, it should not go out of bound!! - while (m_input->tell() <= m_recordEnd) + while (m_input->tell() <= m_recordEnd && !m_input->atEOS()) { unsigned char opcode = readU8(); // specify data size |