From 82e21ba48b3bef514f856748d1ca20178b146be8 Mon Sep 17 00:00:00 2001 From: ishmal Date: Wed, 12 Apr 2006 21:17:50 +0000 Subject: [PATCH] still WIP. added tree-descending code --- src/extension/internal/odf.cpp | 73 ++++++++++++++++++++++------------ src/extension/internal/odf.h | 1 + 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 97e58600d..37f26966c 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -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 &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 &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() "\n" ".odg\n" "text/x-povray-script\n" - "" N_("OpenDocument drawing (*.odg)(placeholder)") "\n" + "" N_("OpenDocument drawing (*.odg)") "\n" "" N_("OpenDocument drawing file") "\n" "\n" "", 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 //######################################################################## diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h index 7a2b1bd32..4d4421b6b 100644 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@ -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; -- 2.30.2