~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/sp-path.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-07-06 22:03:02 UTC
  • mto: (2.4.1 sid) (1.4.1 upstream) (45.1.3 maverick)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060706220302-itgso3qgxdaxjmcy
Tags: upstream-0.44
ImportĀ upstreamĀ versionĀ 0.44

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#ifdef HAVE_CONFIG_H
18
18
# include <config.h>
19
19
#endif
20
 
#include <string.h>
 
20
 
 
21
#include <glibmm/i18n.h>
21
22
 
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>
30
27
 
31
 
#include <glibmm/i18n.h>
32
28
#include "svg/svg.h"
33
29
#include "xml/repr.h"
34
30
#include "attributes.h"
35
 
#include "style.h"
36
 
#include "version.h"
37
31
 
38
32
#include "sp-path.h"
39
33
 
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)
119
113
            r --;
120
114
    return r;
121
115
}
152
146
static void
153
147
sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
154
148
{
155
 
    SPPath *path = SP_PATH(object);
156
 
 
157
 
    Inkscape::Version version = sp_object_get_sodipodi_version(object);
158
 
 
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);
164
 
    }
165
 
 
166
149
    sp_object_read_attr(object, "d");
167
150
 
168
151
    /* d is a required attribute */
179
162
 
180
163
    sp_conn_end_pair_build(object);
181
164
 
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) {
192
 
                    open = TRUE;
193
 
                    break;
194
 
                }
195
 
            }
196
 
        }
197
 
        SPCSSAttr *css = sp_repr_css_attr(repr, "style");
198
 
        if (open) {
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");
202
 
                changed = TRUE;
203
 
            }
204
 
        } else {
205
 
            gchar const *val = sp_repr_css_property(css, "fill-rule", NULL);
206
 
            if (!val) {
207
 
                sp_repr_css_set_property(css, "fill-rule", "evenodd");
208
 
                changed = TRUE;
209
 
            }
210
 
        }
211
 
        if (changed) {
212
 
            sp_repr_css_set(repr, css, "style");
213
 
        }
214
 
        sp_repr_css_attr_unref(css);
215
 
    }
216
 
 
217
165
    if (((SPObjectClass *) parent_class)->build) {
218
166
        ((SPObjectClass *) parent_class)->build(object, document, repr);
219
167
    }
291
239
        NArtBpath *abp = sp_curve_first_bpath(shape->curve);
292
240
        if (abp) {
293
241
            gchar *str = sp_svg_write_path(abp);
294
 
            sp_repr_set_attr(repr, "d", str);
 
242
            repr->setAttribute("d", str);
295
243
            g_free(str);
296
244
        } else {
297
 
            sp_repr_set_attr(repr, "d", "");
 
245
            repr->setAttribute("d", "");
298
246
        }
299
247
    } else {
300
 
        sp_repr_set_attr(repr, "d", NULL);
 
248
        repr->setAttribute("d", NULL);
301
249
    }
302
250
 
303
251
    SP_PATH(shape)->connEndPair.writeRepr(repr);
339
287
 
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);
345
293
    if (curve) {