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

List:       koffice-devel
Subject:    koffice
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2008-10-19 12:21:22
Message-ID: 1224418882.131859.1584.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 873389 by zachmann:

o remove  the following functions as we now use only the dataCenterMap

When shapes are created always the dataCenterMap of the document should
be passed to the create(Default)?ShapeAndInit function. Otherwise some
shapes will not work correctly. So please have a look at your code and
see how that can be fixed. For now I pass an empty dataCenterMap.

CCMAIL: koffice-devel@kde.org


 M  +3 -1      kexi/plugins/reportspgz/backend/wrtembed/reportentityshape.cpp  
 M  +3 -2      kpresenter/part/KPrEndOfSlideShowPage.cpp  
 M  +2 -2      kpresenter/part/KPrNotes.cpp  
 M  +3 -1      krita/plugins/tools/selectiontools/kis_tool_select_elliptical.cc  
 M  +3 -1      krita/plugins/tools/selectiontools/kis_tool_select_rectangular.cc  
 M  +4 -0      kspread/Sheet.cpp  
 M  +1 -1      kword/part/KWDLoader.cpp  
 M  +2 -2      kword/part/KWOdfLoader.cpp  
 M  +1 -1      kword/part/frames/KWFrameLayout.cpp  
 M  +3 -1      kword/plugins/scripting/FrameSet.h  
 M  +0 -19     libs/flake/KoShapeFactory.cpp  
 M  +0 -42     libs/flake/KoShapeFactory.h  
 M  +6 -4      libs/flake/tests/TestKoShapeFactory.cpp  
 M  +4 -1      plugins/tableshape/TableCell.cpp  


--- trunk/koffice/kexi/plugins/reportspgz/backend/wrtembed/reportentityshape.cpp \
#873388:873389 @@ -88,7 +88,9 @@
     QList<KoShape*> shapes;
     painter->setRenderHint(QPainter::Antialiasing);
 
-    mShape = (KoShape*)(KoShapeRegistry::instance()->value(_shapeType->value().toString()))->createDefaultShapeAndInit(0);
 +    // TODO check if it is ok to pass an empty map. The image shape might not work
+    QMap<QString, KoDataCenter *> dataCenterMap;
+    mShape = (KoShape*)(KoShapeRegistry::instance()->value(_shapeType->value().toString()))->createDefaultShapeAndInit(dataCenterMap);
  mShape->setSize(_size.toScene());
     shapes << mShape;
 
