GreatWksDocument.hxx Source File documentation

GreatWksDocument.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 GREAT_WKS_DOCUMENT
35 # define GREAT_WKS_DOCUMENT
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWCell.hxx"
43 #include "MWAWDebug.hxx"
44 #include "MWAWParser.hxx"
45
46 namespace GreatWksDocumentInternal
47 {
48 struct State;
49 }
50
51 class GreatWksGraph;
52 class GreatWksParser;
53 class GreatWksDBParser;
54 class GreatWksDRParser;
55 class GreatWksSSParser;
56 class GreatWksText;
57
60 class GreatWksDocument
61 {
62 friend class GreatWksParser;
63 friend class GreatWksDBParser;
64 friend class GreatWksDRParser;
65 friend class GreatWksSSParser;
66 public:
68 explicit GreatWksDocument(MWAWParser &parser);
70 virtual ~GreatWksDocument();
71
73 bool checkHeader(MWAWHeader *header, bool strict=false);
74
76 MWAWParser &getMainParser()
77 {
78 return *m_parser;
79 }
81 std::shared_ptr<GreatWksGraph> getGraphParser()
82 {
83 return m_graphParser;
84 }
86 std::shared_ptr<GreatWksText> getTextParser()
87 {
88 return m_textParser;
89 }
90
92 MWAWSection getMainSection() const;
94 void newPage(int page);
96 bool sendPicture(MWAWEntry const &entry, MWAWPosition pos);
97
98 // interface with the graph parser
99
101 bool canSendTextboxAsGraphic(MWAWEntry const &entry);
103 bool sendTextbox(MWAWEntry const &entry, MWAWListenerPtr listener);
104
105 protected:
106
108 bool readRSRCZones();
109
110 // formula function
111
113 bool readCellInFormula(MWAWVec2i const &pos, MWAWCellContent::FormulaInstruction &instr);
115 bool readString(long endPos, std::string &res);
117 bool readNumber(long endPos, double &res, bool &isNan);
119 bool readFormula(MWAWVec2i const &cPos, long endPos,
120 std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error);
121
122 //
123 // low level
124 //
125
127 bool readPrintInfo(MWAWEntry const &entry);
128
130 bool readWPSN(MWAWEntry const &entry);
131
133 bool readARRs(MWAWEntry const &entry);
135 bool readDaHS(MWAWEntry const &entry);
137 bool readGrDS(MWAWEntry const &entry);
139 bool readNxEd(MWAWEntry const &entry);
140
142 MWAWInputStreamPtr rsrcInput();
143
145 libmwaw::DebugFile &rsrcAscii();
146
147 private:
148 GreatWksDocument(GreatWksDocument const &orig) = delete;
149 GreatWksDocument &operator=(GreatWksDocument const &orig) = delete;
150
151 //
152 // data
153 //
154
155 protected:
157 std::shared_ptr<GreatWksDocumentInternal::State> m_state;
158 public:
160 std::shared_ptr<MWAWParserState> m_parserState;
161
162 protected:
164 MWAWParser *m_parser;
166 std::shared_ptr<GreatWksGraph> m_graphParser;
168 std::shared_ptr<GreatWksText> m_textParser;
169
171 typedef MWAWSection(MWAWParser::* GetMainSection)() const;
173 typedef void (MWAWParser::* NewPage)(int page);
174
176 GetMainSection m_getMainSection;
178 NewPage m_newPage;
179 };
180 #endif
181 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
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:46
MWAWDocument::MWAW_K_DATABASE
@ MWAW_K_DATABASE
database
Definition: MWAWDocument.hxx:87
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
GreatWksDocument::m_textParser
std::shared_ptr< GreatWksText > m_textParser
the text document
Definition: GreatWksDocument.hxx:168
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
GreatWksDocumentInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: GreatWksDocument.cxx:74
GreatWksDocument::getTextParser
std::shared_ptr< GreatWksText > getTextParser()
returns the text parser
Definition: GreatWksDocument.hxx:86
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
GreatWksDocument::readWPSN
bool readWPSN(MWAWEntry const &entry)
read the windows positions ( WPSN resource block )
Definition: GreatWksDocument.cxx:230
GreatWksDocument::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: GreatWksDocument.cxx:107
MWAWCellContent::FormulaInstruction::F_Operator
@ F_Operator
Definition: MWAWCell.hxx:398
GreatWksDocument::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
read a PrintInfo block ( PRNT resource block )
Definition: GreatWksDocument.cxx:283
GreatWksDocument::readFormula
bool readFormula(MWAWVec2i const &cPos, long endPos, std::vector< MWAWCellContent::FormulaInstruction > &formula, std::string &error)
read to read a formula
Definition: GreatWksDocument.cxx:628
GreatWksDocument::readNxEd
bool readNxEd(MWAWEntry const &entry)
read a unknown zone ( NxED resource block: v2 )
Definition: GreatWksDocument.cxx:445
GreatWksDocument::GetMainSection
MWAWSection(MWAWParser::* GetMainSection)() const
callback used to return the main section
Definition: GreatWksDocument.hxx:171
GreatWksDocumentInternal::Functions
Definition: GreatWksDocument.cxx:599
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition: MWAWCell.hxx:397
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
MWAWDocument::MWAW_T_GREATWORKS
@ MWAW_T_GREATWORKS
GreatWorks (v1-v2): export text, drawing, paint and spreadsheet document.
Definition: MWAWDocument.hxx:116
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
GreatWksParser
the main class to read a GreatWorks text file
Definition: GreatWksParser.hxx:56
GreatWksDocument::getMainSection
MWAWSection getMainSection() const
return the main section
Definition: GreatWksDocument.cxx:115
GreatWksDocument::m_getMainSection
GetMainSection m_getMainSection
the getMainSection callback
Definition: GreatWksDocument.hxx:176
MWAWPrinter.hxx
GreatWksDocumentInternal::Functions::m_name
const char * m_name
Definition: GreatWksDocument.cxx:600
MWAWDocument::MWAW_K_DRAW
@ MWAW_K_DRAW
vectorized grphic
Definition: MWAWDocument.hxx:83
GreatWksDocumentInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: GreatWksDocument.cxx:72
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
MWAWCellContent::FormulaInstruction::F_Function
@ F_Function
Definition: MWAWCell.hxx:398
GreatWksDBParser
the main class to read a GreatWorks database file
Definition: GreatWksDBParser.hxx:61
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
GreatWksDocument::NewPage
void(MWAWParser::* NewPage)(int page)
callback used to send a page break
Definition: GreatWksDocument.hxx:173
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
GreatWksDocument::readARRs
bool readARRs(MWAWEntry const &entry)
read a unknown zone ( ARRs resource block: v2 )
Definition: GreatWksDocument.cxx:337
MWAWCell.hxx
GreatWksDocument::m_parserState
std::shared_ptr< MWAWParserState > m_parserState
the parser state
Definition: GreatWksDocument.hxx:160
GreatWksDocument::canSendTextboxAsGraphic
bool canSendTextboxAsGraphic(MWAWEntry const &entry)
check if a textbox can be send in a graphic zone, ie. does not contains any graphic
Definition: GreatWksDocument.cxx:146
GreatWksDocument::readDaHS
bool readDaHS(MWAWEntry const &entry)
read a unknown zone ( DaHS resource block: v2 )
Definition: GreatWksDocument.cxx:364
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
MWAWCellContent::FormulaInstruction::F_Text
@ F_Text
Definition: MWAWCell.hxx:398
GreatWksDocumentInternal::State
Internal: the state of a GreatWksDocument.
Definition: GreatWksDocument.cxx:62
GreatWksDocument::GreatWksDocument
GreatWksDocument(MWAWParser &parser)
constructor
Definition: GreatWksDocument.cxx:83
MWAWParagraph.hxx
MWAWRSRCParser.hxx
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:673
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
MWAWParser::getPageSpan
const MWAWPageSpan & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:183
MWAWPosition.hxx
MWAWDocument::MWAW_K_TEXT
@ MWAW_K_TEXT
word processing file
Definition: MWAWDocument.hxx:82
MWAWCellContent::FormulaInstruction::m_type
Type m_type
the type
Definition: MWAWCell.hxx:415
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:668
GreatWksGraph.hxx
GreatWksDocument::operator=
GreatWksDocument & operator=(GreatWksDocument const &orig)=delete
GreatWksDocument::newPage
void newPage(int page)
send a page break
Definition: GreatWksDocument.cxx:124
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:47
MWAWColor::isBlack
bool isBlack() const
return true if the color is black
Definition: libmwaw_internal.hxx:284
GreatWksDocument::readNumber
bool readNumber(long endPos, double &res, bool &isNan)
try to read a number
Definition: GreatWksDocument.cxx:586
GreatWksText
the main class to read the text part of GreatWorks Text file
Definition: GreatWksText.hxx:62
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
MWAWVec2< int >
GreatWksDocument::sendPicture
bool sendPicture(MWAWEntry const &entry, MWAWPosition pos)
send a picture
Definition: GreatWksDocument.cxx:158
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
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:83
GreatWksDocument.hxx
MWAWCellContent::FormulaInstruction::m_longValue
double m_longValue
value ( if type==F_Long )
Definition: MWAWCell.hxx:419
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:203
libmwaw::PrinterInfo::read
bool read(MWAWInputStreamPtr input)
reads the struture in a file
Definition: MWAWPrinter.cxx:235
GreatWksDocument::m_graphParser
std::shared_ptr< GreatWksGraph > m_graphParser
the graph document
Definition: GreatWksDocument.hxx:166
MWAWCellContent::FormulaInstruction::m_doubleValue
double m_doubleValue
value ( if type==F_Double )
Definition: MWAWCell.hxx:421
GreatWksDocument::readGrDS
bool readGrDS(MWAWEntry const &entry)
read a unknown zone ( GrDS resource block: v2 )
Definition: GreatWksDocument.cxx:405
MWAWCellContent::FormulaInstruction::F_Cell
@ F_Cell
Definition: MWAWCell.hxx:398
GreatWksDocument::m_state
std::shared_ptr< GreatWksDocumentInternal::State > m_state
the state
Definition: GreatWksDocument.hxx:157
GreatWksDocument::m_parser
MWAWParser * m_parser
the main parser
Definition: GreatWksDocument.hxx:164
MWAWHeader.hxx
GreatWksDocumentInternal
Internal: the structures of a GreatWksDocument.
Definition: GreatWksDocument.cxx:57
MWAWCellContent::FormulaInstruction::F_Long
@ F_Long
Definition: MWAWCell.hxx:398
GreatWksDocument::getMainParser
MWAWParser & getMainParser()
returns the main parser
Definition: GreatWksDocument.hxx:76
GreatWksDocumentInternal::s_listFunctions
static const Functions s_listFunctions[]
Definition: GreatWksDocument.cxx:604
GreatWksDocumentInternal::State::m_actPage
int m_actPage
the actual page
Definition: GreatWksDocument.cxx:72
GreatWksDocument
the main class to read/store generic data of a GreatWorks document
Definition: GreatWksDocument.hxx:60
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:99
GreatWksDRParser
the main class to read a GreatWorks graphic file
Definition: GreatWksDRParser.hxx:55
GreatWksDocument::readString
bool readString(long endPos, std::string &res)
try to read a string
Definition: GreatWksDocument.cxx:571
MWAWTextListener.hxx
GreatWksDocument::getGraphParser
std::shared_ptr< GreatWksGraph > getGraphParser()
returns the graph parser
Definition: GreatWksDocument.hxx:81
MWAWSection.hxx
GreatWksText.hxx
MWAWCellContent::FormulaInstruction::F_Double
@ F_Double
Definition: MWAWCell.hxx:398
MWAWCellContent::FormulaInstruction::m_position
MWAWVec2i m_position[2]
cell position ( if type==F_Cell or F_CellList )
Definition: MWAWCell.hxx:423
GreatWksDocument::readCellInFormula
bool readCellInFormula(MWAWVec2i const &pos, MWAWCellContent::FormulaInstruction &instr)
reads a cell
Definition: GreatWksDocument.cxx:542
GreatWksDocumentInternal::State::State
State()
constructor
Definition: GreatWksDocument.cxx:64
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:198
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:99
GreatWksDocument::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: GreatWksDocument.cxx:477
GreatWksDocumentInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: GreatWksDocument.cxx:75
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
MWAWCellContent::FormulaInstruction::m_positionRelative
MWAWVec2b m_positionRelative[2]
relative cell position ( if type==F_Cell or F_CellList )
Definition: MWAWCell.hxx:425
MWAWColor::isWhite
bool isWhite() const
return true if the color is white
Definition: libmwaw_internal.hxx:289
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
GreatWksGraph
the main class to read the graphic part of a HanMac Word-J file
Definition: GreatWksGraph.hxx:75
MWAWVec2b
MWAWVec2< bool > MWAWVec2b
MWAWVec2 of bool.
Definition: libmwaw_internal.hxx:836
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
GreatWksDocumentInternal::Functions::m_arity
int m_arity
Definition: GreatWksDocument.cxx:601
GreatWksDocument::m_newPage
NewPage m_newPage
the new page callback
Definition: GreatWksDocument.hxx:178
GreatWksDocument::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: GreatWksDocument.cxx:102
GreatWksDocument::~GreatWksDocument
virtual ~GreatWksDocument()
destructor
Definition: GreatWksDocument.cxx:98
GreatWksDocument::sendTextbox
bool sendTextbox(MWAWEntry const &entry, MWAWListenerPtr listener)
try to send textbox
Definition: GreatWksDocument.cxx:137
GreatWksSSParser
the main class to read a GreatWorks spreadsheet file
Definition: GreatWksSSParser.hxx:58
GreatWksDocument::readRSRCZones
bool readRSRCZones()
read the resource fork zone
Definition: GreatWksDocument.cxx:172