diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-01-13 17:36:19 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-01-13 17:36:19 +0100 |
commit | a528cce721e6c9eddafefe82164ca189daa108b5 (patch) | |
tree | 207d7a69df225e3b350946dfd862cdcc17d7af75 | |
parent | 2a640354cc0d435e6c03f1c2a49cbe3eb80065dc (diff) |
create dummy handlers for Pict1 opcodes
-rw-r--r-- | src/lib/Pict1Parser.cpp | 1265 | ||||
-rw-r--r-- | src/lib/Pict1Parser.h | 151 |
2 files changed, 550 insertions, 866 deletions
diff --git a/src/lib/Pict1Parser.cpp b/src/lib/Pict1Parser.cpp index 75e5964..360ca07 100644 --- a/src/lib/Pict1Parser.cpp +++ b/src/lib/Pict1Parser.cpp @@ -14,8 +14,8 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA * * For further information visit http://libpict.sourceforge.net @@ -30,128 +30,9 @@ #include <libwpd/libwpd.h> #include <libwpg/libwpg.h> -static const unsigned char defaultPict1PaletteRed[] = { - 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, - 0xC0, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x14, 0x20, 0x2C, 0x38, 0x45, 0x51, 0x61, - 0x71, 0x82, 0x92, 0xA2, 0xB6, 0xCB, 0xE3, 0xFF, - 0x00, 0x41, 0x7D, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0x7D, 0x41, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7D, 0x9E, 0xBE, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xBE, 0x9E, - 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, - 0xB6, 0xC7, 0xDB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xDB, 0xC7, - 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0x00, 0x1C, 0x38, 0x55, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x55, 0x38, 0x1C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x45, 0x55, 0x61, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x61, 0x55, 0x45, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, - 0x51, 0x59, 0x61, 0x69, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x69, 0x61, 0x59, - 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, - 0x00, 0x10, 0x20, 0x30, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x30, 0x20, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x28, 0x30, 0x38, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x38, 0x30, 0x28, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x3C, 0x30, 0x34, 0x3C, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x3C, 0x34, 0x30, - 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -static const unsigned char defaultPict1PaletteGreen[] = { - 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x3F, 0x7F, - 0xC0, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, - 0x00, 0x14, 0x20, 0x2C, 0x38, 0x45, 0x51, 0x61, - 0x71, 0x82, 0x92, 0xA2, 0xB6, 0xCB, 0xE3, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x41, 0x7D, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0x7D, 0x41, - 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, - 0x7D, 0x9E, 0xBE, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xBE, 0x9E, - 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0xB6, 0xC7, 0xDB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, - 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xDB, 0xC7, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1C, 0x38, 0x55, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x55, 0x38, 0x1C, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, - 0x38, 0x45, 0x55, 0x61, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x61, 0x55, 0x45, - 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, - 0x51, 0x59, 0x61, 0x69, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x69, 0x61, 0x59, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x20, 0x30, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x30, 0x20, 0x10, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x28, 0x30, 0x38, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x38, 0x30, 0x28, - 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, - 0x3C, 0x30, 0x34, 0x3C, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x3C, 0x34, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -static const unsigned char defaultPict1PaletteBlue[] = { - 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, - 0xC0, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0x14, 0x20, 0x2C, 0x38, 0x45, 0x51, 0x61, - 0x71, 0x82, 0x92, 0xA2, 0xB6, 0xCB, 0xE3, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0x7D, 0x41, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x41, 0x7D, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xBE, 0x9E, - 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, - 0x7D, 0x9E, 0xBE, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xDB, 0xC7, - 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0xB6, 0xC7, 0xDB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x55, 0x38, 0x1C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1C, 0x38, 0x55, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x61, 0x55, 0x45, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, - 0x38, 0x45, 0x55, 0x61, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x69, 0x61, 0x59, - 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, - 0x51, 0x59, 0x61, 0x69, 0x71, 0x71, 0x71, 0x71, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x30, 0x20, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x20, 0x30, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x38, 0x30, 0x28, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x28, 0x30, 0x38, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x3C, 0x34, 0x30, - 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, - 0x2C, 0x30, 0x34, 0x3C, 0x41, 0x41, 0x41, 0x41, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - - Pict1Parser::Pict1Parser(WPXInputStream *input, libwpg::WPGPaintInterface* painter): - PictXParser(input, painter), - m_recordLength(0), m_recordEnd(0), - m_success(true), m_exit(false), m_graphicsStarted(false), - m_width(0), m_height(0), m_style(), - m_penForeColor(0,0,0), - m_penBackColor(0xff,0xff,0xff), - m_brushForeColor(0,0,0), - m_brushBackColor(0xff,0xff,0xff), - m_dashArray(), m_gradient() -{ - m_style.insert("draw:fill", "solid"); - m_style.insert("svg:stroke-color", m_penForeColor.getColorString()); - m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT); - m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); - m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); + PictXParser(input, painter) +{ } bool Pict1Parser::parse() @@ -163,61 +44,123 @@ bool Pict1Parser::parse() int type; const char *name; Method handler; + int size; }; static const struct RecordHandler handlers[] = { - { 0x01, "Fill Attributes", &Pict1Parser::handleFillAttributes }, - { 0x02, "Line Attributes", &Pict1Parser::handleLineAttributes }, - { 0x03, "Marker Atttibutes", 0 }, - { 0x04, "Polymarker", 0 }, - { 0x05, "Line", &Pict1Parser::handleLine }, - { 0x06, "Polyline", &Pict1Parser::handlePolyline }, - { 0x07, "Rectangle", &Pict1Parser::handleRectangle }, - { 0x08, "Polygon", &Pict1Parser::handlePolygon }, - { 0x09, "Ellipse", &Pict1Parser::handleEllipse }, - { 0x0a, "Reserved", 0 }, - { 0x0b, "Bitmap (Type 1)", &Pict1Parser::handleBitmapTypeOne }, - { 0x0c, "Graphics Text (Type 1)", &Pict1Parser::handleGraphicsTextTypeOne }, - { 0x0d, "Graphics Text Attributes", &Pict1Parser::handleGraphicsTextAttributes }, - { 0x0e, "Colormap", &Pict1Parser::handleColormap }, - { 0x0f, "Start Pict", &Pict1Parser::handleStartPict }, - { 0x10, "End Pict", &Pict1Parser::handleEndPict }, - { 0x11, "Postscript Data (Type 1)", &Pict1Parser::handlePostscriptTypeOne }, - { 0x12, "Output Attributes", 0 }, - { 0x13, "Curved Polyline", &Pict1Parser::handleCurvedPolyline }, - { 0x14, "Bitmap (Type 2)", &Pict1Parser::handleBitmapTypeTwo }, - { 0x15, "Start Figure", 0 }, - { 0x16, "Start Chart", 0 }, - { 0x17, "Planperfect Data", 0 }, - { 0x18, "Graphics Text (Type 2)", &Pict1Parser::handleGraphicsTextTypeTwo }, - { 0x19, "Start Pict (Type 2)", 0 }, - { 0x1a, "Graphics Text (Type 3)", 0 }, - { 0x1b, "Postscript Data (Type 2)", &Pict1Parser::handlePostscriptTypeTwo }, - { 0x00, 0, 0 } // end marker - }; - - // initialization - m_recordLength = 0; - m_recordEnd = 0; - m_success = true; - m_exit = false; - m_graphicsStarted = false; - - // default style - m_penForeColor = libpict::PictColor(0,0,0); - m_penBackColor = libpict::PictColor(0,0,0); - m_style.insert("svg:stroke-width", 0.001); - // m_dashArray.height = 0.001; - m_style.insert("libpict:stroke-solid", true); - m_dashArray = libpict::PictDashArray(); - m_brushForeColor = libpict::PictColor(0,0,0); - m_brushBackColor = libpict::PictColor(0,0,0); - m_style.insert("svg:stroke-color", m_penForeColor.getColorString()); - m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT); - m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); - m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); - resetPalette(); + { 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()) { @@ -225,744 +168,418 @@ bool Pict1Parser::parse() long recordPos = m_input->tell(); #endif int recordType = readU8(); - if (recordType == 0) + if (recordType == 0xff) break; - m_recordLength = readVariableLengthInteger(); - m_recordEnd = m_input->tell() + m_recordLength - 1; // search function to handler this record int index = -1; for(int i = 0; (index < 0) && handlers[i].name; i++) if(handlers[i].type == recordType) index = i; - - PICT_DEBUG_MSG(("\n")); + if(index < 0) - PICT_DEBUG_MSG(("Unknown record type 0x%02x at %li size %d\n", - recordType, recordPos, m_recordLength)); + ; else { Method recordHandler = handlers[index].handler; if(!recordHandler) - PICT_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %li size %d\n", - handlers[index].name, recordType, recordPos, m_recordLength)); + ; else { - PICT_DEBUG_MSG(("Record '%s' type 0x%02x at %li size %d\n", - handlers[index].name, recordType, recordPos, m_recordLength)); - // invoke the handler for this record (this->*recordHandler)(); } } - - //if(m_input->tell() > m_recordEnd+1) - { - //PICT_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType)); - PICT_DEBUG_MSG(("Current stream position: %li\n", m_input->tell())); - } - - if(m_exit) break; - - m_input->seek(m_recordEnd+1, WPX_SEEK_SET); } + return true; +} - if (!m_exit) - handleEndPict(); +void Pict1Parser::handleNOP() +{ +} - return m_success; +void Pict1Parser::handleClipRgn() +{ } -void Pict1Parser::handleStartPict() +void Pict1Parser::handleBkPat() +{ +} + +void Pict1Parser::handleTxFont() +{ +} + +void Pict1Parser::handleTxFace() +{ +} + +void Pict1Parser::handleTxMode() +{ +} + +void Pict1Parser::handleSpExtra() +{ +} + +void Pict1Parser::handlePnSize() +{ +} + +void Pict1Parser::handlePnMode() +{ +} + +void Pict1Parser::handlePnPat() { - if (m_graphicsStarted) - { - handleEndPict(); - return; - } - // unsigned char version = readU8(); - // unsigned char bitFlags = readU8(); - m_input->seek(2, WPX_SEEK_CUR); - m_width = readU16(); - m_height = readU16(); - - ::WPXPropertyList propList; - propList.insert("svg:width", (double)m_width/1200.0); - propList.insert("svg:height", (double)m_height/1200.0); - m_painter->startGraphics(propList); - m_graphicsStarted = true; - - PICT_DEBUG_MSG(("StartPict\n")); -} - -void Pict1Parser::handleEndPict() -{ - if (!m_graphicsStarted) - return; - m_painter->endGraphics(); - m_exit = true; - - PICT_DEBUG_MSG(("EndPict\n")); -} - -void Pict1Parser::handleColormap() -{ - if (!m_graphicsStarted) - return; - unsigned startIndex = readU16(); - unsigned numEntries = readU16(); - if (startIndex > 255 || numEntries > 256 || startIndex + numEntries > 256) - return; - - PICT_DEBUG_MSG(("Colormap\n")); - for(unsigned int i = 0; i < numEntries; i++) - { - unsigned char red = readU8(); - unsigned char green = readU8(); - unsigned char blue = readU8(); - libpict::PictColor color(red, green, blue); - m_colorPalette[startIndex+i] = color; - PICT_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr())); - } } -void Pict1Parser::handleFillAttributes() +void Pict1Parser::handleThePat() { - if (!m_graphicsStarted) - return; - unsigned char style = readU8(); - unsigned char color = readU8(); +} - if(style == 0) - m_style.insert("draw:fill", "none"); - if(style == 1) - m_style.insert("draw:fill", "solid"); +void Pict1Parser::handleOwSize() +{ +} - m_brushForeColor = m_colorPalette[color]; - m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); - m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); +void Pict1Parser::handleOrigin() +{ +} - PICT_DEBUG_MSG(("Fill Attributes\n")); - PICT_DEBUG_MSG((" Fill style: %d\n", style)); - PICT_DEBUG_MSG((" Fill color index: %d\n", color)); +void Pict1Parser::handleTxSize() +{ } -void Pict1Parser::handleLineAttributes() +void Pict1Parser::handleFgColor() { - if (!m_graphicsStarted) - return; - unsigned char style = readU8(); - unsigned char color = readU8(); - unsigned int width = readU16(); +} - m_style.insert("libpict:stroke-solid", style); - m_penForeColor = m_colorPalette[color]; - m_style.insert("svg:stroke-color", m_penForeColor.getColorString()); - m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT); +void Pict1Parser::handleBkColor() +{ +} - if (!m_style["svg:stroke-width"]->getInt() && m_style["libpict:stroke-solid"]->getInt()) - m_style.insert("svg:stroke-width", 0.001); - else - m_style.insert("svg:stroke-width", (double)width / 1200.0); +void Pict1Parser::handleTxRatio() +{ +} - PICT_DEBUG_MSG(("Line Attributes\n")); - PICT_DEBUG_MSG((" Line style: %d\n", style)); - PICT_DEBUG_MSG((" Line color index: %d\n", color)); - PICT_DEBUG_MSG((" Line width: %d\n", width)); +void Pict1Parser::handlePicVersion() +{ } + void Pict1Parser::handleLine() { - if (!m_graphicsStarted) - return; - int sx = readS16(); - int sy = readS16(); - int ex = readS16(); - int ey = readS16(); - - ::WPXPropertyListVector points; - ::WPXPropertyList point; - point.insert("svg:x", (double)sx/1200.0); - point.insert("svg:y", (double)(m_height-sy)/1200.0); - points.append(point); - point.clear(); - point.insert("svg:x", (double)ex/1200.0); - point.insert("svg:y", (double)(m_height-ey)/1200.0); - points.append(point); - - m_painter->setStyle(m_style, m_gradient); - - m_painter->drawPolyline(points); - - PICT_DEBUG_MSG(("Line\n")); - PICT_DEBUG_MSG((" Starting point: %d,%d\n", sx, sy)); - PICT_DEBUG_MSG((" End point: %d,%d\n", ex, ey)); -} - -void Pict1Parser::handlePolyline() -{ - if (!m_graphicsStarted) - return; - unsigned int count = readU16(); - - ::WPXPropertyListVector points; - ::WPXPropertyList point; - for(unsigned int i = 0; i < count; i++ ) - { - point.clear(); - long x = readS16(); - long y = readS16(); - point.insert("svg:x", (double)x/1200.0); - point.insert("svg:y", (double)(m_height-y)/1200.0); - points.append(point); - } +} + +void Pict1Parser::handleLineFrom() +{ +} - m_painter->setStyle(m_style, ::WPXPropertyListVector()); +void Pict1Parser::handleShortLine() +{ +} + +void Pict1Parser::handleShortLineFrom() +{ +} - m_painter->drawPolyline(points); - PICT_DEBUG_MSG(("Polyline\n")); +void Pict1Parser::handleLongText() +{ } -void Pict1Parser::handleRectangle() +void Pict1Parser::handleDHText() { - if (!m_graphicsStarted) - return; - int x = readS16(); - int y = readS16(); - int w = readS16(); - int h = readS16(); +} - ::WPXPropertyList propList; - propList.insert("svg:x", (double)x/1200.0); - // in Pict, we have the coordinate of lower left point, in SVG-ish coordinates we have to get upper left - propList.insert("svg:y", (double)(m_height - h - y)/1200.0); - propList.insert("svg:width", (double)w/1200.0); - propList.insert("svg:height",(double)h/1200.0); +void Pict1Parser::handleDVText() +{ +} - m_painter->setStyle(m_style, m_gradient); +void Pict1Parser::handleDHDVText() +{ +} - m_painter->drawRectangle(propList); - PICT_DEBUG_MSG(("Line\n")); - PICT_DEBUG_MSG((" Corner point: %d,%d\n", x, y)); - PICT_DEBUG_MSG((" Width: %d\n", w)); - PICT_DEBUG_MSG((" Height: %d\n", h)); +void Pict1Parser::handleFrameRect() +{ } -void Pict1Parser::handlePolygon() +void Pict1Parser::handlePaintRect() { - if (!m_graphicsStarted) - return; - unsigned int count = readU16(); +} - ::WPXPropertyListVector points; - ::WPXPropertyList point; - for(unsigned int i = 0; i < count; i++ ) - { - point.clear(); - long x = readS16(); - long y = readS16(); - point.insert("svg:x", (double)x/1200.0); - point.insert("svg:y", (double)(m_height-y)/1200.0); - points.append(point); - } +void Pict1Parser::handleEraseRect() +{ +} - m_painter->setStyle(m_style, m_gradient); +void Pict1Parser::handleInvertRect() +{ +} - m_painter->drawPolygon(points); +void Pict1Parser::handleFillRect() +{ +} - PICT_DEBUG_MSG(("Polygon\n")); + +void Pict1Parser::handleFrameSameRect() +{ } -void Pict1Parser::handleEllipse() +void Pict1Parser::handlePaintSameRect() { - if (!m_graphicsStarted) - return; +} - ::WPXPropertyList propList; - propList.insert("svg:cx", (double)readS16()/1200.0); - propList.insert("svg:cy", (double)(m_height-readS16())/1200.0); - propList.insert("svg:rx", (double)readS16()/1200.0); - propList.insert("svg:ry", (double)readS16()/1200.0); - propList.insert("libpict:rotate", (double)readS16()); +void Pict1Parser::handleEraseSameRect() +{ +} -#if 0 - int beginAngle = readS16(); - int endAngle = readS16(); - unsigned flags = readU16(); -#endif - m_painter->setStyle(m_style, m_gradient); - - m_painter->drawEllipse(propList); - - PICT_DEBUG_MSG(("Ellipse\n")); - PICT_DEBUG_MSG((" Center point: %s,%s\n", propList["svg:cx"]->getStr().cstr(), propList["svg:cy"]->getStr().cstr())); - PICT_DEBUG_MSG((" Radius x: %s\n", propList["svg:rx"]->getStr().cstr())); - PICT_DEBUG_MSG((" Radius y: %s\n", propList["svg:ry"]->getStr().cstr())); -} - -void Pict1Parser::handleCurvedPolyline() -{ - if (!m_graphicsStarted) - return; - readU32(); - unsigned int count = readU16(); - if (!count) - return; - ::WPXPropertyListVector path; - ::WPXPropertyList element; - - long xInitial = readS16(); - long yInitial = readS16(); - element.insert("libpict:path-action", "M"); - element.insert("svg:x", (double)xInitial/1200.0); - element.insert("svg:y", (double)(m_height-yInitial)/1200.0); - path.append(element); - for (unsigned i = 1; i < (count-1)/3; i++) - { - long xControl1 = readS16(); - long yControl1 = readS16(); - long xControl2 = readS16(); - long yControl2 = readS16(); - long xCoordinate = readS16(); - long yCoordinate = readS16(); - - element.clear(); - element.insert("libpict:path-action", "C"); - element.insert("svg:x1", (double)xControl1/1200.0); - element.insert("svg:y1", (double)(m_height-yControl1)/1200.0); - element.insert("svg:x2", (double)xControl2/1200.0); - element.insert("svg:y2", (double)(m_height-yControl2)/1200.0); - element.insert("svg:x", (double)xCoordinate/1200.0); - element.insert("svg:y", (double)(m_height-yCoordinate)/1200.0); - path.append(element); - - } - - m_painter->setStyle(m_style, m_gradient); +void Pict1Parser::handleInvertSameRect() +{ +} - m_painter->drawPath(path); - - PICT_DEBUG_MSG(("Curved Polyline\n")); +void Pict1Parser::handleFillSameRect() +{ } -void Pict1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth) + +void Pict1Parser::handleFrameRRect() { - buffer.clear(); +} - // This are the known depth values for Pict1, no point to try to decode others since they are likely to indicate corruption - if (depth != 8 && depth != 4 && depth != 2 && depth != 1) - return; +void Pict1Parser::handlePaintRRect() +{ +} - // round to the next byte - unsigned scanline_width = (width * depth + 7)/8; - unsigned tmpBufferSize = scanline_width * height; - PICT_DEBUG_MSG(("Scanline width: %d\n", scanline_width)); - PICT_DEBUG_MSG(("Output size: %d\n", scanline_width * height)); +void Pict1Parser::handleEraseRRect() +{ +} - PICT_DEBUG_MSG(("Decoding RLE data\n")); +void Pict1Parser::handleInvertRRect() +{ +} - buffer.reserve(tmpBufferSize); - while (m_input->tell() < m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize) - { - unsigned char opcode = readU8(); +void Pict1Parser::handleFillRRect() +{ +} - if(opcode & 0x80) - { - // run of byte - int count = (int)(opcode & 0x7f); - unsigned char pixel = (count > 0) ? readU8() : 0xff; - if(count == 0) - count = (int)readU8(); - for( ; count ; --count) - buffer.push_back( pixel ); - } - else - { - int count = (int)(opcode & 0x7f); - if(count > 0) - { - // literal byte copy - for( ; count ; --count) - buffer.push_back( readU8() ); - } - else - { - // copy entire scan line - count = (int)readU8(); - if (buffer.size() < scanline_width ) - { - PICT_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size())); - break; - } - unsigned raster_source = buffer.size() - scanline_width; - for( ; count; --count) - for(unsigned r = 0; r < scanline_width ; r++) - { - unsigned char pixel = buffer[raster_source + r]; - buffer.push_back( pixel ); - } - } - } - } - PICT_DEBUG_MSG(("Finish decoding RLE data\n")); - PICT_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size())); - - while (buffer.size() < tmpBufferSize) - buffer.push_back(0); + +void Pict1Parser::handleFrameSameRRect() +{ } -void Pict1Parser::fillPixels(libpict::PictBitmap& bitmap, const unsigned char* buffer, unsigned width, unsigned height, unsigned depth) +void Pict1Parser::handlePaintSameRRect() { - // sanity - if(!buffer) - return; +} - if (depth != 8 && depth != 4 && depth != 2 && depth != 1) - return; +void Pict1Parser::handleEraseSameRRect() +{ +} - // round to the next byte - unsigned scanline_width = (width * depth + 7)/8; +void Pict1Parser::handleInvertSameRRect() +{ +} - // 1-bit image: black and white - if(depth == 1) - { - libpict::PictColor black(0, 0, 0); - libpict::PictColor white(255, 255, 255); - for(unsigned y = 0; y < height; y++) - { - const unsigned char* buf = buffer + y * scanline_width; - for(unsigned x = 0; x < width; x++) - if(buf[x/8] & (0x80 >> (x & 7))) - bitmap.setPixel(x, y, white); - else - bitmap.setPixel(x, y, black); - } - } - // 2-bit image: 4-color bitmap (indexed) - else if(depth == 2) - { - unsigned i = 0; - for (unsigned y = 0; y < height; y++) - for (unsigned x = 0; x < width; x++, i++) - { - if ((x==0) && (i % 4 != 0)) - i = (i/4 + 1) * 4; - unsigned index = ((buffer[i/4] & (0x03 << 2*(3 - (i % 4)))) >> 2*(3 - (i % 4))); - const libpict::PictColor& color = m_colorPalette[index]; - bitmap.setPixel(x, y, color); - } - } - // 4 -bit image: 16-colour bitmap (indexed) - else if(depth == 4) - { - unsigned i = 0; - for (unsigned y = 0; y < height; y++) - for (unsigned x = 0; x < width; x++, i++) - { - if ((x==0) && (i % 2 != 0)) - i = (i/2 + 1) * 2; - unsigned index = ((buffer[i/2] & (0x0f << 4*(1 - (i % 2)))) >> 4*(1 - (i % 2))); - const libpict::PictColor& color = m_colorPalette[index]; - bitmap.setPixel(x, y, color); - } - } - // 8-bit image: 256-colour image (indexed) - else if(depth == 8) - { - for(unsigned y = 0; y < height; y++) - { - const unsigned char* buf = buffer + y * scanline_width; - for(unsigned x = 0; x < width; x++) - { - const libpict::PictColor& color = m_colorPalette[buf[x]]; - bitmap.setPixel(x, y, color); - } - } +void Pict1Parser::handleFillSameRRect() +{ +} - } + +void Pict1Parser::handleFrameOval() +{ } -void Pict1Parser::handleBitmapTypeOne() -{ - if (!m_graphicsStarted) - return; - int width = readS16(); - int height = readS16(); - int depth = readS16(); - int hres = readS16(); - int vres = readS16(); - - PICT_DEBUG_MSG(("Bitmap\n")); - PICT_DEBUG_MSG((" Width: %d\n", width)); - PICT_DEBUG_MSG((" Height: %d\n", height)); - PICT_DEBUG_MSG((" Depth: %d\n", depth)); - PICT_DEBUG_MSG(("Horizontal resolution: %d\n", hres)); - PICT_DEBUG_MSG((" Vertical resolution: %d\n", vres)); - - // if this happens, likely corruption, bail out. - if (depth != 1 && depth != 2 && depth != 4 && depth != 8) - return; - - // Sanity checks - if(hres <= 0) - hres = 72; - if(vres <= 0) - vres = 72; - if (width < 0) - width = 0; - if (height < 0) - height = 0; - if (depth < 0) - depth = 0; - - // Bitmap Type 1 does not specify position - // Assume on the corner (0,0) - - libpict::PictBitmap bitmap(width, height, vres, hres); - ::WPXPropertyList propList; - propList.insert("svg:x", 0.0); - propList.insert("svg:y", 0.0); - propList.insert("svg:width", (double)width/(double)hres); - propList.insert("svg:height", (double)height/(double)vres); - propList.insert("libpict:mime-type", "image/bmp"); - - std::vector<unsigned char> buffer; - decodeRLE(buffer, width, height, depth); - if (buffer.size() && buffer.size() == (unsigned long)((width*depth + 7)/8)*height) - { - fillPixels(bitmap, &buffer[0], width, height, depth); - m_painter->drawGraphicObject(propList, bitmap.getDIB()); - } +void Pict1Parser::handlePaintOval() +{ } -void Pict1Parser::handleBitmapTypeTwo() -{ - if (!m_graphicsStarted) - return; - int rotation = readS16(); - int x1 = readS16(); - int y1 = readS16(); - int x2 = readS16(); - int y2 = readS16(); - int width = readS16(); - int height = readS16(); - int depth = readS16(); - int hres = readS16(); - int vres = readS16(); - - PICT_DEBUG_MSG(("Bitmap\n")); - PICT_DEBUG_MSG((" Rotation Angle: %d\n", rotation)); - PICT_DEBUG_MSG((" Top left corner: %d,%d\n", x1, y1)); - PICT_DEBUG_MSG((" Bottom right corner: %d,%d\n", x2, y2)); - PICT_DEBUG_MSG((" Width: %d\n", width)); - PICT_DEBUG_MSG((" Height: %d\n", height)); - PICT_DEBUG_MSG((" Depth: %d\n", depth)); - PICT_DEBUG_MSG(("Horizontal resolution: %d\n", hres)); - PICT_DEBUG_MSG((" Vertical resolution: %d\n", vres)); - - // if this happens, likely corruption, bail out. - if (rotation < 0 || rotation > 359) - return; - if (depth != 1 && depth != 2 && depth != 4 && depth != 8) - return; - - // Sanity checks - if(hres <= 0) - hres = 72; - if(vres <= 0) - vres = 72; - if (width < 0) - width = 0; - if (height < 0) - height = 0; - if (depth < 0) - depth = 0; - - y1 = m_height - y1; - y2 = m_height - y2; - - long xs1 = (x1 <= x2) ? x1 : x2; - long xs2 = (x1 <= x2) ? x2 : x1; - long ys1 = (y1 <= y2) ? y1 : y2; - long ys2 = (y1 <= y2) ? y2 : y1; - PICT_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2)); - - libpict::PictBitmap bitmap(width, height, vres, hres); - ::WPXPropertyList propList; - propList.insert("svg:x", (double)xs1/(double)hres); - propList.insert("svg:y", (double)(ys1)/(double)vres); - propList.insert("svg:width", (double)(xs2-xs1)/(double)hres); - propList.insert("svg:height", (double)(ys2-ys1)/(double)vres); - propList.insert("libpict:mime-type", "image/bmp"); - - std::vector<unsigned char> buffer; - decodeRLE(buffer, width, height, depth); - if (buffer.size() && buffer.size() == (unsigned long)((width*depth + 7)/8)*height) - { - fillPixels(bitmap, &buffer[0], width, height, depth); - m_painter->drawGraphicObject(propList, bitmap.getDIB()); - } +void Pict1Parser::handleEraseOval() +{ } -void Pict1Parser::handlePostscriptTypeOne() +void Pict1Parser::handleInsertOval() { - if (!m_graphicsStarted) - return; - long x1 = readS16(); - long y1 = readS16(); - long x2 = readS16(); - long y2 = readS16(); - - ::WPXPropertyList propList; +} - propList.insert("svg:x", (double)x1/72.0); - propList.insert("svg:y", (double)m_height/1200.0 - (double)y1/72.0); - propList.insert("svg:width", ((double)x2 - (double)x1)/72.0); - propList.insert("svg:height", ((double)y1 - (double)y2)/72.0); - propList.insert("libpict:mime-type", "application/x-postscript"); - - ::WPXBinaryData data; - data.clear(); - while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) - data.append((char)readU8()); - if (data.size()) - m_painter->drawGraphicObject(propList, data); +void Pict1Parser::handleFillOval() +{ } -void Pict1Parser::handlePostscriptTypeTwo() + +void Pict1Parser::handleFrameSameOval() +{ +} + +void Pict1Parser::handlePaintSameOval() +{ +} + +void Pict1Parser::handleEraseSameOval() +{ +} + +void Pict1Parser::handleInsertSameOval() +{ +} + +void Pict1Parser::handleFillSameOval() +{ +} + + +void Pict1Parser::handleFrameArc() +{ +} + +void Pict1Parser::handlePaintArc() +{ +} + +void Pict1Parser::handleEraseArc() +{ +} + +void Pict1Parser::handleInsertArc() +{ +} + +void Pict1Parser::handleFillArc() +{ +} + + +void Pict1Parser::handleFrameSameArc() +{ +} + +void Pict1Parser::handlePaintSameArc() +{ +} + +void Pict1Parser::handleEraseSameArc() +{ +} + +void Pict1Parser::handleInsertSameArc() +{ +} + +void Pict1Parser::handleFillSameArc() +{ +} + + +void Pict1Parser::handleFramePoly() +{ +} + +void Pict1Parser::handlePaintPoly() +{ +} + +void Pict1Parser::handleErasePoly() +{ +} + +void Pict1Parser::handleInvertPoly() +{ +} + +void Pict1Parser::handleFillPoly() { - if (!m_graphicsStarted) - return; -#ifdef DEBUG - unsigned lengthOfData = readU32(); - int rotation = readS16(); -#else - readU32(); - readS16(); -#endif - int x1 = readS16(); - int y1 = readS16(); - int x2 = readS16(); - int y2 = readS16(); - - PICT_DEBUG_MSG(("Postscript (Type 2)\n")); - PICT_DEBUG_MSG((" Length of Data: %d\n", lengthOfData)); - PICT_DEBUG_MSG((" Rotation Angle: %d\n", rotation)); - PICT_DEBUG_MSG((" Bottom left corner: %d,%d\n", x1, y1)); - PICT_DEBUG_MSG((" Top right corner: %d,%d\n", x2, y2)); - - y1 = m_height - y1; - y2 = m_height - y2; - - long xs1 = (x1 <= x2) ? x1 : x2; - long xs2 = (x1 <= x2) ? x2 : x1; - long ys1 = (y1 <= y2) ? y1 : y2; - long ys2 = (y1 <= y2) ? y2 : y1; - PICT_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2)); - - ::WPXPropertyList propList; - - propList.insert("svg:x", (double)xs1/1200.0); - propList.insert("svg:y", (double)(ys1)/1200.0); - - propList.insert("svg:width", ((double)xs2 - (double)xs1)/1200.0); - propList.insert("svg:height", ((double)ys2 -(double)ys1)/1200.0); - - propList.insert("libpict:mime-type", "image/x-eps"); - - m_input->seek(48, WPX_SEEK_CUR); - - ::WPXBinaryData data; - data.clear(); - while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) - data.append((char)readU8()); - if (data.size()) - m_painter->drawGraphicObject(propList, data); -} - -void Pict1Parser::handleGraphicsTextAttributes() -{ - if (!m_graphicsStarted) - return; -} - -void Pict1Parser::handleGraphicsTextTypeOne() -{ - if (!m_graphicsStarted) - return; - unsigned short textLength = readU16(); - int x = readS16(); - int y = readS16(); - WPXString textString; - for (unsigned short i=0; i < textLength; i++) - textString.append(readU8()); - - PICT_DEBUG_MSG(("Graphics Text (Type 1)\n")); - PICT_DEBUG_MSG((" Length of String: %d\n", textLength)); - PICT_DEBUG_MSG((" String position: %d,%d\n", x, y)); - PICT_DEBUG_MSG((" String: %s\n", textString.cstr())); - - y = m_height - y; - - ::WPXPropertyList propList; - - propList.insert("svg:x", (double)x/1200.0); - propList.insert("svg:y", (double)(y)/1200.0); - - m_painter->startTextObject(propList, ::WPXPropertyListVector()); - - m_painter->insertText(textString); - - m_painter->endTextObject(); -} - -void Pict1Parser::handleGraphicsTextTypeTwo() -{ - if (!m_graphicsStarted) - return; -#ifdef DEBUG - int sizeEquivalentData = readU32(); - short rotationAngle = readS16(); -#endif - unsigned short textLength = readU16(); -#ifdef DEBUG - int x1 = readS16(); - int y1 = readS16(); - int x2 = readS16(); - int y2 = readS16(); - int sx = readS16(); - int sy = readS16(); - unsigned char type = readU8(); -#endif - WPXBinaryData textString; - for (unsigned short i=0; i < textLength; i++) - textString.append(readU8()); - - PICT_DEBUG_MSG(("Graphics Text (Type 1)\n")); - PICT_DEBUG_MSG((" Size of Equivalent data: %d\n", sizeEquivalentData)); - PICT_DEBUG_MSG((" Rotation Angle: %d\n", rotationAngle)); - PICT_DEBUG_MSG((" Length of String: %d\n", textLength)); - PICT_DEBUG_MSG((" Start position: %d,%d\n", x1, y1)); - PICT_DEBUG_MSG((" End position: %d,%d\n", x2, y2)); - PICT_DEBUG_MSG((" Scale factor: %d,%d\n", sx, sy)); - PICT_DEBUG_MSG((" Type: %d\n", type)); - -// PictTextDataHandler handler(m_painter); -// WPDocument::parseSubDocument(const_cast<WPXInputStream *>(textString.getDataStream()), &handler, WPD_FILE_FORMAT_WP5); -} - -void Pict1Parser::resetPalette() -{ - m_colorPalette.clear(); - for (int i=0; i<256; i++) - { - unsigned char red = defaultPict1PaletteRed[i]; - unsigned char green = defaultPict1PaletteGreen[i]; - unsigned char blue = defaultPict1PaletteBlue[i]; - libpict::PictColor color(red, green, blue); - m_colorPalette[i] = color; - } } + +void Pict1Parser::handleFrameSamePoly() +{ +} + +void Pict1Parser::handlePaintSamePoly() +{ +} + +void Pict1Parser::handleEraseSamePoly() +{ +} + +void Pict1Parser::handleInvertSamePoly() +{ +} + +void Pict1Parser::handleFillSamePoly() +{ +} + + +void Pict1Parser::handleFrameRgn() +{ +} + +void Pict1Parser::handlePaintRgn() +{ +} + +void Pict1Parser::handleEraseRgn() +{ +} + +void Pict1Parser::handleInvertRgn() +{ +} + +void Pict1Parser::handleFillRgn() +{ +} + + +void Pict1Parser::handleFrameSameRgn() +{ +} + +void Pict1Parser::handlePaintSameRgn() +{ +} + +void Pict1Parser::handleEraseSameRgn() +{ +} + +void Pict1Parser::handleInvertSameRgn() +{ +} + +void Pict1Parser::handleFillSameRgn() +{ +} + + +void Pict1Parser::handleBitsRect() +{ +} + +void Pict1Parser::handleBitsRgn() +{ +} + + +void Pict1Parser::handlePackBitsRect() +{ +} + +void Pict1Parser::handlePackBitsRgn() +{ +} + + +void Pict1Parser::handleShortComment() +{ +} + +void Pict1Parser::handleLongComment() +{ +} + + +void Pict1Parser::handleEndOfPicture() +{ +} diff --git a/src/lib/Pict1Parser.h b/src/lib/Pict1Parser.h index ddadc5d..5475cd9 100644 --- a/src/lib/Pict1Parser.h +++ b/src/lib/Pict1Parser.h @@ -41,50 +41,117 @@ public: bool parse(); private: - void handleStartPict(); - void handleEndPict(); - - void handleFillAttributes(); - void handleLineAttributes(); - void handleColormap(); + 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 handlePolyline(); - void handleRectangle(); - void handlePolygon(); - void handleEllipse(); - - void handleCurvedPolyline(); - - void decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth); - void fillPixels(libpict::PictBitmap& bitmap, const unsigned char* buffer, unsigned width, unsigned height, unsigned depth); - void handleBitmapTypeOne(); - void handleBitmapTypeTwo(); - void handlePostscriptTypeOne(); - void handlePostscriptTypeTwo(); - - void handleGraphicsTextAttributes(); - void handleGraphicsTextTypeOne(); - void handleGraphicsTextTypeTwo(); - void handleGraphicsTextTypeThree(); - - void resetPalette(); - - // parsing context - int m_recordLength; - long m_recordEnd; - bool m_success; - bool m_exit; - bool m_graphicsStarted; - int m_width; - int m_height; - ::WPXPropertyList m_style; - libpict::PictColor m_penForeColor; - libpict::PictColor m_penBackColor; - libpict::PictColor m_brushForeColor; - libpict::PictColor m_brushBackColor; - libpict::PictDashArray m_dashArray; - ::WPXPropertyListVector m_gradient; + 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(); }; #endif // __PICT1PARSER_H__ |