sp-flowtext.cpp revision 950ccc6c98dbab31603a66a04b6101ab5a4752fc
299N/A#ifdef HAVE_CONFIG_H
299N/A#include "attributes.h"
299N/A#include "inkscape.h"
299N/A#include "document.h"
299N/A#include "selection.h"
299N/A#include "desktop-handles.h"
299N/A#include "sp-flowdiv.h"
299N/A#include "sp-flowregion.h"
299N/A#include "sp-flowtext.h"
299N/A#include "sp-string.h"
299N/A#include "text-tag-attributes.h"
299N/A#include "text-chemistry.h"
299N/A#include "display/nr-arena-glyphs.h"
299N/Astatic void sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
299N/Astatic Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
299N/Astatic void sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
299N/Astatic void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
sp_flowtext_get_type(void)
if (!group_type) {
sizeof(SPFlowtextClass),
sizeof(SPFlowtext),
return group_type;
for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
l = g_slist_reverse(l);
if (SP_IS_FLOWREGION(o)) {
region = o;
if (!region) return;
switch (key) {
case SP_ATTR_LAYOUT_OPTIONS: {
} else if ( strcmp(val, "simple") == 0 ) { // greedy, but allowed lines to be compressed by up to 20% if it would make them fit
sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) {
for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) ) {
return repr;
sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
if (!bbox_maybe) {
return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character%s)", "<b>Flowed text</b> (%d characters%s)", nChars), nChars, trunc);
return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character%s)", "<b>Linked flowed text</b> (%d characters%s)", nChars), nChars, trunc);
static NRArenaItem *
return flowed;
void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, std::list<Shape> *shapes, SPObject **pending_line_break_object)
bool with_indent = false;
if (SP_IS_FLOWTEXT(t)) {
if (indent != 0) {
with_indent = true;
if (*pending_line_break_object) {
for (SPObject *child = sp_object_first_child(root) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if (*pending_line_break_object) {
if (with_indent)
if (SP_IS_FLOWDIV(root) || SP_IS_FLOWPARA(root) || SP_IS_FLOWREGIONBREAK(root) || SP_IS_FLOWLINE(root)) {
delete shape_temp;
return shape;
delete exclusion_shape;
bool set_x = false;
bool set_y = false;
set_x = true;
set_y = true;
if (set_x)
sp_repr_set_svg_double(span_tspan, "x", anchor_point[Geom::X]); // FIXME: this will pick up the wrong end of counter-directional runs
if (set_y)
sp_repr_set_svg_double(line_tspan, "x", anchor_point[Geom::X]); // FIXME: this will pick up the wrong end of counter-directional runs
void *rawptr = 0;
gchar *style_text = sp_style_write_difference((SP_IS_STRING(source_obj) ? source_obj->parent : source_obj)->style, this->style);
void *rawptr = 0;
for (int i = this->layout.iteratorToCharIndex(it_span_end) - this->layout.iteratorToCharIndex(it) ; i ; --i)
return repr;
if (SP_IS_FLOWREGION(o)) {
region = o;
bool past = false;
if (SP_IS_ITEM(o)) {
past = true;
return frame;
root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create
Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); // FIXME: use path!!! after rects are converted to use path
using Geom::X;
using Geom::Y;
return ft_item;