~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to src/spray-context.cpp

  • Committer: Package Import Robot
  • Author(s): Alex Valavanis
  • Date: 2014-08-19 19:10:32 UTC
  • mfrom: (1.6.5) (2.5.14 sid)
  • Revision ID: package-import@ubuntu.com-20140819191032-2eca1qihaszjk9i6
Tags: 0.48.5-2ubuntu1
* Merge with Debian Unstable (LP: #1358863). Fixes several Ubuntu bugs:
  - Illustrator CS SVG won't load: namespace URIs in entities (LP: #166371)
  - inkscape crashed with SIGSEGV in
    sp_dtw_color_profile_event() (LP: #966441)
  - inkscape crashed with SIGSEGV (LP: #1051017)
  - inkscape crashed with SIGSEGV in Inkscape::Preferences::_getNode()
    (LP: #1163241)
  - save a copy reverts to save as (LP: #529843)
  - Extension to braille not working on Xubuntu 12.10 (LP: #1090865)
* Remaining changes:
  - debian/control:
    + Set Ubuntu Developer as maintainer,
    + build-depend on dh-translation to handle Ubuntu translation,
    + demote pstoedit from Recommends to Suggests (because it's in universe),
  - debian/patches/0006_add_unity_quicklist_support.patch: add.
  - debian/patches/series: update.
  - debian/rules:
    + add dh_translation to handle Ubuntu translation
* Drop debian/patches/librevenge.patch (superseded by
    debian/patches/0006-Update_to_new_libwpg.patch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define __SP_SPRAY_CONTEXT_C__
2
 
 
3
1
/*
4
2
 * Spray Tool
5
3
 *
240
238
        num = g_slist_length((GSList *) desktop->selection->itemList());
241
239
        sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
242
240
    } else {
243
 
        sel_message = g_strdup_printf(_("<b>Nothing</b> selected"));
 
241
        sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
244
242
    }
245
243
 
246
244
 
507
505
        }
508
506
    } else if (mode == SPRAY_MODE_SINGLE_PATH) {
509
507
 
510
 
        SPItem *father;         //initial Object
511
 
        SPItem *item_copied;    //Projected Object
512
 
        SPItem *unionResult;    //previous union
513
 
        SPItem *son;            //father copy
 
508
        SPItem *parent_item = NULL;         //initial Object
 
509
        SPItem *item_copied = NULL;    //Projected Object
 
510
        SPItem *union_result = NULL;    //previous union
514
511
 
515
512
        int i=1;
516
513
        for (GSList *items = g_slist_copy((GSList *) selection->itemList());
519
516
 
520
517
            SPItem *item1 = (SPItem *) items->data;
521
518
            if (i==1) {
522
 
                father=item1;
 
519
                parent_item = item1;
523
520
            }
524
521
            if (i==2) {
525
 
                unionResult=item1;
 
522
                union_result = item1;
526
523
            }
527
524
            i++;
528
525
        }
529
 
        SPDocument *doc = SP_OBJECT_DOCUMENT(father);
 
526
        SPDocument *doc = SP_OBJECT_DOCUMENT(parent_item);
530
527
        Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
531
 
        Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(father);
 
528
        Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(parent_item);
532
529
        Inkscape::XML::Node *parent = old_repr->parent();
533
530
 
534
 
        Geom::OptRect a = father->getBounds(sp_item_i2doc_affine(father));
 
531
        Geom::OptRect a = parent_item->getBounds(sp_item_i2doc_affine(parent_item));
535
532
        if (a) {
536
 
            if (i==2) {
537
 
                Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc);
538
 
                parent->appendChild(copy1);
539
 
                SPObject *new_obj1 = doc->getObjectByRepr(copy1);
540
 
                son = (SPItem *) new_obj1;   // conversion object->item
541
 
                unionResult=son;
542
 
                Inkscape::GC::release(copy1);
543
 
               }
544
 
 
545
533
            if (_fid<=population) { // Rules the population of objects sprayed
546
 
                // duplicates the father
547
 
                Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc);
548
 
                parent->appendChild(copy2);
549
 
                SPObject *new_obj2 = doc->getObjectByRepr(copy2);
550
 
                item_copied = (SPItem *) new_obj2;
 
534
                // duplicates the parent_item
 
535
                Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
 
536
                parent->appendChild(copy);
 
537
                SPObject *new_obj = doc->getObjectByRepr(copy);
 
538
                item_copied = SP_ITEM(new_obj);
551
539
 
552
540
                // Move around the cursor
553
541
                Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); 
554
542
 
555
 
                Geom::Point center=father->getCenter();
 
543
                Geom::Point center = parent_item->getCenter();
556
544
                sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale));
557
545
                sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
558
546
                sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
561
549
                // union and duplication
562
550
                selection->clear();
563
551
                selection->add(item_copied);
564
 
                selection->add(unionResult);
 
552
                if (union_result) {
 
553
                    selection->add(union_result);
 
554
                }
565
555
                sp_selected_path_union_skip_undo(selection->desktop());
566
 
                selection->add(father);
567
 
                Inkscape::GC::release(copy2);
 
556
                selection->add(parent_item);
 
557
                Inkscape::GC::release(copy);
568
558
                did = true;
569
559
            }
570
560
        }
580
570
 
581
571
                // Creation of the clone
582
572
                Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
583
 
                // Ad the clone to the list of the father's sons
 
573
                // Add the clone to the list of the parent_item's children
584
574
                parent->appendChild(clone);
585
 
                // Generates the link between father and son attributes
 
575
                // Generates the link between parent_item and child attributes
586
576
                clone->setAttribute("xlink:href", g_strdup_printf("#%s", old_repr->attribute("id")), false); 
587
577
 
588
578
                SPObject *clone_object = doc->getObjectByRepr(clone);