StyleParser.hxx Source File documentation

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
55 class StyleParser final : public MWAWTextParser
56 {
57 public:
59 StyleParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
61 ~StyleParser() final;
62
64 bool checkHeader(MWAWHeader *header, bool strict=false) final;
65
66 // the main parse function
67 void parse(librevenge::RVNGTextInterface *documentInterface) final;
68
69 protected:
71 void createDocument(librevenge::RVNGTextInterface *documentInterface);
72
74 void newPage(int number);
75
76 protected:
78 bool createZones();
80 bool readTypeEntryMap();
82 bool readBackgroundColor(MWAWEntry const &entry);
84 bool readFormats(MWAWEntry const &entry);
86 bool readExtraProperties(MWAWEntry const &entry);
88 bool readFontNames(MWAWEntry const &entry);
91 bool readFontCorr(MWAWEntry const &entry);
93 bool readStyleTable(MWAWEntry const &entry);
95 bool readMargins(MWAWEntry const &entry);
97 bool readPrintInfo(MWAWEntry const &entry);
99 bool readPLCs(MWAWEntry const &entry, bool para);
101 bool readPictures(MWAWEntry const &entry);
103 bool readRules(MWAWEntry const &entry);
105 bool readStat(MWAWEntry const &entry);
107 bool readTabWidth(MWAWEntry const &entry);
109 bool readVersion(MWAWEntry const &entry);
110
112 int computeNumPages(MWAWEntry const &entry, bool unicodeChar) const;
113
115 bool sendText(MWAWEntry const &entry, bool unicodeChar);
117 bool sendPicture(StyleParserInternal::Picture const &pict);
118
119 //
120 // data
121 //
123 std::shared_ptr<StyleParserInternal::State> m_state;
124 };
125 #endif
126 // 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
StyleParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: StyleParser.cxx:201
StyleParser::readStat
bool readStat(MWAWEntry const &entry)
tries to read the stat zone: stat
Definition: StyleParser.cxx:1448
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
StyleParserInternal::State::State
State()
constructor
Definition: StyleParser.cxx:100
StyleParserInternal::State
Internal: the state of a StyleParser.
Definition: StyleParser.cxx:98
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:130
MWAWFont::set
void set(Script const &newscript)
sets the script position
Definition: MWAWFont.hxx:314
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
StyleParserInternal::State::m_paragraphList
std::vector< MWAWParagraph > m_paragraphList
the list of paragraph style
Definition: StyleParser.cxx:128
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:122
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
StyleParserInternal::State::m_fontList
std::vector< Font > m_fontList
the list of font style
Definition: StyleParser.cxx:126
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:121
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
StyleParser::readBackgroundColor
bool readBackgroundColor(MWAWEntry const &entry)
tries to read the background color: bgcl
Definition: StyleParser.cxx:1325
MWAWFont::setColor
void setColor(MWAWColor color)
sets the font color
Definition: MWAWFont.hxx:341
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
StyleParser::m_state
std::shared_ptr< StyleParserInternal::State > m_state
the state
Definition: StyleParser.hxx:123
MWAWParagraph::setInterline
void setInterline(double value, librevenge::RVNGUnit unit, LineSpacingType type=Fixed)
set the interline
Definition: MWAWParagraph.hxx:129
StyleParser::StyleParser
StyleParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: StyleParser.cxx:143
StyleParserInternal::Picture::m_entry
MWAWEntry m_entry
the picture entry
Definition: StyleParser.cxx:74
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
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWParagraph::m_spacings
MWAWVariable< double > m_spacings[3]
the line spacing
Definition: MWAWParagraph.hxx:156
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:108
StyleParser::readTabWidth
bool readTabWidth(MWAWEntry const &entry)
tries to read the tab width zone : tabw
Definition: StyleParser.cxx:1484
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:84
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
MWAWFont::Line::Simple
@ Simple
Definition: MWAWFont.hxx:49
MWAWBorder::m_width
double m_width
the border total width in point
Definition: libmwaw_internal.hxx:387
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
StyleParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: StyleParser.cxx:135
StyleParser::readVersion
bool readVersion(MWAWEntry const &entry)
tries to read the version zone: vers
Definition: StyleParser.cxx:1510
MWAWEntry::setParsed
void setParsed(bool ok=true) const
sets the flag m_parsed to true or false
Definition: MWAWEntry.hxx:126
StyleParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: StyleParser.cxx:135
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:134
MWAWFont::setDeltaLetterSpacing
void setDeltaLetterSpacing(float d, librevenge::RVNGUnit unit=librevenge::RVNG_POINT)
sets the letter spacing ( delta value in point )
Definition: MWAWFont.hxx:292
MWAWParagraph::m_margins
MWAWVariable< double > m_margins[3]
the margins
Definition: MWAWParagraph.hxx:148
MWAWBorder::Dot
@ Dot
Definition: libmwaw_internal.hxx:335
MWAWEntry::type
const std::string & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
StyleParser::sendPicture
bool sendPicture(StyleParserInternal::Picture const &pict)
try to send a picture knowing the char position
Definition: StyleParser.cxx:1667
StyleParser::readTypeEntryMap
bool readTypeEntryMap()
tries to read the main entry map
Definition: StyleParser.cxx:358
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
StyleParser::readRules
bool readRules(MWAWEntry const &entry)
tries to read the rule zone: rule
Definition: StyleParser.cxx:812
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:427
StyleParser::readMargins
bool readMargins(MWAWEntry const &entry)
tries to read the margins zone: marg
Definition: StyleParser.cxx:1354
MWAWSubDocument.hxx
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
MWAWParagraph::m_borders
std::vector< MWAWVariable< MWAWBorder > > m_borders
list of border ( order MWAWBorder::Pos)
Definition: MWAWParagraph.hxx:186
MWAWPageSpan::setBackgroundColor
void setBackgroundColor(MWAWColor color=MWAWColor::white())
set the background color
Definition: MWAWPageSpan.hxx:258
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
MWAWParagraph::JustificationCenter
@ JustificationCenter
Definition: MWAWParagraph.hxx:90
MWAWFont::shadowBit
@ shadowBit
Definition: MWAWFont.hxx:191
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:132
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:158
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
MWAWParser::getPageSpan
const MWAWPageSpan & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
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
StyleParserInternal::Picture::Picture
Picture()
constructor
Definition: StyleParser.cxx:61
libmwaw::Bottom
@ Bottom
Definition: libmwaw_internal.hxx:176
StyleParser::computeNumPages
int computeNumPages(MWAWEntry const &entry, bool unicodeChar) const
compute the number of page of a zone
Definition: StyleParser.cxx:1543
StyleParser::readStyleTable
bool readStyleTable(MWAWEntry const &entry)
tries to read the style zone: styl
Definition: StyleParser.cxx:502
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:183
MWAWPosition.hxx
StyleParserInternal::Font
small structure used to store a font and a picture
Definition: StyleParser.cxx:78
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:668
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:47
StyleParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: StyleParser.cxx:1701
MWAWBorder
a border
Definition: libmwaw_internal.hxx:333
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
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:454
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
MWAWPictData.hxx
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
MWAWVec2< int >
libmwaw::ParseException
Definition: libmwaw_internal.hxx:143
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:56
StyleParserInternal::Picture::m_size
MWAWVec2i m_size
the picture size in point
Definition: StyleParser.cxx:72
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
StyleParser::readPrintInfo
bool readPrintInfo(MWAWEntry const &entry)
tries to read the printer info zone: prec
Definition: StyleParser.cxx:1398
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:72
StyleParser::~StyleParser
~StyleParser() final
destructor
Definition: StyleParser.cxx:150
StyleParserInternal::Picture::valid
bool valid() const
returns true if the picture is valid
Definition: StyleParser.cxx:67
StyleParser::readFormats
bool readFormats(MWAWEntry const &entry)
tries to read the format: cfor (v1.9)
Definition: StyleParser.cxx:580
MWAWFont::setId
void setId(int newId)
sets the font id
Definition: MWAWFont.hxx:264
StyleParser::readPictures
bool readPictures(MWAWEntry const &entry)
tries to read the pictures zone: soup
Definition: StyleParser.cxx:1038
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:169
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
MWAWPosition::Char
@ Char
Definition: MWAWPosition.hxx:51
StyleParserInternal::Font::Font
Font()
constructor
Definition: StyleParser.cxx:80
StyleParserInternal
Internal: the structures of a StyleParser.
Definition: StyleParser.cxx:56
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:157
StyleParserInternal::Font::m_picture
Picture m_picture
the picture
Definition: StyleParser.cxx:93
MWAWHeader.hxx
MWAWBorder::m_style
Style m_style
the border style
Definition: libmwaw_internal.hxx:380
StyleParserInternal::Font::hasPicture
bool hasPicture() const
returns true if the picture is valid
Definition: StyleParser.cxx:86
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
MWAWBox2i
MWAWBox2< int > MWAWBox2i
MWAWBox2 of int.
Definition: libmwaw_internal.hxx:1191
StyleParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: StyleParser.cxx:173
StyleParserInternal::State::m_textEntry
MWAWEntry m_textEntry
the text entry
Definition: StyleParser.cxx:120
MWAWFont::italicBit
@ italicBit
Definition: MWAWFont.hxx:190
StyleParserInternal::State::m_unicodeChar
bool m_unicodeChar
true if the character are unicode character
Definition: StyleParser.cxx:118
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:998
MWAWParagraph::JustificationFull
@ JustificationFull
Definition: MWAWParagraph.hxx:90
MWAWParagraph::JustificationRight
@ JustificationRight
Definition: MWAWParagraph.hxx:91
StyleParser::sendText
bool sendText(MWAWEntry const &entry, bool unicodeChar)
try to send the main text
Definition: StyleParser.cxx:1557
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:91
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
StyleParserInternal::State::m_fontIdToFinalIdList
std::vector< int > m_fontIdToFinalIdList
list of font final id
Definition: StyleParser.cxx:124
MWAWFont::setBackgroundColor
void setBackgroundColor(MWAWColor color)
sets the font background color
Definition: MWAWFont.hxx:352
StyleParser::readFontNames
bool readFontNames(MWAWEntry const &entry)
tries to read the font table: fntb (v1.6)
Definition: StyleParser.cxx:421
MWAWFont::Script
a small struct to define the script position in MWAWFont
Definition: MWAWFont.hxx:106
StyleParserInternal::State::m_posParagraphIdMap
std::map< long, int > m_posParagraphIdMap
a map pos->paragraphId
Definition: StyleParser.cxx:132
MWAWInputStream.hxx
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:84
MWAWFont.hxx
StyleParser::createZones
bool createZones()
finds the different objects zones
Definition: StyleParser.cxx:231
MWAWFont::flags
uint32_t flags() const
returns the font flags
Definition: MWAWFont.hxx:320
StyleParser
the main class to read a Style file
Definition: StyleParser.hxx:55
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:213
StyleParserInternal::State::m_entryMap
std::map< std::string, MWAWEntry > m_entryMap
the map type to entry
Definition: StyleParser.cxx:116
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
StyleParser::readExtraProperties
bool readExtraProperties(MWAWEntry const &entry)
tries to read the extra property zone: xprc
Definition: StyleParser.cxx:1121
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:98
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:163
MWAWFont::setFlags
void setFlags(uint32_t fl)
sets the font attributes bold, ...
Definition: MWAWFont.hxx:325