NisusWrtStruct.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 { Z_Main=0, Z_Footnote, Z_HeaderFooter };
51
53 enum VariableType { V_None=0, V_Numbering, V_Variable, V_Version };
54
56 struct Position {
58 Position() : m_paragraph(0), m_word(0), m_char(0)
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 }
86 int m_paragraph;
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 {
108 FootnoteInfo() : m_flags(0), m_distToDocument(5), m_distSeparator(36),
109 m_separatorLength(108), m_unknown(0)
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;
128 int m_distToDocument;
130 int m_distSeparator;
132 int m_separatorLength;
134 int m_unknown;
135 };
136
138 struct RecursifData {
139 struct Node;
140 struct Info;
142 RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0) :
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 }
152 RecursifData &operator=(RecursifData const &orig)
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 {
174 Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None) :
175 m_zoneType(zType), m_variableType(vType)
176 {
177 }
179 NisusWrtStruct::ZoneType m_zoneType;
181 NisusWrtStruct::VariableType m_variableType;
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;
198 MWAWEntry m_entry;
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:
NisusWrtStruct::RecursifData::m_info
shared_ptr< Info > m_info
zone information
Definition: NisusWrtStruct.hxx:165
NisusWrtStruct::FootnoteInfo::FootnoteInfo
FootnoteInfo()
constructor
Definition: NisusWrtStruct.hxx:108
NisusWrtStruct::Position::m_char
int m_char
the character position
Definition: NisusWrtStruct.hxx:90
NisusWrtStruct::Position::operator<<
friend std::ostream & operator<<(std::ostream &o, Position const &pos)
operator<<: prints data in form "XxYxZ"
Definition: NisusWrtStruct.cxx:43
NisusWrtStruct
a namespace used to regroup the different structure used to parse a Nisus File
Definition: NisusWrtStruct.cxx:41
MWAWEntry.hxx
libmwaw_internal.hxx
NisusWrtStruct::Position::operator==
bool operator==(Position const &p2) const
operator==
Definition: NisusWrtStruct.hxx:65
NisusWrtStruct::RecursifData::operator=
RecursifData & operator=(RecursifData const &orig)
copy operator
Definition: NisusWrtStruct.hxx:152
NisusWrtStruct::Position::Position
Position()
the constructor
Definition: NisusWrtStruct.hxx:58
NisusWrtStruct::FootnoteInfo::m_distSeparator
int m_distSeparator
the distance between two footnotes ( or between a footnote and the line sep)
Definition: NisusWrtStruct.hxx:130
NisusWrtStruct::Position::cmp
int cmp(Position const &p2) const
a small compare operator
Definition: NisusWrtStruct.hxx:75
NisusWrtStruct::Position
a position
Definition: NisusWrtStruct.hxx:56
NisusWrtStruct::RecursifData::Node
the data data
Definition: NisusWrtStruct.hxx:184
NisusWrtStruct::RecursifData::Info::m_variableType
NisusWrtStruct::VariableType m_variableType
the variable type
Definition: NisusWrtStruct.hxx:181
NisusWrtStruct::Position::Compare
a comparaison structure used to sort the position
Definition: NisusWrtStruct.hxx:93
NisusWrtStruct::Z_Main
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::V_Version
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::FootnoteInfo::m_unknown
int m_unknown
a unknown value
Definition: NisusWrtStruct.hxx:134
NisusWrtStruct::FootnoteInfo::m_distToDocument
int m_distToDocument
the distance between the footnote and the document
Definition: NisusWrtStruct.hxx:128
NisusWrtStruct::FootnoteInfo
Internal: low level a structure helping to store the footnote information.
Definition: NisusWrtStruct.hxx:106
NisusWrtStruct::RecursifData::RecursifData
RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0)
constructor
Definition: NisusWrtStruct.hxx:142
NisusWrtStruct::V_None
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::Position::Compare::operator()
bool operator()(Position const &p1, Position const &p2) const
comparaison function
Definition: NisusWrtStruct.hxx:95
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::RecursifData::Node::Node
Node()
constructor
Definition: NisusWrtStruct.hxx:186
NisusWrtStruct::RecursifData::Info
the zone information
Definition: NisusWrtStruct.hxx:172
NisusWrtStruct::V_Variable
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::RecursifData::Node::isLeaf
bool isLeaf() const
returns true if the node is a final node
Definition: NisusWrtStruct.hxx:190
NisusWrtStruct::Position::m_word
int m_word
the word
Definition: NisusWrtStruct.hxx:88
NisusWrtStruct::FootnoteInfo::m_flags
int m_flags
the footnote flags
Definition: NisusWrtStruct.hxx:126
NisusWrtStruct::V_Numbering
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::FootnoteInfo::m_separatorLength
int m_separatorLength
the separator length
Definition: NisusWrtStruct.hxx:132
NisusWrtStruct::Position::m_paragraph
int m_paragraph
the paragraph
Definition: NisusWrtStruct.hxx:86
NisusWrtParser
the main class to read a Nisus Writer file
Definition: NisusWrtParser.hxx:59
NisusWrtStruct::RecursifData::Node::m_entry
MWAWEntry m_entry
the entry
Definition: NisusWrtStruct.hxx:198
NisusWrtStruct::Z_Footnote
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::Position::operator!=
bool operator!=(Position const &p2) const
operator!=
Definition: NisusWrtStruct.hxx:70
NisusWrtStruct::RecursifData::m_childList
std::vector< Node > m_childList
the list of data entry
Definition: NisusWrtStruct.hxx:169
NisusWrtStruct::FootnoteInfo::endNotes
bool endNotes() const
returns true if we have endnote
Definition: NisusWrtStruct.hxx:116
NisusWrtStruct::VariableType
VariableType
the different variable type
Definition: NisusWrtStruct.hxx:53
NisusWrtStruct::RecursifData::Info::Info
Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None)
the constructor
Definition: NisusWrtStruct.hxx:174
NisusWrtStruct::Z_HeaderFooter
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::RecursifData::Node::m_data
shared_ptr< RecursifData > m_data
the recursif data
Definition: NisusWrtStruct.hxx:200
NisusWrtStruct::RecursifData::Info::m_zoneType
NisusWrtStruct::ZoneType m_zoneType
the zone id
Definition: NisusWrtStruct.hxx:179
NisusWrtStruct::RecursifData
Internal: low level a structure helping to read recursifList.
Definition: NisusWrtStruct.hxx:138
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
NisusWrtStruct::RecursifData::Node::m_type
int m_type
the variable type
Definition: NisusWrtStruct.hxx:196
NisusWrtStruct::ZoneType
ZoneType
the different zone
Definition: NisusWrtStruct.hxx:50
NisusWrtStruct::RecursifData::RecursifData
RecursifData(RecursifData const &orig)
copy constructor
Definition: NisusWrtStruct.hxx:147
NisusWrtStruct::RecursifData::m_level
int m_level
the node level
Definition: NisusWrtStruct.hxx:167