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
47class MWAWParserState;
48
50namespace ClarisWksStruct
51{
53struct Struct {
56 : m_size(0)
57 , m_numData(0)
58 , m_dataSize(-1)
59 , m_headerSize(-1)
60 , m_type(-1)
61 {
62 for (auto &val : m_values) val=0;
63 }
65 bool readHeader(MWAWInputStreamPtr input, bool strict=false);
67 friend std::ostream &operator<<(std::ostream &o, Struct const &z);
69 long m_size;
77 int m_type;
79 int m_values[2];
80};
83bool readIntZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete, int fSz, std::vector<int> &res);
85bool readStructZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete);
87struct DSET {
88 struct Child;
89
94 };
97
100 : m_size(0)
101 , m_numData(0)
102 , m_dataSz(-1)
103 , m_headerSz(-1)
105 , m_fileType(-1)
106 , m_page(-1)
107 , m_box()
108 , m_pageDimension(0,0)
109 , m_id(0)
110 , m_fathersList()
112 , m_endSelection(-1)
113 , m_textType(0)
114 , m_childs()
115 , m_otherChilds()
116 , m_parsed(false)
117 , m_internal(0)
118 {
119 for (auto &fl : m_flags) fl=0;
120 }
121 DSET(DSET const &)=default;
123 virtual ~DSET() {}
124
126 bool isHeaderFooter() const
127 {
129 }
130
132 bool isSlide() const
133 {
135 }
138 {
139 MWAWVec2f minPt(m_box[0][0], m_box[0][1]);
140 MWAWVec2f maxPt(m_box[1][0], m_box[1][1]);
141 for (int c=0; c<2; ++c) {
142 if (m_box.size()[c]>=0) continue;
143 minPt[c]=m_box[1][c];
144 maxPt[c]=m_box[0][c];
145 }
146 return MWAWBox2f(minPt,maxPt);
147 }
149 int getMaximumPage() const
150 {
152 return m_page;
154 return 0;
155 int nPages=m_page;
156 for (const auto &child : m_childs) {
157 if (child.m_page > nPages)
158 nPages=child.m_page;
159 }
160 return nPages;
161 }
162
164 virtual void removeChild(int cId, bool normalChild);
166 virtual void removeChild(int cId);
168 void updateChildPositions(MWAWVec2f const &pageDim, float formLength, int numHorizontalPages=1);
170 void findForbiddenPagesBreaking(float pageDim, float formDim, int dim, MWAWVariable<int> &lastPage) const;
173
175 friend std::ostream &operator<<(std::ostream &o, DSET const &doc);
176
178 long m_size;
185
190
197
199 int m_id;
201 std::set<int> m_fathersList;
202
207
210
212 int m_flags[4];
213
215 std::vector<Child> m_childs;
217 std::vector<int> m_otherChilds;
218
220 mutable bool m_parsed;
222 mutable int m_internal;
223
225 struct Child {
229 , m_id(-1)
230 , m_posC(-1)
231 , m_page(-1)
232 , m_box()
233 {
234 }
237 {
238 MWAWVec2f minPt(m_box[0][0], m_box[0][1]);
239 MWAWVec2f maxPt(m_box[1][0], m_box[1][1]);
240 for (int c=0; c<2; ++c) {
241 if (m_box.size()[c]>=0) continue;
242 minPt[c]=m_box[1][c];
243 maxPt[c]=m_box[0][c];
244 }
245 return MWAWBox2f(minPt,maxPt);
246 }
247
249 friend std::ostream &operator<<(std::ostream &o, Child const &ch)
250 {
251 switch (ch.m_type) {
252 case C_SubText:
253 o << "text,";
254 break;
255 case C_Zone:
256 o << "zone,";
257 break;
258 case C_Graphic:
259 o << "graphic,";
260 break;
261 case C_Unknown:
262 o << "#type,";
263#if !defined(__clang__)
264 default:
265#endif
266 break;
267 }
268 if (ch.m_id != -1) o << "id=" << ch.m_id << ",";
269 if (ch.m_posC != -1) o << "posC=" << ch.m_posC << ",";
270 if (ch.m_page>=0) o << "pg=" << ch.m_page << ",";
271 if (ch.m_box.size().x() > 0 || ch.m_box.size().y() > 0)
272 o << "box=" << ch.m_box << ",";
273 return o;
274 }
275
279 int m_id;
281 long m_posC;
286 };
287};
288}
289
290#endif
291// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWVec2< T > size() const
the box size
Definition: libmwaw_internal.hxx:1067
a class to define the parser state
Definition: MWAWParser.hxx:50
T y() const
second element
Definition: libmwaw_internal.hxx:673
T x() const
first element
Definition: libmwaw_internal.hxx:668
MWAWBox2< float > MWAWBox2f
MWAWBox2 of float.
Definition: libmwaw_internal.hxx:1193
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
namespace to store the main structure which appears in a ClarisDraw/ClarisWorks file
Definition: ClarisWksStruct.cxx:50
bool readIntZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete, int intSz, std::vector< int > &res)
try to read a int structured zone where fSz to the int size: 1(int8), 2(int16), 4(int32)
Definition: ClarisWksStruct.cxx:99
bool readStructZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete)
try to read a structured zone with unknown content
Definition: ClarisWksStruct.cxx:162
structure used to define the child of a DSET structure
Definition: ClarisWksStruct.hxx:225
friend std::ostream & operator<<(std::ostream &o, Child const &ch)
operator<<
Definition: ClarisWksStruct.hxx:249
MWAWBox2f m_box
the bdbox
Definition: ClarisWksStruct.hxx:285
ChildType m_type
the type
Definition: ClarisWksStruct.hxx:277
long m_posC
a position (used in text zone to store the character )
Definition: ClarisWksStruct.hxx:281
Child()
constructor
Definition: ClarisWksStruct.hxx:227
MWAWBox2f getBdBox() const
return the zone bdbox
Definition: ClarisWksStruct.hxx:236
int m_id
the identificator
Definition: ClarisWksStruct.hxx:279
int m_page
the page if known
Definition: ClarisWksStruct.hxx:283
main structure which correspond to a document part
Definition: ClarisWksStruct.hxx:87
long m_size
the size of the DSET header
Definition: ClarisWksStruct.hxx:178
MWAWBox2i getUnionChildBox() const
returns the child box (ie. the union of the childs box)
Definition: ClarisWksStruct.cxx:219
Position
the zone position
Definition: ClarisWksStruct.hxx:91
@ P_Table
Definition: ClarisWksStruct.hxx:91
@ P_SlideThumbnail
Definition: ClarisWksStruct.hxx:93
@ P_Main
Definition: ClarisWksStruct.hxx:91
@ P_GraphicMaster
Definition: ClarisWksStruct.hxx:92
@ P_Slide
Definition: ClarisWksStruct.hxx:93
@ P_SlideMaster
Definition: ClarisWksStruct.hxx:93
@ P_Header
Definition: ClarisWksStruct.hxx:91
@ P_SlideNote
Definition: ClarisWksStruct.hxx:93
@ P_Footer
Definition: ClarisWksStruct.hxx:91
@ P_Frame
Definition: ClarisWksStruct.hxx:91
@ P_Unknown
Definition: ClarisWksStruct.hxx:93
@ P_Footnote
Definition: ClarisWksStruct.hxx:91
MWAWBox2f m_box
the bounding box (if known)
Definition: ClarisWksStruct.hxx:194
int getMaximumPage() const
returns the maximum page
Definition: ClarisWksStruct.hxx:149
void updateChildPositions(MWAWVec2f const &pageDim, float formLength, int numHorizontalPages=1)
try to update the child page and bounding box
Definition: ClarisWksStruct.cxx:259
bool isSlide() const
test if the zone is a slide
Definition: ClarisWksStruct.hxx:132
std::set< int > m_fathersList
the list of fathers
Definition: ClarisWksStruct.hxx:201
std::vector< int > m_otherChilds
the list of other child
Definition: ClarisWksStruct.hxx:217
virtual ~DSET()
virtual destructor
Definition: ClarisWksStruct.hxx:123
int m_flags[4]
some unknown flag
Definition: ClarisWksStruct.hxx:212
MWAWVec2f m_pageDimension
the page dimension (if know)
Definition: ClarisWksStruct.hxx:196
int m_textType
the text type (header/footer,footnote, ...)
Definition: ClarisWksStruct.hxx:209
long m_numData
the number of header
Definition: ClarisWksStruct.hxx:180
void findForbiddenPagesBreaking(float pageDim, float formDim, int dim, MWAWVariable< int > &lastPage) const
find forbidden page break
Definition: ClarisWksStruct.cxx:363
DSET()
constructor
Definition: ClarisWksStruct.hxx:99
virtual void removeChild(int cId, bool normalChild)
virtual function to remove a child from a list
Definition: ClarisWksStruct.cxx:239
bool m_parsed
a flag to know if the entry is sent or not to the listener
Definition: ClarisWksStruct.hxx:220
int m_beginSelection
the begin of selection ( at least in text header)
Definition: ClarisWksStruct.hxx:204
std::vector< Child > m_childs
the list of child zone
Definition: ClarisWksStruct.hxx:215
int m_id
the zone identificator
Definition: ClarisWksStruct.hxx:199
int m_page
the page (if known)
Definition: ClarisWksStruct.hxx:192
Position m_position
the zone type
Definition: ClarisWksStruct.hxx:187
int m_fileType
the type ( 0: text, -1: graphic, ...)
Definition: ClarisWksStruct.hxx:189
int m_endSelection
the end of selection ( at least in text header)
Definition: ClarisWksStruct.hxx:206
ChildType
the different types of zone child
Definition: ClarisWksStruct.hxx:96
@ C_Zone
Definition: ClarisWksStruct.hxx:96
@ C_Unknown
Definition: ClarisWksStruct.hxx:96
@ C_SubText
Definition: ClarisWksStruct.hxx:96
@ C_Graphic
Definition: ClarisWksStruct.hxx:96
long m_headerSz
the header size
Definition: ClarisWksStruct.hxx:184
MWAWBox2f getBdBox() const
return the zone bdbox
Definition: ClarisWksStruct.hxx:137
int m_internal
an internal variable used to do some computation
Definition: ClarisWksStruct.hxx:222
long m_dataSz
the data size
Definition: ClarisWksStruct.hxx:182
bool isHeaderFooter() const
test if the zone is an header/footer
Definition: ClarisWksStruct.hxx:126
friend std::ostream & operator<<(std::ostream &o, DSET const &doc)
operator<<
Definition: ClarisWksStruct.cxx:396
DSET(DSET const &)=default
a basic structure
Definition: ClarisWksStruct.hxx:53
Struct()
constructor
Definition: ClarisWksStruct.hxx:55
long m_size
the size of the DSET header
Definition: ClarisWksStruct.hxx:69
friend std::ostream & operator<<(std::ostream &o, Struct const &z)
operator<<
Definition: ClarisWksStruct.cxx:54
long m_headerSize
the header size
Definition: ClarisWksStruct.hxx:75
long m_numData
the number of header
Definition: ClarisWksStruct.hxx:71
int m_values[2]
an unknown value
Definition: ClarisWksStruct.hxx:79
int m_type
the type
Definition: ClarisWksStruct.hxx:77
bool readHeader(MWAWInputStreamPtr input, bool strict=false)
try to read the header
Definition: ClarisWksStruct.cxx:72
long m_dataSize
the data size
Definition: ClarisWksStruct.hxx:73
a generic variable template: value + flag to know if the variable is set
Definition: libmwaw_internal.hxx:577

Generated on Wed May 3 2023 07:18:29 for libmwaw by doxygen 1.9.6