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:
Generated on Tue Mar 1 2016 23:42:52 for libmwaw by
doxygen
1.8.4