Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef LRFCOLLECTOR_H_INCLUDED
00018 #define LRFCOLLECTOR_H_INCLUDED
00019
00020 #include <string>
00021 #include <stack>
00022
00023 #include "LRFTypes.h"
00024
00025 class WPXDocumentInterface;
00026
00027 namespace libebook
00028 {
00029
00030 class LRFCollector
00031 {
00032
00033 LRFCollector(const LRFCollector &other);
00034 LRFCollector &operator=(const LRFCollector &other);
00035
00036 struct ImageData
00037 {
00038 WPXInputStream *image;
00039 ImageType type;
00040 };
00041
00042 typedef std::map<unsigned, ImageData> ImageMap_t;
00043
00044 public:
00045 explicit LRFCollector(WPXDocumentInterface *document);
00046 ~LRFCollector();
00047
00048 void startDocument();
00049 void endDocument();
00050
00051 void openPage(unsigned pageAtrID, const LRFAttributes &attributes);
00052 void closePage();
00053
00054 void openBlock(unsigned atrID, const LRFAttributes &attributes);
00055 void closeBlock();
00056
00057 void openTextBlock(unsigned atrID, const LRFAttributes &attributes);
00058 void closeTextBlock();
00059
00060 void openParagraph(unsigned atrID, const LRFAttributes &attributes);
00061 void closeParagraph();
00062
00063 void collectText(const std::string &text, const LRFAttributes &attributes);
00064 void insertLineBreak();
00065
00066 void collectMetadata(const LRFMetadata &metadata);
00067
00068 void collectBookAttributes(const LRFAttributes &attributes);
00069 void collectTextAttributes(unsigned id, const LRFAttributes &attributes);
00070 void collectBlockAttributes(unsigned id, const LRFAttributes &attributes);
00071 void collectPageAttributes(unsigned id, const LRFAttributes &attributes);
00072 void collectParagraphAttributes(unsigned id, const LRFAttributes &attributes);
00073
00074 void collectImage(unsigned id);
00075 void collectImageData(unsigned id, ImageType type, WPXInputStream *image);
00076
00077 private:
00078 void collectAttributes(unsigned id, const LRFAttributes &attributes, LRFAttributeMap_t &attributeMap);
00079 void openBlock(unsigned atrID, const LRFAttributes &attributes, const LRFAttributeMap_t *attributeMap);
00080
00081 private:
00082 LRFAttributes m_bookAttributes;
00083 LRFAttributeMap_t m_textAttributeMap;
00084 LRFAttributeMap_t m_blockAttributeMap;
00085 LRFAttributeMap_t m_pageAttributeMap;
00086 LRFAttributeMap_t m_paragraphAttributeMap;
00087 WPXDocumentInterface *const m_document;
00088 std::stack<LRFAttributes> m_currentAttributes;
00089 ImageMap_t m_imageMap;
00090 };
00091
00092 }
00093
00094 #endif // LRFCOLLECTOR_H_INCLUDED
00095
00096