ClarisWksStruct.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* Structures used by Claris Works parser
*
*/
#ifndef CLARIS_WKS_STRUCT
# define CLARIS_WKS_STRUCT
#include <iostream>
#include <set>
#include <vector>
#include "libmwaw_internal.hxx"
class MWAWParserState;
namespace ClarisWksStruct
{
struct Struct {
Struct()
: m_size(0)
, m_numData(0)
, m_dataSize(-1)
, m_headerSize(-1)
, m_type(-1)
{
for (auto &val : m_values) val=0;
}
bool readHeader(MWAWInputStreamPtr input, bool strict=false);
friend std::ostream &operator<<(std::ostream &o, Struct const &z);
long m_size;
long m_numData;
long m_dataSize;
long m_headerSize;
int m_type;
int m_values[2];
};
bool readIntZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete, int fSz, std::vector<int> &res);
bool readStructZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete);
struct DSET {
struct Child;
enum Position { P_Main=0, P_Header, P_Footer, P_Frame, P_Footnote, P_Table,
P_GraphicMaster,
P_Slide, P_SlideNote, P_SlideThumbnail, P_SlideMaster, P_Unknown
};
enum ChildType { C_Zone, C_SubText, C_Graphic, C_Unknown };
DSET()
: m_size(0)
, m_numData(0)
, m_dataSz(-1)
, m_headerSz(-1)
, m_position(P_Unknown)
, m_fileType(-1)
, m_page(-1)
, m_box()
, m_pageDimension(0,0)
, m_id(0)
, m_fathersList()
, m_beginSelection(0)
, m_endSelection(-1)
, m_textType(0)
, m_childs()
, m_otherChilds()
, m_parsed(false)
, m_internal(0)
{
for (auto &fl : m_flags) fl=0;
}
DSET(DSET const &)=default;
virtual ~DSET() {}
bool isHeaderFooter() const
{
return m_position==P_Header||m_position==P_Footer;
}
bool isSlide() const
{
return m_position==P_Slide || m_position==P_SlideNote || m_position==P_SlideThumbnail || m_position==P_SlideMaster;
}
MWAWBox2f getBdBox() const
{
MWAWVec2f minPt(m_box[0][0], m_box[0][1]);
MWAWVec2f maxPt(m_box[1][0], m_box[1][1]);
for (int c=0; c<2; ++c) {
if (m_box.size()[c]>=0) continue;
minPt[c]=m_box[1][c];
maxPt[c]=m_box[0][c];
}
return MWAWBox2f(minPt,maxPt);
}
int getMaximumPage() const
{
if (m_position==ClarisWksStruct::DSET::P_Slide)
return m_page;
if (m_position!=ClarisWksStruct::DSET::P_Main)
return 0;
int nPages=m_page;
for (const auto &child : m_childs) {
if (child.m_page > nPages)
nPages=child.m_page;
}
return nPages;
}
virtual void removeChild(int cId, bool normalChild);
virtual void removeChild(int cId);
void updateChildPositions(MWAWVec2f const &pageDim, float formLength, int numHorizontalPages=1);
void findForbiddenPagesBreaking(float pageDim, float formDim, int dim, MWAWVariable<int> &lastPage) const;
MWAWBox2i getUnionChildBox() const;
friend std::ostream &operator<<(std::ostream &o, DSET const &doc);
long m_size;
long m_numData;
long m_dataSz;
long m_headerSz;
Position m_position;
int m_fileType;
int m_page;
MWAWBox2f m_box;
MWAWVec2f m_pageDimension;
int m_id;
std::set<int> m_fathersList;
int m_beginSelection;
int m_endSelection;
int m_textType;
int m_flags[4];
std::vector<Child> m_childs;
std::vector<int> m_otherChilds;
mutable bool m_parsed;
mutable int m_internal;
struct Child {
Child()
: m_type(C_Unknown)
, m_id(-1)
, m_posC(-1)
, m_page(-1)
, m_box()
{
}
MWAWBox2f getBdBox() const
{
MWAWVec2f minPt(m_box[0][0], m_box[0][1]);
MWAWVec2f maxPt(m_box[1][0], m_box[1][1]);
for (int c=0; c<2; ++c) {
if (m_box.size()[c]>=0) continue;
minPt[c]=m_box[1][c];
maxPt[c]=m_box[0][c];
}
return MWAWBox2f(minPt,maxPt);
}
friend std::ostream &operator<<(std::ostream &o, Child const &ch)
{
switch (ch.m_type) {
case C_SubText:
o << "text,";
break;
case C_Zone:
o << "zone,";
break;
case C_Graphic:
o << "graphic,";
break;
case C_Unknown:
o << "#type,";
#if !defined(__clang__)
default:
#endif
break;
}
if (ch.m_id != -1) o << "id=" << ch.m_id << ",";
if (ch.m_posC != -1) o << "posC=" << ch.m_posC << ",";
if (ch.m_page>=0) o << "pg=" << ch.m_page << ",";
if (ch.m_box.size().x() > 0 || ch.m_box.size().y() > 0)
o << "box=" << ch.m_box << ",";
return o;
}
ChildType m_type;
int m_id;
long m_posC;
int m_page;
MWAWBox2f m_box;
};
};
}
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWBox2::size
MWAWVec2< T > size() const
the box size
Definition libmwaw_internal.hxx:1067
MWAWParserState
a class to define the parser state
Definition MWAWParser.hxx:50
MWAWVec2::y
T y() const
second element
Definition libmwaw_internal.hxx:673
MWAWVec2::x
T x() const
first element
Definition libmwaw_internal.hxx:668
libmwaw_internal.hxx
MWAWBox2f
MWAWBox2< float > MWAWBox2f
MWAWBox2 of float.
Definition libmwaw_internal.hxx:1193
MWAWBox2i
MWAWBox2< int > MWAWBox2i
MWAWBox2 of int.
Definition libmwaw_internal.hxx:1191
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition libmwaw_internal.hxx:842
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
ClarisWksStruct
namespace to store the main structure which appears in a ClarisDraw/ClarisWorks file
Definition ClarisWksStruct.cxx:50
ClarisWksStruct::readIntZone
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
ClarisWksStruct::readStructZone
bool readStructZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete)
try to read a structured zone with unknown content
Definition ClarisWksStruct.cxx:162
ClarisWksStruct::DSET::Child
structure used to define the child of a DSET structure
Definition ClarisWksStruct.hxx:225
ClarisWksStruct::DSET::Child::operator<<
friend std::ostream & operator<<(std::ostream &o, Child const &ch)
operator<<
Definition ClarisWksStruct.hxx:249
ClarisWksStruct::DSET::Child::m_box
MWAWBox2f m_box
the bdbox
Definition ClarisWksStruct.hxx:285
ClarisWksStruct::DSET::Child::m_type
ChildType m_type
the type
Definition ClarisWksStruct.hxx:277
ClarisWksStruct::DSET::Child::m_posC
long m_posC
a position (used in text zone to store the character )
Definition ClarisWksStruct.hxx:281
ClarisWksStruct::DSET::Child::Child
Child()
constructor
Definition ClarisWksStruct.hxx:227
ClarisWksStruct::DSET::Child::getBdBox
MWAWBox2f getBdBox() const
return the zone bdbox
Definition ClarisWksStruct.hxx:236
ClarisWksStruct::DSET::Child::m_id
int m_id
the identificator
Definition ClarisWksStruct.hxx:279
ClarisWksStruct::DSET::Child::m_page
int m_page
the page if known
Definition ClarisWksStruct.hxx:283
ClarisWksStruct::DSET
main structure which correspond to a document part
Definition ClarisWksStruct.hxx:87
ClarisWksStruct::DSET::m_size
long m_size
the size of the DSET header
Definition ClarisWksStruct.hxx:178
ClarisWksStruct::DSET::getUnionChildBox
MWAWBox2i getUnionChildBox() const
returns the child box (ie. the union of the childs box)
Definition ClarisWksStruct.cxx:219
ClarisWksStruct::DSET::Position
Position
the zone position
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::P_Table
@ P_Table
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::P_SlideThumbnail
@ P_SlideThumbnail
Definition ClarisWksStruct.hxx:93
ClarisWksStruct::DSET::P_Main
@ P_Main
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::P_GraphicMaster
@ P_GraphicMaster
Definition ClarisWksStruct.hxx:92
ClarisWksStruct::DSET::P_Slide
@ P_Slide
Definition ClarisWksStruct.hxx:93
ClarisWksStruct::DSET::P_SlideMaster
@ P_SlideMaster
Definition ClarisWksStruct.hxx:93
ClarisWksStruct::DSET::P_Header
@ P_Header
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::P_SlideNote
@ P_SlideNote
Definition ClarisWksStruct.hxx:93
ClarisWksStruct::DSET::P_Footer
@ P_Footer
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::P_Frame
@ P_Frame
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::P_Unknown
@ P_Unknown
Definition ClarisWksStruct.hxx:93
ClarisWksStruct::DSET::P_Footnote
@ P_Footnote
Definition ClarisWksStruct.hxx:91
ClarisWksStruct::DSET::m_box
MWAWBox2f m_box
the bounding box (if known)
Definition ClarisWksStruct.hxx:194
ClarisWksStruct::DSET::getMaximumPage
int getMaximumPage() const
returns the maximum page
Definition ClarisWksStruct.hxx:149
ClarisWksStruct::DSET::updateChildPositions
void updateChildPositions(MWAWVec2f const &pageDim, float formLength, int numHorizontalPages=1)
try to update the child page and bounding box
Definition ClarisWksStruct.cxx:259
ClarisWksStruct::DSET::isSlide
bool isSlide() const
test if the zone is a slide
Definition ClarisWksStruct.hxx:132
ClarisWksStruct::DSET::m_fathersList
std::set< int > m_fathersList
the list of fathers
Definition ClarisWksStruct.hxx:201
ClarisWksStruct::DSET::m_otherChilds
std::vector< int > m_otherChilds
the list of other child
Definition ClarisWksStruct.hxx:217
ClarisWksStruct::DSET::~DSET
virtual ~DSET()
virtual destructor
Definition ClarisWksStruct.hxx:123
ClarisWksStruct::DSET::m_flags
int m_flags[4]
some unknown flag
Definition ClarisWksStruct.hxx:212
ClarisWksStruct::DSET::m_pageDimension
MWAWVec2f m_pageDimension
the page dimension (if know)
Definition ClarisWksStruct.hxx:196
ClarisWksStruct::DSET::m_textType
int m_textType
the text type (header/footer,footnote, ...)
Definition ClarisWksStruct.hxx:209
ClarisWksStruct::DSET::m_numData
long m_numData
the number of header
Definition ClarisWksStruct.hxx:180
ClarisWksStruct::DSET::findForbiddenPagesBreaking
void findForbiddenPagesBreaking(float pageDim, float formDim, int dim, MWAWVariable< int > &lastPage) const
find forbidden page break
Definition ClarisWksStruct.cxx:363
ClarisWksStruct::DSET::DSET
DSET()
constructor
Definition ClarisWksStruct.hxx:99
ClarisWksStruct::DSET::removeChild
virtual void removeChild(int cId, bool normalChild)
virtual function to remove a child from a list
Definition ClarisWksStruct.cxx:239
ClarisWksStruct::DSET::m_parsed
bool m_parsed
a flag to know if the entry is sent or not to the listener
Definition ClarisWksStruct.hxx:220
ClarisWksStruct::DSET::m_beginSelection
int m_beginSelection
the begin of selection ( at least in text header)
Definition ClarisWksStruct.hxx:204
ClarisWksStruct::DSET::m_childs
std::vector< Child > m_childs
the list of child zone
Definition ClarisWksStruct.hxx:215
ClarisWksStruct::DSET::m_id
int m_id
the zone identificator
Definition ClarisWksStruct.hxx:199
ClarisWksStruct::DSET::m_page
int m_page
the page (if known)
Definition ClarisWksStruct.hxx:192
ClarisWksStruct::DSET::m_position
Position m_position
the zone type
Definition ClarisWksStruct.hxx:187
ClarisWksStruct::DSET::m_fileType
int m_fileType
the type ( 0: text, -1: graphic, ...)
Definition ClarisWksStruct.hxx:189
ClarisWksStruct::DSET::m_endSelection
int m_endSelection
the end of selection ( at least in text header)
Definition ClarisWksStruct.hxx:206
ClarisWksStruct::DSET::ChildType
ChildType
the different types of zone child
Definition ClarisWksStruct.hxx:96
ClarisWksStruct::DSET::C_Zone
@ C_Zone
Definition ClarisWksStruct.hxx:96
ClarisWksStruct::DSET::C_Unknown
@ C_Unknown
Definition ClarisWksStruct.hxx:96
ClarisWksStruct::DSET::C_SubText
@ C_SubText
Definition ClarisWksStruct.hxx:96
ClarisWksStruct::DSET::C_Graphic
@ C_Graphic
Definition ClarisWksStruct.hxx:96
ClarisWksStruct::DSET::m_headerSz
long m_headerSz
the header size
Definition ClarisWksStruct.hxx:184
ClarisWksStruct::DSET::getBdBox
MWAWBox2f getBdBox() const
return the zone bdbox
Definition ClarisWksStruct.hxx:137
ClarisWksStruct::DSET::m_internal
int m_internal
an internal variable used to do some computation
Definition ClarisWksStruct.hxx:222
ClarisWksStruct::DSET::m_dataSz
long m_dataSz
the data size
Definition ClarisWksStruct.hxx:182
ClarisWksStruct::DSET::isHeaderFooter
bool isHeaderFooter() const
test if the zone is an header/footer
Definition ClarisWksStruct.hxx:126
ClarisWksStruct::DSET::operator<<
friend std::ostream & operator<<(std::ostream &o, DSET const &doc)
operator<<
Definition ClarisWksStruct.cxx:396
ClarisWksStruct::DSET::DSET
DSET(DSET const &)=default
ClarisWksStruct::Struct
a basic structure
Definition ClarisWksStruct.hxx:53
ClarisWksStruct::Struct::Struct
Struct()
constructor
Definition ClarisWksStruct.hxx:55
ClarisWksStruct::Struct::m_size
long m_size
the size of the DSET header
Definition ClarisWksStruct.hxx:69
ClarisWksStruct::Struct::operator<<
friend std::ostream & operator<<(std::ostream &o, Struct const &z)
operator<<
Definition ClarisWksStruct.cxx:54
ClarisWksStruct::Struct::m_headerSize
long m_headerSize
the header size
Definition ClarisWksStruct.hxx:75
ClarisWksStruct::Struct::m_numData
long m_numData
the number of header
Definition ClarisWksStruct.hxx:71
ClarisWksStruct::Struct::m_values
int m_values[2]
an unknown value
Definition ClarisWksStruct.hxx:79
ClarisWksStruct::Struct::m_type
int m_type
the type
Definition ClarisWksStruct.hxx:77
ClarisWksStruct::Struct::readHeader
bool readHeader(MWAWInputStreamPtr input, bool strict=false)
try to read the header
Definition ClarisWksStruct.cxx:72
ClarisWksStruct::Struct::m_dataSize
long m_dataSize
the data size
Definition ClarisWksStruct.hxx:73
MWAWVariable
a generic variable template: value + flag to know if the variable is set
Definition libmwaw_internal.hxx:577