Code

Rearrange to enable code that does not directly rely on lcms.
[inkscape.git] / src / dom / lsimpl.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 67c899f..b3b3f0b
@@ -10,7 +10,7 @@
  * Authors:
  *   Bob Jamison
  *
- * Copyright (C) 2005 Bob Jamison
+ * Copyright (C) 2005-2007 Bob Jamison
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,9 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "domimpl.h"
+#include "events.h"
+#include "traversal.h"
 #include "lsimpl.h"
 
 #include <stdarg.h>
@@ -58,8 +61,8 @@ bool LSParserImpl::getBusy()
 /**
  *
  */
-Document *LSParserImpl::parse(const LSInput &input)
-                            throw(dom::DOMException, LSException)
+DocumentPtr LSParserImpl::parse(const LSInput &input)
+                                throw(dom::DOMException, LSException)
 {
 
     //#### Check the various inputs of 'input' in order, according
@@ -73,10 +76,10 @@ Document *LSParserImpl::parse(const LSInput &input)
             int ch = lsreader->get();
             if (ch < 0)
                 break;
-            buf.push_back(ch);
+            buf.push_back((XMLCh)ch);
             }
         XmlReader reader;
-        Document *doc = reader.parse(buf);
+        DocumentPtr doc = reader.parse(buf);
         return doc;
         }
 
@@ -89,18 +92,18 @@ Document *LSParserImpl::parse(const LSInput &input)
             int ch = inputStream->get();
             if (ch < 0)
                 break;
-            buf.push_back(ch);
+            buf.push_back((XMLCh)ch);
             }
         XmlReader reader;
-        Document *doc = reader.parse(buf);
+        DocumentPtr doc = reader.parse(buf);
         return doc;
         }
 
     DOMString stringData = input.getStringData();
     if (stringData.size() > 0)
         {
-         XmlReader reader;
-        Document *doc = reader.parse(stringData);
+        XmlReader reader;
+        DocumentPtr doc = reader.parse(stringData);
         return doc;
         }
 
@@ -125,8 +128,8 @@ Document *LSParserImpl::parse(const LSInput &input)
 /**
  *
  */
-Document *LSParserImpl::parseURI(const DOMString &uri)
-                               throw(dom::DOMException, LSException)
+DocumentPtr LSParserImpl::parseURI(const DOMString &/*uri*/)
+                                   throw(dom::DOMException, LSException)
 {
     return NULL;
 }
@@ -134,10 +137,10 @@ Document *LSParserImpl::parseURI(const DOMString &uri)
    /**
  *
  */
-Node *LSParserImpl::parseWithContext(const LSInput &input,
-                                   const Node *contextArg,
-                                   unsigned short action)
-                                   throw(dom::DOMException, LSException)
+NodePtr LSParserImpl::parseWithContext(const LSInput &/*input*/,
+                                       const NodePtr /*contextArg*/,
+                                       unsigned short /*action*/)
+                                       throw(dom::DOMException, LSException)
 {
     return NULL;
 }
@@ -167,13 +170,13 @@ Node *LSParserImpl::parseWithContext(const LSInput &input,
  *
  */
 bool LSSerializerImpl::write(
-                       const Node *nodeArg,
+                       const NodePtr nodeArg,
                        const LSOutput &destination)
                        throw (LSException)
 {
     outbuf = "";
     indent = 0;
-    
+
     writeNode(nodeArg);
 
     //## Check in order specified in the L&S specs
@@ -212,7 +215,7 @@ bool LSSerializerImpl::write(
 /**
  *
  */
-bool LSSerializerImpl::writeToURI(const Node *nodeArg,
+bool LSSerializerImpl::writeToURI(const NodePtr nodeArg,
                                   const DOMString &uriArg)
                                   throw(LSException)
 {
@@ -238,7 +241,7 @@ bool LSSerializerImpl::writeToURI(const Node *nodeArg,
 /**
  *
  */
-DOMString LSSerializerImpl::writeToString(const Node *nodeArg)
+DOMString LSSerializerImpl::writeToString(const NodePtr nodeArg)
                                     throw(dom::DOMException, LSException)
 {
     outbuf = "";
@@ -269,7 +272,7 @@ void LSSerializerImpl::spaces()
 /**
  *
  */
-void LSSerializerImpl::po(char *fmt, ...)
+void LSSerializerImpl::po(char const *fmt, ...)
 {
     char str[257];
     va_list args;
@@ -309,9 +312,9 @@ void LSSerializerImpl::poxml(const DOMString &str)
 /**
  *
  */
-void LSSerializerImpl::writeNode(const Node *nodeArg)
+void LSSerializerImpl::writeNode(const NodePtr nodeArg)
 {
-    Node *node = (Node *)nodeArg;
+    NodePtr node = nodeArg;
 
     int type = node->getNodeType();
 
@@ -323,7 +326,7 @@ void LSSerializerImpl::writeNode(const Node *nodeArg)
         //#############
         case Node::DOCUMENT_NODE:
             {
-            Document *doc = dynamic_cast<Document *>(node);
+            DocumentPtr doc = dynamic_cast<Document *>(node.get());
             writeNode(doc->getDocumentElement());
             }
         break;
@@ -371,7 +374,7 @@ void LSSerializerImpl::writeNode(const Node *nodeArg)
             //### Attributes
             for (int i=0 ; i<nrAttrs ; i++)
                 {
-                Node *attr = attributes.item(i);
+                NodePtr attr = attributes.item(i);
                 spaces();
                 pos(attr->getNodeName());
                 po("=\"");
@@ -391,8 +394,8 @@ void LSSerializerImpl::writeNode(const Node *nodeArg)
             pos(node->getNodeValue());
 
             //### Children
-            for (Node *child = node->getFirstChild() ;
-                 child ;
+            for (NodePtr child = node->getFirstChild() ;
+                 child.get() ;
                  child=child->getNextSibling())
                 {
                 writeNode(child);