| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Major Contributor(s): |
| 17 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 18 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 19 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 20 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 21 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 22 |
* |
| 23 |
* |
| 24 |
* All Rights Reserved. |
| 25 |
* |
| 26 |
* For minor contributions see the git repository. |
| 27 |
* |
| 28 |
* Alternatively, the contents of this file may be used under the terms of |
| 29 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 30 |
* in which case the provisions of the LGPLv2+ are applicable |
| 31 |
* instead of those above. |
| 32 |
*/ |
| 33 |
|
| 34 |
#include <iomanip> |
| 35 |
#include <iostream> |
| 36 |
#include <limits> |
| 37 |
#include <map> |
| 38 |
#include <sstream> |
| 39 |
|
| 40 |
#include <librevenge/librevenge.h> |
| 41 |
|
| 42 |
#include "MWAWFont.hxx" |
| 43 |
#include "MWAWFontConverter.hxx" |
| 44 |
#include "MWAWGraphicListener.hxx" |
| 45 |
#include "MWAWListener.hxx" |
| 46 |
#include "MWAWParagraph.hxx" |
| 47 |
#include "MWAWParser.hxx" |
| 48 |
#include "MWAWPosition.hxx" |
| 49 |
#include "MWAWSection.hxx" |
| 50 |
|
| 51 |
#include "ClarisDrawParser.hxx" |
| 52 |
#include "ClarisDrawStyleManager.hxx" |
| 53 |
|
| 54 |
#include "ClarisDrawText.hxx" |
| 55 |
|
| 56 |
/** Internal: the structures of a ClarisDrawText */ |
| 57 |
namespace ClarisDrawTextInternal |
| 58 |
{ |
| 59 |
/** the different plc type */ |
| 60 |
enum PLCType { P_Font, P_Ruler, P_Child, P_TextZone, P_Token, P_Unknown}; |
| 61 |
|
| 62 |
/** Internal : the different plc types: mainly for debugging */ |
| 63 |
struct PLC { |
| 64 |
/// the constructor |
| 65 |
PLC() |
| 66 |
: m_type(P_Unknown) |
| 67 |
, m_id(-1) |
| 68 |
, m_extra("") |
| 69 |
{ |
| 70 |
} |
| 71 |
//! operator<< |
| 72 |
friend std::ostream &operator<<(std::ostream &o, PLC const &plc); |
| 73 |
/** the PLC types */ |
| 74 |
PLCType m_type; |
| 75 |
/** the id */ |
| 76 |
int m_id; |
| 77 |
/** extra data */ |
| 78 |
std::string m_extra; |
| 79 |
}; |
| 80 |
|
| 81 |
std::ostream &operator<<(std::ostream &o, PLC const &plc) |
| 82 |
{ |
| 83 |
switch (plc.m_type) { |
| 84 |
case P_Font: |
| 85 |
o << "F"; |
| 86 |
break; |
| 87 |
case P_Ruler: |
| 88 |
o << "R"; |
| 89 |
break; |
| 90 |
case P_Child: |
| 91 |
o << "C"; |
| 92 |
break; |
| 93 |
case P_TextZone: |
| 94 |
o << "TZ"; |
| 95 |
break; |
| 96 |
case P_Token: |
| 97 |
o << "Tok"; |
| 98 |
break; |
| 99 |
case P_Unknown: |
| 100 |
#if !defined(__clang__) |
| 101 |
default: |
| 102 |
#endif |
| 103 |
o << "#Unkn"; |
| 104 |
break; |
| 105 |
} |
| 106 |
if (plc.m_id >= 0) o << plc.m_id; |
| 107 |
else o << "_"; |
| 108 |
if (plc.m_extra.length()) o << ":" << plc.m_extra; |
| 109 |
return o; |
| 110 |
} |
| 111 |
|
| 112 |
/** Internal: class to store the paragraph properties */ |
| 113 |
struct Paragraph final : public MWAWParagraph { |
| 114 |
//! Constructor |
| 115 |
Paragraph() |
| 116 |
: MWAWParagraph() |
| 117 |
, m_labelType(0) |
| 118 |
{ |
| 119 |
} |
| 120 |
Paragraph(Paragraph const &)=default; |
| 121 |
Paragraph &operator=(Paragraph const &)=default; |
| 122 |
//! destructor |
| 123 |
~Paragraph() final; |
| 124 |
//! operator<< |
| 125 |
friend std::ostream &operator<<(std::ostream &o, Paragraph const &ind) |
| 126 |
{ |
| 127 |
o << static_cast<MWAWParagraph const &>(ind) << ","; |
| 128 |
if (ind.m_labelType > 0 && ind.m_labelType < 12) { |
| 129 |
static char const *labelNames[] = { |
| 130 |
"none", "diamond", "bullet", "checkbox", "hardvard", "leader", "legal", |
| 131 |
"upperalpha", "alpha", "numeric", "upperroman", "roman" |
| 132 |
}; |
| 133 |
o << "label=" << labelNames[ind.m_labelType] << ","; |
| 134 |
} |
| 135 |
else if (ind.m_labelType) |
| 136 |
o << "#labelType=" << ind.m_labelType << ","; |
| 137 |
return o; |
| 138 |
} |
| 139 |
//! update the list level |
| 140 |
void updateListLevel(); |
| 141 |
//! the label |
| 142 |
int m_labelType; |
| 143 |
}; |
| 144 |
|
| 145 |
Paragraph::~Paragraph() |
| 146 |
{ |
| 147 |
} |
| 148 |
|
| 149 |
void Paragraph::updateListLevel() |
| 150 |
{ |
| 151 |
int extraLevel = m_labelType!=0 ? 1 : 0; |
| 152 |
if (*m_listLevelIndex+extraLevel<=0) |
| 153 |
return; |
| 154 |
int lev = *m_listLevelIndex+extraLevel; |
| 155 |
m_listLevelIndex = lev; |
| 156 |
MWAWListLevel theLevel; |
| 157 |
theLevel.m_labelWidth=0.2; |
| 158 |
switch (m_labelType) { |
| 159 |
case 0: |
| 160 |
theLevel.m_type = MWAWListLevel::NONE; |
| 161 |
break; |
| 162 |
case 1: // diamond |
| 163 |
theLevel.m_type = MWAWListLevel::BULLET; |
| 164 |
libmwaw::appendUnicode(0x25c7, theLevel.m_bullet); |
| 165 |
break; |
| 166 |
case 3: // checkbox |
| 167 |
theLevel.m_type = MWAWListLevel::BULLET; |
| 168 |
libmwaw::appendUnicode(0x2610, theLevel.m_bullet); |
| 169 |
break; |
| 170 |
case 4: { |
| 171 |
theLevel.m_suffix = (lev <= 3) ? "." : ")"; |
| 172 |
if (lev == 1) theLevel.m_type = MWAWListLevel::UPPER_ROMAN; |
| 173 |
else if (lev == 2) theLevel.m_type = MWAWListLevel::UPPER_ALPHA; |
| 174 |
else if (lev == 3) theLevel.m_type = MWAWListLevel::DECIMAL; |
| 175 |
else if (lev == 4) theLevel.m_type = MWAWListLevel::LOWER_ALPHA; |
| 176 |
else if ((lev%3)==2) { |
| 177 |
theLevel.m_prefix = "("; |
| 178 |
theLevel.m_type = MWAWListLevel::DECIMAL; |
| 179 |
} |
| 180 |
else if ((lev%3)==0) { |
| 181 |
theLevel.m_prefix = "("; |
| 182 |
theLevel.m_type = MWAWListLevel::LOWER_ALPHA; |
| 183 |
} |
| 184 |
else |
| 185 |
theLevel.m_type = MWAWListLevel::LOWER_ROMAN; |
| 186 |
break; |
| 187 |
} |
| 188 |
case 5: // leader |
| 189 |
theLevel.m_type = MWAWListLevel::BULLET; |
| 190 |
theLevel.m_bullet = "+"; // in fact + + and - |
| 191 |
break; |
| 192 |
case 6: // legal |
| 193 |
theLevel.m_type = MWAWListLevel::DECIMAL; |
| 194 |
theLevel.m_numBeforeLabels = lev-1; |
| 195 |
theLevel.m_suffix = "."; |
| 196 |
theLevel.m_labelWidth = 0.2*lev; |
| 197 |
break; |
| 198 |
case 7: |
| 199 |
theLevel.m_type = MWAWListLevel::UPPER_ALPHA; |
| 200 |
theLevel.m_suffix = "."; |
| 201 |
break; |
| 202 |
case 8: |
| 203 |
theLevel.m_type = MWAWListLevel::LOWER_ALPHA; |
| 204 |
theLevel.m_suffix = "."; |
| 205 |
break; |
| 206 |
case 9: |
| 207 |
theLevel.m_type = MWAWListLevel::DECIMAL; |
| 208 |
theLevel.m_suffix = "."; |
| 209 |
break; |
| 210 |
case 10: |
| 211 |
theLevel.m_type = MWAWListLevel::UPPER_ROMAN; |
| 212 |
theLevel.m_suffix = "."; |
| 213 |
break; |
| 214 |
case 11: |
| 215 |
theLevel.m_type = MWAWListLevel::LOWER_ROMAN; |
| 216 |
theLevel.m_suffix = "."; |
| 217 |
break; |
| 218 |
case 2: // bullet |
| 219 |
default: |
| 220 |
theLevel.m_type = MWAWListLevel::BULLET; |
| 221 |
libmwaw::appendUnicode(0x2022, theLevel.m_bullet); |
| 222 |
break; |
| 223 |
} |
| 224 |
m_margins[1]=m_margins[1].get()-theLevel.m_labelWidth; |
| 225 |
m_listLevel=theLevel; |
| 226 |
} |
| 227 |
|
| 228 |
//! paragraph plc |
| 229 |
struct ParagraphPLC { |
| 230 |
//! constructor |
| 231 |
ParagraphPLC() |
| 232 |
: m_rulerId(-1) |
| 233 |
, m_flags(0) |
| 234 |
, m_extra("") |
| 235 |
{ |
| 236 |
} |
| 237 |
//! return the label type |
| 238 |
int getLabelType() const |
| 239 |
{ |
| 240 |
return int((m_flags>>3)&0xF); |
| 241 |
} |
| 242 |
//! operator<< |
| 243 |
friend std::ostream &operator<<(std::ostream &o, ParagraphPLC const &info) |
| 244 |
{ |
| 245 |
if (info.m_rulerId >= 0) o << "P" << info.m_rulerId <<","; |
| 246 |
switch (info.m_flags&3) { |
| 247 |
case 0: // normal |
| 248 |
break; |
| 249 |
case 1: |
| 250 |
o << "hidden,"; |
| 251 |
break; |
| 252 |
case 2: |
| 253 |
o << "collapsed,"; |
| 254 |
break; |
| 255 |
default: |
| 256 |
o<< "hidden/collapsed,"; |
| 257 |
break; |
| 258 |
} |
| 259 |
if (info.m_flags&4) |
| 260 |
o << "flags4,"; |
| 261 |
|
| 262 |
auto listType=int((info.m_flags>>3)&0xF); |
| 263 |
if (listType>0 && listType < 12) { |
| 264 |
static char const *labelNames[] = { |
| 265 |
"none", "diamond", "bullet", "checkbox", "hardvard", "leader", "legal", |
| 266 |
"upperalpha", "alpha", "numeric", "upperroman", "roman" |
| 267 |
}; |
| 268 |
o << labelNames[listType] << ","; |
| 269 |
} |
| 270 |
else if (listType) |
| 271 |
o << "#listType=" << listType << ","; |
| 272 |
if (info.m_flags&0x80) o << "flags80,"; |
| 273 |
auto listLevel=int((info.m_flags>>8)&0xF); |
| 274 |
if (listLevel) o << "level=" << listLevel+1; |
| 275 |
if (info.m_flags>>12) o << "flags=" << std::hex << (info.m_flags>>12) << std::dec << ","; |
| 276 |
if (info.m_extra.length()) o << info.m_extra; |
| 277 |
return o; |
| 278 |
} |
| 279 |
|
| 280 |
/** the ruler id */ |
| 281 |
int m_rulerId; |
| 282 |
/** some flags */ |
| 283 |
int m_flags; |
| 284 |
/** extra data */ |
| 285 |
std::string m_extra; |
| 286 |
}; |
| 287 |
|
| 288 |
/** internal class used to store a text zone */ |
| 289 |
struct TextZoneInfo { |
| 290 |
//! constructor |
| 291 |
TextZoneInfo() |
| 292 |
: m_pos(0) |
| 293 |
, m_N(0) |
| 294 |
, m_extra("") |
| 295 |
{ |
| 296 |
} |
| 297 |
//! operator<< |
| 298 |
friend std::ostream &operator<<(std::ostream &o, TextZoneInfo const &info) |
| 299 |
{ |
| 300 |
o << "pos=" << info.m_pos << ","; |
| 301 |
if (info.m_N >= 0) o << "size=" << info.m_N <<","; |
| 302 |
if (info.m_extra.length()) o << info.m_extra; |
| 303 |
return o; |
| 304 |
} |
| 305 |
//! the position |
| 306 |
long m_pos; |
| 307 |
//! the number of character |
| 308 |
int m_N; |
| 309 |
//! extra data |
| 310 |
std::string m_extra; |
| 311 |
}; |
| 312 |
|
| 313 |
//! token type |
| 314 |
enum TokenType { TKN_UNKNOWN, TKN_FOOTNOTE, TKN_PAGENUMBER, TKN_GRAPHIC, TKN_FIELD }; |
| 315 |
|
| 316 |
/** Internal: class to store field definition: TOKN entry*/ |
| 317 |
struct Token { |
| 318 |
//! constructor |
| 319 |
Token() |
| 320 |
: m_type(TKN_UNKNOWN) |
| 321 |
, m_zoneId(-1), m_page(-1) |
| 322 |
, m_descent(0) |
| 323 |
, m_fieldEntry() |
| 324 |
, m_extra("") |
| 325 |
{ |
| 326 |
for (auto &i : m_unknown) i = 0; |
| 327 |
for (auto &i : m_size) i = 0; |
| 328 |
} |
| 329 |
//! operator << |
| 330 |
friend std::ostream &operator<<(std::ostream &o, Token const &tok); |
| 331 |
//! the type |
| 332 |
TokenType m_type; |
| 333 |
//! the zone id which correspond to this type |
| 334 |
int m_zoneId; |
| 335 |
//! the page |
| 336 |
int m_page; |
| 337 |
//! the size(?) |
| 338 |
int m_size[2]; |
| 339 |
//! the descent |
| 340 |
int m_descent; |
| 341 |
//! the field name entry |
| 342 |
MWAWEntry m_fieldEntry; |
| 343 |
//! the unknown zone |
| 344 |
int m_unknown[3]; |
| 345 |
//! a string used to store the parsing errors |
| 346 |
std::string m_extra; |
| 347 |
}; |
| 348 |
std::ostream &operator<<(std::ostream &o, Token const &tok) |
| 349 |
{ |
| 350 |
switch (tok.m_type) { |
| 351 |
case TKN_FOOTNOTE: |
| 352 |
o << "footnoote,"; |
| 353 |
break; |
| 354 |
case TKN_FIELD: |
| 355 |
o << "field[linked],"; |
| 356 |
break; |
| 357 |
case TKN_PAGENUMBER: |
| 358 |
switch (tok.m_unknown[0]) { |
| 359 |
case 0: |
| 360 |
o << "field[pageNumber],"; |
| 361 |
break; |
| 362 |
case 1: |
| 363 |
o << "field[sectionNumber],"; |
| 364 |
break; |
| 365 |
case 2: |
| 366 |
o << "field[sectionInPageNumber],"; |
| 367 |
break; |
| 368 |
case 3: |
| 369 |
o << "field[pageCount],"; |
| 370 |
break; |
| 371 |
default: |
| 372 |
o << "field[pageNumber=#" << tok.m_unknown[0] << "],"; |
| 373 |
break; |
| 374 |
} |
| 375 |
break; |
| 376 |
case TKN_GRAPHIC: |
| 377 |
o << "graphic,"; |
| 378 |
break; |
| 379 |
case TKN_UNKNOWN: |
| 380 |
#if !defined(__clang__) |
| 381 |
default: |
| 382 |
#endif |
| 383 |
o << "##field[unknown]" << ","; |
| 384 |
break; |
| 385 |
} |
| 386 |
if (tok.m_zoneId != -1) o << "zoneId=" << tok.m_zoneId << ","; |
| 387 |
if (tok.m_page != -1) o << "page?=" << tok.m_page << ","; |
| 388 |
o << "pos?=" << tok.m_size[0] << "x" << tok.m_size[1] << ","; |
| 389 |
if (tok.m_descent) o << "descent=" << tok.m_descent << ","; |
| 390 |
for (int i = 0; i < 3; i++) { |
| 391 |
if (tok.m_unknown[i] == 0 || (i==0 && tok.m_type==TKN_PAGENUMBER)) |
| 392 |
continue; |
| 393 |
o << "#unkn" << i << "=" << std::hex << tok.m_unknown[i] << std::dec << ","; |
| 394 |
} |
| 395 |
if (!tok.m_extra.empty()) o << "err=[" << tok.m_extra << "]"; |
| 396 |
return o; |
| 397 |
} |
| 398 |
|
| 399 |
//! low level internal: main text zone |
| 400 |
struct DSET final : public ClarisWksStruct::DSET { |
| 401 |
//! constructor |
| 402 |
explicit DSET(ClarisWksStruct::DSET const &dset = ClarisWksStruct::DSET()) |
| 403 |
: ClarisWksStruct::DSET(dset) |
| 404 |
, m_zones() |
| 405 |
, m_numChar(0) |
| 406 |
, m_numTextZone(0) |
| 407 |
, m_numParagInfo(0) |
| 408 |
, m_numFont(0) |
| 409 |
, m_fatherId(0) |
| 410 |
, m_unknown(0) |
| 411 |
, m_subSectionPosList() |
| 412 |
, m_fontList() |
| 413 |
, m_paragraphList() |
| 414 |
, m_tokenList() |
| 415 |
, m_textZoneList() |
| 416 |
, m_plcMap() |
| 417 |
{ |
| 418 |
} |
| 419 |
//! destructor |
| 420 |
~DSET() final; |
| 421 |
//! true if the zone is outlined |
| 422 |
bool isOutlined() const |
| 423 |
{ |
| 424 |
return m_flags[0]==1; |
| 425 |
} |
| 426 |
//! operator<< |
| 427 |
friend std::ostream &operator<<(std::ostream &o, DSET const &doc) |
| 428 |
{ |
| 429 |
o << static_cast<ClarisWksStruct::DSET const &>(doc); |
| 430 |
if (doc.m_numChar) o << "numChar=" << doc.m_numChar << ","; |
| 431 |
if (doc.m_numTextZone) o << "numTextZone=" << doc.m_numTextZone << ","; |
| 432 |
if (doc.m_numParagInfo) o << "numParag=" << doc.m_numParagInfo << ","; |
| 433 |
if (doc.m_numFont) o << "numFont=" << doc.m_numFont << ","; |
| 434 |
if (doc.m_fatherId) o << "id[father]=" << doc.m_fatherId << ","; |
| 435 |
if (doc.m_unknown) o << "unkn=" << doc.m_unknown << ","; |
| 436 |
return o; |
| 437 |
} |
| 438 |
|
| 439 |
std::vector<MWAWEntry> m_zones; // the text zones |
| 440 |
int m_numChar /** the number of char in text zone */; |
| 441 |
int m_numTextZone /** the number of text zone ( ie. number of page ? ) */; |
| 442 |
int m_numParagInfo /** the number of paragraph info */; |
| 443 |
int m_numFont /** the number of font */; |
| 444 |
int m_fatherId /** the father id */; |
| 445 |
int m_unknown /** an unknown flags */; |
| 446 |
|
| 447 |
std::vector<long> m_subSectionPosList /** list of end of section position */; |
| 448 |
std::vector<MWAWFont> m_fontList /** the list of fonts */; |
| 449 |
std::vector<ParagraphPLC> m_paragraphList /** the list of paragraph */; |
| 450 |
std::vector<Token> m_tokenList /** the list of token */; |
| 451 |
std::vector<TextZoneInfo> m_textZoneList /** the list of zone */; |
| 452 |
std::multimap<long, PLC> m_plcMap /** the plc map */; |
| 453 |
}; |
| 454 |
|
| 455 |
DSET::~DSET() |
| 456 |
{ |
| 457 |
} |
| 458 |
|
| 459 |
//////////////////////////////////////// |
| 460 |
//! Internal: the state of a ClarisDrawText |
| 461 |
struct State { |
| 462 |
//! constructor |
| 463 |
State() |
| 464 |
: m_version(-1) |
| 465 |
, m_paragraphsList() |
| 466 |
, m_zoneMap() |
| 467 |
{ |
| 468 |
} |
| 469 |
|
| 470 |
//! the file version |
| 471 |
mutable int m_version; |
| 472 |
//! the list of paragraph |
| 473 |
std::vector<Paragraph> m_paragraphsList; |
| 474 |
//! the list of text zone |
| 475 |
std::map<int, std::shared_ptr<DSET> > m_zoneMap; |
| 476 |
}; |
| 477 |
|
| 478 |
} |
| 479 |
|
| 480 |
//////////////////////////////////////////////////////////// |
| 481 |
// constructor/destructor, ... |
| 482 |
//////////////////////////////////////////////////////////// |
| 483 |
ClarisDrawText::ClarisDrawText(ClarisDrawParser &parser) |
| 484 |
: m_parserState(parser.getParserState()) |
| 485 |
, m_state(new ClarisDrawTextInternal::State) |
| 486 |
, m_mainParser(&parser) |
| 487 |
, m_styleManager(parser.m_styleManager) |
| 488 |
{ |
| 489 |
} |
| 490 |
|
| 491 |
ClarisDrawText::~ClarisDrawText() |
| 492 |
{ } |
| 493 |
|
| 494 |
int ClarisDrawText::version() const |
| 495 |
{ |
| 496 |
if (m_state->m_version < 0) |
| 497 |
m_state->m_version = m_parserState->m_version; |
| 498 |
return m_state->m_version; |
| 499 |
} |
| 500 |
|
| 501 |
void ClarisDrawText::resetState() |
| 502 |
{ |
| 503 |
m_state.reset(new ClarisDrawTextInternal::State); |
| 504 |
} |
| 505 |
|
| 506 |
int ClarisDrawText::numPages() const |
| 507 |
{ |
| 508 |
// to do |
| 509 |
return 0; |
| 510 |
} |
| 511 |
|
| 512 |
//////////////////////////////////////////////////////////// |
| 513 |
// Intermediate level |
| 514 |
//////////////////////////////////////////////////////////// |
| 515 |
|
| 516 |
//////////////////////////////////////////////////////////// |
| 517 |
// a document part |
| 518 |
//////////////////////////////////////////////////////////// |
| 519 |
std::shared_ptr<ClarisWksStruct::DSET> ClarisDrawText::readDSETZone(ClarisWksStruct::DSET const &zone, MWAWEntry const &entry) |
| 520 |
{ |
| 521 |
if (!entry.valid() || zone.m_fileType != 1) |
| 522 |
return std::shared_ptr<ClarisWksStruct::DSET>(); |
| 523 |
long pos = entry.begin(); |
| 524 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 525 |
input->seek(pos+8+16, librevenge::RVNG_SEEK_SET); // avoid header+8 generic number |
| 526 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 527 |
libmwaw::DebugStream f; |
| 528 |
f << "Entries(DSETT):"; |
| 529 |
|
| 530 |
std::shared_ptr<ClarisDrawTextInternal::DSET> textZone(new ClarisDrawTextInternal::DSET(zone)); |
| 531 |
textZone->m_unknown = static_cast<int>(input->readULong(2)); // alway 0 ? |
| 532 |
textZone->m_fatherId = static_cast<int>(input->readULong(2)); |
| 533 |
textZone->m_numChar = static_cast<int>(input->readULong(4)); |
| 534 |
textZone->m_numTextZone = static_cast<int>(input->readULong(2)); |
| 535 |
textZone->m_numParagInfo = static_cast<int>(input->readULong(2)); |
| 536 |
textZone->m_numFont = static_cast<int>(input->readULong(2)); |
| 537 |
switch (textZone->m_textType >> 4) { |
| 538 |
case 2: |
| 539 |
textZone->m_position = ClarisWksStruct::DSET::P_Header; |
| 540 |
break; |
| 541 |
case 4: |
| 542 |
textZone->m_position = ClarisWksStruct::DSET::P_Footer; |
| 543 |
break; |
| 544 |
case 6: |
| 545 |
textZone->m_position = ClarisWksStruct::DSET::P_Footnote; |
| 546 |
break; |
| 547 |
case 8: |
| 548 |
textZone->m_position = ClarisWksStruct::DSET::P_Frame; |
| 549 |
break; |
| 550 |
case 0xe: |
| 551 |
textZone->m_position = ClarisWksStruct::DSET::P_Table; |
| 552 |
break; |
| 553 |
case 0: |
| 554 |
if (zone.m_id==1) { |
| 555 |
textZone->m_position = ClarisWksStruct::DSET::P_Main; |
| 556 |
break; |
| 557 |
} |
| 558 |
MWAW_FALLTHROUGH; |
| 559 |
default: |
| 560 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone: find unknown position %d\n", (textZone->m_textType >> 4))); |
| 561 |
f << "#position="<< (textZone->m_textType >> 4) << ","; |
| 562 |
break; |
| 563 |
} |
| 564 |
// find 2,3,6,a,b,e,f |
| 565 |
if (textZone->m_textType != ClarisWksStruct::DSET::P_Unknown) |
| 566 |
textZone->m_textType &= 0xF; |
| 567 |
f << *textZone << ","; |
| 568 |
|
| 569 |
if (long(input->tell())%2) |
| 570 |
input->seek(1, librevenge::RVNG_SEEK_CUR); |
| 571 |
ascFile.addDelimiter(input->tell(), '|'); |
| 572 |
ascFile.addPos(pos); |
| 573 |
ascFile.addNote(f.str().c_str()); |
| 574 |
|
| 575 |
// read the last part |
| 576 |
int const data0Length = 28; |
| 577 |
|
| 578 |
auto N = int(zone.m_numData); |
| 579 |
if (N<0 || long(input->tell())+N*data0Length > entry.end()) { |
| 580 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone: file is too short\n")); |
| 581 |
return std::shared_ptr<ClarisWksStruct::DSET>(); |
| 582 |
} |
| 583 |
|
| 584 |
input->seek(entry.end()-N*data0Length, librevenge::RVNG_SEEK_SET); |
| 585 |
ClarisDrawTextInternal::PLC plc; |
| 586 |
plc.m_type = ClarisDrawTextInternal::P_Child; |
| 587 |
int numExtraHId=0; |
| 588 |
textZone->m_subSectionPosList.push_back(0); |
| 589 |
for (int i = 0; i < N; i++) { // normally 1 |
| 590 |
/* definition of a list of text zone ( one by column and one by page )*/ |
| 591 |
pos = input->tell(); |
| 592 |
f.str(""); |
| 593 |
f << "DSETT-" << i << ":"; |
| 594 |
ClarisWksStruct::DSET::Child child; |
| 595 |
child.m_posC = long(input->readULong(4)); |
| 596 |
if (child.m_posC>textZone->m_subSectionPosList.back()) |
| 597 |
textZone->m_subSectionPosList.push_back(child.m_posC); |
| 598 |
child.m_type = ClarisWksStruct::DSET::C_SubText; |
| 599 |
int dim[2]; |
| 600 |
for (int &j : dim) j = static_cast<int>(input->readLong(2)); |
| 601 |
child.m_box = MWAWBox2f(MWAWVec2f(0,0), MWAWVec2f(float(dim[0]), float(dim[1]))); |
| 602 |
textZone->m_childs.push_back(child); |
| 603 |
plc.m_id = i; |
| 604 |
textZone->m_plcMap.insert(std::map<long, ClarisDrawTextInternal::PLC>::value_type(child.m_posC, plc)); |
| 605 |
f << child; |
| 606 |
f << "ptr=" << std::hex << input->readULong(4) << std::dec << ","; |
| 607 |
f << "f0=" << input->readLong(2) << ","; // a small number : number of line ? |
| 608 |
f << "y[real]=" << input->readLong(2) << ","; |
| 609 |
for (int j = 1; j < 4; j++) { |
| 610 |
auto val = static_cast<int>(input->readLong(2)); |
| 611 |
if (val) |
| 612 |
f << "f" << j << "=" << val << ","; |
| 613 |
} |
| 614 |
auto order = static_cast<int>(input->readLong(2)); |
| 615 |
// simple id or 0: main text ?, 1 : header/footnote ?, 2: footer => id or order? |
| 616 |
if (order) |
| 617 |
f << "order?=" << order << ","; |
| 618 |
|
| 619 |
auto id=static_cast<long>(input->readULong(4)); |
| 620 |
if (id) { |
| 621 |
f << "ID=" << std::hex << id << std::dec << ","; |
| 622 |
++numExtraHId; |
| 623 |
} |
| 624 |
|
| 625 |
long actPos = input->tell(); |
| 626 |
if (actPos != pos && actPos != pos+data0Length) |
| 627 |
ascFile.addDelimiter(input->tell(),'|'); |
| 628 |
input->seek(pos+data0Length, librevenge::RVNG_SEEK_SET); |
| 629 |
|
| 630 |
ascFile.addPos(pos); |
| 631 |
ascFile.addNote(f.str().c_str()); |
| 632 |
} |
| 633 |
|
| 634 |
input->seek(entry.end(), librevenge::RVNG_SEEK_SET); |
| 635 |
|
| 636 |
// now normally 4 zones: paragraph, font, token, text zone size + 1 zone for each text zone |
| 637 |
bool ok=true; |
| 638 |
for (int z = 0; z < 4+textZone->m_numTextZone; z++) { |
| 639 |
pos = input->tell(); |
| 640 |
if (input->isEnd()) { |
| 641 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone: can not find some zone\n")); |
| 642 |
if (z > 4) |
| 643 |
break; |
| 644 |
return textZone; |
| 645 |
} |
| 646 |
auto sz = long(input->readULong(4)); |
| 647 |
if (!sz) { |
| 648 |
f.str(""); |
| 649 |
f << "DSETT-Z" << z; |
| 650 |
ascFile.addPos(pos); |
| 651 |
ascFile.addNote(f.str().c_str()); |
| 652 |
continue; |
| 653 |
} |
| 654 |
|
| 655 |
MWAWEntry zEntry; |
| 656 |
zEntry.setBegin(pos); |
| 657 |
zEntry.setLength(sz+4); |
| 658 |
|
| 659 |
if (!input->checkPosition(zEntry.end())) { |
| 660 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone: entry for %d zone is too short\n", z)); |
| 661 |
ascFile.addPos(pos); |
| 662 |
ascFile.addNote("###"); |
| 663 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 664 |
if (z > 4) |
| 665 |
break; |
| 666 |
return textZone; |
| 667 |
} |
| 668 |
|
| 669 |
switch (z) { |
| 670 |
case 0: |
| 671 |
ok = readParagraphs(zEntry, *textZone); |
| 672 |
break; |
| 673 |
case 1: |
| 674 |
ok = readFonts(zEntry, *textZone); |
| 675 |
break; |
| 676 |
case 2: |
| 677 |
ok = readTokens(zEntry, *textZone); |
| 678 |
break; |
| 679 |
case 3: |
| 680 |
ok = readTextZoneSize(zEntry, *textZone); |
| 681 |
break; |
| 682 |
default: |
| 683 |
textZone->m_zones.push_back(zEntry); |
| 684 |
break; |
| 685 |
} |
| 686 |
if (!ok) { |
| 687 |
if (z >= 4) { |
| 688 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 689 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone: can not find text %d zone\n", z-4)); |
| 690 |
if (z > 4) break; |
| 691 |
return textZone; |
| 692 |
} |
| 693 |
f.str(""); |
| 694 |
f << "DSETT-Z" << z << "#"; |
| 695 |
ascFile.addPos(pos); |
| 696 |
ascFile.addNote(f.str().c_str()); |
| 697 |
} |
| 698 |
input->seek(zEntry.end(), librevenge::RVNG_SEEK_SET); |
| 699 |
} |
| 700 |
// never seems |
| 701 |
for (int i=0; ok && i<numExtraHId; ++i) { |
| 702 |
pos=input->tell(); |
| 703 |
auto sz=long(input->readULong(4)); |
| 704 |
if (sz<10 || !input->checkPosition(pos+4+sz)) { |
| 705 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone:: can not read an extra block\n")); |
| 706 |
ascFile.addPos(pos); |
| 707 |
ascFile.addNote("DSETT-extra:###"); |
| 708 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 709 |
ok=false; |
| 710 |
break; |
| 711 |
} |
| 712 |
f.str(""); |
| 713 |
f << "DSETT-extra:"; |
| 714 |
/* Checkme: no sure how to read this unfrequent structures */ |
| 715 |
auto val=static_cast<int>(input->readLong(2)); // 2 (with size=34 or 4c)|a(with size=a or e)|3c (with size 3c) |
| 716 |
f << "type?=" << val << ","; |
| 717 |
int dim[4]; |
| 718 |
for (int &j : dim) j=static_cast<int>(input->readLong(2)); |
| 719 |
f << "dim=" << dim[1] << "x" << dim[0] << "<->" << dim[3] << "x" << dim[2] << ","; |
| 720 |
if (sz!=10) ascFile.addDelimiter(input->tell(),'|'); |
| 721 |
ascFile.addPos(pos); |
| 722 |
ascFile.addNote(f.str().c_str()); |
| 723 |
input->seek(pos+4+sz, librevenge::RVNG_SEEK_SET); |
| 724 |
} |
| 725 |
|
| 726 |
if (m_state->m_zoneMap.find(textZone->m_id) != m_state->m_zoneMap.end()) { |
| 727 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone: zone %d already exists!!!\n", textZone->m_id)); |
| 728 |
} |
| 729 |
else |
| 730 |
m_state->m_zoneMap[textZone->m_id] = textZone; |
| 731 |
|
| 732 |
if (ok) { |
| 733 |
// look for unparsed zone |
| 734 |
pos=input->tell(); |
| 735 |
auto sz=long(input->readULong(4)); |
| 736 |
if (input->checkPosition(pos+4+sz)) { |
| 737 |
if (sz) { |
| 738 |
MWAW_DEBUG_MSG(("ClarisDrawText::readDSETZone:: find some extra block\n")); |
| 739 |
input->seek(pos+4+sz, librevenge::RVNG_SEEK_SET); |
| 740 |
ascFile.addPos(pos); |
| 741 |
ascFile.addNote("Entries(TextEnd):###"); |
| 742 |
} |
| 743 |
else { |
| 744 |
// 2 empty zone is ok, if not probably a problem, but... |
| 745 |
ascFile.addPos(pos); |
| 746 |
ascFile.addNote("_"); |
| 747 |
} |
| 748 |
} |
| 749 |
else |
| 750 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 751 |
} |
| 752 |
|
| 753 |
return textZone; |
| 754 |
} |
| 755 |
//////////////////////////////////////////////////////////// |
| 756 |
// |
| 757 |
// Low level |
| 758 |
// |
| 759 |
//////////////////////////////////////////////////////////// |
| 760 |
bool ClarisDrawText::readFonts(MWAWEntry const &entry, ClarisDrawTextInternal::DSET &zone) |
| 761 |
{ |
| 762 |
long pos = entry.begin(); |
| 763 |
if ((entry.length()%12) != 4) |
| 764 |
return false; |
| 765 |
|
| 766 |
auto numElt = int((entry.length()-4)/12); |
| 767 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 768 |
input->seek(pos+4, librevenge::RVNG_SEEK_SET); // skip header |
| 769 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 770 |
ascFile.addPos(pos); |
| 771 |
ascFile.addNote("Entries(FontPLC)"); |
| 772 |
|
| 773 |
ClarisDrawTextInternal::PLC plc; |
| 774 |
plc.m_type = ClarisDrawTextInternal::P_Font; |
| 775 |
for (int i = 0; i < numElt; i++) { |
| 776 |
MWAWFont font; |
| 777 |
int posChar; |
| 778 |
if (!readFont(i, posChar, font)) return false; |
| 779 |
zone.m_fontList.push_back(font); |
| 780 |
plc.m_id = i; |
| 781 |
zone.m_plcMap.insert(std::map<long, ClarisDrawTextInternal::PLC>::value_type(posChar, plc)); |
| 782 |
} |
| 783 |
|
| 784 |
return true; |
| 785 |
} |
| 786 |
|
| 787 |
|
| 788 |
bool ClarisDrawText::readFont(int id, int &posC, MWAWFont &font) |
| 789 |
{ |
| 790 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 791 |
long pos = input->tell(); |
| 792 |
|
| 793 |
int const fontSize = 12; |
| 794 |
if (!input->checkPosition(pos+fontSize)) { |
| 795 |
MWAW_DEBUG_MSG(("ClarisDrawText::readFont: file is too short")); |
| 796 |
return false; |
| 797 |
} |
| 798 |
|
| 799 |
font = MWAWFont(); |
| 800 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 801 |
libmwaw::DebugStream f; |
| 802 |
if (id >= 0) |
| 803 |
f << "FontPLC-F" << id << ":"; |
| 804 |
else |
| 805 |
f << "Entries(FontDef):"; |
| 806 |
posC = int(input->readULong(4)); |
| 807 |
f << "pos=" << posC << ","; |
| 808 |
font.setId(static_cast<int>(input->readULong(2))); |
| 809 |
auto flag =static_cast<int>(input->readULong(2)); |
| 810 |
uint32_t flags=0; |
| 811 |
if (flag&0x1) flags |= MWAWFont::boldBit; |
| 812 |
if (flag&0x2) flags |= MWAWFont::italicBit; |
| 813 |
if (flag&0x4) font.setUnderlineStyle(MWAWFont::Line::Simple); |
| 814 |
if (flag&0x8) flags |= MWAWFont::embossBit; |
| 815 |
if (flag&0x10) flags |= MWAWFont::shadowBit; |
| 816 |
if (flag&0x20) font.setDeltaLetterSpacing(-1); |
| 817 |
if (flag&0x40) font.setDeltaLetterSpacing(1); |
| 818 |
if (flag&0x80) font.setStrikeOutStyle(MWAWFont::Line::Simple); |
| 819 |
if (flag&0x100) font.set(MWAWFont::Script::super100()); |
| 820 |
if (flag&0x200) font.set(MWAWFont::Script::sub100()); |
| 821 |
if (flag&0x400) font.set(MWAWFont::Script::super()); |
| 822 |
if (flag&0x800) font.set(MWAWFont::Script::sub()); |
| 823 |
if (flag&0x2000) { |
| 824 |
font.setUnderlineStyle(MWAWFont::Line::Simple); |
| 825 |
font.setUnderlineType(MWAWFont::Line::Double); |
| 826 |
} |
| 827 |
font.setSize(float(input->readULong(2))); |
| 828 |
auto colId = static_cast<int>(input->readULong(1)); |
| 829 |
if (colId) f << "#backColor=" << colId << ","; |
| 830 |
colId = static_cast<int>(input->readULong(1)); |
| 831 |
if (colId!=1) { |
| 832 |
MWAWColor col; |
| 833 |
if (m_styleManager->getColor(colId, col)) |
| 834 |
font.setColor(col); |
| 835 |
else { |
| 836 |
MWAW_DEBUG_MSG(("ClarisDrawText::readFont: unknown color %d\n", colId)); |
| 837 |
f << "##colId=" << colId << ","; |
| 838 |
} |
| 839 |
} |
| 840 |
font.setFlags(flags); |
| 841 |
f << font.getDebugString(m_parserState->m_fontConverter); |
| 842 |
if (long(input->tell()) != pos+fontSize) |
| 843 |
ascFile.addDelimiter(input->tell(), '|'); |
| 844 |
input->seek(pos+fontSize, librevenge::RVNG_SEEK_SET); |
| 845 |
ascFile.addPos(pos); |
| 846 |
ascFile.addNote(f.str().c_str()); |
| 847 |
return true; |
| 848 |
} |
| 849 |
|
| 850 |
//////////////////////////////////////////////////////////// |
| 851 |
// read a list of rulers |
| 852 |
//////////////////////////////////////////////////////////// |
| 853 |
bool ClarisDrawText::readParagraphs() |
| 854 |
{ |
| 855 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 856 |
long pos = input->tell(); |
| 857 |
ClarisWksStruct::Struct header; |
| 858 |
if (!header.readHeader(input,true)) { |
| 859 |
MWAW_DEBUG_MSG(("ClarisDrawText::readParagraphs: can not reead the header\n")); |
| 860 |
return false; |
| 861 |
} |
| 862 |
|
| 863 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 864 |
libmwaw::DebugStream f; |
| 865 |
f << "Entries(RULR):" << header; |
| 866 |
if (header.m_headerSize) { |
| 867 |
ascFile.addDelimiter(input->tell(),'|'); |
| 868 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 869 |
} |
| 870 |
ascFile.addPos(pos); |
| 871 |
ascFile.addNote(f.str().c_str()); |
| 872 |
|
| 873 |
for (int i = 0; i < int(header.m_numData); i++) { |
| 874 |
pos = input->tell(); |
| 875 |
if (!readParagraph(i)) { |
| 876 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 877 |
return false; |
| 878 |
} |
| 879 |
} |
| 880 |
return true; |
| 881 |
} |
| 882 |
|
| 883 |
bool ClarisDrawText::readParagraphs(MWAWEntry const &entry, ClarisDrawTextInternal::DSET &zone) |
| 884 |
{ |
| 885 |
long pos = entry.begin(); |
| 886 |
if ((entry.length()%8) != 4) |
| 887 |
return false; |
| 888 |
|
| 889 |
auto numElt = int((entry.length()-4)/8); |
| 890 |
|
| 891 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 892 |
input->seek(pos+4, librevenge::RVNG_SEEK_SET); // skip header |
| 893 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 894 |
pos = entry.begin(); |
| 895 |
ascFile.addPos(pos); |
| 896 |
ascFile.addNote("Entries(ParaPLC)"); |
| 897 |
|
| 898 |
libmwaw::DebugStream f; |
| 899 |
input->seek(pos+4, librevenge::RVNG_SEEK_SET); // skip header |
| 900 |
ClarisDrawTextInternal::PLC plc; |
| 901 |
plc.m_type = ClarisDrawTextInternal::P_Ruler; |
| 902 |
for (int i = 0; i < numElt; i++) { |
| 903 |
pos = input->tell(); |
| 904 |
ClarisDrawTextInternal::ParagraphPLC info; |
| 905 |
|
| 906 |
auto posC = long(input->readULong(4)); |
| 907 |
f.str(""); |
| 908 |
f << "ParaPLC-R" << i << ": pos=" << posC << ","; |
| 909 |
info.m_rulerId = static_cast<int>(input->readLong(2)); |
| 910 |
info.m_flags = static_cast<int>(input->readLong(2)); |
| 911 |
f << info; |
| 912 |
|
| 913 |
zone.m_paragraphList.push_back(info); |
| 914 |
plc.m_id = i; |
| 915 |
zone.m_plcMap.insert(std::map<long, ClarisDrawTextInternal::PLC>::value_type(posC, plc)); |
| 916 |
input->seek(pos+8, librevenge::RVNG_SEEK_SET); |
| 917 |
ascFile.addPos(pos); |
| 918 |
ascFile.addNote(f.str().c_str()); |
| 919 |
} |
| 920 |
|
| 921 |
return true; |
| 922 |
} |
| 923 |
|
| 924 |
//////////////////////////////////////////////////////////// |
| 925 |
// read a ruler zone |
| 926 |
//////////////////////////////////////////////////////////// |
| 927 |
bool ClarisDrawText::readParagraph(int id) |
| 928 |
{ |
| 929 |
int const dataSize=96; |
| 930 |
ClarisDrawTextInternal::Paragraph ruler; |
| 931 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 932 |
long pos = input->tell(); |
| 933 |
long endPos = pos+dataSize; |
| 934 |
if (!input->checkPosition(endPos)) { |
| 935 |
MWAW_DEBUG_MSG(("ClarisDrawText::readParagraph: file is too short\n")); |
| 936 |
return false; |
| 937 |
} |
| 938 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 939 |
libmwaw::DebugStream f; |
| 940 |
|
| 941 |
int val; |
| 942 |
val = static_cast<int>(input->readLong(2)); |
| 943 |
f << "num[used]=" << val << ","; |
| 944 |
val = static_cast<int>(input->readULong(2)); |
| 945 |
int align = 0; |
| 946 |
align = (val >> 14); |
| 947 |
val &= 0x3FFF; |
| 948 |
switch (align) { |
| 949 |
case 0: |
| 950 |
break; |
| 951 |
case 1: |
| 952 |
ruler.m_justify = MWAWParagraph::JustificationCenter; |
| 953 |
break; |
| 954 |
case 2: |
| 955 |
ruler.m_justify = MWAWParagraph::JustificationRight ; |
| 956 |
break; |
| 957 |
case 3: |
| 958 |
ruler.m_justify = MWAWParagraph::JustificationFull; |
| 959 |
break; |
| 960 |
default: |
| 961 |
break; |
| 962 |
} |
| 963 |
|
| 964 |
bool inPoint = (val & 0x2000); |
| 965 |
int interline = val & 0xFF; |
| 966 |
if (interline) { |
| 967 |
if (inPoint) |
| 968 |
ruler.setInterline(interline, librevenge::RVNG_POINT); |
| 969 |
else |
| 970 |
ruler.setInterline(1.0+double(interline)/8, librevenge::RVNG_PERCENT); |
| 971 |
} |
| 972 |
if (val) f << "#flags=" << std::hex << val << std::dec << ","; |
| 973 |
for (auto &margin : ruler.m_margins) |
| 974 |
margin = double(input->readLong(2))/72.; |
| 975 |
*(ruler.m_margins[2]) -= 28./72.; |
| 976 |
if (ruler.m_margins[2].get() < 0.0) ruler.m_margins[2] = 0.0; |
| 977 |
for (int i = 0; i < 2; i++) { |
| 978 |
ruler.m_spacings[i+1] = double(input->readULong(1))/72.; |
| 979 |
input->seek(1, librevenge::RVNG_SEEK_CUR); // flags to define the printing unit |
| 980 |
} |
| 981 |
val = static_cast<int>(input->readLong(1)); |
| 982 |
if (val) f << "unkn1=" << val << ","; |
| 983 |
auto numTabs = static_cast<int>(input->readULong(1)); |
| 984 |
if (long(input->tell())+numTabs*4 > endPos) { |
| 985 |
if (numTabs != 255) { // 0xFF seems to be used in v1, v2 |
| 986 |
MWAW_DEBUG_MSG(("ClarisDrawText::readParagraph: numTabs is too big\n")); |
| 987 |
} |
| 988 |
f << "numTabs*=" << numTabs << ","; |
| 989 |
numTabs = 0; |
| 990 |
} |
| 991 |
for (int i = 0; i < numTabs; i++) { |
| 992 |
MWAWTabStop tab; |
| 993 |
tab.m_position = double(input->readLong(2))/72.; |
| 994 |
val = static_cast<int>(input->readULong(1)); |
| 995 |
switch ((val>>6)&3) { |
| 996 |
case 1: |
| 997 |
tab.m_alignment = MWAWTabStop::CENTER; |
| 998 |
break; |
| 999 |
case 2: |
| 1000 |
tab.m_alignment = MWAWTabStop::RIGHT; |
| 1001 |
break; |
| 1002 |
case 3: |
| 1003 |
tab.m_alignment = MWAWTabStop::DECIMAL; |
| 1004 |
break; |
| 1005 |
case 0: // left |
| 1006 |
default: |
| 1007 |
break; |
| 1008 |
} |
| 1009 |
switch (val&3) { |
| 1010 |
case 1: |
| 1011 |
tab.m_leaderCharacter = '.'; |
| 1012 |
break; |
| 1013 |
case 2: |
| 1014 |
tab.m_leaderCharacter = '-'; |
| 1015 |
break; |
| 1016 |
case 3: |
| 1017 |
tab.m_leaderCharacter = '_'; |
| 1018 |
break; |
| 1019 |
case 0: |
| 1020 |
default: |
| 1021 |
break; |
| 1022 |
} |
| 1023 |
val &= 0x3C; |
| 1024 |
auto decimalChar = char(input->readULong(1)); |
| 1025 |
if (decimalChar) { |
| 1026 |
int unicode= m_parserState->m_fontConverter->unicode(3, static_cast<unsigned char>(decimalChar)); |
| 1027 |
if (unicode==-1) |
| 1028 |
tab.m_decimalCharacter = uint16_t(decimalChar); |
| 1029 |
else |
| 1030 |
tab.m_decimalCharacter = uint16_t(unicode); |
| 1031 |
} |
| 1032 |
ruler.m_tabs->push_back(tab); |
| 1033 |
if (val) |
| 1034 |
f << "#unkn[tab" << i << "=" << std::hex << val << std::dec << "],"; |
| 1035 |
} |
| 1036 |
ruler.m_extra = f.str(); |
| 1037 |
// save the style |
| 1038 |
if (id >= 0) { |
| 1039 |
if (int(m_state->m_paragraphsList.size()) <= id) |
| 1040 |
m_state->m_paragraphsList.resize(size_t(id)+1); |
| 1041 |
m_state->m_paragraphsList[size_t(id)]=ruler; |
| 1042 |
} |
| 1043 |
f.str(""); |
| 1044 |
if (id == 0) |
| 1045 |
f << "Entries(RULR)-P0"; |
| 1046 |
else if (id < 0) |
| 1047 |
f << "Entries(RULR)-P_"; |
| 1048 |
else |
| 1049 |
f << "RULR-P" << id; |
| 1050 |
f << ":" << ruler; |
| 1051 |
|
| 1052 |
if (long(input->tell()) != pos+dataSize) |
| 1053 |
ascFile.addDelimiter(input->tell(), '|'); |
| 1054 |
ascFile.addPos(pos); |
| 1055 |
ascFile.addNote(f.str().c_str()); |
| 1056 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1057 |
if (long(input->tell()) != pos+dataSize) |
| 1058 |
return false; |
| 1059 |
return true; |
| 1060 |
} |
| 1061 |
|
| 1062 |
//////////////////////////////////////////////////////////// |
| 1063 |
// zone which corresponds to the token (never seens data, so suppose that this is simillar to ClarisWorks) |
| 1064 |
//////////////////////////////////////////////////////////// |
| 1065 |
bool ClarisDrawText::readTokens(MWAWEntry const &entry, ClarisDrawTextInternal::DSET &zone) |
| 1066 |
{ |
| 1067 |
long pos = entry.begin(); |
| 1068 |
|
| 1069 |
if ((entry.length()%32) != 4) |
| 1070 |
return false; |
| 1071 |
|
| 1072 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1073 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1074 |
ascFile.addPos(pos); |
| 1075 |
ascFile.addNote("Entries(Token)"); |
| 1076 |
auto numElt = int((entry.length()-4)/32); |
| 1077 |
input->seek(pos+4, librevenge::RVNG_SEEK_SET); // skip header |
| 1078 |
|
| 1079 |
libmwaw::DebugStream f; |
| 1080 |
ClarisDrawTextInternal::PLC plc; |
| 1081 |
plc.m_type = ClarisDrawTextInternal::P_Token; |
| 1082 |
int val; |
| 1083 |
std::vector<int> fieldList; |
| 1084 |
for (int i = 0; i < numElt; i++) { |
| 1085 |
pos = input->tell(); |
| 1086 |
|
| 1087 |
auto posC = static_cast<int>(input->readULong(4)); |
| 1088 |
ClarisDrawTextInternal::Token token; |
| 1089 |
|
| 1090 |
auto type = static_cast<int>(input->readLong(2)); |
| 1091 |
f.str(""); |
| 1092 |
switch (type) { |
| 1093 |
case 0: |
| 1094 |
token.m_type = ClarisDrawTextInternal::TKN_FOOTNOTE; |
| 1095 |
break; |
| 1096 |
case 1: |
| 1097 |
token.m_type = ClarisDrawTextInternal::TKN_GRAPHIC; |
| 1098 |
break; |
| 1099 |
case 2: |
| 1100 |
token.m_type = ClarisDrawTextInternal::TKN_PAGENUMBER; |
| 1101 |
break; |
| 1102 |
case 3: |
| 1103 |
token.m_type = ClarisDrawTextInternal::TKN_FIELD; |
| 1104 |
fieldList.push_back(i); |
| 1105 |
break; |
| 1106 |
default: |
| 1107 |
f << "#type=" << type << ","; |
| 1108 |
break; |
| 1109 |
} |
| 1110 |
|
| 1111 |
token.m_unknown[0] = static_cast<int>(input->readLong(2)); |
| 1112 |
token.m_zoneId = static_cast<int>(input->readLong(2)); |
| 1113 |
token.m_unknown[1] = static_cast<int>(input->readLong(1)); |
| 1114 |
token.m_page = static_cast<int>(input->readLong(1)); |
| 1115 |
token.m_unknown[2] = static_cast<int>(input->readLong(2)); |
| 1116 |
for (int j = 0; j < 2; j++) |
| 1117 |
token.m_size[1-j] = static_cast<int>(input->readLong(2)); |
| 1118 |
for (int j = 0; j < 3; j++) { |
| 1119 |
val = static_cast<int>(input->readLong(2)); |
| 1120 |
if (val) f << "f" << j << "=" << val << ","; |
| 1121 |
} |
| 1122 |
val = static_cast<int>(input->readLong(2)); |
| 1123 |
if (val) |
| 1124 |
f << "f3=" << val << ","; |
| 1125 |
token.m_extra = f.str(); |
| 1126 |
f.str(""); |
| 1127 |
f << "Token-" << i << ": pos=" << posC << "," << token; |
| 1128 |
zone.m_tokenList.push_back(token); |
| 1129 |
plc.m_id = i; |
| 1130 |
zone.m_plcMap.insert(std::map<long, ClarisDrawTextInternal::PLC>::value_type(posC, plc)); |
| 1131 |
|
| 1132 |
if (input->tell() != pos+32) |
| 1133 |
ascFile.addDelimiter(input->tell(), '|'); |
| 1134 |
ascFile.addPos(pos); |
| 1135 |
ascFile.addNote(f.str().c_str()); |
| 1136 |
input->seek(pos+32, librevenge::RVNG_SEEK_SET); |
| 1137 |
} |
| 1138 |
|
| 1139 |
input->seek(entry.end(), librevenge::RVNG_SEEK_SET); |
| 1140 |
int n=0; |
| 1141 |
for (auto fl : fieldList) { |
| 1142 |
pos=input->tell(); |
| 1143 |
auto sz=long(input->readULong(4)); |
| 1144 |
f.str(""); |
| 1145 |
f << "Token[field-" << n++ << "]:"; |
| 1146 |
if (!input->checkPosition(pos+sz+4) || long(input->readULong(1))+1!=sz) { |
| 1147 |
MWAW_DEBUG_MSG(("ClarisDrawText::readTokens: can find token field name %d\n", n-1)); |
| 1148 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1149 |
f << "###"; |
| 1150 |
ascFile.addPos(pos); |
| 1151 |
ascFile.addNote(f.str().c_str()); |
| 1152 |
return false; |
| 1153 |
} |
| 1154 |
ascFile.addPos(pos); |
| 1155 |
ascFile.addNote(f.str().c_str()); |
| 1156 |
MWAWEntry fieldEntry; |
| 1157 |
fieldEntry.setBegin(input->tell()); |
| 1158 |
fieldEntry.setEnd(pos+sz+4); |
| 1159 |
zone.m_tokenList[size_t(fl)].m_fieldEntry=fieldEntry; |
| 1160 |
input->seek(fieldEntry.end(), librevenge::RVNG_SEEK_SET); |
| 1161 |
} |
| 1162 |
return true; |
| 1163 |
} |
| 1164 |
|
| 1165 |
//////////////////////////////////////////////////////////// |
| 1166 |
// read the different size for the text |
| 1167 |
//////////////////////////////////////////////////////////// |
| 1168 |
bool ClarisDrawText::readTextZoneSize(MWAWEntry const &entry, ClarisDrawTextInternal::DSET &zone) |
| 1169 |
{ |
| 1170 |
long pos = entry.begin(); |
| 1171 |
|
| 1172 |
int dataSize = 10; |
| 1173 |
if ((entry.length()%dataSize) != 4) |
| 1174 |
return false; |
| 1175 |
|
| 1176 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1177 |
libmwaw::DebugStream f; |
| 1178 |
ascFile.addPos(pos); |
| 1179 |
ascFile.addNote("Entries(TextZoneSz)"); |
| 1180 |
|
| 1181 |
auto numElt = int((entry.length()-4)/dataSize); |
| 1182 |
|
| 1183 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1184 |
input->seek(pos+4, librevenge::RVNG_SEEK_SET); // skip header |
| 1185 |
|
| 1186 |
ClarisDrawTextInternal::PLC plc; |
| 1187 |
plc.m_type = ClarisDrawTextInternal::P_TextZone; |
| 1188 |
for (int i = 0; i < numElt; i++) { |
| 1189 |
pos = input->tell(); |
| 1190 |
f.str(""); |
| 1191 |
f << "TextZoneSz-" << i << ":"; |
| 1192 |
ClarisDrawTextInternal::TextZoneInfo info; |
| 1193 |
info.m_pos = long(input->readULong(4)); |
| 1194 |
info.m_N = static_cast<int>(input->readULong(2)); |
| 1195 |
f << info; |
| 1196 |
zone.m_textZoneList.push_back(info); |
| 1197 |
plc.m_id = i; |
| 1198 |
zone.m_plcMap.insert(std::map<long, ClarisDrawTextInternal::PLC>::value_type(info.m_pos, plc)); |
| 1199 |
|
| 1200 |
if (long(input->tell()) != pos+dataSize) |
| 1201 |
ascFile.addDelimiter(input->tell(), '|'); |
| 1202 |
ascFile.addPos(pos); |
| 1203 |
ascFile.addNote(f.str().c_str()); |
| 1204 |
input->seek(pos+dataSize, librevenge::RVNG_SEEK_SET); |
| 1205 |
} |
| 1206 |
|
| 1207 |
input->seek(entry.end(), librevenge::RVNG_SEEK_SET); |
| 1208 |
return true; |
| 1209 |
} |
| 1210 |
|
| 1211 |
//////////////////////////////////////////////////////////// |
| 1212 |
// send data |
| 1213 |
//////////////////////////////////////////////////////////// |
| 1214 |
bool ClarisDrawText::sendText(ClarisDrawTextInternal::DSET const &zone, int subZone) |
| 1215 |
{ |
| 1216 |
zone.m_parsed=true; |
| 1217 |
MWAWListenerPtr listener=m_parserState->getMainListener(); |
| 1218 |
if (!listener || !listener->canWriteText()) { |
| 1219 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: can not find a listener\n")); |
| 1220 |
return false; |
| 1221 |
} |
| 1222 |
auto numParaPLC = int(zone.m_paragraphList.size()); |
| 1223 |
auto numParagraphs = int(m_state->m_paragraphsList.size()); |
| 1224 |
int numCols = 1; |
| 1225 |
std::shared_ptr<MWAWList> actList; |
| 1226 |
bool isOutline=zone.isOutlined(); |
| 1227 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1228 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1229 |
|
| 1230 |
long firstChar=0, lastChar=zone.m_numChar; |
| 1231 |
if (subZone>=0) { |
| 1232 |
if (subZone>=static_cast<int>(zone.m_subSectionPosList.size())) |
| 1233 |
return true; |
| 1234 |
firstChar=zone.m_subSectionPosList[size_t(subZone)]; |
| 1235 |
if (subZone+1<static_cast<int>(zone.m_subSectionPosList.size())) |
| 1236 |
lastChar=zone.m_subSectionPosList[size_t(subZone+1)]; |
| 1237 |
} |
| 1238 |
|
| 1239 |
long actC = 0; |
| 1240 |
size_t numZones = zone.m_zones.size(); |
| 1241 |
for (size_t z = 0; z < numZones; z++) { |
| 1242 |
MWAWEntry const &entry = zone.m_zones[z]; |
| 1243 |
long pos = entry.begin(); |
| 1244 |
libmwaw::DebugStream f, f2; |
| 1245 |
|
| 1246 |
auto numC = int(entry.length()-4); |
| 1247 |
input->seek(pos+4, librevenge::RVNG_SEEK_SET); // skip header |
| 1248 |
|
| 1249 |
for (int i = 0; i < numC; i++) { |
| 1250 |
auto plcIt = zone.m_plcMap.find(actC); |
| 1251 |
bool seeToken = false; |
| 1252 |
while (actC>=firstChar && plcIt != zone.m_plcMap.end() && plcIt->first<=actC) { |
| 1253 |
if (actC != plcIt->first) { |
| 1254 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: find a plc inside a complex char!!!\n")); |
| 1255 |
f << "###"; |
| 1256 |
} |
| 1257 |
auto const &plc = plcIt++->second; |
| 1258 |
f << "[" << plc << "]"; |
| 1259 |
switch (plc.m_type) { |
| 1260 |
case ClarisDrawTextInternal::P_Font: |
| 1261 |
if (plc.m_id < 0 || plc.m_id >= int(zone.m_fontList.size())) { |
| 1262 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: can not find font %d\n", plc.m_id)); |
| 1263 |
f << "###"; |
| 1264 |
break; |
| 1265 |
} |
| 1266 |
listener->setFont(zone.m_fontList[size_t(plc.m_id)]); |
| 1267 |
break; |
| 1268 |
case ClarisDrawTextInternal::P_Ruler: { |
| 1269 |
if (plc.m_id < 0 || plc.m_id >= numParaPLC) |
| 1270 |
break; |
| 1271 |
auto const ¶PLC = zone.m_paragraphList[size_t(plc.m_id)]; |
| 1272 |
f << "[" << paraPLC << "]"; |
| 1273 |
if (paraPLC.m_rulerId < 0 || paraPLC.m_rulerId >= numParagraphs) |
| 1274 |
break; |
| 1275 |
auto para = m_state->m_paragraphsList[size_t(paraPLC.m_rulerId)]; |
| 1276 |
if (isOutline) { |
| 1277 |
para.m_labelType=paraPLC.getLabelType(); |
| 1278 |
para.m_listLevelIndex=0; |
| 1279 |
para.updateListLevel(); |
| 1280 |
|
| 1281 |
actList = m_parserState->m_listManager->getNewList(actList, 1, *para.m_listLevel); |
| 1282 |
para.m_listId=actList->getId(); |
| 1283 |
} |
| 1284 |
listener->setParagraph(para); |
| 1285 |
break; |
| 1286 |
} |
| 1287 |
case ClarisDrawTextInternal::P_Token: { |
| 1288 |
if (plc.m_id < 0 || plc.m_id >= int(zone.m_tokenList.size())) { |
| 1289 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: can not find the token %d\n", plc.m_id)); |
| 1290 |
f << "###"; |
| 1291 |
break; |
| 1292 |
} |
| 1293 |
auto const &token = zone.m_tokenList[size_t(plc.m_id)]; |
| 1294 |
switch (token.m_type) { |
| 1295 |
case ClarisDrawTextInternal::TKN_FOOTNOTE: |
| 1296 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: can not send footnote in a paint file\n")); |
| 1297 |
f << "###ftnote"; |
| 1298 |
break; |
| 1299 |
case ClarisDrawTextInternal::TKN_PAGENUMBER: |
| 1300 |
switch (token.m_unknown[0]) { |
| 1301 |
case 1: |
| 1302 |
case 2: { |
| 1303 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: find section token\n")); |
| 1304 |
f << "##"; |
| 1305 |
listener->insertUnicodeString(librevenge::RVNGString("1")); |
| 1306 |
break; |
| 1307 |
} |
| 1308 |
case 3: |
| 1309 |
listener->insertField(MWAWField(MWAWField::PageCount)); |
| 1310 |
break; |
| 1311 |
case 0: |
| 1312 |
default: |
| 1313 |
listener->insertField(MWAWField(MWAWField::PageNumber)); |
| 1314 |
} |
| 1315 |
break; |
| 1316 |
case ClarisDrawTextInternal::TKN_GRAPHIC: |
| 1317 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: can not send graphic\n")); |
| 1318 |
f << "###"; |
| 1319 |
break; |
| 1320 |
case ClarisDrawTextInternal::TKN_FIELD: |
| 1321 |
listener->insertUnicode(0xab); |
| 1322 |
if (token.m_fieldEntry.valid() && |
| 1323 |
input->checkPosition(token.m_fieldEntry.end())) { |
| 1324 |
long actPos=input->tell(); |
| 1325 |
input->seek(token.m_fieldEntry.begin(), librevenge::RVNG_SEEK_SET); |
| 1326 |
long endFPos=token.m_fieldEntry.end(); |
| 1327 |
while (!input->isEnd() && input->tell() < token.m_fieldEntry.end()) |
| 1328 |
listener->insertCharacter(static_cast<unsigned char>(input->readULong(1)), input, endFPos); |
| 1329 |
input->seek(actPos, librevenge::RVNG_SEEK_SET); |
| 1330 |
} |
| 1331 |
else { |
| 1332 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: can not find field token data\n")); |
| 1333 |
listener->insertCharacter(' '); |
| 1334 |
} |
| 1335 |
listener->insertUnicode(0xbb); |
| 1336 |
break; |
| 1337 |
case ClarisDrawTextInternal::TKN_UNKNOWN: |
| 1338 |
#if !defined(__clang__) |
| 1339 |
default: |
| 1340 |
#endif |
| 1341 |
break; |
| 1342 |
} |
| 1343 |
seeToken = true; |
| 1344 |
break; |
| 1345 |
} |
| 1346 |
/* checkme: normally, this corresponds to the first |
| 1347 |
character following a 0xb/0x1, so we do not need to a |
| 1348 |
column/page break here */ |
| 1349 |
case ClarisDrawTextInternal::P_Child: |
| 1350 |
case ClarisDrawTextInternal::P_TextZone: |
| 1351 |
case ClarisDrawTextInternal::P_Unknown: |
| 1352 |
#if !defined(__clang__) |
| 1353 |
default: |
| 1354 |
#endif |
| 1355 |
break; |
| 1356 |
} |
| 1357 |
} |
| 1358 |
auto c = char(input->readULong(1)); |
| 1359 |
if (actC++<firstChar) |
| 1360 |
continue; |
| 1361 |
if (actC>lastChar) break; |
| 1362 |
if (c == '\0') { |
| 1363 |
if (i == numC-1) break; |
| 1364 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: OOPS, find 0 reading the text\n")); |
| 1365 |
f << "###0x0"; |
| 1366 |
continue; |
| 1367 |
} |
| 1368 |
f << c; |
| 1369 |
if (seeToken && static_cast<unsigned char>(c) < 32) continue; |
| 1370 |
switch (c) { |
| 1371 |
case 0x1: // fixme: column break |
| 1372 |
if (numCols) { |
| 1373 |
listener->insertBreak(MWAWListener::ColumnBreak); |
| 1374 |
break; |
| 1375 |
} |
| 1376 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: Find unexpected char 1\n")); |
| 1377 |
f << "###"; |
| 1378 |
MWAW_FALLTHROUGH; |
| 1379 |
case 0xb: // page break |
| 1380 |
MWAW_DEBUG_MSG(("ClarisDrawText::sendText: Find unexpected page break\n")); |
| 1381 |
f << "###pb"; |
| 1382 |
break; |
| 1383 |
case 0x2: // token footnote ( normally already done) |
| 1384 |
break; |
| 1385 |
case 0x3: // token graphic |
| 1386 |
break; |
| 1387 |
case 0x4: |
| 1388 |
listener->insertField(MWAWField(MWAWField::Date)); |
| 1389 |
break; |
| 1390 |
case 0x5: { |
| 1391 |
MWAWField field(MWAWField::Time); |
| 1392 |
field.m_DTFormat="%H:%M"; |
| 1393 |
listener->insertField(field); |
| 1394 |
break; |
| 1395 |
} |
| 1396 |
case 0x6: // normally already done, but if we do not find the token, ... |
| 1397 |
listener->insertField(MWAWField(MWAWField::PageNumber)); |
| 1398 |
break; |
| 1399 |
case 0x7: // footnote index (ok to ignore : index of the footnote ) |
| 1400 |
break; |
| 1401 |
case 0x8: // potential breaking <<hyphen>> |
| 1402 |
break; |
| 1403 |
case 0x9: |
| 1404 |
listener->insertTab(); |
| 1405 |
break; |
| 1406 |
case 0xa: |
| 1407 |
listener->insertEOL(true); |
| 1408 |
break; |
| 1409 |
case 0xc: // new section: this is treated after, at the beginning of the for loop |
| 1410 |
break; |
| 1411 |
case 0xd: |
| 1412 |
f2.str(""); |
| 1413 |
f2 << "Entries(TextContent):" << f.str(); |
| 1414 |
ascFile.addPos(pos); |
| 1415 |
ascFile.addNote(f2.str().c_str()); |
| 1416 |
f.str(""); |
| 1417 |
pos = input->tell(); |
| 1418 |
|
| 1419 |
// ignore last end of line returns |
| 1420 |
if (z != numZones-1 || i != numC-2) |
| 1421 |
listener->insertEOL(); |
| 1422 |
break; |
| 1423 |
|
| 1424 |
default: { |
| 1425 |
int extraChar = listener->insertCharacter |
| 1426 |
(static_cast<unsigned char>(c), input, input->tell()+(numC-1-i)); |
| 1427 |
if (extraChar) { |
| 1428 |
i += extraChar; |
| 1429 |
actC += extraChar; |
| 1430 |
} |
| 1431 |
} |
| 1432 |
} |
| 1433 |
} |
| 1434 |
if (f.str().length()) { |
| 1435 |
f2.str(""); |
| 1436 |
f2 << "Entries(TextContent):" << f.str(); |
| 1437 |
ascFile.addPos(pos); |
| 1438 |
ascFile.addNote(f2.str().c_str()); |
| 1439 |
} |
| 1440 |
} |
| 1441 |
|
| 1442 |
return true; |
| 1443 |
} |
| 1444 |
|
| 1445 |
bool ClarisDrawText::sendZone(int number, int subZone) |
| 1446 |
{ |
| 1447 |
auto iter = m_state->m_zoneMap.find(number); |
| 1448 |
if (iter == m_state->m_zoneMap.end()) |
| 1449 |
return false; |
| 1450 |
auto zone = iter->second; |
| 1451 |
if (zone) |
| 1452 |
sendText(*zone, subZone); |
| 1453 |
return true; |
| 1454 |
} |
| 1455 |
|
| 1456 |
void ClarisDrawText::flushExtra() |
| 1457 |
{ |
| 1458 |
MWAW_DEBUG_MSG(("ClarisDrawText::flushExtra: not implemented\n")); |
| 1459 |
} |
| 1460 |
|
| 1461 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |