WPS8Table.h Source File documentation

WPS8Table.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11 * Copyright (C) 2006, 2007 Andrew Ziem
12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15 *
16 * For minor contributions see the git repository.
17 *
18 * Alternatively, the contents of this file may be used under the terms
19 * of the GNU Lesser General Public License Version 2.1 or later
20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21 * applicable instead of those above.
22 *
23 * For further information visit http://libwps.sourceforge.net
24 */
25
26 #ifndef WPS8_TABLE
27 # define WPS8_TABLE
28
29 #include "libwps_internal.h"
30
31 #include "WPSDebug.h"
32
33 class WPS8Parser;
34
35 namespace WPS8TableInternal
36 {
37 struct Cell;
38 struct State;
39 }
40
42 //
43 // class to parse the object
44 //
46
57 class WPS8Table
58 {
59 friend struct WPS8TableInternal::Cell;
60 friend class WPS8Parser;
61 public:
63 explicit WPS8Table(WPS8Parser &parser);
64
66 ~WPS8Table();
67
69 void setListener(WPSContentListenerPtr &listen)
70 {
71 m_listener = listen;
72 }
73
75 void computePositions() const;
76
78 int numPages() const;
79
81 void flushExtra();
82
83 protected:
85 bool readStructures(RVNGInputStreamPtr const &input);
86
95 bool sendTable(Vec2f const &siz, int tableId, int strsid, bool inTextBox=false);
96
97 // interface with main parser
98 void sendTextInCell(int strsId, int cellId);
99
100 protected: // low level
101
103 bool readMCLD(RVNGInputStreamPtr input, WPSEntry const &entry);
104
106 int version() const;
107
109 libwps::DebugFile &ascii()
110 {
111 return m_asciiFile;
112 }
113 private:
114 WPS8Table(WPS8Table const &orig) = delete;
115 WPS8Table &operator=(WPS8Table const &orig) = delete;
116
117 protected:
119 WPSContentListenerPtr m_listener;
120
122 WPS8Parser &m_mainParser;
123
125 mutable std::shared_ptr<WPS8TableInternal::State> m_state;
126
128 libwps::DebugFile &m_asciiFile;
129 };
130
131 #endif
132 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
WPS8TableInternal::Cell::m_tableParser
WPS8Table & m_tableParser
the actual parser
Definition: WPS8Table.cpp:91
WPSColor::white
static WPSColor white()
return the white color
Definition: libwps_internal.h:311
WPS_N_ELEMENTS
#define WPS_N_ELEMENTS(m)
Definition: libwps_internal.h:124
WPSEntry::hasName
bool hasName(std::string const &nam) const
checks if the entry name is equal to name
Definition: WPSEntry.h:152
WPS8TableInternal::Table::operator=
Table & operator=(Table const &)=default
WPS8Table::setListener
void setListener(WPSContentListenerPtr &listen)
sets the listener
Definition: WPS8Table.h:69
libwps::DebugStream::str
static std::string str()
Definition: WPSDebug.h:200
WPSCellFormat::VALIGN_CENTER
@ VALIGN_CENTER
Definition: WPSCell.h:50
libwps::DebugFile::addPos
static void addPos(long)
Definition: WPSDebug.h:220
WPSBox2f
WPSBox2< float > WPSBox2f
WPSBox2 of float.
Definition: libwps_internal.h:890
WPSEntry::end
long end() const
returns the end offset
Definition: WPSEntry.h:78
WPSBorder::Top
@ Top
Definition: libwps_internal.h:400
WPS8TableInternal::State::m_MCLDTypes
std::map< int, int > m_MCLDTypes
the MCLD type
Definition: WPS8Table.cpp:186
WPSCell.h
WPSPosition::m_anchorTo
AnchorTo m_anchorTo
anchor position
Definition: WPSPosition.h:241
WPS8Table
the main class to read/store table in a Pc MS Works document v5-8
Definition: WPS8Table.h:58
WPS8TableInternal::Cell
Internal: class to store a basic cell with borders.
Definition: WPS8Table.cpp:48
WPSTable::numCells
int numCells() const
returns the number of cell
Definition: WPSTable.h:172
WPS8TableInternal::Cell::sendContent
bool sendContent(WPSListenerPtr &) final
call when the content of a cell must be send
Definition: WPS8Table.cpp:84
WPSTable.h
WPS8Struct::FileData::m_recursData
std::vector< FileData > m_recursData
the list of children
Definition: WPS8Struct.h:145
WPS8Table::version
int version() const
returns the file version
Definition: WPS8Table.cpp:225
WPSContentListenerPtr
std::shared_ptr< WPSContentListener > WPSContentListenerPtr
shared pointer to WPSContentListener
Definition: libwps_internal.h:107
WPS8Struct::readBlockData
bool readBlockData(RVNGInputStreamPtr input, long endPos, FileData &dt, std::string &error)
tries to read a block zone as a list of Data
Definition: WPS8Struct.cpp:168
WPSBorder::BottomBit
@ BottomBit
Definition: libwps_internal.h:401
WPSBorder::Right
@ Right
Definition: libwps_internal.h:400
WPSPosition::m_wrapping
Wrapping m_wrapping
Wrapping.
Definition: WPSPosition.h:249
WPS8Parser::sendTextBox
void sendTextBox(WPSPosition const &pos, int strsid, librevenge::RVNGPropertyList frameExtras=librevenge::RVNGPropertyList())
creates a subdocument to send a textbox which correspond to the strsid text zone
Definition: WPS8.cpp:472
WPSContentListener
Definition: WPSContentListener.h:45
WPS8Table::WPS8Table
WPS8Table(WPS8Table const &orig)=delete
WPSColor::barycenter
static WPSColor barycenter(float alpha, WPSColor const &colA, float beta, WPSColor const &colB)
return alpha*colA+beta*colB
Definition: libwps_internal.cpp:386
WPSEntry
basic class to store an entry in a file This contained :
Definition: WPSEntry.h:39
WPSParser::getNameEntryMap
NameMultiMap & getNameEntryMap()
Definition: WPSParser.h:70
WPSEntry::name
std::string const & name() const
name of the entry
Definition: WPSEntry.h:147
WPSPosition::CharBaseLine
@ CharBaseLine
Definition: WPSPosition.h:43
WPSCellFormat::m_bordersList
std::vector< WPSBorder > m_bordersList
the cell border WPSBorder::Pos
Definition: WPSCell.h:272
WPS8Table::computePositions
void computePositions() const
computes the final position of all table: does nothing as table anchors seem always a char
Definition: WPS8Table.cpp:245
WPS8Parser::sendTextInCell
void sendTextInCell(int strsId, int cellId)
send the text of a cell to a listener (via WPS8Text)
Definition: WPS8.cpp:464
WPS8TableInternal::State::m_version
int m_version
the version
Definition: WPS8Table.cpp:180
WPSListenerPtr
std::shared_ptr< WPSListener > WPSListenerPtr
shared pointer to WPSListener
Definition: libwps_internal.h:105
WPSBorder::m_color
WPSColor m_color
the border color
Definition: libwps_internal.h:456
WPS8Struct.h
WPSTable
Definition: WPSTable.h:157
WPSBorder::Left
@ Left
Definition: libwps_internal.h:400
Vec2f
Vec2< float > Vec2f
Vec2 of float.
Definition: libwps_internal.h:704
WPS8Table::flushExtra
void flushExtra()
sends the data which have not been send to the listener.
Definition: WPS8Table.cpp:250
WPS8TableInternal::Table::m_id
int m_id
the table id
Definition: WPS8Table.cpp:141
WPS8TableInternal::operator<<
std::ostream & operator<<(std::ostream &o, Cell const &cell)
operator<< for a Cell
Definition: WPS8Table.cpp:105
Vec2< float >
WPSBorder::TopBit
@ TopBit
Definition: libwps_internal.h:401
WPS_DEBUG_MSG
#define WPS_DEBUG_MSG(M)
Definition: libwps_internal.h:134
libwps::readU32
uint32_t readU32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:76
WPS_FALLTHROUGH
#define WPS_FALLTHROUGH
fall through attributes
Definition: libwps_internal.h:82
WPSContentListener.h
WPS8TableInternal::Cell::Cell
Cell(WPS8Table &parser)
constructor
Definition: WPS8Table.cpp:50
WPS8TableInternal::State::m_tableMap
std::map< int, Table > m_tableMap
a map id -> table
Definition: WPS8Table.cpp:184
Vec2::x
T x() const
first element
Definition: libwps_internal.h:542
WPS8TableInternal::State::m_numPages
int m_numPages
the number page
Definition: WPS8Table.cpp:182
libwps::read32
int32_t read32(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:85
WPS8Table::sendTextInCell
void sendTextInCell(int strsId, int cellId)
Definition: WPS8Table.cpp:237
WPSBorder::Bottom
@ Bottom
Definition: libwps_internal.h:400
WPSCellFormat::VALIGN_BOTTOM
@ VALIGN_BOTTOM
Definition: WPSCell.h:50
WPSBorder::RightBit
@ RightBit
Definition: libwps_internal.h:401
WPS8Table::~WPS8Table
~WPS8Table()
destructor
Definition: WPS8Table.cpp:218
WPSEntry.h
WPS8TableInternal::Cell::send
bool send(WPSListenerPtr &listener) final
call when a cell must be send
Definition: WPS8Table.cpp:68
libwps::DebugFile::addNote
static void addNote(char const *)
Definition: WPSDebug.h:221
WPSEntry::begin
long begin() const
returns the begin offset
Definition: WPSEntry.h:73
WPS8Struct::FileData
A recursif structure which seems generally used to store complex memory structures in a file.
Definition: WPS8Struct.h:64
WPSEntry::type
std::string const & type() const
returns the type of the entry
Definition: WPSEntry.h:131
WPS8Table::m_asciiFile
libwps::DebugFile & m_asciiFile
the ascii file
Definition: WPS8Table.h:128
WPSBorder::m_style
Style m_style
the border style
Definition: libwps_internal.h:446
WPS8Parser
This class parses Works version 2000 through 8.
Definition: WPS8.h:50
WPSTable::add
void add(WPSCellPtr &cell)
add a new cells
Definition: WPSTable.cpp:105
WPS8TableInternal::Table
Internal: class to store a table: list of cells.
Definition: WPS8Table.cpp:130
WPSCellFormat::VALIGN_TOP
@ VALIGN_TOP
Definition: WPSCell.h:50
WPSEntry::length
long length() const
returns the length of the zone
Definition: WPSEntry.h:83
WPSTable::getCell
WPSCellPtr getCell(int id)
returns the i^th cell
Definition: WPSTable.cpp:110
WPS8Table::WPS8Table
WPS8Table(WPS8Parser &parser)
constructor
Definition: WPS8Table.cpp:210
WPS8Table::numPages
int numPages() const
returns the number page where we find a picture. In practice, 0/1
Definition: WPS8Table.cpp:232
WPSCell
a structure used to defined the cell position, and a format
Definition: WPSCell.h:291
libwps::DebugStream
Definition: WPSDebug.h:192
WPSParser::version
int version() const
Definition: WPSParser.h:56
WPSBorder
a border list
Definition: libwps_internal.h:395
WPS8TableInternal::Table::m_parsed
bool m_parsed
a bool to know if the table has been parsed
Definition: WPS8Table.cpp:144
WPS8Table::m_listener
WPSContentListenerPtr m_listener
the listener
Definition: WPS8Table.h:119
WPS8Table::readMCLD
bool readMCLD(RVNGInputStreamPtr input, WPSEntry const &entry)
reads a MCLD zone: a zone which stores the tables structures
Definition: WPS8Table.cpp:338
WPS8TableInternal::Table::~Table
~Table() final
destructor
Definition: WPS8Table.cpp:147
WPS8TableInternal::State
Internal: the state of a WPS8Table.
Definition: WPS8Table.cpp:166
WPSEntry::hasType
bool hasType(std::string const &tp) const
returns true if the type entry == type
Definition: WPSEntry.h:136
WPS8TableInternal::Cell::m_id
int m_id
the cell id
Definition: WPS8Table.cpp:93
WPS8Parser::getTableSTRSId
int getTableSTRSId(int tableId) const
retrieve the strsId corresponding to a table ( mainly for debug)
Definition: WPS8.cpp:531
WPS8Table::readStructures
bool readStructures(RVNGInputStreamPtr const &input)
finds all structures which correspond to a table
Definition: WPS8Table.cpp:317
WPSPosition.h
RVNGInputStreamPtr
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr
shared pointer to librevenge::RVNGInputStream
Definition: libwps_internal.h:87
WPSPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: WPSPosition.h:40
WPSBorder::LeftBit
@ LeftBit
Definition: libwps_internal.h:401
WPSBorder::m_type
Type m_type
the border repetition
Definition: libwps_internal.h:448
WPS8.h
WPSDebug.h
WPS8TableInternal::State::State
State()
constructor
Definition: WPS8Table.cpp:168
WPS8TableInternal::Cell::~Cell
~Cell() final
virtual destructor
Definition: WPS8Table.cpp:101
WPSBorder::None
@ None
Definition: libwps_internal.h:397
WPS8Table.h
WPSCellPtr
std::shared_ptr< WPSCell > WPSCellPtr
shared pointer to WPSCell
Definition: libwps_internal.h:100
libwps::read16
int16_t read16(librevenge::RVNGInputStream *input)
Definition: libwps_internal.cpp:71
WPS8Table::sendTable
bool sendTable(Vec2f const &siz, int tableId, int strsid, bool inTextBox=false)
tries to send a table corresponding to strsid with actual size siz
Definition: WPS8Table.cpp:266
libwps_internal.h
WPS8Table::m_state
std::shared_ptr< WPS8TableInternal::State > m_state
the state
Definition: WPS8Table.h:125
WPSColor
the class to store a color
Definition: libwps_internal.h:281
WPSBox2< float >
WPS8TableInternal::Table::Table
Table()
constructor
Definition: WPS8Table.cpp:132
WPS8Parser::send
void send(WPSEntry const &entry)
sends text corresponding to the entry to the listener (via WPS8Text)
Definition: WPS8.cpp:451
WPS8TableInternal::Cell::m_size
Vec2f m_size
frame size in inches
Definition: WPS8Table.cpp:97
WPSEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: WPSEntry.h:120
WPS8TableInternal
Internal: the structures of a WPS8Table.
Definition: WPS8Table.cpp:45
WPS8Table::ascii
libwps::DebugFile & ascii()
returns the debug file
Definition: WPS8Table.h:109
WPS8Table::m_mainParser
WPS8Parser & m_mainParser
the main parser
Definition: WPS8Table.h:122
WPS8TableInternal::Table::operator<<
friend std::ostream & operator<<(std::ostream &o, Table const &table)
operator<<
Definition: WPS8Table.cpp:152
WPS8TableInternal::State::initTypeMaps
void initTypeMaps()
initialize the type map
Definition: WPS8Table.cpp:189
libwps::DebugFile
Definition: WPSDebug.h:208
Vec2::y
T y() const
second element
Definition: libwps_internal.h:547
WPS8TableInternal::Cell::m_strsId
int m_strsId
the strsId
Definition: WPS8Table.cpp:95
WPSColor::black
static WPSColor black()
return the back color
Definition: libwps_internal.h:306
WPS8TableInternal::Cell::m_bordersSep
float m_bordersSep[4]
border text separator T,L,R,B ( checkme, not sure )
Definition: WPS8Table.cpp:99
WPS8Table::operator=
WPS8Table & operator=(WPS8Table const &orig)=delete
WPSPosition::WDynamic
@ WDynamic
Definition: WPSPosition.h:45