summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3f906f2)
raw | patch | inline | side by side (parent: 3f906f2)
author | ishmal <ishmal@users.sourceforge.net> | |
Mon, 12 May 2008 20:20:57 +0000 (20:20 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Mon, 12 May 2008 20:20:57 +0000 (20:20 +0000) |
diff --git a/src/dom/Makefile.mingw b/src/dom/Makefile.mingw
index 4d382c8c0adac9b81d3dad328aa7c1a766160ffe..17c28b63b62995b4370121a1b8c0fa5733025056 100644 (file)
--- a/src/dom/Makefile.mingw
+++ b/src/dom/Makefile.mingw
OBJ = $(DOMOBJ)
-all: testdom.exe testhttp.exe \
+all: testsvg.exe
+
+tests: testdom.exe testhttp.exe \
testsvg.exe testuri.exe testxpath.exe testzip.exe
testdom.exe: libdom.a work/testdom.o
diff --git a/src/dom/dom.h b/src/dom/dom.h
index c1d9428d0e3a1bcce35face32ef571178722dba5..540e7361c4286a7e220be32a93b4c87ddaec9bb9 100644 (file)
--- a/src/dom/dom.h
+++ b/src/dom/dom.h
* Then below, select one of the corresponding typedefs.
*/
-#include <glibmm.h>
-//#include <string>
+//#include <glibmm.h>
+#include <string>
//# Unfortunate hack for a name collision
#ifdef SEVERITY_ERROR
* This is the org::w3c::dom::DOMString definition.
* Which type do we want?
*/
-typedef Glib::ustring DOMString;
-typedef gunichar XMLCh;
+//typedef Glib::ustring DOMString;
+//typedef gunichar XMLCh;
-//typedef std::string DOMString;
-//typedef unsigned short XMLCh;
+typedef std::string DOMString;
+typedef unsigned short XMLCh;
/**
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index 2c85fa21e583604f817e12b173c48cb02ef479fe..fc0af59c9b7bce42a928c18d377ed711610a397e 100644 (file)
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
//# Non-API methods
//##################
+void SVGDocumentImpl::init()
+{
+ title = "";
+ referrer = "";
+ domain = "";
+ rootElement = new SVGSVGElementImpl();
+}
diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h
index b3e2066d5112a7f3191c4aed0fe3b7f3f26d3cb8..80800098ac18aeb94b41c2d8f6e1717d063fc9bf 100644 (file)
--- a/src/dom/svgimpl.h
+++ b/src/dom/svgimpl.h
friend class SvgParser;
- void init()
- {
- title = "";
- referrer = "";
- domain = "";
- rootElement = NULL;
- }
+ void init();
DOMString title;
DOMString referrer;
DOMString domain;
DOMString url;
- SVGSVGElementPtr rootElement;
+ SVGSVGElementImplPtr rootElement;
};
diff --git a/src/dom/svgreader.cpp b/src/dom/svgreader.cpp
index 4fd0817432bdb0ac62945829411d5334ac5a3fa8..fb4b3c62ed7c3a78df869c19a6a514b7690d590f 100644 (file)
--- a/src/dom/svgreader.cpp
+++ b/src/dom/svgreader.cpp
/**
*
*/
-void SvgReader::error(char const *fmt, ...)
+void SVGReader::error(char const *fmt, ...)
{
va_list args;
- fprintf(stderr, "SvgReader:error:");
+ fprintf(stderr, "SVGReader:error: ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args) ;
}
+/**
+ *
+ */
+void SVGReader::trace(char const *fmt, ...)
+{
+ va_list args;
+ fprintf(stdout, "SVGReader: ");
+ va_start(args, fmt);
+ vfprintf(stdout, fmt, args);
+ va_end(args) ;
+ fprintf(stdout, "\n");
+}
+
+
//#########################################################################
//# P A R S I N G
/**
* Get the character at the position and record the fact
*/
-XMLCh SvgReader::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 SvgReader::match(int pos, char const *str)
+bool SVGReader::match(int pos, char const *str)
{
while (*str)
{
/**
*
*/
-int SvgReader::skipwhite(int p)
+int SVGReader::skipwhite(int p)
{
while (p < parselen)
{
/**
* get a word from the buffer
*/
-int SvgReader::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 SvgReader::getNumber(int p0, double &result)
+int SVGReader::getNumber(int p0, double &result)
{
int p=p0;
/**
* get a word from the buffer
*/
-int SvgReader::getNumber(int p0, double &result)
+int SVGReader::getNumber(int p0, double &result)
{
int p=p0;
}
-bool SvgReader::parseTransform(const DOMString &str)
+bool SVGReader::parseTransform(const DOMString &str)
{
parsebuf = str;
parselen = str.size();
/**
*
*/
-bool SvgReader::parseElement(SVGElementImplPtr parent,
+bool SVGReader::parseElement(SVGElementImplPtr parent,
ElementImplPtr sourceElem)
{
- if (!parent || !sourceElem)
+ if (!parent)
+ {
+ error("NULL dest element");
+ return false;
+ }
+ if (!sourceElem)
{
error("NULL source element");
return false;
/**
*
*/
-SVGDocumentPtr SvgReader::parse(const DocumentPtr src)
+SVGDocumentPtr SVGReader::parse(const DocumentPtr src)
{
if (!src)
{
/**
*
*/
-SVGDocumentPtr SvgReader::parse(const DOMString &buf)
+SVGDocumentPtr SVGReader::parse(const DOMString &buf)
{
/* remember, smartptrs are null-testable*/
SVGDocumentPtr svgdoc;
/**
*
*/
-SVGDocumentPtr SvgReader::parseFile(const DOMString &fileName)
+SVGDocumentPtr SVGReader::parseFile(const DOMString &fileName)
{
/* remember, smartptrs are null-testable*/
SVGDocumentPtr svgdoc;
DocumentPtr doc = parser.parseFile(fileName);
if (!doc)
{
+ error("Could not load xml doc");
return svgdoc;
}
svgdoc = parse(doc);
diff --git a/src/dom/svgreader.h b/src/dom/svgreader.h
index cfc41287eed9ebf4fcb742c2a2746446a5b0b07f..2a0106cac61bf501976c133cd6ea769802eca283 100644 (file)
--- a/src/dom/svgreader.h
+++ b/src/dom/svgreader.h
{
-class SvgReader
+class SVGReader
{
public:
/**
*
*/
- SvgReader()
+ SVGReader()
{
}
/**
*
*/
- SvgReader(const SvgReader &/*other*/)
+ SVGReader(const SVGReader &/*other*/)
{
}
/**
*
*/
- virtual ~SvgReader()
+ virtual ~SVGReader()
{
}
#endif
;
+ /**
+ *
+ */
+ void trace(char const *format, ...)
+ #ifdef G_GNUC_PRINTF
+ G_GNUC_PRINTF(2, 3)
+ #endif
+ ;
+
DOMString parsebuf;
index bd6cf6bfbf7d80b4d0bcd03cd36a2c8602b9b7a2..41a831aaabbafab5d77012b89a379aa7b8a00708 100644 (file)
--- a/src/dom/work/testdom.cpp
+++ b/src/dom/work/testdom.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
index b347d2415f2b280f98b50a2fc33603d326e2f263..56d8108b031eed5e12386c0d9f10d1503e0c7342 100644 (file)
--- a/src/dom/work/testsvg.cpp
+++ b/src/dom/work/testsvg.cpp
* Authors:
* Bob Jamison
*
- * Copyright (C) 2005-2006 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 "svgreader.h"
#include "lsimpl.h"
using namespace org::w3c::dom;
-bool doTest(char *filename)
+bool doTest(char *fileName)
{
- ls::DOMImplementationLSImpl domImpl;
- ls::LSInput input = domImpl.createLSInput();
- ls::LSParser &parser = domImpl.createLSParser(0, "");
-
- DOMString buf;
- FILE *f = fopen(filename, "rb");
- if (!f)
- {
- printf("Cannot open %s for reading\n", filename);
- return false;
- }
- while (!feof(f))
- {
- int ch = fgetc(f);
- buf.push_back(ch);
- }
- fclose(f);
- input.setStringData(buf);
-
printf("######## PARSE ######################################\n");
- DocumentPtr doc = parser.parse(input);
+ svg::SVGReader parser;
+ svg::SVGDocumentPtr doc = parser.parseFile(fileName);
if (!doc)
{
//### OUTPUT
printf("######## SERIALIZE ##################################\n");
+ ls::DOMImplementationLSImpl domImpl;
ls::LSSerializer &serializer = domImpl.createLSSerializer();
ls::LSOutput output = domImpl.createLSOutput();
io::StdWriter writer;