StyleParser.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 STYLE_PARSER
35 # define STYLE_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 StyleParserInternal
48 {
49 struct Picture;
50 struct State;
51 }
52 
56 {
57  friend class TTText;
58 public:
60  StyleParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
62  virtual ~StyleParser();
63 
65  bool checkHeader(MWAWHeader *header, bool strict=false);
66 
67  // the main parse function
68  void parse(librevenge::RVNGTextInterface *documentInterface);
69 
70 protected:
72  void createDocument(librevenge::RVNGTextInterface *documentInterface);
73 
75  void newPage(int number);
76 
77 protected:
79  bool createZones();
81  bool readTypeEntryMap();
83  bool readBackgroundColor(MWAWEntry const &entry);
85  bool readFormats(MWAWEntry const &entry);
87  bool readExtraProperties(MWAWEntry const &entry);
89  bool readFontNames(MWAWEntry const &entry);
92  bool readFontCorr(MWAWEntry const &entry);
94  bool readStyleTable(MWAWEntry const &entry);
96  bool readMargins(MWAWEntry const &entry);
98  bool readPrintInfo(MWAWEntry const &entry);
100  bool readPLCs(MWAWEntry const &entry, bool para);
102  bool readPictures(MWAWEntry const &entry);
104  bool readRules(MWAWEntry const &entry);
106  bool readStat(MWAWEntry const &entry);
108  bool readTabWidth(MWAWEntry const &entry);
110  bool readVersion(MWAWEntry const &entry);
111 
113  int computeNumPages(MWAWEntry const &entry, bool unicodeChar) const;
114 
116  bool sendText(MWAWEntry const &entry, bool unicodeChar);
118  bool sendPicture(StyleParserInternal::Picture const &pict);
119 
120  //
121  // data
122  //
124  shared_ptr<StyleParserInternal::State> m_state;
125 };
126 #endif
127 // 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:47
StyleParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: StyleParser.cxx:187
StyleParser::readStat
bool readStat(MWAWEntry const &entry)
tries to read the stat zone: stat
Definition: StyleParser.cxx:1438
MWAWParagraph::m_justify
MWAWVariable< Justification > m_justify
the justification
Definition: MWAWParagraph.hxx:161
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:296
StyleParserInternal::State::State
State()
constructor
Definition: StyleParser.cxx:96
StyleParserInternal::State
Internal: the state of a StyleParser.
Definition: StyleParser.cxx:94
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:150
StyleParserInternal::State::m_posFontIdMap
std::map< long, int > m_posFontIdMap
a map pos->font id
Definition: StyleParser.cxx:117
MWAWFont::set
void set(Script const &newscript)
sets the script position
Definition: MWAWFont.hxx:293
MWAWTextListenerPtr
shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:519
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:262
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:127
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:785
StyleParserInternal::State::m_paragraphList
std::vector< MWAWParagraph > m_paragraphList
the list of paragraph style
Definition: StyleParser.cxx:115
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
StyleParserInternal::State::m_backgroundColor
MWAWColor m_backgroundColor
the background color
Definition: StyleParser.cxx:109
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:221
StyleParserInternal::State::m_fontList
std::vector< Font > m_fontList
the list of font style
Definition: StyleParser.cxx:113
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:110
MWAWFont::boldBit
@ boldBit
Definition: MWAWFont.hxx:182
MWAWTextListener
This class contents the main functions needed to create a Word processing Document.
Definition: MWAWTextListener.hxx:65
StyleParser::readBackgroundColor
bool readBackgroundColor(MWAWEntry const &entry)
tries to read the background color: bgcl
Definition: StyleParser.cxx:1315
MWAWFont::setColor
void setColor(MWAWColor color)
sets the font color
Definition: MWAWFont.hxx:320
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
MWAWParagraph::setInterline
void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
set the interline
Definition: MWAWParagraph.hxx:123
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:153
StyleParserInternal::Picture::m_entry
MWAWEntry m_entry
the picture entry
Definition: StyleParser.cxx:72
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:202
MWAWFontConverter.hxx
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:182
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:425
StyleParser::TTText
friend class TTText
Definition: StyleParser.hxx:57
MWAWParagraph::m_spacings
MWAWVariable< double > m_spacings[3]
the line spacing
Definition: MWAWParagraph.hxx:150
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:126
StyleParser::readTabWidth
bool readTabWidth(MWAWEntry const &entry)
tries to read the tab width zone : tabw
Definition: StyleParser.cxx:1474
StyleParserInternal::Picture
small structure used to store picture data in StyleParser
Definition: StyleParser.cxx:59
MWAWPrinter.hxx
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:82
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:187
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
MWAWBorder::m_width
double m_width
the border total width in point
Definition: libmwaw_internal.hxx:357
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
StyleParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: StyleParser.cxx:122
StyleParser::readVersion
bool readVersion(MWAWEntry const &entry)
tries to read the version zone: vers
Definition: StyleParser.cxx:1500
StyleParser::m_state
shared_ptr< StyleParserInternal::State > m_state
the state
Definition: StyleParser.hxx:124
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:115
StyleParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: StyleParser.cxx:122
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
StyleParserInternal::State::m_posPictureMap
std::map< long, Picture > m_posPictureMap
a map pos->pictEntry
Definition: StyleParser.cxx:121
MWAWFont::setDeltaLetterSpacing
void setDeltaLetterSpacing(float d, librevenge::RVNGUnit unit=librevenge::RVNG_POINT)
sets the letter spacing ( delta value in point )
Definition: MWAWFont.hxx:271
MWAWParagraph::m_margins
MWAWVariable< double > m_margins[3]
the margins
Definition: MWAWParagraph.hxx:142
MWAWBorder::Dot
@ Dot
Definition: libmwaw_internal.hxx:316
StyleParser::sendPicture
bool sendPicture(StyleParserInternal::Picture const &pict)
try to send a picture knowing the char position
Definition: StyleParser.cxx:1658
StyleParser::readTypeEntryMap
bool readTypeEntryMap()
tries to read the main entry map
Definition: StyleParser.cxx:345
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:182
StyleParser::readRules
bool readRules(MWAWEntry const &entry)
tries to read the rule zone: rule
Definition: StyleParser.cxx:801
MWAWFont::setStrikeOutStyle
void setStrikeOutStyle(Line::Style style=Line::None, bool doReset=true)
sets the strikeoutline style ( by default, we also reset the style)
Definition: MWAWFont.hxx:406
StyleParser::readMargins
bool readMargins(MWAWEntry const &entry)
tries to read the margins zone: marg
Definition: StyleParser.cxx:1344
MWAWSubDocument.hxx
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:172
MWAWParagraph::m_borders
std::vector< MWAWVariable< MWAWBorder > > m_borders
list of border ( order MWAWBorder::Pos)
Definition: MWAWParagraph.hxx:180
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:252
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:85
MWAWFont::m_extra
std::string m_extra
extra data
Definition: MWAWFont.hxx:552
StyleParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface)
virtual function used to parse the input
Definition: StyleParser.cxx:159
MWAWParagraph::JustificationCenter
@ JustificationCenter
Definition: MWAWParagraph.hxx:87
MWAWFont::shadowBit
@ shadowBit
Definition: MWAWFont.hxx:183
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:121
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:146
MWAWParagraph.hxx
libmwaw::DebugFile::skipZone
void skipZone(long beginPos, long endPos)
skips the file zone defined by beginPos-endPos
Definition: MWAWDebug.hxx:105
MWAWFont::getDebugString
std::string getDebugString(shared_ptr< MWAWFontConverter > &converter) const
returns a string which can be used for debugging
Definition: MWAWFont.cxx:181
MWAWRSRCParser.hxx
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:620
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:197
StyleParserInternal::Picture::Picture
Picture()
constructor
Definition: StyleParser.cxx:61
libmwaw::Bottom
@ Bottom
Definition: libmwaw_internal.hxx:166
StyleParser::computeNumPages
int computeNumPages(MWAWEntry const &entry, bool unicodeChar) const
compute the number of page of a zone
Definition: StyleParser.cxx:1533
StyleParser::readStyleTable
bool readStyleTable(MWAWEntry const &entry)
tries to read the style zone: styl
Definition: StyleParser.cxx:489
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:177
MWAWPosition.hxx
StyleParserInternal::Font
small structure used to store a font and a picture
Definition: StyleParser.cxx:76
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:615
MWAWDocument::MWAW_T_STYLE
@ MWAW_T_STYLE
Style: v1.6, v1.9.
Definition: MWAWDocument.hxx:180
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
MWAWBorder
a border
Definition: libmwaw_internal.hxx:314
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:56
StyleParser::readFontCorr
bool readFontCorr(MWAWEntry const &entry)
tries to read the font correspondance zone: font, contains the font id, the position in fntb and many...
Definition: StyleParser.cxx:441
MWAWParser::setVersion
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:206
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:82
MWAWPictData.hxx
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
StyleParser::StyleParser
StyleParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: StyleParser.cxx:130
MWAWVec2< int >
libmwaw::ParseException
Definition: libmwaw_internal.hxx:142
MWAWDebug.hxx
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
StyleParserInternal::Picture::m_size
MWAWVec2i m_size
the picture size in point
Definition: StyleParser.cxx:70
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:72
StyleParser::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
tries to read the printer info zone: prec
Definition: StyleParser.cxx:1388
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:61
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
StyleParserInternal::Picture::valid
bool valid() const
returns true if the picture is valid
Definition: StyleParser.cxx:65
StyleParser::readFormats
bool readFormats(MWAWEntry const &entry)
tries to read the format: cfor (v1.9)
Definition: StyleParser.cxx:569
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:243
StyleParser::readPictures
bool readPictures(MWAWEntry const &entry)
tries to read the pictures zone: soup
Definition: StyleParser.cxx:1027
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:158
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:197
libmwaw::PrinterInfo::read
bool read(MWAWInputStreamPtr input)
reads the struture in a file
Definition: MWAWPrinter.cxx:218
MWAWPosition::Char
@ Char
Definition: MWAWPosition.hxx:51
StyleParserInternal::Font::Font
Font()
constructor
Definition: StyleParser.cxx:78
StyleParserInternal
Internal: the structures of a StyleParser.
Definition: StyleParser.cxx:57
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
StyleParser::newPage
void newPage(int number)
adds a new page
Definition: StyleParser.cxx:143
StyleParserInternal::Font::m_picture
Picture m_picture
the picture
Definition: StyleParser.cxx:89
MWAWHeader.hxx
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
MWAWBorder::m_style
Style m_style
the border style
Definition: libmwaw_internal.hxx:350
StyleParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: StyleParser.cxx:1692
StyleParserInternal::Font::hasPicture
bool hasPicture() const
returns true if the picture is valid
Definition: StyleParser.cxx:82
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:77
MWAWFont::setSize
void setSize(float sz, bool isRelative=false)
sets the font size
Definition: MWAWFont.hxx:254
MWAWBox2i
MWAWBox2< int > MWAWBox2i
MWAWBox2 of int.
Definition: libmwaw_internal.hxx:1132
StyleParser::~StyleParser
virtual ~StyleParser()
destructor
Definition: StyleParser.cxx:136
StyleParserInternal::State::m_textEntry
MWAWEntry m_textEntry
the text entry
Definition: StyleParser.cxx:107
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:182
StyleParserInternal::State::m_unicodeChar
bool m_unicodeChar
true if the character are unicode character
Definition: StyleParser.cxx:105
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
MWAWTextListener.hxx
StyleParser::readPLCs
bool readPLCs(MWAWEntry const &entry, bool para)
tries to read the plc zone: runa or para
Definition: StyleParser.cxx:987
MWAWParagraph::JustificationFull
@ JustificationFull
Definition: MWAWParagraph.hxx:87
MWAWParagraph::JustificationRight
@ JustificationRight
Definition: MWAWParagraph.hxx:88
StyleParser::sendText
bool sendText(MWAWEntry const &entry, bool unicodeChar)
try to send the main text
Definition: StyleParser.cxx:1547
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
StyleParserInternal::Font::m_font
MWAWFont m_font
the font
Definition: StyleParser.cxx:87
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr ip)
resets the input
Definition: MWAWDebug.hxx:73
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:192
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:88
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:513
StyleParserInternal::State::m_fontIdToFinalIdList
std::vector< int > m_fontIdToFinalIdList
list of font final id
Definition: StyleParser.cxx:111
MWAWFont::setBackgroundColor
void setBackgroundColor(MWAWColor color)
sets the font background color
Definition: MWAWFont.hxx:331
StyleParser::readFontNames
bool readFontNames(MWAWEntry const &entry)
tries to read the font table: fntb (v1.6)
Definition: StyleParser.cxx:408
MWAWFont::Script
a small struct to define the script position in MWAWFont
Definition: MWAWFont.hxx:100
StyleParserInternal::State::m_posParagraphIdMap
std::map< long, int > m_posParagraphIdMap
a map pos->paragraphId
Definition: StyleParser.cxx:119
MWAWInputStream.hxx
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:82
MWAWFont.hxx
StyleParser::createZones
bool createZones()
finds the different objects zones
Definition: StyleParser.cxx:217
MWAWFont::flags
uint32_t flags() const
returns the font flags
Definition: MWAWFont.hxx:299
StyleParser
the main class to read a Style file
Definition: StyleParser.hxx:56
StyleParser.hxx
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:207
StyleParserInternal::State::m_entryMap
std::map< std::string, MWAWEntry > m_entryMap
the map type to entry
Definition: StyleParser.cxx:103
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
StyleParser::readExtraProperties
bool readExtraProperties(MWAWEntry const &entry)
tries to read the extra property zone: xprc
Definition: StyleParser.cxx:1110
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:781
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:445
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:96
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:151
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:304

Generated on Wed Jun 17 2020 06:30:13 for libmwaw by doxygen 1.8.18