RagTimeText.hxx Source File documentation

RagTimeText.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 RagTime text document
36 *
37 */
38 #ifndef RAGTIME_TEXT
39 # define RAGTIME_TEXT
40
41 #include <list>
42 #include <string>
43 #include <vector>
44
45 #include "libmwaw_internal.hxx"
46
47 #include "MWAWEntry.hxx"
48 #include "MWAWSubDocument.hxx"
49
50 #include "MWAWDebug.hxx"
51 #include "MWAWInputStream.hxx"
52
53 #include "MWAWParser.hxx"
54
55 namespace RagTimeTextInternal
56 {
57 struct TextZone;
58 struct Token;
59
60 struct State;
61 }
62
63 class RagTimeParser;
64
70 class RagTimeText
71 {
72 friend class RagTimeParser;
73 public:
75 explicit RagTimeText(RagTimeParser &parser);
77 virtual ~RagTimeText();
78
80 int version() const;
81
83 int getFontId(int localId) const;
85 bool getCharStyle(int charId, MWAWFont &font) const;
86
87 protected:
89 bool readFontNames(MWAWEntry &entry);
91 bool readCharProperties(MWAWEntry &entry);
92
94 bool readTextZone(MWAWEntry &entry, int width, MWAWColor const &fontColor=MWAWColor::black());
96 bool readFonts(RagTimeTextInternal::TextZone &zone, MWAWColor const &color, long endPos);
98 bool readParagraphs(RagTimeTextInternal::TextZone &zone, int width, long endPos);
100 bool readTokens(RagTimeTextInternal::TextZone &zone, long endPos);
101
103 bool send(int id, MWAWListenerPtr listener);
105 void flushExtra();
106
107 //
108 // low level
109 //
110
112 bool send(RagTimeTextInternal::TextZone const &zone, MWAWListenerPtr listener);
113
114 private:
115 RagTimeText(RagTimeText const &orig) = delete;
116 RagTimeText &operator=(RagTimeText const &orig) = delete;
117
118 protected:
119 //
120 // data
121 //
123 MWAWParserStatePtr m_parserState;
124
126 std::shared_ptr<RagTimeTextInternal::State> m_state;
127
129 RagTimeParser *m_mainParser;
130 };
131 #endif
132 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
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
RagTimeTextInternal::TextZone::m_fontPosList
std::vector< long > m_fontPosList
the beginning of character properties in the text zone
Definition: RagTimeText.cxx:177
MWAWFont::set
void set(Script const &newscript)
sets the script position
Definition: MWAWFont.hxx:314
RagTimeParser::getDateTimeFormat
bool getDateTimeFormat(int dtId, std::string &dtFormat) const
returns the ith date format or ""
Definition: RagTimeParser.cxx:462
RagTimeTextInternal::State::m_localFIdMap
std::map< int, int > m_localFIdMap
a map local fontId->fontId
Definition: RagTimeText.cxx:213
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
RagTimeText::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: RagTimeText.hxx:123
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
RagTimeTextInternal::State::m_idTextMap
std::map< int, std::shared_ptr< TextZone > > m_idTextMap
a map entry id to text zone
Definition: RagTimeText.cxx:217
RagTimeParser.hxx
RagTimeTextInternal::TextZone::m_paragraphPosList
std::vector< long > m_paragraphPosList
the beginning of paragraph properties in the text zone
Definition: RagTimeText.cxx:181
MWAWParagraph::m_tabs
MWAWVariable< std::vector< MWAWTabStop > > m_tabs
the tabulations
Definition: MWAWParagraph.hxx:162
RagTimeTextInternal::Token::m_DTFormat
std::string m_DTFormat
the date time format
Definition: RagTimeText.cxx:156
RagTimeTextInternal::State::getFontId
int getFontId(int localId) const
return a mac font id corresponding to a local id
Definition: RagTimeText.cxx:203
MWAWField::m_DTFormat
std::string m_DTFormat
the date/time format using strftime format if defined
Definition: libmwaw_internal.hxx:424
MWAWFont::Script::sub100
static Script sub100()
return a yposition which correspond to a basic subscript100
Definition: MWAWFont.hxx:125
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:190
RagTimeTextInternal::TextZone::m_paragraphList
std::vector< MWAWParagraph > m_paragraphList
the list of paragraph's properties
Definition: RagTimeText.cxx:183
MWAWFont::setColor
void setColor(MWAWColor color)
sets the font color
Definition: MWAWFont.hxx:341
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
MWAWEntry.hxx
RagTimeTextInternal::Token::m_type
Type m_type
the token type
Definition: RagTimeText.cxx:150
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
RagTimeText::readTokens
bool readTokens(RagTimeTextInternal::TextZone &zone, long endPos)
try to read the token zones
Definition: RagTimeText.cxx:840
RagTimeText::m_mainParser
RagTimeParser * m_mainParser
the main parser;
Definition: RagTimeText.hxx:129
MWAWParagraph::m_spacings
MWAWVariable< double > m_spacings[3]
the line spacing
Definition: MWAWParagraph.hxx:156
RagTimeTextInternal::TextZone::m_isSent
bool m_isSent
true if the zone is sent to the listener
Definition: RagTimeText.cxx:187
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:84
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
RagTimeTextInternal::Token::m_listIndices
int m_listIndices[4]
the four list indices
Definition: RagTimeText.cxx:154
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
RagTimeText.hxx
RagTimeText::version
int version() const
returns the file version
Definition: RagTimeText.cxx:235
RagTimeTextInternal::Token
Internal: a token of a RagTimeText.
Definition: RagTimeText.cxx:58
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWFont::setDeltaLetterSpacing
void setDeltaLetterSpacing(float d, librevenge::RVNGUnit unit=librevenge::RVNG_POINT)
sets the letter spacing ( delta value in point )
Definition: MWAWFont.hxx:292
RagTimeTextInternal::Token::PageCount
@ PageCount
Definition: RagTimeText.cxx:60
RagTimeParser::getZoneDataFieldSize
int getZoneDataFieldSize(int zId) const
returns the size of a zone data field
Definition: RagTimeParser.cxx:443
MWAWParagraph::m_margins
MWAWVariable< double > m_margins[3]
the margins
Definition: MWAWParagraph.hxx:148
MWAWEntry::type
const std::string & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
MWAWTabStop::DECIMAL
@ DECIMAL
Definition: MWAWParagraph.hxx:48
RagTimeTextInternal::Token::List
@ List
Definition: RagTimeText.cxx:60
MWAWFont::Script::super100
static Script super100()
return a yposition which correspond to a basic superscript100
Definition: MWAWFont.hxx:135
MWAWFont::embossBit
@ embossBit
Definition: MWAWFont.hxx:190
MWAWField::PageCount
@ PageCount
Definition: libmwaw_internal.hxx:401
RagTimeParser
the main class to read a RagTime v2-3 file
Definition: RagTimeParser.hxx:60
RagTimeText::readTextZone
bool readTextZone(MWAWEntry &entry, int width, MWAWColor const &fontColor=MWAWColor::black())
try to read a text zone (knowing the zone width in point and the font color)
Definition: RagTimeText.cxx:436
MWAWField::Date
@ Date
Definition: libmwaw_internal.hxx:401
RagTimeText::readParagraphs
bool readParagraphs(RagTimeTextInternal::TextZone &zone, int width, long endPos)
try to read the paragraph properties (knowing the zone width in point used to determine the right mar...
Definition: RagTimeText.cxx:687
MWAWTabStop
class to store a tab use by MWAWParagraph
Definition: MWAWParagraph.hxx:46
MWAWSubDocument.hxx
RagTimeTextInternal::Token::Time
@ Time
Definition: RagTimeText.cxx:60
RagTimeTextInternal::Token::operator<<
friend std::ostream & operator<<(std::ostream &o, Token const &tkn)
operator<<
Definition: RagTimeText.cxx:71
RagTimeText::readFontNames
bool readFontNames(MWAWEntry &entry)
try to read the font name: the FHFo structure: FileH?Font zone
Definition: RagTimeText.cxx:260
RagTimeTextInternal::TextZone::m_fontList
std::vector< MWAWFont > m_fontList
the list of character's properties
Definition: RagTimeText.cxx:179
MWAWParagraph::AtLeast
@ AtLeast
Definition: MWAWParagraph.hxx:94
RagTimeText::operator=
RagTimeText & operator=(RagTimeText const &orig)=delete
MWAWParagraph::JustificationCenter
@ JustificationCenter
Definition: MWAWParagraph.hxx:90
RagTimeTextInternal::TextZone::TextZone
TextZone()
constructor
Definition: RagTimeText.cxx:164
MWAWFont::shadowBit
@ shadowBit
Definition: MWAWFont.hxx:191
MWAWParagraph.hxx
libmwaw_internal.hxx
RagTimeText::m_state
std::shared_ptr< RagTimeTextInternal::State > m_state
the state
Definition: RagTimeText.hxx:126
RagTimeText::getCharStyle
bool getCharStyle(int charId, MWAWFont &font) const
returns font style corresponding to a char style id
Definition: RagTimeText.cxx:247
MWAWPosition.hxx
RagTimeTextInternal::State::m_version
int m_version
the file version
Definition: RagTimeText.cxx:211
RagTimeTextInternal::Token::Type
Type
the token's types
Definition: RagTimeText.cxx:60
RagTimeTextInternal::Token::getIndicesString
bool getIndicesString(std::string &str) const
returns a string corresponding to the list indices
Definition: RagTimeText.cxx:134
RagTimeTextInternal::TextZone::m_textPos
MWAWEntry m_textPos
the text zone
Definition: RagTimeText.cxx:175
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
RagTimeText
the main class to read the text part of ragTime file
Definition: RagTimeText.hxx:70
RagTimeTextInternal::Token::PageAfter
@ PageAfter
Definition: RagTimeText.cxx:60
MWAWField::None
@ None
Definition: libmwaw_internal.hxx:401
RagTimeText::RagTimeText
RagTimeText(RagTimeParser &parser)
constructor
Definition: RagTimeText.cxx:225
RagTimeTextInternal::State::m_charPropList
std::vector< MWAWFont > m_charPropList
the character properties
Definition: RagTimeText.cxx:215
RagTimeTextInternal::Token::m_listLevel
int m_listLevel
the list level(for a list)
Definition: RagTimeText.cxx:152
MWAWPictMac.hxx
MWAWTabStop::m_alignment
Alignment m_alignment
the alignment ( left, center, ...)
Definition: MWAWParagraph.hxx:76
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
RagTimeTextInternal::Token::Date
@ Date
Definition: RagTimeText.cxx:60
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
RagTimeTextInternal::Token::Token
Token()
constructor
Definition: RagTimeText.cxx:62
RagTimeTextInternal::TextZone
Internal: a text's zone of a RagTimeText.
Definition: RagTimeText.cxx:162
MWAWColor::black
static MWAWColor black()
return the back color
Definition: libmwaw_internal.hxx:245
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
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWField::PageNumber
@ PageNumber
Definition: libmwaw_internal.hxx:401
RagTimeText::flushExtra
void flushExtra()
flush extra zone
Definition: RagTimeText.cxx:1141
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
RagTimeParser::getColor
bool getColor(int colId, MWAWColor &color, int listId=-1) const
returns the ith color ( if possible)
Definition: RagTimeParser.cxx:427
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
MWAWParagraph::m_marginsUnit
MWAWVariable< librevenge::RVNGUnit > m_marginsUnit
the margins INCH, ...
Definition: MWAWParagraph.hxx:150
RagTimeText::readFonts
bool readFonts(RagTimeTextInternal::TextZone &zone, MWAWColor const &color, long endPos)
try to read the character properties (knowing the font color)
Definition: RagTimeText.cxx:537
RagTimeText::getFontId
int getFontId(int localId) const
returns a mac font id corresponding to a local id
Definition: RagTimeText.cxx:242
MWAWTextListener.hxx
RagTimeTextInternal::Token::m_extra
std::string m_extra
extra data
Definition: RagTimeText.cxx:158
MWAWParagraph::JustificationRight
@ JustificationRight
Definition: MWAWParagraph.hxx:91
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
RagTimeTextInternal::State
Internal: the state of a RagTimeText.
Definition: RagTimeText.cxx:192
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
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
RagTimeTextInternal::State::State
State()
constructor
Definition: RagTimeText.cxx:194
RagTimeTextInternal::Token::Unknown
@ Unknown
Definition: RagTimeText.cxx:60
MWAWFont::Script
a small struct to define the script position in MWAWFont
Definition: MWAWFont.hxx:106
MWAWInputStream.hxx
RagTimeText::readCharProperties
bool readCharProperties(MWAWEntry &entry)
try to read the character properties zone: FHsl zone
Definition: RagTimeText.cxx:344
RagTimeText::send
bool send(int id, MWAWListenerPtr listener)
try to send a text zone
Definition: RagTimeText.cxx:959
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
MWAWFont.hxx
RagTimeTextInternal
Internal: the structures of a RagTimeText.
Definition: RagTimeText.cxx:55
MWAWTabStop::RIGHT
@ RIGHT
Definition: MWAWParagraph.hxx:48
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWFont::setLanguage
void setLanguage(std::string const &lang)
set the language ( in the for en_US, en_GB, en, ...)
Definition: MWAWFont.hxx:500
RagTimeTextInternal::Token::getField
bool getField(MWAWField &field) const
returns a field corresponding to the token if possible
Definition: RagTimeText.cxx:106
RagTimeTextInternal::TextZone::m_tokenList
std::vector< Token > m_tokenList
the list of tokens
Definition: RagTimeText.cxx:185
RagTimeTextInternal::Token::Page
@ Page
Definition: RagTimeText.cxx:60
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
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325
RagTimeText::~RagTimeText
virtual ~RagTimeText()
destructor
Definition: RagTimeText.cxx:232