Main Page
Namespaces
Classes
Files
File List
File Members
NSStruct.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 NS_STRUCT
35
# define NS_STRUCT
36
37
#include <iostream>
38
#include <vector>
39
40
#include "
libmwaw_internal.hxx
"
41
42
#include "
MWAWEntry.hxx
"
43
44
class
NSParser
;
45
47
namespace
NSStruct
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
}
61
friend
std::ostream &
operator<<
(std::ostream &o,
Position
const
&pos);
62
64
bool
operator==
(
Position
const
&p2)
const
{
65
return
cmp
(p2)==0;
66
}
68
bool
operator!=
(
Position
const
&p2)
const
{
69
return
cmp
(p2)!=0;
70
}
72
int
cmp
(
Position
const
&p2)
const
{
73
if
(
m_paragraph
< p2.
m_paragraph
)
return
-1;
74
if
(
m_paragraph
> p2.
m_paragraph
)
return
1;
75
if
(
m_word
< p2.
m_word
)
return
-1;
76
if
(
m_word
> p2.
m_word
)
return
1;
77
if
(
m_char
< p2.
m_char
)
return
-1;
78
if
(
m_char
> p2.
m_char
)
return
1;
79
return
0;
80
}
82
int
m_paragraph
;
84
int
m_word
;
86
int
m_char
;
87
89
struct
Compare
{
91
bool
operator()
(
Position
const
&p1,
Position
const
&p2)
const
{
92
return
p1.
cmp
(p2) < 0;
93
}
94
};
95
};
96
98
// Internal: low level
99
101
struct
FootnoteInfo
{
103
FootnoteInfo
() :
m_flags
(0),
m_distToDocument
(5),
m_distSeparator
(36),
104
m_separatorLength
(108),
m_unknown
(0) {
105
}
107
friend
std::ostream &
operator<<
(std::ostream &o,
FootnoteInfo
const
&fnote);
108
110
bool
endNotes
()
const
{
111
return
(
m_flags
&0x8);
112
}
114
bool
resetNumberOnNewPage
()
const
{
115
return
(
m_flags
&0x8)==0 && (
m_flags
&0x10);
116
}
118
int
m_flags
;
120
int
m_distToDocument
;
122
int
m_distSeparator
;
124
int
m_separatorLength
;
126
int
m_unknown
;
127
};
128
130
struct
RecursifData
{
131
struct
Node
;
132
struct
Info
;
134
RecursifData
(
NSStruct::ZoneType
zone,
NSStruct::VariableType
vType=
NSStruct::V_None
,
int
level=0) :
135
m_info
(new
Info
(zone, vType)),
m_level
(level),
m_childList
() {
136
}
138
RecursifData
(
RecursifData
const
&orig) :
139
m_info
(orig.
m_info
),
m_level
(-1),
m_childList
() {
140
}
142
RecursifData
&
operator=
(
RecursifData
const
&orig) {
143
if
(
this
!= &orig)
m_info
= orig.
m_info
;
144
return
*
this
;
145
}
147
bool
read
(
NSParser
&parser,
MWAWEntry
const
&entry);
148
150
shared_ptr<Info>
m_info
;
152
int
m_level
;
154
std::vector<Node>
m_childList
;
155
157
struct
Info
{
159
Info
(
NSStruct::ZoneType
zType,
NSStruct::VariableType
vType=
NSStruct::V_None
) :
160
m_zoneType
(zType),
m_variableType
(vType) {
161
}
163
NSStruct::ZoneType
m_zoneType
;
165
NSStruct::VariableType
m_variableType
;
166
};
168
struct
Node
{
170
Node
() :
m_type
(0),
m_entry
(),
m_data
() {
171
}
173
bool
isLeaf
()
const
{
174
return
!
m_data
;
175
}
176
178
int
m_type
;
180
MWAWEntry
m_entry
;
182
shared_ptr<RecursifData>
m_data
;
183
};
184
};
185
}
186
187
#endif
188
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Generated on Tue Apr 30 2013 06:16:19 for libmwaw by
doxygen
1.8.3.1