26 , m_startPos(startPos)
28 , m_calculateDeltaPositions(calculateDeltaPositions)
29 , m_textData(shape->getMemento())
40 while (!originalTf.isEmpty()) {
42 positions.append(tf.
finalPos + delta);
48 QLineF l(0, 0, 10, 0);
52 while (!originalTf.isEmpty()) {
55 positions.append(deltaTf.map(tf.
finalPos));
60 rotations.append(tf.
rotateDeg - (l.angle()));
119 return QTransform::fromTranslate(delta.x(), delta.y());
121 const int lineEnd = qMin(shape->
lineEnd(qMin(startPos, endPos)), qMax(startPos, endPos));
124 if (infos.size() < 1)
return deltaTf;
125 const bool rtl = infos.first().rtl;
128 if (infos.size() > 1) {
130 for (
auto it = infos.begin(); it != infos.end(); it++) {
131 if (it->visualIndex >= 0) {
136 for (
auto it = infos.rbegin(); it != infos.rend(); it++) {
137 if (it->visualIndex >= 0) {
143 QTransform t = QTransform::fromTranslate(last.
finalPos.x(), last.
finalPos.y());
148 QLineF newLine(originalLine.p1(), originalLine.p2() + delta);
150 const qreal scale = newLine.length()/originalLine.length();
152 QTransform origin = QTransform::fromTranslate(originalLine.p1().x(), originalLine.p1().y());
153 qreal angle = originalLine.angle() - newLine.angle();
155 deltaTf = origin.inverted();
156 deltaTf *= QTransform::fromScale(scale, scale);
157 deltaTf *= QTransform().rotate(angle);
void notifyCursorPosChanged(int pos, int anchor)
Notify that the cursor position has changed.
bool setCharacterTransformsOnRange(const int startPos, const int endPos, const QVector< QPointF > positions, const QVector< qreal > rotateDegrees, const bool deltaPosition=true)
setCharacterTransformsOnRange Set SVG 1.1 style character transforms on the given range....
void setMemento(const KoSvgTextShapeMementoSP memento)
Set the text data and layout info, reset listening cursors to 0.
int indexForPos(int pos) const
indexForPos get the string index for a given cursor position.
int lineEnd(int pos)
lineEnd return the 'line end' for this pos. This uses anchored chunks, so each absolute x,...
int posForIndex(int index, bool firstIndex=false, bool skipSynthetic=false) const
posForIndex Get the cursor position for a given index in a string.
QList< KoSvgTextCharacterInfo > getPositionsAndRotationsForRange(const int startPos, const int endPos) const
getPositionsAndRotationsForRange
SvgTextChangeTransformsOnRange(KoSvgTextShape *shape, int startPos, int endPos, QVector< QPointF > positions, QVector< qreal > rotations, bool calculateDeltaPositions, KUndo2Command *parentCommand=nullptr)
static QTransform getTransformForOffset(KoSvgTextShape *shape, int startPos, int endPos, QPointF delta, OffsetType type)
getTransformForOffset Function to get the expected transform, so we can test this command better.
The KoSvgTextCharacterInfo class This is a small struct to convey information about character positio...
static bool visualLessThan(const KoSvgTextCharacterInfo &a, const KoSvgTextCharacterInfo &b)