Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pdbim.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef PDBIM_H
00008 #define PDBIM_H
00009 
00010 #include "pluginapi.h"
00011 
00012 class gtWriter;
00013 class gtParagraphStyle;
00014 class QString;
00015 class QStringList;
00016 
00017 extern "C" PLUGIN_API void GetText(QString filename, QString encoding, bool textOnly, gtWriter *writer);
00018 
00019 extern "C" PLUGIN_API QString FileFormatName();
00020 
00021 extern "C" PLUGIN_API QStringList FileExtensions();
00022 
00023 
00026 #define U8_MAX 255u
00027 #if    UCHAR_MAX == U8_MAX
00028 typedef unsigned char       Byte;
00029 #else
00030 #error machine does not seem to support an 8-bit integral type
00031 #endif
00032 
00034 #define       U16_MAX 65535u
00035 #if    USHRT_MAX == U16_MAX
00036 typedef unsigned short      Word;
00037 #else
00038 #error machine does not seem to support a 16-bit integral type
00039 #endif
00040 
00042 #define       U32_MAX 4294967295ul
00043 #if    USHRT_MAX == U32_MAX
00044 typedef unsigned short      DWord;
00045 #elif  UINT_MAX  == U32_MAX
00046 typedef unsigned int DWord;
00047 #elif  ULONG_MAX == U32_MAX
00048 typedef unsigned long       DWord;
00049 #else
00050 #error machine does not seem to support a 32-bit integral type
00051 #endif
00052 
00054 typedef unsigned int UT_uint32;
00055 typedef unsigned short UT_uint16;
00056 
00058 #define RECORD_SIZE_MAX     4096
00059 #define BUFFER_SIZE 4096
00060 #define COUNT_BITS 3
00061 #define DISP_BITS 11
00062 #define       DOC_CREATOR "REAd"
00063 #define       DOC_TYPE "TEXt"
00064 
00065 #define       dmDBNameLength 32
00066 
00078 typedef struct
00079 {
00080        char   name[ dmDBNameLength ];
00081        Word   attributes;
00082        Word   version;
00083        DWord  create_time;
00084        DWord  modify_time;
00085        DWord  backup_time;
00086        DWord  modificationNumber;
00087        DWord  appInfoID;
00088        DWord  sortInfoID;
00089        char   type[4];
00090        char   creator[4];
00091        DWord  id_seed;
00092        DWord  nextRecordList;
00093        Word   numRecords;
00094 } pdb_header;
00095 
00099 #define PDB_HEADER_SIZE 78
00100 #define       PDB_RECORD_HEADER_SIZE 8
00101 
00104 typedef struct {
00105        Word    version; /* 1 = plain text, 2 = compressed */
00106        Word    reserved1;
00107        DWord   doc_size; /* in bytes, when uncompressed */
00108        Word    numRecords; /* text rec's only; = pdb_header.numRecords-1 */
00109        Word    rec_size; /* usually RECORD_SIZE_MAX */
00110        DWord   reserved2;
00111 } doc_record0;
00112 
00114 typedef struct {
00115        Byte buf[BUFFER_SIZE];
00116        UT_uint32   len;
00117        UT_uint32   position;
00118 } buffer;
00119 
00120 #define GET_Word(f,n)   { fread( &n, 2, 1, f ); n = swap_Word ( n ); }
00121 #define GET_DWord(f,n)  { fread( &n, 4, 1, f ); n = swap_DWord( n ); }
00122 
00135 class PdbIm
00136 {
00137 public:
00142        PdbIm(const QString& fname, const QString& enc, gtWriter *w);
00143        ~PdbIm(){};
00146        void write();
00147 private:
00149        buffer *m_buf;
00151        QString data;
00153        QString encoding;
00155        gtWriter *writer;
00157        bool m_littlendian;
00159        bool bCompressed;
00160        
00163        void loadFile(QString fname);
00166        void selectSwap();
00170        Word swap_Word(Word r);
00174        DWord swap_DWord(DWord r);
00177        void uncompress(buffer *m_buf);
00178 };
00179 
00180 #endif