JazzSSParser.hxx Source File documentation

JazzSSParser.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 * Parser to convert spreadsheet Jazz document and some database
36 *
37 */
38 #ifndef JAZZ_SS_PARSER
39 # define JAZZ_SS_PARSER
40
41 #include <string>
42 #include <vector>
43
44 #include "MWAWCell.hxx"
45 #include "MWAWDebug.hxx"
46
47 #include "MWAWParser.hxx"
48
49 namespace JazzSSParserInternal
50 {
51 struct State;
52
53 class SubDocument;
54 }
55
66 class JazzSSParser final : public MWAWSpreadsheetParser
67 {
68 friend class JazzSSParserInternal::SubDocument;
69 public:
71 JazzSSParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
73 ~JazzSSParser() final;
74
76 bool checkHeader(MWAWHeader *header, bool strict=false) final;
77
79 void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final;
80
81 protected:
83 void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface);
84
86 bool createZones();
87
89 bool sendSpreadsheet();
90
91 //
92 // low level
93 //
95
97 bool readZone11(long endPos);
99 bool readCell(int id, long endPos);
101 bool readSheetSize(long endPos);
103 bool readDocument(long endPos);
104
105 /* reads a cell */
106 bool readCell(MWAWVec2i actPos, MWAWCellContent::FormulaInstruction &instr);
107 /* reads a formula */
108 bool readFormula(long endPos, MWAWVec2i const &pos,
109 std::vector<MWAWCellContent::FormulaInstruction> &formula,
110 std::string &error);
111
112 protected:
113
114 //
115 // data
116 //
117
119 std::shared_ptr<JazzSSParserInternal::State> m_state;
120 };
121 #endif
122 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
JazzSSParserInternal::State
Internal: the state of a JazzSSParser.
Definition: JazzSSParser.cxx:80
MWAWCellContent::FormulaInstruction::F_CellList
@ F_CellList
Definition: MWAWCell.hxx:398
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
MWAWSpreadsheetParser
virtual class which defines the ancestor of all spreadsheet zone parser
Definition: MWAWParser.hxx:283
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:150
JazzSSParserInternal::Cell::m_content
MWAWCellContent m_content
the cell content
Definition: JazzSSParser.cxx:72
JazzSSParserInternal::SubDocument::m_multiParser
JazzSSParser & m_multiParser
the main parser
Definition: JazzSSParser.cxx:124
MWAWCellContent::m_textEntry
MWAWEntry m_textEntry
the cell string
Definition: MWAWCell.hxx:489
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
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
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
JazzSSParser::readFormula
bool readFormula(long endPos, MWAWVec2i const &pos, std::vector< MWAWCellContent::FormulaInstruction > &formula, std::string &error)
Definition: JazzSSParser.cxx:887
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
MWAWCell::setHAlignment
void setHAlignment(HorizontalAlignment align)
sets the horizontal alignment
Definition: MWAWCell.hxx:281
JazzSSParserInternal::State::State
State()
constructor
Definition: JazzSSParser.cxx:82
MWAWCellContent::FormulaInstruction::F_Operator
@ F_Operator
Definition: MWAWCell.hxx:398
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
MWAWCell::F_NUMBER_PERCENT
@ F_NUMBER_PERCENT
Definition: MWAWCell.hxx:58
JazzSSParser::readSheetSize
bool readSheetSize(long endPos)
reads sheet size
Definition: JazzSSParser.cxx:750
JazzSSParser::sendSpreadsheet
bool sendSpreadsheet()
sends the spreadsheet
Definition: JazzSSParser.cxx:1139
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition: MWAWCell.hxx:397
JazzSSParser::createDocument
void createDocument(librevenge::RVNGSpreadsheetInterface *documentInterface)
creates the listener which will be associated to the document
Definition: JazzSSParser.cxx:196
MWAWCellContent::C_NONE
@ C_NONE
Definition: MWAWCell.hxx:433
MWAWFontConverter.hxx
JazzSSParserInternal::SubDocument::SubDocument
SubDocument(JazzSSParser &parser, MWAWInputStreamPtr const &input, MWAWEntry const &entry)
Definition: JazzSSParser.cxx:107
MWAWCell::F_NUMBER_SCIENTIFIC
@ F_NUMBER_SCIENTIFIC
Definition: MWAWCell.hxx:58
MWAWCellContent::FormulaInstruction::F_Function
@ F_Function
Definition: MWAWCell.hxx:398
MWAWCell::setFormat
void setFormat(Format const &format)
set the cell format
Definition: MWAWCell.hxx:242
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
MWAWParser::resetSpreadsheetListener
void resetSpreadsheetListener()
resets the listener
Definition: MWAWParser.cxx:152
JazzSSParser::readCell
bool readCell(int id, long endPos)
reads a cell content data
Definition: JazzSSParser.cxx:477
JazzSSParserInternal::Cell::Cell
Cell()
constructor
Definition: JazzSSParser.cxx:63
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
JazzSSParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: JazzSSParser.cxx:139
MWAWCellContent::FormulaInstruction::m_content
std::string m_content
the content ( if type == F_Operator or type = F_Function or type==F_Text)
Definition: MWAWCell.hxx:417
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
JazzSSParserInternal::Cell
Internal: the cell of a JazzSSParser.
Definition: JazzSSParser.cxx:61
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
JazzSSParser::~JazzSSParser
~JazzSSParser() final
destructor
Definition: JazzSSParser.cxx:161
MWAWCell.hxx
Defines MWAWCell (cell content and format)
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
JazzSSParser.hxx
MWAWCellContent::FormulaInstruction::F_Text
@ F_Text
Definition: MWAWCell.hxx:398
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
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
JazzSSParserInternal::State::m_dimensions
MWAWVec2i m_dimensions
the sheet dimensions
Definition: JazzSSParser.cxx:93
MWAWCellContent::m_formula
std::vector< FormulaInstruction > m_formula
the formula list of instruction
Definition: MWAWCell.hxx:491
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
MWAWParagraph.hxx
MWAWRSRCParser.hxx
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
MWAWPosition.hxx
JazzSSParserInternal::SubDocument
Internal: the subdocument of a JazzSSParserInternal.
Definition: JazzSSParser.cxx:105
JazzSSParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: JazzSSParser.cxx:1086
MWAWCellContent::FormulaInstruction::m_type
Type m_type
the type
Definition: MWAWCell.hxx:415
JazzSSParser::readZone11
bool readZone11(long endPos)
reads a query/name/range... data (zone 11)
Definition: JazzSSParser.cxx:319
JazzSSParserInternal
Internal: the structures of a JazzSSParser.
Definition: JazzSSParser.cxx:59
MWAWCell::Format
a structure uses to define the format of a cell content
Definition: MWAWCell.hxx:60
JazzSSParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: JazzSSParser.cxx:127
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
JazzSSParser::m_state
std::shared_ptr< JazzSSParserInternal::State > m_state
the state
Definition: JazzSSParser.hxx:119
MWAWCell::m_font
MWAWFont m_font
the cell font
Definition: MWAWCell.hxx:370
JazzSSParser::readDocument
bool readDocument(long endPos)
read the basic document zones (zone 15): selection, columns' width, default font, preferences....
Definition: JazzSSParser.cxx:371
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
JazzSSParser
the main class to read a Jazz spreadsheet v1 (Lotus) document and some databases.
Definition: JazzSSParser.hxx:67
MWAWVec2< int >
MWAWCellContent
small class use to define a sheet cell content
Definition: MWAWCell.hxx:394
libmwaw::ParseException
Definition: libmwaw_internal.hxx:144
JazzSSParserInternal::Functions
Definition: JazzSSParser.cxx:780
MWAWDebug.hxx
MWAWFont::getDebugString
std::string getDebugString(std::shared_ptr< MWAWFontConverter > &converter) const
returns a string which can be used for debugging
Definition: MWAWFont.cxx:181
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
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
JazzSSParserInternal::State::m_font
MWAWFont m_font
the cell default font
Definition: JazzSSParser.cxx:95
JazzSSParserInternal::State::m_widths
std::vector< float > m_widths
the columns width
Definition: JazzSSParser.cxx:97
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:264
MWAWCellContent::FormulaInstruction::m_longValue
double m_longValue
value ( if type==F_Long )
Definition: MWAWCell.hxx:419
JazzSSParserInternal::Cell::Cell
Cell(Cell const &)=default
MWAWCellContent::FormulaInstruction::m_doubleValue
double m_doubleValue
value ( if type==F_Double )
Definition: MWAWCell.hxx:421
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
MWAWCellContent::FormulaInstruction::F_Cell
@ F_Cell
Definition: MWAWCell.hxx:398
JazzSSParserInternal::State::m_posToCells
std::map< MWAWVec2i, Cell > m_posToCells
map of cells sorted by columns
Definition: JazzSSParser.cxx:99
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWCellContent::FormulaInstruction::F_Long
@ F_Long
Definition: MWAWCell.hxx:398
MWAWFont::setSize
void setSize(float sz, bool isRelative=false)
sets the font size
Definition: MWAWFont.hxx:275
MWAWCell::F_NUMBER
@ F_NUMBER
Definition: MWAWCell.hxx:56
JazzSSParserInternal::Functions::m_arity
int m_arity
Definition: JazzSSParser.cxx:782
MWAWBox2i
MWAWBox2< int > MWAWBox2i
MWAWBox2 of int.
Definition: libmwaw_internal.hxx:1191
MWAWCell::F_TIME
@ F_TIME
Definition: MWAWCell.hxx:56
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
MWAWCell::F_NUMBER_CURRENCY
@ F_NUMBER_CURRENCY
Definition: MWAWCell.hxx:58
JazzSSParserInternal::State::m_isDatabase
bool m_isDatabase
true if the file is a database file
Definition: JazzSSParser.cxx:91
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
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
MWAWCellContent::FormulaInstruction::F_Double
@ F_Double
Definition: MWAWCell.hxx:398
MWAWDocument::MWAW_T_JAZZLOTUS
@ MWAW_T_JAZZLOTUS
Jazz (Lotus): v1 ; retrieve the spreadsheet and if the resource fork is available,...
Definition: MWAWDocument.hxx:236
MWAWCellContent::FormulaInstruction::m_position
MWAWVec2i m_position[2]
cell position ( if type==F_Cell or F_CellList )
Definition: MWAWCell.hxx:423
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWSpreadsheetListener.hxx
Defines MWAWSpreadsheetListener: the libmwaw spreadsheet processor listener.
JazzSSParser::createZones
bool createZones()
finds the different objects zones
Definition: JazzSSParser.cxx:220
MWAWCellContent::FormulaInstruction::m_positionRelative
MWAWVec2b m_positionRelative[2]
relative cell position ( if type==F_Cell or F_CellList )
Definition: MWAWCell.hxx:425
JazzSSParser::JazzSSParser
JazzSSParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: JazzSSParser.cxx:152
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:84
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
MWAWFont.hxx
librevenge
Definition: MWAWDocument.hxx:57
MWAWFont::flags
uint32_t flags() const
returns the font flags
Definition: MWAWFont.hxx:320
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
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:53
JazzSSParserInternal::Cell::~Cell
~Cell() final
destructor
Definition: JazzSSParser.cxx:75
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
JazzSSParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: JazzSSParser.cxx:114
MWAWVec2b
MWAWVec2< bool > MWAWVec2b
MWAWVec2 of bool.
Definition: libmwaw_internal.hxx:836
MWAWFont::hiddenBit
@ hiddenBit
Definition: MWAWFont.hxx:191
MWAWCell::HALIGN_RIGHT
@ HALIGN_RIGHT
Definition: MWAWCell.hxx:128
JazzSSParserInternal::s_listFunctions
static Functions const s_listFunctions[]
Definition: JazzSSParser.cxx:785
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
JazzSSParser::parse
void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) final
the main parse function
Definition: JazzSSParser.cxx:168
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
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
JazzSSParserInternal::Functions::m_name
char const * m_name
Definition: JazzSSParser.cxx:781
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325
MWAWCell::F_TEXT
@ F_TEXT
Definition: MWAWCell.hxx:56