OSDN Git Service

reformat.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sun, 19 Sep 2004 17:46:10 +0000 (17:46 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sun, 19 Sep 2004 17:46:10 +0000 (17:46 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1387 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/libkita/parsemisc.cpp
kita/src/libkita/parsemisc.h

index 5855ae1..9deb335 100644 (file)
@@ -38,26 +38,28 @@ using namespace Kita;
 QCp932Codec* ParseMisc::m_qcpCodec = NULL;
 QTextCodec* ParseMisc::m_utf8Codec = NULL;
 QMutex ParseMisc:: m_codexMutex;
-QString ParseMisc::m_weekstr[7];
+QString ParseMisc::m_weekstr[ 7 ];
 QString ParseMisc::m_colonstr;
 QString ParseMisc::m_colonnamestr;
 
 
-QString ParseMisc::qcpToUnicode( const QString& str ){
+QString ParseMisc::qcpToUnicode( const QString& str )
+{
 
     QMutexLocker locker( & m_codexMutex ); /* QTextCodec is not reentrant. */
 
-    if(!m_qcpCodec) m_qcpCodec = new QCp932Codec();
+    if ( !m_qcpCodec ) m_qcpCodec = new QCp932Codec();
 
     return m_qcpCodec->toUnicode( str );
 }
 
 
-QString ParseMisc::utf8ToUnicode( const QString& str ){
+QString ParseMisc::utf8ToUnicode( const QString& str )
+{
 
     QMutexLocker locker( & m_codexMutex ); /* QTextCodec is not reentrant. */
 
-    if(!m_utf8Codec) m_utf8Codec = QTextCodec::codecForName( "utf8" );
+    if ( !m_utf8Codec ) m_utf8Codec = QTextCodec::codecForName( "utf8" );
 
     return m_utf8Codec->toUnicode( str );
 }
@@ -80,10 +82,10 @@ QString ParseMisc::utf8ToUnicode( const QString& str ){
 /*
   struct RESDAT resdat should be parsed by parseResDat before
   calling this function. struct RESDAT is defined in datinfo.h
-
   If mode = PARSEMODE_DOM, titlenode is DOM tree of title node.
   titletext is ignored.
-
   If mode = PARSEMODE_HTML, titletext is HTML text of title.
   DOM tree is not created. Both hdoc and titlenode are ignored.
   
@@ -95,253 +97,251 @@ QString ParseMisc::utf8ToUnicode( const QString& str ){
 void ParseMisc::parseTITLEdat(
 
     /* input */
-    int mode,                /* mode */
-    DOM::HTMLDocument& hdoc, /* root node of DOM document*/
-    int num,                 /* number of res */
+    int mode,                   /* mode */
+    DOM::HTMLDocument& hdoc,    /* root node of DOM document*/
+    int num,                    /* number of res */
     bool showMailAddress,
-    const RESDAT& resdat,    /* RESDAT is defined in datinfo.h */
+    const RESDAT& resdat,       /* RESDAT is defined in datinfo.h */
 
     /* output */
-    DOM::Element &titlenode, /* DOM tree of title */
+    DOM::Element &titlenode,    /* DOM tree of title */
     QString& titletext       /* HTML or plain text of title */
 
-    ){
+)
+{
 
     /*-----------------------------*/
     /* init                        */
     /*-----------------------------*/
 
-    if( !resdat.parsed ){
-       titletext = QString::null;
-       return;
+    if ( !resdat.parsed ) {
+        titletext = QString::null;
+        return ;
     }
 
     const QString& str_name = resdat.name;
     const QString& str_address = resdat.address;
     const QString& str_id = resdat.id;
-    
+
     unsigned int i;
     DOM::Element tmpelm;
-    QString linkstr,linkstr2,linkurl,addstr,tmpstr;
+    QString linkstr, linkstr2, linkurl, addstr, tmpstr;
 
-    if( m_colonstr == QString::null ){
-       m_colonstr = utf8ToUnicode( KITAUTF8_COLON );
-       m_colonnamestr = utf8ToUnicode( KITAUTF8_NAME );
+    if ( m_colonstr == QString::null ) {
+        m_colonstr = utf8ToUnicode( KITAUTF8_COLON );
+        m_colonnamestr = utf8ToUnicode( KITAUTF8_NAME );
     }
 
     titletext = QString::null;
 
-    
-    /*-----------------------------*/    
+
+    /*-----------------------------*/
     /* number                      */
     /*-----------------------------*/
-    
+
     linkstr = QString( "%1" ).arg( num );
-    linkurl = "#write"+linkstr;
+    linkurl = "#write" + linkstr;
+
+    switch ( mode ) {
 
-    switch( mode ){
-       
     case PARSEMODE_DOM:
-       
-       tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
-       tmpelm.setAttribute( "class", "res_title_number" );
-       tmpelm = tmpelm.appendChild( hdoc.createElement( "A" ) );
-       {
-           /* set anchor id = number */
-           tmpelm.setAttribute( "href", linkurl );
-           tmpelm.appendChild( hdoc.createTextNode( linkstr ));
-       }
-       break;
+
+        tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
+        tmpelm.setAttribute( "class", "res_title_number" );
+        tmpelm = tmpelm.appendChild( hdoc.createElement( "A" ) );
+        {
+            /* set anchor id = number */
+            tmpelm.setAttribute( "href", linkurl );
+            tmpelm.appendChild( hdoc.createTextNode( linkstr ) );
+        }
+        break;
 
     case PARSEMODE_HTML:
-       titletext += "<td class=\"pop_res_title_number\"><a href=\"" + linkurl +"\">";
-       titletext += linkstr;
-       titletext +="</a>";
-       break;
+        titletext += "<td class=\"pop_res_title_number\"><a href=\"" + linkurl + "\">";
+        titletext += linkstr;
+        titletext += "</a>";
+        break;
 
     case PARSEMODE_TEXT:
-       titletext += linkstr;
-       break;  
-       
+        titletext += linkstr;
+        break;
+
     }
 
-    
+
     /*-----------------------------*/
     /* name & mail address         */
     /*-----------------------------*/
-    
+
     DOM::Element namenode;
     linkurl = QString::null;
 
     /* parse name & address strings */
-    parseBODYdatText(PARSEMODE_TEXT,str_name,linkstr);
-    if( str_address != QString::null ) parseBODYdatText( PARSEMODE_TEXT, str_address, addstr );
+    parseBODYdatText( PARSEMODE_TEXT, str_name, linkstr );
+    if ( str_address != QString::null ) parseBODYdatText( PARSEMODE_TEXT, str_address, addstr );
     else addstr = QString::null;
 
     tmpstr = " " + m_colonnamestr;
-    switch( mode ){
-       
+    switch ( mode ) {
+
     case PARSEMODE_DOM:
-       tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
-       tmpelm.setAttribute( "class", "res_title_name" );
-       tmpelm.appendChild( hdoc.createTextNode( tmpstr ) );
-       namenode = tmpelm.appendChild( hdoc.createElement( "B" ) );
-       break;
+        tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
+        tmpelm.setAttribute( "class", "res_title_name" );
+        tmpelm.appendChild( hdoc.createTextNode( tmpstr ) );
+        namenode = tmpelm.appendChild( hdoc.createElement( "B" ) );
+        break;
 
     case PARSEMODE_HTML:
         titletext += "<td class=\"pop_res_title_name\">" + tmpstr;
         break;
     case PARSEMODE_TEXT:
-       titletext += tmpstr;
-       break;  
+        titletext += tmpstr;
+        break;
     }
 
     /* show name with mail address, or show name only */
-    if ( showMailAddress || addstr == QString::null ){
+    if ( showMailAddress || addstr == QString::null ) {
+
+        const QChar * chpt = linkstr.unicode();
+        unsigned int length = linkstr.length();
+
+        unsigned int pos;
+        int refNum[ 2 ];
+        i = 0;
+
+        bool ancChain = TRUE;
+        /* ancChain is chain for anchor. For examle, if anchor "2"
+           appeared, ancChain is set to TRUE. Moreover, if next strings
+           are "=5", anchor for 5 is also set. Thus, we can obtain anchors
+           for strings "2=5" as follows:
 
-       const QChar *chpt = linkstr.unicode();
-       unsigned int length = linkstr.length();
+           <a href="#2">2</a><a href="#5">=5</a>
+        */
 
-       unsigned int pos;
-       int refNum[2];
-       i = 0;
+        /* show name */
+        for ( ;; ) {
+
+            linkurl = QString::null;
+            linkstr2 = QString::null;
+
+            /* get strings & anchor for digits */
+            if ( showMailAddress && ancChain ) {
+
+                if ( ( ancChain = parseResAnchor( chpt + i, length - i, linkstr2, refNum, pos ) ) ) {
+
+                    linkurl = QString( "#%1" ).arg( refNum[ 0 ] );
+                    if ( refNum[ 1 ] ) linkurl += QString( "-%1" ).arg( refNum[ 1 ] );
+                }
+
+                i += pos;
+            } else { /* get strings for non-digits */
+
+                while ( i < length ) linkstr2 += chpt[ i++ ];
+            }
+
+            if ( linkstr2 != QString::null ) {
+
+                switch ( mode ) {
+
+                case PARSEMODE_DOM:
+
+                    if ( linkurl != QString::null ) { /* create anchor */
+
+                        tmpelm = namenode.appendChild( hdoc.createElement( "A" ) );
+                        {
+                            tmpelm.setAttribute( "href", linkurl );
+                            tmpelm.appendChild( hdoc.createTextNode( linkstr2 ) );
+                        }
+
+
+                    } else {
+
+                        tmpelm = namenode.appendChild( hdoc.createElement( "SPAN" ) );
+                        {
+                            tmpelm.setAttribute( "style", "color: green" );
+                            tmpelm.appendChild( hdoc.createTextNode( linkstr2 ) );
+                        }
+                    }
+
+                    break;
+
+                case PARSEMODE_HTML:
+                case PARSEMODE_TEXT:
+
+                    if ( mode == PARSEMODE_HTML
+                            && linkurl != QString::null ) { /* create anchor */
+
+                        titletext += "<a href=\"" + linkurl + "\">";
+                        titletext += linkstr2;
+                        titletext += "</a>";
+
+                    } else titletext += linkstr2;
+
+                    break;
+                }
+            }
+
+            if ( i >= linkstr.length() ) break;
+
+        } /* for(;;) */
+
+
+        /* show mail address */
+        switch ( mode ) {
+
+        case PARSEMODE_DOM:
+
+            if ( showMailAddress && addstr != QString::null ) {
+                tmpstr = QString( " [" ) + addstr + "]";
+                namenode.appendChild( hdoc.createTextNode( tmpstr ) );
+            }
+
+            break;
+
+        case PARSEMODE_HTML:
+        case PARSEMODE_TEXT:
+
+            if ( showMailAddress && addstr != QString::null ) {
+                tmpstr = QString( " [" ) + addstr + "]";
+                titletext += tmpstr;
+            }
+
+            break;
+        }
 
-       bool ancChain = TRUE;
-       /* ancChain is chain for anchor. For examle, if anchor "2"
-          appeared, ancChain is set to TRUE. Moreover, if next strings
-          are "=5", anchor for 5 is also set. Thus, we can obtain anchors
-          for strings "2=5" as follows:
-
-          <a href="#2">2</a><a href="#5">=5</a>
-       */
-       
-       /* show name */
-       for(;;){
-
-           linkurl = QString::null;
-           linkstr2 = QString::null;
-
-           /* get strings & anchor for digits */
-           if(showMailAddress && ancChain){
-               
-               if( ( ancChain = parseResAnchor(chpt+i,length-i,linkstr2,refNum,pos) ) ) {
-
-                   linkurl = QString("#%1").arg(refNum[0]);
-                   if(refNum[1]) linkurl += QString("-%1").arg(refNum[1]);
-               }
-
-               i += pos;
-           }
-           
-           else{ /* get strings for non-digits */
-
-               while( i < length ) linkstr2 += chpt[ i++ ];
-           }
-
-           if( linkstr2 != QString::null){
-
-               switch(mode){
-
-               case PARSEMODE_DOM:
-
-                   if( linkurl != QString::null){ /* create anchor */
-               
-                       tmpelm = namenode.appendChild( hdoc.createElement( "A" ) );
-                       {
-                           tmpelm.setAttribute( "href", linkurl );
-                           tmpelm.appendChild( hdoc.createTextNode( linkstr2  ) );
-                       }
-
-               
-                   } else { 
-       
-                       tmpelm = namenode.appendChild( hdoc.createElement( "SPAN" ) );
-                       {
-                           tmpelm.setAttribute( "style", "color: green" );
-                           tmpelm.appendChild( hdoc.createTextNode( linkstr2 ) );
-                       }
-                   }
-
-                   break;
-
-               case PARSEMODE_HTML:
-               case PARSEMODE_TEXT:
-       
-                   if( mode == PARSEMODE_HTML
-                       && linkurl != QString::null){ /* create anchor */
-    
-                       titletext += "<a href=\"" + linkurl +"\">";
-                       titletext += linkstr2;
-                       titletext +="</a>";
-
-                   }
-                   else titletext += linkstr2;
-
-                   break;
-               }
-           }
-
-           if( i >= linkstr.length()) break;       
-
-       } /* for(;;) */
-
-
-       /* show mail address */ 
-       switch(mode){
-
-       case PARSEMODE_DOM:
-
-           if ( showMailAddress && addstr != QString::null ) {
-               tmpstr = QString( " [" ) + addstr + "]";
-               namenode.appendChild( hdoc.createTextNode( tmpstr ) );
-           }
-
-           break;
-
-       case PARSEMODE_HTML:
-       case PARSEMODE_TEXT:
-
-           if ( showMailAddress && addstr != QString::null ) {
-               tmpstr = QString( " [" ) + addstr + "]";
-               titletext += tmpstr;
-           }
-       
-           break;
-       }
-       
     } /* if ( showMailAddress || addstr == QString::null ) */
 
     /* don't show mail address (i.e. showMailAddress == FALSE) */
     else {
 
-       linkurl = QString( "mailto:" ) + addstr;
-
-       switch(mode){
-
-       case PARSEMODE_DOM:
-           tmpelm = namenode.appendChild( hdoc.createElement( "A" ) );
-           {
-               tmpelm.setAttribute( "href", linkurl );
-               tmpelm.setAttribute( "title", addstr );
-               tmpelm.appendChild( hdoc.createTextNode( linkstr ) );
-           }
-           break;
-
-       case PARSEMODE_HTML:
-       
-           titletext += "<a href=\"" + linkurl;
-           titletext += " title=\"" + addstr + "\">";
-           titletext += linkstr;
-           titletext +="</a>";
-
-           break;
-           
-       case PARSEMODE_TEXT:
-           titletext += linkstr;
-           break;
-       }
+        linkurl = QString( "mailto:" ) + addstr;
+
+        switch ( mode ) {
+
+        case PARSEMODE_DOM:
+            tmpelm = namenode.appendChild( hdoc.createElement( "A" ) );
+            {
+                tmpelm.setAttribute( "href", linkurl );
+                tmpelm.setAttribute( "title", addstr );
+                tmpelm.appendChild( hdoc.createTextNode( linkstr ) );
+            }
+            break;
+
+        case PARSEMODE_HTML:
+
+            titletext += "<a href=\"" + linkurl;
+            titletext += " title=\"" + addstr + "\">";
+            titletext += linkstr;
+            titletext += "</a>";
+
+            break;
+
+        case PARSEMODE_TEXT:
+            titletext += linkstr;
+            break;
+        }
     }
-    
+
 
     /*-----------------------------*/
     /* date & ID                   */
@@ -350,61 +350,61 @@ void ParseMisc::parseTITLEdat(
     /* show date */
     tmpstr = " " + m_colonstr + resdat.date + " ";
 
-    switch(mode){
+    switch ( mode ) {
 
     case PARSEMODE_DOM:
-       tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
-       tmpelm.setAttribute( "class", "res_title_date" );
-       tmpelm.appendChild( hdoc.createTextNode( tmpstr ) );
-       break;
+        tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
+        tmpelm.setAttribute( "class", "res_title_date" );
+        tmpelm.appendChild( hdoc.createTextNode( tmpstr ) );
+        break;
 
     case PARSEMODE_HTML:
         titletext += "<td class=\"pop_res_title_date\">" + tmpstr;
         break;
 
     case PARSEMODE_TEXT:
-       titletext += tmpstr;
-       break;
+        titletext += tmpstr;
+        break;
 
     }
 
     /* show ID */
-    if ( str_id != QString::null){
-       
-       if ( str_id == "???" ) tmpstr = "ID:" + str_id;
-       else  tmpstr = ":" + str_id;
+    if ( str_id != QString::null ) {
 
-       switch(mode){
+        if ( str_id == "???" ) tmpstr = "ID:" + str_id;
+        else tmpstr = ":" + str_id;
 
-       case PARSEMODE_DOM:
+        switch ( mode ) {
+
+        case PARSEMODE_DOM:
 
             tmpelm = titlenode.appendChild( hdoc.createElement( "TD" ) );
             tmpelm.setAttribute( "class", "res_title_id" );
-           if(tmpstr.left(3) != "ID:"){
-               DOM::Element aelm = tmpelm.appendChild( hdoc.createElement( "A" ) );
-               {
-                   aelm.setAttribute( "href", "#idpop" + str_id );
-                   aelm.appendChild( hdoc.createTextNode( "ID" ) );
-               }
-           }
-           
-           tmpelm.appendChild( hdoc.createTextNode( tmpstr ) );
-           break;
-
-       case PARSEMODE_HTML:
+            if ( tmpstr.left( 3 ) != "ID:" ) {
+                DOM::Element aelm = tmpelm.appendChild( hdoc.createElement( "A" ) );
+                {
+                    aelm.setAttribute( "href", "#idpop" + str_id );
+                    aelm.appendChild( hdoc.createTextNode( "ID" ) );
+                }
+            }
+
+            tmpelm.appendChild( hdoc.createTextNode( tmpstr ) );
+            break;
+
+        case PARSEMODE_HTML:
             titletext += "<td class=\"pop_res_title_id\">";
-           if(tmpstr.left(3) != "ID:")
-               titletext += "<a href=\"#idpop" + str_id + "\">ID</a>";
-           titletext += tmpstr;
-           break;
-           
-       case PARSEMODE_TEXT:
-           if(tmpstr.left(3) != "ID:") titletext += "ID";
-           titletext += tmpstr;
-           break;
-       }
+            if ( tmpstr.left( 3 ) != "ID:" )
+                titletext += "<a href=\"#idpop" + str_id + "\">ID</a>";
+            titletext += tmpstr;
+            break;
+
+        case PARSEMODE_TEXT:
+            if ( tmpstr.left( 3 ) != "ID:" ) titletext += "ID";
+            titletext += tmpstr;
+            break;
+        }
     }
-    
+
 }
 
 
@@ -414,24 +414,25 @@ void ParseMisc::parseTITLEdat(
 void ParseMisc::parseTITLEdatText(
 
     /* input */
-    int mode,                /* mode = PARSEMODE_HTML or PARSEMODE_TEXT */
+    int mode,                   /* mode = PARSEMODE_HTML or PARSEMODE_TEXT */
     int num,
     bool showMailAddress,
-    const RESDAT& resdat,          /* RESDAT is defined in datinfo.h */
+    const RESDAT& resdat,             /* RESDAT is defined in datinfo.h */
 
     /* output */
     QString& titletext       /* HTML or plain text of title */
-    
-    ){
-    
+
+)
+{
+
     /* dummy */
     DOM::HTMLDocument hdoc;
     DOM::Element titlenode;
 
-    parseTITLEdat(mode,hdoc,num,showMailAddress,resdat,titlenode,titletext);
+    parseTITLEdat( mode, hdoc, num, showMailAddress, resdat, titlenode, titletext );
 }
 
-    
+
 
 
 
@@ -444,7 +445,7 @@ void ParseMisc::parseTITLEdatText(
 /*
   If mode = PARSEMODE_DOM, bodynode is DOM tree of body.
   bodytext is ignored.
-
   If mode = PARSEMODE_HTML, bodytext is HTML text of body.
   DOM tree is not created. Both hdoc and bodynode are ignored.
   
@@ -456,28 +457,29 @@ void ParseMisc::parseTITLEdatText(
 void ParseMisc::parseBODYdat(
 
     /* input */
-    int mode,                /* mode */
-    const QString &rawStr,   /* raw strings of body text */
-    DOM::HTMLDocument& hdoc, /* root node of DOM document*/
-    bool showAA,             /* show AA (for KDE3.1x) */
-    
+    int mode,                   /* mode */
+    const QString &rawStr,      /* raw strings of body text */
+    DOM::HTMLDocument& hdoc,    /* root node of DOM document*/
+    bool showAA,                /* show AA (for KDE3.1x) */
+
     /* output */
-    DOM::Element &bodynode, /* DOM tree of body */
+    DOM::Element &bodynode,    /* DOM tree of body */
     QString& bodytext       /* HTML or plain text of body */
 
-    ){
+)
+{
 
     /*-----------------------------------------*/
     /* init                                    */
-    
+
     unsigned int i, i2, index, pos, length = rawStr.length();
     DOM::Element tmpelm;
     QString linkstr, linkurl;
-           
+
     const QChar *chpt = rawStr.unicode();
     QString lineStr = QString::null;
     bodytext = QString::null;
-    
+
     bool ancChain = FALSE;
     /* ancChain is chain for anchor. For examle, if anchor "&gt;2"
        appeared, ancChain is set to TRUE. Moreover, if next strings
@@ -489,153 +491,153 @@ void ParseMisc::parseBODYdat(
 
 
     /*-----------------------------------------*/
-    
+
     for ( i = index = 0 ; i < length ; i++ ) {
 
         switch ( chpt[ i ].unicode() ) {
 
         case '<':
 
-           /* " <br> " */
-           if (chpt[i + 1] == 'b' && chpt[i + 2] == 'r' && chpt[i + 3]  == '>'){
-
-               i2 = i - index;
-               if(i  > 0 && chpt[i-1] == ' ') i2--; /* remove space before <br> */
-               lineStr += rawStr.mid( index, i2 );
-
-               switch ( mode ){
-
-               case PARSEMODE_DOM:
-               
-                   /* add BR node */
-                   bodynode.appendChild( hdoc.createTextNode( lineStr ) );
-                   bodynode.appendChild( hdoc.createElement( "BR" ) );
-
-                   /* show Ascii Art (for KDE3.1*) */
-                   if ( showAA ) {
-
-                       /* put the span node after BR node */
-                       tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
-                       {
-                           tmpelm.setAttribute( "style", "color: white" );
-                           tmpelm.appendChild( hdoc.createTextNode( "" ) );
-                       }
-                   }
-                   
-                   break;
-                   
-               case PARSEMODE_HTML:
-
-                   bodytext += lineStr;
-                   bodytext += "<br>";
-                   /* show Ascii Art (for KDE3.1*) */
-                   if ( showAA ) {
-                       bodytext += "<span style=\"color: white\"></span>";
-                   }
-                   break;
-                   
-               case PARSEMODE_TEXT:
-
-                   bodytext += lineStr;
-                   bodytext += '\n';
-
-                   break;
-               }
-
-               index = i + 4;
-               if( chpt[index] == ' ') index++; /* remove space after <br> */
-               i = index - 1;
-               lineStr = QString::null;
-               ancChain = FALSE;
-           }
-
-           /*----------------------------------------*/
-           
-           /* remove HTML tags <[^>]*>  */
-           else{
-               lineStr += rawStr.mid( index, i - index );
-               while( chpt[i] != '>' && i < length ) i++;
-               index = i+1;
-           }
-
-           break;
+            /* " <br> " */
+            if ( chpt[ i + 1 ] == 'b' && chpt[ i + 2 ] == 'r' && chpt[ i + 3 ] == '>' ) {
+
+                i2 = i - index;
+                if ( i > 0 && chpt[ i - 1 ] == ' ' ) i2--; /* remove space before <br> */
+                lineStr += rawStr.mid( index, i2 );
+
+                switch ( mode ) {
+
+                case PARSEMODE_DOM:
+
+                    /* add BR node */
+                    bodynode.appendChild( hdoc.createTextNode( lineStr ) );
+                    bodynode.appendChild( hdoc.createElement( "BR" ) );
+
+                    /* show Ascii Art (for KDE3.1*) */
+                    if ( showAA ) {
+
+                        /* put the span node after BR node */
+                        tmpelm = bodynode.appendChild( hdoc.createElement( "SPAN" ) );
+                        {
+                            tmpelm.setAttribute( "style", "color: white" );
+                            tmpelm.appendChild( hdoc.createTextNode( "" ) );
+                        }
+                    }
+
+                    break;
+
+                case PARSEMODE_HTML:
+
+                    bodytext += lineStr;
+                    bodytext += "<br>";
+                    /* show Ascii Art (for KDE3.1*) */
+                    if ( showAA ) {
+                        bodytext += "<span style=\"color: white\"></span>";
+                    }
+                    break;
+
+                case PARSEMODE_TEXT:
+
+                    bodytext += lineStr;
+                    bodytext += '\n';
+
+                    break;
+                }
+
+                index = i + 4;
+                if ( chpt[ index ] == ' ' ) index++; /* remove space after <br> */
+                i = index - 1;
+                lineStr = QString::null;
+                ancChain = FALSE;
+            }
+
+            /*----------------------------------------*/
+
+            /* remove HTML tags <[^>]*>  */
+            else {
+                lineStr += rawStr.mid( index, i - index );
+                while ( chpt[ i ] != '>' && i < length ) i++;
+                index = i + 1;
+            }
+
+            break;
 
             /*----------------------------------------*/
 
-       case 'h': /* "http://" or "ttp://" or "tp:" */
-       case 't':
+        case 'h':    /* "http://" or "ttp://" or "tp:" */
+        case 't':
+
+            if ( mode != PARSEMODE_TEXT
+                    && parseLink( chpt + i, length - i, linkstr, linkurl, pos ) ) {
 
-           if( mode != PARSEMODE_TEXT
-               && parseLink( chpt + i, length - i,linkstr, linkurl, pos) ){
+                lineStr += rawStr.mid( index, i - index );
 
-               lineStr += rawStr.mid( index, i - index );
-               
-               switch ( mode ){
+                switch ( mode ) {
 
-               case PARSEMODE_DOM:
+                case PARSEMODE_DOM:
 
-                   /* create A node */
-                   bodynode.appendChild( hdoc.createTextNode( lineStr ) );
+                    /* create A node */
+                    bodynode.appendChild( hdoc.createTextNode( lineStr ) );
 
-                   tmpelm = bodynode.appendChild( hdoc.createElement( "A" ) );
-                   {
-                       tmpelm.setAttribute( "href", linkurl );
-                       tmpelm.appendChild( hdoc.createTextNode( linkstr ));
-                   }
+                    tmpelm = bodynode.appendChild( hdoc.createElement( "A" ) );
+                    {
+                        tmpelm.setAttribute( "href", linkurl );
+                        tmpelm.appendChild( hdoc.createTextNode( linkstr ) );
+                    }
 
-                   break;
+                    break;
 
-               case PARSEMODE_HTML:
-                   bodytext += lineStr;
-                   bodytext += "<a href=\"" + linkurl +"\">";
-                   bodytext += linkstr;
-                   bodytext +="</a>";
-                   break;
-               }
+                case PARSEMODE_HTML:
+                    bodytext += lineStr;
+                    bodytext += "<a href=\"" + linkurl + "\">";
+                    bodytext += linkstr;
+                    bodytext += "</a>";
+                    break;
+                }
 
-               index = i + pos;
-               i = index -1;
-               lineStr = QString::null;
+                index = i + pos;
+                i = index - 1;
+                lineStr = QString::null;
             }
-           break;
+
+            break;
 
             /*----------------------------------*/
 
         case '&':
-           
-           /* &gt; */
-            if ( ( mode == PARSEMODE_DOM || mode == PARSEMODE_HTML )
-                && chpt[i + 1] == 'g' && chpt[i + 2] == 't' && chpt[i + 3]  == ';')
-                ancChain = createResAnchor( mode, rawStr, hdoc, bodynode, bodytext, chpt, i, index, lineStr);
-           /* special char */
-           else if ( mode == PARSEMODE_DOM || mode == PARSEMODE_TEXT ){
-
-               QString tmpstr;
-               tmpstr = parseSpecialChar(chpt + i, pos);
 
-               if ( tmpstr != QString::null ){
-                   lineStr += rawStr.mid( index, i - index ) + tmpstr;
-                   index = i + pos;
-                   i = index - 1;
-               }
-           }
+            /* &gt; */
+            if ( ( mode == PARSEMODE_DOM || mode == PARSEMODE_HTML )
+                    && chpt[ i + 1 ] == 'g' && chpt[ i + 2 ] == 't' && chpt[ i + 3 ] == ';' )
+                ancChain = createResAnchor( mode, rawStr, hdoc, bodynode, bodytext, chpt, i, index, lineStr );
+            /* special char */
+            else if ( mode == PARSEMODE_DOM || mode == PARSEMODE_TEXT ) {
+
+                QString tmpstr;
+                tmpstr = parseSpecialChar( chpt + i, pos );
+
+                if ( tmpstr != QString::null ) {
+                    lineStr += rawStr.mid( index, i - index ) + tmpstr;
+                    index = i + pos;
+                    i = index - 1;
+                }
+            }
 
             break;
 
             /*----------------------------------------*/
-           
+
             /* unicode '>'  */
         case UTF16_BRACKET:
-           if( mode != PARSEMODE_TEXT )
-                ancChain = createResAnchor( mode, rawStr, hdoc, bodynode, bodytext, chpt, i, index, lineStr);
+            if ( mode != PARSEMODE_TEXT )
+                ancChain = createResAnchor( mode, rawStr, hdoc, bodynode, bodytext, chpt, i, index, lineStr );
             break;
-           
+
             /*----------------------------------*/
 
-       default:
-           if(mode != PARSEMODE_TEXT && ancChain)
-                ancChain = createResAnchor( mode, rawStr, hdoc, bodynode, bodytext, chpt, i, index, lineStr);
+        default:
+            if ( mode != PARSEMODE_TEXT && ancChain )
+                ancChain = createResAnchor( mode, rawStr, hdoc, bodynode, bodytext, chpt, i, index, lineStr );
         }
     }
 
@@ -643,19 +645,19 @@ void ParseMisc::parseBODYdat(
     /*---------------------------*/
 
     lineStr += rawStr.mid( index );
-       
-    switch ( mode ){
+
+    switch ( mode ) {
 
     case PARSEMODE_DOM:
-       bodynode.appendChild( hdoc.createTextNode( lineStr ) );
-       break;
+        bodynode.appendChild( hdoc.createTextNode( lineStr ) );
+        break;
 
     case PARSEMODE_HTML:
-    case PARSEMODE_TEXT:       
-       bodytext += lineStr;
-       break;
+    case PARSEMODE_TEXT:
+        bodytext += lineStr;
+        break;
     }
-    
+
 }
 
 
@@ -665,37 +667,38 @@ void ParseMisc::parseBODYdat(
 void ParseMisc::parseBODYdatText(
 
     /* input */
-    int mode,                /* mode = PARSEMODE_HTML or PARSEMODE_TEXT */
-    const QString &rawStr,   /* raw strings of body text */
-    
+    int mode,                   /* mode = PARSEMODE_HTML or PARSEMODE_TEXT */
+    const QString &rawStr,      /* raw strings of body text */
+
     /* output */
     QString& bodytext       /* HTML or plain text of body */
 
-    ){
+)
+{
 
     /* dummy */
     DOM::HTMLDocument hdoc;
     DOM::Element bodynode;
 
-    parseBODYdat(mode,rawStr,hdoc,FALSE,bodynode,bodytext);
+    parseBODYdat( mode, rawStr, hdoc, FALSE, bodynode, bodytext );
 }
 
 
 
 /*--------------------------------------------*/
 /* get HTML from RESDAT                       */
-/* 
+/*
   resdat should be parsed by parseResDat before
   calling this function.
   
   struct RESDAT is defined in datinfo.h .     */ /* public */
-QString ParseMisc::ResDatToHtml(const RESDAT& resdat, int num, bool showAddr )
+QString ParseMisc::ResDatToHtml( const RESDAT& resdat, int num, bool showAddr )
 {
-    QString result,titletext,bodytext;
-    
-    ParseMisc::parseTITLEdatText(PARSEMODE_HTML,num,showAddr,resdat,titletext);
-    ParseMisc::parseBODYdatText(PARSEMODE_HTML,resdat.body,bodytext);
+    QString result, titletext, bodytext;
+
+    ParseMisc::parseTITLEdatText( PARSEMODE_HTML, num, showAddr, resdat, titletext );
+    ParseMisc::parseBODYdatText( PARSEMODE_HTML, resdat.body, bodytext );
+
     result = QString( "<div class=\"pop_res_block\"><table class=\"pop_res_title\"><tr>" );
     result += titletext;
     result += "</tr></table><div class=\"pop_res_body\">";
@@ -710,7 +713,7 @@ QString ParseMisc::ResDatToHtml(const RESDAT& resdat, int num, bool showAddr )
 /*--------------------------------------------*/
 /* get HTML from raw data                     */ /* public */
 
-QString ParseMisc::DatToHtml(const QString& rawData, int num, bool showAddr )
+QString ParseMisc::DatToHtml( const QString& rawData, int num, bool showAddr )
 {
     QString tmpstr;
     RESDAT resdat;
@@ -718,9 +721,9 @@ QString ParseMisc::DatToHtml(const QString& rawData, int num, bool showAddr )
     resdat.linestr = rawData;
     resdat.set = TRUE;
     resdat.parsed = FALSE;
-    parseResDat(resdat,tmpstr);
+    parseResDat( resdat, tmpstr );
 
-    return ResDatToHtml(resdat,num,showAddr);
+    return ResDatToHtml( resdat, num, showAddr );
 }
 
 
@@ -736,16 +739,16 @@ QString ParseMisc::DatToHtml(const QString& rawData, int num, bool showAddr )
 /* parsing function for anchor (>>digits)   */
 /*------------------------------------------*/ /* public */
 
-/* This fuction parses res anchor.                          
-
+/* This fuction parses res anchor.
    For example, if cdat = "&gt;12-20", then
-
    linkstr = ">12-20",
    refNum[0] = 12,
    refNum[1] = 20,
    pos (= length of cdat ) = 9,
    ret = TRUE;
-
 */
 
 bool ParseMisc::parseResAnchor(
@@ -754,7 +757,8 @@ bool ParseMisc::parseResAnchor(
     const QChar *cdat, const unsigned int length,
 
     /* output */
-    QString& linkstr, int* refNum, unsigned int& pos ){
+    QString& linkstr, int* refNum, unsigned int& pos )
+{
 
     struct LocalFunc {
         static bool isHYPHEN( unsigned short c )
@@ -764,7 +768,7 @@ bool ParseMisc::parseResAnchor(
             if ( c == '-'
                     || ( c >= 0x2010 && c <= 0x2015 )
                     || ( c == 0x2212 )
-                    || ( c == 0xFF0D )      /* UTF8: 0xEFBC8D */
+                    || ( c == 0xFF0D )         /* UTF8: 0xEFBC8D */
                ) {
                 return TRUE;
             }
@@ -776,16 +780,16 @@ bool ParseMisc::parseResAnchor(
     bool ret = FALSE;
     int i;
 
-    if( length == 0 ) return FALSE;
-    
+    if ( length == 0 ) return FALSE;
+
     linkstr = QString::null;
-    refNum[0] = 0;
-    refNum[1] = 0;    
+    refNum[ 0 ] = 0;
+    refNum[ 1 ] = 0;
     pos = 0;
 
     /* check '>' twice */
     for ( i = 0;i < 2;i++ ) {
-       
+
         if ( cdat[ pos ].unicode() == UTF16_BRACKET ) {
             linkstr += cdat[ pos ];
             pos++;
@@ -816,30 +820,30 @@ bool ParseMisc::parseResAnchor(
     /* check digits */
     int hyphen = 0;
 
-       for ( i = 0 ; i < KITA_RESDIGIT + 1 && pos < length ; i++, pos++ ) {
+    for ( i = 0 ; i < KITA_RESDIGIT + 1 && pos < length ; i++, pos++ ) {
 
-           unsigned short c = cdat[ pos ].unicode();
+        unsigned short c = cdat[ pos ].unicode();
 
-           if ( ( c < UTF16_0 || c > UTF16_9 )
-                && ( c < '0' || c > '9' )
-                && ( !LocalFunc::isHYPHEN( c )
-                     || ( i == 0 && LocalFunc::isHYPHEN( c ) )
-                     || ( hyphen && LocalFunc::isHYPHEN( c ) ) )
-               ) break;
+        if ( ( c < UTF16_0 || c > UTF16_9 )
+                && ( c < '0' || c > '9' )
+                && ( !LocalFunc::isHYPHEN( c )
+                     || ( i == 0 && LocalFunc::isHYPHEN( c ) )
+                     || ( hyphen && LocalFunc::isHYPHEN( c ) ) )
+           ) break;
 
-           linkstr += cdat[ pos ];
+        linkstr += cdat[ pos ];
 
-           if ( LocalFunc::isHYPHEN( c ) ) {
-               hyphen = 1;
-               i = -1;
-           } else {
-               if ( c >= UTF16_0 ) c = '0' + cdat[ pos ].unicode() - UTF16_0;
-               refNum[hyphen] *= 10;
-               refNum[hyphen] += c - '0';
-           }
+        if ( LocalFunc::isHYPHEN( c ) ) {
+            hyphen = 1;
+            i = -1;
+        } else {
+            if ( c >= UTF16_0 ) c = '0' + cdat[ pos ].unicode() - UTF16_0;
+            refNum[ hyphen ] *= 10;
+            refNum[ hyphen ] += c - '0';
+        }
 
-           ret = TRUE;
-       }
+        ret = TRUE;
+    }
 
     return ret;
 }
@@ -855,16 +859,16 @@ bool ParseMisc::parseResAnchor(
 int ParseMisc::stringToPositiveNum( const QChar *cdat, const unsigned int length )
 {
     int ret = 0;
-    
-    for ( unsigned int i = 0 ; i < length ; i++ ){
 
-       unsigned short c = cdat[ i ].unicode();
+    for ( unsigned int i = 0 ; i < length ; i++ ) {
 
-       if ( ( c < UTF16_0 || c > UTF16_9 ) && ( c < '0' || c > '9' ) ) return -1;
+        unsigned short c = cdat[ i ].unicode();
 
-       ret *= 10;
-       if ( c >= UTF16_0 ) ret += c - UTF16_0;
-       else ret += c - '0';
+        if ( ( c < UTF16_0 || c > UTF16_9 ) && ( c < '0' || c > '9' ) ) return -1;
+
+        ret *= 10;
+        if ( c >= UTF16_0 ) ret += c - UTF16_0;
+        else ret += c - '0';
     }
 
     return ret;
@@ -877,7 +881,7 @@ int ParseMisc::stringToPositiveNum( const QChar *cdat, const unsigned int length
 /*-----------------------------------------------------*/ /* public */
 
 /* For example, if cdat = "&amp;", then
-
    pos (= length of cdat) = 5,
    retstr = "&".
 */
@@ -885,21 +889,22 @@ int ParseMisc::stringToPositiveNum( const QChar *cdat, const unsigned int length
 QString ParseMisc::parseSpecialChar(
 
     /* input */
-    const QChar *cdat,  
+    const QChar *cdat,
 
     /* output */
-    unsigned int& pos ){
+    unsigned int& pos )
+{
 
     struct LocalFunc {
-        static int isEqual( const QChar *cdat, const QString& str)
-           {
-               int i = 0;
-               while ( str.at( i ) != '\0' ) {
-                   if ( *cdat != str.at( i ) ) return 0;
-                   cdat++;i++;
-               }
-               return i;
-           }
+        static int isEqual( const QChar *cdat, const QString& str )
+        {
+            int i = 0;
+            while ( str.at( i ) != '\0' ) {
+                if ( *cdat != str.at( i ) ) return 0;
+                cdat++;i++;
+            }
+            return i;
+        }
     };
 
     QString retstr = QString::null;
@@ -911,16 +916,16 @@ QString ParseMisc::parseSpecialChar(
     else if ( ( pos = LocalFunc::isEqual( cdat , "&quot;" ) ) ) retstr = "\"";
 
     else if ( ( pos = LocalFunc::isEqual( cdat , "&hearts;" ) ) )
-       retstr = utf8ToUnicode( KITAUTF8_HEART );
+        retstr = utf8ToUnicode( KITAUTF8_HEART );
 
     else if ( ( pos = LocalFunc::isEqual( cdat , "&diams;" ) ) )
-       retstr = utf8ToUnicode( KITAUTF8_DIA );
+        retstr = utf8ToUnicode( KITAUTF8_DIA );
 
     else if ( ( pos = LocalFunc::isEqual( cdat , "&clubs;" ) ) )
-       retstr = utf8ToUnicode( KITAUTF8_CLUB );
+        retstr = utf8ToUnicode( KITAUTF8_CLUB );
 
     else if ( ( pos = LocalFunc::isEqual( cdat , "&spades;" ) ) )
-       retstr = utf8ToUnicode( KITAUTF8_SPADE );
+        retstr = utf8ToUnicode( KITAUTF8_SPADE );
 
     return retstr;
 }
@@ -940,7 +945,7 @@ void ParseMisc::parseDateId(
 
     if ( regexp.search( str ) == -1 ) {
         resdat.date = str;
-       resdat.id = QString::null;
+        resdat.id = QString::null;
         return ;
     }
 
@@ -951,23 +956,23 @@ void ParseMisc::parseDateId(
         year += 2000;
     }
 
-    if( m_weekstr[ 0 ] == QString::null ){
-       m_weekstr[ 0 ] = utf8ToUnicode( KITAUTF8_MONDAY );
-       m_weekstr[ 1 ] = utf8ToUnicode( KITAUTF8_TUESDAY );
-       m_weekstr[ 2 ] = utf8ToUnicode( KITAUTF8_WEDNESDAY );
-       m_weekstr[ 3 ] = utf8ToUnicode( KITAUTF8_THURSDAY );
-       m_weekstr[ 4 ] = utf8ToUnicode( KITAUTF8_FRIDAY );
-       m_weekstr[ 5 ] = utf8ToUnicode( KITAUTF8_SATURDAY );
-       m_weekstr[ 6 ] = utf8ToUnicode( KITAUTF8_SUNDAY );
+    if ( m_weekstr[ 0 ] == QString::null ) {
+        m_weekstr[ 0 ] = utf8ToUnicode( KITAUTF8_MONDAY );
+        m_weekstr[ 1 ] = utf8ToUnicode( KITAUTF8_TUESDAY );
+        m_weekstr[ 2 ] = utf8ToUnicode( KITAUTF8_WEDNESDAY );
+        m_weekstr[ 3 ] = utf8ToUnicode( KITAUTF8_THURSDAY );
+        m_weekstr[ 4 ] = utf8ToUnicode( KITAUTF8_FRIDAY );
+        m_weekstr[ 5 ] = utf8ToUnicode( KITAUTF8_SATURDAY );
+        m_weekstr[ 6 ] = utf8ToUnicode( KITAUTF8_SUNDAY );
     }
 
     resdat.dateTime = QDateTime( QDate( year, regexp.cap( 3 ).toInt(), regexp.cap( 4 ).toInt() ),
-              QTime( regexp.cap( 5 ).toInt(), regexp.cap( 6 ).toInt(), regexp.cap( 7 ).mid( 1 ).toInt() ) );
-    
-    resdat.date = regexp.cap( 1 ) +  "/" + regexp.cap( 3 ) + "/" + regexp.cap( 4 ) 
-       + m_weekstr[ resdat.dateTime.date().dayOfWeek() -1 ]
-       + regexp.cap( 5 ) + ":" + regexp.cap( 6 ) + regexp.cap( 7 );
-    
+                                 QTime( regexp.cap( 5 ).toInt(), regexp.cap( 6 ).toInt(), regexp.cap( 7 ).mid( 1 ).toInt() ) );
+
+    resdat.date = regexp.cap( 1 ) + "/" + regexp.cap( 3 ) + "/" + regexp.cap( 4 )
+                  + m_weekstr[ resdat.dateTime.date().dayOfWeek() - 1 ]
+                  + regexp.cap( 5 ) + ":" + regexp.cap( 6 ) + regexp.cap( 7 );
+
     resdat.id = regexp.cap( 9 );
 }
 
@@ -975,44 +980,43 @@ void ParseMisc::parseDateId(
 /*--------------------------------------*/
 /* split raw data, then get ID, name,
    date, body text, subject, etc.
-
    (input) "resdat.linestr","resdat.set"
    
    "resdat.linestr" is raw data, and
    "resdat.set" should be set to TRUE
    before calling this.
-
    struct RESDAT is defined in datinfo.h.
    see also datinfo.h.                   */ /* public */
-bool ParseMisc::parseResDat(RESDAT& resdat, QString& subject)
+bool ParseMisc::parseResDat( RESDAT& resdat, QString& subject )
 {
-    if( resdat.parsed ) return TRUE;
-    if( !resdat.set ) return FALSE;
+    if ( resdat.parsed ) return TRUE;
+    if ( !resdat.set ) return FALSE;
 
     resdat.parsed = TRUE;
-    
+
     /* split dat */
     QString idstr = "none";
     QStringList list = QStringList::split( "<>", resdat.linestr, true );
 
     if ( list.size() == 5 ) {
 
-       resdat.broken = FALSE;
+        resdat.broken = FALSE;
 
-       resdat.name = list[ 0 ];
-       parseBODYdatText( PARSEMODE_TEXT, resdat.name, resdat.parsedName );
-       resdat.address = list[ 1 ];
-       parseDateId( list[ 2 ], resdat );
-       if( list[ 3 ].at( 0 ) == ' ' ) resdat.body = list[ 3 ].mid( 1 ); /* remove space after <> */
-       else resdat.body = list[ 3 ];
+        resdat.name = list[ 0 ];
+        parseBODYdatText( PARSEMODE_TEXT, resdat.name, resdat.parsedName );
+        resdat.address = list[ 1 ];
+        parseDateId( list[ 2 ], resdat );
+        if ( list[ 3 ].at( 0 ) == ' ' ) resdat.body = list[ 3 ].mid( 1 ); /* remove space after <> */
+        else resdat.body = list[ 3 ];
 
-       /* get subject */
-       if (list[ 4 ] != QString::null ) {
-           subject = list[ 4 ];
-       }
+        /* get subject */
+        if ( list[ 4 ] != QString::null ) {
+            subject = list[ 4 ];
+        }
 
-    }
-    else resdat.broken = TRUE;
+    } else resdat.broken = TRUE;
 
     return TRUE;
 }
@@ -1023,15 +1027,15 @@ bool ParseMisc::parseResDat(RESDAT& resdat, QString& subject)
 /* parsing function for link   */
 
 /* For example,
-
    cdat = "ttp://foo.com",
-
    then
-
    linkstr = "ttp://foo.com",
    linkurl = "http://foo.com",
    pos (= length of cdat) = 13,
-
    and return TRUE.
                                 */ /* public */
 bool ParseMisc::parseLink(
@@ -1041,33 +1045,34 @@ bool ParseMisc::parseLink(
 
     /* output */
     QString& linkstr, QString& linkurl, unsigned int& pos
-    ){
+)
+{
 
     /*-----------------------------*/
-    
+
     linkstr = QString::null;
     linkurl = QString::null;
 
     QString retlinkstr = QString::null;
     QString prefix = QString::null;
-    
-    if( isEqual( cdat  , "http://" ) ) prefix = "http://";
-    else if( isEqual( cdat  , "ttp://" ) ) prefix = "ttp://";
-    else if( isEqual( cdat  , "tp://" ) ) prefix = "tp://";
-    if( prefix == QString::null ) return FALSE;
+
+    if ( isEqual( cdat , "http://" ) ) prefix = "http://";
+    else if ( isEqual( cdat , "ttp://" ) ) prefix = "ttp://";
+    else if ( isEqual( cdat , "tp://" ) ) prefix = "tp://";
+    if ( prefix == QString::null ) return FALSE;
 
     pos = prefix.length();
     while ( cdat[ pos ] >= '!' && cdat[ pos ] <= '~' &&
-           cdat[ pos ] != ' ' && cdat[ pos ] != '<' && cdat[ pos ] != '>'
-           && pos < length ){
-       retlinkstr += cdat[ pos++ ];
+            cdat[ pos ] != ' ' && cdat[ pos ] != '<' && cdat[ pos ] != '>'
+            && pos < length ) {
+        retlinkstr += cdat[ pos++ ];
     }
     if ( pos > length ) return FALSE;
-    
-    if( retlinkstr != QString::null ) parseBODYdatText( PARSEMODE_TEXT, retlinkstr, linkstr );
+
+    if ( retlinkstr != QString::null ) parseBODYdatText( PARSEMODE_TEXT, retlinkstr, linkstr );
     linkurl = "http://" + linkstr;
     linkstr = prefix + linkstr;
-    
+
     return TRUE;
 }
 
@@ -1075,23 +1080,23 @@ bool ParseMisc::parseLink(
 
 /*----------------------------------------------------------*/
 /* parse URL to get correct URL of dat file.
-
 (ex.1)
-
 http://pc5.2ch.net/linux/dat/1069738960.dat#20-30
-
 ->
-
 newURL = http://pc5.2ch.net/linux/dat/1069738960.dat
 retstr = 20-30
-
 (ex.2)
-
-
 http://pc5.2ch.net/test/read.cgi/linux/1069738960/-100
-
 ->
-
 newURL = http://pc5.2ch.net/linux/dat/1069738960.dat
 refstr = 1-100                                                */ /* public */
 
@@ -1106,37 +1111,36 @@ KURL ParseMisc::parseURL( const KURL& url , QString& refstr )
 
     if ( url.path().contains( "/read.cgi" ) ) {
 
-       if ( url.path().contains( "/test/read.cgi" ) ) /* 2ch */
-           root = url.prettyURL().section( "/test/read.cgi", 0, 0 );
-       else root = url.prettyURL().section( "/read.cgi", 0, 0 );
-
-       QString tmp = url.path().section( "/read.cgi", 1 );
-       
-       board = tmp.section( '/', 1, 1 );
-       thread = tmp.section( '/', 2, 2 );
-       refBase = tmp.section( '/', 3, 3 );
-       
-       QRegExp reg( "\\d+" );
-       if( reg.exactMatch( thread ) ){
-       
-           QString newPath = QString( "/%1/dat/%2.dat" ).arg( board ).arg( thread );
-
-           newURL = root + newPath;
-
-           if ( ! refBase.isEmpty() ){
-               if ( refBase.at( 0 ) == '-' ) refstr = "1" + refBase;
-               else refstr = refBase;
-           }
-
-           return newURL;
-       }
+        if ( url.path().contains( "/test/read.cgi" ) )    /* 2ch */
+            root = url.prettyURL().section( "/test/read.cgi", 0, 0 );
+        else root = url.prettyURL().section( "/read.cgi", 0, 0 );
+
+        QString tmp = url.path().section( "/read.cgi", 1 );
+
+        board = tmp.section( '/', 1, 1 );
+        thread = tmp.section( '/', 2, 2 );
+        refBase = tmp.section( '/', 3, 3 );
+
+        QRegExp reg( "\\d+" );
+        if ( reg.exactMatch( thread ) ) {
+
+            QString newPath = QString( "/%1/dat/%2.dat" ).arg( board ).arg( thread );
+
+            newURL = root + newPath;
+
+            if ( ! refBase.isEmpty() ) {
+                if ( refBase.at( 0 ) == '-' ) refstr = "1" + refBase;
+                else refstr = refBase;
+            }
+
+            return newURL;
+        }
+    }
+
+    if ( newURL.hasRef() ) {
+        refstr = newURL.ref();
+        newURL = newURL.protocol() + "://" + newURL.host() + newURL.path();
     }
-    
-       if( newURL.hasRef() ) 
-       {
-           refstr = newURL.ref();
-           newURL = newURL.protocol() + "://" + newURL.host() + newURL.path();
-       }
 
 
     kdDebug() << "newURL: " << newURL.url() << endl;
@@ -1158,12 +1162,12 @@ KURL ParseMisc::parseURLonly( const KURL& url )
 
 
 /* if cdat == str, return str.length() */ /* private */
-int ParseMisc::isEqual( const QChar *cdat, const QString& str)
+int ParseMisc::isEqual( const QChar *cdat, const QString& str )
 {
     int i = 0;
     while ( str.at( i ) != '\0' ) {
-       if ( *cdat != str.at( i ) ) return 0;
-       cdat++;i++;
+        if ( *cdat != str.at( i ) ) return 0;
+        cdat++;i++;
     }
     return i;
 }
@@ -1191,56 +1195,56 @@ bool ParseMisc::createResAnchor(
     /* internal variables */
     /* They are the same variables that ara used in parseBODYdat. */
     const QChar *chpt, unsigned int &i, unsigned int &index, QString& lineStr
-    )
+)
 {
     /*-----------------------*/
 
-    QString linkstr,linkurl;
+    QString linkstr, linkurl;
     DOM::Element tmpelm;
-    int refNum[2];
+    int refNum[ 2 ];
     unsigned int pos;
     unsigned int length = rawStr.length();
 
     /* parse anchor */
-    if( !parseResAnchor(chpt+i,length-i,linkstr,refNum,pos) ){
-       lineStr += rawStr.mid( index, i - index ) + linkstr;
-       index = i + pos;
-       i = index - 1;
-       return FALSE;
+    if ( !parseResAnchor( chpt + i, length - i, linkstr, refNum, pos ) ) {
+        lineStr += rawStr.mid( index, i - index ) + linkstr;
+        index = i + pos;
+        i = index - 1;
+        return FALSE;
     }
 
     /* create anchor */
     lineStr += rawStr.mid( index, i - index );
-    linkurl = QString("#%1").arg(refNum[0]);
-    if(refNum[1]) linkurl += QString("-%1").arg(refNum[1]);
-           
-    switch ( mode ){
+    linkurl = QString( "#%1" ).arg( refNum[ 0 ] );
+    if ( refNum[ 1 ] ) linkurl += QString( "-%1" ).arg( refNum[ 1 ] );
+
+    switch ( mode ) {
 
     case PARSEMODE_DOM:
-    
-       /* create 'A' element */
-       bodynode.appendChild( hdoc.createTextNode( lineStr ) );
-    
-       tmpelm = bodynode.appendChild( hdoc.createElement( "A" ) );
-       {
-           tmpelm.setAttribute( "href", linkurl );
-           tmpelm.appendChild( hdoc.createTextNode( linkstr ) );
-       }
-
-       break;
+
+        /* create 'A' element */
+        bodynode.appendChild( hdoc.createTextNode( lineStr ) );
+
+        tmpelm = bodynode.appendChild( hdoc.createElement( "A" ) );
+        {
+            tmpelm.setAttribute( "href", linkurl );
+            tmpelm.appendChild( hdoc.createTextNode( linkstr ) );
+        }
+
+        break;
 
     case PARSEMODE_HTML:
-       bodytext += lineStr;
-       bodytext += "<a href=\"" + linkurl +"\">";
-       bodytext += linkstr;
-       bodytext +="</a>";
-       break;  
+        bodytext += lineStr;
+        bodytext += "<a href=\"" + linkurl + "\">";
+        bodytext += linkstr;
+        bodytext += "</a>";
+        break;
     }
-    
+
     index = i + pos;
     i = index - 1;
     lineStr = QString::null;
-       
+
     return TRUE;
 }
 
index 13e5155..12b8e4c 100644 (file)
@@ -19,78 +19,78 @@ class KURL;
 
 namespace DOM
 {
-class HTMLDocument;
-class Element;
-} 
+    class HTMLDocument;
+    class Element;
+}
 
 struct RESDAT;
 
 /* mode */
 enum{
-PARSEMODE_DOM,
-PARSEMODE_HTML,
-PARSEMODE_TEXT
+    PARSEMODE_DOM,
+    PARSEMODE_HTML,
+    PARSEMODE_TEXT
 };
 
 namespace Kita
 {
-   
-class ParseMisc
+
+    class ParseMisc
     {
-       static QMutex m_codexMutex;
-       static QCp932Codec* m_qcpCodec;
-       static QTextCodec* m_utf8Codec;
-
-       /* japanese str */
-       static QString m_weekstr[7];
-       static QString m_colonstr;
-       static QString m_colonnamestr;
-       
-
-      public:
-
-       /* Text codec */
-       static QString qcpToUnicode( const QString& str );
-       static QString utf8ToUnicode( const QString& str );
-
-       
-       /* parsing functions */
-       static void parseTITLEdat(int mode,DOM::HTMLDocument& hdoc, int num,
-           bool showMailAddress,const RESDAT& resdat,DOM::Element &titlenode,QString& titletext);
-
-       static void parseTITLEdatText(int mode,int num,bool showMailAddress,
-                                     const RESDAT& resdat,QString& titletext);
-       
-       static void parseBODYdat(int mode,const QString &rawStr, DOM::HTMLDocument& hdoc,
-                                bool showAA, DOM::Element &bodynode, QString& bodytext);
-
-       static void parseBODYdatText(int mode,const QString &rawStr,QString& bodytext);
-
-       static QString ResDatToHtml(const RESDAT& resdat, int num, bool showAddr);
-       static QString DatToHtml(const QString& rawData, int num, bool showAddr );
-       
-       /* utils */
-       static bool parseResAnchor(const QChar *cdat,const unsigned int length,
-                                  QString& linkstr,int* refNum,unsigned int& pos);
-       static int stringToPositiveNum( const QChar *cdat, const unsigned int length );
-       static QString parseSpecialChar(const QChar *cdat, unsigned int& pos );
-       static void parseDateId( const QString& str, RESDAT& resdat );
-       static bool parseResDat(RESDAT& resdat, QString& subject);
-       static bool parseLink( const QChar *cdat, const unsigned int length,
-           QString& linkstr, QString& linkurl, unsigned int& pos );
-       static KURL parseURL( const KURL& url , QString& refstr );
-       static KURL parseURLonly( const KURL& url );
-       
-       /*-------------------------*/
-       
-      private:
-       
-       static bool createResAnchor(int mode,const QString &rawStr, DOM::HTMLDocument& hdoc ,
-           DOM::Element &bodynode, QString& bodytext,
-           const QChar *chpt, unsigned int &i, unsigned int &index, QString& lineStr );
-       
-       static int isEqual( const QChar *cdat, const QString& str);
-       
+        static QMutex m_codexMutex;
+        static QCp932Codec* m_qcpCodec;
+        static QTextCodec* m_utf8Codec;
+
+        /* japanese str */
+        static QString m_weekstr[ 7 ];
+        static QString m_colonstr;
+        static QString m_colonnamestr;
+
+
+    public:
+
+        /* Text codec */
+        static QString qcpToUnicode( const QString& str );
+        static QString utf8ToUnicode( const QString& str );
+
+
+        /* parsing functions */
+        static void parseTITLEdat( int mode, DOM::HTMLDocument& hdoc, int num,
+                                   bool showMailAddress, const RESDAT& resdat, DOM::Element &titlenode, QString& titletext );
+
+        static void parseTITLEdatText( int mode, int num, bool showMailAddress,
+                                       const RESDAT& resdat, QString& titletext );
+
+        static void parseBODYdat( int mode, const QString &rawStr, DOM::HTMLDocument& hdoc,
+                                  bool showAA, DOM::Element &bodynode, QString& bodytext );
+
+        static void parseBODYdatText( int mode, const QString &rawStr, QString& bodytext );
+
+        static QString ResDatToHtml( const RESDAT& resdat, int num, bool showAddr );
+        static QString DatToHtml( const QString& rawData, int num, bool showAddr );
+
+        /* utils */
+        static bool parseResAnchor( const QChar *cdat, const unsigned int length,
+                                    QString& linkstr, int* refNum, unsigned int& pos );
+        static int stringToPositiveNum( const QChar *cdat, const unsigned int length );
+        static QString parseSpecialChar( const QChar *cdat, unsigned int& pos );
+        static void parseDateId( const QString& str, RESDAT& resdat );
+        static bool parseResDat( RESDAT& resdat, QString& subject );
+        static bool parseLink( const QChar *cdat, const unsigned int length,
+                               QString& linkstr, QString& linkurl, unsigned int& pos );
+        static KURL parseURL( const KURL& url , QString& refstr );
+        static KURL parseURLonly( const KURL& url );
+
+        /*-------------------------*/
+
+    private:
+
+        static bool createResAnchor( int mode, const QString &rawStr, DOM::HTMLDocument& hdoc ,
+                                     DOM::Element &bodynode, QString& bodytext,
+                                     const QChar *chpt, unsigned int &i, unsigned int &index, QString& lineStr );
+
+        static int isEqual( const QChar *cdat, const QString& str );
+
     };
 
 }