Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/gnc/import/mymoneygncreader.cpp
Context not available. | |||||
149 | { | 149 | { | ||
---|---|---|---|---|---|
150 | TRY { | 150 | TRY { | ||
151 | if (map.contains(elName)) { // if it's not in the map, there's nothing to check | 151 | if (map.contains(elName)) { // if it's not in the map, there's nothing to check | ||
152 | if (!map[elName].contains(elAttrs.value("version"))) { | 152 | if (!map[elName].contains(elAttrs.value("version"))) | ||
153 | QString em = Q_FUNC_INFO + i18n(": Sorry. This importer cannot handle version %1 of element %2" | 153 | throw MYMONEYEXCEPTION(QString::fromLatin1("%1 : Sorry. This importer cannot handle version %2 of element %3").arg(Q_FUNC_INFO, elAttrs.value("version"), elName)); | ||
154 | , elAttrs.value("version"), elName); | | |||
155 | throw MYMONEYEXCEPTION(em); | | |||
156 | } | | |||
157 | } | 154 | } | ||
158 | return ; | 155 | return ; | ||
159 | } | 156 | } | ||
Context not available. | |||||
338 | GncObject *next = 0; | 335 | GncObject *next = 0; | ||
339 | switch (m_state) { | 336 | switch (m_state) { | ||
340 | case BOOK: | 337 | case BOOK: | ||
341 | if (m_bookFound) throw MYMONEYEXCEPTION(i18n("This version of the importer cannot handle multi-book files.")); | 338 | if (m_bookFound) MYMONEYEXCEPTION(QString::fromLatin1("This version of the importer cannot handle multi-book files.")); | ||
342 | m_bookFound = true; | 339 | m_bookFound = true; | ||
343 | break; | 340 | break; | ||
344 | case COUNT: | 341 | case COUNT: | ||
Context not available. | |||||
365 | next = new GncSchedule; | 362 | next = new GncSchedule; | ||
366 | break; | 363 | break; | ||
367 | default: | 364 | default: | ||
368 | throw MYMONEYEXCEPTION("GncFile rcvd invalid state"); | 365 | throw MYMONEYEXCEPTION_CSTRING("GncFile rcvd invalid state"); | ||
369 | } | 366 | } | ||
370 | return (next); | 367 | return (next); | ||
371 | } | 368 | } | ||
Context not available. | |||||
457 | next = new GncKvp; | 454 | next = new GncKvp; | ||
458 | break; | 455 | break; | ||
459 | default: | 456 | default: | ||
460 | throw MYMONEYEXCEPTION("GncKvp rcvd invalid m_state "); | 457 | throw MYMONEYEXCEPTION_CSTRING("GncKvp rcvd invalid m_state "); | ||
461 | } | 458 | } | ||
462 | return (next); | 459 | return (next); | ||
463 | } | 460 | } | ||
Context not available. | |||||
578 | next = new GncDate; | 575 | next = new GncDate; | ||
579 | break; | 576 | break; | ||
580 | default: | 577 | default: | ||
581 | throw MYMONEYEXCEPTION("GncPrice rcvd invalid m_state"); | 578 | throw MYMONEYEXCEPTION_CSTRING("GncPrice rcvd invalid m_state"); | ||
582 | } | 579 | } | ||
583 | return (next); | 580 | return (next); | ||
584 | } | 581 | } | ||
Context not available. | |||||
599 | m_vpPriceDate = static_cast<GncDate *>(subObj); | 596 | m_vpPriceDate = static_cast<GncDate *>(subObj); | ||
600 | break; | 597 | break; | ||
601 | default: | 598 | default: | ||
602 | throw MYMONEYEXCEPTION("GncPrice rcvd invalid m_state"); | 599 | throw MYMONEYEXCEPTION_CSTRING("GncPrice rcvd invalid m_state"); | ||
603 | } | 600 | } | ||
604 | return; | 601 | return; | ||
605 | } | 602 | } | ||
Context not available. | |||||
653 | pMain->setLotsFound(true); // we don't handle lots; just set flag to report | 650 | pMain->setLotsFound(true); // we don't handle lots; just set flag to report | ||
654 | break; | 651 | break; | ||
655 | default: | 652 | default: | ||
656 | throw MYMONEYEXCEPTION("GncAccount rcvd invalid m_state"); | 653 | throw MYMONEYEXCEPTION_CSTRING("GncAccount rcvd invalid m_state"); | ||
657 | } | 654 | } | ||
658 | return (next); | 655 | return (next); | ||
659 | } | 656 | } | ||
Context not available. | |||||
730 | next = new GncKvp; | 727 | next = new GncKvp; | ||
731 | break; | 728 | break; | ||
732 | default: | 729 | default: | ||
733 | throw MYMONEYEXCEPTION("GncTransaction rcvd invalid m_state"); | 730 | throw MYMONEYEXCEPTION_CSTRING("GncTransaction rcvd invalid m_state"); | ||
734 | } | 731 | } | ||
735 | return (next); | 732 | return (next); | ||
736 | } | 733 | } | ||
Context not available. | |||||
802 | next = new GncDate; | 799 | next = new GncDate; | ||
803 | break; | 800 | break; | ||
804 | default: | 801 | default: | ||
805 | throw MYMONEYEXCEPTION("GncTemplateSplit rcvd invalid m_state "); | 802 | throw MYMONEYEXCEPTION_CSTRING("GncTemplateSplit rcvd invalid m_state "); | ||
806 | } | 803 | } | ||
807 | return (next); | 804 | return (next); | ||
808 | } | 805 | } | ||
Context not available. | |||||
847 | next = new GncKvp; | 844 | next = new GncKvp; | ||
848 | break; | 845 | break; | ||
849 | default: | 846 | default: | ||
850 | throw MYMONEYEXCEPTION("GncTemplateSplit rcvd invalid m_state"); | 847 | throw MYMONEYEXCEPTION_CSTRING("GncTemplateSplit rcvd invalid m_state"); | ||
851 | } | 848 | } | ||
852 | return (next); | 849 | return (next); | ||
853 | } | 850 | } | ||
Context not available. | |||||
909 | next = new GncSchedDef; | 906 | next = new GncSchedDef; | ||
910 | break; | 907 | break; | ||
911 | default: | 908 | default: | ||
912 | throw MYMONEYEXCEPTION("GncSchedule rcvd invalid m_state"); | 909 | throw MYMONEYEXCEPTION_CSTRING("GncSchedule rcvd invalid m_state"); | ||
913 | } | 910 | } | ||
914 | return (next); | 911 | return (next); | ||
915 | } | 912 | } | ||
Context not available. | |||||
979 | next = new GncFreqSpec; | 976 | next = new GncFreqSpec; | ||
980 | break; | 977 | break; | ||
981 | default: | 978 | default: | ||
982 | throw MYMONEYEXCEPTION("GncFreqSpec rcvd invalid m_state"); | 979 | throw MYMONEYEXCEPTION_CSTRING("GncFreqSpec rcvd invalid m_state"); | ||
983 | } | 980 | } | ||
984 | return (next); | 981 | return (next); | ||
985 | } | 982 | } | ||
Context not available. | |||||
1034 | next = new GncDate; | 1031 | next = new GncDate; | ||
1035 | break; | 1032 | break; | ||
1036 | default: | 1033 | default: | ||
1037 | throw MYMONEYEXCEPTION("GncRecurrence rcvd invalid m_state"); | 1034 | throw MYMONEYEXCEPTION_CSTRING("GncRecurrence rcvd invalid m_state"); | ||
1038 | } | 1035 | } | ||
1039 | return (next); | 1036 | return (next); | ||
1040 | } | 1037 | } | ||
Context not available. | |||||
1110 | m_reader = new QXmlSimpleReader; | 1107 | m_reader = new QXmlSimpleReader; | ||
1111 | m_reader->setContentHandler(this); | 1108 | m_reader->setContentHandler(this); | ||
1112 | // go read the file | 1109 | // go read the file | ||
1113 | if (!m_reader->parse(m_source)) { | 1110 | if (!m_reader->parse(m_source)) | ||
1114 | throw MYMONEYEXCEPTION(i18n("Input file cannot be parsed; may be corrupt\n%1", errorString())); | 1111 | throw MYMONEYEXCEPTION(QString::fromLatin1("Input file cannot be parsed; may be corrupt\n%1").arg(errorString())); | ||
1115 | } | 1112 | | ||
1116 | delete m_reader; | 1113 | delete m_reader; | ||
1117 | delete m_source; | 1114 | delete m_source; | ||
1118 | return ; | 1115 | return ; | ||
Context not available. | |||||
1162 | lastType = 0; | 1159 | lastType = 0; | ||
1163 | #else | 1160 | #else | ||
1164 | if ((!m_headerFound) && (elName != "gnc-v2")) | 1161 | if ((!m_headerFound) && (elName != "gnc-v2")) | ||
1165 | throw MYMONEYEXCEPTION(i18n("Invalid header for file. Should be 'gnc-v2'")); | 1162 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid header for file. Should be 'gnc-v2'")); | ||
1166 | m_headerFound = true; | 1163 | m_headerFound = true; | ||
1167 | #endif // _GNCFILEANON | 1164 | #endif // _GNCFILEANON | ||
1168 | m_co->checkVersion(elName, elAttrs, pMain->m_versionList); | 1165 | m_co->checkVersion(elName, elAttrs, pMain->m_versionList); | ||
Context not available. | |||||
1548 | } else if ("MONEYMRKT" == gac->type()) { | 1545 | } else if ("MONEYMRKT" == gac->type()) { | ||
1549 | acc.setAccountType(Account::Type::MoneyMarket); | 1546 | acc.setAccountType(Account::Type::MoneyMarket); | ||
1550 | } else { // we have here an account type we can't currently handle | 1547 | } else { // we have here an account type we can't currently handle | ||
1551 | QString em = | 1548 | throw MYMONEYEXCEPTION(QString::fromLatin1("Current importer does not recognize GnuCash account type %1").arg(gac->type())); | ||
1552 | i18n("Current importer does not recognize GnuCash account type %1", gac->type()); | | |||
1553 | throw MYMONEYEXCEPTION(em); | | |||
1554 | } | 1549 | } | ||
1555 | // if no parent account is present, assign to one of our standard accounts | 1550 | // if no parent account is present, assign to one of our standard accounts | ||
1556 | if ((acc.parentAccountId().isEmpty()) || (acc.parentAccountId() == m_rootId)) { | 1551 | if ((acc.parentAccountId().isEmpty()) || (acc.parentAccountId() == m_rootId)) { | ||
Context not available. | |||||
2030 | if (static_cast<const GncTemplateSplit *>((*itt)->getSplit(0))->acct() == gsc->templId()) break; | 2025 | if (static_cast<const GncTemplateSplit *>((*itt)->getSplit(0))->acct() == gsc->templId()) break; | ||
2031 | } | 2026 | } | ||
2032 | if (itt == m_templateList.constEnd()) { | 2027 | if (itt == m_templateList.constEnd()) { | ||
2033 | throw MYMONEYEXCEPTION(i18n("Cannot find template transaction for schedule %1", sc.name())); | 2028 | throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot find template transaction for schedule %1").arg(sc.name())); | ||
2034 | } else { | 2029 | } else { | ||
2035 | tx = convertTemplateTransaction(sc.name(), *itt); | 2030 | tx = convertTemplateTransaction(sc.name(), *itt); | ||
2036 | } | 2031 | } | ||
Context not available. | |||||
2257 | parent = checkConsistency(parent, (*acc)); | 2252 | parent = checkConsistency(parent, (*acc)); | ||
2258 | m_storage->addAccount(parent, (*acc)); | 2253 | m_storage->addAccount(parent, (*acc)); | ||
2259 | } else { | 2254 | } else { | ||
2260 | throw MYMONEYEXCEPTION("terminate() could not find account id"); | 2255 | throw MYMONEYEXCEPTION_CSTRING("terminate() could not find account id"); | ||
2261 | } | 2256 | } | ||
2262 | } | 2257 | } | ||
2263 | signalProgress(++i, 0); | 2258 | signalProgress(++i, 0); | ||
Context not available. | |||||
2455 | case 'o': // once-only | 2450 | case 'o': // once-only | ||
2456 | return (lastDate); | 2451 | return (lastDate); | ||
2457 | } | 2452 | } | ||
2458 | throw MYMONEYEXCEPTION(i18n("Internal error - invalid interval char in incrDate")); | 2453 | throw MYMONEYEXCEPTION_CSTRING("Internal error - invalid interval char in incrDate"); | ||
2459 | // QDate r = QDate(); return (r); // to keep compiler happy | 2454 | // QDate r = QDate(); return (r); // to keep compiler happy | ||
2460 | } | 2455 | } | ||
2461 | PASS | 2456 | PASS | ||
Context not available. |