Commit 598f1ffa authored by Thomas Zander's avatar Thomas Zander

Provide a roughly working feature for inline objects. Which is (flake) shapes

that get their position defined by an anchor in the text; the character (anchor)
moves, then so does the shape.
This implementation aims to be a lot broader in scope than the one in KOffce1.
We now have horizontal and vertical alignments.  So a shape can always stay
left or right of the paragraph the marker is in.  Or always top or bottom of
frame / paragraph / line.
As well as a specified distance from the anchor-character.

svn path=/trunk/koffice/; revision=651432
parent 87d20d7b
...@@ -121,8 +121,10 @@ public: ...@@ -121,8 +121,10 @@ public:
/** /**
* Update the size of the inline object. * Update the size of the inline object.
* Each time the text is painted, as well as when the paragraph this variable is in, this method * Each time the text is painted, as well as when the paragraph this variable is in, this method
* is called. You should alter the size of the variable if the content has changed. * is called. You should alter the size of the object if the content has changed.
* Altering the size is done by altering the 'object' parameter using QTextInlineObject::setWidth(), * Altering the size is done by altering the 'object' parameter using QTextInlineObject::setWidth(),
* Note that this method is called while painting; and thus is time sensitive; avoid doing anything time
* consuming.
* QTextInlineObject::setAscent() and QTextInlineObject::setDescent() methods. * QTextInlineObject::setAscent() and QTextInlineObject::setDescent() methods.
* @param document the text document this inline object is operating on. * @param document the text document this inline object is operating on.
* @param object the inline object properties * @param object the inline object properties
......
...@@ -57,6 +57,7 @@ kDebug() << "setContainer " << container << endl; ...@@ -57,6 +57,7 @@ kDebug() << "setContainer " << container << endl;
bool first = model == 0; // first time bool first = model == 0; // first time
model = dynamic_cast<KoTextShapeContainerModel*> (container->model()); model = dynamic_cast<KoTextShapeContainerModel*> (container->model());
if(first) { if(first) {
kDebug() << "**** setContainer first time\n";
distance = shape->position(); distance = shape->position();
model->addAnchor(parent); model->addAnchor(parent);
} }
...@@ -113,8 +114,8 @@ kDebug() << "KoTextAnchor::updatePosition " << posInDocument << endl; ...@@ -113,8 +114,8 @@ kDebug() << "KoTextAnchor::updatePosition " << posInDocument << endl;
d->position = posInDocument; d->position = posInDocument;
d->setContainer(dynamic_cast<KoShapeContainer*> (shapeForPosition(document, posInDocument))); d->setContainer(dynamic_cast<KoShapeContainer*> (shapeForPosition(document, posInDocument)));
if(d->model) // if(d->model)
d->model->reposition(d->shape); // d->model->reposition(d->shape);
} }
void KoTextAnchor::resize(const QTextDocument *document, QTextInlineObject object, int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) { void KoTextAnchor::resize(const QTextDocument *document, QTextInlineObject object, int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) {
...@@ -123,9 +124,6 @@ void KoTextAnchor::resize(const QTextDocument *document, QTextInlineObject objec ...@@ -123,9 +124,6 @@ void KoTextAnchor::resize(const QTextDocument *document, QTextInlineObject objec
Q_UNUSED(posInDocument); Q_UNUSED(posInDocument);
Q_UNUSED(format); Q_UNUSED(format);
Q_UNUSED(pd); Q_UNUSED(pd);
if(d->model)
d->model->reposition(d->shape);
} }
void KoTextAnchor::paint (QPainter &painter, QPaintDevice *pd, const QTextDocument *document, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextCharFormat &format) { void KoTextAnchor::paint (QPainter &painter, QPaintDevice *pd, const QTextDocument *document, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextCharFormat &format) {
......
...@@ -166,13 +166,12 @@ protected: ...@@ -166,13 +166,12 @@ protected:
/// make sure we start a layout run /// make sure we start a layout run
virtual void relayout(); virtual void relayout();
private:
/// reimplemented /// reimplemented
void drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int position, const QTextFormat &format); virtual void drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int position, const QTextFormat &format);
/// reimplemented /// reimplemented
void positionInlineObject(QTextInlineObject item, int position, const QTextFormat &format); virtual void positionInlineObject(QTextInlineObject item, int position, const QTextFormat &format);
/// reimplemented /// reimplemented
void resizeInlineObject(QTextInlineObject item, int position, const QTextFormat &format); virtual void resizeInlineObject(QTextInlineObject item, int position, const QTextFormat &format);
private: private:
Q_PRIVATE_SLOT(d, void relayoutPrivate()) Q_PRIVATE_SLOT(d, void relayoutPrivate())
......
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