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 
108  bool readEndHeader();
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:299
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MWAWField::Time
Definition: libmwaw_internal.hxx:401
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:549
MsWksSSParserInternal::Spreadsheet::m_widthCols
std::vector< int > m_widthCols
the column size in pixels(?)
Definition: MsWksSSParser.cxx:129
MWAWSpreadsheetParser
virtual class which defines the ancestor of all spreadsheet zone parser
Definition: MWAWParser.hxx:282
MsWksSSParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: MsWksSSParser.cxx:170
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:861
MWAWCell::F_BOOLEAN
Definition: MWAWCell.hxx:56
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:68
MWAWEntry::setName
void setName(std::string const &nam)
sets the name of the entry
Definition: MWAWEntry.hxx:147
MsWksSSParserInternal::Spreadsheet::m_name
std::string m_name
the spreadsheet name
Definition: MsWksSSParser.cxx:137
MWAWCellContent::m_textEntry
MWAWEntry m_textEntry
the cell string
Definition: MWAWCell.hxx:474
MWAWDocument::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:104
MsWksSSParser::~MsWksSSParser
~MsWksSSParser() final
destructor
Definition: MsWksSSParser.cxx:248
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:840
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:443
MWAWCell::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:186
MWAWCell::F_NUMBER_DECIMAL
Definition: MWAWCell.hxx:58
MsWksGraph.hxx
MWAWCell::setHAlignment
void setHAlignment(HorizontalAlignment align)
sets the horizontal alignment
Definition: MWAWCell.hxx:278
MsWksSSParserInternal::Spreadsheet::getRightBottomPosition
MWAWVec2i getRightBottomPosition() const
returns the last Right Bottom cell position
Definition: MsWksSSParser.cxx:140
MsWksSSParser::createDocument
void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MsWksSSParser.cxx:362
MWAWFont::boldBit
Definition: MWAWFont.hxx:190
MWAWCell::F_NUMBER_PERCENT
Definition: MWAWCell.hxx:58
MWAWCellContent::isValueSet
bool isValueSet() const
returns true if the value has been setted
Definition: MWAWCell.hxx:449
MsWksSSParserInternal::operator<<
std::ostream & operator<<(std::ostream &o, Cell const &cell)
operator<<
Definition: MsWksSSParser.cxx:91
MWAWFont::setColor
void setColor(MWAWColor color)
sets the font color
Definition: MWAWFont.hxx:341
MWAWCell::F_UNKNOWN
Definition: MWAWCell.hxx:56
MWAWEntry.hxx
MsWksSSParser.hxx
MWAWCellContent::C_NONE
Definition: MWAWCell.hxx:419
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:91
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:563
MsWksSSParserInternal::Spreadsheet::m_cells
std::vector< Cell > m_cells
the list of not empty cells
Definition: MsWksSSParser.cxx:131
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWCell::F_NUMBER_SCIENTIFIC
Definition: MWAWCell.hxx:58
MWAWPrinter.hxx
MsWksSSParserInternal::Spreadsheet
the spreadsheet of a of a MsWksSSParser
Definition: MsWksSSParser.cxx:100
MsWksSSParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MsWksSSParser.cxx:1214
MsWksSSParserInternal::Cell::m_noteId
int m_noteId
the note id
Definition: MsWksSSParser.cxx:87
MWAWCell::setFormat
void setFormat(Format const &format)
set the cell format
Definition: MWAWCell.hxx:239
MWAWFont::Line::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:85
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
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:41
MWAWCell::setFont
void setFont(MWAWFont const &font, bool isDefault=false)
sets the fonts
Definition: MWAWCell.hxx:255
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MWAWFont::embossBit
Definition: MWAWFont.hxx:190
MWAWCell.hxx
MWAWField::Date
Definition: libmwaw_internal.hxx:401
MsWksSSParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: MsWksSSParser.cxx:201
MWAWSubDocument.hxx
MsWksSSParserInternal::SubDocument
Internal: the subdocument of a MsWksSSParser.
Definition: MsWksSSParser.cxx:178
MsWksSSParserInternal::Cell::m_content
MWAWCellContent m_content
the cell content
Definition: MsWksSSParser.cxx:84
MWAWParser::getSpreadsheetListener
MWAWSpreadsheetListenerPtr & getSpreadsheetListener()
returns the spreadsheet listener
Definition: MWAWParser.hxx:140
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:267
MWAWSpreadsheetListenerPtr
std::shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:561
MWAWFont::shadowBit
Definition: MWAWFont.hxx:191
MWAWSpreadsheetListener
This class contents the main functions needed to create a spreadsheet processing Document.
Definition: MWAWSpreadsheetListener.hxx:65
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MWAWParser::getPageSpan
const MWAWPageSpan & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
MsWksSSParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: MsWksSSParser.cxx:217
MWAWEntry::setEnd
void setEnd(long off)
sets the end offset
Definition: MWAWEntry.hxx:76
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:66
MsWksSSParserInternal::Cell::operator=
Cell & operator=(Cell const &)=default
MWAWParser::asciiName
const std::string & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MWAWCellContent::m_value
double m_value
the cell value
Definition: MWAWCell.hxx:470
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:559
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:92
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:170
MWAWOLEParser.hxx
MWAWVec2< int >
MWAWCellContent
small class use to define a sheet cell content
Definition: MWAWCell.hxx:378
MsWksSSParser::createZones
bool createZones()
finds the different objects zones
Definition: MsWksSSParser.cxx:388
libmwaw::ParseException
Definition: libmwaw_internal.hxx:143
MWAWDebug.hxx
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:82
MsWksSSParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: MsWksSSParser.cxx:188
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:168
MsWksSSParserInternal::SubDocument::SubDocument
SubDocument(MsWksSSParser &pars, MWAWInputStreamPtr const &input, int zoneId)
Definition: MsWksSSParser.cxx:181
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWField::PageNumber
Definition: libmwaw_internal.hxx:401
MsWksSSParser
the main class to read a Microsoft Works spreadsheet file
Definition: MsWksSSParser.hxx:65
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:114
MsWksSSParserInternal::Spreadsheet::m_listPageBreaks
std::vector< int > m_listPageBreaks
the list of page break
Definition: MsWksSSParser.cxx:133
MsWksSSParserInternal::Cell
a cell of a MsWksSSParser
Definition: MsWksSSParser.cxx:61
MWAWCellContent::C_FORMULA
Definition: MWAWCell.hxx:419
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
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:87
MsWksSSParser::readSSheetZone
bool readSSheetZone()
try to read the spreadsheet data zone
Definition: MsWksSSParser.cxx:453
MWAWCell::F_NUMBER
Definition: MWAWCell.hxx:56
MWAWCell::F_TIME
Definition: MWAWCell.hxx:56
MsWksSSParserInternal
Internal: the structures of a MsWksSSParser.
Definition: MsWksSSParser.cxx:58
MWAWFont::italicBit
Definition: MWAWFont.hxx:190
MWAWCell::F_NUMBER_CURRENCY
Definition: MWAWCell.hxx:58
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MsWksDocument.hxx
MWAWCellContent::C_TEXT
Definition: MWAWCell.hxx:419
MsWksSSParserInternal::State::m_spreadsheet
Spreadsheet m_spreadsheet
the spreadsheet
Definition: MsWksSSParser.cxx:169
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
MsWksSSParserInternal::Cell::~Cell
~Cell() final
destructor
Definition: MsWksSSParser.cxx:152
MsWks3Text.hxx
MWAWCell::hasBorders
bool hasBorders() const
return true if the cell has some border
Definition: MWAWCell.hxx:295
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:379
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:98
MsWksDocument::Z_MAIN
Definition: MsWksDocument.hxx:78
MsWksSSParser::readEndHeader
bool readEndHeader()
reads the end of the header
MWAWSpreadsheetListener.hxx
MsWksSSParserInternal::Cell::isEmpty
bool isEmpty() const
returns true if the cell do contain any content
Definition: MsWksSSParser.cxx:75
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:65
MsWksSSParserInternal::State::State
State()
constructor
Definition: MsWksSSParser.cxx:160
MsWksSSParser::parse
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
virtual function used to parse the input
Definition: MsWksSSParser.cxx:266
MWAWCellContent::empty
bool empty() const
returns true if the cell has no content
Definition: MWAWCell.hxx:435
MsWksSSParser::sendSpreadsheet
bool sendSpreadsheet()
try to send the main spreadsheet
Definition: MsWksSSParser.cxx:1153
MsWksSSParser::init
void init()
inits all internal variables
Definition: MsWksSSParser.cxx:252
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:551
MWAWFont.hxx
librevenge
Definition: MWAWDocument.hxx:56
MsWksSSParserInternal::Spreadsheet::m_font
MWAWFont m_font
the default font
Definition: MsWksSSParser.cxx:127
MWAWCell::HALIGN_LEFT
Definition: MWAWCell.hxx:127
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:211
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MsWksSSParserInternal::Spreadsheet::m_idNoteMap
std::map< int, MWAWEntry > m_idNoteMap
a map id->note content
Definition: MsWksSSParser.cxx:135
MsWksSSParserInternal::State::m_pageLength
int m_pageLength
the page length in point (if known)
Definition: MsWksSSParser.cxx:173
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
MWAWField::Title
Definition: libmwaw_internal.hxx:401
MWAWCellContent::m_contentType
Type m_contentType
the content type ( by default unknown )
Definition: MWAWCell.hxx:468
MWAWCellContent::C_NUMBER
Definition: MWAWCell.hxx:419
MWAWCell::HALIGN_RIGHT
Definition: MWAWCell.hxx:127
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:836
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:198
MsWksSSParser::MsWksSSParser
MsWksSSParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: MsWksSSParser.cxx:231
MWAWCellContent::C_UNKNOWN
Definition: MWAWCell.hxx:419
MWAWCell::HALIGN_CENTER
Definition: MWAWCell.hxx:127
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:158
MWAWCell::F_TEXT
Definition: MWAWCell.hxx:56

Generated on Wed Jul 24 2024 03:31:53 for libmwaw by doxygen 1.8.16