File indexing completed on 2024-04-28 04:40:02
0001 #include "utils.h" 0002 #include <QtCore/QFile> 0003 #include <QtCore/QDebug> 0004 #include <libxml/parser.h> 0005 #include <libxslt/xsltInternals.h> 0006 #include <libxslt/transform.h> 0007 #include <libxslt/xsltutils.h> 0008 0009 QByteArray loadFile(const QString& filename) { 0010 QFile file(filename); 0011 if (!file.open(QIODevice::ReadOnly)) { 0012 qDebug() << file.errorString(); 0013 } 0014 return file.readAll(); 0015 } 0016 0017 void 0018 xmltosvg(xsltStylesheetPtr xsl, const char* filepath, FILE* out) { 0019 QString file = QString::fromLocal8Bit(filepath); 0020 const QMap<QString, QByteArray> streams = readStreams(file); 0021 const QMap<QString, QSharedPointer<const Introspectable> > introspectables 0022 = parseStreams(streams); 0023 const QByteArray xml = streamsToExtendedXml(introspectables); 0024 xmlDocPtr pptxmldoc = xmlParseMemory(xml, xml.size()); 0025 0026 xmlDocPtr res = xsltApplyStylesheet(xsl, pptxmldoc, 0); 0027 0028 xsltSaveResultToFile(out, res, xsl); 0029 0030 xmlFreeDoc(pptxmldoc); 0031 xmlFreeDoc(res); 0032 } 0033 0034 int 0035 main(int argc, char** argv) { 0036 if (argc < 2) return 1; 0037 0038 QByteArray xslfiledata = loadFile(":/ppttosvg.xsl"); 0039 xmlDocPtr xsldoc = xmlParseMemory(xslfiledata, xslfiledata.size()); 0040 xslfiledata.resize(0); 0041 xsltStylesheetPtr xsl = xsltParseStylesheetDoc(xsldoc); 0042 0043 for (int i=1; i<argc; ++i) { 0044 xmltosvg(xsl, argv[i], stdout); 0045 } 0046 xsltFreeStylesheet(xsl); // this frees xsldoc too 0047 0048 xsltCleanupGlobals(); 0049 xmlCleanupParser(); 0050 0051 return 0; 0052 }