1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* Copyright (C) 2004-2012 Geometer Plus <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __PLUCKERBOOKREADER_H__
#define __PLUCKERBOOKREADER_H__
#include <set>
#include <map>
#include <ZLEncodingConverter.h>
#include "../../bookmodel/BookReader.h"
#include "../EncodedTextReader.h"
class PluckerBookReader : public BookReader, public EncodedTextReader {
public:
PluckerBookReader(BookModel &model);
~PluckerBookReader();
bool readDocument();
private:
enum FontType {
FT_REGULAR = 0,
FT_H1 = 1,
FT_H2 = 2,
FT_H3 = 3,
FT_H4 = 4,
FT_H5 = 5,
FT_H6 = 6,
FT_BOLD = 7,
FT_TT = 8,
FT_SMALL = 9,
FT_SUB = 10,
FT_SUP = 11
};
void readRecord(std::size_t recordSize);
void processTextRecord(std::size_t size, const std::vector<int> &pars);
void processTextParagraph(char *start, char *end);
void processTextFunction(char *ptr);
void setFont(FontType font, bool start);
void changeFont(FontType font);
void safeAddControl(FBTextKind kind, bool start);
void safeAddHyperlinkControl(const std::string &id);
void safeBeginParagraph();
void safeEndParagraph();
void processHeader(FontType font, bool start);
private:
const ZLFile myFile;
shared_ptr<ZLInputStream> myStream;
FontType myFont;
char *myCharBuffer;
std::string myConvertedTextBuffer;
bool myParagraphStarted;
bool myBufferIsEmpty;
ZLTextStyleEntry *myForcedEntry;
std::vector<std::pair<FBTextKind,bool> > myDelayedControls;
std::vector<std::string> myDelayedHyperlinks;
unsigned short myCompressionVersion;
unsigned char myBytesToSkip;
std::set<std::pair<int, int> > myReferencedParagraphs;
std::map<int, std::vector<int> > myParagraphMap;
std::vector<int> *myParagraphVector;
bool myParagraphStored;
};
#endif /* __PLUCKERBOOKREADER_H__ */
|