Commit 89d3203a authored by Thomas Zander's avatar Thomas Zander

Move applyViewboxTransformation to the private

svn path=/trunk/koffice/; revision=1063864
parent de4075a1
......@@ -49,6 +49,7 @@ KoConnectionShapePrivate::KoConnectionShapePrivate(KoConnectionShape *q)
QPointF KoConnectionShapePrivate::escapeDirection(int handleId) const
{
Q_Q(const KoConnectionShape);
QPointF direction;
if (handleConnected(handleId)) {
QMatrix absoluteMatrix = q->absoluteTransformation(0);
......
......@@ -53,6 +53,8 @@ public:
int connectionPointIndex2;
KoConnectionShape::Type connectionType;
bool forceUpdate;
Q_DECLARE_PUBLIC(KoConnectionShape)
};
#endif
......@@ -55,6 +55,34 @@ QRectF KoPathShapePrivate::handleRect(const QPointF &p, qreal radius) const
return QRectF(p.x() - radius, p.y() - radius, 2*radius, 2*radius);
}
void KoPathShapePrivate::applyViewboxTransformation(const KoXmlElement &element)
{
Q_Q(KoPathShape);
// apply viewbox transformation
QRectF viewBox = q->loadOdfViewbox(element);
if (! viewBox.isEmpty()) {
// load the desired size
QSizeF size;
size.setWidth(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "width", QString())));
size.setHeight(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "height", QString())));
// load the desired position
QPointF pos;
pos.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x", QString())));
pos.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y", QString())));
// create matrix to transform original path data into desired size and position
QMatrix viewMatrix;
viewMatrix.translate(-viewBox.left(), -viewBox.top());
viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
viewMatrix.translate(pos.x(), pos.y());
// transform the path data
q->map(viewMatrix);
}
}
/////////////////////////
KoPathShape::KoPathShape()
:KoShape(*(new KoPathShapePrivate(this)))
......@@ -85,6 +113,7 @@ void KoPathShape::saveOdf(KoShapeSavingContext & context) const
bool KoPathShape::loadOdf(const KoXmlElement & element, KoShapeLoadingContext &context)
{
Q_D(KoPathShape);
loadOdfAttributes(element, context, OdfMandatories | OdfAdditionalAttributes | OdfCommonChildElements);
// first clear the path data from the default path
......@@ -125,7 +154,7 @@ bool KoPathShape::loadOdf(const KoXmlElement & element, KoShapeLoadingContext &c
loadNodeTypes(element);
}
applyViewboxTransformation(element);
d->applyViewboxTransformation(element);
QPointF pos = normalize();
setTransformation(QMatrix());
......@@ -189,32 +218,6 @@ QRectF KoPathShape::loadOdfViewbox(const KoXmlElement & element) const
return viewbox;
}
void KoPathShape::applyViewboxTransformation(const KoXmlElement & element)
{
// apply viewbox transformation
QRectF viewBox = loadOdfViewbox(element);
if (! viewBox.isEmpty()) {
// load the desired size
QSizeF size;
size.setWidth(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "width", QString())));
size.setHeight(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "height", QString())));
// load the desired position
QPointF pos;
pos.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x", QString())));
pos.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y", QString())));
// create matrix to transform original path data into desired size and position
QMatrix viewMatrix;
viewMatrix.translate(-viewBox.left(), -viewBox.top());
viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
viewMatrix.translate(pos.x(), pos.y());
// transform the path data
map(viewMatrix);
}
}
void KoPathShape::clear()
{
foreach(KoSubpath *subpath, m_subpaths) {
......
......@@ -489,8 +489,6 @@ protected:
/// Returns the viewbox from the given xml element.
QRectF loadOdfViewbox(const KoXmlElement &element) const;
/// Applies the viewbox transformation defined in the given element
void applyViewboxTransformation(const KoXmlElement &element);
/**
* @brief Saves the node types
......
......@@ -27,8 +27,12 @@ public:
KoPathShapePrivate(KoPathShape *q);
QRectF handleRect(const QPointF &p, qreal radius) const;
/// Applies the viewbox transformation defined in the given element
void applyViewboxTransformation(const KoXmlElement &element);
Qt::FillRule fillRule;
Q_DECLARE_PUBLIC(KoPathShape)
};
#endif
......@@ -76,7 +76,7 @@ KoShapePrivate::KoShapePrivate(KoShape *shape)
appData(0),
fill(0),
border(0),
q(shape),
q_ptr(shape),
shadow(0),
filterEffectStack(0),
transparency(0.0),
......@@ -97,6 +97,7 @@ KoShapePrivate::KoShapePrivate(KoShape *shape)
KoShapePrivate::~KoShapePrivate()
{
Q_Q(KoShape);
if (parent)
parent->removeChild(q);
foreach(KoShapeManager *manager, shapeManagers) {
......@@ -118,6 +119,7 @@ KoShapePrivate::~KoShapePrivate()
void KoShapePrivate::shapeChanged(KoShape::ChangeType type)
{
Q_Q(KoShape);
if (parent)
parent->model()->childChanged(q, type);
q->shapeChanged(type);
......@@ -127,6 +129,7 @@ void KoShapePrivate::shapeChanged(KoShape::ChangeType type)
void KoShapePrivate::updateBorder()
{
Q_Q(KoShape);
if (border == 0)
return;
KoInsets insets;
......
......@@ -35,7 +35,6 @@ public:
void addShapeManager(KoShapeManager *manager);
void removeShapeManager(KoShapeManager *manager);
/// calls update on the shape where the border is.
void updateBorder();
......@@ -53,7 +52,7 @@ public:
KoShapeApplicationData *appData;
KoShapeBackground * fill; ///< Stands for the background color / fill etc.
KoShapeBorderModel *border; ///< points to a border, or 0 if there is no border
KoShape *q;
KoShape *q_ptr;
QList<KoShape*> dependees; ///< list of shape dependent on this shape
KoShapeShadow * shadow; ///< the current shape shadow
QMap<QByteArray, QString> additionalAttributes;
......@@ -61,7 +60,7 @@ public:
QList<KoEventAction *> eventActions; ///< list of event actions the shape has
KoFilterEffectStack *filterEffectStack; ///< stack of filter effects applied to the shape
qreal transparency; ///< the shapes tranparency
static const int MaxZIndex = 32767;
int zIndex : 16; // keep maxZIndex in sync!
int visible : 1;
......@@ -71,6 +70,8 @@ public:
int selectable : 1;
int detectCollision : 1;
int protectContent : 1;
Q_DECLARE_PUBLIC(KoShape)
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment