| 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 |
/** \file MWAWHeader.cxx |
| 35 |
* Implements MWAWHeader (document's type, version, kind) |
| 36 |
*/ |
| 37 |
|
| 38 |
#include <string.h> |
| 39 |
#include <iostream> |
| 40 |
|
| 41 |
#include "libmwaw_internal.hxx" |
| 42 |
|
| 43 |
#include "MWAWEntry.hxx" |
| 44 |
#include "MWAWInputStream.hxx" |
| 45 |
#include "MWAWRSRCParser.hxx" |
| 46 |
|
| 47 |
#include "MWAWHeader.hxx" |
| 48 |
|
| 49 |
MWAWHeader::MWAWHeader(MWAWDocument::Type documentType, int vers, MWAWDocument::Kind kind) |
| 50 |
: m_version(vers) |
| 51 |
, m_docType(documentType) |
| 52 |
, m_docKind(kind) |
| 53 |
{ |
| 54 |
} |
| 55 |
|
| 56 |
MWAWHeader::~MWAWHeader() |
| 57 |
{ |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* So far, we have identified |
| 62 |
*/ |
| 63 |
std::vector<MWAWHeader> MWAWHeader::constructHeader |
| 64 |
(MWAWInputStreamPtr input, std::shared_ptr<MWAWRSRCParser> /*rsrcParser*/) |
| 65 |
{ |
| 66 |
std::vector<MWAWHeader> res; |
| 67 |
if (!input) return res; |
| 68 |
// ------------ first check finder info ------------- |
| 69 |
std::string type, creator; |
| 70 |
if (input->getFinderInfo(type, creator) && !creator.empty()) { |
| 71 |
// set basic version, the correct will be filled by check header |
| 72 |
if (creator[0]=='A') { |
| 73 |
if (creator=="ACTA") { |
| 74 |
if (type=="OTLN") { // at least basic v2 |
| 75 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_ACTA, 1)); |
| 76 |
return res; |
| 77 |
} |
| 78 |
else if (type=="otln") { // classic version |
| 79 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_ACTA, 2)); |
| 80 |
return res; |
| 81 |
} |
| 82 |
} |
| 83 |
else if (creator=="AISW") { |
| 84 |
if (type=="SWDC" || type=="SWSP" || type=="SWWP") { |
| 85 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SCRIPTWRITER, 1)); |
| 86 |
return res; |
| 87 |
} |
| 88 |
} |
| 89 |
else if (creator=="APBP") { |
| 90 |
if (type=="APBL") { |
| 91 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_DRAWINGTABLE, 1, MWAWDocument::MWAW_K_DRAW)); |
| 92 |
return res; |
| 93 |
} |
| 94 |
} |
| 95 |
else if (creator=="ARTX") { // Painter X |
| 96 |
if (type=="RIFF") { |
| 97 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CORELPAINTER, 10, MWAWDocument::MWAW_K_PAINT)); |
| 98 |
return res; |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
else if (creator[0]=='B') { |
| 103 |
if (creator=="BOBO") { |
| 104 |
if (type=="CWDB" || type=="CWD2" || type=="sWDB") { |
| 105 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, 1, MWAWDocument::MWAW_K_DATABASE)); |
| 106 |
return res; |
| 107 |
} |
| 108 |
if (type=="CWGR" || type=="sWGR") { |
| 109 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, 1, MWAWDocument::MWAW_K_DRAW)); |
| 110 |
return res; |
| 111 |
} |
| 112 |
if (type=="CWSS" || type=="CWS2" || type=="sWSS") { |
| 113 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 114 |
return res; |
| 115 |
} |
| 116 |
if (type=="CWPR") { |
| 117 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, 1, MWAWDocument::MWAW_K_PRESENTATION)); |
| 118 |
return res; |
| 119 |
} |
| 120 |
if (type=="CWPT") { |
| 121 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, 1, MWAWDocument::MWAW_K_PAINT)); |
| 122 |
return res; |
| 123 |
} |
| 124 |
if (type=="CWWP" || type=="CWW2" || type=="sWPP") { |
| 125 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, 1, MWAWDocument::MWAW_K_TEXT)); |
| 126 |
return res; |
| 127 |
} |
| 128 |
} |
| 129 |
else if (creator=="BWks") { |
| 130 |
if (type=="BWwp") { |
| 131 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1)); |
| 132 |
return res; |
| 133 |
} |
| 134 |
if (type=="BWdb") { |
| 135 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_DATABASE)); |
| 136 |
return res; |
| 137 |
} |
| 138 |
if (type=="BWdr") { |
| 139 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_DRAW)); |
| 140 |
return res; |
| 141 |
} |
| 142 |
if (type=="BWpt") { |
| 143 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_PAINT)); |
| 144 |
return res; |
| 145 |
} |
| 146 |
if (type=="BWss") { |
| 147 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 148 |
return res; |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
else if (creator[0]=='C') { |
| 153 |
if (creator=="CDrw") { |
| 154 |
if (type=="dDrw" || type=="dDst" || type=="iLib") { |
| 155 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISDRAW, 1, MWAWDocument::MWAW_K_DRAW)); |
| 156 |
return res; |
| 157 |
} |
| 158 |
} |
| 159 |
else if (creator=="CRDW") { |
| 160 |
if (type=="CKDT") { |
| 161 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CRICKETDRAW, 1, MWAWDocument::MWAW_K_DRAW)); |
| 162 |
return res; |
| 163 |
} |
| 164 |
} |
| 165 |
else if (creator=="C#+A") { // solo |
| 166 |
if (type=="C#+D" || type=="C#+F") { |
| 167 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_RAGTIME, 5)); |
| 168 |
return res; |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
else if (creator[0]=='D') { |
| 173 |
if (creator.substr(0,3)=="DAD") { |
| 174 |
if (creator=="DAD2") { |
| 175 |
if (type=="drw2") { |
| 176 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 2, MWAWDocument::MWAW_K_DRAW)); |
| 177 |
return res; |
| 178 |
} |
| 179 |
} |
| 180 |
else if (creator=="DAD5") { |
| 181 |
if (type=="drw2") { |
| 182 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 2, MWAWDocument::MWAW_K_DRAW)); |
| 183 |
return res; |
| 184 |
} |
| 185 |
if (type=="drw5" || type=="drwt") { |
| 186 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 5, MWAWDocument::MWAW_K_DRAW)); |
| 187 |
return res; |
| 188 |
} |
| 189 |
if (type=="VINF") { |
| 190 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 5, MWAWDocument::MWAW_K_PAINT)); |
| 191 |
return res; |
| 192 |
} |
| 193 |
} |
| 194 |
else if (creator=="DAD6") { |
| 195 |
if (type=="drw6" || type=="drwt") { |
| 196 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 6, MWAWDocument::MWAW_K_DRAW)); |
| 197 |
return res; |
| 198 |
} |
| 199 |
if (type=="VINF") { |
| 200 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 6, MWAWDocument::MWAW_K_PAINT)); |
| 201 |
return res; |
| 202 |
} |
| 203 |
} |
| 204 |
else if (creator=="DAD7") { |
| 205 |
if (type=="drw7" || type=="drwt") { |
| 206 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 7, MWAWDocument::MWAW_K_DRAW)); |
| 207 |
return res; |
| 208 |
} |
| 209 |
if (type=="VINF") { |
| 210 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 7, MWAWDocument::MWAW_K_PAINT)); |
| 211 |
return res; |
| 212 |
} |
| 213 |
} |
| 214 |
else if (creator=="DAD8") { |
| 215 |
if (type=="drw8" || type=="drwt") { |
| 216 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 8, MWAWDocument::MWAW_K_DRAW)); |
| 217 |
return res; |
| 218 |
} |
| 219 |
if (type=="VINF") { |
| 220 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 8, MWAWDocument::MWAW_K_PAINT)); |
| 221 |
return res; |
| 222 |
} |
| 223 |
} |
| 224 |
else if (creator=="DAD9" || creator=="DADX") { |
| 225 |
if (type=="drwX" || type=="drwt") { |
| 226 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 9, MWAWDocument::MWAW_K_DRAW)); |
| 227 |
return res; |
| 228 |
} |
| 229 |
} |
| 230 |
} |
| 231 |
else if (creator=="Dc@P" || creator=="Dk@P") { |
| 232 |
if (type=="APPL") { |
| 233 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_DOCMAKER, 1)); |
| 234 |
return res; |
| 235 |
} |
| 236 |
} |
| 237 |
} |
| 238 |
else if (creator[0]=='F') { |
| 239 |
if (creator=="FHA2") { |
| 240 |
if (type=="FHD2" || type=="FHT2") { |
| 241 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FREEHAND, 2, MWAWDocument::MWAW_K_DRAW)); |
| 242 |
return res; |
| 243 |
} |
| 244 |
} |
| 245 |
else if (creator=="FS03") { |
| 246 |
if (type=="WRT+") { |
| 247 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WRITERPLUS, 1)); |
| 248 |
return res; |
| 249 |
} |
| 250 |
} |
| 251 |
else if (creator=="FSPS" || creator=="FSDA") { // Fractal Design Painter or Dabbler |
| 252 |
if (type=="RIFF") { |
| 253 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CORELPAINTER, 1, MWAWDocument::MWAW_K_PAINT)); |
| 254 |
return res; |
| 255 |
} |
| 256 |
} |
| 257 |
else if (creator=="FSX3") { |
| 258 |
if (type=="RIFF") { // also FSFS list of uncompressed picture data for movie |
| 259 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CORELPAINTER, 3, MWAWDocument::MWAW_K_PAINT)); |
| 260 |
return res; |
| 261 |
} |
| 262 |
} |
| 263 |
else if (creator=="FWRT") { |
| 264 |
if (type=="FWRM") { // 1.7 ? |
| 265 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FULLWRITE, 1)); |
| 266 |
return res; |
| 267 |
} |
| 268 |
if (type=="FWRT") { // 1.0 ? |
| 269 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FULLWRITE, 1)); |
| 270 |
return res; |
| 271 |
} |
| 272 |
if (type=="FWRI") { |
| 273 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FULLWRITE,2)); |
| 274 |
return res; |
| 275 |
} |
| 276 |
} |
| 277 |
else if (creator=="F#+A") { // Classic |
| 278 |
if (type=="F#+D" || type=="F#+F") { |
| 279 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_RAGTIME, 3)); |
| 280 |
return res; |
| 281 |
} |
| 282 |
} |
| 283 |
} |
| 284 |
else if (creator=="GM01") { |
| 285 |
if (type=="GfMt") { |
| 286 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MOUSEWRITE, 1)); |
| 287 |
return res; |
| 288 |
} |
| 289 |
} |
| 290 |
else if (creator=="HMiw") { // japonese |
| 291 |
if (type=="IWDC") { |
| 292 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_HANMACWORDJ,1)); |
| 293 |
return res; |
| 294 |
} |
| 295 |
} |
| 296 |
else if (creator=="HMdr") { // korean |
| 297 |
if (type=="DRD2") { |
| 298 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_HANMACWORDK,1)); |
| 299 |
return res; |
| 300 |
} |
| 301 |
} |
| 302 |
else if (creator=="JAZZ") { |
| 303 |
if (type=="JWPD") { |
| 304 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_JAZZLOTUS,1)); |
| 305 |
return res; |
| 306 |
} |
| 307 |
else if (type=="JWKS") { |
| 308 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_JAZZLOTUS, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 309 |
return res; |
| 310 |
} |
| 311 |
else if (type=="JDBS") { |
| 312 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_JAZZLOTUS, 1, MWAWDocument::MWAW_K_DATABASE)); |
| 313 |
return res; |
| 314 |
} |
| 315 |
} |
| 316 |
else if (creator[0]=='L') { |
| 317 |
if (creator=="LMAN") { |
| 318 |
if (type=="TEXT") { |
| 319 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 7, MWAWDocument::MWAW_K_DRAW)); |
| 320 |
return res; |
| 321 |
} |
| 322 |
} |
| 323 |
else if (creator=="LWTE") { |
| 324 |
if (type=="TEXT" || type=="ttro") { |
| 325 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_LIGHTWAYTEXT,1)); |
| 326 |
return res; |
| 327 |
} |
| 328 |
} |
| 329 |
else if (creator=="LWTR") { |
| 330 |
if (type=="APPL") { |
| 331 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_LIGHTWAYTEXT,1)); |
| 332 |
return res; |
| 333 |
} |
| 334 |
} |
| 335 |
} |
| 336 |
else if (creator[0]=='M') { |
| 337 |
if (creator=="MACA") { |
| 338 |
if (type=="WORD") { |
| 339 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACWRITE, 1)); |
| 340 |
return res; |
| 341 |
} |
| 342 |
} |
| 343 |
else if (creator=="MACD") { // v1.0 |
| 344 |
if (type=="DRWG") { |
| 345 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAFT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 346 |
return res; |
| 347 |
} |
| 348 |
} |
| 349 |
else if (creator=="MART") { |
| 350 |
if (type=="RSGF") { |
| 351 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 1, MWAWDocument::MWAW_K_DRAW)); |
| 352 |
return res; |
| 353 |
} |
| 354 |
else if (type=="RSGI") { |
| 355 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 2, MWAWDocument::MWAW_K_DRAW)); |
| 356 |
return res; |
| 357 |
} |
| 358 |
} |
| 359 |
else if (creator=="MAXW") { |
| 360 |
if (type=="MWCT") { |
| 361 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MAXWRITE, 1)); |
| 362 |
return res; |
| 363 |
} |
| 364 |
} |
| 365 |
else if (creator=="MD40") { |
| 366 |
if (type=="MDDC" || type=="MSYM") { |
| 367 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAFT, 4, MWAWDocument::MWAW_K_DRAW)); |
| 368 |
return res; |
| 369 |
} |
| 370 |
} |
| 371 |
else if (creator=="MDFT") { // v1.2 |
| 372 |
if (type=="DRWG") { |
| 373 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAFT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 374 |
return res; |
| 375 |
} |
| 376 |
} |
| 377 |
else if (creator=="MDPL") { // MacDraw II |
| 378 |
if (type=="DRWG") { |
| 379 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 0, MWAWDocument::MWAW_K_DRAW)); |
| 380 |
return res; |
| 381 |
} |
| 382 |
if (type=="STAT") { // stationery |
| 383 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 0, MWAWDocument::MWAW_K_DRAW)); |
| 384 |
return res; |
| 385 |
} |
| 386 |
} |
| 387 |
else if (creator=="MDRW") { |
| 388 |
if (type=="DRWG") { |
| 389 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAW, 1, MWAWDocument::MWAW_K_DRAW)); |
| 390 |
return res; |
| 391 |
} |
| 392 |
} |
| 393 |
else if (creator=="MDsr") { |
| 394 |
if (type=="APPL") { // auto content |
| 395 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDOC, 1)); |
| 396 |
return res; |
| 397 |
} |
| 398 |
} |
| 399 |
else if (creator=="MDvr") { |
| 400 |
if (type=="MDdc") { |
| 401 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDOC, 1)); |
| 402 |
return res; |
| 403 |
} |
| 404 |
} |
| 405 |
else if (creator=="MEMR") { // 4.5 |
| 406 |
if (type=="RSGR") { |
| 407 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 5, MWAWDocument::MWAW_K_DRAW)); |
| 408 |
return res; |
| 409 |
} |
| 410 |
} |
| 411 |
else if (creator=="MMBB") { |
| 412 |
if (type=="MBBT") { |
| 413 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MARINERWRITE, 1)); |
| 414 |
return res; |
| 415 |
} |
| 416 |
} |
| 417 |
else if (creator=="MORE") { |
| 418 |
if (type=="MORE") { |
| 419 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MORE, 1)); |
| 420 |
return res; |
| 421 |
} |
| 422 |
} |
| 423 |
else if (creator=="MOR2") { |
| 424 |
if (type=="MOR2") { |
| 425 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MORE, 2)); |
| 426 |
return res; |
| 427 |
} |
| 428 |
if (type=="MOR3") { |
| 429 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MORE, 3)); |
| 430 |
return res; |
| 431 |
} |
| 432 |
} |
| 433 |
else if (creator=="MPNT") { |
| 434 |
if (type=="PNTG") { |
| 435 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 436 |
return res; |
| 437 |
} |
| 438 |
} |
| 439 |
else if (creator=="MROS") { // 6 |
| 440 |
if (type=="MG6F") { |
| 441 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 6, MWAWDocument::MWAW_K_DRAW)); |
| 442 |
return res; |
| 443 |
} |
| 444 |
} |
| 445 |
else if (creator=="MRJN") { |
| 446 |
if (type=="DSTD") { // Design Studio 2 |
| 447 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 5, MWAWDocument::MWAW_K_DRAW)); |
| 448 |
return res; |
| 449 |
} |
| 450 |
} |
| 451 |
else if (creator=="MRSN") { |
| 452 |
if (type=="RSGJ") { |
| 453 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 3, MWAWDocument::MWAW_K_DRAW)); |
| 454 |
return res; |
| 455 |
} |
| 456 |
if (type=="RSGK") { |
| 457 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 4, MWAWDocument::MWAW_K_DRAW)); |
| 458 |
return res; |
| 459 |
} |
| 460 |
} |
| 461 |
else if (creator=="MSWD") { |
| 462 |
if (type=="WDBN" || type=="GLOS") { |
| 463 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORD, 3)); |
| 464 |
return res; |
| 465 |
} |
| 466 |
} |
| 467 |
else if (creator=="MSWK") { |
| 468 |
if (type=="AWWP") { |
| 469 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 3)); |
| 470 |
return res; |
| 471 |
} |
| 472 |
if (type=="AWDB") { |
| 473 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 3, MWAWDocument::MWAW_K_DATABASE)); |
| 474 |
return res; |
| 475 |
} |
| 476 |
if (type=="AWDR") { |
| 477 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 3, MWAWDocument::MWAW_K_DRAW)); |
| 478 |
return res; |
| 479 |
} |
| 480 |
if (type=="AWSS") { |
| 481 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 2, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 482 |
return res; |
| 483 |
} |
| 484 |
if (type=="RLRB" || type=="sWRB") { |
| 485 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 4)); |
| 486 |
return res; |
| 487 |
} |
| 488 |
} |
| 489 |
else if (creator=="MWII") { // MacWriteII |
| 490 |
if (type=="MW2D") { |
| 491 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACWRITEPRO, 0)); |
| 492 |
return res; |
| 493 |
} |
| 494 |
} |
| 495 |
else if (creator=="MWPR") { |
| 496 |
if (type=="MWPd") { |
| 497 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACWRITEPRO, 1)); |
| 498 |
return res; |
| 499 |
} |
| 500 |
} |
| 501 |
} |
| 502 |
else if (creator=="NISI") { |
| 503 |
if (type=="TEXT") { |
| 504 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_NISUSWRITER, 1)); |
| 505 |
return res; |
| 506 |
} |
| 507 |
if (type=="GLOS") { // checkme: glossary, ie. a list of picture/word, keep it ? |
| 508 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_NISUSWRITER, 1)); |
| 509 |
return res; |
| 510 |
} |
| 511 |
// "edtt": empty file, probably created when the file is edited |
| 512 |
} |
| 513 |
else if (creator[0]=='P') { |
| 514 |
if (creator=="PANT") { |
| 515 |
if (type=="PNTG") { |
| 516 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FULLPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 517 |
return res; |
| 518 |
} |
| 519 |
} |
| 520 |
else if (creator=="PLAN") { |
| 521 |
if (type=="MPBN") { |
| 522 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTMULTIPLAN, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 523 |
return res; |
| 524 |
} |
| 525 |
} |
| 526 |
else if (creator=="PIXR") { |
| 527 |
if (type=="PX01") { |
| 528 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_PIXELPAINT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 529 |
return res; |
| 530 |
} |
| 531 |
} |
| 532 |
else if (creator=="PPT3") { |
| 533 |
if (type=="SLD3") { |
| 534 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_POWERPOINT, 3, MWAWDocument::MWAW_K_PRESENTATION)); |
| 535 |
return res; |
| 536 |
} |
| 537 |
} |
| 538 |
else if (creator=="PPNT") { |
| 539 |
if (type=="SLDS") { |
| 540 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_POWERPOINT, 2, MWAWDocument::MWAW_K_PRESENTATION)); |
| 541 |
return res; |
| 542 |
} |
| 543 |
} |
| 544 |
else if (creator=="PSIP") { |
| 545 |
if (type=="AWWP") { |
| 546 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 1)); |
| 547 |
return res; |
| 548 |
} |
| 549 |
} |
| 550 |
else if (creator=="PSI2") { |
| 551 |
if (type=="AWWP") { |
| 552 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 2)); |
| 553 |
return res; |
| 554 |
} |
| 555 |
if (type=="AWDB") { |
| 556 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 2, MWAWDocument::MWAW_K_DATABASE)); |
| 557 |
return res; |
| 558 |
} |
| 559 |
if (type=="AWSS") { |
| 560 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 2, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 561 |
return res; |
| 562 |
} |
| 563 |
} |
| 564 |
else if (creator=="PWRI") { |
| 565 |
if (type=="OUTL") { |
| 566 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MINDWRITE, 2)); |
| 567 |
return res; |
| 568 |
} |
| 569 |
} |
| 570 |
} |
| 571 |
else if (creator[0]=='R') { |
| 572 |
if (creator=="Rslv") { |
| 573 |
if (type=="RsWs") { |
| 574 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISRESOLVE, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 575 |
return res; |
| 576 |
} |
| 577 |
} |
| 578 |
else if (creator=="R#+A") { |
| 579 |
if (type=="R#+D" || type=="R#+F") { |
| 580 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_RAGTIME, 3)); |
| 581 |
return res; |
| 582 |
} |
| 583 |
} |
| 584 |
} |
| 585 |
else if (creator[0]=='S') { |
| 586 |
if (creator=="SBPA") { |
| 587 |
if (type=="SBPD") { |
| 588 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SPRINGBOARD_PUBLISHER, 2, MWAWDocument::MWAW_K_DRAW)); |
| 589 |
return res; |
| 590 |
} |
| 591 |
} |
| 592 |
else if (creator=="Spud") { |
| 593 |
if (type=="SPUB") { |
| 594 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SCOOP, 1, MWAWDocument::MWAW_K_DRAW)); |
| 595 |
return res; |
| 596 |
} |
| 597 |
} |
| 598 |
else if (creator=="SPNT") { |
| 599 |
if (type=="SPTG") { |
| 600 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SUPERPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 601 |
return res; |
| 602 |
} |
| 603 |
if (type=="PNTG") { |
| 604 |
// same as MacPaint format, so use the MacPaint parser |
| 605 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 606 |
return res; |
| 607 |
} |
| 608 |
// other type seems to correspond to basic picture file, so we do not accept them |
| 609 |
} |
| 610 |
else if (creator=="StAV") { |
| 611 |
if (type=="APPL") { // Style: document application |
| 612 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_STYLE, 1)); |
| 613 |
return res; |
| 614 |
} |
| 615 |
} |
| 616 |
else if (creator==std::string("St")+'\xd8'+"l") { // argh, not standart character |
| 617 |
std::string type1=std::string("TEd")+'\xb6'; // argh, not standart character |
| 618 |
if (type==type1) { |
| 619 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_STYLE, 1)); |
| 620 |
return res; |
| 621 |
} |
| 622 |
} |
| 623 |
else if (creator=="SWCM") { |
| 624 |
if (type=="JRNL" || type=="LTTR" || type=="NWSL" || type=="RPRT" || type=="SIGN") { |
| 625 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_STUDENTWRITING, 1)); |
| 626 |
return res; |
| 627 |
} |
| 628 |
} |
| 629 |
} |
| 630 |
else if (creator=="TBB5") { |
| 631 |
if (type=="TEXT" || type=="ttro") { |
| 632 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_TEXEDIT, 1)); |
| 633 |
return res; |
| 634 |
} |
| 635 |
} |
| 636 |
else if (creator[0]=='W') { |
| 637 |
if (creator=="WMkr") { |
| 638 |
if (type=="Word" || type=="WSta") { |
| 639 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WORDMAKER, 1)); |
| 640 |
return res; |
| 641 |
} |
| 642 |
} |
| 643 |
else if (creator=="WNGZ") { |
| 644 |
if (type=="WZSS") { |
| 645 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WINGZ, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 646 |
return res; |
| 647 |
} |
| 648 |
} |
| 649 |
else if (creator=="WORD") { |
| 650 |
if (type=="WDBN") { |
| 651 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORD, 1)); |
| 652 |
return res; |
| 653 |
} |
| 654 |
} |
| 655 |
} |
| 656 |
else if (creator[0]=='Z') { |
| 657 |
if (creator=="ZEBR") { |
| 658 |
if (type=="ZWRT") { |
| 659 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, 1)); |
| 660 |
return res; |
| 661 |
} |
| 662 |
if (type=="ZOBJ") { |
| 663 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, 1, MWAWDocument::MWAW_K_DRAW)); |
| 664 |
return res; |
| 665 |
} |
| 666 |
if (type=="PNTG") { |
| 667 |
// same as MacPaint format, so use the MacPaint parser |
| 668 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 669 |
return res; |
| 670 |
} |
| 671 |
if (type=="ZPNT") { |
| 672 |
/* the ZPNT(v2) are basic pct files with some resources, but |
| 673 |
we treat them to be complete */ |
| 674 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, 2, MWAWDocument::MWAW_K_PAINT)); |
| 675 |
return res; |
| 676 |
} |
| 677 |
if (type=="ZCAL") { |
| 678 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 679 |
return res; |
| 680 |
} |
| 681 |
if (type=="ZDBS") { |
| 682 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, 1, MWAWDocument::MWAW_K_DATABASE)); |
| 683 |
return res; |
| 684 |
} |
| 685 |
// can we treat also ZOLN ? |
| 686 |
} |
| 687 |
else if (creator=="ZWRT") { |
| 688 |
if (type=="Zart") { |
| 689 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_ZWRITE, 1)); |
| 690 |
return res; |
| 691 |
} |
| 692 |
} |
| 693 |
} |
| 694 |
else if (creator=="aca3") { |
| 695 |
if (type=="acf3" || type=="act3") { |
| 696 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FREEHAND, 1, MWAWDocument::MWAW_K_DRAW)); |
| 697 |
return res; |
| 698 |
} |
| 699 |
} |
| 700 |
else if (creator=="dPro") { |
| 701 |
if (type=="dDoc") { |
| 702 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 1, MWAWDocument::MWAW_K_DRAW)); |
| 703 |
return res; |
| 704 |
} |
| 705 |
if (type=="dLib") { // macdraw pro slide/library |
| 706 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 1, MWAWDocument::MWAW_K_DRAW)); |
| 707 |
return res; |
| 708 |
} |
| 709 |
} |
| 710 |
else if (creator=="eDcR") { |
| 711 |
if (type=="eDoc") { |
| 712 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_EDOC, 1)); |
| 713 |
return res; |
| 714 |
} |
| 715 |
} |
| 716 |
else if (creator=="eSRD") { // self reading application |
| 717 |
if (type=="APPL") { |
| 718 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_EDOC, 1)); |
| 719 |
return res; |
| 720 |
} |
| 721 |
} |
| 722 |
else if (creator=="nX^n") { |
| 723 |
if (type=="nX^d") { |
| 724 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WRITENOW, 2)); |
| 725 |
return res; |
| 726 |
} |
| 727 |
if (type=="nX^2") { |
| 728 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WRITENOW, 3)); |
| 729 |
return res; |
| 730 |
} |
| 731 |
} |
| 732 |
else if (creator=="ttxt") { |
| 733 |
if (type=="TEXT" || type=="ttro") { |
| 734 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_TEACHTEXT, 1)); |
| 735 |
return res; |
| 736 |
} |
| 737 |
} |
| 738 |
// check also basic type |
| 739 |
if (type=="PICT") { |
| 740 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_APPLEPICT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 741 |
return res; |
| 742 |
} |
| 743 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: unknown finder info: type=%s[%s]\n", type.c_str(), creator.c_str())); |
| 744 |
|
| 745 |
} |
| 746 |
|
| 747 |
// ----------- now check resource fork ------------ |
| 748 |
// ----------- now check data fork ------------ |
| 749 |
if (!input->hasDataFork() || input->size() < 8) |
| 750 |
return res; |
| 751 |
|
| 752 |
input->seek(0, librevenge::RVNG_SEEK_SET); |
| 753 |
int val[5]; |
| 754 |
for (auto &v : val) v = int(input->readULong(2)); |
| 755 |
|
| 756 |
// ----------- clearly discriminant ------------------ |
| 757 |
if (val[2] == 0x424F && val[3] == 0x424F && (val[0]>>8) < 7) { |
| 758 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Claris Works file\n")); |
| 759 |
int vers= (val[0] >> 8); |
| 760 |
static int const typePos[7] = {0, 242, 248, 248, 256, 268, 278}; |
| 761 |
int typeFile=-1; |
| 762 |
if (vers >= 1 && input->checkPosition(typePos[vers])) { |
| 763 |
input->seek(typePos[vers], librevenge::RVNG_SEEK_SET); |
| 764 |
typeFile=int(input->readLong(1)); |
| 765 |
} |
| 766 |
switch (typeFile) { |
| 767 |
case 0: |
| 768 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, vers, MWAWDocument::MWAW_K_DRAW)); |
| 769 |
return res; |
| 770 |
case 1: |
| 771 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, vers, MWAWDocument::MWAW_K_TEXT)); |
| 772 |
return res; |
| 773 |
case 2: |
| 774 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, vers, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 775 |
return res; |
| 776 |
case 3: |
| 777 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, vers, MWAWDocument::MWAW_K_DATABASE)); |
| 778 |
return res; |
| 779 |
case 4: |
| 780 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, vers, MWAWDocument::MWAW_K_PAINT)); |
| 781 |
return res; |
| 782 |
case 5: |
| 783 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISWORKS, vers, MWAWDocument::MWAW_K_PRESENTATION)); |
| 784 |
return res; |
| 785 |
default: |
| 786 |
break; |
| 787 |
} |
| 788 |
} |
| 789 |
if (val[0]==0x5772 && val[1]==0x6974 && val[2]==0x654e && val[3]==0x6f77) { |
| 790 |
input->seek(8, librevenge::RVNG_SEEK_SET); |
| 791 |
auto version = int(input->readLong(2)); |
| 792 |
|
| 793 |
#ifdef DEBUG |
| 794 |
bool ok = (version >= 0 && version <= 3); |
| 795 |
if (ok) |
| 796 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a WriteNow file version 3.0 or 4.0\n")); |
| 797 |
else |
| 798 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a WriteNow file (unknown version %d)\n", version)); |
| 799 |
#else |
| 800 |
bool ok = version == 2; |
| 801 |
#endif |
| 802 |
|
| 803 |
if (ok) { |
| 804 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WRITENOW, 3)); |
| 805 |
return res; |
| 806 |
} |
| 807 |
} |
| 808 |
if (val[0]==0x574e && val[1]==0x475a && val[2]==0x575a && val[3]==0x5353) { |
| 809 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Wingz file\n")); |
| 810 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WINGZ, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 811 |
return res; |
| 812 |
} |
| 813 |
if (val[0]==0x4241 && val[1]==0x545F && val[2]==0x4254 && val[3]==0x5353) { |
| 814 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a ClarisResolve file\n")); |
| 815 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISRESOLVE, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 816 |
return res; |
| 817 |
} |
| 818 |
if (val[0]==0x4323 && val[1]==0x2b44 && val[2]==0xa443 && val[3]==0x4da5) { |
| 819 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a RagTime 5-6 file\n")); |
| 820 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_RAGTIME, 5)); |
| 821 |
return res; |
| 822 |
} |
| 823 |
if (val[0]==0x4646 && val[1]==0x4646 && val[2]==0x3030 && val[3]==0x3030) { |
| 824 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Mariner Write file\n")); |
| 825 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MARINERWRITE, 1)); |
| 826 |
return res; |
| 827 |
} |
| 828 |
if (val[0]==0x000c && val[1]==0x1357 && (val[2]==0x13 || val[2]==0x14) && val[3]==0) { |
| 829 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Drawing Table file\n")); |
| 830 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_DRAWINGTABLE, 1, MWAWDocument::MWAW_K_DRAW)); |
| 831 |
return res; |
| 832 |
} |
| 833 |
if (val[0]==0x4257 && val[1]==0x6b73 && val[2]==0x4257) { |
| 834 |
if (val[3]==0x7770) { |
| 835 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a BeagleWorks file\n")); |
| 836 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1)); |
| 837 |
return res; |
| 838 |
} |
| 839 |
if (val[3]==0x6462) { |
| 840 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a BeagleWorks Database file\n")); |
| 841 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_DATABASE)); |
| 842 |
return res; |
| 843 |
} |
| 844 |
if (val[3]==0x6472) { |
| 845 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a BeagleWorks Draw file\n")); |
| 846 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_DRAW)); |
| 847 |
return res; |
| 848 |
} |
| 849 |
if (val[3]==0x7074) { |
| 850 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a BeagleWorks Paint file\n")); |
| 851 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_PAINT)); |
| 852 |
return res; |
| 853 |
} |
| 854 |
if (val[3]==0x7373) { |
| 855 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a BeagleWorks Spreadsheet file\n")); |
| 856 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_BEAGLEWORKS, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 857 |
return res; |
| 858 |
} |
| 859 |
} |
| 860 |
if (val[0]==0 && val[1]==0 && val[2]==0 && val[3]==0x70 && val[4]==0x1100) { |
| 861 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Scoop file\n")); |
| 862 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SCOOP, 1, MWAWDocument::MWAW_K_DRAW)); |
| 863 |
return res; |
| 864 |
} |
| 865 |
if (val[0]==0x4452 && val[1]==0x5747) { // DRWG |
| 866 |
if (val[2]==0x4d44) { // MD |
| 867 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacDraw file\n")); |
| 868 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAW, 1, MWAWDocument::MWAW_K_DRAW)); |
| 869 |
return res; |
| 870 |
} |
| 871 |
if (val[2]==0 || val[2]==0x4432) { // D2 |
| 872 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacDraw II file\n")); |
| 873 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 0, MWAWDocument::MWAW_K_DRAW)); |
| 874 |
// can also be a classic apple pict, so let's continue |
| 875 |
} |
| 876 |
} |
| 877 |
if (val[0]==0x1a54 && val[1]==0x4c43 && (val[2]&0xfeff)==0x246 && val[3]==0x4600) { |
| 878 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Student Writing Center file\n")); |
| 879 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_STUDENTWRITING, 1)); |
| 880 |
} |
| 881 |
if (val[0]==0x5354 && val[1]==0x4154 && (val[2]==0 || val[2]==0x4432)) { |
| 882 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacDraw II template file\n")); |
| 883 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 0, MWAWDocument::MWAW_K_DRAW)); |
| 884 |
return res; |
| 885 |
} |
| 886 |
#ifdef DEBUG |
| 887 |
// we need the resource fork to find the colors, patterns, ... ; so not active in normal mode |
| 888 |
if (val[0]==0x6444 && val[1]==0x6f63 && val[2]==0x4432) { // dDocD2 |
| 889 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacDraw Pro file\n")); |
| 890 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 1, MWAWDocument::MWAW_K_DRAW)); |
| 891 |
return res; |
| 892 |
} |
| 893 |
if (val[0]==0x644c && val[1]==0x6962 && val[2]==0x4432) { // dLibD2 |
| 894 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacDraw Pro template file\n")); |
| 895 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAWPRO, 1, MWAWDocument::MWAW_K_DRAW)); |
| 896 |
return res; |
| 897 |
} |
| 898 |
#endif |
| 899 |
// Canvas |
| 900 |
if (val[0]==0x200 && val[1]==0x80) { |
| 901 |
if (val[2]==0 && val[3]==0 && (val[4]>>8)<=8 && (val[4]&0xff)==0) { |
| 902 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 5 file\n")); |
| 903 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 5, MWAWDocument::MWAW_K_DRAW)); |
| 904 |
} |
| 905 |
else { // 0 followed by compression mode |
| 906 |
input->seek(9, librevenge::RVNG_SEEK_SET); |
| 907 |
auto len=input->readULong(4); |
| 908 |
if (len>=0x800 && len<=0x8000) { // block size |
| 909 |
auto len1=input->readULong(4); |
| 910 |
if (len1>0x800 && len1<=0x800c) { |
| 911 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 6-8 file\n")); |
| 912 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 6, MWAWDocument::MWAW_K_DRAW)); |
| 913 |
} |
| 914 |
} |
| 915 |
} |
| 916 |
} |
| 917 |
if (val[0]==0x100 && val[1]==0x8000) { |
| 918 |
if ((val[2]>=0&&val[2]<=8) && val[3]==0 && (val[4]>>8)==0) { |
| 919 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 5 win file\n")); |
| 920 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 5, MWAWDocument::MWAW_K_DRAW)); |
| 921 |
} |
| 922 |
else { |
| 923 |
input->setReadInverted(true); |
| 924 |
input->seek(9, librevenge::RVNG_SEEK_SET); |
| 925 |
auto len=input->readULong(4); |
| 926 |
if (len>=0x800 && len<=0x8000) { // block size |
| 927 |
auto len1=input->readULong(4); |
| 928 |
if (len1>0x800 && len1<=0x800c) { |
| 929 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 6-8 win file\n")); |
| 930 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 6, MWAWDocument::MWAW_K_DRAW)); |
| 931 |
} |
| 932 |
} |
| 933 |
input->setReadInverted(false); |
| 934 |
} |
| 935 |
} |
| 936 |
if (val[0]==0 && val[1]==0 && val[2]==0 && val[3]==0 && val[4]==0) { |
| 937 |
input->seek(10, librevenge::RVNG_SEEK_SET); |
| 938 |
int v=int(input->readULong(2)); |
| 939 |
if ((v==0x100 && input->readULong(2)==0x8000) || // windows |
| 940 |
(v==0x200 && input->readULong(2)==0x80)) { // mac |
| 941 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 9-11 file\n")); |
| 942 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, 9, MWAWDocument::MWAW_K_DRAW)); |
| 943 |
} |
| 944 |
} |
| 945 |
if (val[0]==0 && (val[1]==1||val[1]==2) && val[2]==0x4441 && val[3]==0x4435 && val[4]==0x5052) { |
| 946 |
if (val[1]==1) { |
| 947 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 5-8 image file\n")); |
| 948 |
} |
| 949 |
else { |
| 950 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 9-10 image file\n")); |
| 951 |
} |
| 952 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, val[1]==1 ? 5 : 9, MWAWDocument::MWAW_K_PAINT)); |
| 953 |
} |
| 954 |
if (val[0]==2 && val[1]==0 && val[2]==2 && val[3]==0x262 && val[4]==0x262) { |
| 955 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacDraft file\n")); |
| 956 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAFT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 957 |
return res; |
| 958 |
} |
| 959 |
if (val[0]==0x4859 && val[1]==0x4c53 && val[2]==0x0210) { |
| 960 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a HanMac Word-K file\n")); |
| 961 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_HANMACWORDK, 1)); |
| 962 |
return res; |
| 963 |
} |
| 964 |
if (val[0]==0x594c && val[1]==0x5953 && val[2]==0x100) { |
| 965 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a HanMac Word-J file\n")); |
| 966 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_HANMACWORDJ, 1)); |
| 967 |
return res; |
| 968 |
} |
| 969 |
if (val[0]==0x6163 && val[1]==0x6633 && val[2]<9) { |
| 970 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a FreeHand v1\n")); |
| 971 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FREEHAND, 1, MWAWDocument::MWAW_K_DRAW)); |
| 972 |
return res; |
| 973 |
} |
| 974 |
if (val[0]==0x4648 && val[1]==0x4432 && val[2]<20) { |
| 975 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a FreeHand v2\n")); |
| 976 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FREEHAND, 2, MWAWDocument::MWAW_K_DRAW)); |
| 977 |
return res; |
| 978 |
} |
| 979 |
if (val[0]==3 && val[1]==0x4d52 && val[2]==0x4949 && val[3]==0x80) { // MRII |
| 980 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MORE, 2)); |
| 981 |
return res; |
| 982 |
} |
| 983 |
if (val[0]==6 && val[1]==0x4d4f && val[2]==0x5233 && val[3]==0x80) { // MOR3 |
| 984 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MORE, 3)); |
| 985 |
return res; |
| 986 |
} |
| 987 |
if ((val[0]==0x100||val[0]==0x200) && val[2]==0x4558 && val[3]==0x5057) { // CHANGEME: ClarisDraw |
| 988 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CLARISDRAW, 1, MWAWDocument::MWAW_K_DRAW)); |
| 989 |
return res; |
| 990 |
} |
| 991 |
|
| 992 |
if (val[0]==0x100 || val[0]==0x200) { |
| 993 |
if (val[1]==0x5a57 && val[2]==0x5254) { |
| 994 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, val[0]==0x100 ? 1 : 2)); |
| 995 |
return res; |
| 996 |
} |
| 997 |
if (val[1]==0x5a4f && val[2]==0x424a) { |
| 998 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, val[0]==0x100 ? 1 : 2, MWAWDocument::MWAW_K_DRAW)); |
| 999 |
return res; |
| 1000 |
} |
| 1001 |
if (val[1]==0x5a43 && val[2]==0x414C) { |
| 1002 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, val[0]==0x100 ? 1 : 2, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 1003 |
return res; |
| 1004 |
} |
| 1005 |
if (val[1]==0x5a44 && val[2]==0x4253) { |
| 1006 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_GREATWORKS, val[0]==0x100 ? 1 : 2, MWAWDocument::MWAW_K_DATABASE)); |
| 1007 |
return res; |
| 1008 |
} |
| 1009 |
// maybe we can also add outline: if (val[1]==0x5a4f && val[2]==0x4c4e) |
| 1010 |
} |
| 1011 |
if (val[0]==0xcd90 && (val[2]&0xff00)==0) |
| 1012 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SPRINGBOARD_PUBLISHER, 2, MWAWDocument::MWAW_K_DRAW)); |
| 1013 |
if (val[0]==0x11ab && val[1]==0 && val[2]==0x13e8 && val[3]==0) { |
| 1014 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTMULTIPLAN, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 1015 |
return res; |
| 1016 |
} |
| 1017 |
if (val[3]==6 && val[4]<6) { |
| 1018 |
if (val[0]==0x4d44 && val[1]==0x4443 && val[2]==0x3230) { |
| 1019 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAFT, 4, MWAWDocument::MWAW_K_DRAW)); |
| 1020 |
return res; |
| 1021 |
} |
| 1022 |
// can be a library file, this will be test in the parser |
| 1023 |
if (input->size()>=30) |
| 1024 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAFT, 4, MWAWDocument::MWAW_K_DRAW)); |
| 1025 |
} |
| 1026 |
// magic ole header |
| 1027 |
if (val[0]==0xd0cf && val[1]==0x11e0 && val[2]==0xa1b1 && val[3]==0x1ae1 && input->isStructured()) { |
| 1028 |
MWAWInputStreamPtr mainOle = input->getSubStreamByName("MN0"); |
| 1029 |
if (mainOle && mainOle->readULong(4) == 0x43484e4b) |
| 1030 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 4)); |
| 1031 |
else if (mainOle && mainOle->size()>18) { |
| 1032 |
mainOle->seek(16, librevenge::RVNG_SEEK_SET); |
| 1033 |
auto value=static_cast<int>(mainOle->readULong(2)); |
| 1034 |
switch (value) { |
| 1035 |
case 2: |
| 1036 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 4, MWAWDocument::MWAW_K_DATABASE)); |
| 1037 |
break; |
| 1038 |
case 3: |
| 1039 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 4, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 1040 |
break; |
| 1041 |
case 12: |
| 1042 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, 4, MWAWDocument::MWAW_K_DRAW)); |
| 1043 |
break; |
| 1044 |
default: |
| 1045 |
break; |
| 1046 |
} |
| 1047 |
} |
| 1048 |
if (!mainOle && input->getSubStreamByName("PP40")) |
| 1049 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_POWERPOINT, 4, MWAWDocument::MWAW_K_PRESENTATION)); |
| 1050 |
else if (!mainOle && input->getSubStreamByName("PowerPoint Document") && input->getSubStreamByName("PersistentStorage Directory")) |
| 1051 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_POWERPOINT, 7, MWAWDocument::MWAW_K_PRESENTATION)); |
| 1052 |
} |
| 1053 |
if (val[0]==0 && val[1]==2 && val[2]==11) { |
| 1054 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Jazz spreadsheet file\n")); |
| 1055 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_JAZZLOTUS, 1, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 1056 |
} |
| 1057 |
|
| 1058 |
if ((val[0]==0xfe32 && val[1]==0) || (val[0]==0xfe34 && val[1]==0) || |
| 1059 |
(val[0] == 0xfe37 && (val[1] == 0x23 || val[1] == 0x1c))) { |
| 1060 |
int vers = -1; |
| 1061 |
switch (val[1]) { |
| 1062 |
case 0: |
| 1063 |
if (val[0]==0xfe34) { |
| 1064 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Word 3.0 file\n")); |
| 1065 |
vers = 3; |
| 1066 |
} |
| 1067 |
else if (val[0]==0xfe32) { |
| 1068 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Word 1.0 file\n")); |
| 1069 |
vers = 1; |
| 1070 |
} |
| 1071 |
break; |
| 1072 |
case 0x1c: |
| 1073 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Word 4.0 file\n")); |
| 1074 |
vers = 4; |
| 1075 |
break; |
| 1076 |
case 0x23: |
| 1077 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Word 5.0 file\n")); |
| 1078 |
vers = 5; |
| 1079 |
break; |
| 1080 |
default: |
| 1081 |
break; |
| 1082 |
} |
| 1083 |
if (vers >= 0) |
| 1084 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORD, vers)); |
| 1085 |
} |
| 1086 |
if (val[0]==0xbad && val[1]==0xdeed && val[2]==0 && (val[3]>=2 && val[3]<=3)) { |
| 1087 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Presentation file\n")); |
| 1088 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_POWERPOINT, val[3], MWAWDocument::MWAW_K_PRESENTATION)); |
| 1089 |
} |
| 1090 |
if (val[0]==0xedde && val[1]==0xad0b && val[3]==0 && (val[2]&0xFF)==0) { |
| 1091 |
int vers=(val[2]>>8); |
| 1092 |
if (vers>=2 && vers<=3) { |
| 1093 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Presentation file\n")); |
| 1094 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_POWERPOINT, vers, MWAWDocument::MWAW_K_PRESENTATION)); |
| 1095 |
} |
| 1096 |
} |
| 1097 |
if (val[0]==0x4348 && val[1]==0x4e4b && val[2]==0x100 && val[3]==0) { |
| 1098 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Style file\n")); |
| 1099 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_STYLE, 1)); |
| 1100 |
} |
| 1101 |
if (val[0]==0x0447 && val[1]==0x4d30 && val[2]==0x3400) { // ^DGM04 |
| 1102 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MouseWrite file\n")); |
| 1103 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MOUSEWRITE, 1)); |
| 1104 |
} |
| 1105 |
if (val[0]==0x1e && val[1]==0 && val[2]==0x86) { |
| 1106 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ReadySetGo 3 file\n")); |
| 1107 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 3, MWAWDocument::MWAW_K_DRAW)); |
| 1108 |
} |
| 1109 |
if ((val[0] >= 400 && val[0] <= 402) && (val[1]&0xff00)==0) { |
| 1110 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ReadySetGo 4 file\n")); |
| 1111 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 4, MWAWDocument::MWAW_K_DRAW)); |
| 1112 |
} |
| 1113 |
if ((val[0] >= 5000 && val[0] <= 5005) && (val[1]&0xff00)==0) { |
| 1114 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ReadySetGo 4.5 file\n")); |
| 1115 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 5, MWAWDocument::MWAW_K_DRAW)); |
| 1116 |
} |
| 1117 |
if ((val[0] >= 6000 && val[0] <= 6003) && (val[1]&0xff00)==0) { |
| 1118 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ReadySetGo 6 file\n")); |
| 1119 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 6, MWAWDocument::MWAW_K_DRAW)); |
| 1120 |
} |
| 1121 |
if (val[0] == 0x1bbc && (val[1]&0xff00)==0) { |
| 1122 |
// I only find some demo files, these files look very simillar to v6 files |
| 1123 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ReadySetGo 7.1 file\n")); |
| 1124 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 7, MWAWDocument::MWAW_K_DRAW)); |
| 1125 |
} |
| 1126 |
if (val[0] == 0x13e4 && (val[1]&0xff00)==0) { |
| 1127 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Design Studio 2 file\n")); |
| 1128 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 5, MWAWDocument::MWAW_K_DRAW)); |
| 1129 |
} |
| 1130 |
// ----------- less discriminant ------------------ |
| 1131 |
if (val[0] == 0x2e && val[1] == 0x2e) { |
| 1132 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacWrite II file\n")); |
| 1133 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACWRITEPRO, 0)); |
| 1134 |
} |
| 1135 |
if (val[0] == 4 && val[1] == 4) { |
| 1136 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MacWritePro file\n")); |
| 1137 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACWRITEPRO, 1)); |
| 1138 |
} |
| 1139 |
if (val[0]==0x464f && val[1]==0x524d) { |
| 1140 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a WordMaker file\n")); |
| 1141 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WORDMAKER, 1)); |
| 1142 |
} |
| 1143 |
if (val[0] == 0x7704) { |
| 1144 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a MindWrite file 2.1\n")); |
| 1145 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MINDWRITE, 2)); |
| 1146 |
} |
| 1147 |
if (val[0] == 0x78) { |
| 1148 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ReadySetGo 1/2 file\n")); |
| 1149 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_READYSETGO, 1, MWAWDocument::MWAW_K_DRAW)); |
| 1150 |
} |
| 1151 |
// ----------- other ------------------ |
| 1152 |
if (val[0]==0 && val[1]==0 && val[2]==0 && val[3]==0) { |
| 1153 |
input->seek(8, librevenge::RVNG_SEEK_SET); |
| 1154 |
auto value=static_cast<int>(input->readULong(1)); |
| 1155 |
if (value==0x4 || value==0x44) { |
| 1156 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a WriteNow 1.0 or 2.0 file\n")); |
| 1157 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WRITENOW, 2)); |
| 1158 |
} |
| 1159 |
} |
| 1160 |
if (val[0]==0 && input->size() > 32) { |
| 1161 |
input->seek(16, librevenge::RVNG_SEEK_SET); |
| 1162 |
if (input->readLong(2)==0x688f && input->readLong(2)==0x688f) { |
| 1163 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a RagTime file\n")); |
| 1164 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_RAGTIME)); |
| 1165 |
} |
| 1166 |
} |
| 1167 |
if (val[0]==0) { |
| 1168 |
int vers = -1; |
| 1169 |
switch (val[1]) { |
| 1170 |
case 4: |
| 1171 |
vers = 1; |
| 1172 |
break; |
| 1173 |
case 8: |
| 1174 |
vers = 2; |
| 1175 |
break; |
| 1176 |
case 9: |
| 1177 |
vers = 3; |
| 1178 |
break; |
| 1179 |
case 11: // embedded data |
| 1180 |
vers = 4; |
| 1181 |
break; |
| 1182 |
default: |
| 1183 |
break; |
| 1184 |
} |
| 1185 |
if (vers > 0 && input->size()>16) { |
| 1186 |
input->seek(16, librevenge::RVNG_SEEK_SET); |
| 1187 |
auto value=static_cast<int>(input->readULong(2)); |
| 1188 |
switch (value) { |
| 1189 |
case 1: |
| 1190 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, vers)); |
| 1191 |
break; |
| 1192 |
case 2: |
| 1193 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, vers, MWAWDocument::MWAW_K_DATABASE)); |
| 1194 |
break; |
| 1195 |
case 3: |
| 1196 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, vers, MWAWDocument::MWAW_K_SPREADSHEET)); |
| 1197 |
break; |
| 1198 |
case 12: |
| 1199 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MICROSOFTWORKS, vers, MWAWDocument::MWAW_K_DRAW)); |
| 1200 |
break; |
| 1201 |
default: |
| 1202 |
break; |
| 1203 |
} |
| 1204 |
} |
| 1205 |
} |
| 1206 |
if (val[0]==0x4d44 && input->size()>=512) { // maybe a MacDraw 0 file, will be check later |
| 1207 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACDRAW, 0, MWAWDocument::MWAW_K_DRAW)); |
| 1208 |
} |
| 1209 |
if (val[0]==2 && (val[1]&0xff)==0 && input->size() > 300) { |
| 1210 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CORELPAINTER, 1, MWAWDocument::MWAW_K_PAINT)); |
| 1211 |
} |
| 1212 |
if (val[0] == 3 || val[0] == 6) { |
| 1213 |
// version will be print by MacWrtParser::check |
| 1214 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACWRITE, val[0])); |
| 1215 |
} |
| 1216 |
if (val[0] == 0x110) { |
| 1217 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a Writerplus file\n")); |
| 1218 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_WRITERPLUS, 1)); |
| 1219 |
} |
| 1220 |
if (val[0] == 0x1000) { |
| 1221 |
input->seek(10, librevenge::RVNG_SEEK_SET); |
| 1222 |
auto value=static_cast<int>(input->readULong(2)); |
| 1223 |
// 1: bitmap, 2: vectorized graphic |
| 1224 |
if (value==1) |
| 1225 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SUPERPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 1226 |
else if (value==2) |
| 1227 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SUPERPAINT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 1228 |
} |
| 1229 |
if (val[0]==0 && (val[1]==0x7FFF || val[1]==0x8000)) { |
| 1230 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential PixelPaint file\n")); |
| 1231 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_PIXELPAINT, (val[1]==0x7FFF) ? 1 : 2, MWAWDocument::MWAW_K_PAINT)); |
| 1232 |
} |
| 1233 |
if (val[0]>=1 && val[0]<=4) { |
| 1234 |
int sSz=(val[1]>>8); |
| 1235 |
if (sSz>=6 && sSz<=8) { |
| 1236 |
// check if we find a date |
| 1237 |
input->seek(3, librevenge::RVNG_SEEK_SET); |
| 1238 |
bool ok=true; |
| 1239 |
int numSlash=0; |
| 1240 |
for (int i=0; i<sSz; ++i) { |
| 1241 |
auto c=char(input->readULong(1)); |
| 1242 |
if (c>='0' && c<='9') |
| 1243 |
continue; |
| 1244 |
if (c=='/') |
| 1245 |
++numSlash; |
| 1246 |
else { |
| 1247 |
ok=false; |
| 1248 |
break; |
| 1249 |
} |
| 1250 |
} |
| 1251 |
if (ok && numSlash==2) |
| 1252 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CRICKETDRAW, 1, MWAWDocument::MWAW_K_DRAW)); |
| 1253 |
} |
| 1254 |
} |
| 1255 |
|
| 1256 |
// |
| 1257 |
// check for pict |
| 1258 |
// |
| 1259 |
for (int st=0; st<2; ++st) { |
| 1260 |
if (!input->checkPosition(512*st+13)) |
| 1261 |
break; |
| 1262 |
input->seek(512*st+10, librevenge::RVNG_SEEK_SET); |
| 1263 |
auto value=static_cast<int>(input->readULong(2)); |
| 1264 |
if (value==0x1101) { |
| 1265 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_APPLEPICT, 1, MWAWDocument::MWAW_K_DRAW)); |
| 1266 |
break; |
| 1267 |
} |
| 1268 |
else if (value==0x11 && input->readULong(2)==0x2ff && input->readULong(2) == 0xC00) { |
| 1269 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_APPLEPICT, 2, MWAWDocument::MWAW_K_DRAW)); |
| 1270 |
break; |
| 1271 |
} |
| 1272 |
} |
| 1273 |
// |
| 1274 |
// middle of file |
| 1275 |
// |
| 1276 |
if (input->size()>=512+720*2) { |
| 1277 |
// check for a MacPaint file |
| 1278 |
input->seek(512, librevenge::RVNG_SEEK_SET); |
| 1279 |
bool ok=true; |
| 1280 |
// check the first 3 row |
| 1281 |
for (int row=0; row<3; ++row) { |
| 1282 |
int lastColor=-1; |
| 1283 |
int col=0; |
| 1284 |
while (col<72) { |
| 1285 |
if (input->tell()+2>input->size()) { |
| 1286 |
ok=false; |
| 1287 |
break; |
| 1288 |
} |
| 1289 |
auto wh=static_cast<int>(input->readULong(1)); |
| 1290 |
if (wh>=0x81) { |
| 1291 |
auto color=static_cast<int>(input->readULong(1)); |
| 1292 |
// consider that repeat color is anormal... |
| 1293 |
if (col+(0x101-wh)>72 || (lastColor>=0 && color==lastColor)) { |
| 1294 |
ok=false; |
| 1295 |
break; |
| 1296 |
} |
| 1297 |
col+=(0x101-wh); |
| 1298 |
lastColor=color; |
| 1299 |
continue; |
| 1300 |
} |
| 1301 |
if (col+1+wh>72) { |
| 1302 |
ok=false; |
| 1303 |
break; |
| 1304 |
} |
| 1305 |
lastColor=-1; |
| 1306 |
col += wh+1; |
| 1307 |
input->seek(wh+1, librevenge::RVNG_SEEK_CUR); |
| 1308 |
} |
| 1309 |
if (!ok) break; |
| 1310 |
} |
| 1311 |
if (ok) { |
| 1312 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential MacPaint file\n")); |
| 1313 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_MACPAINT, 1, MWAWDocument::MWAW_K_PAINT)); |
| 1314 |
} |
| 1315 |
} |
| 1316 |
if ((val[0]>=0x82 && val[0]<=0x85) && val[1]<=0x2) { |
| 1317 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential ScriptWriter file\n")); |
| 1318 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_SCRIPTWRITER, 1)); |
| 1319 |
} |
| 1320 |
if ((val[0]>0 || val[1]>=86) && input->size()>0x900) { |
| 1321 |
input->seek(0x34, librevenge::RVNG_SEEK_SET); |
| 1322 |
int littleEndian=int(input->readULong(1)); |
| 1323 |
if (littleEndian==1) |
| 1324 |
input->setReadInverted(true); |
| 1325 |
input->seek(1, librevenge::RVNG_SEEK_CUR); |
| 1326 |
int vers=int(input->readULong(2)); |
| 1327 |
if (littleEndian<=1 && (vers==1 || vers==2)) { |
| 1328 |
input->seek(0, librevenge::RVNG_SEEK_SET); |
| 1329 |
int numZero=0; |
| 1330 |
for (int i=0; i<13; ++i) { |
| 1331 |
int len=int(input->readLong(4)); |
| 1332 |
if (len<0) { |
| 1333 |
numZero=1000; |
| 1334 |
break; |
| 1335 |
} |
| 1336 |
if (len==0) |
| 1337 |
++numZero; |
| 1338 |
} |
| 1339 |
if (numZero<=2+littleEndian) { |
| 1340 |
MWAW_DEBUG_MSG(("MWAWHeader::constructHeader: find a potential Canvas 2/3 file\n")); |
| 1341 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_CANVAS, vers+1, MWAWDocument::MWAW_K_DRAW)); |
| 1342 |
} |
| 1343 |
} |
| 1344 |
if (littleEndian==1) |
| 1345 |
input->setReadInverted(false); |
| 1346 |
} |
| 1347 |
// |
| 1348 |
//ok now look at the end of file |
| 1349 |
// |
| 1350 |
if (input->seek(-4, librevenge::RVNG_SEEK_END)) |
| 1351 |
return res; |
| 1352 |
int lVal[2]; |
| 1353 |
for (auto &v : lVal) v=int(input->readULong(2)); |
| 1354 |
if (lVal[0] == 0x4E4C && lVal[1]==0x544F) // NLTO |
| 1355 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_ACTA, 2)); |
| 1356 |
else if (lVal[1]==0 && val[0]==1 && (val[1]==1||val[1]==2)) |
| 1357 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_ACTA, 1)); |
| 1358 |
else if (lVal[0] == 0x4657 && lVal[1]==0x5254) // FWRT |
| 1359 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FULLWRITE, 2)); |
| 1360 |
else if (lVal[0] == 0 && lVal[1]==1) // not probable, but |
| 1361 |
res.push_back(MWAWHeader(MWAWDocument::MWAW_T_FULLWRITE, 1)); |
| 1362 |
|
| 1363 |
input->seek(0, librevenge::RVNG_SEEK_SET); |
| 1364 |
return res; |
| 1365 |
} |
| 1366 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |