summaryrefslogtreecommitdiffstats
path: root/ksvg/test/external/printnodetest.cpp
blob: 5310ac682ec689c3797ecaa3bedb19790303f083 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <DocumentFactory.h>
#include <SVGSVGElement.h>
#include <SVGDocument.h>
#include <SVGWindow.h>

#include <tdeapplication.h>
#include <tdecmdlineargs.h>
#include <klocale.h>
#include <tdeaboutdata.h>
#include <kdebug.h>

#include "printnodetest.moc"

using namespace KSVG;

static TDECmdLineOptions options[] =
{
	{ "+URL",   I18N_NOOP("SVG file to open"), 0 },
	TDECmdLineLastOption
};

Worker::Worker(const KURL &url)
{
	m_doc = DocumentFactory::self()->requestDocument(this, TQT_SLOT(slotParsingFinished(bool, const TQString &)));

	if(!m_doc)
		return;
	
	if(!DocumentFactory::self()->startParsing(m_doc, url))
		return;
}

Worker::~Worker()
{
	delete m_doc;
}

void Worker::slotParsingFinished(bool, const TQString &)
{
	SVGWindow win = m_doc->window();	
	SVGSVGElement root = m_doc->rootElement();
	
	kdDebug() << win.printNode(root).string() << endl;
	exit(0);
}

int main(int argc, char **argv)
{
	TDEAboutData *about = new TDEAboutData("KSVG printNode test app", I18N_NOOP("KSVG test"), "0.1", I18N_NOOP("KSVG printNode test app"));
	TDECmdLineArgs::init(argc, argv, about);
	TDECmdLineArgs::addCmdLineOptions(options);
	TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
	if(args->count() == 0)
	{
		args->usage();
		return -1;
	}
	
	TDEApplication a(argc, argv);
	(void) new Worker(args->url(0));
	return a.exec();
}