17#include <glibmm/i18n.h>
54 for (
const auto & pit : pathv) {
58 os << cit->finalPoint()[0] <<
"," << cit->finalPoint()[1] <<
" ";
60 g_error(
"sp_svg_write_polygon: polygon path contains non-straight line segments");
65 return g_strdup(os.
str().c_str());
73 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
99 while (**p !=
'\0' && (**p ==
',' || **p ==
'\x20' || **p ==
'\x9' || **p ==
'\xD' || **p ==
'\xA')) {
108 double value = g_ascii_strtod(*p, &e);
112 if (std::isnan(value)) {
115 if (std::isinf(value)) {
132 size_t constexpr MAX_DISPLAY_SIZE = 64;
133 Glib::ustring s{points};
134 if (s.size() > MAX_DISPLAY_SIZE) {
135 s =
"... " + s.substr(s.size() - MAX_DISPLAY_SIZE);
137 g_warning(
"Error parsing a 'points' attribute: string ended unexpectedly!\n\t\"%s\"", s.c_str());
141 g_warning(
"Invalid number in the 'points' attribute:\n\t\"(...) %s\"", error_location);
145 g_warning(
"Infinity is not allowed in the 'points' attribute:\n\t\"(...) %s\"", error_location);
149 g_warning(
"NaN-value is not allowed in the 'points' attribute:\n\t\"(...) %s\"", error_location);
166 std::optional<Geom::Path>
result;
167 char const *cptr = points;
222 return g_strdup(_(
"<b>Polygon</b>"));
Path - a sequence of contiguous curves.
Cartesian point / 2D vector and related operations.
Lookup dictionary for attributes/properties.
Sequence of contiguous curves, aka spline.
Two-dimensional point that doubles as a vector.
Interface for refcounted XML nodes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
Typed SVG document implementation.
Inkscape::XML::Node * repr
char * description() const override
char const * typeName() const override
The item's type name, not node tag name.
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
void set(SPAttr key, char const *value) override
Base class for shapes, including <path> element.
std::shared_ptr< Geom::PathVector const > _curve
void setCurve(Geom::PathVector const *)
void set(SPAttr key, char const *value) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
Specific curve type functions for Inkscape, not provided by lib2geom.
bool is_straight_curve(Geom::BezierCurve const &c)
static cairo_user_data_key_t key
PathVector - a sequence of subpaths.
static void sp_poly_print_warning(char const *points, char const *error_location, SPPolyParseError error)
Print a warning message related to the parsing of a 'points' attribute.
static char * sp_svg_write_polygon(Geom::PathVector const &pathv)
SPPolyParseError sp_poly_get_value(char const **p, double *v)
Parse a double from the string passed by pointer and advance the string start.
std::optional< Geom::Path > sp_poly_parse_curve(char const *points)
Parse a 'points' attribute, printing a warning when an error occurs.
std::optional< Geom::Path > sp_poly_parse_curve(char const *points)
Parse a 'points' attribute, printing a warning when an error occurs.
Interface for XML documents.
virtual Node * createElement(char const *name)=0
TODO: insert short description here.
Interface for XML documents.