JazzWriterParser.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 JAZZ_WRITER_PARSER
35 # define JAZZ_WRITER_PARSER
36 
37 #include <set>
38 #include <string>
39 #include <vector>
40 
41 #include <librevenge/librevenge.h>
42 
43 #include "MWAWDebug.hxx"
44 #include "MWAWInputStream.hxx"
45 
46 #include "MWAWParser.hxx"
47 
49 {
50 class SubDocument;
51 struct State;
52 }
53 
56 class JazzWriterParser final : public MWAWTextParser
57 {
59 public:
61  JazzWriterParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
63  ~JazzWriterParser() final;
64 
66  bool checkHeader(MWAWHeader *header, bool strict=false) final;
67 
68  // the main parse function
69  void parse(librevenge::RVNGTextInterface *documentInterface) final;
70 
71 protected:
73  void createDocument(librevenge::RVNGTextInterface *documentInterface);
74 
76  bool readParagraph(MWAWEntry const &entry);
78  bool readPLC(MWAWEntry const &entry);
80  bool readZone(MWAWEntry const &entry);
81 
83  bool sendZone(unsigned zId);
85  bool sendParagraph(unsigned pId);
87  bool sendPLC(unsigned pId);
89  bool getPicture(unsigned pId, MWAWEmbeddedObject &obj);
90 
91 protected:
93  bool createZones();
98  bool checkZones();
100  bool checkParagraphs(unsigned id, long &num, std::set<unsigned> &seens) const;
102  bool countCharactersInPLC(unsigned plcId, long &n);
103 
107  libmwaw::DebugFile &rsrcAscii();
108 
109  //
110  // data
111  //
112 
114  bool readString(MWAWInputStreamPtr input, librevenge::RVNGString &string, long endPos);
115 
117  std::shared_ptr<JazzWriterParserInternal::State> m_state;
118 };
119 #endif
120 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWTextListenerPtr
std::shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:567
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MWAWField::Time
@ Time
Definition: libmwaw_internal.hxx:401
MWAWParagraph::m_justify
MWAWVariable< Justification > m_justify
the justification
Definition: MWAWParagraph.hxx:167
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
JazzWriterParserInternal::State
Internal: the state of a JazzWriterParser.
Definition: JazzWriterParser.cxx:99
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:150
JazzWriterParser::checkParagraphs
bool checkParagraphs(unsigned id, long &num, std::set< unsigned > &seens) const
check that a paragraph, its style and its followings exist (and do not create loops) and update the n...
Definition: JazzWriterParser.cxx:394
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
MWAWHeaderFooter::HEADER
@ HEADER
Definition: MWAWPageSpan.hxx:48
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
JazzWriterParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: JazzWriterParser.cxx:126
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
JazzWriterParserInternal::SubDocument::SubDocument
SubDocument(JazzWriterParser &pars, MWAWInputStreamPtr const &input, MWAWInputStreamPtr const &rsrcInput, unsigned id)
Definition: JazzWriterParser.cxx:118
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
JazzWriterParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: JazzWriterParser.cxx:141
JazzWriterParser::sendParagraph
bool sendParagraph(unsigned pId)
try to send a paragraph
Definition: JazzWriterParser.cxx:735
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
MWAWParagraph::m_tabs
MWAWVariable< std::vector< MWAWTabStop > > m_tabs
the tabulations
Definition: MWAWParagraph.hxx:162
MWAWField::m_DTFormat
std::string m_DTFormat
the date/time format using strftime format if defined
Definition: libmwaw_internal.hxx:424
JazzWriterParserInternal::State::m_idToZones
std::map< unsigned, Zone > m_idToZones
map WDOC id to zones
Definition: JazzWriterParser.cxx:108
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
JazzWriterParser::~JazzWriterParser
~JazzWriterParser() final
destructor
Definition: JazzWriterParser.cxx:185
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MWAWTabStop::CENTER
@ CENTER
Definition: MWAWParagraph.hxx:48
MWAWParagraph::setInterline
void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
set the interline
Definition: MWAWParagraph.hxx:129
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:164
JazzWriterParser::m_state
std::shared_ptr< JazzWriterParserInternal::State > m_state
the state
Definition: JazzWriterParser.hxx:117
MWAWFontConverter.hxx
libmwaw::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string
Definition: libmwaw_internal.cxx:63
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWPrinter.hxx
JazzWriterParserInternal
Internal: the structures of a JazzWriterParser.
Definition: JazzWriterParser.cxx:56
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:85
JazzWriterParser::sendZone
bool sendZone(unsigned zId)
try to send a zone
Definition: JazzWriterParser.cxx:717
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
JazzWriterParserInternal::Paragraph
Internal: the structure used to store a paragraph/section.
Definition: JazzWriterParser.cxx:60
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
JazzWriterParserInternal::Zone::m_paragraphId
unsigned m_paragraphId
the paragraph id
Definition: JazzWriterParser.cxx:92
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
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
MWAWParagraph::m_margins
MWAWVariable< double > m_margins[3]
the margins
Definition: MWAWParagraph.hxx:148
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
JazzWriterParser::readZone
bool readZone(MWAWEntry const &entry)
tries to read the WDoc zones
Definition: JazzWriterParser.cxx:599
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:45
MWAWField::Date
@ Date
Definition: libmwaw_internal.hxx:401
JazzWriterParserInternal::State::State
State()
constructor
Definition: JazzWriterParser.cxx:101
JazzWriterParserInternal::Zone::m_hfIds
unsigned m_hfIds[2]
the header/footer id
Definition: JazzWriterParser.cxx:90
JazzWriterParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: JazzWriterParser.cxx:692
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MWAWTabStop
class to store a tab use by MWAWParagraph
Definition: MWAWParagraph.hxx:46
JazzWriterParser.hxx
MWAWSubDocument.hxx
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWSubDocument::m_input
std::shared_ptr< MWAWInputStream > m_input
the input
Definition: MWAWSubDocument.hxx:77
JazzWriterParserInternal::SubDocument::m_rsrcInput
MWAWInputStreamPtr m_rsrcInput
the resource fork input
Definition: JazzWriterParser.cxx:136
MWAWParagraph::JustificationCenter
@ JustificationCenter
Definition: MWAWParagraph.hxx:90
MWAWFont::shadowBit
@ shadowBit
Definition: MWAWFont.hxx:191
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
MWAWParagraph.hxx
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:113
MWAWRSRCParser.hxx
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
MWAWEmbeddedObject::isEmpty
bool isEmpty() const
return true if the picture contains no data
Definition: libmwaw_internal.hxx:486
JazzWriterParserInternal::Paragraph::m_nextParagraphId
unsigned m_nextParagraphId
the next paragraph id
Definition: JazzWriterParser.cxx:74
MWAWPosition.hxx
JazzWriterParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: JazzWriterParser.cxx:189
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
MWAWEntry::name
std::string const & name() const
name of the entry
Definition: MWAWEntry.hxx:153
JazzWriterParserInternal::State::m_idToParagraphs
std::map< unsigned, Paragraph > m_idToParagraphs
map WPPD id to zones
Definition: JazzWriterParser.cxx:110
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
JazzWriterParser::countCharactersInPLC
bool countCharactersInPLC(unsigned plcId, long &n)
retrieve the number of characters corresponding to a PLC
Definition: JazzWriterParser.cxx:416
JazzWriterParserInternal::Zone::Zone
Zone()
constructor
Definition: JazzWriterParser.cxx:83
JazzWriterParserInternal::SubDocument::m_zId
unsigned m_zId
the zone id
Definition: JazzWriterParser.cxx:138
JazzWriterParserInternal::Zone
Internal: the structure used to store a zone.
Definition: JazzWriterParser.cxx:81
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
MWAWPictData.hxx
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
MWAWVec2< int >
MWAWTabStop::m_alignment
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWParagraph.hxx:76
libmwaw::ParseException
Definition: libmwaw_internal.hxx:144
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
JazzWriterParser::sendPLC
bool sendPLC(unsigned pId)
try to send a plc
Definition: JazzWriterParser.cxx:750
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
JazzWriterParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: JazzWriterParser.cxx:163
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
JazzWriterParser::readPLC
bool readPLC(MWAWEntry const &entry)
tries to read the WSCR zones
JazzWriterParserInternal::Paragraph::m_paragraph
MWAWParagraph m_paragraph
the paragraph
Definition: JazzWriterParser.cxx:70
MWAWTabStop::m_position
double m_position
the tab position
Definition: MWAWParagraph.hxx:74
JazzWriterParser::checkZones
bool checkZones()
checks that the main zone exists (and its potential header/footer) and that there are valid.
Definition: JazzWriterParser.cxx:360
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:264
JazzWriterParser::createZones
bool createZones()
finds the different objects zones
Definition: JazzWriterParser.cxx:278
JazzWriterParserInternal::Paragraph::m_dimension
MWAWVec2i m_dimension
the dimension
Definition: JazzWriterParser.cxx:72
JazzWriterParser::readParagraph
bool readParagraph(MWAWEntry const &entry)
tries to read the WPPD zones
Definition: JazzWriterParser.cxx:454
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWField::PageNumber
@ PageNumber
Definition: libmwaw_internal.hxx:401
MWAWHeaderFooter::FOOTER
@ FOOTER
Definition: MWAWPageSpan.hxx:48
MWAWPosition::Char
@ Char
Definition: MWAWPosition.hxx:51
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
JazzWriterParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: JazzWriterParser.cxx:202
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
MWAWFont::setSize
void setSize(float sz, bool isRelative=false)
sets the font size
Definition: MWAWFont.hxx:275
MWAWHeaderFooter::ALL
@ ALL
Definition: MWAWPageSpan.hxx:50
JazzWriterParserInternal::Zone::m_entry
MWAWEntry m_entry
the text position in the data fork
Definition: JazzWriterParser.cxx:94
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
MWAWParagraph::m_marginsUnit
MWAWVariable< librevenge::RVNGUnit > m_marginsUnit
the margins INCH, ...
Definition: MWAWParagraph.hxx:150
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
JazzWriterParser::readString
bool readString(MWAWInputStreamPtr input, librevenge::RVNGString &string, long endPos)
try to read a C-string
Definition: JazzWriterParser.cxx:662
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
MWAWParagraph::JustificationFull
@ JustificationFull
Definition: MWAWParagraph.hxx:90
JazzWriterParserInternal::SubDocument
Internal: the subdocument of a JazzWriterParser.
Definition: JazzWriterParser.cxx:116
MWAWParagraph::JustificationRight
@ JustificationRight
Definition: MWAWParagraph.hxx:91
MWAWDocument::MWAW_T_JAZZLOTUS
@ MWAW_T_JAZZLOTUS
Jazz (Lotus): v1 ; retrieve the spreadsheet and if the resource fork is available,...
Definition: MWAWDocument.hxx:236
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
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
JazzWriterParser
the main class to read a Jazz(Lotus) word file
Definition: JazzWriterParser.hxx:57
JazzWriterParser::getPicture
bool getPicture(unsigned pId, MWAWEmbeddedObject &obj)
try to retrieve a picture
Definition: JazzWriterParser.cxx:929
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:66
JazzWriterParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: JazzWriterParser.cxx:194
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:51
MWAWInputStream.hxx
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
librevenge
Definition: MWAWDocument.hxx:57
JazzWriterParserInternal::Paragraph::m_plcId
unsigned m_plcId
the plc id
Definition: JazzWriterParser.cxx:76
JazzWriterParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: JazzWriterParser.cxx:232
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
JazzWriterParserInternal::Paragraph::Paragraph
Paragraph()
constructor
Definition: JazzWriterParser.cxx:62
JazzWriterParser::JazzWriterParser
JazzWriterParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: JazzWriterParser.cxx:178
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
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325

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