Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextInsertRichCommand.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
9
10SvgTextInsertRichCommand::SvgTextInsertRichCommand(KoSvgTextShape *shape, KoSvgTextShape *insert, int pos, int anchor, bool inheritPropertiesIfPossible, KUndo2Command *parent)
11 : KUndo2Command(parent)
12 , m_shape(shape)
13 , m_insert(insert)
14 , m_pos(pos)
15 , m_anchor(anchor)
16 , m_inheritPropertiesIfPossible(inheritPropertiesIfPossible)
17{
18 setText(kundo2_i18n("Insert Rich Text"));
19}
20
22{
24 // Index defaults to -1 when there's no text in the shape.
25 int oldIndex = qMax(0, m_shape->indexForPos(m_pos));
26
31
32 int pos = m_shape->posForIndex(oldIndex + m_insert->plainText().size(), false, false);
35}
36
void setText(const KUndo2MagicString &text)
static void bulkShapesUpdate(const UpdatesList &updates)
void notifyCursorPosChanged(int pos, int anchor)
Notify that the cursor position has changed.
KoSvgTextShapeMementoSP getMemento()
Get a memento holding the current textdata and layout info.
void setMemento(const KoSvgTextShapeMementoSP memento)
Set the text data and layout info, reset listening cursors to 0.
void notifyMarkupChanged()
Notify that the markup has changed.
int indexForPos(int pos) const
indexForPos get the string index for a given cursor position.
void cleanUp()
Cleans up the internal text data. Used by undo commands.
int posForIndex(int index, bool firstIndex=false, bool skipSynthetic=false) const
posForIndex Get the cursor position for a given index in a string.
bool insertRichText(int pos, const KoSvgTextShape *richText, bool inheritPropertiesIfPossible=false)
insertRichText Insert rich text at the given cursor pos. This will first split contents at the given ...
KoSvgTextShapeMementoSP m_textData
SvgTextInsertRichCommand(KoSvgTextShape *shape, KoSvgTextShape *insert, int pos, int anchor, bool inheritPropertiesIfPossible=false, KUndo2Command *parent=0)
KUndo2MagicString kundo2_i18n(const char *text)