Commit fdda279f authored by Tusooa Zhu's avatar Tusooa Zhu 🔼 Committed by Blackbeard (alberto flores)

Use implicitly-shared d-pointers for KoShapeBackground heirarchy

parent c0d56f86
...@@ -41,7 +41,7 @@ KoColorBackground::KoColorBackground(KoShapeBackgroundPrivate &dd) ...@@ -41,7 +41,7 @@ KoColorBackground::KoColorBackground(KoShapeBackgroundPrivate &dd)
KoColorBackground::KoColorBackground(const QColor &color, Qt::BrushStyle style) KoColorBackground::KoColorBackground(const QColor &color, Qt::BrushStyle style)
: KoShapeBackground(*(new KoColorBackgroundPrivate())) : KoShapeBackground(*(new KoColorBackgroundPrivate()))
{ {
Q_D(KoColorBackground); SHARED_D(KoColorBackground);
if (style < Qt::SolidPattern || style >= Qt::LinearGradientPattern) if (style < Qt::SolidPattern || style >= Qt::LinearGradientPattern)
style = Qt::SolidPattern; style = Qt::SolidPattern;
d->style = style; d->style = style;
...@@ -54,7 +54,7 @@ KoColorBackground::~KoColorBackground() ...@@ -54,7 +54,7 @@ KoColorBackground::~KoColorBackground()
bool KoColorBackground::compareTo(const KoShapeBackground *other) const bool KoColorBackground::compareTo(const KoShapeBackground *other) const
{ {
Q_D(const KoColorBackground); CONST_SHARED_D(KoColorBackground);
const KoColorBackground *bg = dynamic_cast<const KoColorBackground*>(other); const KoColorBackground *bg = dynamic_cast<const KoColorBackground*>(other);
return bg && bg->color() == d->color; return bg && bg->color() == d->color;
...@@ -62,25 +62,25 @@ bool KoColorBackground::compareTo(const KoShapeBackground *other) const ...@@ -62,25 +62,25 @@ bool KoColorBackground::compareTo(const KoShapeBackground *other) const
QColor KoColorBackground::color() const QColor KoColorBackground::color() const
{ {
Q_D(const KoColorBackground); CONST_SHARED_D(KoColorBackground);
return d->color; return d->color;
} }
void KoColorBackground::setColor(const QColor &color) void KoColorBackground::setColor(const QColor &color)
{ {
Q_D(KoColorBackground); SHARED_D(KoColorBackground);
d->color = color; d->color = color;
} }
Qt::BrushStyle KoColorBackground::style() const Qt::BrushStyle KoColorBackground::style() const
{ {
Q_D(const KoColorBackground); CONST_SHARED_D(KoColorBackground);
return d->style; return d->style;
} }
QBrush KoColorBackground::brush() const QBrush KoColorBackground::brush() const
{ {
Q_D(const KoColorBackground); CONST_SHARED_D(KoColorBackground);
return QBrush(d->color, d->style); return QBrush(d->color, d->style);
} }
...@@ -92,13 +92,13 @@ void KoColorBackground::paint(QPainter &painter, const KoViewConverter &/*conver ...@@ -92,13 +92,13 @@ void KoColorBackground::paint(QPainter &painter, const KoViewConverter &/*conver
void KoColorBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context) void KoColorBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context)
{ {
Q_D(KoColorBackground); SHARED_D(KoColorBackground);
KoOdfGraphicStyles::saveOdfFillStyle(style, context.mainStyles(), QBrush(d->color, d->style)); KoOdfGraphicStyles::saveOdfFillStyle(style, context.mainStyles(), QBrush(d->color, d->style));
} }
bool KoColorBackground::loadStyle(KoOdfLoadingContext & context, const QSizeF &) bool KoColorBackground::loadStyle(KoOdfLoadingContext & context, const QSizeF &)
{ {
Q_D(KoColorBackground); SHARED_D(KoColorBackground);
KoStyleStack &styleStack = context.styleStack(); KoStyleStack &styleStack = context.styleStack();
if (! styleStack.hasProperty(KoXmlNS::draw, "fill")) if (! styleStack.hasProperty(KoXmlNS::draw, "fill"))
return false; return false;
......
...@@ -61,8 +61,8 @@ public: ...@@ -61,8 +61,8 @@ public:
protected: protected:
KoColorBackground(KoShapeBackgroundPrivate &dd); KoColorBackground(KoShapeBackgroundPrivate &dd);
private: private:
Q_DECLARE_PRIVATE(KoColorBackground) // Q_DECLARE_PRIVATE(KoColorBackground)
Q_DISABLE_COPY(KoColorBackground) // Q_DISABLE_COPY(KoColorBackground)
}; };
#endif // KOCOLORBACKGROUND_H #endif // KOCOLORBACKGROUND_H
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
KoGradientBackground::KoGradientBackground(QGradient * gradient, const QTransform &matrix) KoGradientBackground::KoGradientBackground(QGradient * gradient, const QTransform &matrix)
: KoShapeBackground(*(new KoGradientBackgroundPrivate())) : KoShapeBackground(*(new KoGradientBackgroundPrivate()))
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
d->gradient = gradient; d->gradient = gradient;
d->matrix = matrix; d->matrix = matrix;
Q_ASSERT(d->gradient); Q_ASSERT(d->gradient);
...@@ -55,7 +55,7 @@ KoGradientBackground::KoGradientBackground(QGradient * gradient, const QTransfor ...@@ -55,7 +55,7 @@ KoGradientBackground::KoGradientBackground(QGradient * gradient, const QTransfor
KoGradientBackground::KoGradientBackground(const QGradient & gradient, const QTransform &matrix) KoGradientBackground::KoGradientBackground(const QGradient & gradient, const QTransform &matrix)
: KoShapeBackground(*(new KoGradientBackgroundPrivate())) : KoShapeBackground(*(new KoGradientBackgroundPrivate()))
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
d->gradient = KoFlake::cloneGradient(&gradient); d->gradient = KoFlake::cloneGradient(&gradient);
d->matrix = matrix; d->matrix = matrix;
Q_ASSERT(d->gradient); Q_ASSERT(d->gradient);
...@@ -63,13 +63,13 @@ KoGradientBackground::KoGradientBackground(const QGradient & gradient, const QTr ...@@ -63,13 +63,13 @@ KoGradientBackground::KoGradientBackground(const QGradient & gradient, const QTr
KoGradientBackground::~KoGradientBackground() KoGradientBackground::~KoGradientBackground()
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
delete d->gradient; delete d->gradient;
} }
bool KoGradientBackground::compareTo(const KoShapeBackground *other) const bool KoGradientBackground::compareTo(const KoShapeBackground *other) const
{ {
Q_D(const KoGradientBackground); CONST_SHARED_D(KoGradientBackground);
const KoGradientBackground *otherGradient = dynamic_cast<const KoGradientBackground*>(other); const KoGradientBackground *otherGradient = dynamic_cast<const KoGradientBackground*>(other);
return otherGradient && return otherGradient &&
...@@ -79,19 +79,19 @@ bool KoGradientBackground::compareTo(const KoShapeBackground *other) const ...@@ -79,19 +79,19 @@ bool KoGradientBackground::compareTo(const KoShapeBackground *other) const
void KoGradientBackground::setTransform(const QTransform &matrix) void KoGradientBackground::setTransform(const QTransform &matrix)
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
d->matrix = matrix; d->matrix = matrix;
} }
QTransform KoGradientBackground::transform() const QTransform KoGradientBackground::transform() const
{ {
Q_D(const KoGradientBackground); CONST_SHARED_D(KoGradientBackground);
return d->matrix; return d->matrix;
} }
void KoGradientBackground::setGradient(const QGradient &gradient) void KoGradientBackground::setGradient(const QGradient &gradient)
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
delete d->gradient; delete d->gradient;
d->gradient = KoFlake::cloneGradient(&gradient); d->gradient = KoFlake::cloneGradient(&gradient);
...@@ -100,13 +100,13 @@ void KoGradientBackground::setGradient(const QGradient &gradient) ...@@ -100,13 +100,13 @@ void KoGradientBackground::setGradient(const QGradient &gradient)
const QGradient * KoGradientBackground::gradient() const const QGradient * KoGradientBackground::gradient() const
{ {
Q_D(const KoGradientBackground); CONST_SHARED_D(KoGradientBackground);
return d->gradient; return d->gradient;
} }
void KoGradientBackground::paint(QPainter &painter, const KoViewConverter &/*converter*/, KoShapePaintingContext &/*context*/, const QPainterPath &fillPath) const void KoGradientBackground::paint(QPainter &painter, const KoViewConverter &/*converter*/, KoShapePaintingContext &/*context*/, const QPainterPath &fillPath) const
{ {
Q_D(const KoGradientBackground); CONST_SHARED_D(KoGradientBackground);
if (!d->gradient) return; if (!d->gradient) return;
if (d->gradient->coordinateMode() == QGradient::ObjectBoundingMode) { if (d->gradient->coordinateMode() == QGradient::ObjectBoundingMode) {
...@@ -147,7 +147,7 @@ void KoGradientBackground::paint(QPainter &painter, const KoViewConverter &/*con ...@@ -147,7 +147,7 @@ void KoGradientBackground::paint(QPainter &painter, const KoViewConverter &/*con
void KoGradientBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context) void KoGradientBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context)
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
if (!d->gradient) return; if (!d->gradient) return;
QBrush brush(*d->gradient); QBrush brush(*d->gradient);
brush.setTransform(d->matrix); brush.setTransform(d->matrix);
...@@ -156,7 +156,7 @@ void KoGradientBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &co ...@@ -156,7 +156,7 @@ void KoGradientBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &co
bool KoGradientBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize) bool KoGradientBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize)
{ {
Q_D(KoGradientBackground); SHARED_D(KoGradientBackground);
KoStyleStack &styleStack = context.styleStack(); KoStyleStack &styleStack = context.styleStack();
if (! styleStack.hasProperty(KoXmlNS::draw, "fill")) if (! styleStack.hasProperty(KoXmlNS::draw, "fill"))
return false; return false;
......
...@@ -72,8 +72,8 @@ public: ...@@ -72,8 +72,8 @@ public:
bool loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize) override; bool loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize) override;
private: private:
Q_DECLARE_PRIVATE(KoGradientBackground) // Q_DECLARE_PRIVATE(KoGradientBackground)
Q_DISABLE_COPY(KoGradientBackground) // Q_DISABLE_COPY(KoGradientBackground)
}; };
#endif // KOGRADIENTBACKGROUND_H #endif // KOGRADIENTBACKGROUND_H
...@@ -84,7 +84,7 @@ bool KoOdfGradientBackground::compareTo(const KoShapeBackground *other) const ...@@ -84,7 +84,7 @@ bool KoOdfGradientBackground::compareTo(const KoShapeBackground *other) const
bool KoOdfGradientBackground::loadOdf(const KoXmlElement& e) bool KoOdfGradientBackground::loadOdf(const KoXmlElement& e)
{ {
Q_D(KoOdfGradientBackground); SHARED_D(KoOdfGradientBackground);
d->style = e.attributeNS(KoXmlNS::draw, "style", QString()); d->style = e.attributeNS(KoXmlNS::draw, "style", QString());
//TODO: support ellipsoid here too //TODO: support ellipsoid here too
if ((d->style != "rectangular") && (d->style != "square")) { if ((d->style != "rectangular") && (d->style != "square")) {
...@@ -109,7 +109,7 @@ bool KoOdfGradientBackground::loadOdf(const KoXmlElement& e) ...@@ -109,7 +109,7 @@ bool KoOdfGradientBackground::loadOdf(const KoXmlElement& e)
void KoOdfGradientBackground::saveOdf(KoGenStyle& styleFill, KoGenStyles& mainStyles) const void KoOdfGradientBackground::saveOdf(KoGenStyle& styleFill, KoGenStyles& mainStyles) const
{ {
Q_D(const KoOdfGradientBackground); CONST_SHARED_D(KoOdfGradientBackground);
KoGenStyle::Type type = styleFill.type(); KoGenStyle::Type type = styleFill.type();
KoGenStyle::PropertyType propertyType = (type == KoGenStyle::GraphicStyle || type == KoGenStyle::GraphicAutoStyle || KoGenStyle::PropertyType propertyType = (type == KoGenStyle::GraphicStyle || type == KoGenStyle::GraphicAutoStyle ||
...@@ -139,7 +139,7 @@ void KoOdfGradientBackground::saveOdf(KoGenStyle& styleFill, KoGenStyles& mainSt ...@@ -139,7 +139,7 @@ void KoOdfGradientBackground::saveOdf(KoGenStyle& styleFill, KoGenStyles& mainSt
void KoOdfGradientBackground::paint(QPainter& painter, const KoViewConverter &/*converter*/, KoShapePaintingContext &/*context*/, const QPainterPath& fillPath) const void KoOdfGradientBackground::paint(QPainter& painter, const KoViewConverter &/*converter*/, KoShapePaintingContext &/*context*/, const QPainterPath& fillPath) const
{ {
Q_D(const KoOdfGradientBackground); CONST_SHARED_D(KoOdfGradientBackground);
QImage buffer; QImage buffer;
...@@ -169,7 +169,7 @@ void KoOdfGradientBackground::fillStyle(KoGenStyle& style, KoShapeSavingContext& ...@@ -169,7 +169,7 @@ void KoOdfGradientBackground::fillStyle(KoGenStyle& style, KoShapeSavingContext&
bool KoOdfGradientBackground::loadStyle(KoOdfLoadingContext& context, const QSizeF& shapeSize) bool KoOdfGradientBackground::loadStyle(KoOdfLoadingContext& context, const QSizeF& shapeSize)
{ {
Q_UNUSED(shapeSize); Q_UNUSED(shapeSize);
Q_D(KoOdfGradientBackground); SHARED_D(KoOdfGradientBackground);
KoStyleStack &styleStack = context.styleStack(); KoStyleStack &styleStack = context.styleStack();
if (!styleStack.hasProperty(KoXmlNS::draw, "fill")) { if (!styleStack.hasProperty(KoXmlNS::draw, "fill")) {
...@@ -197,7 +197,7 @@ bool KoOdfGradientBackground::loadStyle(KoOdfLoadingContext& context, const QSiz ...@@ -197,7 +197,7 @@ bool KoOdfGradientBackground::loadStyle(KoOdfLoadingContext& context, const QSiz
void KoOdfGradientBackground::renderSquareGradient(QImage& buffer) const void KoOdfGradientBackground::renderSquareGradient(QImage& buffer) const
{ {
Q_D(const KoOdfGradientBackground); CONST_SHARED_D(KoOdfGradientBackground);
buffer.fill(d->startColor.rgba()); buffer.fill(d->startColor.rgba());
QPainter painter(&buffer); QPainter painter(&buffer);
...@@ -261,7 +261,7 @@ void KoOdfGradientBackground::renderSquareGradient(QImage& buffer) const ...@@ -261,7 +261,7 @@ void KoOdfGradientBackground::renderSquareGradient(QImage& buffer) const
void KoOdfGradientBackground::renderRectangleGradient(QImage& buffer) const void KoOdfGradientBackground::renderRectangleGradient(QImage& buffer) const
{ {
Q_D(const KoOdfGradientBackground); CONST_SHARED_D(KoOdfGradientBackground);
buffer.fill(d->startColor.rgba()); buffer.fill(d->startColor.rgba());
QPainter painter(&buffer); QPainter painter(&buffer);
...@@ -377,7 +377,7 @@ void KoOdfGradientBackground::renderRectangleGradient(QImage& buffer) const ...@@ -377,7 +377,7 @@ void KoOdfGradientBackground::renderRectangleGradient(QImage& buffer) const
void KoOdfGradientBackground::debug() const void KoOdfGradientBackground::debug() const
{ {
Q_D(const KoOdfGradientBackground); CONST_SHARED_D(KoOdfGradientBackground);
debugFlake << "cx,cy: "<< d->cx << d->cy; debugFlake << "cx,cy: "<< d->cx << d->cy;
debugFlake << "style" << d->style; debugFlake << "style" << d->style;
debugFlake << "colors" << d->startColor << d->endColor; debugFlake << "colors" << d->startColor << d->endColor;
......
...@@ -59,7 +59,7 @@ private: ...@@ -59,7 +59,7 @@ private:
void debug() const; void debug() const;
private: private:
Q_DECLARE_PRIVATE(KoOdfGradientBackground) // Q_DECLARE_PRIVATE(KoOdfGradientBackground)
Q_DISABLE_COPY(KoOdfGradientBackground) Q_DISABLE_COPY(KoOdfGradientBackground)
}; };
......
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
KoPatternBackground::KoPatternBackground(KoImageCollection *imageCollection) KoPatternBackground::KoPatternBackground(KoImageCollection *imageCollection)
: KoShapeBackground(*(new KoPatternBackgroundPrivate())) : KoShapeBackground(*(new KoPatternBackgroundPrivate()))
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
d->imageCollection = imageCollection; d->imageCollection = imageCollection;
Q_ASSERT(d->imageCollection); Q_ASSERT(d->imageCollection);
} }
...@@ -152,19 +152,19 @@ bool KoPatternBackground::compareTo(const KoShapeBackground *other) const ...@@ -152,19 +152,19 @@ bool KoPatternBackground::compareTo(const KoShapeBackground *other) const
void KoPatternBackground::setTransform(const QTransform &matrix) void KoPatternBackground::setTransform(const QTransform &matrix)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
d->matrix = matrix; d->matrix = matrix;
} }
QTransform KoPatternBackground::transform() const QTransform KoPatternBackground::transform() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->matrix; return d->matrix;
} }
void KoPatternBackground::setPattern(const QImage &pattern) void KoPatternBackground::setPattern(const QImage &pattern)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
delete d->imageData; delete d->imageData;
if (d->imageCollection) { if (d->imageCollection) {
d->imageData = d->imageCollection->createImageData(pattern); d->imageData = d->imageCollection->createImageData(pattern);
...@@ -173,7 +173,7 @@ void KoPatternBackground::setPattern(const QImage &pattern) ...@@ -173,7 +173,7 @@ void KoPatternBackground::setPattern(const QImage &pattern)
void KoPatternBackground::setPattern(KoImageData *imageData) void KoPatternBackground::setPattern(KoImageData *imageData)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
delete d->imageData; delete d->imageData;
d->imageData = imageData; d->imageData = imageData;
...@@ -181,7 +181,7 @@ void KoPatternBackground::setPattern(KoImageData *imageData) ...@@ -181,7 +181,7 @@ void KoPatternBackground::setPattern(KoImageData *imageData)
QImage KoPatternBackground::pattern() const QImage KoPatternBackground::pattern() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
if (d->imageData) if (d->imageData)
return d->imageData->image(); return d->imageData->image();
return QImage(); return QImage();
...@@ -189,37 +189,37 @@ QImage KoPatternBackground::pattern() const ...@@ -189,37 +189,37 @@ QImage KoPatternBackground::pattern() const
void KoPatternBackground::setRepeat(PatternRepeat repeat) void KoPatternBackground::setRepeat(PatternRepeat repeat)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
d->repeat = repeat; d->repeat = repeat;
} }
KoPatternBackground::PatternRepeat KoPatternBackground::repeat() const KoPatternBackground::PatternRepeat KoPatternBackground::repeat() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->repeat; return d->repeat;
} }
KoPatternBackground::ReferencePoint KoPatternBackground::referencePoint() const KoPatternBackground::ReferencePoint KoPatternBackground::referencePoint() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->refPoint; return d->refPoint;
} }
void KoPatternBackground::setReferencePoint(ReferencePoint referencePoint) void KoPatternBackground::setReferencePoint(ReferencePoint referencePoint)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
d->refPoint = referencePoint; d->refPoint = referencePoint;
} }
QPointF KoPatternBackground::referencePointOffset() const QPointF KoPatternBackground::referencePointOffset() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->refPointOffsetPercent; return d->refPointOffsetPercent;
} }
void KoPatternBackground::setReferencePointOffset(const QPointF &offset) void KoPatternBackground::setReferencePointOffset(const QPointF &offset)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
qreal ox = qMax(qreal(0.0), qMin(qreal(100.0), offset.x())); qreal ox = qMax(qreal(0.0), qMin(qreal(100.0), offset.x()));
qreal oy = qMax(qreal(0.0), qMin(qreal(100.0), offset.y())); qreal oy = qMax(qreal(0.0), qMin(qreal(100.0), offset.y()));
...@@ -228,38 +228,38 @@ void KoPatternBackground::setReferencePointOffset(const QPointF &offset) ...@@ -228,38 +228,38 @@ void KoPatternBackground::setReferencePointOffset(const QPointF &offset)
QPointF KoPatternBackground::tileRepeatOffset() const QPointF KoPatternBackground::tileRepeatOffset() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->tileRepeatOffsetPercent; return d->tileRepeatOffsetPercent;
} }
void KoPatternBackground::setTileRepeatOffset(const QPointF &offset) void KoPatternBackground::setTileRepeatOffset(const QPointF &offset)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
d->tileRepeatOffsetPercent = offset; d->tileRepeatOffsetPercent = offset;
} }
QSizeF KoPatternBackground::patternDisplaySize() const QSizeF KoPatternBackground::patternDisplaySize() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->targetSize(); return d->targetSize();
} }
void KoPatternBackground::setPatternDisplaySize(const QSizeF &size) void KoPatternBackground::setPatternDisplaySize(const QSizeF &size)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
d->targetImageSizePercent = QSizeF(); d->targetImageSizePercent = QSizeF();
d->targetImageSize = size; d->targetImageSize = size;
} }
QSizeF KoPatternBackground::patternOriginalSize() const QSizeF KoPatternBackground::patternOriginalSize() const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
return d->imageData->imageSize(); return d->imageData->imageSize();
} }
void KoPatternBackground::paint(QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &/*context*/, const QPainterPath &fillPath) const void KoPatternBackground::paint(QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &/*context*/, const QPainterPath &fillPath) const
{ {
Q_D(const KoPatternBackground); CONST_SHARED_D(KoPatternBackground);
if (! d->imageData) if (! d->imageData)
return; return;
...@@ -311,7 +311,7 @@ void KoPatternBackground::paint(QPainter &painter, const KoViewConverter &conver ...@@ -311,7 +311,7 @@ void KoPatternBackground::paint(QPainter &painter, const KoViewConverter &conver
void KoPatternBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context) void KoPatternBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
if (! d->imageData) if (! d->imageData)
return; return;
...@@ -373,7 +373,7 @@ void KoPatternBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &con ...@@ -373,7 +373,7 @@ void KoPatternBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &con
bool KoPatternBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF &) bool KoPatternBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF &)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
KoStyleStack &styleStack = context.styleStack(); KoStyleStack &styleStack = context.styleStack();
if (! styleStack.hasProperty(KoXmlNS::draw, "fill")) if (! styleStack.hasProperty(KoXmlNS::draw, "fill"))
return false; return false;
...@@ -477,7 +477,7 @@ bool KoPatternBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF & ...@@ -477,7 +477,7 @@ bool KoPatternBackground::loadStyle(KoOdfLoadingContext &context, const QSizeF &
QRectF KoPatternBackground::patternRectFromFillSize(const QSizeF &size) QRectF KoPatternBackground::patternRectFromFillSize(const QSizeF &size)
{ {
Q_D(KoPatternBackground); SHARED_D(KoPatternBackground);
QRectF rect; QRectF rect;
switch (d->repeat) { switch (d->repeat) {
......
...@@ -121,7 +121,7 @@ public: ...@@ -121,7 +121,7 @@ public:
/// Returns the bounding rect of the pattern image based on the given fill size /// Returns the bounding rect of the pattern image based on the given fill size
QRectF patternRectFromFillSize(const QSizeF &size); QRectF patternRectFromFillSize(const QSizeF &size);
private: private:
Q_DECLARE_PRIVATE(KoPatternBackground) // Q_DECLARE_PRIVATE(KoPatternBackground)
Q_DISABLE_COPY(KoPatternBackground) Q_DISABLE_COPY(KoPatternBackground)
}; };
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "kritaflake_export.h" #include "kritaflake_export.h"
#include <QtGlobal> #include <QtGlobal>
#include <QSharedDataPointer>
class QSizeF; class QSizeF;
class QPainter; class QPainter;
...@@ -34,6 +35,9 @@ class KoShapeBackgroundPrivate; ...@@ -34,6 +35,9 @@ class KoShapeBackgroundPrivate;
class KoShapePaintingContext; class KoShapePaintingContext;
class KoViewConverter; class KoViewConverter;
#define CONST_SHARED_D(Class) const Class##Private *d = dynamic_cast<const Class##Private *>(d_ptr.constData())
#define SHARED_D(Class) Class##Private *d = dynamic_cast<Class##Private *>(d_ptr.data())
/** /**
* This is the base class for shape backgrounds. * This is the base class for shape backgrounds.
* Derived classes are used to paint the background of * Derived classes are used to paint the background of
...@@ -63,11 +67,13 @@ public: ...@@ -63,11 +67,13 @@ public:
/// load background from odf styles /// load background from odf styles
virtual bool loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize) = 0; virtual bool loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize) = 0;
virtual explicit operator bool() const { return true; }
protected: protected:
KoShapeBackground(KoShapeBackgroundPrivate &); KoShapeBackground(KoShapeBackgroundPrivate &);
KoShapeBackgroundPrivate *d_ptr; QSharedDataPointer<KoShapeBackgroundPrivate> d_ptr;
private: private:
Q_DECLARE_PRIVATE(KoShapeBackground) // Q_DECLARE_PRIVATE(KoShapeBackground)
}; };
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#ifndef KoShapeBackgroundPrivate_H #ifndef KoShapeBackgroundPrivate_H
#define KoShapeBackgroundPrivate_H #define KoShapeBackgroundPrivate_H
class KoShapeBackgroundPrivate #include <QSharedData>
class KoShapeBackgroundPrivate : public QSharedData
{ {
public: public:
KoShapeBackgroundPrivate(); KoShapeBackgroundPrivate();
......
...@@ -65,55 +65,55 @@ bool KoVectorPatternBackground::compareTo(const KoShapeBackground *other) const ...@@ -65,55 +65,55 @@ bool KoVectorPatternBackground::compareTo(const KoShapeBackground *other) const
void KoVectorPatternBackground::setReferenceCoordinates(KoFlake::CoordinateSystem value) void KoVectorPatternBackground::setReferenceCoordinates(KoFlake::CoordinateSystem value)