| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Major Contributor(s): |
| 17 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 18 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 19 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 20 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 21 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 22 |
* |
| 23 |
* |
| 24 |
* All Rights Reserved. |
| 25 |
* |
| 26 |
* For minor contributions see the git repository. |
| 27 |
* |
| 28 |
* Alternatively, the contents of this file may be used under the terms of |
| 29 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 30 |
* in which case the provisions of the LGPLv2+ are applicable |
| 31 |
* instead of those above. |
| 32 |
*/ |
| 33 |
|
| 34 |
#include <iomanip> |
| 35 |
#include <iostream> |
| 36 |
#include <map> |
| 37 |
#include <sstream> |
| 38 |
#include <stack> |
| 39 |
|
| 40 |
#include "MWAWDebug.hxx" |
| 41 |
#include "MWAWPosition.hxx" |
| 42 |
|
| 43 |
#include "RagTime5Document.hxx" |
| 44 |
#include "RagTime5StructManager.hxx" |
| 45 |
|
| 46 |
#include "RagTime5ClusterManager.hxx" |
| 47 |
|
| 48 |
/** Internal: the structures of a RagTime5ClusterManager */ |
| 49 |
namespace RagTime5ClusterManagerInternal |
| 50 |
{ |
| 51 |
//! cluster information |
| 52 |
struct ClusterInformation { |
| 53 |
//! constructor |
| 54 |
ClusterInformation() |
| 55 |
: m_type(-1) |
| 56 |
, m_fileType(-1) |
| 57 |
, m_name("") |
| 58 |
{ |
| 59 |
} |
| 60 |
//! operator<< |
| 61 |
friend std::ostream &operator<<(std::ostream &o, ClusterInformation const &info) |
| 62 |
{ |
| 63 |
switch (info.m_type) { |
| 64 |
case 0: |
| 65 |
o << "root,"; |
| 66 |
break; |
| 67 |
case 0x1: |
| 68 |
o << "layout,"; |
| 69 |
break; |
| 70 |
// case 0xe: mainTextZone? either a graphic zone or a text zone |
| 71 |
case 0x42: |
| 72 |
o << "colPat,"; |
| 73 |
break; |
| 74 |
case 0x80: |
| 75 |
o << "style,"; |
| 76 |
break; |
| 77 |
case 0x104: |
| 78 |
o << "pipeline,"; |
| 79 |
break; |
| 80 |
case 0x10000: |
| 81 |
o << "gObjProp,"; |
| 82 |
break; |
| 83 |
case 0x20000: |
| 84 |
o << "formulaDef,"; |
| 85 |
break; |
| 86 |
case 0x20001: |
| 87 |
o << "formulaPos,"; |
| 88 |
break; |
| 89 |
case 0x30000: |
| 90 |
o << "unkC_A,"; |
| 91 |
break; |
| 92 |
case 0x30001: |
| 93 |
o << "unkC_B,"; |
| 94 |
break; |
| 95 |
case 0x30002: |
| 96 |
o << "unkC_C,"; |
| 97 |
break; |
| 98 |
case 0x30003: |
| 99 |
o << "unkC_D,"; |
| 100 |
break; |
| 101 |
case 0x40000: |
| 102 |
o << "picture,"; |
| 103 |
break; |
| 104 |
case 0x40001: |
| 105 |
o << "graphic,"; |
| 106 |
break; |
| 107 |
case 0x40002: |
| 108 |
o << "spreadsheet,"; |
| 109 |
break; |
| 110 |
case 0x40003: |
| 111 |
o << "text,"; |
| 112 |
break; |
| 113 |
case 0x40004: |
| 114 |
o << "chart,"; |
| 115 |
break; |
| 116 |
case 0x40005: |
| 117 |
o << "button,"; |
| 118 |
break; |
| 119 |
case 0x40006: |
| 120 |
o << "sound,"; |
| 121 |
break; |
| 122 |
case 0x40007: |
| 123 |
o << "group[zones],"; |
| 124 |
break; |
| 125 |
default: |
| 126 |
if (info.m_fileType>=0) |
| 127 |
o << "typ=" << std::hex << info.m_fileType << std::dec << ","; |
| 128 |
} |
| 129 |
if ((info.m_fileType&8)==0) o << "auto[delete],"; |
| 130 |
if (info.m_fileType&0x20) o << "visible[selected],"; |
| 131 |
if (info.m_fileType&0x4000) o << "tear[on],"; |
| 132 |
if (info.m_fileType&0x8000) o << "lock,"; |
| 133 |
if (!info.m_name.empty()) |
| 134 |
o << info.m_name.cstr() << ","; |
| 135 |
return o; |
| 136 |
} |
| 137 |
//! the cluster type |
| 138 |
int m_type; |
| 139 |
//! the cluster file type |
| 140 |
int m_fileType; |
| 141 |
//! the cluster name |
| 142 |
librevenge::RVNGString m_name; |
| 143 |
}; |
| 144 |
//! Internal: the state of a RagTime5ClusterManager |
| 145 |
struct State { |
| 146 |
//! constructor |
| 147 |
State() |
| 148 |
: m_idToClusterInfoMap() |
| 149 |
, m_idToClusterMap() |
| 150 |
, m_rootIdList() |
| 151 |
{ |
| 152 |
} |
| 153 |
//! map id to cluster information map |
| 154 |
std::map<int, ClusterInformation> m_idToClusterInfoMap; |
| 155 |
//! map id to cluster map |
| 156 |
std::map<int, std::shared_ptr<RagTime5ClusterManager::Cluster> > m_idToClusterMap; |
| 157 |
//! the root id list |
| 158 |
std::vector<int> m_rootIdList; |
| 159 |
}; |
| 160 |
} |
| 161 |
|
| 162 |
//////////////////////////////////////////////////////////// |
| 163 |
// constructor/destructor, ... |
| 164 |
//////////////////////////////////////////////////////////// |
| 165 |
RagTime5ClusterManager::RagTime5ClusterManager(RagTime5Document &doc) |
| 166 |
: m_state(new RagTime5ClusterManagerInternal::State) |
| 167 |
, m_document(doc) |
| 168 |
, m_structManager(m_document.getStructManager()) |
| 169 |
{ |
| 170 |
} |
| 171 |
|
| 172 |
RagTime5ClusterManager::~RagTime5ClusterManager() |
| 173 |
{ |
| 174 |
} |
| 175 |
|
| 176 |
RagTime5ClusterManager::Cluster::~Cluster() |
| 177 |
{ |
| 178 |
} |
| 179 |
|
| 180 |
RagTime5ClusterManager::ClusterParser::~ClusterParser() |
| 181 |
{ |
| 182 |
} |
| 183 |
|
| 184 |
RagTime5ClusterManager::ClusterRoot::~ClusterRoot() |
| 185 |
{ |
| 186 |
} |
| 187 |
|
| 188 |
RagTime5ClusterManager::Cluster::Type RagTime5ClusterManager::getClusterType(int zId) const |
| 189 |
{ |
| 190 |
if (m_state->m_idToClusterMap.find(zId) == m_state->m_idToClusterMap.end() || |
| 191 |
!m_state->m_idToClusterMap.find(zId)->second) { |
| 192 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::getClusterType: can not find cluster type for zone %d\n", zId)); |
| 193 |
return RagTime5ClusterManager::Cluster::C_Unknown; |
| 194 |
} |
| 195 |
return m_state->m_idToClusterMap.find(zId)->second->m_type; |
| 196 |
} |
| 197 |
|
| 198 |
//////////////////////////////////////////////////////////// |
| 199 |
// read basic structures |
| 200 |
//////////////////////////////////////////////////////////// |
| 201 |
bool RagTime5ClusterManager::readFieldHeader(RagTime5Zone &zone, long endPos, std::string const &headerName, long &endDataPos, long expectedLVal) |
| 202 |
{ |
| 203 |
MWAWInputStreamPtr input=zone.getInput(); |
| 204 |
long pos=input->tell(); |
| 205 |
libmwaw::DebugFile &ascFile=zone.ascii(); |
| 206 |
libmwaw::DebugStream f; |
| 207 |
|
| 208 |
f << headerName << ":"; |
| 209 |
long lVal, sz; |
| 210 |
bool ok=true; |
| 211 |
if (pos>=endPos || !RagTime5StructManager::readCompressedLong(input, endPos, lVal) || |
| 212 |
!RagTime5StructManager::readCompressedLong(input,endPos,sz) || sz <= 7 || input->tell()+sz>endPos) { |
| 213 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readFieldHeader: can not read the main item\n")); |
| 214 |
f << "###"; |
| 215 |
ok=false; |
| 216 |
} |
| 217 |
else { |
| 218 |
if (lVal!=expectedLVal) |
| 219 |
f << "f0=" << lVal << ","; |
| 220 |
f << "sz=" << sz << ","; |
| 221 |
endDataPos=input->tell()+sz; |
| 222 |
} |
| 223 |
if (!headerName.empty()) { |
| 224 |
ascFile.addPos(pos); |
| 225 |
ascFile.addNote(f.str().c_str()); |
| 226 |
} |
| 227 |
return ok; |
| 228 |
} |
| 229 |
|
| 230 |
std::string RagTime5ClusterManager::getClusterDebugName(int id) |
| 231 |
{ |
| 232 |
if (!id) return ""; |
| 233 |
std::stringstream s; |
| 234 |
s << "data" << id << "A"; |
| 235 |
if (m_state->m_idToClusterInfoMap.find(id)!=m_state->m_idToClusterInfoMap.end()) |
| 236 |
s << "[" << m_state->m_idToClusterInfoMap.find(id)->second << "]"; |
| 237 |
return s.str(); |
| 238 |
} |
| 239 |
|
| 240 |
void RagTime5ClusterManager::setClusterName(int id, librevenge::RVNGString const &name) |
| 241 |
{ |
| 242 |
if (!id) return; |
| 243 |
auto it=m_state->m_idToClusterInfoMap.find(id); |
| 244 |
if (it==m_state->m_idToClusterInfoMap.end()) { |
| 245 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::setClusterName: can not find cluster %d\n", id)); |
| 246 |
return; |
| 247 |
} |
| 248 |
else if (!it->second.m_name.empty()) { |
| 249 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::setClusterName: cluster %d already has a name\n", id)); |
| 250 |
return; |
| 251 |
} |
| 252 |
it->second.m_name=name; |
| 253 |
} |
| 254 |
|
| 255 |
//////////////////////////////////////////////////////////// |
| 256 |
// link to cluster |
| 257 |
//////////////////////////////////////////////////////////// |
| 258 |
bool RagTime5ClusterManager::readClusterMainList(RagTime5ClusterManager::ClusterRoot &root, std::vector<int> &lists, std::vector<int> const &clusterIdList) |
| 259 |
{ |
| 260 |
std::map<int, librevenge::RVNGString> idToNameMap; |
| 261 |
if (!root.m_listClusterName.empty()) |
| 262 |
m_document.readUnicodeStringList(root.m_listClusterName, idToNameMap); |
| 263 |
if (!root.m_listClusterLink[0].empty()) { |
| 264 |
std::vector<long> unknList; |
| 265 |
m_document.readLongList(root.m_listClusterLink[0], unknList); |
| 266 |
} |
| 267 |
auto zone=m_document.getDataZone(root.m_listClusterId); |
| 268 |
if (!zone || zone->getKindLastPart(zone->m_kinds[1].empty())!="ItemData" || |
| 269 |
zone->m_entry.length()<24 || (zone->m_entry.length()%8)) { |
| 270 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readClusterMainList: the item list seems bad\n")); |
| 271 |
return false; |
| 272 |
} |
| 273 |
MWAWEntry &entry=zone->m_entry; |
| 274 |
zone->m_isParsed=true; |
| 275 |
MWAWInputStreamPtr input=zone->getInput(); |
| 276 |
input->seek(entry.begin(), librevenge::RVNG_SEEK_SET); |
| 277 |
input->setReadInverted(!zone->m_hiLoEndian); |
| 278 |
|
| 279 |
libmwaw::DebugFile &ascFile=zone->ascii(); |
| 280 |
libmwaw::DebugStream f; |
| 281 |
ascFile.addPos(entry.end()); |
| 282 |
ascFile.addNote("_"); |
| 283 |
|
| 284 |
auto N=int(entry.length()/8); |
| 285 |
for (int i=0; i<N; ++i) { |
| 286 |
long pos=input->tell(); |
| 287 |
f.str(""); |
| 288 |
if (i==0) |
| 289 |
f << "Entries(RootClustMain)[" << *zone << "]:"; |
| 290 |
else |
| 291 |
f << "RootClustMain-" << i+1 << ":"; |
| 292 |
librevenge::RVNGString name(""); |
| 293 |
if (idToNameMap.find(i+1)!=idToNameMap.end()) { |
| 294 |
name=idToNameMap.find(i+1)->second; |
| 295 |
f << name.cstr() << ","; |
| 296 |
} |
| 297 |
std::vector<int> listIds; |
| 298 |
if (!m_structManager->readDataIdList(input, 1, listIds)) { |
| 299 |
input->seek(pos+8, librevenge::RVNG_SEEK_SET); |
| 300 |
f << "###"; |
| 301 |
ascFile.addPos(pos); |
| 302 |
ascFile.addNote(f.str().c_str()); |
| 303 |
continue; |
| 304 |
} |
| 305 |
if (listIds[0]==0) { |
| 306 |
input->seek(pos+8, librevenge::RVNG_SEEK_SET); |
| 307 |
ascFile.addPos(pos); |
| 308 |
ascFile.addNote("_"); |
| 309 |
continue; |
| 310 |
} |
| 311 |
f << "data" << listIds[0] << "A,"; |
| 312 |
m_state->m_rootIdList.push_back(listIds[0]); |
| 313 |
auto val=static_cast<int>(input->readULong(2)); // the type |
| 314 |
if (val) f << "type=" << std::hex << val << std::dec << ","; |
| 315 |
RagTime5ClusterManagerInternal::ClusterInformation info; |
| 316 |
info.m_fileType=val; |
| 317 |
info.m_name=name; |
| 318 |
m_state->m_idToClusterInfoMap[listIds[0]]=info; |
| 319 |
lists.push_back(listIds[0]); |
| 320 |
val=static_cast<int>(input->readLong(2)); // always 0? |
| 321 |
if (val) f << "#f1=" << val << ","; |
| 322 |
ascFile.addPos(pos); |
| 323 |
ascFile.addNote(f.str().c_str()); |
| 324 |
} |
| 325 |
input->setReadInverted(false); |
| 326 |
|
| 327 |
// update the cluster info zone |
| 328 |
for (auto cId : clusterIdList) { |
| 329 |
auto data=m_document.getDataZone(cId); |
| 330 |
if (!data) continue; |
| 331 |
if (m_state->m_idToClusterInfoMap.find(cId)==m_state->m_idToClusterInfoMap.end()) { |
| 332 |
RagTime5ClusterManagerInternal::ClusterInformation info; |
| 333 |
info.m_fileType=getClusterFileType(*data); |
| 334 |
info.m_type=getClusterType(*data, info.m_fileType); |
| 335 |
m_state->m_idToClusterInfoMap[cId]=info; |
| 336 |
continue; |
| 337 |
} |
| 338 |
auto &info=m_state->m_idToClusterInfoMap.find(cId)->second; |
| 339 |
info.m_type=getClusterType(*data, info.m_fileType); |
| 340 |
} |
| 341 |
return true; |
| 342 |
} |
| 343 |
|
| 344 |
bool RagTime5ClusterManager::readUnknownClusterC(Link const &link) |
| 345 |
{ |
| 346 |
if (link.m_ids.size()!=4) { |
| 347 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readUnknownClusterC: call with bad ids\n")); |
| 348 |
return false; |
| 349 |
} |
| 350 |
for (size_t i=0; i<4; ++i) { |
| 351 |
if (!link.m_ids[i]) continue; |
| 352 |
auto data=m_document.getDataZone(link.m_ids[i]); |
| 353 |
if (!data || data->m_isParsed || data->getKindLastPart(data->m_kinds[1].empty())!="Cluster") { |
| 354 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readUnknownClusterC: the child cluster id %d seems bad\n", link.m_ids[i])); |
| 355 |
continue; |
| 356 |
} |
| 357 |
m_document.readClusterZone(*data, 0x30000+int(i)); |
| 358 |
} |
| 359 |
return true; |
| 360 |
} |
| 361 |
|
| 362 |
//////////////////////////////////////////////////////////// |
| 363 |
// main cluster fonction |
| 364 |
//////////////////////////////////////////////////////////// |
| 365 |
bool RagTime5ClusterManager::readCluster(RagTime5Zone &zone, RagTime5ClusterManager::ClusterParser &parser, bool warnForUnparsed) |
| 366 |
{ |
| 367 |
MWAWEntry &entry=zone.m_entry; |
| 368 |
if (entry.length()<13) { |
| 369 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: the zone %d seems bad\n", zone.m_ids[0])); |
| 370 |
return false; |
| 371 |
} |
| 372 |
auto cluster=parser.getCluster(); |
| 373 |
if (!cluster) { |
| 374 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: oops, the cluster is not defined\n")); |
| 375 |
return false; |
| 376 |
} |
| 377 |
cluster->m_hiLoEndian=parser.m_hiLoEndian=zone.m_hiLoEndian; |
| 378 |
cluster->m_zoneId=zone.m_ids[0]; |
| 379 |
|
| 380 |
MWAWInputStreamPtr input=zone.getInput(); |
| 381 |
long endPos=entry.end(); |
| 382 |
input->setReadInverted(!zone.m_hiLoEndian); |
| 383 |
input->seek(entry.begin(), librevenge::RVNG_SEEK_SET); |
| 384 |
|
| 385 |
libmwaw::DebugStream f; |
| 386 |
f.str(""); |
| 387 |
f << "Entries(" << parser.getZoneName() << ")[" << zone << "]:"; |
| 388 |
if (m_state->m_idToClusterInfoMap.find(zone.m_ids[0])!=m_state->m_idToClusterInfoMap.end() && |
| 389 |
!m_state->m_idToClusterInfoMap.find(zone.m_ids[0])->second.m_name.empty()) { |
| 390 |
cluster->m_name=m_state->m_idToClusterInfoMap.find(zone.m_ids[0])->second.m_name; |
| 391 |
f << cluster->m_name.cstr() << ","; |
| 392 |
} |
| 393 |
for (int i=0; i<4; ++i) { // f0=f1=0, f2=1, f3=small number |
| 394 |
static int const expected[]= {0,0,1,0}; |
| 395 |
auto val=static_cast<int>(input->readLong(2)); |
| 396 |
if (val!=expected[i]) f << "f" << i << "=" << val << ","; |
| 397 |
} |
| 398 |
zone.m_isParsed=true; |
| 399 |
libmwaw::DebugFile &ascFile=zone.ascii(); |
| 400 |
ascFile.addPos(entry.begin()); |
| 401 |
ascFile.addNote(f.str().c_str()); |
| 402 |
ascFile.addPos(endPos); |
| 403 |
ascFile.addNote("_"); |
| 404 |
|
| 405 |
// first create the list of zone to parse |
| 406 |
parser.m_dataId=-1; |
| 407 |
std::map<int, MWAWEntry> idToEntryMap; |
| 408 |
std::set<int> toParseSet; |
| 409 |
MWAWEntry zEntry; |
| 410 |
while (!input->isEnd()) { |
| 411 |
long pos=input->tell(); |
| 412 |
if (pos>=endPos) break; |
| 413 |
long endDataPos; |
| 414 |
++parser.m_dataId; // update dataId |
| 415 |
if (!readFieldHeader(zone, endPos, parser.getZoneName(parser.m_dataId), endDataPos) || |
| 416 |
!input->checkPosition(endDataPos)) { |
| 417 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 418 |
break; |
| 419 |
} |
| 420 |
zEntry.setId(parser.m_dataId); |
| 421 |
zEntry.setBegin(input->tell()); |
| 422 |
zEntry.setEnd(endDataPos); |
| 423 |
idToEntryMap[parser.m_dataId]=zEntry; |
| 424 |
toParseSet.insert(parser.m_dataId); |
| 425 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 426 |
} |
| 427 |
|
| 428 |
long pos=input->tell(); |
| 429 |
if (pos!=endPos) { |
| 430 |
f.str(""); |
| 431 |
f << parser.getZoneName() << "###"; |
| 432 |
ascFile.addPos(pos); |
| 433 |
ascFile.addNote(f.str().c_str()); |
| 434 |
} |
| 435 |
|
| 436 |
while (!toParseSet.empty()) { |
| 437 |
int id=parser.getNewZoneToParse(); |
| 438 |
if (id>=0 && toParseSet.find(id)==toParseSet.end()) { |
| 439 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: zone %d is not valid, reset to basic method\n", id)); |
| 440 |
id=-1; |
| 441 |
} |
| 442 |
if (id<0) |
| 443 |
id=*(toParseSet.begin()); |
| 444 |
toParseSet.erase(id); |
| 445 |
|
| 446 |
auto it=idToEntryMap.find(id); |
| 447 |
if (it==idToEntryMap.end()) { |
| 448 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: can not find some id=%d\n", id)); |
| 449 |
continue; |
| 450 |
} |
| 451 |
parser.m_dataId=id; |
| 452 |
parser.m_link=Link(); |
| 453 |
parser.startZone(); |
| 454 |
|
| 455 |
pos=it->second.begin(); |
| 456 |
long endDataPos=it->second.end(); |
| 457 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 458 |
f.str(""); |
| 459 |
f << parser.getZoneName(parser.m_dataId) << "-A:"; |
| 460 |
if (!zone.m_hiLoEndian) f << "lohi,"; |
| 461 |
long fSz; |
| 462 |
if (!RagTime5StructManager::readCompressedLong(input, endDataPos, fSz) || fSz<6 || input->tell()+fSz>endDataPos) { |
| 463 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: can not read item A\n")); |
| 464 |
f << "###fSz"; |
| 465 |
ascFile.addPos(pos); |
| 466 |
ascFile.addNote(f.str().c_str()); |
| 467 |
|
| 468 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 469 |
continue; |
| 470 |
} |
| 471 |
long debSubDataPos=input->tell(); |
| 472 |
long endSubDataPos=debSubDataPos+fSz; |
| 473 |
auto fl=static_cast<int>(input->readULong(2)); // [01][13][0139b] |
| 474 |
auto N=static_cast<int>(input->readLong(4)); |
| 475 |
if (!parser.parseZone(input, fSz, N, fl, f) && warnForUnparsed) { |
| 476 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: find an unparsed zone\n")); |
| 477 |
f << "###"; |
| 478 |
} |
| 479 |
|
| 480 |
if (input->tell()!=endSubDataPos) { |
| 481 |
ascFile.addDelimiter(input->tell(),'|'); |
| 482 |
input->seek(endSubDataPos, librevenge::RVNG_SEEK_SET); |
| 483 |
} |
| 484 |
ascFile.addPos(pos); |
| 485 |
ascFile.addNote(f.str().c_str()); |
| 486 |
|
| 487 |
int m=-1; |
| 488 |
while (!input->isEnd()) { |
| 489 |
pos=input->tell(); |
| 490 |
if (pos+4>endDataPos) |
| 491 |
break; |
| 492 |
++m; |
| 493 |
|
| 494 |
RagTime5StructManager::Field field; |
| 495 |
if (!m_structManager->readField(input, endDataPos, ascFile, field)) { |
| 496 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 497 |
break; |
| 498 |
} |
| 499 |
f.str(""); |
| 500 |
f << parser.getZoneName(parser.m_dataId,m) << ":"; |
| 501 |
if (!parser.parseField(field, m, f)) { |
| 502 |
if (warnForUnparsed) { |
| 503 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: find an unparsed field\n")); |
| 504 |
f << "###"; |
| 505 |
} |
| 506 |
f << field; |
| 507 |
} |
| 508 |
ascFile.addPos(pos); |
| 509 |
ascFile.addNote(f.str().c_str()); |
| 510 |
} |
| 511 |
pos=input->tell(); |
| 512 |
if (pos!=endDataPos) { |
| 513 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: find some extra data\n")); |
| 514 |
f.str(""); |
| 515 |
f << parser.getZoneName(parser.m_dataId) << ":" << "###"; |
| 516 |
ascFile.addPos(pos); |
| 517 |
ascFile.addNote(f.str().c_str()); |
| 518 |
} |
| 519 |
parser.endZone(); |
| 520 |
input->seek(endDataPos, librevenge::RVNG_SEEK_SET); |
| 521 |
} |
| 522 |
|
| 523 |
input->setReadInverted(false); |
| 524 |
|
| 525 |
return true; |
| 526 |
} |
| 527 |
|
| 528 |
//////////////////////////////////////////////////////////// |
| 529 |
// send data |
| 530 |
//////////////////////////////////////////////////////////// |
| 531 |
bool RagTime5ClusterManager::sendClusterMainList() |
| 532 |
{ |
| 533 |
MWAWPosition pos(MWAWVec2f(0,0), MWAWVec2f(200,200), librevenge::RVNG_POINT); |
| 534 |
pos.m_anchorTo=MWAWPosition::Char; |
| 535 |
for (auto id : m_state->m_rootIdList) { |
| 536 |
if (!id) continue; |
| 537 |
if (m_state->m_idToClusterMap.find(id) == m_state->m_idToClusterMap.end() || |
| 538 |
!m_state->m_idToClusterMap.find(id)->second) { |
| 539 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::sendClusterMainList: can not find cluster type for zone %d\n", id)); |
| 540 |
continue; |
| 541 |
} |
| 542 |
auto cluster=m_state->m_idToClusterMap.find(id)->second; |
| 543 |
if (cluster->m_isSent) continue; |
| 544 |
auto type=cluster->m_type; |
| 545 |
if (type==Cluster::C_ChartZone|| type==Cluster::C_GraphicZone || type==Cluster::C_PictureZone || |
| 546 |
type==Cluster::C_SpreadsheetZone || type==Cluster::C_TextZone) |
| 547 |
m_document.send(id, MWAWListenerPtr(), pos); |
| 548 |
} |
| 549 |
return true; |
| 550 |
} |
| 551 |
|
| 552 |
//////////////////////////////////////////////////////////// |
| 553 |
// pattern cluster implementation |
| 554 |
//////////////////////////////////////////////////////////// |
| 555 |
std::string RagTime5ClusterManager::ClusterParser::getClusterDebugName(int id) |
| 556 |
{ |
| 557 |
return m_parser.getClusterDebugName(id); |
| 558 |
} |
| 559 |
|
| 560 |
bool RagTime5ClusterManager::ClusterParser::readLinkHeader(MWAWInputStreamPtr &input, long fSz, Link &link, long(&values)[4], std::string &msg) |
| 561 |
{ |
| 562 |
if (fSz<28) |
| 563 |
return false; |
| 564 |
long pos=input->tell(); |
| 565 |
std::stringstream s; |
| 566 |
link.m_fileType[0]=input->readULong(4); |
| 567 |
bool shortFixed=link.m_fileType[0]==0x3c052 || |
| 568 |
(fSz<30 && (link.m_fileType[0]==0x34800||link.m_fileType[0]==0x35800||link.m_fileType[0]==0x3e800)); |
| 569 |
if (shortFixed) { |
| 570 |
link.m_type=RagTime5ClusterManager::Link::L_LongList; |
| 571 |
link.m_fieldSize=4; |
| 572 |
} |
| 573 |
else if (fSz<30) { |
| 574 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 575 |
return false; |
| 576 |
} |
| 577 |
if (link.m_fileType[0]) |
| 578 |
s << "type1=" << RagTime5ClusterManager::printType(link.m_fileType[0]) << ","; |
| 579 |
values[0]=long(input->readULong(4)); |
| 580 |
if (values[0]) |
| 581 |
s << "f0=" << std::hex << values[0] << std::dec << ","; |
| 582 |
for (int i=1; i<3; ++i) { // always 0? |
| 583 |
values[i]=input->readLong(2); |
| 584 |
if (values[i]) s << "f" << i << "=" << values[i] << ","; |
| 585 |
} |
| 586 |
values[3]=long(input->readULong(4)); |
| 587 |
if (values[3]) s << "f3=" << std::hex << values[3] << std::dec << ","; |
| 588 |
link.m_fileType[1]=input->readULong(2); |
| 589 |
bool done=false; |
| 590 |
if (!shortFixed) { |
| 591 |
link.m_fieldSize=static_cast<int>(input->readULong(2)); |
| 592 |
if (link.m_fieldSize==0 || link.m_fieldSize==1 || link.m_fieldSize==0x100) { |
| 593 |
if (fSz<32) { |
| 594 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 595 |
return false; |
| 596 |
} |
| 597 |
input->seek(-2, librevenge::RVNG_SEEK_CUR); |
| 598 |
if (!RagTime5StructManager::readDataIdList(input, 2, link.m_ids) || !link.m_ids[1]) { |
| 599 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 600 |
return false; |
| 601 |
} |
| 602 |
link.m_fieldSize=0; |
| 603 |
link.m_type= RagTime5ClusterManager::Link::L_List; |
| 604 |
done=true; |
| 605 |
} |
| 606 |
else if ((link.m_fieldSize%2)!=0 || link.m_fieldSize>=0x100) { |
| 607 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 608 |
return false; |
| 609 |
} |
| 610 |
} |
| 611 |
if (!done && !RagTime5StructManager::readDataIdList(input, 1, link.m_ids)) { |
| 612 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 613 |
return false; |
| 614 |
} |
| 615 |
if ((link.m_ids[0]==0 && (link.m_fileType[1]&0x20)==0 && link.m_N) || |
| 616 |
(link.m_ids[0] && (link.m_fileType[1]&0x20)!=0)) { |
| 617 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 618 |
return false; |
| 619 |
} |
| 620 |
link.m_fileType[1] &=0xFFDF; |
| 621 |
|
| 622 |
msg=s.str(); |
| 623 |
return true; |
| 624 |
} |
| 625 |
|
| 626 |
namespace RagTime5ClusterManagerInternal |
| 627 |
{ |
| 628 |
|
| 629 |
// |
| 630 |
//! low level: parser of color pattern cluster : zone 0x8042 |
| 631 |
// |
| 632 |
struct ColPatCParser final : public RagTime5ClusterManager::ClusterParser { |
| 633 |
//! constructor |
| 634 |
explicit ColPatCParser(RagTime5ClusterManager &parser) |
| 635 |
: ClusterParser(parser, 0x8042, "ClustColPat") |
| 636 |
, m_cluster(new RagTime5ClusterManager::Cluster(RagTime5ClusterManager::Cluster::C_ColorPattern)) |
| 637 |
{ |
| 638 |
} |
| 639 |
//! destructor |
| 640 |
~ColPatCParser() final; |
| 641 |
//! return the current cluster |
| 642 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 643 |
{ |
| 644 |
return m_cluster; |
| 645 |
} |
| 646 |
//! parse a zone |
| 647 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 648 |
{ |
| 649 |
/* |
| 650 |
v5-v6.2 find only the header zone |
| 651 |
v6.5 find only header zone following by a link field (fSz=30) |
| 652 |
*/ |
| 653 |
if ((m_dataId==0&&flag!=0x30) || (m_dataId==1&&flag!=0x10) || m_dataId>=2) |
| 654 |
f << "fl=" << std::hex << flag << std::dec << ","; |
| 655 |
|
| 656 |
if (N==-5) { |
| 657 |
int val; |
| 658 |
if (m_dataId || (fSz!=82 && fSz!=86)) { |
| 659 |
f << "###data,"; |
| 660 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseZone: find unexpected field\n")); |
| 661 |
return false; |
| 662 |
} |
| 663 |
for (int i=0; i<2; ++i) { // always 0? |
| 664 |
val=static_cast<int>(input->readLong(2)); |
| 665 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 666 |
} |
| 667 |
auto type=input->readULong(4); |
| 668 |
if (type!=0x16a8042) f << "#fileType=" << RagTime5ClusterManager::printType(type) << ","; |
| 669 |
for (int i=0; i<2; ++i) { |
| 670 |
val=static_cast<int>(input->readLong(2)); |
| 671 |
if (val) f << "f" << i+3 << "=" << val << ","; |
| 672 |
} |
| 673 |
|
| 674 |
for (int wh=0; wh<2; ++wh) { |
| 675 |
long actPos=input->tell(); |
| 676 |
RagTime5ClusterManager::Link link; |
| 677 |
f << "link" << wh << "=["; |
| 678 |
val=static_cast<int>(input->readLong(2)); |
| 679 |
if (val!= 0x10) |
| 680 |
f << "f0=" << val << ","; |
| 681 |
link.m_N=static_cast<int>(input->readLong(4)); |
| 682 |
link.m_fileType[1]=input->readULong(4); |
| 683 |
if ((wh==0 && link.m_fileType[1]!=0x84040) || |
| 684 |
(wh==1 && link.m_fileType[1]!=0x16de842)) |
| 685 |
f << "#fileType=" << RagTime5ClusterManager::printType(link.m_fileType[1]) << ","; |
| 686 |
for (int i=0; i<7; ++i) { |
| 687 |
val=static_cast<int>(input->readLong(2)); // always 0? |
| 688 |
if (val) f << "f" << i+2 << "=" << val << ","; |
| 689 |
} |
| 690 |
link.m_fieldSize=static_cast<int>(input->readULong(2)); |
| 691 |
std::vector<int> listIds; |
| 692 |
if (!RagTime5StructManager::readDataIdList(input, 1, listIds)) { |
| 693 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseZone: can not read the data id\n")); |
| 694 |
f << "##link=" << link << "],"; |
| 695 |
input->seek(actPos+30, librevenge::RVNG_SEEK_SET); |
| 696 |
continue; |
| 697 |
} |
| 698 |
if (listIds[0]) { |
| 699 |
link.m_ids.push_back(listIds[0]); |
| 700 |
m_cluster->m_linksList.push_back(link); |
| 701 |
} |
| 702 |
f << link; |
| 703 |
f << "],"; |
| 704 |
} |
| 705 |
std::vector<int> listIds; |
| 706 |
if (!RagTime5StructManager::readDataIdList(input, 1, listIds)) { |
| 707 |
f << "##clusterIds"; |
| 708 |
return true; |
| 709 |
} |
| 710 |
if (listIds[0]) { |
| 711 |
m_cluster->m_clusterIdsList.push_back(listIds[0]); |
| 712 |
f << "clusterId1=" << getClusterDebugName(listIds[0]) << ","; |
| 713 |
} |
| 714 |
if (fSz==82) |
| 715 |
return true; |
| 716 |
val=static_cast<int>(input->readLong(4)); |
| 717 |
if (val!=2) |
| 718 |
f << "g0=" << val << ","; |
| 719 |
return true; |
| 720 |
} |
| 721 |
|
| 722 |
if (N<=0 || m_dataId!=1) { |
| 723 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseZone: find unexpected header N\n")); |
| 724 |
f << "###N=" << N << ","; |
| 725 |
return false; |
| 726 |
} |
| 727 |
if (fSz!=30) { |
| 728 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseZone: find unexpected data size\n")); |
| 729 |
f << "###fSz=" << fSz << ","; |
| 730 |
return false; |
| 731 |
} |
| 732 |
|
| 733 |
std::string mess; |
| 734 |
RagTime5ClusterManager::Link link; |
| 735 |
link.m_N=N; |
| 736 |
long linkValues[4]; // f0=2b|2d|85|93 |
| 737 |
if (readLinkHeader(input,fSz,link,linkValues,mess) && link.m_fieldSize==10) { |
| 738 |
if (link.m_fileType[1]!=0x40) |
| 739 |
f << "###fileType1=" << std::hex << link.m_fileType[1] << std::dec << ","; |
| 740 |
f << link << "," << mess; |
| 741 |
if (!link.empty()) |
| 742 |
m_cluster->m_linksList.push_back(link); |
| 743 |
} |
| 744 |
else { |
| 745 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseZone: can not read a link\n")); |
| 746 |
f << "###link" << link << ","; |
| 747 |
} |
| 748 |
return true; |
| 749 |
} |
| 750 |
//! parse a field |
| 751 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 752 |
{ |
| 753 |
if (m_dataId==0 && field.m_type==RagTime5StructManager::Field::T_FieldList && (field.m_fileType==0x16be055 || field.m_fileType==0x16be065)) { |
| 754 |
f << "unk" << (field.m_fileType==0x16be055 ? "0" : "1") << "="; |
| 755 |
for (auto const &child : field.m_fieldList) { |
| 756 |
if (child.m_type==RagTime5StructManager::Field::T_Long && child.m_fileType==0xcf817) { |
| 757 |
f << child.m_longValue[0] << ","; |
| 758 |
continue; |
| 759 |
} |
| 760 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseField: find unexpected color/pattern child field\n")); |
| 761 |
f << "#[" << child << "],"; |
| 762 |
} |
| 763 |
} |
| 764 |
else { |
| 765 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::ColPatCParser::parseField: find unexpected sub field\n")); |
| 766 |
f << "#" << field; |
| 767 |
} |
| 768 |
return true; |
| 769 |
} |
| 770 |
protected: |
| 771 |
//! the current cluster |
| 772 |
std::shared_ptr<RagTime5ClusterManager::Cluster> m_cluster; |
| 773 |
}; |
| 774 |
|
| 775 |
ColPatCParser::~ColPatCParser() |
| 776 |
{ |
| 777 |
} |
| 778 |
|
| 779 |
// |
| 780 |
//! try to read a root cluster: 4001 |
| 781 |
// |
| 782 |
struct RootCParser final : public RagTime5ClusterManager::ClusterParser { |
| 783 |
enum { F_formulaLink=0, F_clusterList, F_functionName=F_clusterList+3, F_docInfo, F_filename, |
| 784 |
F_nextId, F_settings, F_settingsRoot=F_settings+3, F_unknRootA, F_unknRootC=F_unknRootA+3, F_unknRootD, F_unknUnicodeD, F_unknUnicodeE |
| 785 |
}; |
| 786 |
//! constructor |
| 787 |
explicit RootCParser(RagTime5ClusterManager &parser) |
| 788 |
: ClusterParser(parser, 0, "ClustRoot") |
| 789 |
, m_cluster(new RagTime5ClusterManager::ClusterRoot) |
| 790 |
, m_what(-1) |
| 791 |
, m_linkId(-1) |
| 792 |
, m_fieldName("") |
| 793 |
|
| 794 |
, m_expectedIdToType() |
| 795 |
, m_idStack() |
| 796 |
{ |
| 797 |
} |
| 798 |
//! destructor |
| 799 |
~RootCParser() final; |
| 800 |
//! set a data id type |
| 801 |
void setExpectedType(int id, int type) |
| 802 |
{ |
| 803 |
m_expectedIdToType[id]=type; |
| 804 |
m_idStack.push(id); |
| 805 |
} |
| 806 |
/** returns to new zone to parse. -1: means no preference, 0: means first zone, ... */ |
| 807 |
int getNewZoneToParse() final |
| 808 |
{ |
| 809 |
if (m_idStack.empty()) |
| 810 |
return -1; |
| 811 |
int id=m_idStack.top(); |
| 812 |
m_idStack.pop(); |
| 813 |
return id; |
| 814 |
} |
| 815 |
//! return the current cluster |
| 816 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 817 |
{ |
| 818 |
return m_cluster; |
| 819 |
} |
| 820 |
//! end of a start zone call |
| 821 |
void endZone() final |
| 822 |
{ |
| 823 |
if (m_link.empty()) |
| 824 |
return; |
| 825 |
if (m_dataId==0) { |
| 826 |
if (m_cluster->m_dataLink.empty()) |
| 827 |
m_cluster->m_dataLink=m_link; |
| 828 |
else { |
| 829 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::endZone: oops the main link is already set\n")); |
| 830 |
m_cluster->m_linksList.push_back(m_link); |
| 831 |
} |
| 832 |
} |
| 833 |
else if (m_what==3) |
| 834 |
m_cluster->m_graphicTypeLink=m_link; |
| 835 |
else { |
| 836 |
bool ok=true; |
| 837 |
switch (m_linkId) { |
| 838 |
case 0: |
| 839 |
ok=m_cluster->m_listClusterName.empty(); |
| 840 |
m_cluster->m_listClusterName=RagTime5ClusterManager::NameLink(m_link); |
| 841 |
break; |
| 842 |
case 1: |
| 843 |
ok=m_cluster->m_docInfoLink.empty(); |
| 844 |
m_cluster->m_docInfoLink=m_link; |
| 845 |
break; |
| 846 |
case 2: |
| 847 |
ok=m_cluster->m_linkUnknown.empty(); |
| 848 |
m_cluster->m_linkUnknown=m_link; |
| 849 |
break; |
| 850 |
case 3: |
| 851 |
m_cluster->m_settingLinks.push_back(m_link); |
| 852 |
break; |
| 853 |
case 4: |
| 854 |
ok=m_cluster->m_functionNameLink.empty(); |
| 855 |
m_cluster->m_functionNameLink=m_link; |
| 856 |
break; |
| 857 |
case 5: |
| 858 |
case 6: |
| 859 |
case 7: |
| 860 |
ok=m_cluster->m_listClusterLink[m_linkId-5].empty(); |
| 861 |
m_cluster->m_listClusterLink[m_linkId-5]=m_link; |
| 862 |
break; |
| 863 |
case 8: |
| 864 |
ok=m_cluster->m_listUnicodeLink.empty(); |
| 865 |
m_cluster->m_listUnicodeLink=m_link; |
| 866 |
break; |
| 867 |
default: |
| 868 |
m_cluster->m_linksList.push_back(m_link); |
| 869 |
} |
| 870 |
if (!ok) { |
| 871 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::endZone: oops link %d is already set\n", m_linkId)); |
| 872 |
} |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
//! parse the header zone |
| 877 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 878 |
{ |
| 879 |
m_what=m_linkId=-1; |
| 880 |
m_fieldName=""; |
| 881 |
if (m_dataId==0) |
| 882 |
return parseHeaderZone(input, fSz, N, flag, f); |
| 883 |
if (isANameHeader(N)) { |
| 884 |
auto const &it=m_expectedIdToType.find(m_dataId); |
| 885 |
if (it==m_expectedIdToType.end() || it->second!=F_filename) { |
| 886 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseZone: expected n seems bad\n")); |
| 887 |
f << "###expected,"; |
| 888 |
} |
| 889 |
else |
| 890 |
f << "[F" << m_dataId << "]"; |
| 891 |
f << "fileName,"; |
| 892 |
m_fieldName="filename"; |
| 893 |
m_what=1; |
| 894 |
return true; |
| 895 |
} |
| 896 |
if (N<0) { |
| 897 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseZone: expected N value\n")); |
| 898 |
f << "###N=" << N << ","; |
| 899 |
return true; |
| 900 |
} |
| 901 |
return parseDataZone(input, fSz, N, flag, f); |
| 902 |
} |
| 903 |
//! parse a field |
| 904 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 905 |
{ |
| 906 |
if (!m_fieldName.empty()) |
| 907 |
f << m_fieldName << ","; |
| 908 |
switch (m_what) { |
| 909 |
case 0: // main |
| 910 |
if (field.m_type==RagTime5StructManager::Field::T_ZoneId && field.m_fileType==0x14510b7) { |
| 911 |
if (field.m_longValue[0]) { |
| 912 |
m_cluster->m_styleClusterIds[7]=static_cast<int>(field.m_longValue[0]); |
| 913 |
f << "col/pattern[id]=dataA" << field.m_longValue[0] << ","; |
| 914 |
} |
| 915 |
break; |
| 916 |
} |
| 917 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0x3c057) { |
| 918 |
for (auto const &id : field.m_longList) |
| 919 |
f << "unkn0=" << id << ","; // small number between 8 and 10 |
| 920 |
break; |
| 921 |
} |
| 922 |
if (field.m_type==RagTime5StructManager::Field::T_FieldList && field.m_fileType==0x1451025) { |
| 923 |
f << "decal=["; |
| 924 |
for (auto const &child : field.m_fieldList) { |
| 925 |
if (child.m_type==RagTime5StructManager::Field::T_Unstructured && child.m_fileType==0xce017) { |
| 926 |
// can be very long, seems to contain more 0 than 1 |
| 927 |
f << "unkn1="<<child.m_extra << ","; |
| 928 |
continue; |
| 929 |
} |
| 930 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected decal child[main]\n")); |
| 931 |
f << "###[" << child << "],"; |
| 932 |
} |
| 933 |
f << "],"; |
| 934 |
break; |
| 935 |
} |
| 936 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected child[main]\n")); |
| 937 |
f << "###" << field << ","; |
| 938 |
break; |
| 939 |
case 1: // filename |
| 940 |
if (field.m_type==RagTime5StructManager::Field::T_Unicode && field.m_fileType==0xc8042) { |
| 941 |
m_cluster->m_fileName=field.m_string.cstr(); |
| 942 |
f << field.m_string.cstr(); |
| 943 |
break; |
| 944 |
} |
| 945 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected filename field\n")); |
| 946 |
f << "###" << field << ","; |
| 947 |
break; |
| 948 |
case 2: // list |
| 949 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xce842) { |
| 950 |
f << "pos=["; |
| 951 |
for (auto val : field.m_longList) { |
| 952 |
if (val==0) |
| 953 |
f << "_,"; |
| 954 |
else if (val>1000) |
| 955 |
f << std::hex << val << std::dec << ","; |
| 956 |
else |
| 957 |
f << val << ","; |
| 958 |
} |
| 959 |
f << "],"; |
| 960 |
m_link.m_longList=field.m_longList; |
| 961 |
break; |
| 962 |
} |
| 963 |
if (field.m_type==RagTime5StructManager::Field::T_Unstructured && field.m_fileType==0xce017) { |
| 964 |
// a small value 2|4|a|1c|40 |
| 965 |
f << "unkn="<<field.m_extra << ","; |
| 966 |
break; |
| 967 |
} |
| 968 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected list link field\n")); |
| 969 |
f << "###" << field << ","; |
| 970 |
break; |
| 971 |
case 3: // graph type |
| 972 |
if (field.m_type==RagTime5StructManager::Field::T_FieldList && field.m_fileType==0x14eb015) { |
| 973 |
f << "decal=["; |
| 974 |
for (auto const &child : field.m_fieldList) { |
| 975 |
if (child.m_type==RagTime5StructManager::Field::T_LongList && child.m_fileType==0xce842) { |
| 976 |
for (auto val : child.m_longList) { |
| 977 |
if (val==0) |
| 978 |
f << "_,"; |
| 979 |
else if (val>1000) |
| 980 |
f << std::hex << val << std::dec << ","; |
| 981 |
else |
| 982 |
f << val << ","; |
| 983 |
} |
| 984 |
m_link.m_longList=child.m_longList; |
| 985 |
continue; |
| 986 |
} |
| 987 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected decal child[graphType]\n")); |
| 988 |
f << "###[" << child << "],"; |
| 989 |
} |
| 990 |
f << "],"; |
| 991 |
break; |
| 992 |
} |
| 993 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected graph type field\n")); |
| 994 |
f << "###" << field << ","; |
| 995 |
break; |
| 996 |
case 4: |
| 997 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0x154f017) { |
| 998 |
f << "values=["; // find 1,1,2 |
| 999 |
for (auto val : field.m_longList) f << val << ","; |
| 1000 |
f << "],"; |
| 1001 |
break; |
| 1002 |
} |
| 1003 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected child[formulaLink]\n")); |
| 1004 |
f << "###" << field << ","; |
| 1005 |
break; |
| 1006 |
default: |
| 1007 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected field\n")); |
| 1008 |
f << "###" << field << ","; |
| 1009 |
break; |
| 1010 |
} |
| 1011 |
return true; |
| 1012 |
} |
| 1013 |
protected: |
| 1014 |
//! parse a data block |
| 1015 |
bool parseDataZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) |
| 1016 |
{ |
| 1017 |
auto const &it=m_expectedIdToType.find(m_dataId); |
| 1018 |
int expected=(it!=m_expectedIdToType.end())?it->second : -1; |
| 1019 |
if (expected!=-1) |
| 1020 |
f << "[F" << m_dataId << "]"; |
| 1021 |
if (flag!=0x10) f << "fl=" << std::hex << flag << std::dec << ","; |
| 1022 |
m_link.m_N=N; |
| 1023 |
switch (expected) { |
| 1024 |
case F_docInfo: |
| 1025 |
case F_formulaLink: |
| 1026 |
case F_unknRootA: |
| 1027 |
case F_unknRootA+1: |
| 1028 |
case F_unknRootA+2: |
| 1029 |
case F_clusterList: |
| 1030 |
case F_clusterList+1: |
| 1031 |
case F_clusterList+2: |
| 1032 |
case F_functionName: |
| 1033 |
case F_settings: |
| 1034 |
case F_settings+1: |
| 1035 |
case F_settings+2: |
| 1036 |
case F_unknRootC: |
| 1037 |
case F_unknUnicodeD: |
| 1038 |
case F_unknUnicodeE: { |
| 1039 |
std::string mess; |
| 1040 |
long linkValues[4]; |
| 1041 |
if (fSz<28 || !readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1042 |
f << "###fType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 1043 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: the expected field[%d] seems bad\n", expected)); |
| 1044 |
return true; |
| 1045 |
} |
| 1046 |
|
| 1047 |
m_what=2; |
| 1048 |
f << m_link << "," << mess; |
| 1049 |
long expectedFileType1=0, expectedFieldSize=0; |
| 1050 |
if ((expected==F_settings||expected==F_unknRootA) && m_link.m_fileType[0]==0x3e800) |
| 1051 |
m_link.m_name= expected==F_unknRootA ? "unknRootA0" : "settingList0"; |
| 1052 |
else if ((expected==F_settings+1 || expected==F_clusterList+1) && m_link.m_fileType[0]==0x35800) |
| 1053 |
m_link.m_name= expected==F_settings+1 ? "settingList1" : "nameIdToPos"; |
| 1054 |
else if (expected==F_settings+2 && m_link.m_fileType[0]==0x47040) { |
| 1055 |
m_linkId=3; |
| 1056 |
m_link.m_name="settings"; |
| 1057 |
} |
| 1058 |
else if ((expected==F_formulaLink||expected==F_unknRootA+2) && fSz==30) { |
| 1059 |
expectedFileType1=0; |
| 1060 |
expectedFieldSize=4; |
| 1061 |
m_linkId=expected==F_formulaLink ? 6 : 7; |
| 1062 |
m_link.m_name=expected==F_formulaLink?"formulaLink" : "unknRootA2"; |
| 1063 |
} |
| 1064 |
else if (expected==F_unknRootA+1 && m_link.m_fileType[0]==0x35800) { |
| 1065 |
m_link.m_name="unknRootA1"; |
| 1066 |
} |
| 1067 |
else if (expected==F_clusterList && fSz==32) { |
| 1068 |
if (linkValues[0]!=0x7d01a) { |
| 1069 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: unexpected type for zone[name]\n")); |
| 1070 |
f << "##fileType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 1071 |
} |
| 1072 |
m_linkId=0; |
| 1073 |
expectedFileType1=0x200; |
| 1074 |
m_link.m_name="names[cluster]"; |
| 1075 |
} |
| 1076 |
else if (expected==F_clusterList+2 && fSz==30) { |
| 1077 |
if (linkValues[0]) { |
| 1078 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: bad expected linkValues for cluster list id\n")); |
| 1079 |
f << "##linkValues,"; |
| 1080 |
} |
| 1081 |
if ((m_link.m_fileType[1]&0xFFD7)!=0x40 || m_link.m_fieldSize!=8) { |
| 1082 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: find odd definition for cluster list id\n")); |
| 1083 |
f << "##[" << std::hex << m_link.m_fileType[1] << std::dec << ":" << m_link.m_fieldSize << "],"; |
| 1084 |
} |
| 1085 |
m_cluster->m_listClusterId=m_link.m_ids[0]; |
| 1086 |
m_link=RagTime5ClusterManager::Link(); |
| 1087 |
m_link.m_name="clusterList"; |
| 1088 |
} |
| 1089 |
else if (expected==F_functionName && fSz==32) { |
| 1090 |
m_linkId=4; |
| 1091 |
m_link.m_name="functionName"; |
| 1092 |
} |
| 1093 |
else if (expected==F_docInfo && fSz==32) { |
| 1094 |
m_linkId=1; |
| 1095 |
expectedFileType1=0x8010; |
| 1096 |
m_link.m_name="docInfo"; |
| 1097 |
} |
| 1098 |
else if (expected==F_unknRootC && fSz==32) { |
| 1099 |
m_linkId=2; |
| 1100 |
expectedFileType1=0xc010; |
| 1101 |
m_link.m_name="rootUnknC"; // a list, but never find any data |
| 1102 |
} |
| 1103 |
else if (expected==F_unknUnicodeD && fSz==32) { |
| 1104 |
m_what=2; |
| 1105 |
m_linkId=8; |
| 1106 |
expectedFileType1=0x310; |
| 1107 |
m_link.m_name="rootUnicodeLst"; |
| 1108 |
} |
| 1109 |
else if (expected==F_unknUnicodeE && fSz==32) { |
| 1110 |
// checkme an unicode string ? |
| 1111 |
m_what=2; |
| 1112 |
expectedFileType1=0x200; |
| 1113 |
m_link.m_name="rootUnicodeLst"; |
| 1114 |
} |
| 1115 |
else { |
| 1116 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: the expected field[%d] seems bad\n", expected)); |
| 1117 |
f << "###"; |
| 1118 |
} |
| 1119 |
if (!m_link.m_name.empty()) { |
| 1120 |
f << m_link.m_name << ","; |
| 1121 |
m_fieldName=m_link.m_name; |
| 1122 |
} |
| 1123 |
if (expectedFileType1>0 && long(m_link.m_fileType[1]&0xFFD7)!=expectedFileType1) { |
| 1124 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: the expected field[%d] fileType1 seems odd\n", expected)); |
| 1125 |
f << "###fileType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 1126 |
} |
| 1127 |
if (expectedFieldSize>0 && m_link.m_fieldSize!=expectedFieldSize) { |
| 1128 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: fieldSize seems odd[%d]\n", expected)); |
| 1129 |
f << "###fieldSize,"; |
| 1130 |
} |
| 1131 |
return true; |
| 1132 |
} |
| 1133 |
case F_settingsRoot: { |
| 1134 |
if (fSz<38) { |
| 1135 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: unexpected data of size for setting root\n")); |
| 1136 |
f << "##fSz,"; |
| 1137 |
return true; |
| 1138 |
} |
| 1139 |
m_fieldName="settings[root]"; |
| 1140 |
f << "settings[root],"; |
| 1141 |
int val=static_cast<int>(input->readULong(4)); |
| 1142 |
if (val!=0x47040) { |
| 1143 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: unexpected data of for setting root\n")); |
| 1144 |
f << "##fileType=" << std::hex << val << std::dec << ","; |
| 1145 |
} |
| 1146 |
for (int i=0; i<6; ++i) { // always 0 |
| 1147 |
val=static_cast<int>(input->readLong(2)); |
| 1148 |
if (val) f << "f" << i << "=" << val << ","; |
| 1149 |
} |
| 1150 |
val=static_cast<int>(input->readULong(2)); |
| 1151 |
if ((val&0xFFD7)!=0x10) { |
| 1152 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: unexpected fileType1 for setting roots\n")); |
| 1153 |
f << "##fileType1=" << std::hex << val << std::dec << ","; |
| 1154 |
} |
| 1155 |
f << "ids=["; |
| 1156 |
for (int i=0; i<3; ++i) { // small int, often with f1=f0+1, f2=f1+1 |
| 1157 |
val=static_cast<int>(input->readULong(4)); |
| 1158 |
if (!val) { |
| 1159 |
f << "_,"; |
| 1160 |
continue; |
| 1161 |
} |
| 1162 |
setExpectedType(val-1,F_settings+i); |
| 1163 |
f << "F" << val-1 << ","; |
| 1164 |
} |
| 1165 |
f << "],"; |
| 1166 |
val=static_cast<int>(input->readULong(2)); // always 0? |
| 1167 |
if (val) f << "f0=" << val << ","; |
| 1168 |
return true; |
| 1169 |
} |
| 1170 |
case F_nextId: |
| 1171 |
break; |
| 1172 |
default: |
| 1173 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected zone\n")); |
| 1174 |
f << "###"; |
| 1175 |
break; |
| 1176 |
} |
| 1177 |
if (fSz<4) { |
| 1178 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseField: find unexpected short zone\n")); |
| 1179 |
f << "###fSz"; |
| 1180 |
return true; |
| 1181 |
} |
| 1182 |
// linked data size=26|32|52|78 |
| 1183 |
int val=static_cast<int>(input->readULong(4)); // small number or 0: related to the number in cluster list? |
| 1184 |
if (val) { |
| 1185 |
setExpectedType(val-1,F_nextId); |
| 1186 |
f << "next[id]=F" << val-1 << ","; |
| 1187 |
} |
| 1188 |
switch (fSz) { |
| 1189 |
case 26: |
| 1190 |
m_fieldName="graphPrefs"; |
| 1191 |
m_link.m_fileType[0]=input->readULong(4); |
| 1192 |
if (m_link.m_fileType[0]!=0x14b4042) { |
| 1193 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: unexpected type for block1a\n")); |
| 1194 |
f << "##fileType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 1195 |
} |
| 1196 |
for (int i=0; i<6; ++i) { |
| 1197 |
val=static_cast<int>(input->readLong(2)); |
| 1198 |
int const expectedV[]= {0,0,0,0,12,0}; |
| 1199 |
if (val==expectedV[i]) |
| 1200 |
continue; |
| 1201 |
if (i==2) |
| 1202 |
f << "grid[start]=" << val << ","; |
| 1203 |
else if (i==4) |
| 1204 |
f << "grid[sep]=" << val << ","; |
| 1205 |
else |
| 1206 |
f << "f" << i << "=" << val << ","; |
| 1207 |
} |
| 1208 |
break; |
| 1209 |
case 30: |
| 1210 |
val=static_cast<int>(input->readULong(4)); |
| 1211 |
if (val==0x15e5042) { |
| 1212 |
// first near n=9, second near n=15 with no other data |
| 1213 |
// no auxilliar data expected |
| 1214 |
m_fieldName="unknDataD"; |
| 1215 |
for (int i=0; i<4; ++i) { // f0, f3: small number |
| 1216 |
val=static_cast<int>(input->readULong(4)); |
| 1217 |
if (!val) continue; |
| 1218 |
if (i==3) { |
| 1219 |
setExpectedType(val-1,F_unknUnicodeD); |
| 1220 |
f << "unicode=F" << val-1 << ","; |
| 1221 |
} |
| 1222 |
else |
| 1223 |
f << "f" << i << "=" << val << ","; |
| 1224 |
} |
| 1225 |
break; |
| 1226 |
} |
| 1227 |
f << "###fUnknD"; |
| 1228 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: the field unknown d bad\n")); |
| 1229 |
break; |
| 1230 |
case 52: |
| 1231 |
m_what=3; |
| 1232 |
m_fieldName="graphTypes"; |
| 1233 |
if (N!=1) f << "##N=" << N << ","; |
| 1234 |
m_link.m_fileType[0]=input->readULong(4); |
| 1235 |
if (m_link.m_fileType[0]!=0x14e6042) { |
| 1236 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone[graph]: find unexpected fileType\n")); |
| 1237 |
f << "###fileType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 1238 |
} |
| 1239 |
for (int i=0; i<14; ++i) { // g1=0-2, g2=10[size?], g4=1-8[N], g13=30 |
| 1240 |
val=static_cast<int>(input->readLong(2)); |
| 1241 |
if (val) f << "g" << i << "=" << val << ","; |
| 1242 |
} |
| 1243 |
if (RagTime5StructManager::readDataIdList(input, 2, m_link.m_ids) && m_link.m_ids[1]) { |
| 1244 |
m_link.m_fileType[1]=0x30; |
| 1245 |
m_link.m_fieldSize=16; |
| 1246 |
} |
| 1247 |
val=static_cast<int>(input->readLong(2)); |
| 1248 |
if (val) // small number |
| 1249 |
f << "h0=" << val << ","; |
| 1250 |
break; |
| 1251 |
case 78: { |
| 1252 |
m_what=4; |
| 1253 |
m_fieldName="formulaLink"; |
| 1254 |
if (N!=1) f << "##N=" << N << ","; |
| 1255 |
auto type=input->readULong(4); |
| 1256 |
if (type!=0x154a042) { |
| 1257 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: find odd type for fSz=78\n")); |
| 1258 |
f << "##[" << RagTime5ClusterManager::printType(type) << ":" << m_link.m_fieldSize << "],"; |
| 1259 |
} |
| 1260 |
for (int i=0; i<2; ++i) { // always 0 |
| 1261 |
val=static_cast<int>(input->readULong(2)); |
| 1262 |
if (val) |
| 1263 |
f << "f" << i << "=" << val << ","; |
| 1264 |
} |
| 1265 |
std::vector<int> listIds; |
| 1266 |
long actPos=input->tell(); |
| 1267 |
if (!RagTime5StructManager::readDataIdList(input, 2, listIds)) { |
| 1268 |
f << "###fieldId,"; |
| 1269 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: can not read field ids\n")); |
| 1270 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1271 |
} |
| 1272 |
else if (listIds[0] || listIds[1]) { // formuladef and formulapos |
| 1273 |
RagTime5ClusterManager::Link formulaLink; |
| 1274 |
formulaLink.m_type= RagTime5ClusterManager::Link::L_ClusterLink; |
| 1275 |
formulaLink.m_ids=listIds; |
| 1276 |
m_cluster->m_formulaLink=formulaLink; |
| 1277 |
f << "buttons," << formulaLink << ","; |
| 1278 |
} |
| 1279 |
val=static_cast<int>(input->readULong(4)); |
| 1280 |
if (val) { |
| 1281 |
setExpectedType(val-1,F_formulaLink); |
| 1282 |
f << "clusterLink=F" << val-1 << ","; |
| 1283 |
} |
| 1284 |
for (int i=0; i<4; ++i) { // always 0 |
| 1285 |
val=static_cast<int>(input->readULong(2)); |
| 1286 |
if (val) |
| 1287 |
f << "f" << i+2 << "=" << val << ","; |
| 1288 |
} |
| 1289 |
for (int i=0; i<2; ++i) { // always 1,0 |
| 1290 |
val=static_cast<int>(input->readULong(1)); |
| 1291 |
if (val!=1-i) |
| 1292 |
f << "fl" << i << "=" << val << ","; |
| 1293 |
} |
| 1294 |
val=static_cast<int>(input->readLong(2)); |
| 1295 |
if (val!=100) |
| 1296 |
f << "f6=" << val << ","; |
| 1297 |
f << "marg?=["; |
| 1298 |
for (int i=0; i<2; ++i) { |
| 1299 |
actPos=input->tell(); |
| 1300 |
double res; |
| 1301 |
bool isNan; |
| 1302 |
if (input->readDouble8(res, isNan)) // typically 0.01 |
| 1303 |
f << res << ","; |
| 1304 |
else { |
| 1305 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: can not read a double\n")); |
| 1306 |
f << "##double,"; |
| 1307 |
input->seek(actPos+8, librevenge::RVNG_SEEK_SET); |
| 1308 |
} |
| 1309 |
f << ","; |
| 1310 |
} |
| 1311 |
f << "],"; |
| 1312 |
listIds.clear(); |
| 1313 |
actPos=input->tell(); |
| 1314 |
if (!RagTime5StructManager::readDataIdList(input, 4, listIds)) { |
| 1315 |
f << "###clusterCId,"; |
| 1316 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: can not read clusterC ids\n")); |
| 1317 |
input->seek(actPos+16, librevenge::RVNG_SEEK_SET); |
| 1318 |
} |
| 1319 |
else if (listIds[0] || listIds[1] || listIds[2] || listIds[3]) { |
| 1320 |
RagTime5ClusterManager::Link fieldLink; |
| 1321 |
fieldLink.m_type= RagTime5ClusterManager::Link::L_UnknownClusterC; |
| 1322 |
fieldLink.m_ids=listIds; |
| 1323 |
m_cluster->m_linksList.push_back(fieldLink); |
| 1324 |
f << fieldLink << ","; |
| 1325 |
} |
| 1326 |
|
| 1327 |
val=static_cast<int>(input->readULong(4)); |
| 1328 |
if (val) { |
| 1329 |
setExpectedType(val-1,F_functionName); |
| 1330 |
f << "functionName=F" << val-1 << ","; |
| 1331 |
} |
| 1332 |
break; |
| 1333 |
} |
| 1334 |
default: |
| 1335 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseDataZone: find unexpected data field\n")); |
| 1336 |
f << "###N=" << N << ",fSz=" << fSz << ","; |
| 1337 |
} |
| 1338 |
if (!m_fieldName.empty()) |
| 1339 |
f << m_fieldName << ","; |
| 1340 |
return true; |
| 1341 |
} |
| 1342 |
|
| 1343 |
//! parse the header zone |
| 1344 |
bool parseHeaderZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) |
| 1345 |
{ |
| 1346 |
f << "header, fl=" << std::hex << flag << std::dec << ","; |
| 1347 |
m_fieldName="header"; |
| 1348 |
if (N!=-2 || m_dataId!=0 || (fSz!=215 && fSz!=220)) { |
| 1349 |
f << "###N=" << N << ",fSz=" << fSz << ","; |
| 1350 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseHeaderZone: find unexpected main field\n")); |
| 1351 |
return true; |
| 1352 |
} |
| 1353 |
m_what=0; |
| 1354 |
auto val=static_cast<int>(input->readLong(4)); // 8|9|a |
| 1355 |
if (val) { |
| 1356 |
setExpectedType(val-1,F_nextId); |
| 1357 |
f << "next[id]=F" << val-1 << ","; |
| 1358 |
} |
| 1359 |
for (int i=0; i<4; ++i) { // f2=0-7, f3=1|3 |
| 1360 |
val=static_cast<int>(input->readLong(2)); |
| 1361 |
if (val) f << "f" << i+2 << "=" << val << ","; |
| 1362 |
} |
| 1363 |
val=static_cast<int>(input->readLong(4)); // 7|8 |
| 1364 |
setExpectedType(val-1,F_filename); |
| 1365 |
f << "filename=F" << val-1 << ","; |
| 1366 |
std::vector<int> listIds; |
| 1367 |
long actPos=input->tell(); |
| 1368 |
if (!RagTime5StructManager::readDataIdList(input, 1, listIds) || !listIds[0]) { |
| 1369 |
f << "###cluster[child],"; |
| 1370 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseHeaderZone: can not find the cluster's child\n")); |
| 1371 |
input->seek(actPos+4, librevenge::RVNG_SEEK_SET); |
| 1372 |
} |
| 1373 |
else { // link to unknown cluster zone |
| 1374 |
m_cluster->m_clusterIds[0]=listIds[0]; |
| 1375 |
f << "unknClustB=data" << listIds[0] << "A,"; |
| 1376 |
} |
| 1377 |
for (int i=0; i<18; ++i) { // always g0=g11=g16=16, other 0 ? |
| 1378 |
val=static_cast<int>(input->readLong((i==12 || i==13 || i==14) ? 4 : 2)); |
| 1379 |
if (!val) continue; |
| 1380 |
if (i>=12 && i<=14) { |
| 1381 |
setExpectedType(val-1,F_unknRootA+(i-12)); |
| 1382 |
f << "unknRootA" << i-12 << "=F" << val-1 << ","; |
| 1383 |
} |
| 1384 |
else |
| 1385 |
f << "g" << i << "=" << val << ","; |
| 1386 |
} |
| 1387 |
auto type=input->readULong(4); |
| 1388 |
if (type!=0x3c052) |
| 1389 |
f << "#fileType=" << RagTime5ClusterManager::printType(type) << ","; |
| 1390 |
for (int i=0; i<9; ++i) { // always h6=6 |
| 1391 |
val=static_cast<int>(input->readLong(2)); |
| 1392 |
if (val) f << "h" << i << "=" << val << ","; |
| 1393 |
} |
| 1394 |
for (int i=0; i<3; ++i) { // can be 1,11,10 |
| 1395 |
val=static_cast<int>(input->readULong(1)); |
| 1396 |
if (val) |
| 1397 |
f << "fl" << i << "=" << std::hex << val << std::dec << ","; |
| 1398 |
} |
| 1399 |
if (fSz==220) { |
| 1400 |
for (int i=0; i<2; ++i) { // h10=1, h11=16 |
| 1401 |
val=static_cast<int>(input->readLong(2)); |
| 1402 |
if (val) f << "h" << i+9 << "=" << val << ","; |
| 1403 |
} |
| 1404 |
val=static_cast<int>(input->readLong(1)); |
| 1405 |
if (val) f << "h11=" << val << ","; |
| 1406 |
} |
| 1407 |
val=static_cast<int>(input->readLong(4)); // e-5a |
| 1408 |
if (val) f << "N2=" << val << ","; |
| 1409 |
for (int i=0; i<9; ++i) { // j8=18 |
| 1410 |
val=static_cast<int>(input->readLong(2)); |
| 1411 |
if (val) f << "j" << i << "=" << val << ","; |
| 1412 |
} |
| 1413 |
for (int i=0; i<3; ++i) { |
| 1414 |
val=static_cast<int>(input->readLong(4)); |
| 1415 |
setExpectedType(val-1,F_clusterList+i); |
| 1416 |
if (val!=i+2) |
| 1417 |
f << "cluster" << i << "=[F" << val-1 << "],"; |
| 1418 |
} |
| 1419 |
actPos=input->tell(); |
| 1420 |
listIds.clear(); |
| 1421 |
if (!RagTime5StructManager::readDataIdList(input, 4, listIds)) { |
| 1422 |
f << "###style[child],"; |
| 1423 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseHeaderZone: can not find the style's child\n")); |
| 1424 |
input->seek(actPos+16, librevenge::RVNG_SEEK_SET); |
| 1425 |
} |
| 1426 |
else { |
| 1427 |
for (size_t i=0; i<4; ++i) { |
| 1428 |
if (listIds[i]==0) continue; |
| 1429 |
m_cluster->m_styleClusterIds[i]=listIds[i]; |
| 1430 |
static char const *wh[]= { "graph", "units", "units2", "text" }; |
| 1431 |
f << wh[i] << "Style=data" << listIds[i] << "A,"; |
| 1432 |
} |
| 1433 |
} |
| 1434 |
val=static_cast<int>(input->readLong(4)); // always 5? |
| 1435 |
if (val) { |
| 1436 |
setExpectedType(val-1,F_settingsRoot); |
| 1437 |
f << "settings[root]=F" << val-1 << ","; |
| 1438 |
} |
| 1439 |
actPos=input->tell(); |
| 1440 |
listIds.clear(); |
| 1441 |
if (!RagTime5StructManager::readDataIdList(input, 3, listIds)) { |
| 1442 |
f << "###style[child],"; |
| 1443 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseHeaderZone: can not find the style2's child\n")); |
| 1444 |
input->seek(actPos+12, librevenge::RVNG_SEEK_SET); |
| 1445 |
} |
| 1446 |
else { |
| 1447 |
for (size_t i=0; i<3; ++i) { |
| 1448 |
if (listIds[i]==0) continue; |
| 1449 |
m_cluster->m_styleClusterIds[i+4]=listIds[i]; |
| 1450 |
static char const *wh[]= { "format", "#unk", "graphColor" }; |
| 1451 |
f << wh[i] << "Style=data" << listIds[i] << "A,"; |
| 1452 |
} |
| 1453 |
} |
| 1454 |
for (int i=0; i<6; ++i) { // k6=0|6, k7=0|7 |
| 1455 |
val=static_cast<int>(input->readULong(4)); // maybe some dim |
| 1456 |
static int const expected[]= {0xc000, 0x2665, 0xc000, 0x2665, 0xc000, 0xc000}; |
| 1457 |
if (val==expected[i]) continue; |
| 1458 |
f << "k" << i << "=" << std::hex << val << std::dec << ","; |
| 1459 |
} |
| 1460 |
for (int i=0; i<3; ++i) { |
| 1461 |
val=static_cast<int>(input->readULong(4)); // maybe some dim |
| 1462 |
if (!val) continue; |
| 1463 |
int const what[]= { F_docInfo, F_unknRootC, F_unknRootD }; |
| 1464 |
setExpectedType(val-1,what[i]); |
| 1465 |
if (i==2) { |
| 1466 |
f << "##"; |
| 1467 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseHeaderZone: find unknown root D node\n")); |
| 1468 |
} |
| 1469 |
char const *wh[]= {"docInfo", "unknRootC", "unknRootD" }; |
| 1470 |
f << wh[i] << "=F" << val-1 << ","; |
| 1471 |
} |
| 1472 |
for (int i=0; i<2; ++i) { // l0=0|1|2, l1=0|1 |
| 1473 |
val=static_cast<int>(input->readLong(2)); // 0|1|2 |
| 1474 |
if (val) |
| 1475 |
f << "l" << i <<"=" << val << ","; |
| 1476 |
} |
| 1477 |
// a very big number |
| 1478 |
f << "ID=" << std::hex << input->readULong(4) << std::dec << ","; |
| 1479 |
for (int i=0; i<2; ++i) { // always 0 |
| 1480 |
val=static_cast<int>(input->readLong(2)); // 0|1|2 |
| 1481 |
if (val) |
| 1482 |
f << "l" << i+2 <<"=" << val << ","; |
| 1483 |
} |
| 1484 |
val=static_cast<int>(input->readULong(4)); // maybe some dim |
| 1485 |
if (val) { |
| 1486 |
setExpectedType(val-1,F_unknUnicodeE); |
| 1487 |
f << "unknUnicodeE=F" << val-1 << ","; |
| 1488 |
} |
| 1489 |
for (int i=0; i<2; ++i) { // always 0 |
| 1490 |
val=static_cast<int>(input->readLong(2)); // 0|1|2 |
| 1491 |
if (val) |
| 1492 |
f << "l" << i+4 <<"=" << val << ","; |
| 1493 |
} |
| 1494 |
return true; |
| 1495 |
} |
| 1496 |
//! the current cluster |
| 1497 |
std::shared_ptr<RagTime5ClusterManager::ClusterRoot> m_cluster; |
| 1498 |
//! a index to know which field is parsed : 0: main, 1: filename, 2: list, 3: graph type, 4: fieldList |
| 1499 |
int m_what; |
| 1500 |
//! the link id : 0: zone[names], 1: field5=doc[info]?, 2: field6, 3: settings, 4: function names, 5: cluster[list], 6: a def cluster list, 7: a list of unicode string? |
| 1501 |
int m_linkId; |
| 1502 |
//! the actual field name |
| 1503 |
std::string m_fieldName; |
| 1504 |
|
| 1505 |
//! the expected id |
| 1506 |
std::map<int,int> m_expectedIdToType; |
| 1507 |
//! the id stack |
| 1508 |
std::stack<int> m_idStack; |
| 1509 |
}; |
| 1510 |
|
| 1511 |
RootCParser::~RootCParser() |
| 1512 |
{ |
| 1513 |
} |
| 1514 |
|
| 1515 |
// |
| 1516 |
//! try to read a basic root child cluster: either fielddef or fieldpos or a first internal child of the root (unknown) or another child |
| 1517 |
// |
| 1518 |
struct RootChildCParser final : public RagTime5ClusterManager::ClusterParser { |
| 1519 |
//! constructor |
| 1520 |
RootChildCParser(RagTime5ClusterManager &parser, int type) |
| 1521 |
: ClusterParser(parser, type, "ClustCRoot_BAD") |
| 1522 |
, m_cluster(new RagTime5ClusterManager::Cluster(RagTime5ClusterManager::Cluster::C_Unknown)) |
| 1523 |
{ |
| 1524 |
switch (type) { |
| 1525 |
case 0x10000: |
| 1526 |
m_name="ClustGObjProp"; |
| 1527 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_ClusterGProp; |
| 1528 |
break; |
| 1529 |
case 0x20000: |
| 1530 |
m_name="ClustFormula_Def"; |
| 1531 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_FormulaDef; |
| 1532 |
break; |
| 1533 |
case 0x20001: |
| 1534 |
m_name="ClustFormula_Pos"; |
| 1535 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_FormulaPos; |
| 1536 |
break; |
| 1537 |
case 0x30000: |
| 1538 |
m_name="ClustUnkC_A"; |
| 1539 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_ClusterC; |
| 1540 |
break; |
| 1541 |
case 0x30001: |
| 1542 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootChildCParser::RootChildCParser: find zone ClustUnkC_B\n")); |
| 1543 |
m_name="ClustUnkC_B"; |
| 1544 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_ClusterC; |
| 1545 |
break; |
| 1546 |
case 0x30002: |
| 1547 |
m_name="ClustUnkC_C"; |
| 1548 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_ClusterC; |
| 1549 |
break; |
| 1550 |
case 0x30003: |
| 1551 |
m_name="ClustUnkC_D"; |
| 1552 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_ClusterC; |
| 1553 |
break; |
| 1554 |
default: |
| 1555 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootChildCParser::RootChildCParser: find unknown type\n")); |
| 1556 |
break; |
| 1557 |
} |
| 1558 |
} |
| 1559 |
//! destructor |
| 1560 |
~RootChildCParser() final; |
| 1561 |
//! return the current cluster |
| 1562 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 1563 |
{ |
| 1564 |
return m_cluster; |
| 1565 |
} |
| 1566 |
//! parse a zone |
| 1567 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 1568 |
{ |
| 1569 |
if ((m_dataId==0 && flag!=0x30) || (m_dataId==1 && flag !=0x30)) |
| 1570 |
f << "fl=" << std::hex << flag << std::dec << ","; |
| 1571 |
bool ok=false; |
| 1572 |
unsigned long expectedFileType1=0; |
| 1573 |
switch (m_type) { |
| 1574 |
case 0x10000: |
| 1575 |
ok=m_dataId==0 && fSz==32; |
| 1576 |
expectedFileType1=0x4010; |
| 1577 |
break; |
| 1578 |
case 0x20000: |
| 1579 |
ok=m_dataId==0 && fSz==41; |
| 1580 |
expectedFileType1=0x1010; |
| 1581 |
break; |
| 1582 |
case 0x20001: |
| 1583 |
ok=m_dataId==0 && fSz==32; |
| 1584 |
expectedFileType1=0x1010; |
| 1585 |
break; |
| 1586 |
case 0x30000: |
| 1587 |
ok=m_dataId==0 && fSz==34; |
| 1588 |
expectedFileType1=0x50; |
| 1589 |
break; |
| 1590 |
case 0x30002: |
| 1591 |
if (m_dataId==0 && fSz==40) { |
| 1592 |
ok=true; |
| 1593 |
expectedFileType1=0x8010; |
| 1594 |
} |
| 1595 |
else if (m_dataId==1 && fSz==30) { |
| 1596 |
ok=true; |
| 1597 |
expectedFileType1=0x50; |
| 1598 |
} |
| 1599 |
break; |
| 1600 |
case 0x30003: |
| 1601 |
ok=m_dataId==0 && fSz==32; |
| 1602 |
expectedFileType1=0x310; |
| 1603 |
break; |
| 1604 |
default: |
| 1605 |
break; |
| 1606 |
} |
| 1607 |
if (N<=0 || !ok) { |
| 1608 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootChildCParser::parseZone: find unexpected header\n")); |
| 1609 |
f << "###type" << std::hex << N << std::dec; |
| 1610 |
return true; |
| 1611 |
} |
| 1612 |
|
| 1613 |
int val; |
| 1614 |
m_link.m_N=N; |
| 1615 |
long linkValues[4]; // for type=0x30002, f0=3c|60, for fixed size f0=54, other 0 |
| 1616 |
std::string mess; |
| 1617 |
if (!readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 1618 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootChildCParser::parseZone: can not read the link\n")); |
| 1619 |
f << "###link"; |
| 1620 |
return true; |
| 1621 |
} |
| 1622 |
m_link.m_fileType[0]=static_cast<unsigned long>(m_type < 0x30000 ? m_type : m_type-0x30000); |
| 1623 |
f << m_link << "," << mess; |
| 1624 |
if (expectedFileType1>0 && (m_link.m_fileType[1]&0xFFD7)!=expectedFileType1) { |
| 1625 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseZone: fileType1 seems odd[fSz=28...]\n")); |
| 1626 |
f << "###fileType1,"; |
| 1627 |
} |
| 1628 |
|
| 1629 |
if (m_type==0x20000) { |
| 1630 |
std::vector<int> listIds; |
| 1631 |
bool hasCluster=false; |
| 1632 |
if (RagTime5StructManager::readDataIdList(input, 1, listIds) && listIds[0]) { |
| 1633 |
m_cluster->m_clusterIdsList.push_back(listIds[0]); |
| 1634 |
f << "sheet=" << getClusterDebugName(listIds[0]) << ","; |
| 1635 |
hasCluster=true; |
| 1636 |
} |
| 1637 |
val=static_cast<int>(input->readLong(1)); |
| 1638 |
if ((hasCluster && val!=1) || (!hasCluster && val)) |
| 1639 |
f << "#hasCluster=" << val << ","; |
| 1640 |
for (int i=0; i<2; ++i) { // always 0 |
| 1641 |
val=static_cast<int>(input->readLong(2)); |
| 1642 |
if (val) f << "g" << i << "=" << val << ","; |
| 1643 |
} |
| 1644 |
} |
| 1645 |
else if (m_type==0x30000) { |
| 1646 |
for (int i=0; i<2; ++i) { // find 0 |
| 1647 |
val=static_cast<int>(input->readLong(2)); |
| 1648 |
if (val) f << "g" << i << "=" << val << ","; |
| 1649 |
} |
| 1650 |
} |
| 1651 |
else if (m_type==0x30002) { |
| 1652 |
for (int i=0; i<2; ++i) { // find 0 |
| 1653 |
val=static_cast<int>(input->readLong(4)); |
| 1654 |
if (val) f << "g" << i << "=" << val << ","; |
| 1655 |
} |
| 1656 |
} |
| 1657 |
return true; |
| 1658 |
} |
| 1659 |
//! parse a field |
| 1660 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 1661 |
{ |
| 1662 |
if (m_dataId==0 && field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xce842) { |
| 1663 |
f << "pos=["; |
| 1664 |
for (auto val : field.m_longList) |
| 1665 |
f << val << ","; |
| 1666 |
f << "],"; |
| 1667 |
m_link.m_longList=field.m_longList; |
| 1668 |
} |
| 1669 |
else if (m_dataId==0 && field.m_type==RagTime5StructManager::Field::T_Unstructured && field.m_fileType==0xce017) |
| 1670 |
// pos find 2|4|8 |
| 1671 |
// def find f801|000f00 |
| 1672 |
f << "unkn="<<field.m_extra << ","; |
| 1673 |
else { |
| 1674 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootChildCParser::parseField: find unexpected sub field\n")); |
| 1675 |
f << "#" << field; |
| 1676 |
} |
| 1677 |
return true; |
| 1678 |
} |
| 1679 |
//! end of a start zone call |
| 1680 |
void endZone() final |
| 1681 |
{ |
| 1682 |
if (m_link.empty()) |
| 1683 |
return; |
| 1684 |
if (m_dataId==0) |
| 1685 |
m_cluster->m_dataLink=m_link; |
| 1686 |
else |
| 1687 |
m_cluster->m_linksList.push_back(m_link); |
| 1688 |
} |
| 1689 |
protected: |
| 1690 |
//! the current cluster |
| 1691 |
std::shared_ptr<RagTime5ClusterManager::Cluster> m_cluster; |
| 1692 |
}; |
| 1693 |
|
| 1694 |
RootChildCParser::~RootChildCParser() |
| 1695 |
{ |
| 1696 |
} |
| 1697 |
|
| 1698 |
// |
| 1699 |
//! low level: parser of group cluster : zone 4010 |
| 1700 |
// |
| 1701 |
struct GroupCParser final : public RagTime5ClusterManager::ClusterParser { |
| 1702 |
//! constructor |
| 1703 |
explicit GroupCParser(RagTime5ClusterManager &parser, int type) |
| 1704 |
: ClusterParser(parser, type, "ClustGroup") |
| 1705 |
, m_cluster(new RagTime5ClusterManager::Cluster(RagTime5ClusterManager::Cluster::C_GroupZone)) |
| 1706 |
, m_fieldName("") |
| 1707 |
{ |
| 1708 |
} |
| 1709 |
//! destructor |
| 1710 |
~GroupCParser() final; |
| 1711 |
//! return the current cluster |
| 1712 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 1713 |
{ |
| 1714 |
return m_cluster; |
| 1715 |
} |
| 1716 |
//! try to parse a zone |
| 1717 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 1718 |
{ |
| 1719 |
f << "fl=" << std::hex << flag << std::dec << ","; |
| 1720 |
m_fieldName=""; |
| 1721 |
|
| 1722 |
int val; |
| 1723 |
if (N!=-5) { |
| 1724 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: unexpected header\n")); |
| 1725 |
f << "##N=" << N << ","; |
| 1726 |
return true; |
| 1727 |
} |
| 1728 |
if (fSz!=50 || m_dataId!=0) { |
| 1729 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: find unknown block\n")); |
| 1730 |
f << "###unknown,"; |
| 1731 |
return true; |
| 1732 |
} |
| 1733 |
|
| 1734 |
for (int i=0; i<2; ++i) { // always 0? |
| 1735 |
val=static_cast<int>(input->readLong(2)); |
| 1736 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1737 |
} |
| 1738 |
val=static_cast<int>(input->readLong(2)); |
| 1739 |
f << "id=" << val << ","; |
| 1740 |
val=static_cast<int>(input->readULong(2)); |
| 1741 |
if (val!=m_type) { |
| 1742 |
f << "###type=" << std::hex << val << std::dec << ","; |
| 1743 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: the field format seems bad\n")); |
| 1744 |
} |
| 1745 |
for (int i=0; i<4; ++i) { // always 0? |
| 1746 |
val=static_cast<int>(input->readLong(2)); |
| 1747 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1748 |
} |
| 1749 |
int fl1=static_cast<int>(input->readLong(2)); |
| 1750 |
if (fl1!=0x10) |
| 1751 |
f << "fl1=" << std::hex << fl1 << std::dec << ","; |
| 1752 |
m_link.m_N=int(input->readLong(4)); |
| 1753 |
std::string mess; |
| 1754 |
long linkValues[4]; |
| 1755 |
if (!readLinkHeader(input, 28, m_link, linkValues, mess)) { |
| 1756 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: can not read the int link\n")); |
| 1757 |
f << "###"; |
| 1758 |
} |
| 1759 |
f << m_link << mess; |
| 1760 |
return true; |
| 1761 |
} |
| 1762 |
//! parse a field |
| 1763 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 1764 |
{ |
| 1765 |
if (!m_fieldName.empty()) |
| 1766 |
f << m_fieldName << ","; |
| 1767 |
switch (m_dataId) { |
| 1768 |
case 0: { |
| 1769 |
if (field.m_type==RagTime5StructManager::Field::T_FieldList && field.m_fileType==0x17db015) { |
| 1770 |
f << "ids=["; |
| 1771 |
for (auto const &child : field.m_fieldList) { |
| 1772 |
if (child.m_type==RagTime5StructManager::Field::T_LongList && child.m_fileType==0xce842) { |
| 1773 |
for (auto val : child.m_longList) |
| 1774 |
f << val << ","; |
| 1775 |
m_link.m_longList=child.m_longList; |
| 1776 |
continue; |
| 1777 |
} |
| 1778 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: find unexpected child[main]\n")); |
| 1779 |
f << "###[" << child << "],"; |
| 1780 |
} |
| 1781 |
f << "],"; |
| 1782 |
break; |
| 1783 |
} |
| 1784 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: find unexpected field[main]\n")); |
| 1785 |
f << "###" << field; |
| 1786 |
break; |
| 1787 |
} |
| 1788 |
default: |
| 1789 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::parseZone: find unexpected list link field\n")); |
| 1790 |
f << "###" << field; |
| 1791 |
break; |
| 1792 |
} |
| 1793 |
return true; |
| 1794 |
} |
| 1795 |
//! end of a start zone call |
| 1796 |
void endZone() final |
| 1797 |
{ |
| 1798 |
if (m_link.empty()) |
| 1799 |
return; |
| 1800 |
if (m_dataId==0) { |
| 1801 |
if (m_cluster->m_dataLink.empty()) |
| 1802 |
m_cluster->m_dataLink=m_link; |
| 1803 |
else { |
| 1804 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::GroupCParser::endZone: oops the main link is already set\n")); |
| 1805 |
m_cluster->m_linksList.push_back(m_link); |
| 1806 |
} |
| 1807 |
} |
| 1808 |
} |
| 1809 |
protected: |
| 1810 |
//! the current cluster |
| 1811 |
std::shared_ptr<RagTime5ClusterManager::Cluster> m_cluster; |
| 1812 |
//! the actual field name |
| 1813 |
std::string m_fieldName; |
| 1814 |
}; |
| 1815 |
|
| 1816 |
GroupCParser::~GroupCParser() |
| 1817 |
{ |
| 1818 |
} |
| 1819 |
|
| 1820 |
//! the sound cluster ( 2/a/4002/400a zone) |
| 1821 |
struct ClusterSound final : public RagTime5ClusterManager::Cluster { |
| 1822 |
//! constructor |
| 1823 |
ClusterSound() |
| 1824 |
: Cluster(C_Sound) |
| 1825 |
{ |
| 1826 |
} |
| 1827 |
//! destructor |
| 1828 |
~ClusterSound() final; |
| 1829 |
}; |
| 1830 |
|
| 1831 |
ClusterSound::~ClusterSound() |
| 1832 |
{ |
| 1833 |
} |
| 1834 |
|
| 1835 |
// |
| 1836 |
//! low level: parser of sound cluster : zone 2,a,4002,400a |
| 1837 |
// |
| 1838 |
struct SoundCParser final : public RagTime5ClusterManager::ClusterParser { |
| 1839 |
enum { F_nextId, F_parentList }; |
| 1840 |
//! constructor |
| 1841 |
SoundCParser(RagTime5ClusterManager &parser, int type) |
| 1842 |
: ClusterParser(parser, type, "ClustSound") |
| 1843 |
, m_cluster(new ClusterSound) |
| 1844 |
, m_fieldName("") |
| 1845 |
|
| 1846 |
, m_expectedIdToType() |
| 1847 |
, m_idStack() |
| 1848 |
{ |
| 1849 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_Sound; |
| 1850 |
} |
| 1851 |
//! destructor |
| 1852 |
~SoundCParser() final; |
| 1853 |
//! return the current cluster |
| 1854 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 1855 |
{ |
| 1856 |
return m_cluster; |
| 1857 |
} |
| 1858 |
|
| 1859 |
//! return the sound cluster |
| 1860 |
std::shared_ptr<ClusterSound> getSoundCluster() |
| 1861 |
{ |
| 1862 |
return m_cluster; |
| 1863 |
} |
| 1864 |
|
| 1865 |
//! set a data id type |
| 1866 |
void setExpectedType(int id, int type) |
| 1867 |
{ |
| 1868 |
m_expectedIdToType[id]=type; |
| 1869 |
m_idStack.push(id); |
| 1870 |
} |
| 1871 |
/** returns to new zone to parse. */ |
| 1872 |
int getNewZoneToParse() final |
| 1873 |
{ |
| 1874 |
if (m_idStack.empty()) |
| 1875 |
return -1; |
| 1876 |
int id=m_idStack.top(); |
| 1877 |
m_idStack.pop(); |
| 1878 |
return id; |
| 1879 |
} |
| 1880 |
//! parse a zone |
| 1881 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 1882 |
{ |
| 1883 |
if (N==-5) |
| 1884 |
return parseHeaderZone(input, fSz, N, flag, f); |
| 1885 |
|
| 1886 |
auto const &it=m_expectedIdToType.find(m_dataId); |
| 1887 |
int expected=(it!=m_expectedIdToType.end())?it->second : -1; |
| 1888 |
if (expected!=-1) |
| 1889 |
f << "[F" << m_dataId << "]"; |
| 1890 |
if (flag!=0x10) |
| 1891 |
f << "fl=" << std::hex << flag << std::dec << ","; |
| 1892 |
m_fieldName=""; |
| 1893 |
if (N<0) { |
| 1894 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseZone: find unexpected data block\n")); |
| 1895 |
f << "###N=" << N << ","; |
| 1896 |
return true; |
| 1897 |
} |
| 1898 |
m_link.m_N=N; |
| 1899 |
long linkValues[4]; |
| 1900 |
std::string mess; |
| 1901 |
if (expected==-1) { |
| 1902 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseZone: find unexpected field[%d]\n", m_dataId)); |
| 1903 |
f << "###"; |
| 1904 |
} |
| 1905 |
|
| 1906 |
switch (fSz) { |
| 1907 |
case 36: |
| 1908 |
f << "parentListA,"; |
| 1909 |
if (!readLinkHeader(input,fSz,m_link,linkValues,mess)) { |
| 1910 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseZone: can not read the link\n")); |
| 1911 |
f << "###link,"; |
| 1912 |
return true; |
| 1913 |
} |
| 1914 |
if ((m_link.m_fileType[1]&0xFFD7)!= 0x10) { |
| 1915 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::RootCParser::parseZone: fileType1 seems odd[fSz=28...]\n")); |
| 1916 |
f << "###fileType1,"; |
| 1917 |
} |
| 1918 |
setExpectedType(m_dataId, F_parentList); |
| 1919 |
m_fieldName=m_link.m_name="parentList"; |
| 1920 |
f << m_link << "," << mess; |
| 1921 |
for (int i=0; i<2; ++i) { // g0: small number between 38 and 64, g1: 0|-1 |
| 1922 |
int val=static_cast<int>(input->readLong(2)); |
| 1923 |
if (val) f << "g" << i << "=" << val << ","; |
| 1924 |
} |
| 1925 |
break; |
| 1926 |
default: |
| 1927 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseZone: find unknown size[%ld]\n", fSz)); |
| 1928 |
f << "###fSz=" << fSz << ","; |
| 1929 |
break; |
| 1930 |
} |
| 1931 |
return true; |
| 1932 |
} |
| 1933 |
//! parse a field |
| 1934 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 1935 |
{ |
| 1936 |
if (!m_fieldName.empty()) |
| 1937 |
f << m_fieldName << ","; |
| 1938 |
auto const &it=m_expectedIdToType.find(m_dataId); |
| 1939 |
int expected=(it!=m_expectedIdToType.end())?it->second : -1; |
| 1940 |
switch (expected) { |
| 1941 |
case F_parentList: |
| 1942 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xce842) { |
| 1943 |
f << "pos=["; |
| 1944 |
for (auto val : field.m_longList) |
| 1945 |
f << val << ","; |
| 1946 |
f << "],"; |
| 1947 |
m_link.m_longList=field.m_longList; |
| 1948 |
break; |
| 1949 |
} |
| 1950 |
if (field.m_type==RagTime5StructManager::Field::T_Unstructured && field.m_fileType==0xce017) { |
| 1951 |
// a small value 2 (can be first data) |
| 1952 |
f << "unkn="<<field.m_extra << ","; |
| 1953 |
break; |
| 1954 |
} |
| 1955 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseField: find unexpected list link field\n")); |
| 1956 |
f << "###" << field; |
| 1957 |
break; |
| 1958 |
case F_nextId: |
| 1959 |
default: |
| 1960 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseField: find unexpected field\n")); |
| 1961 |
f << "###" << field; |
| 1962 |
break; |
| 1963 |
} |
| 1964 |
return true; |
| 1965 |
} |
| 1966 |
//! parse the header zone |
| 1967 |
bool parseHeaderZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) |
| 1968 |
{ |
| 1969 |
// script size 38 |
| 1970 |
f << "header,fl=" << std::hex << flag << std::dec << ","; |
| 1971 |
if (N!=-5 || m_dataId!=0 || fSz!=38) { |
| 1972 |
f << "###N=" << N << ",fSz=" << fSz << ","; |
| 1973 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseHeaderZone: find unexpected main field\n")); |
| 1974 |
return true; |
| 1975 |
} |
| 1976 |
int val; |
| 1977 |
m_fieldName="main"; |
| 1978 |
for (int i=0; i<2; ++i) { // always 0? |
| 1979 |
val=static_cast<int>(input->readLong(2)); |
| 1980 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1981 |
} |
| 1982 |
val=static_cast<int>(input->readLong(2)); |
| 1983 |
f << "id=" << val << ","; |
| 1984 |
val=static_cast<int>(input->readULong(2)); |
| 1985 |
if (val!=m_type) { |
| 1986 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseHeaderZone: unexpected zone type\n")); |
| 1987 |
f << "##zoneType=" << std::hex << val << std::dec << ","; |
| 1988 |
} |
| 1989 |
val=static_cast<int>(input->readLong(4)); |
| 1990 |
if (val) { |
| 1991 |
setExpectedType(int(val-1), F_nextId); // either next[id] or parentList |
| 1992 |
f << "next[id]=F" << val-1 << ","; |
| 1993 |
} |
| 1994 |
for (int i=0; i<6; ++i) { // always 0 |
| 1995 |
val=static_cast<int>(input->readLong(2)); |
| 1996 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 1997 |
} |
| 1998 |
std::string code(""); // find betr |
| 1999 |
for (int i=0; i<4; ++i) code+=char(input->readULong(1)); |
| 2000 |
if (!code.empty()) f << code << ","; |
| 2001 |
for (int i=0; i<2; ++i) { // always 0 |
| 2002 |
val=static_cast<int>(input->readLong(2)); |
| 2003 |
if (val) f << "g" << i << "=" << val << ","; |
| 2004 |
} |
| 2005 |
return true; |
| 2006 |
} |
| 2007 |
//! end of a start zone call |
| 2008 |
void endZone() final |
| 2009 |
{ |
| 2010 |
if (m_link.empty()) |
| 2011 |
return; |
| 2012 |
auto const &it=m_expectedIdToType.find(m_dataId); |
| 2013 |
int expected=(it!=m_expectedIdToType.end())?it->second : -1; |
| 2014 |
if (expected==F_parentList) |
| 2015 |
m_cluster->m_parentLink=m_link; |
| 2016 |
else { |
| 2017 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::SoundCParser::parseHeaderZone: unexpected link\n")); |
| 2018 |
m_cluster->m_linksList.push_back(m_link); |
| 2019 |
} |
| 2020 |
} |
| 2021 |
|
| 2022 |
protected: |
| 2023 |
//! the current cluster |
| 2024 |
std::shared_ptr<ClusterSound> m_cluster; |
| 2025 |
//! the actual field name |
| 2026 |
std::string m_fieldName; |
| 2027 |
|
| 2028 |
//! the expected id |
| 2029 |
std::map<int,int> m_expectedIdToType; |
| 2030 |
//! the id stack |
| 2031 |
std::stack<int> m_idStack; |
| 2032 |
}; |
| 2033 |
|
| 2034 |
SoundCParser::~SoundCParser() |
| 2035 |
{ |
| 2036 |
} |
| 2037 |
|
| 2038 |
// |
| 2039 |
//! low level: parser of style cluster : zone 480 |
| 2040 |
// |
| 2041 |
struct StyleCParser final : public RagTime5ClusterManager::ClusterParser { |
| 2042 |
//! constructor |
| 2043 |
explicit StyleCParser(RagTime5ClusterManager &parser, int type) |
| 2044 |
: ClusterParser(parser, type, "ClustStyle") |
| 2045 |
, m_cluster(new RagTime5ClusterManager::Cluster(RagTime5ClusterManager::Cluster::C_Unknown)) |
| 2046 |
, m_fieldName("") |
| 2047 |
{ |
| 2048 |
} |
| 2049 |
//! destructor |
| 2050 |
~StyleCParser() final; |
| 2051 |
//! return the current cluster |
| 2052 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 2053 |
{ |
| 2054 |
return m_cluster; |
| 2055 |
} |
| 2056 |
//! try to parse a zone |
| 2057 |
bool parseZone(MWAWInputStreamPtr &input, long fSz, int N, int flag, libmwaw::DebugStream &f) final |
| 2058 |
{ |
| 2059 |
f << "fl=" << std::hex << flag << std::dec << ","; |
| 2060 |
m_fieldName=""; |
| 2061 |
|
| 2062 |
int val; |
| 2063 |
if (N!=-5) { |
| 2064 |
if (N<0 || m_dataId==0 || (fSz!=28 && fSz!=32 && fSz!=36)) { |
| 2065 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: unexpected header\n")); |
| 2066 |
f << "##N=" << N << ","; |
| 2067 |
return true; |
| 2068 |
} |
| 2069 |
m_link.m_N=N; |
| 2070 |
if (fSz==28 || fSz==32) { // n=2,3 with fSz=28, type=0x3e800, can have no data |
| 2071 |
if ((fSz==28 && m_dataId!=2 && m_dataId!=3) || (fSz==32 && m_dataId!=4)) { |
| 2072 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: dataId seems bad\n")); |
| 2073 |
f << "##n=" << m_dataId << ","; |
| 2074 |
} |
| 2075 |
long linkValues[4]; |
| 2076 |
std::string mess; |
| 2077 |
if (!readLinkHeader(input, fSz, m_link, linkValues, mess)) { |
| 2078 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: link seems bad\n")); |
| 2079 |
f << "###link,"; |
| 2080 |
return true; |
| 2081 |
} |
| 2082 |
f << m_link << "," << mess; |
| 2083 |
if (m_link.m_fileType[0]==0x35800) |
| 2084 |
m_fieldName="unicodeList1"; |
| 2085 |
else if (m_link.m_fileType[0]==0x3e800) |
| 2086 |
m_fieldName="unicodeList0"; |
| 2087 |
else if (fSz==32) { |
| 2088 |
m_fieldName="unicodeNames"; |
| 2089 |
m_cluster->m_nameLink.m_N=m_link.m_N; |
| 2090 |
m_cluster->m_nameLink.m_ids=m_link.m_ids; |
| 2091 |
} |
| 2092 |
else { |
| 2093 |
f << "###fType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 2094 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: the field 2,3 type seems bad\n")); |
| 2095 |
return true; |
| 2096 |
} |
| 2097 |
m_link.m_name=m_fieldName; |
| 2098 |
if (m_dataId>=2 && m_dataId<=3) |
| 2099 |
m_cluster->m_nameLink.m_posToNamesLinks[m_dataId-2]=m_link; |
| 2100 |
if ((m_link.m_fileType[1]&0xFFD7)!=(fSz==28 ? 0 : 0x200)) { |
| 2101 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: fileType1 seems odd[fSz=28...]\n")); |
| 2102 |
f << "###fileType1,"; |
| 2103 |
} |
| 2104 |
if (!m_fieldName.empty()) |
| 2105 |
f << m_fieldName << ","; |
| 2106 |
return true; |
| 2107 |
} |
| 2108 |
if (m_dataId!=1) { |
| 2109 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: dataId seems bad\n")); |
| 2110 |
f << "##n=" << m_dataId << ","; |
| 2111 |
} |
| 2112 |
for (int i=0; i<2; ++i) { // always 0 |
| 2113 |
val=static_cast<int>(input->readLong(2)); |
| 2114 |
if (val) f << "f" << i << "=" << val << ","; |
| 2115 |
} |
| 2116 |
m_link.m_fileType[0]=input->readULong(4); |
| 2117 |
if (m_link.m_fileType[0]!=0x7d01a) { |
| 2118 |
f << "###fType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 2119 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: the field 1 type seems bad\n")); |
| 2120 |
} |
| 2121 |
for (int i=0; i<4; ++i) { // always 0 |
| 2122 |
val=static_cast<int>(input->readLong(2)); |
| 2123 |
if (val) f << "f" << i+2 << "=" << val << ","; |
| 2124 |
} |
| 2125 |
m_link.m_fileType[1]=input->readULong(2); |
| 2126 |
if (m_link.m_fileType[1]!=0x10 && m_link.m_fileType[1]!=0x18) { |
| 2127 |
f << "###fType1=" << std::hex << m_link.m_fileType[1] << std::dec << ","; |
| 2128 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: the field 1 type1 seems bad\n")); |
| 2129 |
} |
| 2130 |
for (int i=0; i<3; ++i) { // always 3,4,5 ? |
| 2131 |
val=static_cast<int>(input->readLong(4)); |
| 2132 |
if (val!=i+3) f << "g" << i << "=" << val << ","; |
| 2133 |
} |
| 2134 |
return true; |
| 2135 |
} |
| 2136 |
if ((fSz!=22 && fSz!=58 && fSz!=64 && fSz!=66 && fSz!=68) || m_dataId!=0) { |
| 2137 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: find unknown block\n")); |
| 2138 |
f << "###unknown,"; |
| 2139 |
return true; |
| 2140 |
} |
| 2141 |
|
| 2142 |
for (int i=0; i<2; ++i) { // always 0? |
| 2143 |
val=static_cast<int>(input->readLong(2)); |
| 2144 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 2145 |
} |
| 2146 |
val=static_cast<int>(input->readLong(2)); |
| 2147 |
f << "id=" << val << ","; |
| 2148 |
val=static_cast<int>(input->readULong(2)); |
| 2149 |
if (val!=m_type) { |
| 2150 |
f << "###type=" << std::hex << val << std::dec << ","; |
| 2151 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: the field format seems bad\n")); |
| 2152 |
} |
| 2153 |
m_link.m_N=val; |
| 2154 |
for (int i=0; i< (fSz==22 ? 4 : 13); ++i) { // g3=2, g4=10, g6 and g8 2 small int |
| 2155 |
val=static_cast<int>(input->readLong(2)); |
| 2156 |
if (!val) continue; |
| 2157 |
if (i==6) |
| 2158 |
f << "N=" << val << ","; |
| 2159 |
else |
| 2160 |
f << "g" << i << "=" << val << ","; |
| 2161 |
} |
| 2162 |
if (fSz==22) |
| 2163 |
return true; |
| 2164 |
m_link.m_fileType[0]=input->readULong(4); |
| 2165 |
if (m_link.m_fileType[0] != 0x01473857 && m_link.m_fileType[0] != 0x0146e827) { |
| 2166 |
f << "###fileType=" << RagTime5ClusterManager::printType(m_link.m_fileType[0]) << ","; |
| 2167 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: the field type seems bad\n")); |
| 2168 |
} |
| 2169 |
m_link.m_fileType[1]=input->readULong(2); // c018|c030|c038 or type ? |
| 2170 |
if (!RagTime5StructManager::readDataIdList(input, 2, m_link.m_ids) || m_link.m_ids[1]==0) { |
| 2171 |
f << "###noData,"; |
| 2172 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseZone: can not find any data\n")); |
| 2173 |
} |
| 2174 |
m_link.m_type=RagTime5ClusterManager::Link::L_FieldsList; |
| 2175 |
if (fSz==58) { |
| 2176 |
if (m_link.m_fileType[0] == 0x0146e827) { |
| 2177 |
m_link.m_name=m_fieldName="formats"; |
| 2178 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_FormatStyles; |
| 2179 |
} |
| 2180 |
else { |
| 2181 |
m_link.m_name=m_fieldName="units"; |
| 2182 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_UnitStyles; |
| 2183 |
} |
| 2184 |
} |
| 2185 |
else if (fSz==64) { |
| 2186 |
m_link.m_name=m_fieldName="graphColor"; |
| 2187 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_ColorStyles; |
| 2188 |
} |
| 2189 |
else if (fSz==66) { |
| 2190 |
m_link.m_name=m_fieldName="textStyle"; |
| 2191 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_TextStyles; |
| 2192 |
} |
| 2193 |
else { |
| 2194 |
m_link.m_name=m_fieldName="graphStyle"; |
| 2195 |
m_cluster->m_type=RagTime5ClusterManager::Cluster::C_GraphicStyles; |
| 2196 |
} |
| 2197 |
f << m_link << ","; |
| 2198 |
return true; |
| 2199 |
} |
| 2200 |
//! parse a field |
| 2201 |
bool parseField(RagTime5StructManager::Field const &field, int /*m*/, libmwaw::DebugStream &f) final |
| 2202 |
{ |
| 2203 |
if (!m_fieldName.empty()) |
| 2204 |
f << m_fieldName << ","; |
| 2205 |
switch (m_dataId) { |
| 2206 |
case 0: { |
| 2207 |
unsigned long expectedVal=m_cluster->m_type==RagTime5ClusterManager::Cluster::C_FormatStyles ? 0x146e815 : 0x1473815; |
| 2208 |
if (field.m_type==RagTime5StructManager::Field::T_FieldList && field.m_fileType==expectedVal) { |
| 2209 |
f << "decal=["; |
| 2210 |
for (auto const &child : field.m_fieldList) { |
| 2211 |
if (child.m_type==RagTime5StructManager::Field::T_LongList && child.m_fileType==0xce842) { |
| 2212 |
for (auto val : child.m_longList) |
| 2213 |
f << val << ","; |
| 2214 |
m_link.m_longList=child.m_longList; |
| 2215 |
continue; |
| 2216 |
} |
| 2217 |
if (child.m_type==RagTime5StructManager::Field::T_Unstructured && child.m_fileType==0xce017) { |
| 2218 |
// a list of small int 0104|0110|22f8ffff7f3f |
| 2219 |
f << "unkn0=" << child.m_longValue[0] << child.m_extra << ","; |
| 2220 |
continue; |
| 2221 |
} |
| 2222 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseField: find unexpected child[main]\n")); |
| 2223 |
f << "###[" << child << "],"; |
| 2224 |
} |
| 2225 |
f << "],"; |
| 2226 |
break; |
| 2227 |
} |
| 2228 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseField: find unexpected field[main]\n")); |
| 2229 |
f << "###" << field; |
| 2230 |
break; |
| 2231 |
} |
| 2232 |
case 1: |
| 2233 |
if (field.m_type==RagTime5StructManager::Field::T_Unstructured && field.m_fileType==0xce017) { |
| 2234 |
// a small value 2 (can be first data) |
| 2235 |
f << "unkn="<<field.m_extra << ","; |
| 2236 |
break; |
| 2237 |
} |
| 2238 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseField: find unexpected field[zone1]\n")); |
| 2239 |
f << "###" << field; |
| 2240 |
break; |
| 2241 |
case 2: |
| 2242 |
case 3: |
| 2243 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xce842) { |
| 2244 |
f << "data=["; |
| 2245 |
for (auto val : field.m_longList) { |
| 2246 |
if (val==0) |
| 2247 |
f << "_,"; |
| 2248 |
else if (static_cast<int>(val)==static_cast<int>(0x80000000)) |
| 2249 |
f << "inf,"; |
| 2250 |
else |
| 2251 |
f << val << ","; |
| 2252 |
} |
| 2253 |
f << "],"; |
| 2254 |
m_cluster->m_nameLink.m_posToNames[m_dataId-2]=field.m_longList; |
| 2255 |
break; |
| 2256 |
} |
| 2257 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseField: find unexpected field[zone23–\n")); |
| 2258 |
f << "###" << field; |
| 2259 |
break; |
| 2260 |
case 4: |
| 2261 |
if (field.m_type==RagTime5StructManager::Field::T_LongList && field.m_fileType==0xce842) { |
| 2262 |
f << "data=["; |
| 2263 |
for (auto val : field.m_longList) |
| 2264 |
f << val << ","; |
| 2265 |
f << "],"; |
| 2266 |
m_cluster->m_nameLink.m_decalList=field.m_longList; |
| 2267 |
break; |
| 2268 |
} |
| 2269 |
if (field.m_type==RagTime5StructManager::Field::T_Unstructured && field.m_fileType==0xce017) { |
| 2270 |
// a small value 2 (can be first data) |
| 2271 |
f << "unkn="<<field.m_extra << ","; |
| 2272 |
break; |
| 2273 |
} |
| 2274 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseField: find unexpected unicode field\n")); |
| 2275 |
f << "###" << field; |
| 2276 |
break; |
| 2277 |
default: |
| 2278 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::parseField: find unexpected list link field\n")); |
| 2279 |
f << "###" << field; |
| 2280 |
break; |
| 2281 |
} |
| 2282 |
return true; |
| 2283 |
} |
| 2284 |
//! end of a start zone call |
| 2285 |
void endZone() final |
| 2286 |
{ |
| 2287 |
if (m_link.empty()) |
| 2288 |
return; |
| 2289 |
if (m_dataId==0) { |
| 2290 |
if (m_cluster->m_dataLink.empty()) |
| 2291 |
m_cluster->m_dataLink=m_link; |
| 2292 |
else { |
| 2293 |
MWAW_DEBUG_MSG(("RagTime5ClusterManagerInternal::StyleCParser::endZone: oops the main link is already set\n")); |
| 2294 |
m_cluster->m_linksList.push_back(m_link); |
| 2295 |
} |
| 2296 |
} |
| 2297 |
} |
| 2298 |
protected: |
| 2299 |
//! the current cluster |
| 2300 |
std::shared_ptr<RagTime5ClusterManager::Cluster> m_cluster; |
| 2301 |
//! the actual field name |
| 2302 |
std::string m_fieldName; |
| 2303 |
}; |
| 2304 |
|
| 2305 |
StyleCParser::~StyleCParser() |
| 2306 |
{ |
| 2307 |
} |
| 2308 |
|
| 2309 |
// |
| 2310 |
//! low level: parser of unknown cluster |
| 2311 |
// |
| 2312 |
struct UnknownCParser final : public RagTime5ClusterManager::ClusterParser { |
| 2313 |
//! constructor |
| 2314 |
UnknownCParser(RagTime5ClusterManager &parser, int type) |
| 2315 |
: ClusterParser(parser, type, "ClustUnknown") |
| 2316 |
, m_cluster(new RagTime5ClusterManager::Cluster(RagTime5ClusterManager::Cluster::C_Unknown)) |
| 2317 |
{ |
| 2318 |
if (type==-1) |
| 2319 |
return; |
| 2320 |
} |
| 2321 |
//! destructor |
| 2322 |
~UnknownCParser() final; |
| 2323 |
//! return the current cluster |
| 2324 |
std::shared_ptr<RagTime5ClusterManager::Cluster> getCluster() final |
| 2325 |
{ |
| 2326 |
return m_cluster; |
| 2327 |
} |
| 2328 |
protected: |
| 2329 |
|
| 2330 |
//! the current cluster |
| 2331 |
std::shared_ptr<RagTime5ClusterManager::Cluster> m_cluster; |
| 2332 |
}; |
| 2333 |
|
| 2334 |
UnknownCParser::~UnknownCParser() |
| 2335 |
{ |
| 2336 |
} |
| 2337 |
|
| 2338 |
} |
| 2339 |
|
| 2340 |
bool RagTime5ClusterManager::getClusterBasicHeaderInfo(RagTime5Zone &zone, long &N, long &fSz, long &debHeaderPos) |
| 2341 |
{ |
| 2342 |
MWAWEntry const &entry=zone.m_entry; |
| 2343 |
if (entry.length()<13) return false; |
| 2344 |
MWAWInputStreamPtr input=zone.getInput(); |
| 2345 |
long endPos=entry.end(); |
| 2346 |
input->setReadInverted(!zone.m_hiLoEndian); |
| 2347 |
input->seek(entry.begin()+8, librevenge::RVNG_SEEK_SET); |
| 2348 |
long endDataPos; |
| 2349 |
if (!readFieldHeader(zone, endPos, "", endDataPos) || !RagTime5StructManager::readCompressedLong(input, endDataPos, fSz) || |
| 2350 |
fSz<6 || input->tell()+fSz>endDataPos) { |
| 2351 |
input->setReadInverted(false); |
| 2352 |
return false; |
| 2353 |
} |
| 2354 |
input->seek(2, librevenge::RVNG_SEEK_CUR); // skip flag |
| 2355 |
N=static_cast<int>(input->readLong(4)); |
| 2356 |
debHeaderPos=input->tell(); |
| 2357 |
input->setReadInverted(false); |
| 2358 |
return true; |
| 2359 |
} |
| 2360 |
|
| 2361 |
int RagTime5ClusterManager::getClusterType(RagTime5Zone &zone, int fileType) |
| 2362 |
{ |
| 2363 |
if (fileType==-1) |
| 2364 |
fileType=getClusterFileType(zone); |
| 2365 |
if (fileType==-1) |
| 2366 |
return -1; |
| 2367 |
switch (fileType&0xfff3fd7) { |
| 2368 |
case 0: // root |
| 2369 |
return 0; |
| 2370 |
case 1: // layout |
| 2371 |
return 1; |
| 2372 |
// case 0x2: button/sound |
| 2373 |
// case 0x3: text/spreadsheet/picture |
| 2374 |
case 0x10: |
| 2375 |
return 0x40007; |
| 2376 |
case 0x42: // color pattern |
| 2377 |
case 0x142: // v6 file |
| 2378 |
return 0x42; |
| 2379 |
case 0x104: // pipeline |
| 2380 |
case 0x204: |
| 2381 |
return 0x104; |
| 2382 |
case 0x480: // style |
| 2383 |
case 0x4c0: |
| 2384 |
return 0x80; |
| 2385 |
case 0x10000: // first child of root |
| 2386 |
case 0x20000: // formula def |
| 2387 |
case 0x20001: // formula pos |
| 2388 |
case 0x30000: // 0th element of child list root |
| 2389 |
case 0x30001: // 1th element of child list root, never seen |
| 2390 |
case 0x30002: // 2th element of child list root |
| 2391 |
case 0x30003: // 3th element of child list root |
| 2392 |
case 0x40000: // picture cluster |
| 2393 |
case 0x40001: // graphic cluster |
| 2394 |
case 0x40002: // spreadsheet cluster |
| 2395 |
case 0x40003: // text cluster |
| 2396 |
case 0x40004: // chart |
| 2397 |
case 0x40005: // button |
| 2398 |
case 0x40006: // sound |
| 2399 |
case 0x40007: // group |
| 2400 |
return fileType; |
| 2401 |
default: |
| 2402 |
break; |
| 2403 |
} |
| 2404 |
long N, fSz, debDataPos; |
| 2405 |
if (!getClusterBasicHeaderInfo(zone, N, fSz, debDataPos) || N!=-5) |
| 2406 |
return -1; |
| 2407 |
|
| 2408 |
if ((fileType&0xfff1fd7)!=2 && (fileType&0xfff1fd7)!=3 && fileType!=0xe && fileType!=0x16a) { |
| 2409 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::getClusterType: unexpected filetype=%x\n", (unsigned)fileType)); |
| 2410 |
} |
| 2411 |
switch (fSz) { |
| 2412 |
case 38: // sound cluster |
| 2413 |
return 0x40006; |
| 2414 |
case 50: // group |
| 2415 |
return 0x40007; |
| 2416 |
case 74: // button cluster |
| 2417 |
return 0x40005; |
| 2418 |
case 64: // movie cluster |
| 2419 |
case 104: |
| 2420 |
case 109: // picture cluster |
| 2421 |
return 0x40000; |
| 2422 |
case 118: // graphic cluster |
| 2423 |
return 0x40001; |
| 2424 |
case 134: // spreadsheet cluster |
| 2425 |
return 0x40002; |
| 2426 |
case 135: |
| 2427 |
case 140: |
| 2428 |
case 143: |
| 2429 |
case 208: |
| 2430 |
case 212: |
| 2431 |
case 213: |
| 2432 |
case 216: // text cluster |
| 2433 |
return 0x40003; |
| 2434 |
case 331: |
| 2435 |
case 339: // chart cluster |
| 2436 |
return 0x40004; |
| 2437 |
default: // unknown |
| 2438 |
break; |
| 2439 |
} |
| 2440 |
return -1; |
| 2441 |
} |
| 2442 |
|
| 2443 |
int RagTime5ClusterManager::getClusterFileType(RagTime5Zone &zone) |
| 2444 |
{ |
| 2445 |
long N, fSz, debDataPos; |
| 2446 |
if (!getClusterBasicHeaderInfo(zone, N, fSz, debDataPos)) |
| 2447 |
return -1; |
| 2448 |
int res=-1; |
| 2449 |
|
| 2450 |
MWAWInputStreamPtr input=zone.getInput(); |
| 2451 |
input->setReadInverted(!zone.m_hiLoEndian); |
| 2452 |
switch (N) { |
| 2453 |
case -2: |
| 2454 |
res=0; |
| 2455 |
break; |
| 2456 |
case -5: |
| 2457 |
input->seek(debDataPos+6, librevenge::RVNG_SEEK_SET); // skip id, ... |
| 2458 |
res=static_cast<int>(input->readULong(2)); |
| 2459 |
break; |
| 2460 |
default: |
| 2461 |
if (N<0) { |
| 2462 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::getClusterFileType: unexpected N value\n")); |
| 2463 |
break; |
| 2464 |
} |
| 2465 |
if (fSz==0x20) { |
| 2466 |
input->seek(debDataPos+16, librevenge::RVNG_SEEK_SET); |
| 2467 |
auto fieldType=static_cast<int>(input->readULong(2)); |
| 2468 |
if ((fieldType&0xFFD7)==0x1010) |
| 2469 |
res=0x20001; |
| 2470 |
else if ((fieldType&0xFFD7)==0x310) |
| 2471 |
res=0x30003; |
| 2472 |
else if ((fieldType&0xFFD7)==0x4010) |
| 2473 |
res=0x10000; |
| 2474 |
else { |
| 2475 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::getClusterFileType: unexpected field type %x\n", unsigned(fieldType))); |
| 2476 |
} |
| 2477 |
} |
| 2478 |
else if (fSz==0x22) |
| 2479 |
res=0x30000; |
| 2480 |
else if (fSz==0x28) |
| 2481 |
res=0x30002; |
| 2482 |
else if (fSz==0x29) |
| 2483 |
res=0x20000; |
| 2484 |
else { |
| 2485 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::getClusterFileType: unexpected fSz=%ld\n", fSz)); |
| 2486 |
} |
| 2487 |
break; |
| 2488 |
} |
| 2489 |
input->setReadInverted(false); |
| 2490 |
return res; |
| 2491 |
} |
| 2492 |
|
| 2493 |
bool RagTime5ClusterManager::readClusterGObjProperties(RagTime5Zone &zone) |
| 2494 |
{ |
| 2495 |
MWAWEntry entry=zone.m_entry; |
| 2496 |
libmwaw::DebugFile &ascFile=zone.ascii(); |
| 2497 |
libmwaw::DebugStream f; |
| 2498 |
MWAWInputStreamPtr input=zone.getInput(); |
| 2499 |
input->setReadInverted(!zone.m_hiLoEndian); |
| 2500 |
long debPos=entry.begin(); |
| 2501 |
long endPos=entry.end(); |
| 2502 |
zone.m_isParsed=true; |
| 2503 |
f.str(""); |
| 2504 |
f << "Entries(ClustCGObjProp)[" << zone << "]:"; |
| 2505 |
|
| 2506 |
input->seek(debPos, librevenge::RVNG_SEEK_SET); |
| 2507 |
if (input->readULong(4)==0x5a610600) { // rare, 3 can be good in one file and 1 bad, so... |
| 2508 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readClusterGObjProperties: endian seems bad, reverts it\n")); |
| 2509 |
input->setReadInverted(zone.m_hiLoEndian); |
| 2510 |
f << "##badEndian,"; |
| 2511 |
} |
| 2512 |
ascFile.addPos(debPos); |
| 2513 |
ascFile.addNote(f.str().c_str()); |
| 2514 |
ascFile.addPos(endPos); |
| 2515 |
ascFile.addNote("_"); |
| 2516 |
|
| 2517 |
input->seek(debPos, librevenge::RVNG_SEEK_SET); |
| 2518 |
RagTime5StructManager::GObjPropFieldParser parser("ClustCGObjProp"); |
| 2519 |
m_document.readStructData(zone, endPos, 0, -1, parser, librevenge::RVNGString("ClustCGObjProp")); |
| 2520 |
|
| 2521 |
long pos=input->tell(); |
| 2522 |
if (pos!=endPos) { |
| 2523 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readClusterGObjProperties: find extra data\n")); |
| 2524 |
ascFile.addPos(pos); |
| 2525 |
ascFile.addNote("ClustCGObjProp:##extra"); |
| 2526 |
} |
| 2527 |
input->setReadInverted(false); |
| 2528 |
return true; |
| 2529 |
} |
| 2530 |
|
| 2531 |
std::shared_ptr<RagTime5ClusterManager::Cluster> RagTime5ClusterManager::readRootCluster(RagTime5Zone &zone) |
| 2532 |
{ |
| 2533 |
RagTime5ClusterManagerInternal::RootCParser parser(*this); |
| 2534 |
if (readCluster(zone, parser)) |
| 2535 |
return parser.getCluster(); |
| 2536 |
return std::shared_ptr<Cluster>(); |
| 2537 |
} |
| 2538 |
|
| 2539 |
bool RagTime5ClusterManager::readCluster(RagTime5Zone &zone, std::shared_ptr<RagTime5ClusterManager::Cluster> &cluster, int zoneType) |
| 2540 |
{ |
| 2541 |
cluster.reset(); |
| 2542 |
int zType=-1; |
| 2543 |
if (m_state->m_idToClusterInfoMap.find(zone.m_ids[0])!=m_state->m_idToClusterInfoMap.end()) { |
| 2544 |
auto const &info=m_state->m_idToClusterInfoMap.find(zone.m_ids[0])->second; |
| 2545 |
zoneType=info.m_fileType; |
| 2546 |
zType=info.m_type; |
| 2547 |
} |
| 2548 |
if (zoneType==-1) |
| 2549 |
zoneType=getClusterFileType(zone); |
| 2550 |
if (zType==-1) |
| 2551 |
zType=getClusterType(zone, zoneType); |
| 2552 |
|
| 2553 |
std::shared_ptr<ClusterParser> parser; |
| 2554 |
switch (zType) { |
| 2555 |
case 0: |
| 2556 |
cluster=readRootCluster(zone); |
| 2557 |
break; |
| 2558 |
case 0x1: |
| 2559 |
cluster=m_document.readLayoutCluster(zone, zoneType); |
| 2560 |
break; |
| 2561 |
case 0x42: |
| 2562 |
parser.reset(new RagTime5ClusterManagerInternal::ColPatCParser(*this)); |
| 2563 |
break; |
| 2564 |
case 0x80: |
| 2565 |
parser.reset(new RagTime5ClusterManagerInternal::StyleCParser(*this, zoneType)); |
| 2566 |
break; |
| 2567 |
case 0x104: |
| 2568 |
cluster=m_document.readPipelineCluster(zone, zoneType); |
| 2569 |
break; |
| 2570 |
case 0x10000: // first child of root |
| 2571 |
case 0x20000: // field def |
| 2572 |
case 0x20001: // field pos |
| 2573 |
case 0x30000: // 0th element of child list root |
| 2574 |
case 0x30001: // 1th element of child list root, never seen |
| 2575 |
case 0x30002: // 2th element of child list root |
| 2576 |
case 0x30003: // 3th element of child list root |
| 2577 |
parser.reset(new RagTime5ClusterManagerInternal::RootChildCParser(*this, zType)); |
| 2578 |
break; |
| 2579 |
case 0x40000: |
| 2580 |
cluster=m_document.readPictureCluster(zone, zoneType); |
| 2581 |
break; |
| 2582 |
case 0x40001: |
| 2583 |
cluster=m_document.readGraphicCluster(zone, zoneType); |
| 2584 |
break; |
| 2585 |
case 0x40002: |
| 2586 |
cluster=m_document.readSpreadsheetCluster(zone, zoneType); |
| 2587 |
break; |
| 2588 |
case 0x40003: |
| 2589 |
cluster=m_document.readTextCluster(zone, zoneType); |
| 2590 |
break; |
| 2591 |
case 0x40004: |
| 2592 |
cluster=m_document.readChartCluster(zone, zoneType); |
| 2593 |
break; |
| 2594 |
case 0x40005: |
| 2595 |
cluster=m_document.readButtonCluster(zone, zoneType); |
| 2596 |
break; |
| 2597 |
case 0x40006: { |
| 2598 |
RagTime5ClusterManagerInternal::SoundCParser soundParser(*this, zoneType); |
| 2599 |
if (readCluster(zone, soundParser) && soundParser.getSoundCluster()) { |
| 2600 |
auto sound=soundParser.getSoundCluster(); |
| 2601 |
std::vector<RagTime5StructManager::ZoneLink> listCluster; |
| 2602 |
m_document.readClusterLinkList(sound->m_parentLink, listCluster, "SoundClustLst"); |
| 2603 |
cluster=soundParser.getCluster(); |
| 2604 |
} |
| 2605 |
break; |
| 2606 |
} |
| 2607 |
case 0x40007: { |
| 2608 |
RagTime5ClusterManagerInternal::GroupCParser groupParser(*this, zoneType); |
| 2609 |
if (readCluster(zone, groupParser) && groupParser.getCluster()) { |
| 2610 |
cluster=groupParser.getCluster(); |
| 2611 |
// each group is associated with a list of id, maybe the list of ids corresponding to a type? |
| 2612 |
if (!cluster->m_dataLink.empty()) { |
| 2613 |
cluster->m_dataLink.m_name="groupUnknownLst"; |
| 2614 |
std::vector<long> listIds; |
| 2615 |
m_document.readLongList(cluster->m_dataLink, listIds); |
| 2616 |
} |
| 2617 |
} |
| 2618 |
break; |
| 2619 |
} |
| 2620 |
default: |
| 2621 |
if (!zone.m_entry.valid()) { // rare, but can append; maybe some deleted cluster |
| 2622 |
cluster.reset(new Cluster(Cluster::C_Empty)); |
| 2623 |
cluster->m_hiLoEndian=zone.m_hiLoEndian; |
| 2624 |
break; |
| 2625 |
} |
| 2626 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: can not find cluster type, use default parser\n")); |
| 2627 |
parser.reset(new RagTime5ClusterManagerInternal::UnknownCParser(*this, zoneType)); |
| 2628 |
break; |
| 2629 |
} |
| 2630 |
bool ok=cluster.get() != nullptr; |
| 2631 |
if (!ok && parser) { |
| 2632 |
ok=readCluster(zone, *parser) && parser->getCluster(); |
| 2633 |
cluster=parser->getCluster(); |
| 2634 |
} |
| 2635 |
else if (!ok) { |
| 2636 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: can not find any parser\n")); |
| 2637 |
} |
| 2638 |
if (!ok) |
| 2639 |
return false; |
| 2640 |
|
| 2641 |
// check the level2 child |
| 2642 |
libmwaw::DebugFile &mainAscii=m_document.ascii(); |
| 2643 |
for (auto const &cIt : zone.m_childIdToZoneMap) { |
| 2644 |
auto child=cIt.second; |
| 2645 |
if (!child) continue; |
| 2646 |
child->m_isParsed=true; |
| 2647 |
switch (cIt.first) { |
| 2648 |
case 8: |
| 2649 |
if (child->m_variableD[0] || (child->m_variableD[1]<=0&&cluster->m_type!=Cluster::C_Empty) || child->m_entry.valid()) { |
| 2650 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: refCount seems odd\n")); |
| 2651 |
mainAscii.addPos(child->m_defPosition); |
| 2652 |
mainAscii.addNote("Cluster[child]###"); |
| 2653 |
} |
| 2654 |
break; |
| 2655 |
default: |
| 2656 |
if (child->m_entry.valid() && readClusterGObjProperties(*child)) |
| 2657 |
break; |
| 2658 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: find unknown child zone\n")); |
| 2659 |
mainAscii.addPos(child->m_defPosition); |
| 2660 |
mainAscii.addNote("Cluster[child]###"); |
| 2661 |
break; |
| 2662 |
} |
| 2663 |
} |
| 2664 |
|
| 2665 |
if (m_state->m_idToClusterMap.find(zone.m_ids[0])!=m_state->m_idToClusterMap.end()) { |
| 2666 |
MWAW_DEBUG_MSG(("RagTime5ClusterManager::readCluster: a cluster for zone %d already exists\n", zone.m_ids[0])); |
| 2667 |
} |
| 2668 |
else |
| 2669 |
m_state->m_idToClusterMap[zone.m_ids[0]]=cluster; |
| 2670 |
return true; |
| 2671 |
} |
| 2672 |
|
| 2673 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |