1
#include "leinputstream.h"
2
#include "simpleParser.h"
3
#include "pole.h"
4
#include <QtCore/QBuffer>
5
#include <QtCore/QDebug>
6
7
using namespace std;
8
9
void
10
testFile(const char* path) {
11
    POLE::Storage storage(path);
12
    if (!storage.open()) return;
13
    string prefix;
14
    if (storage.isDirectory("PP97_DUALSTORAGE")) {
15
        prefix = "PP97_DUALSTORAGE/";
16
    } else {
17
        prefix = "/";
18
    }
19
    list<string> entries = storage.entries(prefix);
20
    for (list<string>::const_iterator i=entries.begin(); i!=entries.end(); ++i) {
21
        // if encrypted, do not report failure.
22
        if (*i == "EncryptedSummary") return;
23
    }
24
    POLE::Stream stream(&storage, prefix + "PowerPoint Document");
25
26
    QByteArray array;
27
    array.resize(stream.size());
28
    unsigned long read = stream.read((unsigned char*)array.data(), stream.size());
29
    if (read != stream.size()) {
30
        qDebug() << "Error reading stream ";
31
        return;
32
    }
33
    QBuffer buffer(&array);
34
    buffer.open(QIODevice::ReadOnly);
35
    LEInputStream listream(&buffer);
36
    MSO::PowerPointStructs pps;
37
    try {
38
        parsePowerPointStructs(listream, pps);
39
    } catch (...) {
40
        qDebug() << "Error while parsing.";
41
    }
42
    qDebug() << "Parsed " << buffer.pos() << " of " << array.size() << ": "
43
        << ((buffer.pos() == array.size())?"OK":"FAIL");
44
    if (buffer.pos() != array.size()) {
45
        qDebug() << path;
46
    }
47
}
48
int
49
main(int argc, char** argv) {
50
    for (int i=1; i<argc; ++i) {
51
        testFile(argv[i]);
52
    }
53
    return 0;
54
}