--- trunk/koffice/kpresenter/part/KPrEndOfSlideShowPage.cpp #873388:873389
@@ -56,8 +56,9 @@
     KoShapeFactory *factory = KoShapeRegistry::instance()->value( "TextShapeID" );
     Q_ASSERT( factory );
     if ( factory ) {
-        // as this is never saved 0 is ok here
-        KoShape * textShape = factory->createDefaultShapeAndInit( 0 );
+        // as this is never saved an empty map is ok here
+        QMap<QString, KoDataCenter *> dataCenterMap;
+        KoShape * textShape = factory->createDefaultShapeAndInit( dataCenterMap );
         QTextDocument * document = qobject_cast<KoTextShapeData*>( \
textShape->userData() )->document();  QTextCursor cursor( document );
         QTextCharFormat format;
--- trunk/koffice/kpresenter/part/KPrNotes.cpp #873388:873389
@@ -67,7 +67,7 @@
     // All sizes and positions are hardcoded for now
     KoShapeFactory *factory = KoShapeRegistry::instance()->value("TextShapeID");
     Q_ASSERT(factory);
-    m_textShape = factory->createDefaultShapeAndInit( document );
+    m_textShape = factory->createDefaultShapeAndInit( document->dataCenterMap() );
     m_textShape->setLocked(true);
     m_textShape->setAdditionalAttribute( "presentation:class", "notes" );
     m_pageLayout = KoPageLayout::standardLayout();
@@ -76,7 +76,7 @@
 
     factory = KoShapeRegistry::instance()->value("PictureShape");
     Q_ASSERT(factory);
-    m_thumbnailShape = factory->createDefaultShapeAndInit( document );
+    m_thumbnailShape = factory->createDefaultShapeAndInit( document->dataCenterMap() \
);  m_thumbnailShape->setLocked(true);
     m_thumbnailShape->setAdditionalAttribute( "presentation:class", "page" );
     m_thumbnailShape->setPosition(QPointF(108.00, 60.18));
--- trunk/koffice/krita/plugins/tools/selectiontools/kis_tool_select_elliptical.cc \
#873388:873389 @@ -189,7 +189,9 @@
                 KoShape* shape;
                 KoShapeFactory *rectFactory = \
KoShapeRegistry::instance()->value("KoEllipseShape");  if (rectFactory) {
-                    shape = rectFactory->createDefaultShapeAndInit(0);
+                    // it is ok to use a empty map here as the data is not needed.
+                    QMap<QString, KoDataCenter *> dataCenterMap;
+                    shape = rectFactory->createDefaultShapeAndInit(dataCenterMap);
                     shape->setSize(documentRect.size());
                     shape->setPosition(documentRect.topLeft());
                 } else {
--- trunk/koffice/krita/plugins/tools/selectiontools/kis_tool_select_rectangular.cc \
#873388:873389 @@ -203,7 +203,9 @@
             KoShape* shape;
             KoShapeFactory *rectFactory = \
KoShapeRegistry::instance()->value("KoRectangleShape");  if (rectFactory) {
-                shape = rectFactory->createDefaultShapeAndInit(0);
+                // it is ok to use a empty map here as the data is not needed.
+                QMap<QString, KoDataCenter *> dataCenterMap;
+                shape = rectFactory->createDefaultShapeAndInit(dataCenterMap);
                 shape->setSize(documentRect.size());
                 shape->setPosition(documentRect.topLeft());
             } else {
--- trunk/koffice/kspread/Sheet.cpp #873388:873389
@@ -270,6 +270,9 @@
     d->columns = other.d->columns;
 
     // flake
+#if 0
+    //FIXME This does not work as copySettings does not work. Also \
createDefaultShapeAndInit without the correct settings can not work +    //I think \
this should use saveOdf and loadOdf for copying    KoShape* shape;
     const QList<KoShape*> shapes = other.d->shapes;
     for (int i = 0; i < shapes.count(); ++i)
@@ -278,6 +281,7 @@
         shape->copySettings(shapes[i]);
         addShape(shape);
     }
+#endif
 
     d->print = new SheetPrint(this); // FIXME = new SheetPrint(*other.d->print);
 
--- trunk/koffice/kword/part/KWDLoader.cpp #873388:873389
@@ -561,7 +561,7 @@
         if (frameElem.tagName() == "FRAME") {
             KoShapeFactory *factory = \
KoShapeRegistry::instance()->value(TextShape_SHAPEID);  Q_ASSERT(factory);
-            KoShape *shape = factory->createDefaultShapeAndInit(m_document);
+            KoShape *shape = \
factory->createDefaultShapeAndInit(m_document->dataCenterMap());  KWTextFrame *frame \
= new KWTextFrame(shape, fs);  fill(frame, frameElem);
 
--- trunk/koffice/kword/part/KWOdfLoader.cpp #873388:873389
@@ -218,7 +218,7 @@
     KoShapeFactory *factory = KoShapeRegistry::instance()->value(TextShape_SHAPEID);
     Q_ASSERT(factory);
     // Create a TextShape
-    KoShape *shape = factory->createDefaultShapeAndInit(d->document);
+    KoShape *shape = \
factory->createDefaultShapeAndInit(d->document->dataCenterMap());  Q_ASSERT(shape);
     // The TextShape will be displayed within a KWTextFrame
     KWTextFrame *frame = new KWTextFrame(shape, fs);
@@ -324,7 +324,7 @@
     // Add the frameset and the shape for the header/footer to the document.
     KoShapeFactory *sf = KoShapeRegistry::instance()->value(TextShape_SHAPEID);
     Q_ASSERT(sf);
-    KoShape *s = sf->createDefaultShapeAndInit(document);
+    KoShape *s = sf->createDefaultShapeAndInit(document->dataCenterMap());
     Q_ASSERT(s);
     KWTextFrame *f = new KWTextFrame(s, fs);
     document->addFrameSet(fs);
--- trunk/koffice/kword/part/frames/KWFrameLayout.cpp #873388:873389
@@ -499,7 +499,7 @@
     Q_ASSERT(page.isValid());
     KoShapeFactory *factory = KoShapeRegistry::instance()->value(TextShape_SHAPEID);
     Q_ASSERT(factory);
-    KoShape *shape = factory->createDefaultShapeAndInit(m_document);
+    KoShape *shape = \
factory->createDefaultShapeAndInit(m_document->dataCenterMap());  \
shape->setPosition(QPointF(0, page.offsetInDocument()));  return shape;
 }
--- trunk/koffice/kword/plugins/scripting/FrameSet.h #873388:873389
@@ -103,7 +103,9 @@
             kWarning(32010) << "Scripting::Module::addFrame() Invalid shapeId: " << \
shapeId << endl;  return 0;
         }
-        KoShape *shape = factory->createDefaultShapeAndInit(0);
+        // FIXME check if it is ok to pass an empty map. The shape might not work \
and crash the program +        QMap<QString, KoDataCenter *> dataCenterMap;
+        KoShape *shape = factory->createDefaultShapeAndInit( dataCenterMap );
         Q_ASSERT(shape);
         shape->setZIndex(100 + m_frameset->frameCount());
         KWFrame* frame = 0;
--- trunk/koffice/libs/flake/KoShapeFactory.cpp #873388:873389
@@ -23,7 +23,6 @@
 #include "KoShapeFactory.h"
 #include "KoShape.h"
 #include <KoProperties.h>
-#include "KoShapeControllerBase.h"
 
 #include <kdebug.h>
 
@@ -67,15 +66,6 @@
     delete d;
 }
 
