2010-06-22 14:43:03 +02:00
|
|
|
#include "odf.h"
|
|
|
|
|
#include "odfcontainer.h"
|
|
|
|
|
#include <QtCore/QDebug>
|
2010-06-24 11:54:55 +02:00
|
|
|
#include <QtWebKit/QWebFrame>
|
2010-06-22 14:43:03 +02:00
|
|
|
|
|
|
|
|
OdfContainer* Odf::getContainer(const QString& url) {
|
|
|
|
|
return new OdfContainer(url, this);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-25 10:08:51 -07:00
|
|
|
OdfContainer* Odf::getOpenContainer(const QString& id) {
|
|
|
|
|
return openfiles.value(id);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-22 14:43:03 +02:00
|
|
|
void
|
|
|
|
|
Odf::addFile(const QString& containerid, const QString& path)
|
|
|
|
|
{
|
|
|
|
|
if (!openfiles.contains(containerid)) {
|
|
|
|
|
openfiles.insert(containerid, new OdfContainer(path, this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString
|
2010-07-02 15:48:27 +02:00
|
|
|
Odf::load(QString containerid, QString path, QString callbackid)
|
2010-06-22 14:43:03 +02:00
|
|
|
{
|
|
|
|
|
OdfContainer* c = openfiles.value(containerid);
|
2010-06-24 11:54:55 +02:00
|
|
|
QString result;
|
|
|
|
|
if (c) {
|
|
|
|
|
result = c->loadAsString(path);
|
|
|
|
|
}
|
2010-07-02 15:48:27 +02:00
|
|
|
if (!callbackid.isNull()) {
|
|
|
|
|
callbackdata = result;
|
|
|
|
|
// call the callback with escaped result data
|
|
|
|
|
QVariant out = frame->evaluateJavaScript("window.qtodf." + callbackid
|
|
|
|
|
+ "(window.qtodf.callbackdata);window.qtodf." + callbackid
|
|
|
|
|
+"=null;");
|
|
|
|
|
if (out.toString().length()) {
|
|
|
|
|
qDebug() << out.toString();
|
|
|
|
|
}
|
|
|
|
|
callbackdata = QString();
|
|
|
|
|
}
|
2010-06-24 11:54:55 +02:00
|
|
|
return result;
|
2010-06-22 14:43:03 +02:00
|
|
|
}
|