17
17
#ifdef HAVE_CONFIG_H
18
18
# include <config.h>
21
#include <glibmm/i18n.h>
22
23
#include <display/curve.h>
23
24
#include <libnr/n-art-bpath.h>
24
25
#include <libnr/nr-path.h>
25
#include <libnr/nr-values.h>
26
#include <libnr/nr-macros.h>
27
#include <libnr/nr-matrix.h>
28
26
#include <libnr/nr-matrix-fns.h>
29
#include <libnr/nr-matrix-ops.h>
31
#include <glibmm/i18n.h>
32
28
#include "svg/svg.h"
33
29
#include "xml/repr.h"
34
30
#include "attributes.h"
38
32
#include "sp-path.h"
115
109
gint i = curve->length - 1;
116
110
if (i > r) i = r; // sometimes after switching from node editor length is wrong, e.g. f6 - draw - f2 - tab - f1, this fixes it
117
111
for (; i >= 0; i --)
118
if ((curve->bpath + i) -> code == NR_MOVETO)
112
if (SP_CURVE_BPATH(curve)[i].code == NR_MOVETO)
153
147
sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
155
SPPath *path = SP_PATH(object);
157
Inkscape::Version version = sp_object_get_sodipodi_version(object);
159
/* Fixes old Sodipodi nodetype to namespaced parameter */
160
if (sp_version_inside_range(version, 0, 0, 0, 25)) {
161
gchar const *str = repr->attribute("SODIPODI-PATH-NODE-TYPES");
162
sp_repr_set_attr(repr, "sodipodi:nodetypes", str);
163
sp_repr_set_attr(repr, "SODIPODI-PATH-NODE-TYPES", NULL);
166
149
sp_object_read_attr(object, "d");
168
151
/* d is a required attribute */
180
163
sp_conn_end_pair_build(object);
182
if (sp_version_inside_range(version, 0, 0, 0, 25)) {
183
SPShape *shape = (SPShape *) path;
184
/* Remove fill from open paths for compatibility with inkscape < 0.25 */
185
/* And set fill-rule of closed paths to evenodd */
186
/* We force style rewrite at moment (Lauris) */
187
gboolean changed = TRUE;
188
gboolean open = FALSE;
189
if (shape->curve && shape->curve->bpath) {
190
for (NArtBpath *bp = shape->curve->bpath; bp->code != NR_END; bp++) {
191
if (bp->code == NR_MOVETO_OPEN) {
197
SPCSSAttr *css = sp_repr_css_attr(repr, "style");
199
gchar const *val = sp_repr_css_property(css, "fill", NULL);
200
if (val && strcmp(val, "none")) {
201
sp_repr_css_set_property(css, "fill", "none");
205
gchar const *val = sp_repr_css_property(css, "fill-rule", NULL);
207
sp_repr_css_set_property(css, "fill-rule", "evenodd");
212
sp_repr_css_set(repr, css, "style");
214
sp_repr_css_attr_unref(css);
217
165
if (((SPObjectClass *) parent_class)->build) {
218
166
((SPObjectClass *) parent_class)->build(object, document, repr);
291
239
NArtBpath *abp = sp_curve_first_bpath(shape->curve);
293
241
gchar *str = sp_svg_write_path(abp);
294
sp_repr_set_attr(repr, "d", str);
242
repr->setAttribute("d", str);
297
sp_repr_set_attr(repr, "d", "");
245
repr->setAttribute("d", "");
300
sp_repr_set_attr(repr, "d", NULL);
248
repr->setAttribute("d", NULL);
303
251
SP_PATH(shape)->connEndPair.writeRepr(repr);
340
288
/* Transform the path */
341
289
NRBPath dpath, spath;
342
spath.path = shape->curve->bpath;
290
spath.path = SP_CURVE_BPATH(shape->curve);
343
291
nr_path_duplicate_transform(&dpath, &spath, xform);
344
292
SPCurve *curve = sp_curve_new_from_bpath(dpath.path);