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 {
51 
54 
56 struct Position {
59  {
60  }
62  friend std::ostream &operator<< (std::ostream &o, Position const &pos);
63 
65  bool operator==(Position const &p2) const
66  {
67  return cmp(p2)==0;
68  }
70  bool operator!=(Position const &p2) const
71  {
72  return cmp(p2)!=0;
73  }
75  int cmp(Position const &p2) const
76  {
77  if (m_paragraph < p2.m_paragraph) return -1;
78  if (m_paragraph > p2.m_paragraph) return 1;
79  if (m_word < p2.m_word) return -1;
80  if (m_word > p2.m_word) return 1;
81  if (m_char < p2.m_char) return -1;
82  if (m_char > p2.m_char) return 1;
83  return 0;
84  }
88  int m_word;
90  int m_char;
91 
93  struct Compare {
95  bool operator()(Position const &p1, Position const &p2) const
96  {
97  return p1.cmp(p2) < 0;
98  }
99  };
100 };
101 
103 // Internal: low level
104 
106 struct FootnoteInfo {
110  {
111  }
113  friend std::ostream &operator<< (std::ostream &o, FootnoteInfo const &fnote);
114 
116  bool endNotes() const
117  {
118  return (m_flags&0x8);
119  }
121  bool resetNumberOnNewPage() const
122  {
123  return (m_flags&0x8)==0 && (m_flags&0x10);
124  }
126  int m_flags;
135 };
136 
138 struct RecursifData {
139  struct Node;
140  struct Info;
143  m_info(new Info(zone, vType)), m_level(level), m_childList()
144  {
145  }
147  RecursifData(RecursifData const &orig) :
148  m_info(orig.m_info), m_level(-1), m_childList()
149  {
150  }
153  {
154  if (this != &orig) {
155  m_info = orig.m_info;
156  m_level = orig.m_level;
157  m_childList = orig.m_childList;
158  }
159  return *this;
160  }
162  bool read(NisusWrtParser &parser, MWAWEntry const &entry);
163 
165  shared_ptr<Info> m_info;
167  int m_level;
169  std::vector<Node> m_childList;
170 
172  struct Info {
175  m_zoneType(zType), m_variableType(vType)
176  {
177  }
182  };
184  struct Node {
186  Node() : m_type(0), m_entry(), m_data()
187  {
188  }
190  bool isLeaf() const
191  {
192  return !m_data;
193  }
194 
196  int m_type;
200  shared_ptr<RecursifData> m_data;
201  };
202 };
203 }
204 
205 #endif
206 // 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:128
NisusWrtStruct::RecursifData::m_level
int m_level
the node level
Definition: NisusWrtStruct.hxx:167
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:75
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:127
NisusWrtStruct::Position::operator==
bool operator==(Position const &p2) const
operator==
Definition: NisusWrtStruct.hxx:65
NisusWrtStruct::V_Numbering
@ V_Numbering
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::RecursifData
Internal: low level a structure helping to read recursifList.
Definition: NisusWrtStruct.hxx:138
NisusWrtStruct::RecursifData::Node::m_type
int m_type
the variable type
Definition: NisusWrtStruct.hxx:196
NisusWrtStruct::Z_HeaderFooter
@ Z_HeaderFooter
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::V_Version
@ V_Version
Definition: NisusWrtStruct.hxx:53
NisusWrtParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: NisusWrtParser.cxx:342
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:121
NisusWrtStruct::ZoneType
ZoneType
the different zone
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::RecursifData::m_childList
std::vector< Node > m_childList
the list of data entry
Definition: NisusWrtStruct.hxx:169
NisusWrtStruct::FootnoteInfo::FootnoteInfo
FootnoteInfo()
constructor
Definition: NisusWrtStruct.hxx:108
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:115
NisusWrtStruct::Position::operator!=
bool operator!=(Position const &p2) const
operator!=
Definition: NisusWrtStruct.hxx:70
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:88
NisusWrtStruct::RecursifData::Node::m_data
shared_ptr< RecursifData > m_data
the recursif data
Definition: NisusWrtStruct.hxx:200
NisusWrtStruct::RecursifData::Info::Info
Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None)
the constructor
Definition: NisusWrtStruct.hxx:174
NisusWrtStruct::RecursifData::Info
the zone information
Definition: NisusWrtStruct.hxx:172
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:190
NisusWrtStruct::RecursifData::m_info
shared_ptr< Info > m_info
zone information
Definition: NisusWrtStruct.hxx:165
libmwaw_internal.hxx
NisusWrtStruct::Position::m_char
int m_char
the character position
Definition: NisusWrtStruct.hxx:90
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:66
NisusWrtStruct::RecursifData::Node
the data data
Definition: NisusWrtStruct.hxx:184
NisusWrtStruct::RecursifData::RecursifData
RecursifData(RecursifData const &orig)
copy constructor
Definition: NisusWrtStruct.hxx:147
NisusWrtStruct::RecursifData::operator=
RecursifData & operator=(RecursifData const &orig)
copy operator
Definition: NisusWrtStruct.hxx:152
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:142
NisusWrtStruct::Position::m_paragraph
int m_paragraph
the paragraph
Definition: NisusWrtStruct.hxx:86
NisusWrtStruct::RecursifData::Node::m_entry
MWAWEntry m_entry
the entry
Definition: NisusWrtStruct.hxx:198
NisusWrtStruct::FootnoteInfo::m_distSeparator
int m_distSeparator
the distance between two footnotes ( or between a footnote and the line sep)
Definition: NisusWrtStruct.hxx:130
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:56
NisusWrtStruct::RecursifData::Info::m_zoneType
NisusWrtStruct::ZoneType m_zoneType
the zone id
Definition: NisusWrtStruct.hxx:179
NisusWrtStruct::FootnoteInfo::m_separatorLength
int m_separatorLength
the separator length
Definition: NisusWrtStruct.hxx:132
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:82
NisusWrtStruct
a namespace used to regroup the different structure used to parse a Nisus File
Definition: NisusWrtStruct.cxx:42
MWAWDebug.hxx
NisusWrtStruct::FootnoteInfo
Internal: low level a structure helping to store the footnote information.
Definition: NisusWrtStruct.hxx:106
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:72
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:61
NisusWrtParser.hxx
NisusWrtStruct::VariableType
VariableType
the different variable type
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::V_None
@ V_None
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct.hxx
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:77
NisusWrtStruct::RecursifData::RecursifData
RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0)
constructor
Definition: NisusWrtStruct.hxx:142
NisusWrtStruct::Z_Footnote
@ Z_Footnote
Definition: NisusWrtStruct.hxx:50
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:95
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
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:181
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:347
NisusWrtStruct::RecursifData::Node::Node
Node()
constructor
Definition: NisusWrtStruct.hxx:186
NisusWrtStruct::Position::Compare
a comparaison structure used to sort the position
Definition: NisusWrtStruct.hxx:93
NisusWrtStruct::FootnoteInfo::endNotes
bool endNotes() const
returns true if we have endnote
Definition: NisusWrtStruct.hxx:116
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:126
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:134
NisusWrtStruct::Z_Main
@ Z_Main
Definition: NisusWrtStruct.hxx:50

Generated on Wed Jun 17 2020 06:30:12 for libmwaw by doxygen 1.8.18