|
|
|
@ -32,9 +32,9 @@
|
|
|
|
|
#include <dom/html_misc.h>
|
|
|
|
|
#include <tqregexp.h>
|
|
|
|
|
|
|
|
|
|
KHTMLReader::KHTMLReader(KWDWriter *w)
|
|
|
|
|
TDEHTMLReader::TDEHTMLReader(KWDWriter *w)
|
|
|
|
|
{
|
|
|
|
|
_html=new KHTMLPart();
|
|
|
|
|
_html=new TDEHTMLPart();
|
|
|
|
|
_writer=w;
|
|
|
|
|
_it_worked=false;
|
|
|
|
|
}
|
|
|
|
@ -44,9 +44,9 @@ void tqt_enter_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()));
|
|
|
|
|
|
|
|
|
|
_state.clear();
|
|
|
|
@ -72,7 +72,7 @@ bool KHTMLReader::filter(KURL url)
|
|
|
|
|
return _it_worked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTMLReader_state *KHTMLReader::state()
|
|
|
|
|
HTMLReader_state *TDEHTMLReader::state()
|
|
|
|
|
{
|
|
|
|
|
if (_state.count() == 0)
|
|
|
|
|
{
|
|
|
|
@ -87,7 +87,7 @@ HTMLReader_state *KHTMLReader::state()
|
|
|
|
|
return _state.top();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTMLReader_state *KHTMLReader::pushNewState()
|
|
|
|
|
HTMLReader_state *TDEHTMLReader::pushNewState()
|
|
|
|
|
{
|
|
|
|
|
HTMLReader_state *s=new HTMLReader_state;
|
|
|
|
|
s->frameset=state()->frameset;
|
|
|
|
@ -101,7 +101,7 @@ HTMLReader_state *KHTMLReader::pushNewState()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::popState()
|
|
|
|
|
void TDEHTMLReader::popState()
|
|
|
|
|
{
|
|
|
|
|
kdDebug(30503) << "Entering popState" << endl;
|
|
|
|
|
|
|
|
|
@ -127,22 +127,22 @@ void KHTMLReader::popState()
|
|
|
|
|
delete(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::startNewLayout(bool startNewFormat)
|
|
|
|
|
void TDEHTMLReader::startNewLayout(bool startNewFormat)
|
|
|
|
|
{
|
|
|
|
|
TQDomElement layout;
|
|
|
|
|
startNewLayout(startNewFormat,layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::startNewLayout(bool startNewFormat, TQDomElement layout)
|
|
|
|
|
void TDEHTMLReader::startNewLayout(bool startNewFormat, TQDomElement layout)
|
|
|
|
|
{
|
|
|
|
|
kdDebug() << "entering startNewLayout" << endl;
|
|
|
|
|
startNewParagraph(startNewFormat,true);
|
|
|
|
|
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();
|
|
|
|
|
DOM::Document doc=_html->document(); // FIXME parse <HEAD> too
|
|
|
|
|
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;
|
|
|
|
|
// check if this is a text node.
|
|
|
|
@ -207,7 +207,7 @@ void KHTMLReader::parseNode(DOM::Node node)
|
|
|
|
|
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()) {
|
|
|
|
|
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;
|
|
|
|
|
if (e.tagName().lower()=="a") { return parse_a(e); }
|
|
|
|
@ -283,7 +283,7 @@ bool KHTMLReader::parseTag(DOM::Element e)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::startNewParagraph(bool startnewformat, bool startnewlayout)
|
|
|
|
|
void TDEHTMLReader::startNewParagraph(bool startnewformat, bool startnewlayout)
|
|
|
|
|
{
|
|
|
|
|
kdDebug() << "Entering startNewParagraph" << endl;
|
|
|
|
|
|
|
|
|
@ -325,7 +325,7 @@ void KHTMLReader::startNewParagraph(bool startnewformat, bool startnewlayout)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KHTMLReader::~KHTMLReader(){
|
|
|
|
|
TDEHTMLReader::~TDEHTMLReader(){
|
|
|
|
|
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;
|
|
|
|
|
TQString s=e.getAttribute("align").string();
|
|
|
|
|
if (!s.isEmpty())
|
|
|
|
@ -364,7 +364,7 @@ bool KHTMLReader::parse_CommonAttributes(DOM::Element e)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_a(DOM::Element e) {
|
|
|
|
|
bool TDEHTMLReader::parse_a(DOM::Element e) {
|
|
|
|
|
TQString url = e.getAttribute("href").string();
|
|
|
|
|
if (!url.isEmpty())
|
|
|
|
|
{
|
|
|
|
@ -381,7 +381,7 @@ bool KHTMLReader::parse_a(DOM::Element e) {
|
|
|
|
|
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.
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_hr(DOM::Element /*e*/)
|
|
|
|
|
bool TDEHTMLReader::parse_hr(DOM::Element /*e*/)
|
|
|
|
|
{
|
|
|
|
|
startNewParagraph();
|
|
|
|
|
_writer->createHR(state()->paragraph);
|
|
|
|
@ -401,7 +401,7 @@ bool KHTMLReader::parse_hr(DOM::Element /*e*/)
|
|
|
|
|
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
|
|
|
|
|
return false; // a BR tag has no childs.
|
|
|
|
@ -466,7 +466,7 @@ static const TQColor parsecolor(const TQString& colorstring)
|
|
|
|
|
return colorstring;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KHTMLReader::parseStyle(DOM::Element e)
|
|
|
|
|
void TDEHTMLReader::parseStyle(DOM::Element e)
|
|
|
|
|
{
|
|
|
|
|
// styles are broken broken broken broken broken broken.
|
|
|
|
|
//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()) {
|
|
|
|
|
// 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();
|
|
|
|
|
if(table_body.isNull()) {
|
|
|
|
|
// 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.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -612,13 +612,13 @@ bool KHTMLReader::parse_table(DOM::Element e)
|
|
|
|
|
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();
|
|
|
|
|
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
|
|
|
|
|
//pushNewState();
|
|
|
|
@ -644,12 +644,12 @@ bool KHTMLReader::parse_pre(DOM::Element e)
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KHTMLReader::parse_ol(DOM::Element e)
|
|
|
|
|
bool TDEHTMLReader::parse_ol(DOM::Element 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;
|
|
|
|
|
// fixme don't hardcode 12 font size ...
|
|
|
|
@ -676,10 +676,10 @@ bool KHTMLReader::parse_font(DOM::Element e)
|
|
|
|
|
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.
|
|
|
|
|
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;
|
|
|
|
|
_list_depth++;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
_list_depth--;
|
|
|
|
|
kdDebug(30503) << "Leaving KHTMLReader::parse_ul" << endl;
|
|
|
|
|
kdDebug(30503) << "Leaving TDEHTMLReader::parse_ul" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|