Debian Codegraph @

src/lib/DocMkrParser.cxx

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 #include <iomanip>
35 #include <iostream>
36 #include <limits>
37 #include <set>
38 #include <sstream>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWTextListener.hxx"
43 #include "MWAWFontConverter.hxx"
44 #include "MWAWHeader.hxx"
45 #include "MWAWPictData.hxx"
46 #include "MWAWPosition.hxx"
47 #include "MWAWPrinter.hxx"
48 #include "MWAWRSRCParser.hxx"
49 #include "MWAWSubDocument.hxx"
50
51 #include "DocMkrText.hxx"
52
53 #include "DocMkrParser.hxx"
54
55 /** Internal: the structures of a DocMkrParser */
56 namespace DocMkrParserInternal
57 {
58 ////////////////////////////////////////
59 //! Internal: store a picture information in DocMkrParser
60 struct PictInfo {
61 //! constructor
62 PictInfo()
63 : m_id(-1)
64 , m_sndId(-1)
65 , m_align(1)
66 , m_print(false)
67 , m_invert(false)
68 , m_action(0)
69 , m_actionString("")
70 , m_extra("")
71 {
72 for (auto &next : m_next) next=0;
73 }
74 //! operator<<
75 friend std::ostream &operator<<(std::ostream &o, PictInfo const &info);
76 //! the picture id
77 int m_id;
78 //! the sound id
79 int m_sndId;
80 //! the alignment ( 1:center, ... )
81 int m_align;
82 //! true if the picture is printed
83 bool m_print;
84 //! true if we must invert the picture
85 bool m_invert;
86 //! the action
87 int m_action;
88 //! the action string
89 std::string m_actionString;
90 //! the next chapter/paragraph position for goChapter
91 int m_next[2];
92 //! the applescript type
93 std::string m_appleScript[3];
94 //! extra data
95 std::string m_extra;
96 };
97
98 std::ostream &operator<<(std::ostream &o, PictInfo const &info)
99 {
100 if (info.m_id >= 0) o << "pictId=" << info.m_id << ",";
101 switch (info.m_align) {
102 case 1:
103 o << "center,";
104 break;
105 case 2:
106 o << "left,";
107 break;
108 case 3:
109 o << "right,";
110 break;
111 default:
112 o << "#align=" << info.m_align << ",";
113 break;
114 }
115 if (info.m_action >= 0 && info.m_action <= 16) {
116 static char const *wh[]= {
117 "", "goTo", "aboutDialog", "print", "quit", "launch", "sound", "QMOV",
118 "note", "export[asText]", "last[chapter]", "TOC[show]", "find", "appleEvent",
119 "next[chapter]", "prev[chapter]", "script"
120 };
121 o << wh[info.m_action];
122 }
123 else
124 o << "#action=" << info.m_action << ",";
125 switch (info.m_action) {
126 case 1:
127 o << "[chapter=" << info.m_next[0];
128 if (info.m_next[1]) o << ",para=" << info.m_next[1] << "]";
129 else o << "]";
130 break;
131 case 5:
132 case 7:
133 case 8:
134 case 0x10:
135 o << "[" << info.m_actionString << "]";
136 break;
137 case 6:
138 o << "[id=" << info.m_sndId << "]";
139 break;
140 case 0xd:
141 o << "[appli=" << info.m_appleScript[0] << ",class=" << info.m_appleScript[1]
142 << ",eventid=" << info.m_appleScript[2];
143 if (info.m_actionString.size())
144 o << ",data=" <<info.m_actionString;
145 o << "]";
146 break;
147 default:
148 break;
149 }
150 o << "],";
151 if (!info.m_print) o << "noPrint,";
152 if (info.m_invert) o << "invert,";
153 o << info.m_extra;
154 return o;
155 }
156 ////////////////////////////////////////
157 //! Internal: the state of a DocMkrParser
158 struct State {
159 //! constructor
160 State()
161 : m_idPictEntryMap()
162 , m_idPictInfoMap()
163 , m_zonePictInfoUnit(100)
164 , m_actPage(0)
165 , m_numPages(0)
166 , m_headerHeight(0)
167 , m_footerHeight(0)
168 {
169 }
170 //! return a pictinfo id corresponding to a zone and a local if
171 int pictInfoId(int zId, int lId) const
172 {
173 return (zId+2)*m_zonePictInfoUnit+lId;
174 }
175 //! try to find the picture info unit (fixme: a hack)
176 void findPictInfoUnit(int nZones);
177 //! a map id->pictEntry
178 std::map<int,MWAWEntry> m_idPictEntryMap;
179 //! a map id->pictInfo
180 std::map<int,PictInfo> m_idPictInfoMap;
181 //! the zone unit to retrieve pictInfo
182 int m_zonePictInfoUnit;
183 int m_actPage /** the actual page */, m_numPages /** the number of page of the final document */;
184
185 int m_headerHeight /** the header height if known */,
186 m_footerHeight /** the footer height if known */;
187 };
188
189 void State::findPictInfoUnit(int nZones)
190 {
191 if (m_idPictInfoMap.empty())
192 return;
193 bool is100=true, is1000=true;
194 for (auto const &it : m_idPictInfoMap) {
195 int id=it.first;
196 if (id > (nZones+3)*100 || id < 200)
197 is100=false;
198 if (id > (nZones+3)*1000 || id < 2000)
199 is1000=false;
200 }
201 if (is100 && !is1000)
202 m_zonePictInfoUnit=100;
203 else if (is1000 && !is100)
204 m_zonePictInfoUnit=1000;
205 else {
206 MWAW_DEBUG_MSG(("DocMkrParserInternal::State::findPictInfoUnit can not find unit\n"));
207 }
208 }
209 }
210
211 ////////////////////////////////////////////////////////////
212 // constructor/destructor, ...
213 ////////////////////////////////////////////////////////////
214 DocMkrParser::DocMkrParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
215 : MWAWTextParser(input, rsrcParser, header)
216 , m_state()
217 , m_textParser()
218 {
219 init();
220 }
221
222 DocMkrParser::~DocMkrParser()
223 {
224 }
225
226 void DocMkrParser::init()
227 {
228 resetTextListener();
229
230 m_state.reset(new DocMkrParserInternal::State);
231
232 m_textParser.reset(new DocMkrText(*this));
233 }
234
235 MWAWInputStreamPtr DocMkrParser::rsrcInput()
236 {
237 return getRSRCParser()->getInput();
238 }
239
240 libmwaw::DebugFile &DocMkrParser::rsrcAscii()
241 {
242 return getRSRCParser()->ascii();
243 }
244
245 ////////////////////////////////////////////////////////////
246 // new page
247 ////////////////////////////////////////////////////////////
248 void DocMkrParser::newPage(int number)
249 {
250 if (number <= m_state->m_actPage || number > m_state->m_numPages)
251 return;
252
253 while (m_state->m_actPage < number) {
254 m_state->m_actPage++;
255 if (!getTextListener() || m_state->m_actPage == 1)
256 continue;
257 getTextListener()->insertBreak(MWAWTextListener::PageBreak);
258 }
259 }
260
261 ////////////////////////////////////////////////////////////
262 // the parser
263 ////////////////////////////////////////////////////////////
264 void DocMkrParser::parse(librevenge::RVNGTextInterface *docInterface)
265 {
266 if (!getInput().get() || !getRSRCParser() || !checkHeader(nullptr)) throw(libmwaw::ParseException());
267 bool ok = false;
268 try {
269 checkHeader(nullptr);
270 ok = createZones();
271 if (ok) {
272 createDocument(docInterface);
273 m_textParser->sendMainText();
274 m_textParser->sendTOC();
275 #ifdef DEBUG
276 m_textParser->flushExtra();
277 flushExtra();
278 #endif
279 }
280 ascii().reset();
281 }
282 catch (...) {
283 MWAW_DEBUG_MSG(("DocMkrParser::parse: exception catched when parsing\n"));
284 ok = false;
285 }
286
287 resetTextListener();
288 if (!ok) throw(libmwaw::ParseException());
289 }
290
291 ////////////////////////////////////////////////////////////
292 // create the document
293 ////////////////////////////////////////////////////////////
294 void DocMkrParser::createDocument(librevenge::RVNGTextInterface *documentInterface)
295 {
296 if (!documentInterface) return;
297 if (getTextListener()) {
298 MWAW_DEBUG_MSG(("DocMkrParser::createDocument: listener already exist\n"));
299 return;
300 }
301
302 // update the page
303 m_state->m_actPage = 0;
304
305 // create the page list
306 std::vector<MWAWPageSpan> pageList;
307 m_textParser->updatePageSpanList(pageList);
308 m_state->m_numPages = int(pageList.size());
309
310 //
311 MWAWTextListenerPtr listen(new MWAWTextListener(*getParserState(), pageList, documentInterface));
312 setTextListener(listen);
313 listen->startDocument();
314 }
315
316
317 ////////////////////////////////////////////////////////////
318 //
319 // Intermediate level
320 //
321 ////////////////////////////////////////////////////////////
322 bool DocMkrParser::createZones()
323 {
324 MWAWRSRCParserPtr rsrcParser = getRSRCParser();
325 auto const &entryMap = rsrcParser->getEntriesMap();
326
327 if (!m_textParser->createZones())
328 return false;
329 // the different pict zones
330 auto it = entryMap.lower_bound("PICT");
331 while (it != entryMap.end()) {
332 if (it->first != "PICT")
333 break;
334 MWAWEntry const &entry = it++->second;
335 m_state->m_idPictEntryMap[entry.id()]=entry;
336 }
337 it = entryMap.lower_bound("conp"); // local picture 5000-...?
338 while (it != entryMap.end()) {
339 if (it->first != "conp")
340 break;
341 MWAWEntry const &entry = it++->second;
342 librevenge::RVNGBinaryData data;
343 rsrcParser->parsePICT(entry, data);
344 }
345 it = entryMap.lower_bound("pInf"); // 201|202,301..309,401..410,501..
346 while (it != entryMap.end()) {
347 if (it->first != "pInf")
348 break;
349 MWAWEntry const &entry = it++->second;
350 readPictInfo(entry);
351 }
352
353 // chapiter name STR 2000..
354 // entry 0: copyright
355 it = entryMap.lower_bound("Dk@P");
356 while (it != entryMap.end()) {
357 if (it->first != "Dk@P")
358 break;
359 MWAWEntry const &entry = it++->second;
360 std::string str;
361 rsrcParser->parseSTR(entry, str);
362 }
363 it = entryMap.lower_bound("sTwD");
364 while (it != entryMap.end()) {
365 if (it->first != "sTwD")
366 break;
367 MWAWEntry const &entry = it++->second;
368 readSTwD(entry);
369 }
370 it = entryMap.lower_bound("xtr2");
371 while (it != entryMap.end()) {
372 if (it->first != "xtr2")
373 break;
374 MWAWEntry const &entry = it++->second;
375 readXtr2(entry);
376 }
377 // 1000:docname, 1001:footer name, 2001-... chapter name, others ...
378 it = entryMap.lower_bound("STR ");
379 while (it != entryMap.end()) {
380 if (it->first != "STR ")
381 break;
382 MWAWEntry const &entry = it++->second;
383 std::string str;
384 rsrcParser->parseSTR(entry, str);
385 }
386
387 m_state->findPictInfoUnit(m_textParser->numChapters());
388
389 #ifdef DEBUG_WITH_FILES
390 // get rid of the default application resource
391 libmwaw::DebugFile &ascFile = rsrcAscii();
392 static char const *appliRsrc[]= {
393 // default, Dialog (3000: DLOG,DITL,DLGX,dctb","ictb","STR ")
394 "ALRT","BNDL","CNTL","CURS","CDEF", "DLOG","DLGX","DITL","FREF","ICON", "ICN#","MENU","SIZE",
395 "crsr","dctb","icl4","icl8","ics4", "ics8","ics#","ictb","snd ",
396 // local
397 "mstr" /* menu string */, "aete" /* some function name?*/
398 };
399 for (int r=0; r < 13+9+2; r++) {
400 it = entryMap.lower_bound(appliRsrc[r]);
401 while (it != entryMap.end()) {
402 if (it->first != appliRsrc[r])
403 break;
404 MWAWEntry const &entry = it++->second;
405 if (entry.isParsed()) continue;
406 entry.setParsed(true);
407 ascFile.skipZone(entry.begin()-4,entry.end()-1);
408 }
409 }
410 #endif
411 return true;
412 }
413
414 void DocMkrParser::flushExtra()
415 {
416 MWAWRSRCParserPtr rsrcParser = getRSRCParser();
417 for (auto const &it : m_state->m_idPictEntryMap) {
418 MWAWEntry const &entry=it.second;
419 if (entry.isParsed()) continue;
420 librevenge::RVNGBinaryData data;
421 rsrcParser->parsePICT(entry,data);
422 }
423 }
424
425 ////////////////////////////////////////////////////////////
426 //
427 // Low level
428 //
429 ////////////////////////////////////////////////////////////
430 bool DocMkrParser::sendPicture(int zId, int lId, double /*lineW*/)
431 {
432 int pictId=m_state->pictInfoId(zId,lId);
433 auto it=m_state->m_idPictInfoMap.find(pictId);
434 if (it==m_state->m_idPictInfoMap.end()) {
435 MWAW_DEBUG_MSG(("DocMkrText::sendPicture: can not find picture for zone=%d, id=%d\n",zId,lId));
436 return false;
437 }
438 DocMkrParserInternal::PictInfo const &info=it->second;
439 if (m_state->m_idPictEntryMap.find(info.m_id)==m_state->m_idPictEntryMap.end()) {
440 MWAW_DEBUG_MSG(("DocMkrText::sendPicture: can not find picture for id=%d\n",info.m_id));
441 return false;
442 }
443 if (!getTextListener()) {
444 MWAW_DEBUG_MSG(("DocMkrText::sendPicture: can not find the listener\n"));
445 return false;
446 }
447
448 if (info.m_action==8 && info.m_actionString.size())
449 m_textParser->sendComment(info.m_actionString);
450 MWAWInputStreamPtr input = rsrcInput();
451 MWAWRSRCParserPtr rsrcParser = getRSRCParser();
452 MWAWEntry const &entry=m_state->m_idPictEntryMap.find(info.m_id)->second;
453
454 librevenge::RVNGBinaryData data;
455 long pos = input->tell();
456 rsrcParser->parsePICT(entry,data);
457 input->seek(pos,librevenge::RVNG_SEEK_SET);
458
459 auto dataSz=int(data.size());
460 if (!dataSz) {
461 return false;
462 }
463 MWAWInputStreamPtr pictInput=MWAWInputStream::get(data, false);
464 if (!pictInput) {
465 MWAW_DEBUG_MSG(("DocMkrText::sendPicture: oops can not find an input\n"));
466 return false;
467 }
468 MWAWBox2f box;
469 auto res = MWAWPictData::check(pictInput, dataSz,box);
470 if (res == MWAWPict::MWAW_R_BAD) {
471 MWAW_DEBUG_MSG(("DocMkrText::sendPicture: can not find the picture\n"));
472 return false;
473 }
474 pictInput->seek(0,librevenge::RVNG_SEEK_SET);
475 std::shared_ptr<MWAWPict> thePict(MWAWPictData::get(pictInput, dataSz));
476 MWAWPosition pictPos=MWAWPosition(MWAWVec2f(0,0),box.size(), librevenge::RVNG_POINT);
477 auto xpos= (info.m_align==1) ? MWAWPosition::XCenter :
478 (info.m_align==3) ? MWAWPosition::XRight : MWAWPosition::XLeft;
479 pictPos.setRelativePosition(MWAWPosition::Paragraph, xpos);
480 pictPos.m_wrapping = MWAWPosition::WRunThrough;
481 if (thePict) {
482 MWAWEmbeddedObject picture;
483 if (thePict->getBinary(picture))
484 getTextListener()->insertPicture(pictPos, picture);
485 }
486 return true;
487 }
488
489 bool DocMkrParser::readPictInfo(MWAWEntry const &entry)
490 {
491 long length = entry.length();
492 if (!entry.valid() || length<8) {
493 MWAW_DEBUG_MSG(("DocMkrText::readPictInfo: the entry seems very short\n"));
494 return false;
495 }
496
497 entry.setParsed(true);
498 long pos = entry.begin();
499 long endPos = entry.end();
500 MWAWInputStreamPtr input = rsrcInput();
501 libmwaw::DebugFile &ascFile = rsrcAscii();
502 input->seek(pos, librevenge::RVNG_SEEK_SET);
503
504 libmwaw::DebugStream f;
505 DocMkrParserInternal::PictInfo info;
506 info.m_id = static_cast<int>(input->readULong(2));
507 info.m_align = static_cast<int>(input->readLong(2));
508 auto val =static_cast<int>(input->readLong(2)); // 0|1
509 if (val) f << "unkn=" << val << ",";
510
511 auto action =static_cast<int>(input->readLong(2)); // 0..b
512 auto extraN = int(endPos-input->tell());
513 if (action < 0) {
514 info.m_invert=true;
515 action = -action;
516 }
517 info.m_action=action;
518 switch (action) {
519 case 1:
520 if (extraN < 2) {
521 f << "actionArg##,";
522 break;
523 }
524 info.m_next[0]=static_cast<int>(input->readLong(2));
525 if (extraN < 4)
526 break;
527 info.m_next[1]=static_cast<int>(input->readLong(2));
528 break;
529 case 5:
530 case 7:
531 case 8:
532 case 0x10: {
533 if (extraN < 1) {
534 f << "actionArg##,";
535 }
536 auto fSz=static_cast<int>(input->readULong(1));
537 if (extraN < fSz+1) {
538 f << "##[N=" << fSz << "],";
539 break;
540 }
541 std::string name("");
542 for (int i = 0; i < fSz; i++)
543 name += char(input->readULong(1));
544 info.m_actionString=name;
545 break;
546 }
547 case 6: {
548 if (extraN < 4) {
549 f << "actionArg##,";
550 break;
551 }
552 info.m_sndId=static_cast<int>(input->readULong(2));
553 val = static_cast<int>(input->readULong(2)); // loop?
554 if (val)
555 f << "sndFlag=" << val << ",";
556 break;
557 }
558 case 0xd: {
559 if (extraN < 13) {
560 f << "actionArg##,";
561 break;
562 }
563 for (auto &w : info.m_appleScript) {
564 std::string name("");
565 for (int i = 0; i < 4; i++)
566 name += char(input->readULong(1));
567 w=name;
568 }
569 auto fSz=static_cast<int>(input->readULong(1));
570 if (extraN < fSz+13) {
571 f << "##[N=" << fSz << "],";
572 break;
573 }
574 std::string name("");
575 for (int i = 0; i < fSz; i++)
576 name += char(input->readULong(1));
577 info.m_actionString=name;
578 break;
579 }
580 default:
581 break;
582 }
583 extraN = int(endPos-input->tell())/2;
584 if (extraN==1) {
585 val =static_cast<int>(input->readLong(2));
586 if (val==0)
587 info.m_print = false;
588 else if (val==1)
589 info.m_print = true;
590 else if (val) {
591 f << "#print=" << val << ",";
592 }
593 }
594 else {
595 for (int i = 0; i < extraN; i++) { // g0=0|1
596 val =static_cast<int>(input->readLong(2));
597 if (val)
598 f << "#g" << i << "=" << val << ",";
599 }
600 }
601 info.m_extra=f.str();
602 m_state->m_idPictInfoMap[entry.id()]=info;
603 f.str("");
604 f << "Entries(PctInfo)[" << entry.type() << "-" << entry.id() << "]:" << info;
605
606 if (input->tell()!=entry.end())
607 ascFile.addDelimiter(input->tell(),'|');
608 ascFile.addPos(pos-4);
609 ascFile.addNote(f.str().c_str());
610 return true;
611 }
612
613 ////////////////////////////////////////////////////////////
614 // read some unknown zone
615 ////////////////////////////////////////////////////////////
616 bool DocMkrParser::readSTwD(MWAWEntry const &entry)
617 {
618 if (!entry.valid() || entry.length()<10) {
619 MWAW_DEBUG_MSG(("DocMkrText::readSTwD: the entry seems very short\n"));
620 return false;
621 }
622
623 entry.setParsed(true);
624 long pos = entry.begin();
625 MWAWInputStreamPtr input = rsrcInput();
626 libmwaw::DebugFile &ascFile = rsrcAscii();
627 input->seek(pos, librevenge::RVNG_SEEK_SET);
628
629 libmwaw::DebugStream f;
630 f << "Entries(STwD)[" << entry.type() << "-" << entry.id() << "]:";
631 int val;
632 for (int i=0; i < 2; i++) { // f0=2, f1=1|2
633 val =static_cast<int>(input->readLong(2));
634 if (val)
635 f << "f" << i << "=" << val << ",";
636 }
637 auto flag =static_cast<int>(input->readLong(2)); // 320|7d0|1388 ?
638 f << "fl=" << std::hex << flag << std::dec << ",";
639 f << "dim=" << static_cast<int>(input->readLong(2)) << ","; // 0x1Fa|0x200
640 for (int i=0; i < 2; i++) { // f0=1, f1=0|1
641 val =static_cast<int>(input->readLong(1));
642 if (val)
643 f << "f" << i+2 << "=" << val << ",";
644 }
645 f << "],";
646 if (input->tell()!=entry.end())
647 ascFile.addDelimiter(input->tell(),'|');
648 ascFile.addPos(pos-4);
649 ascFile.addNote(f.str().c_str());
650 return true;
651 }
652
653 bool DocMkrParser::readXtr2(MWAWEntry const &entry)
654 {
655 if (!entry.valid() || entry.length()<1) {
656 MWAW_DEBUG_MSG(("DocMkrText::readXtr2: the entry seems very short\n"));
657 return false;
658 }
659
660 entry.setParsed(true);
661 long pos = entry.begin();
662 MWAWInputStreamPtr input = rsrcInput();
663 libmwaw::DebugFile &ascFile = rsrcAscii();
664 input->seek(pos, librevenge::RVNG_SEEK_SET);
665
666 libmwaw::DebugStream f;
667 f << "Entries(Xtr2)[" << entry.type() << "-" << entry.id() << "]:";
668 int N=1;
669 if (entry.length() != 1) {
670 MWAW_DEBUG_MSG(("DocMkrText::readXtr2: find more than one flag\n"));
671 N = entry.length()>20 ? 20 : int(entry.length());
672 }
673 // f0=79|a8|b9|99
674 for (int i=0; i < N; i++) {
675 auto val =static_cast<int>(input->readULong(1));
676 if (val)
677 f << "f" << i << "=" << std::hex << val << std::dec << ",";
678 }
679 if (input->tell()!=entry.end())
680 ascFile.addDelimiter(input->tell(),'|');
681 ascFile.addPos(pos-4);
682 ascFile.addNote(f.str().c_str());
683 return true;
684 }
685
686 ////////////////////////////////////////////////////////////
687 // read the header
688 ////////////////////////////////////////////////////////////
689 bool DocMkrParser::checkHeader(MWAWHeader *header, bool /*strict*/)
690 {
691 *m_state = DocMkrParserInternal::State();
692 /** no data fork, may be ok, but this means
693 that the file contains no text, so... */
694 MWAWInputStreamPtr input = getInput();
695 if (!input || !getRSRCParser())
696 return false;
697 if (input->hasDataFork()) {
698 MWAW_DEBUG_MSG(("DocMkrParser::checkHeader: find a datafork, odd!!!\n"));
699 }
700 MWAWRSRCParser::Version vers;
701 // read the Docmaker version
702 int docmakerVersion = 1;
703 MWAWEntry entry = getRSRCParser()->getEntry("vers", 2);
704 if (entry.valid() && getRSRCParser()->parseVers(entry, vers))
705 docmakerVersion = vers.m_majorVersion;
706 else {
707 MWAW_DEBUG_MSG(("DocMkrParser::checkHeader: can not find the DocMaker version\n"));
708 }
709 setVersion(docmakerVersion);
710 if (header)
711 header->reset(MWAWDocument::MWAW_T_DOCMAKER, version());
712
713 return true;
714 }
715
716 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: