Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef NS_STRUCT
00035 # define NS_STRUCT
00036
00037 #include <iostream>
00038 #include <vector>
00039
00040 #include "libmwaw_internal.hxx"
00041
00042 #include "MWAWEntry.hxx"
00043
00044 class NSParser;
00045
00047 namespace NSStruct
00048 {
00050 enum ZoneType { Z_Main=0, Z_Footnote, Z_HeaderFooter };
00051
00053 enum VariableType { V_None=0, V_Numbering, V_Variable, V_Version };
00054
00056 struct Position {
00058 Position() : m_paragraph(0), m_word(0), m_char(0) {
00059 }
00061 friend std::ostream &operator<< (std::ostream &o, Position const &pos);
00062
00064 bool operator==(Position const &p2) const {
00065 return cmp(p2)==0;
00066 }
00068 bool operator!=(Position const &p2) const {
00069 return cmp(p2)!=0;
00070 }
00072 int cmp(Position const &p2) const {
00073 if (m_paragraph < p2.m_paragraph) return -1;
00074 if (m_paragraph > p2.m_paragraph) return 1;
00075 if (m_word < p2.m_word) return -1;
00076 if (m_word > p2.m_word) return 1;
00077 if (m_char < p2.m_char) return -1;
00078 if (m_char > p2.m_char) return 1;
00079 return 0;
00080 }
00082 int m_paragraph;
00084 int m_word;
00086 int m_char;
00087
00089 struct Compare {
00091 bool operator()(Position const &p1, Position const &p2) const {
00092 return p1.cmp(p2) < 0;
00093 }
00094 };
00095 };
00096
00098
00099
00101 struct FootnoteInfo {
00103 FootnoteInfo() : m_flags(0), m_distToDocument(5), m_distSeparator(36),
00104 m_separatorLength(108), m_unknown(0) {
00105 }
00107 friend std::ostream &operator<< (std::ostream &o, FootnoteInfo const &fnote);
00108
00110 bool endNotes() const {
00111 return (m_flags&0x8);
00112 }
00114 bool resetNumberOnNewPage() const {
00115 return (m_flags&0x8)==0 && (m_flags&0x10);
00116 }
00118 int m_flags;
00120 int m_distToDocument;
00122 int m_distSeparator;
00124 int m_separatorLength;
00126 int m_unknown;
00127 };
00128
00130 struct RecursifData {
00131 struct Node;
00132 struct Info;
00134 RecursifData(NSStruct::ZoneType zone, NSStruct::VariableType vType=NSStruct::V_None, int level=0) :
00135 m_info(new Info(zone, vType)), m_level(level), m_childList() {
00136 }
00138 RecursifData(RecursifData const &orig) :
00139 m_info(orig.m_info), m_level(-1), m_childList() {
00140 }
00142 RecursifData &operator=(RecursifData const &orig) {
00143 if (this != &orig) {
00144 m_info = orig.m_info;
00145 m_level = orig.m_level;
00146 m_childList = orig.m_childList;
00147 }
00148 return *this;
00149 }
00151 bool read(NSParser &parser, MWAWEntry const &entry);
00152
00154 shared_ptr<Info> m_info;
00156 int m_level;
00158 std::vector<Node> m_childList;
00159
00161 struct Info {
00163 Info(NSStruct::ZoneType zType, NSStruct::VariableType vType=NSStruct::V_None) :
00164 m_zoneType(zType), m_variableType(vType) {
00165 }
00167 NSStruct::ZoneType m_zoneType;
00169 NSStruct::VariableType m_variableType;
00170 };
00172 struct Node {
00174 Node() : m_type(0), m_entry(), m_data() {
00175 }
00177 bool isLeaf() const {
00178 return !m_data;
00179 }
00180
00182 int m_type;
00184 MWAWEntry m_entry;
00186 shared_ptr<RecursifData> m_data;
00187 };
00188 };
00189 }
00190
00191 #endif
00192