|
|
|
@@ -20,6 +20,8 @@
|
|
|
|
|
#include <libxml/encoding.h>
|
|
|
|
|
#include <libxml/xmlwriter.h>
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
#include "XMLExportEngine.hpp"
|
|
|
|
|
|
|
|
|
|
static XMLExportEngine xmlExportEngine;
|
|
|
|
@@ -28,7 +30,7 @@ XMLExportEngine::XMLExportEngine()
|
|
|
|
|
{
|
|
|
|
|
KissCount::RegisterExportEngine(this);
|
|
|
|
|
|
|
|
|
|
_shortExt = wxT("xml");
|
|
|
|
|
_shortExt = "xml";
|
|
|
|
|
_longExt = _("XML files (*.xml)|*.xml");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -36,7 +38,7 @@ XMLExportEngine::~XMLExportEngine()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool XMLExportEngine::HandleFile(const wxString& path, User* user, Database* db, KissCount* kiss)
|
|
|
|
|
bool XMLExportEngine::HandleFile(const QString& path, User* user, Database* db, KissCount* kiss)
|
|
|
|
|
{
|
|
|
|
|
return ExportEngine::HandleFile(path, user, db, kiss);
|
|
|
|
|
}
|
|
|
|
@@ -44,7 +46,7 @@ bool XMLExportEngine::HandleFile(const wxString& path, User* user, Database* db,
|
|
|
|
|
bool XMLExportEngine::SaveAccounts()
|
|
|
|
|
{
|
|
|
|
|
Account account;
|
|
|
|
|
std::map<wxString, int>::iterator it;
|
|
|
|
|
std::map<int, int>::iterator it;
|
|
|
|
|
|
|
|
|
|
for(it=_accounts.begin(); it!=_accounts.end(); it++)
|
|
|
|
|
{
|
|
|
|
@@ -54,9 +56,9 @@ bool XMLExportEngine::SaveAccounts()
|
|
|
|
|
ESCAPE_CHARS(account.number);
|
|
|
|
|
|
|
|
|
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "account");
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) account.id.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) account.name.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "number", (const xmlChar*) account.number.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) QString::number(account.id).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) account.name.toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "number", (const xmlChar*) account.number.toStdString().c_str());
|
|
|
|
|
// xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "shared", (const xmlChar*) (account.shared ? "1" : "0"));
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "blocked", (const xmlChar*) (account.blocked ? "1" : "0"));
|
|
|
|
|
// xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "default", (const xmlChar*) (account._default ? "1" : "0"));
|
|
|
|
@@ -75,7 +77,7 @@ bool XMLExportEngine::SaveAccountAmounts()
|
|
|
|
|
for(it=_accountAmounts.begin(); it!=_accountAmounts.end(); it++)
|
|
|
|
|
{
|
|
|
|
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "account_amount");
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) it->first.account.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) QString::number(it->first.account).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "month", "%d", it->first.month);
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "year", "%d", it->first.year);
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "amount", "%.2lf", it->second);
|
|
|
|
@@ -88,7 +90,7 @@ bool XMLExportEngine::SaveAccountAmounts()
|
|
|
|
|
bool XMLExportEngine::SaveCategories()
|
|
|
|
|
{
|
|
|
|
|
Category category;
|
|
|
|
|
std::map<wxString, int>::iterator it;
|
|
|
|
|
std::map<int, int>::iterator it;
|
|
|
|
|
int rgb;
|
|
|
|
|
|
|
|
|
|
for(it=_categories.begin(); it!=_categories.end(); it++)
|
|
|
|
@@ -98,16 +100,16 @@ bool XMLExportEngine::SaveCategories()
|
|
|
|
|
ESCAPE_CHARS(category.name);
|
|
|
|
|
|
|
|
|
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "category");
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) category.id.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) category.name.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "font", (const xmlChar*) category.font.utf8_str().data());
|
|
|
|
|
rgb = category.backcolor.Blue();
|
|
|
|
|
rgb |= category.backcolor.Green() << 8;
|
|
|
|
|
rgb |= category.backcolor.Red() << 16;
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) QString::number(category.id).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) category.name.toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "font", (const xmlChar*) category.font.toStdString().c_str());
|
|
|
|
|
rgb = category.backcolor.blue();
|
|
|
|
|
rgb |= category.backcolor.green() << 8;
|
|
|
|
|
rgb |= category.backcolor.red() << 16;
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "backcolor", "0x%08X", rgb);
|
|
|
|
|
rgb = category.forecolor.Blue();
|
|
|
|
|
rgb |= category.forecolor.Green() << 8;
|
|
|
|
|
rgb |= category.forecolor.Red() << 16;
|
|
|
|
|
rgb = category.forecolor.blue();
|
|
|
|
|
rgb |= category.forecolor.green() << 8;
|
|
|
|
|
rgb |= category.forecolor.red() << 16;
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "forecolor", "0x%08X", rgb);
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "fix_cost", (const xmlChar*) (category.fix_cost ? "1" : "0"));
|
|
|
|
|
xmlTextWriterEndElement(_writer);
|
|
|
|
@@ -125,19 +127,19 @@ bool XMLExportEngine::SaveOperations(std::vector<Operation>* operations)
|
|
|
|
|
ESCAPE_CHARS(it->description);
|
|
|
|
|
|
|
|
|
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "operation");
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) it->id.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "parent", (const xmlChar*) it->parent.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) QString::number(it->id).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "parent", (const xmlChar*) QString::number(it->parent).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "day", "%d", it->day);
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "month", "%d", it->month);
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "year", "%d", it->year);
|
|
|
|
|
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "amount", "%.2lf", it->amount);
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "description", (const xmlChar*) it->description.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "category", (const xmlChar*) it->category.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "description", (const xmlChar*) it->description.toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "category", (const xmlChar*) QString::number(it->category).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "fix_cost", (const xmlChar*) (it->fix_cost ? "1" : "0"));
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) it->account.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) QString::number(it->account).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "checked", (const xmlChar*) (it->checked ? "1" : "0"));
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "transfert", (const xmlChar*) it->transfert.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "formula", (const xmlChar*) it->formula.utf8_str().data());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "transfert", (const xmlChar*) QString::number(it->transfert).toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "formula", (const xmlChar*) it->formula.toStdString().c_str());
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "meta", (const xmlChar*) (it->meta ? "1" : "0"));
|
|
|
|
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "virtual", (const xmlChar*) (it->_virtual ? "1" : "0"));
|
|
|
|
|
xmlTextWriterEndElement(_writer);
|
|
|
|
@@ -154,7 +156,7 @@ bool XMLExportEngine::SaveFile(std::vector<Operation>* operations)
|
|
|
|
|
|
|
|
|
|
if (!rc) return false;
|
|
|
|
|
|
|
|
|
|
_writer = xmlNewTextWriterFilename(_path.mb_str(), 0);
|
|
|
|
|
_writer = xmlNewTextWriterFilename(_path.toStdString().c_str(), 0);
|
|
|
|
|
|
|
|
|
|
if (!_writer)
|
|
|
|
|
{
|
|
|
|
|