~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/sp-star.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * Released under GNU GPL, read the file 'COPYING' for more information
15
15
 */
16
16
 
17
 
#include "config.h"
 
17
#ifdef HAVE_CONFIG_H
 
18
# include "config.h"
 
19
#endif
18
20
 
 
21
#include <cstring>
 
22
#include <string>
19
23
#include <glibmm/i18n.h>
20
24
 
21
25
#include "svg/svg.h"
22
26
#include "attributes.h"
23
27
#include "display/curve.h"
24
28
#include "xml/repr.h"
 
29
#include "document.h"
25
30
 
26
31
#include "sp-star.h"
27
32
 
37
42
static void sp_star_snappoints(SPItem const *item, SnapPointsIter p);
38
43
 
39
44
static void sp_star_set_shape (SPShape *shape);
 
45
static void sp_star_update_patheffect (SPShape *shape, bool write);
40
46
 
41
47
static SPShapeClass *parent_class;
42
48
 
87
93
        item_class->snappoints = sp_star_snappoints;
88
94
 
89
95
        shape_class->set_shape = sp_star_set_shape;
 
96
    shape_class->update_patheffect = sp_star_update_patheffect;
90
97
}
91
98
 
92
99
static void
126
133
        SPStar *star = SP_STAR (object);
127
134
 
128
135
        if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
129
 
                repr = sp_repr_new ("svg:path");
 
136
                Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
 
137
                repr = xml_doc->createElement("svg:path");
130
138
        }
131
139
 
132
140
        if (flags & SP_OBJECT_WRITE_EXT) {
267
275
                ((SPObjectClass *) parent_class)->update (object, ctx, flags);
268
276
}
269
277
 
 
278
static void
 
279
sp_star_update_patheffect(SPShape *shape, bool write)
 
280
{
 
281
    sp_star_set_shape(shape);
 
282
 
 
283
    if (write) {
 
284
        Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
 
285
        if ( shape->curve != NULL ) {
 
286
            NArtBpath *abp = sp_curve_first_bpath(shape->curve);
 
287
            if (abp) {
 
288
                gchar *str = sp_svg_write_path(abp);
 
289
                repr->setAttribute("d", str);
 
290
                g_free(str);
 
291
            } else {
 
292
                repr->setAttribute("d", "");
 
293
            }
 
294
        } else {
 
295
            repr->setAttribute("d", NULL);
 
296
        }
 
297
    }
 
298
 
 
299
    ((SPObject *)shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
300
}
 
301
 
270
302
static gchar *
271
303
sp_star_description (SPItem *item)
272
304
{
468
500
                        }
469
501
                }
470
502
 
471
 
        sp_curve_closepath (c);
472
 
        sp_shape_set_curve_insync (SP_SHAPE (star), c, TRUE);
473
 
        sp_curve_unref (c);
 
503
    sp_curve_closepath (c);
 
504
    sp_shape_perform_path_effect(c, SP_SHAPE (star));
 
505
    sp_shape_set_curve_insync (SP_SHAPE (star), c, TRUE);
 
506
    sp_curve_unref (c);
474
507
}
475
508
 
476
509
void