NisusWrtStruct.hxx Source File documentation

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