From: Fridrich S. <str...@us...> - 2008-12-04 10:16:23
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18363/src/lib Modified Files: WPG2Parser.cpp WPGSVGGenerator.cpp WPGSVGGenerator.h Log Message: don't fill straight line + don't fill opened objects Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- WPG2Parser.cpp 3 Dec 2008 23:05:05 -0000 1.92 +++ WPG2Parser.cpp 4 Dec 2008 10:16:18 -0000 1.93 @@ -1193,15 +1193,23 @@ { // otherwise draw directly ::WPXPropertyList fillRule; - if(objCh.windingRule) - fillRule.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 ); - if (objCh.filled || objCh.closed) - m_painter->drawPolygon(points); + if (count > 2) + { + if(objCh.windingRule) + fillRule.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 ); + if (objCh.filled || objCh.closed) + m_painter->drawPolygon(points); + else + m_painter->drawPolyline(points); + } else + { + m_painter->setStyle( objCh.framed ? m_pen : libwpg::WPGPen(), libwpg::WPGBrush(), fillRule ); m_painter->drawPolyline(points); + } } WPG_DEBUG_MSG((" Vertices count : %li\n", count)); Index: WPGSVGGenerator.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- WPGSVGGenerator.h 28 Nov 2008 12:25:45 -0000 1.17 +++ WPGSVGGenerator.h 4 Dec 2008 10:16:18 -0000 1.18 @@ -61,7 +61,7 @@ libwpg::WPGBrush m_brush; ::WPXPropertyList m_fillRule; int m_gradientIndex; - void writeStyle(); + void writeStyle(bool isClosed=true); void drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed); std::ostream & m_outputSink; Index: WPGSVGGenerator.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGSVGGenerator.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- WPGSVGGenerator.cpp 3 Dec 2008 23:05:05 -0000 1.26 +++ WPGSVGGenerator.cpp 4 Dec 2008 10:16:18 -0000 1.27 @@ -207,7 +207,7 @@ m_outputSink << ", "; } m_outputSink << "\"\n"; - writeStyle(); + writeStyle(isClosed); m_outputSink << "/>\n"; } } @@ -215,6 +215,7 @@ void libwpg::WPGSVGGenerator::drawPath(const ::WPXPropertyListVector& path) { m_outputSink << "<path d=\" "; + bool isClosed = false; WPXPropertyListVector::Iter i(path); for(unsigned i=0; i < path.count(); i++) { @@ -236,12 +237,15 @@ m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " "; m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); } - else if ((i >= path.count()-1) && propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z" ) + else if ((i >= path.count()-1 && i > 2) && propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z" ) + { + isClosed = true; m_outputSink << "\nZ"; + } } m_outputSink << "\" \n"; - writeStyle(); + writeStyle(isClosed); m_outputSink << "/>\n"; } @@ -260,7 +264,7 @@ } // create "style" attribute based on current pen and brush -void libwpg::WPGSVGGenerator::writeStyle() +void libwpg::WPGSVGGenerator::writeStyle(bool isClosed) { m_outputSink << "style=\""; @@ -287,17 +291,19 @@ m_outputSink << "; "; } - if(m_brush.style == libwpg::WPGBrush::NoBrush) + if(!isClosed || m_brush.style == libwpg::WPGBrush::NoBrush) m_outputSink << "fill: none; "; + else + { + if(m_fillRule["svg:fill-rule"]) + m_outputSink << "fill-rule: " << m_fillRule["svg:fill-rule"]->getStr().cstr() << "; "; - if(m_fillRule["svg:fill-rule"]) - m_outputSink << "fill-rule: " << m_fillRule["svg:fill-rule"]->getStr().cstr() << "; "; - - if(m_brush.style == libwpg::WPGBrush::Gradient) - m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; + if(m_brush.style == libwpg::WPGBrush::Gradient) + m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; - if(m_brush.style == libwpg::WPGBrush::Solid) - m_outputSink << "fill: " << m_brush.foreColor.getColorString().cstr() << "; "; + if(m_brush.style == libwpg::WPGBrush::Solid) + m_outputSink << "fill: " << m_brush.foreColor.getColorString().cstr() << "; "; + } m_outputSink << "\""; // style } |