00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "keduvockvtml2reader.h"
00021
00022 #include <QtCore/QTextStream>
00023 #include <QtCore/QList>
00024 #include <QtCore/QIODevice>
00025
00026 #include <klocale.h>
00027
00028 #include "keduvocdocument.h"
00029 #include "keduvoclesson.h"
00030 #include "keduvocleitnerbox.h"
00031 #include "keduvocwordtype.h"
00032 #include "kvtml2defs.h"
00033 #include "keduvockvtmlreader.h"
00034 #include "keduvoccommon_p.h"
00035
00036 #include <KDebug>
00037
00038 KEduVocKvtml2Reader::KEduVocKvtml2Reader( QIODevice *file )
00039 : m_inputFile( file )
00040 {
00041
00042 if ( !m_inputFile->isOpen() ) {
00043 m_errorMessage = i18n( "file must be opened first" );
00044 }
00045 }
00046
00047
00048 bool KEduVocKvtml2Reader::readDoc( KEduVocDocument *doc )
00049 {
00050 m_doc = doc;
00051
00052 QDomDocument domDoc( "KEduVocDocument" );
00053
00054 if ( !domDoc.setContent( m_inputFile, &m_errorMessage ) )
00055 return false;
00056
00057 QDomElement domElementKvtml = domDoc.documentElement();
00058 if ( domElementKvtml.tagName() != KVTML_TAG ) {
00059 m_errorMessage = i18n( "This is not a KDE Vocabulary document." );
00060 return false;
00061 }
00062
00063 if ( domElementKvtml.attribute( KVTML_VERSION ).toFloat() < 2.0 ) {
00064
00065
00066
00067 m_inputFile->seek( 0 );
00068 KEduVocKvtmlReader oldFormat( m_inputFile );
00069
00070
00071 bool retval = oldFormat.readDoc( doc );
00072
00073
00074 m_errorMessage = oldFormat.errorMessage();
00075 return retval;
00076 }
00077
00078
00079
00080
00081
00082 QDomElement info = domElementKvtml.firstChildElement( KVTML_INFORMATION );
00083 if ( !info.isNull() ) {
00084 if ( !readInformation( info ) )
00085 return false;
00086 }
00087
00088 bool result = readGroups( domElementKvtml );
00089
00090 return result;
00091 }
00092
00093 bool KEduVocKvtml2Reader::readInformation( QDomElement &informationElement )
00094 {
00095
00096 QDomElement currentElement = informationElement.firstChildElement( KVTML_GENERATOR );
00097 if ( !currentElement.isNull() ) {
00098 m_doc->setGenerator( currentElement.text() );
00099
00100 int pos = m_doc->generator().lastIndexOf( KVD_VERS_PREFIX );
00101 if ( pos >= 0 ) {
00102 m_doc->setVersion( m_doc->generator().remove( 0, pos + 2 ) );
00103 }
00104 }
00105
00106
00107 currentElement = informationElement.firstChildElement( KVTML_TITLE );
00108 if ( !currentElement.isNull() ) {
00109 m_doc->setTitle( currentElement.text() );
00110 }
00111
00112
00113 currentElement = informationElement.firstChildElement( KVTML_AUTHOR );
00114 if ( !currentElement.isNull() ) {
00115 m_doc->setAuthor( currentElement.text() );
00116 }
00117
00118 currentElement = informationElement.firstChildElement( KVTML_AUTHORCONTACT );
00119 if ( !currentElement.isNull() ) {
00120 m_doc->setAuthorContact( currentElement.text() );
00121 }
00122
00123
00124 currentElement = informationElement.firstChildElement( KVTML_LICENSE );
00125 if ( !currentElement.isNull() ) {
00126 m_doc->setLicense( currentElement.text() );
00127 }
00128
00129
00130 currentElement = informationElement.firstChildElement( KVTML_COMMENT );
00131 if ( !currentElement.isNull() ) {
00132 m_doc->setDocumentComment( currentElement.text() );
00133 }
00134
00135
00136 currentElement = informationElement.firstChildElement( KVTML_CATEGORY );
00137 if ( !currentElement.isNull() ) {
00138 m_doc->setCategory( currentElement.text() );
00139 }
00140
00141 return true;
00142 }
00143
00144 bool KEduVocKvtml2Reader::readGroups( QDomElement &domElementParent )
00145 {
00146 bool result = false;
00147
00148 QDomElement groupElement = domElementParent.firstChildElement( KVTML_IDENTIFIERS );
00149
00150 QDomElement currentElement;
00151
00152
00153
00154 QStringList tensesCompability;
00155 groupElement = groupElement.firstChildElement( KVTML_TENSES );
00156 if ( !groupElement.isNull() ) {
00157 tensesCompability = readTenses( groupElement );
00158 }
00159
00160 groupElement = domElementParent.firstChildElement( KVTML_IDENTIFIERS );
00161 if ( !groupElement.isNull() ) {
00162 QDomNodeList entryList = groupElement.elementsByTagName( KVTML_IDENTIFIER );
00163 if ( entryList.length() <= 0 ) {
00164 m_errorMessage = i18n( "missing identifier elements from identifiers tag" );
00165 return false;
00166 }
00167
00168 for ( int i = 0; i < entryList.count(); ++i ) {
00169 currentElement = entryList.item( i ).toElement();
00170 if ( currentElement.parentNode() == groupElement ) {
00171 result = readIdentifier( currentElement );
00172 if ( !result ) {
00173 return false;
00174 }
00175 if (!tensesCompability.isEmpty()) {
00176 m_doc->identifier(i).setTenseList(tensesCompability);
00177 }
00178 }
00179 }
00180 }
00181
00182 groupElement = domElementParent.firstChildElement( KVTML_ENTRIES );
00183 if ( !groupElement.isNull() ) {
00184 QDomNodeList entryList = groupElement.elementsByTagName( KVTML_ENTRY );
00185 for ( int i = 0; i < entryList.count(); ++i ) {
00186 currentElement = entryList.item( i ).toElement();
00187 if ( currentElement.parentNode() == groupElement ) {
00188 result = readEntry( currentElement );
00189 if ( !result )
00190 return false;
00191 }
00192 }
00193 }
00194
00195 readSynonymsAntonymsFalseFriends( domElementParent );
00196
00197 groupElement = domElementParent.firstChildElement( KVTML_WORDTYPES );
00198 if ( !groupElement.isNull() ) {
00199 readChildWordTypes( m_doc->wordTypeContainer(), groupElement );
00200 }
00201
00202 groupElement = domElementParent.firstChildElement( KVTML_LEITNERBOXES );
00203 if ( !groupElement.isNull() ) {
00204 readLeitner( m_doc->leitnerContainer(), groupElement );
00205 }
00206
00207 groupElement = domElementParent.firstChildElement( KVTML_LESSONS );
00208 if ( !groupElement.isNull() ) {
00209 readChildLessons(m_doc->lesson(), groupElement);
00210 }
00211
00212
00213 KEduVocLesson *defaultLesson = new KEduVocLesson(i18n("Default Lesson"), m_doc->lesson());
00214
00215
00216 foreach (KEduVocExpression * entry, m_allEntries) {
00217 if (!entry->lesson())
00218 {
00219 defaultLesson->appendEntry(entry);
00220 }
00221 }
00222
00223 if (defaultLesson->entryCount() > 0)
00224 {
00225 m_doc->lesson()->appendChildContainer(defaultLesson);
00226 } else {
00227 delete defaultLesson;
00228 }
00229
00230 return true;
00231 }
00232
00233
00234 bool KEduVocKvtml2Reader::readIdentifier( QDomElement &identifierElement )
00235 {
00236 bool result = true;
00237 int id = identifierElement.attribute( KVTML_ID ).toInt( &result );
00238 if ( !result ) {
00239 m_errorMessage = i18n( "identifier missing id" );
00240 return false;
00241 }
00242
00243
00244 for ( int i = m_doc->identifierCount(); i <= id; i++ ) {
00245 m_doc->appendIdentifier( KEduVocIdentifier() );
00246 }
00247
00248
00249 QDomElement currentElement = identifierElement.firstChildElement( KVTML_NAME );
00250 m_doc->identifier(id).setName( currentElement.text() );
00251
00252 currentElement = identifierElement.firstChildElement( KVTML_LOCALE );
00253 m_doc->identifier(id).setLocale( currentElement.text() );
00254
00255 currentElement = identifierElement.firstChildElement( KVTML_IDENTIFIERTYPE );
00256 if ( !currentElement.isNull() ) {
00257
00258 }
00259
00260
00261 currentElement = identifierElement.firstChildElement( KVTML_ARTICLE );
00262 if ( !currentElement.isNull() ) {
00263 readArticle( currentElement, id );
00264 }
00265
00266 currentElement = identifierElement.firstChildElement( KVTML_PERSONALPRONOUNS );
00267 if ( !currentElement.isNull() ) {
00268 KEduVocPersonalPronoun personalPronoun;
00269 readPersonalPronoun( currentElement, personalPronoun );
00270 m_doc->identifier(id).setPersonalPronouns( personalPronoun );
00271 }
00272
00273 QStringList tenses = readTenses(identifierElement);
00274 kDebug() << tenses;
00275
00276 m_doc->identifier(id).setTenseList(tenses);
00277
00278 return result;
00279 }
00280
00281 bool KEduVocKvtml2Reader::readEntry( QDomElement &entryElement )
00282 {
00283 QDomElement currentElement;
00284 bool result = true;
00285
00286
00287 int id = entryElement.attribute( KVTML_ID ).toInt( &result );
00288 if ( !result ) {
00289 m_errorMessage = i18n( "entry missing id" );
00290 return false;
00291 }
00292
00293 KEduVocExpression *expr = new KEduVocExpression;
00294
00295
00296 currentElement = entryElement.firstChildElement( KVTML_DEACTIVATED );
00297 if ( !currentElement.isNull() ) {
00298
00299 if ( currentElement.text() == KVTML_TRUE ) {
00300 expr->setActive( false );
00301 } else {
00302 expr->setActive( true );
00303 }
00304 }
00305
00306
00307
00308 QDomNodeList translationList = entryElement.elementsByTagName( KVTML_TRANSLATION );
00309 if ( translationList.length() <= 0 ) {
00310 delete expr;
00311 m_errorMessage = i18n( "no translations found" );
00312 return false;
00313 }
00314
00315 for ( int i = 0; i < translationList.count(); ++i ) {
00316 currentElement = translationList.item( i ).toElement();
00317 if ( currentElement.parentNode() == entryElement ) {
00318 result = readTranslation( currentElement, expr, i );
00319 if ( !result )
00320 return false;
00321 }
00322 }
00323
00324
00325
00326 m_allEntries[id] = expr;
00327 return result;
00328 }
00329
00330 bool KEduVocKvtml2Reader::readTranslation( QDomElement &translationElement,
00331 KEduVocExpression *expr, int index )
00332 {
00333
00334 expr->translation(index)->fromKVTML2(translationElement);
00335 QDomElement currentElement;
00336
00337
00339
00340
00341
00342
00343
00344
00345
00346 currentElement = translationElement.firstChildElement( KVTML_COMPARISON );
00347 if ( !currentElement.isNull() ) {
00348 readComparison( currentElement, expr->translation(index) );
00349 }
00350
00351
00352 currentElement = translationElement.firstChildElement( KVTML_MULTIPLECHOICE );
00353 if ( !currentElement.isNull() ) {
00354 readMultipleChoice( currentElement, expr->translation(index) );
00355 }
00356
00357
00358 currentElement = translationElement.firstChildElement( KVTML_IMAGE );
00359 if ( !currentElement.isNull() ) {
00360 expr->translation(index)->setImageUrl( KUrl( m_doc->url(), currentElement.text() ) );
00361 }
00362
00363
00364 currentElement = translationElement.firstChildElement( KVTML_SOUND );
00365 if ( !currentElement.isNull() ) {
00366 expr->translation(index)->setSoundUrl( KUrl( m_doc->url(), currentElement.text() ) );
00367 }
00368
00369 return true;
00370 }
00371
00372 bool KEduVocKvtml2Reader::readChildLessons( KEduVocLesson* parentLesson, QDomElement &lessonElement )
00373 {
00374 QDomElement currentElement = lessonElement.firstChildElement( KVTML_CONTAINER );
00375 while ( !currentElement.isNull() ) {
00376 readLesson(parentLesson, currentElement);
00377 currentElement = currentElement.nextSiblingElement( KVTML_CONTAINER );
00378 }
00379 return true;
00380 }
00381
00382 bool KEduVocKvtml2Reader::readLesson( KEduVocLesson* parentLesson, QDomElement &lessonElement )
00383 {
00384
00385 QDomElement currentElement = lessonElement.firstChildElement( KVTML_NAME );
00386 KEduVocLesson * lesson = new KEduVocLesson(currentElement.text(), parentLesson);
00387 parentLesson->appendChildContainer( lesson );
00388
00389 readChildLessons( lesson, lessonElement );
00390
00391
00392 currentElement = lessonElement.firstChildElement( KVTML_INPRACTICE );
00393 lesson->setInPractice(currentElement.text() == KVTML_TRUE);
00394
00395
00396 currentElement = lessonElement.firstChildElement( KVTML_ENTRY );
00397 while ( !currentElement.isNull() ) {
00398 bool result = false;
00399 int entryId = currentElement.attribute( KVTML_ID ).toInt( &result );
00400 if(result) {
00401 lesson->appendEntry( m_allEntries[entryId] );
00402 }
00403 currentElement = currentElement.nextSiblingElement( KVTML_ENTRY );
00404 }
00405 return true;
00406 }
00407
00408 bool KEduVocKvtml2Reader::readSynonymsAntonymsFalseFriends( QDomElement &rootElement )
00409 {
00410 QDomElement pairElement;
00411 for(int type = KEduVocTranslation::Synonym; type <= KEduVocTranslation::FalseFriend; type++) {
00412 switch (type) {
00413 case KEduVocTranslation::Synonym:
00414 pairElement= rootElement.firstChildElement( KVTML_SYNONYM );
00415 break;
00416 case KEduVocTranslation::Antonym:
00417 pairElement= rootElement.firstChildElement( KVTML_ANTONYM );
00418 break;
00419 case KEduVocTranslation::FalseFriend:
00420 pairElement= rootElement.firstChildElement( KVTML_FALSEFRIEND );
00421 break;
00422 }
00423
00424 pairElement = pairElement.firstChildElement( KVTML_PAIR );
00425 while ( !pairElement.isNull() ) {
00426
00427 QDomElement entryElement = pairElement.firstChildElement( KVTML_ENTRY );
00428 int firstEntryId = entryElement.attribute( KVTML_ID ).toInt();
00429
00430 QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
00431 int firstTranslationId = translationElement.attribute( KVTML_ID ).toInt();
00432
00433
00434 entryElement = entryElement.nextSiblingElement( KVTML_ENTRY );
00435 int secondEntryId = entryElement.attribute( KVTML_ID ).toInt();
00436 translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
00437 int secondTranslationId = translationElement.attribute( KVTML_ID ).toInt();
00438
00439
00440 KEduVocTranslation *first = m_allEntries[firstEntryId]->translation(firstTranslationId);
00441 KEduVocTranslation *second = m_allEntries[secondEntryId]->translation(secondTranslationId);
00442
00443 switch (type) {
00444 case KEduVocTranslation::Synonym:
00445 first->addSynonym(second);
00446 second->addSynonym(first);
00447 break;
00448 case KEduVocTranslation::Antonym:
00449 first->addAntonym(second);
00450 second->addAntonym(first);
00451 break;
00452 case KEduVocTranslation::FalseFriend:
00453 first->addFalseFriend(second);
00454 second->addFalseFriend(first);
00455 break;
00456 }
00457 pairElement = pairElement.nextSiblingElement( KVTML_PAIR );
00458 }
00459 }
00460 return true;
00461 }
00462
00463 bool KEduVocKvtml2Reader::readArticle( QDomElement &articleElement, int identifierNum )
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 {
00483 QMap<int, KEduVocWordFlag::Flags> numbers;
00484 numbers[0] = KEduVocWordFlag::Singular;
00485 numbers[1] = KEduVocWordFlag::Dual;
00486 numbers[2] = KEduVocWordFlag::Plural;
00487 QMap<int, KEduVocWordFlag::Flags> genders;
00488 genders[0] = KEduVocWordFlag::Masculine;
00489 genders[1] = KEduVocWordFlag::Feminine;
00490 genders[2] = KEduVocWordFlag::Neuter;
00491 QMap<int, KEduVocWordFlag::Flags> defs;
00492 defs[0] = KEduVocWordFlag::Definite;
00493 defs[1] = KEduVocWordFlag::Indefinite;
00494
00495 for ( int num = 0; num <= 2; ++num) {
00496 QDomElement numberElement = articleElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[num] );
00497 if (!numberElement.isNull()) {
00498
00499 for ( int def = 0; def <= 1; ++def ) {
00500 QDomElement defElement = numberElement.firstChildElement( KVTML_GRAMMATICAL_DEFINITENESS[def] );
00501 if (!defElement.isNull()) {
00502
00503 for ( int gen = 0; gen <= 2; ++gen ) {
00504 QDomElement genderElement = defElement.firstChildElement( KVTML_GRAMMATICAL_GENDER[gen] );
00505 if (!genderElement.isNull()) {
00506 m_doc->identifier(identifierNum).article().setArticle( genderElement.text(), numbers[num] | defs[def] | genders[gen]);
00507 }
00508 }
00509 }
00510 }
00511 }
00512 }
00513
00514 return true;
00515 }
00516
00517
00518 bool KEduVocKvtml2Reader::readChildWordTypes(KEduVocWordType* parentContainer, QDomElement &lessonElement)
00519 {
00520 QDomElement currentElement = lessonElement.firstChildElement( KVTML_CONTAINER );
00521 while ( !currentElement.isNull() ) {
00522 readWordType(parentContainer, currentElement);
00523 currentElement = currentElement.nextSiblingElement( KVTML_CONTAINER );
00524 }
00525 return true;
00526 }
00527
00528 bool KEduVocKvtml2Reader::readLeitner( KEduVocLeitnerBox* parentContainer, QDomElement &leitnerParentElement )
00529 {
00530 QDomElement leitnerElement = leitnerParentElement.firstChildElement( KVTML_CONTAINER );
00531 while ( !leitnerElement.isNull() ) {
00532 QString name = leitnerElement.firstChildElement( KVTML_NAME ).text();
00533
00534 KEduVocLeitnerBox * leitner = new KEduVocLeitnerBox(name, parentContainer);
00535 parentContainer->appendChildContainer(leitner);
00536
00537
00538
00539 QDomElement entryElement = leitnerElement.firstChildElement( KVTML_ENTRY );
00540 while ( !entryElement.isNull() ) {
00541
00542 int entryId = entryElement.attribute( KVTML_ID ).toInt();
00543 QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
00544 while( !translationElement.isNull() ) {
00545
00546 int translationId = translationElement.attribute( KVTML_ID ).toInt();
00547 m_allEntries.value(entryId)->translation(translationId)->setLeitnerBox(leitner);
00548 translationElement = translationElement.nextSiblingElement( KVTML_TRANSLATION );
00549 }
00550 entryElement = entryElement.nextSiblingElement( KVTML_ENTRY );
00551 }
00552 leitnerElement = leitnerElement.nextSiblingElement( KVTML_CONTAINER );
00553 }
00554 return true;
00555 }
00556
00557 bool KEduVocKvtml2Reader::readWordType( KEduVocWordType* parentContainer, QDomElement &typeElement )
00558 {
00559
00560 QString typeName =
00561 typeElement.firstChildElement( KVTML_NAME ).text();
00562
00563 KEduVocWordType * wordTypeContainer = new KEduVocWordType(typeName, parentContainer);
00564 parentContainer->appendChildContainer(wordTypeContainer);
00565
00566 QString specialType = typeElement.firstChildElement( KVTML_SPECIALWORDTYPE ).text();
00567 if ( !specialType.isEmpty() ) {
00568
00569 if ( specialType == KVTML_SPECIALWORDTYPE_NOUN ) {
00570 wordTypeContainer->setWordType(KEduVocWordFlag::Noun);
00571 }
00572 if ( specialType == KVTML_SPECIALWORDTYPE_VERB ) {
00573 wordTypeContainer->setWordType(KEduVocWordFlag::Verb);
00574 }
00575 if ( specialType == KVTML_SPECIALWORDTYPE_ADVERB ) {
00576 wordTypeContainer->setWordType(KEduVocWordFlag::Adverb);
00577 }
00578 if ( specialType == KVTML_SPECIALWORDTYPE_ADJECTIVE ) {
00579 wordTypeContainer->setWordType(KEduVocWordFlag::Adjective);
00580 }
00581 if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_MALE ) {
00582 wordTypeContainer->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Masculine);
00583 }
00584 if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_FEMALE ) {
00585 wordTypeContainer->setWordType(KEduVocWordFlag::Noun | KEduVocWordFlag::Feminine);
00586 }
00587 if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL ) {
00588 wordTypeContainer->setWordType(KEduVocWordFlag::Noun| KEduVocWordFlag::Neuter);
00589 }
00590 }
00591
00592
00593
00594 QDomElement entryElement = typeElement.firstChildElement( KVTML_ENTRY );
00595 while ( !entryElement.isNull() ) {
00596
00597 int entryId = entryElement.attribute( KVTML_ID ).toInt();
00598 QDomElement translationElement = entryElement.firstChildElement( KVTML_TRANSLATION );
00599 while( !translationElement.isNull() ) {
00600
00601 int translationId = translationElement.attribute( KVTML_ID ).toInt();
00602 m_allEntries.value(entryId)->translation(translationId)->setWordType(wordTypeContainer);
00603 translationElement = translationElement.nextSiblingElement( KVTML_TRANSLATION );
00604 }
00605 entryElement = entryElement.nextSiblingElement( KVTML_ENTRY );
00606 }
00607
00608 readChildWordTypes(wordTypeContainer, typeElement);
00609
00610 return true;
00611 }
00612
00613 QStringList KEduVocKvtml2Reader::readTenses( QDomElement &tensesElement )
00614 {
00615 QStringList tenses;
00616
00617 QDomNodeList tenseNodes = tensesElement.elementsByTagName( KVTML_TENSE );
00618 for ( int i = 0; i < tenseNodes.count(); ++i ) {
00619 QDomElement currentElement = tenseNodes.item( i ).toElement();
00620 if ( currentElement.parentNode() == tensesElement ) {
00621 tenses.append( currentElement.text() );
00622 }
00623 }
00624
00625 return tenses;
00626 }
00627
00628 bool KEduVocKvtml2Reader::readComparison( QDomElement &domElementParent, KEduVocTranslation* translation )
00629
00630
00631
00632
00633
00634
00635 {
00636 QDomElement currentElement;
00637
00638 currentElement = domElementParent.firstChildElement( KVTML_COMPARATIVE );
00639 if ( !currentElement.isNull() )
00640 {
00641 translation->setComparative( currentElement.text() );
00642 }
00643
00644 currentElement = domElementParent.firstChildElement( KVTML_SUPERLATIVE );
00645 if ( !currentElement.isNull() )
00646 {
00647 translation->setSuperlative( currentElement.text() );
00648 }
00649 return true;
00650 }
00651
00652
00653 bool KEduVocKvtml2Reader::readMultipleChoice( QDomElement &multipleChoiceElement, KEduVocTranslation* translation )
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663 {
00664 QDomElement currentElement;
00665 QDomNodeList choiceNodes = multipleChoiceElement.elementsByTagName( KVTML_CHOICE );
00666 for ( int i = 0; i < choiceNodes.count(); ++i )
00667 {
00668 currentElement = choiceNodes.item( i ).toElement();
00669 if ( currentElement.parentNode() == multipleChoiceElement ) {
00670 translation->multipleChoice().append( currentElement.text() );
00671 }
00672 }
00673 return true;
00674 }
00675
00676
00677 bool KEduVocKvtml2Reader::readPersonalPronoun(QDomElement & pronounElement, KEduVocPersonalPronoun & pronoun)
00678 {
00679 pronoun.setMaleFemaleDifferent(!pronounElement.firstChildElement(
00680 KVTML_THIRD_PERSON_MALE_FEMALE_DIFFERENT).isNull());
00681 pronoun.setNeutralExists( !pronounElement.firstChildElement(
00682 KVTML_THIRD_PERSON_NEUTRAL_EXISTS).isNull() );
00683 pronoun.setDualExists( !pronounElement.firstChildElement(
00684 KVTML_DUAL_EXISTS).isNull() );
00685
00686 QDomElement personElement = pronounElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[0] );
00687 if ( !personElement.isNull() ) {
00688 readPersonalPronounChild( personElement, pronoun, KEduVocWordFlag::Singular );
00689 }
00690
00691 personElement = pronounElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[1] );
00692 if ( !personElement.isNull() ) {
00693 readPersonalPronounChild( personElement, pronoun, KEduVocWordFlag::Dual );
00694 }
00695
00696 personElement = pronounElement.firstChildElement( KVTML_GRAMMATICAL_NUMBER[2] );
00697 if ( !personElement.isNull() ) {
00698 readPersonalPronounChild( personElement, pronoun, KEduVocWordFlag::Plural );
00699 }
00700 return true;
00701 }
00702
00703
00704 bool KEduVocKvtml2Reader::readPersonalPronounChild(QDomElement & personElement, KEduVocPersonalPronoun & pronoun, KEduVocWordFlags number)
00705 {
00706 QMap<int, KEduVocWordFlag::Flags> persons;
00707 persons[0] = KEduVocWordFlag::First;
00708 persons[1] = KEduVocWordFlag::Second;
00709 persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine);
00710 persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine);
00711 persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter);
00712
00713
00714
00715 for (int person = 0; person < 5; person++) {
00716 QDomElement currentElement = personElement.firstChildElement( KVTML_GRAMMATICAL_PERSON[person] );
00717 pronoun.setPersonalPronoun( currentElement.text(), persons[person] | number );
00718 }
00719
00720 return true;
00721 }
00722
00723
00724 #include "keduvockvtml2reader.moc"