MsWksSSParser.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 #ifndef MS_WKS_SS_PARSER
35 # define MS_WKS_SS_PARSER
36 
37 #include <list>
38 #include <string>
39 #include <vector>
40 
41 #include "MWAWCell.hxx"
42 #include "MWAWDebug.hxx"
43 #include "MWAWEntry.hxx"
44 #include "MWAWInputStream.hxx"
45 
46 #include "MsWksDocument.hxx"
47 
48 #include "MWAWParser.hxx"
49 
50 namespace MsWksSSParserInternal
51 {
52 struct State;
53 
54 class Cell;
55 class SubDocument;
56 }
57 
58 class MsWksDocument;
59 
66 {
68 public:
70  MsWksSSParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
72  ~MsWksSSParser() final;
73 
75  bool checkHeader(MWAWHeader *header, bool strict=false) final;
76 
77  // the main parse function
78  void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
79 
80 protected:
82  void init();
83 
85  void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface);
86 
88  bool createZones();
89 
90  //
91  // intermediate level
92  //
93 
95  bool readSSheetZone();
96 
98  void sendNote(int id);
99 
101  bool sendSpreadsheet();
102 
103  //
104  // low level
105  //
106 
110  bool readCell(int sz, MWAWVec2i const &cellPos, MsWksSSParserInternal::Cell &cell);
111 
112 protected:
113  //
114  // data
115  //
117  std::shared_ptr<MsWksSSParserInternal::State> m_state;
118 
120  std::vector<MWAWEntry> m_listZones;
121 
123  std::shared_ptr<MsWksDocument> m_document;
124 };
125 #endif
126 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MsWksSSParser::sendNote
void sendNote(int id)
try to send a note
Definition: MsWksSSParser.cxx:300
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MWAWField::Time
@ Time
Definition: libmwaw_internal.hxx:401
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
MsWksSSParserInternal::Spreadsheet::m_widthCols
std::vector< int > m_widthCols
the column size in pixels(?)
Definition: MsWksSSParser.cxx:130
MWAWSpreadsheetParser
virtual class which defines the ancestor of all spreadsheet zone parser
Definition: MWAWParser.hxx:283
MsWksSSParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: MsWksSSParser.cxx:171
MsWksDocument::Zone
a zone of a MsWksDocument ( main, header, footer )
Definition: MsWksDocument.hxx:80
MsWksSSParser::readCell
bool readCell(int sz, MWAWVec2i const &cellPos, MsWksSSParserInternal::Cell &cell)
reads a cell content data
Definition: MsWksSSParser.cxx:862
MWAWCell::F_BOOLEAN
@ F_BOOLEAN
Definition: MWAWCell.hxx:56
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:69
MWAWEntry::setName
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:148
MsWksSSParserInternal::Spreadsheet::m_name
std::string m_name
the spreadsheet name
Definition: MsWksSSParser.cxx:138
MWAWCellContent::m_textEntry
MWAWEntry m_textEntry
the cell string
Definition: MWAWCell.hxx:489
MWAWDocument::MWAW_K_SPREADSHEET
@ MWAW_K_SPREADSHEET
spreadsheet
Definition: MWAWDocument.hxx:86
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MsWksSSParserInternal::Spreadsheet::Spreadsheet
Spreadsheet()
constructor
Definition: MsWksSSParser.cxx:105
MsWksSSParser::~MsWksSSParser
~MsWksSSParser() final
destructor
Definition: MsWksSSParser.cxx:249
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MWAWCellContent::setValue
void setValue(double value)
sets the double value
Definition: MWAWCell.hxx:458
MWAWCell::F_DATE
@ F_DATE
Definition: MWAWCell.hxx:56
MWAWCell::setPosition
void setPosition(MWAWVec2i posi)
set the cell positions : 0,0 -> A1, 0,1 -> A2
Definition: MWAWCell.hxx:189
MWAWCell::F_NUMBER_DECIMAL
@ F_NUMBER_DECIMAL
Definition: MWAWCell.hxx:58
MsWksGraph.hxx
MWAWCell::setHAlignment
void setHAlignment(HorizontalAlignment align)
sets the horizontal alignment
Definition: MWAWCell.hxx:281
MsWksSSParserInternal::Spreadsheet::getRightBottomPosition
MWAWVec2i getRightBottomPosition() const
returns the last Right Bottom cell position
Definition: MsWksSSParser.cxx:141
MsWksSSParser::createDocument
void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MsWksSSParser.cxx:363
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
MWAWCell::F_NUMBER_PERCENT
@ F_NUMBER_PERCENT
Definition: MWAWCell.hxx:58
MWAWCellContent::isValueSet
bool isValueSet() const
returns true if the value has been setted
Definition: MWAWCell.hxx:464
MsWksSSParserInternal::operator<<
std::ostream & operator<<(std::ostream &o, Cell const &cell)
operator<<
Definition: MsWksSSParser.cxx:92
MWAWFont::setColor
void setColor(MWAWColor color)
sets the font color
Definition: MWAWFont.hxx:341
MsWksSSParserInternal::Cell::operator=
Cell & operator=(Cell &&)=default
MWAWCell::F_UNKNOWN
@ F_UNKNOWN
Definition: MWAWCell.hxx:56
MWAWEntry.hxx
MsWksSSParser.hxx
MWAWCellContent::C_NONE
@ C_NONE
Definition: MWAWCell.hxx:433
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MsWksSSParserInternal::Cell::operator<<
friend std::ostream & operator<<(std::ostream &o, Cell const &cell)
operator<<
Definition: MsWksSSParser.cxx:92
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:565
MsWksSSParserInternal::Spreadsheet::m_cells
std::vector< Cell > m_cells
the list of not empty cells
Definition: MsWksSSParser.cxx:132
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWCell::F_NUMBER_SCIENTIFIC
@ F_NUMBER_SCIENTIFIC
Definition: MWAWCell.hxx:58
MWAWPrinter.hxx
MsWksSSParserInternal::Spreadsheet
the spreadsheet of a of a MsWksSSParser
Definition: MsWksSSParser.cxx:102
MsWksSSParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MsWksSSParser.cxx:1215
MsWksSSParserInternal::Cell::m_noteId
int m_noteId
the note id
Definition: MsWksSSParser.cxx:88
MWAWCell::setFormat
void setFormat(Format const &format)
set the cell format
Definition: MWAWCell.hxx:242
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
MWAWOLEParser
a class used to parse some basic oles Tries to read the different ole parts and stores their contents...
Definition: MWAWOLEParser.hxx:86
MWAW_FALLTHROUGH
#define MWAW_FALLTHROUGH
Definition: libmwaw_internal.hxx:118
MWAWParser::resetSpreadsheetListener
void resetSpreadsheetListener()
resets the listener
Definition: MWAWParser.cxx:152
MWAWCell::F_NUMBER_GENERIC
@ F_NUMBER_GENERIC
Definition: MWAWCell.hxx:58
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWSubDocument
abstract class used to store a subdocument (with a comparison function)
Definition: MWAWSubDocument.hxx:42
MWAWCell::Format::m_DTFormat
std::string m_DTFormat
a date/time format ( using a subset of strftime format )
Definition: MWAWCell.hxx:113
MWAWCell::setFont
void setFont(MWAWFont const &font, bool isDefault=false)
sets the fonts
Definition: MWAWCell.hxx:258
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MWAWFont::embossBit
@ embossBit
Definition: MWAWFont.hxx:190
MWAWCell.hxx
Defines MWAWCell (cell content and format)
MWAWField::Date
@ Date
Definition: libmwaw_internal.hxx:401
MsWksSSParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: MsWksSSParser.cxx:202
MWAWCell::Format::m_digits
int m_digits
the number of digits
Definition: MWAWCell.hxx:99
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MWAWSubDocument.hxx
MsWksSSParserInternal::SubDocument
Internal: the subdocument of a MsWksSSParser.
Definition: MsWksSSParser.cxx:180
MsWksSSParserInternal::Cell::m_content
MWAWCellContent m_content
the cell content
Definition: MsWksSSParser.cxx:85
MWAWParser::getSpreadsheetListener
MWAWSpreadsheetListenerPtr & getSpreadsheetListener()
returns the spreadsheet listener
Definition: MWAWParser.hxx:140
MWAWCell::Format::m_numberFormat
NumberType m_numberFormat
the numeric format
Definition: MWAWCell.hxx:97
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWSubDocument::m_input
std::shared_ptr< MWAWInputStream > m_input
the input
Definition: MWAWSubDocument.hxx:77
MWAWCell::setProtected
void setProtected(bool fl)
sets the cell's protected flag
Definition: MWAWCell.hxx:270
MWAWSpreadsheetListenerPtr
std::shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:563
MWAWFont::shadowBit
@ shadowBit
Definition: MWAWFont.hxx:191
MWAWSpreadsheetListener
This class contents the main functions needed to create a spreadsheet processing Document.
Definition: MWAWSpreadsheetListener.hxx:66
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MsWksSSParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: MsWksSSParser.cxx:218
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:77
MWAWCell::Format
a structure uses to define the format of a cell content
Definition: MWAWCell.hxx:60
MWAWBorder
a border
Definition: libmwaw_internal.hxx:333
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
MsWksSSParserInternal::Cell::operator=
Cell & operator=(Cell const &)=default
MWAWCellContent::m_value
double m_value
the cell value
Definition: MWAWCell.hxx:485
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
MsWksSSParser::m_state
std::shared_ptr< MsWksSSParserInternal::State > m_state
the state
Definition: MsWksSSParser.hxx:117
MsWksSSParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: MsWksSSParser.cxx:171
MWAWOLEParser.hxx
MWAWVec2< int >
MWAWCellContent
small class use to define a sheet cell content
Definition: MWAWCell.hxx:394
MsWksSSParser::createZones
bool createZones()
finds the different objects zones
Definition: MsWksSSParser.cxx:389
libmwaw::ParseException
Definition: libmwaw_internal.hxx:144
MWAWDebug.hxx
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:72
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
MsWksSSParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: MsWksSSParser.cxx:189
MsWksSSParser::m_document
std::shared_ptr< MsWksDocument > m_document
the actual zone
Definition: MsWksSSParser.hxx:123
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:169
MsWksSSParserInternal::SubDocument::SubDocument
SubDocument(MsWksSSParser &pars, MWAWInputStreamPtr const &input, int zoneId)
Definition: MsWksSSParser.cxx:182
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWField::PageNumber
@ PageNumber
Definition: libmwaw_internal.hxx:401
MsWksSSParser
the main class to read a Microsoft Works spreadsheet file
Definition: MsWksSSParser.hxx:66
MsWksSSParserInternal::Spreadsheet::convertInPoint
std::vector< float > convertInPoint(std::vector< int > const &list, float defSize) const
convert the m_widthCols in a vector of of point size
Definition: MsWksSSParser.cxx:115
MsWksSSParserInternal::Spreadsheet::m_listPageBreaks
std::vector< int > m_listPageBreaks
the list of page break
Definition: MsWksSSParser.cxx:134
MsWksSSParserInternal::Cell
a cell of a MsWksSSParser
Definition: MsWksSSParser.cxx:62
MWAWCellContent::C_FORMULA
@ C_FORMULA
Definition: MWAWCell.hxx:433
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWParser::setSpreadsheetListener
void setSpreadsheetListener(MWAWSpreadsheetListenerPtr &listener)
sets the spreadsheet listener
Definition: MWAWParser.cxx:147
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
MsWksSSParser::readSSheetZone
bool readSSheetZone()
try to read the spreadsheet data zone
Definition: MsWksSSParser.cxx:454
MWAWCell::F_NUMBER
@ F_NUMBER
Definition: MWAWCell.hxx:56
MsWksSSParserInternal::Cell::Cell
Cell(Cell const &)=default
MWAWCell::F_TIME
@ F_TIME
Definition: MWAWCell.hxx:56
MsWksSSParserInternal
Internal: the structures of a MsWksSSParser.
Definition: MsWksSSParser.cxx:59
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
MWAWCell::F_NUMBER_CURRENCY
@ F_NUMBER_CURRENCY
Definition: MWAWCell.hxx:58
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MsWksDocument.hxx
MWAWCellContent::C_TEXT
@ C_TEXT
Definition: MWAWCell.hxx:433
MWAWCell::Format::m_format
FormatType m_format
the cell format : by default unknown
Definition: MWAWCell.hxx:95
MsWksSSParserInternal::State::m_spreadsheet
Spreadsheet m_spreadsheet
the spreadsheet
Definition: MsWksSSParser.cxx:170
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
MsWksSSParserInternal::Cell::~Cell
~Cell() final
destructor
Definition: MsWksSSParser.cxx:153
MsWks3Text.hxx
MWAWCell::hasBorders
bool hasBorders() const
return true if the cell has some border
Definition: MWAWCell.hxx:308
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWCell::setBorders
void setBorders(int wh, MWAWBorder const &border)
sets the cell border: wh=libmwaw::LeftBit|...
Definition: MWAWCell.cxx:382
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:99
MsWksDocument::Z_MAIN
@ Z_MAIN
Definition: MsWksDocument.hxx:78
MsWksSSParser::readEndHeader
bool readEndHeader()
reads the end of the header
MWAWSpreadsheetListener.hxx
Defines MWAWSpreadsheetListener: the libmwaw spreadsheet processor listener.
MsWksSSParserInternal::Cell::isEmpty
bool isEmpty() const
returns true if the cell do contain any content
Definition: MsWksSSParser.cxx:76
MsWksSSParser::m_listZones
std::vector< MWAWEntry > m_listZones
the list of different Zones
Definition: MsWksSSParser.hxx:120
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
MsWksSSParserInternal::State::State
State()
constructor
Definition: MsWksSSParser.cxx:161
MsWksSSParser::parse
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
virtual function used to parse the input
Definition: MsWksSSParser.cxx:267
MWAWCellContent::empty
bool empty() const
returns true if the cell has no content
Definition: MWAWCell.hxx:450
MsWksSSParser::sendSpreadsheet
bool sendSpreadsheet()
try to send the main spreadsheet
Definition: MsWksSSParser.cxx:1154
MsWksSSParser::init
void init()
inits all internal variables
Definition: MsWksSSParser.cxx:253
MWAWInputStream.hxx
MsWksSSParserInternal::Cell::Cell
Cell()
constructor
Definition: MsWksSSParser.cxx:65
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
MWAWFont.hxx
librevenge
Definition: MWAWDocument.hxx:57
MsWksSSParserInternal::Spreadsheet::m_font
MWAWFont m_font
the default font
Definition: MsWksSSParser.cxx:128
MWAWCell::HALIGN_LEFT
@ HALIGN_LEFT
Definition: MWAWCell.hxx:128
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:213
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
MsWksSSParserInternal::Spreadsheet::m_idNoteMap
std::map< int, MWAWEntry > m_idNoteMap
a map id->note content
Definition: MsWksSSParser.cxx:136
MsWksSSParserInternal::State::m_pageLength
int m_pageLength
the page length in point (if known)
Definition: MsWksSSParser.cxx:174
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:53
MWAWField::Title
@ Title
Definition: libmwaw_internal.hxx:401
MWAWCellContent::m_contentType
Type m_contentType
the content type ( by default unknown )
Definition: MWAWCell.hxx:483
MWAWCellContent::C_NUMBER
@ C_NUMBER
Definition: MWAWCell.hxx:433
MWAWCell::HALIGN_RIGHT
@ HALIGN_RIGHT
Definition: MWAWCell.hxx:128
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:838
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWParser.hxx
MWAWFont::setUnderlineStyle
void setUnderlineStyle(Line::Style style=Line::None, bool doReset=true)
sets the underline style ( by default, we also reset the style)
Definition: MWAWFont.hxx:466
MsWksSSParserInternal::SubDocument::m_id
int m_id
the subdocument id
Definition: MsWksSSParser.cxx:199
MsWksSSParser::MsWksSSParser
MsWksSSParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: MsWksSSParser.cxx:232
MWAWCellContent::C_UNKNOWN
@ C_UNKNOWN
Definition: MWAWCell.hxx:433
MWAWCell::Format::m_thousandHasSeparator
bool m_thousandHasSeparator
true if we must separate the thousand
Definition: MWAWCell.hxx:107
MWAWCell::HALIGN_CENTER
@ HALIGN_CENTER
Definition: MWAWCell.hxx:128
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325
MsWksSSParserInternal::State
Internal: the state of a MsWksSSParser.
Definition: MsWksSSParser.cxx:159
MWAWCell::F_TEXT
@ F_TEXT
Definition: MWAWCell.hxx:56

Generated on Fri Sep 18 2020 18:14:52 for libmwaw by doxygen 1.8.20