/***************************************************************************
                            Document.cpp -  description
                             -------------------
    begin                : Sun Jan 27 16:22:17 2002
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Jan 27 16:22:17 2002, using kalyptus 0.9.
 ***************************************************************************/

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

#define _BOOL_H_
#include <dom/dom_doc.h>
#include <dom/dom_element.h>
#include <dom/dom_text.h>
#include <dom/dom_node.h>
#include <dom/dom_xml.h>
#include <dom/dom2_range.h>
#include <dom/dom2_traversal.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <kdejava/KDESupport.h>
#include <kdejava/DOMDocument.h>

class DocumentJBridge : public DOM::Document
{
public:
	DocumentJBridge() : Document() {}
	DocumentJBridge(bool arg1) : Document(arg1) {}
	DocumentJBridge(const Document& other) : Document(other) {}
	DocumentJBridge(const DOM::Node& other) : Document(other) {}
	~DocumentJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_DOMDocument_newDOMDocument__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DocumentJBridge());
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMDocument_newDOMDocument__Z(JNIEnv *env, jobject obj, jboolean arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DocumentJBridge((bool) arg1));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMDocument_newDOMDocument__Lorg_kde_koala_DOMDocument_2(JNIEnv *env, jobject obj, jobject other)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DocumentJBridge((DOM::Document&) *(DOM::Document *) QtSupport::getQt(env, other)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMDocument_newDOMDocument__Lorg_kde_koala_DOMNode_2(JNIEnv *env, jobject obj, jobject other)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DocumentJBridge((DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, other)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMDocument_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (DOM::Document*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DOMDocument_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_DOMDocument_finalize(env, obj);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMDocument_isDisposed(JNIEnv *env, jobject obj)
{
	return (QtSupport::getQt(env, obj) == 0);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_doctype(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::DocumentType (((DOM::Document*) QtSupport::getQt(env, obj))->doctype()), "org.kde.koala.DocumentType", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_implementation(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::DOMImplementation (((DOM::Document*) QtSupport::getQt(env, obj))->implementation()), "org.kde.koala.DOMImplementation", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_documentElement(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Element (((DOM::Document*) QtSupport::getQt(env, obj))->documentElement()), "org.kde.koala.Element", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createElement(JNIEnv *env, jobject obj, jstring tagName)
{
static DOM::DOMString * _domstring_tagName = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Element (((DOM::Document*) QtSupport::getQt(env, obj))->createElement((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, tagName, &_domstring_tagName))), "org.kde.koala.Element", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createElementNS(JNIEnv *env, jobject obj, jstring namespaceURI, jstring qualifiedName)
{
static DOM::DOMString * _domstring_qualifiedName = 0;
static DOM::DOMString * _domstring_namespaceURI = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Element (((DOM::Document*) QtSupport::getQt(env, obj))->createElementNS((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, namespaceURI, &_domstring_namespaceURI), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, qualifiedName, &_domstring_qualifiedName))), "org.kde.koala.Element", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createDocumentFragment(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::DocumentFragment (((DOM::Document*) QtSupport::getQt(env, obj))->createDocumentFragment()), "org.kde.koala.DocumentFragment", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createTextNode(JNIEnv *env, jobject obj, jstring data)
{
static DOM::DOMString * _domstring_data = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Text (((DOM::Document*) QtSupport::getQt(env, obj))->createTextNode((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, data, &_domstring_data))), "org.kde.koala.Text", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createComment(JNIEnv *env, jobject obj, jstring data)
{
static DOM::DOMString * _domstring_data = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Comment (((DOM::Document*) QtSupport::getQt(env, obj))->createComment((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, data, &_domstring_data))), "org.kde.koala.Comment", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createCDATASection(JNIEnv *env, jobject obj, jstring data)
{
static DOM::DOMString * _domstring_data = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::CDATASection (((DOM::Document*) QtSupport::getQt(env, obj))->createCDATASection((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, data, &_domstring_data))), "org.kde.koala.CDATASection", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createProcessingInstruction(JNIEnv *env, jobject obj, jstring target, jstring data)
{
static DOM::DOMString * _domstring_data = 0;
static DOM::DOMString * _domstring_target = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::ProcessingInstruction (((DOM::Document*) QtSupport::getQt(env, obj))->createProcessingInstruction((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, target, &_domstring_target), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, data, &_domstring_data))), "org.kde.koala.ProcessingInstruction", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createAttribute(JNIEnv *env, jobject obj, jstring name)
{
static DOM::DOMString * _domstring_name = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Attr (((DOM::Document*) QtSupport::getQt(env, obj))->createAttribute((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, name, &_domstring_name))), "org.kde.koala.Attr", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createAttributeNS(JNIEnv *env, jobject obj, jstring namespaceURI, jstring qualifiedName)
{
static DOM::DOMString * _domstring_qualifiedName = 0;
static DOM::DOMString * _domstring_namespaceURI = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Attr (((DOM::Document*) QtSupport::getQt(env, obj))->createAttributeNS((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, namespaceURI, &_domstring_namespaceURI), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, qualifiedName, &_domstring_qualifiedName))), "org.kde.koala.Attr", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createEntityReference(JNIEnv *env, jobject obj, jstring name)
{
static DOM::DOMString * _domstring_name = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::EntityReference (((DOM::Document*) QtSupport::getQt(env, obj))->createEntityReference((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, name, &_domstring_name))), "org.kde.koala.EntityReference", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_getElementById(JNIEnv *env, jobject obj, jstring elementId)
{
static DOM::DOMString * _domstring_elementId = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Element (((DOM::Document*) QtSupport::getQt(env, obj))->getElementById((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, elementId, &_domstring_elementId))), "org.kde.koala.Element", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_getElementsByTagName(JNIEnv *env, jobject obj, jstring tagname)
{
	DOM::NodeList  _qlist;
static DOM::DOMString * _domstring_tagname = 0;
	_qlist = ((DOM::Document*) QtSupport::getQt(env, obj))->getElementsByTagName((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, tagname, &_domstring_tagname));
	return (jobject) KDESupport::arrayWithNodeList(env, (DOM::NodeList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_getElementsByTagNameNS(JNIEnv *env, jobject obj, jstring namespaceURI, jstring localName)
{
	DOM::NodeList  _qlist;
static DOM::DOMString * _domstring_localName = 0;
static DOM::DOMString * _domstring_namespaceURI = 0;
	_qlist = ((DOM::Document*) QtSupport::getQt(env, obj))->getElementsByTagNameNS((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, namespaceURI, &_domstring_namespaceURI), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, localName, &_domstring_localName));
	return (jobject) KDESupport::arrayWithNodeList(env, (DOM::NodeList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_importNode(JNIEnv *env, jobject obj, jobject importedNode, jboolean deep)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Node (((DOM::Document*) QtSupport::getQt(env, obj))->importNode((DOM::Node&) *(DOM::Node *) QtSupport::getQt(env, importedNode), (bool) deep)), "org.kde.koala.DOMNode", TRUE);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMDocument_isHTMLDocument(JNIEnv *env, jobject obj)
{
	return (jboolean) ((DOM::Document*) QtSupport::getQt(env, obj))->isHTMLDocument();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createRange(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Range (((DOM::Document*) QtSupport::getQt(env, obj))->createRange()), "org.kde.koala.Range", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createNodeIterator(JNIEnv *env, jobject obj, jobject root, jlong whatToShow, jobject filter, jboolean entityReferenceExpansion)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::NodeIterator (((DOM::Document*) QtSupport::getQt(env, obj))->createNodeIterator((DOM::Node) *(DOM::Node *) QtSupport::getQt(env, root), (unsigned long) whatToShow, (DOM::NodeFilter) *(DOM::NodeFilter *) QtSupport::getQt(env, filter), (bool) entityReferenceExpansion)), "org.kde.koala.NodeIterator", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_createTreeWalker(JNIEnv *env, jobject obj, jobject root, jlong whatToShow, jobject filter, jboolean entityReferenceExpansion)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::TreeWalker (((DOM::Document*) QtSupport::getQt(env, obj))->createTreeWalker((DOM::Node) *(DOM::Node *) QtSupport::getQt(env, root), (unsigned long) whatToShow, (DOM::NodeFilter) *(DOM::NodeFilter *) QtSupport::getQt(env, filter), (bool) entityReferenceExpansion)), "org.kde.koala.TreeWalker", TRUE);
}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_DOMDocument_createEvent(JNIEnv *env, jobject obj, jstring eventType)
//{
//static DOM::DOMString * _domstring_eventType = 0;
//	return () ((DOM::Document*) QtSupport::getQt(env, obj))->createEvent((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, eventType, &_domstring_eventType));
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_DOMDocument_defaultView(JNIEnv *env, jobject obj)
//{
//	return () ((DOM::Document*) QtSupport::getQt(env, obj))->defaultView();
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_styleSheets(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::StyleSheetList (((DOM::Document*) QtSupport::getQt(env, obj))->styleSheets()), "org.kde.koala.StyleSheetList", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_view(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((DOM::Document*) QtSupport::getQt(env, obj))->view(), "org.kde.koala.KHTMLView");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DOMDocument_getOverrideStyle(JNIEnv *env, jobject obj, jobject elt, jstring pseudoElt)
{
static DOM::DOMString * _domstring_pseudoElt = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::CSSStyleDeclaration (((DOM::Document*) QtSupport::getQt(env, obj))->getOverrideStyle((DOM::Element&) *(DOM::Element *) QtSupport::getQt(env, elt), (DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, pseudoElt, &_domstring_pseudoElt))), "org.kde.koala.CSSStyleDeclaration", TRUE);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DOMDocument_completeURL(JNIEnv *env, jobject obj, jstring url)
{
	DOM::DOMString _domstring;
static DOM::DOMString * _domstring_url = 0;
	_domstring = ((DOM::Document*) QtSupport::getQt(env, obj))->completeURL((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, url, &_domstring_url));
	return KDESupport::fromDOMString(env, &_domstring);
}

