| 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 <cctype> |
| 35 |
#include <iomanip> |
| 36 |
#include <iostream> |
| 37 |
#include <sstream> |
| 38 |
|
| 39 |
#include "MWAWDebug.hxx" |
| 40 |
#include "MWAWPrinter.hxx" |
| 41 |
|
| 42 |
#include "RagTime5ClusterManager.hxx" |
| 43 |
#include "RagTime5Document.hxx" |
| 44 |
#include "RagTime5Formula.hxx" |
| 45 |
#include "RagTime5Text.hxx" |
| 46 |
|
| 47 |
#include "RagTime5StructManager.hxx" |
| 48 |
|
| 49 |
//////////////////////////////////////////////////////////// |
| 50 |
// constructor/destructor, ... |
| 51 |
//////////////////////////////////////////////////////////// |
| 52 |
RagTime5StructManager::RagTime5StructManager(RagTime5Document &doc) |
| 53 |
: m_document(doc) |
| 54 |
{ |
| 55 |
} |
| 56 |
|
| 57 |
RagTime5StructManager::~RagTime5StructManager() |
| 58 |
{ |
| 59 |
} |
| 60 |
|
| 61 |
RagTime5StructManager::DataParser::DataParser(std::string const &zoneName) |
| 62 |
: m_name(zoneName) |
| 63 |
{ |
| 64 |
if (!m_name.empty()) |
| 65 |
m_name[0]=char(std::toupper((unsigned char)(m_name[0]))); |
| 66 |
} |
| 67 |
|
| 68 |
RagTime5StructManager::DataParser::~DataParser() |
| 69 |
{ |
| 70 |
} |
| 71 |
|
| 72 |
RagTime5StructManager::FieldParser::~FieldParser() |
| 73 |
{ |
| 74 |
} |
| 75 |
//////////////////////////////////////////////////////////// |
| 76 |
// read basic structures |
| 77 |
//////////////////////////////////////////////////////////// |
| 78 |
bool RagTime5StructManager::readCompressedLong(MWAWInputStreamPtr &input, long endPos, long &val) |
| 79 |
{ |
| 80 |
val=long(input->readULong(1)); |
| 81 |
if ((val&0xF0)==0xC0) { |
| 82 |
input->seek(-1, librevenge::RVNG_SEEK_CUR); |
| 83 |
val=long(MWAWInputStream::readULong(input->input().get(), 4, 0, false)&0xFFFFFFF); |
| 84 |
} |
| 85 |
else if (val>=0xD0) { // never seems, but may be ok |
| 86 |
MWAW_DEBUG_MSG(("RagTime5Struct::readCompressedLong: can not read a long\n")); |
| 87 |
return false; |
| 88 |
} |
| 89 |
else if (val>=0x80) |
| 90 |
val=((val&0x7F)<<8)+long(input->readULong(1)); |
| 91 |
return input->tell()<=endPos; |
| 92 |
} |
| 93 |
|
| 94 |
std::string RagTime5StructManager::printType(unsigned long fileType) |
| 95 |
{ |
| 96 |
static std::map<unsigned long, char const *> const s_typeToName = { |
| 97 |
{0x145e042, "fillStyle[container]"}, |
| 98 |
{0x1460042, "lineStyle[container]"}, |
| 99 |
{0x146902a, "unit[base,from]"}, |
| 100 |
{0x146903a, "unit[base,to]"}, |
| 101 |
{0x146904a, "unit[base,id]"}, |
| 102 |
{0x146905a, "unit[name]"}, |
| 103 |
{0x146907a, "unit[second,id]"}, // rare |
| 104 |
{0x146908a, "unit[digits,place]"}, |
| 105 |
{0x146a042, "unit[container]"}, |
| 106 |
{0x146e02a, "ruler[unit,id]"}, |
| 107 |
{0x146e03a, "ruler[step,major]"}, |
| 108 |
{0x146e04a, "ruler[step,minor]"}, |
| 109 |
{0x146e05a, "ruler[grid/major]"}, // a fraction or a fixed decimal? |
| 110 |
{0x146e06a, "ruler[grid,line/gridPoint]"}, |
| 111 |
{0x146f042, "ruler[container]"}, |
| 112 |
{0x17d5042, "color[container]"}, |
| 113 |
|
| 114 |
// functions collections |
| 115 |
{0x14c2042, "functions[layout]"}, |
| 116 |
{0x1559842, "functions[standart]"}, |
| 117 |
{0x1663842, "functions[spreadsheet]"}, |
| 118 |
{0x1be5042, "functions[fax]"}, |
| 119 |
{0x1d50842, "functions[button]"}, |
| 120 |
{0x1e16842, "functions[slide]"}, |
| 121 |
{0x23aa042, "functions[calendar]"}, |
| 122 |
{0x23af042, "functions[serialNumber]"}, |
| 123 |
{0x23b4042, "functions[euro]"}, |
| 124 |
}; |
| 125 |
auto it=s_typeToName.find(fileType); |
| 126 |
if (it!=s_typeToName.end()) |
| 127 |
return it->second; |
| 128 |
std::stringstream s; |
| 129 |
s << (fileType>>11) << "-" << std::hex << (fileType&0x7ff) << std::dec; |
| 130 |
return s.str(); |
| 131 |
} |
| 132 |
|
| 133 |
bool RagTime5StructManager::readTypeDefinitions(RagTime5Zone &zone) |
| 134 |
{ |
| 135 |
if (zone.m_entry.length()<26) return false; |
| 136 |
MWAWInputStreamPtr input=zone.getInput(); |
| 137 |
long endPos=zone.m_entry.end(); |
| 138 |
input->setReadInverted(!zone.m_hiLoEndian); |
| 139 |
input->seek(zone.m_entry.begin(), librevenge::RVNG_SEEK_SET); |
| 140 |
|
| 141 |
libmwaw::DebugStream f; |
| 142 |
f << "Entries(TypeDef):[" << zone << "]"; |
| 143 |
long N; |
| 144 |
if (!input->checkPosition(endPos) || !RagTime5StructManager::readCompressedLong(input, endPos, N) || N<20 || 12+14*N>zone.m_entry.length()) { |
| 145 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: can not read the list type zone\n")); |
| 146 |
input->setReadInverted(false); |
| 147 |
return false; |
| 148 |
} |
| 149 |
zone.m_isParsed=true; |
| 150 |
libmwaw::DebugFile &ascFile=zone.ascii(); |
| 151 |
f << "N=" << N << ","; |
| 152 |
int val; |
| 153 |
for (int i=0; i<2; ++i) { // always 0,0 |
| 154 |
val=static_cast<int>(input->readLong(2)); |
| 155 |
if (val) f << "f" << i << "=" << val << ","; |
| 156 |
} |
| 157 |
auto sz=static_cast<int>(input->readULong(1)); |
| 158 |
if (input->tell()+sz>endPos) { |
| 159 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: can not find the data1 sz\n")); |
| 160 |
return false; |
| 161 |
} |
| 162 |
if (sz) { |
| 163 |
f << "data1=[" << std::hex; |
| 164 |
for (int i=0; i<sz+1; ++i) { |
| 165 |
val=static_cast<int>(input->readULong(1)); |
| 166 |
if (val) f << val << ","; |
| 167 |
else f << "_,"; |
| 168 |
} |
| 169 |
f << std::dec << "],"; |
| 170 |
} |
| 171 |
long debDataPos=input->tell()+4*(N+1); |
| 172 |
long remain=endPos-debDataPos; |
| 173 |
if (remain<=0) { |
| 174 |
input->setReadInverted(false); |
| 175 |
return false; |
| 176 |
} |
| 177 |
f << "ptr=[" << std::hex; |
| 178 |
std::vector<long> listPtrs(size_t(N+1), -1); |
| 179 |
long lastPtr=0; |
| 180 |
int numOk=0; |
| 181 |
for (size_t i=0; i<=size_t(N); ++i) { |
| 182 |
auto ptr=long(input->readULong(4)); |
| 183 |
if (ptr<0 || ptr>remain || ptr<lastPtr) { |
| 184 |
f << "###"; |
| 185 |
static bool first=true; |
| 186 |
if (first) { |
| 187 |
first = false; |
| 188 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: problem reading some type position\n")); |
| 189 |
} |
| 190 |
listPtrs[size_t(i)]=lastPtr; |
| 191 |
} |
| 192 |
else { |
| 193 |
++numOk; |
| 194 |
lastPtr=listPtrs[size_t(i)]=ptr; |
| 195 |
} |
| 196 |
f << ptr << ","; |
| 197 |
} |
| 198 |
f << std::dec << "],"; |
| 199 |
ascFile.addPos(zone.m_entry.begin()); |
| 200 |
ascFile.addNote(f.str().c_str()); |
| 201 |
ascFile.addPos(endPos); |
| 202 |
ascFile.addNote("_"); |
| 203 |
if (!numOk) { |
| 204 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: problem reading some type position\n")); |
| 205 |
input->setReadInverted(false); |
| 206 |
return false; |
| 207 |
} |
| 208 |
|
| 209 |
// first 10 main types are the same: |
| 210 |
// 0: 1451042, 1:6d042, 2:cf042, 3:1454042, 4:74040, 5:df842, 6:ce042, 7:3c042, 8:ce842, 9:67842, 10:6a842 |
| 211 |
// Component correspondance |
| 212 |
// 14b5842: layout, 14b7842: master layout, |
| 213 |
// 14e6842: drawing |
| 214 |
// 15e0842: Text |
| 215 |
// 1645042: spreadsheet |
| 216 |
// 16a8842: Graph |
| 217 |
// 170c842: Picture |
| 218 |
// 1d4d042: Button |
| 219 |
// 1d7f842: Sound |
| 220 |
// 1db0842: Movie |
| 221 |
for (size_t i=0; i+1<listPtrs.size(); ++i) { |
| 222 |
if (listPtrs[i]<0 || listPtrs[i]==listPtrs[i+1]) continue; |
| 223 |
if (listPtrs[i]==remain) break; |
| 224 |
f.str(""); |
| 225 |
f << "TypeDef-" << i << "[head]:"; |
| 226 |
auto dSz=int(listPtrs[i+1]-listPtrs[i]); |
| 227 |
long pos=debDataPos+listPtrs[i]; |
| 228 |
if (dSz<4+20) { |
| 229 |
f << "###"; |
| 230 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: problem with some type size\n")); |
| 231 |
ascFile.addPos(pos); |
| 232 |
ascFile.addNote(f.str().c_str()); |
| 233 |
} |
| 234 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 235 |
val=static_cast<int>(input->readLong(4)); |
| 236 |
if (val!=1) f << "num[used]=" << val << ","; |
| 237 |
auto hSz=static_cast<int>(input->readULong(2)); |
| 238 |
int nData=(dSz-4-hSz)/12; |
| 239 |
if (4+hSz>dSz || dSz!=4+hSz+12*nData || nData<0 || hSz<20) { |
| 240 |
f << "###hSz=" << hSz << ","; |
| 241 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: the header size seems bad\n")); |
| 242 |
ascFile.addPos(pos); |
| 243 |
ascFile.addNote(f.str().c_str()); |
| 244 |
continue; |
| 245 |
} |
| 246 |
val=static_cast<int>(input->readULong(2)); |
| 247 |
if (val) f << "fl=" << std::hex << val << std::dec << ","; |
| 248 |
val=static_cast<int>(input->readULong(4)); |
| 249 |
if (val) f << "id?=" << std::hex << val << std::dec << ","; // maybe a date, origin? |
| 250 |
auto type=input->readULong(4); |
| 251 |
if (type) f << "type=" << printType(type) << ","; |
| 252 |
for (int j=0; j<2; ++j) { // f1=0..12, |
| 253 |
val=static_cast<int>(input->readLong(2)); |
| 254 |
if (val) f << "f" << j+1 << "=" << val << ","; |
| 255 |
} |
| 256 |
auto type2=input->readULong(4); |
| 257 |
if (type2) f << "type2=" << printType(type2) << ","; |
| 258 |
if (hSz>20) { |
| 259 |
auto sSz=static_cast<int>(input->readULong(1)); |
| 260 |
if ((sSz%2)!=0 || 20+1+sSz>hSz) { |
| 261 |
f << "###sSz=" << sSz << ","; |
| 262 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: the string size seems bad\n")); |
| 263 |
} |
| 264 |
else { // Layout, Text, Picture, .. a componant name |
| 265 |
std::string name(""); |
| 266 |
for (int c=0; c<sSz/2; ++c) |
| 267 |
name+=char(input->readULong(2)); |
| 268 |
f << "name=" << name << ","; |
| 269 |
if (type2!=0x14a9842) { |
| 270 |
f << "###type2,"; |
| 271 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readTypeDefinitions: find odd type2 with a string size\n")); |
| 272 |
} |
| 273 |
} |
| 274 |
} |
| 275 |
if (input->tell()!=pos+4+hSz) |
| 276 |
ascFile.addDelimiter(input->tell(),'|'); |
| 277 |
ascFile.addPos(pos); |
| 278 |
ascFile.addNote(f.str().c_str()); |
| 279 |
|
| 280 |
input->seek(pos+4+hSz, librevenge::RVNG_SEEK_SET); |
| 281 |
for (int j=0; j<nData; ++j) { |
| 282 |
pos=input->tell(); |
| 283 |
f.str(""); |
| 284 |
f << "TypeDef-" << i << "[" << j << "]:"; |
| 285 |
f << "type=" << printType(input->readULong(4)) << ","; // a big number, ~type (but a multiple of 5) |
| 286 |
f << "type2=" << printType(input->readULong(4)) << std::dec << ","; // a big number |
| 287 |
for (int k=0; k<2; ++k) { |
| 288 |
val=static_cast<int>(input->readULong(1)); |
| 289 |
if (val) f << "fl" << k << "=" << std::hex << val << std::dec << ","; |
| 290 |
} |
| 291 |
val=static_cast<int>(input->readLong(2)); |
| 292 |
if (val) f << "f0=" << val << ","; |
| 293 |
ascFile.addPos(pos); |
| 294 |
ascFile.addNote(f.str().c_str()); |
| 295 |
input->seek(pos+12, librevenge::RVNG_SEEK_SET); |
| 296 |
} |
| 297 |
} |
| 298 |
if (!listPtrs.empty() && listPtrs.back()!=remain) { |
| 299 |
ascFile.addPos(debDataPos+listPtrs.back()); |
| 300 |
ascFile.addNote("TypeDef-end"); |
| 301 |
} |
| 302 |
input->setReadInverted(false); |
| 303 |
return true; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
bool RagTime5StructManager::readUnicodeString(MWAWInputStreamPtr input, long endPos, librevenge::RVNGString &string) |
| 308 |
{ |
| 309 |
string=""; |
| 310 |
long pos=input->tell(); |
| 311 |
if (pos==endPos) return true; |
| 312 |
long length=endPos-pos; |
| 313 |
if (length<0 || (length%2)==1) { |
| 314 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readUnicodeString: find unexpected data length\n")); |
| 315 |
return false; |
| 316 |
} |
| 317 |
length/=2; |
| 318 |
int lEndian=0, hEndian=0; // for checking if little/big endian is set correctly |
| 319 |
for (long i=0; i<length; ++i) { |
| 320 |
auto c=static_cast<uint32_t>(input->readULong(2)); |
| 321 |
if ((c&0xFF00)==0) ++hEndian; |
| 322 |
else if ((c&0xFF)==0) ++lEndian; |
| 323 |
if (c!=0) |
| 324 |
libmwaw::appendUnicode(c, string); |
| 325 |
} |
| 326 |
if (lEndian>hEndian) { |
| 327 |
static bool first=true; |
| 328 |
if (first) { |
| 329 |
first=false; |
| 330 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readUnicodeString: the endian reading seems bad...\n")); |
| 331 |
} |
| 332 |
} |
| 333 |
return true; |
| 334 |
} |
| 335 |
|
| 336 |
bool RagTime5StructManager::readDataIdList(MWAWInputStreamPtr input, int n, std::vector<int> &listIds) |
| 337 |
{ |
| 338 |
listIds.clear(); |
| 339 |
long pos=input->tell(); |
| 340 |
for (int i=0; i<n; ++i) { |
| 341 |
int val=static_cast<int>(MWAWInputStream::readULong(input->input().get(), 2, 0, false)); |
| 342 |
if (val==0) { |
| 343 |
listIds.push_back(0); |
| 344 |
input->seek(2, librevenge::RVNG_SEEK_CUR); |
| 345 |
continue; |
| 346 |
} |
| 347 |
if (val!=1) { |
| 348 |
// update the position |
| 349 |
input->seek(pos+4*n, librevenge::RVNG_SEEK_SET); |
| 350 |
return false; |
| 351 |
} |
| 352 |
listIds.push_back(static_cast<int>(MWAWInputStream::readULong(input->input().get(), 2, 0, false))); |
| 353 |
} |
| 354 |
return true; |
| 355 |
} |
| 356 |
|
| 357 |
bool RagTime5StructManager::readField(MWAWInputStreamPtr input, long endPos, libmwaw::DebugFile &ascFile, |
| 358 |
RagTime5StructManager::Field &field, long fSz) |
| 359 |
{ |
| 360 |
libmwaw::DebugStream f; |
| 361 |
long debPos=input->tell(); |
| 362 |
if ((fSz>0 && (fSz<4 || debPos+fSz>endPos)) || (fSz<=0 && debPos+5>endPos)) { |
| 363 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: the zone seems too short\n")); |
| 364 |
return false; |
| 365 |
} |
| 366 |
auto type=input->readULong(4); |
| 367 |
if ((type>>16)==0) { |
| 368 |
input->seek(debPos, librevenge::RVNG_SEEK_SET); |
| 369 |
return false; |
| 370 |
} |
| 371 |
field.m_fileType=type; |
| 372 |
bool complex=static_cast<int>(input->readULong(1))==0xc0; |
| 373 |
input->seek(-1, librevenge::RVNG_SEEK_CUR); |
| 374 |
if (fSz<=0) { |
| 375 |
if (!readCompressedLong(input, endPos, fSz) || fSz<=0 || input->tell()+fSz>endPos) { |
| 376 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read the data size\n")); |
| 377 |
input->seek(debPos, librevenge::RVNG_SEEK_SET); |
| 378 |
return false; |
| 379 |
} |
| 380 |
} |
| 381 |
else |
| 382 |
fSz-=4; |
| 383 |
long debDataPos=input->tell(); |
| 384 |
long endDataPos=debDataPos+fSz; |
| 385 |
switch (static_cast<unsigned long>(type)) { |
| 386 |
case 0x360c0: |
| 387 |
case 0x368c0: |
| 388 |
if (fSz!=1) { |
| 389 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for bool\n")); |
| 390 |
f << "###bool,"; |
| 391 |
break; |
| 392 |
} |
| 393 |
field.m_type=Field::T_Bool; |
| 394 |
|
| 395 |
field.m_name="bool"; |
| 396 |
field.m_longValue[0]=long(input->readLong(1)); |
| 397 |
return true; |
| 398 |
|
| 399 |
case 0x328c0: |
| 400 |
if (fSz!=1) { |
| 401 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for bInt\n")); |
| 402 |
f << "###bInt,"; |
| 403 |
break; |
| 404 |
} |
| 405 |
field.m_type=Field::T_Long; |
| 406 |
field.m_name="bInt"; |
| 407 |
field.m_longValue[0]=long(input->readLong(1)); |
| 408 |
return true; |
| 409 |
|
| 410 |
case 0x3b880: |
| 411 |
case 0x1479080: |
| 412 |
case 0x147b880: |
| 413 |
case 0x147c080: |
| 414 |
case 0x149d880: |
| 415 |
case 0x149e080: |
| 416 |
case 0x17d5880: |
| 417 |
if (fSz!=2) { |
| 418 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for int\n")); |
| 419 |
f << "###int,"; |
| 420 |
break; |
| 421 |
} |
| 422 |
field.m_type=Field::T_Long; |
| 423 |
field.m_name="int"; |
| 424 |
field.m_longValue[0]=long(input->readLong(2)); |
| 425 |
return true; |
| 426 |
case 0x34080: |
| 427 |
case 0xcf817: // bigger int dataId?: not in typedef |
| 428 |
if (fSz!=2) { |
| 429 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for uint\n")); |
| 430 |
f << "###uint,"; |
| 431 |
break; |
| 432 |
} |
| 433 |
field.m_type=Field::T_Long; |
| 434 |
field.m_name="uint"; |
| 435 |
field.m_longValue[0]=long(input->readULong(2)); |
| 436 |
return true; |
| 437 |
case 0xb6000: // color percent |
| 438 |
case 0x1493800: // checkme double(as int) |
| 439 |
case 0x1494800: // checkme double(as int) |
| 440 |
case 0x1495000: |
| 441 |
case 0x1495800: // checkme double(as int) |
| 442 |
if (fSz!=4) { |
| 443 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for double4\n")); |
| 444 |
f << "###float,"; |
| 445 |
break; |
| 446 |
} |
| 447 |
// checkme if val=0xFFFFFFFF, inf? |
| 448 |
field.m_type=Field::T_Double; |
| 449 |
field.m_name="double4"; |
| 450 |
field.m_doubleValue=double(input->readLong(4))/65536; |
| 451 |
return true; |
| 452 |
case 0x45840: { |
| 453 |
if (fSz!=8) { |
| 454 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for double\n")); |
| 455 |
f << "###double,"; |
| 456 |
break; |
| 457 |
} |
| 458 |
double res; |
| 459 |
bool isNan; |
| 460 |
if (!input->readDouble8(res, isNan)) { |
| 461 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read a double\n")); |
| 462 |
f << "###double"; |
| 463 |
break; |
| 464 |
} |
| 465 |
field.m_type=Field::T_Double; |
| 466 |
field.m_name="double"; |
| 467 |
field.m_doubleValue=res; |
| 468 |
return true; |
| 469 |
} |
| 470 |
case 0x14510b7: { |
| 471 |
std::vector<int> listIds; |
| 472 |
if (!readDataIdList(input, 1, listIds)) { |
| 473 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read the cluster id\n")); |
| 474 |
f << "###clustId,"; |
| 475 |
break; |
| 476 |
} |
| 477 |
field.m_name="colPatId"; |
| 478 |
field.m_type=Field::T_ZoneId; |
| 479 |
field.m_longValue[0]=listIds[0]; |
| 480 |
return true; |
| 481 |
} |
| 482 |
case 0x34800: |
| 483 |
case 0x8c000: // a dim |
| 484 |
case 0x234800: // checkme, find always with 0x0 |
| 485 |
case 0x147415a: // checkme, find always with 0x0 |
| 486 |
case 0x15e3017: // 2 long, not in typedef |
| 487 |
if (fSz!=4) { |
| 488 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for 2xint\n")); |
| 489 |
f << "###2xint,"; |
| 490 |
break; |
| 491 |
} |
| 492 |
field.m_type=Field::T_2Long; |
| 493 |
field.m_name="2xint"; |
| 494 |
field.m_longValue[0]=long(input->readLong(2)); |
| 495 |
field.m_longValue[1]=long(input->readLong(2)); |
| 496 |
return true; |
| 497 |
case 0x7d01a: |
| 498 |
case 0xc8042: { // unicode |
| 499 |
if (fSz<2) { |
| 500 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for unicode\n")); |
| 501 |
f << "###unicode"; |
| 502 |
break; |
| 503 |
} |
| 504 |
field.m_type=Field::T_Unicode; |
| 505 |
field.m_name="unicode"; |
| 506 |
auto val=static_cast<int>(input->readULong(2)); |
| 507 |
if ((val&0x70FF)==0) { |
| 508 |
if (val) f << "f1=" << ((val&0x7F00)>>8); |
| 509 |
for (long i=2; i<fSz; ++i) |
| 510 |
libmwaw::appendUnicode(static_cast<uint32_t>(input->readULong(1)), field.m_string); |
| 511 |
} |
| 512 |
else { |
| 513 |
input->seek(debDataPos, librevenge::RVNG_SEEK_SET); |
| 514 |
if (!readUnicodeString(input, endDataPos, field.m_string)) |
| 515 |
f << "###"; |
| 516 |
} |
| 517 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 518 |
field.m_extra=f.str(); |
| 519 |
return true; |
| 520 |
} |
| 521 |
case 0x1f6817: |
| 522 |
case 0x1f6827: |
| 523 |
case 0x1f7877: { // CHECKME: is this also valid for unicode ? |
| 524 |
if (fSz<2) { |
| 525 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for int+unicode\n")); |
| 526 |
f << "###int+unicode"; |
| 527 |
break; |
| 528 |
} |
| 529 |
field.m_type=Field::T_Unicode; |
| 530 |
field.m_name="int+unicode"; |
| 531 |
int val=int(input->readULong(2)); |
| 532 |
if ((val&0xff) || val==0xff00) { // ff00 means list of {length+str} for normal string |
| 533 |
f << "multistring,"; |
| 534 |
f << "val=" << std::hex << val << std::dec << ","; |
| 535 |
val=static_cast<int>(input->readULong(2)); |
| 536 |
} |
| 537 |
//std::cout << "ICI1:" << std::hex << val << std::dec << "\n"; |
| 538 |
if ((val&0x8000)==0) { |
| 539 |
if ((val>>8)>2) f << "f1=" << (val>>8); |
| 540 |
fSz=int(endDataPos-input->tell()); |
| 541 |
for (long i=0; i<fSz; ++i) { |
| 542 |
auto c=static_cast<uint32_t>(input->readULong(1)); |
| 543 |
if (c) |
| 544 |
libmwaw::appendUnicode(c, field.m_string); |
| 545 |
else |
| 546 |
field.m_string.append('#'); |
| 547 |
} |
| 548 |
} |
| 549 |
else if (!readUnicodeString(input, endDataPos, field.m_string)) { |
| 550 |
field.m_string="###"; |
| 551 |
} |
| 552 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 553 |
field.m_extra=f.str(); |
| 554 |
return true; |
| 555 |
} |
| 556 |
case 0x149a940: { |
| 557 |
if (fSz!=6) { |
| 558 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for interline\n")); |
| 559 |
f << "###interline"; |
| 560 |
break; |
| 561 |
} |
| 562 |
field.m_type=Field::T_LongDouble; |
| 563 |
field.m_name="interline"; |
| 564 |
field.m_longValue[0]=static_cast<int>(input->readLong(2)); |
| 565 |
field.m_doubleValue=double(input->readLong(4))/65536.; |
| 566 |
return true; |
| 567 |
} |
| 568 |
case 0x149c940: { // checkme |
| 569 |
if (fSz!=6) { |
| 570 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for floatxint\n")); |
| 571 |
f << "###floatxint"; |
| 572 |
break; |
| 573 |
} |
| 574 |
field.m_type=Field::T_LongDouble; |
| 575 |
field.m_name="floatxint"; |
| 576 |
field.m_doubleValue=double(input->readLong(4))/65536.; |
| 577 |
field.m_longValue[0]=static_cast<int>(input->readLong(2)); |
| 578 |
return true; |
| 579 |
} |
| 580 |
case 0x74040: { |
| 581 |
if (fSz!=8) { |
| 582 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for 2xfloat\n")); |
| 583 |
f << "###2xfloat"; |
| 584 |
break; |
| 585 |
} |
| 586 |
field.m_type=Field::T_DoubleList; |
| 587 |
field.m_name="2xfloat"; |
| 588 |
for (int i=0; i<2; ++i) |
| 589 |
field.m_doubleList.push_back(double(input->readLong(4))/65536); |
| 590 |
return true; |
| 591 |
} |
| 592 |
case 0x1474040: // maybe one tab |
| 593 |
case 0x81474040: { |
| 594 |
if ((fSz%8)!=0) { |
| 595 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for tab\n")); |
| 596 |
f << "###tab[list]"; |
| 597 |
break; |
| 598 |
} |
| 599 |
field.m_type=Field::T_TabList; |
| 600 |
field.m_name="tab"; |
| 601 |
auto N=int(fSz/8); |
| 602 |
for (int i=0; i<N; ++i) { |
| 603 |
TabStop tab; |
| 604 |
tab.m_position=float(input->readLong(4))/65536.f; |
| 605 |
tab.m_type=static_cast<int>(input->readLong(2)); |
| 606 |
tab.m_leaderChar=static_cast<uint16_t>(input->readULong(2)); |
| 607 |
field.m_tabList.push_back(tab); |
| 608 |
} |
| 609 |
return true; |
| 610 |
} |
| 611 |
case 0x74840: // dimension |
| 612 |
case 0x112040: // also some dimension ? ( often 0,0,0,1 but can be 0,-0.00564575,0,0.25 ) |
| 613 |
if (fSz!=16) { |
| 614 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for dim\n")); |
| 615 |
f << "###dim"; |
| 616 |
break; |
| 617 |
} |
| 618 |
field.m_type=Field::T_DoubleList; |
| 619 |
field.m_name="dim"; |
| 620 |
for (long i=0; i<4; ++i) |
| 621 |
field.m_doubleList.push_back(double(input->readLong(4))/65536.); |
| 622 |
field.m_extra=f.str(); |
| 623 |
return true; |
| 624 |
|
| 625 |
case 0x1476840: |
| 626 |
if (fSz!=10) { |
| 627 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for 3intxfloat\n")); |
| 628 |
f << "###3intxfloat"; |
| 629 |
break; |
| 630 |
} |
| 631 |
field.m_type=Field::T_Unstructured; |
| 632 |
field.m_name="3intxfloat"; |
| 633 |
field.m_entry.setBegin(input->tell()); |
| 634 |
field.m_entry.setEnd(endDataPos); |
| 635 |
for (long i=0; i<3; ++i) { // 1|3,1,1 |
| 636 |
auto val=static_cast<int>(input->readLong(2)); |
| 637 |
if (val) f << val << ":"; |
| 638 |
else f << "_:"; |
| 639 |
} |
| 640 |
f << double(input->readLong(4))/65536. << ","; |
| 641 |
field.m_extra=f.str(); |
| 642 |
return true; |
| 643 |
case 0x79040: { // checkme: unsure |
| 644 |
if (fSz!=14) { |
| 645 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for 0x79040\n")); |
| 646 |
f << "###unstr"; |
| 647 |
break; |
| 648 |
} |
| 649 |
field.m_type=Field::T_Unstructured; |
| 650 |
field.m_name="unstr"; |
| 651 |
field.m_entry.setBegin(input->tell()); |
| 652 |
field.m_entry.setEnd(endDataPos); |
| 653 |
for (long i=0; i<2; ++i) { // something like 49c4x6c2b |
| 654 |
f << std::hex << input->readULong(4) << std::dec; |
| 655 |
if (i==0) f << "x"; |
| 656 |
else f << ","; |
| 657 |
} |
| 658 |
for (int i=0; i<2; ++i) { // often 4000, 3fed |
| 659 |
f << std::hex << input->readULong(2) << std::dec; |
| 660 |
if (i==0) f << "x"; |
| 661 |
else f << ","; |
| 662 |
} |
| 663 |
auto val=static_cast<int>(input->readLong(2)); |
| 664 |
if (val!=0x100) f << val << ":"; |
| 665 |
field.m_extra=f.str(); |
| 666 |
return true; |
| 667 |
} |
| 668 |
case 0x84040: { |
| 669 |
if (fSz!=10) { |
| 670 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for rgba\n")); |
| 671 |
f << "###rgba"; |
| 672 |
break; |
| 673 |
} |
| 674 |
field.m_type=Field::T_Color; |
| 675 |
field.m_name="rgba"; |
| 676 |
field.m_longValue[0]=long(input->readLong(2)); // id or numUsed |
| 677 |
if (field.m_longValue[0]==50) { |
| 678 |
field.m_longValue[1]=long(input->readULong(2)); |
| 679 |
field.m_color=MWAWColor(255,255,255); |
| 680 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 681 |
return true; |
| 682 |
} |
| 683 |
unsigned char col[4]; |
| 684 |
for (auto &c : col) c=static_cast<unsigned char>(input->readULong(2)>>8); // rgba |
| 685 |
field.m_color=MWAWColor(col[0],col[1],col[2],col[3]); |
| 686 |
return true; |
| 687 |
} |
| 688 |
case 0x8d000: { |
| 689 |
if (fSz!=4) { |
| 690 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for rsrcName\n")); |
| 691 |
f << "###rsrcName"; |
| 692 |
break; |
| 693 |
} |
| 694 |
field.m_type=Field::T_Code; |
| 695 |
field.m_name="rsrcName"; |
| 696 |
auto cod=input->readULong(4); |
| 697 |
for (int i=0; i<4; ++i) field.m_string.append(char(cod>>(24-8*i))); |
| 698 |
return true; |
| 699 |
} |
| 700 |
case 0x31e040: |
| 701 |
// <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 702 |
if (fSz<30) { |
| 703 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for xml printer\n")); |
| 704 |
f << "###printInfoX"; |
| 705 |
break; |
| 706 |
} |
| 707 |
field.m_type=Field::T_String; |
| 708 |
field.m_name="printInfoX"; |
| 709 |
for (long i=0; i<fSz && i<30; ++i) |
| 710 |
field.m_string.append(char(input->readULong(1))); |
| 711 |
field.m_string.append("..."); |
| 712 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 713 |
return true; |
| 714 |
case 0x2fd040: { |
| 715 |
if (fSz<120) { |
| 716 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for printInfo\n")); |
| 717 |
f << "###printInfo"; |
| 718 |
break; |
| 719 |
} |
| 720 |
libmwaw::PrinterInfo info; |
| 721 |
if (!info.read(input)) { |
| 722 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read printInfo\n")); |
| 723 |
f << "###printInfo"; |
| 724 |
break; |
| 725 |
} |
| 726 |
field.m_type=Field::T_PrintInfo; |
| 727 |
field.m_name="printInfo"; |
| 728 |
f << info << ","; |
| 729 |
field.m_extra=f.str(); |
| 730 |
// then sometimes 4 string title, ... |
| 731 |
if (input->tell()!=endDataPos) |
| 732 |
ascFile.addDelimiter(input->tell(),'|'); |
| 733 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 734 |
return true; |
| 735 |
} |
| 736 |
case 0x333140: // AppleWriter pref, probably safe to ignore |
| 737 |
if (fSz!=908) { |
| 738 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for AppleWriter prefs\n")); |
| 739 |
f << "###appleWriterInfo"; |
| 740 |
break; |
| 741 |
} |
| 742 |
field.m_type=Field::T_Unstructured; |
| 743 |
field.m_name="appleWriterInfo"; |
| 744 |
field.m_entry.setBegin(input->tell()); |
| 745 |
field.m_entry.setEnd(endDataPos); |
| 746 |
// name in lohi ? |
| 747 |
for (int i=0; i<32; ++i) { |
| 748 |
auto c=static_cast<int>(input->readULong(1)); |
| 749 |
c+=static_cast<int>(input->readULong(1)<<8); |
| 750 |
if (c==0) break; |
| 751 |
f << char(c); |
| 752 |
} |
| 753 |
f << "..."; |
| 754 |
field.m_extra=f.str(); |
| 755 |
ascFile.addDelimiter(input->tell(),'|'); |
| 756 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 757 |
return true; |
| 758 |
case 0x148c01a: // 2 int + 8 bytes for pat ? |
| 759 |
if (fSz!=12) { |
| 760 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for pat\n")); |
| 761 |
f << "###pat"; |
| 762 |
break; |
| 763 |
} |
| 764 |
field.m_type=Field::T_Unstructured; |
| 765 |
field.m_name="pat"; |
| 766 |
field.m_entry.setBegin(input->tell()); |
| 767 |
field.m_entry.setEnd(endDataPos); |
| 768 |
field.m_extra="..."; |
| 769 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 770 |
return true; |
| 771 |
case 0x226140: |
| 772 |
if (fSz!=21) { |
| 773 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for font\n")); |
| 774 |
f << "###font"; |
| 775 |
break; |
| 776 |
} |
| 777 |
field.m_type=Field::T_Unstructured; |
| 778 |
field.m_name="font"; |
| 779 |
field.m_entry.setBegin(input->tell()); |
| 780 |
field.m_entry.setEnd(endDataPos); |
| 781 |
field.m_extra="..."; |
| 782 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 783 |
return true; |
| 784 |
case 0x226940: { // checkme |
| 785 |
if (fSz<262 || ((fSz-262)%6)!=0) { |
| 786 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for para\n")); |
| 787 |
f << "###para"; |
| 788 |
break; |
| 789 |
} |
| 790 |
field.m_type=Field::T_Unstructured; |
| 791 |
field.m_name="para"; |
| 792 |
field.m_entry.setBegin(input->tell()); |
| 793 |
field.m_entry.setEnd(endDataPos); |
| 794 |
field.m_extra="..."; |
| 795 |
ascFile.addPos(input->tell()+70); |
| 796 |
ascFile.addNote("TextStyle-para-B0:"); |
| 797 |
ascFile.addPos(input->tell()+166); |
| 798 |
ascFile.addNote("TextStyle-para-B1:"); |
| 799 |
if (fSz>262) { |
| 800 |
ascFile.addPos(input->tell()+262); |
| 801 |
ascFile.addNote("TextStyle-para-C:"); |
| 802 |
} |
| 803 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 804 |
return true; |
| 805 |
} |
| 806 |
case 0x71940: // checkme: locale data ? |
| 807 |
if (fSz!=108) { |
| 808 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for locale\n")); |
| 809 |
f << "###locale"; |
| 810 |
break; |
| 811 |
} |
| 812 |
field.m_type=Field::T_Unstructured; |
| 813 |
field.m_name="locale"; |
| 814 |
field.m_entry.setBegin(input->tell()); |
| 815 |
field.m_entry.setEnd(endDataPos); |
| 816 |
f << "fls=[" << std::hex; |
| 817 |
for (long i=0; i<8; ++i) { |
| 818 |
auto val=static_cast<int>(input->readLong(1)); |
| 819 |
if (val==1) f << "_,"; |
| 820 |
else f << val << ","; |
| 821 |
} |
| 822 |
f << "],"; |
| 823 |
f << "chars=["; |
| 824 |
for (long i=0; i<21; ++i) { |
| 825 |
auto val=static_cast<int>(input->readULong(2)); |
| 826 |
if (!val) f << "_,"; |
| 827 |
else if (val<128) f << char(val) << ","; |
| 828 |
else f << std::hex << val << std::dec << ","; |
| 829 |
} |
| 830 |
f << "],"; |
| 831 |
ascFile.addDelimiter(input->tell(),'|'); |
| 832 |
field.m_extra=f.str(); |
| 833 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 834 |
return true; |
| 835 |
case 0x32040: |
| 836 |
if (fSz<160) { |
| 837 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: the data fSz for docInfo data seems too short\n")); |
| 838 |
f << "###docInfo"; |
| 839 |
break; |
| 840 |
} |
| 841 |
else { |
| 842 |
field.m_type=Field::T_Unstructured; |
| 843 |
field.m_name="docInfo"; |
| 844 |
field.m_entry.setBegin(input->tell()); |
| 845 |
field.m_entry.setEnd(endDataPos); |
| 846 |
field.m_extra="..."; |
| 847 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 848 |
return true; |
| 849 |
} |
| 850 |
case 0x227140: { // border checkme |
| 851 |
if ((fSz%6)!=2) { |
| 852 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for list of border\n")); |
| 853 |
f << "###border"; |
| 854 |
break; |
| 855 |
} |
| 856 |
auto val=static_cast<int>(input->readULong(2)); // c000 or c1000 |
| 857 |
if (val!=0xc000) f << "f0=" << std::hex << val << std::dec << ","; |
| 858 |
field.m_type=Field::T_LongList; |
| 859 |
field.m_name="border"; |
| 860 |
field.m_numLongByData=3; |
| 861 |
fSz/=6; |
| 862 |
for (long i=0; i<fSz; ++i) { |
| 863 |
field.m_longList.push_back(long(input->readLong(2))); // row? |
| 864 |
field.m_longList.push_back(long(input->readLong(2))); // col? |
| 865 |
field.m_longList.push_back(long(input->readULong(2))); // flags? |
| 866 |
} |
| 867 |
field.m_extra=f.str(); |
| 868 |
return true; |
| 869 |
} |
| 870 |
case 0x64040: { // chart pref |
| 871 |
if (fSz<3) { |
| 872 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for chart pref\n")); |
| 873 |
f << "###chart pref"; |
| 874 |
break; |
| 875 |
} |
| 876 |
field.m_type=Field::T_FieldList; |
| 877 |
field.m_entry.setBegin(input->tell()); |
| 878 |
field.m_entry.setEnd(endDataPos); |
| 879 |
for (int i=0; i<3; ++i) { // f2=8|9 |
| 880 |
auto val=static_cast<int>(input->readLong(1)); |
| 881 |
if (val) f << "f" << i << "=" << val << ","; |
| 882 |
} |
| 883 |
bool ok=true; |
| 884 |
while (input->tell()<endDataPos) { |
| 885 |
Field child; |
| 886 |
long pos=input->tell(); |
| 887 |
if (!readField(input, endDataPos, ascFile, child)) { |
| 888 |
ok=false; |
| 889 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 890 |
break; |
| 891 |
} |
| 892 |
field.m_fieldList.push_back(child); |
| 893 |
} |
| 894 |
if (!ok || input->tell() != endDataPos) { |
| 895 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read some charr pref list data\n")); |
| 896 |
f.str(""); |
| 897 |
f << "###pos=" << input->tell()-debPos; |
| 898 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 899 |
} |
| 900 |
field.m_extra=f.str(); |
| 901 |
return true; |
| 902 |
} |
| 903 |
case 0xce017: { // unstructured: not in typedef |
| 904 |
if (fSz<5) { |
| 905 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for unstructured\n")); |
| 906 |
f << "###unstr"; |
| 907 |
break; |
| 908 |
} |
| 909 |
field.m_type=Field::T_Unstructured; |
| 910 |
field.m_name="unstruct"; |
| 911 |
field.m_longValue[0]=input->readLong(4); |
| 912 |
field.m_entry.setBegin(input->tell()); |
| 913 |
field.m_entry.setEnd(endDataPos); |
| 914 |
f << "data=" << std::hex; |
| 915 |
for (long i=0; i<fSz-4; ++i) |
| 916 |
f << std::setfill('0') << std::setw(2) << static_cast<int>(input->readULong(1)); |
| 917 |
f << std::dec << ","; |
| 918 |
field.m_extra=f.str(); |
| 919 |
return true; |
| 920 |
} |
| 921 |
case 0xce842: // list of long : header fl=2000, f2=7 |
| 922 |
case 0x170c8e5: { // maybe list of color: f0=418,fl1=40,fl2=8 |
| 923 |
if ((fSz%4)!=0) { |
| 924 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for list of long\n")); |
| 925 |
f << "###"; |
| 926 |
break; |
| 927 |
} |
| 928 |
fSz/=4; |
| 929 |
field.m_type=Field::T_LongList; |
| 930 |
field.m_name="longList"; |
| 931 |
for (long i=0; i<fSz; ++i) |
| 932 |
field.m_longList.push_back(long(input->readLong(4))); |
| 933 |
return true; |
| 934 |
} |
| 935 |
case 0x3c057: |
| 936 |
case 0x80045080: // child of 14741fa |
| 937 |
case 0xcf042: { // list of small int: header fl=2000 with f2=9 |
| 938 |
if ((fSz%2)!=0) { |
| 939 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for list of long\n")); |
| 940 |
f << "###"; |
| 941 |
break; |
| 942 |
} |
| 943 |
fSz/=2; |
| 944 |
field.m_type=Field::T_LongList; |
| 945 |
field.m_name="intList"; |
| 946 |
for (long i=0; i<fSz; ++i) |
| 947 |
field.m_longList.push_back(long(input->readLong(2))); |
| 948 |
return true; |
| 949 |
} |
| 950 |
case 0x154f017: // list of bytes |
| 951 |
field.m_type=Field::T_LongList; |
| 952 |
field.m_name="byteList"; |
| 953 |
for (long i=0; i<fSz; ++i) |
| 954 |
field.m_longList.push_back(long(input->readLong(1))); |
| 955 |
return true; |
| 956 |
case 0x35000: // checkme find also a string code here... |
| 957 |
case 0x35800: // unsure, ie small int |
| 958 |
case 0x3e800: // unsure, find with 000af040, 00049840 or 0004c040 |
| 959 |
case 0xa4000: |
| 960 |
if (fSz!=4) { |
| 961 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for list of uint32_t\n")); |
| 962 |
f << "###uint32"; |
| 963 |
break; |
| 964 |
} |
| 965 |
field.m_type=Field::T_Long; |
| 966 |
field.m_longValue[0]=long(input->readULong(4)); |
| 967 |
return true; |
| 968 |
case 0xa4840: |
| 969 |
if (fSz!=8) { |
| 970 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for list of 2xuint32_t\n")); |
| 971 |
f << "###2xuint32"; |
| 972 |
break; |
| 973 |
} |
| 974 |
field.m_type=Field::T_2Long; |
| 975 |
field.m_name="2xuint32"; |
| 976 |
for (long &i : field.m_longValue) |
| 977 |
i=long(input->readULong(4)); |
| 978 |
return true; |
| 979 |
|
| 980 |
case 0x33000: // maybe one 2xint |
| 981 |
case 0x1671817: |
| 982 |
case 0x16b491a: // in chart, |
| 983 |
case 0x16b492a: // in chart, dim[4byte], id, 0 |
| 984 |
case 0x16b5aea: // chart preference, always 0,0,id,0 |
| 985 |
case 0x80033000: |
| 986 |
if ((fSz%4)!=0) { |
| 987 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for list of 2xint\n")); |
| 988 |
f << "###"; |
| 989 |
break; |
| 990 |
} |
| 991 |
field.m_type=Field::T_LongList; |
| 992 |
field.m_name="2intList"; |
| 993 |
field.m_numLongByData=2; |
| 994 |
fSz/=2; |
| 995 |
for (long i=0; i<fSz; ++i) |
| 996 |
field.m_longList.push_back(long(input->readLong(2))); |
| 997 |
return true; |
| 998 |
case 0x81452040: { |
| 999 |
if (fSz!=8) { |
| 1000 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for id+long\n")); |
| 1001 |
f << "###clustIdxlong"; |
| 1002 |
break; |
| 1003 |
} |
| 1004 |
field.m_type=Field::T_ZoneId; |
| 1005 |
field.m_name="clustIdxlong"; |
| 1006 |
field.m_entry.setBegin(input->tell()); |
| 1007 |
field.m_entry.setEnd(endDataPos); |
| 1008 |
std::vector<int> listIds; |
| 1009 |
if (!readDataIdList(input, 1, listIds)) { |
| 1010 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read the cluster id for id+long\n")); |
| 1011 |
f << "###clustId,"; |
| 1012 |
break; |
| 1013 |
} |
| 1014 |
field.m_longValue[0]=listIds[0]; |
| 1015 |
unsigned long val= input->readULong(4); // always 90000001 |
| 1016 |
if (val!=0x90000001) f << std::hex << val << std::dec << ","; |
| 1017 |
field.m_extra=f.str(); |
| 1018 |
return true; |
| 1019 |
} |
| 1020 |
case 0xa7017: // unicode |
| 1021 |
case 0xa7027: |
| 1022 |
case 0xa7037: |
| 1023 |
case 0xa7047: |
| 1024 |
case 0xa7057: |
| 1025 |
case 0xa7067: |
| 1026 |
case 0x146905a: // unicode |
| 1027 |
|
| 1028 |
case 0x7a047: // font definition |
| 1029 |
case 0x7a057: // ?? definition |
| 1030 |
case 0x7a067: // ?? definition |
| 1031 |
|
| 1032 |
case 0x146005a: // code |
| 1033 |
case 0x146007a: |
| 1034 |
case 0x14600aa: |
| 1035 |
case 0x147403a: |
| 1036 |
case 0x14740ba: |
| 1037 |
case 0x147501a: |
| 1038 |
case 0x148981a: |
| 1039 |
|
| 1040 |
case 0x145e0ba: // bool |
| 1041 |
case 0x147406a: |
| 1042 |
case 0x147550a: |
| 1043 |
case 0x17d486a: |
| 1044 |
|
| 1045 |
case 0x147512a: // small int |
| 1046 |
|
| 1047 |
case 0xa7077: // with type=3b880 |
| 1048 |
case 0x145e01a: |
| 1049 |
case 0x146904a: // int with type=0x149d880 |
| 1050 |
case 0x146907a: // withe type = 149d880 |
| 1051 |
case 0x146908a: // with type=0x3b880 |
| 1052 |
case 0x1469840: // with type=147b88 |
| 1053 |
case 0x146e02a: |
| 1054 |
case 0x146e03a: |
| 1055 |
case 0x146e04a: |
| 1056 |
case 0x146e06a: |
| 1057 |
case 0x146e08a: |
| 1058 |
case 0x145e11a: // with type=0x17d5880 |
| 1059 |
case 0x145e12a: // with type=017d5880 |
| 1060 |
case 0x147407a: |
| 1061 |
case 0x147408a: |
| 1062 |
case 0x1474042: |
| 1063 |
case 0x147416a: |
| 1064 |
case 0x14741ea: |
| 1065 |
case 0x147420a: // with type=3b880 |
| 1066 |
case 0x14754aa: // with type=328c0 |
| 1067 |
case 0x147551a: // with type=1479080 |
| 1068 |
case 0x147e81a: // with type=3b880 |
| 1069 |
case 0x17d481a: // int |
| 1070 |
|
| 1071 |
case 0x7d04a: |
| 1072 |
case 0x147405a: |
| 1073 |
case 0x14741ca: // 2 long |
| 1074 |
case 0x145e02a: // with type=b600000 |
| 1075 |
case 0x14741ba: // with type=b600000 |
| 1076 |
case 0x145e0ea: |
| 1077 |
case 0x146008a: |
| 1078 |
case 0x14752da: // with type=1495000 |
| 1079 |
case 0x14740ea: // with type=b600000 |
| 1080 |
case 0x147536a: // with type=1495000 |
| 1081 |
case 0x147538a: // with type=1495000 |
| 1082 |
case 0x146902a: // double |
| 1083 |
case 0x146903a: // double |
| 1084 |
case 0x17d484a: // with type=34800 |
| 1085 |
case 0x147404a: // with type=149c94 |
| 1086 |
case 0x7d02a: // rgba color? |
| 1087 |
case 0x145e05a: |
| 1088 |
|
| 1089 |
case 0x14750ea: // keep with next para |
| 1090 |
case 0x147530a: // break behavior |
| 1091 |
case 0x14753aa: // min word spacing |
| 1092 |
case 0x14753ca: // optimal word spacing |
| 1093 |
case 0x14753ea: // max word spacing |
| 1094 |
case 0x147546a: // number line in widows |
| 1095 |
case 0x147548a: // number line in orphan |
| 1096 |
case 0x147552a: // do not use spacing for single word |
| 1097 |
case 0x147516a: // align paragraph on grid |
| 1098 |
case 0x147418a: // small caps scaling x |
| 1099 |
case 0x14741aa: // small caps scaling y |
| 1100 |
|
| 1101 |
case 0x14c2042: /* function container*/ |
| 1102 |
case 0x1559842: |
| 1103 |
case 0x1663842: |
| 1104 |
case 0x1be5042: |
| 1105 |
case 0x1d50842: |
| 1106 |
case 0x1e16842: |
| 1107 |
case 0x23aa042: |
| 1108 |
case 0x23af042: |
| 1109 |
case 0x23b4042: |
| 1110 |
|
| 1111 |
case 0x7a09a: // with a4000 or a4840 |
| 1112 |
case 0x7a05a: // unknown |
| 1113 |
case 0x7a0aa: |
| 1114 |
case 0x14600ca: // with type=80033000 |
| 1115 |
case 0x146e05a: // with type=33000 |
| 1116 |
case 0x147402a: |
| 1117 |
case 0x14741fa: // unsure find with type=80045080 |
| 1118 |
case 0x147502a: // with type=149a940 |
| 1119 |
case 0x147505a: // with type=1493800 |
| 1120 |
case 0x147506a: // with type=1493800 |
| 1121 |
case 0x147507a: // with type=1493800 |
| 1122 |
case 0x14750aa: // with type=149a940 |
| 1123 |
case 0x14750ba: // with type=149a940 |
| 1124 |
case 0x14750ca: // with type=1474040 |
| 1125 |
case 0x147510a: // with type=81474040 or 1474040 |
| 1126 |
case 0x147513a: // with type=1493800 |
| 1127 |
case 0x14754ba: // with type=1476840 |
| 1128 |
case 0x148983a: // with type=0074040 |
| 1129 |
case 0x148985a: // with type=1495800 |
| 1130 |
|
| 1131 |
case 0x16c1825: // chart pref with type=0042040 CHECKME |
| 1132 |
case 0x16d5840: // chart main pref |
| 1133 |
|
| 1134 |
// docinfo zone |
| 1135 |
case 0x1f7817: |
| 1136 |
case 0x1f7827: |
| 1137 |
case 0x1f7837: |
| 1138 |
case 0x1f7847: |
| 1139 |
case 0x1f7857: |
| 1140 |
case 0x1f7887: |
| 1141 |
|
| 1142 |
// gobj property |
| 1143 |
case 0x6615a: |
| 1144 |
case 0x6616a: |
| 1145 |
case 0x6617a: |
| 1146 |
case 0x6619a: |
| 1147 |
case 0xfd827: |
| 1148 |
case 0x10581a: |
| 1149 |
case 0x111817: |
| 1150 |
case 0x111827: |
| 1151 |
case 0x1467837: |
| 1152 |
case 0x146789a: |
| 1153 |
case 0x14678aa: { |
| 1154 |
if (fSz<4) { |
| 1155 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected list field size\n")); |
| 1156 |
f << "###list,"; |
| 1157 |
break; |
| 1158 |
} |
| 1159 |
|
| 1160 |
long pos=input->tell(); |
| 1161 |
Field child; |
| 1162 |
if (!readField(input, endDataPos, ascFile, child, fSz)) { |
| 1163 |
f << "###pos=" << pos-debPos; |
| 1164 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1165 |
break; |
| 1166 |
} |
| 1167 |
field.m_name="container"; |
| 1168 |
|
| 1169 |
field.m_type=Field::T_FieldList; |
| 1170 |
field.m_fieldList.push_back(child); |
| 1171 |
if (input->tell() != endDataPos) { |
| 1172 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read some field list data\n")); |
| 1173 |
f.str(""); |
| 1174 |
f << "###pos=" << pos-debPos; |
| 1175 |
field.m_extra+=f.str(); |
| 1176 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 1177 |
} |
| 1178 |
return true; |
| 1179 |
} |
| 1180 |
|
| 1181 |
// condition, function, ... |
| 1182 |
case 0xe2c59: |
| 1183 |
case 0x1a473a: |
| 1184 |
case 0x1c58b1: |
| 1185 |
case 0x1d5ab5: |
| 1186 |
case 0x1dad60: |
| 1187 |
case 0x1e1c3b: |
| 1188 |
case 0x329eef: |
| 1189 |
case 0x6604ee: |
| 1190 |
case 0xcfdfc0: |
| 1191 |
case 0x1466794: |
| 1192 |
case 0x1468721: |
| 1193 |
case 0x1919327: |
| 1194 |
case 0x28b427c: |
| 1195 |
case 0x2a72e5f: |
| 1196 |
case 0x3217ef3: { |
| 1197 |
if (fSz!=12) { |
| 1198 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for condition\n")); |
| 1199 |
f << "###condition"; |
| 1200 |
break; |
| 1201 |
} |
| 1202 |
field.m_type=Field::T_CondColor; |
| 1203 |
field.m_name="condition"; |
| 1204 |
field.m_longValue[0]=long(input->readLong(2)); // numUsed ? |
| 1205 |
field.m_longValue[1]=long(input->readLong(2)); // formula id ? |
| 1206 |
unsigned char col[4]; |
| 1207 |
for (auto &c : col) c=static_cast<unsigned char>(input->readULong(2)>>8); // rgba |
| 1208 |
field.m_color=MWAWColor(col[0],col[1],col[2],col[3]); |
| 1209 |
return true; |
| 1210 |
} |
| 1211 |
|
| 1212 |
case 0x154a840: { |
| 1213 |
if (fSz<6) { |
| 1214 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected field size for functions def list\n")); |
| 1215 |
f << "###func[def],"; |
| 1216 |
break; |
| 1217 |
} |
| 1218 |
auto val=static_cast<int>(input->readLong(1)); // always 0? |
| 1219 |
if (val) f << "f1=" << val << ","; |
| 1220 |
auto N=static_cast<int>(input->readULong(1)); |
| 1221 |
if (6+N!=fSz) { |
| 1222 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected field N for functions def list\n")); |
| 1223 |
f << "###func[def],N=" << N << ","; |
| 1224 |
break; |
| 1225 |
} |
| 1226 |
for (int i=0; i<3; ++i) { // 0,-1|0|1,0 |
| 1227 |
val=static_cast<int>(input->readLong(1)); |
| 1228 |
if (!val) continue; |
| 1229 |
f << "f" << i+2 << "=" << val << ","; |
| 1230 |
} |
| 1231 |
val=static_cast<int>(input->readULong(1)); //0|40|c0 |
| 1232 |
if (val) f << "f5=" << std::hex << val << std::dec << ","; |
| 1233 |
// list of [0|1|20]* |
| 1234 |
field.m_type=Field::T_LongList; |
| 1235 |
field.m_name="func[def]"; |
| 1236 |
for (int i=0; i<N; ++i) |
| 1237 |
field.m_longList.push_back(static_cast<int>(input->readULong(1))); |
| 1238 |
field.m_extra=f.str(); |
| 1239 |
return true; |
| 1240 |
} |
| 1241 |
case 0x42040: { |
| 1242 |
if (fSz<10) { |
| 1243 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected field size for day/month list\n")); |
| 1244 |
f << "###list[day/month],"; |
| 1245 |
break; |
| 1246 |
} |
| 1247 |
int val; |
| 1248 |
for (int i=0; i<2; ++i) { // always 0? |
| 1249 |
val=static_cast<int>(input->readULong(2)); |
| 1250 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1251 |
} |
| 1252 |
auto N=static_cast<int>(input->readULong(2)); |
| 1253 |
val=static_cast<int>(input->readULong(2)); // always 20 ? |
| 1254 |
if (val!=20) f << "f3=" << val << ","; |
| 1255 |
val=static_cast<int>(input->readULong(2)); // always 0 ? |
| 1256 |
if (val) f << "f4=" << val << ","; |
| 1257 |
field.m_type=Field::T_FieldList; |
| 1258 |
field.m_name="container[list]"; // can be day/month, ... |
| 1259 |
bool ok=true; |
| 1260 |
for (int i=0; i<N; ++i) { |
| 1261 |
Field child; |
| 1262 |
long pos=input->tell(); |
| 1263 |
if (!readField(input, endDataPos, ascFile, child)) { |
| 1264 |
ok=false; |
| 1265 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1266 |
break; |
| 1267 |
} |
| 1268 |
field.m_fieldList.push_back(child); |
| 1269 |
} |
| 1270 |
if (!ok || input->tell() != endDataPos) { |
| 1271 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read some container list data\n")); |
| 1272 |
f.str(""); |
| 1273 |
f << "###pos=" << input->tell()-debPos; |
| 1274 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 1275 |
} |
| 1276 |
field.m_extra+=f.str(); |
| 1277 |
return true; |
| 1278 |
} |
| 1279 |
case 0xd7842: { // list of ? : header fl=0|4000, f2=3 |
| 1280 |
if ((fSz%6)!=0) { |
| 1281 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected data fSz for 0xd7842\n")); |
| 1282 |
f << "###"; |
| 1283 |
break; |
| 1284 |
} |
| 1285 |
fSz/=2; |
| 1286 |
field.m_type=Field::T_LongList; |
| 1287 |
field.m_name="3unknList"; |
| 1288 |
field.m_numLongByData=3; |
| 1289 |
for (long i=0; i<fSz; ++i) |
| 1290 |
field.m_longList.push_back(long(input->readLong(2))); |
| 1291 |
return true; |
| 1292 |
} |
| 1293 |
default: { |
| 1294 |
auto const &functIds=m_document.getFormulaParser()->getFunctionsId(); |
| 1295 |
if (functIds.find(static_cast<unsigned long>(type))!=functIds.end()) { |
| 1296 |
if (fSz<14) { |
| 1297 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected field size for functions name list\n")); |
| 1298 |
f << "###func[name],"; |
| 1299 |
break; |
| 1300 |
} |
| 1301 |
for (int i=0; i<3; ++i) { // f1=0|-1, f2=small number, other 0 |
| 1302 |
auto val=static_cast<int>(input->readLong(2)); |
| 1303 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1304 |
} |
| 1305 |
field.m_type=Field::T_FieldList; |
| 1306 |
field.m_name="func[name]"; |
| 1307 |
bool ok=true; |
| 1308 |
for (int i=0; i<2; ++i) { |
| 1309 |
Field child; |
| 1310 |
long pos=input->tell(); |
| 1311 |
if (!readField(input, endDataPos, ascFile, child)) { |
| 1312 |
ok=false; |
| 1313 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1314 |
break; |
| 1315 |
} |
| 1316 |
field.m_fieldList.push_back(child); |
| 1317 |
} |
| 1318 |
if (!ok || input->tell() != endDataPos) { |
| 1319 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read some 2fields list data\n")); |
| 1320 |
f.str(""); |
| 1321 |
f << "###pos=" << input->tell()-debPos; |
| 1322 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 1323 |
} |
| 1324 |
field.m_extra+=f.str(); |
| 1325 |
return true; |
| 1326 |
} |
| 1327 |
break; |
| 1328 |
} |
| 1329 |
} |
| 1330 |
|
| 1331 |
input->seek(debDataPos, librevenge::RVNG_SEEK_SET); |
| 1332 |
if (!complex) { |
| 1333 |
static bool first=true; |
| 1334 |
if (first) { |
| 1335 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: find some unexpected data type=%lx, ...\n", static_cast<unsigned long>(type))); |
| 1336 |
first=false; |
| 1337 |
} |
| 1338 |
field.m_name="#unknType"; |
| 1339 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1340 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 1341 |
return true; |
| 1342 |
} |
| 1343 |
switch (type) { |
| 1344 |
case 0x14b5815: // increasing list: with fl1=3, fl2=80, f1=29 |
| 1345 |
case 0x16be055: // fl1=f, fl2=80, f1=30 |
| 1346 |
case 0x16be065: // fl1=f, fl2=80, f1=30 |
| 1347 |
case 0x146e815: // maybe a list of dim: fl1=28-2a, fl2=80, f1=34 |
| 1348 |
case 0x1473815: // maybe a list of dim, fl2=80,f1=32 |
| 1349 |
case 0x14e6825: // maybe a list of coldim |
| 1350 |
case 0x14eb015: // maybe a list of rowdim |
| 1351 |
case 0x14f1825: |
| 1352 |
case 0x15f4815: // maybe related to list |
| 1353 |
case 0x160f815: |
| 1354 |
case 0x1671845: |
| 1355 |
case 0x17db015: // in group cluster |
| 1356 |
field.m_name="longList"; |
| 1357 |
break; |
| 1358 |
case 0x1451025: |
| 1359 |
case 0x146c015: // with ce017 |
| 1360 |
case 0x14e6875: |
| 1361 |
case 0x15f4015: // with ce017 |
| 1362 |
case 0x15f6815: |
| 1363 |
case 0x15f9015: // sometimes a list of 15f6815 |
| 1364 |
field.m_name="unstructList"; |
| 1365 |
break; |
| 1366 |
case 0x15e0825: |
| 1367 |
field.m_name="3unknList"; |
| 1368 |
break; |
| 1369 |
case 0x14b4815: // with type=ce842 |
| 1370 |
field.m_name="unknLayout"; |
| 1371 |
break; |
| 1372 |
case 0x1715815: // with type=ce842 |
| 1373 |
field.m_name="unknLstPict"; |
| 1374 |
break; |
| 1375 |
default: |
| 1376 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: unexpected list type=%lx\n", static_cast<unsigned long>(type))); |
| 1377 |
field.m_name="#unknList"; |
| 1378 |
break; |
| 1379 |
} |
| 1380 |
field.m_type=Field::T_FieldList; |
| 1381 |
while (input->tell()<endDataPos) { |
| 1382 |
long pos=input->tell(); |
| 1383 |
Field child; |
| 1384 |
if (!readField(input, endDataPos, ascFile, child)) { |
| 1385 |
f << "###pos=" << pos-debPos; |
| 1386 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1387 |
break; |
| 1388 |
} |
| 1389 |
field.m_fieldList.push_back(child); |
| 1390 |
} |
| 1391 |
if (input->tell()+4<endDataPos) { |
| 1392 |
MWAW_DEBUG_MSG(("RagTime5StructManager::readField: can not read some data\n")); |
| 1393 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1394 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 1395 |
return true; |
| 1396 |
} |
| 1397 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 1398 |
field.m_extra=f.str(); |
| 1399 |
return true; |
| 1400 |
} |
| 1401 |
|
| 1402 |
//////////////////////////////////////////////////////////// |
| 1403 |
// field function |
| 1404 |
//////////////////////////////////////////////////////////// |
| 1405 |
std::ostream &operator<<(std::ostream &o, RagTime5StructManager::Field const &field) |
| 1406 |
{ |
| 1407 |
if (!field.m_name.empty()) |
| 1408 |
o << field.m_name << ":" << RagTime5StructManager::printType(field.m_fileType); |
| 1409 |
else |
| 1410 |
o << "T:" << RagTime5StructManager::printType(field.m_fileType); |
| 1411 |
switch (field.m_type) { |
| 1412 |
case RagTime5StructManager::Field::T_Double: |
| 1413 |
o << "=" << field.m_doubleValue << ","; |
| 1414 |
break; |
| 1415 |
case RagTime5StructManager::Field::T_Bool: |
| 1416 |
if (field.m_longValue[0]==1) |
| 1417 |
o << ","; |
| 1418 |
else if (field.m_longValue[0]==0) |
| 1419 |
o << "=no,"; |
| 1420 |
else |
| 1421 |
o << field.m_longValue[0] << ","; |
| 1422 |
break; |
| 1423 |
case RagTime5StructManager::Field::T_Long: |
| 1424 |
if (field.m_longValue[0]>1000) |
| 1425 |
o << "=0x" << std::hex << field.m_longValue[0] << std::dec << ","; |
| 1426 |
else |
| 1427 |
o << "=" << field.m_longValue[0] << ","; |
| 1428 |
break; |
| 1429 |
case RagTime5StructManager::Field::T_2Long: |
| 1430 |
o << "=" << field.m_longValue[0] << ":" << field.m_longValue[1] << ","; |
| 1431 |
break; |
| 1432 |
case RagTime5StructManager::Field::T_LongDouble: |
| 1433 |
o << "=" << field.m_doubleValue << ":" << field.m_longValue[0] << ","; |
| 1434 |
break; |
| 1435 |
case RagTime5StructManager::Field::T_Color: |
| 1436 |
o << "=" << field.m_color; |
| 1437 |
if (field.m_longValue[0]) |
| 1438 |
o << "[" << field.m_longValue[0] << "]"; |
| 1439 |
o << ","; |
| 1440 |
return o; |
| 1441 |
case RagTime5StructManager::Field::T_CondColor: |
| 1442 |
o << "=" << field.m_color << "[" << field.m_longValue[0] << "," << field.m_longValue[1] << "],"; |
| 1443 |
return o; |
| 1444 |
case RagTime5StructManager::Field::T_String: |
| 1445 |
case RagTime5StructManager::Field::T_Code: |
| 1446 |
o << "=" << field.m_string.cstr() << ","; |
| 1447 |
return o; |
| 1448 |
case RagTime5StructManager::Field::T_ZoneId: |
| 1449 |
if (field.m_longValue[0]) |
| 1450 |
o << "=data" << field.m_longValue[0] << "A,"; |
| 1451 |
return o; |
| 1452 |
case RagTime5StructManager::Field::T_Unicode: |
| 1453 |
o << "=\"" << field.m_string.cstr() << "\","; |
| 1454 |
return o; |
| 1455 |
case RagTime5StructManager::Field::T_PrintInfo: |
| 1456 |
case RagTime5StructManager::Field::T_Unstructured: |
| 1457 |
o << "=" << field.m_extra << ","; |
| 1458 |
return o; |
| 1459 |
case RagTime5StructManager::Field::T_FieldList: |
| 1460 |
if (!field.m_fieldList.empty()) { |
| 1461 |
o << "=["; |
| 1462 |
for (auto const &val : field.m_fieldList) |
| 1463 |
o << "[" << val << "],"; |
| 1464 |
o << "]"; |
| 1465 |
} |
| 1466 |
o << ","; |
| 1467 |
break; |
| 1468 |
case RagTime5StructManager::Field::T_DoubleList: |
| 1469 |
if (!field.m_doubleList.empty()) { |
| 1470 |
o << "=["; |
| 1471 |
for (auto const &val : field.m_doubleList) |
| 1472 |
o << val << ","; |
| 1473 |
o << "],"; |
| 1474 |
} |
| 1475 |
break; |
| 1476 |
case RagTime5StructManager::Field::T_LongList: |
| 1477 |
if (!field.m_longList.empty() && field.m_numLongByData>0) { |
| 1478 |
o << "=["; |
| 1479 |
size_t pos=0; |
| 1480 |
while (pos+size_t(field.m_numLongByData-1)<field.m_longList.size()) { |
| 1481 |
for (int i=0; i<field.m_numLongByData; ++i) { |
| 1482 |
long val=field.m_longList[pos++]; |
| 1483 |
if (!val) |
| 1484 |
o << "_"; |
| 1485 |
else if (val>-1000 && val <1000) |
| 1486 |
o << val; |
| 1487 |
else if (val==long(0x80000000)) |
| 1488 |
o << "inf"; |
| 1489 |
// find sometime 0x3e7f0001 |
| 1490 |
else |
| 1491 |
o << "0x" << std::hex << val << std::dec; |
| 1492 |
o << ((i+1==field.m_numLongByData) ? "," : ":"); |
| 1493 |
} |
| 1494 |
} |
| 1495 |
o << "]"; |
| 1496 |
} |
| 1497 |
o << ","; |
| 1498 |
break; |
| 1499 |
case RagTime5StructManager::Field::T_TabList: |
| 1500 |
if (!field.m_tabList.empty()) { |
| 1501 |
o << "=["; |
| 1502 |
for (auto const &tab : field.m_tabList) |
| 1503 |
o << tab << ","; |
| 1504 |
o << "],"; |
| 1505 |
} |
| 1506 |
break; |
| 1507 |
case RagTime5StructManager::Field::T_Unknown: |
| 1508 |
#if !defined(__clang__) |
| 1509 |
default: |
| 1510 |
#endif |
| 1511 |
o << "[###unkn],"; |
| 1512 |
break; |
| 1513 |
} |
| 1514 |
o << field.m_extra; |
| 1515 |
return o; |
| 1516 |
} |
| 1517 |
|
| 1518 |
//////////////////////////////////////////////////////////// |
| 1519 |
// parser function |
| 1520 |
//////////////////////////////////////////////////////////// |
| 1521 |
bool RagTime5StructManager::GObjPropFieldParser::parseField(Field &field, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) |
| 1522 |
{ |
| 1523 |
if (field.m_type==Field::T_FieldList) { |
| 1524 |
switch (field.m_fileType) { |
| 1525 |
case 0x6615a: |
| 1526 |
for (auto const &child : field.m_fieldList) { |
| 1527 |
if (child.m_type==Field::T_2Long && child.m_fileType==0x8c000) { |
| 1528 |
f << "dim=" << child.m_longValue[0] << "x" << child.m_longValue[1] << ","; |
| 1529 |
continue; |
| 1530 |
} |
| 1531 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected dim field\n")); |
| 1532 |
f << "##dim=" << child << ","; |
| 1533 |
} |
| 1534 |
break; |
| 1535 |
case 0x6616a: |
| 1536 |
for (auto const &child : field.m_fieldList) { |
| 1537 |
if (child.m_type==Field::T_Unstructured && child.m_fileType==0x79040) { |
| 1538 |
f << "data1=" << child << ","; |
| 1539 |
continue; |
| 1540 |
} |
| 1541 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected data1 field\n")); |
| 1542 |
f << "##data1=" << child << ","; |
| 1543 |
} |
| 1544 |
break; |
| 1545 |
case 0x6617a: // 0[13]0[01] |
| 1546 |
for (auto const &child : field.m_fieldList) { |
| 1547 |
if (child.m_type==Field::T_Long && child.m_fileType==0x34080) { |
| 1548 |
f << "data2=" << std::hex << child.m_longValue[0] << std::dec << ","; |
| 1549 |
continue; |
| 1550 |
} |
| 1551 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected data2 field\n")); |
| 1552 |
f << "##data2=" << child << ","; |
| 1553 |
} |
| 1554 |
break; |
| 1555 |
case 0x6619a: |
| 1556 |
for (auto const &child : field.m_fieldList) { |
| 1557 |
if (child.m_type==Field::T_ZoneId && static_cast<unsigned long>(child.m_fileType)==0x81452040) { |
| 1558 |
f << "cluster[id]=data" << child.m_longValue[0] << "A,"; |
| 1559 |
continue; |
| 1560 |
} |
| 1561 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected cluster id field\n")); |
| 1562 |
f << "##cluster[id]=" << child << ","; |
| 1563 |
} |
| 1564 |
break; |
| 1565 |
case 0xfd827: // rare with 0 |
| 1566 |
for (auto const &child : field.m_fieldList) { |
| 1567 |
if (child.m_type==Field::T_Long && child.m_fileType==0x3b880) { |
| 1568 |
f << "data3=" << child.m_longValue[0] << ","; |
| 1569 |
continue; |
| 1570 |
} |
| 1571 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected data3 field\n")); |
| 1572 |
f << "##data3=" << child << ","; |
| 1573 |
} |
| 1574 |
break; |
| 1575 |
case 0x10581a: // 1,_ or _,1 or 4000,1 |
| 1576 |
for (auto const &child : field.m_fieldList) { |
| 1577 |
if (child.m_type==Field::T_LongList && child.m_fileType==0x33000) { |
| 1578 |
f << "long[list]=["; |
| 1579 |
for (auto val : child.m_longList) f << std::hex << val << std::dec << ","; |
| 1580 |
f << "],"; |
| 1581 |
continue; |
| 1582 |
} |
| 1583 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find long[list] field\n")); |
| 1584 |
f << "##long[list]=" << child << ","; |
| 1585 |
} |
| 1586 |
break; |
| 1587 |
case 0x111817: // margin in % |
| 1588 |
for (auto const &child : field.m_fieldList) { |
| 1589 |
if (child.m_type==Field::T_DoubleList && child.m_fileType==0x112040 && child.m_doubleList.size()==4) { |
| 1590 |
f << "margins=" << MWAWBox2f(MWAWVec2f(float(child.m_doubleList[0]),float(child.m_doubleList[1])), |
| 1591 |
MWAWVec2f(float(child.m_doubleList[2]),float(child.m_doubleList[3]))) << ","; |
| 1592 |
continue; |
| 1593 |
} |
| 1594 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find margins field\n")); |
| 1595 |
f << "##margins[list]=" << child << ","; |
| 1596 |
} |
| 1597 |
break; |
| 1598 |
case 0x111827: // always 0,0 |
| 1599 |
for (auto const &child : field.m_fieldList) { |
| 1600 |
if (child.m_type==Field::T_2Long && child.m_fileType==0x34800) { |
| 1601 |
f << "unknPos=" << child.m_longValue[0] << "x" << child.m_longValue[1] << ","; |
| 1602 |
continue; |
| 1603 |
} |
| 1604 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected unknPos field\n")); |
| 1605 |
f << "##unknPos=" << child << ","; |
| 1606 |
} |
| 1607 |
break; |
| 1608 |
case 0x1467837: // always 0,0 |
| 1609 |
for (auto const &child : field.m_fieldList) { |
| 1610 |
if (child.m_type==Field::T_DoubleList && child.m_fileType==0x74040) { |
| 1611 |
f << "float[list]=["; |
| 1612 |
for (auto const &val : child.m_doubleList) f << val << ","; |
| 1613 |
f << "],"; |
| 1614 |
continue; |
| 1615 |
} |
| 1616 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected float[list] field\n")); |
| 1617 |
f << "##float[list]=" << child << ","; |
| 1618 |
} |
| 1619 |
break; |
| 1620 |
case 0x146789a: // 1-2 |
| 1621 |
case 0x14678aa: // 1-2 |
| 1622 |
for (auto const &child : field.m_fieldList) { |
| 1623 |
if (child.m_type==Field::T_Long && child.m_fileType==0x149e080) { |
| 1624 |
f << "d" << ((field.m_fileType>>4)&0xf) << "=" << std::hex << child.m_longValue[0] << std::dec << ","; |
| 1625 |
continue; |
| 1626 |
} |
| 1627 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected data%ld field\n", ((field.m_fileType>>4)&0xf))); |
| 1628 |
f << "##d" << ((field.m_fileType>>4)&0xf) << "=" << child << ","; |
| 1629 |
} |
| 1630 |
break; |
| 1631 |
default: |
| 1632 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected list field\n")); |
| 1633 |
f << "###field=" << field << ","; |
| 1634 |
break; |
| 1635 |
} |
| 1636 |
} |
| 1637 |
else { |
| 1638 |
MWAW_DEBUG_MSG(("RagTime5StructManager::GObjPropFieldParser::parseField: find unexpected field type\n")); |
| 1639 |
f << "###field=" << field << ","; |
| 1640 |
} |
| 1641 |
return true; |
| 1642 |
} |
| 1643 |
|
| 1644 |
//////////////////////////////////////////////////////////// |
| 1645 |
// zone function |
| 1646 |
//////////////////////////////////////////////////////////// |
| 1647 |
RagTime5Zone::~RagTime5Zone() |
| 1648 |
{ |
| 1649 |
} |
| 1650 |
|
| 1651 |
void RagTime5Zone::createAsciiFile() |
| 1652 |
{ |
| 1653 |
if (!m_input) |
| 1654 |
return; |
| 1655 |
if (m_asciiName.empty()) { |
| 1656 |
MWAW_DEBUG_MSG(("RagTime5Zone::createAsciiFile: can not find the ascii name\n")); |
| 1657 |
return; |
| 1658 |
} |
| 1659 |
if (m_localAsciiFile) { |
| 1660 |
MWAW_DEBUG_MSG(("RagTime5Zone::createAsciiFile: the ascii file already exist\n")); |
| 1661 |
} |
| 1662 |
m_localAsciiFile.reset(new libmwaw::DebugFile(m_input)); |
| 1663 |
m_asciiFile = m_localAsciiFile.get(); |
| 1664 |
m_asciiFile->open(m_asciiName); |
| 1665 |
} |
| 1666 |
|
| 1667 |
std::string RagTime5Zone::getZoneName() const |
| 1668 |
{ |
| 1669 |
if (m_level==1) { |
| 1670 |
if (m_ids[0]==0 && m_idsFlag[0]==1) |
| 1671 |
return "FileHeader"; |
| 1672 |
else if (m_ids[0]==1 && m_idsFlag[0]==0) |
| 1673 |
return "ZoneInfo"; |
| 1674 |
} |
| 1675 |
std::stringstream s; |
| 1676 |
if (m_level==1) |
| 1677 |
s << "Data" << m_ids[0] << "A"; |
| 1678 |
else if (m_level<0 || m_level>3) |
| 1679 |
s << "###unknLevel" << m_level << "-" << m_ids[0]; |
| 1680 |
else if (!m_parentName.empty()) |
| 1681 |
s << m_parentName << "-" << m_ids[0] << char('A'+m_level-1); |
| 1682 |
else |
| 1683 |
s << "###unknChild" << m_ids[0] << char('A'+m_level-1) ; |
| 1684 |
return s.str(); |
| 1685 |
} |
| 1686 |
|
| 1687 |
void RagTime5Zone::addErrorInDebugFile(std::string const &zoneName) |
| 1688 |
{ |
| 1689 |
m_isParsed=true; |
| 1690 |
if (m_entry.valid()) { |
| 1691 |
libmwaw::DebugStream f; |
| 1692 |
f << "Entries(" << zoneName << ")[" << *this << "]:###bad"; |
| 1693 |
ascii().addPos(m_entry.begin()); |
| 1694 |
ascii().addNote(f.str().c_str()); |
| 1695 |
ascii().addPos(m_entry.end()); |
| 1696 |
ascii().addNote("_"); |
| 1697 |
} |
| 1698 |
libmwaw::DebugStream f; |
| 1699 |
f << zoneName << ":###bad"; |
| 1700 |
m_mainAsciiFile->addPos(m_defPosition); |
| 1701 |
m_mainAsciiFile->addNote(f.str().c_str()); |
| 1702 |
} |
| 1703 |
|
| 1704 |
std::ostream &operator<<(std::ostream &o, RagTime5Zone const &z) |
| 1705 |
{ |
| 1706 |
o << z.getZoneName(); |
| 1707 |
if (z.m_idsFlag[0]==0) |
| 1708 |
o << "[head],"; |
| 1709 |
else if (z.m_idsFlag[0]==1) |
| 1710 |
o << ","; |
| 1711 |
else |
| 1712 |
o << "[" << z.m_idsFlag[0] << "],"; |
| 1713 |
for (int i=1; i<3; ++i) { |
| 1714 |
if (!z.m_kinds[i-1].empty()) { |
| 1715 |
o << z.m_kinds[i-1] << ","; |
| 1716 |
continue; |
| 1717 |
} |
| 1718 |
if (!z.m_ids[i] && !z.m_idsFlag[i]) continue; |
| 1719 |
o << "id" << i << "=" << z.m_ids[i]; |
| 1720 |
if (z.m_idsFlag[i]==0) |
| 1721 |
o << "*"; |
| 1722 |
else if (z.m_idsFlag[i]!=1) |
| 1723 |
o << ":" << z.m_idsFlag[i] << ","; |
| 1724 |
o << ","; |
| 1725 |
} |
| 1726 |
if (z.m_variableD[0] || z.m_variableD[1]) |
| 1727 |
o << "varD=[" << z.m_variableD[0] << "," << z.m_variableD[1] << "],"; |
| 1728 |
if (z.m_entry.valid()) |
| 1729 |
o << z.m_entry.begin() << "<->" << z.m_entry.end() << ","; |
| 1730 |
else if (!z.m_entriesList.empty()) { |
| 1731 |
o << "ptr=" << std::hex; |
| 1732 |
for (size_t i=0; i< z.m_entriesList.size(); ++i) { |
| 1733 |
o << z.m_entriesList[i].begin() << "<->" << z.m_entriesList[i].end(); |
| 1734 |
if (i+1<z.m_entriesList.size()) |
| 1735 |
o << "+"; |
| 1736 |
} |
| 1737 |
o << std::dec << ","; |
| 1738 |
} |
| 1739 |
if (!z.m_hiLoEndian) o << "loHi[endian],"; |
| 1740 |
o << z.m_extra << ","; |
| 1741 |
return o; |
| 1742 |
} |
| 1743 |
|
| 1744 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |