7#ifndef KOSVGTEXTSHAPE_H
8#define KOSVGTEXTSHAPE_H
10#include "kritaflake_export.h"
27#define KoSvgTextShape_SHAPEID "KoSvgTextShapeID"
28#define KoSvgTextShape_TEXTCONTOURGROUP "krita:textContourGroup"
39 static const QString &defaultPlaceholderText();
43 void paint(QPainter &painter)
const override;
46 QPainterPath
outline()
const override;
50 QSizeF
size()
const override;
51 void setSize(
const QSizeF &size)
override;
58 void paintDebug(QPainter &painter, DebugElements elements)
const;
65 void relayout()
const;
77 PrePositionedText = 0,
94 TextType textType()
const;
110 void addShapeContours(
QList<KoShape*> shapes,
const bool inside =
true);
116 bool shapeInContours(
KoShape *shape);
125 void removeShapesFromContours(
QList<KoShape*> shapes,
bool callUpdate =
true,
bool cleanup =
true);
136 void moveShapeInsideToIndex(
KoShape* shapeInside,
const int index);
147 bool setTextPathOnRange(
KoShape *textPath,
const int startPos = -1,
const int endPos = -1);
157 QList<KoShape*> textPathsAtRange(
const int startPos = -1,
const int endPos = -1);
164 void addTextPathAtEnd(
KoShape *textPath);
202 QMap<QString, QString> shapeTypeSpecificStyles(
SvgSavingContext &context)
const;
210 int posLeft(
int pos,
bool visual =
false);
213 int posRight(
int pos,
bool visual =
false);
215 int posUp(
int pos,
bool visual =
false);
217 int posDown(
int pos,
bool visual =
false);
226 int lineStart(
int pos);
234 int lineEnd(
int pos);
243 int wordLeft(
int pos,
bool visual =
false);
251 int wordRight(
int pos,
bool visual =
false);
261 int nextIndex(
int pos);
269 int previousIndex(
int pos);
277 int nextLine(
int pos);
284 int previousLine(
int pos);
292 int wordEnd(
int pos);
299 int wordStart(
int pos);
308 QPainterPath cursorForPos(
int pos, QLineF &caret, QColor &color,
double bidiFlagSize = 1.0);
318 QPainterPath selectionBoxes(
int pos,
int anchor);
320 QPainterPath underlines(
int pos,
int anchor,
321 KoSvgText::TextDecorations decor,
323 qreal minimum,
bool thick);
334 int posForPoint(QPointF point,
int start = -1,
int end = -1,
bool *overlaps =
nullptr);
350 int posForPointLineSensitive(QPointF point);
359 int posForIndex(
int index,
bool firstIndex =
false,
bool skipSynthetic =
false)
const;
366 int indexForPos(
int pos)
const;
384 bool insertText(
int pos, QString text);
401 bool removeText(
int &index,
int &
length);
438 void mergePropertiesIntoRange(
const int startPos,
441 const QSet<KoSvgTextProperties::PropertyId> removeProperties = QSet<KoSvgTextProperties::PropertyId>());
451 std::unique_ptr<KoSvgTextShape> copyRange(
int index,
int length)
const;
461 bool insertRichText(
int pos,
const KoSvgTextShape *richText,
bool inheritPropertiesIfPossible =
false);
477 bool setCharacterTransformsOnRange(
const int startPos,
const int endPos,
const QVector<QPointF> positions,
const QVector<qreal> rotateDegrees,
const bool deltaPosition =
true);
491 void removeTransformsFromRange(
const int startPos,
const int endPos);
573 bool singleNode()
const;
582 void notifyCursorPosChanged(
int pos,
int anchor);
584 void notifyMarkupChanged();
594 void convertCharTransformsToPreformatted(
bool makeInlineSize =
false);
601 void setCharacterTransformsFromLayout();
611 void enterNodeSubtree();
613 void leaveNodeSubtree();
633 void setRelayoutBlocked(
const bool disable);
640 bool relayoutIsBlocked()
const;
650 void setFontMatchingDisabled(
const bool disable);
656 bool fontMatchingDisabled()
const;
676 friend class TestSvgText;
684 int nextPos(
int pos,
bool visual);
692 int previousPos(
int pos,
bool visual);
699 QPainterPath defaultCursorShape();
704 QScopedPointer<Private>
d;
758 QScopedPointer<Private>
d;
783 bool compare =
false;
785 && b.visualIndex >= 0) {
qreal length(const QPointF &vec)
QSharedPointer< KoSvgTextShapeMemento > KoSvgTextShapeMementoSP
The HtmlSavingContext class provides context for saving a flake-based document to html.
The position of a path point within a path shape.
virtual void setPaintOrder(PaintOrder first, PaintOrder second)
setPaintOrder set the paint order. As there's only three entries in any given paintorder,...
virtual void paintStroke(QPainter &painter) const
paintStroke paints the shape's stroked outline
virtual QSizeF size() const
Get the size of the shape in pt.
virtual QRectF outlineRect() const
virtual QPainterPath outline() const
virtual QVector< PaintOrder > paintOrder() const
paintOrder
virtual KoShapeStrokeModelSP stroke() const
virtual void setResolution(qreal xRes, qreal yRes)
virtual QRectF boundingRect() const
Get the bounding box of the shape.
virtual void shapeChanged(ChangeType type, KoShape *shape=0)
virtual void setStroke(KoShapeStrokeModelSP stroke)
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
virtual void paint(QPainter &painter) const =0
Paint the shape fill The class extending this one is responsible for painting itself....
ChangeType
Used by shapeChanged() to select which change was made.
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
virtual QSharedPointer< KoShapeBackground > background() const
virtual void setSize(const QSizeF &size)
Resize the shape.
The KoSvgTextNodeIndex class.
QScopedPointer< Private > d
KoSvgTextShapeFactory()
constructor
bool supports(const QDomElement &e, KoShapeLoadingContext &context) const override
Reimplemented.
KoShape * createDefaultShape(KoDocumentResourceManager *documentResources=0) const override
KoShape * createShape(const KoProperties *params, KoDocumentResourceManager *documentResources=0) const override
virtual ~KoSvgTextShapeMemento()
QString plainText()
plainText plain text of all text inside this text shape, without the bidi controls or any transforms.
@ InlineWrap
Uses inline size to wrap and preserves spaces.
QPointF initialTextPosition() const
initialTextPosition Returns the initial text position as per SVG algorithm. The eventual result of th...
QScopedPointer< Private > d
Q_DECLARE_FLAGS(DebugElements, DebugElement)
QList< KoShape * > shapesSubtract() const
shapesSubtract
QList< KoShape * > shapesInside() const
shapesInside
Context for saving svg files.
An interface providing svg loading and saving routines.
virtual bool saveSvg(SvgSavingContext &context)
Saves data utilizing specified svg saving context.
Q_DECLARE_OPERATORS_FOR_FLAGS(KisBaseRectsWalker::SubtreeVisitFlags)
TextDecorationStyle
Style of the text-decoration.
Interface for bulk actions on shapes.
virtual QRectF endBulkAction()=0
virtual void startBulkAction()=0
The KoSvgTextCharacterInfo class This is a small struct to convey information about character positio...
KoSvgText::FontMetrics metrics
<Whether the character is in the middle of a cluster.
static bool logicalLessThan(const KoSvgTextCharacterInfo &a, const KoSvgTextCharacterInfo &b)
static bool visualLessThan(const KoSvgTextCharacterInfo &a, const KoSvgTextCharacterInfo &b)
ShapeChangeListener so we can inform any text cursors that the cursor needs updating.
virtual void notifyMarkupChanged()=0
virtual void notifyCursorPosChanged(int pos, int anchor)=0
The FontMetrics class A class to keep track of a variety of font metrics. Note that values are in Fre...