summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-06-18 22:35:59 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2013-06-18 22:35:59 +0200
commit1c830dcf93a2001e8bbfff59c694097e196e1c66 (patch)
tree1f29068439296816c56ef2997e336a771d52c439
parentfd47806ce4c94eab2513da5b5aab2a8c2be7a218 (diff)
Reformat (astyle -b -k3 -y -n -s2 -r \*.h \*.cpp)
-rw-r--r--inc/libpict/PictImage.h6
-rw-r--r--inc/libpict/libpict.h2
-rw-r--r--src/conv/raw/pict2raw.cpp218
-rw-r--r--src/conv/svg/pict2svg.cpp86
-rw-r--r--src/lib/Pict1Parser.cpp510
-rw-r--r--src/lib/Pict1Parser.h236
-rw-r--r--src/lib/Pict2Parser.cpp660
-rw-r--r--src/lib/Pict2Parser.h266
-rw-r--r--src/lib/PictBitmap.cpp290
-rw-r--r--src/lib/PictBitmap.h34
-rw-r--r--src/lib/PictColor.cpp50
-rw-r--r--src/lib/PictColor.h16
-rw-r--r--src/lib/PictHeader.cpp234
-rw-r--r--src/lib/PictHeader.h92
-rw-r--r--src/lib/PictImage.cpp84
-rw-r--r--src/lib/PictSVGGenerator.cpp424
-rw-r--r--src/lib/PictSVGGenerator.h56
-rw-r--r--src/lib/PictXParser.cpp98
-rw-r--r--src/lib/PictXParser.h30
19 files changed, 1696 insertions, 1696 deletions
diff --git a/inc/libpict/PictImage.h b/inc/libpict/PictImage.h
index 9e10e5e..4c46723 100644
--- a/inc/libpict/PictImage.h
+++ b/inc/libpict/PictImage.h
@@ -37,11 +37,11 @@ class PictImage
{
public:
- static bool isSupported(WPXInputStream *input);
+ static bool isSupported(WPXInputStream *input);
- static bool parse(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
+ static bool parse(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
- static bool generateSVG(WPXInputStream *input, WPXString &output);
+ static bool generateSVG(WPXInputStream *input, WPXString &output);
};
} // namespace libpict
diff --git a/inc/libpict/libpict.h b/inc/libpict/libpict.h
index 927b983..9ec2037 100644
--- a/inc/libpict/libpict.h
+++ b/inc/libpict/libpict.h
@@ -14,7 +14,7 @@
*
* 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,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1301 USA
*
* For further information visit http://libpict.sourceforge.net
diff --git a/src/conv/raw/pict2raw.cpp b/src/conv/raw/pict2raw.cpp
index 7c1a72b..89625c0 100644
--- a/src/conv/raw/pict2raw.cpp
+++ b/src/conv/raw/pict2raw.cpp
@@ -43,77 +43,77 @@
class RawPainter : public libwpg::WPGPaintInterface
{
public:
- RawPainter();
-
- void startGraphics(const ::WPXPropertyList &propList);
- void endGraphics();
- void startLayer(const ::WPXPropertyList &propList);
- void endLayer();
- void startEmbeddedGraphics(const ::WPXPropertyList &propList);
- void endEmbeddedGraphics();
-
- void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
-
- void drawRectangle(const ::WPXPropertyList &propList);
- void drawEllipse(const ::WPXPropertyList &propList);
- void drawPolyline(const ::WPXPropertyListVector &vertices);
- void drawPolygon(const ::WPXPropertyListVector &vertices);
- void drawPath(const ::WPXPropertyListVector &path);
- void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
- void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
- void endTextObject();
- void startTextLine(const ::WPXPropertyList &propList);
- void endTextLine();
- void startTextSpan(const ::WPXPropertyList &propList);
- void endTextSpan();
- void insertText(const ::WPXString &str);
+ RawPainter();
+
+ void startGraphics(const ::WPXPropertyList &propList);
+ void endGraphics();
+ void startLayer(const ::WPXPropertyList &propList);
+ void endLayer();
+ void startEmbeddedGraphics(const ::WPXPropertyList &propList);
+ void endEmbeddedGraphics();
+
+ void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
+
+ void drawRectangle(const ::WPXPropertyList &propList);
+ void drawEllipse(const ::WPXPropertyList &propList);
+ void drawPolyline(const ::WPXPropertyListVector &vertices);
+ void drawPolygon(const ::WPXPropertyListVector &vertices);
+ void drawPath(const ::WPXPropertyListVector &path);
+ void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
+ void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
+ void endTextObject();
+ void startTextLine(const ::WPXPropertyList &propList);
+ void endTextLine();
+ void startTextSpan(const ::WPXPropertyList &propList);
+ void endTextSpan();
+ void insertText(const ::WPXString &str);
};
WPXString getPropString(const WPXPropertyList &propList)
{
- WPXString propString;
- WPXPropertyList::Iter i(propList);
- if (!i.last())
- {
- propString.append(i.key());
- propString.append(": ");
- propString.append(i()->getStr().cstr());
- for (; i.next(); )
- {
- propString.append(", ");
- propString.append(i.key());
- propString.append(": ");
- propString.append(i()->getStr().cstr());
- }
- }
-
- return propString;
+ WPXString propString;
+ WPXPropertyList::Iter i(propList);
+ if (!i.last())
+ {
+ propString.append(i.key());
+ propString.append(": ");
+ propString.append(i()->getStr().cstr());
+ for (; i.next(); )
+ {
+ propString.append(", ");
+ propString.append(i.key());
+ propString.append(": ");
+ propString.append(i()->getStr().cstr());
+ }
+ }
+
+ return propString;
}
WPXString getPropString(const WPXPropertyListVector &itemList)
{
- WPXString propString;
+ WPXString propString;
- propString.append("(");
- WPXPropertyListVector::Iter i(itemList);
+ propString.append("(");
+ WPXPropertyListVector::Iter i(itemList);
- if (!i.last())
- {
- propString.append("(");
- propString.append(getPropString(i()));
- propString.append(")");
+ if (!i.last())
+ {
+ propString.append("(");
+ propString.append(getPropString(i()));
+ propString.append(")");
- for (; i.next();)
- {
- propString.append(", (");
- propString.append(getPropString(i()));
- propString.append(")");
- }
+ for (; i.next();)
+ {
+ propString.append(", (");
+ propString.append(getPropString(i()));
+ propString.append(")");
+ }
- }
- propString.append(")");
+ }
+ propString.append(")");
- return propString;
+ return propString;
}
RawPainter::RawPainter(): libwpg::WPGPaintInterface()
@@ -122,102 +122,102 @@ RawPainter::RawPainter(): libwpg::WPGPaintInterface()
void RawPainter::startGraphics(const ::WPXPropertyList &propList)
{
- printf("RawPainter::startGraphics(%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::startGraphics(%s)\n", getPropString(propList).cstr());
}
void RawPainter::endGraphics()
{
- printf("RawPainter::endGraphics\n");
+ printf("RawPainter::endGraphics\n");
}
void RawPainter::startLayer(const ::WPXPropertyList &propList)
{
- printf("RawPainter::startLayer (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::startLayer (%s)\n", getPropString(propList).cstr());
}
void RawPainter::endLayer()
{
- printf("RawPainter::endLayer\n");
+ printf("RawPainter::endLayer\n");
}
void RawPainter::startEmbeddedGraphics(const ::WPXPropertyList &propList)
{
- printf("RawPainter::startEmbeddedGraphics (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::startEmbeddedGraphics (%s)\n", getPropString(propList).cstr());
}
void RawPainter::endEmbeddedGraphics()
{
- printf("RawPainter::endEmbeddedGraphics \n");
+ printf("RawPainter::endEmbeddedGraphics \n");
}
void RawPainter::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient)
{
- printf("RawPainter::setStyle(%s, gradient: (%s))\n", getPropString(propList).cstr(), getPropString(gradient).cstr());
+ printf("RawPainter::setStyle(%s, gradient: (%s))\n", getPropString(propList).cstr(), getPropString(gradient).cstr());
}
void RawPainter::drawRectangle(const ::WPXPropertyList &propList)
{
- printf("RawPainter::drawRectangle (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::drawRectangle (%s)\n", getPropString(propList).cstr());
}
void RawPainter::drawEllipse(const ::WPXPropertyList &propList)
{
- printf("RawPainter::drawEllipse (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::drawEllipse (%s)\n", getPropString(propList).cstr());
}
void RawPainter::drawPolyline(const ::WPXPropertyListVector &vertices)
{
- printf("RawPainter::drawPolyline (%s)\n", getPropString(vertices).cstr());
+ printf("RawPainter::drawPolyline (%s)\n", getPropString(vertices).cstr());
}
void RawPainter::drawPolygon(const ::WPXPropertyListVector &vertices)
{
- printf("RawPainter::drawPolygon (%s)\n", getPropString(vertices).cstr());
+ printf("RawPainter::drawPolygon (%s)\n", getPropString(vertices).cstr());
}
void RawPainter::drawPath(const ::WPXPropertyListVector &path)
{
- printf("RawPainter::drawPath (%s)\n", getPropString(path).cstr());
+ printf("RawPainter::drawPath (%s)\n", getPropString(path).cstr());
}
void RawPainter::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData & /*binaryData*/)
{
- printf("RawPainter::drawGraphicObject (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::drawGraphicObject (%s)\n", getPropString(propList).cstr());
}
void RawPainter::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path)
{
- printf("RawPainter::startTextObject (%s, path: (%s))\n", getPropString(propList).cstr(), getPropString(path).cstr());
+ printf("RawPainter::startTextObject (%s, path: (%s))\n", getPropString(propList).cstr(), getPropString(path).cstr());
}
void RawPainter::endTextObject()
{
- printf("RawPainter::endTextObject\n");
+ printf("RawPainter::endTextObject\n");
}
void RawPainter::startTextLine(const ::WPXPropertyList &propList)
{
- printf("RawPainter::startTextLine (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::startTextLine (%s)\n", getPropString(propList).cstr());
}
void RawPainter::endTextLine()
{
- printf("RawPainter::endTextLine\n");
+ printf("RawPainter::endTextLine\n");
}
void RawPainter::startTextSpan(const ::WPXPropertyList &propList)
{
- printf("RawPainter::startTextSpan (%s)\n", getPropString(propList).cstr());
+ printf("RawPainter::startTextSpan (%s)\n", getPropString(propList).cstr());
}
void RawPainter::endTextSpan()
{
- printf("RawPainter::endTextSpan\n");
+ printf("RawPainter::endTextSpan\n");
}
void RawPainter::insertText(const ::WPXString &str)
{
- printf("RawPainter::insertText (%s)\n", str.cstr());
+ printf("RawPainter::insertText (%s)\n", str.cstr());
}
@@ -226,53 +226,53 @@ namespace
int printUsage()
{
- printf("Usage: pict2raw [OPTION] <WordPerfect Graphics File>\n");
- printf("\n");
- printf("Options:\n");
- printf("--help Shows this help message\n");
- printf("--version Output pict2raw version \n");
- return -1;
+ printf("Usage: pict2raw [OPTION] <WordPerfect Graphics File>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--help Shows this help message\n");
+ printf("--version Output pict2raw version \n");
+ return -1;
}
int printVersion()
{
- printf("pict2raw %s\n", VERSION);
- return 0;
+ printf("pict2raw %s\n", VERSION);
+ return 0;
}
} // anonymous namespace
int main(int argc, char *argv[])
{
- if (argc < 2)
- return printUsage();
+ if (argc < 2)
+ return printUsage();
- char *file = 0;
+ char *file = 0;
- for (int i = 1; i < argc; i++)
- {
- if (!strcmp(argv[i], "--version"))
- return printVersion();
- else if (!file && strncmp(argv[i], "--", 2))
- file = argv[i];
- else
- return printUsage();
- }
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
+ }
- if (!file)
- return printUsage();
+ if (!file)
+ return printUsage();
- WPXFileStream input(file);
+ WPXFileStream input(file);
- if (!libpict::PictImage::isSupported(&input))
- {
- fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
- return 1;
- }
+ if (!libpict::PictImage::isSupported(&input))
+ {
+ fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
+ return 1;
+ }
- RawPainter painter;
- libpict::PictImage::parse(&input, &painter);
+ RawPainter painter;
+ libpict::PictImage::parse(&input, &painter);
- return 0;
+ return 0;
}
diff --git a/src/conv/svg/pict2svg.cpp b/src/conv/svg/pict2svg.cpp
index 14038a0..28e7e69 100644
--- a/src/conv/svg/pict2svg.cpp
+++ b/src/conv/svg/pict2svg.cpp
@@ -44,57 +44,57 @@ namespace
int printUsage()
{
- printf("Usage: pict2svg [OPTION] <WordPerfect Graphics File>\n");
- printf("\n");
- printf("Options:\n");
- printf("--help Shows this help message\n");
- printf("--version Output pict2svg version \n");
- return -1;
+ printf("Usage: pict2svg [OPTION] <WordPerfect Graphics File>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--help Shows this help message\n");
+ printf("--version Output pict2svg version \n");
+ return -1;
}
int printVersion()
{
- printf("pict2svg %s\n", VERSION);
- return 0;
+ printf("pict2svg %s\n", VERSION);
+ 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++)
- {
- if (!strcmp(argv[i], "--version"))
- return printVersion();
- else if (!file && strncmp(argv[i], "--", 2))
- file = argv[i];
- else
- return printUsage();
- }
-
- if (!file)
- return printUsage();
-
- WPXFileStream input(file);
-
- if (!libpict::PictImage::isSupported(&input))
- {
- std::cerr << "ERROR: Unsupported file format (unsupported version) or file is encrypted!" << std::endl;
- return 1;
- }
-
- ::WPXString output;
- if (!libpict::PictImage::generateSVG(&input, output))
- {
- std::cerr << "ERROR: SVG Generation failed!" << std::endl;
- return 1;
- }
-
- std::cout << output.cstr() << std::endl;
- return 0;
+ if (argc < 2)
+ return printUsage();
+
+ char *file = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
+ }
+
+ if (!file)
+ return printUsage();
+
+ WPXFileStream input(file);
+
+ if (!libpict::PictImage::isSupported(&input))
+ {
+ std::cerr << "ERROR: Unsupported file format (unsupported version) or file is encrypted!" << std::endl;
+ return 1;
+ }
+
+ ::WPXString output;
+ if (!libpict::PictImage::generateSVG(&input, output))
+ {
+ std::cerr << "ERROR: SVG Generation failed!" << std::endl;
+ return 1;
+ }
+
+ std::cout << output.cstr() << std::endl;
+ return 0;
}
diff --git a/src/lib/Pict1Parser.cpp b/src/lib/Pict1Parser.cpp
index 2661d99..3168457 100644
--- a/src/lib/Pict1Parser.cpp
+++ b/src/lib/Pict1Parser.cpp
@@ -24,178 +24,178 @@
#include <libwpg/libwpg.h>
Pict1Parser::Pict1Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter):
- PictXParser(input, painter),
- m_recordSize(0)
+ PictXParser(input, painter),
+ m_recordSize(0)
{
}
bool Pict1Parser::parse()
{
- typedef void (Pict1Parser::*Method)();
-
- struct RecordHandler
- {
- int type;
- const char *name;
- Method handler;
- int size;
- };
-
- static const struct RecordHandler handlers[] =
- {
- { 0x00, "NOP", &Pict1Parser::handleNOP, 1 },
- { 0x01, "clipRgn", &Pict1Parser::handleClipRgn, -1 },
- { 0x02, "bkPat", &Pict1Parser::handleBkPat, 9 },
- { 0x03, "txFont", &Pict1Parser::handleTxFont, 3 },
- { 0x04, "txFace", &Pict1Parser::handleTxFace, 2 },
- { 0x05, "txMode", &Pict1Parser::handleTxMode, 3 },
- { 0x06, "spExtra", &Pict1Parser::handleSpExtra, 5 },
- { 0x07, "pnSize", &Pict1Parser::handlePnSize, 5 },
- { 0x08, "pnMode", &Pict1Parser::handlePnMode, 3 },
- { 0x09, "pnPat", &Pict1Parser::handlePnPat, 9 },
- { 0x0a, "thePat", &Pict1Parser::handleThePat, 9 },
- { 0x0b, "owSize", &Pict1Parser::handleOwSize, 5 },
- { 0x0c, "origin", &Pict1Parser::handleOrigin, 5 },
- { 0x0d, "txSize", &Pict1Parser::handleTxSize, 3 },
- { 0x0e, "fgColor", &Pict1Parser::handleFgColor, 5 },
- { 0x0f, "bkColor", &Pict1Parser::handleBkColor, 5 },
- { 0x10, "txRatio", &Pict1Parser::handleTxRatio, 9 },
- { 0x11, "picVersion", &Pict1Parser::handlePicVersion, 2 },
-
- { 0x20, "line", &Pict1Parser::handleLine, 9 },
- { 0x21, "line from", &Pict1Parser::handleLineFrom, 5 },
- { 0x22, "short line", &Pict1Parser::handleShortLine, 7 },
- { 0x23, "short line from", &Pict1Parser::handleShortLineFrom, 3 },
-
- { 0x28, "long text", &Pict1Parser::handleLongText, -1 },
- { 0x29, "DH text", &Pict1Parser::handleDHText, -1 },
- { 0x2a, "DV text", &Pict1Parser::handleDVText, -1 },
- { 0x2b, "DHDV text", &Pict1Parser::handleDHDVText, -1 },
-
- { 0x30, "frameRect", &Pict1Parser::handleFrameRect, 9 },
- { 0x31, "paintRect", &Pict1Parser::handlePaintRect, 9 },
- { 0x32, "eraseRect", &Pict1Parser::handleEraseRect, 9 },
- { 0x33, "invertRect", &Pict1Parser::handleInvertRect, 9 },
- { 0x34, "fillRect", &Pict1Parser::handleFillRect, 9 },
-
- { 0x38, "frameSameRect", &Pict1Parser::handleFrameSameRect, 1 },
- { 0x39, "paintSameRect", &Pict1Parser::handlePaintSameRect, 1 },
- { 0x3a, "eraseSameRect", &Pict1Parser::handleEraseSameRect, 1 },
- { 0x3b, "invertSameRect", &Pict1Parser::handleInvertSameRect, 1 },
- { 0x3c, "fillSameRect", &Pict1Parser::handleFillSameRect, 1 },
-
- { 0x40, "frameRRect", &Pict1Parser::handleFrameRRect, 9 },
- { 0x41, "paintRRect", &Pict1Parser::handlePaintRRect, 9 },
- { 0x42, "eraseRRect", &Pict1Parser::handleEraseRRect, 9 },
- { 0x43, "invertRRect", &Pict1Parser::handleInvertRRect, 9 },
- { 0x44, "fillRRect", &Pict1Parser::handleFillRRect, 9 },
-
- { 0x48, "frameSameRRect", &Pict1Parser::handleFrameSameRRect, 1 },
- { 0x49, "paintSameRRect", &Pict1Parser::handlePaintSameRRect, 1 },
- { 0x4a, "eraseSameRRect", &Pict1Parser::handleEraseSameRRect, 1 },
- { 0x4b, "invertSameRRect", &Pict1Parser::handleInvertSameRRect, 1 },
- { 0x4c, "fillSameRRect", &Pict1Parser::handleFillSameRRect, 1 },
-
- { 0x50, "frameOval", &Pict1Parser::handleFrameOval, 9 },
- { 0x51, "paintOval", &Pict1Parser::handlePaintOval, 9 },
- { 0x52, "eraseOval", &Pict1Parser::handleEraseOval, 9 },
- { 0x53, "invertOval", &Pict1Parser::handleInsertOval, 9 },
- { 0x54, "fillOval", &Pict1Parser::handleFillOval, 9 },
-
- { 0x58, "frameSameOval", &Pict1Parser::handleFrameSameOval, 1 },
- { 0x59, "paintSameOval", &Pict1Parser::handlePaintSameOval, 1 },
- { 0x5a, "eraseSameOval", &Pict1Parser::handleEraseSameOval, 1 },
- { 0x5b, "invertSameOval", &Pict1Parser::handleInsertSameOval, 1 },
- { 0x5c, "fillSameOval", &Pict1Parser::handleFillSameOval, 1 },
-
- { 0x60, "frameArc", &Pict1Parser::handleFrameArc, 13 },
- { 0x61, "paintArc", &Pict1Parser::handlePaintArc, 13 },
- { 0x62, "eraseArc", &Pict1Parser::handleEraseArc, 13 },
- { 0x63, "invertArc", &Pict1Parser::handleInsertArc, 13 },
- { 0x64, "fillArc", &Pict1Parser::handleFillArc, 13 },
-
- { 0x68, "frameSameArc", &Pict1Parser::handleFrameSameArc, 5 },
- { 0x69, "paintSameArc", &Pict1Parser::handlePaintSameArc, 5 },
- { 0x6a, "eraseSameArc", &Pict1Parser::handleEraseSameArc, 5 },
- { 0x6b, "inverSameArc", &Pict1Parser::handleInsertSameArc, 5 },
- { 0x6c, "fillSameArc", &Pict1Parser::handleFillSameArc, 5 },
-
- { 0x70, "framePoly", &Pict1Parser::handleFramePoly, -1 },
- { 0x71, "paintPoly", &Pict1Parser::handlePaintPoly, -1 },
- { 0x72, "erasePoly", &Pict1Parser::handleErasePoly, -1 },
- { 0x73, "invertPoly", &Pict1Parser::handleInvertPoly, -1 },
- { 0x74, "fillPoly", &Pict1Parser::handleFillPoly, -1 },
-
- { 0x78, "frameSamePoly", &Pict1Parser::handleFrameSamePoly, 1 },
- { 0x79, "paintSamePoly", &Pict1Parser::handlePaintSamePoly, 1 },
- { 0x7a, "eraseSamePoly", &Pict1Parser::handleEraseSamePoly, 1 },
- { 0x7b, "invertSamePoly", &Pict1Parser::handleInvertSamePoly, 1 },
- { 0x7c, "fillSamePoly", &Pict1Parser::handleFillSamePoly, 1 },
-
- { 0x80, "frameRgn", &Pict1Parser::handleFrameRgn, -1 },
- { 0x81, "paintRgn", &Pict1Parser::handlePaintRgn, -1 },
- { 0x82, "eraseRgn", &Pict1Parser::handleEraseRgn, -1 },
- { 0x83, "invertRgn", &Pict1Parser::handleInvertRgn, -1 },
- { 0x84, "fillRgn", &Pict1Parser::handleFillRgn, -1 },
-
- { 0x88, "frameSameRgn", &Pict1Parser::handleFrameSameRgn, 1 },
- { 0x89, "paintSameRgn", &Pict1Parser::handlePaintSameRgn, 1 },
- { 0x8a, "eraseSameRgn", &Pict1Parser::handleEraseSameRgn, 1 },
- { 0x8b, "invertSameRgn", &Pict1Parser::handleInvertSameRgn, 1 },
- { 0x8c, "fillSameRgn", &Pict1Parser::handleFillSameRgn, 1 },
-
- { 0x90, "BitsRect", &Pict1Parser::handleBitsRect, -1 },
- { 0x91, "BitsRgn", &Pict1Parser::handleBitsRgn, -1 },
-
- { 0x98, "PackBitsRect", &Pict1Parser::handlePackBitsRect, -1 },
- { 0x99, "PackBitsRgn", &Pict1Parser::handlePackBitsRgn, -1 },
-
- { 0xa0, "shortComment", &Pict1Parser::handleShortComment, 3 },
- { 0xa1, "longComment", &Pict1Parser::handleLongComment, -1 },
-
- { 0xff, "EndOfPicture", &Pict1Parser::handleEndOfPicture, 1 }
- };
-
- while(!m_input->atEOS())
- {
- long initialPosition = m_input->tell();
- int recordType = readU8();
- if (recordType == 0xff)
- 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)
- {
- 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)();
- }
- 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);
- m_recordSize = 0;
- }
- }
- else
- return false;
- }
- return true;
+ typedef void (Pict1Parser::*Method)();
+
+ struct RecordHandler
+ {
+ int type;
+ const char *name;
+ Method handler;
+ int size;
+ };
+
+ static const struct RecordHandler handlers[] =
+ {
+ { 0x00, "NOP", &Pict1Parser::handleNOP, 1 },
+ { 0x01, "clipRgn", &Pict1Parser::handleClipRgn, -1 },
+ { 0x02, "bkPat", &Pict1Parser::handleBkPat, 9 },
+ { 0x03, "txFont", &Pict1Parser::handleTxFont, 3 },
+ { 0x04, "txFace", &Pict1Parser::handleTxFace, 2 },
+ { 0x05, "txMode", &Pict1Parser::handleTxMode, 3 },
+ { 0x06, "spExtra", &Pict1Parser::handleSpExtra, 5 },
+ { 0x07, "pnSize", &Pict1Parser::handlePnSize, 5 },
+ { 0x08, "pnMode", &Pict1Parser::handlePnMode, 3 },
+ { 0x09, "pnPat", &Pict1Parser::handlePnPat, 9 },
+ { 0x0a, "thePat", &Pict1Parser::handleThePat, 9 },
+ { 0x0b, "owSize", &Pict1Parser::handleOwSize, 5 },
+ { 0x0c, "origin", &Pict1Parser::handleOrigin, 5 },
+ { 0x0d, "txSize", &Pict1Parser::handleTxSize, 3 },
+ { 0x0e, "fgColor", &Pict1Parser::handleFgColor, 5 },
+ { 0x0f, "bkColor", &Pict1Parser::handleBkColor, 5 },
+ { 0x10, "txRatio", &Pict1Parser::handleTxRatio, 9 },
+ { 0x11, "picVersion", &Pict1Parser::handlePicVersion, 2 },
+
+ { 0x20, "line", &Pict1Parser::handleLine, 9 },
+ { 0x21, "line from", &Pict1Parser::handleLineFrom, 5 },
+ { 0x22, "short line", &Pict1Parser::handleShortLine, 7 },
+ { 0x23, "short line from", &Pict1Parser::handleShortLineFrom, 3 },
+
+ { 0x28, "long text", &Pict1Parser::handleLongText, -1 },
+ { 0x29, "DH text", &Pict1Parser::handleDHText, -1 },
+ { 0x2a, "DV text", &Pict1Parser::handleDVText, -1 },
+ { 0x2b, "DHDV text", &Pict1Parser::handleDHDVText, -1 },
+
+ { 0x30, "frameRect", &Pict1Parser::handleFrameRect, 9 },
+ { 0x31, "paintRect", &Pict1Parser::handlePaintRect, 9 },
+ { 0x32, "eraseRect", &Pict1Parser::handleEraseRect, 9 },
+ { 0x33, "invertRect", &Pict1Parser::handleInvertRect, 9 },
+ { 0x34, "fillRect", &Pict1Parser::handleFillRect, 9 },
+
+ { 0x38, "frameSameRect", &Pict1Parser::handleFrameSameRect, 1 },
+ { 0x39, "paintSameRect", &Pict1Parser::handlePaintSameRect, 1 },
+ { 0x3a, "eraseSameRect", &Pict1Parser::handleEraseSameRect, 1 },
+ { 0x3b, "invertSameRect", &Pict1Parser::handleInvertSameRect, 1 },
+ { 0x3c, "fillSameRect", &Pict1Parser::handleFillSameRect, 1 },
+
+ { 0x40, "frameRRect", &Pict1Parser::handleFrameRRect, 9 },
+ { 0x41, "paintRRect", &Pict1Parser::handlePaintRRect, 9 },
+ { 0x42, "eraseRRect", &Pict1Parser::handleEraseRRect, 9 },
+ { 0x43, "invertRRect", &Pict1Parser::handleInvertRRect, 9 },
+ { 0x44, "fillRRect", &Pict1Parser::handleFillRRect, 9 },
+
+ { 0x48, "frameSameRRect", &Pict1Parser::handleFrameSameRRect, 1 },
+ { 0x49, "paintSameRRect", &Pict1Parser::handlePaintSameRRect, 1 },
+ { 0x4a, "eraseSameRRect", &Pict1Parser::handleEraseSameRRect, 1 },
+ { 0x4b, "invertSameRRect", &Pict1Parser::handleInvertSameRRect, 1 },
+ { 0x4c, "fillSameRRect", &Pict1Parser::handleFillSameRRect, 1 },
+
+ { 0x50, "frameOval", &Pict1Parser::handleFrameOval, 9 },
+ { 0x51, "paintOval", &Pict1Parser::handlePaintOval, 9 },
+ { 0x52, "eraseOval", &Pict1Parser::handleEraseOval, 9 },
+ { 0x53, "invertOval", &Pict1Parser::handleInsertOval, 9 },
+ { 0x54, "fillOval", &Pict1Parser::handleFillOval, 9 },
+
+ { 0x58, "frameSameOval", &Pict1Parser::handleFrameSameOval, 1 },
+ { 0x59, "paintSameOval", &Pict1Parser::handlePaintSameOval, 1 },
+ { 0x5a, "eraseSameOval", &Pict1Parser::handleEraseSameOval, 1 },
+ { 0x5b, "invertSameOval", &Pict1Parser::handleInsertSameOval, 1 },
+ { 0x5c, "fillSameOval", &Pict1Parser::handleFillSameOval, 1 },
+
+ { 0x60, "frameArc", &Pict1Parser::handleFrameArc, 13 },
+ { 0x61, "paintArc", &Pict1Parser::handlePaintArc, 13 },
+ { 0x62, "eraseArc", &Pict1Parser::handleEraseArc, 13 },
+ { 0x63, "invertArc", &Pict1Parser::handleInsertArc, 13 },
+ { 0x64, "fillArc", &Pict1Parser::handleFillArc, 13 },
+
+ { 0x68, "frameSameArc", &Pict1Parser::handleFrameSameArc, 5 },
+ { 0x69, "paintSameArc", &Pict1Parser::handlePaintSameArc, 5 },
+ { 0x6a, "eraseSameArc", &Pict1Parser::handleEraseSameArc, 5 },
+ { 0x6b, "inverSameArc", &Pict1Parser::handleInsertSameArc, 5 },
+ { 0x6c, "fillSameArc", &Pict1Parser::handleFillSameArc, 5 },
+
+ { 0x70, "framePoly", &Pict1Parser::handleFramePoly, -1 },
+ { 0x71, "paintPoly", &Pict1Parser::handlePaintPoly, -1 },
+ { 0x72, "erasePoly", &Pict1Parser::handleErasePoly, -1 },
+ { 0x73, "invertPoly", &Pict1Parser::handleInvertPoly, -1 },
+ { 0x74, "fillPoly", &Pict1Parser::handleFillPoly, -1 },
+
+ { 0x78, "frameSamePoly", &Pict1Parser::handleFrameSamePoly, 1 },
+ { 0x79, "paintSamePoly", &Pict1Parser::handlePaintSamePoly, 1 },
+ { 0x7a, "eraseSamePoly", &Pict1Parser::handleEraseSamePoly, 1 },
+ { 0x7b, "invertSamePoly", &Pict1Parser::handleInvertSamePoly, 1 },
+ { 0x7c, "fillSamePoly", &Pict1Parser::handleFillSamePoly, 1 },
+
+ { 0x80, "frameRgn", &Pict1Parser::handleFrameRgn, -1 },
+ { 0x81, "paintRgn", &Pict1Parser::handlePaintRgn, -1 },
+ { 0x82, "eraseRgn", &Pict1Parser::handleEraseRgn, -1 },
+ { 0x83, "invertRgn", &Pict1Parser::handleInvertRgn, -1 },
+ { 0x84, "fillRgn", &Pict1Parser::handleFillRgn, -1 },
+
+ { 0x88, "frameSameRgn", &Pict1Parser::handleFrameSameRgn, 1 },
+ { 0x89, "paintSameRgn", &Pict1Parser::handlePaintSameRgn, 1 },
+ { 0x8a, "eraseSameRgn", &Pict1Parser::handleEraseSameRgn, 1 },
+ { 0x8b, "invertSameRgn", &Pict1Parser::handleInvertSameRgn, 1 },
+ { 0x8c, "fillSameRgn", &Pict1Parser::handleFillSameRgn, 1 },
+
+ { 0x90, "BitsRect", &Pict1Parser::handleBitsRect, -1 },
+ { 0x91, "BitsRgn", &Pict1Parser::handleBitsRgn, -1 },
+
+ { 0x98, "PackBitsRect", &Pict1Parser::handlePackBitsRect, -1 },
+ { 0x99, "PackBitsRgn", &Pict1Parser::handlePackBitsRgn, -1 },
+
+ { 0xa0, "shortComment", &Pict1Parser::handleShortComment, 3 },
+ { 0xa1, "longComment", &Pict1Parser::handleLongComment, -1 },
+
+ { 0xff, "EndOfPicture", &Pict1Parser::handleEndOfPicture, 1 }
+ };
+
+ while(!m_input->atEOS())
+ {
+ long initialPosition = m_input->tell();
+ int recordType = readU8();
+ if (recordType == 0xff)
+ 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)
+ {
+ 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)();
+ }
+ 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);
+ m_recordSize = 0;
+ }
+ }
+ else
+ return false;
+ }
+ return true;
}
void Pict1Parser::handleNOP()
@@ -204,8 +204,8 @@ void Pict1Parser::handleNOP()
void Pict1Parser::handleClipRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleBkPat()
@@ -290,30 +290,30 @@ void Pict1Parser::handleShortLineFrom()
void Pict1Parser::handleLongText()
{
- m_input->seek(6, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 6;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(6, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 6;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleDHText()
{
- m_input->seek(2, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 3;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(2, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 3;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleDVText()
{
- m_input->seek(2, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 3;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(2, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 3;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleDHDVText()
{
- m_input->seek(3, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 4;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(3, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 4;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
@@ -479,32 +479,32 @@ void Pict1Parser::handleFillSameArc()
void Pict1Parser::handleFramePoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handlePaintPoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleErasePoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleInvertPoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleFillPoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleFrameSamePoly()
@@ -529,32 +529,32 @@ void Pict1Parser::handleFillSamePoly()
void Pict1Parser::handleFrameRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handlePaintRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleEraseRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleInvertRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleFillRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
@@ -580,82 +580,82 @@ void Pict1Parser::handleFillSameRgn()
void Pict1Parser::handleBitsRect()
{
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleBitsRgn()
{
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? (int)(bounds_bottom - bounds_top) : (int)(bounds_top - bounds_bottom));
- m_recordSize += readU16();
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? (int)(bounds_bottom - bounds_top) : (int)(bounds_top - bounds_bottom));
+ m_recordSize += readU16();
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handlePackBitsRect()
{
#ifdef DEBUG
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
#else
- readU16();
- readU16();
- readU16();
- readU16();
+ readU16();
+ readU16();
+ readU16();
+ readU16();
#endif
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
#if 0
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
#endif
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handlePackBitsRgn()
{
#ifdef DEBUG
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
#else
- readU16();
- readU16();
- readU16();
- readU16();
+ readU16();
+ readU16();
+ readU16();
+ readU16();
#endif
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
#if 0
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
- m_recordSize += readU16();
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
+ m_recordSize += readU16();
#endif
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict1Parser::handleShortComment()
diff --git a/src/lib/Pict1Parser.h b/src/lib/Pict1Parser.h
index 0dc1c5a..ad44d92 100644
--- a/src/lib/Pict1Parser.h
+++ b/src/lib/Pict1Parser.h
@@ -29,126 +29,126 @@
class Pict1Parser : public PictXParser
{
public:
- Pict1Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
- bool parse();
+ Pict1Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
+ bool parse();
private:
- void handleNOP();
- void handleClipRgn();
- void handleBkPat();
- void handleTxFont();
- void handleTxFace();
- void handleTxMode();
- void handleSpExtra();
- void handlePnSize();
- void handlePnMode();
- void handlePnPat();
- void handleThePat();
- void handleOwSize();
- void handleOrigin();
- void handleTxSize();
- void handleFgColor();
- void handleBkColor();
- void handleTxRatio();
- void handlePicVersion();
-
- void handleLine();
- void handleLineFrom();
- void handleShortLine();
- void handleShortLineFrom();
-
- void handleLongText();
- void handleDHText();
- void handleDVText();
- void handleDHDVText();
-
- void handleFrameRect();
- void handlePaintRect();
- void handleEraseRect();
- void handleInvertRect();
- void handleFillRect();
-
- void handleFrameSameRect();
- void handlePaintSameRect();
- void handleEraseSameRect();
- void handleInvertSameRect();
- void handleFillSameRect();
-
- void handleFrameRRect();
- void handlePaintRRect();
- void handleEraseRRect();
- void handleInvertRRect();
- void handleFillRRect();
-
- void handleFrameSameRRect();
- void handlePaintSameRRect();
- void handleEraseSameRRect();
- void handleInvertSameRRect();
- void handleFillSameRRect();
-
- void handleFrameOval();
- void handlePaintOval();
- void handleEraseOval();
- void handleInsertOval();
- void handleFillOval();
-
- void handleFrameSameOval();
- void handlePaintSameOval();
- void handleEraseSameOval();
- void handleInsertSameOval();
- void handleFillSameOval();
-
- void handleFrameArc();
- void handlePaintArc();
- void handleEraseArc();
- void handleInsertArc();
- void handleFillArc();
-
- void handleFrameSameArc();
- void handlePaintSameArc();
- void handleEraseSameArc();
- void handleInsertSameArc();
- void handleFillSameArc();
-
- void handleFramePoly();
- void handlePaintPoly();
- void handleErasePoly();
- void handleInvertPoly();
- void handleFillPoly();
-
- void handleFrameSamePoly();
- void handlePaintSamePoly();
- void handleEraseSamePoly();
- void handleInvertSamePoly();
- void handleFillSamePoly();
-
- void handleFrameRgn();
- void handlePaintRgn();
- void handleEraseRgn();
- void handleInvertRgn();
- void handleFillRgn();
-
- void handleFrameSameRgn();
- void handlePaintSameRgn();
- void handleEraseSameRgn();
- void handleInvertSameRgn();
- void handleFillSameRgn();
-
- void handleBitsRect();
- void handleBitsRgn();
-
- void handlePackBitsRect();
- void handlePackBitsRgn();
-
- void handleShortComment();
- void handleLongComment();
-
- void handleEndOfPicture();
-
- void _handlePackBitsData();
- void _handlePictureComment();
-
- int m_recordSize;
+ void handleNOP();
+ void handleClipRgn();
+ void handleBkPat();
+ void handleTxFont();
+ void handleTxFace();
+ void handleTxMode();
+ void handleSpExtra();
+ void handlePnSize();
+ void handlePnMode();
+ void handlePnPat();
+ void handleThePat();
+ void handleOwSize();
+ void handleOrigin();
+ void handleTxSize();
+ void handleFgColor();
+ void handleBkColor();
+ void handleTxRatio();
+ void handlePicVersion();
+
+ void handleLine();
+ void handleLineFrom();
+ void handleShortLine();
+ void handleShortLineFrom();
+
+ void handleLongText();
+ void handleDHText();
+ void handleDVText();
+ void handleDHDVText();
+
+ void handleFrameRect();
+ void handlePaintRect();
+ void handleEraseRect();
+ void handleInvertRect();
+ void handleFillRect();
+
+ void handleFrameSameRect();
+ void handlePaintSameRect();
+ void handleEraseSameRect();
+ void handleInvertSameRect();
+ void handleFillSameRect();
+
+ void handleFrameRRect();
+ void handlePaintRRect();
+ void handleEraseRRect();
+ void handleInvertRRect();
+ void handleFillRRect();
+
+ void handleFrameSameRRect();
+ void handlePaintSameRRect();
+ void handleEraseSameRRect();
+ void handleInvertSameRRect();
+ void handleFillSameRRect();
+
+ void handleFrameOval();
+ void handlePaintOval();
+ void handleEraseOval();
+ void handleInsertOval();
+ void handleFillOval();
+
+ void handleFrameSameOval();
+ void handlePaintSameOval();
+ void handleEraseSameOval();
+ void handleInsertSameOval();
+ void handleFillSameOval();
+
+ void handleFrameArc();
+ void handlePaintArc();
+ void handleEraseArc();
+ void handleInsertArc();
+ void handleFillArc();
+
+ void handleFrameSameArc();
+ void handlePaintSameArc();
+ void handleEraseSameArc();
+ void handleInsertSameArc();
+ void handleFillSameArc();
+
+ void handleFramePoly();
+ void handlePaintPoly();
+ void handleErasePoly();
+ void handleInvertPoly();
+ void handleFillPoly();
+
+ void handleFrameSamePoly();
+ void handlePaintSamePoly();
+ void handleEraseSamePoly();
+ void handleInvertSamePoly();
+ void handleFillSamePoly();
+
+ void handleFrameRgn();
+ void handlePaintRgn();
+ void handleEraseRgn();
+ void handleInvertRgn();
+ void handleFillRgn();
+
+ void handleFrameSameRgn();
+ void handlePaintSameRgn();
+ void handleEraseSameRgn();
+ void handleInvertSameRgn();
+ void handleFillSameRgn();
+
+ void handleBitsRect();
+ void handleBitsRgn();
+
+ void handlePackBitsRect();
+ void handlePackBitsRgn();
+
+ void handleShortComment();
+ void handleLongComment();
+
+ void handleEndOfPicture();
+
+ void _handlePackBitsData();
+ void _handlePictureComment();
+
+ int m_recordSize;
};
#endif // __PICT1PARSER_H__
diff --git a/src/lib/Pict2Parser.cpp b/src/lib/Pict2Parser.cpp
index 5260484..e9bb65d 100644
--- a/src/lib/Pict2Parser.cpp
+++ b/src/lib/Pict2Parser.cpp
@@ -23,249 +23,249 @@
#include <libwpg/libwpg.h>
Pict2Parser::Pict2Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter):
- PictXParser(input, painter),
- m_recordSize(0)
+ PictXParser(input, painter),
+ m_recordSize(0)
{
}
bool Pict2Parser::parse()
{
- typedef void (Pict2Parser::*Method)();
-
- struct RecordHandler
- {
- int type;
- const char *name;
- Method handler;
- int size;
- };
-
- static const struct RecordHandler handlers[] =
- {
- { 0x00, "NOP", &Pict2Parser::handleNOP, 2 },
- { 0x01, "clipRgn", &Pict2Parser::handleClipRgn, -1 },
- { 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, 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 },
- { 0x27, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x28, "long text", &Pict2Parser::handleLongText, -1 },
- { 0x29, "DH text", &Pict2Parser::handleDHText, -1 },
- { 0x2a, "DV text", &Pict2Parser::handleDVText, -1 },
- { 0x2b, "DHDV text", &Pict2Parser::handleDHDVText, -1 },
- { 0x2c, "fontName", &Pict2Parser::handleFontName, -1 },
- { 0x2d, "lineJustify", &Pict2Parser::handleLineJustify, 12 },
- { 0x2e, "glyphState", &Pict2Parser::handleGlyphState, 10 },
- { 0x2f, "Reserved", &Pict2Parser::skipData, -1 },
- { 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 },
- { 0x73, "invertPoly", &Pict2Parser::handleInvertPoly, -1 },
- { 0x74, "fillPoly", &Pict2Parser::handleFillPoly, -1 },
- { 0x75, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x76, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x77, "Reserved", &Pict2Parser::skipData, -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 },
- { 0x83, "invertRgn", &Pict2Parser::handleInvertRgn, -1 },
- { 0x84, "fillRgn", &Pict2Parser::handleFillRgn, -1 },
- { 0x85, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x86, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x87, "Reserved", &Pict2Parser::skipData, -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 },
- { 0x93, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x94, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x95, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x96, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x97, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x98, "PackBitsRect", &Pict2Parser::handlePackBitsRect, -1 },
- { 0x99, "PackBitsRgn", &Pict2Parser::handlePackBitsRgn, -1 },
- { 0x9a, "DirectBitsRect", &Pict2Parser::handleDirectBitsRect, -1 },
- { 0x9b, "DirectBitsRgn", &Pict2Parser::handleDirectBitsRgn, -1 },
- { 0x9c, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x9d, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x9e, "Reserved", &Pict2Parser::skipData, -1 },
- { 0x9f, "Reserved", &Pict2Parser::skipData, -1 },
- { 0xa0, "shortComment", &Pict2Parser::handleShortComment, 4 },
- { 0xa1, "longComment", &Pict2Parser::handleLongComment, -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)
- m_input->seek((int)(++initialPosition), WPX_SEEK_SET);
- int recordType = readU16();
- if (recordType == 0x00ff)
- break;
- 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
- {
- // 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)
- {
- 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)();
- }
- }
- }
-
- 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;
+ typedef void (Pict2Parser::*Method)();
+
+ struct RecordHandler
+ {
+ int type;
+ const char *name;
+ Method handler;
+ int size;
+ };
+
+ static const struct RecordHandler handlers[] =
+ {
+ { 0x00, "NOP", &Pict2Parser::handleNOP, 2 },
+ { 0x01, "clipRgn", &Pict2Parser::handleClipRgn, -1 },
+ { 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, 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 },
+ { 0x27, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x28, "long text", &Pict2Parser::handleLongText, -1 },
+ { 0x29, "DH text", &Pict2Parser::handleDHText, -1 },
+ { 0x2a, "DV text", &Pict2Parser::handleDVText, -1 },
+ { 0x2b, "DHDV text", &Pict2Parser::handleDHDVText, -1 },
+ { 0x2c, "fontName", &Pict2Parser::handleFontName, -1 },
+ { 0x2d, "lineJustify", &Pict2Parser::handleLineJustify, 12 },
+ { 0x2e, "glyphState", &Pict2Parser::handleGlyphState, 10 },
+ { 0x2f, "Reserved", &Pict2Parser::skipData, -1 },
+ { 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 },
+ { 0x73, "invertPoly", &Pict2Parser::handleInvertPoly, -1 },
+ { 0x74, "fillPoly", &Pict2Parser::handleFillPoly, -1 },
+ { 0x75, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x76, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x77, "Reserved", &Pict2Parser::skipData, -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 },
+ { 0x83, "invertRgn", &Pict2Parser::handleInvertRgn, -1 },
+ { 0x84, "fillRgn", &Pict2Parser::handleFillRgn, -1 },
+ { 0x85, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x86, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x87, "Reserved", &Pict2Parser::skipData, -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 },
+ { 0x93, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x94, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x95, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x96, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x97, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x98, "PackBitsRect", &Pict2Parser::handlePackBitsRect, -1 },
+ { 0x99, "PackBitsRgn", &Pict2Parser::handlePackBitsRgn, -1 },
+ { 0x9a, "DirectBitsRect", &Pict2Parser::handleDirectBitsRect, -1 },
+ { 0x9b, "DirectBitsRgn", &Pict2Parser::handleDirectBitsRgn, -1 },
+ { 0x9c, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x9d, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x9e, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0x9f, "Reserved", &Pict2Parser::skipData, -1 },
+ { 0xa0, "shortComment", &Pict2Parser::handleShortComment, 4 },
+ { 0xa1, "longComment", &Pict2Parser::handleLongComment, -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)
+ m_input->seek((int)(++initialPosition), WPX_SEEK_SET);
+ int recordType = readU16();
+ if (recordType == 0x00ff)
+ break;
+ 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
+ {
+ // 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)
+ {
+ 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)();
+ }
+ }
+ }
+
+ 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;
}
void Pict2Parser::handleNOP()
@@ -274,8 +274,8 @@ void Pict2Parser::handleNOP()
void Pict2Parser::handleClipRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleBkPat()
@@ -404,30 +404,30 @@ void Pict2Parser::handleShortLineFrom()
void Pict2Parser::handleLongText()
{
- m_input->seek(6, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 6;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(6, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 6;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleDHText()
{
- m_input->seek(2, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 3;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(2, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 3;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleDVText()
{
- m_input->seek(2, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 3;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(2, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 3;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleDHDVText()
{
- m_input->seek(3, WPX_SEEK_CUR);
- m_recordSize = (int)readU16() + 4;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_input->seek(3, WPX_SEEK_CUR);
+ m_recordSize = (int)readU16() + 4;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
@@ -593,32 +593,32 @@ void Pict2Parser::handleFillSameArc()
void Pict2Parser::handleFramePoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handlePaintPoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleErasePoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleInvertPoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleFillPoly()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleFrameSamePoly()
@@ -643,32 +643,32 @@ void Pict2Parser::handleFillSamePoly()
void Pict2Parser::handleFrameRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handlePaintRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleEraseRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleInvertRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleFillRgn()
{
- m_recordSize = (int)readU16() + 1;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ m_recordSize = (int)readU16() + 1;
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
@@ -694,82 +694,82 @@ void Pict2Parser::handleFillSameRgn()
void Pict2Parser::handleBitsRect()
{
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleBitsRgn()
{
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? (int)(bounds_bottom - bounds_top) : (int)(bounds_top - bounds_bottom));
- m_recordSize += readU16();
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? (int)(bounds_bottom - bounds_top) : (int)(bounds_top - bounds_bottom));
+ m_recordSize += readU16();
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handlePackBitsRect()
{
#ifdef DEBUG
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
#else
- readU16();
- readU16();
- readU16();
- readU16();
+ readU16();
+ readU16();
+ readU16();
+ readU16();
#endif
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
#if 0
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
#endif
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handlePackBitsRgn()
{
#ifdef DEBUG
- unsigned short rowBytes = readU16();
- PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
- unsigned short bounds_top = readU16();
- PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
- readU16();
- unsigned short bounds_bottom = readU16();
- PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
+ unsigned short rowBytes = readU16();
+ PICT_DEBUG_MSG(("Row bytes: %i\n", rowBytes));
+ unsigned short bounds_top = readU16();
+ PICT_DEBUG_MSG(("Bounds.top: %i\n", bounds_top));
+ readU16();
+ unsigned short bounds_bottom = readU16();
+ PICT_DEBUG_MSG(("Bounds.bottom: %i\n", bounds_bottom));
#else
- readU16();
- readU16();
- readU16();
- readU16();
+ readU16();
+ readU16();
+ readU16();
+ readU16();
#endif
- readU16();
- m_input->seek(18, WPX_SEEK_CUR);
+ readU16();
+ m_input->seek(18, WPX_SEEK_CUR);
#if 0
- m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
- m_recordSize += readU16();
+ m_recordSize = 29 + (0x7fff & rowBytes)*((bounds_bottom > bounds_top) ? bounds_bottom - bounds_top : bounds_top - bounds_bottom);
+ m_recordSize += readU16();
#endif
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
}
void Pict2Parser::handleShortComment()
@@ -806,12 +806,12 @@ void Pict2Parser::handleDirectBitsRgn()
void Pict2Parser::skipData()
{
- m_recordSize = (int)readU16() + 2 + 2;
- PICT_DEBUG_MSG(("Size of the data: %i\n", m_recordSize));
+ 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));
+ 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 c0ec598..5091cf0 100644
--- a/src/lib/Pict2Parser.h
+++ b/src/lib/Pict2Parser.h
@@ -31,141 +31,141 @@
class Pict2Parser : public PictXParser
{
public:
- Pict2Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
- bool parse();
+ Pict2Parser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
+ bool parse();
private:
- void handleNOP();
- void handleClipRgn();
- void handleBkPat();
- void handleTxFont();
- void handleTxFace();
- void handleTxMode();
- void handleSpExtra();
- void handlePnSize();
- void handlePnMode();
- void handlePnPat();
- void handleThePat();
- void handleOwSize();
- void handleOrigin();
- void handleTxSize();
- void handleFgColor();
- void handleBkColor();
- void handleTxRatio();
- void handlePicVersion();
- void handleBkPixPat();
- void handlePnPixPat();
- void handleFillPixPat();
- void handlePnLocHFrac();
- void handleChExtra();
- void handleRGBFgCol();
- void handleRGBBkCol();
- void handleHiliteMode();
- void handleHiliteColor();
- void handleDefHilite();
- void handleOpColor();
- void handleLine();
- void handleLineFrom();
- void handleShortLine();
- void handleShortLineFrom();
-
- void handleLongText();
- void handleDHText();
- void handleDVText();
- void handleDHDVText();
- void handleFontName();
- void handleLineJustify();
- void handleGlyphState();
-
- void handleFrameRect();
- void handlePaintRect();
- void handleEraseRect();
- void handleInvertRect();
- void handleFillRect();
-
- void handleFrameSameRect();
- void handlePaintSameRect();
- void handleEraseSameRect();
- void handleInvertSameRect();
- void handleFillSameRect();
-
- void handleFrameRRect();
- void handlePaintRRect();
- void handleEraseRRect();
- void handleInvertRRect();
- void handleFillRRect();
-
- void handleFrameSameRRect();
- void handlePaintSameRRect();
- void handleEraseSameRRect();
- void handleInvertSameRRect();
- void handleFillSameRRect();
-
- void handleFrameOval();
- void handlePaintOval();
- void handleEraseOval();
- void handleInsertOval();
- void handleFillOval();
-
- void handleFrameSameOval();
- void handlePaintSameOval();
- void handleEraseSameOval();
- void handleInsertSameOval();
- void handleFillSameOval();
-
- void handleFrameArc();
- void handlePaintArc();
- void handleEraseArc();
- void handleInsertArc();
- void handleFillArc();
-
- void handleFrameSameArc();
- void handlePaintSameArc();
- void handleEraseSameArc();
- void handleInsertSameArc();
- void handleFillSameArc();
-
- void handleFramePoly();
- void handlePaintPoly();
- void handleErasePoly();
- void handleInvertPoly();
- void handleFillPoly();
-
- void handleFrameSamePoly();
- void handlePaintSamePoly();
- void handleEraseSamePoly();
- void handleInvertSamePoly();
- void handleFillSamePoly();
-
- void handleFrameRgn();
- void handlePaintRgn();
- void handleEraseRgn();
- void handleInvertRgn();
- void handleFillRgn();
-
- void handleFrameSameRgn();
- void handlePaintSameRgn();
- void handleEraseSameRgn();
- void handleInvertSameRgn();
- void handleFillSameRgn();
-
- void handleBitsRect();
- void handleBitsRgn();
-
- void handlePackBitsRect();
- void handlePackBitsRgn();
- void handleDirectBitsRect();
- void handleDirectBitsRgn();
-
- void handleShortComment();
- void handleLongComment();
-
- void handleEndOfPicture();
-
- void skipData();
- void skipLongData();
-
- int m_recordSize;
+ void handleNOP();
+ void handleClipRgn();
+ void handleBkPat();
+ void handleTxFont();
+ void handleTxFace();
+ void handleTxMode();
+ void handleSpExtra();
+ void handlePnSize();
+ void handlePnMode();
+ void handlePnPat();
+ void handleThePat();
+ void handleOwSize();
+ void handleOrigin();
+ void handleTxSize();
+ void handleFgColor();
+ void handleBkColor();
+ void handleTxRatio();
+ void handlePicVersion();
+ void handleBkPixPat();
+ void handlePnPixPat();
+ void handleFillPixPat();
+ void handlePnLocHFrac();
+ void handleChExtra();
+ void handleRGBFgCol();
+ void handleRGBBkCol();
+ void handleHiliteMode();
+ void handleHiliteColor();
+ void handleDefHilite();
+ void handleOpColor();
+ void handleLine();
+ void handleLineFrom();
+ void handleShortLine();
+ void handleShortLineFrom();
+
+ void handleLongText();
+ void handleDHText();
+ void handleDVText();
+ void handleDHDVText();
+ void handleFontName();
+ void handleLineJustify();
+ void handleGlyphState();
+
+ void handleFrameRect();
+ void handlePaintRect();
+ void handleEraseRect();
+ void handleInvertRect();
+ void handleFillRect();
+
+ void handleFrameSameRect();
+ void handlePaintSameRect();
+ void handleEraseSameRect();
+ void handleInvertSameRect();
+ void handleFillSameRect();
+
+ void handleFrameRRect();
+ void handlePaintRRect();
+ void handleEraseRRect();
+ void handleInvertRRect();
+ void handleFillRRect();
+
+ void handleFrameSameRRect();
+ void handlePaintSameRRect();
+ void handleEraseSameRRect();
+ void handleInvertSameRRect();
+ void handleFillSameRRect();
+
+ void handleFrameOval();
+ void handlePaintOval();
+ void handleEraseOval();
+ void handleInsertOval();
+ void handleFillOval();
+
+ void handleFrameSameOval();
+ void handlePaintSameOval();
+ void handleEraseSameOval();
+ void handleInsertSameOval();
+ void handleFillSameOval();
+
+ void handleFrameArc();
+ void handlePaintArc();
+ void handleEraseArc();
+ void handleInsertArc();
+ void handleFillArc();
+
+ void handleFrameSameArc();
+ void handlePaintSameArc();
+ void handleEraseSameArc();
+ void handleInsertSameArc();
+ void handleFillSameArc();
+
+ void handleFramePoly();
+ void handlePaintPoly();
+ void handleErasePoly();
+ void handleInvertPoly();
+ void handleFillPoly();
+
+ void handleFrameSamePoly();
+ void handlePaintSamePoly();
+ void handleEraseSamePoly();
+ void handleInvertSamePoly();
+ void handleFillSamePoly();
+
+ void handleFrameRgn();
+ void handlePaintRgn();
+ void handleEraseRgn();
+ void handleInvertRgn();
+ void handleFillRgn();
+
+ void handleFrameSameRgn();
+ void handlePaintSameRgn();
+ void handleEraseSameRgn();
+ void handleInvertSameRgn();
+ void handleFillSameRgn();
+
+ void handleBitsRect();
+ void handleBitsRgn();
+
+ void handlePackBitsRect();
+ void handlePackBitsRgn();
+ void handleDirectBitsRect();
+ void handleDirectBitsRgn();
+
+ void handleShortComment();
+ void handleLongComment();
+
+ void handleEndOfPicture();
+
+ void skipData();
+ void skipLongData();
+
+ int m_recordSize;
};
#endif // __PICT2PARSER_H__
diff --git a/src/lib/PictBitmap.cpp b/src/lib/PictBitmap.cpp
index bb54a23..f8ef45e 100644
--- a/src/lib/PictBitmap.cpp
+++ b/src/lib/PictBitmap.cpp
@@ -42,21 +42,21 @@ namespace
{
void writeU16(unsigned char *buffer, unsigned &position, const int value)
{
- buffer[position++] = (unsigned char)(value & 0xFF);
- buffer[position++] = (unsigned char)((value >> 8) & 0xFF);
+ buffer[position++] = (unsigned char)(value & 0xFF);
+ buffer[position++] = (unsigned char)((value >> 8) & 0xFF);
}
void writeU32(unsigned char *buffer, unsigned &position, const int value)
{
- buffer[position++] = (unsigned char)(value & 0xFF);
- buffer[position++] = (unsigned char)((value >> 8) & 0xFF);
- buffer[position++] = (unsigned char)((value >> 16) & 0xFF);
- buffer[position++] = (unsigned char)((value >> 24) & 0xFF);
+ buffer[position++] = (unsigned char)(value & 0xFF);
+ buffer[position++] = (unsigned char)((value >> 8) & 0xFF);
+ buffer[position++] = (unsigned char)((value >> 16) & 0xFF);
+ buffer[position++] = (unsigned char)((value >> 24) & 0xFF);
}
void writeU8(unsigned char *buffer, unsigned &position, const int value)
{
- buffer[position++] = (unsigned char)(value & 0xFF);
+ buffer[position++] = (unsigned char)(value & 0xFF);
}
}
@@ -64,214 +64,214 @@ void writeU8(unsigned char *buffer, unsigned &position, const int value)
class libpict::PictBitmap::Private
{
public:
- int width;
- int height;
- int vRes;
- int hRes;
- bool vFlip;
- bool hFlip;
- PictColor *pixels;
- ::WPXBinaryData dib;
-
- Private(int w, int h): width(w), height(h), vRes(72), hRes(72), vFlip(false), hFlip(false), pixels(0), dib() {}
+ int width;
+ int height;
+ int vRes;
+ int hRes;
+ bool vFlip;
+ bool hFlip;
+ PictColor *pixels;
+ ::WPXBinaryData dib;
+
+ Private(int w, int h): width(w), height(h), vRes(72), hRes(72), vFlip(false), hFlip(false), pixels(0), dib() {}
};
libpict::PictBitmap::PictBitmap(int w, int h, int verticalResolution, int horizontalResolution, bool verticalFlip, bool horizontalFlip) :
- d(new Private(w, h))
+ d(new Private(w, h))
{
- d->vRes = verticalResolution;
- d->hRes = horizontalResolution;
- d->vFlip = verticalFlip;
- d->hFlip = horizontalFlip;
- d->pixels = new PictColor[w*h];
+ d->vRes = verticalResolution;
+ d->hRes = horizontalResolution;
+ d->vFlip = verticalFlip;
+ d->hFlip = horizontalFlip;
+ d->pixels = new PictColor[w*h];
}
libpict::PictBitmap::~PictBitmap()
{
- if (d)
- {
- if (d->pixels)
- delete [] d->pixels;
- delete d;
- }
+ if (d)
+ {
+ if (d->pixels)
+ delete [] d->pixels;
+ delete d;
+ }
}
libpict::PictBitmap::PictBitmap(const PictBitmap &bitmap): d(new Private(0,0))
{
- copyFrom(bitmap);
+ copyFrom(bitmap);
}
libpict::PictBitmap &libpict::PictBitmap::operator=(const PictBitmap &bitmap)
{
- copyFrom(bitmap);
- return *this;
+ copyFrom(bitmap);
+ return *this;
}
void libpict::PictBitmap::copyFrom(const PictBitmap &bitmap)
{
- d->width = bitmap.d->width;
- d->height = bitmap.d->height;
- delete [] d->pixels;
- d->pixels = new PictColor[d->width*d->height];
- for(int i=0; i < d->width*d->height; i++)
- d->pixels[i] = bitmap.d->pixels[i];
+ d->width = bitmap.d->width;
+ d->height = bitmap.d->height;
+ delete [] d->pixels;
+ d->pixels = new PictColor[d->width*d->height];
+ for(int i=0; i < d->width*d->height; i++)
+ d->pixels[i] = bitmap.d->pixels[i];
}
int libpict::PictBitmap::width() const
{
- return d->width;
+ return d->width;
}
int libpict::PictBitmap::height() const
{
- return d->height;
+ return d->height;
}
int libpict::PictBitmap::vres() const
{
- return d->vRes;
+ return d->vRes;
}
int libpict::PictBitmap::hres() const
{
- return d->hRes;
+ return d->hRes;
}
void libpict::PictBitmap::setPixel(int x, int y, const libpict::PictColor &color)
{
- if((x < 0) || (y <0) || (x >= d->width) || (y >= d->height))
- return;
+ if((x < 0) || (y <0) || (x >= d->width) || (y >= d->height))
+ return;
- d->pixels[y*d->width + x] = color;
+ d->pixels[y*d->width + x] = color;
}
const ::WPXBinaryData &libpict::PictBitmap::getDIB() const
{
- if (d->dib.size() || d->height <= 0 || d->width <= 0)
- return d->dib;
+ if (d->dib.size() || d->height <= 0 || d->width <= 0)
+ return d->dib;
#ifndef OUTPUT_DUMMY_BITMAPS
- unsigned tmpPixelSize = (unsigned)(d->height * d->width);
- if (tmpPixelSize < (unsigned)d->height) // overflow
- return d->dib;
+ unsigned tmpPixelSize = (unsigned)(d->height * d->width);
+ if (tmpPixelSize < (unsigned)d->height) // overflow
+ return d->dib;
#else
- unsigned tmpPixelSize = 1;
+ unsigned tmpPixelSize = 1;
#endif
- unsigned tmpBufferPosition = 0;
+ unsigned tmpBufferPosition = 0;
- unsigned tmpDIBImageSize = tmpPixelSize * 4;
- if (tmpPixelSize > tmpDIBImageSize) // overflow !!!
- return d->dib;
+ unsigned tmpDIBImageSize = tmpPixelSize * 4;
+ if (tmpPixelSize > tmpDIBImageSize) // overflow !!!
+ return d->dib;
- unsigned tmpDIBOffsetBits = 14 + 40;
- unsigned tmpDIBFileSize = tmpDIBOffsetBits + tmpDIBImageSize;
- if (tmpDIBImageSize > tmpDIBFileSize) // overflow !!!
- return d->dib;
+ unsigned tmpDIBOffsetBits = 14 + 40;
+ unsigned tmpDIBFileSize = tmpDIBOffsetBits + tmpDIBImageSize;
+ if (tmpDIBImageSize > tmpDIBFileSize) // overflow !!!
+ return d->dib;
- unsigned char *tmpDIBBuffer = new unsigned char[tmpDIBFileSize];
+ unsigned char *tmpDIBBuffer = new unsigned char[tmpDIBFileSize];
- // Create DIB file header
- writeU16(tmpDIBBuffer, tmpBufferPosition, 0x4D42); // Type
- writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBFileSize); // Size
- writeU16(tmpDIBBuffer, tmpBufferPosition, 0); // Reserved1
- writeU16(tmpDIBBuffer, tmpBufferPosition, 0); // Reserved2
- writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBOffsetBits); // OffsetBits
+ // Create DIB file header
+ writeU16(tmpDIBBuffer, tmpBufferPosition, 0x4D42); // Type
+ writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBFileSize); // Size
+ writeU16(tmpDIBBuffer, tmpBufferPosition, 0); // Reserved1
+ writeU16(tmpDIBBuffer, tmpBufferPosition, 0); // Reserved2
+ writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBOffsetBits); // OffsetBits
- PICT_DEBUG_MSG(("PictBitmap: DIB file header end = %i\n", tmpBufferPosition - 1));
+ PICT_DEBUG_MSG(("PictBitmap: DIB file header end = %i\n", tmpBufferPosition - 1));
- // Create DIB Info header
- writeU32(tmpDIBBuffer, tmpBufferPosition, 40); // Size
+ // Create DIB Info header
+ writeU32(tmpDIBBuffer, tmpBufferPosition, 40); // Size
#ifndef OUTPUT_DUMMY_BITMAPS
- writeU32(tmpDIBBuffer, tmpBufferPosition, width()); // Width
- writeU32(tmpDIBBuffer, tmpBufferPosition, height()); // Height
+ writeU32(tmpDIBBuffer, tmpBufferPosition, width()); // Width
+ writeU32(tmpDIBBuffer, tmpBufferPosition, height()); // Height
#else
- writeU32(tmpDIBBuffer, tmpBufferPosition, 1); // Width
- writeU32(tmpDIBBuffer, tmpBufferPosition, 1); // Height
+ writeU32(tmpDIBBuffer, tmpBufferPosition, 1); // Width
+ writeU32(tmpDIBBuffer, tmpBufferPosition, 1); // Height
#endif
- writeU16(tmpDIBBuffer, tmpBufferPosition, 1); // Planes
- writeU16(tmpDIBBuffer, tmpBufferPosition, 32); // BitCount
- writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // Compression
- writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBImageSize); // SizeImage
- writeU32(tmpDIBBuffer, tmpBufferPosition, (int)(hres()*100.0/2.54)); // XPelsPerMeter
- writeU32(tmpDIBBuffer, tmpBufferPosition, (int)(vres()*100.0/2.54)); // YPelsPerMeter
- writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // ColorsUsed
- writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // ColorsImportant
+ writeU16(tmpDIBBuffer, tmpBufferPosition, 1); // Planes
+ writeU16(tmpDIBBuffer, tmpBufferPosition, 32); // BitCount
+ writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // Compression
+ writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBImageSize); // SizeImage
+ writeU32(tmpDIBBuffer, tmpBufferPosition, (int)(hres()*100.0/2.54)); // XPelsPerMeter
+ writeU32(tmpDIBBuffer, tmpBufferPosition, (int)(vres()*100.0/2.54)); // YPelsPerMeter
+ writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // ColorsUsed
+ writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // ColorsImportant
- PICT_DEBUG_MSG(("PictBitmap: DIB info header end = %i\n", tmpBufferPosition - 1));
+ PICT_DEBUG_MSG(("PictBitmap: DIB info header end = %i\n", tmpBufferPosition - 1));
- // Write DIB Image data
+ // Write DIB Image data
#ifndef OUTPUT_DUMMY_BITMAPS
- int i = 0;
- int j = 0;
- if (d->vFlip)
- for (i = 0; i < d->height && tmpBufferPosition < tmpDIBFileSize; i++)
- {
- if (d->hFlip)
- for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--)
- {
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
- }
- else
- for (j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++)
- {
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
- }
- }
- else
- for (i = d->height - 1; i >= 0 && tmpBufferPosition < tmpDIBFileSize; i--)
- {
- if (d->hFlip)
- for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--)
- {
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
- }
- else
- for (j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++)
- {
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
- writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
- }
- }
-
- PICT_DEBUG_MSG(("PictBitmap: DIB file size = %i\n", tmpBufferPosition - 1));
+ int i = 0;
+ int j = 0;
+ if (d->vFlip)
+ for (i = 0; i < d->height && tmpBufferPosition < tmpDIBFileSize; i++)
+ {
+ if (d->hFlip)
+ for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--)
+ {
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
+ }
+ else
+ for (j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++)
+ {
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
+ }
+ }
+ else
+ for (i = d->height - 1; i >= 0 && tmpBufferPosition < tmpDIBFileSize; i--)
+ {
+ if (d->hFlip)
+ for (j = d->width - 1; j >= 0 && tmpBufferPosition < tmpDIBFileSize; j--)
+ {
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
+ }
+ else
+ for (j = 0; j < d->width && tmpBufferPosition < tmpDIBFileSize; j++)
+ {
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].blue);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].green);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].red);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, d->pixels[i*d->width + j].alpha);
+ }
+ }
+
+ PICT_DEBUG_MSG(("PictBitmap: DIB file size = %i\n", tmpBufferPosition - 1));
#else
- writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
- writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
- writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
- writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
+ writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
#endif
- d->dib.append(tmpDIBBuffer, tmpDIBFileSize);
+ d->dib.append(tmpDIBBuffer, tmpDIBFileSize);
- // temporary for debug - dump the binary bmp (need to have write access in the current directory
+ // temporary for debug - dump the binary bmp (need to have write access in the current directory
#if DUMP_BITMAP
- std::ostringstream filename;
- filename << "binarydump" << bitmapId++ << ".bmp";
- FILE *f = fopen(filename.str().c_str(), "wb");
- if (f)
- {
- for (unsigned k = 0; k < tmpDIBFileSize; k++)
- fprintf(f, "%c",tmpDIBBuffer[k]);
- fclose(f);
- }
+ std::ostringstream filename;
+ filename << "binarydump" << bitmapId++ << ".bmp";
+ FILE *f = fopen(filename.str().c_str(), "wb");
+ if (f)
+ {
+ for (unsigned k = 0; k < tmpDIBFileSize; k++)
+ fprintf(f, "%c",tmpDIBBuffer[k]);
+ fclose(f);
+ }
#endif
- // Cleanup things before returning
- delete [] tmpDIBBuffer;
+ // Cleanup things before returning
+ delete [] tmpDIBBuffer;
- return d->dib;
+ return d->dib;
}
diff --git a/src/lib/PictBitmap.h b/src/lib/PictBitmap.h
index 408c6a9..4791cb7 100644
--- a/src/lib/PictBitmap.h
+++ b/src/lib/PictBitmap.h
@@ -36,35 +36,35 @@ namespace libpict
class PictBitmap
{
public:
- PictBitmap(int width, int height, int verticalResolution, int horizontalResolution, bool verticalFlip=false, bool horizontalFlip=false);
+ PictBitmap(int width, int height, int verticalResolution, int horizontalResolution, bool verticalFlip=false, bool horizontalFlip=false);
- PictBitmap(const PictBitmap &);
+ PictBitmap(const PictBitmap &);
- PictBitmap &operator=(const PictBitmap &);
+ PictBitmap &operator=(const PictBitmap &);
- void copyFrom(const PictBitmap &);
+ void copyFrom(const PictBitmap &);
- ~PictBitmap();
+ ~PictBitmap();
- // return width in pixel
- int width() const;
+ // return width in pixel
+ int width() const;
- // return height in pixel
- int height() const;
+ // return height in pixel
+ int height() const;
- // return vertical resolution in pixels per inch
- int vres() const;
+ // return vertical resolution in pixels per inch
+ int vres() const;
- // return horizontal resolution in pixels per inch
- int hres() const;
+ // return horizontal resolution in pixels per inch
+ int hres() const;
- void setPixel(int x, int y, const PictColor &color);
+ void setPixel(int x, int y, const PictColor &color);
- const ::WPXBinaryData &getDIB() const;
+ const ::WPXBinaryData &getDIB() const;
private:
- class Private;
- Private *const d;
+ class Private;
+ Private *const d;
};
} // namespace libpict
diff --git a/src/lib/PictColor.cpp b/src/lib/PictColor.cpp
index ff7554f..4338dec 100644
--- a/src/lib/PictColor.cpp
+++ b/src/lib/PictColor.cpp
@@ -26,50 +26,50 @@
#include "PictColor.h"
libpict::PictColor::PictColor():
- red(0),
- green(0),
- blue(0),
- alpha(0xff)
+ red(0),
+ green(0),
+ blue(0),
+ alpha(0xff)
{}
libpict::PictColor::PictColor(int r, int g, int b):
- red(r),
- green(g),
- blue(b),
- alpha(0xff)
+ red(r),
+ green(g),
+ blue(b),
+ alpha(0xff)
{}
libpict::PictColor::PictColor(int r, int g, int b, int a):
- red(r),
- green(g),
- blue(b),
- alpha(a)
+ red(r),
+ green(g),
+ blue(b),
+ alpha(a)
{}
libpict::PictColor::PictColor(const PictColor &color):
- red(color.red),
- green(color.green),
- blue(color.blue),
- alpha(color.alpha)
+ red(color.red),
+ green(color.green),
+ blue(color.blue),
+ alpha(color.alpha)
{}
libpict::PictColor &libpict::PictColor::operator=(const libpict::PictColor &color)
{
- red = color.red;
- green = color.green;
- blue = color.blue;
- alpha = color.alpha;
- return *this;
+ red = color.red;
+ green = color.green;
+ blue = color.blue;
+ alpha = color.alpha;
+ return *this;
}
const ::WPXString libpict::PictColor::getColorString() const
{
- ::WPXString sColor;
- sColor.sprintf("#%.2x%.2x%.2x", red, green, blue);
- return sColor;
+ ::WPXString sColor;
+ sColor.sprintf("#%.2x%.2x%.2x", red, green, blue);
+ return sColor;
}
double libpict::PictColor::getOpacity() const
{
- return ((double)alpha/255.0);
+ return ((double)alpha/255.0);
}
diff --git a/src/lib/PictColor.h b/src/lib/PictColor.h
index 91102b9..d6bbdbe 100644
--- a/src/lib/PictColor.h
+++ b/src/lib/PictColor.h
@@ -34,21 +34,21 @@ namespace libpict
class PictColor
{
public:
- int red, green, blue, alpha;
+ int red, green, blue, alpha;
- PictColor();
+ PictColor();
- PictColor(int r, int g, int b);
+ PictColor(int r, int g, int b);
- PictColor(int r, int g, int b, int a);
+ PictColor(int r, int g, int b, int a);
- PictColor(const PictColor &color);
+ PictColor(const PictColor &color);
- PictColor &operator=(const PictColor &color);
+ PictColor &operator=(const PictColor &color);
- const ::WPXString getColorString() const;
+ const ::WPXString getColorString() const;
- double getOpacity() const;
+ double getOpacity() const;
};
} // namespace libpict
diff --git a/src/lib/PictHeader.cpp b/src/lib/PictHeader.cpp
index c9338a6..a4d2006 100644
--- a/src/lib/PictHeader.cpp
+++ b/src/lib/PictHeader.cpp
@@ -24,148 +24,148 @@ namespace
{
unsigned char readU8(WPXInputStream *input)
{
- unsigned long numBytesRead;
- unsigned char const *p = input->read(sizeof(unsigned char), numBytesRead);
+ unsigned long numBytesRead;
+ unsigned char const *p = input->read(sizeof(unsigned char), numBytesRead);
- if (numBytesRead != sizeof(unsigned char))
- throw libpict::EndOfStreamException();
- return *(unsigned char const *)(p);
+ if (numBytesRead != sizeof(unsigned char))
+ throw libpict::EndOfStreamException();
+ return *(unsigned char const *)(p);
}
unsigned short readU16(WPXInputStream *input)
{
- unsigned long numBytesRead;
- unsigned short const *p = (unsigned short const *)input->read(sizeof(unsigned short), numBytesRead);
+ unsigned long numBytesRead;
+ unsigned short const *p = (unsigned short const *)input->read(sizeof(unsigned short), numBytesRead);
- if (numBytesRead != sizeof(unsigned short))
- throw libpict::EndOfStreamException();
- return (unsigned short)((((unsigned char const *)(p))[1] << 0) | (((unsigned char const *)(p))[0] << 8));
+ if (numBytesRead != sizeof(unsigned short))
+ throw libpict::EndOfStreamException();
+ return (unsigned short)((((unsigned char const *)(p))[1] << 0) | (((unsigned char const *)(p))[0] << 8));
}
unsigned readU32(WPXInputStream *input)
{
- unsigned long numBytesRead;
- unsigned const *p = (unsigned const *)input->read(sizeof(unsigned), numBytesRead);
- if (numBytesRead != sizeof(unsigned))
- throw libpict::EndOfStreamException();
- 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));
+ unsigned long numBytesRead;
+ unsigned const *p = (unsigned const *)input->read(sizeof(unsigned), numBytesRead);
+ if (numBytesRead != sizeof(unsigned))
+ throw libpict::EndOfStreamException();
+ 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));
}
}
PictHeader::PictHeader() :
- m_fileSize(0),
- m_top(0),
- m_left(0),
- m_bottom(0),
- m_right(0),
- m_pictVersion(0),
- m_horizontalResolution(72),
- m_verticalResolution(72),
- m_dataStart(0)
+ m_fileSize(0),
+ m_top(0),
+ m_left(0),
+ m_bottom(0),
+ m_right(0),
+ m_pictVersion(0),
+ m_horizontalResolution(72),
+ m_verticalResolution(72),
+ m_dataStart(0)
{
}
bool PictHeader::load(WPXInputStream *input)
{
- if (loadPict1Header(input))
- return true;
- if (loadPict2Header(input))
- return true;
- return false;
+ if (loadPict1Header(input))
+ return true;
+ if (loadPict2Header(input))
+ return true;
+ return false;
}
bool PictHeader::loadPict1Header(WPXInputStream *input)
{
- input->seek(0, WPX_SEEK_SET);
- /* Try first to see whether the 512 bytes header is missing */
- input->seek(10, WPX_SEEK_CUR);
- if ((0x11 == readU8(input)) && (0x01 == readU8(input)))
- input->seek(0, WPX_SEEK_CUR);
- /* Ok, let us now skip the first 512 bytes and restart */
- else
- {
- input->seek(512 + 10, WPX_SEEK_SET);
- if ((0x11 == readU8(input)) && (0x01 == readU8(input)))
- input->seek(512, WPX_SEEK_SET);
- else
- {
- input->seek(0, WPX_SEEK_SET);
- PICT_DEBUG_MSG(("No Pict1 header present\n"));
- return false;
- }
- }
- /* Now, we should be out or at the beginning of the Pict1 file */
- PICT_DEBUG_MSG(("Reading Pict1 header\n"));
- m_fileSize = readU16(input);
- m_top = readU16(input);
- m_left = readU16(input);
- m_bottom = readU16(input);
- m_right = readU16(input);
- if (0x11 != readU8(input))
- {
- input->seek(0, WPX_SEEK_SET);
- return false;
- }
- if (0x01 != readU8(input))
- {
- input->seek(0, WPX_SEEK_SET);
- return false;
- }
- PICT_DEBUG_MSG(("Pict1Header: 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);
- m_pictVersion = 1;
- return true;
+ input->seek(0, WPX_SEEK_SET);
+ /* Try first to see whether the 512 bytes header is missing */
+ input->seek(10, WPX_SEEK_CUR);
+ if ((0x11 == readU8(input)) && (0x01 == readU8(input)))
+ input->seek(0, WPX_SEEK_CUR);
+ /* Ok, let us now skip the first 512 bytes and restart */
+ else
+ {
+ input->seek(512 + 10, WPX_SEEK_SET);
+ if ((0x11 == readU8(input)) && (0x01 == readU8(input)))
+ input->seek(512, WPX_SEEK_SET);
+ else
+ {
+ input->seek(0, WPX_SEEK_SET);
+ PICT_DEBUG_MSG(("No Pict1 header present\n"));
+ return false;
+ }
+ }
+ /* Now, we should be out or at the beginning of the Pict1 file */
+ PICT_DEBUG_MSG(("Reading Pict1 header\n"));
+ m_fileSize = readU16(input);
+ m_top = readU16(input);
+ m_left = readU16(input);
+ m_bottom = readU16(input);
+ m_right = readU16(input);
+ if (0x11 != readU8(input))
+ {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ if (0x01 != readU8(input))
+ {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ PICT_DEBUG_MSG(("Pict1Header: 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);
+ m_pictVersion = 1;
+ return true;
}
bool PictHeader::loadPict2Header(WPXInputStream *input)
{
- input->seek(0, WPX_SEEK_SET);
- /* Try first to see whether the 512 bytes header is missing */
- input->seek(10, WPX_SEEK_CUR);
- if ((0x0011 == readU16(input)) && (0x02FF == readU16(input)))
- input->seek(0, WPX_SEEK_CUR);
- /* Ok, let us now skip the first 512 bytes and restart */
- else
- {
- input->seek(512 + 10, WPX_SEEK_SET);
- if ((0x0011 == readU16(input)) && (0x02FF == readU16(input)))
- input->seek(512, WPX_SEEK_SET);
- else
- {
- input->seek(0, WPX_SEEK_SET);
- PICT_DEBUG_MSG(("No Pict2 header present\n"));
- return false;
- }
- }
- /* Now, we should be out or at the beginning of the Pict1 file */
- PICT_DEBUG_MSG(("Reading Pict2 header\n"));
- m_fileSize = readU16(input);
- m_top = readU16(input);
- m_left = readU16(input);
- m_bottom = readU16(input);
- m_right = readU16(input);
- if (0x0011 != readU16(input))
- {
- input->seek(0, WPX_SEEK_SET);
- return false;
- }
- if (0x02FF != readU16(input))
- {
- input->seek(0, WPX_SEEK_SET);
- return false;
- }
- if (0x0C00 != readU16(input))
- {
- input->seek(0, WPX_SEEK_SET);
- return false;
- }
- else
- 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);
- m_pictVersion = 2;
- return true;
+ input->seek(0, WPX_SEEK_SET);
+ /* Try first to see whether the 512 bytes header is missing */
+ input->seek(10, WPX_SEEK_CUR);
+ if ((0x0011 == readU16(input)) && (0x02FF == readU16(input)))
+ input->seek(0, WPX_SEEK_CUR);
+ /* Ok, let us now skip the first 512 bytes and restart */
+ else
+ {
+ input->seek(512 + 10, WPX_SEEK_SET);
+ if ((0x0011 == readU16(input)) && (0x02FF == readU16(input)))
+ input->seek(512, WPX_SEEK_SET);
+ else
+ {
+ input->seek(0, WPX_SEEK_SET);
+ PICT_DEBUG_MSG(("No Pict2 header present\n"));
+ return false;
+ }
+ }
+ /* Now, we should be out or at the beginning of the Pict1 file */
+ PICT_DEBUG_MSG(("Reading Pict2 header\n"));
+ m_fileSize = readU16(input);
+ m_top = readU16(input);
+ m_left = readU16(input);
+ m_bottom = readU16(input);
+ m_right = readU16(input);
+ if (0x0011 != readU16(input))
+ {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ if (0x02FF != readU16(input))
+ {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ if (0x0C00 != readU16(input))
+ {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ else
+ 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);
+ m_pictVersion = 2;
+ return true;
}
diff --git a/src/lib/PictHeader.h b/src/lib/PictHeader.h
index 26101b7..d910634 100644
--- a/src/lib/PictHeader.h
+++ b/src/lib/PictHeader.h
@@ -25,60 +25,60 @@
class PictHeader
{
public:
- PictHeader();
+ PictHeader();
- bool load(WPXInputStream *input);
+ bool load(WPXInputStream *input);
- unsigned long startOfDocument() const
- {
- return m_dataStart;
- }
+ unsigned long startOfDocument() const
+ {
+ return m_dataStart;
+ }
- int getVersion() const
- {
- return m_pictVersion;
- }
+ int getVersion() const
+ {
+ return m_pictVersion;
+ }
- unsigned getTop() const
- {
- return m_top;
- }
- unsigned getLeft() const
- {
- return m_left;
- }
- unsigned getBottom() const
- {
- return m_bottom;
- }
- unsigned getRight() const
- {
- return m_right;
- }
- unsigned getHorizontalResolution() const
- {
- return m_horizontalResolution;
- }
- unsigned getVerticalResolution() const
- {
- return m_verticalResolution;
- }
+ unsigned getTop() const
+ {
+ return m_top;
+ }
+ unsigned getLeft() const
+ {
+ return m_left;
+ }
+ unsigned getBottom() const
+ {
+ return m_bottom;
+ }
+ unsigned getRight() const
+ {
+ return m_right;
+ }
+ unsigned getHorizontalResolution() const
+ {
+ return m_horizontalResolution;
+ }
+ unsigned getVerticalResolution() const
+ {
+ return m_verticalResolution;
+ }
private:
- unsigned short m_fileSize;
- unsigned short m_top;
- unsigned short m_left;
- unsigned short m_bottom;
- unsigned short m_right;
- unsigned char m_pictVersion;
- unsigned long m_horizontalResolution;
- unsigned long m_verticalResolution;
- unsigned long m_pictureSize;
- unsigned long m_dataStart;
+ unsigned short m_fileSize;
+ unsigned short m_top;
+ unsigned short m_left;
+ unsigned short m_bottom;
+ unsigned short m_right;
+ unsigned char m_pictVersion;
+ unsigned long m_horizontalResolution;
+ unsigned long m_verticalResolution;
+ unsigned long m_pictureSize;
+ unsigned long m_dataStart;
- bool loadPict1Header(WPXInputStream *input);
- bool loadPict2Header(WPXInputStream *input);
+ bool loadPict1Header(WPXInputStream *input);
+ bool loadPict2Header(WPXInputStream *input);
};
#endif // PictHEADER
diff --git a/src/lib/PictImage.cpp b/src/lib/PictImage.cpp
index ad78e13..7b3e026 100644
--- a/src/lib/PictImage.cpp
+++ b/src/lib/PictImage.cpp
@@ -35,13 +35,13 @@ stream is a Macintosh Pict Image that libpict is able to parse
*/
bool libpict::PictImage::isSupported(WPXInputStream *input)
{
- input->seek(0, WPX_SEEK_SET);
+ input->seek(0, WPX_SEEK_SET);
- PictHeader header;
- if(!header.load(input))
- return false;
+ PictHeader header;
+ if(!header.load(input))
+ return false;
- return true;
+ return true;
}
/**
@@ -54,41 +54,41 @@ WPGPaintInterface class implementation when needed. This is often commonly calle
*/
bool libpict::PictImage::parse(::WPXInputStream *input, libwpg::WPGPaintInterface *painter)
{
- PictXParser *parser = 0;
+ PictXParser *parser = 0;
- input->seek(0, WPX_SEEK_SET);
+ input->seek(0, WPX_SEEK_SET);
- PICT_DEBUG_MSG(("Loading header...\n"));
- PictHeader header;
- if(!header.load(input))
- return false;
+ PICT_DEBUG_MSG(("Loading header...\n"));
+ PictHeader header;
+ if(!header.load(input))
+ return false;
- // seek to the start of document
- input->seek(header.startOfDocument(), WPX_SEEK_SET);
- unsigned char tmpVersion = header.getVersion();
+ // seek to the start of document
+ input->seek(header.startOfDocument(), WPX_SEEK_SET);
+ unsigned char tmpVersion = header.getVersion();
- bool retval;
- switch (tmpVersion)
- {
- case 0x01: // Pict1
- PICT_DEBUG_MSG(("Parsing Pict1\n"));
- parser = new Pict1Parser(input, painter);
- retval = parser->parse();
- break;
- case 0x02: // Pict2
- PICT_DEBUG_MSG(("Parsing Pict2\n"));
- parser = new Pict2Parser(input, painter);
- retval = parser->parse();
- break;
- default: // other :-)
- PICT_DEBUG_MSG(("Unknown format\n"));
- return false;
- }
+ bool retval;
+ switch (tmpVersion)
+ {
+ case 0x01: // Pict1
+ PICT_DEBUG_MSG(("Parsing Pict1\n"));
+ parser = new Pict1Parser(input, painter);
+ retval = parser->parse();
+ break;
+ case 0x02: // Pict2
+ PICT_DEBUG_MSG(("Parsing Pict2\n"));
+ parser = new Pict2Parser(input, painter);
+ retval = parser->parse();
+ break;
+ default: // other :-)
+ PICT_DEBUG_MSG(("Unknown format\n"));
+ return false;
+ }
- if (parser)
- delete parser;
+ if (parser)
+ delete parser;
- return retval;
+ return retval;
}
/**
@@ -100,12 +100,12 @@ Provided as a convenience function for applications that support SVG internally.
*/
bool libpict::PictImage::generateSVG(::WPXInputStream *input, WPXString &output)
{
- std::ostringstream tmpOutputStream;
- libpict::PictSVGGenerator generator(tmpOutputStream);
- bool result = libpict::PictImage::parse(input, &generator);
- if (result)
- output = WPXString(tmpOutputStream.str().c_str());
- else
- output = WPXString("");
- return result;
+ std::ostringstream tmpOutputStream;
+ libpict::PictSVGGenerator generator(tmpOutputStream);
+ bool result = libpict::PictImage::parse(input, &generator);
+ if (result)
+ output = WPXString(tmpOutputStream.str().c_str());
+ else
+ output = WPXString("");
+ return result;
}
diff --git a/src/lib/PictSVGGenerator.cpp b/src/lib/PictSVGGenerator.cpp
index 7325c14..16a4012 100644
--- a/src/lib/PictSVGGenerator.cpp
+++ b/src/lib/PictSVGGenerator.cpp
@@ -24,19 +24,19 @@
static std::string doubleToString(const double value)
{
- std::ostringstream tempStream;
- tempStream << value;
- std::string decimalPoint(localeconv()->decimal_point);
- if ((decimalPoint.size() == 0) || (decimalPoint == "."))
- return tempStream.str();
- std::string stringValue(tempStream.str());
- if (!stringValue.empty())
- {
- std::string::size_type pos;
- while ((pos = stringValue.find(decimalPoint)) != std::string::npos)
- stringValue.replace(pos,decimalPoint.size(),".");
- }
- return stringValue;
+ std::ostringstream tempStream;
+ tempStream << value;
+ std::string decimalPoint(localeconv()->decimal_point);
+ if ((decimalPoint.size() == 0) || (decimalPoint == "."))
+ return tempStream.str();
+ std::string stringValue(tempStream.str());
+ if (!stringValue.empty())
+ {
+ std::string::size_type pos;
+ while ((pos = stringValue.find(decimalPoint)) != std::string::npos)
+ stringValue.replace(pos,decimalPoint.size(),".");
+ }
+ return stringValue;
}
@@ -50,293 +50,293 @@ libpict::PictSVGGenerator::~PictSVGGenerator()
void libpict::PictSVGGenerator::startGraphics(const WPXPropertyList &propList)
{
- m_outputSink << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
- m_outputSink << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"";
- m_outputSink << " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
+ m_outputSink << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
+ m_outputSink << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"";
+ m_outputSink << " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
- m_outputSink << "<!-- Created with pict2svg/libpict -->\n";
+ m_outputSink << "<!-- Created with pict2svg/libpict -->\n";
- m_outputSink << "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ";
- m_outputSink << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" ";
- if (propList["svg:width"])
- m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" ";
- if (propList["svg:height"])
- m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\"";
- m_outputSink << " >\n";
+ m_outputSink << "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ";
+ m_outputSink << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" ";
+ if (propList["svg:width"])
+ m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" ";
+ if (propList["svg:height"])
+ m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\"";
+ m_outputSink << " >\n";
- m_gradientIndex = 1;
+ m_gradientIndex = 1;
}
void libpict::PictSVGGenerator::endGraphics()
{
- m_outputSink << "</svg>\n";
+ m_outputSink << "</svg>\n";
}
void libpict::PictSVGGenerator::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient)
{
- m_style = propList;
+ m_style = propList;
- m_gradient = gradient;
+ m_gradient = gradient;
- if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "gradient" && m_gradient.count())
- {
- double angle = (m_style["draw:angle"] ? m_style["draw:angle"]->getDouble() : 0.0);
+ if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "gradient" && m_gradient.count())
+ {
+ double angle = (m_style["draw:angle"] ? m_style["draw:angle"]->getDouble() : 0.0);
- m_outputSink << "<defs>\n";
- m_outputSink << " <linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n";
- for(unsigned c = 0; c < m_gradient.count(); c++)
- {
- m_outputSink << " <stop offset=\"" << m_gradient[c]["svg:offset"]->getStr().cstr() << "\"";
+ m_outputSink << "<defs>\n";
+ m_outputSink << " <linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n";
+ for(unsigned c = 0; c < m_gradient.count(); c++)
+ {
+ m_outputSink << " <stop offset=\"" << m_gradient[c]["svg:offset"]->getStr().cstr() << "\"";
- m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\"";
- m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getStr().cstr() << "\" />" << std::endl;
+ m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\"";
+ m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getStr().cstr() << "\" />" << std::endl;
- }
- m_outputSink << " </linearGradient>\n";
+ }
+ m_outputSink << " </linearGradient>\n";
- // not a simple horizontal gradient
- if(angle != -90)
- {
- m_outputSink << " <linearGradient xlink:href=\"#grad" << m_gradientIndex-1 << "\"";
- m_outputSink << " id=\"grad" << m_gradientIndex++ << "\" ";
- m_outputSink << "x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" ";
- m_outputSink << "gradientTransform=\"rotate(" << angle << ")\" ";
- m_outputSink << "gradientUnits=\"objectBoundingBox\" >\n";
- m_outputSink << " </linearGradient>\n";
- }
+ // not a simple horizontal gradient
+ if(angle != -90)
+ {
+ m_outputSink << " <linearGradient xlink:href=\"#grad" << m_gradientIndex-1 << "\"";
+ m_outputSink << " id=\"grad" << m_gradientIndex++ << "\" ";
+ m_outputSink << "x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" ";
+ m_outputSink << "gradientTransform=\"rotate(" << angle << ")\" ";
+ m_outputSink << "gradientUnits=\"objectBoundingBox\" >\n";
+ m_outputSink << " </linearGradient>\n";
+ }
- m_outputSink << "</defs>\n";
- }
+ m_outputSink << "</defs>\n";
+ }
}
void libpict::PictSVGGenerator::startLayer(const ::WPXPropertyList &propList)
{
- m_outputSink << "<g id=\"Layer" << propList["svg:id"]->getInt() << "\" >\n";
+ m_outputSink << "<g id=\"Layer" << propList["svg:id"]->getInt() << "\" >\n";
}
void libpict::PictSVGGenerator::endLayer()
{
- m_outputSink << "</g>\n";
+ m_outputSink << "</g>\n";
}
void libpict::PictSVGGenerator::drawRectangle(const ::WPXPropertyList &propList)
{
- m_outputSink << "<rect ";
- m_outputSink << "x=\"" << doubleToString(72*propList["svg:x"]->getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" ";
- m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" ";
- if((propList["svg:rx"] && propList["svg:rx"]->getInt() !=0) || (propList["svg:ry"] && propList["svg:ry"]->getInt() !=0))
- m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" ";
- writeStyle();
- m_outputSink << "/>\n";
+ m_outputSink << "<rect ";
+ m_outputSink << "x=\"" << doubleToString(72*propList["svg:x"]->getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" ";
+ m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" ";
+ if((propList["svg:rx"] && propList["svg:rx"]->getInt() !=0) || (propList["svg:ry"] && propList["svg:ry"]->getInt() !=0))
+ m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" ";
+ writeStyle();
+ m_outputSink << "/>\n";
}
void libpict::PictSVGGenerator::drawEllipse(const WPXPropertyList &propList)
{
- m_outputSink << "<ellipse ";
- m_outputSink << "cx=\"" << doubleToString(72*propList["svg:cx"]->getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" ";
- m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" ";
- writeStyle();
- if (propList["libpict:rotate"] && propList["libpict:rotate"]->getDouble() != 0.0)
- m_outputSink << " transform=\" translate(" << doubleToString(72*propList["svg:cx"]->getDouble()) << ", " << doubleToString(72*propList["svg:cy"]->getDouble())
- << ") rotate(" << doubleToString(-propList["libpict:rotate"]->getDouble())
- << ") translate(" << doubleToString(-72*propList["svg:cx"]->getDouble())
- << ", " << doubleToString(-72*propList["svg:cy"]->getDouble())
- << ")\" ";
- m_outputSink << "/>\n";
+ m_outputSink << "<ellipse ";
+ m_outputSink << "cx=\"" << doubleToString(72*propList["svg:cx"]->getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" ";
+ m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" ";
+ writeStyle();
+ if (propList["libpict:rotate"] && propList["libpict:rotate"]->getDouble() != 0.0)
+ m_outputSink << " transform=\" translate(" << doubleToString(72*propList["svg:cx"]->getDouble()) << ", " << doubleToString(72*propList["svg:cy"]->getDouble())
+ << ") rotate(" << doubleToString(-propList["libpict:rotate"]->getDouble())
+ << ") translate(" << doubleToString(-72*propList["svg:cx"]->getDouble())
+ << ", " << doubleToString(-72*propList["svg:cy"]->getDouble())
+ << ")\" ";
+ m_outputSink << "/>\n";
}
void libpict::PictSVGGenerator::drawPolyline(const ::WPXPropertyListVector &vertices)
{
- drawPolySomething(vertices, false);
+ drawPolySomething(vertices, false);
}
void libpict::PictSVGGenerator::drawPolygon(const ::WPXPropertyListVector &vertices)
{
- drawPolySomething(vertices, true);
+ drawPolySomething(vertices, true);
}
void libpict::PictSVGGenerator::drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed)
{
- if(vertices.count() < 2)
- return;
-
- if(vertices.count() == 2)
- {
- m_outputSink << "<line ";
- m_outputSink << "x1=\"" << doubleToString(72*(vertices[0]["svg:x"]->getDouble())) << "\" y1=\"" << doubleToString(72*(vertices[0]["svg:y"]->getDouble())) << "\" ";
- m_outputSink << "x2=\"" << doubleToString(72*(vertices[1]["svg:x"]->getDouble())) << "\" y2=\"" << doubleToString(72*(vertices[1]["svg:y"]->getDouble())) << "\"\n";
- writeStyle();
- m_outputSink << "/>\n";
- }
- else
- {
- if (isClosed)
- m_outputSink << "<polygon ";
- else
- m_outputSink << "<polyline ";
-
- m_outputSink << "points=\"";
- for(unsigned i = 0; i < vertices.count(); i++)
- {
- m_outputSink << doubleToString(72*(vertices[i]["svg:x"]->getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble()));
- if (i < vertices.count()-1)
- m_outputSink << ", ";
- }
- m_outputSink << "\"\n";
- writeStyle(isClosed);
- m_outputSink << "/>\n";
- }
+ if(vertices.count() < 2)
+ return;
+
+ if(vertices.count() == 2)
+ {
+ m_outputSink << "<line ";
+ m_outputSink << "x1=\"" << doubleToString(72*(vertices[0]["svg:x"]->getDouble())) << "\" y1=\"" << doubleToString(72*(vertices[0]["svg:y"]->getDouble())) << "\" ";
+ m_outputSink << "x2=\"" << doubleToString(72*(vertices[1]["svg:x"]->getDouble())) << "\" y2=\"" << doubleToString(72*(vertices[1]["svg:y"]->getDouble())) << "\"\n";
+ writeStyle();
+ m_outputSink << "/>\n";
+ }
+ else
+ {
+ if (isClosed)
+ m_outputSink << "<polygon ";
+ else
+ m_outputSink << "<polyline ";
+
+ m_outputSink << "points=\"";
+ for(unsigned i = 0; i < vertices.count(); i++)
+ {
+ m_outputSink << doubleToString(72*(vertices[i]["svg:x"]->getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble()));
+ if (i < vertices.count()-1)
+ m_outputSink << ", ";
+ }
+ m_outputSink << "\"\n";
+ writeStyle(isClosed);
+ m_outputSink << "/>\n";
+ }
}
void libpict::PictSVGGenerator::drawPath(const ::WPXPropertyListVector &path)
{
- m_outputSink << "<path d=\" ";
- bool isClosed = false;
- unsigned i=0;
- for(i=0; i < path.count(); i++)
- {
- WPXPropertyList propList = path[i];
- if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "M")
- {
- m_outputSink << "\nM";
- m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
- }
- else if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "L")
- {
- m_outputSink << "\nL";
- m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
- }
- else if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "C")
- {
- m_outputSink << "\nC";
- m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " ";
- m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " ";
- m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
- }
- else if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "A")
- {
- m_outputSink << "\nA";
- m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " ";
- m_outputSink << (propList["libpict:rotate"] ? propList["libpict:rotate"]->getStr().cstr() : "0") << " ";
- m_outputSink << "0,0 ";
- m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
- }
- else if ((i >= path.count()-1 && i > 2) && propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "Z" )
- {
- isClosed = true;
- m_outputSink << "\nZ";
- }
- }
-
- m_outputSink << "\" \n";
- writeStyle(isClosed);
- m_outputSink << "/>\n";
+ m_outputSink << "<path d=\" ";
+ bool isClosed = false;
+ unsigned i=0;
+ for(i=0; i < path.count(); i++)
+ {
+ WPXPropertyList propList = path[i];
+ if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "M")
+ {
+ m_outputSink << "\nM";
+ m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
+ }
+ else if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "L")
+ {
+ m_outputSink << "\nL";
+ m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
+ }
+ else if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "C")
+ {
+ m_outputSink << "\nC";
+ m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " ";
+ m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " ";
+ m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
+ }
+ else if (propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "A")
+ {
+ m_outputSink << "\nA";
+ m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " ";
+ m_outputSink << (propList["libpict:rotate"] ? propList["libpict:rotate"]->getStr().cstr() : "0") << " ";
+ m_outputSink << "0,0 ";
+ m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble()));
+ }
+ else if ((i >= path.count()-1 && i > 2) && propList["libpict:path-action"] && propList["libpict:path-action"]->getStr() == "Z" )
+ {
+ isClosed = true;
+ m_outputSink << "\nZ";
+ }
+ }
+
+ m_outputSink << "\" \n";
+ writeStyle(isClosed);
+ m_outputSink << "/>\n";
}
void libpict::PictSVGGenerator::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData)
{
- if (!propList["libpict:mime-type"] || propList["libpict:mime-type"]->getStr().len() <= 0)
- return;
- WPXString base64 = binaryData.getBase64Data();
- m_outputSink << "<image ";
- if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"])
- m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" ";
- m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\" ";
- m_outputSink << "xlink:href=\"data:" << propList["libpict:mime-type"]->getStr().cstr() << ";base64,";
- m_outputSink << base64.cstr();
- m_outputSink << "\" />\n";
+ if (!propList["libpict:mime-type"] || propList["libpict:mime-type"]->getStr().len() <= 0)
+ return;
+ WPXString base64 = binaryData.getBase64Data();
+ m_outputSink << "<image ";
+ if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"])
+ m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" ";
+ m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\" ";
+ m_outputSink << "xlink:href=\"data:" << propList["libpict:mime-type"]->getStr().cstr() << ";base64,";
+ m_outputSink << base64.cstr();
+ m_outputSink << "\" />\n";
}
void libpict::PictSVGGenerator::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector & /* path */)
{
- m_outputSink << "<text ";
- if (propList["svg:x"] && propList["svg:y"])
- m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\">\n";
+ m_outputSink << "<text ";
+ if (propList["svg:x"] && propList["svg:y"])
+ m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\">\n";
}
void libpict::PictSVGGenerator::endTextObject()
{
- m_outputSink << "</text>\n";
+ m_outputSink << "</text>\n";
}
void libpict::PictSVGGenerator::startTextSpan(const ::WPXPropertyList &propList)
{
- m_outputSink << "<tspan ";
- if (propList["style:font-name"])
- m_outputSink << "font-family=\"" << propList["style:font-name"]->getStr().cstr() << "\" ";
- if (propList["fo:font-style"])
- m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" ";
- if (propList["fo:font-weight"])
- m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" ";
- if (propList["fo:font-variant"])
- m_outputSink << "font-variant=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" ";
- if (propList["fo:font-size"])
- m_outputSink << "font-size=\"" << propList["fo:font-size"]->getStr().cstr() << "\" ";
- if (propList["fo:color"])
- m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" ";
- m_outputSink << ">\n";
+ m_outputSink << "<tspan ";
+ if (propList["style:font-name"])
+ m_outputSink << "font-family=\"" << propList["style:font-name"]->getStr().cstr() << "\" ";
+ if (propList["fo:font-style"])
+ m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" ";
+ if (propList["fo:font-weight"])
+ m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" ";
+ if (propList["fo:font-variant"])
+ m_outputSink << "font-variant=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" ";
+ if (propList["fo:font-size"])
+ m_outputSink << "font-size=\"" << propList["fo:font-size"]->getStr().cstr() << "\" ";
+ if (propList["fo:color"])
+ m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" ";
+ m_outputSink << ">\n";
}
void libpict::PictSVGGenerator::endTextSpan()
{
- m_outputSink << "</tspan>\n";
+ m_outputSink << "</tspan>\n";
}
void libpict::PictSVGGenerator::insertText(const ::WPXString &str)
{
- WPXString tempUTF8(str, true);
- m_outputSink << tempUTF8.cstr() << "\n";
+ WPXString tempUTF8(str, true);
+ m_outputSink << tempUTF8.cstr() << "\n";
}
// create "style" attribute based on current pen and brush
void libpict::PictSVGGenerator::writeStyle(bool /* isClosed */)
{
- m_outputSink << "style=\"";
+ m_outputSink << "style=\"";
- if (m_style["svg:stroke-width"])
- m_outputSink << "stroke-width: " << doubleToString(72*m_style["svg:stroke-width"]->getDouble()) << "; ";
+ if (m_style["svg:stroke-width"])
+ m_outputSink << "stroke-width: " << doubleToString(72*m_style["svg:stroke-width"]->getDouble()) << "; ";
- if((m_style["svg:stroke-width"] && m_style["svg:stroke-width"]->getDouble() > 0.0) || (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "solid"))
- {
- if (m_style["svg:stroke-color"])
- m_outputSink << "stroke: " << m_style["svg:stroke-color"]->getStr().cstr() << "; ";
- if(m_style["svg:stroke-opacity"] && m_style["svg:stroke-opacity"]->getInt()!= 1)
- m_outputSink << "stroke-opacity: " << doubleToString(m_style["svg:stroke-opacity"]->getDouble()) << "; ";
- }
+ if((m_style["svg:stroke-width"] && m_style["svg:stroke-width"]->getDouble() > 0.0) || (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "solid"))
+ {
+ if (m_style["svg:stroke-color"])
+ m_outputSink << "stroke: " << m_style["svg:stroke-color"]->getStr().cstr() << "; ";
+ if(m_style["svg:stroke-opacity"] && m_style["svg:stroke-opacity"]->getInt()!= 1)
+ m_outputSink << "stroke-opacity: " << doubleToString(m_style["svg:stroke-opacity"]->getDouble()) << "; ";
+ }
- if(!m_style["draw:stroke"] || !(m_style["draw:stroke"]->getStr() == "solid"))
- {
+ if(!m_style["draw:stroke"] || !(m_style["draw:stroke"]->getStr() == "solid"))
+ {
#if 0
- if (m_dashArray.count())
- {
- m_outputSink << "stroke-dasharray: ";
- for(unsigned i = 0; i < m_dashArray.count(); i++)
- {
- m_outputSink << doubleToString(72*m_dashArray.at(i)*m_style["svg:stroke_width"]->getDouble());
- if(i < m_dashArray.count()-1)
- m_outputSink << ", ";
- }
- m_outputSink << "; ";
- }
+ if (m_dashArray.count())
+ {
+ m_outputSink << "stroke-dasharray: ";
+ for(unsigned i = 0; i < m_dashArray.count(); i++)
+ {
+ m_outputSink << doubleToString(72*m_dashArray.at(i)*m_style["svg:stroke_width"]->getDouble());
+ if(i < m_dashArray.count()-1)
+ m_outputSink << ", ";
+ }
+ m_outputSink << "; ";
+ }
#endif
- }
+ }
- if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none")
- m_outputSink << "fill: none; ";
+ if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none")
+ m_outputSink << "fill: none; ";
- if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap")
- if(m_style["svg:fill-rule"])
- m_outputSink << "fill-rule: " << m_style["svg:fill-rule"]->getStr().cstr() << "; ";
+ if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap")
+ if(m_style["svg:fill-rule"])
+ m_outputSink << "fill-rule: " << m_style["svg:fill-rule"]->getStr().cstr() << "; ";
- if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient")
- m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); ";
- if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient")
- m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); ";
+ if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient")
+ m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); ";
+ if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient")
+ m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); ";
- if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "solid")
- if (m_style["draw:fill-color"])
- m_outputSink << "fill: " << m_style["draw:fill-color"]->getStr().cstr() << "; ";
+ if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "solid")
+ if (m_style["draw:fill-color"])
+ m_outputSink << "fill: " << m_style["draw:fill-color"]->getStr().cstr() << "; ";
- m_outputSink << "\""; // style
+ m_outputSink << "\""; // style
}
diff --git a/src/lib/PictSVGGenerator.h b/src/lib/PictSVGGenerator.h
index e6caab5..9300133 100644
--- a/src/lib/PictSVGGenerator.h
+++ b/src/lib/PictSVGGenerator.h
@@ -39,40 +39,40 @@ namespace libpict
class PictSVGGenerator : public libwpg::WPGPaintInterface
{
public:
- PictSVGGenerator(std::ostream &output_sink);
- ~PictSVGGenerator();
+ PictSVGGenerator(std::ostream &output_sink);
+ ~PictSVGGenerator();
- void startGraphics(const ::WPXPropertyList &propList);
- void endGraphics();
- void startLayer(const ::WPXPropertyList &propList);
- void endLayer();
- void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {}
- void endEmbeddedGraphics() {}
+ void startGraphics(const ::WPXPropertyList &propList);
+ void endGraphics();
+ void startLayer(const ::WPXPropertyList &propList);
+ void endLayer();
+ void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {}
+ void endEmbeddedGraphics() {}
- void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
+ void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
- void drawRectangle(const ::WPXPropertyList &propList);
- void drawEllipse(const ::WPXPropertyList &propList);
- void drawPolyline(const ::WPXPropertyListVector &vertices);
- void drawPolygon(const ::WPXPropertyListVector &vertices);
- void drawPath(const ::WPXPropertyListVector &path);
- void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
- void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
- void endTextObject();
- void startTextLine(const ::WPXPropertyList & /* propList */) {}
- void endTextLine() {}
- void startTextSpan(const ::WPXPropertyList &propList);
- void endTextSpan();
- void insertText(const ::WPXString &str);
+ void drawRectangle(const ::WPXPropertyList &propList);
+ void drawEllipse(const ::WPXPropertyList &propList);
+ void drawPolyline(const ::WPXPropertyListVector &vertices);
+ void drawPolygon(const ::WPXPropertyListVector &vertices);
+ void drawPath(const ::WPXPropertyListVector &path);
+ void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
+ void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
+ void endTextObject();
+ void startTextLine(const ::WPXPropertyList & /* propList */) {}
+ void endTextLine() {}
+ void startTextSpan(const ::WPXPropertyList &propList);
+ void endTextSpan();
+ void insertText(const ::WPXString &str);
private:
- ::WPXPropertyListVector m_gradient;
- ::WPXPropertyList m_style;
- int m_gradientIndex;
- void writeStyle(bool isClosed=true);
- void drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed);
+ ::WPXPropertyListVector m_gradient;
+ ::WPXPropertyList m_style;
+ int m_gradientIndex;
+ void writeStyle(bool isClosed=true);
+ void drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed);
- std::ostream &m_outputSink;
+ std::ostream &m_outputSink;
};
} // namespace libpict
diff --git a/src/lib/PictXParser.cpp b/src/lib/PictXParser.cpp
index 65c0b98..698dc90 100644
--- a/src/lib/PictXParser.cpp
+++ b/src/lib/PictXParser.cpp
@@ -21,87 +21,87 @@
#include "libpict_utils.h"
PictXParser::PictXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter):
- m_input(input), m_painter(painter), m_colorPalette(std::map<int,libpict::PictColor>())
+ m_input(input), m_painter(painter), m_colorPalette(std::map<int,libpict::PictColor>())
{
}
PictXParser::PictXParser(const PictXParser &parser):
- m_input(parser.m_input), m_painter(parser.m_painter),
- m_colorPalette(parser.m_colorPalette)
+ m_input(parser.m_input), m_painter(parser.m_painter),
+ m_colorPalette(parser.m_colorPalette)
{
}
unsigned char PictXParser::readU8()
{
- if (!m_input || m_input->atEOS())
- return (unsigned char)0;
- unsigned long numBytesRead;
- unsigned char const *p = m_input->read(sizeof(unsigned char), numBytesRead);
+ if (!m_input || m_input->atEOS())
+ return (unsigned char)0;
+ unsigned long numBytesRead;
+ unsigned char const *p = m_input->read(sizeof(unsigned char), numBytesRead);
- if (p && numBytesRead == 1)
- return *(unsigned char const *)(p);
- return (unsigned char)0;
+ if (p && numBytesRead == 1)
+ return *(unsigned char const *)(p);
+ return (unsigned char)0;
}
unsigned short PictXParser::readU16()
{
- unsigned short p0 = (unsigned short)readU8();
- unsigned short p1 = (unsigned short)readU8();
- return (unsigned short)(p1|(p0<<8));
+ unsigned short p0 = (unsigned short)readU8();
+ unsigned short p1 = (unsigned short)readU8();
+ return (unsigned short)(p1|(p0<<8));
}
unsigned PictXParser::readU32()
{
- unsigned p0 = (unsigned)readU8();
- unsigned p1 = (unsigned)readU8();
- unsigned p2 = (unsigned)readU8();
- unsigned p3 = (unsigned)readU8();
- return (unsigned long)(p3|(p2<<8)|(p1<<16)|(p0<<24));
+ unsigned p0 = (unsigned)readU8();
+ unsigned p1 = (unsigned)readU8();
+ unsigned p2 = (unsigned)readU8();
+ unsigned p3 = (unsigned)readU8();
+ return (unsigned long)(p3|(p2<<8)|(p1<<16)|(p0<<24));
}
short PictXParser::readS16()
{
- return (short)readU16();
+ return (short)readU16();
}
int PictXParser::readS32()
{
- return (int)readU32();
+ return (int)readU32();
}
unsigned PictXParser::readVariableLengthInteger()
{
- // read a byte
- unsigned char value8 = readU8();
- // if it's in the range 0-0xFE, then we have a 8-bit value
- if (value8<=0xFE)
- {
- return (unsigned)value8;
- }
- else
- {
- // now read a 16 bit value
- unsigned short value16 = readU16();
- // if the MSB is 1, we have a 32 bit value
- if (value16>>15)
- {
- // read the next 16 bit value (LSB part, in value16 resides the MSB part)
- unsigned long lvalue16 = readU16();
- unsigned long value32 = value16 & 0x7fff; // mask out the MSB
- return (value32<<16)+lvalue16;
- }
- else
- {
- // we have a 16 bit value, return it
- return (unsigned)value16;
- }
- }
+ // read a byte
+ unsigned char value8 = readU8();
+ // if it's in the range 0-0xFE, then we have a 8-bit value
+ if (value8<=0xFE)
+ {
+ return (unsigned)value8;
+ }
+ else
+ {
+ // now read a 16 bit value
+ unsigned short value16 = readU16();
+ // if the MSB is 1, we have a 32 bit value
+ if (value16>>15)
+ {
+ // read the next 16 bit value (LSB part, in value16 resides the MSB part)
+ unsigned long lvalue16 = readU16();
+ unsigned long value32 = value16 & 0x7fff; // mask out the MSB
+ return (value32<<16)+lvalue16;
+ }
+ else
+ {
+ // we have a 16 bit value, return it
+ return (unsigned)value16;
+ }
+ }
}
PictXParser &PictXParser::operator=(const PictXParser &parser)
{
- m_input = parser.m_input;
- m_painter = parser.m_painter;
- m_colorPalette = parser.m_colorPalette;
- return *this;
+ m_input = parser.m_input;
+ m_painter = parser.m_painter;
+ m_colorPalette = parser.m_colorPalette;
+ return *this;
}
diff --git a/src/lib/PictXParser.h b/src/lib/PictXParser.h
index e9bd541..3159284 100644
--- a/src/lib/PictXParser.h
+++ b/src/lib/PictXParser.h
@@ -38,23 +38,23 @@
class PictXParser
{
public:
- PictXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
- PictXParser(const PictXParser &parser);
- virtual ~PictXParser() {};
- virtual bool parse() = 0;
-
- unsigned char readU8();
- unsigned short readU16();
- unsigned readU32();
- short readS16();
- int readS32();
- unsigned readVariableLengthInteger();
- PictXParser &operator=(const PictXParser &parser);
+ PictXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
+ PictXParser(const PictXParser &parser);
+ virtual ~PictXParser() {};
+ virtual bool parse() = 0;
+
+ unsigned char readU8();
+ unsigned short readU16();
+ unsigned readU32();
+ short readS16();
+ int readS32();
+ unsigned readVariableLengthInteger();
+ PictXParser &operator=(const PictXParser &parser);
protected:
- WPXInputStream *m_input;
- libwpg::WPGPaintInterface *m_painter;
- std::map<int,libpict::PictColor> m_colorPalette;
+ WPXInputStream *m_input;
+ libwpg::WPGPaintInterface *m_painter;
+ std::map<int,libpict::PictColor> m_colorPalette;
};