Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
text-tag-attributes.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
10 * Authors: see git history
11 *
12 * Copyright (C) 2018 Authors
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15#ifndef INKSCAPE_TEXT_TAG_ATTRIBUTES_H
16#define INKSCAPE_TEXT_TAG_ATTRIBUTES_H
17
18#include <utility>
19#include <vector>
20#include <glib.h>
22#include "svg/svg-length.h"
23
24namespace Inkscape {
25namespace XML {
26class Node;
27}
28}
29enum class SPAttr;
30
32public:
33 TextTagAttributes() = default;
36
39
42 bool readSingleAttribute(SPAttr key, gchar const *value, SPStyle const *style, Geom::Rect const *viewport);
43
45 void writeTo(Inkscape::XML::Node *node) const;
46
48 void update( double em, double ex, double w, double h );
49
56 bool singleXYCoordinates() const;
57
59 bool anyAttributesSet() const;
60
69 void mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs *output, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_attrs, unsigned parent_attrs_offset, bool copy_xy, bool copy_dxdyrotate) const;
70
74 void erase(unsigned start_index, unsigned n);
75
83 void insert(unsigned start_index, unsigned n);
84
89 void split(unsigned index, TextTagAttributes *second);
90
94 void join(TextTagAttributes const &first, TextTagAttributes const &second, unsigned second_index);
95
102 void transform(Geom::Affine const &matrix, double scale_x, double scale_y, bool extend_zero_length = false);
103
105 double getDx(unsigned index);
106
108 double getDy(unsigned index);
109
112 void addToDx(unsigned index, double delta);
113
116 void addToDy(unsigned index, double delta);
117
120 void addToDxDy(unsigned index, Geom::Point const &adjust);
121
123 double getRotate(unsigned index);
124
128 void addToRotate(unsigned index, double delta);
129
132 void setRotate(unsigned index, double angle);
133
136 Geom::Point firstXY() const;
137
139 void setFirstXY(Geom::Point &point);
140
143
146
149
150private:
153
157 static void writeSingleAttributeVector(Inkscape::XML::Node *node, gchar const *key, std::vector<SVGLength> const &attr_vector);
158
161 static void writeSingleAttributeLength(Inkscape::XML::Node *node, gchar const *key, const SVGLength &length);
162
166 static void mergeSingleAttribute(std::vector<SVGLength> *output_list, std::vector<SVGLength> const &parent_list, unsigned parent_offset, std::vector<SVGLength> const *overlay_list = nullptr);
167
169 static void eraseSingleAttribute(std::vector<SVGLength> *attr_vector, unsigned start_index, unsigned n);
170
172 static void insertSingleAttribute(std::vector<SVGLength> *attr_vector, unsigned start_index, unsigned n, bool is_xy);
173
175 static void splitSingleAttribute(std::vector<SVGLength> *first_vector, unsigned index, std::vector<SVGLength> *second_vector, bool trimZeros);
176
178 static void joinSingleAttribute(std::vector<SVGLength> *dest_vector, std::vector<SVGLength> const &first_vector, std::vector<SVGLength> const &second_vector, unsigned second_index);
179};
180
181
182#endif /* !INKSCAPE_TEXT_TAG_ATTRIBUTES_H */
183
184/*
185 Local Variables:
186 mode:c++
187 c-file-style:"stroustrup"
188 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
189 indent-tabs-mode:nil
190 fill-column:99
191 End:
192*/
193// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
3x3 matrix representing an affine transformation.
Definition affine.h:70
Two-dimensional point that doubles as a vector.
Definition point.h:66
Axis aligned, non-empty rectangle.
Definition rect.h:92
Interface for refcounted XML nodes.
Definition node.h:80
An SVG style object.
Definition style.h:45
SVG length type.
Definition svg-length.h:22
void split(unsigned index, TextTagAttributes *second)
Divides the stored attributes into two, at the given index.
Definition sp-text.cpp:1609
static void insertSingleAttribute(std::vector< SVGLength > *attr_vector, unsigned start_index, unsigned n, bool is_xy)
Does the work for insert().
Definition sp-text.cpp:1595
static void writeSingleAttributeLength(Inkscape::XML::Node *node, gchar const *key, const SVGLength &length)
Writes a single length value to node.
Definition sp-text.cpp:1438
static void splitSingleAttribute(std::vector< SVGLength > *first_vector, unsigned index, std::vector< SVGLength > *second_vector, bool trimZeros)
Does the work for split().
Definition sp-text.cpp:1620
Geom::Point firstXY() const
Returns the first coordinates in the x and y vectors.
Definition sp-text.cpp:1472
void mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs *output, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_attrs, unsigned parent_attrs_offset, bool copy_xy, bool copy_dxdyrotate) const
Implements the rules for overlaying the contents of the class (treated as the child object) on top of...
Definition sp-text.cpp:1519
SVGLength * getTextLength()
SVGLength * getFirstXLength()
Gets first value in the x vector as an SVGLength.
Definition sp-text.cpp:1495
TextTagAttributes()=default
void setRotate(unsigned index, double angle)
Sets rotate vector at the given index.
Definition sp-text.cpp:1788
bool readSingleAttribute(SPAttr key, gchar const *value, SPStyle const *style, Geom::Rect const *viewport)
Process the parameters from the set() function of SPObject.
Definition sp-text.cpp:1359
bool singleXYCoordinates() const
For tspan role=line elements we should not use the set x,y coordinates since that would overrule the ...
Definition sp-text.cpp:1462
double getDx(unsigned index)
Gets current value of dx vector at index.
Definition sp-text.cpp:1701
SVGLength * getFirstYLength()
Gets first value in the y vector as an SVGLength.
Definition sp-text.cpp:1504
void addToDy(unsigned index, double delta)
Adds the given value to the dy vector at the given index.
Definition sp-text.cpp:1736
void addToDxDy(unsigned index, Geom::Point const &adjust)
Adds the given values to the dx and dy vectors at the given index.
Definition sp-text.cpp:1745
void addToRotate(unsigned index, double delta)
Adds the given value to the rotate vector at the given index.
Definition sp-text.cpp:1773
void setFirstXY(Geom::Point &point)
Sets the first coordinates in the x and y vectors.
Definition sp-text.cpp:1482
void readFrom(Inkscape::XML::Node const *node)
Fill in all the fields of attributes from the given node.
void transform(Geom::Affine const &matrix, double scale_x, double scale_y, bool extend_zero_length=false)
Applies the given transformation to the stored coordinates.
Definition sp-text.cpp:1663
void erase(unsigned start_index, unsigned n)
Deletes all the values from all the vectors beginning at start_index and extending for n fields.
Definition sp-text.cpp:1562
static void mergeSingleAttribute(std::vector< SVGLength > *output_list, std::vector< SVGLength > const &parent_list, unsigned parent_offset, std::vector< SVGLength > const *overlay_list=nullptr)
Does mergeInto() for one member of attributes.
Definition sp-text.cpp:1535
bool anyAttributesSet() const
Returns false if all of the vectors are zero length.
Definition sp-text.cpp:1467
static void writeSingleAttributeVector(Inkscape::XML::Node *node, gchar const *key, std::vector< SVGLength > const &attr_vector)
Does the reverse of readSingleAttribute(), converting a vector<> to its SVG string representation and...
Definition sp-text.cpp:1446
void writeTo(Inkscape::XML::Node *node) const
Write out all the contents of attributes to the given node.
Definition sp-text.cpp:1403
Inkscape::Text::Layout::OptionalTextTagAttrs attributes
This holds the actual values.
void insert(unsigned start_index, unsigned n)
Inserts n new values in all the stored vectors at start_index.
Definition sp-text.cpp:1583
void addToDx(unsigned index, double delta)
Adds the given value to the dx vector at the given index.
Definition sp-text.cpp:1727
double getRotate(unsigned index)
Gets current value of rotate vector at index.
Definition sp-text.cpp:1760
void update(double em, double ex, double w, double h)
Update relative values.
Definition sp-text.cpp:1422
static void joinSingleAttribute(std::vector< SVGLength > *dest_vector, std::vector< SVGLength > const &first_vector, std::vector< SVGLength > const &second_vector, unsigned second_index)
Does the work for join().
Definition sp-text.cpp:1646
double getDy(unsigned index)
Gets current value of dy vector at index.
Definition sp-text.cpp:1714
static void eraseSingleAttribute(std::vector< SVGLength > *attr_vector, unsigned start_index, unsigned n)
Does the work for erase().
Definition sp-text.cpp:1574
TextTagAttributes(Inkscape::Text::Layout::OptionalTextTagAttrs attrs)
void join(TextTagAttributes const &first, TextTagAttributes const &second, unsigned second_index)
Overwrites all the attributes contained in this object with the given parameters by putting first at ...
Definition sp-text.cpp:1632
const double w
Definition conic-4.cpp:19
Inkscape::XML::Node * node
Helper class to stream background task notifications as a series of messages.
STL namespace.
static cairo_user_data_key_t key
The optional attributes which can be applied to a SVG text or related tag.
Definition Layout-TNG.h:184
int delta
int index