From: Fridrich S. <str...@us...> - 2008-12-05 00:14:40
|
Update of /cvsroot/libwpg/perfectspot/src/odg In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18793/src/odg Modified Files: OdgExporter.cxx Log Message: adapting to the current state of libwpg api Index: OdgExporter.cxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/OdgExporter.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- OdgExporter.cxx 28 Nov 2008 15:09:15 -0000 1.8 +++ OdgExporter.cxx 5 Dec 2008 00:14:35 -0000 1.9 @@ -40,8 +40,8 @@ miGradientIndex(1), miDashIndex(1), miGraphicsStyleIndex(1), - mfWidth(0.0f), - mfHeight(0.0f), + mfWidth(0.0), + mfHeight(0.0), mbIsFlatXML(isFlatXML) { } @@ -122,7 +122,7 @@ configItemOpenElement.addAttribute("config:type", "int"); configItemOpenElement.write(mpHandler); if (propList["svg:width"]) - mfWidth = propList["svg:width"]->getFloat(); + mfWidth = propList["svg:width"]->getDouble(); WPXString sWidth; sWidth.sprintf("%li", (unsigned long)(2540 * mfWidth)); mpHandler->characters(sWidth); mpHandler->endElement("config:config-item"); @@ -131,7 +131,7 @@ configItemOpenElement.addAttribute("config:type", "int"); configItemOpenElement.write(mpHandler); if (propList["svg:height"]) - mfHeight = propList["svg:height"]->getFloat(); + mfHeight = propList["svg:height"]->getDouble(); WPXString sHeight; sHeight.sprintf("%li", (unsigned long)(2540 * mfHeight)); mpHandler->characters(sHeight); mpHandler->endElement("config:config-item"); @@ -268,7 +268,10 @@ pDrawRectElement->addAttribute("svg:width", propList["svg:width"]->getStr()); pDrawRectElement->addAttribute("svg:height", propList["svg:height"]->getStr()); // FIXME: what to do when rx != ry ? + if (propList["svg:rx"]) pDrawRectElement->addAttribute("draw:corner-radius", propList["svg:rx"]->getStr()); + else + pDrawRectElement->addAttribute("draw:corner-radius", "0.0000in"); mBodyElements.push_back(pDrawRectElement); mBodyElements.push_back(new TagCloseElement("draw:rect")); } @@ -280,35 +283,35 @@ WPXString sValue; sValue.sprintf("gr%i", miGraphicsStyleIndex-1); pDrawEllipseElement->addAttribute("draw:style-name", sValue); - sValue = doubleToString(2 * propList["svg:rx"]->getFloat()); sValue.append("in"); + sValue = doubleToString(2 * propList["svg:rx"]->getDouble()); sValue.append("in"); pDrawEllipseElement->addAttribute("svg:width", sValue); - sValue = doubleToString(2 * propList["svg:ry"]->getFloat()); sValue.append("in"); + sValue = doubleToString(2 * propList["svg:ry"]->getDouble()); sValue.append("in"); pDrawEllipseElement->addAttribute("svg:height", sValue); - if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getFloat() != 0.0) + if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) { - double rotation = propList["libwpg:rotate"]->getFloat(); + double rotation = propList["libwpg:rotate"]->getDouble(); while(rotation < -180) rotation += 360; while(rotation > 180) rotation -= 360; double radrotation = rotation*M_PI/180.0; - double deltax = sqrt(pow(propList["svg:rx"]->getFloat(), 2.0) - + pow(propList["svg:ry"]->getFloat(), 2.0))*cos(atan(propList["svg:ry"]->getFloat()/propList["svg:rx"]->getFloat()) - - radrotation ) - propList["svg:rx"]->getFloat(); - double deltay = sqrt(pow(propList["svg:rx"]->getFloat(), 2.0) - + pow(propList["svg:ry"]->getFloat(), 2.0))*sin(atan(propList["svg:ry"]->getFloat()/propList["svg:rx"]->getFloat()) - - radrotation ) - propList["svg:ry"]->getFloat(); + double deltax = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0) + + pow(propList["svg:ry"]->getDouble(), 2.0))*cos(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble()) + - radrotation ) - propList["svg:rx"]->getDouble(); + double deltay = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0) + + pow(propList["svg:ry"]->getDouble(), 2.0))*sin(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble()) + - radrotation ) - propList["svg:ry"]->getDouble(); sValue = "rotate("; sValue.append(doubleToString(radrotation)); sValue.append(") "); - sValue.append("translate("); sValue.append(doubleToString(propList["svg:cx"]->getFloat() - propList["svg:rx"]->getFloat() - deltax)); + sValue.append("translate("); sValue.append(doubleToString(propList["svg:cx"]->getDouble() - propList["svg:rx"]->getDouble() - deltax)); sValue.append("in, "); - sValue.append(doubleToString(propList["svg:cy"]->getFloat() - propList["svg:ry"]->getFloat() - deltay)); sValue.append("in)"); + sValue.append(doubleToString(propList["svg:cy"]->getDouble() - propList["svg:ry"]->getDouble() - deltay)); sValue.append("in)"); pDrawEllipseElement->addAttribute("svg:transform", sValue); } else { - sValue = doubleToString(propList["svg:cx"]->getFloat()-propList["svg:rx"]->getFloat()); sValue.append("in"); + sValue = doubleToString(propList["svg:cx"]->getDouble()-propList["svg:rx"]->getDouble()); sValue.append("in"); pDrawEllipseElement->addAttribute("svg:x", sValue); - sValue = doubleToString(propList["svg:cy"]->getFloat()-propList["svg:ry"]->getFloat()); sValue.append("in"); + sValue = doubleToString(propList["svg:cy"]->getDouble()-propList["svg:ry"]->getDouble()); sValue.append("in"); pDrawEllipseElement->addAttribute("svg:y", sValue); } mBodyElements.push_back(pDrawEllipseElement); @@ -378,28 +381,28 @@ // try to find the bounding box // this is simple convex hull technique, the bounding box might not be // accurate but that should be enough for this purpose - double px = path[0]["svg:x"]->getFloat(); - double py = path[0]["svg:y"]->getFloat(); - double qx = path[0]["svg:x"]->getFloat(); - double qy = path[0]["svg:y"]->getFloat(); + double px = path[0]["svg:x"]->getDouble(); + double py = path[0]["svg:y"]->getDouble(); + double qx = path[0]["svg:x"]->getDouble(); + double qy = path[0]["svg:y"]->getDouble(); for(unsigned k = 0; k < path.count(); k++) { if (!path[k]["svg:x"] || !path[k]["svg:y"]) continue; - px = (px > path[k]["svg:x"]->getFloat()) ? path[k]["svg:x"]->getFloat() : px; - py = (py > path[k]["svg:y"]->getFloat()) ? path[k]["svg:y"]->getFloat() : py; - qx = (qx < path[k]["svg:x"]->getFloat()) ? path[k]["svg:x"]->getFloat() : qx; - qy = (qy < path[k]["svg:y"]->getFloat()) ? path[k]["svg:y"]->getFloat() : qy; + px = (px > path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : px; + py = (py > path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : py; + qx = (qx < path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : qx; + qy = (qy < path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : qy; if(path[k]["libwpg:path-action"]->getStr() == "C") { - px = (px > path[k]["svg:x1"]->getFloat()) ? path[k]["svg:x1"]->getFloat() : px; - py = (py > path[k]["svg:y1"]->getFloat()) ? path[k]["svg:y1"]->getFloat() : py; - qx = (qx < path[k]["svg:x1"]->getFloat()) ? path[k]["svg:x1"]->getFloat() : qx; - qy = (qy < path[k]["svg:y1"]->getFloat()) ? path[k]["svg:y1"]->getFloat() : qy; - px = (px > path[k]["svg:x2"]->getFloat()) ? path[k]["svg:x2"]->getFloat() : px; - py = (py > path[k]["svg:y2"]->getFloat()) ? path[k]["svg:y2"]->getFloat() : py; - qx = (qx < path[k]["svg:x2"]->getFloat()) ? path[k]["svg:x2"]->getFloat() : qx; - qy = (qy < path[k]["svg:y2"]->getFloat()) ? path[k]["svg:y2"]->getFloat() : qy; + px = (px > path[k]["svg:x1"]->getDouble()) ? path[k]["svg:x1"]->getDouble() : px; + py = (py > path[k]["svg:y1"]->getDouble()) ? path[k]["svg:y1"]->getDouble() : py; + qx = (qx < path[k]["svg:x1"]->getDouble()) ? path[k]["svg:x1"]->getDouble() : qx; + qy = (qy < path[k]["svg:y1"]->getDouble()) ? path[k]["svg:y1"]->getDouble() : qy; + px = (px > path[k]["svg:x2"]->getDouble()) ? path[k]["svg:x2"]->getDouble() : px; + py = (py > path[k]["svg:y2"]->getDouble()) ? path[k]["svg:y2"]->getDouble() : py; + qx = (qx < path[k]["svg:x2"]->getDouble()) ? path[k]["svg:x2"]->getDouble() : qx; + qy = (qy < path[k]["svg:y2"]->getDouble()) ? path[k]["svg:y2"]->getDouble() : qy; } } double vw = qx - px; @@ -431,22 +434,25 @@ if (path[i]["libwpg:path-action"]->getStr() == "M") { // 2540 is 2.54*1000, 2.54 in = 1 inch - sElement.sprintf("M%i %i", (unsigned)((path[i]["svg:x"]->getFloat()-px)*2540), (unsigned)((path[i]["svg:y"]->getFloat()-py)*2540)); + sElement.sprintf("M%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), + (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540)); sValue.append(sElement); } else if (path[i]["libwpg:path-action"]->getStr() == "L") { - sElement.sprintf("L%i %i", (unsigned)((path[i]["svg:x"]->getFloat()-px)*2540), (unsigned)((path[i]["svg:y"]->getFloat()-py)*2540)); + sElement.sprintf("L%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), + (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540)); sValue.append(sElement); } else if (path[i]["libwpg:path-action"]->getStr() == "C") { - sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((path[i]["svg:x1"]->getFloat()-px)*2540), - (int)((path[i]["svg:y1"]->getFloat()-py)*2540), (unsigned)((path[i]["svg:x2"]->getFloat()-px)*2540), - (int)((path[i]["svg:y2"]->getFloat()-py)*2540), (unsigned)((path[i]["svg:x"]->getFloat()-px)*2540), (unsigned)((path[i]["svg:y"]->getFloat()-py)*2540)); + sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540), + (int)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x2"]->getDouble()-px)*2540), + (int)((path[i]["svg:y2"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), + (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540)); sValue.append(sElement); } - else if (path[i]["libwpg:path-action"]->getStr() == "Z" && i == (path.count() - 1)) + else if (path[i]["libwpg:path-action"]->getStr() == "Z" && i >= (path.count() - 1)) sValue.append(" Z"); } pDrawPathElement->addAttribute("svg:d", sValue); @@ -516,7 +522,7 @@ mGraphicsStrokeDashStyles.push_back(new TagCloseElement("draw:stroke-dash")); } - if(mxBrush.style == libwpg::WPGBrush::Gradient) + if(mxBrush.style == "gradient") { TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient"); pDrawGradientElement->addAttribute("draw:style", "linear"); @@ -534,12 +540,8 @@ sValue.sprintf("%i", (unsigned)(angle*10)); pDrawGradientElement->addAttribute("draw:angle", sValue); - libwpg::WPGColor startColor = mxBrush.gradient.stopColor(0); - libwpg::WPGColor stopColor = mxBrush.gradient.stopColor(1); - sValue.sprintf("#%.2x%.2x%.2x", (startColor.red & 0xff), (startColor.green & 0xff), (startColor.blue & 0xff)); - pDrawGradientElement->addAttribute("draw:start-color", sValue); - sValue.sprintf("#%.2x%.2x%.2x", (stopColor.red & 0xff), (stopColor.green & 0xff), (stopColor.blue & 0xff)); - pDrawGradientElement->addAttribute("draw:end-color", sValue); + pDrawGradientElement->addAttribute("draw:start-color", mxBrush.gradient.stopColor(0).cstr()); + pDrawGradientElement->addAttribute("draw:end-color", mxBrush.gradient.stopColor(1).cstr()); pDrawGradientElement->addAttribute("draw:start-intensity", "100%"); pDrawGradientElement->addAttribute("draw:end-intensity", "100%"); pDrawGradientElement->addAttribute("draw:border", "0%"); @@ -562,9 +564,7 @@ sValue = doubleToString(mxPen.width); sValue.append("in"); pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-width", sValue); - sValue.sprintf("#%.2x%.2x%.2x", (mxPen.foreColor.red & 0xff), - (mxPen.foreColor.green & 0xff), (mxPen.foreColor.blue & 0xff)); - pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-color", sValue); + pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-color", mxPen.foreColor.cstr()); if(!mxPen.solid) { @@ -576,18 +576,16 @@ else pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "none"); - if(mxBrush.style == libwpg::WPGBrush::NoBrush) + if(mxBrush.style == "none") pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "none"); - if(mxBrush.style == libwpg::WPGBrush::Solid) + if(mxBrush.style == "solid") { pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "solid"); - sValue.sprintf("#%.2x%.2x%.2x", (mxBrush.foreColor.red & 0xff), - (mxBrush.foreColor.green & 0xff), (mxBrush.foreColor.blue & 0xff)); - pStyleGraphicsPropertiesElement->addAttribute("draw:fill-color", sValue); + pStyleGraphicsPropertiesElement->addAttribute("draw:fill-color", mxBrush.foreColor.cstr()); } - if(mxBrush.style == libwpg::WPGBrush::Gradient) + if(mxBrush.style == "gradient") { pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "gradient"); sValue.sprintf("Gradient_%i", miGradientIndex-1); |