~ubuntu-branches/ubuntu/precise/inkscape/precise-updates

« back to all changes in this revision

Viewing changes to src/sp-flowtext.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "sp-rect.h"
28
28
#include "text-tag-attributes.h"
29
29
#include "text-chemistry.h"
30
 
 
 
30
#include "text-editing.h"
31
31
 
32
32
#include "livarot/Shape.h"
33
33
 
49
49
static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
50
50
static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx);
51
51
static gchar *sp_flowtext_description(SPItem *item);
 
52
static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
52
53
static NRArenaItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags);
53
54
static void sp_flowtext_hide(SPItem *item, unsigned key);
54
55
 
98
99
    item_class->bbox = sp_flowtext_bbox;
99
100
    item_class->print = sp_flowtext_print;
100
101
    item_class->description = sp_flowtext_description;
 
102
    item_class->snappoints = sp_flowtext_snappoints;
101
103
    item_class->show = sp_flowtext_show;
102
104
    item_class->hide = sp_flowtext_hide;
103
105
}
372
374
{
373
375
    Inkscape::Text::Layout const &layout = SP_FLOWTEXT(item)->layout;
374
376
    int const nChars = layout.iteratorToCharIndex(layout.end());
375
 
    if (SP_FLOWTEXT(item)->has_internal_frame())
376
 
        return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character)", "<b>Flowed text</b> (%d characters)", nChars), nChars);
377
 
    else
378
 
        return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character)", "<b>Linked flowed text</b> (%d characters)", nChars), nChars);
 
377
 
 
378
    char const *trunc = (layout.inputTruncated()) ? _(" [truncated]") : "";
 
379
 
 
380
    if (SP_FLOWTEXT(item)->has_internal_frame()) {
 
381
        return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character%s)", "<b>Flowed text</b> (%d characters%s)", nChars), nChars, trunc);
 
382
    } else {
 
383
        return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character%s)", "<b>Linked flowed text</b> (%d characters%s)", nChars), nChars, trunc);
 
384
    }
 
385
}
 
386
 
 
387
static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const */*snapprefs*/)
 
388
{
 
389
    // Choose a point on the baseline for snapping from or to, with the horizontal position
 
390
    // of this point depending on the text alignment (left vs. right)
 
391
    Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item);
 
392
    if (layout != NULL && layout->outputExists()) {
 
393
        boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
 
394
        if (pt) {
 
395
            p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
 
396
        }
 
397
    }
379
398
}
380
399
 
381
400
static NRArenaItem *