MouseWrtParser.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 MOUSE_WRT_PARSER
35 # define MOUSE_WRT_PARSER
36 
37 #include <vector>
38 
39 #include "MWAWDebug.hxx"
40 #include "MWAWInputStream.hxx"
41 
42 #include "MWAWParser.hxx"
43 
44 namespace MouseWrtParserInternal
45 {
46 struct State;
47 class SubDocument;
48 }
49 
55 class MouseWrtParser final : public MWAWTextParser
56 {
58 
59 public:
61  MouseWrtParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
63  ~MouseWrtParser() 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 createZones();
77 
79  bool readCharPLCs(long sz);
81  bool readParagraphPLCs(long sz);
83  bool readPrintInfo();
85  bool readDocumentInfo(long sz);
86 
87  // low level
88 
90  bool readFont(MWAWFont &font, int &cPos);
91 
93  void newPage(int number);
95  int computeNumPages();
97  bool sendMainZone();
99  bool sendZone(int number);
100 
101 protected:
102  //
103  // data
104  //
106  std::shared_ptr<MouseWrtParserInternal::State> m_state;
107 };
108 #endif
109 // 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
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
MouseWrtParserInternal::State::m_text
MWAWEntry m_text
the main text entry
Definition: MouseWrtParser.cxx:115
MouseWrtParserInternal::State::State
State()
constructor
Definition: MouseWrtParser.cxx:97
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
MouseWrtParser
the main class to read a MouseWrite file
Definition: MouseWrtParser.hxx:56
MWAWHeaderFooter::HEADER
@ HEADER
Definition: MWAWPageSpan.hxx:48
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MouseWrtParserInternal::Zone
Internal: class to store zone information of a MouseWrtParser.
Definition: MouseWrtParser.cxx:60
MouseWrtParserInternal::Paragraph::Paragraph
Paragraph(int id=0)
constructor
Definition: MouseWrtParser.cxx:80
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
MouseWrtParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MouseWrtParser.cxx:332
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MouseWrtParserInternal::Zone::Zone
Zone()
constructor
Definition: MouseWrtParser.cxx:62
MouseWrtParserInternal::State::m_paraPLCMap
std::map< int, Paragraph > m_paraPLCMap
the map position to paraPLC
Definition: MouseWrtParser.cxx:113
MWAWParagraph::m_writingMode
MWAWVariable< libmwaw::WritingMode > m_writingMode
the writing mode
Definition: MWAWParagraph.hxx:171
MWAWParagraph::m_tabs
MWAWVariable< std::vector< MWAWTabStop > > m_tabs
the tabulations
Definition: MWAWParagraph.hxx:162
MouseWrtParserInternal::Zone::m_writingHebrew
bool m_writingHebrew
flag to know if the writing is reverted
Definition: MouseWrtParser.cxx:71
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
MouseWrtParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: MouseWrtParser.cxx:132
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
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
MouseWrtParserInternal::SubDocument
Internal: the subdocument of a MouseWrtParser.
Definition: MouseWrtParser.cxx:123
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
MouseWrtParserInternal::State::m_blockSizes
long m_blockSizes[5]
the first zone's size
Definition: MouseWrtParser.cxx:109
MWAWFontConverter.hxx
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MouseWrtParser::readParagraphPLCs
bool readParagraphPLCs(long sz)
reads the paragraph plc zone: zone 2
Definition: MouseWrtParser.cxx:440
MouseWrtParser::sendMainZone
bool sendMainZone()
tries to send the main text zone
Definition: MouseWrtParser.cxx:738
MWAWPrinter.hxx
MouseWrtParser::newPage
void newPage(int number)
adds a new page
Definition: MouseWrtParser.cxx:189
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:85
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
MouseWrtParserInternal::SubDocument::m_id
int m_id
the subdocument id
Definition: MouseWrtParser.cxx:142
MWAWHeaderFooter::m_subDocument
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:92
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
MWAWDocument::MWAW_T_MOUSEWRITE
@ MWAW_T_MOUSEWRITE
MouseWrite: v1.
Definition: MWAWDocument.hxx:216
MouseWrtParserInternal::Paragraph::m_picture
bool m_picture
flag to know if this is a picture
Definition: MouseWrtParser.cxx:91
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:145
MouseWrtParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MouseWrtParser.cxx:234
MouseWrtParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: MouseWrtParser.cxx:162
MWAWPageSpan::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:157
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
MouseWrtParserInternal::SubDocument::SubDocument
SubDocument(MouseWrtParser &pars, MWAWInputStreamPtr const &input, int zoneId)
Definition: MouseWrtParser.cxx:125
MouseWrtParser::createZones
bool createZones()
finds the different objects zones
Definition: MouseWrtParser.cxx:269
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
MouseWrtParserInternal::State::m_charPLCMap
std::map< int, MWAWFont > m_charPLCMap
the map position to charPLC
Definition: MouseWrtParser.cxx:111
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:45
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
MWAWSubDocument.hxx
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
MouseWrtParserInternal::Zone::m_text
MWAWEntry m_text
the text entry
Definition: MouseWrtParser.cxx:73
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
MWAWFont::m_extra
std::string m_extra
extra data
Definition: MWAWFont.hxx:573
MWAWParser::getMainListener
MWAWListenerPtr getMainListener()
returns the main listener
Definition: MWAWParser.cxx:120
MWAWParagraph::JustificationCenter
@ JustificationCenter
Definition: MWAWParagraph.hxx:90
MouseWrtParser::~MouseWrtParser
~MouseWrtParser() final
destructor
Definition: MouseWrtParser.cxx:182
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
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
MouseWrtParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: MouseWrtParser.cxx:107
MouseWrtParser.hxx
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
MouseWrtParserInternal::State
Internal: the state of a MouseWrtParser.
Definition: MouseWrtParser.cxx:95
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
MWAWVec2< int >
MWAWPictMac.hxx
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
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
MouseWrtParser::readDocumentInfo
bool readDocumentInfo(long sz)
reads the document info zone: zone 4
Definition: MouseWrtParser.cxx:572
MWAWTabStop::m_position
double m_position
the tab position
Definition: MWAWParagraph.hxx:74
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:264
MouseWrtParserInternal::Zone::m_font
MWAWFont m_font
the font
Definition: MouseWrtParser.cxx:69
MouseWrtParserInternal::Paragraph::m_paragraph
MWAWParagraph m_paragraph
the paragraph
Definition: MouseWrtParser.cxx:89
MouseWrtParserInternal
Internal: the structures of a MouseWrtParser.
Definition: MouseWrtParser.cxx:57
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
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWFont::setSize
void setSize(float sz, bool isRelative=false)
sets the font size
Definition: MWAWFont.hxx:275
MWAWHeaderFooter::ALL
@ ALL
Definition: MWAWPageSpan.hxx:50
MouseWrtParser::m_state
std::shared_ptr< MouseWrtParserInternal::State > m_state
the state
Definition: MouseWrtParser.hxx:106
MouseWrtParser::sendZone
bool sendZone(int number)
tries to send the header/footer zone
Definition: MouseWrtParser.cxx:887
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
MouseWrtParser::readFont
bool readFont(MWAWFont &font, int &cPos)
try to read a font
Definition: MouseWrtParser.cxx:413
MouseWrtParser::readCharPLCs
bool readCharPLCs(long sz)
reads the char plc zone: zone 0
Definition: MouseWrtParser.cxx:383
MouseWrtParserInternal::Paragraph
Internal: class to store paragraph information of a MouseWrtParser.
Definition: MouseWrtParser.cxx:78
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
MouseWrtParser::readPrintInfo
bool readPrintInfo()
reads the print info zone: zone 3
Definition: MouseWrtParser.cxx:685
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
MWAWParagraph::JustificationFull
@ JustificationFull
Definition: MWAWParagraph.hxx:90
MWAWParagraph::JustificationRight
@ JustificationRight
Definition: MWAWParagraph.hxx:91
MouseWrtParser::computeNumPages
int computeNumPages()
computes the number of page
Definition: MouseWrtParser.cxx:655
MouseWrtParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: MouseWrtParser.cxx:205
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
MWAWPageSpan::setHeaderFooter
void setHeaderFooter(MWAWHeaderFooter const &headerFooter)
add a header/footer on some page
Definition: MWAWPageSpan.cxx:227
MouseWrtParserInternal::Paragraph::m_id
int m_id
the paragraph id
Definition: MouseWrtParser.cxx:87
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
MouseWrtParserInternal::State::m_zones
Zone m_zones[2]
the header and the footer zone
Definition: MouseWrtParser.cxx:117
MWAWFont.hxx
MWAWPosition::m_anchorTo
AnchorTo m_anchorTo
anchor position
Definition: MWAWPosition.hxx:270
librevenge
Definition: MWAWDocument.hxx:57
MWAWBox2< int >
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
libmwaw::WritingRightTop
@ WritingRightTop
Definition: libmwaw_internal.hxx:185
MouseWrtParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: MouseWrtParser.cxx:145
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
MouseWrtParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: MouseWrtParser.cxx:107
MouseWrtParser::MouseWrtParser
MouseWrtParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: MouseWrtParser.cxx:175
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