Main Page
Namespaces
Classes
Files
File List
File Members
ClarisWksStruct.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
/*
35
* Structures used by Claris Works parser
36
*
37
*/
38
#ifndef CLARIS_WKS_STRUCT
39
# define CLARIS_WKS_STRUCT
40
41
#include <iostream>
42
#include <set>
43
#include <vector>
44
45
#include "
libmwaw_internal.hxx
"
46
47
class
MWAWParserState
;
48
50
namespace
ClarisWksStruct
51
{
54
bool
readIntZone
(
MWAWParserState
&parserState,
char
const
*zoneName,
bool
hasEntete,
int
fSz, std::vector<int> &res);
56
bool
readStructZone
(
MWAWParserState
&parserState,
char
const
*zoneName,
bool
hasEntete);
58
struct
DSET
{
59
struct
Child
;
60
62
enum
Position
{
P_Main
=0,
P_Header
,
P_Footer
,
P_Frame
,
P_Footnote
,
P_Table
,
63
P_GraphicMaster
,
64
P_Slide
,
P_SlideNote
,
P_SlideThumbnail
,
P_SlideMaster
,
P_Unknown
65
};
67
enum
ChildType
{
C_Zone
,
C_SubText
,
C_Graphic
,
C_Unknown
};
68
70
DSET
() :
m_size
(0),
m_numData
(0),
m_dataSz
(-1),
m_headerSz
(-1),
71
m_position
(
P_Unknown
),
m_fileType
(-1),
72
m_page
(-1),
m_box
(),
m_pageDimension
(0,0),
m_id
(0),
m_fathersList
(),
73
m_beginSelection
(0),
m_endSelection
(-1),
m_textType
(0),
74
m_childs
(),
m_otherChilds
(),
m_parsed
(false),
m_internal
(0)
75
{
76
for
(
int
i = 0; i < 4; i++)
m_flags
[i] = 0;
77
}
78
80
virtual
~DSET
() {}
81
83
bool
isHeaderFooter
()
const
84
{
85
return
m_position
==
P_Header
||
m_position
==
P_Footer
;
86
}
87
89
bool
isSlide
()
const
90
{
91
return
m_position
==
P_Slide
||
m_position
==
P_SlideNote
||
m_position
==
P_SlideThumbnail
||
m_position
==
P_SlideMaster
;
92
}
94
MWAWBox2f
getBdBox
()
const
95
{
96
MWAWVec2f
minPt(
m_box
[0][0],
m_box
[0][1]);
97
MWAWVec2f
maxPt(
m_box
[1][0],
m_box
[1][1]);
98
for
(
int
c=0; c<2; ++c) {
99
if
(
m_box
.
size
()[c]>=0)
continue
;
100
minPt[c]=
m_box
[1][c];
101
maxPt[c]=
m_box
[0][c];
102
}
103
return
MWAWBox2f
(minPt,maxPt);
104
}
106
int
getMaximumPage
()
const
107
{
108
if
(
m_position
==
ClarisWksStruct::DSET::P_Slide
)
109
return
m_page
;
110
if
(
m_position
!=
ClarisWksStruct::DSET::P_Main
)
111
return
0;
112
int
nPages=
m_page
;
113
for
(
size_t
b=0; b <
m_childs
.size(); b++) {
114
if
(
m_childs
[b].
m_page
> nPages)
115
nPages=
m_childs
[b].m_page;
116
}
117
return
nPages;
118
}
119
121
virtual
void
removeChild
(
int
cId,
bool
normalChild);
123
virtual
void
removeChild
(
int
cId);
125
void
updateChildPositions
(
MWAWVec2f
const
&pageDim,
float
formLength,
int
numHorizontalPages=1);
127
void
findForbiddenPagesBreaking
(
float
pageDim,
float
formDim,
int
dim, std::set<int> &forbiddenPageBreak)
const
;
129
MWAWBox2i
getUnionChildBox
()
const
;
130
132
friend
std::ostream &
operator<<
(std::ostream &o,
DSET
const
&doc);
133
135
long
m_size
;
137
long
m_numData
;
139
long
m_dataSz
;
141
long
m_headerSz
;
142
144
Position
m_position
;
146
int
m_fileType
;
147
149
int
m_page
;
151
MWAWBox2f
m_box
;
153
MWAWVec2f
m_pageDimension
;
154
156
int
m_id
;
158
std::set<int>
m_fathersList
;
159
161
int
m_beginSelection
;
163
int
m_endSelection
;
164
166
int
m_textType
;
167
169
int
m_flags
[4];
170
172
std::vector<Child>
m_childs
;
174
std::vector<int>
m_otherChilds
;
175
177
mutable
bool
m_parsed
;
179
mutable
int
m_internal
;
180
182
struct
Child
{
184
Child
() :
m_type
(
C_Unknown
),
m_id
(-1),
m_posC
(-1),
m_page
(-1),
m_box
()
185
{
186
}
188
MWAWBox2f
getBdBox
()
const
189
{
190
MWAWVec2f
minPt(
m_box
[0][0],
m_box
[0][1]);
191
MWAWVec2f
maxPt(
m_box
[1][0],
m_box
[1][1]);
192
for
(
int
c=0; c<2; ++c) {
193
if
(
m_box
.
size
()[c]>=0)
continue
;
194
minPt[c]=
m_box
[1][c];
195
maxPt[c]=
m_box
[0][c];
196
}
197
return
MWAWBox2f
(minPt,maxPt);
198
}
199
201
friend
std::ostream &
operator<<
(std::ostream &o,
Child
const
&ch)
202
{
203
switch
(ch.
m_type
) {
204
case
C_SubText
:
205
o <<
"text,"
;
206
break
;
207
case
C_Zone
:
208
o <<
"zone,"
;
209
break
;
210
case
C_Graphic
:
211
o <<
"graphic,"
;
212
break
;
213
case
C_Unknown
:
214
o <<
"#type,"
;
215
default
:
216
break
;
217
}
218
if
(ch.
m_id
!= -1) o <<
"id="
<< ch.
m_id
<<
","
;
219
if
(ch.
m_posC
!= -1) o <<
"posC="
<< ch.
m_posC
<<
","
;
220
if
(ch.
m_page
>=0) o <<
"pg="
<< ch.
m_page
<<
","
;
221
if
(ch.
m_box
.
size
().
x
() > 0 || ch.
m_box
.
size
().
y
() > 0)
222
o <<
"box="
<< ch.
m_box
<<
","
;
223
return
o;
224
}
225
227
ChildType
m_type
;
229
int
m_id
;
231
long
m_posC
;
233
int
m_page
;
235
MWAWBox2f
m_box
;
236
};
237
};
238
}
239
240
#endif
241
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Generated on Tue Mar 1 2016 23:42:41 for libmwaw by
doxygen
1.8.4