Debian Codegraph @

src/lib/StyleParser.hxx

raw
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 ([email protected])
18 * Copyright (C) 2002,2004 Marc Maurer ([email protected])
19 * Copyright (C) 2004-2006 Fridrich Strba ([email protected])
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent ([email protected])
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
53 /** \brief the main class to read a Style file
54 */
55 class StyleParser final : public MWAWTextParser
56 {
57 public:
58 //! constructor
59 StyleParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
60 //! destructor
61 ~StyleParser() final;
62
63 //! checks if the document header is correct (or not)
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:
70 //! creates the listener which will be associated to the document
71 void createDocument(librevenge::RVNGTextInterface *documentInterface);
72
73 //! adds a new page
74 void newPage(int number);
75
76 protected:
77 //! finds the different objects zones
78 bool createZones();
79 //! tries to read the main entry map
80 bool readTypeEntryMap();
81 //! tries to read the background color: bgcl
82 bool readBackgroundColor(MWAWEntry const &entry);
83 //! tries to read the format: cfor (v1.9)
84 bool readFormats(MWAWEntry const &entry);
85 //! tries to read the extra property zone: xprc
86 bool readExtraProperties(MWAWEntry const &entry);
87 //! tries to read the font table: fntb (v1.6)
88 bool readFontNames(MWAWEntry const &entry);
89 /** tries to read the font correspondance zone: font, contains the
90 font id, the position in fntb and many unknown datas (v1.6).*/
91 bool readFontCorr(MWAWEntry const &entry);
92 //! tries to read the style zone: styl
93 bool readStyleTable(MWAWEntry const &entry);
94 //! tries to read the margins zone: marg
95 bool readMargins(MWAWEntry const &entry);
96 //! tries to read the printer info zone: prec
97 bool readPrintInfo(MWAWEntry const &entry);
98 //! tries to read the plc zone: runa or para
99 bool readPLCs(MWAWEntry const &entry, bool para);
100 //! tries to read the pictures zone: soup
101 bool readPictures(MWAWEntry const &entry);
102 //! tries to read the rule zone: rule
103 bool readRules(MWAWEntry const &entry);
104 //! tries to read the stat zone: stat
105 bool readStat(MWAWEntry const &entry);
106 //! tries to read the tab width zone : tabw
107 bool readTabWidth(MWAWEntry const &entry);
108 //! tries to read the version zone: vers
109 bool readVersion(MWAWEntry const &entry);
110
111 /** compute the number of page of a zone*/
112 int computeNumPages(MWAWEntry const &entry, bool unicodeChar) const;
113
114 /** try to send the main text*/
115 bool sendText(MWAWEntry const &entry, bool unicodeChar);
116 //! try to send a picture knowing the char position
117 bool sendPicture(StyleParserInternal::Picture const &pict);
118
119 //
120 // data
121 //
122 //! the state
123 std::shared_ptr<StyleParserInternal::State> m_state;
124 };
125 #endif
126 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: