/***************************************************************************
                            Document.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_DOMDocument.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/DOMDocument.h>
#include <kdeobjc/NodeFilter.h>
#include <kdeobjc/Element.h>

@implementation  DOMDocument


//- init
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_DOMDocument()];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

//- initWithBOOL: (BOOL)arg1
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_DOMDocument1((int)arg1)];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

//- copyWithZone: (NSZone *) zone
//{
//	DOMDocument * aCopy;
//	aCopy = [[(DOMDocument *)[[self class] allocWithZone: zone] setQt: kde_new_DOMDocument2([self qt])] init];
//	[aCopy setAllocatedInObjcWorld: YES];
//	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
//	return aCopy;
//}

//- initWithDOMNode: (DOMNode*)other
//{
//	if ([self qt] == 0L) {
//		[self setQt: kde_new_DOMDocument3((kde_DOMNode*) [other qt])];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

//- (void) dealloc
//{
//	if ([self qt] != 0L) {
//		if ([self allocatedInObjcWorld]) {
//			kde_del_DOMDocument((kde_DOMDocument *)[self qt]);
//		}
//		[QtSupport removeQtKey: [self qt]];
//		[self setQt: 0L];
//	}
//	[super dealloc];
//}

- (DocumentType*) doctype
{
	return (DocumentType*) [QtSupport objectForQtKey: kde_DOMDocument_doctype((kde_DOMDocument *)[self qt]) withClass: [DocumentType class] allocatedInObjcWorld: YES];
}

- (Element*) documentElement
{
	return (Element*) [QtSupport objectForQtKey: kde_DOMDocument_documentElement((kde_DOMDocument *)[self qt]) withClass: [Element class] allocatedInObjcWorld: YES];
}

- (Element*) createElement: (NSString *)tagName
{
static kde_DOMString * _domstring_tagName = 0L;
	return (Element*) [QtSupport objectForQtKey: kde_DOMDocument_createElement((kde_DOMDocument *)[self qt], (kde_DOMString*) [tagName toDOMString: &_domstring_tagName]) withClass: [Element class] allocatedInObjcWorld: YES];
}

- (Element*) createElementNS: (NSString *)namespaceURI qualifiedName: (NSString *)qualifiedName
{
static kde_DOMString * _domstring_qualifiedName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	return (Element*) [QtSupport objectForQtKey: kde_DOMDocument_createElementNS((kde_DOMDocument *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [qualifiedName toDOMString: &_domstring_qualifiedName]) withClass: [Element class] allocatedInObjcWorld: YES];
}

//- (DocumentFragment*) createDocumentFragment
//{
//	return (DocumentFragment*) [QtSupport objectForQtKey: kde_DOMDocument_createDocumentFragment((kde_DOMDocument *)[self qt]) withClass: [DocumentFragment class] allocatedInObjcWorld: YES];
//}

- (Text*) createTextNode: (NSString *)data
{
static kde_DOMString * _domstring_data = 0L;
	return (Text*) [QtSupport objectForQtKey: kde_DOMDocument_createTextNode((kde_DOMDocument *)[self qt], (kde_DOMString*) [data toDOMString: &_domstring_data]) withClass: [Text class] allocatedInObjcWorld: YES];
}

- (Comment*) createComment: (NSString *)data
{
static kde_DOMString * _domstring_data = 0L;
	return (Comment*) [QtSupport objectForQtKey: kde_DOMDocument_createComment((kde_DOMDocument *)[self qt], (kde_DOMString*) [data toDOMString: &_domstring_data]) withClass: [Comment class] allocatedInObjcWorld: YES];
}

- (CDATASection*) createCDATASection: (NSString *)data
{
static kde_DOMString * _domstring_data = 0L;
	return (CDATASection*) [QtSupport objectForQtKey: kde_DOMDocument_createCDATASection((kde_DOMDocument *)[self qt], (kde_DOMString*) [data toDOMString: &_domstring_data]) withClass: [CDATASection class] allocatedInObjcWorld: YES];
}

- (ProcessingInstruction*) createProcessingInstruction: (NSString *)target data: (NSString *)data
{
static kde_DOMString * _domstring_data = 0L;
static kde_DOMString * _domstring_target = 0L;
	return (ProcessingInstruction*) [QtSupport objectForQtKey: kde_DOMDocument_createProcessingInstruction((kde_Document *)[self qt], (kde_DOMString*) [target toDOMString: &_domstring_target], (kde_DOMString*) [data toDOMString: &_domstring_data]) withClass: [ProcessingInstruction class] allocatedInObjcWorld: YES];
}

- (Attr*) createAttribute: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (Attr*) [QtSupport objectForQtKey: kde_DOMDocument_createAttribute((kde_DOMDocument *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (Attr*) createAttributeNS: (NSString *)namespaceURI qualifiedName: (NSString *)qualifiedName
{
static kde_DOMString * _domstring_qualifiedName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	return (Attr*) [QtSupport objectForQtKey: kde_DOMDocument_createAttributeNS((kde_DOMDocument *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [qualifiedName toDOMString: &_domstring_qualifiedName]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (EntityReference*) createEntityReference: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (EntityReference*) [QtSupport objectForQtKey: kde_DOMDocument_createEntityReference((kde_DOMDocument *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]) withClass: [EntityReference class] allocatedInObjcWorld: YES];
}

- (Element*) getElementById: (NSString *)elementId
{
static kde_DOMString * _domstring_elementId = 0L;
	return (Element*) [QtSupport objectForQtKey: kde_DOMDocument_getElementById((kde_DOMDocument *)[self qt], (kde_DOMString*) [elementId toDOMString: &_domstring_elementId]) withClass: [Element class] allocatedInObjcWorld: YES];
}

- (NSArray *) getElementsByTagName: (NSString *)tagname
{
static kde_DOMNodeList * _qlist = 0L;
static kde_DOMString * _domstring_tagname = 0L;
	_qlist = kde_DOMDocument_getElementsByTagName((kde_DOMDocument *)[self qt], (kde_DOMString*) [tagname toDOMString: &_domstring_tagname]);
	return (NSArray *) [NSMutableArray arrayWithNodeList: _qlist];
}

- (NSArray *) getElementsByTagNameNS: (NSString *)namespaceURI localName: (NSString *)localName
{
static kde_DOMNodeList * _qlist = 0L;
static kde_DOMString * _domstring_localName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	_qlist = kde_DOMDocument_getElementsByTagNameNS((kde_DOMDocument *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [localName toDOMString: &_domstring_localName]);
	return (NSArray *) [NSMutableArray arrayWithNodeList: _qlist];
}

- (DOMNode*) importNode: (DOMNode*)importedNode deep: (BOOL)deep
{
	return (DOMNode*) kde_DOMDocument_importNode((kde_DOMDocument *)[self qt], (kde_DOMNode*) [importedNode qt], (int)deep);
}

- (BOOL) isHTMLDocument
{
	return (BOOL) kde_DOMDocument_isHTMLDocument((kde_DOMDocument *)[self qt]);
}

- (Range*) createRange
{
	return (Range*) [QtSupport objectForQtKey: kde_DOMDocument_createRange((kde_Document *)[self qt]) withClass: [Range class] allocatedInObjcWorld: YES];
}

- (NodeIterator*) createNodeIterator: (DOMNode*)root whatToShow: (unsigned long)whatToShow filter: (NodeFilter*)filter entityReferenceExpansion: (BOOL)entityReferenceExpansion
{
	return (NodeIterator*) [QtSupport objectForQtKey: kde_DOMDocument_createNodeIterator((kde_DOMDocument *)[self qt], (kde_DOMNode*) [root qt], (unsigned long)whatToShow, (kde_NodeFilter*) [filter qt], (int)entityReferenceExpansion) withClass: [NodeIterator class] allocatedInObjcWorld: YES];
}

- (TreeWalker*) createTreeWalker: (DOMNode*)root whatToShow: (unsigned long)whatToShow filter: (NodeFilter*)filter entityReferenceExpansion: (BOOL)entityReferenceExpansion
{
	return (TreeWalker*) [QtSupport objectForQtKey: kde_DOMDocument_createTreeWalker((kde_DOMDocument *)[self qt], (kde_DOMNode*) [root qt], (unsigned long)whatToShow, (kde_NodeFilter*) [filter qt], (int)entityReferenceExpansion) withClass: [TreeWalker class] allocatedInObjcWorld: YES];
}

//- (Event) createEvent: (NSString *)eventType
//{
//static kde_DOMString * _domstring_eventType = 0L;
//	return (Event) kde_Document_createEvent((kde_Document *)[self qt], (kde_DOMString*) [eventType toDOMString: &_domstring_eventType]);
//}

//- (AbstractView) defaultView
//{
//	return (AbstractView) kde_DOMDocument_defaultView((kde_DOMDocument *)[self qt]);
//}

//- (StyleSheetList) styleSheets
//{
//	return (StyleSheetList) [QtSupport objectForQtKey: kde_Document_styleSheets((kde_Document *)[self qt]) withClass: [ class] allocatedInObjcWorld: YES];
//}

- (KHTMLView*) view
{
	return (KHTMLView*) [QtSupport objectForQtKey: kde_DOMDocument_view((kde_DOMDocument *)[self qt]) withClass: [KHTMLView class] allocatedInObjcWorld: YES];
}

- (CSSStyleDeclaration*) getOverrideStyle: (Element*)elt pseudoElt: (NSString *)pseudoElt
{
static kde_DOMString * _domstring_pseudoElt = 0L;
	return (CSSStyleDeclaration*) [QtSupport objectForQtKey: kde_DOMDocument_getOverrideStyle((kde_DOMDocument *)[self qt], (kde_Element*) [elt qt], (kde_DOMString*) [pseudoElt toDOMString: &_domstring_pseudoElt]) withClass: [CSSStyleDeclaration class] allocatedInObjcWorld: YES];
}

- (NSString *) completeURL: (NSString *)url
{
static kde_DOMString * _domstring = 0L;
static kde_DOMString * _domstring_url = 0L;
	_domstring = kde_DOMDocument_completeURL((kde_Document *)[self qt], (kde_DOMString*) [url toDOMString: &_domstring_url]);
	return [NSString fromDOMString: _domstring];
}

@end
