/***************************************************************************
                            Element.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_element.h>
#include <dom/dom_string.h>
#include <qstring.h>
#include <qcstring.h>

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

class ElementJBridge : public DOM::Element
{
public:
	ElementJBridge() : DOM::Element() {}
	ElementJBridge(const DOM::Node& other) : DOM::Element(other) {}
	ElementJBridge(const DOM::Element& other) : DOM::Element(other) {}
	~ElementJBridge() {QtSupport::qtKeyDeleted(this);}
	ElementJBridge(DOM::ElementImpl* _impl) : DOM::Element(_impl) {}
};


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

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

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

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

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

JNIEXPORT jstring JNICALL
Java_org_kde_koala_Element_getAttribute(JNIEnv *env, jobject obj, jstring name)
{
	DOM::DOMString  _domstring;
static DOM::DOMString * _domstring_name = 0;
	_domstring = ((ElementJBridge*) QtSupport::getQt(env, obj))->getAttribute((DOM::DOMString) * (DOM::DOMString *) KDESupport::toDOMString(env, name, &_domstring_name));
	return KDESupport::fromDOMString(env, &_domstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Element_setAttribute(JNIEnv *env, jobject obj, jstring name, jstring value)
{
static DOM::DOMString * _domstring_value = 0;
static DOM::DOMString * _domstring_name = 0;
	((ElementJBridge*) QtSupport::getQt(env, obj))->setAttribute((DOM::DOMString&) * (DOM::DOMString *) KDESupport::toDOMString(env, name, &_domstring_name), (DOM::DOMString&) * (DOM::DOMString *) KDESupport::toDOMString(env, value, &_domstring_value));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Element_removeAttribute(JNIEnv *env, jobject obj, jstring name)
{
static DOM::DOMString * _domstring_name = 0;
	((ElementJBridge*) QtSupport::getQt(env, obj))->removeAttribute((DOM::DOMString&) * (DOM::DOMString *) KDESupport::toDOMString(env, name, &_domstring_name));
	return;
}

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Element_setAttributeNode(JNIEnv *env, jobject obj, jobject newAttr)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Attr (((ElementJBridge*) QtSupport::getQt(env, obj))->setAttributeNode((DOM::Attr&) *(DOM::Attr *) QtSupport::getQt(env, newAttr))), "org.kde.koala.Attr", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Element_removeAttributeNode(JNIEnv *env, jobject obj, jobject oldAttr)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::Attr (((ElementJBridge*) QtSupport::getQt(env, obj))->removeAttributeNode((DOM::Attr&) *(DOM::Attr *) QtSupport::getQt(env, oldAttr))), "org.kde.koala.Attr", TRUE);
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Element_normalize(JNIEnv *env, jobject obj)
{
	((ElementJBridge*) QtSupport::getQt(env, obj))->normalize();
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Element_style(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new DOM::CSSStyleDeclaration (((ElementJBridge*) QtSupport::getQt(env, obj))->style()), "org.kde.koala.CSSStyleDeclaration", TRUE);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Element_isHTMLElement(JNIEnv *env, jobject obj)
{
	return (jboolean) ((ElementJBridge*) QtSupport::getQt(env, obj))->isHTMLElement();
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_Element_newElement__Lorg_kde_koala_ElementImpl_2(JNIEnv *env, jobject obj, jobject _impl)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new ElementJBridge((ElementImpl*) QtSupport::getQt(env, _impl)));
//		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
//	}
//	return;
//}

