summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/wmf-print.cpp
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/internal/wmf-print.cpp
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/internal/wmf-print.cpp')
-rw-r--r--src/extension/internal/wmf-print.cpp49
1 files changed, 44 insertions, 5 deletions
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;
}