ActaParser.hxx Source File documentation

ActaParser.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 ACTA_PARSER
35 # define ACTA_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWDebug.hxx"
43 #include "MWAWInputStream.hxx"
44
45 #include "MWAWParser.hxx"
46
47 namespace ActaParserInternal
48 {
49 class SubDocument;
50 struct State;
51 }
52
53 class ActaText;
54
57 class ActaParser final : public MWAWTextParser
58 {
59 friend class ActaParserInternal::SubDocument;
60 friend class ActaText;
61 public:
63 ActaParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
65 ~ActaParser() final;
66
68 bool checkHeader(MWAWHeader *header, bool strict=false) final;
69
70 // the main parse function
71 void parse(librevenge::RVNGTextInterface *documentInterface) final;
72
73 protected:
75 void init();
76
78 void createDocument(librevenge::RVNGTextInterface *documentInterface);
79
81 MWAWVec2f getPageLeftTop() const;
83 void newPage(int number);
84
85 // interface with the text parser
86
88 std::shared_ptr<MWAWList> getMainList();
89
90 protected:
92 bool createZones();
93
95 bool readRSRCZones();
96
98 bool readEndDataV3();
99
101 void sendHeaderFooter();
102
104 bool readPrintInfo(MWAWEntry const &entry);
105
107 bool readWindowPos(MWAWEntry const &entry);
108
110 bool readLabel(MWAWEntry const &entry);
111
113 bool readHFProperties(MWAWEntry const &entry);
114
116 bool readOption(MWAWEntry const &entry);
117
118 //
119 // low level
120 //
121
123 MWAWInputStreamPtr rsrcInput();
124
126 libmwaw::DebugFile &rsrcAscii();
127
128 //
129 // data
130 //
131
133 std::shared_ptr<ActaParserInternal::State> m_state;
134
136 std::shared_ptr<ActaText> m_textParser;
137 };
138 #endif
139 // 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:46
ActaParserInternal::State::State
State()
constructor
Definition: ActaParser.cxx:197
ActaParserInternal::Option
Internal: class used to store the optional preferences in ActaParser.
Definition: ActaParser.cxx:162
ActaParserInternal::Printing::isEmpty
bool isEmpty() const
returns true if the header is empty
Definition: ActaParser.cxx:115
ActaParser::readWindowPos
bool readWindowPos(MWAWEntry const &entry)
read the window position ( WSIZ resource block )
Definition: ActaParser.cxx:784
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:298
ActaParserInternal::Printing::m_font
MWAWFont m_font
the font
Definition: ActaParser.cxx:155
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:150
ActaParser::readRSRCZones
bool readRSRCZones()
read the resource fork zone
Definition: ActaParser.cxx:540
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
ActaParserInternal::Printing::operator<<
friend std::ostream & operator<<(std::ostream &o, Printing const &print)
operator<<
Definition: ActaParser.cxx:136
MWAWHeaderFooter::HEADER
@ HEADER
Definition: MWAWPageSpan.hxx:48
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MWAWListLevel::m_suffix
librevenge::RVNGString m_suffix
string which follows the number if we have an ordered level
Definition: MWAWList.hxx:113
ActaParserInternal
Internal: the structures of a ActaParser.
Definition: ActaParser.cxx:57
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
ActaParserInternal::State::m_label
Label m_label
the list type
Definition: ActaParser.cxx:214
ActaParser::ActaParser
ActaParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: ActaParser.cxx:268
ActaParserInternal::State::m_printerPreferences
Printing m_printerPreferences
the printer preferences
Definition: ActaParser.cxx:210
MWAWField::m_DTFormat
std::string m_DTFormat
the date/time format using strftime format if defined
Definition: libmwaw_internal.hxx:424
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:64
ActaParserInternal::State::m_title
std::string m_title
the title (if defined)
Definition: ActaParser.cxx:212
ActaParserInternal::Label::operator!=
bool operator!=(Label const &lbl) const
operator=!
Definition: ActaParser.cxx:96
MWAWListLevel::NONE
@ NONE
Definition: MWAWList.hxx:46
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MWAWListLevel::LOWER_ALPHA
@ LOWER_ALPHA
Definition: MWAWList.hxx:46
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:164
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
ActaParserInternal::Printing::Printing
Printing()
constructor
Definition: ActaParser.cxx:108
MWAWFontConverter.hxx
libmwaw::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string
Definition: libmwaw_internal.cxx:63
ActaParserInternal::Label
Internal: class used to store a list type in ActaParser.
Definition: ActaParser.cxx:61
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWPrinter.hxx
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:84
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
ActaParser::init
void init()
inits all internal variables
Definition: ActaParser.cxx:280
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
ActaParserInternal::Label::operator==
bool operator==(Label const &lbl) const
operator==
Definition: ActaParser.cxx:91
MWAWListLevel::UPPER_ALPHA
@ UPPER_ALPHA
Definition: MWAWList.hxx:46
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_ACTA
@ MWAW_T_ACTA
Acta (v2 and Classic v1)
Definition: MWAWDocument.hxx:101
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
ActaParser::readOption
bool readOption(MWAWEntry const &entry)
read the QOPT resource block (small print change )
Definition: ActaParser.cxx:886
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:41
ActaParser::readEndDataV3
bool readEndDataV3()
read the end file data zones
Definition: ActaParser.cxx:607
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
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:44
ActaParser::m_state
std::shared_ptr< ActaParserInternal::State > m_state
the state
Definition: ActaParser.hxx:133
ActaParser::readLabel
bool readLabel(MWAWEntry const &entry)
read the label type
Definition: ActaParser.cxx:813
MWAWField::Date
@ Date
Definition: libmwaw_internal.hxx:401
ActaParserInternal::Option::m_flags
int m_flags
the flags
Definition: ActaParser.cxx:190
MWAWSubDocument.hxx
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
ActaParserInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: ActaParser.cxx:232
ActaParserInternal::SubDocument
Internal: the subdocument of a ActaParser.
Definition: ActaParser.cxx:225
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
ActaParser.hxx
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
MWAWList
a small structure used to store the informations about a list
Definition: MWAWList.hxx:122
MWAWListLevel::UPPER_ROMAN
@ UPPER_ROMAN
Definition: MWAWList.hxx:47
ActaParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: ActaParser.cxx:217
MWAWRSRCParser.hxx
ActaParserInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: ActaParser.cxx:249
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
ActaParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: ActaParser.cxx:220
ActaParserInternal::SubDocument::SubDocument
SubDocument(ActaParser &pars, MWAWInputStreamPtr const &input)
Definition: ActaParser.cxx:228
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
ActaParser::getMainList
std::shared_ptr< MWAWList > getMainList()
returns a list to be used in the text
Definition: ActaParser.cxx:316
MWAWListManagerPtr
std::shared_ptr< MWAWListManager > MWAWListManagerPtr
a smart pointer of MWAWListManager
Definition: libmwaw_internal.hxx:555
ActaParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: ActaParser.cxx:293
ActaParser::createZones
bool createZones()
finds the different objects zones
Definition: ActaParser.cxx:525
ActaText.hxx
MWAWParser::asciiName
const std::string & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
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
ActaParser::readHFProperties
bool readHFProperties(MWAWEntry const &entry)
read the Header/Footer property (QHDR block)
Definition: ActaParser.cxx:836
MWAWVec2< float >
ActaParserInternal::State
Internal: the state of a ActaParser.
Definition: ActaParser.cxx:195
libmwaw::ParseException
Definition: libmwaw_internal.hxx:143
ActaParserInternal::Printing::m_flags
int m_flags[2]
the flags
Definition: ActaParser.cxx:157
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
ActaParser
the main class to read a Acta file
Definition: ActaParser.hxx:57
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
ActaParser::newPage
void newPage(int number)
adds a new page
Definition: ActaParser.cxx:397
MWAWListLevel::LOWER_ROMAN
@ LOWER_ROMAN
Definition: MWAWList.hxx:47
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:264
ActaParserInternal::Printing::operator!=
bool operator!=(Printing const &print) const
operator=!
Definition: ActaParser.cxx:131
ActaParserInternal::Label::Label
Label(int type=-1)
constructor
Definition: ActaParser.cxx:63
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWField::PageNumber
@ PageNumber
Definition: libmwaw_internal.hxx:401
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
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
ActaParserInternal::State::m_stringLabel
std::string m_stringLabel
the custom label (if defined)
Definition: ActaParser.cxx:216
ActaParserInternal::Label::m_type
int m_type
the label type
Definition: ActaParser.cxx:101
MWAWHeader.hxx
MWAWFont::setSize
void setSize(float sz, bool isRelative=false)
sets the font size
Definition: MWAWFont.hxx:275
MWAWHeaderFooter::ALL
@ ALL
Definition: MWAWPageSpan.hxx:50
MWAWListLevel::m_bullet
librevenge::RVNGString m_bullet
the bullet if we have an bullet level
Definition: MWAWList.hxx:114
MWAWList.hxx
MWAWListLevel::DECIMAL
@ DECIMAL
Definition: MWAWList.hxx:46
ActaParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: ActaParser.cxx:219
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
ActaParserInternal::Label::operator<<
friend std::ostream & operator<<(std::ostream &o, Label const &lbl)
operator<<
Definition: ActaParser.cxx:66
MWAWTextListener.hxx
MWAWListLevel::BULLET
@ BULLET
Definition: MWAWList.hxx:46
MWAWSubDocument::m_parser
MWAWParser * m_parser
the main zone parser
Definition: MWAWSubDocument.hxx:75
MWAWListLevel
small structure to keep information about a list level
Definition: MWAWList.hxx:44
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWListLevel::m_type
Type m_type
the type of the level
Definition: MWAWList.hxx:101
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
ActaParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: ActaParser.cxx:413
MWAWListLevel::m_numBeforeLabels
int m_numBeforeLabels
the number of label to show before this
Definition: MWAWList.hxx:103
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
MWAWListLevel::m_labelAfterSpace
double m_labelAfterSpace
the minimum distance between the label and the text
Definition: MWAWList.hxx:106
ActaParserInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: ActaParser.cxx:235
ActaParserInternal::Option::operator<<
friend std::ostream & operator<<(std::ostream &o, Option const &opt)
operator<<
Definition: ActaParser.cxx:167
ActaParser::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
read a PrintInfo block ( PSET resource block )
Definition: ActaParser.cxx:730
ActaParserInternal::Option::Option
Option(int flags=0)
constructor
Definition: ActaParser.cxx:164
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition: libmwaw_internal.cxx:50
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:56
ActaParser::sendHeaderFooter
void sendHeaderFooter()
sends the header/footer data
Definition: ActaParser.cxx:474
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:213
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWListLevel::m_prefix
librevenge::RVNGString m_prefix
string which preceedes the number if we have an ordered level
Definition: MWAWList.hxx:112
MWAWField::Title
@ Title
Definition: libmwaw_internal.hxx:401
ActaParser::m_textParser
std::shared_ptr< ActaText > m_textParser
the text parser
Definition: ActaParser.hxx:136
ActaParserInternal::Printing
Internal: class used to store the printing preferences in ActaParser.
Definition: ActaParser.cxx:106
ActaParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: ActaParser.cxx:442
ActaText
the main class to read the text part of Acta Text file
Definition: ActaText.hxx:57
ActaParserInternal::Printing::operator==
bool operator==(Printing const &print) const
operator==
Definition: ActaParser.cxx:120
ActaParser::ActaText
friend class ActaText
Definition: ActaParser.hxx:60
ActaParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: ActaParser.cxx:916
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
ActaParser::~ActaParser
~ActaParser() final
destructor
Definition: ActaParser.cxx:276
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:98
ActaParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: ActaParser.cxx:306
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163
ActaParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: ActaParser.cxx:298
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325
ActaParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: ActaParser.cxx:217