ShrinkToFitShapeContainer::ShrinkToFitShapeContainer(KoShape *childShape, KoDocumentResourceManager *documentResources) : KoShapeContainer(*(new ShrinkToFitShapeContainerPrivate(this, childShape))) { Q_UNUSED(documentResources); Q_D(ShrinkToFitShapeContainer); setPosition(childShape->position()); setSize(childShape->size()); setZIndex(childShape->zIndex()); setRunThrough(childShape->runThrough()); rotate(childShape->rotation()); //setTransformation(childShape->transformation()); if (childShape->parent()) { childShape->parent()->addShape(this); childShape->setParent(0); } childShape->setPosition(QPointF(0.0,0.0)); // since its relative to my position, this won't move it childShape->setSelectable(false); // our ShrinkToFitShapeContainer will handle that from now on d->model = new ShrinkToFitShapeContainerModel(this, d); addShape(childShape); QSet<KoShape*> delegates; delegates << childShape; setToolDelegates(delegates); KoTextShapeData* data = dynamic_cast<KoTextShapeData*>(childShape->userData()); Q_ASSERT(data); KoTextDocumentLayout *lay = qobject_cast<KoTextDocumentLayout*>(data->document()->documentLayout()); Q_ASSERT(lay); QObject::connect(lay, SIGNAL(finishedLayout()), static_cast<ShrinkToFitShapeContainerModel*>(d->model), SLOT(finishedLayout())); }
/// KoTextOnShapeContainer KoTextOnShapeContainer::KoTextOnShapeContainer(KoShape *childShape, KoResourceManager *documentResources) : KoShapeContainer(*(new KoTextOnShapeContainerPrivate(this))) { Q_D(KoTextOnShapeContainer); Q_ASSERT(childShape); d->content = childShape; setSize(childShape->size()); setZIndex(childShape->zIndex()); setTransformation(childShape->transformation()); if (childShape->parent()) { childShape->parent()->addShape(this); childShape->setParent(0); } childShape->setPosition(QPointF()); // since its relative to my position, this won't move it childShape->setSelectable(false); d->model = new KoTextOnShapeContainerModel(this, d); addShape(childShape); QSet<KoShape*> delegates; delegates << childShape; KoShapeFactoryBase *factory = KoShapeRegistry::instance()->get("TextShapeID"); if (factory) { // not installed, thats too bad, but allowed d->textShape = factory->createDefaultShape(documentResources); Q_ASSERT(d->textShape); // would be a bug in the text shape; if (d->resizeBehavior == TextFollowsPreferredTextRect) { d->textShape->setSize(d->preferredTextRect.size()); } else { d->textShape->setSize(size()); } d->textShape->setTransformation(childShape->transformation()); if (d->resizeBehavior == TextFollowsPreferredTextRect) { d->textShape->setPosition(d->preferredTextRect.topLeft()); } KoTextShapeDataBase *shapeData = qobject_cast<KoTextShapeDataBase*>(d->textShape->userData()); Q_ASSERT(shapeData); // would be a bug in kotext shapeData->setVerticalAlignment(Qt::AlignVCenter); addShape(d->textShape); d->textShape->setZIndex(childShape->zIndex() + 1); d->textShape->setSelectable(false); delegates << d->textShape; } else { kWarning(30006) << "Text shape factory not found"; } static_cast<KoTextOnShapeContainerModel*>(d->model)->lock = false; setToolDelegates(delegates); }
KWCopyShape::KWCopyShape(KoShape *original, const KWPageManager *pageManager) : KoShape() ,m_original(original) ,m_pageManager(pageManager) { setSize(m_original->size()); setSelectable(original->isSelectable()); // allow selecting me to get the tool for the original to still work. QSet<KoShape*> delegates; delegates << m_original; setToolDelegates(delegates); kDebug(32001) << "originalShape=" << m_original; }
void ShrinkToFitShapeContainer::unwrapShape(KoShape *shape) { Q_ASSERT(shape->parent() == this); removeShape(shape); shape->setParent(parent()); QSet<KoShape*> delegates = toolDelegates(); delegates.remove(shape); setToolDelegates(delegates); shape->setPosition(position()); shape->setSize(size()); shape->rotate(rotation()); shape->setSelectable(true); }
KoShape *KoTosContainer::createTextShape(KoDocumentResourceManager *documentResources) { if (!documentResources) { warnFlake << "KoDocumentResourceManager not found"; return 0; } Q_D(KoTosContainer); delete textShape(); delete d->model; d->model = new KoTosContainerModel(); QSet<KoShape*> delegates; delegates << this; KoShape *textShape = 0; KoShapeFactoryBase *factory = KoShapeRegistry::instance()->get("TextShapeID"); if (factory) { // not installed, thats too bad, but allowed textShape = factory->createDefaultShape(documentResources); Q_ASSERT(textShape); // would be a bug in the text shape; if (d->resizeBehavior == TextFollowsPreferredTextRect) { textShape->setSize(d->preferredTextRect.size()); } else { textShape->setSize(size()); } if (d->resizeBehavior == TextFollowsPreferredTextRect) { textShape->setPosition(d->preferredTextRect.topLeft()); } else { textShape->setPosition(QPointF(0, 0)); } textShape->setSelectable(false); textShape->setRunThrough(runThrough()); KoTextShapeDataBase *shapeData = qobject_cast<KoTextShapeDataBase*>(textShape->userData()); Q_ASSERT(shapeData); // would be a bug in kotext // TODO check if that is correct depending on the resize mode shapeData->setVerticalAlignment(Qt::AlignVCenter); addShape(textShape); // textShape->setZIndex(zIndex() + 1); // not needed as there as the text shape is the only sub shape delegates << textShape; } else { warnFlake << "Text shape factory not found"; } setToolDelegates(delegates); return textShape; }