diff --git a/shared/defaulttextprocessor.cpp b/shared/defaulttextprocessor.cpp index c393486..a06cd82 100644 --- a/shared/defaulttextprocessor.cpp +++ b/shared/defaulttextprocessor.cpp @@ -24,7 +24,9 @@ QString DefaultTextProcessor::processText(const QByteArray &data) const return {}; } -QVector DefaultTextProcessor::process(const QByteArray &data) const +DocumentProcessResult DefaultTextProcessor::process(const QByteArray &data) const { - return {{0, processText(data)}}; + DocumentProcessResult result; + result.pages.append({0, processText(data)}); + return result; } diff --git a/shared/defaulttextprocessor.h b/shared/defaulttextprocessor.h index 13d1061..87ce45a 100644 --- a/shared/defaulttextprocessor.h +++ b/shared/defaulttextprocessor.h @@ -11,7 +11,7 @@ class DefaultTextProcessor : public Processor public: DefaultTextProcessor(); QString processText(const QByteArray &data) const; - QVector process(const QByteArray &data) const override; + DocumentProcessResult process(const QByteArray &data) const override; }; #endif // DEFAULTTEXTPROCESSOR_H diff --git a/shared/odtprocessor.cpp b/shared/odtprocessor.cpp index a72e91a..e60727c 100644 --- a/shared/odtprocessor.cpp +++ b/shared/odtprocessor.cpp @@ -3,12 +3,12 @@ #include "odtprocessor.h" #include "tagstripperprocessor.h" -QVector OdtProcessor::process(const QByteArray & /*data*/) const +DocumentProcessResult OdtProcessor::process(const QByteArray & /*data*/) const { throw LooqsGeneralException("Not implemented yet"); } -QVector OdtProcessor::process(QString path) const +DocumentProcessResult OdtProcessor::process(QString path) const { QuaZipFile zipFile(path); zipFile.setFileName("content.xml"); diff --git a/shared/odtprocessor.h b/shared/odtprocessor.h index cef4083..aeed1d9 100644 --- a/shared/odtprocessor.h +++ b/shared/odtprocessor.h @@ -8,9 +8,9 @@ class OdtProcessor : public Processor { this->PREFERED_DATA_SOURCE = FILEPATH; } - QVector process(const QByteArray &data) const override; + DocumentProcessResult process(const QByteArray &data) const override; - QVector process(QString path) const override; + DocumentProcessResult process(QString path) const override; }; #endif // ODTPROCESSOR_H diff --git a/shared/sandboxedprocessor.cpp b/shared/sandboxedprocessor.cpp index 5ae5f7a..7af0121 100644 --- a/shared/sandboxedprocessor.cpp +++ b/shared/sandboxedprocessor.cpp @@ -65,18 +65,12 @@ void SandboxedProcessor::enableSandbox(QString readablePath) exile_free_policy(policy); } -void SandboxedProcessor::printResults(const QVector &pageData) +void SandboxedProcessor::printResults(const DocumentProcessResult &result) { QFile fsstdout; fsstdout.open(stdout, QIODevice::WriteOnly); QDataStream stream(&fsstdout); - - for(const PageData &data : pageData) - { - stream << data; - // fsstdout.flush(); - } - + stream << result; fsstdout.close(); } @@ -102,7 +96,7 @@ SaveFileResult SandboxedProcessor::process() return OK; } - QVector pageData; + DocumentProcessResult processResult; QString absPath = fileInfo.absoluteFilePath(); try @@ -111,13 +105,13 @@ SaveFileResult SandboxedProcessor::process() { /* Read access to FS needed... doh..*/ enableSandbox(absPath); - pageData = processor->process(absPath); + processResult = processor->process(absPath); } else { QByteArray data = Utils::readFile(absPath); enableSandbox(); - pageData = processor->process(data); + processResult = processor->process(data); } } catch(LooqsGeneralException &e) @@ -126,6 +120,6 @@ SaveFileResult SandboxedProcessor::process() return PROCESSFAIL; } - printResults(pageData); - return pageData.isEmpty() ? OK_WASEMPTY : OK; + printResults(processResult); + return processResult.pages.isEmpty() ? OK_WASEMPTY : OK; } diff --git a/shared/sandboxedprocessor.h b/shared/sandboxedprocessor.h index 72a8ea1..71ca806 100644 --- a/shared/sandboxedprocessor.h +++ b/shared/sandboxedprocessor.h @@ -2,7 +2,7 @@ #define SANDBOXEDPROCESSOR_H #include #include -#include "pagedata.h" +#include "documentprocessresult.h" #include "savefileresult.h" class SandboxedProcessor @@ -12,7 +12,7 @@ class SandboxedProcessor QMimeDatabase mimeDatabase; void enableSandbox(QString readablePath = ""); - void printResults(const QVector &pageData); + void printResults(const DocumentProcessResult &pageData); public: SandboxedProcessor(QString filepath) diff --git a/shared/tagstripperprocessor.cpp b/shared/tagstripperprocessor.cpp index 1cef41d..131fe31 100644 --- a/shared/tagstripperprocessor.cpp +++ b/shared/tagstripperprocessor.cpp @@ -4,11 +4,11 @@ TagStripperProcessor::TagStripperProcessor() { } -QVector TagStripperProcessor::process(const QByteArray &data) const +DocumentProcessResult TagStripperProcessor::process(const QByteArray &data) const { auto result = DefaultTextProcessor::process(data); // TODO: does not work properly with
and does not deal with entities... - - result[0].content.remove(QRegExp("<[^>]*>")); + Q_ASSERT(result.pages.size() > 0); + result.pages[0].content.remove(QRegExp("<[^>]*>")); return result; } diff --git a/shared/tagstripperprocessor.h b/shared/tagstripperprocessor.h index 4e485d1..37cfac2 100644 --- a/shared/tagstripperprocessor.h +++ b/shared/tagstripperprocessor.h @@ -8,7 +8,7 @@ class TagStripperProcessor : public DefaultTextProcessor TagStripperProcessor(); public: - QVector process(const QByteArray &data) const override; + DocumentProcessResult process(const QByteArray &data) const override; }; #endif // XMLSTRIPPERPROCESSOR_H