| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Major Contributor(s): |
| 17 |
* Copyright (C) 2002 William Lachance ([email protected]) |
| 18 |
* Copyright (C) 2002,2004 Marc Maurer ([email protected]) |
| 19 |
* Copyright (C) 2004-2006 Fridrich Strba ([email protected]) |
| 20 |
* Copyright (C) 2006, 2007 Andrew Ziem |
| 21 |
* Copyright (C) 2011, 2012 Alonso Laurent ([email protected]) |
| 22 |
* |
| 23 |
* |
| 24 |
* All Rights Reserved. |
| 25 |
* |
| 26 |
* For minor contributions see the git repository. |
| 27 |
* |
| 28 |
* Alternatively, the contents of this file may be used under the terms of |
| 29 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 30 |
* in which case the provisions of the LGPLv2+ are applicable |
| 31 |
* instead of those above. |
| 32 |
*/ |
| 33 |
|
| 34 |
#include <cmath> |
| 35 |
#include <iomanip> |
| 36 |
#include <iostream> |
| 37 |
#include <limits> |
| 38 |
#include <map> |
| 39 |
#include <sstream> |
| 40 |
|
| 41 |
#include <librevenge/librevenge.h> |
| 42 |
|
| 43 |
#include "MWAWFont.hxx" |
| 44 |
#include "MWAWFontConverter.hxx" |
| 45 |
#include "MWAWGraphicShape.hxx" |
| 46 |
#include "MWAWGraphicStyle.hxx" |
| 47 |
#include "MWAWParser.hxx" |
| 48 |
#include "MWAWPosition.hxx" |
| 49 |
#include "MWAWGraphicStyle.hxx" |
| 50 |
#include "MWAWPresentationListener.hxx" |
| 51 |
#include "MWAWSubDocument.hxx" |
| 52 |
|
| 53 |
#include "PowerPoint7Struct.hxx" |
| 54 |
|
| 55 |
#include "PowerPoint7Graph.hxx" |
| 56 |
#include "PowerPoint7Parser.hxx" |
| 57 |
|
| 58 |
/** Internal: the structures of a PowerPoint7Graph */ |
| 59 |
namespace PowerPoint7GraphInternal |
| 60 |
{ |
| 61 |
//! Internal: a frame of a PowerPoint7Graph |
| 62 |
struct Frame { |
| 63 |
//! the frame type |
| 64 |
enum Type { Arc, Line, Group, Placeholder, Polygon, Rect, Unknown }; |
| 65 |
//! constructor |
| 66 |
explicit Frame(Type type=Unknown) |
| 67 |
: m_type(type) |
| 68 |
, m_subType(-10000) |
| 69 |
, m_dimension() |
| 70 |
, m_rotation(0) |
| 71 |
, m_style() |
| 72 |
, m_pictureId(-1) |
| 73 |
, m_textId(-1) |
| 74 |
, m_isBackground(false) |
| 75 |
, m_isSent(false) |
| 76 |
{ |
| 77 |
for (auto &flip : m_flip) flip=false; |
| 78 |
} |
| 79 |
//! destructor |
| 80 |
virtual ~Frame(); |
| 81 |
//! try to update the list of text sub zone |
| 82 |
virtual void getTextZoneList(std::vector<int> &textIdList) const |
| 83 |
{ |
| 84 |
if (m_textId>=0) |
| 85 |
textIdList.push_back(m_textId); |
| 86 |
} |
| 87 |
//! the type: |
| 88 |
enum Type m_type; |
| 89 |
//! the sub type |
| 90 |
int m_subType; |
| 91 |
//! the dimension |
| 92 |
MWAWBox2i m_dimension; |
| 93 |
//! the rotation |
| 94 |
float m_rotation; |
| 95 |
//! the flip flags: horizontal and vertical |
| 96 |
bool m_flip[2]; |
| 97 |
//! the style |
| 98 |
MWAWGraphicStyle m_style; |
| 99 |
//! the picture id(if positif) |
| 100 |
int m_pictureId; |
| 101 |
//! the text id(if positif) |
| 102 |
int m_textId; |
| 103 |
//! a flag to know if this is the slide's background |
| 104 |
bool m_isBackground; |
| 105 |
//! flag to know if a frame is sent |
| 106 |
mutable bool m_isSent; |
| 107 |
}; |
| 108 |
|
| 109 |
Frame::~Frame() |
| 110 |
{ |
| 111 |
} |
| 112 |
|
| 113 |
//! Internal: a frame rect of a PowerPoint7Graph |
| 114 |
struct FrameArc final : public Frame { |
| 115 |
//! constructor |
| 116 |
FrameArc() : Frame(Arc) |
| 117 |
{ |
| 118 |
m_angles[0]=0; |
| 119 |
m_angles[1]=90; |
| 120 |
} |
| 121 |
//! destructor |
| 122 |
~FrameArc() final; |
| 123 |
//! update the shape |
| 124 |
bool updateShape(MWAWBox2f const &finalBox, MWAWGraphicShape &shape) const; |
| 125 |
//! the arc angles |
| 126 |
float m_angles[2]; |
| 127 |
}; |
| 128 |
|
| 129 |
FrameArc::~FrameArc() |
| 130 |
{ |
| 131 |
} |
| 132 |
|
| 133 |
bool FrameArc::updateShape(MWAWBox2f const &finalBox, MWAWGraphicShape &shape) const |
| 134 |
{ |
| 135 |
float angle[2] = { m_angles[0], m_angles[0]+m_angles[1] }; |
| 136 |
if (angle[1]<angle[0]) |
| 137 |
std::swap(angle[0],angle[1]); |
| 138 |
if (angle[1]>360) { |
| 139 |
int numLoop=int(angle[1]/360)-1; |
| 140 |
angle[0]-=float(numLoop*360); |
| 141 |
angle[1]-=float(numLoop*360); |
| 142 |
while (angle[1] > 360) { |
| 143 |
angle[0]-=360; |
| 144 |
angle[1]-=360; |
| 145 |
} |
| 146 |
} |
| 147 |
if (angle[0] < -360) { |
| 148 |
int numLoop=int(angle[0]/360)+1; |
| 149 |
angle[0]-=float(numLoop*360); |
| 150 |
angle[1]-=float(numLoop*360); |
| 151 |
while (angle[0] < -360) { |
| 152 |
angle[0]+=360; |
| 153 |
angle[1]+=360; |
| 154 |
} |
| 155 |
} |
| 156 |
MWAWVec2f center = finalBox.center(); |
| 157 |
MWAWVec2f axis = 0.5f*MWAWVec2f(finalBox.size()); |
| 158 |
// we must compute the real bd box |
| 159 |
float minVal[2] = { 0, 0 }, maxVal[2] = { 0, 0 }; |
| 160 |
int limitAngle[2]; |
| 161 |
for (int i = 0; i < 2; i++) |
| 162 |
limitAngle[i] = (angle[i] < 0) ? int(angle[i]/90)-1 : int(angle[i]/90); |
| 163 |
for (int bord = limitAngle[0]; bord <= limitAngle[1]+1; bord++) { |
| 164 |
float ang = (bord == limitAngle[0]) ? angle[0] : |
| 165 |
(bord == limitAngle[1]+1) ? angle[1] : 90 * float(bord); |
| 166 |
ang *= float(M_PI/180.); |
| 167 |
float const actVal[2] = { axis[0] *std::cos(ang), -axis[1] *std::sin(ang)}; |
| 168 |
if (actVal[0] < minVal[0]) minVal[0] = actVal[0]; |
| 169 |
else if (actVal[0] > maxVal[0]) maxVal[0] = actVal[0]; |
| 170 |
if (actVal[1] < minVal[1]) minVal[1] = actVal[1]; |
| 171 |
else if (actVal[1] > maxVal[1]) maxVal[1] = actVal[1]; |
| 172 |
} |
| 173 |
MWAWBox2f realBox(MWAWVec2f(center[0]+minVal[0],center[1]+minVal[1]), |
| 174 |
MWAWVec2f(center[0]+maxVal[0],center[1]+maxVal[1])); |
| 175 |
shape = MWAWGraphicShape::pie(realBox, finalBox, MWAWVec2f(float(angle[0]),float(angle[1]))); |
| 176 |
return true; |
| 177 |
} |
| 178 |
|
| 179 |
//! Internal: a group of a PowerPoint7Graph |
| 180 |
struct FrameGroup final : public Frame { |
| 181 |
//! constructor |
| 182 |
FrameGroup() |
| 183 |
: Frame(Group) |
| 184 |
, m_child() |
| 185 |
{ |
| 186 |
} |
| 187 |
//! destructor |
| 188 |
~FrameGroup() final; |
| 189 |
//! try to update the list of text sub zone |
| 190 |
void getTextZoneList(std::vector<int> &textIdList) const final |
| 191 |
{ |
| 192 |
for (auto const &child : m_child) { |
| 193 |
if (child) |
| 194 |
child->getTextZoneList(textIdList); |
| 195 |
} |
| 196 |
} |
| 197 |
//! the child |
| 198 |
std::vector<std::shared_ptr<Frame> > m_child; |
| 199 |
}; |
| 200 |
|
| 201 |
FrameGroup::~FrameGroup() |
| 202 |
{ |
| 203 |
} |
| 204 |
|
| 205 |
//! Internal: a frame placeholder of a PowerPoint7Graph |
| 206 |
struct FramePlaceholder final : public Frame { |
| 207 |
//! constructor |
| 208 |
FramePlaceholder() |
| 209 |
: Frame(Placeholder) |
| 210 |
{ |
| 211 |
} |
| 212 |
//! destructor |
| 213 |
~FramePlaceholder() final; |
| 214 |
}; |
| 215 |
|
| 216 |
FramePlaceholder::~FramePlaceholder() |
| 217 |
{ |
| 218 |
} |
| 219 |
|
| 220 |
//! Internal: a polygon of a PowerPoint7Graph |
| 221 |
struct FramePolygon final : public Frame { |
| 222 |
//! constructor |
| 223 |
FramePolygon() |
| 224 |
: Frame(Polygon) |
| 225 |
, m_vertices() |
| 226 |
{ |
| 227 |
} |
| 228 |
//! destructor |
| 229 |
~FramePolygon(); |
| 230 |
//! update the shape |
| 231 |
bool updateShape(MWAWBox2f const &finalBox, MWAWGraphicShape &shape) const; |
| 232 |
//! the vertices |
| 233 |
std::vector<MWAWVec2i> m_vertices; |
| 234 |
}; |
| 235 |
|
| 236 |
FramePolygon::~FramePolygon() |
| 237 |
{ |
| 238 |
} |
| 239 |
|
| 240 |
bool FramePolygon::updateShape(MWAWBox2f const &finalBox, MWAWGraphicShape &shape) const |
| 241 |
{ |
| 242 |
if (m_vertices.empty()) return false; |
| 243 |
MWAWBox2i actBox(m_vertices[0],m_vertices[0]); |
| 244 |
for (size_t i=1; i<m_vertices.size(); ++i) actBox=actBox.getUnion(MWAWBox2i(m_vertices[i],m_vertices[i])); |
| 245 |
float factor[2], decal[2]; |
| 246 |
for (int i=0; i<2; ++i) { |
| 247 |
if (actBox.size()[i]<0||actBox.size()[i]>0) |
| 248 |
factor[i]=float(finalBox.size()[i])/float(actBox.size()[i]); |
| 249 |
else |
| 250 |
factor[i]=1.f; |
| 251 |
decal[i]=finalBox[0][i]-factor[i]*float(actBox[0][i]); |
| 252 |
} |
| 253 |
shape.m_type = MWAWGraphicShape::Polygon; |
| 254 |
for (auto const &pt : m_vertices) |
| 255 |
shape.m_vertices.push_back(MWAWVec2f(decal[0]+factor[0]*float(pt[0]), decal[1]+factor[1]*float(pt[1]))); |
| 256 |
//if (m_type==1) shape.m_vertices.push_back(shape.m_vertices[0]); |
| 257 |
return true; |
| 258 |
} |
| 259 |
|
| 260 |
//! Internal: a frame rect of a PowerPoint7Graph |
| 261 |
struct FrameRect final : public Frame { |
| 262 |
//! constructor |
| 263 |
FrameRect() |
| 264 |
: Frame(Rect) |
| 265 |
{ |
| 266 |
} |
| 267 |
//! destructor |
| 268 |
~FrameRect() final; |
| 269 |
}; |
| 270 |
|
| 271 |
FrameRect::~FrameRect() |
| 272 |
{ |
| 273 |
} |
| 274 |
|
| 275 |
//! Internal: a picture of a PowerPoint7Graph |
| 276 |
struct Picture { |
| 277 |
//! constructor |
| 278 |
Picture() |
| 279 |
: m_object() |
| 280 |
, m_box() |
| 281 |
, m_name("") |
| 282 |
{ |
| 283 |
} |
| 284 |
//! returns true if the picture is empty |
| 285 |
bool isEmpty() const |
| 286 |
{ |
| 287 |
return m_object.isEmpty(); |
| 288 |
} |
| 289 |
//! the picture data |
| 290 |
MWAWEmbeddedObject m_object; |
| 291 |
//! the picture box |
| 292 |
MWAWBox2i m_box; |
| 293 |
//! the picture name |
| 294 |
std::string m_name; |
| 295 |
}; |
| 296 |
|
| 297 |
//////////////////////////////////////// |
| 298 |
//! Internal: the state of a PowerPoint7Graph |
| 299 |
struct State { |
| 300 |
//! constructor |
| 301 |
State() |
| 302 |
: m_decal(-2880,-2160) |
| 303 |
, m_actualSlideId() |
| 304 |
, m_colorList() |
| 305 |
, m_arrowList() |
| 306 |
, m_actualFrame() |
| 307 |
, m_actualGroup() |
| 308 |
, m_idToFrameMap() |
| 309 |
, m_idToPictureMap() |
| 310 |
{ |
| 311 |
} |
| 312 |
//! try to add a frame |
| 313 |
void setFrame(Frame *frame) |
| 314 |
{ |
| 315 |
if (!frame) { |
| 316 |
MWAW_DEBUG_MSG(("PowerPoint7GraphInternal::State::setFrame: oops called with no frame\n")); |
| 317 |
return; |
| 318 |
} |
| 319 |
auto *group=dynamic_cast<FrameGroup *>(frame); |
| 320 |
std::shared_ptr<Frame> newFrame; |
| 321 |
bool inGroup=m_actualGroup.get()!=nullptr; |
| 322 |
if (group==nullptr) { |
| 323 |
if (m_actualFrame) { |
| 324 |
MWAW_DEBUG_MSG(("PowerPoint7GraphInternal::State::setFrame: oops a frame is not closed\n")); |
| 325 |
} |
| 326 |
newFrame.reset(frame); |
| 327 |
m_actualFrame=newFrame; |
| 328 |
if (inGroup) |
| 329 |
m_actualGroup->m_child.push_back(newFrame); |
| 330 |
} |
| 331 |
else { |
| 332 |
std::shared_ptr<FrameGroup> newGroup(group); |
| 333 |
newFrame=newGroup; |
| 334 |
if (inGroup) |
| 335 |
m_actualGroup->m_child.push_back(newFrame); |
| 336 |
m_actualGroup=newGroup; |
| 337 |
} |
| 338 |
if (!inGroup && !m_actualSlideId.isValid()) { |
| 339 |
MWAW_DEBUG_MSG(("PowerPoint7GraphInternal::State::setFrame: oops called with no parent\n")); |
| 340 |
} |
| 341 |
else if (!inGroup) { |
| 342 |
if (m_idToFrameMap.find(m_actualSlideId)==m_idToFrameMap.end()) |
| 343 |
m_idToFrameMap[m_actualSlideId]=std::vector<std::shared_ptr<Frame> >(); |
| 344 |
m_idToFrameMap.find(m_actualSlideId)->second.push_back(newFrame); |
| 345 |
} |
| 346 |
} |
| 347 |
//! reset the actual frame |
| 348 |
void resetFrame() |
| 349 |
{ |
| 350 |
m_actualFrame.reset(); |
| 351 |
} |
| 352 |
//! try to return a pattern |
| 353 |
bool getPattern(int id, MWAWGraphicStyle::Pattern &pattern) const; |
| 354 |
//! returns an arrow if possible |
| 355 |
bool getArrow(int id, MWAWGraphicStyle::Arrow &arrow) |
| 356 |
{ |
| 357 |
if (m_arrowList.empty()) initArrows(); |
| 358 |
if (id<=0 || id>int(m_arrowList.size())) { |
| 359 |
MWAW_DEBUG_MSG(("PowerPoint7GraphInternal::State::getArrow: can not find arrow %d\n", id)); |
| 360 |
return false; |
| 361 |
} |
| 362 |
arrow=m_arrowList[size_t(id-1)]; |
| 363 |
return true; |
| 364 |
} |
| 365 |
//! init the arrow list |
| 366 |
void initArrows(); |
| 367 |
//! returns a custom shape corresponding to an id |
| 368 |
static bool getCustomShape(int id, MWAWGraphicShape &shape); |
| 369 |
//! the decal from file position to final position |
| 370 |
MWAWVec2i m_decal; |
| 371 |
//! the actual slide id |
| 372 |
PowerPoint7Struct::SlideId m_actualSlideId; |
| 373 |
//! the current color list |
| 374 |
std::vector<MWAWColor> m_colorList; |
| 375 |
//! the arrow list |
| 376 |
std::vector<MWAWGraphicStyle::Arrow> m_arrowList; |
| 377 |
//! the actual frame |
| 378 |
std::shared_ptr<Frame> m_actualFrame; |
| 379 |
//! the actual group |
| 380 |
std::shared_ptr<FrameGroup> m_actualGroup; |
| 381 |
//! a map slide id to the list of frame |
| 382 |
std::map<PowerPoint7Struct::SlideId, std::vector<std::shared_ptr<Frame> > > m_idToFrameMap; |
| 383 |
//! a map id to picture |
| 384 |
std::map<int, Picture> m_idToPictureMap; |
| 385 |
}; |
| 386 |
|
| 387 |
bool State::getPattern(int id, MWAWGraphicStyle::Pattern &pattern) const |
| 388 |
{ |
| 389 |
// normally between 1 and 32 but find a pattern resource with 38 patterns |
| 390 |
if (id<=0 || id>=39) { |
| 391 |
MWAW_DEBUG_MSG(("PowerPoint7GraphInternal::State::getPattern: unknown id=%d\n", id)); |
| 392 |
return false; |
| 393 |
} |
| 394 |
static uint16_t const values[] = { |
| 395 |
0xffff, 0xffff, 0xffff, 0xffff, 0x0, 0x0, 0x0, 0x0, |
| 396 |
0xddff, 0x77ff, 0xddff, 0x77ff, 0x8000, 0x800, 0x8000, 0x800, |
| 397 |
0xdd77, 0xdd77, 0xdd77, 0xdd77, 0x8800, 0x2200, 0x8800, 0x2200, |
| 398 |
0xaa55, 0xaa55, 0xaa55, 0xaa55, 0x8822, 0x8822, 0x8822, 0x8822, |
| 399 |
0x8844, 0x2211, 0x8844, 0x2211, 0x1122, 0x4488, 0x1122, 0x4488, |
| 400 |
0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa, 0xff00, 0xff00, 0xff00, 0xff00, |
| 401 |
0x81c0, 0x6030, 0x180c, 0x603, 0x8103, 0x60c, 0x1830, 0x60c0, |
| 402 |
0x8888, 0x8888, 0x8888, 0x8888, 0xff00, 0x0, 0xff00, 0x0, |
| 403 |
0xb130, 0x31b, 0xd8c0, 0xc8d, 0x8010, 0x220, 0x108, 0x4004, |
| 404 |
0xff80, 0x8080, 0x8080, 0x8080, 0xff88, 0x8888, 0xff88, 0x8888, |
| 405 |
0xff80, 0x8080, 0xff08, 0x808, 0xeedd, 0xbb77, 0xeedd, 0xbb77, |
| 406 |
0x7fff, 0xffff, 0xf7ff, 0xffff, 0x88, 0x4422, 0x1100, 0x0, |
| 407 |
0x11, 0x2244, 0x8800, 0x0, 0x8080, 0x8080, 0x808, 0x808, 0xf000, |
| 408 |
0x0, 0xf00, 0x0, 0x8142, 0x2418, 0x8142, 0x2418, |
| 409 |
0x8000, 0x2200, 0x800, 0x2200, 0x1038, 0x7cfe, 0x7c38, 0x1000, |
| 410 |
0x102, 0x408, 0x1824, 0x4281, 0xc1e0, 0x7038, 0x1c0e, 0x783, |
| 411 |
0x8307, 0xe1c, 0x3870, 0xe0c1, 0xcccc, 0xcccc, 0xcccc, 0xcccc, |
| 412 |
0xffff, 0x0, 0xffff, 0x0, 0xf0f0, 0xf0f0, 0xf0f, 0xf0f, |
| 413 |
0x6699, 0x9966, 0x6699, 0x9966, 0x8142, 0x2418, 0x1824, 0x4281, |
| 414 |
}; |
| 415 |
pattern.m_dim=MWAWVec2i(8,8); |
| 416 |
uint16_t const *ptr=&values[4*(id-1)]; |
| 417 |
pattern.m_data.resize(8); |
| 418 |
for (size_t i=0; i < 4; ++i, ++ptr) { |
| 419 |
pattern.m_data[2*i]=static_cast<unsigned char>((*ptr)>>8); |
| 420 |
pattern.m_data[2*i+1]=static_cast<unsigned char>((*ptr)&0xff); |
| 421 |
} |
| 422 |
return true; |
| 423 |
} |
| 424 |
|
| 425 |
void State::initArrows() |
| 426 |
{ |
| 427 |
if (!m_arrowList.empty()) |
| 428 |
return; |
| 429 |
m_arrowList.push_back(MWAWGraphicStyle::Arrow(5, MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(1131,1580)), |
| 430 |
"M1013 1491l118 89-567-1580-564 1580 114-85 136-68 148-46 161-17 161 13 153 46z", false)); |
| 431 |
m_arrowList.push_back(MWAWGraphicStyle::Arrow(5, MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(1131,1131)), "M462 1118l-102-29-102-51-93-72-72-93-51-102-29-102-13-105 13-102 29-106 51-102 72-89 93-72 102-50 102-34 106-9 101 9 106 34 98 50 93 72 72 89 51 102 29 106 13 102-13 105-29 102-51 102-72 93-93 72-98 51-106 29-101 13z", false)); |
| 432 |
m_arrowList.push_back(MWAWGraphicStyle::Arrow(5, MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(1131,1131)), "M462 1118l-102-29-102-51-93-72-72-93-51-102-29-102-13-105 13-102 29-106 51-102 72-89 93-72 102-50 102-34 106-9 101 9 106 34 98 50 93 72 72 89 51 102 29 106 13 102-13 105-29 102-51 102-72 93-93 72-98 51-106 29-101 13z", false)); |
| 433 |
m_arrowList.push_back(MWAWGraphicStyle::Arrow(5, MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(1131,1580)), |
| 434 |
"M1013 1491l118 89-567-1580-564 1580 114-85 136-68 148-46 161-17 161 13 153 46z", false)); |
| 435 |
} |
| 436 |
|
| 437 |
bool State::getCustomShape(int id, MWAWGraphicShape &shape) |
| 438 |
{ |
| 439 |
int N=4; |
| 440 |
double const *vertices=nullptr; |
| 441 |
switch (id) { |
| 442 |
case 0: { |
| 443 |
static double const v[]= {0.5,1, 1,0.5, 0.5,0, 0,0.5 }; |
| 444 |
vertices=v; |
| 445 |
break; |
| 446 |
} |
| 447 |
case 1: { |
| 448 |
N=3; |
| 449 |
static double const v[]= {0,1, 1,1, 0.5,0}; |
| 450 |
vertices=v; |
| 451 |
break; |
| 452 |
} |
| 453 |
case 2: { |
| 454 |
N=3; |
| 455 |
static double const v[]= {0,1, 1,1, 0,0}; |
| 456 |
vertices=v; |
| 457 |
break; |
| 458 |
} |
| 459 |
case 3: { |
| 460 |
static double const v[]= {0,1, 0.7,1, 1,0, 0.3,0 }; |
| 461 |
vertices=v; |
| 462 |
break; |
| 463 |
} |
| 464 |
case 4: { |
| 465 |
static double const v[]= {0,1, 0.3,0, 0.7,0, 1,1 }; |
| 466 |
vertices=v; |
| 467 |
break; |
| 468 |
} |
| 469 |
case 5: { |
| 470 |
N=6; |
| 471 |
static double const v[]= {0,0.5, 0.2,1, 0.8,1, 1,0.5, 0.8,0, 0.2,0}; |
| 472 |
vertices=v; |
| 473 |
break; |
| 474 |
} |
| 475 |
case 6: { |
| 476 |
N=8; |
| 477 |
static double const v[]= {0,0.3, 0,0.7, 0.3,1, 0.7,1, 1,0.7, 1,0.3, 0.7,0, 0.3,0}; |
| 478 |
vertices=v; |
| 479 |
break; |
| 480 |
} |
| 481 |
case 7: { |
| 482 |
N=12; |
| 483 |
static double const v[]= {0,0.2, 0,0.8, 0.2,0.8, 0.2,1, |
| 484 |
0.8,1, 0.8,0.8, 1,0.8, 1,0.2, |
| 485 |
0.8,0.2, 0.8,0, 0.2,0, 0.2,0.2 |
| 486 |
}; |
| 487 |
vertices=v; |
| 488 |
break; |
| 489 |
} |
| 490 |
case 8: { |
| 491 |
N=10; |
| 492 |
static double const v[]= {0.5,0, 0.383,0.383, 0,0.383, 0.3112,0.62, |
| 493 |
0.1943,1, 0.5,0.78, 0.8056,1, 0.688,0.62, |
| 494 |
1,0.3822, 0.6167,0.3822, |
| 495 |
}; |
| 496 |
vertices=v; |
| 497 |
break; |
| 498 |
} |
| 499 |
case 9: { |
| 500 |
N=7; |
| 501 |
static double const v[]= {0,0.333, 0,0.666, 0.7,0.666, 0.7,1, |
| 502 |
1,0.5, 0.7,0, 0.7,0.333 |
| 503 |
}; |
| 504 |
vertices=v; |
| 505 |
break; |
| 506 |
} |
| 507 |
case 10: { |
| 508 |
N=7; |
| 509 |
static double const v[]= {0,0.2, 0,0.8, 0.7,0.8, 0.7,1, |
| 510 |
1,0.5, 0.7,0, 0.7,0.2 |
| 511 |
}; |
| 512 |
vertices=v; |
| 513 |
break; |
| 514 |
} |
| 515 |
case 11: { |
| 516 |
N=5; |
| 517 |
static double const v[]= {0,0, 0,1, 0.7,1, 1,0.5, 0.7,0}; |
| 518 |
vertices=v; |
| 519 |
break; |
| 520 |
} |
| 521 |
case 12: { |
| 522 |
N=12; |
| 523 |
static double const v[]= {0,1, 0.8,1, 1,0.8, 1,0, |
| 524 |
0.8,0.2, 0.8,1, 0.8,0.2, 0,0.2, |
| 525 |
0.2,0., 1,0, 0.2,0, 0,0.2 |
| 526 |
}; |
| 527 |
|
| 528 |
vertices=v; |
| 529 |
break; |
| 530 |
} |
| 531 |
case 13: { |
| 532 |
N=11; |
| 533 |
static double const v[]= {0,0.1, 0,0.8, 0.1,0.9, 0.2,0.9, |
| 534 |
0.1,1, 0.3,0.9, 0.9,0.9, 1,0.8, |
| 535 |
1,0.1, 0.9,0, 0.1,0 |
| 536 |
}; |
| 537 |
vertices=v; |
| 538 |
break; |
| 539 |
} |
| 540 |
case 14: { |
| 541 |
N=24; |
| 542 |
static double const v[]= { 0.5,0, 0.55,0.286, 0.7465,0.07, 0.656,0.342, |
| 543 |
0.935,0.251, 0.7186,0.4465, 1,0.5, 0.7186,0.5535, |
| 544 |
0.935,0.75, 0.6558,0.66558, 0.7465,0.9349, 0.558,0.7186, |
| 545 |
0.495,1, 0.44,0.7186, 0.2511,0.935, 0.3418,0.6627, |
| 546 |
0.063,0.7535, 0.279,0.558, 0,0.502, 0.279,0.4465, |
| 547 |
0.063,0.2511, 0.3418,0.3418, 0.2511,0.069, 0.4395,0.286 |
| 548 |
}; |
| 549 |
vertices=v; |
| 550 |
break; |
| 551 |
} |
| 552 |
default: |
| 553 |
break; |
| 554 |
} |
| 555 |
if (N<=0 || !vertices) { |
| 556 |
MWAW_DEBUG_MSG(("PowerPoint7GraphInternal::State::getCustomShape: unknown id %d\n", id)); |
| 557 |
return false; |
| 558 |
} |
| 559 |
shape.m_type = MWAWGraphicShape::Polygon; |
| 560 |
shape.m_vertices.resize(size_t(N+1)); |
| 561 |
for (int i=0; i<N; ++i) |
| 562 |
shape.m_vertices[size_t(i)]=MWAWVec2f(float(vertices[2*i]),float(vertices[2*i+1])); |
| 563 |
shape.m_vertices[size_t(N)]=MWAWVec2f(float(vertices[0]),float(vertices[1])); |
| 564 |
return true; |
| 565 |
} |
| 566 |
|
| 567 |
//////////////////////////////////////// |
| 568 |
//! Internal: the subdocument of a PowerPoint7Graph |
| 569 |
class SubDocument final : public MWAWSubDocument |
| 570 |
{ |
| 571 |
public: |
| 572 |
//! constructor for a text zone |
| 573 |
SubDocument(PowerPoint7Graph &parser, MWAWInputStreamPtr const &input, int tId) |
| 574 |
: MWAWSubDocument(nullptr, input, MWAWEntry()) |
| 575 |
, m_powerpointParser(parser) |
| 576 |
, m_textId(tId) |
| 577 |
, m_listTextId() |
| 578 |
{ |
| 579 |
} |
| 580 |
//! constructor for a list text zone |
| 581 |
SubDocument(PowerPoint7Graph &parser, MWAWInputStreamPtr const &input, std::vector<int> const &listTextId) |
| 582 |
: MWAWSubDocument(nullptr, input, MWAWEntry()) |
| 583 |
, m_powerpointParser(parser) |
| 584 |
, m_textId(-1) |
| 585 |
, m_listTextId(listTextId) |
| 586 |
{ |
| 587 |
} |
| 588 |
|
| 589 |
//! destructor |
| 590 |
~SubDocument() final {} |
| 591 |
|
| 592 |
//! operator!= |
| 593 |
bool operator!=(MWAWSubDocument const &doc) const final |
| 594 |
{ |
| 595 |
if (MWAWSubDocument::operator!=(doc)) return true; |
| 596 |
auto const *sDoc = dynamic_cast<SubDocument const *>(&doc); |
| 597 |
if (!sDoc) return true; |
| 598 |
if (&m_powerpointParser != &sDoc->m_powerpointParser) return true; |
| 599 |
if (m_textId != sDoc->m_textId) return true; |
| 600 |
if (m_listTextId != sDoc->m_listTextId) return true; |
| 601 |
return false; |
| 602 |
} |
| 603 |
|
| 604 |
//! the parser function |
| 605 |
void parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType type) final; |
| 606 |
|
| 607 |
protected: |
| 608 |
//! the parser |
| 609 |
PowerPoint7Graph &m_powerpointParser; |
| 610 |
//! the text id |
| 611 |
int m_textId; |
| 612 |
//! a list of text id |
| 613 |
std::vector<int> m_listTextId; |
| 614 |
private: |
| 615 |
SubDocument(SubDocument const &) = delete; |
| 616 |
SubDocument &operator=(SubDocument const &) = delete; |
| 617 |
}; |
| 618 |
|
| 619 |
void SubDocument::parse(MWAWListenerPtr &listener, libmwaw::SubDocumentType) |
| 620 |
{ |
| 621 |
if (!listener.get()) { |
| 622 |
MWAW_DEBUG_MSG(("PowerPoint7ParserInternal::SubDocument::parse: no listener\n")); |
| 623 |
return; |
| 624 |
} |
| 625 |
long pos = m_input->tell(); |
| 626 |
if (m_textId>=0) |
| 627 |
m_powerpointParser.sendText(m_textId); |
| 628 |
else { |
| 629 |
for (size_t z=0; z<m_listTextId.size(); ++z) { |
| 630 |
if (z) listener->insertEOL(); |
| 631 |
m_powerpointParser.sendText(m_listTextId[z]); |
| 632 |
} |
| 633 |
} |
| 634 |
m_input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 635 |
} |
| 636 |
} |
| 637 |
|
| 638 |
//////////////////////////////////////////////////////////// |
| 639 |
// constructor/destructor, ... |
| 640 |
//////////////////////////////////////////////////////////// |
| 641 |
PowerPoint7Graph::PowerPoint7Graph(PowerPoint7Parser &parser) |
| 642 |
: m_parserState(parser.getParserState()) |
| 643 |
, m_state(new PowerPoint7GraphInternal::State) |
| 644 |
, m_mainParser(&parser) |
| 645 |
{ |
| 646 |
} |
| 647 |
|
| 648 |
PowerPoint7Graph::~PowerPoint7Graph() |
| 649 |
{ } |
| 650 |
|
| 651 |
int PowerPoint7Graph::version() const |
| 652 |
{ |
| 653 |
return m_parserState->m_version; |
| 654 |
} |
| 655 |
|
| 656 |
void PowerPoint7Graph::setPageSize(MWAWVec2i const &pageSize) |
| 657 |
{ |
| 658 |
m_state->m_decal=MWAWVec2i(pageSize[0]/2,pageSize[1]/2); |
| 659 |
} |
| 660 |
|
| 661 |
void PowerPoint7Graph::setSlideId(PowerPoint7Struct::SlideId const &id) |
| 662 |
{ |
| 663 |
m_state->m_actualSlideId=id; |
| 664 |
} |
| 665 |
|
| 666 |
void PowerPoint7Graph::setColorList(std::vector<MWAWColor> const &colorList) |
| 667 |
{ |
| 668 |
m_state->m_colorList=colorList; |
| 669 |
} |
| 670 |
|
| 671 |
//////////////////////////////////////////////////////////// |
| 672 |
// |
| 673 |
// Intermediate level |
| 674 |
// |
| 675 |
//////////////////////////////////////////////////////////// |
| 676 |
|
| 677 |
bool PowerPoint7Graph::readGroup(int level, long lastPos) |
| 678 |
{ |
| 679 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 680 |
long pos=input->tell(); |
| 681 |
|
| 682 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 683 |
libmwaw::DebugStream f; |
| 684 |
PowerPoint7Struct::Zone header; |
| 685 |
if (!header.read(input,lastPos) || header.m_type!=3001) { |
| 686 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readGroup: can not find the zone header\n")); |
| 687 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 688 |
return false; |
| 689 |
} |
| 690 |
f << "Entries(Group)[" << level << "]:" << header; |
| 691 |
ascFile.addPos(pos); |
| 692 |
ascFile.addNote(f.str().c_str()); |
| 693 |
|
| 694 |
auto actualGroup=m_state->m_actualGroup; |
| 695 |
m_state->setFrame(new PowerPoint7GraphInternal::FrameGroup); |
| 696 |
long endPos=pos+16+header.m_dataSize; |
| 697 |
while (input->tell()<endPos) { |
| 698 |
pos=input->tell(); |
| 699 |
auto cType=int(input->readULong(2)); |
| 700 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 701 |
|
| 702 |
bool done=false; |
| 703 |
switch (cType) { |
| 704 |
case 2000: |
| 705 |
done=m_mainParser->readContainerList(level+1,endPos); |
| 706 |
break; |
| 707 |
case 3000: |
| 708 |
done=m_mainParser->readZone3000(level+1,endPos); |
| 709 |
break; |
| 710 |
case 3002: |
| 711 |
done=readGroupAtom(level+1,endPos); |
| 712 |
break; |
| 713 |
default: |
| 714 |
done=m_mainParser->readZone(level+1,endPos); |
| 715 |
if (done) { |
| 716 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readGroup: find unexpected zone %d\n", cType)); |
| 717 |
} |
| 718 |
break; |
| 719 |
} |
| 720 |
if (done) continue; |
| 721 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readGroup: can not read some data\n")); |
| 722 |
ascFile.addPos(pos); |
| 723 |
ascFile.addNote("Group:###extra"); |
| 724 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 725 |
break; |
| 726 |
} |
| 727 |
m_state->m_actualGroup=actualGroup; |
| 728 |
return true; |
| 729 |
} |
| 730 |
|
| 731 |
bool PowerPoint7Graph::readGroupAtom(int level, long lastPos) |
| 732 |
{ |
| 733 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 734 |
long pos=input->tell(); |
| 735 |
|
| 736 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 737 |
libmwaw::DebugStream f; |
| 738 |
PowerPoint7Struct::Zone header; |
| 739 |
if (!header.read(input,lastPos) || header.m_type!=3002) { |
| 740 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readGroupAtom: can not find the zone header\n")); |
| 741 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 742 |
return false; |
| 743 |
} |
| 744 |
f << "Entries(Group)[atom," << level << "]:" << header; |
| 745 |
if (header.m_dataSize!=4) { |
| 746 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readGroupAtom: find unexpected data size\n")); |
| 747 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 748 |
if (header.m_dataSize) |
| 749 |
ascFile.addDelimiter(pos+16,'|'); |
| 750 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 751 |
} |
| 752 |
else { |
| 753 |
for (int i=0; i<2; ++i) { |
| 754 |
auto val=int(input->readULong(2)); |
| 755 |
int const expected[]= {0x3b5b, 0x5000}; |
| 756 |
if (val!=expected[i]) f << "f" << i << "=" << std::hex << val << std::dec << ","; |
| 757 |
} |
| 758 |
} |
| 759 |
ascFile.addPos(pos); |
| 760 |
ascFile.addNote(f.str().c_str()); |
| 761 |
return true; |
| 762 |
} |
| 763 |
|
| 764 |
bool PowerPoint7Graph::readStyle(int level, long lastPos) |
| 765 |
{ |
| 766 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 767 |
long pos=input->tell(); |
| 768 |
|
| 769 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 770 |
libmwaw::DebugStream f; |
| 771 |
PowerPoint7Struct::Zone header; |
| 772 |
if (!header.read(input,lastPos) || header.m_type!=3005) { |
| 773 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: can not find the zone header\n")); |
| 774 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 775 |
return false; |
| 776 |
} |
| 777 |
f << "Entries(GraphStyle)[" << level << "]:" << header; |
| 778 |
if (header.m_dataSize!=0x38) { |
| 779 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: find unexpected data size\n")); |
| 780 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 781 |
if (header.m_dataSize) |
| 782 |
ascFile.addDelimiter(pos+16,'|'); |
| 783 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 784 |
ascFile.addPos(pos); |
| 785 |
ascFile.addNote(f.str().c_str()); |
| 786 |
return true; |
| 787 |
} |
| 788 |
|
| 789 |
MWAWGraphicStyle emptyStyle; |
| 790 |
MWAWGraphicStyle *style=m_state->m_actualFrame ? &m_state->m_actualFrame->m_style : &emptyStyle; |
| 791 |
int val; |
| 792 |
// |
| 793 |
// line |
| 794 |
// |
| 795 |
val=int(input->readLong(1)); |
| 796 |
bool showLine=true; |
| 797 |
if (val==-1 || val==1) { // normally -1, but =1 in dual powerpoint 95 and 97 files |
| 798 |
showLine=false; |
| 799 |
f << "no[line],"; |
| 800 |
} |
| 801 |
else if (val) f << "fl0=" << val << ","; |
| 802 |
auto dashId=int(input->readLong(1)); |
| 803 |
switch (dashId) { |
| 804 |
case 0: // no dash |
| 805 |
break; |
| 806 |
case 1: |
| 807 |
f << "dot,"; |
| 808 |
break; |
| 809 |
case 2: |
| 810 |
f << "dot[2x2],"; |
| 811 |
break; |
| 812 |
case 3: |
| 813 |
f << "dot[4x2],"; |
| 814 |
break; |
| 815 |
case 4: |
| 816 |
f << "dot[4,4,1,4],"; |
| 817 |
break; |
| 818 |
default: |
| 819 |
f << "###dashId=" << dashId << ","; |
| 820 |
} |
| 821 |
val=int(input->readLong(1)); // 0 |
| 822 |
if (val) f << "f0=" << val << ","; |
| 823 |
auto lineW=int(input->readLong(1)); |
| 824 |
if (lineW>=1 && lineW<=9) { |
| 825 |
char const *wh[]= {"w=1", "w=2","w=4", "w=8", "w=16", "w=32", |
| 826 |
"double", "double1x2", "double2x1", "triple1x2x1" |
| 827 |
}; |
| 828 |
f << wh[lineW] << ","; |
| 829 |
} |
| 830 |
else if (lineW) { |
| 831 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: find unexpected line style\n")); |
| 832 |
f << "##style[line]=" << lineW << ","; |
| 833 |
} |
| 834 |
unsigned char col[4]; |
| 835 |
for (auto &c : col) c=static_cast<unsigned char>(input->readULong(1)); |
| 836 |
MWAWColor lineColor=MWAWColor::black(); |
| 837 |
if (col[3]==0xfe) |
| 838 |
lineColor=MWAWColor(col[0],col[1],col[2]); |
| 839 |
else if (col[3]<int(m_state->m_colorList.size())) |
| 840 |
lineColor=m_state->m_colorList[size_t(col[3])]; |
| 841 |
else { |
| 842 |
// normally can happen one time at the beginning |
| 843 |
if (m_state->m_actualSlideId.isValid()) { |
| 844 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: can not find the line color\n")); |
| 845 |
f << "##"; |
| 846 |
} |
| 847 |
f << "color[lineId]=" << int(col[3]) << ","; |
| 848 |
} |
| 849 |
if (!lineColor.isBlack()) |
| 850 |
f << "color[line]=" << lineColor<< ","; |
| 851 |
if (!showLine) |
| 852 |
style->m_lineWidth=0; |
| 853 |
else { |
| 854 |
int lineWidth=1; |
| 855 |
MWAWBorder border; |
| 856 |
if (lineW>=1&&lineW<=9) { |
| 857 |
int const lWidth[]= {1, 2, 3, 6, 8, 10, 3, 4, 4, 6}; |
| 858 |
lineWidth=lWidth[lineW]; |
| 859 |
switch (lineW) { |
| 860 |
case 6: |
| 861 |
border.m_type=MWAWBorder::Double; |
| 862 |
break; |
| 863 |
case 7: |
| 864 |
border.m_type=MWAWBorder::Double; |
| 865 |
border.m_widthsList.push_back(1); |
| 866 |
border.m_widthsList.push_back(0); |
| 867 |
border.m_widthsList.push_back(2); |
| 868 |
break; |
| 869 |
case 8: |
| 870 |
border.m_type=MWAWBorder::Double; |
| 871 |
border.m_widthsList.push_back(2); |
| 872 |
border.m_widthsList.push_back(0); |
| 873 |
border.m_widthsList.push_back(1); |
| 874 |
break; |
| 875 |
case 9: |
| 876 |
border.m_type=MWAWBorder::Triple; |
| 877 |
border.m_widthsList.push_back(1); |
| 878 |
border.m_widthsList.push_back(0); |
| 879 |
border.m_widthsList.push_back(2); |
| 880 |
border.m_widthsList.push_back(0); |
| 881 |
border.m_widthsList.push_back(1); |
| 882 |
break; |
| 883 |
default: |
| 884 |
break; |
| 885 |
} |
| 886 |
} |
| 887 |
style->m_lineWidth=float(lineWidth); |
| 888 |
border.m_width=double(lineWidth); |
| 889 |
style->setBorders(0xF, border); |
| 890 |
|
| 891 |
style->m_lineColor=border.m_color=lineColor; |
| 892 |
switch (dashId) { |
| 893 |
case 0: // no dash |
| 894 |
default: // problem |
| 895 |
break; |
| 896 |
case 1: |
| 897 |
style->m_lineDashWidth.resize(2,float(lineWidth)); |
| 898 |
break; |
| 899 |
case 2: |
| 900 |
style->m_lineDashWidth.resize(2,float(2*lineWidth)); |
| 901 |
break; |
| 902 |
case 3: |
| 903 |
style->m_lineDashWidth.resize(2,float(4*lineWidth)); |
| 904 |
break; |
| 905 |
case 4: |
| 906 |
style->m_lineDashWidth.resize(4,float(2*lineWidth)); |
| 907 |
style->m_lineDashWidth[2]=float(lineWidth); |
| 908 |
break; |
| 909 |
} |
| 910 |
} |
| 911 |
|
| 912 |
for (int i=0; i<2; ++i) { // 0 |
| 913 |
val=int(input->readLong(2)); |
| 914 |
if (val) f << "f" << i+1 << "=" << val << ","; |
| 915 |
} |
| 916 |
|
| 917 |
// |
| 918 |
// surface |
| 919 |
// |
| 920 |
val=int(input->readLong(1)); |
| 921 |
bool showSurf=true; |
| 922 |
if (val==-1 || val==1) { |
| 923 |
showSurf=false; |
| 924 |
f << "no[surf],"; |
| 925 |
} |
| 926 |
else if (val) f << "fl1=" << val << ","; |
| 927 |
auto surfType=int(input->readLong(1)); |
| 928 |
switch (surfType) { |
| 929 |
case 1: // color |
| 930 |
break; |
| 931 |
case 2: |
| 932 |
f << "background,"; |
| 933 |
break; |
| 934 |
case 3: |
| 935 |
f << "transparent[semi],"; |
| 936 |
break; |
| 937 |
case 4: |
| 938 |
f << "pattern,"; |
| 939 |
break; |
| 940 |
case 5: |
| 941 |
f << "gradient,"; |
| 942 |
break; |
| 943 |
case 6: |
| 944 |
f << "picture,"; |
| 945 |
break; |
| 946 |
case 7: |
| 947 |
f << "background[picture],"; |
| 948 |
break; |
| 949 |
default: |
| 950 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: find unexpected surface type\n")); |
| 951 |
f << "##surf[type]=" << surfType << ","; |
| 952 |
break; |
| 953 |
} |
| 954 |
int patGradId=0, gradType=0, gradColorMapId=0, subGradientId=0; |
| 955 |
for (int i=0; i<6; ++i) { // fl3=0|78-b7,fl4=0|1|4,then small number |
| 956 |
val=int(input->readULong(1)); |
| 957 |
if (!val) continue; |
| 958 |
switch (i) { |
| 959 |
case 2: |
| 960 |
patGradId=val; |
| 961 |
f << "patGrad[id]=" << val << ","; |
| 962 |
break; |
| 963 |
case 3: |
| 964 |
subGradientId=val; |
| 965 |
f << "grad[subId]=" << val << ","; |
| 966 |
break; |
| 967 |
case 4: |
| 968 |
gradColorMapId=val; |
| 969 |
f << "grad[colorMap]=" << val << ","; |
| 970 |
break; |
| 971 |
case 5: // 0: one color, 1: two color, 2: preset |
| 972 |
gradType=val; |
| 973 |
if (val==2) |
| 974 |
f << "gradType=preset,"; |
| 975 |
else if (val!=1) |
| 976 |
f << "###gradType=" << val << ","; |
| 977 |
break; |
| 978 |
default: |
| 979 |
f << "fl" << i+3 << "=" << std::hex << val << std::dec << ","; |
| 980 |
} |
| 981 |
} |
| 982 |
MWAWColor surfColors[2]= {MWAWColor::white(), MWAWColor::black()}; |
| 983 |
for (int c=0; c<2; ++c) { |
| 984 |
for (auto &co : col) co=static_cast<unsigned char>(input->readULong(1)); |
| 985 |
if (col[3]==0xfe) |
| 986 |
surfColors[c]=MWAWColor(col[0],col[1],col[2]); |
| 987 |
else if (col[3]<int(m_state->m_colorList.size())) |
| 988 |
surfColors[c]=m_state->m_colorList[size_t(col[3])]; |
| 989 |
else { |
| 990 |
// normally can happen one time at the beginning |
| 991 |
if (m_state->m_actualSlideId.isValid()) { |
| 992 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: can not find the surface color\n")); |
| 993 |
f << "##"; |
| 994 |
} |
| 995 |
f << "color" << c << "[surf]=" << int(col[3]) << ","; |
| 996 |
} |
| 997 |
if ((c==0 && !surfColors[c].isWhite()) || (c==1 && !surfColors[c].isBlack())) |
| 998 |
f << "color" << c << "[surf]=" << surfColors[c] << ","; |
| 999 |
} |
| 1000 |
if (showSurf) { |
| 1001 |
switch (surfType) { |
| 1002 |
case 1: |
| 1003 |
style->setSurfaceColor(surfColors[0]); |
| 1004 |
break; |
| 1005 |
case 2: |
| 1006 |
if (!m_state->m_colorList.empty()) |
| 1007 |
style->setSurfaceColor(m_state->m_colorList[0]); |
| 1008 |
break; |
| 1009 |
case 3: |
| 1010 |
style->setSurfaceColor(surfColors[0], 0.5); |
| 1011 |
break; |
| 1012 |
case 4: { |
| 1013 |
MWAWGraphicStyle::Pattern pattern; |
| 1014 |
if (m_state->getPattern(patGradId+1, pattern)) { |
| 1015 |
pattern.m_colors[0]=surfColors[1]; |
| 1016 |
pattern.m_colors[1]=surfColors[0]; |
| 1017 |
MWAWColor color; |
| 1018 |
if (pattern.getUniqueColor(color)) |
| 1019 |
style->setSurfaceColor(color); |
| 1020 |
else |
| 1021 |
style->setPattern(pattern); |
| 1022 |
} |
| 1023 |
break; |
| 1024 |
} |
| 1025 |
case 5: { |
| 1026 |
auto &finalGrad=style->m_gradient; |
| 1027 |
finalGrad.m_stopList.resize(0); |
| 1028 |
MWAWColor colors[]= {surfColors[0],surfColors[1]}; |
| 1029 |
if (gradType==2 && gradColorMapId>=0 && gradColorMapId<=15) { |
| 1030 |
uint32_t const defColors[]= { |
| 1031 |
0xff, 0xff0000, // early sunset |
| 1032 |
0xff, 0xffff00, // late sunset |
| 1033 |
0, 0x80, // night fall |
| 1034 |
0xff, 0xffffff, // daybreak |
| 1035 |
0xfff8dc, 0xd284bc, // parchment |
| 1036 |
0xfff8dc, 0xbf8f8f, // Mahogany |
| 1037 |
0x80, 0x808080, // fog |
| 1038 |
0xffffff, 0xff00, // moss |
| 1039 |
0xff, 0x80, // ocean |
| 1040 |
0xffff00, 0xff0000, // fire |
| 1041 |
0xff00ff, 0xffff00, // rainbow |
| 1042 |
0xffffff, 0xffff00, // gold |
| 1043 |
0xffff00, 0x808000, // brass |
| 1044 |
0xffffff, 0x808080, // chrome |
| 1045 |
0xffffff, 0x808080, // silver |
| 1046 |
0xff, 0x80, // sapphire |
| 1047 |
}; |
| 1048 |
colors[0]=defColors[2*gradColorMapId]; |
| 1049 |
colors[1]=defColors[2*gradColorMapId+1]; |
| 1050 |
} |
| 1051 |
if (patGradId>=1 && patGradId<=4) { |
| 1052 |
if (subGradientId<2) { |
| 1053 |
finalGrad.m_type=MWAWGraphicStyle::Gradient::G_Linear; |
| 1054 |
for (int c=0; c < 2; ++c) |
| 1055 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c), (c==subGradientId) ? colors[0] : colors[1])); |
| 1056 |
} |
| 1057 |
else { |
| 1058 |
finalGrad.m_type=MWAWGraphicStyle::Gradient::G_Axial; |
| 1059 |
for (int c=0; c < 3; ++c) |
| 1060 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c)/2.f, ((c%2)==(subGradientId%2)) ? colors[0] : colors[1])); |
| 1061 |
} |
| 1062 |
float const angles[]= {90,0,45,315}; |
| 1063 |
finalGrad.m_angle=angles[patGradId-1]; |
| 1064 |
} |
| 1065 |
else if (patGradId==5) { |
| 1066 |
finalGrad.m_type=MWAWGraphicStyle::Gradient::G_Rectangular; |
| 1067 |
for (int c=0; c < 2; ++c) |
| 1068 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c), c==0 ? colors[0] : colors[1])); |
| 1069 |
finalGrad.m_percentCenter=MWAWVec2f(float(subGradientId&1),float(subGradientId<2 ? 0 : 1)); |
| 1070 |
} |
| 1071 |
else if (patGradId==7) { |
| 1072 |
finalGrad.m_type=MWAWGraphicStyle::Gradient::G_Rectangular; |
| 1073 |
for (int c=0; c < 2; ++c) |
| 1074 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c), ((c%2)==(subGradientId%2)) ? colors[0] : colors[1])); |
| 1075 |
} |
| 1076 |
else { |
| 1077 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: find unknown gradient\n")); |
| 1078 |
style->setSurfaceColor(colors[0]); |
| 1079 |
} |
| 1080 |
break; |
| 1081 |
} |
| 1082 |
case 6: { |
| 1083 |
if (m_state->m_idToPictureMap.find(patGradId)==m_state->m_idToPictureMap.end()) { |
| 1084 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: can not find picture %d\n", patGradId)); |
| 1085 |
break; |
| 1086 |
} |
| 1087 |
auto const &picture=m_state->m_idToPictureMap.find(patGradId)->second; |
| 1088 |
MWAWGraphicStyle::Pattern pattern(picture.m_box.size(), picture.m_object, surfColors[0]); |
| 1089 |
style->setPattern(pattern); |
| 1090 |
break; |
| 1091 |
} |
| 1092 |
default: |
| 1093 |
break; |
| 1094 |
} |
| 1095 |
} |
| 1096 |
ascFile.addPos(pos); |
| 1097 |
ascFile.addNote(f.str().c_str()); |
| 1098 |
|
| 1099 |
// |
| 1100 |
// the shadow |
| 1101 |
// |
| 1102 |
pos=input->tell(); |
| 1103 |
f.str(""); |
| 1104 |
f << "GraphStyle-A:"; |
| 1105 |
bool hasShadow=false; |
| 1106 |
val=int(input->readLong(1)); |
| 1107 |
if (val==0) { |
| 1108 |
f << "has[shadow],"; |
| 1109 |
hasShadow=true; |
| 1110 |
} |
| 1111 |
else if (val!=-1 && val!=1) f << "#has[shadow]=" << val << ","; |
| 1112 |
auto shadowType=int(input->readLong(1)); // 1 |
| 1113 |
switch (shadowType) { |
| 1114 |
case 1: // basic |
| 1115 |
break; |
| 1116 |
case 2: |
| 1117 |
f << "semi[transparent],"; |
| 1118 |
break; |
| 1119 |
default: |
| 1120 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: find unexpected shadow type\n")); |
| 1121 |
f << "##shadow[type]=" << shadowType << ","; |
| 1122 |
} |
| 1123 |
for (auto &c : col) c=static_cast<unsigned char>(input->readULong(1)); |
| 1124 |
MWAWColor shadowColor=MWAWColor::black(); |
| 1125 |
if (col[3]==0xfe) |
| 1126 |
shadowColor=MWAWColor(col[0],col[1],col[2]); |
| 1127 |
else if (col[3]<int(m_state->m_colorList.size())) |
| 1128 |
shadowColor=m_state->m_colorList[size_t(col[3])]; |
| 1129 |
else { |
| 1130 |
// normally can happen one time at the beginning |
| 1131 |
if (m_state->m_actualSlideId.isValid()) { |
| 1132 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readStyle: can not find the shadow color\n")); |
| 1133 |
f << "##"; |
| 1134 |
} |
| 1135 |
f << "color[shadowId]=" << int(col[3]) << ","; |
| 1136 |
} |
| 1137 |
if (!shadowColor.isBlack()) |
| 1138 |
f << "color[shadow]=" << shadowColor<< ","; |
| 1139 |
val=int(input->readLong(2)); // 0|bd |
| 1140 |
if (val) f << "f1=" << val << ","; |
| 1141 |
float shadowDepl[2]= {6,6}; |
| 1142 |
for (int i=0; i<2; ++i) { |
| 1143 |
long depl=input->readLong(4); |
| 1144 |
if (depl==48) continue; |
| 1145 |
shadowDepl[i]=float(depl)/8.f; |
| 1146 |
f << "depl[" << (i==0 ? "right" : "bottom") << "]=" << shadowDepl[i] << ","; |
| 1147 |
} |
| 1148 |
if (hasShadow) { |
| 1149 |
style->setShadowColor(shadowColor, shadowType==2 ? 0.5f : 1.f); |
| 1150 |
style->m_shadowOffset=MWAWVec2f(shadowDepl[0],shadowDepl[1]); |
| 1151 |
} |
| 1152 |
val=int(input->readULong(1)); // 0|1|4 |
| 1153 |
if (val) f << "f2=" << val << ","; |
| 1154 |
val=int(input->readULong(2)); // 0|62XX |
| 1155 |
if (val) f << "f3=" << std::hex << val << std::dec << ","; |
| 1156 |
val=int(input->readULong(1)); // 0|1|50 |
| 1157 |
if (val) f << "f4=" << std::hex << val << std::dec << ","; |
| 1158 |
val=int(input->readLong(2)); |
| 1159 |
if (val) f << "rot=" << float(val)/16.f << ","; |
| 1160 |
val=int(input->readULong(2)); // 0 |
| 1161 |
if (val) f << "f5=" << val << ","; |
| 1162 |
val=int(input->readULong(1)); |
| 1163 |
if (val&0x1) { |
| 1164 |
if (m_state->m_actualFrame) m_state->m_actualFrame->m_flip[0]=true; |
| 1165 |
f << "flipX,"; |
| 1166 |
} |
| 1167 |
if (val&0x2) { |
| 1168 |
if (m_state->m_actualFrame) m_state->m_actualFrame->m_flip[1]=true; |
| 1169 |
f << "flipY,"; |
| 1170 |
} |
| 1171 |
val&=0xfc; |
| 1172 |
if (val) f << "fl1=" << std::hex << val << std::dec << ","; |
| 1173 |
val=int(input->readULong(2)); |
| 1174 |
if (val) f << "f5=" << std::hex << val << std::dec << ","; |
| 1175 |
val=int(input->readULong(1)); // 0 |
| 1176 |
if (val) f << "fl2=" << val << ","; |
| 1177 |
input->seek(pos+28, librevenge::RVNG_SEEK_SET); |
| 1178 |
ascFile.addPos(pos); |
| 1179 |
ascFile.addNote(f.str().c_str()); |
| 1180 |
|
| 1181 |
return true; |
| 1182 |
} |
| 1183 |
|
| 1184 |
bool PowerPoint7Graph::readLineArrows(int level, long lastPos) |
| 1185 |
{ |
| 1186 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1187 |
long pos=input->tell(); |
| 1188 |
|
| 1189 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1190 |
libmwaw::DebugStream f; |
| 1191 |
PowerPoint7Struct::Zone header; |
| 1192 |
if (!header.read(input,lastPos) || header.m_type!=3007) { |
| 1193 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLineArrows: can not find the zone header\n")); |
| 1194 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1195 |
return false; |
| 1196 |
} |
| 1197 |
MWAWGraphicStyle emptyStyle; |
| 1198 |
MWAWGraphicStyle *style=m_state->m_actualFrame ? &m_state->m_actualFrame->m_style : &emptyStyle; |
| 1199 |
f << "Entries(GraphLine)[arrows," << level << "]:" << header; |
| 1200 |
if (header.m_dataSize!=2) { |
| 1201 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLineArrows: find unexpected data size\n")); |
| 1202 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1203 |
if (header.m_dataSize) |
| 1204 |
ascFile.addDelimiter(pos+16,'|'); |
| 1205 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1206 |
} |
| 1207 |
else { |
| 1208 |
for (int i=0; i<2; ++i) { // f0=0|1, f1=0|1 |
| 1209 |
auto val=int(input->readULong(1)); |
| 1210 |
if (!val) continue; |
| 1211 |
MWAWGraphicStyle::Arrow arrow; |
| 1212 |
if (m_state->getArrow(val, arrow)) |
| 1213 |
style->m_arrows[i]=arrow; |
| 1214 |
f << "arrow[" << (i==0 ? "start" : "end") << "]=" << val << ","; |
| 1215 |
} |
| 1216 |
} |
| 1217 |
ascFile.addPos(pos); |
| 1218 |
ascFile.addNote(f.str().c_str()); |
| 1219 |
return true; |
| 1220 |
} |
| 1221 |
|
| 1222 |
bool PowerPoint7Graph::readRect(int level, long lastPos) |
| 1223 |
{ |
| 1224 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1225 |
long pos=input->tell(); |
| 1226 |
|
| 1227 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1228 |
libmwaw::DebugStream f; |
| 1229 |
PowerPoint7Struct::Zone header; |
| 1230 |
if (!header.read(input,lastPos) || header.m_type!=3008) { |
| 1231 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRect: can not find the zone header\n")); |
| 1232 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1233 |
return false; |
| 1234 |
} |
| 1235 |
f << "Entries(GraphRect)[" << level << "]:" << header; |
| 1236 |
switch (header.m_values[3]) { |
| 1237 |
case 16: |
| 1238 |
f << "type=16,"; |
| 1239 |
break; |
| 1240 |
case 19: // basic |
| 1241 |
break; |
| 1242 |
case 28: |
| 1243 |
f << "background,"; |
| 1244 |
break; |
| 1245 |
default: |
| 1246 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRect: find unknow type\n")); |
| 1247 |
f << "##type=" << header.m_values[3] << ","; |
| 1248 |
break; |
| 1249 |
} |
| 1250 |
ascFile.addPos(pos); |
| 1251 |
ascFile.addNote(f.str().c_str()); |
| 1252 |
|
| 1253 |
m_state->setFrame(new PowerPoint7GraphInternal::FrameRect); |
| 1254 |
auto &frame=*m_state->m_actualFrame; |
| 1255 |
if (header.m_values[3]==28) |
| 1256 |
frame.m_isBackground=true; |
| 1257 |
long endPos=pos+16+header.m_dataSize; |
| 1258 |
while (input->tell()<endPos) { |
| 1259 |
pos=input->tell(); |
| 1260 |
auto cType=int(input->readULong(2)); |
| 1261 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1262 |
|
| 1263 |
bool done=false; |
| 1264 |
switch (cType) { |
| 1265 |
case 3005: |
| 1266 |
done=readStyle(level+1,endPos); |
| 1267 |
break; |
| 1268 |
case 3009: |
| 1269 |
done=readRectAtom(level+1,endPos); |
| 1270 |
break; |
| 1271 |
case 3036: |
| 1272 |
done=readZoneFlags(level+1,endPos); |
| 1273 |
break; |
| 1274 |
case 4001: |
| 1275 |
if (frame.m_textId!=-1) { |
| 1276 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRect: already find some text zone\n")); |
| 1277 |
} |
| 1278 |
done=m_mainParser->readStyleTextPropAtom(level+1,endPos,frame.m_textId); |
| 1279 |
break; |
| 1280 |
case 4014: { |
| 1281 |
PowerPoint7Struct::SlideId sId; |
| 1282 |
done=m_mainParser->readOutlineTextProps9Atom(level+1,endPos,frame.m_pictureId,sId); |
| 1283 |
break; |
| 1284 |
} |
| 1285 |
case 4072: |
| 1286 |
done=m_mainParser->readZone4072(level+1,endPos); |
| 1287 |
break; |
| 1288 |
case 5000: |
| 1289 |
done=readZone5000(level+1,endPos); |
| 1290 |
break; |
| 1291 |
default: |
| 1292 |
done=m_mainParser->readZone(level+1,endPos); |
| 1293 |
if (done) { |
| 1294 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRect: find unexpected zone %d\n", cType)); |
| 1295 |
} |
| 1296 |
break; |
| 1297 |
} |
| 1298 |
if (done) continue; |
| 1299 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRect: can not read some data\n")); |
| 1300 |
ascFile.addPos(pos); |
| 1301 |
ascFile.addNote("GraphRect:###extra"); |
| 1302 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1303 |
break; |
| 1304 |
} |
| 1305 |
m_state->resetFrame(); |
| 1306 |
return true; |
| 1307 |
} |
| 1308 |
|
| 1309 |
bool PowerPoint7Graph::readRectAtom(int level, long lastPos) |
| 1310 |
{ |
| 1311 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1312 |
long pos=input->tell(); |
| 1313 |
|
| 1314 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1315 |
libmwaw::DebugStream f; |
| 1316 |
PowerPoint7Struct::Zone header; |
| 1317 |
if (!header.read(input,lastPos) || header.m_type!=3009) { |
| 1318 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRectAtom: can not find the zone header\n")); |
| 1319 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1320 |
return false; |
| 1321 |
} |
| 1322 |
f << "Entries(GraphRect)[atom," << level << "]:" << header; |
| 1323 |
if (header.m_dataSize!=0x28) { |
| 1324 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readRectAtom: find unexpected data size\n")); |
| 1325 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1326 |
if (header.m_dataSize) |
| 1327 |
ascFile.addDelimiter(pos+16,'|'); |
| 1328 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1329 |
ascFile.addPos(pos); |
| 1330 |
ascFile.addNote(f.str().c_str()); |
| 1331 |
return true; |
| 1332 |
} |
| 1333 |
|
| 1334 |
auto frame=m_state->m_actualFrame; |
| 1335 |
auto type=int(input->readLong(1)); |
| 1336 |
if (frame) frame->m_subType=type; |
| 1337 |
switch (type) { |
| 1338 |
case -3: |
| 1339 |
f << "rect,"; |
| 1340 |
break; |
| 1341 |
case -2: |
| 1342 |
f << "rectOval,"; |
| 1343 |
break; |
| 1344 |
case -1: |
| 1345 |
f << "circle,"; |
| 1346 |
break; |
| 1347 |
default: // >=1 && <=? : the shape id |
| 1348 |
f << "type=" << type << ","; |
| 1349 |
break; |
| 1350 |
} |
| 1351 |
auto val=int(input->readULong(1)); |
| 1352 |
if (val!=0xff) { // unsure |
| 1353 |
switch ((val>>5)&3) { |
| 1354 |
case 0: |
| 1355 |
break; |
| 1356 |
case 2: |
| 1357 |
f << "flipX,"; |
| 1358 |
break; |
| 1359 |
case 3: |
| 1360 |
f << "flipY,"; |
| 1361 |
break; |
| 1362 |
default: |
| 1363 |
f << "##flip=1,"; |
| 1364 |
break; |
| 1365 |
} |
| 1366 |
val&=0x9f; |
| 1367 |
if (val) f << "##flip[other]=" << std::hex << val << std::dec << ","; |
| 1368 |
} |
| 1369 |
for (int i=0; i<3; ++i) { |
| 1370 |
val=int(input->readLong(2)); |
| 1371 |
int const expected[]= {-1,0,0}; |
| 1372 |
if (val!=expected[i]) f << "f" << i << "=" << val << ","; |
| 1373 |
} |
| 1374 |
for (int i=0; i<4; ++i) { |
| 1375 |
val=int(input->readULong(1)); |
| 1376 |
if (val) f << "fl" << i << "=" << std::hex << val << std::dec << ","; |
| 1377 |
} |
| 1378 |
int dim[4]; |
| 1379 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 1380 |
MWAWBox2i dimension(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])); |
| 1381 |
if (frame) frame->m_dimension=dimension; |
| 1382 |
f << "dim=" << dimension << ","; |
| 1383 |
val=int(input->readLong(2)); |
| 1384 |
if (val) { |
| 1385 |
if (frame) frame->m_rotation=float(val)/16.f; |
| 1386 |
f << "rot=" << float(val)/16.f << ","; |
| 1387 |
} |
| 1388 |
for (int i=0; i<2; ++i) { |
| 1389 |
val=int(input->readLong(i==0 ? 2 : 4)); |
| 1390 |
int const expected[]= {0,-3}; |
| 1391 |
if (val!=expected[i]) |
| 1392 |
f << "f" << i+6 << "=" << val << ","; |
| 1393 |
} |
| 1394 |
val=int(input->readULong(1)); |
| 1395 |
if (val==1) |
| 1396 |
f << "has[anchor],"; |
| 1397 |
else if (val) |
| 1398 |
f << "##has[anchor]=" << val << ","; |
| 1399 |
for (int i=0; i<3; ++i) { // fl0=0-1, fl1=0|76-b8 |
| 1400 |
val=int(input->readULong(1)); |
| 1401 |
if (val) f << "fl" << i+4 << "=" << std::hex << val << std::dec << ","; |
| 1402 |
} |
| 1403 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1404 |
ascFile.addPos(pos); |
| 1405 |
ascFile.addNote(f.str().c_str()); |
| 1406 |
|
| 1407 |
return true; |
| 1408 |
} |
| 1409 |
|
| 1410 |
bool PowerPoint7Graph::readPlaceholderContainer(int level, long lastPos) |
| 1411 |
{ |
| 1412 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1413 |
long pos=input->tell(); |
| 1414 |
|
| 1415 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1416 |
libmwaw::DebugStream f; |
| 1417 |
PowerPoint7Struct::Zone header; |
| 1418 |
if (!header.read(input,lastPos) || header.m_type!=3010) { |
| 1419 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPlaceholderContainer: can not find the zone header\n")); |
| 1420 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1421 |
return false; |
| 1422 |
} |
| 1423 |
f << "Entries(Placeholder)[container," << level << "]:" << header; |
| 1424 |
ascFile.addPos(pos); |
| 1425 |
ascFile.addNote(f.str().c_str()); |
| 1426 |
|
| 1427 |
m_state->setFrame(new PowerPoint7GraphInternal::FramePlaceholder); |
| 1428 |
auto &frame=*m_state->m_actualFrame; |
| 1429 |
long endPos=pos+16+header.m_dataSize; |
| 1430 |
while (input->tell()<endPos) { |
| 1431 |
pos=input->tell(); |
| 1432 |
auto cType=int(input->readULong(2)); |
| 1433 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1434 |
|
| 1435 |
bool done=false; |
| 1436 |
switch (cType) { |
| 1437 |
case 3005: |
| 1438 |
done=readStyle(level+1,endPos); |
| 1439 |
break; |
| 1440 |
case 3009: |
| 1441 |
done=readRectAtom(level+1,endPos); |
| 1442 |
break; |
| 1443 |
case 3011: |
| 1444 |
done=readPlaceholderAtom(level+1,endPos); |
| 1445 |
break; |
| 1446 |
case 3036: |
| 1447 |
done=readZoneFlags(level+1,endPos); |
| 1448 |
break; |
| 1449 |
case 4001: |
| 1450 |
if (frame.m_textId!=-1) { |
| 1451 |
MWAW_DEBUG_MSG(("PowerPoint7GraphPlaceholderContainer::read: already find some text zone\n")); |
| 1452 |
} |
| 1453 |
done=m_mainParser->readStyleTextPropAtom(level+1,endPos,frame.m_textId); |
| 1454 |
break; |
| 1455 |
case 4014: { |
| 1456 |
int pId; |
| 1457 |
PowerPoint7Struct::SlideId sId; |
| 1458 |
done=m_mainParser->readOutlineTextProps9Atom(level+1,endPos,pId,sId); |
| 1459 |
break; |
| 1460 |
} |
| 1461 |
default: |
| 1462 |
done=m_mainParser->readZone(level+1,endPos); |
| 1463 |
if (done) { |
| 1464 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPlaceholderContainer: find unexpected zone %d\n", cType)); |
| 1465 |
} |
| 1466 |
break; |
| 1467 |
} |
| 1468 |
if (done) continue; |
| 1469 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPlaceholderContainer: can not read some data\n")); |
| 1470 |
ascFile.addPos(pos); |
| 1471 |
ascFile.addNote("Placeholder:###extra"); |
| 1472 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1473 |
break; |
| 1474 |
} |
| 1475 |
m_state->resetFrame(); |
| 1476 |
return true; |
| 1477 |
} |
| 1478 |
|
| 1479 |
bool PowerPoint7Graph::readPlaceholderAtom(int level, long lastPos) |
| 1480 |
{ |
| 1481 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1482 |
long pos=input->tell(); |
| 1483 |
|
| 1484 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1485 |
libmwaw::DebugStream f; |
| 1486 |
PowerPoint7Struct::Zone header; |
| 1487 |
if (!header.read(input,lastPos) || header.m_type!=3011) { |
| 1488 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPlaceholderAtom: can not find the zone header\n")); |
| 1489 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1490 |
return false; |
| 1491 |
} |
| 1492 |
f << "Entries(Placeholder)[atom," << level << "]:" << header; |
| 1493 |
if (header.m_dataSize!=8) { |
| 1494 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPlaceholderAtom: find unexpected data size\n")); |
| 1495 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1496 |
if (header.m_dataSize) |
| 1497 |
ascFile.addDelimiter(pos+16,'|'); |
| 1498 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1499 |
} |
| 1500 |
else { |
| 1501 |
for (int i=0; i<4; ++i) { // f0 id?, f1=62, f2=0-6 |
| 1502 |
auto val=int(input->readULong(2)); |
| 1503 |
if (!val) continue; |
| 1504 |
f << "f" << i << "=" << val << ","; |
| 1505 |
} |
| 1506 |
} |
| 1507 |
ascFile.addPos(pos); |
| 1508 |
ascFile.addNote(f.str().c_str()); |
| 1509 |
return true; |
| 1510 |
} |
| 1511 |
|
| 1512 |
bool PowerPoint7Graph::readLine(int level, long lastPos) |
| 1513 |
{ |
| 1514 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1515 |
long pos=input->tell(); |
| 1516 |
|
| 1517 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1518 |
libmwaw::DebugStream f; |
| 1519 |
PowerPoint7Struct::Zone header; |
| 1520 |
if (!header.read(input,lastPos) || header.m_type!=3014) { |
| 1521 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLine: can not find the zone header\n")); |
| 1522 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1523 |
return false; |
| 1524 |
} |
| 1525 |
f << "Entries(GraphLine)[" << level << "]:" << header; |
| 1526 |
ascFile.addPos(pos); |
| 1527 |
ascFile.addNote(f.str().c_str()); |
| 1528 |
|
| 1529 |
m_state->setFrame(new PowerPoint7GraphInternal::Frame(PowerPoint7GraphInternal::Frame::Line)); |
| 1530 |
long endPos=pos+16+header.m_dataSize; |
| 1531 |
while (input->tell()<endPos) { |
| 1532 |
pos=input->tell(); |
| 1533 |
auto cType=int(input->readULong(2)); |
| 1534 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1535 |
|
| 1536 |
bool done=false; |
| 1537 |
switch (cType) { |
| 1538 |
case 3005: |
| 1539 |
done=readStyle(level+1,endPos); |
| 1540 |
break; |
| 1541 |
case 3007: |
| 1542 |
done=readLineArrows(level+1,endPos); |
| 1543 |
break; |
| 1544 |
case 3015: |
| 1545 |
done=readLineAtom(level+1,endPos); |
| 1546 |
break; |
| 1547 |
default: |
| 1548 |
done=m_mainParser->readZone(level+1,endPos); |
| 1549 |
if (done) { |
| 1550 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLine: find unexpected zone %d\n", cType)); |
| 1551 |
} |
| 1552 |
break; |
| 1553 |
} |
| 1554 |
if (done) continue; |
| 1555 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLine: can not read some data\n")); |
| 1556 |
ascFile.addPos(pos); |
| 1557 |
ascFile.addNote("GraphLine:###extra"); |
| 1558 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1559 |
break; |
| 1560 |
} |
| 1561 |
m_state->resetFrame(); |
| 1562 |
return true; |
| 1563 |
} |
| 1564 |
|
| 1565 |
bool PowerPoint7Graph::readLineAtom(int level, long lastPos) |
| 1566 |
{ |
| 1567 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1568 |
long pos=input->tell(); |
| 1569 |
|
| 1570 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1571 |
libmwaw::DebugStream f; |
| 1572 |
PowerPoint7Struct::Zone header; |
| 1573 |
if (!header.read(input,lastPos) || header.m_type!=3015) { |
| 1574 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLineAtom: can not find the zone header\n")); |
| 1575 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1576 |
return false; |
| 1577 |
} |
| 1578 |
f << "Entries(GraphLine)[atom," << level << "]:" << header; |
| 1579 |
if (header.m_dataSize!=0x10) { |
| 1580 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readLineAtom: find unexpected data size\n")); |
| 1581 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1582 |
if (header.m_dataSize) |
| 1583 |
ascFile.addDelimiter(pos+16,'|'); |
| 1584 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1585 |
ascFile.addPos(pos); |
| 1586 |
ascFile.addNote(f.str().c_str()); |
| 1587 |
return true; |
| 1588 |
} |
| 1589 |
|
| 1590 |
auto frame=m_state->m_actualFrame; |
| 1591 |
int dim[4]; |
| 1592 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 1593 |
MWAWBox2i dimension(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])); |
| 1594 |
if (frame) frame->m_dimension=dimension; |
| 1595 |
f << "dim=" << dimension << ","; |
| 1596 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1597 |
ascFile.addPos(pos); |
| 1598 |
ascFile.addNote(f.str().c_str()); |
| 1599 |
|
| 1600 |
return true; |
| 1601 |
} |
| 1602 |
|
| 1603 |
bool PowerPoint7Graph::readPolygon(int level, long lastPos) |
| 1604 |
{ |
| 1605 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1606 |
long pos=input->tell(); |
| 1607 |
|
| 1608 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1609 |
libmwaw::DebugStream f; |
| 1610 |
PowerPoint7Struct::Zone header; |
| 1611 |
if (!header.read(input,lastPos) || header.m_type!=3016) { |
| 1612 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPolygon: can not find the zone header\n")); |
| 1613 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1614 |
return false; |
| 1615 |
} |
| 1616 |
f << "Entries(GraphPolygon)[" << level << "]:" << header; |
| 1617 |
ascFile.addPos(pos); |
| 1618 |
ascFile.addNote(f.str().c_str()); |
| 1619 |
|
| 1620 |
auto *poly=new PowerPoint7GraphInternal::FramePolygon; |
| 1621 |
m_state->setFrame(poly); |
| 1622 |
long endPos=pos+16+header.m_dataSize; |
| 1623 |
while (input->tell()<endPos) { |
| 1624 |
pos=input->tell(); |
| 1625 |
auto cType=int(input->readULong(2)); |
| 1626 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1627 |
|
| 1628 |
bool done=false; |
| 1629 |
switch (cType) { |
| 1630 |
case 3005: |
| 1631 |
done=readStyle(level+1,endPos); |
| 1632 |
break; |
| 1633 |
case 3007: |
| 1634 |
done=readLineArrows(level+1,endPos); |
| 1635 |
break; |
| 1636 |
case 3017: |
| 1637 |
done=readPolygonAtom(level+1,endPos); |
| 1638 |
break; |
| 1639 |
case 3035: |
| 1640 |
done=readPointList(level+1,endPos, poly->m_vertices); |
| 1641 |
break; |
| 1642 |
default: |
| 1643 |
done=m_mainParser->readZone(level+1,endPos); |
| 1644 |
if (done) { |
| 1645 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPolygon: find unexpected zone %d\n", cType)); |
| 1646 |
} |
| 1647 |
break; |
| 1648 |
} |
| 1649 |
if (done) continue; |
| 1650 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPolygon: can not read some data\n")); |
| 1651 |
ascFile.addPos(pos); |
| 1652 |
ascFile.addNote("GraphPolygon:###extra"); |
| 1653 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1654 |
break; |
| 1655 |
} |
| 1656 |
m_state->resetFrame(); |
| 1657 |
return true; |
| 1658 |
} |
| 1659 |
|
| 1660 |
bool PowerPoint7Graph::readPolygonAtom(int level, long lastPos) |
| 1661 |
{ |
| 1662 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1663 |
long pos=input->tell(); |
| 1664 |
|
| 1665 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1666 |
libmwaw::DebugStream f; |
| 1667 |
PowerPoint7Struct::Zone header; |
| 1668 |
if (!header.read(input,lastPos) || header.m_type!=3017) { |
| 1669 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPolygonAtom: can not find the zone header\n")); |
| 1670 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1671 |
return false; |
| 1672 |
} |
| 1673 |
f << "Entries(GraphPolygon)[atom," << level << "]:" << header; |
| 1674 |
if (header.m_dataSize!=0x28) { |
| 1675 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPolygonAtom: find unexpected data size\n")); |
| 1676 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1677 |
if (header.m_dataSize) |
| 1678 |
ascFile.addDelimiter(pos+16,'|'); |
| 1679 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1680 |
ascFile.addPos(pos); |
| 1681 |
ascFile.addNote(f.str().c_str()); |
| 1682 |
return true; |
| 1683 |
} |
| 1684 |
|
| 1685 |
auto frame=m_state->m_actualFrame; |
| 1686 |
int dim[4]; |
| 1687 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 1688 |
MWAWBox2i dimension(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])); |
| 1689 |
if (frame) frame->m_dimension=dimension; |
| 1690 |
f << "dim=" << dimension << ","; |
| 1691 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 1692 |
f << "dim2=" << MWAWBox2i(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])) << ","; |
| 1693 |
for (int i=0; i<4; ++i) { // f0=4,f2=dc01,f3=12 |
| 1694 |
int val=int(input->readLong(2)); |
| 1695 |
if (val) |
| 1696 |
f << "f" << i << "=" << val << ","; |
| 1697 |
} |
| 1698 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1699 |
ascFile.addPos(pos); |
| 1700 |
ascFile.addNote(f.str().c_str()); |
| 1701 |
|
| 1702 |
return true; |
| 1703 |
} |
| 1704 |
|
| 1705 |
bool PowerPoint7Graph::readArc(int level, long lastPos) |
| 1706 |
{ |
| 1707 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1708 |
long pos=input->tell(); |
| 1709 |
|
| 1710 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1711 |
libmwaw::DebugStream f; |
| 1712 |
PowerPoint7Struct::Zone header; |
| 1713 |
if (!header.read(input,lastPos) || header.m_type!=3018) { |
| 1714 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readArc: can not find the zone header\n")); |
| 1715 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1716 |
return false; |
| 1717 |
} |
| 1718 |
f << "Entries(GraphArc)[" << level << "]:" << header; |
| 1719 |
ascFile.addPos(pos); |
| 1720 |
ascFile.addNote(f.str().c_str()); |
| 1721 |
|
| 1722 |
m_state->setFrame(new PowerPoint7GraphInternal::FrameArc); |
| 1723 |
long endPos=pos+16+header.m_dataSize; |
| 1724 |
while (input->tell()<endPos) { |
| 1725 |
pos=input->tell(); |
| 1726 |
auto cType=int(input->readULong(2)); |
| 1727 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1728 |
|
| 1729 |
bool done=false; |
| 1730 |
switch (cType) { |
| 1731 |
case 3005: |
| 1732 |
done=readStyle(level+1,endPos); |
| 1733 |
break; |
| 1734 |
case 3007: |
| 1735 |
done=readLineArrows(level+1,endPos); |
| 1736 |
break; |
| 1737 |
case 3019: |
| 1738 |
done=readArcAtom(level+1,endPos); |
| 1739 |
break; |
| 1740 |
default: |
| 1741 |
done=m_mainParser->readZone(level+1,endPos); |
| 1742 |
if (done) { |
| 1743 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readArc: find unexpected zone %d\n", cType)); |
| 1744 |
} |
| 1745 |
break; |
| 1746 |
} |
| 1747 |
if (done) continue; |
| 1748 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readArc: can not read some data\n")); |
| 1749 |
ascFile.addPos(pos); |
| 1750 |
ascFile.addNote("GraphArc:###extra"); |
| 1751 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1752 |
break; |
| 1753 |
} |
| 1754 |
m_state->resetFrame(); |
| 1755 |
return true; |
| 1756 |
} |
| 1757 |
|
| 1758 |
bool PowerPoint7Graph::readArcAtom(int level, long lastPos) |
| 1759 |
{ |
| 1760 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1761 |
long pos=input->tell(); |
| 1762 |
|
| 1763 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1764 |
libmwaw::DebugStream f; |
| 1765 |
PowerPoint7Struct::Zone header; |
| 1766 |
if (!header.read(input,lastPos) || header.m_type!=3019) { |
| 1767 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readArcAtom: can not find the zone header\n")); |
| 1768 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1769 |
return false; |
| 1770 |
} |
| 1771 |
f << "Entries(GraphArc)[atom," << level << "]:" << header; |
| 1772 |
if (header.m_dataSize!=0x20) { |
| 1773 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readArcAtom: find unexpected data size\n")); |
| 1774 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1775 |
if (header.m_dataSize) |
| 1776 |
ascFile.addDelimiter(pos+16,'|'); |
| 1777 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1778 |
ascFile.addPos(pos); |
| 1779 |
ascFile.addNote(f.str().c_str()); |
| 1780 |
return true; |
| 1781 |
} |
| 1782 |
|
| 1783 |
auto frame=m_state->m_actualFrame; |
| 1784 |
PowerPoint7GraphInternal::FrameArc *arc=nullptr; |
| 1785 |
if (frame) arc=dynamic_cast<PowerPoint7GraphInternal::FrameArc *>(frame.get()); |
| 1786 |
int dim[4]; |
| 1787 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 1788 |
MWAWBox2i dimension(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])); |
| 1789 |
if (frame) frame->m_dimension=dimension; |
| 1790 |
f << "dim=" << dimension << ","; |
| 1791 |
f << "angles=["; |
| 1792 |
for (int i=0; i<2; ++i) { // find 1440,-1440 |
| 1793 |
float angle=float(input->readLong(4))/16.f; |
| 1794 |
if (arc) arc->m_angles[i]=angle; |
| 1795 |
f << angle << ","; |
| 1796 |
} |
| 1797 |
f << "],"; |
| 1798 |
auto val=int(input->readLong(2)); |
| 1799 |
if (val) { |
| 1800 |
if (frame) |
| 1801 |
frame->m_rotation=float(val)/16.0f; |
| 1802 |
f << "rot=" << float(val)/16.0f << ","; |
| 1803 |
} |
| 1804 |
for (int i=0; i<3; ++i) { // f2=74 |
| 1805 |
val=int(input->readLong(2)); |
| 1806 |
if (val) |
| 1807 |
f << "f" << i << "=" << val << ","; |
| 1808 |
} |
| 1809 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1810 |
ascFile.addPos(pos); |
| 1811 |
ascFile.addNote(f.str().c_str()); |
| 1812 |
|
| 1813 |
return true; |
| 1814 |
} |
| 1815 |
|
| 1816 |
bool PowerPoint7Graph::readPointList(int level, long lastPos, std::vector<MWAWVec2i> &points) |
| 1817 |
{ |
| 1818 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1819 |
long pos=input->tell(); |
| 1820 |
|
| 1821 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1822 |
libmwaw::DebugStream f; |
| 1823 |
PowerPoint7Struct::Zone header; |
| 1824 |
if (!header.read(input,lastPos) || header.m_type!=3035) { |
| 1825 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPointList: can not find the zone header\n")); |
| 1826 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1827 |
return false; |
| 1828 |
} |
| 1829 |
f << "Entries(GraphPointList)[" << level << "]:" << header; |
| 1830 |
int N=header.m_dataSize>=2 ? int(input->readLong(2)) : 0; |
| 1831 |
if (8*N+2!=header.m_dataSize) { |
| 1832 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPointList: find unexpected data size\n")); |
| 1833 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1834 |
if (header.m_dataSize) |
| 1835 |
ascFile.addDelimiter(pos+16,'|'); |
| 1836 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1837 |
ascFile.addPos(pos); |
| 1838 |
ascFile.addNote(f.str().c_str()); |
| 1839 |
return true; |
| 1840 |
} |
| 1841 |
f << "points=["; |
| 1842 |
points.resize(size_t(N)); |
| 1843 |
for (auto &pt : points) { |
| 1844 |
int dim[2]; |
| 1845 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 1846 |
pt=MWAWVec2i(dim[0],dim[1]); |
| 1847 |
f << pt << ","; |
| 1848 |
} |
| 1849 |
f << "],"; |
| 1850 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1851 |
ascFile.addPos(pos); |
| 1852 |
ascFile.addNote(f.str().c_str()); |
| 1853 |
|
| 1854 |
return true; |
| 1855 |
} |
| 1856 |
|
| 1857 |
bool PowerPoint7Graph::readZoneFlags(int level, long lastPos) |
| 1858 |
{ |
| 1859 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1860 |
long pos=input->tell(); |
| 1861 |
|
| 1862 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1863 |
libmwaw::DebugStream f; |
| 1864 |
PowerPoint7Struct::Zone header; |
| 1865 |
if (!header.read(input,lastPos) || header.m_type!=3036) { |
| 1866 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZoneFlags: can not find the zone header\n")); |
| 1867 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1868 |
return false; |
| 1869 |
} |
| 1870 |
f << "Entries(GraphZone)[flags" << level << "]:" << header; |
| 1871 |
if (header.m_dataSize!=0x24) { |
| 1872 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZoneFlags: find unexpected data size\n")); |
| 1873 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 1874 |
if (header.m_dataSize) |
| 1875 |
ascFile.addDelimiter(pos+16,'|'); |
| 1876 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 1877 |
ascFile.addPos(pos); |
| 1878 |
ascFile.addNote(f.str().c_str()); |
| 1879 |
return true; |
| 1880 |
} |
| 1881 |
|
| 1882 |
for (int i=0; i<18; ++i) { // f0=1,f2=2,f5=700,f6=a,f8=3,f16=f7=-1 |
| 1883 |
int val=int(input->readLong(2)); |
| 1884 |
if (val) f << "f" << i << "=" << val << ","; |
| 1885 |
} |
| 1886 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1887 |
ascFile.addPos(pos); |
| 1888 |
ascFile.addNote(f.str().c_str()); |
| 1889 |
|
| 1890 |
return true; |
| 1891 |
} |
| 1892 |
|
| 1893 |
//////////////////////////////////////////////////////////// |
| 1894 |
// Picture |
| 1895 |
//////////////////////////////////////////////////////////// |
| 1896 |
bool PowerPoint7Graph::readPictureList(int level, long lastPos) |
| 1897 |
{ |
| 1898 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1899 |
long pos=input->tell(); |
| 1900 |
|
| 1901 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1902 |
libmwaw::DebugStream f; |
| 1903 |
PowerPoint7Struct::Zone header; |
| 1904 |
if (!header.read(input,lastPos) || header.m_type!=2006) { |
| 1905 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureList: can not find the zone header\n")); |
| 1906 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1907 |
return false; |
| 1908 |
} |
| 1909 |
f << "Entries(Picture)[list," << level << "]:" << header; |
| 1910 |
ascFile.addPos(pos); |
| 1911 |
ascFile.addNote(f.str().c_str()); |
| 1912 |
|
| 1913 |
long endPos=pos+16+header.m_dataSize; |
| 1914 |
PowerPoint7GraphInternal::Picture picture; |
| 1915 |
while (input->tell()<endPos) { |
| 1916 |
pos=input->tell(); |
| 1917 |
auto cType=int(input->readULong(2)); |
| 1918 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1919 |
|
| 1920 |
bool done=false; |
| 1921 |
switch (cType) { |
| 1922 |
case 1027: |
| 1923 |
done=readBitmapContainer(level+1,endPos,picture); |
| 1924 |
break; |
| 1925 |
case 2017: { |
| 1926 |
int id; |
| 1927 |
done=m_mainParser->readIdentifier(level+1,endPos,id,"Picture"); |
| 1928 |
if (!done || picture.isEmpty()) break; |
| 1929 |
if (m_state->m_idToPictureMap.find(id)!=m_state->m_idToPictureMap.end()) { |
| 1930 |
picture=PowerPoint7GraphInternal::Picture(); |
| 1931 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureList: a picture %d is already defined\n", id)); |
| 1932 |
break; |
| 1933 |
} |
| 1934 |
m_state->m_idToPictureMap.insert(std::map<int, PowerPoint7GraphInternal::Picture>::value_type(id,picture)); |
| 1935 |
break; |
| 1936 |
} |
| 1937 |
case 2018: |
| 1938 |
done=m_mainParser->readZoneNoData(level+1,endPos,"Picture","id,end"); |
| 1939 |
break; |
| 1940 |
case 4028: |
| 1941 |
done=readPictureContainer(level+1,endPos,picture); |
| 1942 |
break; |
| 1943 |
case 4043: // check me |
| 1944 |
done=m_mainParser->readZoneNoData(level+1,endPos,"Picture","flags"); |
| 1945 |
break; |
| 1946 |
default: |
| 1947 |
done=m_mainParser->readZone(level+1,endPos); |
| 1948 |
if (done) { |
| 1949 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureList: find unexpected zone %d\n", cType)); |
| 1950 |
} |
| 1951 |
break; |
| 1952 |
} |
| 1953 |
if (done) continue; |
| 1954 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureList: can not read some data\n")); |
| 1955 |
ascFile.addPos(pos); |
| 1956 |
ascFile.addNote("Picture:###extra"); |
| 1957 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1958 |
break; |
| 1959 |
} |
| 1960 |
return true; |
| 1961 |
} |
| 1962 |
|
| 1963 |
bool PowerPoint7Graph::readBitmapContainer(int level, long lastPos, PowerPoint7GraphInternal::Picture &picture) |
| 1964 |
{ |
| 1965 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 1966 |
long pos=input->tell(); |
| 1967 |
|
| 1968 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1969 |
libmwaw::DebugStream f; |
| 1970 |
PowerPoint7Struct::Zone header; |
| 1971 |
if (!header.read(input,lastPos) || header.m_type!=1027) { |
| 1972 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmapContainer: can not find the zone header\n")); |
| 1973 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1974 |
return false; |
| 1975 |
} |
| 1976 |
f << "Entries(Bitmap)[container," << level << "]:" << header; |
| 1977 |
ascFile.addPos(pos); |
| 1978 |
ascFile.addNote(f.str().c_str()); |
| 1979 |
|
| 1980 |
long endPos=pos+16+header.m_dataSize; |
| 1981 |
while (input->tell()<endPos) { |
| 1982 |
pos=input->tell(); |
| 1983 |
auto cType=int(input->readULong(2)); |
| 1984 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1985 |
|
| 1986 |
bool done=false; |
| 1987 |
switch (cType) { |
| 1988 |
case 2012: |
| 1989 |
done=readBitmap(level+1, endPos, picture.m_object, picture.m_box); |
| 1990 |
break; |
| 1991 |
case 3038: |
| 1992 |
done=readBitmapFlag(level+1, endPos); |
| 1993 |
break; |
| 1994 |
case 4026: { |
| 1995 |
int zId; // 130: picture name |
| 1996 |
done=m_mainParser->readString(level+1, endPos, picture.m_name, zId, "Bitmap"); |
| 1997 |
break; |
| 1998 |
} |
| 1999 |
default: |
| 2000 |
done=m_mainParser->readZone(level+1,endPos); |
| 2001 |
if (done) { |
| 2002 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmapContainer: find unexpected zone %d\n", cType)); |
| 2003 |
} |
| 2004 |
break; |
| 2005 |
} |
| 2006 |
if (done) continue; |
| 2007 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmapContainer: can not read some data\n")); |
| 2008 |
ascFile.addPos(pos); |
| 2009 |
ascFile.addNote("Bitmap:###extra"); |
| 2010 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2011 |
break; |
| 2012 |
} |
| 2013 |
return true; |
| 2014 |
} |
| 2015 |
|
| 2016 |
bool PowerPoint7Graph::readBitmap(int level, long lastPos, MWAWEmbeddedObject &object, MWAWBox2i &box) |
| 2017 |
{ |
| 2018 |
object=MWAWEmbeddedObject(); |
| 2019 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2020 |
long pos=input->tell(); |
| 2021 |
|
| 2022 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2023 |
libmwaw::DebugStream f; |
| 2024 |
PowerPoint7Struct::Zone header; |
| 2025 |
if (!header.read(input,lastPos) || header.m_type!=2012) { |
| 2026 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmap: can not find the zone header\n")); |
| 2027 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2028 |
return false; |
| 2029 |
} |
| 2030 |
f << "Entries(Bitmap)[" << level << "]:" << header; |
| 2031 |
if (header.m_dataSize<40) { |
| 2032 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmap: find unexpected data size\n")); |
| 2033 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2034 |
if (header.m_dataSize) |
| 2035 |
ascFile.addDelimiter(pos+16,'|'); |
| 2036 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 2037 |
ascFile.addPos(pos); |
| 2038 |
ascFile.addNote(f.str().c_str()); |
| 2039 |
return true; |
| 2040 |
} |
| 2041 |
// BITMAPINFOHEADER: normally with size 40, but can probably be longer |
| 2042 |
auto headerSz=int(input->readLong(4)); |
| 2043 |
if (headerSz<40 || headerSz>=header.m_dataSize-16) { |
| 2044 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmap: find unexpected header size\n")); |
| 2045 |
f << "###headerSz=" << headerSz << ","; |
| 2046 |
if (header.m_dataSize) |
| 2047 |
ascFile.addDelimiter(input->tell(),'|'); |
| 2048 |
if (16+headerSz<header.m_dataSize) |
| 2049 |
ascFile.skipZone(pos+16+headerSz, pos+16+header.m_dataSize-1); |
| 2050 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 2051 |
ascFile.addPos(pos); |
| 2052 |
ascFile.addNote(f.str().c_str()); |
| 2053 |
return true; |
| 2054 |
} |
| 2055 |
int dim[2]; |
| 2056 |
for (auto &d : dim) d=int(input->readULong(4)); |
| 2057 |
f << "dim=" << MWAWVec2i(dim[0],dim[1]) << ","; |
| 2058 |
auto val=int(input->readULong(2)); |
| 2059 |
if (val!=1) f << "num[planes]=" << val << ","; |
| 2060 |
auto nbBytes=int(input->readULong(2)); |
| 2061 |
f << "nunBytes=" << nbBytes << ","; |
| 2062 |
ascFile.addDelimiter(input->tell(),'|'); |
| 2063 |
input->seek(pos+16+32, librevenge::RVNG_SEEK_SET); |
| 2064 |
auto nColors=int(input->readULong(4)); |
| 2065 |
if (nColors) |
| 2066 |
f << "numColors=" << nColors << ","; |
| 2067 |
else if (nbBytes<=8) { |
| 2068 |
nColors=1; |
| 2069 |
for (int b=0; b<=nbBytes; ++b) |
| 2070 |
nColors<<=1; |
| 2071 |
} |
| 2072 |
if ((header.m_dataSize-16-headerSz)/4<=nColors) { |
| 2073 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmap: can not find the pixel data zone\n")); |
| 2074 |
f << "###nColors,"; |
| 2075 |
ascFile.skipZone(pos+16+headerSz, pos+16+header.m_dataSize-1); |
| 2076 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 2077 |
ascFile.addPos(pos); |
| 2078 |
ascFile.addNote(f.str().c_str()); |
| 2079 |
return true; |
| 2080 |
} |
| 2081 |
|
| 2082 |
// ok, let create a bmp file |
| 2083 |
box=MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(dim[0],dim[1])); |
| 2084 |
unsigned char bmHeader[14]; |
| 2085 |
bmHeader[0]='B'; |
| 2086 |
bmHeader[1]='M'; |
| 2087 |
auto fileSize=uint32_t(14+header.m_dataSize); |
| 2088 |
for (int i=0; i<4; ++i, fileSize>>=8) |
| 2089 |
bmHeader[i+2]=static_cast<unsigned char>(fileSize&0xFF); |
| 2090 |
for (int i=0; i<4; ++i) |
| 2091 |
bmHeader[i+6]=0; |
| 2092 |
auto dataOffs=uint32_t(14+headerSz+4*nColors); |
| 2093 |
for (int i=0; i<4; ++i, dataOffs>>=8) |
| 2094 |
bmHeader[i+10]=static_cast<unsigned char>(dataOffs&0xFF); |
| 2095 |
librevenge::RVNGBinaryData file(bmHeader,14); |
| 2096 |
input->seek(pos+16, librevenge::RVNG_SEEK_SET); |
| 2097 |
|
| 2098 |
const unsigned char *readData; |
| 2099 |
unsigned long sizeRead; |
| 2100 |
if ((readData=input->read(static_cast<unsigned long>(header.m_dataSize), sizeRead)) != nullptr || long(sizeRead)==header.m_dataSize) { |
| 2101 |
file.append(readData, sizeRead); |
| 2102 |
object.add(file, "image/bmp"); |
| 2103 |
#ifdef DEBUG_WITH_FILES |
| 2104 |
static int volatile pictName = 0; |
| 2105 |
libmwaw::DebugStream f2; |
| 2106 |
f2 << "PICT-" << ++pictName << ".bmp"; |
| 2107 |
libmwaw::Debug::dumpFile(file, f2.str().c_str()); |
| 2108 |
#endif |
| 2109 |
} |
| 2110 |
else { |
| 2111 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmap: can not reconstruct the final bmp file\n")); |
| 2112 |
f << "###"; |
| 2113 |
} |
| 2114 |
ascFile.skipZone(pos+16+headerSz, pos+16+header.m_dataSize-1); |
| 2115 |
ascFile.addPos(pos); |
| 2116 |
ascFile.addNote(f.str().c_str()); |
| 2117 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 2118 |
return true; |
| 2119 |
} |
| 2120 |
|
| 2121 |
bool PowerPoint7Graph::readBitmapFlag(int level, long lastPos) |
| 2122 |
{ |
| 2123 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2124 |
long pos=input->tell(); |
| 2125 |
|
| 2126 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2127 |
libmwaw::DebugStream f; |
| 2128 |
PowerPoint7Struct::Zone header; |
| 2129 |
if (!header.read(input,lastPos) || header.m_type!=3038) { |
| 2130 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmapFlag: can not find the zone header\n")); |
| 2131 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2132 |
return false; |
| 2133 |
} |
| 2134 |
f << "Entries(Bitmap)[flag," << level << "]:" << header; |
| 2135 |
if (header.m_dataSize!=1) { |
| 2136 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readBitmapFlag: find unexpected data size\n")); |
| 2137 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2138 |
if (header.m_dataSize) |
| 2139 |
ascFile.addDelimiter(pos+16,'|'); |
| 2140 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2141 |
} |
| 2142 |
else { |
| 2143 |
auto val=int(input->readULong(1)); |
| 2144 |
if (val==1) |
| 2145 |
f << "on[disk],"; |
| 2146 |
else if (val) |
| 2147 |
f << "bitmap[type]=" << val << ","; |
| 2148 |
} |
| 2149 |
ascFile.addPos(pos); |
| 2150 |
ascFile.addNote(f.str().c_str()); |
| 2151 |
return true; |
| 2152 |
} |
| 2153 |
|
| 2154 |
bool PowerPoint7Graph::readMetaFileContainer(int level, long lastPos, PowerPoint7GraphInternal::Picture &picture) |
| 2155 |
{ |
| 2156 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2157 |
long pos=input->tell(); |
| 2158 |
|
| 2159 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2160 |
libmwaw::DebugStream f; |
| 2161 |
PowerPoint7Struct::Zone header; |
| 2162 |
if (!header.read(input,lastPos) || header.m_type!=4037) { |
| 2163 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFileContainer: can not find the zone header\n")); |
| 2164 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2165 |
return false; |
| 2166 |
} |
| 2167 |
f << "Entries(MetaFile)[container," << level << "]:" << header; |
| 2168 |
ascFile.addPos(pos); |
| 2169 |
ascFile.addNote(f.str().c_str()); |
| 2170 |
|
| 2171 |
long endPos=pos+16+header.m_dataSize; |
| 2172 |
while (input->tell()<endPos) { |
| 2173 |
pos=input->tell(); |
| 2174 |
auto cType=int(input->readULong(2)); |
| 2175 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2176 |
|
| 2177 |
bool done=false; |
| 2178 |
switch (cType) { |
| 2179 |
case 4033: |
| 2180 |
done=readMetaFile(level+1,endPos,picture.m_object); |
| 2181 |
break; |
| 2182 |
case 4038: |
| 2183 |
done=readMetaFileBox(level+1,endPos,picture.m_box); |
| 2184 |
break; |
| 2185 |
default: |
| 2186 |
done=m_mainParser->readZone(level+1,endPos); |
| 2187 |
if (done) { |
| 2188 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFileContainer: find unexpected zone %d\n", cType)); |
| 2189 |
} |
| 2190 |
break; |
| 2191 |
} |
| 2192 |
if (done) continue; |
| 2193 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFileContainer: can not read some data\n")); |
| 2194 |
ascFile.addPos(pos); |
| 2195 |
ascFile.addNote("MetaFile:###extra"); |
| 2196 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2197 |
break; |
| 2198 |
} |
| 2199 |
return true; |
| 2200 |
} |
| 2201 |
|
| 2202 |
bool PowerPoint7Graph::readMetaFile(int level, long lastPos, MWAWEmbeddedObject &object) |
| 2203 |
{ |
| 2204 |
object=MWAWEmbeddedObject(); |
| 2205 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2206 |
long pos=input->tell(); |
| 2207 |
|
| 2208 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2209 |
libmwaw::DebugStream f; |
| 2210 |
PowerPoint7Struct::Zone header; |
| 2211 |
if (!header.read(input,lastPos) || header.m_type!=4033) { |
| 2212 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFile: can not find the zone header\n")); |
| 2213 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2214 |
return false; |
| 2215 |
} |
| 2216 |
f << "Entries(MetaFile)[" << level << "]:" << header; |
| 2217 |
if (header.m_dataSize<10) { |
| 2218 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFile: find unexpected data size\n")); |
| 2219 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2220 |
if (header.m_dataSize) |
| 2221 |
ascFile.addDelimiter(pos+16,'|'); |
| 2222 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2223 |
ascFile.addPos(pos); |
| 2224 |
ascFile.addNote(f.str().c_str()); |
| 2225 |
return true; |
| 2226 |
} |
| 2227 |
ascFile.skipZone(input->tell(), pos+16+header.m_dataSize-1); |
| 2228 |
ascFile.addPos(pos); |
| 2229 |
ascFile.addNote(f.str().c_str()); |
| 2230 |
librevenge::RVNGBinaryData file; |
| 2231 |
input->readDataBlock(header.m_dataSize, file); |
| 2232 |
object.add(file, "image/wmf"); |
| 2233 |
#ifdef DEBUG_WITH_FILES |
| 2234 |
static int volatile pictName = 0; |
| 2235 |
f.str(""); |
| 2236 |
f << "PICT-" << ++pictName << ".wmf"; |
| 2237 |
libmwaw::Debug::dumpFile(file, f.str().c_str()); |
| 2238 |
#endif |
| 2239 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 2240 |
return true; |
| 2241 |
} |
| 2242 |
|
| 2243 |
bool PowerPoint7Graph::readMetaFileBox(int level, long lastPos, MWAWBox2i &box) |
| 2244 |
{ |
| 2245 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2246 |
long pos=input->tell(); |
| 2247 |
|
| 2248 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2249 |
libmwaw::DebugStream f; |
| 2250 |
PowerPoint7Struct::Zone header; |
| 2251 |
if (!header.read(input,lastPos) || header.m_type!=4038) { |
| 2252 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFileBox: can not find the zone header\n")); |
| 2253 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2254 |
return false; |
| 2255 |
} |
| 2256 |
f << "Entries(MetaFile)[box," << level << "]:" << header; |
| 2257 |
if (header.m_dataSize!=0x14) { |
| 2258 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readMetaFileBox: find unexpected data size\n")); |
| 2259 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2260 |
if (header.m_dataSize) |
| 2261 |
ascFile.addDelimiter(pos+16,'|'); |
| 2262 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2263 |
ascFile.addPos(pos); |
| 2264 |
ascFile.addNote(f.str().c_str()); |
| 2265 |
return true; |
| 2266 |
} |
| 2267 |
|
| 2268 |
for (int i=0; i<2; ++i) { // f0=f00 |
| 2269 |
int val=int(input->readLong(2)); |
| 2270 |
if (val) f << "f" << i << "=" << val << ","; |
| 2271 |
} |
| 2272 |
int dim[4]; |
| 2273 |
for (auto &d : dim) d=int(input->readLong(4)); |
| 2274 |
box=MWAWBox2i(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])); |
| 2275 |
f << "box=" << box << ","; |
| 2276 |
input->seek(pos+16+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 2277 |
ascFile.addPos(pos); |
| 2278 |
ascFile.addNote(f.str().c_str()); |
| 2279 |
|
| 2280 |
return true; |
| 2281 |
} |
| 2282 |
|
| 2283 |
bool PowerPoint7Graph::readExternalOleObjectAtom(int level, long lastPos) |
| 2284 |
{ |
| 2285 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2286 |
long pos=input->tell(); |
| 2287 |
|
| 2288 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2289 |
libmwaw::DebugStream f; |
| 2290 |
PowerPoint7Struct::Zone header; |
| 2291 |
if (!header.read(input,lastPos) || header.m_type!=4035) { |
| 2292 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleObjectAtom: can not find the zone header\n")); |
| 2293 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2294 |
return false; |
| 2295 |
} |
| 2296 |
f << "Entries(ExternalOleEmbed)[object," << level << "]:" << header; |
| 2297 |
if (header.m_dataSize!=0x14) { |
| 2298 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleObjectAtom: find unexpected data size\n")); |
| 2299 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2300 |
if (header.m_dataSize) |
| 2301 |
ascFile.addDelimiter(pos+16,'|'); |
| 2302 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2303 |
} |
| 2304 |
else { |
| 2305 |
for (int i=0; i<10; ++i) { // f0=1, f6=0|1, f8=1|5 |
| 2306 |
auto val=int(input->readLong(2)); |
| 2307 |
if (!val) continue; |
| 2308 |
f << "f"<< i << "=" << val << ","; |
| 2309 |
} |
| 2310 |
} |
| 2311 |
ascFile.addPos(pos); |
| 2312 |
ascFile.addNote(f.str().c_str()); |
| 2313 |
return true; |
| 2314 |
} |
| 2315 |
|
| 2316 |
bool PowerPoint7Graph::readExternalOleEmbed(int level, long lastPos, int &id) |
| 2317 |
{ |
| 2318 |
id=-1; |
| 2319 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2320 |
long pos=input->tell(); |
| 2321 |
|
| 2322 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2323 |
libmwaw::DebugStream f; |
| 2324 |
PowerPoint7Struct::Zone header; |
| 2325 |
if (!header.read(input,lastPos) || header.m_type!=4044) { |
| 2326 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleEmbed: can not find the zone header\n")); |
| 2327 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2328 |
return false; |
| 2329 |
} |
| 2330 |
f << "Entries(ExternalOleEmbed)[list," << level << "]:" << header; |
| 2331 |
ascFile.addPos(pos); |
| 2332 |
ascFile.addNote(f.str().c_str()); |
| 2333 |
|
| 2334 |
long endPos=pos+16+header.m_dataSize; |
| 2335 |
while (input->tell()<endPos) { |
| 2336 |
pos=input->tell(); |
| 2337 |
auto cType=int(input->readULong(2)); |
| 2338 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2339 |
|
| 2340 |
bool done=false; |
| 2341 |
switch (cType) { |
| 2342 |
case 4026: { |
| 2343 |
std::string string; |
| 2344 |
int zId; // 0: Ole name, 2:prog, 3:type, 45: program |
| 2345 |
done=m_mainParser->readString(level+1,endPos,string,zId,"ExternalOleEmbed"); |
| 2346 |
break; |
| 2347 |
} |
| 2348 |
case 4035: |
| 2349 |
done=readExternalOleObjectAtom(level+1,endPos); |
| 2350 |
break; |
| 2351 |
case 4036: |
| 2352 |
done=readPictureId(level+1,endPos,id); |
| 2353 |
break; |
| 2354 |
case 4045: |
| 2355 |
done=readExternalOleEmbedAtom(level+1,endPos); |
| 2356 |
break; |
| 2357 |
default: |
| 2358 |
done=m_mainParser->readZone(level+1,endPos); |
| 2359 |
if (done) { |
| 2360 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleEmbed: find unexpected zone %d\n", cType)); |
| 2361 |
} |
| 2362 |
break; |
| 2363 |
} |
| 2364 |
if (done) continue; |
| 2365 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleEmbed: can not read some data\n")); |
| 2366 |
ascFile.addPos(pos); |
| 2367 |
ascFile.addNote("ExternalOleEmbed:###extra"); |
| 2368 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2369 |
break; |
| 2370 |
} |
| 2371 |
return true; |
| 2372 |
} |
| 2373 |
|
| 2374 |
bool PowerPoint7Graph::readExternalOleEmbedAtom(int level, long lastPos) |
| 2375 |
{ |
| 2376 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2377 |
long pos=input->tell(); |
| 2378 |
|
| 2379 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2380 |
libmwaw::DebugStream f; |
| 2381 |
PowerPoint7Struct::Zone header; |
| 2382 |
if (!header.read(input,lastPos) || header.m_type!=4045) { |
| 2383 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleEmbedAtom: can not find the zone header\n")); |
| 2384 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2385 |
return false; |
| 2386 |
} |
| 2387 |
f << "Entries(ExternalOleEmbed)[atom," << level << "]:" << header; |
| 2388 |
if (header.m_dataSize!=0x8) { |
| 2389 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readExternalOleEmbedAtom: find unexpected data size\n")); |
| 2390 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2391 |
if (header.m_dataSize) |
| 2392 |
ascFile.addDelimiter(pos+16,'|'); |
| 2393 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2394 |
} |
| 2395 |
else { |
| 2396 |
for (int i=0; i<4; ++i) { // f0=0|1, f2=1 |
| 2397 |
auto val=int(input->readLong(2)); |
| 2398 |
if (!val) continue; |
| 2399 |
f << "f"<< i << "=" << val << ","; |
| 2400 |
} |
| 2401 |
} |
| 2402 |
ascFile.addPos(pos); |
| 2403 |
ascFile.addNote(f.str().c_str()); |
| 2404 |
return true; |
| 2405 |
} |
| 2406 |
|
| 2407 |
bool PowerPoint7Graph::readPictureContainer(int level, long lastPos, PowerPoint7GraphInternal::Picture &picture) |
| 2408 |
{ |
| 2409 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2410 |
long pos=input->tell(); |
| 2411 |
|
| 2412 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2413 |
libmwaw::DebugStream f; |
| 2414 |
PowerPoint7Struct::Zone header; |
| 2415 |
if (!header.read(input,lastPos) || header.m_type!=4028) { |
| 2416 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureContainer: can not find the zone header\n")); |
| 2417 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2418 |
return false; |
| 2419 |
} |
| 2420 |
f << "Entries(Picture)[container," << level << "]:" << header; |
| 2421 |
ascFile.addPos(pos); |
| 2422 |
ascFile.addNote(f.str().c_str()); |
| 2423 |
|
| 2424 |
long endPos=pos+16+header.m_dataSize; |
| 2425 |
while (input->tell()<endPos) { |
| 2426 |
pos=input->tell(); |
| 2427 |
auto cType=int(input->readULong(2)); |
| 2428 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2429 |
|
| 2430 |
bool done=false; |
| 2431 |
switch (cType) { |
| 2432 |
case 4037: |
| 2433 |
done=readMetaFileContainer(level+1,endPos, picture); |
| 2434 |
break; |
| 2435 |
default: |
| 2436 |
done=m_mainParser->readZone(level+1,endPos); |
| 2437 |
if (done) { |
| 2438 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureContainer: find unexpected zone %d\n", cType)); |
| 2439 |
} |
| 2440 |
break; |
| 2441 |
} |
| 2442 |
if (done) continue; |
| 2443 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureContainer: can not read some data\n")); |
| 2444 |
ascFile.addPos(pos); |
| 2445 |
ascFile.addNote("Picture:###extra"); |
| 2446 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2447 |
break; |
| 2448 |
} |
| 2449 |
return true; |
| 2450 |
} |
| 2451 |
|
| 2452 |
bool PowerPoint7Graph::readPictureId(int level, long lastPos, int &id) |
| 2453 |
{ |
| 2454 |
id=-1; |
| 2455 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2456 |
long pos=input->tell(); |
| 2457 |
|
| 2458 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2459 |
libmwaw::DebugStream f; |
| 2460 |
PowerPoint7Struct::Zone header; |
| 2461 |
if (!header.read(input,lastPos) || header.m_type!=4036) { |
| 2462 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureId: can not find the zone header\n")); |
| 2463 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2464 |
return false; |
| 2465 |
} |
| 2466 |
f << "Entries(Picture)[id," << level << "]:" << header; |
| 2467 |
if (header.m_dataSize!=4) { |
| 2468 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureId: find unexpected data size\n")); |
| 2469 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2470 |
if (header.m_dataSize) |
| 2471 |
ascFile.addDelimiter(pos+16,'|'); |
| 2472 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2473 |
ascFile.addPos(pos); |
| 2474 |
ascFile.addNote(f.str().c_str()); |
| 2475 |
return true; |
| 2476 |
} |
| 2477 |
id=int(input->readLong(4)); |
| 2478 |
if (id) f << "id=" << id << ","; |
| 2479 |
ascFile.addPos(pos); |
| 2480 |
ascFile.addNote(f.str().c_str()); |
| 2481 |
|
| 2482 |
return true; |
| 2483 |
} |
| 2484 |
|
| 2485 |
bool PowerPoint7Graph::readPictureIdContainer(int level, long lastPos, int &id) |
| 2486 |
{ |
| 2487 |
id=-1; |
| 2488 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2489 |
long pos=input->tell(); |
| 2490 |
|
| 2491 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2492 |
libmwaw::DebugStream f; |
| 2493 |
PowerPoint7Struct::Zone header; |
| 2494 |
if (!header.read(input,lastPos) || header.m_type!=4053) { |
| 2495 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureIdContainer: can not find the zone header\n")); |
| 2496 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2497 |
return false; |
| 2498 |
} |
| 2499 |
f << "Entries(Picture)[id,container," << level << "]:" << header; |
| 2500 |
ascFile.addPos(pos); |
| 2501 |
ascFile.addNote(f.str().c_str()); |
| 2502 |
|
| 2503 |
long endPos=pos+16+header.m_dataSize; |
| 2504 |
while (input->tell()<endPos) { |
| 2505 |
pos=input->tell(); |
| 2506 |
auto cType=int(input->readULong(2)); |
| 2507 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2508 |
|
| 2509 |
bool done=false; |
| 2510 |
switch (cType) { |
| 2511 |
case 4036: |
| 2512 |
done=readPictureId(level+1,endPos,id); |
| 2513 |
break; |
| 2514 |
default: |
| 2515 |
done=m_mainParser->readZone(level+1,endPos); |
| 2516 |
if (done) { |
| 2517 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureIdContainer: find unexpected zone %d\n", cType)); |
| 2518 |
} |
| 2519 |
break; |
| 2520 |
} |
| 2521 |
if (done) continue; |
| 2522 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readPictureIdContainer: can not read some data\n")); |
| 2523 |
ascFile.addPos(pos); |
| 2524 |
ascFile.addNote("Picture:###extra"); |
| 2525 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2526 |
break; |
| 2527 |
} |
| 2528 |
return true; |
| 2529 |
} |
| 2530 |
|
| 2531 |
bool PowerPoint7Graph::readZone5000(int level, long lastPos) |
| 2532 |
{ |
| 2533 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2534 |
long pos=input->tell(); |
| 2535 |
|
| 2536 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2537 |
libmwaw::DebugStream f; |
| 2538 |
PowerPoint7Struct::Zone header; |
| 2539 |
if (!header.read(input,lastPos) || header.m_type!=5000) { |
| 2540 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000: can not find the zone header\n")); |
| 2541 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2542 |
return false; |
| 2543 |
} |
| 2544 |
f << "Entries(Zone5000B)[" << level << "]:" << header; |
| 2545 |
ascFile.addPos(pos); |
| 2546 |
ascFile.addNote(f.str().c_str()); |
| 2547 |
|
| 2548 |
long endPos=pos+16+header.m_dataSize; |
| 2549 |
while (input->tell()<endPos) { |
| 2550 |
pos=input->tell(); |
| 2551 |
auto cType=int(input->readULong(2)); |
| 2552 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2553 |
|
| 2554 |
bool done=false; |
| 2555 |
switch (cType) { |
| 2556 |
case 5001: |
| 2557 |
done=readZone5000Header(level+1,endPos); |
| 2558 |
break; |
| 2559 |
case 5002: |
| 2560 |
done=readZone5000Data(level+1,endPos); |
| 2561 |
break; |
| 2562 |
default: |
| 2563 |
done=m_mainParser->readZone(level+1,endPos); |
| 2564 |
if (done) { |
| 2565 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000: find unexpected zone %d\n", cType)); |
| 2566 |
} |
| 2567 |
break; |
| 2568 |
} |
| 2569 |
if (done) continue; |
| 2570 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000: can not read some data\n")); |
| 2571 |
ascFile.addPos(pos); |
| 2572 |
ascFile.addNote("Zone5000B:###extra"); |
| 2573 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2574 |
break; |
| 2575 |
} |
| 2576 |
return true; |
| 2577 |
} |
| 2578 |
|
| 2579 |
bool PowerPoint7Graph::readZone5000Header(int level, long lastPos) |
| 2580 |
{ |
| 2581 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2582 |
long pos=input->tell(); |
| 2583 |
|
| 2584 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2585 |
libmwaw::DebugStream f; |
| 2586 |
PowerPoint7Struct::Zone header; |
| 2587 |
if (!header.read(input,lastPos) || header.m_type!=5001) { |
| 2588 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000Header: can not find the zone header\n")); |
| 2589 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2590 |
return false; |
| 2591 |
} |
| 2592 |
f << "Entries(Zone5000B)[header," << level << "]:" << header; |
| 2593 |
if (header.m_dataSize!=4) { |
| 2594 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000Header: find unexpected data size\n")); |
| 2595 |
f << "###dataSz=" << header.m_dataSize << ","; |
| 2596 |
if (header.m_dataSize) |
| 2597 |
ascFile.addDelimiter(pos+16,'|'); |
| 2598 |
input->seek(header.m_dataSize, librevenge::RVNG_SEEK_CUR); |
| 2599 |
ascFile.addPos(pos); |
| 2600 |
ascFile.addNote(f.str().c_str()); |
| 2601 |
return true; |
| 2602 |
} |
| 2603 |
auto val=int(input->readLong(4)); |
| 2604 |
if (val!=4) f << "num[data]=" << val << ","; |
| 2605 |
ascFile.addPos(pos); |
| 2606 |
ascFile.addNote(f.str().c_str()); |
| 2607 |
|
| 2608 |
return true; |
| 2609 |
} |
| 2610 |
|
| 2611 |
bool PowerPoint7Graph::readZone5000Data(int level, long lastPos) |
| 2612 |
{ |
| 2613 |
MWAWInputStreamPtr input=m_parserState->m_input; |
| 2614 |
long pos=input->tell(); |
| 2615 |
|
| 2616 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 2617 |
libmwaw::DebugStream f; |
| 2618 |
PowerPoint7Struct::Zone header; |
| 2619 |
if (!header.read(input,lastPos) || header.m_type!=5002) { |
| 2620 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000Data: can not find the zone header\n")); |
| 2621 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2622 |
return false; |
| 2623 |
} |
| 2624 |
f << "Entries(Zone5000B)[data," << level << "]:" << header; |
| 2625 |
ascFile.addPos(pos); |
| 2626 |
ascFile.addNote(f.str().c_str()); |
| 2627 |
|
| 2628 |
long endPos=pos+16+header.m_dataSize; |
| 2629 |
while (input->tell()<endPos) { |
| 2630 |
pos=input->tell(); |
| 2631 |
auto cType=int(input->readULong(2)); |
| 2632 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 2633 |
|
| 2634 |
bool done=false; |
| 2635 |
switch (cType) { |
| 2636 |
case 4026: { |
| 2637 |
std::string string; |
| 2638 |
int zId; |
| 2639 |
done=m_mainParser->readString(level+1,endPos,string,zId,"Zone5000B"); |
| 2640 |
break; |
| 2641 |
} |
| 2642 |
default: |
| 2643 |
done=m_mainParser->readZone(level+1,endPos); |
| 2644 |
if (done) { |
| 2645 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000: find unexpected zone %d\n", cType)); |
| 2646 |
} |
| 2647 |
break; |
| 2648 |
} |
| 2649 |
if (done) continue; |
| 2650 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::readZone5000: can not read some data\n")); |
| 2651 |
ascFile.addPos(pos); |
| 2652 |
ascFile.addNote("Zone5000B:###extra"); |
| 2653 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 2654 |
break; |
| 2655 |
} |
| 2656 |
return true; |
| 2657 |
} |
| 2658 |
|
| 2659 |
//////////////////////////////////////////////////////////// |
| 2660 |
// send data |
| 2661 |
//////////////////////////////////////////////////////////// |
| 2662 |
|
| 2663 |
bool PowerPoint7Graph::sendSlide(PowerPoint7Struct::SlideId const &id, bool sendBackground) |
| 2664 |
{ |
| 2665 |
MWAWPresentationListenerPtr listener=m_parserState->m_presentationListener; |
| 2666 |
if (!listener) { |
| 2667 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::sendSlide: can not find the listener\n")); |
| 2668 |
return false; |
| 2669 |
} |
| 2670 |
std::vector<int> textIdList; |
| 2671 |
if (m_state->m_idToFrameMap.find(id)!=m_state->m_idToFrameMap.end()) { |
| 2672 |
std::vector<std::shared_ptr<PowerPoint7GraphInternal::Frame> > const &frames=m_state->m_idToFrameMap.find(id)->second; |
| 2673 |
for (auto const &fram : frames) { |
| 2674 |
if (!fram) continue; |
| 2675 |
if (!sendBackground && fram->m_isBackground) continue; |
| 2676 |
sendFrame(*fram, id.m_isMaster); |
| 2677 |
} |
| 2678 |
} |
| 2679 |
// check if the slide has some note |
| 2680 |
if (id.m_isMaster) return true; |
| 2681 |
PowerPoint7Struct::SlideId noteId=id; |
| 2682 |
noteId.m_inNotes=true; |
| 2683 |
if (m_state->m_idToFrameMap.find(noteId)==m_state->m_idToFrameMap.end()) |
| 2684 |
return true; |
| 2685 |
auto const &frames=m_state->m_idToFrameMap.find(noteId)->second; |
| 2686 |
for (auto fram : frames) { |
| 2687 |
if (!fram) continue; |
| 2688 |
if (!sendBackground && fram->m_isBackground) continue; |
| 2689 |
fram->getTextZoneList(textIdList); |
| 2690 |
} |
| 2691 |
if (textIdList.empty()) |
| 2692 |
return true; |
| 2693 |
|
| 2694 |
MWAWPosition pos(MWAWVec2f(0,0), MWAWVec2f(200,200), librevenge::RVNG_POINT); |
| 2695 |
pos.m_anchorTo = MWAWPosition::Page; |
| 2696 |
MWAWSubDocumentPtr subdoc(new PowerPoint7GraphInternal::SubDocument(*this, m_parserState->m_input,textIdList)); |
| 2697 |
listener->insertSlideNote(pos, subdoc); |
| 2698 |
return true; |
| 2699 |
} |
| 2700 |
|
| 2701 |
bool PowerPoint7Graph::sendFrame(PowerPoint7GraphInternal::Frame const &frame, bool master) |
| 2702 |
{ |
| 2703 |
frame.m_isSent=true; |
| 2704 |
if (master && frame.m_type==PowerPoint7GraphInternal::Frame::Placeholder) |
| 2705 |
return true; |
| 2706 |
MWAWListenerPtr listener=m_parserState->m_presentationListener; |
| 2707 |
if (!listener) { |
| 2708 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::sendFrame: can not find the listener\n")); |
| 2709 |
return false; |
| 2710 |
} |
| 2711 |
MWAWBox2f fBox(1.f/8.f*MWAWVec2f(frame.m_dimension[0]+m_state->m_decal), |
| 2712 |
1.f/8.f*MWAWVec2f(frame.m_dimension[1]+m_state->m_decal)); |
| 2713 |
if (frame.m_textId>=0) { |
| 2714 |
MWAWPosition pos(fBox[0], fBox.size(), librevenge::RVNG_POINT); |
| 2715 |
pos.m_anchorTo = MWAWPosition::Page; |
| 2716 |
MWAWSubDocumentPtr subdoc(new PowerPoint7GraphInternal::SubDocument(*this, m_parserState->m_input, frame.m_textId)); |
| 2717 |
listener->insertTextBox(pos, subdoc, frame.m_style); |
| 2718 |
return true; |
| 2719 |
} |
| 2720 |
if (frame.m_pictureId>=0) { |
| 2721 |
if (m_state->m_idToPictureMap.find(frame.m_pictureId)==m_state->m_idToPictureMap.end()) { |
| 2722 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::sendFrame: can not find the picture %d\n", frame.m_pictureId)); |
| 2723 |
return false; |
| 2724 |
} |
| 2725 |
MWAWPosition pos(fBox[0], fBox.size(), librevenge::RVNG_POINT); |
| 2726 |
pos.m_anchorTo = MWAWPosition::Page; |
| 2727 |
if (frame.m_isBackground) pos.m_wrapping = MWAWPosition::WBackground; |
| 2728 |
listener->insertPicture(pos, m_state->m_idToPictureMap.find(frame.m_pictureId)->second.m_object); |
| 2729 |
return true; |
| 2730 |
} |
| 2731 |
MWAWGraphicShape shape; |
| 2732 |
switch (frame.m_type) { |
| 2733 |
case PowerPoint7GraphInternal::Frame::Arc: { |
| 2734 |
auto const *arc= dynamic_cast<PowerPoint7GraphInternal::FrameArc const *>(&frame); |
| 2735 |
if (!arc) { |
| 2736 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::sendFrame: can not find the arc\n")); |
| 2737 |
return false; |
| 2738 |
} |
| 2739 |
if (!arc->updateShape(fBox, shape)) return false; |
| 2740 |
if (frame.m_rotation<0||frame.m_rotation>0) |
| 2741 |
shape=shape.rotate(-frame.m_rotation, fBox.center()); |
| 2742 |
break; |
| 2743 |
} |
| 2744 |
case PowerPoint7GraphInternal::Frame::Line: |
| 2745 |
shape=MWAWGraphicShape::line(fBox[0], fBox[1]); |
| 2746 |
break; |
| 2747 |
case PowerPoint7GraphInternal::Frame::Group: { |
| 2748 |
auto const *group=dynamic_cast<PowerPoint7GraphInternal::FrameGroup const *>(&frame); |
| 2749 |
if (!group) { |
| 2750 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::sendFrame: can not find the group\n")); |
| 2751 |
return false; |
| 2752 |
} |
| 2753 |
if (group->m_child.empty()) |
| 2754 |
return true; |
| 2755 |
MWAWPosition pos(fBox[0], fBox.size(), librevenge::RVNG_POINT); |
| 2756 |
pos.m_anchorTo = MWAWPosition::Page; |
| 2757 |
listener->openGroup(pos); |
| 2758 |
for (auto const &child : group->m_child) { |
| 2759 |
if (!child) continue; |
| 2760 |
sendFrame(*child, master); |
| 2761 |
} |
| 2762 |
listener->closeGroup(); |
| 2763 |
return true; |
| 2764 |
} |
| 2765 |
case PowerPoint7GraphInternal::Frame::Polygon: { |
| 2766 |
auto const *poly=dynamic_cast<PowerPoint7GraphInternal::FramePolygon const *>(&frame); |
| 2767 |
if (!poly) { |
| 2768 |
MWAW_DEBUG_MSG(("PowerPoint7Graph::sendFrame: can not find the polygon\n")); |
| 2769 |
return false; |
| 2770 |
} |
| 2771 |
if (!poly->updateShape(fBox, shape)) return false; |
| 2772 |
break; |
| 2773 |
} |
| 2774 |
case PowerPoint7GraphInternal::Frame::Rect: |
| 2775 |
if (frame.m_subType>=0) { |
| 2776 |
if (!m_state->getCustomShape(frame.m_subType, shape)) |
| 2777 |
return false; |
| 2778 |
if (frame.m_flip[0]||frame.m_flip[1]) { |
| 2779 |
shape.translate(MWAWVec2f(-0.5f,-0.5f)); |
| 2780 |
if (frame.m_flip[0]) shape.scale(MWAWVec2f(-1,1)); |
| 2781 |
if (frame.m_flip[1]) shape.scale(MWAWVec2f(1,-1)); |
| 2782 |
shape.translate(MWAWVec2f(0.5f,0.5f)); |
| 2783 |
} |
| 2784 |
shape.scale(fBox.size()); |
| 2785 |
shape.translate(fBox[0]); |
| 2786 |
if (frame.m_rotation<0||frame.m_rotation>0) |
| 2787 |
shape=shape.rotate(-frame.m_rotation, fBox.center()); |
| 2788 |
break; |
| 2789 |
} |
| 2790 |
switch (frame.m_subType) { |
| 2791 |
case -1: |
| 2792 |
shape=MWAWGraphicShape::circle(fBox); |
| 2793 |
break; |
| 2794 |
case -2: |
| 2795 |
shape=MWAWGraphicShape::rectangle(fBox, MWAWVec2f(3,3)); |
| 2796 |
break; |
| 2797 |
case -3: |
| 2798 |
shape=MWAWGraphicShape::rectangle(fBox); |
| 2799 |
break; |
| 2800 |
default: |
| 2801 |
return false; |
| 2802 |
} |
| 2803 |
if (frame.m_rotation<0||frame.m_rotation>0) |
| 2804 |
shape=shape.rotate(-frame.m_rotation, fBox.center()); |
| 2805 |
break; |
| 2806 |
case PowerPoint7GraphInternal::Frame::Placeholder: |
| 2807 |
case PowerPoint7GraphInternal::Frame::Unknown: |
| 2808 |
#if !defined(__clang__) |
| 2809 |
default: |
| 2810 |
#endif |
| 2811 |
return false; |
| 2812 |
} |
| 2813 |
|
| 2814 |
MWAWBox2f box=shape.getBdBox(); |
| 2815 |
MWAWPosition pos(box[0], box.size(), librevenge::RVNG_POINT); |
| 2816 |
pos.m_anchorTo = MWAWPosition::Page; |
| 2817 |
if (frame.m_isBackground) pos.m_wrapping = MWAWPosition::WBackground; |
| 2818 |
listener->insertShape(pos, shape, frame.m_style); |
| 2819 |
return true; |
| 2820 |
} |
| 2821 |
|
| 2822 |
bool PowerPoint7Graph::sendText(int textId) |
| 2823 |
{ |
| 2824 |
return m_mainParser->sendText(textId); |
| 2825 |
} |
| 2826 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |