summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e569bdc)
raw | patch | inline | side by side (parent: e569bdc)
author | ishmal <ishmal@users.sourceforge.net> | |
Thu, 1 May 2008 19:15:49 +0000 (19:15 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Thu, 1 May 2008 19:15:49 +0000 (19:15 +0000) |
diff --git a/src/dom/svg.h b/src/dom/svg.h
index 1d6e2df5d2df0694e8faf0e311631ffce143e6bd..09a58a7e52ae4c7fd8ad125d643a8a232525e46c 100644 (file)
--- a/src/dom/svg.h
+++ b/src/dom/svg.h
* This API follows:
* http://www.w3.org/TR/SVG11/svgdom.html
*
+ * This file defines the main SVG-DOM Node types. Other non-Node types are
+ * defined in svgtypes.h.
+ *
*/
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index 9343c311d9a6a6329194c5cc918a304e96eae666..2c85fa21e583604f817e12b173c48cb02ef479fe 100644 (file)
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
* Authors:
* Bob Jamison
*
- * Copyright (C) 2005 Bob Jamison
+ * Copyright (C) 2005-2008 Bob Jamison
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "svgimpl.h"
-
+/**
+ * This is the .cpp side of the SVG implementations classes. Note that many
+ * of the sections for each of the classes is empty. This is because that class
+ * has been implemented totally in svgimpl.h
+ */
namespace org
{
*
*/
NodeList SVGSVGElementImpl::getIntersectionList(const SVGRect &/*rect*/,
- const SVGElementPtr /*referenceElement*/ )
+ const SVGElementPtr /*referenceElement*/ )
{
NodeList list;
return list;
*
*/
NodeList SVGSVGElementImpl::getEnclosureList(const SVGRect &/*rect*/,
- const SVGElementPtr /*referenceElement*/ )
+ const SVGElementPtr /*referenceElement*/ )
{
NodeList list;
return list;
diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h
index 2ea09be3caeb49cdbda350302592a6e690bf7d49..b3e2066d5112a7f3191c4aed0fe3b7f3f26d3cb8 100644 (file)
--- a/src/dom/svgimpl.h
+++ b/src/dom/svgimpl.h
*
*/
virtual double getSubStringLength(unsigned long charnum,
- unsigned long nchars )
+ unsigned long nchars )
throw( DOMException );
/**
diff --git a/src/dom/svgparser.cpp b/src/dom/svgparser.cpp
index 186fd40ff3594135d08486e7f005a8571ce8e00b..956112c2540ca7ea99631c9cc624fb4f9c3cad5f 100644 (file)
--- a/src/dom/svgparser.cpp
+++ b/src/dom/svgparser.cpp
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * =======================================================================
+ * NOTES
+ *
+ *
*/
#include "svgparser.h"
#include "dom/cssparser.h"
#include "dom/ucd.h"
+#include "xmlreader.h"
#include <stdarg.h>
/**
*
*/
-void SvgParser::error(char const *fmt, ...)
+void SvgReader::error(char const *fmt, ...)
{
va_list args;
- fprintf(stderr, "SvgParser:error:");
+ fprintf(stderr, "SvgReader:error:");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args) ;
/**
* Get the character at the position and record the fact
*/
-XMLCh SvgParser::get(int p)
+XMLCh SvgReader::get(int p)
{
if (p >= parselen)
return 0;
* Test if the given substring exists at the given position
* in parsebuf. Use get() in case of out-of-bounds
*/
-bool SvgParser::match(int pos, char const *str)
+bool SvgReader::match(int pos, char const *str)
{
while (*str)
{
/**
*
*/
-int SvgParser::skipwhite(int p)
+int SvgReader::skipwhite(int p)
{
while (p < parselen)
{
/**
* get a word from the buffer
*/
-int SvgParser::getWord(int p, DOMString &result)
+int SvgReader::getWord(int p, DOMString &result)
{
XMLCh ch = get(p);
if (!uni_is_letter(ch))
/**
* get a word from the buffer
*/
-int SvgParser::getNumber(int p0, double &result)
+int SvgReader::getNumber(int p0, double &result)
{
int p=p0;
/**
* get a word from the buffer
*/
-int SvgParser::getNumber(int p0, double &result)
+int SvgReader::getNumber(int p0, double &result)
{
int p=p0;
}
-bool SvgParser::parseTransform(const DOMString &str)
+bool SvgReader::parseTransform(const DOMString &str)
{
parsebuf = str;
parselen = str.size();
/**
*
*/
-bool SvgParser::parseElement(SVGElementImplPtr parent,
+bool SvgReader::parseElement(SVGElementImplPtr parent,
ElementImplPtr sourceElem)
{
if (!parent || !sourceElem)
/**
*
*/
-SVGDocumentPtr SvgParser::parse(const DocumentPtr src)
+SVGDocumentPtr SvgReader::parse(const DocumentPtr src)
{
if (!src)
{
+/**
+ *
+ */
+SVGDocumentPtr SvgReader::parse(const DOMString &buf)
+{
+ /* remember, smartptrs are null-testable*/
+ SVGDocumentPtr svgdoc;
+ XmlReader parser;
+ DocumentPtr doc = parser.parse(buf);
+ if (!doc)
+ {
+ return svgdoc;
+ }
+ svgdoc = parse(doc);
+ return svgdoc;
+}
+
+
+
+/**
+ *
+ */
+SVGDocumentPtr SvgReader::parseFile(const DOMString &fileName)
+{
+ /* remember, smartptrs are null-testable*/
+ SVGDocumentPtr svgdoc;
+ XmlReader parser;
+ DocumentPtr doc = parser.parseFile(fileName);
+ if (!doc)
+ {
+ return svgdoc;
+ }
+ svgdoc = parse(doc);
+ return svgdoc;
+}
+
+
+
} //namespace svg
} //namespace dom
diff --git a/src/dom/svgparser.h b/src/dom/svgparser.h
index cb3ac15d4c87d83055adaf5570b9dd973b6d3f2b..8e53fe656593478bb7a47bff78bc4d7b9f22ea49 100644 (file)
--- a/src/dom/svgparser.h
+++ b/src/dom/svgparser.h
* Authors:
* Bob Jamison
*
- * Copyright (C) 2005-2007 Bob Jamison
+ * Copyright (C) 2005-2008 Bob Jamison
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * =======================================================================
+ * NOTES
+ *
+ * This parser takes an XML document, as a file, string, or DOM Document,
+ * and attempts to parse it as an SVG-DOM SVGDocument.
+ *
+ * Look in svg.h and svgtypes.h for the classes which are the target of this
+ * parser.
+ *
+ * They loosely follow the specification:
+ * http://www.w3.org/TR/SVG11/svgdom.html
+ *
*/
{
-class SvgParser
+class SvgReader
{
public:
/**
*
*/
- SvgParser()
+ SvgReader()
{
}
/**
*
*/
- SvgParser(const SvgParser &/*other*/)
+ SvgReader(const SvgReader &/*other*/)
{
}
/**
*
*/
- virtual ~SvgParser()
+ virtual ~SvgReader()
{
}
/**
*
*/
- SVGDocumentPtr parse(const DocumentPtr sourceDoc);
+ SVGDocumentPtr parse(const DocumentPtr /*sourceDoc*/);
+
+ /**
+ *
+ */
+ SVGDocumentPtr parse(const DOMString &/*buffer*/);
+
+ /**
+ *
+ */
+ SVGDocumentPtr parseFile(const DOMString &/*fileName*/);
diff --git a/src/dom/svgtypes.h b/src/dom/svgtypes.h
index 36bb1fcdf14fb3f6d6fc6f7bd3957e7c9304fc60..674add792c2a2d54502674b2e24b27fefd03bcdb 100644 (file)
--- a/src/dom/svgtypes.h
+++ b/src/dom/svgtypes.h
* Authors:
* Bob Jamison
*
- * Copyright (C) 2006 Bob Jamison
+ * Copyright (C) 2006-2008 Bob Jamison
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * =======================================================================
+ * NOTES
+ *
+ * This API follows:
+ * http://www.w3.org/TR/SVG11/svgdom.html
+ *
+ * This file contains the definitions of the non-Node SVG classes. DOM Nodes
+ * for SVG are defined in svg.h.
+ *
*/
diff --git a/src/dom/xmlreader.cpp b/src/dom/xmlreader.cpp
index 8258514795d3716c220a4bf3e4f1d4afadc80eac..fc4eee51f5d45bff29c9ce32c55dc522cb7fb0fb 100644 (file)
--- a/src/dom/xmlreader.cpp
+++ b/src/dom/xmlreader.cpp
//#########################################################################
struct EntityInfo
{
- char *escape;
+ const char *escape;
int escapeLength;
- char *value;
+ const char *value;
};
/**
*
*/
-void XmlReader::error(char *fmt, ...)
+void XmlReader::error(const char *fmt, ...)
{
va_list args;
fprintf(stderr, "XmlReader:error at line %d, column %d:", lineNr, colNr);
* Test if the given substring exists at the given position
* in parsebuf. Use peek() in case of out-of-bounds
*/
-bool XmlReader::match(int pos, char const *str)
+bool XmlReader::match(int pos, const char *str)
{
while (*str)
{
{
DocumentPtr doc = parse(str, 0, str.size());
+ if (!doc)
+ return doc;
doc->normalizeDocument();
-
return doc;
}
*
*/
org::w3c::dom::DocumentPtr
-XmlReader::parseFile(char *fileName)
+XmlReader::parseFile(const DOMString &fileName)
{
-
+ DocumentPtr doc;
+
DOMString buf = loadFile(fileName);
+ if (buf.size() == 0)
+ return doc; /*doc still null*/
- DocumentPtr doc = parse(buf, 0, buf.size());
+ doc = parse(buf, 0, buf.size());
return doc;
}
*
*/
org::w3c::dom::DOMString
-XmlReader::loadFile(char *fileName)
+XmlReader::loadFile(const DOMString &fileName)
{
+ DOMString buf;
- if (!fileName)
- return NULL;
- FILE *f = fopen(fileName, "rb");
+ if (fileName.size() == 0)
+ return buf;
+ FILE *f = fopen(fileName.c_str(), "rb");
if (!f)
- return NULL;
+ {
+ //error here
+ return buf;
+ }
- DOMString buf;
while (!feof(f))
{
int ch = fgetc(f);
diff --git a/src/dom/xmlreader.h b/src/dom/xmlreader.h
index fbd62c17944ed6c1af7454e5fd650ff213d1c217..3f97d87c9c6a4b2a7be2baaa8c786966e3bd127e 100644 (file)
--- a/src/dom/xmlreader.h
+++ b/src/dom/xmlreader.h
* Authors:
* Bob Jamison
*
- * Copyright (C) 2005-2007 Bob Jamison
+ * Copyright (C) 2005-2008 Bob Jamison
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/**
*
*/
- org::w3c::dom::DocumentPtr parseFile(char *fileName);
+ org::w3c::dom::DocumentPtr parseFile(const DOMString &fileName);
private:
- void error(char *format, ...)
+ void error(const char *format, ...)
#ifdef G_GNUC_PRINTF
G_GNUC_PRINTF(2, 3)
#endif
int len; //length of parsed region
DOMString parsebuf;
- DOMString loadFile(char *fileName);
+ DOMString loadFile(const DOMString &fileName);
int lineNr;
int colNr;