From: Fridrich S. <str...@us...> - 2008-12-05 15:17:33
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12685/src/lib Modified Files: Makefile.am WPG1Parser.cpp WPG1Parser.h WPG2Parser.cpp WPG2Parser.h WPGColor.cpp WPGGradient.cpp WPGPaintInterface.h WPGPen.cpp WPGPen.h WPGSVGGenerator.cpp WPGSVGGenerator.h libwpg.h.in Log Message: committing work done in the train while having wireless access Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- WPG2Parser.h 5 Dec 2008 00:53:49 -0000 1.34 +++ WPG2Parser.h 5 Dec 2008 15:17:25 -0000 1.35 @@ -29,8 +29,8 @@ #define __WPG2PARSER_H__ #include "WPGXParser.h" -#include "WPGBrush.h" -#include "WPGPen.h" +#include "WPGGradient.h" +#include "WPGDashArray.h" #include "WPGBitmap.h" #include <libwpd/libwpd.h> @@ -215,8 +215,12 @@ long m_height; bool m_doublePrecision; ::WPXPropertyList m_style; - libwpg::WPGPen m_pen; - libwpg::WPGBrush m_brush; + libwpg::WPGColor m_penForeColor; + libwpg::WPGColor m_penBackColor; + libwpg::WPGColor m_brushForeColor; + libwpg::WPGColor m_brushBackColor; + libwpg::WPGDashArray m_dashArray; + libwpg::WPGGradient m_gradient; std::map<unsigned int,libwpg::WPGDashArray> m_penStyles; bool m_layerOpened; unsigned int m_layerId; Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- WPG1Parser.cpp 5 Dec 2008 00:53:49 -0000 1.57 +++ WPG1Parser.cpp 5 Dec 2008 15:17:25 -0000 1.58 @@ -142,9 +142,17 @@ m_recordLength(0), m_recordEnd(0), m_success(true), m_exit(false), m_graphicsStarted(false), m_width(0), m_height(0), m_style(), - m_pen(), m_brush() + 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); } bool WPG1Parser::parse() @@ -198,14 +206,18 @@ m_graphicsStarted = false; // default style - m_pen.foreColor = "#000000"; - m_pen.backColor = "#000000"; - m_pen.width = 0.001; - m_pen.height = 0.001; - m_pen.solid = true; - m_pen.dashArray = libwpg::WPGDashArray(); - m_brush.foreColor = "#000000"; - m_brush.backColor = "#000000"; + m_penForeColor = libwpg::WPGColor(0,0,0); + m_penBackColor = libwpg::WPGColor(0,0,0); + m_style.insert("svg:stroke-width", 0.001); +// m_pen.height = 0.001; + m_style.insert("libwpg:stroke-solid", true); + m_dashArray = libwpg::WPGDashArray(); + m_brushForeColor = libwpg::WPGColor(0,0,0); + m_brushBackColor = libwpg::WPGColor(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(); while(!m_input->atEOS()) @@ -327,8 +339,9 @@ if(style == 1) m_style.insert("draw:fill", "solid"); - m_brush.foreColor = m_colorPalette[color].getColorString(); - m_brush.foreOpacity = m_colorPalette[color].getOpacity() + m_brushForeColor = m_colorPalette[color]; + m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); + m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); WPG_DEBUG_MSG(("Fill Attributes\n")); WPG_DEBUG_MSG((" Fill style: %d\n", style)); @@ -343,13 +356,15 @@ unsigned char color = readU8(); unsigned int width = readU16(); - m_pen.solid = style != 0; - m_pen.foreColor = m_colorPalette[color].getColorString(); - m_pen.foreOpacity = m_colorPalette[color].getOpacity(); - if (!width && m_pen.solid) - m_pen.width = 0.001; + m_style.insert("libwpg: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); + + if (!m_style["svg:stroke-width"]->getInt() && m_style["libwpg:stroke-solid"]->getInt()) + m_style.insert("svg:stroke-width", 0.001); else - m_pen.width = (double)width / 1200.0; + m_style.insert("svg:stroke-width", (double)width / 1200.0); WPG_DEBUG_MSG(("Line Attributes\n")); WPG_DEBUG_MSG((" Line style: %d\n", style)); @@ -376,7 +391,7 @@ point.insert("svg:y", (double)(m_height-ey)/1200.0); points.append(point); - m_painter->setStyle(m_pen, m_brush,::WPXPropertyList()); + m_painter->setStyle(m_dashArray, m_gradient, m_style); m_painter->drawPolyline(points); @@ -403,7 +418,7 @@ points.append(point); } - m_painter->setStyle(m_pen, libwpg::WPGBrush(),::WPXPropertyList()); + m_painter->setStyle(m_dashArray, libwpg::WPGGradient(), m_style); m_painter->drawPolyline(points); @@ -426,7 +441,7 @@ propList.insert("svg:width", (double)w/1200.0); propList.insert("svg:height",(double)h/1200.0); - m_painter->setStyle(m_pen, m_brush,::WPXPropertyList()); + m_painter->setStyle(m_dashArray, m_gradient, m_style); m_painter->drawRectangle(propList); @@ -454,7 +469,7 @@ points.append(point); } - m_painter->setStyle(m_pen, m_brush,::WPXPropertyList()); + m_painter->setStyle(m_dashArray, m_gradient, m_style); m_painter->drawPolygon(points); @@ -478,14 +493,14 @@ int endAngle = readS16(); unsigned flags = readU16(); #endif - m_painter->setStyle(m_pen, m_brush,::WPXPropertyList()); + m_painter->setStyle(m_dashArray, m_gradient, m_style); m_painter->drawEllipse(propList); WPG_DEBUG_MSG(("Ellipse\n")); - WPG_DEBUG_MSG((" Center point: %d,%d\n", cx, cy)); - WPG_DEBUG_MSG((" Radius x: %d\n", rx)); - WPG_DEBUG_MSG((" Radius y: %d\n", ry)); + WPG_DEBUG_MSG((" Center point: %f,%f\n", propList["svg:cx"]->getDouble(), propList["svg:cy"]->getDouble())); + WPG_DEBUG_MSG((" Radius x: %f\n", propList["svg:rx"]->getDouble())); + WPG_DEBUG_MSG((" Radius y: %f\n", propList["svg:ry"]->getDouble())); } void WPG1Parser::handleCurvedPolyline() @@ -526,7 +541,7 @@ } - m_painter->setStyle(m_pen, m_brush,::WPXPropertyList()); + m_painter->setStyle(m_dashArray, m_gradient, m_style); m_painter->drawPath(path); Index: WPGGradient.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGGradient.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- WPGGradient.cpp 3 Dec 2008 23:05:05 -0000 1.8 +++ WPGGradient.cpp 5 Dec 2008 15:17:25 -0000 1.9 @@ -46,8 +46,9 @@ { public: WPGGradientPrivate() : - gradientStops(std::vector<WPGGradientStop>()), - angle(0.0) {}; + gradientStops(), + angle(0.0) {}; + std::vector<WPGGradientStop> gradientStops; double angle; }; Index: WPGSVGGenerator.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- WPGSVGGenerator.h 5 Dec 2008 00:53:49 -0000 1.19 +++ WPGSVGGenerator.h 5 Dec 2008 15:17:26 -0000 1.20 @@ -47,7 +47,7 @@ void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} void endEmbeddedGraphics() {} - void setStyle(const libwpg::WPGPen& pen, const libwpg::WPGBrush& brush, const ::WPXPropertyList &propList); + void setStyle(const libwpg::WPGDashArray& dashArray, const libwpg::WPGGradient& gradient, const ::WPXPropertyList &propList); void drawRectangle(const ::WPXPropertyList& propList); void drawEllipse(const ::WPXPropertyList& propList); @@ -57,8 +57,8 @@ void drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData); private: - libwpg::WPGPen m_pen; - libwpg::WPGBrush m_brush; + libwpg::WPGDashArray m_dashArray; + libwpg::WPGGradient m_gradient; ::WPXPropertyList m_style; int m_gradientIndex; void writeStyle(bool isClosed=true); Index: WPG1Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- WPG1Parser.h 5 Dec 2008 00:53:49 -0000 1.21 +++ WPG1Parser.h 5 Dec 2008 15:17:25 -0000 1.22 @@ -29,8 +29,8 @@ #define __WPG1PARSER_H__ #include "WPGXParser.h" -#include "WPGBrush.h" -#include "WPGPen.h" +#include "WPGGradient.h" +#include "WPGDashArray.h" #include "WPGBitmap.h" #include <vector> @@ -74,8 +74,12 @@ int m_width; int m_height; ::WPXPropertyList m_style; - libwpg::WPGPen m_pen; - libwpg::WPGBrush m_brush; + libwpg::WPGColor m_penForeColor; + libwpg::WPGColor m_penBackColor; + libwpg::WPGColor m_brushForeColor; + libwpg::WPGColor m_brushBackColor; + libwpg::WPGDashArray m_dashArray; + libwpg::WPGGradient m_gradient; }; #endif // __WPG1PARSER_H__ Index: WPGColor.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGColor.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- WPGColor.cpp 3 Dec 2008 23:05:05 -0000 1.3 +++ WPGColor.cpp 5 Dec 2008 15:17:25 -0000 1.4 @@ -29,14 +29,14 @@ red(0), green(0), blue(0), - alpha(1) + alpha(0xff) {} libwpg::WPGColor::WPGColor(int r, int g, int b): red(r), green(g), blue(b), - alpha(1) + alpha(0xff) {} libwpg::WPGColor::WPGColor(int r, int g, int b, int a): @@ -71,5 +71,5 @@ double libwpg::WPGColor::getOpacity() const { - return 1.0 - ((double)alpha/256.0); + return ((double)alpha/255.0); } Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- WPGSVGGenerator.cpp 5 Dec 2008 00:53:49 -0000 1.29 +++ WPGSVGGenerator.cpp 5 Dec 2008 15:17:25 -0000 1.30 @@ -47,7 +47,7 @@ } -libwpg::WPGSVGGenerator::WPGSVGGenerator(std::ostream & output_sink): m_pen(libwpg::WPGPen()), m_brush(libwpg::WPGBrush()), m_style(), m_gradientIndex(1), m_outputSink(output_sink) +libwpg::WPGSVGGenerator::WPGSVGGenerator(std::ostream & output_sink): m_dashArray(), m_gradient(), m_style(), m_gradientIndex(1), m_outputSink(output_sink) { } @@ -79,25 +79,27 @@ m_outputSink << "</svg>\n"; } -void libwpg::WPGSVGGenerator::setStyle(const libwpg::WPGPen& pen, const libwpg::WPGBrush& brush, const ::WPXPropertyList &propList) +void libwpg::WPGSVGGenerator::setStyle(const libwpg::WPGDashArray& dashArray, const libwpg::WPGGradient& gradient, const ::WPXPropertyList &propList) { - m_pen = pen; + m_style = propList; - m_brush = brush; + m_dashArray = dashArray; + + m_gradient = gradient; if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "gradient") { - double angle = m_brush.gradient.angle(); + double angle = m_gradient.angle(); m_outputSink << "<defs>\n"; m_outputSink << " <linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n"; - for(unsigned c = 0; c < m_brush.gradient.count(); c++) + for(unsigned c = 0; c < m_gradient.count(); c++) { // round to nearest percentage - int ofs = (int)((100.0*m_brush.gradient.stopOffset(c))+0.5); + int ofs = (int)((100.0*m_gradient.stopOffset(c))+0.5); - ::WPXString color = m_brush.gradient.stopColor(c); - double opacity = m_brush.gradient.stopOpacity(c); + ::WPXString color = m_gradient.stopColor(c); + double opacity = m_gradient.stopOpacity(c); m_outputSink << " <stop offset=\"" << ofs << "%\""; // set stream to %02x formatting @@ -129,8 +131,6 @@ m_outputSink << "</defs>\n"; } - m_style = propList; - } void libwpg::WPGSVGGenerator::startLayer(const ::WPXPropertyList& propList) @@ -268,25 +268,25 @@ { m_outputSink << "style=\""; - ::WPXString color = m_pen.foreColor; - double opacity = m_pen.foreOpacity; - m_outputSink << "stroke-width: " << doubleToString(72*m_pen.width) << "; "; +// ::WPXString color = m_dashArray.foreColor; +// double opacity = m_dashArray.foreOpacity; + m_outputSink << "stroke-width: " << doubleToString(72*m_style["svg:stroke-width"]->getDouble()) << "; "; - if(m_pen.width > 0.0 || m_pen.solid) + if(m_style["svg:stroke-width"]->getDouble() > 0.0 || m_style["libwpg:stroke-solid"]->getInt()) { - m_outputSink << "stroke: " << color.cstr() << "; "; - if(opacity != 1.0) - // alpha = 0 means opacity = 1.0, alpha = 256 means opacity = 0 - m_outputSink << "stroke-opacity: " << doubleToString(opacity) << "; "; + 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_pen.solid) + if(!m_style["libwpg:stroke-solid"]->getInt()) { m_outputSink << "stroke-dasharray: "; - for(unsigned i = 0; i < m_pen.dashArray.count(); i++) + for(unsigned i = 0; i < m_dashArray.count(); i++) { - m_outputSink << doubleToString(72*m_pen.dashArray.at(i)*m_pen.width); - if(i < m_pen.dashArray.count()-1) + m_outputSink << doubleToString(72*m_dashArray.at(i)*(m_style["svg:stroke-width"]->getDouble())); + if(i < m_dashArray.count()-1) m_outputSink << ", "; } m_outputSink << "; "; @@ -302,8 +302,8 @@ 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") - m_outputSink << "fill: " << m_brush.foreColor.cstr() << "; "; + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "solid" && m_style["draw:fill-color"]) + m_outputSink << "fill: " << m_style["draw:fill-color"]->getStr().cstr() << "; "; } m_outputSink << "\""; // style Index: WPGPaintInterface.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGPaintInterface.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- WPGPaintInterface.h 28 Nov 2008 12:25:45 -0000 1.17 +++ WPGPaintInterface.h 5 Dec 2008 15:17:25 -0000 1.18 @@ -28,8 +28,8 @@ #define __WPGPAINTINTERFACE_H__ #include <libwpd/libwpd.h> -#include "WPGBrush.h" -#include "WPGPen.h" +#include "WPGDashArray.h" +#include "WPGGradient.h" namespace libwpg { @@ -41,7 +41,7 @@ // none of the other callback functions will be called before this function is called virtual void startGraphics(const ::WPXPropertyList &propList) = 0; - virtual void setStyle(const WPGPen& pen, const WPGBrush& brush, const ::WPXPropertyList &propList) = 0; + virtual void setStyle(const WPGDashArray& dashArray, const WPGGradient& gradient, const ::WPXPropertyList &propList) = 0; virtual void startLayer(const ::WPXPropertyList& propList) = 0; Index: Makefile.am =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/Makefile.am,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- Makefile.am 4 Dec 2008 23:17:39 -0000 1.34 +++ Makefile.am 5 Dec 2008 15:17:25 -0000 1.35 @@ -24,8 +24,6 @@ libwpg.h \ WPGraphics.h \ WPGDashArray.h \ - WPGPen.h \ - WPGBrush.h \ WPGGradient.h \ WPGPaintInterface.h @@ -36,8 +34,6 @@ libwpg_@WPG_MAJOR_VERSION@_@WPG_MINOR_VERSION@_la_LDFLAGS = $(version_info) -export-dynamic $(no_undefined) libwpg_@WPG_MAJOR_VERSION@_@WPG_MINOR_VERSION@_la_SOURCES = \ WPGraphics.cpp \ - WPGBrush.cpp \ - WPGPen.cpp \ WPGColor.cpp \ WPGDashArray.cpp \ WPGGradient.cpp \ @@ -51,8 +47,6 @@ libwpg.h \ libwpg_utils.h \ WPGColor.h \ - WPGPen.h \ - WPGBrush.h \ WPGGradient.h \ WPGHeader.h \ WPGSVGGenerator.h \ Index: WPGPen.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGPen.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- WPGPen.cpp 4 Dec 2008 23:17:39 -0000 1.11 +++ WPGPen.cpp 5 Dec 2008 15:17:25 -0000 1.12 @@ -28,38 +28,17 @@ #include <vector> libwpg::WPGPen::WPGPen(): - foreColor("#000000"), - backColor("#ffffff"), - foreOpacity(1.0), - backOpacity(1.0), - width(0), - height(0), - solid(true) , dashArray() { } libwpg::WPGPen::WPGPen(const WPGPen& pen): - foreColor(pen.foreColor), - backColor(pen.backColor), - foreOpacity(pen.foreOpacity), - backOpacity(pen.backOpacity), - width(pen.width), - height(pen.height), - solid(pen.solid), dashArray(pen.dashArray) { } libwpg::WPGPen& libwpg::WPGPen::operator=(const libwpg::WPGPen& pen) { - foreColor = pen.foreColor; - backColor = pen.backColor; - foreOpacity = pen.foreOpacity; - backOpacity = pen.backOpacity; - width = pen.width; - height = pen.height; - solid = pen.solid; dashArray = pen.dashArray; return *this; } Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- WPG2Parser.cpp 5 Dec 2008 00:53:49 -0000 1.95 +++ WPG2Parser.cpp 5 Dec 2008 15:17:25 -0000 1.96 @@ -218,8 +218,12 @@ m_width(0), m_height(0), m_doublePrecision(false), m_style(), - m_pen(), - m_brush(), + 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_penStyles(), m_layerOpened(false), m_layerId(0), m_matrix(), @@ -239,14 +243,20 @@ m_embedded(isEmbedded) { // default style - m_pen.foreColor = "#000000"; - m_pen.backColor = "#ffffff"; - m_pen.width = 0.0; - m_pen.height = 0.0; - m_pen.solid = true; - m_pen.dashArray = libwpg::WPGDashArray(); - m_brush.foreColor = "#000000"; - m_brush.backColor = "#ffffff"; + m_penForeColor = ::libwpg::WPGColor(0,0,0); + m_penBackColor = ::libwpg::WPGColor(0xff,0xff,0xff); + m_style.insert("svg:stroke-width", 0.001); +// m_pen.height = 0.0; + m_style.insert("libwpg:stroke-solid", true); + m_dashArray = libwpg::WPGDashArray(); + m_brushForeColor = ::libwpg::WPGColor(0,0,0); + m_brushBackColor = ::libwpg::WPGColor(0xff,0xff,0xff); + + 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(); m_style.insert("draw:fill", "solid"); } @@ -610,13 +620,12 @@ return; WPGGroupContext& context = m_groupStack.top(); - ::WPXPropertyList fillRule; if(context.compoundWindingRule) - fillRule.insert("svg:fill-rule", "nonzero"); + m_style.insert("svg:fill-rule", "nonzero"); else - fillRule.insert("svg:fill-rule", "evenodd"); + m_style.insert("svg:fill-rule", "evenodd"); - m_painter->setStyle( context.compoundFramed ? m_pen : libwpg::WPGPen(), context.compoundFilled ? m_brush : libwpg::WPGBrush(), fillRule ); + m_painter->setStyle( context.compoundFramed ? m_dashArray : libwpg::WPGDashArray(), context.compoundFilled ? m_gradient : libwpg::WPGGradient(), m_style ); if (context.compoundClosed) { @@ -670,7 +679,7 @@ unsigned char red = readU8(); unsigned char green = readU8(); unsigned char blue = readU8(); - unsigned char alpha = readU8(); + unsigned char alpha = 0xff - readU8(); libwpg::WPGColor color(red, green, blue, alpha); m_colorPalette[startIndex+i] = color; WPG_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr())); @@ -689,7 +698,7 @@ unsigned char red = readU16() >> 8 ; unsigned char green = readU16() >> 8 ; unsigned char blue = readU16() >> 8 ; - unsigned char alpha = readU16() >> 8 ; + unsigned char alpha = 0xff - (readU16() >> 8) ; libwpg::WPGColor color(red, green, blue, alpha); m_colorPalette[startIndex+i] = color; WPG_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr())); @@ -705,10 +714,9 @@ unsigned char red = readU8(); unsigned char green = readU8(); unsigned char blue = readU8(); - unsigned char alpha = readU8(); + unsigned char alpha = 0xff - readU8(); - m_pen.foreColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_pen.foreOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity() + m_penForeColor = libwpg::WPGColor(red, green, blue, alpha); WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha)); } @@ -723,10 +731,9 @@ unsigned char red = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned char green = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned char blue = (m_doublePrecision) ? readU16()>>8 : readU8(); - unsigned char alpha = (m_doublePrecision) ? readU16()>>8 : readU8(); + unsigned char alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8(); - m_pen.foreColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_pen.foreOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); + m_penForeColor = libwpg::WPGColor(red, green, blue, alpha); WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha)); } @@ -740,10 +747,12 @@ unsigned char red = readU8(); unsigned char green = readU8(); unsigned char blue = readU8(); - unsigned char alpha = readU8(); + unsigned char alpha = 0xff - readU8(); - m_pen.backColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_pen.backOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); + m_penBackColor = libwpg::WPGColor(red, green, blue, alpha); + + m_style.insert("svg:stroke-color", m_penForeColor.getColorString()); + m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT); WPG_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha)); } @@ -758,10 +767,12 @@ unsigned int red = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned int blue = (m_doublePrecision) ? readU16()>>8 : readU8(); - unsigned int alpha = (m_doublePrecision) ? readU16()>>8 : readU8(); + unsigned int alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8(); - m_pen.backColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_pen.backOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); + m_penBackColor = libwpg::WPGColor(red, green, blue, alpha); + + m_style.insert("svg:stroke-color", m_penForeColor.getColorString()); + m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT); WPG_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha)); } @@ -774,11 +785,11 @@ return; unsigned int style = readU16(); - m_pen.dashArray = m_penStyles[style]; - m_pen.solid = (style == 0); + m_dashArray = m_penStyles[style]; + m_style.insert("libwpg:stroke-solid", !style); WPG_DEBUG_MSG((" Pen style : %d\n", style)); - WPG_DEBUG_MSG((" Segments : %d\n", m_pen.dashArray.count())); + WPG_DEBUG_MSG((" Segments : %d\n", m_dashArray.count())); } void WPG2Parser::handlePenSize() @@ -788,13 +799,13 @@ if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon()) return; unsigned int width = readU16(); - unsigned int height = readU16(); +// unsigned int height = readU16(); - m_pen.width = TO_DOUBLE(width) / m_xres; - m_pen.height = TO_DOUBLE(height) / m_yres; + m_style.insert("svg:stroke-width", TO_DOUBLE(width) / m_xres) +// m_pen.height = TO_DOUBLE(height) / m_yres; WPG_DEBUG_MSG((" Width: %d\n", width)); - WPG_DEBUG_MSG((" Height: %d\n", height)); +// WPG_DEBUG_MSG((" Height: %d\n", height)); } void WPG2Parser::handleDPPenSize() @@ -804,13 +815,13 @@ if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon()) return; unsigned long width = readU32(); - unsigned long height = readU32(); +// unsigned long height = readU32(); - m_pen.width = TO_DOUBLE(width) / m_xres / 256; - m_pen.height = TO_DOUBLE(height) / m_yres / 256; + m_style.insert("svg:stroke-width", TO_DOUBLE(width) / m_xres / 256); +// m_pen.height = TO_DOUBLE(height) / m_yres / 256; WPG_DEBUG_MSG((" Width: %li\n", width)); - WPG_DEBUG_MSG((" Height: %li\n", height)); +// WPG_DEBUG_MSG((" Height: %li\n", height)); } void WPG2Parser::handleBrushGradient() @@ -887,11 +898,14 @@ unsigned char red = readU8(); unsigned char green = readU8(); unsigned char blue = readU8(); - unsigned char alpha = readU8(); + unsigned char alpha = 0xff - readU8(); WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha)); - m_brush.foreColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_brush.foreOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); + m_brushForeColor = libwpg::WPGColor(red, green, blue, alpha); + + m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); + m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); + if(!m_style["draw:fill"] || m_style["draw:fill"]->getStr() != "gradient") m_style.insert("draw:fill", "solid"); } @@ -909,7 +923,7 @@ unsigned char red = readU8(); unsigned char green = readU8(); unsigned char blue = readU8(); - unsigned char alpha = readU8(); + unsigned char alpha = 0xff - readU8(); libwpg::WPGColor color(red, green, blue, alpha); colors.push_back(color); WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); @@ -938,7 +952,7 @@ gradient.addStop(ref, colors[0].getColorString(), colors[0].getOpacity()); if((m_gradientRef["svg:x"]->getInt() != 65535) && (m_gradientRef["svg:y"]->getInt() != 65535)) gradient.addStop(1, colors[1].getColorString(), colors[1].getOpacity()); - m_brush.gradient = gradient; + m_gradient = gradient; m_style.insert("draw:fill", "gradient"); } } @@ -958,11 +972,14 @@ unsigned char red = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned char green = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned char blue = (m_doublePrecision) ? readU16()>>8 : readU8(); - unsigned char alpha = (m_doublePrecision) ? readU16()>>8 : readU8(); + unsigned char alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8(); WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha)); - m_brush.foreColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_brush.foreOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); + m_brushForeColor = libwpg::WPGColor(red, green, blue, alpha); + + m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); + m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); + if(!m_style["draw:fill"] || m_style["draw:fill"]->getStr() != "none") m_style.insert("draw:fill", "solid"); } @@ -978,7 +995,7 @@ unsigned char red = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned char green = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned char blue = (m_doublePrecision) ? readU16()>>8 : readU8(); - unsigned char alpha = (m_doublePrecision) ? readU16()>>8 : readU8(); + unsigned char alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8(); libwpg::WPGColor color(red, green, blue, alpha); colors.push_back(color); WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); @@ -1006,7 +1023,7 @@ gradient.addStop(ref, colors[0].getColorString(), colors[0].getOpacity()); if((m_gradientRef["svg:x"]->getInt() != 65535) && (m_gradientRef["svg:y"]->getInt() != 65536)) gradient.addStop(1, colors[1].getColorString(), colors[1].getOpacity()); - m_brush.gradient = gradient; + m_gradient = gradient; m_style.insert("draw:fill", "gradient"); } } @@ -1021,10 +1038,13 @@ unsigned char red = readU8(); unsigned char green = readU8(); unsigned char blue = readU8(); - unsigned char alpha = readU8(); + unsigned char alpha = 0xff - readU8(); + + m_brushBackColor = libwpg::WPGColor(red, green, blue, alpha); + + m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); + m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); - m_brush.backColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_brush.backOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none") m_style.insert("draw:fill", "solid"); @@ -1041,10 +1061,13 @@ unsigned int red = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8(); unsigned int blue = (m_doublePrecision) ? readU16()>>8 : readU8(); - unsigned int alpha = (m_doublePrecision) ? readU16()>>8 : readU8(); + unsigned int alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8(); + + m_brushBackColor = libwpg::WPGColor(red, green, blue, alpha); + + m_style.insert("draw:fill-color", m_brushForeColor.getColorString()); + m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT); - m_brush.backColor = libwpg::WPGColor(red, green, blue, alpha).getColorString(); - m_brush.backOpacity = libwpg::WPGColor(red, green, blue, alpha).getOpacity(); if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none") m_style.insert("draw:fill", "solid"); @@ -1202,14 +1225,13 @@ else { // otherwise draw directly - ::WPXPropertyList fillRule; if (count > 2) { if(objCh.windingRule) - fillRule.insert("svg:fill-rule", "nonzero"); + m_style.insert("svg:fill-rule", "nonzero"); else - fillRule.insert("svg:fill-rule", "evenodd"); - m_painter->setStyle( objCh.framed ? m_pen : libwpg::WPGPen(), objCh.filled ? m_brush : libwpg::WPGBrush(), fillRule ); + m_style.insert("svg:fill-rule", "evenodd"); + m_painter->setStyle( objCh.framed ? m_dashArray : libwpg::WPGDashArray(), objCh.filled ? m_gradient : libwpg::WPGGradient(), m_style ); if (objCh.filled || objCh.closed) m_painter->drawPolygon(points); else @@ -1217,14 +1239,14 @@ } else { - m_painter->setStyle( objCh.framed ? m_pen : libwpg::WPGPen(), libwpg::WPGBrush(), fillRule ); + m_painter->setStyle( objCh.framed ? m_dashArray : libwpg::WPGDashArray(), libwpg::WPGGradient(), m_style ); m_painter->drawPolyline(points); } } WPG_DEBUG_MSG((" Vertices count : %li\n", count)); for(unsigned int j = 0; j < count; j++ ) - WPG_DEBUG_MSG((" Point #%d : %g,%g\n", j+1, points[j].x, points[j].y)); + WPG_DEBUG_MSG((" Point #%d : %g,%g\n", j+1, points[j]["svg:x"]->getDouble(), points[j]["svg:x"]->getDouble())); } void WPG2Parser::handlePolyspline() @@ -1303,12 +1325,11 @@ else { // otherwise draw directly - ::WPXPropertyList fillRule; if(objCh.windingRule) - fillRule.insert("svg:fill-rule", "nonzero"); + m_style.insert("svg:fill-rule", "nonzero"); else - fillRule.insert("svg:fill-rule", "evenodd"); - m_painter->setStyle( objCh.framed ? m_pen : libwpg::WPGPen(), objCh.filled ? m_brush : libwpg::WPGBrush(), fillRule ); + m_style.insert("svg:fill-rule", "evenodd"); + m_painter->setStyle( objCh.framed ? m_dashArray : libwpg::WPGDashArray(), objCh.filled ? m_gradient : libwpg::WPGGradient(), m_style ); m_painter->drawPath(path); } } @@ -1346,7 +1367,7 @@ propList.insert("svg:rx", (TO_DOUBLE(rx)/m_xres)); propList.insert("svg:ry", (TO_DOUBLE(ry)/m_yres)); - m_painter->setStyle( objCh.framed ? m_pen : libwpg::WPGPen(), objCh.filled ? m_brush : libwpg::WPGBrush(), ::WPXPropertyList() ); + m_painter->setStyle( objCh.framed ? m_dashArray : libwpg::WPGDashArray(), objCh.filled ? m_gradient : libwpg::WPGGradient(), m_style ); m_painter->drawRectangle(propList); WPG_DEBUG_MSG((" X1 : %li\n", x1)); @@ -1388,7 +1409,7 @@ if (objCh.rotate) propList.insert("libwpg:rotate", (double)(objCh.rotationAngle)); - m_painter->setStyle( objCh.framed ? m_pen : libwpg::WPGPen(), objCh.filled ? m_brush : libwpg::WPGBrush(), ::WPXPropertyList() ); + m_painter->setStyle( objCh.framed ? m_dashArray : libwpg::WPGDashArray(), objCh.filled ? m_gradient : libwpg::WPGGradient(), m_style ); m_painter->drawEllipse(propList /* TODO: fix this: libwpg::WPGPoint((double)ix/m_xres, (double)iy/m_yres), libwpg::WPGPoint((double)ex/m_xres, (double)ey/m_yres) */); @@ -1791,19 +1812,6 @@ m_painter->drawImageObject(propList, bitmap.getDIB()); } - -#ifdef DEBUG - // debugging only - if(buffer.size() && 0) - { - for(unsigned long x = 0; x < width; x++) - for(unsigned long y = 0; y < height; y++) - { - libwpg::WPGColor color = bitmap.pixel(x,y); - WPG_DEBUG_MSG((" pixel at %li, %li: %3d %3d %3d\n", x, y, color.red, color.green, color.blue)); - } - } -#endif } void WPG2Parser::handleObjectCapsule() @@ -1912,7 +1920,7 @@ propList.insert("svg:height", (m_binaryData.y2 - m_binaryData.y1)); propList.insert("libwpg:mime-type", m_binaryData.mimeTypes[m_binaryData.objectIndex]); - WPG_DEBUG_MSG(("Image Object Mime Type : %s\n", binaryData.mimeType.cstr())); + WPG_DEBUG_MSG(("Image Object Mime Type : %s\n", propList["libwpg:mime-type"]->getStr().cstr())); ::WPXBinaryData binaryData; while (!m_input->atEOS() && m_input->tell() <= m_recordEnd) Index: libwpg.h.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/libwpg.h.in,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- libwpg.h.in 4 Dec 2008 23:17:39 -0000 1.12 +++ libwpg.h.in 5 Dec 2008 15:17:26 -0000 1.13 @@ -35,8 +35,7 @@ #include "WPGraphics.h" #include "WPGPaintInterface.h" -#include "WPGPen.h" -#include "WPGBrush.h" +#include "WPGDashArray.h" #include "WPGGradient.h" #endif Index: WPGPen.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGPen.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- WPGPen.h 4 Dec 2008 23:17:39 -0000 1.7 +++ WPGPen.h 5 Dec 2008 15:17:25 -0000 1.8 @@ -35,13 +35,6 @@ class WPGPen { public: - ::WPXString foreColor; - ::WPXString backColor; - double foreOpacity; - double backOpacity; - double width; - double height; - bool solid; WPGDashArray dashArray; WPGPen(); |