[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra] words/part: Place images (imageshapes) correctly when
From: Silvio Heinrich <plassy () web ! de>
Date: 2012-01-10 15:56:38
Message-ID: 20120110155638.ECD4CA60A9 () git ! kde ! org
[Download RAW message or body]
Git commit 81eba50f1c6200837f54e6c53972f4a0ebd3ca7f by Silvio Heinrich.
Committed on 10/01/2012 at 12:21.
Pushed by heinrich into branch 'master'.
Place images (imageshapes) correctly when they get inserted by the user.
M +6 -23 words/part/KWView.cpp
http://commits.kde.org/calligra/81eba50f1c6200837f54e6c53972f4a0ebd3ca7f
diff --git a/words/part/KWView.cpp b/words/part/KWView.cpp
index 78ed848..bcbd2ed 100644
--- a/words/part/KWView.cpp
+++ b/words/part/KWView.cpp
@@ -1058,34 +1058,18 @@ void KWView::addImages(const QList<QImage> &imageList, const \
QPoint &insertAt) return;
}
- QPointF pos(0, 0);
-
- /* TODO: find out how to convert the position correctly
- // get position from event and convert to document coordinates
- QPointF pos = m_canvas->viewConverter()->viewToDocument(insertAt) +
- m_canvas->documentOffset() - m_canvas->documentOrigin();
- //*/
-
+ QPointF pos = viewConverter()->viewToDocument(m_canvas->documentOffset() + \
insertAt - KWView::pos()); + pos.setX(qMax(qreal(0), pos.x()));
+ pos.setY(qMax(qreal(0), pos.y()));
+
// create a factory
KoShapeFactoryBase *factory = \
KoShapeRegistry::instance()->value("PictureShape");
-
+
if (!factory) {
kWarning(30003) << "No picture shape found, cannot drop images.";
return;
}
- // get the textshape at this point
- QList<KoShape*> possibleTextShapes = \
canvasBase()->shapeManager()->shapesAt(QRectF(pos.x() - 10, pos.y() \
-10, 20, 20));
- KoTextShapeData *textShapeData = 0;
-
- foreach (KoShape* shape, possibleTextShapes) {
- KoShapeUserData *userData = shape->userData();
- if ((textShapeData = dynamic_cast<KoTextShapeData*>(userData))) {
- // We've found the top-level text shape.
- break;
- }
- }
-
foreach(const QImage image, imageList) {
KoProperties params;
params.setProperty("qimage", image);
@@ -1110,8 +1094,7 @@ void KWView::addImages(const QList<QImage> &imageList, const \
QPoint &insertAt)
shape->setTextRunAroundSide(KoShape::BothRunAroundSide);
- //QTextDocument *qdoc = textShapeData ? textShapeData->document() : 0;
- KoTextAnchor *anchor = new KoTextAnchor(shape);
+ KoTextAnchor *anchor = new KoTextAnchor(shape);
anchor->setAnchorType(KoTextAnchor::AnchorPage);
anchor->setHorizontalPos(KoTextAnchor::HFromLeft);
anchor->setVerticalPos(KoTextAnchor::VFromTop);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic