diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index fbf0efabd5b5da992b7f75a642f72991cce13dad..a161239017fa0e70218c1132294933558b5a8cff 100644 (file)
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
static void
sp_flowtext_init(SPFlowtext *group)
{
+ group->par_indent = 0;
new (&group->layout) Inkscape::Text::Layout();
}
group->rebuildLayout();
- // pass the bbox of the flowtext object as paintbox (used for paintserver fills)
+ // pass the bbox of the flowtext object as paintbox (used for paintserver fills)
NRRect paintbox;
sp_item_invoke_bbox(group, &paintbox, NR::identity(), TRUE);
for (SPItemView *v = group->display; v != NULL; v = v->next) {
}
}
}
+ */
{ // This would probably translate to padding-left, if SPStyle had it.
gchar const *val = sp_repr_css_property(opts, "par-indent", NULL);
if ( val == NULL ) {
sp_repr_get_double((Inkscape::XML::Node*)opts, "par-indent", &group->par_indent);
}
}
- */
sp_repr_css_attr_unref(opts);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
Inkscape::XML::Node *c_repr = NULL;
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) {
c_repr = child->updateRepr(NULL, flags);
- }
+ }
if ( c_repr ) l = g_slist_prepend(l, c_repr);
}
while ( l ) {
@@ -310,6 +311,21 @@ sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform,
{
SPFlowtext *group = SP_FLOWTEXT(item);
group->layout.getBoundingBox(bbox, transform);
+
+ // Add stroke width
+ SPStyle* style=SP_OBJECT_STYLE (item);
+ if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ double const scale = expansion(transform);
+ if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
+ double const width = MAX(0.125, style->stroke_width.computed * scale);
+ if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
+ bbox->x0-=0.5*width;
+ bbox->x1+=0.5*width;
+ bbox->y0-=0.5*width;
+ bbox->y1+=0.5*width;
+ }
+ }
+ }
}
static void
Inkscape::Text::Layout const &layout = SP_FLOWTEXT(item)->layout;
int const nChars = layout.iteratorToCharIndex(layout.end());
if (SP_FLOWTEXT(item)->has_internal_frame())
- return g_strdup_printf(_("<b>Flowed text</b> (%d characters)"), nChars);
- else
- return g_strdup_printf(_("<b>Linked flowed text</b> (%d characters)"), nChars);
+ return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character)", "<b>Flowed text</b> (%d characters)", nChars), nChars);
+ else
+ return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character)", "<b>Linked flowed text</b> (%d characters)", nChars), nChars);
}
static NRArenaItem *
@@ -349,7 +365,7 @@ sp_flowtext_show(SPItem *item, NRArena *arena, unsigned/* key*/, unsigned /*flag
NRArenaGroup *flowed = NRArenaGroup::create(arena);
nr_arena_group_set_transparent(flowed, FALSE);
- // pass the bbox of the flowtext object as paintbox (used for paintserver fills)
+ // pass the bbox of the flowtext object as paintbox (used for paintserver fills)
NRRect paintbox;
sp_item_invoke_bbox(item, &paintbox, NR::identity(), TRUE);
group->layout.show(flowed, &paintbox);
void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, std::list<Shape> *shapes, SPObject **pending_line_break_object)
{
+ Inkscape::Text::Layout::OptionalTextTagAttrs pi;
+ bool with_indent = false;
+
+ if (SP_IS_FLOWPARA(root)) {
+ // emulate par-indent with the first char's kern
+ SPObject *t = root;
+ for ( ; t != NULL && !SP_IS_FLOWTEXT(t); t = SP_OBJECT_PARENT(t));
+ if (SP_IS_FLOWTEXT(t)) {
+ double indent = SP_FLOWTEXT(t)->par_indent;
+ if (indent != 0) {
+ with_indent = true;
+ SVGLength sl;
+ sl.value = sl.computed = indent;
+ sl._set = true;
+ pi.dx.push_back(sl);
+ }
+ }
+ }
+
if (*pending_line_break_object) {
- if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object))
+ if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object)) {
layout.appendControlCode(Inkscape::Text::Layout::SHAPE_BREAK, *pending_line_break_object);
- else
+ } else {
layout.appendControlCode(Inkscape::Text::Layout::PARAGRAPH_BREAK, *pending_line_break_object);
+ }
*pending_line_break_object = NULL;
}
@@ -384,11 +420,15 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
if (*pending_line_break_object) {
if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object))
layout.appendControlCode(Inkscape::Text::Layout::SHAPE_BREAK, *pending_line_break_object);
- else
+ else {
layout.appendControlCode(Inkscape::Text::Layout::PARAGRAPH_BREAK, *pending_line_break_object);
+ }
*pending_line_break_object = NULL;
}
- layout.appendText(SP_STRING(child)->string, root->style, child);
+ if (with_indent)
+ layout.appendText(SP_STRING(child)->string, root->style, child, &pi);
+ else
+ layout.appendText(SP_STRING(child)->string, root->style, child);
} else if (SP_IS_FLOWREGION(child)) {
std::vector<Shape*> const &computed = SP_FLOWREGION(child)->computed;
for (std::vector<Shape*>::const_iterator it = computed.begin() ; it != computed.end() ; it++) {
void SPFlowtext::convert_to_text()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPItem *item = selection->singleItem();
if (!SP_IS_FLOWTEXT(item)) return;
sp_repr_set_svg_double(repr, "y", anchor_point[NR::Y]);
for (Inkscape::Text::Layout::iterator it = group->layout.begin() ; it != group->layout.end() ; ) {
-
+
Inkscape::XML::Node *line_tspan = sp_repr_new("svg:tspan");
line_tspan->setAttribute("sodipodi:role", "line");
Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent();
parent->appendChild(repr);
- SPItem *new_item = (SPItem *) SP_DT_DOCUMENT(desktop)->getObjectByRepr(repr);
+ SPItem *new_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
sp_item_write_transform(new_item, repr, item->transform);
SP_OBJECT(new_item)->updateRepr();
selection->set(new_item);
item->deleteObject();
- sp_document_done(SP_DT_DOCUMENT(desktop));
+ sp_document_done(sp_desktop_document(desktop));
}
SPItem *SPFlowtext::get_frame(SPItem *after)
SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, NR::Point p0, NR::Point p1)
{
- SPDocument *doc = SP_DT_DOCUMENT (desktop);
+ SPDocument *doc = sp_desktop_document (desktop);
Inkscape::XML::Node *root_repr = sp_repr_new("svg:flowRoot");
root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create