Code

still WIP. added tree-descending code
authorishmal <ishmal@users.sourceforge.net>
Wed, 12 Apr 2006 21:17:50 +0000 (21:17 +0000)
committerishmal <ishmal@users.sourceforge.net>
Wed, 12 Apr 2006 21:17:50 +0000 (21:17 +0000)
src/extension/internal/odf.cpp
src/extension/internal/odf.h

index 97e58600d93f3b8c096feea594aafe7382896f10..37f26966c774e307b9382dfe6c079723275237df 100644 (file)
@@ -182,21 +182,26 @@ void OdfOutput::po(char *str)
 
 
 
+
+
 /**
- * Make sure that we are in the database
+ * This function searches the Repr tree recursively from the given node,
+ * and adds refs to all nodes with the given name, to the result vector
  */
-bool
-OdfOutput::check (Inkscape::Extension::Extension *module)
+static void
+findElementsByTagName(std::vector<Inkscape::XML::Node *> &results,
+                      Inkscape::XML::Node *node,
+                      char const *name)
 {
-    /* We don't need a Key
-    if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_POV))
-        return FALSE;
-    */
-
-    return TRUE;
-}
+    if ( !name || strcmp(node->name(), name) == 0 )
+        {
+        results.push_back(node);
+        }
 
+    for (Inkscape::XML::Node *child = node->firstChild() ; child ; child = child->next())
+        findElementsByTagName( results, child, name );
 
+}
 
 /**
  * This function searches the Repr tree recursively from the given node,
@@ -320,28 +325,32 @@ OdfOutput::preprocess(SPDocument *doc)
 }
 
 
-
-
-/**
- * This function searches the Repr tree recursively from the given node,
- * and adds refs to all nodes with the given name, to the result vector
- */
-static void
-findElementsByTagName(std::vector<Inkscape::XML::Node *> &results,
-                      Inkscape::XML::Node *node,
-                      char const *name)
+bool OdfOutput::writeTree(Inkscape::XML::Node *node)
 {
-    if ( !name || strcmp(node->name(), name) == 0 )
+    //# Get the SPItem, if applicable
+    SPObject *reprobj = SP_ACTIVE_DOCUMENT->getObjectByRepr(node);
+    if (!reprobj)
+        return true;
+    if (!SP_IS_ITEM(reprobj))
         {
-        results.push_back(node);
+        return true;
         }
+    SPItem *item = SP_ITEM(reprobj);
 
-    for (Inkscape::XML::Node *child = node->firstChild() ; child ; child = child->next())
-        findElementsByTagName( results, child, name );
+    //# Do our stuff
 
+
+    //# Iterate through the children
+    for (Inkscape::XML::Node *child = node->firstChild() ; child ; child = child->next())
+        {
+        if (!writeTree(child))
+            return false;
+        }
+    return true;
 }
 
 
+
 /**
  * Descends into the SVG tree, mapping things to ODF when appropriate
  */
@@ -371,13 +380,27 @@ OdfOutput::init()
             "<output>\n"
                 "<extension>.odg</extension>\n"
                 "<mimetype>text/x-povray-script</mimetype>\n"
-                "<filetypename>" N_("OpenDocument drawing (*.odg)(placeholder)") "</filetypename>\n"
+                "<filetypename>" N_("OpenDocument drawing (*.odg)") "</filetypename>\n"
                 "<filetypetooltip>" N_("OpenDocument drawing file") "</filetypetooltip>\n"
             "</output>\n"
         "</inkscape-extension>",
         new OdfOutput());
 }
 
+/**
+ * Make sure that we are in the database
+ */
+bool
+OdfOutput::check (Inkscape::Extension::Extension *module)
+{
+    /* We don't need a Key
+    if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_POV))
+        return FALSE;
+    */
+
+    return TRUE;
+}
+
 //########################################################################
 //# I N P U T
 //########################################################################
index 7a2b1bd3227f4a15332d8a2eafa6cf05be40888c..4d4421b6b01fc681f1f4e36fc494215c6e722be2 100644 (file)
@@ -73,6 +73,7 @@ private:
 
     void preprocess(SPDocument *doc);
     void preprocess(Inkscape::XML::Node *node);
+    bool writeTree(Inkscape::XML::Node *node);
 
     void po(char *str);
     org::w3c::dom::io::StringOutputStream outs;