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.
10
#include "pluginapi.h"
13
class gtParagraphStyle;
17
extern "C" PLUGIN_API void GetText(QString filename, QString encoding, bool textOnly, gtWriter *writer);
19
extern "C" PLUGIN_API QString FileFormatName();
21
extern "C" PLUGIN_API QStringList FileExtensions();
26
/*! \brief Abiword's internal data types */
27
typedef unsigned int UT_uint32;
28
typedef unsigned short UT_uint16;
30
/*! \brief Define integral type Byte, Word, and DWord to match those on the
31
Pilot being 8, 16, and 32 bits, respectively. Max 8-bit unsigned */
32
typedef unsigned char Byte;
33
typedef UT_uint16 Word;
34
typedef UT_uint32 DWord;
36
/*! \brief Pilots have a fixed 4K record size */
37
#define RECORD_SIZE_MAX 4096
38
#define BUFFER_SIZE 4096
41
#define DOC_CREATOR "REAd"
42
#define DOC_TYPE "TEXt"
43
/*! \brief 31 chars + 1 null terminator */
44
#define dmDBNameLength 32
46
/*! \brief PDB document header
47
http://www.pyrite.org/doc_format.html
48
version 2 bytes 0x0002 if data is compressed, 0x0001 if uncompressed
49
spare 2 bytes purpose unknown (set to 0 on creation)
50
length 4 bytes total length of text before compression
51
records 2 bytes number of text records
52
record_size 2 bytes maximum size of each record (usually 4096; see below)
53
position 4 bytes currently viewed position in the document
54
sizes 2*records bytes record size array
59
char name[ dmDBNameLength ];
65
DWord modificationNumber;
75
/*! \brief Some compilers pad structures out to DWord boundaries so using
76
sizeof() doesn't give the intended result.
78
#define PDB_HEADER_SIZE 78
79
#define PDB_RECORD_HEADER_SIZE 8
81
/*! \brief PDB Document record.
84
Word version; /* 1 = plain text, 2 = compressed */
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 */
92
/*! \brief Binary buffer */
94
Byte buf[BUFFER_SIZE];
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 ); }
102
/*! \brief An import filter for Palm Documents (PDB files).
103
PDB documents are simple non-formatted texts in binary forms used
104
mainly for e-books distribution.
105
It's taken from Abiword's PDB import/export plugin http://www.abisource.com
106
I've simplified the importer guts to fit special Scribus needs.
107
\warning This plugin uses a very special low-level IO and memory operations.
108
It uses big/little endian handling for bit related operations.
109
Welcome in the "macro and gtk hell" ;)
110
\note User should specify file encoding correctly.
111
\author Copyright (C) 2001 AbiSource, Inc.
112
\author Petr Vanek <petr@scribus.info>
117
/*! \brief Parse and decode the PDB file
118
\param fname a file name of the document
119
\param enc user selected text encoding. See encoding attr.
120
\param w a reference to the gtWriter instance */
121
PdbIm(const QString& fname, const QString& enc, gtWriter *w);
123
/*! \brief Write data into Scribus text frame.
124
User should specify encoding of the imported text - it's recoded here. */
127
//! \brief Binary buffer for extraction tasks
129
//! \brief Store the extracted text here
131
//! \brief Name of the codec/encoding to recode
133
//! \brief Imp plugin handler
135
//! \brief A "bit order" flag. True on little endian systems.
137
//! \brief A "document uses that strange compress algorithm" flag.
140
/*! \brief Parse the PDB file.
141
\param fname a filename to open */
142
void loadFile(QString fname);
143
/*! \brief Learn which endian to use.
144
It fills the m_littlendian flag */
146
/*! \brief Recompute the binary value for given endian
147
\param r a binary Word
148
\retval Word a correct endian Word */
149
Word swap_Word(Word r);
150
/*! \brief Recompute the binary value for given endian
151
\param r a binary DWord
152
\retval DWord a correct endian Word */
153
DWord swap_DWord(DWord r);
154
/*! \brief PDB strange decompress algorithm implementation.
155
\param m_buf a reference to the current buffer */
156
void uncompress(buffer *m_buf);