- 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
48 namespace ClarisWksStruct
49 {
51 struct DSET {
52 struct Child;
53
55 enum Position { P_Main=0, P_Header, P_Footer, P_Frame, P_Footnote, P_Table,
56 P_GraphicMaster,
57 P_Slide, P_SlideNote, P_SlideThumbnail, P_SlideMaster, P_Unknown
58 };
60 enum ChildType { C_Zone, C_SubText, C_Graphic, C_Unknown };
61
63 DSET() : m_size(0), m_numData(0), m_dataSz(-1), m_headerSz(-1),
64 m_position(P_Unknown), m_fileType(-1),
65 m_page(-1), m_box(), m_pageDimension(0,0), m_id(0), m_fathersList(),
66 m_beginSelection(0), m_endSelection(-1), m_textType(0),
67 m_childs(), m_otherChilds(), m_parsed(false), m_internal(0)
68 {
69 for (int i = 0; i < 4; i++) m_flags[i] = 0;
70 }
71
73 virtual ~DSET() {}
74
76 bool isHeaderFooter() const
77 {
78 return m_position==P_Header||m_position==P_Footer;
79 }
80
82 bool isSlide() const
83 {
84 return m_position==P_Slide || m_position==P_SlideNote || m_position==P_SlideThumbnail || m_position==P_SlideMaster;
85 }
87 Box2f getBdBox() const
88 {
89 Vec2f minPt(m_box[0][0], m_box[0][1]);
90 Vec2f maxPt(m_box[1][0], m_box[1][1]);
91 for (int c=0; c<2; ++c) {
92 if (m_box.size()[c]>=0) continue;
93 minPt[c]=m_box[1][c];
94 maxPt[c]=m_box[0][c];
95 }
96 return Box2f(minPt,maxPt);
97 }
99 int getMaximumPage() const
100 {
101 if (m_position==ClarisWksStruct::DSET::P_Slide)
102 return m_page;
103 if (m_position!=ClarisWksStruct::DSET::P_Main)
104 return 0;
105 int nPages=m_page;
106 for (size_t b=0; b < m_childs.size(); b++) {
107 if (m_childs[b].m_page > nPages)
108 nPages=m_childs[b].m_page;
109 }
110 return nPages;
111 }
112
114 virtual void removeChild(int cId, bool normalChild);
116 virtual void removeChild(int cId);
118 void updateChildPositions(Vec2f const &pageDim, float formLength, int numHorizontalPages=1);
120 void findForbiddenPagesBreaking(float pageDim, float formDim, int dim, std::set<int> &forbiddenPageBreak) const;
122 Box2i getUnionChildBox() const;
123
125 friend std::ostream &operator<<(std::ostream &o, DSET const &doc);
126
128 long m_size;
130 long m_numData;
132 long m_dataSz;
134 long m_headerSz;
135
137 Position m_position;
139 int m_fileType;
140
142 int m_page;
144 Box2f m_box;
146 Vec2f m_pageDimension;
147
149 int m_id;
151 std::set<int> m_fathersList;
152
154 int m_beginSelection;
156 int m_endSelection;
157
159 int m_textType;
160
162 int m_flags[4];
163
165 std::vector<Child> m_childs;
167 std::vector<int> m_otherChilds;
168
170 mutable bool m_parsed;
172 mutable int m_internal;
173
175 struct Child {
177 Child() : m_type(C_Unknown), m_id(-1), m_posC(-1), m_page(-1), m_box()
178 {
179 }
181 Box2f getBdBox() const
182 {
183 Vec2f minPt(m_box[0][0], m_box[0][1]);
184 Vec2f maxPt(m_box[1][0], m_box[1][1]);
185 for (int c=0; c<2; ++c) {
186 if (m_box.size()[c]>=0) continue;
187 minPt[c]=m_box[1][c];
188 maxPt[c]=m_box[0][c];
189 }
190 return Box2f(minPt,maxPt);
191 }
192
194 friend std::ostream &operator<<(std::ostream &o, Child const &ch)
195 {
196 switch (ch.m_type) {
197 case C_SubText:
198 o << "text,";
199 break;
200 case C_Zone:
201 o << "zone,";
202 break;
203 case C_Graphic:
204 o << "graphic,";
205 break;
206 case C_Unknown:
207 o << "#type,";
208 default:
209 break;
210 }
211 if (ch.m_id != -1) o << "id=" << ch.m_id << ",";
212 if (ch.m_posC != -1) o << "posC=" << ch.m_posC << ",";
213 if (ch.m_page>=0) o << "pg=" << ch.m_page << ",";
214 if (ch.m_box.size().x() > 0 || ch.m_box.size().y() > 0)
215 o << "box=" << ch.m_box << ",";
216 return o;
217 }
218
220 ChildType m_type;
222 int m_id;
224 long m_posC;
226 int m_page;
228 Box2f m_box;
229 };
230 };
231 }
232
233 #endif
234 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
ClarisWksStruct::DSET::m_beginSelection
int m_beginSelection
the begin of selection ( at least in text header)
Definition: ClarisWksStruct.hxx:154
ClarisWksStruct::DSET::getBdBox
Box2f getBdBox() const
return the zone bdbox
Definition: ClarisWksStruct.hxx:87
ClarisWksStruct::DSET::m_endSelection
int m_endSelection
the end of selection ( at least in text header)
Definition: ClarisWksStruct.hxx:156
ClarisWksStruct::DSET::C_Unknown
Definition: ClarisWksStruct.hxx:60
ClarisWksStruct::DSET::Child::getBdBox
Box2f getBdBox() const
return the zone bdbox
Definition: ClarisWksStruct.hxx:181
ClarisWksStruct::DSET::isHeaderFooter
bool isHeaderFooter() const
test if the zone is an header/footer
Definition: ClarisWksStruct.hxx:76
ClarisWksStruct::DSET::Child::m_box
Box2f m_box
the bdbox
Definition: ClarisWksStruct.hxx:228
ClarisWksStruct::DSET::isSlide
bool isSlide() const
test if the zone is a slide
Definition: ClarisWksStruct.hxx:82
ClarisWksStruct::DSET::Child::Child
Child()
constructor
Definition: ClarisWksStruct.hxx:177
ClarisWksStruct::DSET::~DSET
virtual ~DSET()
virtual destructor
Definition: ClarisWksStruct.hxx:73
ClarisWksStruct::DSET::Child::m_type
ChildType m_type
the type
Definition: ClarisWksStruct.hxx:220
libmwaw_internal.hxx
ClarisWksStruct::DSET::m_fathersList
std::set< int > m_fathersList
the list of fathers
Definition: ClarisWksStruct.hxx:151
ClarisWksStruct::DSET::Child
structure used to define the child of a DSET structure
Definition: ClarisWksStruct.hxx:175
Box2< float >
ClarisWksStruct::DSET::Child::operator<<
friend std::ostream & operator<<(std::ostream &o, Child const &ch)
operator<<
Definition: ClarisWksStruct.hxx:194
ClarisWksStruct::DSET::m_size
long m_size
the size of the DSET header
Definition: ClarisWksStruct.hxx:128
ClarisWksStruct::DSET::m_page
int m_page
the page (if known)
Definition: ClarisWksStruct.hxx:142
ClarisWksStruct::DSET::P_SlideThumbnail
Definition: ClarisWksStruct.hxx:57
ClarisWksStruct::DSET::m_flags
int m_flags[4]
some unknown flag
Definition: ClarisWksStruct.hxx:162
ClarisWksStruct::DSET::P_GraphicMaster
Definition: ClarisWksStruct.hxx:56
ClarisWksStruct::DSET::m_internal
int m_internal
an internal variable used to do some computation
Definition: ClarisWksStruct.hxx:172
ClarisWksStruct::DSET::getMaximumPage
int getMaximumPage() const
returns the maximum page
Definition: ClarisWksStruct.hxx:99
ClarisWksStruct::DSET::P_Header
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET::m_numData
long m_numData
the number of header
Definition: ClarisWksStruct.hxx:130
Box2f
Box2< float > Box2f
Box2 of float.
Definition: libmwaw_internal.hxx:1072
ClarisWksStruct::DSET::m_id
int m_id
the zone identificator
Definition: ClarisWksStruct.hxx:149
ClarisWksStruct::DSET::m_textType
int m_textType
the text type (header/footer,footnote, ...)
Definition: ClarisWksStruct.hxx:159
ClarisWksStruct::DSET::P_Frame
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET
main structure which correspond to a document part
Definition: ClarisWksStruct.hxx:51
Vec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:546
ClarisWksStruct::DSET::m_box
Box2f m_box
the bounding box (if known)
Definition: ClarisWksStruct.hxx:144
ClarisWksStruct::DSET::m_otherChilds
std::vector< int > m_otherChilds
the list of other child
Definition: ClarisWksStruct.hxx:167
ClarisWksStruct::DSET::P_Slide
Definition: ClarisWksStruct.hxx:57
ClarisWksStruct::DSET::P_SlideMaster
Definition: ClarisWksStruct.hxx:57
ClarisWksStruct::DSET::DSET
DSET()
constructor
Definition: ClarisWksStruct.hxx:63
ClarisWksStruct::DSET::m_parsed
bool m_parsed
a flag to know if the entry is sent or not to the listener
Definition: ClarisWksStruct.hxx:170
ClarisWksStruct::DSET::Child::m_page
int m_page
the page if known
Definition: ClarisWksStruct.hxx:226
ClarisWksStruct::DSET::P_Footnote
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET::getUnionChildBox
Box2i getUnionChildBox() const
returns the child box (ie. the union of the childs box)
Definition: ClarisWksStruct.cxx:51
Vec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:541
ClarisWksStruct::DSET::m_fileType
int m_fileType
the type ( 0: text, -1: graphic, ...)
Definition: ClarisWksStruct.hxx:139
ClarisWksStruct::DSET::operator<<
friend std::ostream & operator<<(std::ostream &o, DSET const &doc)
operator<<
Definition: ClarisWksStruct.cxx:237
ClarisWksStruct::DSET::P_Table
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET::updateChildPositions
void updateChildPositions(Vec2f const &pageDim, float formLength, int numHorizontalPages=1)
try to update the child page and bounding box
Definition: ClarisWksStruct.cxx:94
ClarisWksStruct::DSET::findForbiddenPagesBreaking
void findForbiddenPagesBreaking(float pageDim, float formDim, int dim, std::set< int > &forbiddenPageBreak) const
find forbidden page break
Definition: ClarisWksStruct.cxx:196
ClarisWksStruct::DSET::C_Zone
Definition: ClarisWksStruct.hxx:60
ClarisWksStruct::DSET::P_Unknown
Definition: ClarisWksStruct.hxx:57
ClarisWksStruct::DSET::Position
Position
the zone position
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET::C_Graphic
Definition: ClarisWksStruct.hxx:60
ClarisWksStruct::DSET::m_position
Position m_position
the zone type
Definition: ClarisWksStruct.hxx:137
ClarisWksStruct::DSET::C_SubText
Definition: ClarisWksStruct.hxx:60
ClarisWksStruct::DSET::removeChild
virtual void removeChild(int cId, bool normalChild)
virtual function to remove a child from a list
Definition: ClarisWksStruct.cxx:72
ClarisWksStruct
namespace to store the main structure which appears in a Claris Works file
Definition: ClarisWksStruct.cxx:46
ClarisWksStruct::DSET::m_dataSz
long m_dataSz
the data size
Definition: ClarisWksStruct.hxx:132
ClarisWksStruct::DSET::m_childs
std::vector< Child > m_childs
the list of child zone
Definition: ClarisWksStruct.hxx:165
ClarisWksStruct::DSET::m_pageDimension
Vec2f m_pageDimension
the page dimension (if know)
Definition: ClarisWksStruct.hxx:146
Vec2< float >
Box2::size
Vec2< T > size() const
the box size
Definition: libmwaw_internal.hxx:937
ClarisWksStruct::DSET::ChildType
ChildType
the different types of zone child
Definition: ClarisWksStruct.hxx:60
ClarisWksStruct::DSET::P_SlideNote
Definition: ClarisWksStruct.hxx:57
ClarisWksStruct::DSET::Child::m_posC
long m_posC
a position (used in text zone to store the character )
Definition: ClarisWksStruct.hxx:224
ClarisWksStruct::DSET::Child::m_id
int m_id
the identificator
Definition: ClarisWksStruct.hxx:222
ClarisWksStruct::DSET::P_Footer
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET::P_Main
Definition: ClarisWksStruct.hxx:55
ClarisWksStruct::DSET::m_headerSz
long m_headerSz
the header size
Definition: ClarisWksStruct.hxx:134