From 1fdc150116cad39aae5c5da407c3312b47a59e3a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Fri, 17 Dec 2021 07:06:30 -0500 Subject: New upstream version 3.3.3+dfsg1. --- Plugins/XmlExport/package.xml | 10 ---- Plugins/XmlExport/xmlexport.cpp | 104 +++++++++++++++++++++++----------------- Plugins/XmlExport/xmlexport.h | 2 + 3 files changed, 63 insertions(+), 53 deletions(-) delete mode 100644 Plugins/XmlExport/package.xml (limited to 'Plugins/XmlExport') diff --git a/Plugins/XmlExport/package.xml b/Plugins/XmlExport/package.xml deleted file mode 100644 index f5f02a9..0000000 --- a/Plugins/XmlExport/package.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - XML Export plugin - Plugin for exporting schema and data to XML format. - %VERSION% - %DATE% - pl.com.salsoft.sqlitestudio.plugins.xmlexport - pl.com.salsoft.sqlitestudio.plugins - true - \ No newline at end of file diff --git a/Plugins/XmlExport/xmlexport.cpp b/Plugins/XmlExport/xmlexport.cpp index 0cea7df..9d55736 100644 --- a/Plugins/XmlExport/xmlexport.cpp +++ b/Plugins/XmlExport/xmlexport.cpp @@ -71,11 +71,11 @@ bool XmlExport::beforeExportQueryResults(const QString& query, QList"); incrIndent(); - writeln(""+ escape(col->displayName) + ""); - writeln(""+ escape(col->column) + ""); - writeln(""+ escape(col->table) + "
"); - writeln(""+ escape(col->database) + ""); - writeln(""+ escape(type.toFullTypeString()) + ""); + writeTagWithValue("displayName", col->displayName); + writeTagWithValue("name>", col->column); + writeTagWithValue("table", col->table); + writeTagWithValue("database", col->database); + writeTagWithValue("type", type.toFullTypeString()); decrIndent(); writeln(""); i++; @@ -134,12 +134,12 @@ bool XmlExport::exportTable(const QString& database, const QString& table, const writeln(QString("").arg(isTableExport() ? nsStr : "")); incrIndent(); - writeln("" + escape(database) + ""); - writeln("" + escape(table) + ""); + writeTagWithValue("database", database); + writeTagWithValue("name", table); if (!createTable->withOutRowId.isNull()) - writeln(QString("true")); + writeln("true"); - writeln("" + escape(ddl) + ""); + writeTagWithValue("ddl", ddl); writeln(""); incrIndent(); @@ -147,8 +147,8 @@ bool XmlExport::exportTable(const QString& database, const QString& table, const { writeln(""); incrIndent(); - writeln(""+ col->name + ""); - writeln(QString("%1").arg((col->type ? col->type->toDataType().toFullTypeString() : ""))); + writeTagWithValue("name", col->name); + writeTagWithValue("type", (col->type ? col->type->toDataType().toFullTypeString() : "")); if (col->constraints.size() > 0) { writeln(""); @@ -157,8 +157,8 @@ bool XmlExport::exportTable(const QString& database, const QString& table, const { writeln(""); incrIndent(); - writeln("" + constr->typeString() + ""); - writeln("" + constr->detokenize() + ""); + writeTagWithValue("type", constr->typeString()); + writeTagWithValue("definition", constr->detokenize()); decrIndent(); writeln(""); } @@ -179,8 +179,8 @@ bool XmlExport::exportTable(const QString& database, const QString& table, const { writeln(""); incrIndent(); - writeln("" + constr->typeString() + ""); - writeln("" + constr->detokenize() + ""); + writeTagWithValue("type", constr->typeString()); + writeTagWithValue("definition", constr->detokenize()); decrIndent(); writeln(""); } @@ -206,12 +206,11 @@ bool XmlExport::exportVirtualTable(const QString& database, const QString& table writeln(QString("").arg(isTableExport() ? nsStr : "")); incrIndent(); - writeln("" + escape(database) + ""); - writeln("" + escape(table) + ""); - writeln("true"); - writeln("" + escape(createTable->module) + ""); - - writeln("" + escape(ddl) + ""); + writeTagWithValue("database", database); + writeTagWithValue("name", table); + writeln("true"); + writeTagWithValue("module", createTable->module); + writeTagWithValue("ddl", ddl); writeln(""); incrIndent(); @@ -219,7 +218,7 @@ bool XmlExport::exportVirtualTable(const QString& database, const QString& table { writeln(""); incrIndent(); - writeln(""+ col + ""); + writeTagWithValue("name", col); decrIndent(); writeln(""); } @@ -231,7 +230,7 @@ bool XmlExport::exportVirtualTable(const QString& database, const QString& table writeln(""); incrIndent(); for (const QString& arg : createTable->args) - writeln("" + arg + ""); + writeTagWithValue("arg", arg); decrIndent(); writeln(""); @@ -263,7 +262,7 @@ bool XmlExport::beforeExportDatabase(const QString& database) writeln(QString("").arg(nsStr)); incrIndent(); - writeln("" + escape(database) + ""); + writeTagWithValue("name", database); return true; } @@ -273,15 +272,15 @@ bool XmlExport::exportIndex(const QString& database, const QString& name, const writeln(""); incrIndent(); - writeln("" + escape(database) + ""); - writeln("" + escape(name) + ""); + writeTagWithValue("database", database); + writeTagWithValue("name", name); if (createIndex->uniqueKw) writeln("true"); if (createIndex->where) - writeln("" + createIndex->where->detokenize() + ""); + writeTagWithValue("partial", createIndex->where->detokenize()); - writeln("" + escape(ddl) + ""); + writeTagWithValue("ddl", ddl); decrIndent(); writeln(""); @@ -294,32 +293,32 @@ bool XmlExport::exportTrigger(const QString& database, const QString& name, cons writeln(""); incrIndent(); - writeln("" + escape(database) + ""); - writeln("" + escape(name) + ""); - writeln("" + escape(ddl) + ""); + writeTagWithValue("database", database); + writeTagWithValue("name", name); + writeTagWithValue("ddl", ddl); QString timing = SqliteCreateTrigger::time(createTrigger->eventTime); - writeln("" + escape(timing) + ""); + writeTagWithValue("timing", timing); QString event = createTrigger->event ? SqliteCreateTrigger::Event::typeToString(createTrigger->event->type) : ""; - writeln("" + escape(event) + ""); + writeTagWithValue("action", event); QString tag; if (createTrigger->eventTime == SqliteCreateTrigger::Time::INSTEAD_OF) - tag = ""; + tag = "<%1view>"; else - tag = ""; + tag = "<%1table>"; - writeln(tag + escape(createTrigger->table) + tag); + writeln(tag.arg("") + escape(createTrigger->table) + tag.arg("/")); if (createTrigger->precondition) - writeln("" + escape(createTrigger->precondition->detokenize()) + ""); + writeTagWithValue("precondition", createTrigger->precondition->detokenize()); QStringList queryStrings; for (SqliteQuery* q : createTrigger->queries) queryStrings << q->detokenize(); - writeln("" + escape(queryStrings.join("\n")) + ""); + writeTagWithValue("code", queryStrings.join("\n")); decrIndent(); writeln(""); @@ -332,10 +331,11 @@ bool XmlExport::exportView(const QString& database, const QString& name, const Q writeln(""); incrIndent(); - writeln("" + escape(database) + ""); - writeln("" + escape(name) + ""); - writeln("" + escape(ddl) + ""); - writeln(""); + writeTagWithValue("database", database); + writeTagWithValue("name", name); + writeTagWithValue("ddl", ddl); + writeTagWithValue("select", createView->select->detokenize()); + decrIndent(); writeln(""); return true; @@ -442,8 +442,15 @@ QString XmlExport::escape(const QString& str) QString XmlExport::escapeCdata(const QString& str) { + static_qstring(tpl, ""); if (str.contains('"') || str.contains('&') || str.contains('<') || str.contains('>')) - return ""; + { + int idx = str.indexOf("]]>"); + if (idx > -1) + return escape(str.left(idx + 2)) + escape(str.mid(idx + 2)); + + return tpl.arg(str); + } return str; } @@ -453,6 +460,17 @@ QString XmlExport::escapeAmpersand(const QString& str) return str.toHtmlEscaped(); } +QString XmlExport::tagWithValue(const QString& tag, const QString& value) +{ + static_qstring(tpl, "<%1>%2"); + return tpl.arg(tag, escape(value)); +} + +void XmlExport::writeTagWithValue(const QString& tag, const QString& value) +{ + writeln(tagWithValue(tag, value)); +} + QString XmlExport::toString(bool value) { return value ? "true" : "false"; diff --git a/Plugins/XmlExport/xmlexport.h b/Plugins/XmlExport/xmlexport.h index c0842bc..94337e9 100644 --- a/Plugins/XmlExport/xmlexport.h +++ b/Plugins/XmlExport/xmlexport.h @@ -55,6 +55,8 @@ class XMLEXPORTSHARED_EXPORT XmlExport : public GenericExportPlugin QString escape(const QString& str); QString escapeCdata(const QString& str); QString escapeAmpersand(const QString& str); + QString tagWithValue(const QString& tag, const QString& value); + void writeTagWithValue(const QString& tag, const QString& value); static QString toString(bool value); -- cgit v1.2.3