• Skip to content
  • Skip to link menu
KDE 4.0 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( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::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( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::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( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::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( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::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( KEduVocArticle::Singular, KEduVocArticle::Definite, KEduVocArticle::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( KEduVocArticle::Singular, KEduVocArticle::Indefinite, KEduVocArticle::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(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( 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(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 KEduVocComparison &comp )
00499 /*
00500  <comparison>
00501    <l1>good</l1>
00502    <l2>better</l2>
00503    <l3>best</l3>
00504  </comparison>
00505 */
00506 {
00507     if ( comp.isEmpty() )
00508         return true;
00509 
00510     QDomElement domElementComparison = m_domDoc.createElement( KV_COMPARISON_GRP );
00511 
00512     if ( !comp.l1().isEmpty() ) {
00513         QDomElement domElementL1 = m_domDoc.createElement( KV_COMP_L1 );
00514         QDomText domTextL1 = m_domDoc.createTextNode( comp.l1() );
00515 
00516         domElementL1.appendChild( domTextL1 );
00517         domElementComparison.appendChild( domElementL1 );
00518     }
00519 
00520     if ( !comp.l2().isEmpty() ) {
00521         QDomElement domElementL2 = m_domDoc.createElement( KV_COMP_L2 );
00522         QDomText domTextL2 = m_domDoc.createTextNode( comp.l2() );
00523 
00524         domElementL2.appendChild( domTextL2 );
00525         domElementComparison.appendChild( domElementL2 );
00526     }
00527 
00528     if ( !comp.l3().isEmpty() ) {
00529         QDomElement domElementL3 = m_domDoc.createElement( KV_COMP_L3 );
00530         QDomText domTextL3 = m_domDoc.createTextNode( comp.l3() );
00531 
00532         domElementL3.appendChild( domTextL3 );
00533         domElementComparison.appendChild( domElementL3 );
00534     }
00535 
00536     domElementParent.appendChild( domElementComparison );
00537     return true;
00538 }
00539 
00540 
00541 bool KEduVocKvtmlWriter::writeMultipleChoice( QDomElement &domElementParent, const KEduVocMultipleChoice &mc )
00542 /*
00543  <multiplechoice>
00544    <mc1>good</mc1>
00545    <mc2>better</mc2>
00546    <mc3>best</mc3>
00547    <mc4>best 2</mc4>
00548    <mc5>best 3</mc5>
00549  </multiplechoice>
00550 */
00551 {
00552     if ( mc.isEmpty() )
00553         return true;
00554 
00555     QDomElement domElementMC = m_domDoc.createElement( KV_MULTIPLECHOICE_GRP );
00556 
00557     if ( !mc.choice( 1 ).isEmpty() ) {
00558         QDomElement domElementMC1 = m_domDoc.createElement( KV_MC_1 );
00559         QDomText domTextMC1 = m_domDoc.createTextNode( mc.choice( 1 ) );
00560 
00561         domElementMC1.appendChild( domTextMC1 );
00562         domElementMC.appendChild( domElementMC1 );
00563     }
00564 
00565     if ( !mc.choice( 2 ).isEmpty() ) {
00566         QDomElement domElementMC2 = m_domDoc.createElement( KV_MC_2 );
00567         QDomText domTextMC2 = m_domDoc.createTextNode( mc.choice( 2 ) );
00568 
00569         domElementMC2.appendChild( domTextMC2 );
00570         domElementMC.appendChild( domElementMC2 );
00571     }
00572 
00573     if ( !mc.choice( 3 ).isEmpty() ) {
00574         QDomElement domElementMC3 = m_domDoc.createElement( KV_MC_3 );
00575         QDomText domTextMC3 = m_domDoc.createTextNode( mc.choice( 3 ) );
00576 
00577         domElementMC3.appendChild( domTextMC3 );
00578         domElementMC.appendChild( domElementMC3 );
00579     }
00580 
00581     if ( !mc.choice( 4 ).isEmpty() ) {
00582         QDomElement domElementMC4 = m_domDoc.createElement( KV_MC_4 );
00583         QDomText domTextMC4 = m_domDoc.createTextNode( mc.choice( 4 ) );
00584 
00585         domElementMC4.appendChild( domTextMC4 );
00586         domElementMC.appendChild( domElementMC4 );
00587     }
00588 
00589     if ( !mc.choice( 5 ).isEmpty() ) {
00590         QDomElement domElementMC5 = m_domDoc.createElement( KV_MC_5 );
00591         QDomText domTextMC5 = m_domDoc.createTextNode( mc.choice( 5 ) );
00592 
00593         domElementMC5.appendChild( domTextMC5 );
00594         domElementMC.appendChild( domElementMC5 );
00595     }
00596 
00597     domElementParent.appendChild( domElementMC );
00598     return true;
00599 }
00600 
00601 
00602 bool KEduVocKvtmlWriter::writeConjugHeader( QDomElement &domElementParent, QList<KEduVocConjugation> &curr_conjug )
00603 {
00604     /*
00605      <conjugation>    used in header for definiton of "prefix"
00606       <e l="de">      lang determines also lang order in entries !!
00607        <s1>I</s1>     which must NOT differ
00608        <s2>you<2>
00609        <s3f common="0">he</s3f>
00610        <s3m>she</s3m>
00611        <s3n>it</s3n>
00612        <p1>we</p1>
00613        <p2>you</p2>
00614        <p3f common="1">they</p3f>
00615        <p3m>they</p3m>
00616        <p3n>they</p3n>
00617       </e>
00618      </conjugation>
00619 
00620     */
00621     if ( curr_conjug.size() == 0 )
00622         return true;
00623 
00624     QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP );
00625     QString s;
00626 
00627     for ( int ent = 0; ent < qMin( curr_conjug.count(), m_doc->identifierCount() ); ent++ ) {
00628         QDomElement domElementEntry = m_domDoc.createElement( KV_CON_ENTRY );
00629 
00630         s = m_doc->identifier( ent ).name().simplified();
00631         if ( s.isEmpty() ) {
00632             s.setNum( ent );
00633             s.prepend( "translation " );
00634         }
00635 
00636         domElementEntry.setAttribute( KV_LANG, s );
00637         if ( !writeConjug(domElementEntry, curr_conjug[ent], "--" ) )
00638             return false;
00639 
00640         domElementConjug.appendChild( domElementEntry );
00641     }
00642 
00643     domElementParent.appendChild( domElementConjug );
00644     return true;
00645 }
00646 
00647 
00648 bool KEduVocKvtmlWriter::writeConjugEntry( QDomElement &domElementParent, KEduVocTranslation &translation )
00649 /*
00650  <conjugation>    in entry for definition of tenses of (irreg.) verbs
00651   <t n="sipa">
00652    <s1>go</s1>
00653    <s2>go</s2>
00654    <s3f>goes</s3f>
00655    <s3m>goes</s3m>
00656    <s3n>goes</s3n>
00657    <p1>go</p1>
00658    <p2>go</p2>
00659    <p3f>go</p3f>
00660    <p3m>go</p3m>
00661    <p3n>go</p3n>
00662   </t>
00663  </conjugation>
00664 */
00665 {
00666 
00667 //     curr_conjug.cleanUp();
00668     QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP );
00669 
00670     foreach ( QString tense, translation.conjugationTenses() ) {
00671         QDomElement domElementType = m_domDoc.createElement( KV_CON_TYPE );
00672 
00673         domElementType.setAttribute( KV_CON_NAME, m_compability.oldTense(tense) );
00674 
00675         if ( !writeConjug(domElementType, translation.conjugation(tense), m_compability.oldTense(tense) ) )
00676             return false;
00677 
00678         domElementConjug.appendChild( domElementType );
00679     }
00680 
00681     domElementParent.appendChild( domElementConjug );
00682     return true;
00683 }
00684 
00685 
00686 bool KEduVocKvtmlWriter::writeConjug( QDomElement &domElementParent, const KEduVocConjugation &curr_conjug, const QString &type )
00687 {
00689 /*
00690     if ( !curr_conjug.pers1Singular().isEmpty() ) {
00691         QDomElement domElementP1s = m_domDoc.createElement( KV_CON_P1S );
00692         QDomText domTextP1s = m_domDoc.createTextNode( curr_conjug.pers1Singular() );
00693 
00694         domElementP1s.appendChild( domTextP1s );
00695         domElementParent.appendChild( domElementP1s );
00696     }
00697 
00698     if ( !curr_conjug.pers2Singular().isEmpty() ) {
00699