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
44class NisusWrtParser;
45
47namespace NisusWrtStruct
48{
50enum ZoneType : unsigned { Z_Main=0, Z_Footnote, Z_HeaderFooter };
51
54
56struct 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
112 : m_flags(0)
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 }
129 {
130 return (m_flags&0x8)==0 && (m_flags&0x10);
131 }
142};
143
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;
169 }
170 return *this;
171 }
173 bool read(NisusWrtParser &parser, MWAWEntry const &entry);
174
176 std::shared_ptr<Info> m_info;
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
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:
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
the main class to read a Nisus Writer file
Definition: NisusWrtParser.hxx:60
a namespace used to regroup the different structure used to parse a Nisus File
Definition: NisusWrtStruct.cxx:42
ZoneType
the different zone
Definition: NisusWrtStruct.hxx:50
@ Z_Main
Definition: NisusWrtStruct.hxx:50
@ Z_Footnote
Definition: NisusWrtStruct.hxx:50
@ Z_HeaderFooter
Definition: NisusWrtStruct.hxx:50
VariableType
the different variable type
Definition: NisusWrtStruct.hxx:53
@ V_Version
Definition: NisusWrtStruct.hxx:53
@ V_Variable
Definition: NisusWrtStruct.hxx:53
@ V_None
Definition: NisusWrtStruct.hxx:53
@ V_Numbering
Definition: NisusWrtStruct.hxx:53
Internal: low level a structure helping to store the footnote information.
Definition: NisusWrtStruct.hxx:109
FootnoteInfo()
constructor
Definition: NisusWrtStruct.hxx:111
int m_unknown
a unknown value
Definition: NisusWrtStruct.hxx:141
int m_distSeparator
the distance between two footnotes ( or between a footnote and the line sep)
Definition: NisusWrtStruct.hxx:137
bool endNotes() const
returns true if we have endnote
Definition: NisusWrtStruct.hxx:123
int m_flags
the footnote flags
Definition: NisusWrtStruct.hxx:133
friend std::ostream & operator<<(std::ostream &o, FootnoteInfo const &fnote)
operator<<: prints data
Definition: NisusWrtStruct.cxx:54
bool resetNumberOnNewPage() const
returns true if we have to reset index at the beginning of a page
Definition: NisusWrtStruct.hxx:128
int m_distToDocument
the distance between the footnote and the document
Definition: NisusWrtStruct.hxx:135
int m_separatorLength
the separator length
Definition: NisusWrtStruct.hxx:139
a comparaison structure used to sort the position
Definition: NisusWrtStruct.hxx:96
bool operator()(Position const &p1, Position const &p2) const
comparaison function
Definition: NisusWrtStruct.hxx:98
a position
Definition: NisusWrtStruct.hxx:56
Position()
the constructor
Definition: NisusWrtStruct.hxx:58
int m_paragraph
the paragraph
Definition: NisusWrtStruct.hxx:89
bool operator!=(Position const &p2) const
operator!=
Definition: NisusWrtStruct.hxx:73
int m_char
the character position
Definition: NisusWrtStruct.hxx:93
int cmp(Position const &p2) const
a small compare operator
Definition: NisusWrtStruct.hxx:78
friend std::ostream & operator<<(std::ostream &o, Position const &pos)
operator<<: prints data in form "XxYxZ"
Definition: NisusWrtStruct.cxx:43
bool operator==(Position const &p2) const
operator==
Definition: NisusWrtStruct.hxx:68
int m_word
the word
Definition: NisusWrtStruct.hxx:91
the zone information
Definition: NisusWrtStruct.hxx:183
NisusWrtStruct::ZoneType m_zoneType
the zone id
Definition: NisusWrtStruct.hxx:191
NisusWrtStruct::VariableType m_variableType
the variable type
Definition: NisusWrtStruct.hxx:193
Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None)
the constructor
Definition: NisusWrtStruct.hxx:185
the data data
Definition: NisusWrtStruct.hxx:196
bool isLeaf() const
returns true if the node is a final node
Definition: NisusWrtStruct.hxx:205
Node()
constructor
Definition: NisusWrtStruct.hxx:198
int m_type
the variable type
Definition: NisusWrtStruct.hxx:211
std::shared_ptr< RecursifData > m_data
the recursif data
Definition: NisusWrtStruct.hxx:215
MWAWEntry m_entry
the entry
Definition: NisusWrtStruct.hxx:213
Internal: low level a structure helping to read recursifList.
Definition: NisusWrtStruct.hxx:145
int m_level
the node level
Definition: NisusWrtStruct.hxx:178
std::shared_ptr< Info > m_info
zone information
Definition: NisusWrtStruct.hxx:176
bool read(NisusWrtParser &parser, MWAWEntry const &entry)
read the data
Definition: NisusWrtStruct.cxx:77
RecursifData(RecursifData const &orig)
copy constructor
Definition: NisusWrtStruct.hxx:156
RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0)
constructor
Definition: NisusWrtStruct.hxx:149
std::vector< Node > m_childList
the list of data entry
Definition: NisusWrtStruct.hxx:180
RecursifData & operator=(RecursifData const &orig)
copy operator
Definition: NisusWrtStruct.hxx:163

Generated on Thu Jan 19 2023 00:00:00 for libmwaw by doxygen 1.9.6