/***************************************************************************
                            HTMLDocument.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/html_document.h>
#include <dom/html_misc.h>
#include <dom/dom_string.h>
#include <qstring.h>
#include <qcstring.h>

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

class HTMLDocumentJBridge : public DOM::HTMLDocument
{
public:
	HTMLDocumentJBridge() : DOM::HTMLDocument() {}
	HTMLDocumentJBridge(KHTMLView* parent) : DOM::HTMLDocument(parent) {}
	HTMLDocumentJBridge(const DOM::HTMLDocument& other) : DOM::HTMLDocument(other) {}
	HTMLDocumentJBridge(const Node& other) : DOM::HTMLDocument(other) {}
	~HTMLDocumentJBridge() {QtSupport::qtKeyDeleted(this);}
	HTMLDocumentJBridge(DOM::HTMLDocumentImpl* impl) : DOM::HTMLDocument(impl) {}
};


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

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

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

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

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

JNIEXPORT jstring JNICALL
Java_org_kde_koala_HTMLDocument_title(JNIEnv *env, jobject obj)
{
	DOM::DOMString  _domstring;
	_domstring = ((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->title();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_setTitle(JNIEnv *env, jobject obj, jstring arg1)
{
static DOM::DOMString * _domstring_arg1 = 0;
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->setTitle((DOM::DOMString&) * (DOM::DOMString *) KDESupport::toDOMString(env, arg1, &_domstring_arg1));
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_HTMLDocument_referrer(JNIEnv *env, jobject obj)
{
	DOM::DOMString  _domstring;
	_domstring = ((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->referrer();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_HTMLDocument_domain(JNIEnv *env, jobject obj)
{
	DOM::DOMString  _domstring;
	_domstring = ((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->domain();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_HTMLDocument_URL(JNIEnv *env, jobject obj)
{
	DOM::DOMString  _domstring;
	_domstring = ((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->URL();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_body(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLElement (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->body()), "org.kde.koala.HTMLElement", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_setBody(JNIEnv *env, jobject obj, jobject arg1)
{
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->setBody((DOM::HTMLElement&) *(DOM::HTMLElement *) QtSupport::getQt(env, arg1));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_images(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLCollection (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->images()), "org.kde.koala.HTMLCollection", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_applets(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLCollection (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->applets()), "org.kde.koala.HTMLCollection", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_links(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLCollection (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->links()), "org.kde.koala.HTMLCollection", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_forms(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLCollection (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->forms()), "org.kde.koala.HTMLCollection", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_anchors(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLCollection (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->anchors()), "org.kde.koala.HTMLCollection", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_all(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::HTMLCollection (((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->all()), "org.kde.koala.HTMLCollection", TRUE);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_HTMLDocument_cookie(JNIEnv *env, jobject obj)
{
	DOM::DOMString  _domstring;
	_domstring = ((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->cookie();
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_setCookie(JNIEnv *env, jobject obj, jstring arg1)
{
static DOM::DOMString * _domstring_arg1 = 0;
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->setCookie((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, arg1, &_domstring_arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_open(JNIEnv *env, jobject obj)
{
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->open();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_close(JNIEnv *env, jobject obj)
{
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->close();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_write(JNIEnv *env, jobject obj, jstring text)
{
static DOM::DOMString * _domstring_text = 0;
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->write((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, text, &_domstring_text));
	return;
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_HTMLDocument_write__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring text)
//{
//static QString * _qstring_text = 0;
//	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->write((QString&) * (QString *) QtSupport::toQString(env, text, &_qstring_text));
//	return;
//}

JNIEXPORT void JNICALL
Java_org_kde_koala_HTMLDocument_writeln(JNIEnv *env, jobject obj, jstring text)
{
static DOM::DOMString * _domstring_text = 0;
	((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->writeln((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, text, &_domstring_text));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_HTMLDocument_getElementById(JNIEnv *env, jobject obj, jstring elementId)
{
static DOM::DOMString * _domstring_elementId = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Element (((HTMLDocumentJBridge*) 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_HTMLDocument_getElementsByName(JNIEnv *env, jobject obj, jstring elementName)
{
	DOM::NodeList  _qlist;
static DOM::DOMString * _domstring_elementName = 0;
	_qlist = ((HTMLDocumentJBridge*) QtSupport::getQt(env, obj))->getElementsByName((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, elementName, &_domstring_elementName));
	return (jobject) KDESupport::arrayWithNodeList(env, (DOM::NodeList *) &_qlist);
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_HTMLDocument_newHTMLDocument__Lorg_kde_koala_HTMLDocumentImpl_2(JNIEnv *env, jobject obj, jobject impl)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new HTMLDocumentJBridge((HTMLDocumentImpl*) QtSupport::getQt(env, impl)));
//		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
//	}
//	return;
//}

