summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-06-10 14:20:18 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-08-05 00:31:06 +0000
commit7aaeaacc08de60fd324646afe69f4dbed93f89d4 (patch)
tree13c87e946659151021e553dc3b752c3dbcd2f4a2 /src/extension
parentFix one symbolic icon bug (diff)
downloadinkscape-7aaeaacc08de60fd324646afe69f4dbed93f89d4.tar.gz
inkscape-7aaeaacc08de60fd324646afe69f4dbed93f89d4.zip
Allow inkscape handle units and percent in dasharray and dashoffset. Add pref optional to scale dashes on stroke scale
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/internal/cairo-render-context.cpp28
-rw-r--r--src/extension/internal/emf-inout.cpp58
-rw-r--r--src/extension/internal/emf-print.cpp53
-rw-r--r--src/extension/internal/javafx-out.cpp31
-rw-r--r--src/extension/internal/latex-pstricks.cpp10
-rw-r--r--src/extension/internal/wmf-inout.cpp33
-rw-r--r--src/extension/internal/wmf-print.cpp49
7 files changed, 222 insertions, 40 deletions
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index da0797600..6d2267fde 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -48,7 +48,8 @@
#include "object/sp-pattern.h"
#include "object/sp-mask.h"
#include "object/sp-clippath.h"
-
+#include "object/sp-namedview.h"
+#include "inkscape.h"
#include "util/units.h"
#ifdef WIN32
#include "libnrtype/FontFactory.h" // USE_PANGO_WIN32
@@ -1435,10 +1436,31 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, Geom::OptRect const &p
{
size_t ndashes = style->stroke_dasharray.values.size();
double* dashes =(double*)malloc(ndashes*sizeof(double));
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
for( unsigned i = 0; i < ndashes; ++i ) {
- dashes[i] = style->stroke_dasharray.values[i];
+ if(style->stroke_dasharray.values[i].unit == SVGLength::NONE) {
+ dashes[i] = style->stroke_dasharray.values[i].value;
+ } else if (style->stroke_dasharray.values[i].unit == SVGLength::PERCENT) {
+ dashes[i] = vbox.width() * style->stroke_dasharray.values[i].value;
+ } else {
+ dashes[i] = Inkscape::Util::Quantity::convert(style->stroke_dasharray.values[i].computed, "px", display_unit.c_str());
+ }
+ }
+ double dash_offset = 0;
+ if (style->stroke_dashoffset.unit == SVGLength::NONE) {
+ dash_offset = style->stroke_dashoffset.value;
+ } else if (style->stroke_dashoffset.unit == SVGLength::PERCENT) {
+ dash_offset = vbox.width() * style->stroke_dashoffset.value ;
+ } else {
+ dash_offset = Inkscape::Util::Quantity::convert(style->stroke_dashoffset.computed, "px", display_unit.c_str());
}
- cairo_set_dash(_cr, dashes, ndashes, style->stroke_dashoffset.value);
+ cairo_set_dash(_cr, dashes, ndashes, dash_offset);
free(dashes);
} else {
cairo_set_dash(_cr, nullptr, 0, 0.0); // disable dashing
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index d0556e467..79645466f 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -35,6 +35,7 @@
#include "document.h"
#include "object/sp-root.h"
#include "object/sp-path.h"
+#include "object/sp-namedview.h"
#include "print.h"
#include "extension/system.h"
#include "extension/print.h"
@@ -45,9 +46,11 @@
#include "display/drawing-item.h"
#include "clear-n_.h"
#include "svg/svg.h"
+#include "svg/svg-length.h"
#include "util/units.h" // even though it is included indirectly by emf-inout.h
#include "inkscape.h" // even though it is included indirectly by emf-inout.h
+
#include "emf-print.h"
#include "emf-inout.h"
@@ -981,10 +984,24 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
!d->dc[d->level].style.stroke_dasharray.values.empty() )
{
tmp_style << "stroke-dasharray:";
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
for (unsigned i=0; i<d->dc[d->level].style.stroke_dasharray.values.size(); i++) {
if (i)
tmp_style << ",";
- tmp_style << d->dc[d->level].style.stroke_dasharray.values[i];
+ if(d->dc[d->level].style.stroke_dasharray.values[i].unit == SVGLength::NONE) {
+ tmp_style << d->dc[d->level].style.stroke_dasharray.values[i].value;
+ } else if (d->dc[d->level].style.stroke_dasharray.values[i].unit == SVGLength::PERCENT) {
+ tmp_style << vbox.width() * d->dc[d->level].style.stroke_dasharray.values[i].value;
+ } else {
+ tmp_style << Inkscape::Util::Quantity::convert(d->dc[d->level].style.stroke_dasharray.values[i].computed, "px", display_unit.c_str());
+ }
+
}
tmp_style << ";";
tmp_style << "stroke-dashoffset:0;";
@@ -1097,17 +1114,21 @@ Emf::select_pen(PEMF_CALLBACK_DATA d, int index)
int penstyle = (pEmr->lopn.lopnStyle & U_PS_STYLE_MASK);
if (!d->dc[d->level].style.stroke_dasharray.values.empty() && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dasharray.values!=d->dc[d->level-1].style.stroke_dasharray.values)))
d->dc[d->level].style.stroke_dasharray.values.clear();
+ SVGLength svglength;
+ svglength.read("1");
if (penstyle==U_PS_DASH || penstyle==U_PS_DASHDOT || penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 3 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
+ svglength.read("3");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ svglength.read("1");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
if (penstyle==U_PS_DOT || penstyle==U_PS_DASHDOT || penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
if (penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
d->dc[d->level].style.stroke_dasharray.set = 1;
@@ -1183,7 +1204,9 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
d->dc[d->level].style.stroke_dasharray.values.clear();
for (unsigned int i=0; i<pEmr->elp.elpNumEntries; i++) {
double dash_length = pix_to_abs_size( d, pEmr->elp.elpStyleEntry[i] );
- d->dc[d->level].style.stroke_dasharray.values.push_back(dash_length);
+ SVGLength svglength;
+ svglength.set(SVGLength::PX, dash_length);
+ d->dc[d->level].style.stroke_dasharray.values.push_back(svglength);
}
d->dc[d->level].style.stroke_dasharray.set = 1;
} else {
@@ -1200,17 +1223,24 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
int penstyle = (pEmr->elp.elpPenStyle & U_PS_STYLE_MASK);
if (!d->dc[d->level].style.stroke_dasharray.values.empty() && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dasharray.values!=d->dc[d->level-1].style.stroke_dasharray.values)))
d->dc[d->level].style.stroke_dasharray.values.clear();
+ SVGLength svglength;
if (penstyle==U_PS_DASH || penstyle==U_PS_DASHDOT || penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 3 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 2 );
+ svglength.read("3");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ svglength.read("2");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
if (penstyle==U_PS_DOT || penstyle==U_PS_DASHDOT || penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 2 );
+ svglength.read("1");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ svglength.read("2");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
if (penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 2 );
+ svglength.read("1");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ svglength.read("2");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
d->dc[d->level].style.stroke_dasharray.set = 1;
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 254000db3..459794654 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -38,7 +38,7 @@
#include "helper/geom.h"
#include "helper/geom-curves.h"
#include "util/units.h"
-
+#include "inkscape.h"
#include "inkscape-version.h"
#include "extension/system.h"
@@ -55,6 +55,7 @@
#include "object/sp-root.h"
#include "object/sp-shape.h"
#include "object/sp-clippath.h"
+#include "object/sp-namedview.h"
#include "style.h"
#include "display/cairo-utils.h"
@@ -695,17 +696,32 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform)
} else {
unsigned i = 0;
while ((linestyle != U_PS_USERSTYLE) && (i < style->stroke_dasharray.values.size())) {
- if (style->stroke_dasharray.values[i] > 0.00000001) {
+ if (style->stroke_dasharray.values[i].computed > 0.00000001) {
linestyle = U_PS_USERSTYLE;
}
i++;
}
-
+
if (linestyle == U_PS_USERSTYLE) {
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
n_dash = style->stroke_dasharray.values.size();
dash = new uint32_t[n_dash];
for (i = 0; i < n_dash; i++) {
- dash[i] = MAX(1, (uint32_t) round(scale * style->stroke_dasharray.values[i] * PX2WORLD));
+ double dashval = 0;
+ if(style->stroke_dasharray.values[i].unit == SVGLength::NONE) {
+ dashval = style->stroke_dasharray.values[i].value;
+ } else if (style->stroke_dasharray.values[i].unit == SVGLength::PERCENT) {
+ dashval = vbox.width() * style->stroke_dasharray.values[i].value;
+ } else {
+ dashval = Inkscape::Util::Quantity::convert(style->stroke_dasharray.values[i].computed, "px", display_unit.c_str());
+ }
+ dash[i] = MAX(1, (uint32_t) round(scale * dashval * PX2WORLD));
}
}
}
@@ -1455,10 +1471,25 @@ unsigned int PrintEmf::stroke(
}
tlength = length(tmp_pathpw, 0.1);
tmp_pathpw2 = arc_length_parametrization(tmp_pathpw);
-
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
// go around the dash array repeatedly until the entire path is consumed (but not beyond).
while (slength < tlength) {
- elength = slength + style->stroke_dasharray.values[i++];
+ SVGLength i1 = style->stroke_dasharray.values[i++];
+ double dashval = 0;
+ if(i1.unit == SVGLength::NONE) {
+ dashval = i1.value;
+ } else if (i1.unit == SVGLength::PERCENT) {
+ dashval = vbox.width() * i1.value;
+ } else {
+ dashval = Inkscape::Util::Quantity::convert(i1.computed, "px", display_unit.c_str());
+ }
+ elength = slength + dashval;
if (elength > tlength) {
elength = tlength;
}
@@ -1469,7 +1500,15 @@ unsigned int PrintEmf::stroke(
first_frag = fragment;
}
slength = elength;
- slength += style->stroke_dasharray.values[i++]; // the gap
+ SVGLength i2 = style->stroke_dasharray.values[i++];
+ if(i2.unit == SVGLength::NONE) {
+ dashval = i2.value;
+ } else if (i2.unit == SVGLength::PERCENT) {
+ dashval = vbox.width() * i2.value;
+ } else {
+ dashval = Inkscape::Util::Quantity::convert(i2.computed, "px", display_unit.c_str());
+ }
+ slength += dashval; // the gap
if (i >= n_dash) {
i = 0;
}
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index ad8fa855d..9b795ea21 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -40,7 +40,9 @@
#include "object/sp-path.h"
#include "object/sp-linear-gradient.h"
#include "object/sp-radial-gradient.h"
+#include "object/sp-namedview.h"
#include "style.h"
+#include "util/units.h"
#include <string>
#include <cstdio>
@@ -435,15 +437,38 @@ bool JavaFXOutput::doStyle(SPStyle *style)
out(" strokeLineJoin: %s\n", getStrokeLineJoin(linejoin).c_str());
out(" strokeMiterLimit: %s\n", DSTR(style->stroke_miterlimit.value));
if (style->stroke_dasharray.set) {
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
+ double dash_offset = 0;
+ if (style->stroke_dashoffset.unit == SVGLength::NONE) {
+ dash_offset = style->stroke_dashoffset.value;
+ } else if (style->stroke_dashoffset.unit == SVGLength::PERCENT) {
+ dash_offset = vbox.width() * style->stroke_dashoffset.value;
+ } else {
+ dash_offset = Inkscape::Util::Quantity::convert(style->stroke_dashoffset.computed, "px", display_unit.c_str());
+ }
if (style->stroke_dashoffset.set) {
- out(" strokeDashOffset: %s\n", DSTR(style->stroke_dashoffset.value));
+ out(" strokeDashOffset: %s\n", DSTR(dash_offset));
}
out(" strokeDashArray: [ ");
for(unsigned i = 0; i < style->stroke_dasharray.values.size(); i++ ) {
+ double dash = 0;
+ if(style->stroke_dasharray.values[i].unit == SVGLength::NONE) {
+ dash = style->stroke_dasharray.values[i].value;
+ } else if (style->stroke_dasharray.values[i].unit == SVGLength::PERCENT) {
+ dash = vbox.width() * style->stroke_dasharray.values[i].value;
+ } else {
+ dash = Inkscape::Util::Quantity::convert(style->stroke_dasharray.values[i].computed, "px", display_unit.c_str());
+ }
if (i > 0) {
- out(", %.2lf", style->stroke_dasharray.values[i]);
+ out(", %.2lf", dash);
}else {
- out(" %.2lf", style->stroke_dasharray.values[i]);
+ out(" %.2lf", dash);
}
}
out(" ]\n");
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index f3bf06708..664ec0310 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -23,8 +23,10 @@
#include "util/units.h"
#include "helper/geom-curves.h"
+#include "object/sp-namedview.h"
#include "extension/print.h"
#include "extension/system.h"
+#include "inkscape.h"
#include "inkscape-version.h"
#include "io/sys.h"
#include "latex-pstricks.h"
@@ -240,11 +242,17 @@ unsigned int PrintLatex::stroke(Inkscape::Extension::Print * /*mod*/,
if (style->stroke_dasharray.set && !style->stroke_dasharray.values.empty()) {
os << ",linestyle=dashed,dash=";
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
for (unsigned i = 0; i < style->stroke_dasharray.values.size(); i++) {
if ((i)) {
os << " ";
}
- os << style->stroke_dasharray.values[i];
+ os << Inkscape::Util::Quantity::convert(style->stroke_dasharray.values[i].computed, "px", display_unit.c_str());
}
}
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index 72d44e123..a3df20903 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -44,8 +44,10 @@
#include "extension/output.h"
#include "display/drawing.h"
#include "display/drawing-item.h"
+#include "object/sp-namedview.h"
#include "clear-n_.h"
#include "svg/svg.h"
+#include "svg/svg-length.h"
#include "util/units.h" // even though it is included indirectly by wmf-inout.h
#include "inkscape.h" // even though it is included indirectly by wmf-inout.h
@@ -889,10 +891,23 @@ Wmf::output_style(PWMF_CALLBACK_DATA d)
!d->dc[d->level].style.stroke_dasharray.values.empty())
{
tmp_style << "stroke-dasharray:";
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
for (unsigned i=0; i<d->dc[d->level].style.stroke_dasharray.values.size(); i++) {
if (i)
tmp_style << ",";
- tmp_style << d->dc[d->level].style.stroke_dasharray.values[i];
+ if(d->dc[d->level].style.stroke_dasharray.values[i].unit == SVGLength::NONE) {
+ tmp_style << d->dc[d->level].style.stroke_dasharray.values[i].value;
+ } else if (d->dc[d->level].style.stroke_dasharray.values[i].unit == SVGLength::PERCENT) {
+ tmp_style << vbox.width() * d->dc[d->level].style.stroke_dasharray.values[i].value;
+ } else {
+ tmp_style << Inkscape::Util::Quantity::convert(d->dc[d->level].style.stroke_dasharray.values[i].computed, "px", display_unit.c_str());
+ }
}
tmp_style << ";";
tmp_style << "stroke-dashoffset:0;";
@@ -987,17 +1002,21 @@ Wmf::select_pen(PWMF_CALLBACK_DATA d, int index)
int penstyle = (up.Style & U_PS_STYLE_MASK);
if (!d->dc[d->level].style.stroke_dasharray.values.empty() && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dasharray.values!=d->dc[d->level-1].style.stroke_dasharray.values)))
d->dc[d->level].style.stroke_dasharray.values.clear();
+ SVGLength svglength;
if (penstyle==U_PS_DASH || penstyle==U_PS_DASHDOT || penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 3 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
+ svglength.read("3");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ svglength.read("1");
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
+ svglength.read("1");
if (penstyle==U_PS_DOT || penstyle==U_PS_DASHDOT || penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
if (penstyle==U_PS_DASHDOTDOT) {
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
- d->dc[d->level].style.stroke_dasharray.values.push_back( 1 );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
+ d->dc[d->level].style.stroke_dasharray.values.push_back( svglength );
}
d->dc[d->level].style.stroke_dasharray.set = 1;
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 613ae3f04..dbcfebfc5 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -40,6 +40,7 @@
#include "helper/geom-curves.h"
#include "inkscape-version.h"
+#include "inkscape.h"
#include "util/units.h"
@@ -55,6 +56,7 @@
#include "object/sp-linear-gradient.h"
#include "object/sp-root.h"
#include "object/sp-item.h"
+#include "object/sp-namedview.h"
#include "splivarot.h" // pieces for union on shapes
#include <2geom/svg-path-parser.h> // to get from SVG text to Geom::Path
@@ -602,8 +604,23 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform)
int mark_short=INT_MAX;
int mark_long =0;
int i;
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
for (i=0;i<n_dash;i++) {
- int mark = style->stroke_dasharray.values[i];
+ double dashval = 0;
+ if(style->stroke_dasharray.values[i].unit == SVGLength::NONE) {
+ dashval = style->stroke_dasharray.values[i].value;
+ } else if (style->stroke_dasharray.values[i].unit == SVGLength::PERCENT) {
+ dashval = vbox.width() * style->stroke_dasharray.values[i].value;
+ } else {
+ dashval = Inkscape::Util::Quantity::convert(style->stroke_dasharray.values[i].computed, "px", display_unit.c_str());
+ }
+ int mark = (int)dashval;
if (mark>mark_long) { mark_long = mark; }
if (mark<mark_short) { mark_short = mark; }
}
@@ -887,10 +904,25 @@ unsigned int PrintWmf::stroke(
}
tlength = length(tmp_pathpw, 0.1);
tmp_pathpw2 = arc_length_parametrization(tmp_pathpw);
-
// go around the dash array repeatedly until the entire path is consumed (but not beyond).
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Geom::Rect vbox = document->getViewBox();
+ Glib::ustring display_unit = "px";
+ if (nv) {
+ display_unit = nv->display_units->abbr;
+ }
while (slength < tlength) {
- elength = slength + style->stroke_dasharray.values[i++];
+ SVGLength i1 = style->stroke_dasharray.values[i++];
+ double dashval = 0;
+ if(i1.unit == SVGLength::NONE) {
+ dashval = i1.value;
+ } else if (i1.unit == SVGLength::PERCENT) {
+ dashval = vbox.width() * i1.value;
+ } else {
+ dashval = Inkscape::Util::Quantity::convert(i1.computed, "px", display_unit.c_str());
+ }
+ elength = slength + dashval;
if (elength > tlength) {
elength = tlength;
}
@@ -900,8 +932,15 @@ unsigned int PrintWmf::stroke(
} else {
first_frag = fragment;
}
- slength = elength;
- slength += style->stroke_dasharray.values[i++]; // the gap
+ SVGLength i2 = style->stroke_dasharray.values[i++];
+ if(i2.unit == SVGLength::NONE) {
+ dashval = i2.value;
+ } else if (i2.unit == SVGLength::PERCENT) {
+ dashval = vbox.width() * i2.value;
+ } else {
+ dashval = Inkscape::Util::Quantity::convert(i2.computed, "px", display_unit.c_str());
+ }
+ slength += dashval; // the gap
if (i >= n_dash) {
i = 0;
}