|
|
@ -32,9 +32,9 @@
|
|
|
|
#include <dom/html_misc.h>
|
|
|
|
#include <dom/html_misc.h>
|
|
|
|
#include <tqregexp.h>
|
|
|
|
#include <tqregexp.h>
|
|
|
|
|
|
|
|
|
|
|
|
KHTMLReader::KHTMLReader(KWDWriter *w)
|
|
|
|
TDEHTMLReader::TDEHTMLReader(KWDWriter *w)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_html=new KHTMLPart();
|
|
|
|
_html=new TDEHTMLPart();
|
|
|
|
_writer=w;
|
|
|
|
_writer=w;
|
|
|
|
_it_worked=false;
|
|
|
|
_it_worked=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -44,9 +44,9 @@ void tqt_enter_modal( TQWidget *widget );
|
|
|
|
void tqt_leave_modal( TQWidget *widget );
|
|
|
|
void tqt_leave_modal( TQWidget *widget );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::filter(KURL url)
|
|
|
|
bool TDEHTMLReader::filter(KURL url)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "KHTMLReader::filter" << endl;
|
|
|
|
kdDebug(30503) << "TDEHTMLReader::filter" << endl;
|
|
|
|
TQObject::connect(_html,TQT_SIGNAL(completed()),this,TQT_SLOT(completed()));
|
|
|
|
TQObject::connect(_html,TQT_SIGNAL(completed()),this,TQT_SLOT(completed()));
|
|
|
|
|
|
|
|
|
|
|
|
_state.clear();
|
|
|
|
_state.clear();
|
|
|
@ -72,7 +72,7 @@ bool KHTMLReader::filter(KURL url)
|
|
|
|
return _it_worked;
|
|
|
|
return _it_worked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HTMLReader_state *KHTMLReader::state()
|
|
|
|
HTMLReader_state *TDEHTMLReader::state()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_state.count() == 0)
|
|
|
|
if (_state.count() == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -87,7 +87,7 @@ HTMLReader_state *KHTMLReader::state()
|
|
|
|
return _state.top();
|
|
|
|
return _state.top();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HTMLReader_state *KHTMLReader::pushNewState()
|
|
|
|
HTMLReader_state *TDEHTMLReader::pushNewState()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HTMLReader_state *s=new HTMLReader_state;
|
|
|
|
HTMLReader_state *s=new HTMLReader_state;
|
|
|
|
s->frameset=state()->frameset;
|
|
|
|
s->frameset=state()->frameset;
|
|
|
@ -101,7 +101,7 @@ HTMLReader_state *KHTMLReader::pushNewState()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::popState()
|
|
|
|
void TDEHTMLReader::popState()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "Entering popState" << endl;
|
|
|
|
kdDebug(30503) << "Entering popState" << endl;
|
|
|
|
|
|
|
|
|
|
|
@ -127,22 +127,22 @@ void KHTMLReader::popState()
|
|
|
|
delete(s);
|
|
|
|
delete(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::startNewLayout(bool startNewFormat)
|
|
|
|
void TDEHTMLReader::startNewLayout(bool startNewFormat)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQDomElement layout;
|
|
|
|
TQDomElement layout;
|
|
|
|
startNewLayout(startNewFormat,layout);
|
|
|
|
startNewLayout(startNewFormat,layout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::startNewLayout(bool startNewFormat, TQDomElement layout)
|
|
|
|
void TDEHTMLReader::startNewLayout(bool startNewFormat, TQDomElement layout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug() << "entering startNewLayout" << endl;
|
|
|
|
kdDebug() << "entering startNewLayout" << endl;
|
|
|
|
startNewParagraph(startNewFormat,true);
|
|
|
|
startNewParagraph(startNewFormat,true);
|
|
|
|
state()->layout=_writer->setLayout(state()->paragraph,layout);
|
|
|
|
state()->layout=_writer->setLayout(state()->paragraph,layout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::completed()
|
|
|
|
void TDEHTMLReader::completed()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "KHTMLReader::completed" << endl;
|
|
|
|
kdDebug(30503) << "TDEHTMLReader::completed" << endl;
|
|
|
|
tqApp->exit_loop();
|
|
|
|
tqApp->exit_loop();
|
|
|
|
DOM::Document doc=_html->document(); // FIXME parse <HEAD> too
|
|
|
|
DOM::Document doc=_html->document(); // FIXME parse <HEAD> too
|
|
|
|
DOM::NodeList list=doc.getElementsByTagName("body");
|
|
|
|
DOM::NodeList list=doc.getElementsByTagName("body");
|
|
|
@ -170,7 +170,7 @@ void KHTMLReader::completed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::parseNode(DOM::Node node)
|
|
|
|
void TDEHTMLReader::parseNode(DOM::Node node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "Entering parseNode" << endl;
|
|
|
|
kdDebug(30503) << "Entering parseNode" << endl;
|
|
|
|
// check if this is a text node.
|
|
|
|
// check if this is a text node.
|
|
|
@ -207,7 +207,7 @@ void KHTMLReader::parseNode(DOM::Node node)
|
|
|
|
popState();
|
|
|
|
popState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::parse_head(DOM::Element e)
|
|
|
|
void TDEHTMLReader::parse_head(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (DOM::Element items=e.firstChild();!items.isNull();items=items.nextSibling()) {
|
|
|
|
for (DOM::Element items=e.firstChild();!items.isNull();items=items.nextSibling()) {
|
|
|
|
if (items.tagName().string().lower() == "title") {
|
|
|
|
if (items.tagName().string().lower() == "title") {
|
|
|
@ -242,7 +242,7 @@ void KHTMLReader::parse_head(DOM::Element e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parseTag(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parseTag(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "Entering parseTag for " << e.tagName().lower() << endl;
|
|
|
|
kdDebug(30503) << "Entering parseTag for " << e.tagName().lower() << endl;
|
|
|
|
if (e.tagName().lower()=="a") { return parse_a(e); }
|
|
|
|
if (e.tagName().lower()=="a") { return parse_a(e); }
|
|
|
@ -283,7 +283,7 @@ bool KHTMLReader::parseTag(DOM::Element e)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::startNewParagraph(bool startnewformat, bool startnewlayout)
|
|
|
|
void TDEHTMLReader::startNewParagraph(bool startnewformat, bool startnewlayout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug() << "Entering startNewParagraph" << endl;
|
|
|
|
kdDebug() << "Entering startNewParagraph" << endl;
|
|
|
|
|
|
|
|
|
|
|
@ -325,7 +325,7 @@ void KHTMLReader::startNewParagraph(bool startnewformat, bool startnewlayout)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KHTMLReader::~KHTMLReader(){
|
|
|
|
TDEHTMLReader::~TDEHTMLReader(){
|
|
|
|
delete _html;
|
|
|
|
delete _html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -339,9 +339,9 @@ KHTMLReader::~KHTMLReader(){
|
|
|
|
//==============================================================
|
|
|
|
//==============================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_CommonAttributes(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_CommonAttributes(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "entering KHTMLReader::parse_CommonAttributes" << endl;
|
|
|
|
kdDebug(30503) << "entering TDEHTMLReader::parse_CommonAttributes" << endl;
|
|
|
|
kdDebug(30503) << "tagName is " << e.tagName().string() << endl;
|
|
|
|
kdDebug(30503) << "tagName is " << e.tagName().string() << endl;
|
|
|
|
TQString s=e.getAttribute("align").string();
|
|
|
|
TQString s=e.getAttribute("align").string();
|
|
|
|
if (!s.isEmpty())
|
|
|
|
if (!s.isEmpty())
|
|
|
@ -364,7 +364,7 @@ bool KHTMLReader::parse_CommonAttributes(DOM::Element e)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_a(DOM::Element e) {
|
|
|
|
bool TDEHTMLReader::parse_a(DOM::Element e) {
|
|
|
|
TQString url = e.getAttribute("href").string();
|
|
|
|
TQString url = e.getAttribute("href").string();
|
|
|
|
if (!url.isEmpty())
|
|
|
|
if (!url.isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -381,7 +381,7 @@ bool KHTMLReader::parse_a(DOM::Element e) {
|
|
|
|
return true; /* stop parsing recursively */
|
|
|
|
return true; /* stop parsing recursively */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_p(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_p(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// For every starting paragraph, a line break has to be inserted.
|
|
|
|
// For every starting paragraph, a line break has to be inserted.
|
|
|
|
// exception: the first paragraph, e.g. if the <body> starts with a <p>.
|
|
|
|
// exception: the first paragraph, e.g. if the <body> starts with a <p>.
|
|
|
@ -393,7 +393,7 @@ bool KHTMLReader::parse_p(DOM::Element e)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_hr(DOM::Element /*e*/)
|
|
|
|
bool TDEHTMLReader::parse_hr(DOM::Element /*e*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
startNewParagraph();
|
|
|
|
startNewParagraph();
|
|
|
|
_writer->createHR(state()->paragraph);
|
|
|
|
_writer->createHR(state()->paragraph);
|
|
|
@ -401,7 +401,7 @@ bool KHTMLReader::parse_hr(DOM::Element /*e*/)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_br(DOM::Element /*e*/)
|
|
|
|
bool TDEHTMLReader::parse_br(DOM::Element /*e*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
startNewParagraph(false,false); //keep the current format and layout
|
|
|
|
startNewParagraph(false,false); //keep the current format and layout
|
|
|
|
return false; // a BR tag has no childs.
|
|
|
|
return false; // a BR tag has no childs.
|
|
|
@ -466,7 +466,7 @@ static const TQColor parsecolor(const TQString& colorstring)
|
|
|
|
return colorstring;
|
|
|
|
return colorstring;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::parseStyle(DOM::Element e)
|
|
|
|
void TDEHTMLReader::parseStyle(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// styles are broken broken broken broken broken broken.
|
|
|
|
// styles are broken broken broken broken broken broken.
|
|
|
|
//FIXME: wait until getComputedStyle is more than
|
|
|
|
//FIXME: wait until getComputedStyle is more than
|
|
|
@ -529,7 +529,7 @@ void KHTMLReader::parseStyle(DOM::Element e)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_table(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_table(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(_writer->isInTable()) {
|
|
|
|
if(_writer->isInTable()) {
|
|
|
|
// We are already inside of a table. Tables in tables are not supported
|
|
|
|
// We are already inside of a table. Tables in tables are not supported
|
|
|
@ -545,7 +545,7 @@ bool KHTMLReader::parse_table(DOM::Element e)
|
|
|
|
DOM::Element table_body=e.firstChild();
|
|
|
|
DOM::Element table_body=e.firstChild();
|
|
|
|
if(table_body.isNull()) {
|
|
|
|
if(table_body.isNull()) {
|
|
|
|
// If the table_body is empty, we don't continue cause else
|
|
|
|
// If the table_body is empty, we don't continue cause else
|
|
|
|
// KHTML will throw a DOM::DOMException if we try to access
|
|
|
|
// TDEHTML will throw a DOM::DOMException if we try to access
|
|
|
|
// the null element.
|
|
|
|
// the null element.
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -612,13 +612,13 @@ bool KHTMLReader::parse_table(DOM::Element e)
|
|
|
|
return false; // we do our own recursion
|
|
|
|
return false; // we do our own recursion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_img(DOM::Element /*e*/)
|
|
|
|
bool TDEHTMLReader::parse_img(DOM::Element /*e*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TQRect e=e.getRect();
|
|
|
|
//TQRect e=e.getRect();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_pre(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_pre(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if 0 // see Bug #74601 (normal): kword doesn't recognize PRE-tags in HTML
|
|
|
|
#if 0 // see Bug #74601 (normal): kword doesn't recognize PRE-tags in HTML
|
|
|
|
//pushNewState();
|
|
|
|
//pushNewState();
|
|
|
@ -644,12 +644,12 @@ bool KHTMLReader::parse_pre(DOM::Element e)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_ol(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_ol(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return parse_ul(e);
|
|
|
|
return parse_ul(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_font(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_font(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdDebug(30503) << "Entering parse_font" << endl;
|
|
|
|
kdDebug(30503) << "Entering parse_font" << endl;
|
|
|
|
// fixme don't hardcode 12 font size ...
|
|
|
|
// fixme don't hardcode 12 font size ...
|
|
|
@ -676,10 +676,10 @@ bool KHTMLReader::parse_font(DOM::Element e)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_ul(DOM::Element e)
|
|
|
|
bool TDEHTMLReader::parse_ul(DOM::Element e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Parse the tag ul and all its subnodes. Take special care for the li tag.
|
|
|
|
// Parse the tag ul and all its subnodes. Take special care for the li tag.
|
|
|
|
kdDebug(30503) << "Entering KHTMLReader::parse_ul" << endl;
|
|
|
|
kdDebug(30503) << "Entering TDEHTMLReader::parse_ul" << endl;
|
|
|
|
kdDebug(30503) << "_writer->getText(state()->paragraph)=" << _writer->getText(state()->paragraph) << endl;
|
|
|
|
kdDebug(30503) << "_writer->getText(state()->paragraph)=" << _writer->getText(state()->paragraph) << endl;
|
|
|
|
_list_depth++;
|
|
|
|
_list_depth++;
|
|
|
|
if (e.firstChild().nodeName().string().lower() == "#text") // e.g. <ul>this is indented<li>first listitem</li></ul>
|
|
|
|
if (e.firstChild().nodeName().string().lower() == "#text") // e.g. <ul>this is indented<li>first listitem</li></ul>
|
|
|
@ -711,7 +711,7 @@ bool KHTMLReader::parse_ul(DOM::Element e)
|
|
|
|
parseNode(items);
|
|
|
|
parseNode(items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_list_depth--;
|
|
|
|
_list_depth--;
|
|
|
|
kdDebug(30503) << "Leaving KHTMLReader::parse_ul" << endl;
|
|
|
|
kdDebug(30503) << "Leaving TDEHTMLReader::parse_ul" << endl;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|