-KoShape * KoShapeFactory::createDefaultShapeAndInit(const KoShapeControllerBase * \
                shapeController) const
-{
-    KoShape * shape = createDefaultShape();
-    if (shape && shapeController) {
-        shape->init(shapeController->dataCenterMap());
-    }
-    return shape;
-}
-
 KoShape * KoShapeFactory::createDefaultShapeAndInit(const QMap<QString, KoDataCenter \
*> & dataCenterMap) const  {
     KoShape * shape = createDefaultShape();
@@ -83,15 +73,6 @@
     return shape;
 }
 
-KoShape * KoShapeFactory::createShapeAndInit(const KoProperties * params, const \
                KoShapeControllerBase *shapeController) const
-{
-    KoShape * shape = createShape(params);
-    if (shape && shapeController) {
-        shape->init(shapeController->dataCenterMap());
-    }
-    return shape;
-}
-
 KoShape * KoShapeFactory::createShapeAndInit(const KoProperties * params, const \
QMap<QString, KoDataCenter *> & dataCenterMap) const  {
     KoShape * shape = createShape(params);
--- trunk/koffice/libs/flake/KoShapeFactory.h #873388:873389
@@ -122,54 +122,12 @@
      * @see KoShapeFactory::createDefaultShape
      * @see KoShape::init
      */
-    KoShape * createDefaultShapeAndInit(const KoShapeControllerBase * \
                shapeController) const;
-
-    /**
-     * This method should be called to create a shape that the user gets when doing \
                a base insert.
-     * For example from a script or during loading.
-     *
-     * This function will call init on the shape with the dataCenterMap that was \
                given. You
-     * should make sure to pass the dataCenterMap so that all works as expected.
-     * However in some cases it is ok to not pass the shapeController e.g. when it \
                is only
-     * a temporary shape that will not be inserted in the document. The shape can \
                then set
-     * things that e.g. need to be available during loading of the shape.
-     * This method internally calls createShape( params );
-     *
-     * @param dataCenterMap The dataCenterMap of the document.
-     *
-     * @return a new shape
-     *
-     * @see KoShapeFactory::createDefaultShape
-     * @see KoShape::init
-     */
     KoShape * createDefaultShapeAndInit(const QMap<QString, KoDataCenter *> & \
dataCenterMap) const;  
     /**
      * This method should be called to create a shape based on a set of properties \
                that are
      * specifically made for this shape-type.
      *
-     * This function will call init on the shape with the dataCenterMap of the \
                shapeController
-     * that was given. You should make sure to pass the dataCenterMap so that all \
                works as expected.
-     * However in some cases it is ok to not pass the shapeController e.g. when it \
                is only
-     * a temporary shape that will not be inserted in the document. The shape can \
                then set
-     * things that e.g. need to be available during loading of the shape.
-     * This method internally calls createShape( params );
-     *
-     * @param params The properties to used to create the shape
-     * @param shapeController The shape controller for which the shape is created.
-     *
-     * @return a new shape
-     *
-     * @see KoShapeFactory::createShape
-     * @see KoShapeTemplate::properties
-     * @see KoShape::init
-     */
-    KoShape * createShapeAndInit(const KoProperties * params, const \
                KoShapeControllerBase *shapeController) const;
-
-    /**
-     * This method should be called to create a shape based on a set of properties \
                that are
-     * specifically made for this shape-type.
-     *
      * This function will call init on the shape with the dataCenterMap that was \
                given. You
      * should make sure to pass the dataCenterMap so that all works as expected.
      * However in some cases it is ok to not pass the shapeController e.g. when it \
                is only
--- trunk/koffice/libs/flake/tests/TestKoShapeFactory.cpp #873388:873389
@@ -49,7 +49,8 @@
 void TestKoShapeFactory::testCreateDefaultShape()
 {
     KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
-    KoShape * shape = factory->createDefaultShapeAndInit(0);
+    QMap<QString, KoDataCenter *> dataCenterMap;
+    KoShape * shape = factory->createDefaultShapeAndInit(dataCenterMap);
     QVERIFY(shape != 0);
     delete shape;
     delete factory;
@@ -58,7 +59,8 @@
 void TestKoShapeFactory::testCreateShape()
 {
     KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
-    KoShape * shape = factory->createShapeAndInit(0, 0);
+    QMap<QString, KoDataCenter *> dataCenterMap;
+    KoShape * shape = factory->createShapeAndInit(0, dataCenterMap);
     QVERIFY(shape != 0);
     delete shape;
     delete factory;
@@ -109,14 +111,14 @@
     QVERIFY(pathElement.tagName() == "path");
     QCOMPARE(factory->supports(pathElement), true);
 
-    KoShape * shape = factory->createDefaultShapeAndInit(0);
+    QMap<QString, KoDataCenter *> dataCenterMap;
+    KoShape * shape = factory->createDefaultShapeAndInit(dataCenterMap);
     QVERIFY(shape);
 
     // XXX: When loading is implemented, these no doubt have to be
     // sensibly filled.
     KoOdfStylesReader stylesReader;
     KoOdfLoadingContext odfContext(stylesReader, 0);
-    QMap<QString, KoDataCenter *> dataCenterMap;
     KoShapeLoadingContext shapeContext(odfContext, dataCenterMap);
 
     QVERIFY(shape->loadOdf(pathElement, shapeContext));
--- trunk/koffice/plugins/tableshape/TableCell.cpp #873388:873389
@@ -65,7 +65,10 @@
     KoShapeFactory * factory = KoShapeRegistry::instance()->get(shapeId);
     if (!factory) return 0;
 
-    KoShape * shape = factory->createDefaultShapeAndInit( 0 );
+    Q_ASSERT( 0 );
+    // TODO we need to pass the dataCenterMap of the document here
+    QMap<QString, KoDataCenter *> dataCenterMap;
+    KoShape * shape = factory->createDefaultShapeAndInit( dataCenterMap );
     d->shape = shape;
 
     return d->shape;
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


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

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