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

List:       kde-commits
Subject:    koffice/libs
From:       Thomas Zander <zander () kde ! org>
Date:       2010-07-17 15:18:48
Message-ID: 20100717151848.D1B05AC76A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1151040 by zander:

Implement textOnShape loading

This code is functional but might be slower than needed since we
check for the presence of "text:p" for all objects.
So a TODO is to move the call to load to the path shapes instead.
Just wanted to commit this before my holidays so we have the
functionality in place.

BUG:239704
BUG:239365
BUG:184546

 M  +12 -3     flake/KoShapeRegistry.cpp  
 M  +7 -2      flake/KoTextOnShapeContainer.cpp  
 M  +7 -0      flake/KoTextShapeDataBase.h  
 M  +9 -1      kotext/KoTextShapeData.h  


--- trunk/koffice/libs/flake/KoShapeRegistry.cpp #1151039:1151040
@@ -23,6 +23,7 @@
 #include "KoPathShapeFactory.h"
 #include "KoConnectionShapeFactory.h"
 #include "KoShapeLoadingContext.h"
+#include "KoTextOnShapeContainer.h"
 #include "KoShapeSavingContext.h"
 #include "KoShapeGroup.h"
 
@@ -208,10 +209,8 @@
 
     // Higher numbers are more specific, map is sorted by keys
     for (int i = factories.size() - 1; i >= 0; --i) {
-
         KoShapeFactoryBase * factory = factories[i];
         if (factory->supports(element)) {
-
             KoShape *shape = \
factory->createDefaultShape(context.documentResourceManager());  
             if (shape->shapeId().isEmpty())
@@ -221,8 +220,18 @@
             bool loaded = shape->loadOdf(fullElement, context);
             context.odfLoadingContext().styleStack().restore();
 
-            if (loaded)
+            if (loaded) {
+                KoXmlElement text = KoXml::namedItemNS(fullElement, KoXmlNS::text, \
"p"); +                if (!text.isNull()) {
+                    KoTextOnShapeContainer *tos = new KoTextOnShapeContainer(shape,
+                            context.documentResourceManager());
+                    if (tos->loadOdf(fullElement, context)) {
+                        return tos;
+                    }
+                    delete tos;
+                }
                 return shape;
+            }
 
             // Maybe a shape with a lower priority can load our
             // element, but this attempt has failed.
--- trunk/koffice/libs/flake/KoTextOnShapeContainer.cpp #1151039:1151040
@@ -171,8 +171,13 @@
 
 bool KoTextOnShapeContainer::loadOdf(const KoXmlElement &element, \
KoShapeLoadingContext &context)  {
-    // TODO
-    return false;
+    Q_D(KoTextOnShapeContainer);
+    if (d->textShape == 0)
+        return false; // probably because the factory was not found.
+
+    KoTextShapeDataBase *shapeData = \
qobject_cast<KoTextShapeDataBase*>(d->textShape->userData()); +    \
Q_ASSERT(shapeData); // would be a bug in kotext +    return \
shapeData->loadOdf(element, context);  }
 
 void KoTextOnShapeContainer::saveOdf(KoShapeSavingContext &context) const
--- trunk/koffice/libs/flake/KoTextShapeDataBase.h #1151039:1151040
@@ -27,6 +27,8 @@
 #include <QTextDocument>
 
 class KoTextShapeDataBasePrivate;
+class KoXmlElement;
+class KoShapeLoadingContext;
 
 /**
  * \internal
@@ -54,6 +56,11 @@
      */
     KoInsets shapeMargins() const;
 
+    /**
+    * Load the text from ODF.
+    */
+    virtual bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext \
&context) = 0; +
     /** Sets the vertical alignment of all the text inside the shape. */
     void setVerticalAlignment(Qt::Alignment alignment);
     /** Returns the vertical alignment of all the text in the shape */
--- trunk/koffice/libs/kotext/KoTextShapeData.h #1151039:1151040
@@ -131,9 +131,17 @@
     * @see the @a KoTextLoader::loadBody() method which got called by this method
     * to load the ODF.
     */
-    bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context, \
KoDocumentRdfBase *rdfData = 0, KoShape *shape = 0); +    bool loadOdf(const \
KoXmlElement &element, KoShapeLoadingContext &context, KoDocumentRdfBase *rdfData, \
KoShape *shape = 0);  
     /**
+    * Load the TextShape from ODF.
+    * Overloaded method provided for your convenience.
+    */
+    virtual bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext \
&context) { +        return loadOdf(element, context, 0);
+    }
+
+    /**
     * Store the TextShape data as ODF.
     * @see TextShape::saveOdf()
     */


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

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