/***************************************************************************
                            Document.cpp -  description
                             -------------------
    begin                : Sun Aug 26 09:45:02 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Aug 26 09:45:02 2001, using kdoc parser/custom Java conversion backend.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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);}
//	DocumentJBridge(DocumentImpl* i) : Document(i) {}
};


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 jobject JNICALL
Java_org_kde_koala_DOMDocument_doctype(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::DocumentType (((DocumentJBridge*) 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 DOMImplementation (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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_getElementsByTagName(JNIEnv *env, jobject obj, jstring tagname)
{
	DOM::NodeList  _qlist;
static DOM::DOMString * _domstring_tagname = 0;
	_qlist = ((DocumentJBridge*) QtSupport::getQt(env, obj))->getElementsByTagName((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, tagname, &_domstring_tagname));
	return (jobject) KDESupport::arrayWithNodeList(env, (DOM::NodeList *) &_qlist);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DOMDocument_isHTMLDocument(JNIEnv *env, jobject obj)
{
	return (jboolean) ((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 (((DocumentJBridge*) 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 () ((DocumentJBridge*) 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 () ((DocumentJBridge*) 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 (((DocumentJBridge*) 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 *)((DocumentJBridge*) 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 (((DocumentJBridge*) 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 void JNICALL
//Java_org_kde_koala_DOMDocument_newDOMDocument__Lorg_kde_koala_DOMDocumentImpl_2(JNIEnv *env, jobject obj, jobject i)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new DOM::DocumentJBridge((DocumentImpl*) QtSupport::getQt(env, i)));
//		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
//	}
//	return;
//}

