summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2011-01-18 11:33:07 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-01-18 11:33:07 +0100
commit085915aaba574645dfa8e80d659578a82965dea8 (patch)
tree76df7ce1fd7eede594f9871314b291f64c8ce59d
parent9e0397f5e07102c5a9e29e16dda4d7608db32231 (diff)
Trying to get the Pict2 parser a bit right + general cleanup
-rw-r--r--src/lib/Makefile.am2
-rw-r--r--src/lib/Pict1Parser.h1
-rw-r--r--src/lib/Pict2Parser.cpp313
-rw-r--r--src/lib/Pict2Parser.h12
-rw-r--r--src/lib/PictDashArray.cpp74
-rw-r--r--src/lib/PictDashArray.h52
-rw-r--r--src/lib/PictGradient.cpp102
-rw-r--r--src/lib/PictHeader.cpp20
-rw-r--r--src/lib/PictHeader.h6
-rw-r--r--src/lib/PictImage.cpp9
-rw-r--r--src/lib/PictSVGGenerator.cpp9
-rw-r--r--src/lib/PictXParser.cpp10
12 files changed, 173 insertions, 437 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 62296e7..bd4a158 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -31,7 +31,6 @@ libpict_@Pict_MAJOR_VERSION@_@Pict_MINOR_VERSION@_la_DEPENDENCIES = @LIBPict_WIN
libpict_@Pict_MAJOR_VERSION@_@Pict_MINOR_VERSION@_la_LDFLAGS = $(version_info) -export-dynamic $(no_undefined)
libpict_@Pict_MAJOR_VERSION@_@Pict_MINOR_VERSION@_la_SOURCES = \
PictImage.cpp \
- PictDashArray.cpp \
PictColor.cpp \
PictHeader.cpp \
PictSVGGenerator.cpp \
@@ -42,7 +41,6 @@ libpict_@Pict_MAJOR_VERSION@_@Pict_MINOR_VERSION@_la_SOURCES = \
libpict.h \
libpict_utils.h \
PictColor.h \
- PictDashArray.h \
PictHeader.h \
PictSVGGenerator.h \
PictXParser.h \
diff --git a/src/lib/Pict1Parser.h b/src/lib/Pict1Parser.h
index 49f41fe..f1199b0 100644
--- a/src/lib/Pict1Parser.h
+++ b/src/lib/Pict1Parser.h
@@ -22,7 +22,6 @@
#define __PICT1PARSER_H__
#include "PictXParser.h"
-#include "PictDashArray.h"
#include "PictBitmap.h"
#include <libwpd/libwpd.h>
#include <vector>
diff --git a/src/lib/Pict2Parser.cpp b/src/lib/Pict2Parser.cpp
index ed46c49..9fb8306 100644
--- a/src/lib/Pict2Parser.cpp
+++ b/src/lib/Pict2Parser.cpp
@@ -1,7 +1,5 @@
/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005-2007 Fridrich Strba (fridrich.strba@bluewin.ch)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
+ * Copyright (C) 20011 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -17,12 +15,6 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
*/
#include "Pict2Parser.h"
@@ -50,40 +42,40 @@ bool Pict2Parser::parse()
static const struct RecordHandler handlers[] =
{
- { 0x00, "NOP", &Pict2Parser::handleNOP, 1 },
+ { 0x00, "NOP", &Pict2Parser::handleNOP, 2 },
{ 0x01, "clipRgn", &Pict2Parser::handleClipRgn, -1 },
- { 0x02, "bkPat", &Pict2Parser::handleBkPat, 9 },
- { 0x03, "txFont", &Pict2Parser::handleTxFont, 3 },
- { 0x04, "txFace", &Pict2Parser::handleTxFace, 2 },
- { 0x05, "txMode", &Pict2Parser::handleTxMode, 3 },
- { 0x06, "spExtra", &Pict2Parser::handleSpExtra, 5 },
- { 0x07, "pnSize", &Pict2Parser::handlePnSize, 5 },
- { 0x08, "pnMode", &Pict2Parser::handlePnMode, 3 },
- { 0x09, "pnPat", &Pict2Parser::handlePnPat, 9 },
- { 0x0a, "thePat", &Pict2Parser::handleThePat, 9 },
- { 0x0b, "owSize", &Pict2Parser::handleOwSize, 5 },
- { 0x0c, "origin", &Pict2Parser::handleOrigin, 5 },
- { 0x0d, "txSize", &Pict2Parser::handleTxSize, 3 },
- { 0x0e, "fgColor", &Pict2Parser::handleFgColor, 5 },
- { 0x0f, "bkColor", &Pict2Parser::handleBkColor, 5 },
- { 0x10, "txRatio", &Pict2Parser::handleTxRatio, 9 },
- { 0x11, "picVersion", &Pict2Parser::handlePicVersion, 2 },
+ { 0x02, "bkPat", &Pict2Parser::handleBkPat, 10 },
+ { 0x03, "txFont", &Pict2Parser::handleTxFont, 4 },
+ { 0x04, "txFace", &Pict2Parser::handleTxFace, 3 },
+ { 0x05, "txMode", &Pict2Parser::handleTxMode, 4 },
+ { 0x06, "spExtra", &Pict2Parser::handleSpExtra, 6 },
+ { 0x07, "pnSize", &Pict2Parser::handlePnSize, 6 },
+ { 0x08, "pnMode", &Pict2Parser::handlePnMode, 4 },
+ { 0x09, "pnPat", &Pict2Parser::handlePnPat, 10 },
+ { 0x0a, "thePat", &Pict2Parser::handleThePat, 10 },
+ { 0x0b, "owSize", &Pict2Parser::handleOwSize, 6 },
+ { 0x0c, "origin", &Pict2Parser::handleOrigin, 6 },
+ { 0x0d, "txSize", &Pict2Parser::handleTxSize, 4 },
+ { 0x0e, "fgColor", &Pict2Parser::handleFgColor, 6 },
+ { 0x0f, "bkColor", &Pict2Parser::handleBkColor, 6 },
+ { 0x10, "txRatio", &Pict2Parser::handleTxRatio, 10 },
+ { 0x11, "picVersion", &Pict2Parser::handlePicVersion, 4 },
{ 0x12, "BkPixPat", &Pict2Parser::handleBkPixPat, -1 },
{ 0x13, "PnPixPat", &Pict2Parser::handlePnPixPat, -1 },
{ 0x14, "FillPixPat", &Pict2Parser::handleFillPixPat, -1 },
- { 0x15, "PnLocHFrac", &Pict2Parser::handlePnLocHFrac, 3 },
- { 0x16, "ChExtra", &Pict2Parser::handleChExtra, 3 },
-
- { 0x1a, "RGBFgCol", &Pict2Parser::handleRGBFgCol, 7 },
- { 0x1b, "RGBBkCol", &Pict2Parser::handleRGBBkCol, 7 },
- { 0x1c, "HiliteMode", &Pict2Parser::handleHiliteMode, 1 },
- { 0x1d, "HiliteColor", &Pict2Parser::handleHiliteColor, 7 },
- { 0x1e, "DefHilite", &Pict2Parser::handleDefHilite, 1 },
- { 0x1f, "OpColor", &Pict2Parser::handleOpColor, 7 },
- { 0x20, "line", &Pict2Parser::handleLine, 9 },
- { 0x21, "line from", &Pict2Parser::handleLineFrom, 5 },
- { 0x22, "short line", &Pict2Parser::handleShortLine, 7 },
- { 0x23, "short line from", &Pict2Parser::handleShortLineFrom, 3 },
+ { 0x15, "PnLocHFrac", &Pict2Parser::handlePnLocHFrac, 4 },
+ { 0x16, "ChExtra", &Pict2Parser::handleChExtra, 4 },
+
+ { 0x1a, "RGBFgCol", &Pict2Parser::handleRGBFgCol, 8 },
+ { 0x1b, "RGBBkCol", &Pict2Parser::handleRGBBkCol, 8 },
+ { 0x1c, "HiliteMode", &Pict2Parser::handleHiliteMode, 2 },
+ { 0x1d, "HiliteColor", &Pict2Parser::handleHiliteColor, 8 },
+ { 0x1e, "DefHilite", &Pict2Parser::handleDefHilite, 2 },
+ { 0x1f, "OpColor", &Pict2Parser::handleOpColor, 8 },
+ { 0x20, "line", &Pict2Parser::handleLine, 10 },
+ { 0x21, "line from", &Pict2Parser::handleLineFrom, 6 },
+ { 0x22, "short line", &Pict2Parser::handleShortLine, 8 },
+ { 0x23, "short line from", &Pict2Parser::handleShortLineFrom, 4 },
{ 0x24, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x25, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x26, "Reserved", &Pict2Parser::skipData, -1 },
@@ -93,73 +85,72 @@ bool Pict2Parser::parse()
{ 0x2a, "DV text", &Pict2Parser::handleDVText, -1 },
{ 0x2b, "DHDV text", &Pict2Parser::handleDHDVText, -1 },
{ 0x2c, "fontName", &Pict2Parser::handleFontName, -1 },
- { 0x2d, "lineJustify", &Pict2Parser::handleLineJustify, 11 },
- { 0x2e, "glyphState", &Pict2Parser::handleGlyphState, 9 },
+ { 0x2d, "lineJustify", &Pict2Parser::handleLineJustify, 12 },
+ { 0x2e, "glyphState", &Pict2Parser::handleGlyphState, 10 },
{ 0x2f, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x30, "frameRect", &Pict2Parser::handleFrameRect, 9 },
- { 0x31, "paintRect", &Pict2Parser::handlePaintRect, 9 },
- { 0x32, "eraseRect", &Pict2Parser::handleEraseRect, 9 },
- { 0x33, "invertRect", &Pict2Parser::handleInvertRect, 9 },
- { 0x34, "fillRect", &Pict2Parser::handleFillRect, 9 },
- { 0x35, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x36, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x37, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x38, "frameSameRect", &Pict2Parser::handleFrameSameRect, 1 },
- { 0x39, "paintSameRect", &Pict2Parser::handlePaintSameRect, 1 },
- { 0x3a, "eraseSameRect", &Pict2Parser::handleEraseSameRect, 1 },
- { 0x3b, "invertSameRect", &Pict2Parser::handleInvertSameRect, 1 },
- { 0x3c, "fillSameRect", &Pict2Parser::handleFillSameRect, 1 },
- { 0x3d, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x3e, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x3f, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x40, "frameRRect", &Pict2Parser::handleFrameRRect, 9 },
- { 0x41, "paintRRect", &Pict2Parser::handlePaintRRect, 9 },
- { 0x42, "eraseRRect", &Pict2Parser::handleEraseRRect, 9 },
- { 0x43, "invertRRect", &Pict2Parser::handleInvertRRect, 9 },
- { 0x44, "fillRRect", &Pict2Parser::handleFillRRect, 9 },
- { 0x45, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x46, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x47, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x48, "frameSameRRect", &Pict2Parser::handleFrameSameRRect, 1 },
- { 0x49, "paintSameRRect", &Pict2Parser::handlePaintSameRRect, 1 },
- { 0x4a, "eraseSameRRect", &Pict2Parser::handleEraseSameRRect, 1 },
- { 0x4b, "invertSameRRect", &Pict2Parser::handleInvertSameRRect, 1 },
- { 0x4c, "fillSameRRect", &Pict2Parser::handleFillSameRRect, 1 },
- { 0x4d, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x4e, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x4f, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x50, "frameOval", &Pict2Parser::handleFrameOval, 9 },
- { 0x51, "paintOval", &Pict2Parser::handlePaintOval, 9 },
- { 0x52, "eraseOval", &Pict2Parser::handleEraseOval, 9 },
- { 0x53, "invertOval", &Pict2Parser::handleInsertOval, 9 },
- { 0x54, "fillOval", &Pict2Parser::handleFillOval, 9 },
- { 0x55, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x56, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x57, "Reserved", &Pict2Parser::handleNOP, 9 },
- { 0x58, "frameSameOval", &Pict2Parser::handleFrameSameOval, 1 },
- { 0x59, "paintSameOval", &Pict2Parser::handlePaintSameOval, 1 },
- { 0x5a, "eraseSameOval", &Pict2Parser::handleEraseSameOval, 1 },
- { 0x5b, "invertSameOval", &Pict2Parser::handleInsertSameOval, 1 },
- { 0x5c, "fillSameOval", &Pict2Parser::handleFillSameOval, 1 },
- { 0x5d, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x5e, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x5f, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x60, "frameArc", &Pict2Parser::handleFrameArc, 13 },
- { 0x61, "paintArc", &Pict2Parser::handlePaintArc, 13 },
- { 0x62, "eraseArc", &Pict2Parser::handleEraseArc, 13 },
- { 0x63, "invertArc", &Pict2Parser::handleInsertArc, 13 },
- { 0x64, "fillArc", &Pict2Parser::handleFillArc, 13 },
- { 0x65, "Reserved", &Pict2Parser::handleNOP, 13 },
- { 0x66, "Reserved", &Pict2Parser::handleNOP, 13 },
- { 0x67, "Reserved", &Pict2Parser::handleNOP, 13 },
- { 0x68, "frameSameArc", &Pict2Parser::handleFrameSameArc, 5 },
- { 0x69, "paintSameArc", &Pict2Parser::handlePaintSameArc, 5 },
- { 0x6a, "eraseSameArc", &Pict2Parser::handleEraseSameArc, 5 },
- { 0x6b, "inverSameArc", &Pict2Parser::handleInsertSameArc, 5 },
- { 0x6c, "fillSameArc", &Pict2Parser::handleFillSameArc, 5 },
- { 0x6d, "Reserved", &Pict2Parser::handleNOP, 5 },
- { 0x6e, "Reserved", &Pict2Parser::handleNOP, 5 },
- { 0x6f, "Reserved", &Pict2Parser::handleNOP, 5 },
+ { 0x30, "frameRect", &Pict2Parser::handleFrameRect, 10 },
+ { 0x31, "paintRect", &Pict2Parser::handlePaintRect, 10 },
+ { 0x32, "eraseRect", &Pict2Parser::handleEraseRect, 10 },
+ { 0x33, "invertRect", &Pict2Parser::handleInvertRect, 10 },
+ { 0x34, "fillRect", &Pict2Parser::handleFillRect, 10 },
+ { 0x35, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x36, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x38, "frameSameRect", &Pict2Parser::handleFrameSameRect, 2 },
+ { 0x39, "paintSameRect", &Pict2Parser::handlePaintSameRect, 2 },
+ { 0x3a, "eraseSameRect", &Pict2Parser::handleEraseSameRect, 2 },
+ { 0x3b, "invertSameRect", &Pict2Parser::handleInvertSameRect, 2 },
+ { 0x3c, "fillSameRect", &Pict2Parser::handleFillSameRect, 2 },
+ { 0x3d, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x3e, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x3f, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x40, "frameRRect", &Pict2Parser::handleFrameRRect, 10 },
+ { 0x41, "paintRRect", &Pict2Parser::handlePaintRRect, 10 },
+ { 0x42, "eraseRRect", &Pict2Parser::handleEraseRRect, 10 },
+ { 0x43, "invertRRect", &Pict2Parser::handleInvertRRect, 10 },
+ { 0x44, "fillRRect", &Pict2Parser::handleFillRRect, 10 },
+ { 0x45, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x46, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x47, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x48, "frameSameRRect", &Pict2Parser::handleFrameSameRRect, 2 },
+ { 0x49, "paintSameRRect", &Pict2Parser::handlePaintSameRRect, 2 },
+ { 0x4a, "eraseSameRRect", &Pict2Parser::handleEraseSameRRect, 2 },
+ { 0x4b, "invertSameRRect", &Pict2Parser::handleInvertSameRRect, 2 },
+ { 0x4c, "fillSameRRect", &Pict2Parser::handleFillSameRRect, 2 },
+ { 0x4d, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x4e, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x4f, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x50, "frameOval", &Pict2Parser::handleFrameOval, 10 },
+ { 0x51, "paintOval", &Pict2Parser::handlePaintOval, 10 },
+ { 0x52, "eraseOval", &Pict2Parser::handleEraseOval, 10 },
+ { 0x53, "invertOval", &Pict2Parser::handleInsertOval, 10 },
+ { 0x54, "fillOval", &Pict2Parser::handleFillOval, 10 },
+ { 0x55, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x56, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x57, "Reserved", &Pict2Parser::handleNOP, 10 },
+ { 0x58, "frameSameOval", &Pict2Parser::handleFrameSameOval, 2 },
+ { 0x59, "paintSameOval", &Pict2Parser::handlePaintSameOval, 2 },
+ { 0x5a, "eraseSameOval", &Pict2Parser::handleEraseSameOval, 2 },
+ { 0x5b, "invertSameOval", &Pict2Parser::handleInsertSameOval, 2 },
+ { 0x5c, "fillSameOval", &Pict2Parser::handleFillSameOval, 2 },
+ { 0x5d, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x5e, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x5f, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x60, "frameArc", &Pict2Parser::handleFrameArc, 14 },
+ { 0x61, "paintArc", &Pict2Parser::handlePaintArc, 14 },
+ { 0x62, "eraseArc", &Pict2Parser::handleEraseArc, 14 },
+ { 0x63, "invertArc", &Pict2Parser::handleInsertArc, 14 },
+ { 0x64, "fillArc", &Pict2Parser::handleFillArc, 14 },
+ { 0x65, "Reserved", &Pict2Parser::handleNOP, 14 },
+ { 0x66, "Reserved", &Pict2Parser::handleNOP, 14 },
+ { 0x67, "Reserved", &Pict2Parser::handleNOP, 14 },
+ { 0x68, "frameSameArc", &Pict2Parser::handleFrameSameArc, 6 },
+ { 0x69, "paintSameArc", &Pict2Parser::handlePaintSameArc, 6 },
+ { 0x6a, "eraseSameArc", &Pict2Parser::handleEraseSameArc, 6 },
+ { 0x6b, "inverSameArc", &Pict2Parser::handleInsertSameArc, 6 },
+ { 0x6c, "fillSameArc", &Pict2Parser::handleFillSameArc, 6 },
+ { 0x6d, "Reserved", &Pict2Parser::handleNOP, 6 },
+ { 0x6e, "Reserved", &Pict2Parser::handleNOP, 6 },
+ { 0x6f, "Reserved", &Pict2Parser::handleNOP, 6 },
{ 0x70, "framePoly", &Pict2Parser::handleFramePoly, -1 },
{ 0x71, "paintPoly", &Pict2Parser::handlePaintPoly, -1 },
{ 0x72, "erasePoly", &Pict2Parser::handleErasePoly, -1 },
@@ -168,14 +159,14 @@ bool Pict2Parser::parse()
{ 0x75, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x76, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x77, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x78, "frameSamePoly", &Pict2Parser::handleFrameSamePoly, 1 },
- { 0x79, "paintSamePoly", &Pict2Parser::handlePaintSamePoly, 1 },
- { 0x7a, "eraseSamePoly", &Pict2Parser::handleEraseSamePoly, 1 },
- { 0x7b, "invertSamePoly", &Pict2Parser::handleInvertSamePoly, 1 },
- { 0x7c, "fillSamePoly", &Pict2Parser::handleFillSamePoly, 1 },
- { 0x7d, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x7e, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x7f, "Reserved", &Pict2Parser::handleNOP, 1 },
+ { 0x78, "frameSamePoly", &Pict2Parser::handleFrameSamePoly, 2 },
+ { 0x79, "paintSamePoly", &Pict2Parser::handlePaintSamePoly, 2 },
+ { 0x7a, "eraseSamePoly", &Pict2Parser::handleEraseSamePoly, 2 },
+ { 0x7b, "invertSamePoly", &Pict2Parser::handleInvertSamePoly, 2 },
+ { 0x7c, "fillSamePoly", &Pict2Parser::handleFillSamePoly, 2 },
+ { 0x7d, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x7e, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x7f, "Reserved", &Pict2Parser::handleNOP, 2 },
{ 0x80, "frameRgn", &Pict2Parser::handleFrameRgn, -1 },
{ 0x81, "paintRgn", &Pict2Parser::handlePaintRgn, -1 },
{ 0x82, "eraseRgn", &Pict2Parser::handleEraseRgn, -1 },
@@ -184,14 +175,14 @@ bool Pict2Parser::parse()
{ 0x85, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x86, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x87, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x88, "frameSameRgn", &Pict2Parser::handleFrameSameRgn, 1 },
- { 0x89, "paintSameRgn", &Pict2Parser::handlePaintSameRgn, 1 },
- { 0x8a, "eraseSameRgn", &Pict2Parser::handleEraseSameRgn, 1 },
- { 0x8b, "invertSameRgn", &Pict2Parser::handleInvertSameRgn, 1 },
- { 0x8c, "fillSameRgn", &Pict2Parser::handleFillSameRgn, 1 },
- { 0x8d, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x8e, "Reserved", &Pict2Parser::handleNOP, 1 },
- { 0x8f, "Reserved", &Pict2Parser::handleNOP, 1 },
+ { 0x88, "frameSameRgn", &Pict2Parser::handleFrameSameRgn, 2 },
+ { 0x89, "paintSameRgn", &Pict2Parser::handlePaintSameRgn, 2 },
+ { 0x8a, "eraseSameRgn", &Pict2Parser::handleEraseSameRgn, 2 },
+ { 0x8b, "invertSameRgn", &Pict2Parser::handleInvertSameRgn, 2 },
+ { 0x8c, "fillSameRgn", &Pict2Parser::handleFillSameRgn, 2 },
+ { 0x8d, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x8e, "Reserved", &Pict2Parser::handleNOP, 2 },
+ { 0x8f, "Reserved", &Pict2Parser::handleNOP, 2 },
{ 0x90, "BitsRect", &Pict2Parser::handleBitsRect, -1 },
{ 0x91, "BitsRgn", &Pict2Parser::handleBitsRgn, -1 },
{ 0x92, "Reserved", &Pict2Parser::skipData, -1 },
@@ -208,14 +199,15 @@ bool Pict2Parser::parse()
{ 0x9d, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x9e, "Reserved", &Pict2Parser::skipData, -1 },
{ 0x9f, "Reserved", &Pict2Parser::skipData, -1 },
- { 0xa0, "shortComment", &Pict2Parser::handleShortComment, 3 },
+ { 0xa0, "shortComment", &Pict2Parser::handleShortComment, 4 },
{ 0xa1, "longComment", &Pict2Parser::handleLongComment, -1 },
- { 0xff, "EndOfPicture", &Pict2Parser::handleEndOfPicture, 1 }
+ { 0xff, "EndOfPicture", &Pict2Parser::handleEndOfPicture, 2 }
};
while(!m_input->atEOS())
{
+ m_recordSize = -1;
long initialPosition = m_input->tell();
// Opcodes are aligned to 2 bytes
if (initialPosition % 2)
@@ -223,38 +215,55 @@ bool Pict2Parser::parse()
int recordType = readU16();
if (recordType == 0x00ff)
break;
-
- // search function to handler this record
- int index = -1;
- for(int i=0; i < (int)(sizeof(handlers)/sizeof(RecordHandler)); i++)
- {
- if(handlers[i].type == recordType)
- {
- index = i;
- break;
- }
- }
-
- if(index >= 0)
+ else if ((recordType >= 0x00a2) && (recordType <= 0x00af))
+ skipData();
+ else if ((recordType >= 0x00b0) && (recordType <= 0x00cf))
+ m_recordSize = 2;
+ else if ((recordType >= 0x00d0) && (recordType <= 0x00fe))
+ skipLongData();
+ else if ((recordType >= 0x0100) && (recordType <= 0x01ff))
+ m_recordSize = 4;
+ else if (recordType == 0x0200)
+ m_recordSize = 6;
+ else if (recordType == 0x02ff)
+ m_recordSize = 4;
+ else if (recordType == 0x0bff)
+ m_recordSize = 24;
+ else if (recordType == 0x0c00)
+ m_recordSize = 26;
+ else if (recordType == 0x0c01)
+ m_recordSize = 24;
+ /* Add other skipped opcodes here */
+ else
{
- PICT_DEBUG_MSG(("Position: 0x%.8x, Opcode: 0x%.2x, Opcode Name: %s\n", (int)initialPosition, recordType, handlers[index].name));
- m_recordSize = handlers[index].size;
- Method recordHandler = handlers[index].handler;
- if(recordHandler)
+ // search function to handler this record
+ int index = -1;
+ for(int i=0; i < (int)(sizeof(handlers)/sizeof(RecordHandler)); i++)
{
- // invoke the handler for this record
- (this->*recordHandler)();
+ if(handlers[i].type == recordType)
+ {
+ index = i;
+ break;
+ }
}
- if (m_recordSize <= 0) // we were not able to compute variable record size
- return false;
- else
+
+ if(index >= 0)
{
- m_input->seek(initialPosition + m_recordSize, WPX_SEEK_SET);
- m_recordSize = 0;
+ PICT_DEBUG_MSG(("Position: 0x%.8x, Opcode: 0x%.2x, Opcode Name: %s\n", (int)initialPosition, recordType, handlers[index].name));
+ m_recordSize = handlers[index].size;
+ Method recordHandler = handlers[index].handler;
+ if(recordHandler)
+ {
+ // invoke the handler for this record
+ (this->*recordHandler)();
+ }
}
}
- else
+
+ if (m_recordSize <= 0) // we were not able to compute variable record size
return false;
+ else
+ m_input->seek(initialPosition + m_recordSize, WPX_SEEK_SET);
}
return true;
}
@@ -783,6 +792,12 @@ void Pict2Parser::handleDirectBitsRgn()
void Pict2Parser::skipData()
{
- m_recordSize = (int)readU16() + 1;
+ m_recordSize = (int)readU16() + 2 + 2;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+}
+
+void Pict2Parser::skipLongData()
+{
+ m_recordSize = (int)readU32() + 4 + 2;
PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
diff --git a/src/lib/Pict2Parser.h b/src/lib/Pict2Parser.h
index 26c7762..a09c49e 100644
--- a/src/lib/Pict2Parser.h
+++ b/src/lib/Pict2Parser.h
@@ -1,7 +1,5 @@
/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
+ * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -17,19 +15,12 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
*/
#ifndef __PICT2PARSER_H__
#define __PICT2PARSER_H__
#include "PictXParser.h"
-#include "PictDashArray.h"
#include "PictBitmap.h"
#include <libwpd/libwpd.h>
@@ -172,6 +163,7 @@ private:
void handleEndOfPicture();
void skipData();
+ void skipLongData();
int m_recordSize;
};
diff --git a/src/lib/PictDashArray.cpp b/src/lib/PictDashArray.cpp
deleted file mode 100644
index c294512..0000000
--- a/src/lib/PictDashArray.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "PictDashArray.h"
-
-#include <vector>
-
-namespace libpict
-{
-class PictDashArrayPrivate
-{
-public:
- PictDashArrayPrivate() : dashes(std::vector<double>()) {};
- std::vector<double> dashes;
-};
-}
-
-libpict::PictDashArray::PictDashArray() : d(new libpict::PictDashArrayPrivate())
-{
-}
-
-libpict::PictDashArray::~PictDashArray()
-{
- delete d;
-}
-
-libpict::PictDashArray::PictDashArray(const libpict::PictDashArray& dash):
- d(new libpict::PictDashArrayPrivate())
-{
- d->dashes = dash.d->dashes;
-}
-
-libpict::PictDashArray& libpict::PictDashArray::operator=(const libpict::PictDashArray& dash)
-{
- d->dashes = dash.d->dashes;
- return *this;
-}
-
-unsigned libpict::PictDashArray::count() const
-{
- return d->dashes.size();
-}
-
-double libpict::PictDashArray::at(unsigned i) const
-{
- return d->dashes[i];
-}
-
-void libpict::PictDashArray::add(double p)
-{
- d->dashes.push_back(p);
-}
diff --git a/src/lib/PictDashArray.h b/src/lib/PictDashArray.h
deleted file mode 100644
index 2119652..0000000
--- a/src/lib/PictDashArray.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __PICTDASHARRAY_H__
-#define __PICTDASHARRAY_H__
-
-namespace libpict
-{
-
-class PictDashArrayPrivate;
-
-class PictDashArray
-{
-public:
- PictDashArray();
- ~PictDashArray();
- PictDashArray(const PictDashArray&);
- PictDashArray& operator=(const PictDashArray&);
- unsigned count() const;
- double at(unsigned i) const;
- void add(double p);
-
-private:
- PictDashArrayPrivate *d;
-};
-
-} // namespace libpict
-
-
-#endif // __PICTDASHARRAY_H__
diff --git a/src/lib/PictGradient.cpp b/src/lib/PictGradient.cpp
deleted file mode 100644
index f408833..0000000
--- a/src/lib/PictGradient.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "PictGradient.h"
-
-#include <vector>
-
-namespace libpict
-{
-
-class PictGradientStop
-{
-public:
- double offset;
- ::WPXString color;
- double opacity;
-
- PictGradientStop(): offset(0), color("#000000"), opacity(1.0) {}
-
- PictGradientStop(double ofs, const ::WPXString& c, double opa): offset(ofs), color(c), opacity(opa) {}
-};
-
-class PictGradientPrivate
-{
-public:
- PictGradientPrivate() :
- gradientStops() {};
-
- std::vector<PictGradientStop> gradientStops;
-};
-
-} // namespace libpict
-
-libpict::PictGradient::PictGradient() :
- d(new PictGradientPrivate())
-{
-}
-
-libpict::PictGradient::~PictGradient()
-{
- delete d;
-}
-
-libpict::PictGradient::PictGradient(const libpict::PictGradient& g) :
- d(new libpict::PictGradientPrivate())
-{
- d->gradientStops = g.d->gradientStops;
-}
-
-libpict::PictGradient& libpict::PictGradient::operator=(const libpict::PictGradient& g)
-{
- d->gradientStops = g.d->gradientStops;
- return *this;
-}
-
-unsigned libpict::PictGradient::count() const
-{
- return d->gradientStops.size();
-}
-
-double libpict::PictGradient::stopOffset(unsigned index) const
-{
- return d->gradientStops[index].offset;
-}
-
-::WPXString libpict::PictGradient::stopColor(unsigned index) const
-{
- return d->gradientStops[index].color;
-}
-
-double libpict::PictGradient::stopOpacity(unsigned index) const
-{
- return d->gradientStops[index].opacity;
-}
-
-void libpict::PictGradient::addStop(double offset, const ::WPXString& color, double opacity)
-{
- libpict::PictGradientStop stop(offset, color, opacity);
- d->gradientStops.push_back(stop);
-}
diff --git a/src/lib/PictHeader.cpp b/src/lib/PictHeader.cpp
index bc599b7..2949057 100644
--- a/src/lib/PictHeader.cpp
+++ b/src/lib/PictHeader.cpp
@@ -1,6 +1,5 @@
/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
+ * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,12 +15,6 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
*/
#include "PictHeader.h"
@@ -36,7 +29,6 @@ unsigned char readU8(WPXInputStream *input)
if (numBytesRead != sizeof(unsigned char))
;
- PICT_DEBUG_MSG(("readU8: 0x%.2x\n",*(unsigned char const *)(p)));
return *(unsigned char const *)(p);
}
@@ -47,9 +39,7 @@ unsigned short readU16(WPXInputStream *input)
if (numBytesRead != sizeof(unsigned short))
;
- unsigned short val = (unsigned short)((((unsigned char const *)(p))[1] << 0) | (((unsigned char const *)(p))[0] << 8));
- PICT_DEBUG_MSG(("readU16: 0x%.4x\n", val));
- return val;
+ return (unsigned short)((((unsigned char const *)(p))[1] << 0) | (((unsigned char const *)(p))[0] << 8));
}
unsigned readU32(WPXInputStream *input)
@@ -58,10 +48,8 @@ unsigned readU32(WPXInputStream *input)
unsigned const *p = (unsigned int const *)input->read(sizeof(unsigned int), numBytesRead);
if (numBytesRead != sizeof(unsigned int))
;
- unsigned val = (unsigned)((((unsigned char const *)(p))[3] << 0) | (((unsigned char const *)(p))[2] << 8) |
+ return (unsigned)((((unsigned char const *)(p))[3] << 0) | (((unsigned char const *)(p))[2] << 8) |
(((unsigned char const *)(p))[1] << 16) | (((unsigned char const *)(p))[0] << 24));
- PICT_DEBUG_MSG(("readU32: 0x%.8x\n", val));
- return val;
}
}
@@ -163,7 +151,7 @@ bool PictHeader::loadPict2Header(WPXInputStream *input)
return false;
}
else
- input->seek(24, WPX_SEEK_SET);
+ input->seek(24, WPX_SEEK_CUR);
PICT_DEBUG_MSG(("Pict2Header: fileSize = 0x%.4x, top = 0x%.4x, left = 0x%.4x, bottom = 0x%.4x, right = 0x%.4x\n", m_fileSize, m_top, m_left, m_bottom, m_right));
m_dataStart = input->tell();
input->seek(0, WPX_SEEK_SET);
diff --git a/src/lib/PictHeader.h b/src/lib/PictHeader.h
index dfe0ac1..1c04f99 100644
--- a/src/lib/PictHeader.h
+++ b/src/lib/PictHeader.h
@@ -15,12 +15,6 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
*/
#ifndef __PICTHEADER_H__
diff --git a/src/lib/PictImage.cpp b/src/lib/PictImage.cpp
index 49e5b80..3b9e71f 100644
--- a/src/lib/PictImage.cpp
+++ b/src/lib/PictImage.cpp
@@ -1,6 +1,5 @@
/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2007 Fridrich Strba (fridrich.strba@bluewin.ch)
+ * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,12 +15,6 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
*/
#include "PictImage.h"
diff --git a/src/lib/PictSVGGenerator.cpp b/src/lib/PictSVGGenerator.cpp
index 392e718..5d28b24 100644
--- a/src/lib/PictSVGGenerator.cpp
+++ b/src/lib/PictSVGGenerator.cpp
@@ -1,6 +1,5 @@
/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
+ * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,12 +15,6 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
*/
#include "PictSVGGenerator.h"
diff --git a/src/lib/PictXParser.cpp b/src/lib/PictXParser.cpp
index e9b208d..a1f00be 100644
--- a/src/lib/PictXParser.cpp
+++ b/src/lib/PictXParser.cpp
@@ -1,7 +1,5 @@
/* libpict
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
+ * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -17,14 +15,8 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
- *
- * For further information visit http://libpict.sourceforge.net
*/
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
#include "PictXParser.h"
#include "libpict_utils.h"