• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

libkdeedu/keduvocdocument

keduvockvtmlwriter.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                    export a KEduVocDocument to a KVTML file
00003     -----------------------------------------------------------------------
00004     copyright           : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00005 
00006                           (C) 2005 Eric Pignet <eric at erixpage.com>
00007                           (C) 2007 Peter Hedlund <peter.hedlund@kdemail.net>
00008                           (C) 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *   This program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   (at your option) any later version.                                   *
00017  *                                                                         *
00018  ***************************************************************************/
00019 
00020 #include "keduvockvtmlwriter.h"
00021 
00022 #include <QtCore/QTextStream>
00023 #include <QtCore/QFile>
00024 
00025 #include <KDebug>
00026 
00027 #include "keduvocdocument.h"
00028 #include "keduvocgrade.h"
00029 #include "keduvoclesson.h"
00030 #include "keduvocexpression.h"
00031 #include "kvtmldefs.h"
00032 #include "keduvoccommon_p.h"
00033 
00034 KEduVocKvtmlWriter::KEduVocKvtmlWriter( QFile *file )
00035 {
00036     // the file must be already open
00037     m_outputFile = file;
00038 }
00039 
00040 
00041 bool KEduVocKvtmlWriter::writeDoc( KEduVocDocument *doc, const QString &generator )
00042 {
00043     bool first_expr = true;
00044 
00045     m_doc = doc;
00046 
00047     m_domDoc = QDomDocument( "kvtml SYSTEM \"kvoctrain.dtd\"" );
00048     m_domDoc.appendChild( m_domDoc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
00049     QDomElement domElementKvtml = m_domDoc.createElement( "kvtml" );
00050     m_domDoc.appendChild( domElementKvtml );
00051 
00052     domElementKvtml.setAttribute( KV_ENCODING, ( QString ) "UTF-8" );
00053     domElementKvtml.setAttribute( KV_GENERATOR, generator );
00054     domElementKvtml.setAttribute( KV_COLS, m_doc->identifierCount() );
00055     domElementKvtml.setAttribute( KV_LINES, m_doc->entryCount() );
00056 
00057     if ( !m_doc->title().isEmpty() )
00058         domElementKvtml.setAttribute( KV_TITLE, m_doc->title() );
00059 
00060     if ( !m_doc->author().isEmpty() )
00061         domElementKvtml.setAttribute( KV_AUTHOR, m_doc->author() );
00062 
00063     if ( !m_doc->license().isEmpty() )
00064         domElementKvtml.setAttribute( KV_LICENSE, m_doc->license() );
00065 
00066     if ( !m_doc->documentComment().isEmpty() )
00067         domElementKvtml.setAttribute( KV_DOC_REM, m_doc->documentComment() );
00068 
00069     if ( !writeLesson( domElementKvtml ) )
00070         return false;
00071 
00072     if ( !writeArticle( domElementKvtml ) )
00073         return false;
00074 
00075     QList<KEduVocPersonalPronoun> pronouns;
00076     for ( int i = 0; i < m_doc->identifierCount(); i++ )
00077         pronouns.append( m_doc->identifier(i).personalPronouns() );
00078     if ( pronouns.count() > 0 ) {
00079         if ( !writePersonalPronouns(domElementKvtml, pronouns ) )
00080             return false;
00081     }
00082 
00083     if ( !writeType( domElementKvtml ) )
00084         return false;
00085 
00086     if ( !writeTense( domElementKvtml ) )
00087         return false;
00088 
00089     if ( !writeUsage( domElementKvtml ) )
00090         return false;
00091 
00092     QString q_org, q_trans;
00093     m_doc->queryIdentifier( q_org, q_trans );
00094 
00095     int entryCount = m_doc->entryCount();
00096 
00097     for ( int i = 0; i < entryCount; i++ ) {
00098         KEduVocExpression *entry = m_doc->entry( i );
00099         QDomElement domElementExpression = m_domDoc.createElement( KV_EXPR );
00100 
00101         if ( entry->lesson() != 0 ) {
00102             int lm = entry->lesson();
00103             if ( lm > m_doc->lessonCount() ) {
00104                 // should not be
00105                 kError() << "index of lesson member too high: " << lm << endl;
00106                 lm = 0;
00107             }
00108             domElementExpression.setAttribute( KV_LESS_MEMBER, lm );
00109         }
00110 
00111 // Sorry, but we don't support this any more.
00112 //         if ( entry->isInQuery() )
00113 //             domElementExpression.setAttribute( KV_SELECTED, 1 );
00114 
00115         if ( !entry->isActive() )
00116             domElementExpression.setAttribute( KV_INACTIVE, 1 );
00117 
00118         QDomElement domElementOriginal = m_domDoc.createElement( KV_ORG );
00119         if ( first_expr ) {
00120             // save space, only tell language in first entry
00121             QString s;
00122             domElementOriginal.setAttribute( KV_SIZEHINT, m_doc->sizeHint( 0 ) );
00123 
00124             s = m_doc->identifier( 0 ).name().simplified();
00125             if ( s.isEmpty() )
00126                 s = "original";
00127             domElementOriginal.setAttribute( KV_LANG, s );
00128             if ( s == q_org )
00129                 domElementOriginal.setAttribute( KV_QUERY, ( QString ) KV_O );
00130             else if ( s == q_trans )
00131                 domElementOriginal.setAttribute( KV_QUERY, ( QString ) KV_T );
00132         }
00133 
00134         if ( !entry->translation( 0 ).comment().isEmpty() )
00135             domElementOriginal.setAttribute( KV_REMARK, entry->translation( 0 ).comment() );
00136 
00137         if ( !entry->translation( 0 ).synonym().isEmpty() )
00138             domElementOriginal.setAttribute( KV_SYNONYM, entry->translation( 0 ).synonym() );
00139 
00140         if ( !entry->translation( 0 ).example().isEmpty() )
00141             domElementOriginal.setAttribute( KV_EXAMPLE, entry->translation( 0 ).example() );
00143         /*
00144             if (!entry->translation(0).usageLabel().isEmpty() )
00145               domElementOriginal.setAttribute(KV_USAGE, entry->translation(0).usageLabel());
00146         */
00147         if ( !entry->translation( 0 ).paraphrase().isEmpty() )
00148             domElementOriginal.setAttribute( KV_PARAPHRASE, entry->translation( 0 ).paraphrase() );
00149 
00150         if ( !entry->translation( 0 ).antonym().isEmpty() )
00151             domElementOriginal.setAttribute( KV_ANTONYM, entry->translation( 0 ).antonym() );
00152 
00153         if ( !entry->translation( 0 ).pronunciation().isEmpty() )
00154             domElementOriginal.setAttribute( KV_PRONUNCE, entry->translation( 0 ).pronunciation() );
00155 
00156         if ( !entry->translation( 0 ).type().isEmpty() )
00157             domElementOriginal.setAttribute( KV_EXPRTYPE, m_compability.oldType( entry->translation( 0 ).type(), entry->translation( 0 ).subType() ) );
00158 
00159         if ( !writeMultipleChoice(domElementOriginal, entry->translation( 0 ).multipleChoice() ) )
00160             return false;
00161 
00162         QString s;
00163         QString entype = s = entry->translation( 0 ).type();
00164         int pos = s.indexOf( QM_TYPE_DIV );
00165         if ( pos >= 0 )
00166             entype = s.left( pos );
00167         else
00168             entype = s;
00169 
00170         if ( entype == QM_VERB ) {
00171                 // conjugation
00172             if ( !writeConjugEntry(domElementOriginal, entry->translation( 0 )) ) {
00173                     return false;
00174             }
00175 
00176 
00177         } else if ( entype == QM_ADJ && !entry->translation( 0 ).comparison().isEmpty() ) {
00178             KEduVocComparison comp = entry->translation( 0 ).comparison();
00179             if ( !writeComparison(domElementOriginal, comp ) )
00180                 return false;
00181         }
00182 
00183         QDomText domTextOriginal = m_domDoc.createTextNode( entry->translation( 0 ).text() );
00184         domElementOriginal.appendChild( domTextOriginal );
00185         domElementExpression.appendChild( domElementOriginal );
00186 
00187         int trans = 1;
00188         while ( trans < m_doc->identifierCount() ) {
00189             QDomElement domElementTranslation = m_domDoc.createElement( KV_TRANS );
00190             if ( first_expr ) {
00191                 // save space, only tell language in first entry
00192                 QString s;
00193                 domElementTranslation.setAttribute( KV_SIZEHINT, m_doc->sizeHint( trans ) );
00194 
00195                 s = m_doc->identifier( trans ).name().simplified();
00196                 if ( s.isEmpty() ) {
00197                     s.setNum( trans );
00198                     s.prepend( "translation " );
00199                 }
00200                 domElementTranslation.setAttribute( KV_LANG, s );
00201                 if ( s == q_org )
00202                     domElementTranslation.setAttribute( KV_QUERY, ( QString ) KV_O );
00203                 else if ( s == q_trans )
00204                     domElementTranslation.setAttribute( KV_QUERY, ( QString ) KV_T );
00205             }
00206 
00207             if ( entry->translation( trans ).gradeFrom( 0 ).grade() != 0 || entry->translation( 0 ).gradeFrom( trans ).grade() != 0 )
00208                 domElementTranslation.setAttribute( KV_GRADE, QString::number( entry->translation( trans ).gradeFrom( 0 ).grade() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).grade() ) );
00209 
00210             if ( entry->translation( trans ).gradeFrom( 0 ).practiceCount() != 0 || entry->translation( 0 ).gradeFrom( trans ).practiceCount() != 0 )
00211                 domElementTranslation.setAttribute( KV_COUNT, QString::number( entry->translation( trans ).gradeFrom( 0 ).practiceCount() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).practiceCount() ) );
00212 
00213             if ( entry->translation( trans ).gradeFrom( 0 ).badCount() != 0 || entry->translation( 0 ).gradeFrom( trans ).badCount() != 0 )
00214                 domElementTranslation.setAttribute( KV_BAD, QString::number( entry->translation( trans ).gradeFrom( 0 ).badCount() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).badCount() ) );
00215 
00216             if ( entry->translation( trans ).gradeFrom( 0 ).practiceDate().toTime_t() != 0 || entry->translation( 0 ).gradeFrom( trans ).practiceDate().toTime_t() != 0 )
00217                 domElementTranslation.setAttribute( KV_DATE, QString::number( entry->translation( trans ).gradeFrom( 0 ).practiceDate().toTime_t() ) + ';' + QString::number( entry->translation( 0 ).gradeFrom( trans ).practiceDate().toTime_t() ) );
00218 
00219             if ( !entry->translation( trans ).comment().isEmpty() )
00220                 domElementTranslation.setAttribute( KV_REMARK, entry->translation( trans ).comment() );
00221 
00222             if ( !entry->translation( trans ).falseFriend( 0 ).isEmpty() )
00223                 domElementTranslation.setAttribute( KV_FAUX_AMI_F, entry->translation( trans ).falseFriend( 0 ) );
00224 
00225             if ( !entry->translation( 0 ).falseFriend( trans ).isEmpty() )
00226                 domElementTranslation.setAttribute( KV_FAUX_AMI_T, entry->translation( 0 ).falseFriend( trans ) );
00227 
00228             if ( !entry->translation( trans ).synonym().isEmpty() )
00229                 domElementTranslation.setAttribute( KV_SYNONYM, entry->translation( trans ).synonym() );
00230 
00231             if ( !entry->translation( trans ).example().isEmpty() )
00232                 domElementTranslation.setAttribute( KV_EXAMPLE, entry->translation( trans ).example() );
00233 
00235             /*
00236                   if (!entry->translation(trans).usageLabel().isEmpty() )
00237                     domElementTranslation.setAttribute(KV_USAGE, entry->translation(trans).usageLabel());
00238             */
00239             if ( !entry->translation( trans ).paraphrase().isEmpty() )
00240                 domElementTranslation.setAttribute( KV_PARAPHRASE, entry->translation( trans ).paraphrase() );
00241 
00242             if ( !entry->translation( trans ).antonym().isEmpty() )
00243                 domElementTranslation.setAttribute( KV_ANTONYM, entry->translation( trans ).antonym() );
00244 
00245             if ( !entry->translation( trans ).pronunciation().isEmpty() )
00246                 domElementTranslation.setAttribute( KV_PRONUNCE, entry->translation( trans ).pronunciation() );
00247 
00248             if ( !entry->translation( trans ).type().isEmpty() )
00249                 domElementTranslation.setAttribute( KV_EXPRTYPE, m_compability.oldType( entry->translation( trans ).type(), entry->translation( trans ).subType() ) );
00250 
00251             if ( !writeMultipleChoice(domElementTranslation, entry->translation( trans ).multipleChoice() ) )
00252                 return false;
00253 
00254             QString s;
00255             QString entype = s = entry->translation( 0 ).type();
00256             int pos = s.indexOf( QM_TYPE_DIV );
00257             if ( pos >= 0 )
00258                 entype = s.left( pos );
00259             else
00260                 entype = s;
00261 
00262             if ( entype == QM_VERB ) {
00263                 if ( !writeConjugEntry(domElementTranslation, entry->translation( trans ) ) ) {
00264                     return false;
00265                 }
00266             }
00267 
00268             if ( entype == QM_ADJ && !entry->translation( trans ).comparison().isEmpty() ) {
00269                 KEduVocComparison comp = entry->translation( trans ).comparison();
00270                 if ( !writeComparison(domElementTranslation, comp ) )
00271                     return false;
00272             }
00273 
00274             QDomText domTextTranslation = m_domDoc.createTextNode( entry->translation( trans ).text() );
00275             domElementTranslation.appendChild( domTextTranslation );
00276             domElementExpression.appendChild( domElementTranslation );
00277 
00278             trans++;
00279         }
00280 
00281         domElementKvtml.appendChild( domElementExpression );
00282 
00283         first_expr = false;
00284     }
00285 
00286     m_domDoc.appendChild( domElementKvtml );
00287 
00288     QTextStream ts( m_outputFile );
00289     m_domDoc.save( ts, 2 );
00290 
00291     return true;
00292 }
00293 
00294 
00295 bool KEduVocKvtmlWriter::writeLesson( QDomElement &domElementParent )
00296 {
00297     if ( m_doc->lessonCount() == 0 )
00298         return true;
00299 
00300     QDomElement domElementLesson = m_domDoc.createElement( KV_LESS_GRP );
00301     domElementLesson.setAttribute( KV_SIZEHINT, m_doc->sizeHint( -1 ) );
00302 
00303     for ( int i = 0; i < m_doc->lessonCount(); ++i ) {
00304         QDomElement domElementDesc = m_domDoc.createElement( KV_LESS_DESC );
00305         QDomText domTextDesc = m_domDoc.createTextNode( m_doc->lesson(i).name() );
00306 
00307         domElementDesc.setAttribute( KV_LESS_NO, i );
00308         if ( m_doc->currentLesson() == i ) {
00309             domElementDesc.setAttribute( KV_LESS_CURR, 1 );
00310         }
00311         if ( m_doc->lesson(i).inPractice() ) {
00312             domElementDesc.setAttribute( KV_LESS_QUERY, 1 );
00313         }
00314         domElementDesc.appendChild( domTextDesc );
00315         domElementLesson.appendChild( domElementDesc );
00316     }
00317 
00318     domElementParent.appendChild( domElementLesson );
00319     return true;
00320 }
00321 
00322 
00323 bool KEduVocKvtmlWriter::writeArticle( QDomElement &domElementParent )
00324 /*
00325  <article>
00326   <e l="de">    lang determines also lang order in entries !!
00327    <fi>eine</fi>  which must NOT differ
00328    <fd>die</fd>
00329    <mi>ein</mi>
00330    <md>der</md>
00331    <ni>ein</ni>
00332    <nd>das</nd>
00333   </e>
00334  </article>
00335 */
00336 {
00337     QDomElement domElementArticle = m_domDoc.createElement( KV_ARTICLE_GRP );
00338     QString def;
00339     QString indef;
00340     QString s;
00341 
00342     for ( int i = 0; i < m_doc->identifierCount(); i++ )
00343     {
00344         QDomElement domElementEntry = m_domDoc.createElement( KV_ART_ENTRY );
00345         s = m_doc->identifier(i).name().simplified();
00346         domElementEntry.setAttribute( KV_LANG, s );
00347 
00348         QString articleString;
00349         // female
00350         articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Feminine );
00351         if ( !articleString.isEmpty() ) {
00352             QDomElement domElementFD = m_domDoc.createElement( KV_ART_FD );
00353             QDomText domTextFD = m_domDoc.createTextNode( articleString );
00354 
00355             domElementFD.appendChild( domTextFD );
00356             domElementEntry.appendChild( domElementFD );
00357         }
00358         articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Feminine );
00359         if ( !articleString.isEmpty() ) {
00360             QDomElement domElementFI = m_domDoc.createElement( KV_ART_FI );
00361             QDomText domTextFI = m_domDoc.createTextNode( articleString );
00362 
00363             domElementFI.appendChild( domTextFI );
00364             domElementEntry.appendChild( domElementFI );
00365         }
00366 
00367 
00368         // male
00369         articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Masculine );
00370         if ( !articleString.isEmpty() ) {
00371             QDomElement domElementMD = m_domDoc.createElement( KV_ART_MD );
00372             QDomText domTextMD = m_domDoc.createTextNode( articleString );
00373 
00374             domElementMD.appendChild( domTextMD );
00375             domElementEntry.appendChild( domElementMD );
00376         }
00377         articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Masculine );
00378         if ( !articleString.isEmpty() ) {
00379             QDomElement domElementMI = m_domDoc.createElement( KV_ART_MI );
00380             QDomText domTextMI = m_domDoc.createTextNode( articleString );
00381 
00382             domElementMI.appendChild( domTextMI );
00383             domElementEntry.appendChild( domElementMI );
00384         }
00385 
00386         // neutral
00387         articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Definite | KEduVocWordFlag::Neutral );
00388         if ( !articleString.isEmpty() ) {
00389             QDomElement domElementND = m_domDoc.createElement( KV_ART_ND );
00390             QDomText domTextND = m_domDoc.createTextNode( articleString );
00391 
00392             domElementND.appendChild( domTextND );
00393             domElementEntry.appendChild( domElementND );
00394         }
00395         articleString = m_doc->identifier(i).article().article( KEduVocWordFlag::Singular | KEduVocWordFlag::Indefinite | KEduVocWordFlag::Neutral );
00396         if ( !articleString.isEmpty() ) {
00397             QDomElement domElementNI = m_domDoc.createElement( KV_ART_NI );
00398             QDomText domTextNI = m_domDoc.createTextNode( articleString );
00399 
00400             domElementNI.appendChild( domTextNI );
00401             domElementEntry.appendChild( domElementNI );
00402         }
00403 
00404         domElementArticle.appendChild( domElementEntry );
00405     }
00406 
00407     domElementParent.appendChild( domElementArticle );
00408     return true;
00409 }
00410 
00411 
00412 bool KEduVocKvtmlWriter::writeType( QDomElement &domElementParent )
00413 {
00415     /*
00416       if (m_doc->typeDescriptions().count() == 0)
00417         return true;
00418 
00419       QDomElement domElementType = m_domDoc.createElement(KV_TYPE_GRP);
00420       int count = 1;
00421 
00422       foreach(const QString &type, m_doc->typeDescriptions())
00423       {
00424         if (!(type.isNull()) )
00425         {
00426           QDomElement domElementDesc = m_domDoc.createElement(KV_TYPE_DESC);
00427           QDomText domTextDesc = m_domDoc.createTextNode(type);
00428 
00429           domElementDesc.setAttribute(KV_TYPE_NO, count);
00430           domElementDesc.appendChild(domTextDesc);
00431           domElementType.appendChild(domElementDesc);
00432           count++;
00433         }
00434       }
00435 
00436       domElementParent.appendChild(domElementType);
00437     */
00438     return true;
00439 }
00440 
00441 /*
00442 bool KEduVocKvtmlWriter::writeTense( QDomElement &domElementParent )
00443 {
00444     if ( m_doc->tenseDescriptions().count() == 0 )
00445         return true;
00446 
00447     QDomElement domElementTense = m_domDoc.createElement( KV_TENSE_GRP );
00448     int count = 1;
00449 
00450     foreach( const QString &tense, m_doc->tenseDescriptions() ) {
00451         if ( !( tense.isNull() ) ) {
00452             QDomElement domElementDesc = m_domDoc.createElement( KV_TENSE_DESC );
00453             QDomText domTextDesc = m_domDoc.createTextNode( tense );
00454 
00455             domElementDesc.setAttribute( KV_TENSE_NO, count );
00456             domElementDesc.appendChild( domTextDesc );
00457             domElementTense.appendChild( domElementDesc );
00458             count++;
00459         }
00460     }
00461 
00462     domElementParent.appendChild( domElementTense );
00463     return true;
00464 }
00465 */
00466 
00467 bool KEduVocKvtmlWriter::writeUsage( QDomElement &domElementParent )
00468 {
00469 
00471     /*
00472       if (m_doc->usageDescriptions().count() == 0)
00473         return true;
00474 
00475       QDomElement domElementUsage = m_domDoc.createElement(KV_USAGE_GRP);
00476       int count = 1;
00477 
00478       foreach(const QString &usage, m_doc->usageDescriptions())
00479       {
00480         if (!(usage.isNull()))
00481         {
00482           QDomElement domElementDesc = m_domDoc.createElement(KV_USAGE_DESC);
00483           QDomText domTextDesc = m_domDoc.createTextNode(usage);
00484 
00485           domElementDesc.setAttribute(KV_USAGE_NO, count);
00486           domElementDesc.appendChild(domTextDesc);
00487           domElementUsage.appendChild(domElementDesc);
00488           count++;
00489         }
00490       }
00491 
00492       domElementParent.appendChild(domElementUsage);
00493     */
00494     return true;
00495 }
00496 
00497 
00498 bool KEduVocKvtmlWriter::writeComparison( QDomElement &domElementParent, const KEduVocTranslation* translation )
00499 /*
00500  <comparison>
00501    <l1>good</l1>
00502    <l2>better</l2>
00503    <l3>best</l3>
00504  </comparison>
00505 */
00506 {
00507     if ( translation.comparison().isEmpty() && translation.superlative().isEmpty() ) {
00508         return true;
00509     }
00510 
00511     QDomElement domElementComparison = m_domDoc.createElement( KV_COMPARISON_GRP );
00512 
00513     if ( !comp.l1().isEmpty() ) {
00514         QDomElement domElementL1 = m_domDoc.createElement( KV_COMP_L1 );
00515         QDomText domTextL1 = m_domDoc.createTextNode( comp.l1() );
00516 
00517         domElementL1.appendChild( domTextL1 );
00518         domElementComparison.appendChild( domElementL1 );
00519     }
00520 
00521     if ( !comp.l2().isEmpty() ) {
00522         QDomElement domElementL2 = m_domDoc.createElement( KV_COMP_L2 );
00523         QDomText domTextL2 = m_domDoc.createTextNode( comp.l2() );
00524 
00525         domElementL2.appendChild( domTextL2 );
00526         domElementComparison.appendChild( domElementL2 );
00527     }
00528 
00529     if ( !comp.l3().isEmpty() ) {
00530         QDomElement domElementL3 = m_domDoc.createElement( KV_COMP_L3 );
00531         QDomText domTextL3 = m_domDoc.createTextNode( comp.l3() );
00532 
00533         domElementL3.appendChild( domTextL3 );
00534         domElementComparison.appendChild( domElementL3 );
00535     }
00536 
00537     domElementParent.appendChild( domElementComparison );
00538     return true;
00539 }
00540 
00541 
00542 bool KEduVocKvtmlWriter::writeMultipleChoice( QDomElement &domElementParent, const KEduVocMultipleChoice &mc )
00543 /*
00544  <multiplechoice>
00545    <mc1>good</mc1>
00546    <mc2>better</mc2>
00547    <mc3>best</mc3>
00548    <mc4>best 2</mc4>
00549    <mc5>best 3</mc5>
00550  </multiplechoice>
00551 */
00552 {
00553     if ( mc.isEmpty() )
00554         return true;
00555 
00556     QDomElement domElementMC = m_domDoc.createElement( KV_MULTIPLECHOICE_GRP );
00557 
00558     if ( !mc.choice( 1 ).isEmpty() ) {
00559         QDomElement domElementMC1 = m_domDoc.createElement( KV_MC_1 );
00560         QDomText domTextMC1 = m_domDoc.createTextNode( mc.choice( 1 ) );
00561 
00562         domElementMC1.appendChild( domTextMC1 );
00563         domElementMC.appendChild( domElementMC1 );
00564     }
00565 
00566     if ( !mc.choice( 2 ).isEmpty() ) {
00567         QDomElement domElementMC2 = m_domDoc.createElement( KV_MC_2 );
00568         QDomText domTextMC2 = m_domDoc.createTextNode( mc.choice( 2 ) );
00569 
00570         domElementMC2.appendChild( domTextMC2 );
00571         domElementMC.appendChild( domElementMC2 );
00572     }
00573 
00574     if ( !mc.choice( 3 ).isEmpty() ) {
00575         QDomElement domElementMC3 = m_domDoc.createElement( KV_MC_3 );
00576         QDomText domTextMC3 = m_domDoc.createTextNode( mc.choice( 3 ) );
00577 
00578         domElementMC3.appendChild( domTextMC3 );
00579         domElementMC.appendChild( domElementMC3 );
00580     }
00581 
00582     if ( !mc.choice( 4 ).isEmpty() ) {
00583         QDomElement domElementMC4 = m_domDoc.createElement( KV_MC_4 );
00584         QDomText domTextMC4 = m_domDoc.createTextNode( mc.choice( 4 ) );
00585 
00586         domElementMC4.appendChild( domTextMC4 );
00587         domElementMC.appendChild( domElementMC4 );
00588     }
00589 
00590     if ( !mc.choice( 5 ).isEmpty() ) {
00591         QDomElement domElementMC5 = m_domDoc.createElement( KV_MC_5 );
00592         QDomText domTextMC5 = m_domDoc.createTextNode( mc.choice( 5 ) );
00593 
00594         domElementMC5.appendChild( domTextMC5 );
00595         domElementMC.appendChild( domElementMC5 );
00596     }
00597 
00598     domElementParent.appendChild( domElementMC );
00599     return true;
00600 }
00601 
00602 
00603 bool KEduVocKvtmlWriter::writeConjugHeader( QDomElement &domElementParent, QList<KEduVocConjugation> &curr_conjug )
00604 {
00605     /*
00606      <conjugation>    used in header for definiton of "prefix"
00607       <e l="de">      lang determines also lang order in entries !!
00608        <s1>I</s1>     which must NOT differ
00609        <s2>you<2>
00610        <s3f common="0">he</s3f>
00611        <s3m>she</s3m>
00612        <s3n>it</s3n>
00613        <p1>we</p1>
00614        <p2>you</p2>
00615        <p3f common="1">they</p3f>
00616        <p3m>they</p3m>
00617        <p3n>they</p3n>
00618       </e>
00619      </conjugation>
00620 
00621     */
00622     if ( curr_conjug.size() == 0 )
00623         return true;
00624 
00625     QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP );
00626     QString s;
00627 
00628     for ( int ent = 0; ent < qMin( curr_conjug.count(), m_doc->identifierCount() ); ent++ ) {
00629         QDomElement domElementEntry = m_domDoc.createElement( KV_CON_ENTRY );
00630 
00631         s = m_doc->identifier( ent ).name().simplified();
00632         if ( s.isEmpty() ) {
00633             s.setNum( ent );
00634             s.prepend( "translation " );
00635         }
00636 
00637         domElementEntry.setAttribute( KV_LANG, s );
00638         if ( !writeConjug(domElementEntry, curr_conjug[ent], "--" ) )
00639             return false;
00640 
00641         domElementConjug.appendChild( domElementEntry );
00642     }
00643 
00644     domElementParent.appendChild( domElementConjug );
00645     return true;
00646 }
00647 
00648 
00649 bool KEduVocKvtmlWriter::writeConjugEntry( QDomElement &domElementParent, KEduVocTranslation &translation )
00650 /*
00651  <conjugation>    in entry for definition of tenses of (irreg.) verbs
00652   <t n="sipa">
00653    <s1>go</s1>
00654    <s2>go</s2>
00655    <s3f>goes</s3f>
00656    <s3m>goes</s3m>
00657    <s3n>goes</s3n>
00658    <p1>go</p1>
00659    <p2>go</p2>
00660    <p3f>go</p3f>
00661    <p3m>go</p3m>
00662    <p3n>go</p3n>
00663   </t>
00664  </conjugation>
00665 */
00666 {
00667 
00668 //     curr_conjug.cleanUp();
00669     QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP );
00670 
00671     foreach ( const QString &tense, translation.conjugationTenses() ) {
00672         QDomElement domElementType = m_domDoc.createElement( KV_CON_TYPE );
00673 
00674         domElementType.setAttribute( KV_CON_NAME, m_compability.oldTense(tense) );
00675 
00676         if ( !writeConjug(domElementType, translation.conjugation(tense), m_compability.oldTense(tense) ) )
00677             return false;
00678 
00679         domElementConjug.appendChild( domElementType );
00680     }
00681 
00682     domElementParent.appendChild( domElementConjug );
00683     return true;
00684 }
00685 
00686 
00687 bool KEduVocKvtmlWriter::writeConjug( QDomElement &domElementParent, const KEduVocConjugation &curr_conjug, const QString &type )
00688 {
00690 /*
00691     if ( !curr_conjug.pers1Singular().isEmpty() ) {
00692         QDomElement domElementP1s = m_domDoc.createElement( KV_CON_P1S );
00693         QDomText domTextP1s = m_domDoc.createTextNode( curr_conjug.pers1Singular() );
00694 
00695         domElementP1s.appendChild( domTextP1s );
00696         domElementParent.appendChild( domElementP1s );
00697     }
00698 
00699     if ( !curr_conjug.pers2Singular().isEmpty() ) {
00700         QDomElement domElementP2s = m_domDoc.createElement( KV_CON_P2S );
00701         QDomText domTextP2s = m_domDoc.createTextNode( curr_conjug.pers2Singular() );
00702 
00703         domElementP2s.appendChild( domTextP2s );
00704         domElementParent.appendChild( domElementP2s );
00705     }
00706 
00707     if ( !curr_conjug.pers3FemaleSingular().isEmpty() || curr_conjug.pers3SingularCommon() ) {
00708         QDomElement domElementP3sf = m_domDoc.createElement( KV_CON_P3SF );
00709         QDomText domTextP3sf = m_domDoc.createTextNode( curr_conjug.pers3FemaleSingular() );
00710 
00711         if ( curr_conjug.pers3SingularCommon() )
00712             domElementP3sf.setAttribute( KV_CONJ_COMMON, 1 );
00713 
00714         domElementP3sf.appendChild( domTextP3sf );
00715         domElementParent.appendChild( domElementP3sf );
00716     }
00717 
00718     if ( !curr_conjug.pers3MaleSingular().isEmpty() ) {
00719         QDomElement domElementP3sm = m_domDoc.createElement( KV_CON_P3SM );
00720         QDomText domTextP3sm = m_domDoc.createTextNode( curr_conjug.pers3MaleSingular() );
00721 
00722         domElementP3sm.appendChild( domTextP3sm );
00723         domElementParent.appendChild( domElementP3sm );
00724     }
00725 
00726     if ( !curr_conjug.pers3NaturalSingular().isEmpty() ) {
00727         QDomElement domElementP3sn = m_domDoc.createElement( KV_CON_P3SN );
00728         QDomText domTextP3sn = m_domDoc.createTextNode( curr_conjug.pers3NaturalSingular() );
00729 
00730         domElementP3sn.appendChild( domTextP3sn );
00731         domElementParent.appendChild( domElementP3sn );
00732     }
00733 
00734     if ( !curr_conjug.pers1Plural().isEmpty() ) {
00735         QDomElement domElementP1p = m_domDoc.createElement( KV_CON_P1P );
00736         QDomText domTextP1p = m_domDoc.createTextNode( curr_conjug.pers1Plural() );
00737 
00738         domElementP1p.appendChild( domTextP1p );
00739         domElementParent.appendChild( domElementP1p );
00740     }
00741 
00742     if ( !curr_conjug.pers2Plural().isEmpty() ) {
00743         QDomElement domElementP2p = m_domDoc.createElement( KV_CON_P2P );
00744         QDomText domTextP2p = m_domDoc.createTextNode( curr_conjug.pers2Plural() );
00745 
00746         domElementP2p.appendChild( domTextP2p );
00747         domElementParent.appendChild( domElementP2p );
00748     }
00749 
00750     if ( !curr_conjug.pers3FemalePlural().isEmpty() || curr_conjug.pers3PluralCommon() ) {
00751         QDomElement domElementP3pf = m_domDoc.createElement( KV_CON_P3PF );
00752         QDomText domTextP3pf = m_domDoc.createTextNode( curr_conjug.pers3FemalePlural() );
00753 
00754         if ( curr_conjug.pers3PluralCommon() )
00755             domElementP3pf.setAttribute( KV_CONJ_COMMON, 1 );
00756 
00757         domElementP3pf.appendChild( domTextP3pf );
00758         domElementParent.appendChild( domElementP3pf );
00759     }
00760 
00761     if ( !curr_conjug.pers3MalePlural().isEmpty() ) {
00762         QDomElement domElementP3pm = m_domDoc.createElement( KV_CON_P3PM );
00763         QDomText domTextP3pm = m_domDoc.createTextNode( curr_conjug.pers3MalePlural() );
00764 
00765         domElementP3pm.appendChild( domTextP3pm );
00766         domElementParent.appendChild( domElementP3pm );
00767     }
00768 
00769     if ( !curr_conjug.pers3NaturalPlural().isEmpty() ) {
00770         QDomElement domElementP3pn = m_domDoc.createElement( KV_CON_P3PN );
00771         QDomText domTextP3pn = m_domDoc.createTextNode( curr_conjug.pers3NaturalPlural() );
00772 
00773         domElementP3pn.appendChild( domTextP3pn );
00774         domElementParent.appendChild( domElementP3pn );
00775     }
00776 
00777     return true; */
00778     kDebug() << "Implement me!";
00779     return false;
00780 }
00781 
00782 bool KEduVocKvtmlWriter::writePersonalPronouns( QDomElement &domElementParent, QList<KEduVocPersonalPronoun> &curr_conjug )
00783 {
00784     /*
00785      <conjugation>    used in header for definiton of "prefix"
00786       <e l="de">      lang determines also lang order in entries !!
00787        <s1>I</s1>     which must NOT differ
00788        <s2>you<2>
00789        <s3f common="0">he</s3f>