| 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 <cmath> |
| 35 |
#include <iomanip> |
| 36 |
#include <iostream> |
| 37 |
#include <limits> |
| 38 |
#include <map> |
| 39 |
#include <set> |
| 40 |
#include <sstream> |
| 41 |
|
| 42 |
#include <librevenge/librevenge.h> |
| 43 |
|
| 44 |
#include "MWAWFont.hxx" |
| 45 |
#include "MWAWListener.hxx" |
| 46 |
#include "MWAWPosition.hxx" |
| 47 |
#include "MWAWSubDocument.hxx" |
| 48 |
|
| 49 |
#include "RagTime5Document.hxx" |
| 50 |
#include "RagTime5StructManager.hxx" |
| 51 |
#include "RagTime5ClusterManager.hxx" |
| 52 |
|
| 53 |
#include "RagTime5Chart.hxx" |
| 54 |
|
| 55 |
#include "libmwaw_internal.hxx" |
| 56 |
|
| 57 |
/** Internal: the structures of a RagTime5Chart */ |
| 58 |
namespace RagTime5ChartInternal |
| 59 |
{ |
| 60 |
//! the setting zone |
| 61 |
struct SettingZone { |
| 62 |
//! constructor |
| 63 |
SettingZone() |
| 64 |
{ |
| 65 |
} |
| 66 |
/** three list of long: first zone of type?, second list pos to id?, main data link |
| 67 |
the 0 and 1 data zone are directly stored in link.m_longList is data are short, if not in the link |
| 68 |
the 2 zone only contains a link to the settings zone |
| 69 |
*/ |
| 70 |
RagTime5ClusterManager::Link m_listLinkId[3]; |
| 71 |
}; |
| 72 |
|
| 73 |
//! the unknown third chart zone |
| 74 |
struct UnknownZone3 { |
| 75 |
//! constructor |
| 76 |
UnknownZone3() |
| 77 |
{ |
| 78 |
} |
| 79 |
/** three list of long: first zone of type?, second list pos to id?, third list of flag |
| 80 |
the data zone are directly stored in link.m_longList is data are short, if not in the link |
| 81 |
*/ |
| 82 |
RagTime5ClusterManager::Link m_listLinkId[3]; |
| 83 |
}; |
| 84 |
|
| 85 |
//! the unknown ten chart zone |
| 86 |
struct UnknownZone10 { |
| 87 |
//! constructor |
| 88 |
UnknownZone10() |
| 89 |
{ |
| 90 |
} |
| 91 |
/** three list of long: first zone of type?, second list pos to id?, third list of sub zones |
| 92 |
the data zone are directly stored in link.m_longList is data are short, if not in the link |
| 93 |
*/ |
| 94 |
RagTime5ClusterManager::Link m_listLinkId[3]; |
| 95 |
}; |
| 96 |
|
| 97 |
//! structure to store chart information in RagTime5ChartInternal |
| 98 |
struct Chart { |
| 99 |
//! constructor |
| 100 |
Chart() |
| 101 |
: m_numSeries(0) |
| 102 |
, m_settingZone() |
| 103 |
, m_zone3() |
| 104 |
, m_zone10() |
| 105 |
{ |
| 106 |
} |
| 107 |
//! the number of series |
| 108 |
int m_numSeries; |
| 109 |
//! the setting zone |
| 110 |
SettingZone m_settingZone; |
| 111 |
//! the unknown zone3 |
| 112 |
UnknownZone3 m_zone3; |
| 113 |
//! the unknown zone10 |
| 114 |
UnknownZone3 m_zone10; |
| 115 |
}; |
| 116 |
// |
| 117 |
// parser |
| 118 |
// |
| 119 |
|
| 120 |
//! Internal: the helper to read a clustList |
| 121 |
struct ClustListParser final : public RagTime5StructManager::DataParser { |
| 122 |
//! constructor |
| 123 |
ClustListParser(RagTime5ClusterManager &clusterManager, int fieldSize, std::string const &zoneName) |
| 124 |
: RagTime5StructManager::DataParser(zoneName) |
| 125 |
, m_clusterList() |
| 126 |
, m_fieldSize(fieldSize) |
| 127 |
, m_clusterManager(clusterManager) |
| 128 |
{ |
| 129 |
if (fieldSize!=24 && fieldSize!=60) { |
| 130 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ClustListParser::ClustListParser: bad data size\n")); |
| 131 |
m_fieldSize=0; |
| 132 |
} |
| 133 |
} |
| 134 |
//! destructor |
| 135 |
~ClustListParser() final; |
| 136 |
//! returns a cluster name |
| 137 |
std::string getClusterDebugName(int id) const |
| 138 |
{ |
| 139 |
return m_clusterManager.getClusterDebugName(id); |
| 140 |
} |
| 141 |
|
| 142 |
//! try to parse a data |
| 143 |
bool parseData(MWAWInputStreamPtr &input, long endPos, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) final |
| 144 |
{ |
| 145 |
long pos=input->tell(); |
| 146 |
if (!m_fieldSize || endPos-pos!=m_fieldSize) { |
| 147 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ClustListParser::parse: bad data size\n")); |
| 148 |
return false; |
| 149 |
} |
| 150 |
|
| 151 |
std::vector<int> listIds; |
| 152 |
if (!RagTime5StructManager::readDataIdList(input, 1, listIds)) { |
| 153 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ClustListParser::parse: can not read an cluster id\n")); |
| 154 |
f << "##clusterIds,"; |
| 155 |
return false; |
| 156 |
} |
| 157 |
if (listIds[0]) { |
| 158 |
m_clusterList.push_back(listIds[0]); |
| 159 |
// a e,2003,200b, ... cluster |
| 160 |
f << getClusterDebugName(listIds[0]) << ","; |
| 161 |
} |
| 162 |
unsigned long lVal=input->readULong(4); // c00..small number |
| 163 |
if ((lVal&0xc0000000)==0xc0000000) |
| 164 |
f << "f0=" << (lVal&0x3fffffff) << ","; |
| 165 |
else |
| 166 |
f << "f0*" << lVal << ","; |
| 167 |
if (m_fieldSize==24) { |
| 168 |
for (int i=0; i<8; ++i) { // f1=0|1, f2=f3=f4=0, f5=0|c, f6=0|d|e |
| 169 |
auto val=static_cast<int>(input->readLong(2)); |
| 170 |
if (val) f << "f" << i << "=" << val << ","; |
| 171 |
} |
| 172 |
return true; |
| 173 |
} |
| 174 |
auto val=static_cast<int>(input->readLong(4)); // small int |
| 175 |
if (val) f << "f0=" << val << ","; |
| 176 |
for (int i=0; i<3; ++i) { |
| 177 |
float dim[4]; |
| 178 |
for (auto &d : dim) d=float(input->readLong(4))/65536.f; |
| 179 |
MWAWBox2f box(MWAWVec2f(dim[0],dim[1]), MWAWVec2f(dim[2],dim[3])); |
| 180 |
if (box!=MWAWBox2f(MWAWVec2f(0,0),MWAWVec2f(0,0))) |
| 181 |
f << "dim" << i << "=" << box << ","; |
| 182 |
} |
| 183 |
return true; |
| 184 |
} |
| 185 |
|
| 186 |
//! the list of read cluster |
| 187 |
std::vector<int> m_clusterList; |
| 188 |
private: |
| 189 |
//! the field size |
| 190 |
int m_fieldSize; |
| 191 |
//! the main zone manager |
| 192 |
RagTime5ClusterManager &m_clusterManager; |
| 193 |
//! copy constructor, not implemented |
| 194 |
ClustListParser(ClustListParser &orig); |
| 195 |
//! copy operator, not implemented |
| 196 |
ClustListParser &operator=(ClustListParser &orig); |
| 197 |
}; |
| 198 |
|
| 199 |
ClustListParser::~ClustListParser() |
| 200 |
{ |
| 201 |
} |
| 202 |
|
| 203 |
//! Internal: the helper to read a double's cell double |
| 204 |
struct DoubleParser final : public RagTime5StructManager::DataParser { |
| 205 |
//! constructor |
| 206 |
DoubleParser() |
| 207 |
: RagTime5StructManager::DataParser("ChartValueDouble") |
| 208 |
{ |
| 209 |
} |
| 210 |
//! destructor |
| 211 |
~DoubleParser() final; |
| 212 |
//! try to parse a data |
| 213 |
bool parseData(MWAWInputStreamPtr &input, long endPos, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) final |
| 214 |
{ |
| 215 |
long pos=input->tell(); |
| 216 |
long fSz=endPos-pos; |
| 217 |
if (fSz!=8) { |
| 218 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::DoubleParser::parse: bad data size\n")); |
| 219 |
return false; |
| 220 |
} |
| 221 |
double res; |
| 222 |
bool isNan; |
| 223 |
if (input->readDouble8(res, isNan)) { |
| 224 |
f << res; |
| 225 |
return true; |
| 226 |
} |
| 227 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 228 |
if (input->readULong(4)==0x7ff01fe0 && input->readULong(4)==0) { |
| 229 |
// some kind of nan ? |
| 230 |
f << "undef,"; |
| 231 |
return true; |
| 232 |
} |
| 233 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::DoubleParser::parse: can not read a double\n")); |
| 234 |
f << "##double"; |
| 235 |
return true; |
| 236 |
} |
| 237 |
}; |
| 238 |
|
| 239 |
DoubleParser::~DoubleParser() |
| 240 |
{ |
| 241 |
} |
| 242 |
|
| 243 |
//! Internal: the helper to read a serieType's cell serieType |
| 244 |
struct SerieTypeParser final : public RagTime5StructManager::DataParser { |
| 245 |
//! constructor |
| 246 |
SerieTypeParser() |
| 247 |
: RagTime5StructManager::DataParser("ChartSerieType") |
| 248 |
{ |
| 249 |
} |
| 250 |
//! destructor |
| 251 |
~SerieTypeParser() final; |
| 252 |
//! try to parse a data |
| 253 |
bool parseData(MWAWInputStreamPtr &input, long endPos, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) final |
| 254 |
{ |
| 255 |
long pos=input->tell(); |
| 256 |
long fSz=endPos-pos; |
| 257 |
if (fSz!=8) { |
| 258 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::SerieTypeParser::parse: bad data size\n")); |
| 259 |
return false; |
| 260 |
} |
| 261 |
long val=static_cast<int>(input->readULong(4)); // always 1 |
| 262 |
if (val!=1) { |
| 263 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::SerieTypeParser::parse: find unknown f0 value\n")); |
| 264 |
f << "##f0=" << val << ","; |
| 265 |
} |
| 266 |
auto type=input->readULong(4); |
| 267 |
switch (type) { // todo: find meaning |
| 268 |
case 0x7d01a: |
| 269 |
case 0x16b481a: |
| 270 |
case 0x16b482a: |
| 271 |
case 0x16b48fa: |
| 272 |
case 0x16b601a: |
| 273 |
f << "type=" << RagTime5StructManager::printType(type) << ","; |
| 274 |
break; |
| 275 |
default: |
| 276 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::SerieTypeParser::parse: find unknown type\n")); |
| 277 |
f << "##type=" << RagTime5StructManager::printType(type) << ","; |
| 278 |
break; |
| 279 |
} |
| 280 |
return true; |
| 281 |
} |
| 282 |
}; |
| 283 |
|
| 284 |
SerieTypeParser::~SerieTypeParser() |
| 285 |
{ |
| 286 |
} |
| 287 |
|
| 288 |
//! Internal: the helper to read child text box value(title+label) |
| 289 |
struct ChildTZoneParser final : public RagTime5StructManager::DataParser { |
| 290 |
//! constructor |
| 291 |
ChildTZoneParser() |
| 292 |
: RagTime5StructManager::DataParser("ChartValueTZone") |
| 293 |
{ |
| 294 |
} |
| 295 |
//! destructor |
| 296 |
~ChildTZoneParser() final; |
| 297 |
//! try to parse a data |
| 298 |
bool parseData(MWAWInputStreamPtr &input, long endPos, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) final |
| 299 |
{ |
| 300 |
long pos=input->tell(); |
| 301 |
long fSz=endPos-pos; |
| 302 |
if (fSz!=14) { |
| 303 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChildTZoneParser::parse: bad data size\n")); |
| 304 |
return false; |
| 305 |
} |
| 306 |
for (int i=0; i<5; ++i) { // f0=403d, f5=1|8 |
| 307 |
auto val=static_cast<int>(input->readLong(2)); |
| 308 |
if (val) f << "f" << i << "=" << val << ","; |
| 309 |
} |
| 310 |
unsigned long id= input->readULong(4); |
| 311 |
if ((id&0xfc000000) != 0x4000000) { |
| 312 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChildTZoneParser::parse: textbox sub[id] seems bad\n")); |
| 313 |
f << "#partId[h]=" << (id>>26) << ","; |
| 314 |
} |
| 315 |
id &= 0x3ffffff; |
| 316 |
if (id) f << "subId=" << id << ","; |
| 317 |
return true; |
| 318 |
} |
| 319 |
}; |
| 320 |
|
| 321 |
ChildTZoneParser::~ChildTZoneParser() |
| 322 |
{ |
| 323 |
} |
| 324 |
|
| 325 |
//! Internal: the helper to read a ZoneUnknown1's cell ZoneUnknown1 |
| 326 |
struct ZoneUnknown1Parser final : public RagTime5StructManager::DataParser { |
| 327 |
//! constructor |
| 328 |
ZoneUnknown1Parser() |
| 329 |
: RagTime5StructManager::DataParser("ChartUnknown1") |
| 330 |
{ |
| 331 |
} |
| 332 |
//! destructor |
| 333 |
~ZoneUnknown1Parser() final; |
| 334 |
//! try to parse a data |
| 335 |
bool parseData(MWAWInputStreamPtr &input, long endPos, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) final |
| 336 |
{ |
| 337 |
long pos=input->tell(); |
| 338 |
long fSz=endPos-pos; |
| 339 |
if (fSz!=6) { |
| 340 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ZoneUnknown1Parser::parse: bad data size\n")); |
| 341 |
return false; |
| 342 |
} |
| 343 |
for (int i=0; i<2; ++i) { // f0: constant in the zone 1|18, f1=10..25 |
| 344 |
auto val=static_cast<int>(input->readLong(2)); |
| 345 |
if (val) f << "f" << i << "=" << val << ","; |
| 346 |
} |
| 347 |
auto val=static_cast<int>(input->readULong(2)); // always 0|4 |
| 348 |
if (val!=4) |
| 349 |
f << "f2=" << val << ","; |
| 350 |
return true; |
| 351 |
} |
| 352 |
}; |
| 353 |
|
| 354 |
ZoneUnknown1Parser::~ZoneUnknown1Parser() |
| 355 |
{ |
| 356 |
} |
| 357 |
|
| 358 |
//! Internal: the helper to read a ZoneUnknown3's cell ZoneUnknown3 |
| 359 |
struct ZoneUnknown3Parser final : public RagTime5StructManager::DataParser { |
| 360 |
//! constructor |
| 361 |
ZoneUnknown3Parser() : RagTime5StructManager::DataParser("ChartUnknown3") |
| 362 |
{ |
| 363 |
} |
| 364 |
//! destructor |
| 365 |
~ZoneUnknown3Parser() final; |
| 366 |
//! try to parse a data |
| 367 |
bool parseData(MWAWInputStreamPtr &input, long endPos, RagTime5Zone &/*zone*/, int /*n*/, libmwaw::DebugStream &f) final |
| 368 |
{ |
| 369 |
long pos=input->tell(); |
| 370 |
long fSz=endPos-pos; |
| 371 |
if (fSz!=32) { |
| 372 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ZoneUnknown3Parser::parse: bad data size\n")); |
| 373 |
return false; |
| 374 |
} |
| 375 |
for (int i=0; i<16; ++i) { // f1=1, f3=800, f8=9 |
| 376 |
auto val=static_cast<int>(input->readLong(2)); |
| 377 |
if (val) f << "f" << i << "=" << val << ","; |
| 378 |
} |
| 379 |
return true; |
| 380 |
} |
| 381 |
}; |
| 382 |
|
| 383 |
ZoneUnknown3Parser::~ZoneUnknown3Parser() |
| 384 |
{ |
| 385 |
} |
| 386 |
|
| 387 |
//////////////////////////////////////// |
| 388 |
//! Internal: the state of a RagTime5Chart |
| 389 |
struct State { |
| 390 |
//! constructor |
| 391 |
State() |
| 392 |
: m_numPages(0) |
| 393 |
{ |
| 394 |
} |
| 395 |
//! the number of pages |
| 396 |
int m_numPages; |
| 397 |
}; |
| 398 |
|
| 399 |
} |
| 400 |
|
| 401 |
//////////////////////////////////////////////////////////// |
| 402 |
// constructor/destructor, ... |
| 403 |
//////////////////////////////////////////////////////////// |
| 404 |
RagTime5Chart::RagTime5Chart(RagTime5Document &doc) |
| 405 |
: m_document(doc) |
| 406 |
, m_structManager(m_document.getStructManager()) |
| 407 |
, m_styleManager(m_document.getStyleManager()) |
| 408 |
, m_parserState(m_document.getParserState()) |
| 409 |
, m_state(new RagTime5ChartInternal::State) |
| 410 |
{ |
| 411 |
} |
| 412 |
|
| 413 |
RagTime5Chart::~RagTime5Chart() |
| 414 |
{ } |
| 415 |
|
| 416 |
int RagTime5Chart::version() const |
| 417 |
{ |
| 418 |
return m_parserState->m_version; |
| 419 |
} |
| 420 |
|
| 421 |
int RagTime5Chart::numPages() const |
| 422 |
{ |
| 423 |
// TODO IMPLEMENT ME |
| 424 |
MWAW_DEBUG_MSG(("RagTime5Chart::numPages: is not implemented\n")); |
| 425 |
return 0; |
| 426 |
} |
| 427 |
|
| 428 |
//////////////////////////////////////////////////////////// |
| 429 |
// |
| 430 |
// Intermediate level |
| 431 |
// |
| 432 |
//////////////////////////////////////////////////////////// |
| 433 |
|
| 434 |
//////////////////////////////////////////////////////////// |
| 435 |
// |
| 436 |
// Low level |
| 437 |
// |
| 438 |
//////////////////////////////////////////////////////////// |
| 439 |
|
| 440 |
//////////////////////////////////////////////////////////// |
| 441 |
// interface send function |
| 442 |
//////////////////////////////////////////////////////////// |
| 443 |
|
| 444 |
void RagTime5Chart::flushExtra() |
| 445 |
{ |
| 446 |
MWAW_DEBUG_MSG(("RagTime5Chart::flushExtra: is not implemented\n")); |
| 447 |
} |
| 448 |
|
| 449 |
//////////////////////////////////////////////////////////// |
| 450 |
// cluster parser |
| 451 |
//////////////////////////////////////////////////////////// |
| 452 |
|
| 453 |
namespace RagTime5ChartInternal |
| 454 |
{ |
| 455 |
//! low level: the chart cluster data |
| 456 |
struct ClusterChart final : public RagTime5ClusterManager::Cluster { |
| 457 |
//! constructor |
| 458 |
ClusterChart() |
| 459 |
: RagTime5ClusterManager::Cluster(C_ChartZone) |
| 460 |
, m_typesLink() |
| 461 |
, m_unknownLink1() |
| 462 |
, m_unknownLink3() |
| 463 |
{ |
| 464 |
} |
| 465 |
//! destructor |
| 466 |
~ClusterChart() final; |
| 467 |
//! some content zone: first a double zone, second link to sub text zone data |
| 468 |
std::vector<RagTime5ClusterManager::Link> m_valuesLink[2]; |
| 469 |
//! list of type link |
| 470 |
RagTime5ClusterManager::Link m_typesLink; |
| 471 |
//! unknown link of size 6 |
| 472 |
RagTime5ClusterManager::Link m_unknownLink1; |
| 473 |
//! unknown link of size 32 |
| 474 |
RagTime5ClusterManager::Link m_unknownLink3; |
| 475 |
}; |
| 476 |
|
| 477 |
ClusterChart::~ClusterChart() |
| 478 |
{ |
| 479 |
} |
| 480 |
|
| 481 |
// |
| 482 |
//! low level: parser of chart cluster |
| 483 |
// |
| 484 |
struct ChartCParser final : public RagTime5ClusterManager::ClusterParser { |
| 485 |
//! the different field types |
| 486 |
enum Type { |
| 487 |
F_ParentLink, F_Prefs, F_Pref, F_Series, F_Series2, F_Serie, F_SerieTypes, F_Settings, F_Setting, F_Values, F_Values2, F_Value, |
| 488 |
F_DZone1, F_DZones3, F_DZone3, F_DZone5, F_DZone8, F_DZone9, F_DZones10, F_DZone10, |
| 489 |
F_DZoneF12, F_DZoneF70, F_DZoneF226, |
| 490 |
F_ChartList, |
| 491 |
F_UnknZone1, F_UnknZone2, |
| 492 |
F_Unknown |
| 493 |
}; |
| 494 |
//! a small structure used to stored a field type |
| 495 |
struct ZoneType { |
| 496 |
//! constructor |
| 497 |
ZoneType() |
| 498 |
: m_type(F_Unknown) |
| 499 |
, m_id(-1) |
| 500 |
{ |
| 501 |
} |
| 502 |
//! return the zone type name |
| 503 |
std::string getName() const |
| 504 |
{ |
| 505 |
std::stringstream s; |
| 506 |
switch (m_type) { |
| 507 |
case F_ParentLink: |
| 508 |
s << "parent[list]"; |
| 509 |
break; |
| 510 |
case F_Prefs: // unsure |
| 511 |
s << "pref[list]"; |
| 512 |
break; |
| 513 |
case F_Pref: // unsure |
| 514 |
s << "pref"; |
| 515 |
break; |
| 516 |
case F_Series: |
| 517 |
s << "serie[list1]"; |
| 518 |
break; |
| 519 |
case F_Series2: |
| 520 |
s << "serie[list2]"; |
| 521 |
break; |
| 522 |
case F_Serie: |
| 523 |
s << "serie"; |
| 524 |
break; |
| 525 |
case F_SerieTypes: |
| 526 |
s << "serie[types]"; |
| 527 |
break; |
| 528 |
case F_Settings: |
| 529 |
s << "setting[list]"; |
| 530 |
break; |
| 531 |
case F_Setting: |
| 532 |
s << "setting"; |
| 533 |
break; |
| 534 |
case F_ChartList: |
| 535 |
s << "charList"; |
| 536 |
break; |
| 537 |
case F_Values: |
| 538 |
s << "value[list1]"; |
| 539 |
break; |
| 540 |
case F_Values2: // column value size 18 or 22 or 24 ? |
| 541 |
s << "value[list2]"; |
| 542 |
break; |
| 543 |
case F_Value: |
| 544 |
s << "value"; |
| 545 |
break; |
| 546 |
case F_DZone1: |
| 547 |
s << "dZone1"; |
| 548 |
break; |
| 549 |
case F_DZone5: |
| 550 |
s << "dZone5"; |
| 551 |
break; |
| 552 |
case F_DZones3: |
| 553 |
s << "dZone3[list]"; |
| 554 |
break; |
| 555 |
case F_DZone3: |
| 556 |
s << "dZone3"; |
| 557 |
break; |
| 558 |
case F_DZone8: |
| 559 |
s << "dZone8"; |
| 560 |
break; |
| 561 |
case F_DZone9: |
| 562 |
s << "dZone9"; |
| 563 |
break; |
| 564 |
case F_DZones10: |
| 565 |
s << "dZone10[list]"; |
| 566 |
break; |
| 567 |
case F_DZone10: |
| 568 |
s << "dZone10"; |
| 569 |
break; |
| 570 |
case F_DZoneF12: // size 12 or 20 |
| 571 |
s << "dZone12"; |
| 572 |
break; |
| 573 |
case F_DZoneF70: |
| 574 |
s << "dZone70"; |
| 575 |
break; |
| 576 |
case F_DZoneF226: |
| 577 |
s << "dZone226"; |
| 578 |
break; |
| 579 |
case F_UnknZone1: |
| 580 |
s << "unkZone1"; |
| 581 |
break; |
| 582 |
case F_UnknZone2: |
| 583 |
s << "unkZone2"; |
| 584 |
break; |
| 585 |
case F_Unknown: |
| 586 |
#if !defined(__clang__) |
| 587 |
default: |
| 588 |
#endif |
| 589 |
s << "unknown"; |
| 590 |
break; |
| 591 |
} |
| 592 |
if (m_id>=0) s << "[" << m_id << "]"; |
| 593 |
return s.str(); |
| 594 |
} |
| 595 |
//! the field type |
| 596 |
Type m_type; |
| 597 |
//! the field local id |
| 598 |
int m_id; |
| 599 |
}; |
| 600 |
//! constructor |
| 601 |
ChartCParser(RagTime5ClusterManager &parser, int type, libmwaw::DebugFile &ascii) |
| 602 |
: ClusterParser(parser, type, "ClustChart") |
| 603 |
, m_cluster(new ClusterChart) |
| 604 |
, m_chart(new Chart) |
| 605 |
, m_what(-1) |
| 606 |
, m_linkId(-1) |
| 607 |
, m_fieldName("") |
| 608 |
, m_zoneType() |
| 609 |
, m_fieldIdToZoneTypeMap() |
| 610 |
, m_zoneToParseSet() |
| 611 |
, m_asciiFile(ascii) |
| 612 |
{ |
| 613 |
} |
| 614 |
//! destructor |
| 615 |
~ChartCParser() final; |
| 616 |
//! return the current cluster |
| 617 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 618 |
{ |
| 619 |
return m_cluster; |
| 620 |
} |
| 621 |
//! return the current cluster |
| 622 |
std::shared_ptr<ClusterChart> getChartCluster() |
| 623 |
{ |
| 624 |
return m_cluster; |
| 625 |
} |
| 626 |
//! return the chart |
| 627 |
std::shared_ptr<Chart> getChart() |
| 628 |
{ |
| 629 |
return m_chart; |
| 630 |
} |
| 631 |
//! insert a new zone to be parsed |
| 632 |
void insertZoneToBeParsed(int id, ZoneType const &type, bool canBeDuplicated=false) |
| 633 |
{ |
| 634 |
if (canBeDuplicated && m_fieldIdToZoneTypeMap.find(id)!=m_fieldIdToZoneTypeMap.end() && |
| 635 |
m_fieldIdToZoneTypeMap.find(id)->second.m_type==type.m_type) |
| 636 |
return; |
| 637 |
if (id<0 || m_fieldIdToZoneTypeMap.find(id)!=m_fieldIdToZoneTypeMap.end()) { |
| 638 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::insertZoneToParse: oops the zone %d seems bad\n", id)); |
| 639 |
return; |
| 640 |
} |
| 641 |
m_fieldIdToZoneTypeMap[id]=type; |
| 642 |
m_zoneToParseSet.insert(id); |
| 643 |
} |
| 644 |
//! try to check the father type |
| 645 |
bool checkFatherType(int id, Type type) const |
| 646 |
{ |
| 647 |
if (m_fieldIdToZoneTypeMap.find(id)==m_fieldIdToZoneTypeMap.end() || |
| 648 |
m_fieldIdToZoneTypeMap.find(id)->second.m_type!=type) { |
| 649 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::insertZoneToParse: can not check the father type for %d\n", id)); |
| 650 |
return false; |
| 651 |
} |
| 652 |
return true; |
| 653 |
} |
| 654 |
/** returns to new zone to parse. -1: means no preference, 0: means first zone, ... |
| 655 |
*/ |
| 656 |
int getNewZoneToParse() final |
| 657 |
{ |
| 658 |
if (m_zoneToParseSet.empty()) |
| 659 |
return -1; |
| 660 |
int id=*(m_zoneToParseSet.begin()); |
| 661 |
m_zoneToParseSet.erase(id); |
| 662 |
return id; |
| 663 |
} |
| 664 |
//! end of a start zone call |
| 665 |
void endZone() final |
| 666 |
{ |
| 667 |
if (m_link.empty()) |
| 668 |
return; |
| 669 |
switch (m_zoneType.m_type) { |
| 670 |
case F_Setting: |
| 671 |
if (m_zoneType.m_id<0 || m_zoneType.m_id>=3 || |
| 672 |
!m_chart->m_settingZone.m_listLinkId[m_zoneType.m_id].empty()) { |
| 673 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops setting%d link is already set\n", m_zoneType.m_id)); |
| 674 |
m_cluster->m_linksList.push_back(m_link); |
| 675 |
return; |
| 676 |
} |
| 677 |
m_link.m_name=std::string("ChartSetting_")+char('0'+m_zoneType.m_id); |
| 678 |
m_chart->m_settingZone.m_listLinkId[m_zoneType.m_id]=m_link; |
| 679 |
return; |
| 680 |
case F_DZone3: |
| 681 |
if (m_zoneType.m_id<0 || m_zoneType.m_id>=3 || |
| 682 |
!m_chart->m_zone3.m_listLinkId[m_zoneType.m_id].empty()) { |
| 683 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops zone3%d link is already set\n", m_zoneType.m_id)); |
| 684 |
m_cluster->m_linksList.push_back(m_link); |
| 685 |
return; |
| 686 |
} |
| 687 |
m_link.m_name=std::string("ChartDZone3_")+char('0'+m_zoneType.m_id); |
| 688 |
m_chart->m_zone3.m_listLinkId[m_zoneType.m_id]=m_link; |
| 689 |
return; |
| 690 |
case F_DZone10: |
| 691 |
if (m_zoneType.m_id<0 || m_zoneType.m_id>=2 || |
| 692 |
!m_chart->m_zone10.m_listLinkId[m_zoneType.m_id].empty()) { |
| 693 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops zone10%d link is already set\n", m_zoneType.m_id)); |
| 694 |
m_cluster->m_linksList.push_back(m_link); |
| 695 |
return; |
| 696 |
} |
| 697 |
m_link.m_name=std::string("ChartDZone10_")+char('0'+m_zoneType.m_id); |
| 698 |
m_chart->m_zone10.m_listLinkId[m_zoneType.m_id]=m_link; |
| 699 |
return; |
| 700 |
case F_ParentLink: |
| 701 |
if (m_cluster->m_parentLink.empty()) |
| 702 |
m_cluster->m_parentLink=m_link; |
| 703 |
else { |
| 704 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops parent link is already set\n")); |
| 705 |
m_cluster->m_linksList.push_back(m_link); |
| 706 |
} |
| 707 |
return; |
| 708 |
case F_SerieTypes: |
| 709 |
if (m_cluster->m_typesLink.empty()) |
| 710 |
m_cluster->m_typesLink=m_link; |
| 711 |
else { |
| 712 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops serie types link is already set\n")); |
| 713 |
m_cluster->m_linksList.push_back(m_link); |
| 714 |
} |
| 715 |
return; |
| 716 |
case F_DZone5: // a link to some data but never fills in my file |
| 717 |
if (m_link.m_fieldSize>0) { |
| 718 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: find unexpected not empty zone 5's link\n")); |
| 719 |
} |
| 720 |
m_cluster->m_linksList.push_back(m_link); |
| 721 |
return; |
| 722 |
case F_UnknZone1: |
| 723 |
if (m_cluster->m_unknownLink1.empty()) |
| 724 |
m_cluster->m_unknownLink1=m_link; |
| 725 |
else { |
| 726 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops unknown1 link is already set\n")); |
| 727 |
m_cluster->m_linksList.push_back(m_link); |
| 728 |
} |
| 729 |
return; |
| 730 |
case F_DZoneF70: |
| 731 |
if (m_cluster->m_unknownLink3.empty()) |
| 732 |
m_cluster->m_unknownLink3=m_link; |
| 733 |
else { |
| 734 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops unknown1 link is already set\n")); |
| 735 |
m_cluster->m_linksList.push_back(m_link); |
| 736 |
} |
| 737 |
return; |
| 738 |
case F_Pref: |
| 739 |
case F_Prefs: |
| 740 |
case F_Series: |
| 741 |
case F_Series2: |
| 742 |
case F_Settings: |
| 743 |
case F_Values: |
| 744 |
case F_DZone1: |
| 745 |
case F_DZones3: |
| 746 |
case F_DZone8: |
| 747 |
case F_DZone9: |
| 748 |
case F_DZones10: |
| 749 |
case F_DZoneF12: |
| 750 |
case F_Values2: |
| 751 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::endZone: oops find unexpected link for zone %s\n", m_zoneType.getName().c_str())); |
| 752 |
m_cluster->m_linksList.push_back(m_link); |
| 753 |
return; |
| 754 |
case F_ChartList: |
| 755 |
case F_DZoneF226: |
| 756 |
case F_UnknZone2: |
| 757 |
case F_Serie: |
| 758 |
case F_Value: |
| 759 |
case F_Unknown: |
| 760 |
#if !defined(__clang__) |
| 761 |
default: |
| 762 |
#endif |
| 763 |
break; |
| 764 |
} |
| 765 |
|
| 766 |
switch (m_linkId) { |
| 767 |
case 1: |
| 768 |
case 2: |
| 769 |
m_cluster->m_valuesLink[m_linkId-1].push_back(m_link); |
| 770 |
break; |
| 771 |
default: |
| 772 |
m_cluster->m_linksList.push_back(m_link); |
| 773 |
break; |
| 774 |
} |
| 775 |
} |
| 776 |
//! parse a zone |
| 777 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 778 |
{ |
| 779 |
m_linkId=-1; |
| 780 |
m_fieldName=""; |
| 781 |
if (N==-5) |
| 782 |
return parseHeaderZone(input,fSz,N,flag,f); |
| 783 |
if (N<0) { |
| 784 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseZone: expected N value\n")); |
| 785 |
f << "###N=" << N << ","; |
| 786 |
return true; |
| 787 |
} |
| 788 |
m_what=1; |
| 789 |
return parseDataZone(input, fSz, N, flag, f); |
| 790 |
} |
| 791 |
//! parse a field |
| 792 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 793 |
{ |
| 794 |
if (!m_fieldName.empty()) |
| 795 |
f << m_fieldName << ","; |
| 796 |
|
| 797 |
switch (m_what) { |
| 798 |
case 0: // header |
| 799 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0x3c057) { |
| 800 |
f << "unkn0=["; |
| 801 |
for (auto const id : field.m_longList) |
| 802 |
f << id << ","; // 15 |
| 803 |
f << "],"; |
| 804 |
break; |
| 805 |
} |
| 806 |
break; |
| 807 |
case 2: // list link |
| 808 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xce842) { |
| 809 |
f << "pos=["; |
| 810 |
for (auto const &val : field.m_longList) { |
| 811 |
if (val>1000) |
| 812 |
f << std::hex << val << std::dec << ","; |
| 813 |
else |
| 814 |
f << val << ","; |
| 815 |
} |
| 816 |
f << "],"; |
| 817 |
m_link.m_longList=field.m_longList; |
| 818 |
break; |
| 819 |
} |
| 820 |
if (m_zoneType.m_type==F_Setting || m_zoneType.m_type==F_DZone3 || |
| 821 |
m_zoneType.m_type==F_DZone5 || m_zoneType.m_type==F_DZone10) { |
| 822 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected list link field\n")); |
| 823 |
f << "###" << field; |
| 824 |
break; |
| 825 |
} |
| 826 |
if (field.m_type==RagTime5StructManager::Field::T_Unstructured && field.m_fileType==0xce017) { |
| 827 |
// a small value 2|4|a|1c|40 |
| 828 |
f << "unkn="<<field.m_extra << ","; |
| 829 |
break; |
| 830 |
} |
| 831 |
if (m_zoneType.m_type==F_ParentLink) { |
| 832 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected list link field\n")); |
| 833 |
f << "###" << field; |
| 834 |
break; |
| 835 |
} |
| 836 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xcf042) { |
| 837 |
f << "unkn=["; |
| 838 |
for (auto val : field.m_longList) { |
| 839 |
if (val==0) |
| 840 |
f << "_,"; |
| 841 |
else |
| 842 |
f << val << ","; |
| 843 |
} |
| 844 |
break; |
| 845 |
} |
| 846 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected list link field\n")); |
| 847 |
f << "###" << field; |
| 848 |
break; |
| 849 |
case 3: |
| 850 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xcf042) { |
| 851 |
bool listPos=false, canBeDupplicated=false; |
| 852 |
ZoneType zoneType; |
| 853 |
if (m_zoneType.m_type==F_Series || m_zoneType.m_type==F_Series2) { |
| 854 |
listPos=true; |
| 855 |
zoneType.m_type=F_Serie; |
| 856 |
canBeDupplicated=true; |
| 857 |
} |
| 858 |
else if (m_zoneType.m_type==F_Values) { |
| 859 |
listPos=true; |
| 860 |
zoneType.m_type=F_Value; |
| 861 |
canBeDupplicated=true; |
| 862 |
} |
| 863 |
else if (m_zoneType.m_type==F_DZone10 && m_zoneType.m_id==2) { |
| 864 |
listPos=true; |
| 865 |
zoneType.m_type=F_DZoneF226; |
| 866 |
canBeDupplicated=true; |
| 867 |
} |
| 868 |
else if (m_zoneType.m_type==F_Prefs) { |
| 869 |
listPos=true; |
| 870 |
zoneType.m_type=F_Pref; |
| 871 |
} |
| 872 |
if (listPos) |
| 873 |
f << "child=["; |
| 874 |
else |
| 875 |
f << "unkn=["; |
| 876 |
for (size_t j=0; j<field.m_longList.size(); ++j) { |
| 877 |
if (field.m_longList[j]==0) |
| 878 |
f << "_,"; |
| 879 |
else if (listPos) { |
| 880 |
f << "F" << field.m_longList[j]-1 << ","; |
| 881 |
zoneType.m_id=int(j); |
| 882 |
insertZoneToBeParsed(int(field.m_longList[j])-1, zoneType,canBeDupplicated); |
| 883 |
} |
| 884 |
else |
| 885 |
f << field.m_longList[j] << ","; |
| 886 |
} |
| 887 |
f << "],"; |
| 888 |
break; |
| 889 |
} |
| 890 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected data4 field\n")); |
| 891 |
f << "###" << field; |
| 892 |
break; |
| 893 |
case 4: // UnknZone1 |
| 894 |
if (field.m_type==RagTime5StructManager::Field::T_Long && field.m_fileType==0xcf817) { |
| 895 |
f << "unkn=" << field.m_longValue[0]; // 56|87 |
| 896 |
break; |
| 897 |
} |
| 898 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected what=4 field\n")); |
| 899 |
f << "###" << field; |
| 900 |
break; |
| 901 |
case 5: // Pref |
| 902 |
if (field.m_type==RagTime5StructManager::Field::T_FieldList && field.m_fileType==0x16c1825) { |
| 903 |
for (auto const &child : field.m_fieldList) { |
| 904 |
if (child.m_type==RagTime5StructManager::Field::T_FieldList && child.m_fileType==0x42040) { |
| 905 |
f << child; |
| 906 |
continue; |
| 907 |
} |
| 908 |
MWAW_DEBUG_MSG(("RagTime5GraphInternal::SpreadsheetCParser::parseField: find unexpected child[fSz=91]\n")); |
| 909 |
f << "##[" << child << "],"; |
| 910 |
} |
| 911 |
break; |
| 912 |
} |
| 913 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected preferences field\n")); |
| 914 |
f << "###" << field; |
| 915 |
break; |
| 916 |
default: |
| 917 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseField: find unexpected field\n")); |
| 918 |
f << "###" << field; |
| 919 |
break; |
| 920 |
} |
| 921 |
return true; |
| 922 |
} |
| 923 |
protected: |
| 924 |
//! parse a data block |
| 925 |
bool parseDataZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) |
| 926 |
{ |
| 927 |
f << "fl=" << std::hex << flag << std::dec << ","; |
| 928 |
m_zoneType=ZoneType(); |
| 929 |
if (m_fieldIdToZoneTypeMap.find(m_dataId)!=m_fieldIdToZoneTypeMap.end()) |
| 930 |
m_zoneType=m_fieldIdToZoneTypeMap.find(m_dataId)->second; |
| 931 |
long pos=input->tell(); |
| 932 |
m_link.m_N=N; |
| 933 |
int val; |
| 934 |
long linkValues[4]; |
| 935 |
std::string mess(""); |
| 936 |
if (m_zoneType.m_type==F_Unknown) |
| 937 |
f << "@"; |
| 938 |
else |
| 939 |
f << "[F" << m_dataId << "],"; |
| 940 |
switch (m_zoneType.m_type) { |
| 941 |
case F_ParentLink: |
| 942 |
if (fSz!=36 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 943 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a link for parent list\n")); |
| 944 |
f << "###"; |
| 945 |
break; |
| 946 |
} |
| 947 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x10) { |
| 948 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the fileType1 seems bad\n")); |
| 949 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 950 |
} |
| 951 |
// a cluster zone with field of size 60... |
| 952 |
m_link.m_name="ChartParentLst"; |
| 953 |
m_what=2; |
| 954 |
f << m_link << "," << mess; |
| 955 |
// now 2 int |
| 956 |
for (int i=0; i<2; ++i) { |
| 957 |
val=static_cast<int>(input->readLong(2)); |
| 958 |
if (val) f << "f" << i << "=" << val << ","; |
| 959 |
} |
| 960 |
break; |
| 961 |
case F_Prefs: |
| 962 |
if (fSz==36) { |
| 963 |
val=static_cast<int>(input->readLong(4)); |
| 964 |
if (val) f << "#f0=" << val << ","; |
| 965 |
val=static_cast<int>(input->readLong(4)); |
| 966 |
if (val!=0x17db042) { |
| 967 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseZone: find unexpected type0\n")); |
| 968 |
f << "#fileType0=" << std::hex << val << std::dec << ","; |
| 969 |
} |
| 970 |
for (int i=0; i<2; ++i) { |
| 971 |
val=static_cast<int>(input->readLong(4)); |
| 972 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 973 |
} |
| 974 |
val=static_cast<int>(input->readULong(2)); |
| 975 |
if ((val&0xFFD7)!=0x10) { |
| 976 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseZone: find unexpected type1[fSz36]\n")); |
| 977 |
f << "#fileType1=" << std::hex << val << std::dec << ","; |
| 978 |
} |
| 979 |
ZoneType zoneType; |
| 980 |
zoneType.m_type=F_ChartList; |
| 981 |
f << "ids=["; |
| 982 |
for (int i=0; i<3; ++i) { |
| 983 |
val=static_cast<int>(input->readLong(4)); |
| 984 |
if (!val) { |
| 985 |
f << "_,"; |
| 986 |
continue; |
| 987 |
} |
| 988 |
zoneType.m_id=i; |
| 989 |
insertZoneToBeParsed(val-1, zoneType); |
| 990 |
f << "F" << val-1 << ","; |
| 991 |
} |
| 992 |
f << "],"; |
| 993 |
break; |
| 994 |
} |
| 995 |
if (fSz!=29 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 996 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a link for prefs list\n")); |
| 997 |
f << "###"; |
| 998 |
break; |
| 999 |
} |
| 1000 |
m_what=3; |
| 1001 |
if (m_link.m_fileType[0]!=0x3c052) { |
| 1002 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: fileType0 seems odd for prefs list\n")); |
| 1003 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << std::dec << ","; |
| 1004 |
} |
| 1005 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x50) { |
| 1006 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: fileType1 seems odd for prefs list\n")); |
| 1007 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 1008 |
} |
| 1009 |
val=static_cast<int>(input->readLong(1)); // always 1 |
| 1010 |
if (val!=1) |
| 1011 |
f << "f0=" << val << ","; |
| 1012 |
break; |
| 1013 |
case F_Series: { |
| 1014 |
if (fSz!=35 && fSz!=40) { |
| 1015 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected size for series list1\n")); |
| 1016 |
f << "###"; |
| 1017 |
break; |
| 1018 |
} |
| 1019 |
m_what=3; |
| 1020 |
if (m_dataId!=4) { |
| 1021 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the zone id seems bad\n")); |
| 1022 |
f << "##zoneId=" << m_dataId << ","; |
| 1023 |
} |
| 1024 |
auto type=input->readULong(4); |
| 1025 |
if (type && type!=0x3c052) { |
| 1026 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone:fileType0 seems bad\n")); |
| 1027 |
f << "##fileType0=" << RagTime5StructManager::printType(type) << ","; |
| 1028 |
} |
| 1029 |
for (int i=0; i<3; ++i) { // f2=0|16a88a7 |
| 1030 |
type=input->readULong(4); |
| 1031 |
if (type) f << "f" << i << "=" << RagTime5StructManager::printType(type) << ","; |
| 1032 |
} |
| 1033 |
val=static_cast<int>(input->readULong(2)); // 67|6f |
| 1034 |
if ((val&0xFFF7)!=0x67) |
| 1035 |
f << "f3=" << val << ","; |
| 1036 |
for (int i=0; i<3; ++i) { // always 0,0,0x100 |
| 1037 |
val=static_cast<int>(input->readULong(2)); |
| 1038 |
if (val) f << "f" << i+4 << "=" << val << ","; |
| 1039 |
} |
| 1040 |
if (fSz==40) { |
| 1041 |
for (int i=0; i<5; ++i) { // always 0 |
| 1042 |
val=static_cast<int>(input->readULong(1)); |
| 1043 |
if (val) f << "f" << i+7 << "=" << val << ","; |
| 1044 |
} |
| 1045 |
} |
| 1046 |
val=static_cast<int>(input->readULong(1)); // always 0 |
| 1047 |
if (val) f << "g0=" << val << ","; |
| 1048 |
for (int i=0; i<2; ++i) { // 1,1-4 |
| 1049 |
val=static_cast<int>(input->readULong(2)); |
| 1050 |
if (val) f << "f" << i+4 << "=" << val << ","; |
| 1051 |
} |
| 1052 |
break; |
| 1053 |
} |
| 1054 |
case F_Series2: { |
| 1055 |
if (fSz!=29 && fSz!=34) { |
| 1056 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected size for series list 2\n")); |
| 1057 |
f << "###"; |
| 1058 |
break; |
| 1059 |
} |
| 1060 |
f << "father=A" << N-1 << ","; |
| 1061 |
m_what=3; |
| 1062 |
auto type=input->readULong(4); |
| 1063 |
if (type!=0x16c2042) { |
| 1064 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: filetype0 seems bad\n")); |
| 1065 |
f << "###fileType0=" << RagTime5StructManager::printType(type) << ","; |
| 1066 |
} |
| 1067 |
for (int i=0; i<6; ++i) { // always 0 |
| 1068 |
val=static_cast<int>(input->readLong(2)); |
| 1069 |
if (val) f << "f" << i << "=" << val << ","; |
| 1070 |
} |
| 1071 |
val=static_cast<int>(input->readULong(2)); |
| 1072 |
if (val!=0x70) { |
| 1073 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the filetype1 seems bad\n")); |
| 1074 |
f << "###fileType1=" << std::hex << val << std::dec << ","; |
| 1075 |
} |
| 1076 |
for (int i=0; i<5; ++i) { //g2=0|256 |
| 1077 |
val=static_cast<int>(input->readLong(fSz==29 ? 1 : 2)); |
| 1078 |
if (val) f << "g" << i << "=" << val << ","; |
| 1079 |
} |
| 1080 |
break; |
| 1081 |
} |
| 1082 |
case F_Settings: { // second zone, no auxiliar data |
| 1083 |
if (fSz!=38) { |
| 1084 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the settings size seems bad\n")); |
| 1085 |
f << "###"; |
| 1086 |
break; |
| 1087 |
} |
| 1088 |
auto type=input->readULong(4); |
| 1089 |
if (type!=0x47040) { |
| 1090 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone:fileType0 seems bad\n")); |
| 1091 |
f << "##fileType0=" << RagTime5StructManager::printType(type) << ","; |
| 1092 |
} |
| 1093 |
for (int i=0; i<5; ++i) { // always 0 |
| 1094 |
val=static_cast<int>(input->readLong(2)); |
| 1095 |
if (val) f << "f" << i << "=" << val << ","; |
| 1096 |
} |
| 1097 |
|
| 1098 |
val=static_cast<int>(input->readLong(4)); // often 16 |
| 1099 |
if (val!=16) f << "unk=" << val << ","; |
| 1100 |
ZoneType zoneType; |
| 1101 |
zoneType.m_type=F_Setting; |
| 1102 |
int listIds[3]; |
| 1103 |
for (auto &id : listIds) id=static_cast<int>(input->readLong(4)); |
| 1104 |
for (int i=0; i<3; ++i) { |
| 1105 |
if (!listIds[i]) { |
| 1106 |
f << "_,"; |
| 1107 |
continue; |
| 1108 |
} |
| 1109 |
f << "F" << listIds[i]-1 << ","; |
| 1110 |
zoneType.m_id=i; |
| 1111 |
insertZoneToBeParsed(listIds[i]-1, zoneType); |
| 1112 |
} |
| 1113 |
|
| 1114 |
val=static_cast<int>(input->readLong(2)); // always 1 |
| 1115 |
if (val!=1) |
| 1116 |
f << "f10=" << val << ","; |
| 1117 |
break; |
| 1118 |
} |
| 1119 |
case F_DZones3: |
| 1120 |
case F_DZones10: { |
| 1121 |
if (fSz!=36) { |
| 1122 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the zone 3 seems odd\n")); |
| 1123 |
f << "###"; |
| 1124 |
break; |
| 1125 |
} |
| 1126 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1127 |
auto fType=input->readULong(4); |
| 1128 |
if (fType && fType!=0x35800) { |
| 1129 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the file type 0 seems bad\n")); |
| 1130 |
f << "##fileType0=" << RagTime5StructManager::printType(fType) << ","; |
| 1131 |
} |
| 1132 |
for (int i=0; i<2; ++i) { |
| 1133 |
val=static_cast<int>(input->readULong(4)); |
| 1134 |
if (val) f << "f" << i << "=" << std::hex << val << std::dec << ","; |
| 1135 |
} |
| 1136 |
fType=input->readULong(4); |
| 1137 |
unsigned long const expectedFileType=m_zoneType.m_type==F_DZones3 ? 0 : 0x16a88a7; |
| 1138 |
if (fType!=expectedFileType) { |
| 1139 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the file type1 seems bad\n")); |
| 1140 |
f << "##fileType1=" << RagTime5StructManager::printType(fType) << ","; |
| 1141 |
} |
| 1142 |
val=static_cast<int>(input->readULong(2)); |
| 1143 |
if (val!=0x10) |
| 1144 |
f << "f3=" << val << ","; |
| 1145 |
ZoneType zoneType; |
| 1146 |
zoneType.m_type= m_zoneType.m_type==F_DZones3 ? F_DZone3 : F_DZone10; |
| 1147 |
for (int i=0; i<3; ++i) { |
| 1148 |
val=static_cast<int>(input->readULong(4)); |
| 1149 |
if (!val) |
| 1150 |
continue; |
| 1151 |
f << "F" << val-1 << ","; |
| 1152 |
zoneType.m_id=i; |
| 1153 |
insertZoneToBeParsed(val-1, zoneType); |
| 1154 |
} |
| 1155 |
break; |
| 1156 |
} |
| 1157 |
case F_Values: { |
| 1158 |
if (fSz!=29 && fSz!=34) { |
| 1159 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected size for values list 1\n")); |
| 1160 |
f << "###"; |
| 1161 |
break; |
| 1162 |
} |
| 1163 |
if (!readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1164 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read the values link\n")); |
| 1165 |
f << "###link"; |
| 1166 |
break; |
| 1167 |
} |
| 1168 |
m_what=3; |
| 1169 |
if (m_link.m_fileType[0]!=0x3c052) { |
| 1170 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected fieldType0\n")); |
| 1171 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1172 |
} |
| 1173 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x40) { |
| 1174 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected fieldType1\n")); |
| 1175 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 1176 |
} |
| 1177 |
if (fSz==34) { |
| 1178 |
for (int i=0; i<3; ++i) { // f0=100 |
| 1179 |
val=static_cast<int>(input->readLong(2)); |
| 1180 |
if (val) f << "f" << i << "=" << val << ","; |
| 1181 |
} |
| 1182 |
} |
| 1183 |
val=static_cast<int>(input->readLong(1)); // always 1 |
| 1184 |
if (val!=1) |
| 1185 |
f << "f0=" << val << ","; |
| 1186 |
f << m_link << "," << mess; |
| 1187 |
break; |
| 1188 |
} |
| 1189 |
case F_Values2: { // 18, 22 or 24 |
| 1190 |
if (fSz<18) { |
| 1191 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected size for values list2\n")); |
| 1192 |
f << "###"; |
| 1193 |
break; |
| 1194 |
} |
| 1195 |
if (!checkFatherType(N-1, F_Serie)) |
| 1196 |
f << "###"; |
| 1197 |
f << "father=A" << N-1 << ","; |
| 1198 |
auto type=input->readULong(4); |
| 1199 |
if (type!=0x7a4a9d && (type&0xFFF00E0)!=0x1fa0000) { // find 0x1fa601e, 0x1fa421c, 0x1faa21d |
| 1200 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: filetype0 seems bad\n")); |
| 1201 |
f << "###"; |
| 1202 |
} |
| 1203 |
f << "fileType0=" << RagTime5StructManager::printType(type) << ","; |
| 1204 |
int numExtra=int(fSz-10)/4; |
| 1205 |
f << "child=["; |
| 1206 |
ZoneType zoneType; |
| 1207 |
zoneType.m_type=F_Value; |
| 1208 |
zoneType.m_id=m_zoneType.m_id; |
| 1209 |
for (int i=0; i<numExtra; ++i) { |
| 1210 |
val=static_cast<int>(input->readLong(4)); |
| 1211 |
if (!val) { |
| 1212 |
f << "_,"; |
| 1213 |
continue; |
| 1214 |
} |
| 1215 |
f << "F" << val-1 << ","; |
| 1216 |
insertZoneToBeParsed(val-1, zoneType, true); |
| 1217 |
} |
| 1218 |
f << "],"; |
| 1219 |
if ((fSz%4)==0) { |
| 1220 |
val=static_cast<int>(input->readLong(2)); |
| 1221 |
if (val) f << "g0=" << val << ","; |
| 1222 |
} |
| 1223 |
break; |
| 1224 |
} |
| 1225 |
// simple data |
| 1226 |
case F_Pref: { |
| 1227 |
if (fSz!=30) { |
| 1228 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read pref link\n")); |
| 1229 |
f << "###link"; |
| 1230 |
break; |
| 1231 |
} |
| 1232 |
m_what=5; |
| 1233 |
for (int i=0; i<6; ++i) { // f3=1 |
| 1234 |
val=static_cast<int>(input->readLong(2)); |
| 1235 |
if (val) f << "f" << i << "=" << val << ","; |
| 1236 |
} |
| 1237 |
auto type=input->readULong(4); |
| 1238 |
if (type!=0x16a8842) { |
| 1239 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the filetype0 seems bad\n")); |
| 1240 |
f << "###fileType0=" << RagTime5StructManager::printType(type) << ","; |
| 1241 |
} |
| 1242 |
for (int i=0; i<4; ++i) { // g0=1 |
| 1243 |
val=static_cast<int>(input->readLong(2)); |
| 1244 |
if (val) f << "g" << i << "=" << val << ","; |
| 1245 |
} |
| 1246 |
break; |
| 1247 |
} |
| 1248 |
case F_ChartList: { |
| 1249 |
if (fSz!=28 && fSz!=30) { |
| 1250 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected size for chart list link\n")); |
| 1251 |
f << "###"; |
| 1252 |
break; |
| 1253 |
} |
| 1254 |
if (!readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1255 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read the chart list link\n")); |
| 1256 |
f << "###link"; |
| 1257 |
break; |
| 1258 |
} |
| 1259 |
m_what=2; |
| 1260 |
if ((m_zoneType.m_id==0 && m_link.m_fileType[0]!=0x3e800) || |
| 1261 |
(m_zoneType.m_id==1 && m_link.m_fileType[0]!=0x35800) || |
| 1262 |
(m_zoneType.m_id==2 && m_link.m_fileType[0]!=0x45080)) { |
| 1263 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected fieldType0\n")); |
| 1264 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1265 |
} |
| 1266 |
if ((m_link.m_fileType[1]&0xFFD7)!=0) { |
| 1267 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected fieldType1\n")); |
| 1268 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 1269 |
} |
| 1270 |
break; |
| 1271 |
} |
| 1272 |
case F_Serie: { |
| 1273 |
if (fSz!=14 && fSz!=116) { |
| 1274 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected series field size\n")); |
| 1275 |
f << "###"; |
| 1276 |
break; |
| 1277 |
} |
| 1278 |
for (int i=0; i<4; ++i) { // f2=0|1000 |
| 1279 |
val=static_cast<int>(input->readULong(2)); |
| 1280 |
static int const expected[]= {0,0,0,0x400}; |
| 1281 |
if (val!=expected[i]) f << "f" << i << "=" << std::hex << val << std::dec << ","; |
| 1282 |
} |
| 1283 |
if (fSz==14) { // empty |
| 1284 |
f << "empty,"; |
| 1285 |
break; |
| 1286 |
} |
| 1287 |
for (int i=0; i<3; ++i) { // f4=1-23, |
| 1288 |
val=static_cast<int>(input->readLong(2)); |
| 1289 |
if (val) f << "f" << i+4 << "=" << val << ","; |
| 1290 |
} |
| 1291 |
auto zoneId=static_cast<int>(input->readLong(4)); |
| 1292 |
if (zoneId) { |
| 1293 |
f << "F" << zoneId-1 << ","; |
| 1294 |
ZoneType zoneType; |
| 1295 |
zoneType.m_type=F_Values2; |
| 1296 |
zoneType.m_id=m_zoneType.m_id; |
| 1297 |
insertZoneToBeParsed(zoneId-1, zoneType); |
| 1298 |
} |
| 1299 |
for (int i=0; i<3; ++i) { // f4=1-23, |
| 1300 |
val=static_cast<int>(input->readLong(2)); |
| 1301 |
if (val) f << "f" << i+7 << "=" << val << ","; |
| 1302 |
} |
| 1303 |
f << "num=["; |
| 1304 |
for (int i=0; i<5; ++i) { |
| 1305 |
val=static_cast<int>(input->readLong(2)); |
| 1306 |
if (val) |
| 1307 |
f << val << ","; |
| 1308 |
else |
| 1309 |
f << "_,"; |
| 1310 |
} |
| 1311 |
f << "],"; |
| 1312 |
f << "fl=["; |
| 1313 |
for (int i=0; i<6; ++i) { // 0|4,1,0|1|e|68,0|1|6|55,2,8 |
| 1314 |
val=static_cast<int>(input->readULong(1)); |
| 1315 |
if (val) |
| 1316 |
f << std::hex << val << std::dec << ","; |
| 1317 |
else |
| 1318 |
f << "_,"; |
| 1319 |
} |
| 1320 |
f << "],"; |
| 1321 |
double res; |
| 1322 |
bool isNan; |
| 1323 |
long actPos; |
| 1324 |
f << "dim="; |
| 1325 |
for (int i=0; i<2; ++i) { // always Xx0.2? |
| 1326 |
actPos=input->tell(); |
| 1327 |
if (!input->readDouble8(res, isNan)) { |
| 1328 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a double\n")); |
| 1329 |
f << "###double"; |
| 1330 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1331 |
} |
| 1332 |
else |
| 1333 |
f << res; |
| 1334 |
f << (i==0 ? "x" : ","); |
| 1335 |
} |
| 1336 |
val=static_cast<int>(input->readLong(4)); |
| 1337 |
if (val) f << "f12=" << val << ","; |
| 1338 |
actPos=input->tell(); |
| 1339 |
if (!input->readDouble8(res, isNan)) { |
| 1340 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a double\n")); |
| 1341 |
f << "###double,"; |
| 1342 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1343 |
} |
| 1344 |
else |
| 1345 |
f << "dim1=" << res << ","; // always 6? |
| 1346 |
f << "fl2=["; |
| 1347 |
for (int i=0; i<4; ++i) { // 0|10, 0|80, 8,0|20 |
| 1348 |
val=static_cast<int>(input->readULong(1)); |
| 1349 |
if (val) |
| 1350 |
f << std::hex << val << std::dec << ","; |
| 1351 |
else |
| 1352 |
f << "_,"; |
| 1353 |
} |
| 1354 |
f << "],"; |
| 1355 |
val=static_cast<int>(input->readLong(2)); // always 0 |
| 1356 |
if (val) f << "g0=" << val << ","; |
| 1357 |
for (int i=0; i<2; ++i) { |
| 1358 |
f << "unk" << i << "=["; |
| 1359 |
for (int j=0; j<3; ++j) { // always _,_,1d8-218,[138]0 |
| 1360 |
val=static_cast<int>(input->readULong(j==1 ? 4 : 2)); |
| 1361 |
if (!val) { |
| 1362 |
f << "_,"; |
| 1363 |
continue; |
| 1364 |
} |
| 1365 |
if (j==1 && m_zoneType.m_type==F_Serie) { |
| 1366 |
f << "F" << val-1 << ","; |
| 1367 |
if (i==0 && val==zoneId) continue; |
| 1368 |
ZoneType zoneType; |
| 1369 |
zoneType.m_type=i==0 ? F_Values2 : F_Values; |
| 1370 |
zoneType.m_id=m_zoneType.m_id; |
| 1371 |
insertZoneToBeParsed(val-1, zoneType); |
| 1372 |
} |
| 1373 |
else |
| 1374 |
f << std::hex << val << std::dec << ","; |
| 1375 |
|
| 1376 |
} |
| 1377 |
f << "],"; |
| 1378 |
} |
| 1379 |
val=static_cast<int>(input->readLong(4)); |
| 1380 |
if (val) f << "id=" << val << ","; |
| 1381 |
val=static_cast<int>(input->readLong(4)); |
| 1382 |
if (val) { |
| 1383 |
f << "unknZone2=F" << val-1 << ","; |
| 1384 |
ZoneType zoneType; |
| 1385 |
zoneType.m_type=F_UnknZone2; |
| 1386 |
zoneType.m_id=m_zoneType.m_id; |
| 1387 |
insertZoneToBeParsed(val-1, zoneType); |
| 1388 |
} |
| 1389 |
for (int i=0; i<6; ++i) { |
| 1390 |
val=static_cast<int>(input->readLong(2)); |
| 1391 |
if (!val) continue; |
| 1392 |
f << "g" << i+1 << "=" << val << ","; |
| 1393 |
} |
| 1394 |
break; |
| 1395 |
} |
| 1396 |
case F_SerieTypes: |
| 1397 |
if (fSz!=34 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1398 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read series type link\n")); |
| 1399 |
f << "###"; |
| 1400 |
break; |
| 1401 |
} |
| 1402 |
if (m_link.m_fileType[0]!=0x3e800) { |
| 1403 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected fileType0\n")); |
| 1404 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1405 |
} |
| 1406 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x10) { |
| 1407 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected fileType1\n")); |
| 1408 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 1409 |
} |
| 1410 |
m_link.m_name="ChartSerieType"; |
| 1411 |
f << m_link << "," << mess; |
| 1412 |
val=static_cast<int>(input->readLong(4)); |
| 1413 |
if (val) { |
| 1414 |
ZoneType zoneType; |
| 1415 |
zoneType.m_type=F_Series2; |
| 1416 |
f << "serie[list]=F" << val-1 << ","; |
| 1417 |
insertZoneToBeParsed(val-1, zoneType); |
| 1418 |
} |
| 1419 |
break; |
| 1420 |
case F_Setting: { |
| 1421 |
if (((fSz!=28 || m_zoneType.m_id>=2) && (fSz!=32 || m_zoneType.m_id!=2)) || |
| 1422 |
!readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1423 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a setting link\n")); |
| 1424 |
f << "###link,"; |
| 1425 |
break; |
| 1426 |
} |
| 1427 |
m_what=2; |
| 1428 |
unsigned long const expectedType=m_zoneType.m_id==0 ? 0x3e800 : m_zoneType.m_id==1 ? 0x35800 : 0x47040; |
| 1429 |
if (m_link.m_fileType[0]!=expectedType) { |
| 1430 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected fileType0\n")); |
| 1431 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1432 |
} |
| 1433 |
if (m_zoneType.m_id==2) |
| 1434 |
m_link.m_name="settings"; |
| 1435 |
f << m_link << "," << mess; |
| 1436 |
break; |
| 1437 |
} |
| 1438 |
case F_DZone3: { |
| 1439 |
if (fSz!=28 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1440 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a dZone3 link\n")); |
| 1441 |
f << "###link,"; |
| 1442 |
break; |
| 1443 |
} |
| 1444 |
m_what=2; |
| 1445 |
unsigned long const expectedType=m_zoneType.m_id==0 ? 0x3e800 : 0x35800; |
| 1446 |
if (m_link.m_fileType[0]!=expectedType) { |
| 1447 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected fileType0\n")); |
| 1448 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1449 |
} |
| 1450 |
f << m_link << "," << mess; |
| 1451 |
break; |
| 1452 |
} |
| 1453 |
case F_DZone10: |
| 1454 |
if (m_zoneType.m_id==2) { |
| 1455 |
if (fSz!=29 && fSz!=34) { |
| 1456 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the size dzone10[2] of seems odd\n")); |
| 1457 |
f << "###fSz,"; |
| 1458 |
break; |
| 1459 |
} |
| 1460 |
auto type=input->readULong(4); |
| 1461 |
if (type!=0x16aa842) { |
| 1462 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the filetype0 seems bad\n")); |
| 1463 |
f << "##fileType0=" << RagTime5StructManager::printType(type) << ","; |
| 1464 |
} |
| 1465 |
m_what=3; |
| 1466 |
for (int i=0; i<6; ++i) { // always 0 |
| 1467 |
val=static_cast<int>(input->readLong(2)); |
| 1468 |
if (val) f << "f" << i << "=" << val << ","; |
| 1469 |
} |
| 1470 |
val=static_cast<int>(input->readULong(2)); |
| 1471 |
if (val!=0x60 && val!=0x70) { |
| 1472 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the filetype1 seems bad\n")); |
| 1473 |
f << "##fileType1=" << std::hex << val << std::dec << ","; |
| 1474 |
} |
| 1475 |
for (int i=0; i<5; ++i) { //g2=0|256 |
| 1476 |
val=static_cast<int>(input->readLong(fSz==29 ? 1 : 2)); |
| 1477 |
if (val) f << "g" << i << "=" << val << ","; |
| 1478 |
} |
| 1479 |
break; |
| 1480 |
} |
| 1481 |
if (fSz!=28 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1482 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a dZone10 link\n")); |
| 1483 |
f << "###link,"; |
| 1484 |
break; |
| 1485 |
} |
| 1486 |
m_what=2; |
| 1487 |
if (m_link.m_fileType[0]!=(m_zoneType.m_id==0 ? 0x3e800 : 0x35800)) { |
| 1488 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected fileType0\n")); |
| 1489 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1490 |
} |
| 1491 |
f << m_link << "," << mess; |
| 1492 |
break; |
| 1493 |
case F_Value: { |
| 1494 |
if (fSz!=50 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1495 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a value link\n")); |
| 1496 |
f << "###link,"; |
| 1497 |
break; |
| 1498 |
} |
| 1499 |
if (m_link.m_fieldSize==8) { |
| 1500 |
f << "double,"; |
| 1501 |
m_link.m_name="ChartValueDouble"; |
| 1502 |
m_linkId=1; |
| 1503 |
} |
| 1504 |
else if (m_link.m_fieldSize==14) { |
| 1505 |
f << "text[zone],"; |
| 1506 |
m_link.m_name="ChartValueTZone"; |
| 1507 |
m_linkId=2; |
| 1508 |
} |
| 1509 |
else { |
| 1510 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unknown link\n")); |
| 1511 |
f << "###unknown,"; |
| 1512 |
} |
| 1513 |
f << m_link << "," << mess; |
| 1514 |
auto type=input->readULong(4); |
| 1515 |
if (type && (type&0xFFFD70F)!=0x16b400a) { |
| 1516 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unknown fileType2\n")); |
| 1517 |
f << "###"; |
| 1518 |
} |
| 1519 |
if (type) |
| 1520 |
f << "fileType2=" << RagTime5StructManager::printType(type) << ","; |
| 1521 |
for (int i=0; i<3; ++i) { // g0=1, g1,g2 small number |
| 1522 |
val=static_cast<int>(input->readLong(4)); |
| 1523 |
if (!val) continue; |
| 1524 |
if (i==1) { |
| 1525 |
f << "serie=A" << val-1 << ","; |
| 1526 |
if (!checkFatherType(val-1, F_Serie)) |
| 1527 |
f << "###"; |
| 1528 |
} |
| 1529 |
else f << "g" << i << "=" << val << ","; |
| 1530 |
} |
| 1531 |
val=static_cast<int>(input->readULong(2)); // 0|21|40|4000 |
| 1532 |
if (val) f << "fl=" << std::hex << val << std::dec << ","; |
| 1533 |
val=static_cast<int>(input->readULong(2)); // 1-4 |
| 1534 |
if (val) f << "g3=" << val << ","; |
| 1535 |
break; |
| 1536 |
} |
| 1537 |
case F_DZone1: // fSz=74|117|119 |
| 1538 |
if (fSz!=74 && fSz!=117 && fSz!=119) { |
| 1539 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: the first zone size seems bad\n")); |
| 1540 |
f << "###sz"; |
| 1541 |
break; |
| 1542 |
} |
| 1543 |
for (int step=0; step<2; ++step) { |
| 1544 |
f << "data" << step << "=["; |
| 1545 |
for (int i=0; i<3; ++i) { // f2=0|1000 |
| 1546 |
val=static_cast<int>(input->readLong(2)); |
| 1547 |
if (val) f << "f" << i << "=" << std::hex << val << std::dec << ","; |
| 1548 |
} |
| 1549 |
for (int i=0; i<3; ++i) { // f3=0|d|e, f4=e|f, f5=0|f|10 |
| 1550 |
val=static_cast<int>(input->readLong(4)); |
| 1551 |
if (!val) continue; |
| 1552 |
ZoneType zoneType; |
| 1553 |
zoneType.m_type=F_DZoneF226; |
| 1554 |
zoneType.m_id=m_zoneType.m_id; |
| 1555 |
insertZoneToBeParsed(val-1, zoneType, true); |
| 1556 |
f << "zone226=F" << val-1 << ","; |
| 1557 |
} |
| 1558 |
if (step==1) |
| 1559 |
break; |
| 1560 |
for (int i=0; i<2; ++i) { // always 0 |
| 1561 |
val=static_cast<int>(input->readLong(2)); |
| 1562 |
if (val) f << "f" << i+5 << "=" << std::hex << val << std::dec << ","; |
| 1563 |
} |
| 1564 |
for (int i=0; i<4; ++i) { |
| 1565 |
auto lVal=long(input->readULong(4)); |
| 1566 |
static long const expected[]= {0x5ab56, 0x2d5ab, 0x8000, 0x7162c}; |
| 1567 |
if (lVal!=expected[i]) |
| 1568 |
f << "#fileType" << i << "=" << std::hex << lVal << std::dec << ","; |
| 1569 |
} |
| 1570 |
for (int i=0; i<4; ++i) { // g0=-1|0|1d,1e, g1=-1|0|9|a|d, g2=1 |
| 1571 |
val=static_cast<int>(input->readLong(2)); |
| 1572 |
if (val) f << "g" << i << "=" << val << ","; |
| 1573 |
} |
| 1574 |
for (int i=0; i<2; ++i) { // always ccd |
| 1575 |
val=static_cast<int>(input->readLong(4)); |
| 1576 |
if (val!=0xccd) f << "g" << i+3 << "=" << val << ","; |
| 1577 |
} |
| 1578 |
val=static_cast<int>(input->readULong(2)); // [04]1[01][137] |
| 1579 |
if (val) f<<"fl=" << std::hex << val << std::dec << ","; |
| 1580 |
val=static_cast<int>(input->readULong(2)); |
| 1581 |
if (val!=0xe07) f<<"fl2=" << std::hex << val << std::dec << ","; |
| 1582 |
val=static_cast<int>(input->readULong(4)); |
| 1583 |
if (val) { |
| 1584 |
f << "unknZone1=F" << val-1 << ","; |
| 1585 |
ZoneType zoneType; |
| 1586 |
zoneType.m_type=F_UnknZone1; |
| 1587 |
zoneType.m_id=m_zoneType.m_id; |
| 1588 |
insertZoneToBeParsed(val-1, zoneType); |
| 1589 |
} |
| 1590 |
for (int i=0; i<2; ++i) { |
| 1591 |
val=static_cast<int>(input->readLong(2)); |
| 1592 |
if (val) f << "g" << i+5 << "=" << val << ","; |
| 1593 |
} |
| 1594 |
val=static_cast<int>(input->readULong(2)); |
| 1595 |
if (val==0xc000) |
| 1596 |
f << "fl3*"; |
| 1597 |
else if (val) |
| 1598 |
f << "fl3=" << std::hex << val << std::dec << ","; |
| 1599 |
f << "],"; |
| 1600 |
if (fSz==74) |
| 1601 |
break; |
| 1602 |
} |
| 1603 |
if (fSz==74) |
| 1604 |
break; |
| 1605 |
f << "num=["; |
| 1606 |
for (int i=0; i<12; ++i) { // a decreasing sequence |
| 1607 |
val=static_cast<int>(input->readLong(2)); |
| 1608 |
if (val) |
| 1609 |
f << val << ","; |
| 1610 |
else |
| 1611 |
f << "_,"; |
| 1612 |
} |
| 1613 |
f << "],"; |
| 1614 |
val=static_cast<int>(input->readLong(1)); // alway 1 ? |
| 1615 |
if (val!=1) |
| 1616 |
f << "f0=" << val << ","; |
| 1617 |
if (fSz==117) |
| 1618 |
break; |
| 1619 |
val=static_cast<int>(input->readULong(2)); // 0[01][01]2 |
| 1620 |
if (val) |
| 1621 |
f << "fl2=" << std::hex << val << std::dec << ","; |
| 1622 |
break; |
| 1623 |
case F_DZone5: |
| 1624 |
if (fSz!=32 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1625 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read the zone5 link\n")); |
| 1626 |
f << "###link"; |
| 1627 |
break; |
| 1628 |
} |
| 1629 |
m_what=2; |
| 1630 |
m_link.m_type=RagTime5ClusterManager::Link::L_List; |
| 1631 |
m_link.m_name="ChartUnknLink5"; |
| 1632 |
m_link.m_N=N; |
| 1633 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x210) { |
| 1634 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected file type 1\n")); |
| 1635 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 1636 |
} |
| 1637 |
f << m_link << "," << mess; |
| 1638 |
break; |
| 1639 |
case F_DZone8: // fSz=20 |
| 1640 |
case F_DZone9: // fSz=18 |
| 1641 |
if ((fSz!=20 || m_zoneType.m_type!=F_DZone8) && |
| 1642 |
(fSz!=18 || m_zoneType.m_type!=F_DZone9)) { |
| 1643 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a data8 or 9 zone\n")); |
| 1644 |
f << "###"; |
| 1645 |
break; |
| 1646 |
} |
| 1647 |
val=static_cast<int>(input->readULong(4)); |
| 1648 |
if (val) |
| 1649 |
f << "f0=" << val << ","; |
| 1650 |
val=static_cast<int>(input->readULong(2)); // 0|b00|1000 |
| 1651 |
if (val) f << "fl=" << std::hex << val << std::dec << ","; |
| 1652 |
for (int i=0; i<4; ++i) { // small number |
| 1653 |
val=static_cast<int>(input->readLong(2)); |
| 1654 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1655 |
if (fSz==18 && i==2) |
| 1656 |
break; |
| 1657 |
} |
| 1658 |
break; |
| 1659 |
case F_DZoneF12: { // find with size 12 or 20 |
| 1660 |
if (fSz<12) { |
| 1661 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected size for zone 12\n")); |
| 1662 |
f << "###"; |
| 1663 |
break; |
| 1664 |
} |
| 1665 |
val=static_cast<int>(input->readLong(4)); |
| 1666 |
if (!checkFatherType(val-1, F_DZoneF226)) |
| 1667 |
f << "###"; |
| 1668 |
f << "father=A" << val-1 << ","; |
| 1669 |
val=static_cast<int>(input->readLong(2)); // 0|300|b00|1000 ... |
| 1670 |
if (val) f << "fl=" << std::hex << val << std::dec << ","; |
| 1671 |
int extra=int(fSz-12)/2; |
| 1672 |
for (int i=0; i<extra; ++i) { // smal number |
| 1673 |
val=static_cast<int>(input->readLong(2)); |
| 1674 |
if (val) f << "f" << i << "=" << val << ","; |
| 1675 |
} |
| 1676 |
break; |
| 1677 |
} |
| 1678 |
case F_DZoneF226: { |
| 1679 |
if (fSz!=226) { |
| 1680 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read a zone 226\n")); |
| 1681 |
f << "###sz"; |
| 1682 |
break; |
| 1683 |
} |
| 1684 |
for (int i=0; i<3; ++i) { // f2=0|1000 |
| 1685 |
val=static_cast<int>(input->readULong(2)); |
| 1686 |
static int const expected[]= {0,0,0,0x400}; |
| 1687 |
if (val!=expected[i]) f << "f" << i << "=" << std::hex << val << std::dec << ","; |
| 1688 |
} |
| 1689 |
bool isType2=false; |
| 1690 |
for (int i=0; i<2; ++i) { |
| 1691 |
auto type=input->readULong(4); |
| 1692 |
if (type && (type&0xFFF000F)!=0x16b000a && (i!=0 || (type&0xFFF000F)!=0x196000a)) { |
| 1693 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unknown fileType%d\n", i)); |
| 1694 |
f << "###"; |
| 1695 |
} |
| 1696 |
f << "fileType" << i << "=" << RagTime5StructManager::printType(type) << ","; |
| 1697 |
if (i==1 && type==0x16b684a) { |
| 1698 |
// the second seems quite differents |
| 1699 |
isType2=true; |
| 1700 |
f << "type2,"; |
| 1701 |
} |
| 1702 |
} |
| 1703 |
for (int i=0; i<2; ++i) { |
| 1704 |
val=static_cast<int>(input->readULong(2)); |
| 1705 |
if (val) |
| 1706 |
f << "fl" << i << "=" << std::hex << val << std::dec << ","; |
| 1707 |
} |
| 1708 |
float dim[2]; |
| 1709 |
for (auto &d : dim) d=float(input->readLong(4))/65536.f; |
| 1710 |
f << "dim=" << MWAWVec2f(dim[0], dim[1]) << ","; |
| 1711 |
for (int i=0; i<5; ++i) { // f3=1, f4=0|400, f5=0-f |
| 1712 |
val=static_cast<int>(input->readLong(2)); |
| 1713 |
if (val) |
| 1714 |
f << "f" << i+3 << "=" << val << ','; |
| 1715 |
} |
| 1716 |
f << "num0=["; |
| 1717 |
for (int i=0; i<4; ++i) { // 1|12, 1-6, 3, 3 |
| 1718 |
val=static_cast<int>(input->readLong(2)); |
| 1719 |
if (val) |
| 1720 |
f << val << ','; |
| 1721 |
else |
| 1722 |
f << ","; |
| 1723 |
} |
| 1724 |
f << "],"; |
| 1725 |
val=static_cast<int>(input->readLong(4)); |
| 1726 |
if (val) { |
| 1727 |
f << "F" << val-1 << ","; |
| 1728 |
ZoneType zoneType; |
| 1729 |
zoneType.m_type=F_DZoneF12; |
| 1730 |
zoneType.m_id=m_zoneType.m_id; |
| 1731 |
insertZoneToBeParsed(val-1, zoneType); |
| 1732 |
} |
| 1733 |
f << "num1=["; |
| 1734 |
for (int i=0; i<4; ++i) { // X1, X1, X1,5 |
| 1735 |
val=static_cast<int>(input->readLong(2)); |
| 1736 |
if (val) |
| 1737 |
f << val << ','; |
| 1738 |
else |
| 1739 |
f << ","; |
| 1740 |
} |
| 1741 |
f << "],"; |
| 1742 |
int n=isType2 ? 1 : 5; |
| 1743 |
for (int i=0; i<n; ++i) { |
| 1744 |
f << "unkn" << i << "=["; |
| 1745 |
for (int j=0; j<10; ++j) { |
| 1746 |
val=static_cast<int>(input->readULong(1)); |
| 1747 |
if (val) |
| 1748 |
f << std::hex << val << std::dec << ','; |
| 1749 |
else |
| 1750 |
f << "_,"; |
| 1751 |
} |
| 1752 |
val=static_cast<int>(input->readLong(2)); // 1|5 |
| 1753 |
if (val!=1) |
| 1754 |
f << val << "],"; |
| 1755 |
else |
| 1756 |
f << "_],"; |
| 1757 |
} |
| 1758 |
input->seek(pos+116,librevenge::RVNG_SEEK_SET); |
| 1759 |
double res; |
| 1760 |
bool isNan; |
| 1761 |
f << "val0=["; |
| 1762 |
for (int i=0; i<3; ++i) { // checkme: sometimes double sometimes not double... |
| 1763 |
if (!input->readDouble8(res, isNan)) |
| 1764 |
break; |
| 1765 |
f << res << ","; |
| 1766 |
} |
| 1767 |
f << "],"; |
| 1768 |
input->seek(pos+140,librevenge::RVNG_SEEK_SET); |
| 1769 |
for (int i=0; i<4; ++i) { |
| 1770 |
val=static_cast<int>(input->readULong(1)); // 0|4 |
| 1771 |
if (val) |
| 1772 |
f << "fl" << i+2 << "=" << val << ","; |
| 1773 |
} |
| 1774 |
f << "val1=["; |
| 1775 |
for (int i=0; i<4; ++i) { // often 0,1,1,1 |
| 1776 |
if (!input->readDouble8(res, isNan)) |
| 1777 |
break; |
| 1778 |
f << res << ","; |
| 1779 |
} |
| 1780 |
input->seek(pos+176,librevenge::RVNG_SEEK_SET); |
| 1781 |
f << "],"; |
| 1782 |
int lDim[4]; |
| 1783 |
for (auto &d : lDim) d=static_cast<int>(input->readLong(4)); |
| 1784 |
MWAWBox2i box(MWAWVec2i(lDim[0],lDim[1]),MWAWVec2i(lDim[1],lDim[2])); |
| 1785 |
if (box!=MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(0,0))) |
| 1786 |
f << "dim1=" << box << ","; |
| 1787 |
for (int i=0; i<3; ++i) { // g0=1-5, g1=1-14, g2=13|19|fa |
| 1788 |
val=static_cast<int>(input->readULong(2)); |
| 1789 |
if (val) |
| 1790 |
f << "g" << i << "=" << val << ","; |
| 1791 |
} |
| 1792 |
f << "unkn2=["; |
| 1793 |
for (int i=0; i<11; ++i) { |
| 1794 |
val=static_cast<int>(input->readULong(2)); |
| 1795 |
if (val) |
| 1796 |
f << std::hex << val << std::dec << ","; |
| 1797 |
else |
| 1798 |
f << "_,"; |
| 1799 |
} |
| 1800 |
f << "],"; |
| 1801 |
break; |
| 1802 |
} |
| 1803 |
case F_DZoneF70: // see only in one file, so ... |
| 1804 |
if (fSz!=70 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1805 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: unexpected zoneF70 size\n")); |
| 1806 |
f << "###fSz,"; |
| 1807 |
break; |
| 1808 |
} |
| 1809 |
m_link.m_name="ChartUnknown3"; |
| 1810 |
f << m_link << "," << mess; |
| 1811 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x50) { |
| 1812 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unknown fileType1\n")); |
| 1813 |
f << "###fileType1="<<std::hex << m_link.m_fileType[1] << std::dec << ",";; |
| 1814 |
} |
| 1815 |
for (int i=0; i<2; ++i) { |
| 1816 |
val=static_cast<int>(input->readLong(2)); |
| 1817 |
if (val) f << "f" << i << "=" << val << ","; |
| 1818 |
} |
| 1819 |
val=static_cast<int>(input->readULong(4)); |
| 1820 |
if (val && val!=0x25544f2c) // %To, ? |
| 1821 |
f << "#f2="<<std::hex << val << std::dec << ",";; |
| 1822 |
val=static_cast<int>(input->readULong(2)); // 9 |
| 1823 |
if (val!=9) f << "f3=" << val << ","; |
| 1824 |
for (int i=0; i<9; ++i) { |
| 1825 |
val=static_cast<int>(input->readULong(2)); |
| 1826 |
static int const expected[]= {0x6443,0x2554,0x3ee4,0,0,0,0,0x58a5,0x5c85,}; |
| 1827 |
if (val!=expected[i]) f << "g" << i << "=" << std::hex << val << std::dec << ","; |
| 1828 |
} |
| 1829 |
for (int i=0; i<6; ++i) { // h3=1, h5=0|800 |
| 1830 |
val=static_cast<int>(input->readLong(2)); |
| 1831 |
if (val) |
| 1832 |
f << "h" << i << "=" << val << ","; |
| 1833 |
} |
| 1834 |
break; |
| 1835 |
case F_UnknZone1: |
| 1836 |
if (fSz!=30 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1837 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read the unknownZone1 link\n")); |
| 1838 |
f << "###link"; |
| 1839 |
break; |
| 1840 |
} |
| 1841 |
if (m_link.m_fileType[0]!=0x16cd840) { |
| 1842 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find odd fileType0\n")); |
| 1843 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1844 |
} |
| 1845 |
if (m_link.m_fieldSize!=6) { |
| 1846 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unexpected field size\n")); |
| 1847 |
f << "###field[size]=" << m_link.m_fieldSize << ","; |
| 1848 |
} |
| 1849 |
m_link.m_name="ChartUnknown1"; |
| 1850 |
m_what=4; |
| 1851 |
f << m_link << "," << mess; |
| 1852 |
break; |
| 1853 |
case F_UnknZone2: |
| 1854 |
if (fSz!=28 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1855 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: can not read the unknownZone1 link\n")); |
| 1856 |
f << "###link"; |
| 1857 |
break; |
| 1858 |
} |
| 1859 |
if (m_link.m_fileType[0]!=0x34800) { |
| 1860 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find odd fileType0\n")); |
| 1861 |
f << "###fileType0=" << RagTime5StructManager::printType(m_link.m_fileType[0]) << ","; |
| 1862 |
} |
| 1863 |
f << m_link << "," << mess; |
| 1864 |
m_what=2; |
| 1865 |
break; |
| 1866 |
case F_Unknown: |
| 1867 |
#if !defined(__clang__) |
| 1868 |
default: |
| 1869 |
#endif |
| 1870 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseDataZone: find unknown zone type\n")); |
| 1871 |
f << "###fSz,"; |
| 1872 |
break; |
| 1873 |
} |
| 1874 |
if (m_zoneType.m_type!=F_Unknown) |
| 1875 |
m_fieldName=m_zoneType.getName(); |
| 1876 |
if (!m_fieldName.empty()) |
| 1877 |
f << m_fieldName << ","; |
| 1878 |
return true; |
| 1879 |
} |
| 1880 |
//! parse the header zone |
| 1881 |
bool parseHeaderZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) |
| 1882 |
{ |
| 1883 |
f << "header, fl=" << std::hex << flag << std::dec << ","; |
| 1884 |
m_fieldName="header"; |
| 1885 |
m_what=0; |
| 1886 |
if (N!=-5 || m_dataId!=0 || (fSz!=331 && fSz!=339)) { |
| 1887 |
f << "###N=" << N << ",fSz=" << fSz << ","; |
| 1888 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseHeaderZone: find unexpected main field\n")); |
| 1889 |
return true; |
| 1890 |
} |
| 1891 |
int val; |
| 1892 |
for (int i=0; i<2; ++i) { // always 0? |
| 1893 |
val=static_cast<int>(input->readLong(2)); |
| 1894 |
if (val) f << "f" << i << "=" << val << ","; |
| 1895 |
} |
| 1896 |
val=static_cast<int>(input->readLong(2)); |
| 1897 |
f << "id=" << val << ","; |
| 1898 |
val=static_cast<int>(input->readULong(2)); |
| 1899 |
if (m_type>0 && val!=m_type) { |
| 1900 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseHeaderZone: unexpected zone type\n")); |
| 1901 |
f << "##zoneType=" << std::hex << val << std::dec << ","; |
| 1902 |
} |
| 1903 |
for (int i=0; i<2; ++i) { |
| 1904 |
val=static_cast<int>(input->readLong(4)); |
| 1905 |
if (!val) continue; |
| 1906 |
ZoneType zoneType; |
| 1907 |
zoneType.m_type=i==0 ? F_ParentLink : F_Prefs; |
| 1908 |
if (i==0) |
| 1909 |
f << "parent=F" << val-1 << ","; |
| 1910 |
else |
| 1911 |
f << "prefs=F" << val-1 << ","; |
| 1912 |
insertZoneToBeParsed(val-1, zoneType); |
| 1913 |
} |
| 1914 |
for (int i=0; i<8; ++i) { // f3=0|d, f7=0|1|2|3|7, f8=3|4, f9=2 |
| 1915 |
val=static_cast<int>(input->readLong(2)); |
| 1916 |
if (!val) continue; |
| 1917 |
if (i==1) { |
| 1918 |
f << "num[series]=" << val << ","; |
| 1919 |
m_chart->m_numSeries=val; |
| 1920 |
} |
| 1921 |
else |
| 1922 |
f << "f" << i+2 << "=" << val << ","; |
| 1923 |
} |
| 1924 |
val=static_cast<int>(input->readLong(2)); // always 10 |
| 1925 |
if (val!=0x10) |
| 1926 |
f << "fl0=" << val << ","; |
| 1927 |
f << "double0=["; |
| 1928 |
for (int i=0; i<6; ++i) { // something like [200,150,200,0,0,500,] |
| 1929 |
double res; |
| 1930 |
bool isNan; |
| 1931 |
long actPos=input->tell(); |
| 1932 |
if (!input->readDouble8(res, isNan)) { |
| 1933 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseHeaderZone: can not read a double0\n")); |
| 1934 |
f << "##double" << i << ","; |
| 1935 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1936 |
} |
| 1937 |
else f << res << ","; |
| 1938 |
} |
| 1939 |
f << "],"; |
| 1940 |
val=static_cast<int>(input->readLong(1)); // always f |
| 1941 |
if (val!=0xf) |
| 1942 |
f << "fl1=" << val << ","; |
| 1943 |
f << "double1=["; |
| 1944 |
for (int i=0; i<2; ++i) { // small number between 0 et 2: some angle? |
| 1945 |
double res; |
| 1946 |
bool isNan; |
| 1947 |
long actPos=input->tell(); |
| 1948 |
if (!input->readDouble8(res, isNan)) { |
| 1949 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseHeaderZone: can not read a double1\n")); |
| 1950 |
f << "##double" << i << ","; |
| 1951 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1952 |
} |
| 1953 |
else f << res << ","; |
| 1954 |
} |
| 1955 |
f << "],"; |
| 1956 |
float dim[4]; |
| 1957 |
for (int i=0; i<2; ++i) dim[i]=float(input->readLong(4))/65536.f; |
| 1958 |
f << "dim?=" << MWAWVec2f(dim[0],dim[1]) << ","; |
| 1959 |
f << "double2=["; |
| 1960 |
int numData=fSz==331 ? 11 : 12; |
| 1961 |
for (int i=0; i<1+numData; ++i) { // checkme 500+a matrix (without the last line and/or column) |
| 1962 |
double res; |
| 1963 |
bool isNan; |
| 1964 |
long actPos=input->tell(); |
| 1965 |
if (!input->readDouble8(res, isNan)) { |
| 1966 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseHeaderZone: can not read a double1\n")); |
| 1967 |
f << "##double" << i << ","; |
| 1968 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1969 |
} |
| 1970 |
else f << res << ","; |
| 1971 |
} |
| 1972 |
f << "],"; |
| 1973 |
long pos=input->tell(); |
| 1974 |
libmwaw::DebugStream f2; |
| 1975 |
f2 << "ClustChart-0-A:headerB,"; |
| 1976 |
f2 << "child=["; |
| 1977 |
for (int i=0; i<12; ++i) { |
| 1978 |
val=static_cast<int>(input->readLong(4)); |
| 1979 |
static Type const wh[]= { |
| 1980 |
F_DZone1, F_Settings, F_DZones3, F_Series, |
| 1981 |
F_DZone5, F_Unknown/*never seen*/, F_SerieTypes, F_Serie, |
| 1982 |
F_DZone8, F_DZone9, F_DZones10, F_Values |
| 1983 |
}; |
| 1984 |
if (!val) continue; |
| 1985 |
if (wh[i]!=F_Unknown) { |
| 1986 |
ZoneType zoneType; |
| 1987 |
zoneType.m_type=wh[i]; |
| 1988 |
insertZoneToBeParsed(val-1, zoneType); |
| 1989 |
f2 << zoneType.getName() << "=F" << val-1 << ","; |
| 1990 |
} |
| 1991 |
else { |
| 1992 |
MWAW_DEBUG_MSG(("RagTime5ChartInternal::ChartCParser::parseHeaderZone: find unknown zone\n")); |
| 1993 |
f2 << "###unk" << i << "=F" << val-1 << ","; |
| 1994 |
} |
| 1995 |
} |
| 1996 |
f2 << "],"; |
| 1997 |
val=static_cast<int>(input->readULong(2)); // [128][8c][045] |
| 1998 |
if (val) f2 << "fl2=" << std::hex << val << std::dec << ","; |
| 1999 |
for (int i=0; i<3; ++i) { // never seems dim3 so unsure ... |
| 2000 |
for (auto &d : dim) d=float(input->readLong(4))/65536.f; |
| 2001 |
MWAWBox2f bdbox(MWAWVec2f(dim[0],dim[1]),MWAWVec2f(dim[2],dim[3])); |
| 2002 |
if (bdbox!=MWAWBox2f(MWAWVec2f(0,0),MWAWVec2f(0,0))) |
| 2003 |
f2 << "dim" << i+1 << "?=" << bdbox << ","; |
| 2004 |
} |
| 2005 |
val=static_cast<int>(input->readLong(2)); // always 0? |
| 2006 |
if (val) f2 << "h0=" << val << ","; |
| 2007 |
f2 << "ID?=["; |
| 2008 |
for (int i=0; i<2; ++i) f2 << std::hex << input->readULong(4) << std::dec << ","; |
| 2009 |
f2 << "],"; |
| 2010 |
val=static_cast<int>(input->readLong(2)); // 1|6|7 |
| 2011 |
if (val) f2 << "h1=" << val << ","; |
| 2012 |
for (int i=0; i<2; ++i) { |
| 2013 |
val=static_cast<int>(input->readULong(2)); |
| 2014 |
if (val) f2 << "fl" << i+2 << "=" << std::hex << val << std::dec << ","; |
| 2015 |
} |
| 2016 |
val=static_cast<int>(input->readULong(4)); |
| 2017 |
if (val) { |
| 2018 |
f2 << "dZone70=F" << val-1 << ","; |
| 2019 |
ZoneType zoneType; |
| 2020 |
zoneType.m_type=F_DZoneF70; |
| 2021 |
insertZoneToBeParsed(val-1, zoneType); |
| 2022 |
} |
| 2023 |
for (int i=0; i<2; ++i) { // h2=small number, h3:1 |
| 2024 |
val=static_cast<int>(input->readULong(2)); |
| 2025 |
if (val) f2 << "h" << i+2 << "=" << val << ","; |
| 2026 |
} |
| 2027 |
m_asciiFile.addPos(pos); |
| 2028 |
m_asciiFile.addNote(f2.str().c_str()); |
| 2029 |
return true; |
| 2030 |
} |
| 2031 |
|
| 2032 |
//! the current cluster |
| 2033 |
std::shared_ptr<ClusterChart> m_cluster; |
| 2034 |
//! the chart |
| 2035 |
std::shared_ptr<Chart> m_chart; |
| 2036 |
//! a index to know which field is parsed : 0: main, 1: common data, 2: list, 3: sub zone position, 4: unknown1, 5: the preferences |
| 2037 |
int m_what; |
| 2038 |
//! the link id: 1: value double, 2: value text zone |
| 2039 |
int m_linkId; |
| 2040 |
//! the actual field name |
| 2041 |
std::string m_fieldName; |
| 2042 |
//! the current zone type |
| 2043 |
ZoneType m_zoneType; |
| 2044 |
//! the list of id to zone type map |
| 2045 |
std::map<int, ZoneType> m_fieldIdToZoneTypeMap; |
| 2046 |
//! the list of know zone remaining to be parsed |
| 2047 |
std::set<int> m_zoneToParseSet; |
| 2048 |
//! the ascii file |
| 2049 |
libmwaw::DebugFile &m_asciiFile; |
| 2050 |
private: |
| 2051 |
//! copy constructor (not implemented) |
| 2052 |
ChartCParser(ChartCParser const &orig) = delete; |
| 2053 |
//! copy operator (not implemented) |
| 2054 |
ChartCParser &operator=(ChartCParser const &orig) = delete; |
| 2055 |
}; |
| 2056 |
|
| 2057 |
ChartCParser::~ChartCParser() |
| 2058 |
{ |
| 2059 |
} |
| 2060 |
|
| 2061 |
} |
| 2062 |
|
| 2063 |
std::shared_ptr<RagTime5ClusterManager::Cluster> RagTime5Chart::readChartCluster(RagTime5Zone &zone, int zoneType) |
| 2064 |
{ |
| 2065 |
std::shared_ptr<RagTime5ClusterManager> clusterManager=m_document.getClusterManager(); |
| 2066 |
if (!clusterManager) { |
| 2067 |
MWAW_DEBUG_MSG(("RagTime5Chart::readChartCluster: oops can not find the cluster manager\n")); |
| 2068 |
return std::shared_ptr<RagTime5ClusterManager::Cluster>(); |
| 2069 |
} |
| 2070 |
RagTime5ChartInternal::ChartCParser parser(*clusterManager, zoneType, zone.ascii()); |
| 2071 |
if (!clusterManager->readCluster(zone, parser) || !parser.getChartCluster() || !parser.getChart()) { |
| 2072 |
MWAW_DEBUG_MSG(("RagTime5Chart::readChartCluster: oops can not find the cluster\n")); |
| 2073 |
return std::shared_ptr<RagTime5ClusterManager::Cluster>(); |
| 2074 |
} |
| 2075 |
auto cluster=parser.getChartCluster(); |
| 2076 |
auto chart=parser.getChart(); |
| 2077 |
m_document.checkClusterList(cluster->m_clusterIdsList); |
| 2078 |
|
| 2079 |
// setting zone |
| 2080 |
for (int i=0; i<3; ++i) { |
| 2081 |
RagTime5ClusterManager::Link &link=chart->m_settingZone.m_listLinkId[i]; |
| 2082 |
if (link.empty()) |
| 2083 |
continue; |
| 2084 |
if (i<2) |
| 2085 |
m_document.readLongList(link, link.m_longList); |
| 2086 |
else { |
| 2087 |
RagTime5StructManager::FieldParser defaultParser("Settings"); |
| 2088 |
m_document.readStructZone(link, defaultParser, 0); |
| 2089 |
} |
| 2090 |
} |
| 2091 |
// unknown zone3 |
| 2092 |
for (auto &link : chart->m_zone3.m_listLinkId) { |
| 2093 |
if (link.empty()) |
| 2094 |
continue; |
| 2095 |
m_document.readLongList(link, link.m_longList); |
| 2096 |
} |
| 2097 |
// unknown zone10 |
| 2098 |
for (int i=0; i<2; ++i) { // normally, we must already have use listLinkId[2] |
| 2099 |
auto &link=chart->m_zone10.m_listLinkId[i]; |
| 2100 |
if (link.empty()) |
| 2101 |
continue; |
| 2102 |
m_document.readLongList(link, link.m_longList); |
| 2103 |
} |
| 2104 |
if (!cluster->m_dataLink.empty()) { |
| 2105 |
MWAW_DEBUG_MSG(("RagTime5Chart::readChartCluster: oops do not how to parse the main data\n")); |
| 2106 |
} |
| 2107 |
if (!cluster->m_parentLink.empty()) { |
| 2108 |
RagTime5ChartInternal::ClustListParser linkParser(*clusterManager, 60, "ChartParentLst"); |
| 2109 |
m_document.readListZone(cluster->m_parentLink, linkParser); |
| 2110 |
m_document.checkClusterList(linkParser.m_clusterList); |
| 2111 |
} |
| 2112 |
if (!cluster->m_typesLink.empty()) { |
| 2113 |
RagTime5ChartInternal::SerieTypeParser serieTypeParser; |
| 2114 |
m_document.readFixedSizeZone(cluster->m_typesLink, serieTypeParser); |
| 2115 |
} |
| 2116 |
for (int i=0; i<2; ++i) { |
| 2117 |
for (auto const &lnk : cluster->m_valuesLink[i]) { |
| 2118 |
if (i==0) { |
| 2119 |
RagTime5ChartInternal::DoubleParser doubleParser; |
| 2120 |
m_document.readFixedSizeZone(lnk, doubleParser); |
| 2121 |
} |
| 2122 |
else { // argh, where is the textZoneId ? |
| 2123 |
RagTime5ChartInternal::ChildTZoneParser textParser; |
| 2124 |
m_document.readFixedSizeZone(lnk, textParser); |
| 2125 |
} |
| 2126 |
} |
| 2127 |
} |
| 2128 |
if (!cluster->m_unknownLink1.empty()) { |
| 2129 |
RagTime5ChartInternal::ZoneUnknown1Parser zone1Parser; |
| 2130 |
m_document.readFixedSizeZone(cluster->m_unknownLink1, zone1Parser); |
| 2131 |
} |
| 2132 |
if (!cluster->m_unknownLink3.empty()) { |
| 2133 |
RagTime5ChartInternal::ZoneUnknown3Parser zone3Parser; |
| 2134 |
m_document.readFixedSizeZone(cluster->m_unknownLink3, zone3Parser); |
| 2135 |
} |
| 2136 |
|
| 2137 |
if (!cluster->m_nameLink.empty()) { |
| 2138 |
std::map<int, librevenge::RVNGString> idToStringMap; |
| 2139 |
m_document.readUnicodeStringList(cluster->m_nameLink, idToStringMap); |
| 2140 |
} |
| 2141 |
|
| 2142 |
for (auto const &lnk : cluster->m_linksList) { |
| 2143 |
if (lnk.m_type==RagTime5ClusterManager::Link::L_List) { |
| 2144 |
m_document.readListZone(lnk); |
| 2145 |
continue; |
| 2146 |
} |
| 2147 |
std::stringstream s; |
| 2148 |
s << "Chart_data" << lnk.m_fieldSize; |
| 2149 |
RagTime5StructManager::DataParser defaultParser(lnk.m_name.empty() ? s.str() : lnk.m_name); |
| 2150 |
m_document.readFixedSizeZone(lnk, defaultParser); |
| 2151 |
} |
| 2152 |
|
| 2153 |
return cluster; |
| 2154 |
} |
| 2155 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |