X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-text.cpp;h=0390df6bfa7901646c55470a47dda7a8c1f6b18c;hb=9e973c4fb2183b877bb600a7e9c75e93b3e7d6d1;hp=5d1abbb3a21a9a9c4c3634ebcfc7716381c5dd4f;hpb=5834db43b21308e958a2fdbbec082b1a4f019a38;p=inkscape.git diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 5d1abbb3a..0390df6bf 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -65,7 +65,7 @@ static void sp_text_child_added (SPObject *object, Inkscape::XML::Node *rch, Ink static void sp_text_remove_child (SPObject *object, Inkscape::XML::Node *rch); static void sp_text_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_text_modified (SPObject *object, guint flags); -static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Node *repr, guint flags); +static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_text_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); static NRArenaItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags); @@ -299,12 +299,11 @@ sp_text_modified (SPObject *object, guint flags) } static Inkscape::XML::Node * -sp_text_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) +sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPText *text = SP_TEXT (object); if (flags & SP_OBJECT_WRITE_BUILD) { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); if (!repr) repr = xml_doc->createElement("svg:text"); GSList *l = NULL; @@ -313,7 +312,7 @@ sp_text_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) if (SP_IS_STRING(child)) { crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } else { - crepr = child->updateRepr(NULL, flags); + crepr = child->updateRepr(xml_doc, NULL, flags); } if (crepr) l = g_slist_prepend (l, crepr); } @@ -344,7 +343,7 @@ sp_text_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) SP_OBJECT_REPR(text)->setAttribute("sodipodi:linespacing", NULL); if (((SPObjectClass *) (text_parent_class))->write) - ((SPObjectClass *) (text_parent_class))->write (object, repr, flags); + ((SPObjectClass *) (text_parent_class))->write (object, xml_doc, repr, flags); return repr; } @@ -429,7 +428,7 @@ static void sp_text_snappoints(SPItem const *item, SnapPointsIter p) // the baseline anchor of the first char Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); if(layout != NULL) { - *p = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item); + *p = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(item)); } } @@ -494,7 +493,7 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) dbox.y0 = 0.0; dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); - NR::Matrix const ctm = sp_item_i2d_affine(item); + NR::Matrix const ctm = from_2geom(sp_item_i2d_affine(item)); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); } @@ -554,7 +553,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio Glib::ustring const &string = SP_STRING(child)->string; layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); length += string.length(); - } else { + } else if (!sp_repr_is_meta_element(child->repr)) { length += _buildLayoutInput(child, optional_attrs, child_attrs_offset + length, in_textpath); } } @@ -748,11 +747,14 @@ void TextTagAttributes::mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs * void TextTagAttributes::mergeSingleAttribute(std::vector *output_list, std::vector const &parent_list, unsigned parent_offset, std::vector const *overlay_list) { + output_list->clear(); if (overlay_list == NULL) { - output_list->resize(std::max(0, (int)parent_list.size() - (int)parent_offset)); - std::copy(parent_list.begin() + parent_offset, parent_list.end(), output_list->begin()); + if (parent_list.size() > parent_offset) + { + output_list->reserve(parent_list.size() - parent_offset); + std::copy(parent_list.begin() + parent_offset, parent_list.end(), std::back_inserter(*output_list)); + } } else { - output_list->clear(); output_list->reserve(std::max((int)parent_list.size() - (int)parent_offset, (int)overlay_list->size())); unsigned overlay_offset = 0; while (parent_offset < parent_list.size() || overlay_offset < overlay_list->size()) {