File indexing completed on 2024-04-28 04:40:02
0001 #include "leinputstream.h" 0002 #include "simpleParser.h" 0003 #include "pole.h" 0004 #include <QtCore/QBuffer> 0005 #include <QtCore/QDebug> 0006 0007 using namespace std; 0008 0009 void 0010 testFile(const char* path) { 0011 POLE::Storage storage(path); 0012 if (!storage.open()) return; 0013 string prefix; 0014 if (storage.isDirectory("PP97_DUALSTORAGE")) { 0015 prefix = "PP97_DUALSTORAGE/"; 0016 } else { 0017 prefix = "/"; 0018 } 0019 list<string> entries = storage.entries(prefix); 0020 for (list<string>::const_iterator i=entries.begin(); i!=entries.end(); ++i) { 0021 // if encrypted, do not report failure. 0022 if (*i == "EncryptedSummary") return; 0023 } 0024 POLE::Stream stream(&storage, prefix + "PowerPoint Document"); 0025 0026 QByteArray array; 0027 array.resize(stream.size()); 0028 unsigned long read = stream.read((unsigned char*)array.data(), stream.size()); 0029 if (read != stream.size()) { 0030 qDebug() << "Error reading stream "; 0031 return; 0032 } 0033 QBuffer buffer(&array); 0034 buffer.open(QIODevice::ReadOnly); 0035 LEInputStream listream(&buffer); 0036 MSO::PowerPointStructs pps; 0037 try { 0038 parsePowerPointStructs(listream, pps); 0039 } catch (...) { 0040 qDebug() << "Error while parsing."; 0041 } 0042 qDebug() << "Parsed " << buffer.pos() << " of " << array.size() << ": " 0043 << ((buffer.pos() == array.size())?"OK":"FAIL"); 0044 if (buffer.pos() != array.size()) { 0045 qDebug() << path; 0046 } 0047 } 0048 int 0049 main(int argc, char** argv) { 0050 for (int i=1; i<argc; ++i) { 0051 testFile(argv[i]); 0052 } 0053 return 0; 0054 }