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

« back to all changes in this revision

Viewing changes to src/sp-tspan.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Kees Cook, Ted Gould
  • Date: 2008-02-10 14:20:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080210142016-vcnb2zqyhszu0xvb
Tags: 0.46~pre1-0ubuntu1
[ Kees Cook ]
* debian/control:
  - add libgtkspell-dev build-dep to gain GtkSpell features (LP: #183547).
  - update Standards version (no changes needed).
  - add Vcs and Homepage fields.
  - switch to new python-lxml dep.
* debian/{control,rules}: switch from dpatch to quilt for more sanity.
* debian/patches/20_fix_glib_and_gxx43_ftbfs.patch:
  - merged against upstream fixes.
  - added additional fixes for newly written code.
* debian/rules: enable parallel building.

[ Ted Gould ]
* Updating POTFILES.in to make it so things build correctly.
* debian/control:
  - add ImageMagick++ and libboost-dev to build-deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
# include "config.h"
28
28
#endif
29
29
 
 
30
#include <cstring>
 
31
#include <string>
 
32
#include <glibmm/i18n.h>
 
33
 
30
34
#include <livarot/Path.h>
31
35
#include "svg/stringstream.h"
32
36
#include "attributes.h"
33
37
#include "sp-use-reference.h"
34
38
#include "sp-tspan.h"
 
39
#include "sp-tref.h"
35
40
#include "sp-textpath.h"
36
41
#include "text-editing.h"
37
42
#include "style.h"
38
43
#include "libnr/nr-matrix-fns.h"
39
44
#include "xml/repr.h"
 
45
#include "document.h"
40
46
 
41
47
 
42
48
/*#####################################################
53
59
static void sp_tspan_modified(SPObject *object, unsigned flags);
54
60
static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
55
61
static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
 
62
static char *sp_tspan_description (SPItem *item);
56
63
 
57
64
static SPItemClass *tspan_parent_class;
58
65
 
100
107
    sp_object_class->write = sp_tspan_write;
101
108
 
102
109
    item_class->bbox = sp_tspan_bbox;
 
110
    item_class->description = sp_tspan_description;
103
111
}
104
112
 
105
113
static void
142
150
    SPTSpan *tspan = SP_TSPAN(object);
143
151
        
144
152
    if (tspan->attributes.readSingleAttribute(key, value)) {
145
 
        if (tspan->role != SP_TSPAN_ROLE_LINE)
146
 
            object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 
153
        object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
147
154
    } else {
148
155
        switch (key) {
149
156
            case SP_ATTR_SODIPODI_ROLE:
196
203
    }
197
204
}
198
205
 
199
 
static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
 
206
static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
200
207
{
201
208
    // find out the ancestor text which holds our layout
202
209
    SPObject *parent_text = SP_OBJECT(item);
208
215
 
209
216
    // Add stroke width
210
217
    SPStyle* style=SP_OBJECT_STYLE (item);
211
 
    if (style->stroke.type != SP_PAINT_TYPE_NONE) {
 
218
    if (!style->stroke.isNone()) {
212
219
        double const scale = expansion(transform);
213
220
        if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
214
221
            double const width = MAX(0.125, style->stroke_width.computed * scale);
226
233
sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
227
234
{
228
235
    SPTSpan *tspan = SP_TSPAN(object);
 
236
    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
229
237
        
230
238
    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
231
 
        repr = sp_repr_new("svg:tspan");
 
239
        repr = xml_doc->createElement("svg:tspan");
232
240
    }
233
241
        
234
242
    tspan->attributes.writeTo(repr);
237
245
        GSList *l = NULL;
238
246
        for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
239
247
            Inkscape::XML::Node* c_repr=NULL;
240
 
            if ( SP_IS_TSPAN(child) ) {
 
248
            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
241
249
                c_repr = child->updateRepr(NULL, flags);
242
250
            } else if ( SP_IS_TEXTPATH(child) ) {
243
251
                //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
244
252
            } else if ( SP_IS_STRING(child) ) {
245
 
                c_repr = sp_repr_new_text(SP_STRING(child)->string.c_str());
 
253
                c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
246
254
            }
247
255
            if ( c_repr ) l = g_slist_prepend(l, c_repr);
248
256
        }
253
261
        }
254
262
    } else {
255
263
        for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
256
 
            if ( SP_IS_TSPAN(child) ) {
 
264
            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
257
265
                child->updateRepr(flags);
258
266
            } else if ( SP_IS_TEXTPATH(child) ) {
259
267
                //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
269
277
    return repr;
270
278
}
271
279
 
 
280
static char *
 
281
sp_tspan_description(SPItem *item)
 
282
{
 
283
    g_return_val_if_fail(SP_IS_TSPAN(item), NULL);
 
284
 
 
285
    return g_strdup(_("<b>Text span</b>"));
 
286
}
 
287
 
 
288
 
272
289
/*#####################################################
273
290
#  SPTEXTPATH
274
291
#####################################################*/
390
407
    }
391
408
        
392
409
    if ( no_content ) {
393
 
        Inkscape::XML::Node* rch = sp_repr_new_text("");
 
410
        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
 
411
        Inkscape::XML::Node* rch = xml_doc->createTextNode("");
394
412
        repr->addChild(rch, NULL);
395
413
    }
396
414
        
487
505
sp_textpath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
488
506
{
489
507
    SPTextPath *textpath = SP_TEXTPATH(object);
 
508
    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
490
509
        
491
510
    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
492
 
        repr = sp_repr_new("svg:textPath");
 
511
        repr = xml_doc->createElement("svg:textPath");
493
512
    }
494
513
        
495
514
    textpath->attributes.writeTo(repr);
511
530
        GSList *l = NULL;
512
531
        for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
513
532
            Inkscape::XML::Node* c_repr=NULL;
514
 
            if ( SP_IS_TSPAN(child) ) {
 
533
            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
515
534
                c_repr = child->updateRepr(NULL, flags);
516
535
            } else if ( SP_IS_TEXTPATH(child) ) {
517
536
                //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
518
537
            } else if ( SP_IS_STRING(child) ) {
519
 
                c_repr = sp_repr_new_text(SP_STRING(child)->string.c_str());
 
538
                c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
520
539
            }
521
540
            if ( c_repr ) l = g_slist_prepend(l, c_repr);
522
541
        }
527
546
        }
528
547
    } else {
529
548
        for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
530
 
            if ( SP_IS_TSPAN(child) ) {
 
549
            if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
531
550
                child->updateRepr(flags);
532
551
            } else if ( SP_IS_TEXTPATH(child) ) {
533
552
                //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
572
591
 
573
592
    for ( GSList *i = tp_reprs ; i ; i = i->next ) {
574
593
        // make a copy of each textpath child
575
 
        Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate();
 
594
        Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(SP_OBJECT_REPR(text)->document());
576
595
        // remove the old repr from under textpath
577
596
        SP_OBJECT_REPR(tp)->removeChild((Inkscape::XML::Node *) i->data);
578
 
        // put its copy into under textPath
 
597
        // put its copy under text
579
598
        SP_OBJECT_REPR(text)->addChild(copy, NULL); // fixme: copy id
580
599
    }
581
600