From: Fridrich S. <str...@us...> - 2008-07-16 09:57:33
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18349/src/lib Modified Files: WPG1Parser.cpp WPG1Parser.h WPG2Parser.cpp WPG2Parser.h WPGBitmap.cpp WPGSVGGenerator.cpp Log Message: miscellanous fixes form stable branch Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- WPG2Parser.h 9 Jul 2008 13:45:30 -0000 1.23 +++ WPG2Parser.h 16 Jul 2008 09:57:28 -0000 1.24 @@ -146,7 +146,7 @@ class WPG2Parser : public WPGXParser { public: - WPG2Parser(WPXInputStream *input, libwpg::WPGPaintInterface* painter); + WPG2Parser(WPXInputStream *input, libwpg::WPGPaintInterface* painter, bool isEmbedded = false); bool parse(); private: @@ -222,6 +222,8 @@ class ObjectCharacterization; void parseCharacterization(ObjectCharacterization*); unsigned m_binaryId; + + bool m_embedded; }; #endif // __WPG2PARSER_H__ Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- WPGBitmap.cpp 9 Jul 2008 14:46:23 -0000 1.18 +++ WPGBitmap.cpp 16 Jul 2008 09:57:28 -0000 1.19 @@ -27,12 +27,11 @@ #include "WPGBitmap.h" #include "libwpg_utils.h" -#include <sstream> - #define DUMP_BITMAP 0 #if DUMP_BITMAP static unsigned bitmapId = 0; +#include <sstream> #endif class libwpg::WPGBitmap::Private Index: WPG1Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- WPG1Parser.h 16 Jul 2007 12:03:33 -0000 1.15 +++ WPG1Parser.h 16 Jul 2008 09:57:28 -0000 1.16 @@ -51,6 +51,8 @@ void handleRectangle(); void handlePolygon(); void handleEllipse(); + + void handleCurvedPolyline(); unsigned char* decodeRLE(int width, int height, int depth); void fillPixels(libwpg::WPGBitmap& bitmap, unsigned char* buffer, int width, int height, int depth); Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- WPGSVGGenerator.cpp 11 Jul 2008 22:19:09 -0000 1.13 +++ WPGSVGGenerator.cpp 16 Jul 2008 09:57:28 -0000 1.14 @@ -274,10 +274,7 @@ m_outputSink << "style=\""; const libwpg::WPGColor& color = m_pen.foreColor; - if(m_pen.width > 0.0) - m_outputSink << "stroke-width: " << doubleToString(72*m_pen.width) << "; "; - else if(m_pen.solid) - m_outputSink << "stroke-width: 0.72; "; + m_outputSink << "stroke-width: " << doubleToString(72*m_pen.width) << "; "; if(m_pen.width > 0.0 || m_pen.solid) { Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -u -d -r1.68 -r1.69 --- WPG2Parser.cpp 11 Jul 2008 22:19:09 -0000 1.68 +++ WPG2Parser.cpp 16 Jul 2008 09:57:28 -0000 1.69 @@ -31,7 +31,6 @@ #include <math.h> #include <vector> -#include <sstream> // MSVC++ 6.0 does not have the macro defined, so we define it #ifndef M_PI @@ -40,6 +39,10 @@ #define DUMP_BINARY_DATA 0 +#if DUMP_BINARY_DATA +#include <sstream> +#endif + static const unsigned char defaultWPG2PaletteRed[] = { 0x00, 0xFF, 0x7F, 0xBF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, @@ -205,11 +208,11 @@ {} }; -WPG2Parser::WPG2Parser(WPXInputStream *input, libwpg::WPGPaintInterface* painter): +WPG2Parser::WPG2Parser(WPXInputStream *input, libwpg::WPGPaintInterface* painter, bool isEmbedded): WPGXParser(input, painter), m_recordLength(0), m_recordEnd(0), - m_success(true), m_exit(false), m_graphicsStarted(false), + m_success(true), m_exit(false), m_graphicsStarted(isEmbedded), m_xres(1200), m_yres(1200), m_xofs(0), m_yofs(0), m_width(0), m_height(0), @@ -225,14 +228,25 @@ m_compoundMatrix(), m_compoundWindingRule(false), m_compoundFilled(false), - m_compoundFramed(false), + m_compoundFramed(true), m_compoundClosed(false), m_bitmap(), m_binaryData(), m_hFlipped(false), m_vFlipped(false), - m_binaryId(0) + m_binaryId(0), + m_embedded(isEmbedded) { + // default style + m_pen.foreColor = libwpg::WPGColor(0,0,0); + m_pen.backColor = libwpg::WPGColor(0xff,0xff,0xff); + m_pen.width = 0.0; + m_pen.height = 0.0; + m_pen.solid = true; + m_pen.dashArray = libwpg::WPGDashArray(); + m_brush.foreColor = libwpg::WPGColor(0,0,0); + m_brush.backColor = libwpg::WPGColor(0xff, 0xff, 0xff); + resetPalette(); } bool WPG2Parser::parse() @@ -309,34 +323,6 @@ { 0x00, 0, 0 } // end marker }; - // initialization - m_recordLength = 0; - m_recordEnd = 0; - m_success = true; - m_exit = false; - m_graphicsStarted = false; - m_xres = m_yres = 1200; - m_doublePrecision = false; - m_layerOpened = false; - m_matrix = WPG2TransformMatrix(); - m_groupStack = std::stack<WPGGroupContext>(); - m_compoundMatrix = WPG2TransformMatrix(); - m_compoundWindingRule = false; - m_compoundFilled = false; - m_compoundFramed = true; - m_compoundClosed = false; - - // default style - m_pen.foreColor = libwpg::WPGColor(0,0,0); - m_pen.backColor = libwpg::WPGColor(0,0,0); - m_pen.width = 0.01; - m_pen.height = 0.01; - m_pen.solid = true; - m_pen.dashArray = libwpg::WPGDashArray(); - m_brush.foreColor = libwpg::WPGColor(0,0,0); - m_brush.backColor = libwpg::WPGColor(0,0,0); - resetPalette(); - while(!m_input->atEOS()) { #ifdef DEBUG @@ -488,8 +474,7 @@ } // danger if we do not recognize the precision code - if(precision != 0) - if(precision != 1) + if(precision != 0 && precision != 1) { m_success = false; m_exit = true; Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- WPG1Parser.cpp 11 Jul 2008 22:19:08 -0000 1.37 +++ WPG1Parser.cpp 16 Jul 2008 09:57:28 -0000 1.38 @@ -166,11 +166,24 @@ { 0x07, "Rectangle", &WPG1Parser::handleRectangle }, { 0x08, "Polygon", &WPG1Parser::handlePolygon }, { 0x09, "Ellipse", &WPG1Parser::handleEllipse }, + { 0x0a, "Reserved", 0 }, { 0x0b, "Bitmap (Type 1)", &WPG1Parser::handleBitmapTypeOne }, + { 0x0c, "Graphics Text (Type 1)", 0 }, + { 0x0d, "Grephics Text Attributes", 0 }, { 0x0e, "Colormap", &WPG1Parser::handleColormap }, { 0x0f, "Start WPG", &WPG1Parser::handleStartWPG }, { 0x10, "End WPG", &WPG1Parser::handleEndWPG }, + { 0x11, "Postscript Data Follows", 0 }, + { 0x12, "Output Attributes", 0 }, + { 0x13, "Curved Polyline", &WPG1Parser::handleCurvedPolyline }, { 0x14, "Bitmap (Type 2)", &WPG1Parser::handleBitmapTypeTwo }, + { 0x15, "Start Figure", 0 }, + { 0x16, "Start Chart", 0 }, + { 0x17, "Planperfect Data", 0 }, + { 0x18, "Graphics Text (Type 2)", 0 }, + { 0x19, "Start WPG (Type 2)", 0 }, + { 0x1a, "Graphics Text (Type 3)", 0 }, + { 0x1b, "Ellipse", 0 }, { 0x00, 0, 0 } // end marker }; @@ -184,8 +197,8 @@ // default style m_pen.foreColor = libwpg::WPGColor(0,0,0); m_pen.backColor = libwpg::WPGColor(0,0,0); - m_pen.width = 0.01; - m_pen.height = 0.01; + m_pen.width = 0.001; + m_pen.height = 0.001; m_pen.solid = true; m_pen.dashArray = libwpg::WPGDashArray(); m_brush.foreColor = libwpg::WPGColor(0,0,0); @@ -325,7 +338,10 @@ m_pen.solid = style != 0; m_pen.foreColor = m_colorPalette[color]; - m_pen.width = (double)width / 1200.0; + if (!width && m_pen.solid) + m_pen.width = 0.001; + else + m_pen.width = (double)width / 1200.0; WPG_DEBUG_MSG(("Line Attributes\n")); WPG_DEBUG_MSG((" Line style: %d\n", style)); @@ -449,6 +465,39 @@ WPG_DEBUG_MSG((" Radius y: %d\n", ry)); } +void WPG1Parser::handleCurvedPolyline() +{ + if (!m_graphicsStarted) + return; + readU32(); + unsigned int count = readU16(); + if (!count) + return; + libwpg::WPGPath path; + path.closed = false; + long xInitial = readS16(); + long yInitial = readS16(); + path.moveTo(libwpg::WPGPoint((double)xInitial/1200.0, (double)yInitial/1200.0)); + 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(); + path.curveTo(libwpg::WPGPoint((double)xControl1/1200.0, (double)yControl1/1200.0), + libwpg::WPGPoint((double)xControl2/1200.0, (double)yControl2/1200.0), + libwpg::WPGPoint((double)xCoordinate/1200.0, (double)yCoordinate/1200.0)); + } + + m_painter->setBrush(m_brush); + m_painter->setPen(m_pen); + m_painter->drawPath(path); + + WPG_DEBUG_MSG(("Curved Polyline\n")); +} + // allocate a buffer (of specified bitmap size), then start decoding RLE data // from the input stream to fill the buffer // NOTE: delete the buffer by yourself! |