Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Remove KoShape::textRunAroundSide()
Dmitry Kazakov91b27c701ce5
diff --git a/libs/flake/CMakeLists.txt b/libs/flake/CMakeLists.txtindex 526a7ee294..ec49b57705 100644--- a/libs/flake/CMakeLists.txt+++ b/libs/flake/CMakeLists.txt@@ -149,7 +149,6 @@ set(kritaflake_SRCScommands/KoPathFillRuleCommand.cppcommands/KoPathReverseCommand.cppcommands/KoShapeRenameCommand.cpp- commands/KoShapeRunAroundCommand.cppcommands/KoPathPointMergeCommand.cppcommands/KoShapeTransparencyCommand.cppcommands/KoShapeClipCommand.cppdiff --git a/libs/flake/KoShape.cpp b/libs/flake/KoShape.cppindex e76904eac0..4fe877e2c1 100644--- a/libs/flake/KoShape.cpp+++ b/libs/flake/KoShape.cpp@@ -63,13 +63,6 @@ KoShape::SharedData::SharedData(), keepAspect(false), selectable(true), protectContent(false)- , textRunAroundSide(KoShape::BiggestRunAroundSide)- , textRunAroundDistanceLeft(0.0)- , textRunAroundDistanceTop(0.0)- , textRunAroundDistanceRight(0.0)- , textRunAroundDistanceBottom(0.0)- , textRunAroundThreshold(0.0)- , textRunAroundContour(KoShape::ContourFull), paintOrder(defaultPaintOrder()), inheritPaintOrder(true){ }@@ -101,14 +94,6 @@ KoShape::SharedData::SharedData(const SharedData &rhs), selectable(rhs.selectable), protectContent(rhs.protectContent)- , textRunAroundSide(rhs.textRunAroundSide)- , textRunAroundDistanceLeft(rhs.textRunAroundDistanceLeft)- , textRunAroundDistanceTop(rhs.textRunAroundDistanceTop)- , textRunAroundDistanceRight(rhs.textRunAroundDistanceRight)- , textRunAroundDistanceBottom(rhs.textRunAroundDistanceBottom)- , textRunAroundThreshold(rhs.textRunAroundThreshold)- , textRunAroundContour(rhs.textRunAroundContour)-, paintOrder(rhs.paintOrder), inheritPaintOrder(rhs.inheritPaintOrder){@@ -795,93 +780,6 @@ QPointF KoShape::position() constreturn s->localMatrix.map(center) - center;}-KoShape::TextRunAroundSide KoShape::textRunAroundSide() const-{- return s->textRunAroundSide;-}--void KoShape::setTextRunAroundSide(TextRunAroundSide side, RunThroughLevel runThrough)-{-- if (side == RunThrough) {- if (runThrough == Background) {- setRunThrough(-1);- } else {- setRunThrough(1);- }- } else {- setRunThrough(0);- }-- if ( s->textRunAroundSide == side) {- return;- }-- s->textRunAroundSide = side;- notifyChanged();- shapeChangedPriv(TextRunAroundChanged);-}--qreal KoShape::textRunAroundDistanceTop() const-{- return s->textRunAroundDistanceTop;-}--void KoShape::setTextRunAroundDistanceTop(qreal distance)-{- s->textRunAroundDistanceTop = distance;-}--qreal KoShape::textRunAroundDistanceLeft() const-{- return s->textRunAroundDistanceLeft;-}--void KoShape::setTextRunAroundDistanceLeft(qreal distance)-{- s->textRunAroundDistanceLeft = distance;-}--qreal KoShape::textRunAroundDistanceRight() const-{- return s->textRunAroundDistanceRight;-}--void KoShape::setTextRunAroundDistanceRight(qreal distance)-{- s->textRunAroundDistanceRight = distance;-}--qreal KoShape::textRunAroundDistanceBottom() const-{- return s->textRunAroundDistanceBottom;-}--void KoShape::setTextRunAroundDistanceBottom(qreal distance)-{- s->textRunAroundDistanceBottom = distance;-}--qreal KoShape::textRunAroundThreshold() const-{- return s->textRunAroundThreshold;-}--void KoShape::setTextRunAroundThreshold(qreal threshold)-{- s->textRunAroundThreshold = threshold;-}--KoShape::TextRunAroundContour KoShape::textRunAroundContour() const-{- return s->textRunAroundContour;-}--void KoShape::setTextRunAroundContour(KoShape::TextRunAroundContour contour)-{- s->textRunAroundContour = contour;-}-void KoShape::setBackground(QSharedPointer<KoShapeBackground> fill){s->inheritBackground = false;diff --git a/libs/flake/KoShape.h b/libs/flake/KoShape.hindex 7b2871185e..80bb7ed0a6 100644--- a/libs/flake/KoShape.h+++ b/libs/flake/KoShape.h@@ -104,7 +104,7 @@ public:BorderChanged, ///< the shapes border has changedParameterChanged, ///< the shapes parameter has changed (KoParameterShape only)ContentChanged, ///< the content of the shape changed e.g. a new image inside a pixmap/text change inside a textshape- TextRunAroundChanged, ///< used after a setTextRunAroundSide()+ TextContourMarginChanged, ///< used after text properties changed and modified the contour margin in the text shapeChildChanged, ///< a child of a container was changed/removed. This is propagated to all parentsConnectionPointChanged, ///< a connection point has changedClipPathChanged, ///< the shapes clip path has changed@@ -112,32 +112,6 @@ public:TransparencyChanged ///< the shapetransparency value has changed};- /// The behavior text should do when intersecting this shape.- enum TextRunAroundSide {- BiggestRunAroundSide, ///< Run other text around the side that has the most space- LeftRunAroundSide, ///< Run other text around the left side of the frame- RightRunAroundSide, ///< Run other text around the right side of the frame- EnoughRunAroundSide, ///< Run other text dynamically around both sides of the shape, provided there is sufficient space left- BothRunAroundSide, ///< Run other text around both sides of the shape- NoRunAround, ///< The text will be completely avoiding the frame by keeping the horizontal space that this frame occupies blank.- RunThrough ///< The text will completely ignore the frame and layout as if it was not there- };-- /// The behavior text should do when intersecting this shape.- enum TextRunAroundContour {- ContourBox, /// Run other text around a bounding rect of the outline- ContourFull, ///< Run other text around also on the inside- ContourOutside ///< Run other text around only on the outside- };-- /**- * TODO- */- enum RunThroughLevel {- Background,- Foreground- };-enum PaintOrder {Fill,Stroke,@@ -301,95 +275,6 @@ public:*/static QRectF absoluteOutlineRect(const QList<KoShape*> &shapes);- /**- * Return the side text should flow around this shape. This implements the ODF style:wrap- * attribute that specifies how text is displayed around a frame or graphic object.- */- TextRunAroundSide textRunAroundSide() const;-- /**- * Set the side text should flow around this shape.- * @param side the requested side- * @param runThrough run through the foreground or background or...- */- void setTextRunAroundSide(TextRunAroundSide side, RunThroughLevel runThrough = Background);-- /**- * The space between this shape's left edge and text that runs around this shape.- * @return the space around this shape to keep free from text- */- qreal textRunAroundDistanceLeft() const;-- /**- * Set the space between this shape's left edge and the text that run around this shape.- * @param distance the space around this shape to keep free from text- */- void setTextRunAroundDistanceLeft(qreal distance);-- /**- * The space between this shape's top edge and text that runs around this shape.- * @return the space around this shape to keep free from text- */- qreal textRunAroundDistanceTop() const;-- /**- * Set the space between this shape's top edge and the text that run around this shape.- * @param distance the space around this shape to keep free from text- */- void setTextRunAroundDistanceTop(qreal distance);-- /**- * The space between this shape's right edge and text that runs around this shape.- * @return the space around this shape to keep free from text- */- qreal textRunAroundDistanceRight() const;-- /**- * Set the space between this shape's right edge and the text that run around this shape.- * @param distance the space around this shape to keep free from text- */- void setTextRunAroundDistanceRight(qreal distance);-- /**- * The space between this shape's bottom edge and text that runs around this shape.- * @return the space around this shape to keep free from text- */- qreal textRunAroundDistanceBottom() const;-- /**- * Set the space between this shape's bottom edge and the text that run around this shape.- * @param distance the space around this shape to keep free from text- */- void setTextRunAroundDistanceBottom(qreal distance);-- /**- * Return the threshold above which text should flow around this shape.- * The text will not flow around the shape on a side unless the space available on that side- * is above this threshold. Only used when the text run around side is EnoughRunAroundSide.- * @return threshold the threshold- */- qreal textRunAroundThreshold() const;-- /**- * Set the threshold above which text should flow around this shape.- * The text will not flow around the shape on a side unless the space available on that side- * is above this threshold. Only used when the text run around side is EnoughRunAroundSide.- * @param threshold the new threshold- */- void setTextRunAroundThreshold(qreal threshold);-- /**- * Return the how tight text run around is done around this shape.- * @return the contour- */- TextRunAroundContour textRunAroundContour() const;-- /**- * Set how tight text run around is done around this shape.- * @param contour the new contour- */- void setTextRunAroundContour(TextRunAroundContour contour);-/*** Set the KoShapeAnchor*/diff --git a/libs/flake/KoShape_p.h b/libs/flake/KoShape_p.hindex 282d683ecc..0f705eaa03 100644--- a/libs/flake/KoShape_p.h+++ b/libs/flake/KoShape_p.h@@ -60,14 +60,6 @@ public:int selectable : 1;int protectContent : 1;- KoShape::TextRunAroundSide textRunAroundSide;- qreal textRunAroundDistanceLeft;- qreal textRunAroundDistanceTop;- qreal textRunAroundDistanceRight;- qreal textRunAroundDistanceBottom;- qreal textRunAroundThreshold;- KoShape::TextRunAroundContour textRunAroundContour;-QVector<PaintOrder> paintOrder {Fill, Stroke, Markers};bool inheritPaintOrder = true;};diff --git a/libs/flake/commands/KoShapeRunAroundCommand.cpp b/libs/flake/commands/KoShapeRunAroundCommand.cppdeleted file mode 100644index e7210a7b63..0000000000--- a/libs/flake/commands/KoShapeRunAroundCommand.cpp+++ /dev/null@@ -1,92 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2008 Thorsten Zachmann <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include "KoShapeRunAroundCommand.h"--#include <klocalizedstring.h>-#include "KoShape.h"--class Q_DECL_HIDDEN KoShapeRunAroundCommand::Private-{-public:- Private(KoShape *s, KoShape::TextRunAroundSide side, int runThrough, qreal distanceLeft, qreal distanceTop, qreal distanceRight, qreal distanceBottom, qreal threshold, KoShape::TextRunAroundContour contour)- : shape(s)- , newSide(side)- , newRunThrough(runThrough)- , newDistanceLeft(distanceLeft)- , newDistanceTop(distanceTop)- , newDistanceRight(distanceRight)- , newDistanceBottom(distanceBottom)- , newThreshold(threshold)- , newContour(contour)- , oldSide(shape->textRunAroundSide())- , oldRunThrough(shape->runThrough())- , oldDistanceLeft(shape->textRunAroundDistanceLeft())- , oldDistanceTop(shape->textRunAroundDistanceTop())- , oldDistanceRight(shape->textRunAroundDistanceRight())- , oldDistanceBottom(shape->textRunAroundDistanceBottom())- , oldThreshold(shape->textRunAroundThreshold())- , oldContour(shape->textRunAroundContour())- {}-- KoShape *shape;- KoShape::TextRunAroundSide newSide;- int newRunThrough;- qreal newDistanceLeft;- qreal newDistanceTop;- qreal newDistanceRight;- qreal newDistanceBottom;- qreal newThreshold;- KoShape::TextRunAroundContour newContour;- KoShape::TextRunAroundSide oldSide;- int oldRunThrough;- qreal oldDistanceLeft;- qreal oldDistanceTop;- qreal oldDistanceRight;- qreal oldDistanceBottom;- qreal oldThreshold;- KoShape::TextRunAroundContour oldContour;-};--KoShapeRunAroundCommand::KoShapeRunAroundCommand(KoShape *shape, KoShape::TextRunAroundSide side, int runThrough, qreal distanceLeft, qreal distanceTop, qreal distanceRight, qreal distanceBottom, qreal threshold, KoShape::TextRunAroundContour contour, KUndo2Command *parent)-: KUndo2Command(parent)-, d(new Private(shape, side, runThrough, distanceLeft, distanceTop, distanceRight, distanceBottom, threshold, contour))-{- setText(kundo2_i18n("Change Shape RunAround"));-}--KoShapeRunAroundCommand::~KoShapeRunAroundCommand()-{- delete d;-}--void KoShapeRunAroundCommand::redo()-{- KUndo2Command::redo();- d->shape->setTextRunAroundSide(d->newSide, KoShape::Background);- d->shape->setRunThrough(d->newRunThrough);- d->shape->setTextRunAroundDistanceLeft(d->newDistanceLeft);- d->shape->setTextRunAroundDistanceTop(d->newDistanceTop);- d->shape->setTextRunAroundDistanceRight(d->newDistanceRight);- d->shape->setTextRunAroundDistanceBottom(d->newDistanceBottom);- d->shape->setTextRunAroundThreshold(d->newThreshold);- d->shape->setTextRunAroundContour(d->newContour);- d->shape->notifyChanged();-}--void KoShapeRunAroundCommand::undo()-{- KUndo2Command::undo();- d->shape->setTextRunAroundSide(d->oldSide, KoShape::Background);- d->shape->setRunThrough(d->oldRunThrough);- d->shape->setTextRunAroundDistanceLeft(d->oldDistanceLeft);- d->shape->setTextRunAroundDistanceTop(d->oldDistanceTop);- d->shape->setTextRunAroundDistanceRight(d->oldDistanceRight);- d->shape->setTextRunAroundDistanceBottom(d->oldDistanceBottom);- d->shape->setTextRunAroundThreshold(d->oldThreshold);- d->shape->setTextRunAroundContour(d->oldContour);- d->shape->notifyChanged();-}diff --git a/libs/flake/commands/KoShapeRunAroundCommand.h b/libs/flake/commands/KoShapeRunAroundCommand.hdeleted file mode 100644index fb480ec506..0000000000--- a/libs/flake/commands/KoShapeRunAroundCommand.h+++ /dev/null@@ -1,32 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2008 Thorsten Zachmann <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOSHAPERUNAROUNDCOMMAND_H-#define KOSHAPERUNAROUNDCOMMAND_H--#include "kritaflake_export.h"-#include <kundo2command.h>--#include "KoShape.h"--/// API docs go here-class KRITAFLAKE_EXPORT KoShapeRunAroundCommand : public KUndo2Command-{-public:- KoShapeRunAroundCommand(KoShape *shape, KoShape::TextRunAroundSide side, int runThrough, qreal distanceLeft, qreal distanceTop, qreal distanceRight, qreal distanceBottom, qreal threshold, KoShape::TextRunAroundContour contour, KUndo2Command *parent = 0);- ~KoShapeRunAroundCommand() override;-- /// redo the command- void redo() override;- /// revert the actions done in redo- void undo() override;--private:- class Private;- Private * const d;-};--#endif /* KOSHAPERUNAROUNDCOMMAND_H */diff --git a/libs/flake/tests/TestShapeReorderCommand.cpp b/libs/flake/tests/TestShapeReorderCommand.cppindex d8a715d4ba..e37eb085d2 100644--- a/libs/flake/tests/TestShapeReorderCommand.cpp+++ b/libs/flake/tests/TestShapeReorderCommand.cpp@@ -49,39 +49,6 @@ void TestShapeReorderCommand::testZIndexSorting()QCOMPARE(shapes.indexOf(&shape5), 0);}-void TestShapeReorderCommand::testRunThroughSorting()-{- MockShape shape1;- MockShape shape2;- MockShape shape3;- MockShape shape4;- MockShape shape5;-- shape1.setZIndex(-2);- shape2.setZIndex(5);- shape3.setZIndex(0);- shape4.setZIndex(9999);- shape5.setZIndex(-9999);-- shape2.setTextRunAroundSide(KoShape::RunThrough, KoShape::Background);- shape3.setTextRunAroundSide(KoShape::RunThrough, KoShape::Foreground);-- QList<KoShape*> shapes;- shapes.append(&shape1);- shapes.append(&shape2);- shapes.append(&shape3);- shapes.append(&shape4);- shapes.append(&shape5);-- std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex);-- QCOMPARE(shapes.indexOf(&shape1), 2);- QCOMPARE(shapes.indexOf(&shape2), 0);- QCOMPARE(shapes.indexOf(&shape3), 4);- QCOMPARE(shapes.indexOf(&shape4), 3);- QCOMPARE(shapes.indexOf(&shape5), 1);-}-void TestShapeReorderCommand::testParentChildSorting(){MockShape *shape1 = new MockShape();@@ -105,12 +72,7 @@ void TestShapeReorderCommand::testParentChildSorting()container1->setZIndex(-55);container2->setZIndex(57);- shape2->setTextRunAroundSide(KoShape::RunThrough, KoShape::Background);- shape3->setTextRunAroundSide(KoShape::RunThrough, KoShape::Foreground);- container1->setTextRunAroundSide(KoShape::RunThrough, KoShape::Foreground);-container1->addShape(shape1);- //container1.addShape(&shape2); //we shouldn't parent combine fg and bgcontainer2->addShape(shape4);container2->addShape(shape5);container1->addShape(container2);@@ -131,30 +93,28 @@ void TestShapeReorderCommand::testParentChildSorting()std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex);/* This is the expected result-s3 0 fg- s4 9999- s5 -9999- c2 57- c3 0- s1 -2-c1 -55 fg--s7 7-s6 3--s2 5 bg+c1 -55+ s1 -2+ c3 0+ c2 57+ s5 -9999+ s4 9999+s3 0+s6 3+s2 5+s7 7*/- QCOMPARE(shapes.indexOf(shape1), 4);- QCOMPARE(shapes.indexOf(shape2), 0);- QCOMPARE(shapes.indexOf(shape3), 9);- QCOMPARE(shapes.indexOf(shape4), 8);- QCOMPARE(shapes.indexOf(shape5), 7);- QCOMPARE(shapes.indexOf(shape6), 1);- QCOMPARE(shapes.indexOf(shape7), 2);- QCOMPARE(shapes.indexOf(container1), 3);- QCOMPARE(shapes.indexOf(container2), 6);- QCOMPARE(shapes.indexOf(container3), 5);+ QCOMPARE(shapes.indexOf(shape1), 1);+ QCOMPARE(shapes.indexOf(shape2), 8);+ QCOMPARE(shapes.indexOf(shape3), 6);+ QCOMPARE(shapes.indexOf(shape4), 5);+ QCOMPARE(shapes.indexOf(shape5), 4);+ QCOMPARE(shapes.indexOf(shape6), 7);+ QCOMPARE(shapes.indexOf(shape7), 9);+ QCOMPARE(shapes.indexOf(container1), 0);+ QCOMPARE(shapes.indexOf(container2), 3);+ QCOMPARE(shapes.indexOf(container3), 2);delete container1;delete shape2;diff --git a/libs/flake/tests/TestShapeReorderCommand.h b/libs/flake/tests/TestShapeReorderCommand.hindex ea7027f147..68aa34f829 100644--- a/libs/flake/tests/TestShapeReorderCommand.h+++ b/libs/flake/tests/TestShapeReorderCommand.h@@ -17,7 +17,6 @@ public:~TestShapeReorderCommand() override;private Q_SLOTS:void testZIndexSorting();- void testRunThroughSorting();void testParentChildSorting();void testBringToFront();diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cppindex 4cf417c502..862880b939 100644--- a/libs/flake/text/KoSvgTextShape.cpp+++ b/libs/flake/text/KoSvgTextShape.cpp@@ -230,8 +230,7 @@ void KoSvgTextShape::shapeChanged(ChangeType type, KoShape *shape)}} else if (transformationTypes.contains(type) || type == ParentChanged) {d->shapeGroup->setTransformation(this->absoluteTransformation());- } else if (type == TextRunAroundChanged) {- // Hack: we don't use runaround else where, so we're using it for padding and margin.+ } else if (type == TextContourMarginChanged) {if (d->bulkActionState) {d->bulkActionState->contourHasChanged = true;} else {@@ -1072,7 +1071,7 @@ void KoSvgTextShape::mergePropertiesIntoRange(const int startPos,|| properties.hasProperty(KoSvgTextProperties::ShapeMarginId)|| removeProperties.contains(KoSvgTextProperties::ShapePaddingId)|| removeProperties.contains(KoSvgTextProperties::ShapeMarginId)) {- shapeChangedPriv(TextRunAroundChanged);+ shapeChangedPriv(TextContourMarginChanged);} else {shapeChangedPriv(ContentChanged);}