From 8362bda6232d49568a2ba0e171ac1a2de2f261e9 Mon Sep 17 00:00:00 2001 From: ishmal Date: Fri, 14 Apr 2006 18:20:42 +0000 Subject: [PATCH] Fixed desktop-to-doc Y flip --- src/extension/internal/odf.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 3b6d0e79e..6424e0302 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -185,7 +185,7 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) int r = (fillCol >> 24) & 0xff; int g = (fillCol >> 16) & 0xff; int b = (fillCol >> 8) & 0xff; - g_message("## %s %lx", id.c_str(), fillCol); + //g_message("## %s %lx", id.c_str(), fillCol); snprintf(buf, 15, "#%02x%02x%02x", r, g, b); si.fillColor = buf; si.fill = "solid"; @@ -380,7 +380,12 @@ bool OdfOutput::writeStyle(Writer &outs) outs.printf("\n"); outs.printf("\n"); outs.printf("\n"); - outs.printf(" \n"); + outs.printf(" \n"); outs.printf("\n"); outs.printf("\n"); outs.printf(" \n"); @@ -422,14 +427,6 @@ writePath(Writer &outs, NArtBpath const *bpath, NArtBpath *bp = (NArtBpath *)bpath; for ( ; bp->code != NR_END; bp++) { - /* - double x1 = (bp->x1 * pxToCm - xoff) * 1000.0; - double y1 = (bp->y1 * pxToCm - yoff) * 1000.0; - double x2 = (bp->x2 * pxToCm - xoff) * 1000.0; - double y2 = (bp->y2 * pxToCm - yoff) * 1000.0; - double x3 = (bp->x3 * pxToCm - xoff) * 1000.0; - double y3 = (bp->y3 * pxToCm - yoff) * 1000.0; - */ NR::Point const p1(bp->c(1) * tf); NR::Point const p2(bp->c(2) * tf); NR::Point const p3(bp->c(3) * tf); @@ -491,6 +488,14 @@ bool OdfOutput::writeTree(Writer &outs, Inkscape::XML::Node *node) NR::Matrix tf = sp_item_i2d_affine(item); NR::Rect bbox = sp_item_bbox_desktop(item); + //Flip Y into document coordinates + double svgHeight = sp_document_height(SP_ACTIVE_DOCUMENT); + double doc_height = svgHeight; // * pxToCm; + NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1, -1)); + doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height)); + tf = tf * doc2dt_tf; + bbox = bbox * doc2dt_tf; + double x = pxToCm * bbox.min()[NR::X]; double y = pxToCm * bbox.min()[NR::Y]; double width = pxToCm * ( bbox.max()[NR::X] - bbox.min()[NR::X] ); @@ -500,7 +505,7 @@ bool OdfOutput::writeTree(Writer &outs, Inkscape::XML::Node *node) //# Do our stuff SPCurve *curve = NULL; - g_message("##### %s #####", nodeName.c_str()); + //g_message("##### %s #####", nodeName.c_str()); if (nodeName == "svg" || nodeName == "svg:svg") { @@ -694,7 +699,8 @@ bool OdfOutput::writeContent(ZipFile &zf, Inkscape::XML::Node *node) outs.printf("\n"); outs.printf("\n"); outs.printf("\n"); - outs.printf("\n"); + outs.printf("\n"); outs.printf("\n"); outs.printf("\n"); -- 2.30.2