Commit 35be399f authored by Thorsten Zachmann's avatar Thorsten Zachmann

o make it possible to save shape with an offset to there real position.

  This is e.g. needed for anchored shapes in kword.

svn path=/trunk/koffice/; revision=924996
parent 6f4066e8
......@@ -1085,13 +1085,13 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
// The position is implicitly stored in the transformation matrix
// if the transformation is saved as well
if ((attributes & OdfPosition) && !(attributes & OdfTransformation)) {
const QPointF p(position());
const QPointF p(position() * context.shapeOffset(this));
context.xmlWriter().addAttributePt("svg:x", p.x());
context.xmlWriter().addAttributePt("svg:y", p.y());
}
if (attributes & OdfTransformation) {
QMatrix matrix = absoluteTransformation(0);
QMatrix matrix = absoluteTransformation(0) * context.shapeOffset(this);
if (! matrix.isIdentity()) {
QString m = QString("matrix(%1 %2 %3 %4 %5pt %6pt)")
.arg(matrix.m11()).arg(matrix.m12())
......
......@@ -225,3 +225,18 @@ KoSharedSavingData * KoShapeSavingContext::sharedData(const QString & id) const
}
return data;
}
void KoShapeSavingContext::addShapeOffset(const KoShape * shape, const QMatrix & m)
{
m_shapeOffsets.insert(shape, m);
}
void KoShapeSavingContext::removeShapeOffset(const KoShape * shape)
{
m_shapeOffsets.remove(shape);
}
QMatrix KoShapeSavingContext::shapeOffset(const KoShape * shape) const
{
return m_shapeOffsets.value(shape, QMatrix());
}
......@@ -233,6 +233,32 @@ public:
*/
KoSharedSavingData * sharedData(const QString & id) const;
/**
* Add an offset that will be applied to the shape position when saved
*
* This is needed e.g. for shapes anchored to a text shape as the position is
* saved as offset to the anchor.
*
* @param shape The shape for which the offset should be added.
* @param m The offset which should be applied on saving the position.
*/
void addShapeOffset(const KoShape * shape, const QMatrix & m);
/**
* Remove an offset from the saved offset list
*
* @param shape The shape for which the offset should be removed.
*/
void removeShapeOffset(const KoShape * shape);
/**
* Get the offest that will be applied to the shape position when saved.
*
* @param shape The shape for which the offset should be get.
* @return the saved offset or QMatrix() when offset is not set.
*/
QMatrix shapeOffset(const KoShape * shape) const;
private:
KoXmlWriter *m_xmlWriter;
KoShapeSavingOptions m_savingOptions;
......@@ -244,6 +270,7 @@ private:
QMap<QByteArray, QString> m_imageNames;
int m_imageId;
QMap<QString, QImage> m_images;
QHash<const KoShape *, QMatrix> m_shapeOffsets;
KoGenStyles& m_mainStyles;
KoEmbeddedDocumentSaver& m_embeddedSaver;
......
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