From: Fridrich S. <str...@us...> - 2008-11-25 11:58:33
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28859/src/lib Modified Files: Makefile.am WPG1Parser.cpp WPG2Parser.cpp WPG2Parser.h WPGPaintInterface.h WPGSVGGenerator.cpp WPGSVGGenerator.h libwpg.h.in Removed Files: WPGPath.cpp WPGPath.h Log Message: getting rid of another data structure in favour of libwpd framework WPXProperty* classes Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- WPG2Parser.h 24 Nov 2008 10:16:19 -0000 1.26 +++ WPG2Parser.h 25 Nov 2008 11:58:28 -0000 1.27 @@ -112,7 +112,7 @@ public: unsigned subIndex; int parentType; - libwpg::WPGPath compoundPath; + ::WPXPropertyListVector compoundPath; WPG2TransformMatrix compoundMatrix; bool compoundWindingRule; bool compoundFilled; --- WPGPath.h DELETED --- Index: WPG1Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- WPG1Parser.cpp 24 Nov 2008 10:16:19 -0000 1.48 +++ WPG1Parser.cpp 25 Nov 2008 11:58:28 -0000 1.49 @@ -273,10 +273,11 @@ m_input->seek(2, WPX_SEEK_CUR); m_width = readU16(); m_height = readU16(); - - double width = (double)m_width / 1200.0; - double height = (double)m_height / 1200.0; - m_painter->startGraphics(width, height); + + ::WPXPropertyList propList; + propList.insert("svg:width", (float)((double)m_width/1200.0)); + propList.insert("svg:height", (float)((double)m_height/1200.0)); + m_painter->startGraphics(propList); m_graphicsStarted = true; WPG_DEBUG_MSG(("StartWPG\n")); @@ -362,9 +363,15 @@ int ex = readS16(); int ey = readS16(); - libwpg::WPGPointArray points; - points.add(libwpg::WPGPoint((double)sx/1200.0, (double)(m_height-sy)/1200.0)); - points.add(libwpg::WPGPoint((double)ex/1200.0, (double)(m_height-ey)/1200.0)); + ::WPXPropertyListVector points; + ::WPXPropertyList point; + point.insert("svg:x", (float)((double)sx/1200.0)); + point.insert("svg:y", (float)((double)(m_height-sy)/1200.0)); + points.append(point); + point.clear(); + point.insert("svg:x", (float)((double)ex/1200.0)); + point.insert("svg:y", (float)((double)(m_height-ey)/1200.0)); + points.append(point); m_painter->setBrush(m_brush); m_painter->setPen(m_pen); @@ -381,12 +388,16 @@ return; unsigned int count = readU16(); - libwpg::WPGPointArray points; + ::WPXPropertyListVector points; + ::WPXPropertyList point; for(unsigned int i = 0; i < count; i++ ) { + point.clear(); long x = readS16(); long y = readS16(); - points.add(libwpg::WPGPoint((double)x/1200.0, (double)(m_height-y)/1200.0)); + point.insert("svg:x", (float)((double)x/1200.0)); + point.insert("svg:y", (float)((double)(m_height-y)/1200.0)); + points.append(point); } m_painter->setBrush(libwpg::WPGBrush()); // not filled @@ -428,12 +439,16 @@ return; unsigned int count = readU16(); - libwpg::WPGPointArray points; + ::WPXPropertyListVector points; + ::WPXPropertyList point; for(unsigned int i = 0; i < count; i++ ) { + point.clear(); long x = readS16(); long y = readS16(); - points.add(libwpg::WPGPoint((double)x/1200.0, (double)(m_height-y)/1200.0)); + point.insert("svg:x", (float)((double)x/1200.0)); + point.insert("svg:y", (float)((double)(m_height-y)/1200.0)); + points.append(point); } m_painter->setBrush(m_brush); @@ -482,25 +497,37 @@ unsigned int count = readU16(); if (!count) return; - libwpg::WPGPath path; - path.closed = false; + ::WPXPropertyListVector path; + ::WPXPropertyList element; + + bool path_closed = false; long xInitial = readS16(); long yInitial = readS16(); - path.moveTo(libwpg::WPGPoint((double)xInitial/1200.0, (double)(m_height-yInitial)/1200.0)); + element.insert("libwpg:path-action", "M"); + element.insert("svg:x", (float)((double)xInitial/1200.0)); + element.insert("svg:y", (float)((double)(m_height-yInitial)/1200.0)); + path.append(element); for (unsigned i = 1; i < (count-1)/3; i++) { + element.clear(); 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)(m_height-yControl1)/1200.0), - libwpg::WPGPoint((double)xControl2/1200.0, (double)(m_height-yControl2)/1200.0), - libwpg::WPGPoint((double)xCoordinate/1200.0, (double)(m_height-yCoordinate)/1200.0)); + + element.insert("libwpg:path-action", "C"); + element.insert("svg:x1", (float)((double)xControl1/1200.0)); + element.insert("svg:y1", (float)((double)(m_height-yControl1)/1200.0)); + element.insert("svg:x2", (float)((double)xControl2/1200.0)); + element.insert("svg:y2", (float)((double)(m_height-yControl2)/1200.0)); + element.insert("svg:x", (float)((double)xCoordinate/1200.0)); + element.insert("svg:y", (float)((double)(m_height-yCoordinate)/1200.0)); + } - m_painter->setBrush(path.closed ? m_brush : libwpg::WPGBrush()); + m_painter->setBrush(path_closed ? m_brush : libwpg::WPGBrush()); m_painter->setPen(m_pen); m_painter->drawPath(path); Index: WPGSVGGenerator.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- WPGSVGGenerator.h 24 Nov 2008 10:16:19 -0000 1.11 +++ WPGSVGGenerator.h 25 Nov 2008 11:58:28 -0000 1.12 @@ -40,11 +40,11 @@ WPGSVGGenerator(std::ostream & output_sink); ~WPGSVGGenerator(); - void startGraphics(double imageWidth, double imageHeight); + void startGraphics(const ::WPXPropertyList &propList); void endGraphics(); void startLayer(unsigned int id); void endLayer(unsigned int id); - void startEmbeddedGraphics(double /* imageWidth */, double /* imageHeight */) {} + void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} void endEmbeddedGraphics() {} void setPen(const libwpg::WPGPen& pen); @@ -53,9 +53,9 @@ void drawRectangle(const libwpg::WPGRect& rect, double rx, double ry); void drawEllipse(const WPGPoint& center, double rx, double ry, double rotation, const WPGPoint& from, const WPGPoint& to); - void drawPolyline(const libwpg::WPGPointArray& vertices); - void drawPolygon(const libwpg::WPGPointArray& vertices); - void drawPath(const libwpg::WPGPath& path); + void drawPolyline(const ::WPXPropertyListVector& vertices); + void drawPolygon(const ::WPXPropertyListVector& vertices); + void drawPath(const ::WPXPropertyListVector& path); void drawBitmap(const libwpg::WPGBitmap& bitmap); void drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData); @@ -65,7 +65,7 @@ FillRule m_fillRule; int m_gradientIndex; void writeStyle(); - void drawPolySomething(const libwpg::WPGPointArray& vertices, bool isClosed); + void drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed); std::ostream & m_outputSink; }; --- WPGPath.cpp DELETED --- Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- WPGSVGGenerator.cpp 24 Nov 2008 10:16:19 -0000 1.17 +++ WPGSVGGenerator.cpp 25 Nov 2008 11:58:28 -0000 1.18 @@ -55,7 +55,7 @@ { } -void libwpg::WPGSVGGenerator::startGraphics(double width, double height) +void libwpg::WPGSVGGenerator::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\""; @@ -65,7 +65,11 @@ m_outputSink << "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" "; m_outputSink << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "; - m_outputSink << "width=\"" << doubleToString(72*width) << "\" height=\"" << doubleToString(72*height) << "\" >\n"; + if (propList["svg:width"]) + m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getFloat())) << "\" "; + if (propList["svg:height"]) + m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getFloat())) << "\""; + m_outputSink << " >\n"; m_gradientIndex = 1; } @@ -166,28 +170,26 @@ m_outputSink << "/>\n"; } -void libwpg::WPGSVGGenerator::drawPolyline(const libwpg::WPGPointArray& vertices) +void libwpg::WPGSVGGenerator::drawPolyline(const ::WPXPropertyListVector& vertices) { drawPolySomething(vertices, false); } -void libwpg::WPGSVGGenerator::drawPolygon(const libwpg::WPGPointArray& vertices) +void libwpg::WPGSVGGenerator::drawPolygon(const ::WPXPropertyListVector& vertices) { drawPolySomething(vertices, true); } -void libwpg::WPGSVGGenerator::drawPolySomething(const libwpg::WPGPointArray& vertices, bool isClosed) +void libwpg::WPGSVGGenerator::drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed) { if(vertices.count() < 2) return; if(vertices.count() == 2) { - const libwpg::WPGPoint& p1 = vertices[0]; - const libwpg::WPGPoint& p2 = vertices[1]; m_outputSink << "<line "; - m_outputSink << "x1=\"" << doubleToString(72*p1.x) << "\" y1=\"" << doubleToString(72*p1.y) << "\" "; - m_outputSink << "x2=\"" << doubleToString(72*p2.x) << "\" y2=\"" << doubleToString(72*p2.y) << "\"\n"; + m_outputSink << "x1=\"" << doubleToString(72*(vertices[0]["svg:x"]->getFloat())) << "\" y1=\"" << doubleToString(72*(vertices[0]["svg:y"]->getFloat())) << "\" "; + m_outputSink << "x2=\"" << doubleToString(72*(vertices[1]["svg:x"]->getFloat())) << "\" y2=\"" << doubleToString(72*(vertices[1]["svg:y"]->getFloat())) << "\"\n"; writeStyle(); m_outputSink << "/>\n"; } @@ -199,10 +201,11 @@ m_outputSink << "<polyline "; m_outputSink << "points=\""; - for(unsigned i = 0; i < vertices.count(); i++) + WPXPropertyListVector::Iter i(vertices); + for(i.rewind(); i.next();) { - m_outputSink << doubleToString(72*vertices[i].x) << " " << doubleToString(72*vertices[i].y); - if(i < vertices.count()-1) m_outputSink << ", "; + m_outputSink << doubleToString(72*(i()["svg:x"]->getFloat())) << " " << doubleToString(72*(i()["svg:y"]->getFloat())); + if(!i.last()) m_outputSink << ", "; } m_outputSink << "\"\n"; writeStyle(); @@ -210,38 +213,34 @@ } } -void libwpg::WPGSVGGenerator::drawPath(const libwpg::WPGPath& path) +void libwpg::WPGSVGGenerator::drawPath(const ::WPXPropertyListVector& path) { m_outputSink << "<path d=\""; - for(unsigned i = 0; i < path.count(); i++) + WPXPropertyListVector::Iter i(path); + for(i.rewind(); i.next();) { - libwpg::WPGPathElement element = path.element(i); - libwpg::WPGPoint point = element.point; - switch(element.type) + WPXPropertyList propList = i(); + if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "M") { - case libwpg::WPGPathElement::MoveToElement: - m_outputSink << "\n M" << doubleToString(72*point.x) << "," << doubleToString(72*point.y) << " "; - break; - - case libwpg::WPGPathElement::LineToElement: - m_outputSink << "\n L" << doubleToString(72*point.x) << "," << doubleToString(72*point.y) << " "; - break; - - case libwpg::WPGPathElement::CurveToElement: - m_outputSink << "C"; - m_outputSink << doubleToString(72*element.extra1.x) << "," << doubleToString(72*element.extra1.y) << " "; - m_outputSink << doubleToString(72*element.extra2.x) << "," << doubleToString(72*element.extra2.y) << " "; - m_outputSink << doubleToString(72*point.x) << "," << doubleToString(72*point.y); - break; - - default: - break; + m_outputSink << "\n M"; + m_outputSink << doubleToString(72*(propList["svg:x"]->getFloat())) << "," << doubleToString(72*(propList["svg:y"]->getFloat())) << " "; + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "L") + { + m_outputSink << "\n L"; + m_outputSink << doubleToString(72*(propList["svg:x"]->getFloat())) << "," << doubleToString(72*(propList["svg:y"]->getFloat())) << " "; + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "C") + { + m_outputSink << "C"; + m_outputSink << doubleToString(72*(propList["svg:x1"]->getFloat())) << "," << doubleToString(72*(propList["svg:y1"]->getFloat())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x2"]->getFloat())) << "," << doubleToString(72*(propList["svg:y2"]->getFloat())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x"]->getFloat())) << "," << doubleToString(72*(propList["svg:y"]->getFloat())) << " "; } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z") + m_outputSink << "Z"; } - if(path.closed) - m_outputSink << "Z"; - m_outputSink << "\" \n"; writeStyle(); m_outputSink << "/>\n"; Index: WPGPaintInterface.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGPaintInterface.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- WPGPaintInterface.h 24 Nov 2008 10:16:19 -0000 1.11 +++ WPGPaintInterface.h 25 Nov 2008 11:58:28 -0000 1.12 @@ -30,7 +30,6 @@ #include "WPGBitmap.h" #include <libwpd/libwpd.h> #include "WPGBrush.h" -#include "WPGPath.h" #include "WPGPen.h" #include "WPGPoint.h" #include "WPGRect.h" @@ -43,7 +42,7 @@ virtual ~WPGPaintInterface() {} // none of the other callback functions will be called before this function is called - virtual void startGraphics(double width, double height) = 0; + virtual void startGraphics(const ::WPXPropertyList &propList) = 0; virtual void setPen(const WPGPen& pen) = 0; @@ -56,7 +55,7 @@ virtual void endLayer(unsigned int id) = 0; - virtual void startEmbeddedGraphics(double width, double height) = 0; + virtual void startEmbeddedGraphics(const ::WPXPropertyList &propList) = 0; virtual void endEmbeddedGraphics() = 0; @@ -64,11 +63,11 @@ virtual void drawEllipse(const WPGPoint& center, double rx, double ry, double rotation, const WPGPoint& from, const WPGPoint& to) = 0; - virtual void drawPolygon(const WPGPointArray& vertices) = 0; + virtual void drawPolygon(const ::WPXPropertyListVector& vertices) = 0; - virtual void drawPolyline(const WPGPointArray& vertices) = 0; + virtual void drawPolyline(const ::WPXPropertyListVector &vertices) = 0; - virtual void drawPath(const WPGPath& path) = 0; + virtual void drawPath(const ::WPXPropertyListVector& path) = 0; virtual void drawBitmap(const WPGBitmap& bitmap) = 0; Index: Makefile.am =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/Makefile.am,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- Makefile.am 24 Nov 2008 10:16:19 -0000 1.28 +++ Makefile.am 25 Nov 2008 11:58:28 -0000 1.29 @@ -29,7 +29,6 @@ WPGGradient.h \ WPGPoint.h \ WPGRect.h \ - WPGPath.h \ WPGBitmap.h \ WPGPaintInterface.h @@ -45,7 +44,6 @@ WPGColor.cpp \ WPGGradient.cpp \ WPGPoint.cpp \ - WPGPath.cpp \ WPGRect.cpp \ WPGHeader.cpp \ WPGSVGGenerator.cpp \ @@ -59,7 +57,6 @@ WPGColor.h \ WPGPen.h \ WPGBrush.h \ - WPGPath.h \ WPGGradient.h \ WPGHeader.h \ WPGSVGGenerator.h \ Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -r1.83 -r1.84 --- WPG2Parser.cpp 24 Nov 2008 10:16:19 -0000 1.83 +++ WPG2Parser.cpp 25 Nov 2008 11:58:28 -0000 1.84 @@ -518,10 +518,11 @@ WPG_DEBUG_MSG((" width : %li\n", m_width)); WPG_DEBUG_MSG((" height : %li\n", m_height)); - double width = (TO_DOUBLE(m_width)) / m_xres; - double height = (TO_DOUBLE(m_height)) / m_yres; + ::WPXPropertyList propList; + propList.insert("svg:width", (float)((TO_DOUBLE(m_width)) / m_xres)); + propList.insert("svg:height", (float)((TO_DOUBLE(m_height)) / m_yres)); - m_painter->startGraphics(width, height); + m_painter->startGraphics(propList); static const int WPG2_defaultPenDashes[] = { 1, 291, 0, // style #0 (actually solid) @@ -612,7 +613,12 @@ m_painter->setFillRule(libwpg::WPGPaintInterface::WindingFill); else m_painter->setFillRule(libwpg::WPGPaintInterface::AlternatingFill); - context.compoundPath.closed = context.compoundClosed; + if (context.compoundClosed) + { + WPXPropertyList element; + element.insert("libwpg:path-action", "Z"); + context.compoundPath.append(element); + } m_painter->drawPath(context.compoundPath); } @@ -1145,14 +1151,17 @@ unsigned long count = readU16(); - libwpg::WPGPointArray points; + ::WPXPropertyListVector points; + ::WPXPropertyList point; for(unsigned long i = 0; i < count; i++ ) { + point.clear(); long x = (m_doublePrecision) ? readS32() : readS16(); long y = (m_doublePrecision) ? readS32() : readS16(); TRANSFORM_XY(x,y); - libwpg::WPGPoint p(TO_DOUBLE(x)/m_xres, TO_DOUBLE(y)/m_yres); - points.add(p); + point.insert("svg:x", (float)(TO_DOUBLE(x)/m_xres)); + point.insert("svg:y", (float)(TO_DOUBLE(y)/m_yres)); + points.append(point); } if(insideCompound) @@ -1161,10 +1170,18 @@ { // inside a compound ? convert it into path because for compound // we will only use paths - libwpg::WPGPath& path = m_groupStack.top().compoundPath; - path.moveTo(points[0]); + ::WPXPropertyListVector& path = m_groupStack.top().compoundPath; + ::WPXPropertyList element; + element = points[0]; + element.insert("libwpg:path-action", "M"); + path.append(element); for(unsigned long ii = 1; ii < count; ii++) - path.lineTo(points[ii]); + { + element.clear(); + element = points[ii]; + element.insert("libwpg:path-action", "L"); + path.append(element); + } } } else @@ -1217,36 +1234,49 @@ unsigned int count = readU16(); - libwpg::WPGPointArray vertices; - libwpg::WPGPointArray controlPoints; + ::WPXPropertyListVector path; + ::WPXPropertyList element; + ::WPXPropertyListVector vertices; + ::WPXPropertyListVector controlPoints; for(unsigned int i = 0; i < count; i++ ) { long ix = (m_doublePrecision) ? readS32() : readS16(); long iy = (m_doublePrecision) ? readS32() : readS16(); TRANSFORM_XY(ix,iy); - libwpg::WPGPoint initialPoint( TO_DOUBLE(ix)/m_xres, TO_DOUBLE(iy)/m_yres ); long ax = (m_doublePrecision) ? readS32() : readS16(); long ay = (m_doublePrecision) ? readS32() : readS16(); TRANSFORM_XY(ax,ay); - libwpg::WPGPoint anchorPoint( TO_DOUBLE(ax)/m_xres, TO_DOUBLE(ay)/m_yres ); long tx = (m_doublePrecision) ? readS32() : readS16(); long ty = (m_doublePrecision) ? readS32() : readS16(); TRANSFORM_XY(tx,ty); - libwpg::WPGPoint terminalPoint( TO_DOUBLE(tx)/m_xres, TO_DOUBLE(ty)/m_yres ); - vertices.add(anchorPoint); - if(i > 0) - controlPoints.add(initialPoint); - controlPoints.add(terminalPoint); + libwpg::WPGPoint initialPoint( TO_DOUBLE(ix)/m_xres, TO_DOUBLE(iy)/m_yres ); + libwpg::WPGPoint terminalPoint( TO_DOUBLE(tx)/m_xres, TO_DOUBLE(ty)/m_yres ); + libwpg::WPGPoint anchorPoint( TO_DOUBLE(ax)/m_xres, TO_DOUBLE(ay)/m_yres ); + + element.insert("svg:x", (float)(TO_DOUBLE(ax)/m_xres)); + element.insert("svg:y", (float)(TO_DOUBLE(ay)/m_yres)); + if (i == 0) + element.insert("libwpg:path-action", "M"); + else + { + element.insert("svg:x2", (float)(TO_DOUBLE(ix)/m_xres)); + element.insert("svg:y2", (float)(TO_DOUBLE(iy)/m_yres)); + element.insert("libwpg:path-action", "C"); + } + path.append(element); + element.insert("svg:x1", (float)(TO_DOUBLE(tx)/m_xres)); + element.insert("svg:y1", (float)(TO_DOUBLE(ty)/m_yres)); } - libwpg::WPGPath path; - path.closed = objCh.closed; - path.moveTo(vertices[0]); - for(unsigned j = 1; j < vertices.count(); j++) - path.curveTo(controlPoints[j*2-2], controlPoints[j*2-1], vertices[j]); + element.clear(); + if (objCh.closed) + { + element.insert("libwpg:path-action", "Z"); + path.append(element); + } if(insideCompound) // inside a compound ? just collect the path together Index: libwpg.h.in =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/libwpg.h.in,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- libwpg.h.in 24 Nov 2008 10:16:19 -0000 1.7 +++ libwpg.h.in 25 Nov 2008 11:58:28 -0000 1.8 @@ -39,7 +39,6 @@ #include "WPGPen.h" #include "WPGBrush.h" #include "WPGGradient.h" -#include "WPGPath.h" #include "WPGPoint.h" #include "WPGRect.h" #include "WPGBitmap.h" |