Changeset View
Changeset View
Standalone View
Standalone View
commands/tools/selection/text/kpToolTextGiveContentCommand.cpp
Show All 39 Lines | |||||
40 | 40 | | |||
41 | kpToolTextGiveContentCommand::kpToolTextGiveContentCommand ( | 41 | kpToolTextGiveContentCommand::kpToolTextGiveContentCommand ( | ||
42 | const kpTextSelection &originalSelBorder, | 42 | const kpTextSelection &originalSelBorder, | ||
43 | const QString &name, | 43 | const QString &name, | ||
44 | kpCommandEnvironment *environ) | 44 | kpCommandEnvironment *environ) | ||
45 | : kpAbstractSelectionContentCommand (originalSelBorder, name, environ) | 45 | : kpAbstractSelectionContentCommand (originalSelBorder, name, environ) | ||
46 | { | 46 | { | ||
47 | qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::<ctor>() environ=" | 47 | qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::<ctor>() environ=" | ||
48 | << environ | 48 | << environ; | ||
49 | << endl; | | |||
50 | } | 49 | } | ||
51 | 50 | | |||
52 | kpToolTextGiveContentCommand::~kpToolTextGiveContentCommand () | 51 | kpToolTextGiveContentCommand::~kpToolTextGiveContentCommand () = default; | ||
53 | { | | |||
54 | } | | |||
55 | 52 | | |||
56 | 53 | | |||
57 | // public virtual [base kpCommand] | 54 | // public virtual [base kpCommand] | ||
58 | void kpToolTextGiveContentCommand::execute () | 55 | void kpToolTextGiveContentCommand::execute () | ||
59 | { | 56 | { | ||
60 | qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::execute()"; | 57 | qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::execute()"; | ||
61 | 58 | | |||
62 | kpDocument *doc = document (); | 59 | kpDocument *doc = document (); | ||
Show All 28 Lines | 69 | { | |||
91 | // This assertion covers all 3 possibilities: | 88 | // This assertion covers all 3 possibilities: | ||
92 | // | 89 | // | ||
93 | // 1. First call: text selection with no content | 90 | // 1. First call: text selection with no content | ||
94 | // 2. Later calls: | 91 | // 2. Later calls: | ||
95 | // a) no text selection (due to deselection) | 92 | // a) no text selection (due to deselection) | ||
96 | // b) text selection with no content, at an arbitrary location | 93 | // b) text selection with no content, at an arbitrary location | ||
97 | Q_ASSERT (!textSelection () || !textSelection ()->hasContent ()); | 94 | Q_ASSERT (!textSelection () || !textSelection ()->hasContent ()); | ||
98 | 95 | | |||
99 | const kpTextSelection *originalTextSel = | 96 | const auto *originalTextSel = dynamic_cast <const kpTextSelection *> | ||
100 | static_cast <const kpTextSelection *> (originalSelection ()); | 97 | (originalSelection ()); | ||
101 | if (originalTextSel->textStyle () != environ ()->textStyle ()) | 98 | | ||
99 | if (originalTextSel->textStyle () != environ ()->textStyle ()) { | ||||
102 | environ ()->setTextStyle (originalTextSel->textStyle ()); | 100 | environ ()->setTextStyle (originalTextSel->textStyle ()); | ||
101 | } | ||||
103 | 102 | | |||
104 | doc->setSelection (*originalSelection ()); | 103 | doc->setSelection (*originalSelection ()); | ||
105 | 104 | | |||
106 | 105 | | |||
107 | // | 106 | // | ||
108 | // Add Content | 107 | // Add Content | ||
109 | // | 108 | // | ||
110 | 109 | | |||
Show All 36 Lines |