1 | #include "xslt.h" |
---|---|
2 | |
3 | #include <libxslt/xsltconfig.h> |
4 | #include <libxslt/xsltInternals.h> |
5 | #include <libxslt/transform.h> |
6 | #include <libxslt/xsltutils.h> |
7 | #include <libxml/xmlIO.h> |
8 | #include <libxml/parserInternals.h> |
9 | #include <libxml/catalog.h> |
10 | #include <kdebug.h> |
11 | #include <kstandarddirs.h> |
12 | #include <QtCore/QDate> |
13 | #include <QtCore/QDir> |
14 | #include <QtCore/QRegExp> |
15 | #include <kcomponentdata.h> |
16 | #include <klocale.h> |
17 | #include <assert.h> |
18 | #include <kfilterbase.h> |
19 | #include <kfilterdev.h> |
20 | #include <QtCore/QTextCodec> |
21 | #include <stdlib.h> |
22 | #include <config.h> |
23 | #include <stdarg.h> |
24 | #include <kcharsets.h> |
25 | #include <kurl.h> |
26 | |
27 | void fillInstance(KComponentData &ins, const QString &srcdir) |
28 | { |
29 | QByteArray catalogs; |
30 | |
31 | if ( srcdir.isEmpty() ) { |
32 | catalogs += KUrl::fromLocalFile( ins.dirs()->findResource("data", "ksgmltools2/customization/catalog.xml") ).toEncoded(); |
33 | ins.dirs()->addResourceType("dtd", "data", "ksgmltools2/"); |
34 | } else { |
35 | catalogs += KUrl::fromLocalFile( srcdir +"/customization/catalog.xml").toEncoded(); |
36 | ins.dirs()->addResourceDir("dtd", srcdir); |
37 | } |
38 | |
39 | setenv( "XML_CATALOG_FILES", catalogs.constData(), 1 ); |
40 | xmlInitializeCatalog(); |
41 | } |
42 | |
43 | QIODevice *getBZip2device(const QString &fileName ) |
44 | { |
45 | return KFilterDev::deviceForFile(fileName); |
46 | } |
47 | |
48 | bool saveToCache( const QString &contents, const QString &filename ) |
49 | { |
50 | QIODevice *fd = ::getBZip2device(filename); |
51 | if ( !fd ) |
52 | return false; |
53 | |
54 | if (!fd->open(QIODevice::WriteOnly)) |
55 | { |
56 | delete fd; |
57 | return false; |
58 | } |
59 | |
60 | fd->write( contents.toUtf8() ); |
61 | fd->close(); |
62 | delete fd; |
63 | return true; |
64 | } |
65 |