31#include <glibmm/i18n.h>
32#include <glibmm/regex.h>
68 auto text = cast<SPText>(
parent);
69 if (text && !(text->has_shape_inside()|| text->has_inline_size())) {
89 if (value && (!strcmp(value,
"line") || !strcmp(value,
"paragraph"))) {
98 Glib::ustring
style(value);
99 Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create(
"visibility\\s*:\\s*hidden;*");
100 Glib::ustring stripped = regex->replace_literal(
style, 0,
"",
static_cast<Glib::Regex::MatchFlags
>(0));
113 unsigned childflags = flags;
114 if (flags & SP_OBJECT_MODIFIED_FLAG) {
115 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
117 childflags &= SP_OBJECT_MODIFIED_CASCADE;
120 if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) {
121 ochild.updateDisplay(ctx, childflags);
127 if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG |
128 SP_OBJECT_CHILD_MODIFIED_FLAG |
129 SP_TEXT_LAYOUT_MODIFIED_FLAG ) )
136 double const ex = 0.5 * em;
145 if (flags & SP_OBJECT_MODIFIED_FLAG) {
146 flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
149 flags &= SP_OBJECT_MODIFIED_CASCADE;
152 if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) {
153 ochild.emitModified(flags);
163 while (parent_text && !is<SPText>(parent_text)) {
164 parent_text = parent_text->
parent;
167 if (parent_text ==
nullptr) {
172 return cast<SPText>(parent_text)->layout.bounds(
transform,
179 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
185 if ( flags&SP_OBJECT_WRITE_BUILD ) {
186 std::vector<Inkscape::XML::Node *> l;
191 if ( is<SPTSpan>(&
child) || is<SPTRef>(&
child) ) {
192 c_repr =
child.updateRepr(xml_doc,
nullptr, flags);
193 }
else if ( is<SPTextPath>(&
child) ) {
195 }
else if ( is<SPString>(&
child) ) {
204 for (
auto i = l.rbegin(); i!= l.rend(); ++i) {
210 if ( is<SPTSpan>(&
child) || is<SPTRef>(&
child) ) {
211 child.updateRepr(flags);
212 }
else if ( is<SPTextPath>(&
child) ) {
214 }
else if ( is<SPString>(&
child) ) {
215 child.getRepr()->setContent(cast<SPString>(&
child)->string.c_str());
230 return _(
"Text Span");
295 if (strncmp(value,
"left", 4) == 0)
297 else if (strncmp(value,
"right", 5) == 0)
300 std::cerr <<
"SPTextPath: Bad side value: " << (value?value:
"null") << std::endl;
324 unsigned childflags = (flags & SP_OBJECT_MODIFIED_CASCADE);
325 if (flags & SP_OBJECT_MODIFIED_FLAG) {
326 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
330 if (childflags || (ochild.uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
331 ochild.updateDisplay(ctx, childflags);
337 if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG |
338 SP_OBJECT_CHILD_MODIFIED_FLAG |
339 SP_TEXT_LAYOUT_MODIFIED_FLAG ) )
346 double const ex = 0.5 * em;
355 if ( tp ==
nullptr ) {
369 curve_copy.reverse();
382 if (flags & SP_OBJECT_MODIFIED_FLAG) {
383 flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
386 flags &= SP_OBJECT_MODIFIED_CASCADE;
389 if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) {
390 ochild.emitModified(flags);
396 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
422 if ( flags & SP_OBJECT_WRITE_BUILD ) {
423 std::vector<Inkscape::XML::Node *> l;
428 if ( is<SPTSpan>(&
child) || is<SPTRef>(&
child) ) {
429 c_repr =
child.updateRepr(xml_doc,
nullptr, flags);
430 }
else if ( is<SPTextPath>(&
child) ) {
432 }
else if ( is<SPString>(&
child) ) {
441 for(
auto i = l.rbegin(); i != l.rend(); ++i ) {
447 if ( is<SPTSpan>(&
child) || is<SPTRef>(&
child) ) {
448 child.updateRepr(flags);
449 }
else if ( is<SPTextPath>(&
child) ) {
451 }
else if ( is<SPString>(&
child) ) {
452 child.getRepr()->setContent(cast<SPString>(&
child)->string.c_str());
476 std::vector<Inkscape::XML::Node *> tp_reprs;
479 tp_reprs.push_back(o.getRepr());
482 for (
auto i = tp_reprs.rbegin(); i != tp_reprs.rend(); ++i) {
496 if (
auto path = cast<SPTextPath>(tp)->originalPath) {
497 SVGLength const startOffset = cast<SPTextPath>(tp)->startOffset;
499 if (startOffset.
_set) {
508 path->PointAndTangentAt(cut_pos[0].piece, cut_pos[0].t, midpoint, tangent);
510 std::cerr <<
"sp_textpath_to_text: no path" << std::endl;
TODO: insert short description here.
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Interface for refcounted XML nodes.
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute of this node.
virtual Document * document()=0
Get the node's associated document.
virtual void removeChild(Node *child)=0
Remove a child of this node.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Path and its polyline approximation.
void ConvertWithBackData(double threshhold, bool relative=false)
Creates a polyline approximation of the path.
void LoadPathVector(Geom::PathVector const &pv, Geom::Affine const &tr, bool doTransformation)
Load a lib2geom Geom::PathVector in this path object.
Typed SVG document implementation.
Base class for visual SVG elements.
void update(SPCtx *ctx, unsigned int flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, char const *value) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
void readAttr(char const *key)
Read value of key attribute from XML node into object.
void deleteObject(bool propagate, bool propagate_descendants)
Deletes an object, unparenting it from its parent.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
T< SPAttr::FONT_SIZE, SPIFontSize > font_size
Size of the font.
void modified(unsigned int flags) override
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
TextTagAttributes attributes
void set(SPAttr key, const char *value) override
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override
const char * displayName() const override
The item's type name as a translated human string.
const char * typeName() const override
The item's type name, not node tag name.
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
void update(SPCtx *ctx, unsigned int flags) override
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
void modified(unsigned int flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, const char *value) override
void update(SPCtx *ctx, unsigned int flags) override
TextTagAttributes attributes
void(* user_unlink)(SPObject *user)
std::optional< Geom::PathVector > originalPath
SPItem * getObject() const
void readOrUnset(char const *str, Unit u=NONE, float v=0, float c=0)
bool readSingleAttribute(SPAttr key, gchar const *value, SPStyle const *style, Geom::Rect const *viewport)
Process the parameters from the set() function of SPObject.
void writeTo(Inkscape::XML::Node *node) const
Write out all the contents of attributes to the given node.
void update(double em, double ex, double w, double h)
Update relative values.
static R & release(R &r)
Decrements the reference count of a anchored object.
void setHrefAttribute(XML::Node &node, Util::const_char_ptr value)
If the 'href' attribute already exists for the given node, then set a new value for it.
static cairo_user_data_key_t key
TODO: insert short description here.
void sp_textpath_to_text(SPObject *tp)
@ SP_TEXT_PATH_SIDE_RIGHT
SVG <tref> implementation, see sp-tref.cpp.
void sp_textpath_to_text(SPObject *tp)
SPItem * sp_textpath_get_path_item(SPTextPath const *tp)
void refresh_textpath_source(SPTextPath *offset)
TODO: insert short description here.
@ SP_TSPAN_ROLE_UNSPECIFIED
Interface for XML documents.
virtual Node * createTextNode(char const *content)=0
virtual Node * createElement(char const *name)=0
Contains transformations to document/viewport and the viewport size.
Geom::Rect viewport
Viewport size.
SPStyle - a style object for SPItem objects.
TODO: insert short description here.
unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto)
Recursively gets the length of all the SPStrings at or below the given item, before and not including...
std::vector< Texture > unused