DocMkrText.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 /*
35  * Parser to Nisus text document
36  *
37  */
38 #ifndef DOC_MKR_TEXT
39 # define DOC_MKR_TEXT
40 
41 #include "libmwaw_internal.hxx"
42 #include "MWAWDebug.hxx"
43 
44 namespace DocMkrTextInternal
45 {
46 struct Zone;
47 
48 class SubDocument;
49 struct State;
50 }
51 
52 class DocMkrParser;
53 
60 {
62  friend class DocMkrParser;
63 public:
65  explicit DocMkrText(DocMkrParser &parser);
67  virtual ~DocMkrText();
68 
70  int version() const;
71 
73  int numPages() const;
74 
76  int numChapters() const;
77 
79  void sendComment(std::string const &str);
80 
81 protected:
82 
84  bool createZones();
85 
87  bool sendMainText();
88 
90  void flushExtra();
91 
92  //
93  // intermediate level
94  //
95 
97  void computeNumPages(DocMkrTextInternal::Zone const &zone) const;
98 
100  void updatePageSpanList(std::vector<MWAWPageSpan> &spanList);
101 
103  bool sendText(DocMkrTextInternal::Zone const &zone);
104 
106  bool readFontNames(MWAWEntry const &entry);
107 
109  bool readStyles(MWAWEntry const &entry);
110 
112  bool readTOC(MWAWEntry const &entry);
113 
115  bool sendTOC();
116 
118  bool readWindows(MWAWEntry const &entry);
119 
121  bool readFooter(MWAWEntry const &entry);
122 
124  bool sendFooter(int zId);
125 
126  //
127  // low level
128  //
129 
131  void sendString(std::string const &str) const;
132 private:
133  DocMkrText(DocMkrText const &orig) = delete;
134  DocMkrText &operator=(DocMkrText const &orig) = delete;
135 
136 protected:
137  //
138  // data
139  //
142 
144  std::shared_ptr<DocMkrTextInternal::State> m_state;
145 
148 
149 };
150 #endif
151 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
DocMkrTextInternal::SubDocument::parse
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final
the parser function
Definition: DocMkrText.cxx:245
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
DocMkrTextInternal::Zone::m_name
std::string m_name
the name
Definition: DocMkrText.cxx:158
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
DocMkrTextInternal::TOC::TOC
TOC()
constructor
Definition: DocMkrText.cxx:63
DocMkrTextInternal::Footer::m_userInfo
std::string m_userInfo
the user information entry
Definition: DocMkrText.cxx:126
DocMkrParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: DocMkrParser.cxx:240
DocMkrText::updatePageSpanList
void updatePageSpanList(std::vector< MWAWPageSpan > &spanList)
update the page span list
Definition: DocMkrText.cxx:357
MWAWTabStop::m_leaderCharacter
uint16_t m_leaderCharacter
the leader char
Definition: MWAWParagraph.hxx:78
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
DocMkrTextInternal::SubDocument::m_id
int m_id
the subdocument id
Definition: DocMkrText.cxx:235
DocMkrTextInternal::Zone::Zone
Zone()
constructor
Definition: DocMkrText.cxx:135
MWAWParagraph::m_tabs
MWAWVariable< std::vector< MWAWTabStop > > m_tabs
the tabulations
Definition: MWAWParagraph.hxx:162
DocMkrTextInternal::State::getZone
Zone & getZone(int id)
returns the zone corresponding to an id
Definition: DocMkrText.cxx:181
DocMkrText::sendText
bool sendText(DocMkrTextInternal::Zone const &zone)
try to send the text corresponding to a zone
Definition: DocMkrText.cxx:505
libmwaw::DOC_COMMENT_ANNOTATION
@ DOC_COMMENT_ANNOTATION
Definition: libmwaw_internal.hxx:188
DocMkrText::DocMkrText
DocMkrText(DocMkrText const &orig)=delete
MWAWField::m_DTFormat
std::string m_DTFormat
the date/time format using strftime format if defined
Definition: libmwaw_internal.hxx:424
DocMkrText::sendFooter
bool sendFooter(int zId)
try to send a footer corresponding to a zone id
Definition: DocMkrText.cxx:894
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
DocMkrTextInternal::SubDocument
Internal: the subdocument of a DocMkrText.
Definition: DocMkrText.cxx:205
DocMkrParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: DocMkrParser.cxx:235
DocMkrTextInternal::State::State
State()
constructor
Definition: DocMkrText.cxx:170
MWAWFont::setColor
void setColor(MWAWColor color)
sets the font color
Definition: MWAWFont.hxx:341
DocMkrTextInternal::State::m_toc
TOC m_toc
the table of content
Definition: DocMkrText.cxx:199
MWAWTabStop::CENTER
@ CENTER
Definition: MWAWParagraph.hxx:48
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
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
DocMkrText::sendString
void sendString(std::string const &str) const
send a string to the listener
Definition: DocMkrText.cxx:1029
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
DocMkrText::createZones
bool createZones()
finds the different text zones
Definition: DocMkrText.cxx:406
DocMkrTextInternal::Zone::m_posFontMap
std::map< long, MWAWFont > m_posFontMap
the map of id -> font
Definition: DocMkrText.cxx:160
DocMkrTextInternal::Footer::m_font
MWAWFont m_font
the font
Definition: DocMkrText.cxx:120
DocMkrText::DocMkrText
DocMkrText(DocMkrParser &parser)
constructor
Definition: DocMkrText.cxx:285
DocMkrText::~DocMkrText
virtual ~DocMkrText()
destructor
Definition: DocMkrText.cxx:292
DocMkrTextInternal::SubDocument::m_type
libmwaw::SubDocumentType m_type
the subdocument type
Definition: DocMkrText.cxx:239
DocMkrTextInternal::SubDocument::SubDocument
SubDocument(DocMkrText &pars, MWAWInputStreamPtr const &input, int id, libmwaw::SubDocumentType type)
constructor for a footer zone
Definition: DocMkrText.cxx:208
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
DocMkrText::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: DocMkrText.hxx:141
DocMkrTextInternal::Footer::operator<<
friend std::ostream & operator<<(std::ostream &o, Footer const &f)
operator<<
Definition: DocMkrText.cxx:100
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
MWAWHeaderFooter::m_subDocument
MWAWSubDocumentPtr m_subDocument
the document data
Definition: MWAWPageSpan.hxx:92
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
DocMkrText::readWindows
bool readWindows(MWAWEntry const &entry)
try to read the windows information zone? ( resource Wndo )
Definition: DocMkrText.cxx:833
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
DocMkrTextInternal::SubDocument::m_textParser
DocMkrText * m_textParser
the text parser
Definition: DocMkrText.cxx:233
DocMkrText::readStyles
bool readStyles(MWAWEntry const &entry)
try to read the styles ( resource styl )
Definition: DocMkrText.cxx:648
DocMkrText::computeNumPages
void computeNumPages(DocMkrTextInternal::Zone const &zone) const
compute the number of page of a zone
Definition: DocMkrText.cxx:340
MWAWFont::embossBit
@ embossBit
Definition: MWAWFont.hxx:190
DocMkrParser
the main class to read a DocMake file
Definition: DocMkrParser.hxx:57
MWAWHeaderFooter
a class which stores the header/footer data
Definition: MWAWPageSpan.hxx:45
DocMkrTextInternal::State::m_pageWidth
double m_pageWidth
the page width ( not really define so default value 8.5)
Definition: DocMkrText.cxx:193
MWAWField::Date
@ Date
Definition: libmwaw_internal.hxx:401
DocMkrText::sendMainText
bool sendMainText()
send a main zone
Definition: DocMkrText.cxx:1038
MWAWTabStop
class to store a tab use by MWAWParagraph
Definition: MWAWParagraph.hxx:46
DocMkrText::numChapters
int numChapters() const
returns the number of chapter
Definition: DocMkrText.cxx:320
MWAWSubDocument.hxx
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
DocMkrTextInternal::TOC::m_textList
std::vector< std::string > m_textList
the toc texts
Definition: DocMkrText.cxx:76
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:258
DocMkrText::flushExtra
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: DocMkrText.cxx:1053
MWAWSubDocument::m_input
std::shared_ptr< MWAWInputStream > m_input
the input
Definition: MWAWSubDocument.hxx:77
MWAWFont::m_extra
std::string m_extra
extra data
Definition: MWAWFont.hxx:573
MWAWParagraph::JustificationCenter
@ JustificationCenter
Definition: MWAWParagraph.hxx:90
DocMkrTextInternal::Footer::m_items
int m_items[6]
the item values
Definition: DocMkrText.cxx:124
MWAWParagraph::Justification
Justification
an enum used to defined the paragraph justification: left, center, right, full ...
Definition: MWAWParagraph.hxx:90
MWAWFont::shadowBit
@ shadowBit
Definition: MWAWFont.hxx:191
MWAWParagraph.hxx
DocMkrTextInternal::SubDocument::operator=
SubDocument & operator=(SubDocument const &orig)=delete
MWAWRSRCParser.hxx
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
libmwaw_internal.hxx
DocMkrTextInternal::Zone::m_justify
MWAWParagraph::Justification m_justify
the paragraph justification
Definition: DocMkrText.cxx:150
MWAWPosition.hxx
DocMkrTextInternal::State::m_idZoneMap
std::map< int, Zone > m_idZoneMap
the map of id -> text zone
Definition: DocMkrText.cxx:195
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
libmwaw::DOC_HEADER_FOOTER
@ DOC_HEADER_FOOTER
Definition: libmwaw_internal.hxx:188
DocMkrTextInternal::Zone
Internal: structure to store a the data of a DocMkrText Zone.
Definition: DocMkrText.cxx:133
DocMkrTextInternal::Footer
Internal: structure to store a footer data of a DocMkrText.
Definition: DocMkrText.cxx:81
DocMkrTextInternal::Footer::m_extra
std::string m_extra
extra data
Definition: DocMkrText.cxx:128
MWAWTabStop::m_alignment
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWParagraph.hxx:76
DocMkrTextInternal::State::m_numPages
int m_numPages
Definition: DocMkrText.cxx:191
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
DocMkrTextInternal::SubDocument::m_text
std::string m_text
the string text
Definition: DocMkrText.cxx:237
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
DocMkrTextInternal::Zone::m_backgroundColor
MWAWColor m_backgroundColor
the background color
Definition: DocMkrText.cxx:152
DocMkrTextInternal
Internal: the structures of a DocMkrText.
Definition: DocMkrText.cxx:58
DocMkrTextInternal::Zone::m_pos
MWAWEntry m_pos
the text entry
Definition: DocMkrText.cxx:148
MWAWTabStop::m_position
double m_position
the tab position
Definition: MWAWParagraph.hxx:74
DocMkrTextInternal::Footer::m_chapterResetPage
bool m_chapterResetPage
true if a chapter reset page
Definition: DocMkrText.cxx:122
DocMkrTextInternal::SubDocument::SubDocument
SubDocument(SubDocument const &orig)=delete
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:264
DocMkrTextInternal::SubDocument::~SubDocument
~SubDocument() final
destructor
Definition: DocMkrText.cxx:224
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
MWAWHeaderFooter::FOOTER
@ FOOTER
Definition: MWAWPageSpan.hxx:48
DocMkrText::operator=
DocMkrText & operator=(DocMkrText const &orig)=delete
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
DocMkrText::sendTOC
bool sendTOC()
try to send a TOC zone
Definition: DocMkrText.cxx:717
DocMkrTextInternal::State::m_footer
Footer m_footer
the footer
Definition: DocMkrText.cxx:197
DocMkrText::readFooter
bool readFooter(MWAWEntry const &entry)
try to read the footer zone ( resource foot )
Definition: DocMkrText.cxx:968
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
MWAWPageSpan.hxx
DocMkrText::numPages
int numPages() const
returns the number of pages
Definition: DocMkrText.cxx:303
DocMkrTextInternal::State::m_actualPage
int m_actualPage
Definition: DocMkrText.cxx:191
DocMkrParser.hxx
DocMkrText::m_mainParser
DocMkrParser * m_mainParser
the main parser;
Definition: DocMkrText.hxx:147
MWAWTextListener.hxx
Defines MWAWTextListener: the libmwaw word processor listener.
DocMkrTextInternal::TOC
Internal: structure to store a table of contents of a DocMkrText.
Definition: DocMkrText.cxx:61
MWAWParagraph::JustificationRight
@ JustificationRight
Definition: MWAWParagraph.hxx:91
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
DocMkrTextInternal::Footer::empty
bool empty() const
returns true if the footer is empty
Definition: DocMkrText.cxx:92
DocMkrParser::sendPicture
bool sendPicture(int zId, int lId, double lineW)
try to send a picture knowing zId and local id
Definition: DocMkrParser.cxx:430
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
DocMkrText::sendComment
void sendComment(std::string const &str)
send a string as comment
Definition: DocMkrText.cxx:325
DocMkrTextInternal::Zone::m_parsed
bool m_parsed
a flag to know if we have send the data to the listener
Definition: DocMkrText.cxx:164
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
DocMkrTextInternal::Footer::Footer
Footer()
constructor
Definition: DocMkrText.cxx:83
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
DocMkrText.hxx
DocMkrText
the main class to read the text part of DocMaker file
Definition: DocMkrText.hxx:60
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
MWAWFont.hxx
DocMkrText::version
int version() const
returns the file version
Definition: DocMkrText.cxx:296
DocMkrTextInternal::State
Internal: the state of a DocMkrText.
Definition: DocMkrText.cxx:168
DocMkrTextInternal::Zone::m_numPages
int m_numPages
the number of page
Definition: DocMkrText.cxx:162
MWAWTabStop::RIGHT
@ RIGHT
Definition: MWAWParagraph.hxx:48
DocMkrTextInternal::TOC::empty
bool empty() const
returns true if the table is empty
Definition: DocMkrText.cxx:69
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
DocMkrText::readTOC
bool readTOC(MWAWEntry const &entry)
try to read a TOC zone? ( resource cnt# )
Definition: DocMkrText.cxx:771
DocMkrText::m_state
std::shared_ptr< DocMkrTextInternal::State > m_state
the state
Definition: DocMkrText.hxx:144
MWAWField::Title
@ Title
Definition: libmwaw_internal.hxx:401
DocMkrTextInternal::Zone::m_useFooter
bool m_useFooter
print or ignore the footer
Definition: DocMkrText.cxx:154
DocMkrTextInternal::TOC::m_cIdList
std::vector< int > m_cIdList
the toc chapter id
Definition: DocMkrText.cxx:74
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWPageSpan::setPageNumber
void setPageNumber(const int pageNumber)
set the page number
Definition: MWAWPageSpan.hxx:263
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
DocMkrTextInternal::SubDocument::operator!=
bool operator!=(MWAWSubDocument const &doc) const final
operator!=
Definition: DocMkrText.cxx:269
DocMkrTextInternal::Zone::m_margins
int m_margins[4]
the margins L,T,R,B in points
Definition: DocMkrText.cxx:156
DocMkrParser::newPage
void newPage(int number)
adds a new page
Definition: DocMkrParser.cxx:248
DocMkrTextInternal::State::m_version
int m_version
the file version
Definition: DocMkrText.cxx:189
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325
DocMkrText::readFontNames
bool readFontNames(MWAWEntry const &entry)
try to read the font name ( resource rQDF )
Definition: DocMkrText.cxx:576
DocMkrTextInternal::SubDocument::SubDocument
SubDocument(DocMkrText &pars, MWAWInputStreamPtr const &input, std::string const &text, libmwaw::SubDocumentType type)
constructor for a comment zone
Definition: DocMkrText.cxx:216

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