NisusWrtStruct.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 NISUS_WRT_STRUCT
35 # define NISUS_WRT_STRUCT
36 
37 #include <iostream>
38 #include <vector>
39 
40 #include "libmwaw_internal.hxx"
41 
42 #include "MWAWEntry.hxx"
43 
44 class NisusWrtParser;
45 
47 namespace NisusWrtStruct
48 {
50 enum ZoneType : unsigned { Z_Main=0, Z_Footnote, Z_HeaderFooter };
51 
54 
56 struct Position {
59  : m_paragraph(0)
60  , m_word(0)
61  , m_char(0)
62  {
63  }
65  friend std::ostream &operator<< (std::ostream &o, Position const &pos);
66 
68  bool operator==(Position const &p2) const
69  {
70  return cmp(p2)==0;
71  }
73  bool operator!=(Position const &p2) const
74  {
75  return cmp(p2)!=0;
76  }
78  int cmp(Position const &p2) const
79  {
80  if (m_paragraph < p2.m_paragraph) return -1;
81  if (m_paragraph > p2.m_paragraph) return 1;
82  if (m_word < p2.m_word) return -1;
83  if (m_word > p2.m_word) return 1;
84  if (m_char < p2.m_char) return -1;
85  if (m_char > p2.m_char) return 1;
86  return 0;
87  }
91  int m_word;
93  int m_char;
94 
96  struct Compare {
98  bool operator()(Position const &p1, Position const &p2) const
99  {
100  return p1.cmp(p2) < 0;
101  }
102  };
103 };
104 
106 // Internal: low level
107 
109 struct FootnoteInfo {
112  : m_flags(0)
113  , m_distToDocument(5)
114  , m_distSeparator(36)
115  , m_separatorLength(108)
116  , m_unknown(0)
117  {
118  }
120  friend std::ostream &operator<< (std::ostream &o, FootnoteInfo const &fnote);
121 
123  bool endNotes() const
124  {
125  return (m_flags&0x8)!=0;
126  }
128  bool resetNumberOnNewPage() const
129  {
130  return (m_flags&0x8)==0 && (m_flags&0x10);
131  }
133  int m_flags;
142 };
143 
145 struct RecursifData {
146  struct Node;
147  struct Info;
150  : m_info(new Info(zone, vType))
151  , m_level(level)
152  , m_childList()
153  {
154  }
157  : m_info(orig.m_info)
158  , m_level(-1)
159  , m_childList()
160  {
161  }
164  {
165  if (this != &orig) {
166  m_info = orig.m_info;
167  m_level = orig.m_level;
168  m_childList = orig.m_childList;
169  }
170  return *this;
171  }
173  bool read(NisusWrtParser &parser, MWAWEntry const &entry);
174 
176  std::shared_ptr<Info> m_info;
178  int m_level;
180  std::vector<Node> m_childList;
181 
183  struct Info {
186  : m_zoneType(zType)
187  , m_variableType(vType)
188  {
189  }
194  };
196  struct Node {
199  : m_type(0)
200  , m_entry()
201  , m_data()
202  {
203  }
205  bool isLeaf() const
206  {
207  return !m_data;
208  }
209 
211  int m_type;
215  std::shared_ptr<RecursifData> m_data;
216  };
217 };
218 }
219 
220 #endif
221 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
NisusWrtStruct::FootnoteInfo::m_distToDocument
int m_distToDocument
the distance between the footnote and the document
Definition: NisusWrtStruct.hxx:135
NisusWrtStruct::RecursifData::m_level
int m_level
the node level
Definition: NisusWrtStruct.hxx:178
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
NisusWrtStruct::Position::Position
Position()
the constructor
Definition: NisusWrtStruct.hxx:58
NisusWrtStruct::Position::cmp
int cmp(Position const &p2) const
a small compare operator
Definition: NisusWrtStruct.hxx:78
NisusWrtStruct::RecursifData::read
bool read(NisusWrtParser &parser, MWAWEntry const &entry)
read the data
Definition: NisusWrtStruct.cxx:77
NisusWrtStruct::operator<<
std::ostream & operator<<(std::ostream &o, Position const &pos)
Definition: NisusWrtStruct.cxx:43
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
NisusWrtStruct::Position::operator==
bool operator==(Position const &p2) const
operator==
Definition: NisusWrtStruct.hxx:68
NisusWrtStruct::V_Numbering
@ V_Numbering
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::Z_Main
@ Z_Main
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::RecursifData
Internal: low level a structure helping to read recursifList.
Definition: NisusWrtStruct.hxx:145
NisusWrtStruct::RecursifData::Node::m_type
int m_type
the variable type
Definition: NisusWrtStruct.hxx:211
NisusWrtStruct::V_Version
@ V_Version
Definition: NisusWrtStruct.hxx:53
NisusWrtParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: NisusWrtParser.cxx:367
MWAWEntry.hxx
NisusWrtStruct::FootnoteInfo::resetNumberOnNewPage
bool resetNumberOnNewPage() const
returns true if we have to reset index at the beginning of a page
Definition: NisusWrtStruct.hxx:128
NisusWrtStruct::RecursifData::m_childList
std::vector< Node > m_childList
the list of data entry
Definition: NisusWrtStruct.hxx:180
NisusWrtStruct::FootnoteInfo::FootnoteInfo
FootnoteInfo()
constructor
Definition: NisusWrtStruct.hxx:111
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
NisusWrtStruct::Position::operator!=
bool operator!=(Position const &p2) const
operator!=
Definition: NisusWrtStruct.hxx:73
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
NisusWrtStruct::Position::m_word
int m_word
the word
Definition: NisusWrtStruct.hxx:91
NisusWrtStruct::RecursifData::Info::Info
Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None)
the constructor
Definition: NisusWrtStruct.hxx:185
NisusWrtStruct::Z_HeaderFooter
@ Z_HeaderFooter
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::RecursifData::Info
the zone information
Definition: NisusWrtStruct.hxx:183
NisusWrtStruct::Position
a position
Definition: NisusWrtStruct.hxx:56
NisusWrtStruct::RecursifData::Node::isLeaf
bool isLeaf() const
returns true if the node is a final node
Definition: NisusWrtStruct.hxx:205
libmwaw_internal.hxx
NisusWrtStruct::Position::m_char
int m_char
the character position
Definition: NisusWrtStruct.hxx:93
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:77
NisusWrtStruct::RecursifData::Node
the data data
Definition: NisusWrtStruct.hxx:196
NisusWrtStruct::RecursifData::RecursifData
RecursifData(RecursifData const &orig)
copy constructor
Definition: NisusWrtStruct.hxx:156
NisusWrtStruct::RecursifData::operator=
RecursifData & operator=(RecursifData const &orig)
copy operator
Definition: NisusWrtStruct.hxx:163
NisusWrtStruct::Position::operator<<
friend std::ostream & operator<<(std::ostream &o, Position const &pos)
operator<<: prints data in form "XxYxZ"
Definition: NisusWrtStruct.cxx:43
MWAWEntry::name
std::string const & name() const
name of the entry
Definition: MWAWEntry.hxx:153
NisusWrtStruct::Position::m_paragraph
int m_paragraph
the paragraph
Definition: NisusWrtStruct.hxx:89
NisusWrtStruct::RecursifData::Node::m_entry
MWAWEntry m_entry
the entry
Definition: NisusWrtStruct.hxx:213
NisusWrtStruct::FootnoteInfo::m_distSeparator
int m_distSeparator
the distance between two footnotes ( or between a footnote and the line sep)
Definition: NisusWrtStruct.hxx:137
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
NisusWrtStruct::RecursifData::Info::m_zoneType
NisusWrtStruct::ZoneType m_zoneType
the zone id
Definition: NisusWrtStruct.hxx:191
NisusWrtStruct::ZoneType
ZoneType
the different zone
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::FootnoteInfo::m_separatorLength
int m_separatorLength
the separator length
Definition: NisusWrtStruct.hxx:139
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
NisusWrtStruct
a namespace used to regroup the different structure used to parse a Nisus File
Definition: NisusWrtStruct.cxx:42
NisusWrtStruct::RecursifData::m_info
std::shared_ptr< Info > m_info
zone information
Definition: NisusWrtStruct.hxx:176
NisusWrtStruct::Z_Footnote
@ Z_Footnote
Definition: NisusWrtStruct.hxx:50
MWAWDebug.hxx
NisusWrtStruct::FootnoteInfo
Internal: low level a structure helping to store the footnote information.
Definition: NisusWrtStruct.hxx:109
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:72
NisusWrtParser.hxx
NisusWrtStruct::VariableType
VariableType
the different variable type
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::V_None
@ V_None
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct.hxx
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
NisusWrtStruct::RecursifData::RecursifData
RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0)
constructor
Definition: NisusWrtStruct.hxx:149
NisusWrtStruct::V_Variable
@ V_Variable
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::Position::Compare::operator()
bool operator()(Position const &p1, Position const &p2) const
comparaison function
Definition: NisusWrtStruct.hxx:98
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
NisusWrtParser
the main class to read a Nisus Writer file
Definition: NisusWrtParser.hxx:60
NisusWrtStruct::RecursifData::Node::m_data
std::shared_ptr< RecursifData > m_data
the recursif data
Definition: NisusWrtStruct.hxx:215
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
NisusWrtStruct::RecursifData::Info::m_variableType
NisusWrtStruct::VariableType m_variableType
the variable type
Definition: NisusWrtStruct.hxx:193
MWAWInputStream.hxx
NisusWrtParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: NisusWrtParser.cxx:372
NisusWrtStruct::RecursifData::Node::Node
Node()
constructor
Definition: NisusWrtStruct.hxx:198
NisusWrtStruct::Position::Compare
a comparaison structure used to sort the position
Definition: NisusWrtStruct.hxx:96
NisusWrtStruct::FootnoteInfo::endNotes
bool endNotes() const
returns true if we have endnote
Definition: NisusWrtStruct.hxx:123
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
NisusWrtStruct::FootnoteInfo::m_flags
int m_flags
the footnote flags
Definition: NisusWrtStruct.hxx:133
NisusWrtStruct::FootnoteInfo::operator<<
friend std::ostream & operator<<(std::ostream &o, FootnoteInfo const &fnote)
operator<<: prints data
Definition: NisusWrtStruct.cxx:54
NisusWrtStruct::FootnoteInfo::m_unknown
int m_unknown
a unknown value
Definition: NisusWrtStruct.hxx:141

Generated on Fri Sep 18 2020 18:14:52 for libmwaw by doxygen 1.8.20