Debian Codegraph @

src/lib/RagTimeParser.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 RAG_TIME_PARSER
35 # define RAG_TIME_PARSER
36
37 #include <set>
38 #include <vector>
39
40 #include "MWAWDebug.hxx"
41 #include "MWAWInputStream.hxx"
42
43 #include "MWAWParser.hxx"
44
45 namespace RagTimeParserInternal
46 {
47 struct Picture;
48 struct State;
49 class SubDocument;
50 }
51
52 class RagTimeText;
53 class RagTimeSpreadsheet;
54
55 /** \brief the main class to read a RagTime v2-3 file
56 *
57 *
58 *
59 */
60 class RagTimeParser final : public MWAWTextParser
61 {
62 friend class RagTimeParserInternal::SubDocument;
63 friend class RagTimeText;
64 friend class RagTimeSpreadsheet;
65
66 public:
67 //! constructor
68 RagTimeParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
69 //! destructor
70 ~RagTimeParser() final;
71
72 //! checks if the document header is correct (or not)
73 bool checkHeader(MWAWHeader *header, bool strict=false) final;
74
75 // the main parse function
76 void parse(librevenge::RVNGTextInterface *documentInterface) final;
77
78 protected:
79 //! inits all internal variables
80 void init();
81
82 //
83 // interface
84 //
85
86 //! returns the ith color ( if possible)
87 bool getColor(int colId, MWAWColor &color, int listId=-1) const;
88 //! returns the ith date format or ""
89 bool getDateTimeFormat(int dtId, std::string &dtFormat) const;
90 //! returns the size of a zone data field
91 int getZoneDataFieldSize(int zId) const;
92 //! returns a new unique zone id
93 int getNewZoneId();
94
95 //
96 // interface with text parser
97 //
98
99 //! returns a mac font id corresponding to a local id
100 int getFontId(int localId) const;
101 //! returns font style corresponding to a char style id
102 bool getCharStyle(int charId, MWAWFont &font) const;
103 //! try to read a text zone (knowing the zone width in point and the font color)
104 bool readTextZone(MWAWEntry &entry, int width, MWAWColor const &fontColor=MWAWColor::black());
105
106 //! creates the listener which will be associated to the document
107 void createDocument(librevenge::RVNGTextInterface *documentInterface);
108 //! try to send the different zones
109 bool sendZones();
110
111 //! adds a new page
112 void newPage(int number);
113
114 //! finds the different objects zones
115 bool createZones();
116
117 //! try to create the main data zones list
118 bool findDataZones();
119 //! try to read a data zone header
120 bool readDataZoneHeader(int id, long endPos);
121 //! try to sort the zone on each page
122 bool findPagesZones();
123
124 //! try to create the resource zones list
125 bool findRsrcZones();
126
127 //! try to send the different zones of a page
128 bool sendPageZone(int page);
129 //! try to send a zone
130 bool send(int zId);
131 //! try to send the text zone (interface of RagTimeText)
132 bool sendText(int zId, MWAWListenerPtr listener);
133
134 //! sends the picture
135 bool sendPicture(int zId, MWAWPosition const &pos);
136 //! sends a bitmap
137 bool sendBitmap(RagTimeParserInternal::Picture const &pict, MWAWPosition const &pos);
138 //! sends a basic shape
139 bool sendBasicPicture(int zId, MWAWPosition const &pos);
140 //! flush unsent zone (debugging function)
141 void flushExtra();
142
143 /** try to read page zone ( unknown content of size 40). A zone
144 which seems to appear between each page data */
145 bool readPageZone(MWAWEntry &entry);
146
147 //! try to read pictZone ( a big zone)
148 bool readPictZone(MWAWEntry &entry);
149
150 //! try to read pictZone ( a big zone):v2
151 bool readPictZoneV2(MWAWEntry &entry);
152
153 // some rsrc zone
154
155 //! try to read the color map:v2
156 bool readColorMapV2(MWAWEntry &entry);
157 //! try to read the color map:v3
158 bool readColorsMap();
159 //! read a printInfo block (a PREC rsrc)
160 bool readPrintInfo(MWAWEntry &entry, bool inRSRCFork=false);
161 /** try to read the File Link zone: FLink */
162 bool readLinks(MWAWEntry &entry);
163 //! try to read the format map:v3
164 bool readFormatsMap();
165 //! try to read the macro format zone: RTml zones
166 bool readMacroFormats(MWAWEntry &entry);
167 //! try to read the color table zone: CHTa zones
168 bool readColorTable(MWAWEntry &entry);
169
170 // unknown data fork zone
171
172 //! try to read zone6 ( a big zone)
173 bool readZone6(MWAWEntry &entry);
174
175 // unknown rsrc fork zone
176 //! try to read the BeDc zone ( zone of size 52, one by file with id=0);
177 bool readRsrcBeDc(MWAWEntry &entry);
178
179 //! try to read a structured zone
180 bool readRsrcStructured(MWAWEntry &entry);
181
182 //! try to read the Btch zone (zone with id=0)
183 bool readRsrcBtch(MWAWEntry &entry);
184 //! try to read the Calc zone (zone with id=0)
185 bool readRsrcCalc(MWAWEntry &entry);
186 //! try to read the fppr zone (zone with id=0)
187 bool readRsrcfppr(MWAWEntry &entry);
188 //! try to read the Sele zone (zone with id=0), maybe related to selection
189 bool readRsrcSele(MWAWEntry &entry);
190 // maybe FH=footer/header zone
191 //! try to read the FHwl zone ( one by file with id=0), maybe width length?
192 bool readRsrcFHwl(MWAWEntry &entry);
193 protected:
194 //
195 // data
196 //
197 //! the state
198 std::shared_ptr<RagTimeParserInternal::State> m_state;
199 //! the spreadsheet parser
200 std::shared_ptr<RagTimeSpreadsheet> m_spreadsheetParser;
201 //! the text parser
202 std::shared_ptr<RagTimeText> m_textParser;
203 };
204 #endif
205 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: