ukui-search/libsearch/parser/binary-parser.h

108 lines
2.6 KiB
C
Raw Normal View History

#ifndef SEARCHHELPER_H
#define SEARCHHELPER_H
#include <QtCore>
#include <QtConcurrent/QtConcurrent>
#define ULONG unsigned long
#define UCHAR unsigned char
#define USHORT unsigned short
2021-04-26 15:06:47 +08:00
typedef enum {
Word = 0,
Excel,
Ppt
} TYPE;
/* Property Set Storage */
2021-04-26 15:06:47 +08:00
typedef struct pps_tag {
ULONG ulSB;
ULONG ulSize;
} ppsTag;
2021-04-26 15:06:47 +08:00
typedef struct pps_info_tag {
ppsTag tWordDocument; /* Text stream */
ppsTag tWorkBook;
ppsTag tPPTDocument;
ppsTag tData; /* Data stream */
ppsTag tTable; /* Table stream */
ppsTag tSummaryInfo; /* Summary Information */
ppsTag tDocSummaryInfo;/* Document Summary Information */
ppsTag t0Table; /* Table 0 stream */
ppsTag t1Table; /* Table 1 stream */
ppsTag tCurrentUser;
TYPE type;
} ppsInfoType;
/* Private type for Property Set Storage entries */
2021-04-26 15:06:47 +08:00
typedef struct pps_entry_tag {
ULONG ulNext;
ULONG ulPrevious;
ULONG ulDir;
ULONG ulSB;
ULONG ulSize;
int iLevel;
char szName[32];
UCHAR ucType;
} ppsEntryType;
/* Excel Record Struct*/
2021-04-26 15:06:47 +08:00
typedef struct excelRecord {
excelRecord() {
usLen = 0;
usRichLen = 0;
ulWLen = 0;
bUni = false;
}
ushort usLen;
ushort usRichLen;
ulong ulWLen;
bool bUni;
} excelRecord;
2021-04-26 15:06:47 +08:00
typedef struct readDataParam {
readDataParam() {
ulStBlk = 0;
pFile = NULL;
ulBBd = NULL;
tBBdLen = 0;
usBlkSize = 0;
}
ulong ulStBlk;
FILE *pFile;
ulong *ulBBd;
size_t tBBdLen;
ushort usBlkSize;
} rdPara;
class KBinaryParser : public QObject {
Q_OBJECT
public:
2021-04-26 15:06:47 +08:00
KBinaryParser(QObject *parent = 0);
~KBinaryParser();
public:
2021-04-26 15:06:47 +08:00
bool RunParser(QString strFile, QString &content);
private:
2021-04-26 15:06:47 +08:00
bool bGetPPS(FILE *pFile,
const ULONG *aulRootList, size_t tRootListLen, ppsInfoType *pPPS);
2021-04-26 15:06:47 +08:00
int readData(rdPara &readParam, uchar *aucBuffer, ulong ulOffset, size_t tToRead);
2021-04-26 15:06:47 +08:00
int InitDocOle(FILE *pFile, long lFilesize, QString &content);
bool read8DocText(FILE *pFile, const ppsInfoType *pPPS,
2021-04-26 15:06:47 +08:00
const ULONG *aulBBD, size_t tBBDLen,
const ULONG *aulSBD, size_t tSBDLen,
const UCHAR *aucHeader, QString &content);
2021-04-26 15:06:47 +08:00
int readSSTRecord(readDataParam &rdParam, ppsInfoType, ulong &ulOff, ushort usPartLen, QString &content);
int read8BiffRecord(uchar uFlag, ulong ulOff, ulong &ulNext, readDataParam &rdParam, excelRecord &eR);
ULONG readPPtRecord(FILE* pFile, ppsInfoType* PPS_info, ULONG* aulBBD,
2021-04-26 15:06:47 +08:00
size_t tBBDLen, ULONG ulPos, QString &content);
2021-04-26 15:06:47 +08:00
QString m_strFileName;
};
#endif // SEARCHHELPER_H