[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice
From:       Thomas Zander <zander () kde ! org>
Date:       2009-09-01 11:50:59
Message-ID: 1251805859.211702.19044.nullmailer () svn ! kde ! org
[Download RAW message or body]

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 <QPainter>
 
 #include <KoOdfLoadingContext.h>
+#include <KoProperties.h>
 #include <KoOdfStylesReader.h>
 #include <KoGenStyles.h>
 #include <KoXmlWriter.h>
@@ -159,12 +160,9 @@
 {
     KoShapeFactory *factory = KoShapeRegistry::instance()->value( "TextShapeID" );
     Q_ASSERT( factory );
-    m_textShape = factory->createDefaultShapeAndInit( dataCenterMap );
-
-    KoTextShapeData * shapeData = qobject_cast<KoTextShapeData*>(  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 <klocale.h>
-
 #include <KoProperties.h>
 #include <KoShape.h>
 #include <KoTextShapeData.h>
@@ -31,6 +29,9 @@
 #include <KoInlineTextObjectManager.h>
 #include <changetracker/KoChangeTracker.h>
 
+#include <klocale.h>
+#include <QTextCursor>
+
 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<KoTextShapeData*>(shape->userData());
+        QTextCursor cursor(shapeData->document());
+        cursor.insertText(params->stringProperty(text));
+    }
     return shape;
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic