File indexing completed on 2025-01-26 04:04:54
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2008 Thorsten Zachmann <zachmann@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "KoShapeRunAroundCommand.h" 0008 0009 #include <QString> 0010 #include <klocalizedstring.h> 0011 #include "KoShape.h" 0012 0013 class Q_DECL_HIDDEN KoShapeRunAroundCommand::Private 0014 { 0015 public: 0016 Private(KoShape *s, KoShape::TextRunAroundSide side, int runThrough, qreal distanceLeft, qreal distanceTop, qreal distanceRight, qreal distanceBottom, qreal threshold, KoShape::TextRunAroundContour contour) 0017 : shape(s) 0018 , newSide(side) 0019 , newRunThrough(runThrough) 0020 , newDistanceLeft(distanceLeft) 0021 , newDistanceTop(distanceTop) 0022 , newDistanceRight(distanceRight) 0023 , newDistanceBottom(distanceBottom) 0024 , newThreshold(threshold) 0025 , newContour(contour) 0026 , oldSide(shape->textRunAroundSide()) 0027 , oldRunThrough(shape->runThrough()) 0028 , oldDistanceLeft(shape->textRunAroundDistanceLeft()) 0029 , oldDistanceTop(shape->textRunAroundDistanceTop()) 0030 , oldDistanceRight(shape->textRunAroundDistanceRight()) 0031 , oldDistanceBottom(shape->textRunAroundDistanceBottom()) 0032 , oldThreshold(shape->textRunAroundThreshold()) 0033 , oldContour(shape->textRunAroundContour()) 0034 {} 0035 0036 KoShape *shape; 0037 KoShape::TextRunAroundSide newSide; 0038 int newRunThrough; 0039 qreal newDistanceLeft; 0040 qreal newDistanceTop; 0041 qreal newDistanceRight; 0042 qreal newDistanceBottom; 0043 qreal newThreshold; 0044 KoShape::TextRunAroundContour newContour; 0045 KoShape::TextRunAroundSide oldSide; 0046 int oldRunThrough; 0047 qreal oldDistanceLeft; 0048 qreal oldDistanceTop; 0049 qreal oldDistanceRight; 0050 qreal oldDistanceBottom; 0051 qreal oldThreshold; 0052 KoShape::TextRunAroundContour oldContour; 0053 }; 0054 0055 KoShapeRunAroundCommand::KoShapeRunAroundCommand(KoShape *shape, KoShape::TextRunAroundSide side, int runThrough, qreal distanceLeft, qreal distanceTop, qreal distanceRight, qreal distanceBottom, qreal threshold, KoShape::TextRunAroundContour contour, KUndo2Command *parent) 0056 : KUndo2Command(parent) 0057 , d(new Private(shape, side, runThrough, distanceLeft, distanceTop, distanceRight, distanceBottom, threshold, contour)) 0058 { 0059 setText(kundo2_i18n("Change Shape RunAround")); 0060 } 0061 0062 KoShapeRunAroundCommand::~KoShapeRunAroundCommand() 0063 { 0064 delete d; 0065 } 0066 0067 void KoShapeRunAroundCommand::redo() 0068 { 0069 KUndo2Command::redo(); 0070 d->shape->setTextRunAroundSide(d->newSide, KoShape::Background); 0071 d->shape->setRunThrough(d->newRunThrough); 0072 d->shape->setTextRunAroundDistanceLeft(d->newDistanceLeft); 0073 d->shape->setTextRunAroundDistanceTop(d->newDistanceTop); 0074 d->shape->setTextRunAroundDistanceRight(d->newDistanceRight); 0075 d->shape->setTextRunAroundDistanceBottom(d->newDistanceBottom); 0076 d->shape->setTextRunAroundThreshold(d->newThreshold); 0077 d->shape->setTextRunAroundContour(d->newContour); 0078 d->shape->notifyChanged(); 0079 } 0080 0081 void KoShapeRunAroundCommand::undo() 0082 { 0083 KUndo2Command::undo(); 0084 d->shape->setTextRunAroundSide(d->oldSide, KoShape::Background); 0085 d->shape->setRunThrough(d->oldRunThrough); 0086 d->shape->setTextRunAroundDistanceLeft(d->oldDistanceLeft); 0087 d->shape->setTextRunAroundDistanceTop(d->oldDistanceTop); 0088 d->shape->setTextRunAroundDistanceRight(d->oldDistanceRight); 0089 d->shape->setTextRunAroundDistanceBottom(d->oldDistanceBottom); 0090 d->shape->setTextRunAroundThreshold(d->oldThreshold); 0091 d->shape->setTextRunAroundContour(d->oldContour); 0092 d->shape->notifyChanged(); 0093 }