NSStruct.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 #ifndef NS_STRUCT
35 # define NS_STRUCT
36 
37 #include <iostream>
38 #include <vector>
39 
40 #include "libmwaw_internal.hxx"
41 
42 #include "MWAWEntry.hxx"
43 
44 class NSParser;
45 
47 namespace NSStruct
48 {
51 
54 
56 struct Position {
58  Position() : m_paragraph(0), m_word(0), m_char(0) {
59  }
61  friend std::ostream &operator<< (std::ostream &o, Position const &pos);
62 
64  bool operator==(Position const &p2) const {
65  return cmp(p2)==0;
66  }
68  bool operator!=(Position const &p2) const {
69  return cmp(p2)!=0;
70  }
72  int cmp(Position const &p2) const {
73  if (m_paragraph < p2.m_paragraph) return -1;
74  if (m_paragraph > p2.m_paragraph) return 1;
75  if (m_word < p2.m_word) return -1;
76  if (m_word > p2.m_word) return 1;
77  if (m_char < p2.m_char) return -1;
78  if (m_char > p2.m_char) return 1;
79  return 0;
80  }
84  int m_word;
86  int m_char;
87 
89  struct Compare {
91  bool operator()(Position const &p1, Position const &p2) const {
92  return p1.cmp(p2) < 0;
93  }
94  };
95 };
96 
98 // Internal: low level
99 
101 struct FootnoteInfo {
104  m_separatorLength(108), m_unknown(0) {
105  }
107  friend std::ostream &operator<< (std::ostream &o, FootnoteInfo const &fnote);
108 
110  bool endNotes() const {
111  return (m_flags&0x8);
112  }
114  bool resetNumberOnNewPage() const {
115  return (m_flags&0x8)==0 && (m_flags&0x10);
116  }
118  int m_flags;
127 };
128 
130 struct RecursifData {
131  struct Node;
132  struct Info;
135  m_info(new Info(zone, vType)), m_level(level), m_childList() {
136  }
138  RecursifData(RecursifData const &orig) :
139  m_info(orig.m_info), m_level(-1), m_childList() {
140  }
143  if (this != &orig) {
144  m_info = orig.m_info;
145  m_level = orig.m_level;
146  m_childList = orig.m_childList;
147  }
148  return *this;
149  }
151  bool read(NSParser &parser, MWAWEntry const &entry);
152 
154  shared_ptr<Info> m_info;
156  int m_level;
158  std::vector<Node> m_childList;
159 
161  struct Info {
164  m_zoneType(zType), m_variableType(vType) {
165  }
170  };
172  struct Node {
174  Node() : m_type(0), m_entry(), m_data() {
175  }
177  bool isLeaf() const {
178  return !m_data;
179  }
180 
182  int m_type;
186  shared_ptr<RecursifData> m_data;
187  };
188 };
189 }
190 
191 #endif
192 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Definition: NSStruct.hxx:53
std::vector< Node > m_childList
the list of data entry
Definition: NSStruct.hxx:158
the zone information
Definition: NSStruct.hxx:161
shared_ptr< RecursifData > m_data
the recursif data
Definition: NSStruct.hxx:186
int m_type
the variable type
Definition: NSStruct.hxx:182
Definition: NSStruct.hxx:53
RecursifData(NSStruct::ZoneType zone, NSStruct::VariableType vType=NSStruct::V_None, int level=0)
constructor
Definition: NSStruct.hxx:134
Definition: NSStruct.hxx:50
bool operator!=(Position const &p2) const
operator!=
Definition: NSStruct.hxx:68
int m_flags
the footnote flags
Definition: NSStruct.hxx:118
int m_distSeparator
the distance between two footnotes ( or between a footnote and the line sep)
Definition: NSStruct.hxx:122
int m_paragraph
the paragraph
Definition: NSStruct.hxx:82
bool endNotes() const
returns true if we have endnote
Definition: NSStruct.hxx:110
NSStruct::VariableType m_variableType
the variable type
Definition: NSStruct.hxx:169
VariableType
the different variable type
Definition: NSStruct.hxx:53
bool operator()(Position const &p1, Position const &p2) const
comparaison function
Definition: NSStruct.hxx:91
ZoneType
the different zone
Definition: NSStruct.hxx:50
Definition: NSStruct.hxx:53
int m_level
the node level
Definition: NSStruct.hxx:156
RecursifData(RecursifData const &orig)
copy constructor
Definition: NSStruct.hxx:138
bool isLeaf() const
returns true if the node is a final node
Definition: NSStruct.hxx:177
Definition: NSStruct.hxx:53
int m_unknown
a unknown value
Definition: NSStruct.hxx:126
bool resetNumberOnNewPage() const
returns true if we have to reset index at the beginning of a page
Definition: NSStruct.hxx:114
RecursifData & operator=(RecursifData const &orig)
copy operator
Definition: NSStruct.hxx:142
Internal: low level a structure helping to store the footnote information.
Definition: NSStruct.hxx:101
the data data
Definition: NSStruct.hxx:172
int m_word
the word
Definition: NSStruct.hxx:84
MWAWEntry m_entry
the entry
Definition: NSStruct.hxx:184
the main class to read a Nisus Writer file
Definition: NSParser.hxx:59
FootnoteInfo()
constructor
Definition: NSStruct.hxx:103
bool read(NSParser &parser, MWAWEntry const &entry)
read the data
Definition: NSStruct.cxx:77
friend std::ostream & operator<<(std::ostream &o, FootnoteInfo const &fnote)
operator&lt;&lt;: prints data
Definition: NSStruct.cxx:54
a comparaison structure used to sort the position
Definition: NSStruct.hxx:89
Info(NSStruct::ZoneType zType, NSStruct::VariableType vType=NSStruct::V_None)
the constructor
Definition: NSStruct.hxx:163
int m_separatorLength
the separator length
Definition: NSStruct.hxx:124
friend std::ostream & operator<<(std::ostream &o, Position const &pos)
operator&lt;&lt;: prints data in form &quot;XxYxZ&quot;
Definition: NSStruct.cxx:43
Position()
the constructor
Definition: NSStruct.hxx:58
NSStruct::ZoneType m_zoneType
the zone id
Definition: NSStruct.hxx:167
Node()
constructor
Definition: NSStruct.hxx:174
int cmp(Position const &p2) const
a small compare operator
Definition: NSStruct.hxx:72
bool operator==(Position const &p2) const
operator==
Definition: NSStruct.hxx:64
Definition: NSStruct.hxx:50
a position
Definition: NSStruct.hxx:56
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
int m_char
the character position
Definition: NSStruct.hxx:86
Internal: low level a structure helping to read recursifList.
Definition: NSStruct.hxx:130
Definition: NSStruct.hxx:50
shared_ptr< Info > m_info
zone information
Definition: NSStruct.hxx:154
int m_distToDocument
the distance between the footnote and the document
Definition: NSStruct.hxx:120

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5