Scribus
Open source desktop publishing at your fingertips
pdbim.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef PDBIM_H
8 #define PDBIM_H
9 
10 #include "pluginapi.h"
11 
12 class gtWriter;
13 class gtParagraphStyle;
14 class QString;
15 class QStringList;
16 
17 extern "C" PLUGIN_API void GetText(QString filename, QString encoding, bool textOnly, gtWriter *writer);
18 
19 extern "C" PLUGIN_API QString FileFormatName();
20 
21 extern "C" PLUGIN_API QStringList FileExtensions();
22 
23 
24 
25 
27 typedef unsigned int UT_uint32;
28 typedef unsigned short UT_uint16;
29 
32 typedef unsigned char Byte;
33 typedef UT_uint16 Word;
34 typedef UT_uint32 DWord;
35 
37 #define RECORD_SIZE_MAX 4096
38 #define BUFFER_SIZE 4096
39 #define COUNT_BITS 3
40 #define DISP_BITS 11
41 #define DOC_CREATOR "REAd"
42 #define DOC_TYPE "TEXt"
43 
44 #define dmDBNameLength 32
45 
57 typedef struct
58 {
59  char name[ dmDBNameLength ];
60  Word attributes;
61  Word version;
62  DWord create_time;
63  DWord modify_time;
64  DWord backup_time;
65  DWord modificationNumber;
66  DWord appInfoID;
67  DWord sortInfoID;
68  char type[4];
69  char creator[4];
70  DWord id_seed;
71  DWord nextRecordList;
72  Word numRecords;
73 } pdb_header;
74 
78 #define PDB_HEADER_SIZE 78
79 #define PDB_RECORD_HEADER_SIZE 8
80 
83 typedef struct {
84  Word version; /* 1 = plain text, 2 = compressed */
85  Word reserved1;
86  DWord doc_size; /* in bytes, when uncompressed */
87  Word numRecords; /* text rec's only; = pdb_header.numRecords-1 */
88  Word rec_size; /* usually RECORD_SIZE_MAX */
89  DWord reserved2;
90 } doc_record0;
91 
93 typedef struct {
94  Byte buf[BUFFER_SIZE];
95  UT_uint32 len;
96  UT_uint32 position;
97 } buffer;
98 
99 #define GET_Word(f,n) { fread( &n, 2, 1, f ); n = swap_Word ( n ); }
100 #define GET_DWord(f,n) { fread( &n, 4, 1, f ); n = swap_DWord( n ); }
101 
114 class PdbIm
115 {
116 public:
121  PdbIm(const QString& fname, const QString& enc, gtWriter *w);
122  ~PdbIm(){};
125  void write();
126 private:
128  buffer *m_buf;
130  QString data;
132  QString encoding;
134  gtWriter *writer;
136  bool m_littlendian;
138  bool bCompressed;
139 
142  void loadFile(QString fname);
145  void selectSwap();
149  Word swap_Word(Word r);
153  DWord swap_DWord(DWord r);
156  void uncompress(buffer *m_buf);
157 };
158 
159 #endif
void write()
Write data into Scribus text frame. User should specify encoding of the imported text - it's recoded ...
Definition: pdbim.cpp:70
PDB document header http://www.pyrite.org/doc_format.html version 2 bytes 0x0002 if data is compresse...
Definition: pdbim.h:57
Definition: gtwriter.h:38
PDB Document record. 16 bytes total.
Definition: pdbim.h:83
PdbIm(const QString &fname, const QString &enc, gtWriter *w)
Parse and decode the PDB file.
Definition: pdbim.cpp:58
Definition: gtparagraphstyle.h:51
Binary buffer.
Definition: pdbim.h:93
An import filter for Palm Documents (PDB files). PDB documents are simple non-formatted texts in bina...
Definition: pdbim.h:114