WriteNowParser.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 /* libmwaw
3 * Version: MPL 2.0 / LGPLv2+
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 2.0 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * Major Contributor(s):
16 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
17 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
18 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
19 * Copyright (C) 2006, 2007 Andrew Ziem
20 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
21 *
22 *
23 * All Rights Reserved.
24 *
25 * For minor contributions see the git repository.
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
29 * in which case the provisions of the LGPLv2+ are applicable
30 * instead of those above.
31 */
32 
33 /*
34  * parser for WriteNow 3.0 and 4.0
35  *
36  * Note: WriteNow 2.0 seems very different
37  */
38 #ifndef WRITE_NOW_PARSER
39 # define WRITE_NOW_PARSER
40 
41 #include <list>
42 #include <string>
43 #include <vector>
44 
45 #include "MWAWDebug.hxx"
46 #include "MWAWEntry.hxx"
47 #include "MWAWInputStream.hxx"
48 #include "MWAWPosition.hxx"
49 
50 #include "MWAWParser.hxx"
51 
52 namespace WriteNowParserInternal
53 {
54 struct State;
55 class SubDocument;
56 }
57 
58 struct WriteNowEntry;
60 
61 class WriteNowText;
62 
68 class WriteNowParser final : public MWAWTextParser
69 {
70  friend class WriteNowText;
72 
73 public:
75  WriteNowParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
77  ~WriteNowParser() final;
78 
80  bool checkHeader(MWAWHeader *header, bool strict=false) final;
81 
82  // the main parse function
83  void parse(librevenge::RVNGTextInterface *documentInterface) final;
84 
85 protected:
87  void init();
88 
90  void createDocument(librevenge::RVNGTextInterface *documentInterface);
91 
93  bool createZones();
94 
96  void getColumnInfo(int &numColumns, int &width) const;
97 
99  void newPage(int number);
100 
101  /*
102  * interface with WriteNowText
103  */
105  bool getColor(int colId, MWAWColor &col) const;
106 
108  void sendFootnote(WriteNowEntry const &entry);
109 
111  bool sendGraphic(int gId, MWAWBox2i const &bdbox);
112 
113  /*
114  * interface with subdocument
115  */
116 
118  void send(WriteNowEntry const &entry);
119 
120  //
121  // low level
122  //
123 
125  bool readDocEntries();
126 
128  bool readDocEntriesV2();
129 
133  bool parseGraphicZone(WriteNowEntry const &entry);
134 
136  bool readColorMap(WriteNowEntry const &entry);
137 
139  bool readPrintInfo(WriteNowEntry const &entry);
140 
142  bool readGenericUnkn(WriteNowEntry const &entry);
143 
145  bool sendPicture(WriteNowEntry const &entry, MWAWBox2i const &bdbox);
146 
149 
151  bool checkIfPositionValid(long pos);
152 
153 protected:
154  //
155  // data
156  //
158  std::shared_ptr<WriteNowParserInternal::State> m_state;
159 
162 
164  std::shared_ptr<WriteNowText> m_textParser;
165 };
166 #endif
167 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
WriteNowParser::checkIfPositionValid
bool checkIfPositionValid(long pos)
check if a position is inside the file
Definition: WriteNowParser.cxx:989
MWAWTextListenerPtr
std::shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:567
WriteNowParserInternal::State::m_endPos
long m_endPos
the last position
Definition: WriteNowParser.cxx:76
WriteNowParser::init
void init()
inits all internal variables
Definition: WriteNowParser.cxx:159
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
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:299
WriteNowParser::readDocEntriesV2
bool readDocEntriesV2()
try to read the document entries zone v2
Definition: WriteNowParser.cxx:478
MWAWNote
a note
Definition: libmwaw_internal.hxx:445
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
WriteNowParser::WriteNowParser
WriteNowParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: WriteNowParser.cxx:146
MWAWHeaderFooter::HEADER
@ HEADER
Definition: MWAWPageSpan.hxx:48
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
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
WriteNowParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: WriteNowParser.cxx:132
WriteNowParser::readEntry
WriteNowEntry readEntry()
read a file entry
Definition: WriteNowParser.cxx:1003
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:121
WriteNowParserInternal::State::m_picturesList
std::vector< WriteNowEntry > m_picturesList
the list of picture entries
Definition: WriteNowParser.cxx:80
WriteNowParser::readDocEntries
bool readDocEntries()
try to read the document entries zone v3-v4
Definition: WriteNowParser.cxx:389
WriteNowParser::newPage
void newPage(int number)
adds a new page
Definition: WriteNowParser.cxx:185
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
WriteNowParser::readColorMap
bool readColorMap(WriteNowEntry const &entry)
try to read the colormap zone
Definition: WriteNowParser.cxx:722
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
WriteNowParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: WriteNowParser.cxx:85
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:164
MWAWEntry.hxx
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
WriteNowParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: WriteNowParser.cxx:281
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:565
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
WriteNowEntry
class to store entry in a WriteNow document
Definition: WriteNowEntry.hxx:48
WriteNowParserInternal::State::m_numColumns
int m_numColumns
the number of columns
Definition: WriteNowParser.cxx:87
WriteNowParserInternal::State::m_colorMap
std::vector< MWAWColor > m_colorMap
the color map
Definition: WriteNowParser.cxx:78
MWAWPrinter.hxx
WriteNowParser::sendPicture
bool sendPicture(WriteNowEntry const &entry, MWAWBox2i const &bdbox)
try to send a picture to the listener
Definition: WriteNowParser.cxx:635
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
WriteNowEntryManager
the manager of the entries
Definition: WriteNowEntry.hxx:106
WriteNowParser::m_entryManager
std::shared_ptr< WriteNowEntryManager > m_entryManager
the list of entry
Definition: WriteNowParser.hxx:161
MWAWPictData::get
static MWAWPictData * get(MWAWInputStreamPtr const &input, int size)
checks if the data pointed by input is known
Definition: MWAWPictData.hxx:108
MWAWHeaderFooter::m_subDocument
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:92
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
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:145
WriteNowParserInternal::State
Internal: the state of a WriteNowParser.
Definition: WriteNowParser.cxx:60
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
MWAWPosition::setNaturalSize
void setNaturalSize(MWAWVec2f const &naturalSz)
sets the natural size (if known)
Definition: MWAWPosition.hxx:220
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:45
WriteNowParserInternal::SubDocument::SubDocument
SubDocument(WriteNowParser &pars, MWAWInputStreamPtr const &input, WriteNowEntry const &pos)
Definition: WriteNowParser.cxx:95
WriteNowParser::readGenericUnkn
bool readGenericUnkn(WriteNowEntry const &entry)
try to read the last generic zones
Definition: WriteNowParser.cxx:905
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
WriteNowParserInternal::State::State
State()
constructor
Definition: WriteNowParser.cxx:62
WriteNowParser::getColumnInfo
void getColumnInfo(int &numColumns, int &width) const
returns the columns information
Definition: WriteNowParser.cxx:176
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
WriteNowParser::sendGraphic
bool sendGraphic(int gId, MWAWBox2i const &bdbox)
try to send the graphic zone
Definition: WriteNowParser.cxx:220
WriteNowParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: WriteNowParser.cxx:115
MWAWDocument::MWAW_T_WRITENOW
@ MWAW_T_WRITENOW
WriteNow.
Definition: MWAWDocument.hxx:156
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWSubDocument::m_input
std::shared_ptr< MWAWInputStream > m_input
the input
Definition: MWAWSubDocument.hxx:77
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
WriteNowEntry::m_fileType
int m_fileType
the file entry id
Definition: WriteNowEntry.hxx:100
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:132
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:158
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:113
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:673
libmwaw::Debug::dumpFile
bool dumpFile(librevenge::RVNGBinaryData &data, char const *fileName)
a debug function to store in a datafile in the current directory WARNING: this function erase the fil...
Definition: MWAWDebug.cxx:193
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:183
MWAWPosition.hxx
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:668
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
WriteNowParser::parseGraphicZone
bool parseGraphicZone(WriteNowEntry const &entry)
try to read the graphic zone (unknown + list of entries ) and to create the graphic data zone
Definition: WriteNowParser.cxx:555
WriteNowParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: WriteNowParser.cxx:82
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
WriteNowParser::readPrintInfo
bool readPrintInfo(WriteNowEntry const &entry)
try to read the print info zone
Definition: WriteNowParser.cxx:829
WriteNowParser
the main class to read a WriteNow file
Definition: WriteNowParser.hxx:69
MWAWParser::setVersion
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:206
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
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
WriteNowText.hxx
MWAWVec2< int >
MWAWPictMac.hxx
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
WriteNowParser::WriteNowText
friend class WriteNowText
Definition: WriteNowParser.hxx:70
WriteNowEntry::isZoneType
bool isZoneType() const
returns true if this entry store a zone
Definition: WriteNowEntry.hxx:62
WriteNowParser.hxx
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:169
WriteNowParser::createZones
bool createZones()
finds the different objects zones
Definition: WriteNowParser.cxx:329
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
MWAWHeaderFooter::FOOTER
@ FOOTER
Definition: MWAWPageSpan.hxx:48
MWAWPosition::Char
@ Char
Definition: MWAWPosition.hxx:51
WriteNowEntry::m_val
int m_val[4]
other values
Definition: WriteNowEntry.hxx:102
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
MWAWHeaderFooter::ALL
@ ALL
Definition: MWAWPageSpan.hxx:50
WriteNowParser::getColor
bool getColor(int colId, MWAWColor &col) const
returns the color which corresponds to colId
Definition: WriteNowParser.cxx:198
WriteNowParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: WriteNowParser.cxx:84
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
WriteNowParser::m_textParser
std::shared_ptr< WriteNowText > m_textParser
the text parser
Definition: WriteNowParser.hxx:164
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
WriteNowParser::send
void send(WriteNowEntry const &entry)
try to send an entry
Definition: WriteNowParser.cxx:215
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
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:227
WriteNowParserInternal::SubDocument::m_pos
WriteNowEntry m_pos
the subdocument file position
Definition: WriteNowParser.cxx:112
MWAWBox2::size
MWAWVec2< T > size() const
the box size
Definition: libmwaw_internal.hxx:1067
MWAWNote::FootNote
@ FootNote
Definition: libmwaw_internal.hxx:447
MWAWInputStream.hxx
WriteNowParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: WriteNowParser.cxx:82
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
WriteNowParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: WriteNowParser.cxx:1029
librevenge
Definition: MWAWDocument.hxx:57
WriteNowParserInternal::SubDocument
Internal: the subdocument of a WriteNowParser.
Definition: WriteNowParser.cxx:93
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:213
WriteNowParser::sendFootnote
void sendFootnote(WriteNowEntry const &entry)
try to send a footnote entry
Definition: WriteNowParser.cxx:207
MWAWBox2< int >
WriteNowParser::~WriteNowParser
~WriteNowParser() final
destructor
Definition: WriteNowParser.cxx:155
WriteNowParserInternal
Internal: the structures of a WriteNowParser.
Definition: WriteNowParser.cxx:57
WriteNowParserInternal::State::m_columnWidth
int m_columnWidth
the columns size
Definition: WriteNowParser.cxx:87
WriteNowEntry::isZone
bool isZone() const
returns true if this is a zone
Definition: WriteNowEntry.hxx:67
WriteNowParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: WriteNowParser.cxx:239
WriteNowEntry.hxx
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
WriteNowParser::m_state
std::shared_ptr< WriteNowParserInternal::State > m_state
the state
Definition: WriteNowParser.hxx:158
WriteNowText
the main class to read the text part of writenow file
Definition: WriteNowText.hxx:82
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
WriteNowParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: WriteNowParser.cxx:102
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163

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