From kde-commits Tue Sep 01 11:50:59 2009 From: Thomas Zander Date: Tue, 01 Sep 2009 11:50:59 +0000 To: kde-commits Subject: koffice Message-Id: <1251805859.211702.19044.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=125180587825481 SVN commit 1018169 by zander: Move inserting text to the text shape. CCBUG:205374 Provide a new property in the properties based 'createShape()' method called 'text' which will result in the argument QString to be inserted as text into the initial shape. Note that this will avoid any undo stack or similar. M +4 -6 kpresenter/part/KPrPlaceholderTextStrategy.cpp M +10 -3 plugins/textshape/TextShapeFactory.cpp --- trunk/koffice/kpresenter/part/KPrPlaceholderTextStrategy.cpp #1018168:1018169 @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -159,12 +160,9 @@ { KoShapeFactory *factory = KoShapeRegistry::instance()->value( "TextShapeID" ); Q_ASSERT( factory ); - m_textShape = factory->createDefaultShapeAndInit( dataCenterMap ); - - KoTextShapeData * shapeData = qobject_cast( m_textShape->userData() ); - QTextDocument * document = shapeData->document(); - QTextCursor cursor( document ); - cursor.insertText( text() ); + KoProperties props; + props.setProperty("text", text()); + m_textShape = factory->createShapeAndInit(&props, dataCenterMap); } KoShapeUserData * KPrPlaceholderTextStrategy::userData() const --- trunk/koffice/plugins/textshape/TextShapeFactory.cpp #1018168:1018169 @@ -21,8 +21,6 @@ #include "TextShapeFactory.h" #include "TextShape.h" -#include - #include #include #include @@ -31,6 +29,9 @@ #include #include +#include +#include + TextShapeFactory::TextShapeFactory(QObject *parent) : KoShapeFactory(parent, TextShape_SHAPEID, i18n("Text")), m_inlineTextObjectManager(0) @@ -55,11 +56,17 @@ return text; } -KoShape *TextShapeFactory::createShape(const KoProperties * params) const +KoShape *TextShapeFactory::createShape(const KoProperties *params) const { TextShape *shape = new TextShape(m_inlineTextObjectManager); shape->setSize(QSizeF(300, 200)); shape->setDemoText(params->boolProperty("demo")); + QString text("text"); + if (params->contains(text)) { + KoTextShapeData *shapeData = qobject_cast(shape->userData()); + QTextCursor cursor(shapeData->document()); + cursor.insertText(params->stringProperty(text)); + } return shape; }