MsWksDocument.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.
*/
#ifndef MS_WKS_DOCUMENT
# define MS_WKS_DOCUMENT
#include <string>
#include <map>
#include <vector>
#include <librevenge/librevenge.h>
#include "libmwaw_internal.hxx"
#include "MWAWDebug.hxx"
#include "MWAWCell.hxx"
#include "MWAWParser.hxx"
namespace MsWksDocumentInternal
{
struct State;
class SubDocument;
}
class MsWksParser;
class MsWksDBParser;
class MsWksDRParser;
class MsWksSSParser;
class MsWks4Zone;
class MsWksGraph;
class MsWks3Text;
class MsWks4Text;
class MsWksDocument
{
friend class MsWksDocumentInternal::SubDocument;
friend class MsWksParser;
friend class MsWks4Zone;
friend class MsWksDBParser;
friend class MsWksDRParser;
friend class MsWksSSParser;
public:
enum ZoneType { Z_MAIN, Z_HEADER, Z_FOOTER, Z_NONE };
struct Zone {
explicit Zone(ZoneType type=Z_NONE, int zoneId=-1)
: m_type(type)
, m_zoneId(zoneId)
, m_textId(-1)
{
}
ZoneType m_type;
int m_zoneId;
int m_textId;
};
public:
MsWksDocument(MWAWInputStreamPtr const &input, MWAWParser &parser);
virtual ~MsWksDocument();
int version() const;
void setVersion(int vers);
MWAWDocument::Kind getKind() const;
void setKind(MWAWDocument::Kind kind);
MWAWInputStreamPtr &getInput()
{
return m_input;
}
MWAWParser &getMainParser()
{
return *m_parser;
}
std::shared_ptr<MsWksGraph> getGraphParser()
{
return m_graphParser;
}
std::shared_ptr<MsWks3Text> getTextParser3();
std::shared_ptr<MsWks4Text> getTextParser4();
libmwaw::DebugFile &ascii()
{
return m_asciiFile;
}
//
// read some v3 structure
//
bool checkHeader3(MWAWHeader *header, bool strict=false);
long getLengthOfFileHeader3() const;
bool readPrintInfo();
bool readDocumentInfo(long sz=-1);
bool readZone(Zone &zone);
bool readGroupHeaderFooter(bool header, int check);
//
// read some ole structures
//
bool createOLEZones(MWAWInputStreamPtr input);
std::vector<std::string> const &getUnparsedOLEZones() const;
//
// utilities functions
//
bool hasHeader() const;
bool hasFooter() const;
float getHeaderFooterHeight(bool header) const;
void getPageSpanList(std::vector<MWAWPageSpan> &pagesList, int &numPages);
bool getColor(int id, MWAWColor &col, int vers);
std::vector<MWAWColor> const &getPalette(int vers);
std::multimap<int, Zone> &getTypeZoneMap();
Zone getZone(ZoneType type) const;
int getNewZoneId() const;
std::multimap<std::string, MWAWEntry> &getEntryMap();
// general interface
void sendZone(int zoneType);
// interface with the text parser
void newPage(int page, bool softBreak=false);
void sendFootnoteContent(int noteId);
void sendFootnote(int id);
void sendText(int id);
// interface with the graph parser
void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style);
void sendRBIL(int id, MWAWVec2i const &sz);
void sendTextbox(MWAWEntry const &entry, std::string const &frame);
protected:
//
// spreadsheet/database function
//
bool readCellInFormula(MWAWCellContent::FormulaInstruction &instr, bool is2D);
bool readDBString(long endPos, std::string &res);
bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str);
/* reads a formula */
bool readFormula(long endPos, MWAWCellContent &content, std::string &extra);
protected:
//
// low level
//
void initAsciiFile(std::string const &name);
private:
MsWksDocument(MsWksDocument const &orig) = delete;
MsWksDocument &operator=(MsWksDocument const &orig) = delete;
//
// data
//
protected:
std::shared_ptr<MsWksDocumentInternal::State> m_state;
public:
std::shared_ptr<MWAWParserState> m_parserState;
protected:
MWAWParser *m_parser;
MsWksDocument *m_parentDocument;
MWAWInputStreamPtr m_input;
libmwaw::DebugFile m_asciiFile;
std::shared_ptr<MsWksGraph> m_graphParser;
std::shared_ptr<MsWks3Text> m_textParser3;
std::shared_ptr<MsWks4Text> m_textParser4;
typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
NewPage m_newPage;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWCell.hxx
Defines MWAWCell (cell content and format).
MWAWDebug.hxx
MWAWParser.hxx
MWAWCellContent
small class use to define a sheet cell content
Definition MWAWCell.hxx:394
MWAWDocument::Kind
Kind
an enum to define the kind of document
Definition MWAWDocument.hxx:80
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWGraphicStyle
a structure used to define a picture style
Definition MWAWGraphicStyle.hxx:48
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition MWAWParser.hxx:100
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition MWAWPosition.hxx:48
MsWks3Text
the main class to read the text part of Microsoft Works file
Definition MsWks3Text.hxx:70
MsWks4Text
The class which parses text zones in a mac MS Works document v4.
Definition MsWks4Text.hxx:65
MsWks4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition MsWks4Zone.hxx:74
MsWksDBParser
the main class to read a Microsoft Works database file and convert it in a spreadsheet file
Definition MsWksDBParser.hxx:66
MsWksDRParser
the main class to read a Microsoft Works graphic file
Definition MsWksDRParser.hxx:60
MsWksDocumentInternal::SubDocument
Internal: the subdocument of a MsWksDocument.
Definition MsWksDocument.cxx:219
MsWksDocument::getPageSpanList
void getPageSpanList(std::vector< MWAWPageSpan > &pagesList, int &numPages)
get the page span list and the number of page for a v1-v3 document
Definition MsWksDocument.cxx:426
MsWksDocument::getMainParser
MWAWParser & getMainParser()
returns the main parser
Definition MsWksDocument.hxx:118
MsWksDocument::MsWksDocument
MsWksDocument(MWAWInputStreamPtr const &input, MWAWParser &parser)
constructor
Definition MsWksDocument.cxx:297
MsWksDocument::createOLEZones
bool createOLEZones(MWAWInputStreamPtr input)
finds the different OLE zones
Definition MsWksDocument.cxx:613
MsWksDocument::getNewZoneId
int getNewZoneId() const
returns a free zone'id
Definition MsWksDocument.cxx:355
MsWksDocument::m_input
MWAWInputStreamPtr m_input
the input which can be an OLE in MSWorks 4 file
Definition MsWksDocument.hxx:256
MsWksDocument::hasFooter
bool hasFooter() const
returns true if the document has some footer ( found by checkHeader3)
Definition MsWksDocument.cxx:416
MsWksDocument::readDBNumber
bool readDBNumber(long endPos, double &res, bool &isNan, std::string &str)
try to read a number
Definition MsWksDocument.cxx:1202
MsWksDocument::getGraphParser
std::shared_ptr< MsWksGraph > getGraphParser()
returns the graph parser
Definition MsWksDocument.hxx:123
MsWksDocument::MsWksParser
friend class MsWksParser
Definition MsWksDocument.hxx:71
MsWksDocument::ZoneType
ZoneType
the different type of zone (v1-v3)
Definition MsWksDocument.hxx:78
MsWksDocument::Z_MAIN
@ Z_MAIN
Definition MsWksDocument.hxx:78
MsWksDocument::Z_NONE
@ Z_NONE
Definition MsWksDocument.hxx:78
MsWksDocument::Z_HEADER
@ Z_HEADER
Definition MsWksDocument.hxx:78
MsWksDocument::Z_FOOTER
@ Z_FOOTER
Definition MsWksDocument.hxx:78
MsWksDocument::NewPage
void(MWAWParser::* NewPage)(int page, bool softBreak)
callback used to send a page break
Definition MsWksDocument.hxx:268
MsWksDocument::operator=
MsWksDocument & operator=(MsWksDocument const &orig)=delete
MsWksDocument::m_newPage
NewPage m_newPage
the new page callback
Definition MsWksDocument.hxx:271
MsWksDocument::sendTextbox
void sendTextbox(MWAWEntry const &entry, std::string const &frame)
send a textbox
Definition MsWksDocument.cxx:540
MsWksDocument::readCellInFormula
bool readCellInFormula(MWAWCellContent::FormulaInstruction &instr, bool is2D)
reads a cell
Definition MsWksDocument.cxx:1212
MsWksDocument::m_state
std::shared_ptr< MsWksDocumentInternal::State > m_state
the state
Definition MsWksDocument.hxx:245
MsWksDocument::getLengthOfFileHeader3
long getLengthOfFileHeader3() const
returns the length of the file header of a v1-v3 document (if know)
Definition MsWksDocument.cxx:378
MsWksDocument::sendRBIL
void sendRBIL(int id, MWAWVec2i const &sz)
send a rbil zone
Definition MsWksDocument.cxx:530
MsWksDocument::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition MsWksDocument.hxx:113
MsWksDocument::MsWksSSParser
friend class MsWksSSParser
Definition MsWksDocument.hxx:75
MsWksDocument::readGroupHeaderFooter
bool readGroupHeaderFooter(bool header, int check)
try to read a header/footer group
Definition MsWksDocument.cxx:875
MsWksDocument::getUnparsedOLEZones
std::vector< std::string > const & getUnparsedOLEZones() const
returns the list of unparsed OLE zones
Definition MsWksDocument.cxx:608
MsWksDocument::MsWksDocument
MsWksDocument(MsWksDocument const &orig)=delete
MsWksDocument::hasHeader
bool hasHeader() const
returns true if the document has some header ( found by checkHeader3)
Definition MsWksDocument.cxx:411
MsWksDocument::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file of the actual input
Definition MsWksDocument.hxx:258
MsWksDocument::checkHeader3
bool checkHeader3(MWAWHeader *header, bool strict=false)
checks if the file header corresponds to a v1-v3 document (or not)
Definition MsWksDocument.cxx:1020
MsWksDocument::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition MsWksDocument.hxx:132
MsWksDocument::readZone
bool readZone(Zone &zone)
try to read a generic zone
Definition MsWksDocument.cxx:973
MsWksDocument::getEntryMap
std::multimap< std::string, MWAWEntry > & getEntryMap()
returns the document entry map of a v4 document
Definition MsWksDocument.cxx:373
MsWksDocument::getColor
bool getColor(int id, MWAWColor &col, int vers)
returns the color which correspond to an index
Definition MsWksDocument.cxx:583
MsWksDocument::newPage
void newPage(int page, bool softBreak=false)
tries to create a new page
Definition MsWksDocument.cxx:492
MsWksDocument::m_parser
MWAWParser * m_parser
the main parser
Definition MsWksDocument.hxx:252
MsWksDocument::readDBString
bool readDBString(long endPos, std::string &res)
try to read a string
Definition MsWksDocument.cxx:1187
MsWksDocument::readPrintInfo
bool readPrintInfo()
read the print info zone (v1-v3)
Definition MsWksDocument.cxx:695
MsWksDocument::sendZone
void sendZone(int zoneType)
try to send a zone (v1-v3 document)
Definition MsWksDocument.cxx:388
MsWksDocument::sendFootnote
void sendFootnote(int id)
tries to send a footnote
Definition MsWksDocument.cxx:503
MsWksDocument::MsWks4Zone
friend class MsWks4Zone
Definition MsWksDocument.hxx:72
MsWksDocument::readDocumentInfo
bool readDocumentInfo(long sz=-1)
try to read the documentinfo ( v1-v3)
Definition MsWksDocument.cxx:761
MsWksDocument::m_parserState
std::shared_ptr< MWAWParserState > m_parserState
the parser state
Definition MsWksDocument.hxx:248
MsWksDocument::~MsWksDocument
virtual ~MsWksDocument()
destructor
Definition MsWksDocument.cxx:313
MsWksDocument::m_parentDocument
MsWksDocument * m_parentDocument
the parent document (if this is not the main document)
Definition MsWksDocument.hxx:254
MsWksDocument::readFormula
bool readFormula(long endPos, MWAWCellContent &content, std::string &extra)
Definition MsWksDocument.cxx:1250
MsWksDocument::setVersion
void setVersion(int vers)
sets the document's version
Definition MsWksDocument.cxx:335
MsWksDocument::MsWksDBParser
friend class MsWksDBParser
Definition MsWksDocument.hxx:73
MsWksDocument::initAsciiFile
void initAsciiFile(std::string const &name)
inits the ascii file
Definition MsWksDocument.cxx:317
MsWksDocument::sendText
void sendText(int id)
try to send a text zone (v1-v3 document)
Definition MsWksDocument.cxx:383
MsWksDocument::sendFootnoteContent
void sendFootnoteContent(int noteId)
try to send a footnote content (v4 document)
Definition MsWksDocument.cxx:396
MsWksDocument::m_textParser3
std::shared_ptr< MsWks3Text > m_textParser3
the text document (for v1-3 document)
Definition MsWksDocument.hxx:263
MsWksDocument::m_graphParser
std::shared_ptr< MsWksGraph > m_graphParser
the graph document
Definition MsWksDocument.hxx:261
MsWksDocument::setKind
void setKind(MWAWDocument::Kind kind)
sets the document's kind
Definition MsWksDocument.cxx:350
MsWksDocument::getHeaderFooterHeight
float getHeaderFooterHeight(bool header) const
returns the header/footer height (found by readGroupHeaderFooter)
Definition MsWksDocument.cxx:421
MsWksDocument::m_textParser4
std::shared_ptr< MsWks4Text > m_textParser4
the text document (for v4 document)
Definition MsWksDocument.hxx:265
MsWksDocument::getTextParser4
std::shared_ptr< MsWks4Text > getTextParser4()
returns the text parser (for v4 document)
Definition MsWksDocument.cxx:329
MsWksDocument::getZone
Zone getZone(ZoneType type) const
returns the zone corresponding to a zoneType (v1-v3 document)
Definition MsWksDocument.cxx:360
MsWksDocument::sendOLE
void sendOLE(int id, MWAWPosition const &pos, MWAWGraphicStyle const &style)
send an OLE zone
Definition MsWksDocument.cxx:514
MsWksDocument::getKind
MWAWDocument::Kind getKind() const
returns the document's kind
Definition MsWksDocument.cxx:345
MsWksDocument::version
int version() const
returns the document's version
Definition MsWksDocument.cxx:340
MsWksDocument::MsWksDRParser
friend class MsWksDRParser
Definition MsWksDocument.hxx:74
MsWksDocument::getTextParser3
std::shared_ptr< MsWks3Text > getTextParser3()
returns the text parser (for v1-v3 document)
Definition MsWksDocument.cxx:323
MsWksDocument::getTypeZoneMap
std::multimap< int, Zone > & getTypeZoneMap()
returns the document entry map of a v1-v3 document
Definition MsWksDocument.cxx:368
MsWksDocument::getPalette
std::vector< MWAWColor > const & getPalette(int vers)
returns a list of color corresponding to a version
Definition MsWksDocument.cxx:578
MsWksGraph
the main class to read the graphic of a Microsoft Works file
Definition MsWksGraph.hxx:74
MsWksParser
the main class to read a Microsoft Works file: v1-v4
Definition MsWksParser.hxx:60
MsWksSSParser
the main class to read a Microsoft Works spreadsheet file
Definition MsWksSSParser.hxx:66
libmwaw::DebugFile
Definition MWAWDebug.hxx:66
libmwaw_internal.hxx
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition libmwaw_internal.hxx:838
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MsWksDocumentInternal
Internal: the structures of a MsWksDocument.
Definition MsWksDocument.cxx:64
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition MWAWCell.hxx:397
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192
MsWksDocumentInternal::State
Internal: the state of a MsWksDocument.
Definition MsWksDocument.cxx:68
MsWksDocument::Zone::m_type
ZoneType m_type
the zone type
Definition MsWksDocument.hxx:89
MsWksDocument::Zone::m_textId
int m_textId
the text internal id
Definition MsWksDocument.hxx:93
MsWksDocument::Zone::m_zoneId
int m_zoneId
the parser zone id
Definition MsWksDocument.hxx:91
MsWksDocument::Zone::Zone
Zone(ZoneType type=Z_NONE, int zoneId=-1)
the constructor
Definition MsWksDocument.hxx:82