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