| 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 <sstream> |
| 39 |
|
| 40 |
#include <librevenge/librevenge.h> |
| 41 |
|
| 42 |
#include "MWAWFont.hxx" |
| 43 |
#include "MWAWFontConverter.hxx" |
| 44 |
#include "MWAWGraphicListener.hxx" |
| 45 |
#include "MWAWGraphicShape.hxx" |
| 46 |
#include "MWAWGraphicStyle.hxx" |
| 47 |
#include "MWAWHeader.hxx" |
| 48 |
#include "MWAWParagraph.hxx" |
| 49 |
#include "MWAWPictBitmap.hxx" |
| 50 |
#include "MWAWPictData.hxx" |
| 51 |
#include "MWAWPrinter.hxx" |
| 52 |
#include "MWAWPosition.hxx" |
| 53 |
#include "MWAWRSRCParser.hxx" |
| 54 |
#include "MWAWSubDocument.hxx" |
| 55 |
|
| 56 |
#include "ClarisDrawParser.hxx" |
| 57 |
|
| 58 |
#include "ClarisDrawStyleManager.hxx" |
| 59 |
|
| 60 |
/** Internal: the structures of a ClarisDrawStyleManager */ |
| 61 |
namespace ClarisDrawStyleManagerInternal |
| 62 |
{ |
| 63 |
// gradient of ClarisDrawStyleManagerInternal |
| 64 |
struct Gradient { |
| 65 |
//! construtor |
| 66 |
explicit Gradient(int type=0, int nColor=0, int angle=0, float decal=0) |
| 67 |
: m_type(type) |
| 68 |
, m_numColors(nColor) |
| 69 |
, m_angle(angle) |
| 70 |
, m_decal(decal) |
| 71 |
, m_box() |
| 72 |
{ |
| 73 |
m_colors[0]=MWAWColor::black(); |
| 74 |
m_colors[1]=MWAWColor::white(); |
| 75 |
} |
| 76 |
//! check if the gradient is valid |
| 77 |
bool ok() const |
| 78 |
{ |
| 79 |
return m_type>=0 && m_type<=2 && m_numColors>=2 && m_numColors<=4; |
| 80 |
} |
| 81 |
//! update the style |
| 82 |
bool update(MWAWGraphicStyle &style) const; |
| 83 |
//! operator<< |
| 84 |
friend std::ostream &operator<<(std::ostream &o, Gradient const &gr) |
| 85 |
{ |
| 86 |
switch (gr.m_type) { |
| 87 |
case 0: |
| 88 |
o << "linear,"; |
| 89 |
break; |
| 90 |
case 1: |
| 91 |
o << "radial,"; |
| 92 |
break; |
| 93 |
case 2: |
| 94 |
o << "rectangle,"; |
| 95 |
break; |
| 96 |
default: |
| 97 |
o << "#type=" << gr.m_type << ","; |
| 98 |
break; |
| 99 |
} |
| 100 |
if (gr.m_angle) |
| 101 |
o << "angle=" << gr.m_angle << ","; |
| 102 |
if (gr.m_decal>0) |
| 103 |
o << "decal=" << gr.m_decal << ","; |
| 104 |
o << "col=["; |
| 105 |
for (int c=0; c < gr.m_numColors; ++c) { |
| 106 |
if (c>=4) break; |
| 107 |
o << gr.m_colors[c] << ","; |
| 108 |
} |
| 109 |
o << "],"; |
| 110 |
if (gr.m_box!=MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(0,0))) |
| 111 |
o << "center=" << gr.m_box << ","; |
| 112 |
return o; |
| 113 |
} |
| 114 |
//! the type |
| 115 |
int m_type; |
| 116 |
//! the number of color |
| 117 |
int m_numColors; |
| 118 |
//! the color |
| 119 |
MWAWColor m_colors[4]; |
| 120 |
//! the angle |
| 121 |
int m_angle; |
| 122 |
//! the decal |
| 123 |
float m_decal; |
| 124 |
//! the center bdbox |
| 125 |
MWAWBox2i m_box; |
| 126 |
}; |
| 127 |
bool Gradient::update(MWAWGraphicStyle &style) const |
| 128 |
{ |
| 129 |
if (!ok()) return false; |
| 130 |
auto &finalGrad=style.m_gradient; |
| 131 |
finalGrad.m_stopList.resize(0); |
| 132 |
if (m_type==1 || m_type==2) { |
| 133 |
finalGrad.m_type=m_type==1 ? MWAWGraphicStyle::Gradient::G_Radial : MWAWGraphicStyle::Gradient::G_Rectangular; |
| 134 |
for (int c=0; c < m_numColors; ++c) |
| 135 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c)/float(m_numColors-1), m_colors[c])); |
| 136 |
finalGrad.m_percentCenter=MWAWVec2f(float(m_box.center()[1])/100.f, float(m_box.center()[0])/100.f); |
| 137 |
return true; |
| 138 |
} |
| 139 |
finalGrad.m_angle=float(m_angle+90); |
| 140 |
if (m_decal>=0.5f-0.1e-3f && m_decal<=0.5f+0.1e-3f) { |
| 141 |
finalGrad.m_type= MWAWGraphicStyle::Gradient::G_Axial; |
| 142 |
for (int c=0; c < m_numColors; ++c) |
| 143 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c)/float(m_numColors-1), m_colors[m_numColors-1-c])); |
| 144 |
return true; |
| 145 |
} |
| 146 |
finalGrad.m_type= MWAWGraphicStyle::Gradient::G_Linear; |
| 147 |
if (m_decal <= 0.05f) { |
| 148 |
for (int c=0; c < m_numColors; ++c) |
| 149 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c)/float(m_numColors-1), m_colors[m_numColors-1-c])); |
| 150 |
return true; |
| 151 |
} |
| 152 |
if (m_decal >=0.95f) { |
| 153 |
for (int c=0; c < m_numColors; ++c) |
| 154 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(float(c)/float(m_numColors-1), m_colors[c])); |
| 155 |
return true; |
| 156 |
} |
| 157 |
for (int c=-m_numColors+1; c<m_numColors; ++c) { |
| 158 |
// checkme: look almost good |
| 159 |
float pos=float(c)/float(m_numColors-1)+m_decal/2.f; |
| 160 |
if (pos < 0) { |
| 161 |
if (c!=m_numColors-1 && float(c+1)/float(m_numColors-1)+(1-m_decal)/2.f>=0) |
| 162 |
continue; |
| 163 |
pos=0; |
| 164 |
} |
| 165 |
finalGrad.m_stopList.push_back(MWAWGraphicStyle::Gradient::Stop(pos>1?1:pos, m_colors[m_numColors-1+(c<0?c:-c)])); |
| 166 |
if (pos>=1) |
| 167 |
break; |
| 168 |
} |
| 169 |
return true; |
| 170 |
} |
| 171 |
|
| 172 |
//////////////////////////////////////// |
| 173 |
//! Internal: the state of a ClarisDrawStyleManager |
| 174 |
struct State { |
| 175 |
//! constructor |
| 176 |
State() |
| 177 |
: m_documentSize() |
| 178 |
, m_numColors(0) |
| 179 |
, m_numBWPatterns(0) |
| 180 |
, m_numGradients(0) |
| 181 |
, m_colorList() |
| 182 |
, m_dashList() |
| 183 |
, m_fontList() |
| 184 |
, m_paragraphList() |
| 185 |
, m_BWPatternList() |
| 186 |
, m_gradientList() |
| 187 |
{ |
| 188 |
for (auto &numStyle : m_numStyleZones) numStyle=0; |
| 189 |
} |
| 190 |
//! init the black and white patterns list |
| 191 |
void initBWPatterns(); |
| 192 |
//! init the colors list |
| 193 |
void initColors(); |
| 194 |
//! init the dashs list |
| 195 |
void initDashs(); |
| 196 |
//! init the gradient list |
| 197 |
void initGradients(); |
| 198 |
//! the document size (in point) |
| 199 |
MWAWVec2f m_documentSize; |
| 200 |
//! the number of zones |
| 201 |
int m_numStyleZones[6]; |
| 202 |
//! the number of color |
| 203 |
int m_numColors; |
| 204 |
//! the number of BW pattern |
| 205 |
int m_numBWPatterns; |
| 206 |
//! the number of gradient |
| 207 |
int m_numGradients; |
| 208 |
//! the color list |
| 209 |
std::vector<MWAWColor> m_colorList; |
| 210 |
//! the list of dash |
| 211 |
std::vector< std::vector<float> > m_dashList; |
| 212 |
//! the list of font |
| 213 |
std::vector<MWAWFont> m_fontList; |
| 214 |
//! the list of paragraph |
| 215 |
std::vector<MWAWParagraph> m_paragraphList; |
| 216 |
|
| 217 |
//! the patterns list |
| 218 |
std::vector<MWAWGraphicStyle::Pattern> m_BWPatternList; |
| 219 |
//! the gradient list |
| 220 |
std::vector<Gradient> m_gradientList; |
| 221 |
}; |
| 222 |
|
| 223 |
void State::initColors() |
| 224 |
{ |
| 225 |
if (!m_colorList.empty()) return; |
| 226 |
if (m_numColors==168) { // the 168 palettes has more than 168 colors... |
| 227 |
uint32_t const defCol[186] = { |
| 228 |
0xffffff,0x000000,0x777777,0x555555,0xffff00,0xff6600,0xdd0000,0xff0099, |
| 229 |
0x660099,0x0000dd,0x0099ff,0x00ee00,0x006600,0x663300,0x996633,0xbbbbbb, |
| 230 |
0x0c0c0c,0x191919,0x262626,0x333333,0x404040,0x4c4c4c,0x595959,0x666666, |
| 231 |
0x737373,0x808080,0x8c8c8c,0x999999,0xa6a6a6,0xb3b3b3,0xbfbfbf,0xcccccc, |
| 232 |
0xd9d9d9,0xe6e6e6,0xf3f3f3,0x660000,0x661900,0x663300,0x664c00,0x665900, |
| 233 |
0x666600,0x336600,0x006600,0x006633,0x00664c,0x006666,0x005966,0x004c66, |
| 234 |
0x004066,0x003366,0x001f66,0x000066,0x330066,0x660066,0x660044,0x66002a, |
| 235 |
0x990000,0x992600,0x994c00,0x997300,0x998600,0x999900,0x4c9900,0x009900, |
| 236 |
0x00994c,0x009973,0x009999,0x008699,0x007399,0x006099,0x004c99,0x002e99, |
| 237 |
0x000099,0x4c0099,0x990099,0x990066,0x990040,0xcc0000,0xcc3300,0xcc6600, |
| 238 |
0xcc9900,0xccb300,0xcccc00,0x66cc00,0x00cc00,0x00cc66,0x00cc99,0x00cccc, |
| 239 |
0x00b3cc,0x0099cc,0x007fcc,0x0066cc,0x003ecc,0x0000cc,0x6600cc,0xcc00cc, |
| 240 |
0xcc0088,0xcc0055,0xff0000,0xff4000,0xff7f00,0xffc000,0xffdf00,0xffff00, |
| 241 |
0x80ff00,0x00ff00,0x00ff7f,0x00ffc0,0x00ffff,0x00e0ff,0x00c0ff,0x00a0ff, |
| 242 |
0x0080ff,0x004eff,0x0000ff,0x7f00ff,0xff00ff,0xff00aa,0xff006a,0xff4c4c, |
| 243 |
0xff794c,0xffa64c,0xffd34c,0xffe94c,0xffff4c,0xa6ff4c,0x4cff4c,0x4cffa6, |
| 244 |
0x4cffd3,0x4cffff,0x4ce9ff,0x4cd3ff,0x4cbcff,0x4ca6ff,0x4c83ff,0x4c4cff, |
| 245 |
0xa64cff,0xff4cff,0xff4cc4,0xff4c97,0xff9999,0xffb399,0xffcc99,0xffe699, |
| 246 |
0xfff399,0xffff99,0xccff99,0x99ff99,0x99ffcc,0x99ffe6,0x99ffff,0x99f3ff, |
| 247 |
0x99e6ff,0x99d9ff,0x99ccff,0x99b8ff,0x9999ff,0xcc99ff,0xff99ff,0xff99dd, |
| 248 |
0xff99c4,0xffcccc,0xffd9cc,0xffe6cc,0xfff3cc,0xfff9cc,0xffffcc,0xe6ffcc, |
| 249 |
0xccffcc,0xccffe6,0xccfff3,0xccffff,0xccf9ff,0xccf3ff,0xccecff,0xcce6ff, |
| 250 |
0xccdcff,0xccccff,0xe6ccff,0xffccff,0xffccee,0xffcce2,0x000000,0x000000, |
| 251 |
}; |
| 252 |
m_colorList.resize(186); |
| 253 |
for (size_t i = 0; i < 186; i++) |
| 254 |
m_colorList[i] = defCol[i]; |
| 255 |
return; |
| 256 |
} |
| 257 |
uint32_t const defCol[256] = { |
| 258 |
0xffffff,0x000000,0x777777,0x555555,0xffff00,0xff6600,0xdd0000,0xff0099, |
| 259 |
0x660099,0x0000dd,0x0099ff,0x00ee00,0x006600,0x663300,0x996633,0xbbbbbb, |
| 260 |
0xffffcc,0xffff99,0xffff66,0xffff33,0xffccff,0xffcccc,0xffcc99,0xffcc66, |
| 261 |
0xffcc33,0xffcc00,0xff99ff,0xff99cc,0xff9999,0xff9966,0xff9933,0xff9900, |
| 262 |
0xff66ff,0xff66cc,0xff6699,0xff6666,0xff6633,0xff33ff,0xff33cc,0xff3399, |
| 263 |
0xff3366,0xff3333,0xff3300,0xff00ff,0xff00cc,0xff0066,0xff0033,0xff0000, |
| 264 |
0xccffff,0xccffcc,0xccff99,0xccff66,0xccff33,0xccff00,0xccccff,0xcccccc, |
| 265 |
0xcccc99,0xcccc66,0xcccc33,0xcccc00,0xcc99ff,0xcc99cc,0xcc9999,0xcc9966, |
| 266 |
0xcc9933,0xcc9900,0xcc66ff,0xcc66cc,0xcc6699,0xcc6666,0xcc6633,0xcc6600, |
| 267 |
0xcc33ff,0xcc33cc,0xcc3399,0xcc3366,0xcc3333,0xcc3300,0xcc00ff,0xcc00cc, |
| 268 |
0xcc0099,0xcc0066,0xcc0033,0xcc0000,0x99ffff,0x99ffcc,0x99ff99,0x99ff66, |
| 269 |
0x99ff33,0x99ff00,0x99ccff,0x99cccc,0x99cc99,0x99cc66,0x99cc33,0x99cc00, |
| 270 |
0x9999ff,0x9999cc,0x999999,0x999966,0x999933,0x999900,0x9966ff,0x9966cc, |
| 271 |
0x996699,0x996666,0x996600,0x9933ff,0x9933cc,0x993399,0x993366,0x993333, |
| 272 |
0x993300,0x9900ff,0x9900cc,0x990099,0x990066,0x990033,0x990000,0x66ffff, |
| 273 |
0x66ffcc,0x66ff99,0x66ff66,0x66ff33,0x66ff00,0x66ccff,0x66cccc,0x66cc99, |
| 274 |
0x66cc66,0x66cc33,0x66cc00,0x6699ff,0x6699cc,0x669999,0x669966,0x669933, |
| 275 |
0x669900,0x6666ff,0x6666cc,0x666699,0x666666,0x666633,0x666600,0x6633ff, |
| 276 |
0x6633cc,0x663399,0x663366,0x663333,0x6600ff,0x6600cc,0x660066,0x660033, |
| 277 |
0x660000,0x33ffff,0x33ffcc,0x33ff99,0x33ff66,0x33ff33,0x33ff00,0x33ccff, |
| 278 |
0x33cccc,0x33cc99,0x33cc66,0x33cc33,0x33cc00,0x3399ff,0x3399cc,0x339999, |
| 279 |
0x339966,0x339933,0x339900,0x3366ff,0x3366cc,0x336699,0x336666,0x336633, |
| 280 |
0x336600,0x3333ff,0x3333cc,0x333399,0x333366,0x333333,0x333300,0x3300ff, |
| 281 |
0x3300cc,0x330099,0x330066,0x330033,0x330000,0x00ffff,0x00ffcc,0x00ff99, |
| 282 |
0x00ff66,0x00ff33,0x00ff00,0x00ccff,0x00cccc,0x00cc99,0x00cc66,0x00cc33, |
| 283 |
0x00cc00,0x0099cc,0x009999,0x009966,0x009933,0x009900,0x0066ff,0x0066cc, |
| 284 |
0x006699,0x006666,0x006633,0x0033ff,0x0033cc,0x003399,0x003366,0x003333, |
| 285 |
0x003300,0x0000ff,0x0000cc,0x000099,0x000066,0x000033,0xee0000,0xbb0000, |
| 286 |
0xaa0000,0x880000,0x770000,0x550000,0x440000,0x220000,0x110000,0x00dd00, |
| 287 |
0x00bb00,0x00aa00,0x008800,0x007700,0x005500,0x004400,0x002200,0x001100, |
| 288 |
0x0000ee,0x0000bb,0x0000aa,0x000088,0x000077,0x000055,0x000044,0x000022, |
| 289 |
0x000011,0xeeeeee,0xdddddd,0xaaaaaa,0x888888,0x444444,0x222222,0x111111, |
| 290 |
}; |
| 291 |
if (m_numColors==0) |
| 292 |
m_numColors=256; |
| 293 |
else if (m_numColors!=256) { |
| 294 |
/* there also exist a 81 color palettes */ |
| 295 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::initColors: unimplemented number of color %d\n", m_numColors)); |
| 296 |
} |
| 297 |
m_colorList.resize(256); |
| 298 |
for (size_t i = 0; i < 256; i++) |
| 299 |
m_colorList[i] = defCol[i]; |
| 300 |
} |
| 301 |
|
| 302 |
void State::initDashs() |
| 303 |
{ |
| 304 |
if (!m_dashList.empty()) return; |
| 305 |
std::vector<float> dash; |
| 306 |
// 1: 9x9 |
| 307 |
dash.push_back(9); |
| 308 |
dash.push_back(9); |
| 309 |
m_dashList.push_back(dash); |
| 310 |
// 2: 27x9 |
| 311 |
dash[0]=27; |
| 312 |
m_dashList.push_back(dash); |
| 313 |
// 3: 18x18 |
| 314 |
dash[0]=dash[1]=18; |
| 315 |
m_dashList.push_back(dash); |
| 316 |
// 4: 54x18 |
| 317 |
dash[0]=54; |
| 318 |
m_dashList.push_back(dash); |
| 319 |
// 5: 72x9, 9x9 |
| 320 |
dash.resize(4,9); |
| 321 |
dash[0]=72; |
| 322 |
dash[1]=9; |
| 323 |
m_dashList.push_back(dash); |
| 324 |
// 6: 72x9, 9x9, 9x9 |
| 325 |
dash.resize(6,9); |
| 326 |
m_dashList.push_back(dash); |
| 327 |
} |
| 328 |
|
| 329 |
void State::initGradients() |
| 330 |
{ |
| 331 |
if (!m_gradientList.empty()) return; |
| 332 |
Gradient grad; |
| 333 |
if (m_numGradients==32) { // checkme |
| 334 |
// grad0 |
| 335 |
grad=Gradient(0,2,0,1); |
| 336 |
m_gradientList.push_back(grad); |
| 337 |
// grad1 |
| 338 |
grad=Gradient(0,2,180,1); |
| 339 |
m_gradientList.push_back(grad); |
| 340 |
// grad2 |
| 341 |
grad=Gradient(0,2,90,0); |
| 342 |
m_gradientList.push_back(grad); |
| 343 |
// grad3 |
| 344 |
grad=Gradient(0,2,315,1); |
| 345 |
m_gradientList.push_back(grad); |
| 346 |
// grad4 |
| 347 |
grad=Gradient(0,2,225,1); |
| 348 |
m_gradientList.push_back(grad); |
| 349 |
// grad5 |
| 350 |
grad=Gradient(2,2,0,0); |
| 351 |
grad.m_box=MWAWBox2i(MWAWVec2i(79,80),MWAWVec2i(79,80)); |
| 352 |
m_gradientList.push_back(grad); |
| 353 |
// grad6 |
| 354 |
grad=Gradient(2,2,0,0); |
| 355 |
grad.m_box=MWAWBox2i(MWAWVec2i(81,20),MWAWVec2i(81,20)); |
| 356 |
m_gradientList.push_back(grad); |
| 357 |
// grad7 |
| 358 |
grad=Gradient(2,2,0,0); |
| 359 |
grad.m_box=MWAWBox2i(MWAWVec2i(50,50),MWAWVec2i(50,50)); |
| 360 |
m_gradientList.push_back(grad); |
| 361 |
// grad8 |
| 362 |
grad=Gradient(0,2,90,1); |
| 363 |
m_gradientList.push_back(grad); |
| 364 |
// grad9 |
| 365 |
grad=Gradient(0,2,270,0.979172f); |
| 366 |
m_gradientList.push_back(grad); |
| 367 |
// grad10 |
| 368 |
grad=Gradient(0,2,0,0); |
| 369 |
m_gradientList.push_back(grad); |
| 370 |
// grad11 |
| 371 |
grad=Gradient(0,2,45,1); |
| 372 |
m_gradientList.push_back(grad); |
| 373 |
// grad12 |
| 374 |
grad=Gradient(0,2,135,1); |
| 375 |
m_gradientList.push_back(grad); |
| 376 |
// grad13 |
| 377 |
grad=Gradient(2,2,0,0); |
| 378 |
grad.m_box=MWAWBox2i(MWAWVec2i(22,77),MWAWVec2i(23,77)); |
| 379 |
m_gradientList.push_back(grad); |
| 380 |
// grad14 |
| 381 |
grad=Gradient(2,2,0,0); |
| 382 |
grad.m_box=MWAWBox2i(MWAWVec2i(22,22),MWAWVec2i(22,22)); |
| 383 |
m_gradientList.push_back(grad); |
| 384 |
// grad15 |
| 385 |
grad=Gradient(1,2,0,0); |
| 386 |
grad.m_box=MWAWBox2i(MWAWVec2i(51,50),MWAWVec2i(51,50)); |
| 387 |
m_gradientList.push_back(grad); |
| 388 |
// grad16 |
| 389 |
grad=Gradient(2,3,0,0); |
| 390 |
grad.m_box=MWAWBox2i(MWAWVec2i(79,15),MWAWVec2i(86,22)); |
| 391 |
grad.m_colors[1]=MWAWColor(0xaa0000); |
| 392 |
grad.m_colors[2]=MWAWColor(0xcc3300); |
| 393 |
m_gradientList.push_back(grad); |
| 394 |
// grad17 |
| 395 |
grad=Gradient(0,4,0,1); |
| 396 |
grad.m_colors[0]=MWAWColor(0xff33cc); |
| 397 |
grad.m_colors[1]=MWAWColor(0xdd0000); |
| 398 |
grad.m_colors[2]=MWAWColor(0xdd0000); |
| 399 |
grad.m_colors[3]=MWAWColor(0x000000); |
| 400 |
m_gradientList.push_back(grad); |
| 401 |
// grad18 |
| 402 |
grad=Gradient(0,3,112,0.80835f); |
| 403 |
grad.m_colors[0]=MWAWColor(0x0000dd); |
| 404 |
grad.m_colors[1]=MWAWColor(0x000077); |
| 405 |
grad.m_colors[2]=MWAWColor(0xff3333); |
| 406 |
m_gradientList.push_back(grad); |
| 407 |
// grad19 |
| 408 |
grad=Gradient(1,4,332,0); |
| 409 |
grad.m_box=MWAWBox2i(MWAWVec2i(77,71),MWAWVec2i(77,71)); |
| 410 |
grad.m_colors[0]=MWAWColor(0xffff00); |
| 411 |
grad.m_colors[1]=MWAWColor(0xff3300); |
| 412 |
grad.m_colors[2]=MWAWColor(0x9900cc); |
| 413 |
grad.m_colors[3]=MWAWColor(0x0000dd); |
| 414 |
m_gradientList.push_back(grad); |
| 415 |
// grad20 |
| 416 |
grad=Gradient(0,3,270,0.625f); |
| 417 |
grad.m_colors[1]=MWAWColor(0x0000dd); |
| 418 |
grad.m_colors[2]=MWAWColor(0x00cccc); |
| 419 |
m_gradientList.push_back(grad); |
| 420 |
// grad21 |
| 421 |
grad=Gradient(0,2,270,0.229172f); |
| 422 |
grad.m_colors[0]=MWAWColor(0x0000aa); |
| 423 |
grad.m_colors[1]=MWAWColor(0xdddddd); |
| 424 |
m_gradientList.push_back(grad); |
| 425 |
// grad22 |
| 426 |
grad=Gradient(0,3,90,0.729172f); |
| 427 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 428 |
grad.m_colors[2]=MWAWColor(0x9999ff); |
| 429 |
m_gradientList.push_back(grad); |
| 430 |
// grad23 |
| 431 |
grad=Gradient(2,4,0,0); |
| 432 |
grad.m_box=MWAWBox2i(MWAWVec2i(41,40),MWAWVec2i(62,62)); |
| 433 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 434 |
grad.m_colors[1]=MWAWColor(0xccffff); |
| 435 |
grad.m_colors[2]=MWAWColor(0x99ffff); |
| 436 |
grad.m_colors[3]=MWAWColor(0x66ffff); |
| 437 |
m_gradientList.push_back(grad); |
| 438 |
// grad24 |
| 439 |
grad=Gradient(0,3,90,0.854172f); |
| 440 |
grad.m_colors[1]=MWAWColor(0xdd0000); |
| 441 |
grad.m_colors[2]=MWAWColor(0xffcc00); |
| 442 |
m_gradientList.push_back(grad); |
| 443 |
// grad25 |
| 444 |
grad=Gradient(0,4,315,0.633453f); |
| 445 |
grad.m_colors[0]=MWAWColor(0xcc3300); |
| 446 |
grad.m_colors[1]=MWAWColor(0xff6600); |
| 447 |
grad.m_colors[2]=MWAWColor(0xffcc00); |
| 448 |
grad.m_colors[3]=MWAWColor(0xffff00); |
| 449 |
m_gradientList.push_back(grad); |
| 450 |
// grad26 |
| 451 |
grad=Gradient(0,3,45,0.721832f); |
| 452 |
grad.m_colors[1]=MWAWColor(0x0000dd); |
| 453 |
grad.m_colors[2]=MWAWColor(0xff0099); |
| 454 |
m_gradientList.push_back(grad); |
| 455 |
// grad27 |
| 456 |
grad=Gradient(0,3,180,1); |
| 457 |
grad.m_colors[1]=MWAWColor(0x0000dd); |
| 458 |
grad.m_colors[2]=MWAWColor(0x9900cc); |
| 459 |
m_gradientList.push_back(grad); |
| 460 |
// grad28 |
| 461 |
grad=Gradient(0,4,90,0.81987f); |
| 462 |
grad.m_colors[1]=MWAWColor(0x9900cc); |
| 463 |
grad.m_colors[2]=MWAWColor(0x9933ff); |
| 464 |
grad.m_colors[3]=MWAWColor(0x66ffff); |
| 465 |
m_gradientList.push_back(grad); |
| 466 |
// grad29 |
| 467 |
grad=Gradient(0,4,270,0.916672f); |
| 468 |
grad.m_colors[0]=MWAWColor(0x0066ff); |
| 469 |
grad.m_colors[1]=MWAWColor(0x00ccff); |
| 470 |
grad.m_colors[2]=MWAWColor(0xffffcc); |
| 471 |
grad.m_colors[3]=MWAWColor(0xff6633); |
| 472 |
m_gradientList.push_back(grad); |
| 473 |
// grad30 |
| 474 |
grad=Gradient(2,2,0,0); |
| 475 |
grad.m_box=MWAWBox2i(MWAWVec2i(0,88),MWAWVec2i(12,100)); |
| 476 |
grad.m_colors[0]=MWAWColor(0xff6600); |
| 477 |
grad.m_colors[1]=MWAWColor(0xffff00); |
| 478 |
m_gradientList.push_back(grad); |
| 479 |
// grad31 |
| 480 |
grad=Gradient(2,4,0,0); |
| 481 |
grad.m_box=MWAWBox2i(MWAWVec2i(99,52),MWAWVec2i(100,54)); |
| 482 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 483 |
grad.m_colors[1]=MWAWColor(0xffffcc); |
| 484 |
grad.m_colors[2]=MWAWColor(0xffff66); |
| 485 |
grad.m_colors[3]=MWAWColor(0xffcc00); |
| 486 |
m_gradientList.push_back(grad); |
| 487 |
return; |
| 488 |
} |
| 489 |
if (m_numGradients==0) |
| 490 |
m_numGradients=64; |
| 491 |
if (m_numGradients!=64) { |
| 492 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::initGradients: unimplemented number of color %d\n", m_numGradients)); |
| 493 |
} |
| 494 |
// grad0 |
| 495 |
grad=Gradient(0,2,0,0); |
| 496 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 497 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 498 |
m_gradientList.push_back(grad); |
| 499 |
// grad1 |
| 500 |
grad=Gradient(0,2,180,0); |
| 501 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 502 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 503 |
m_gradientList.push_back(grad); |
| 504 |
// grad2 |
| 505 |
grad=Gradient(0,2,90,0.5f); |
| 506 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 507 |
grad.m_colors[1]=MWAWColor(0xffffff); |
| 508 |
m_gradientList.push_back(grad); |
| 509 |
// grad3 |
| 510 |
grad=Gradient(0,2,315,0); |
| 511 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 512 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 513 |
m_gradientList.push_back(grad); |
| 514 |
// grad4 |
| 515 |
grad=Gradient(0,2,225,0); |
| 516 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 517 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 518 |
m_gradientList.push_back(grad); |
| 519 |
// grad5 |
| 520 |
grad=Gradient(2,2,0,0); |
| 521 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 522 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 523 |
grad.m_box=MWAWBox2i(MWAWVec2i(79,80),MWAWVec2i(79,80)); |
| 524 |
m_gradientList.push_back(grad); |
| 525 |
// grad6 |
| 526 |
grad=Gradient(2,2,0,0); |
| 527 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 528 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 529 |
grad.m_box=MWAWBox2i(MWAWVec2i(81,20),MWAWVec2i(81,20)); |
| 530 |
m_gradientList.push_back(grad); |
| 531 |
// grad7 |
| 532 |
grad=Gradient(2,2,0,0); |
| 533 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 534 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 535 |
grad.m_box=MWAWBox2i(MWAWVec2i(50,50),MWAWVec2i(50,50)); |
| 536 |
m_gradientList.push_back(grad); |
| 537 |
// grad8 |
| 538 |
grad=Gradient(0,2,90,0); |
| 539 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 540 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 541 |
m_gradientList.push_back(grad); |
| 542 |
// grad9 |
| 543 |
grad=Gradient(0,2,270,0.989578f); |
| 544 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 545 |
grad.m_colors[1]=MWAWColor(0xffffff); |
| 546 |
m_gradientList.push_back(grad); |
| 547 |
// grad10 |
| 548 |
grad=Gradient(0,2,0,0.5f); |
| 549 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 550 |
grad.m_colors[1]=MWAWColor(0xffffff); |
| 551 |
m_gradientList.push_back(grad); |
| 552 |
// grad11 |
| 553 |
grad=Gradient(0,2,45,0); |
| 554 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 555 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 556 |
m_gradientList.push_back(grad); |
| 557 |
// grad12 |
| 558 |
grad=Gradient(0,2,135,0); |
| 559 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 560 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 561 |
m_gradientList.push_back(grad); |
| 562 |
// grad13 |
| 563 |
grad=Gradient(2,2,0,0); |
| 564 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 565 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 566 |
grad.m_box=MWAWBox2i(MWAWVec2i(22,77),MWAWVec2i(23,77)); |
| 567 |
m_gradientList.push_back(grad); |
| 568 |
// grad14 |
| 569 |
grad=Gradient(2,2,0,0); |
| 570 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 571 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 572 |
grad.m_box=MWAWBox2i(MWAWVec2i(22,22),MWAWVec2i(22,22)); |
| 573 |
m_gradientList.push_back(grad); |
| 574 |
// grad15 |
| 575 |
grad=Gradient(1,2,180,0); |
| 576 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 577 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 578 |
grad.m_box=MWAWBox2i(MWAWVec2i(0,1),MWAWVec2i(0,0)); |
| 579 |
m_gradientList.push_back(grad); |
| 580 |
// grad16 |
| 581 |
grad=Gradient(0,4,0,0); |
| 582 |
grad.m_colors[0]=MWAWColor(0x00ff00); |
| 583 |
grad.m_colors[1]=MWAWColor(0xffff00); |
| 584 |
grad.m_colors[2]=MWAWColor(0xff7f00); |
| 585 |
grad.m_colors[3]=MWAWColor(0xff0000); |
| 586 |
m_gradientList.push_back(grad); |
| 587 |
// grad17 |
| 588 |
grad=Gradient(0,4,0,0); |
| 589 |
grad.m_colors[0]=MWAWColor(0x0000ff); |
| 590 |
grad.m_colors[1]=MWAWColor(0x00a0ff); |
| 591 |
grad.m_colors[2]=MWAWColor(0x00ffc0); |
| 592 |
grad.m_colors[3]=MWAWColor(0x00ff00); |
| 593 |
m_gradientList.push_back(grad); |
| 594 |
// grad18 |
| 595 |
grad=Gradient(0,4,0,0); |
| 596 |
grad.m_colors[0]=MWAWColor(0xff0000); |
| 597 |
grad.m_colors[1]=MWAWColor(0xff00aa); |
| 598 |
grad.m_colors[2]=MWAWColor(0x7f00ff); |
| 599 |
grad.m_colors[3]=MWAWColor(0x0000ff); |
| 600 |
m_gradientList.push_back(grad); |
| 601 |
// grad19 |
| 602 |
grad=Gradient(0,3,135,0); |
| 603 |
grad.m_colors[0]=MWAWColor(0x4cbcff); |
| 604 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 605 |
grad.m_colors[2]=MWAWColor(0x660066); |
| 606 |
m_gradientList.push_back(grad); |
| 607 |
// grad20 |
| 608 |
grad=Gradient(0,3,225,0); |
| 609 |
grad.m_colors[0]=MWAWColor(0xa64cff); |
| 610 |
grad.m_colors[1]=MWAWColor(0x4c4cff); |
| 611 |
grad.m_colors[2]=MWAWColor(0xff00ff); |
| 612 |
m_gradientList.push_back(grad); |
| 613 |
// grad21 |
| 614 |
grad=Gradient(2,3,0,0); |
| 615 |
grad.m_colors[0]=MWAWColor(0xffcc66); |
| 616 |
grad.m_colors[1]=MWAWColor(0x993300); |
| 617 |
grad.m_colors[2]=MWAWColor(0x111111); |
| 618 |
grad.m_box=MWAWBox2i(MWAWVec2i(23,22),MWAWVec2i(27,24)); |
| 619 |
m_gradientList.push_back(grad); |
| 620 |
// grad22 |
| 621 |
grad=Gradient(2,3,0,0); |
| 622 |
grad.m_colors[0]=MWAWColor(0x3300ff); |
| 623 |
grad.m_colors[1]=MWAWColor(0x3300ff); |
| 624 |
grad.m_colors[2]=MWAWColor(0x0c0c0c); |
| 625 |
grad.m_box=MWAWBox2i(MWAWVec2i(28,26),MWAWVec2i(28,31)); |
| 626 |
m_gradientList.push_back(grad); |
| 627 |
// grad23 |
| 628 |
grad=Gradient(1,4,135,0); |
| 629 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 630 |
grad.m_colors[1]=MWAWColor(0x0000ff); |
| 631 |
grad.m_colors[2]=MWAWColor(0x000000); |
| 632 |
grad.m_colors[3]=MWAWColor(0x000000); |
| 633 |
grad.m_box=MWAWBox2i(MWAWVec2i(255,247),MWAWVec2i(255,250)); |
| 634 |
m_gradientList.push_back(grad); |
| 635 |
// grad24 |
| 636 |
grad=Gradient(0,3,270,0.998474f); |
| 637 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 638 |
grad.m_colors[1]=MWAWColor(0x330099); |
| 639 |
grad.m_colors[2]=MWAWColor(0xffc000); |
| 640 |
m_gradientList.push_back(grad); |
| 641 |
// grad25 |
| 642 |
grad=Gradient(0,3,270,0); |
| 643 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 644 |
grad.m_colors[1]=MWAWColor(0x4c4cff); |
| 645 |
grad.m_colors[2]=MWAWColor(0x660044); |
| 646 |
m_gradientList.push_back(grad); |
| 647 |
// grad26 |
| 648 |
grad=Gradient(0,3,180,0); |
| 649 |
grad.m_colors[0]=MWAWColor(0x666666); |
| 650 |
grad.m_colors[1]=MWAWColor(0x33cc33); |
| 651 |
grad.m_colors[2]=MWAWColor(0xcc00ff); |
| 652 |
m_gradientList.push_back(grad); |
| 653 |
// grad27 |
| 654 |
grad=Gradient(0,2,45,0); |
| 655 |
grad.m_colors[0]=MWAWColor(0xff0000); |
| 656 |
grad.m_colors[1]=MWAWColor(0x664c00); |
| 657 |
m_gradientList.push_back(grad); |
| 658 |
// grad28 |
| 659 |
grad=Gradient(0,4,145,0); |
| 660 |
grad.m_colors[0]=MWAWColor(0x006099); |
| 661 |
grad.m_colors[1]=MWAWColor(0x00e0ff); |
| 662 |
grad.m_colors[2]=MWAWColor(0x00cc99); |
| 663 |
grad.m_colors[3]=MWAWColor(0x006633); |
| 664 |
m_gradientList.push_back(grad); |
| 665 |
// grad29 |
| 666 |
grad=Gradient(2,3,0,0); |
| 667 |
grad.m_colors[0]=MWAWColor(0xcccc33); |
| 668 |
grad.m_colors[1]=MWAWColor(0x666600); |
| 669 |
grad.m_colors[2]=MWAWColor(0x111111); |
| 670 |
grad.m_box=MWAWBox2i(MWAWVec2i(23,21),MWAWVec2i(23,21)); |
| 671 |
m_gradientList.push_back(grad); |
| 672 |
// grad30 |
| 673 |
grad=Gradient(2,3,0,0); |
| 674 |
grad.m_colors[0]=MWAWColor(0x00cc33); |
| 675 |
grad.m_colors[1]=MWAWColor(0x005500); |
| 676 |
grad.m_colors[2]=MWAWColor(0x0c0c0c); |
| 677 |
grad.m_box=MWAWBox2i(MWAWVec2i(19,21),MWAWVec2i(22,26)); |
| 678 |
m_gradientList.push_back(grad); |
| 679 |
// grad31 |
| 680 |
grad=Gradient(1,3,45,0); |
| 681 |
grad.m_colors[0]=MWAWColor(0xff4c4c); |
| 682 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 683 |
grad.m_colors[2]=MWAWColor(0x66002a); |
| 684 |
grad.m_box=MWAWBox2i(MWAWVec2i(255,224),MWAWVec2i(255,237)); |
| 685 |
m_gradientList.push_back(grad); |
| 686 |
// grad32 |
| 687 |
grad=Gradient(0,3,180,0); |
| 688 |
grad.m_colors[0]=MWAWColor(0xff00ff); |
| 689 |
grad.m_colors[1]=MWAWColor(0x6666cc); |
| 690 |
grad.m_colors[2]=MWAWColor(0x9999ff); |
| 691 |
m_gradientList.push_back(grad); |
| 692 |
// grad33 |
| 693 |
grad=Gradient(0,2,177,0.660599f); |
| 694 |
grad.m_colors[0]=MWAWColor(0x00cc00); |
| 695 |
grad.m_colors[1]=MWAWColor(0xffdf00); |
| 696 |
m_gradientList.push_back(grad); |
| 697 |
// grad34 |
| 698 |
grad=Gradient(0,4,270,0.576279f); |
| 699 |
grad.m_colors[0]=MWAWColor(0x66002a); |
| 700 |
grad.m_colors[1]=MWAWColor(0x990066); |
| 701 |
grad.m_colors[2]=MWAWColor(0x990099); |
| 702 |
grad.m_colors[3]=MWAWColor(0xcc00cc); |
| 703 |
m_gradientList.push_back(grad); |
| 704 |
// grad35 |
| 705 |
grad=Gradient(0,2,155,0.712677f); |
| 706 |
grad.m_colors[0]=MWAWColor(0xff0000); |
| 707 |
grad.m_colors[1]=MWAWColor(0xffff00); |
| 708 |
m_gradientList.push_back(grad); |
| 709 |
// grad36 |
| 710 |
grad=Gradient(0,4,45,0); |
| 711 |
grad.m_colors[0]=MWAWColor(0x004066); |
| 712 |
grad.m_colors[1]=MWAWColor(0x00e0ff); |
| 713 |
grad.m_colors[2]=MWAWColor(0xffffcc); |
| 714 |
grad.m_colors[3]=MWAWColor(0xff4c4c); |
| 715 |
m_gradientList.push_back(grad); |
| 716 |
// grad37 |
| 717 |
grad=Gradient(2,3,0,0); |
| 718 |
grad.m_colors[0]=MWAWColor(0xff9999); |
| 719 |
grad.m_colors[1]=MWAWColor(0x990000); |
| 720 |
grad.m_colors[2]=MWAWColor(0x262626); |
| 721 |
grad.m_box=MWAWBox2i(MWAWVec2i(17,19),MWAWVec2i(23,26)); |
| 722 |
m_gradientList.push_back(grad); |
| 723 |
// grad38 |
| 724 |
grad=Gradient(2,3,0,0); |
| 725 |
grad.m_colors[0]=MWAWColor(0x0099cc); |
| 726 |
grad.m_colors[1]=MWAWColor(0x0033cc); |
| 727 |
grad.m_colors[2]=MWAWColor(0x111111); |
| 728 |
grad.m_box=MWAWBox2i(MWAWVec2i(18,18),MWAWVec2i(22,21)); |
| 729 |
m_gradientList.push_back(grad); |
| 730 |
// grad39 |
| 731 |
grad=Gradient(1,2,214,0); |
| 732 |
grad.m_colors[0]=MWAWColor(0xffdf00); |
| 733 |
grad.m_colors[1]=MWAWColor(0x0000cc); |
| 734 |
grad.m_box=MWAWBox2i(MWAWVec2i(0,24),MWAWVec2i(255,232)); |
| 735 |
m_gradientList.push_back(grad); |
| 736 |
// grad40 |
| 737 |
grad=Gradient(0,3,0,0); |
| 738 |
grad.m_colors[0]=MWAWColor(0x330033); |
| 739 |
grad.m_colors[1]=MWAWColor(0x006666); |
| 740 |
grad.m_colors[2]=MWAWColor(0x660033); |
| 741 |
m_gradientList.push_back(grad); |
| 742 |
// grad41 |
| 743 |
grad=Gradient(0,2,90,0); |
| 744 |
grad.m_colors[0]=MWAWColor(0x005966); |
| 745 |
grad.m_colors[1]=MWAWColor(0xff4c4c); |
| 746 |
m_gradientList.push_back(grad); |
| 747 |
// grad42 |
| 748 |
grad=Gradient(0,3,180,0); |
| 749 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 750 |
grad.m_colors[1]=MWAWColor(0x0080ff); |
| 751 |
grad.m_colors[2]=MWAWColor(0x000000); |
| 752 |
m_gradientList.push_back(grad); |
| 753 |
// grad43 |
| 754 |
grad=Gradient(0,3,45,0); |
| 755 |
grad.m_colors[0]=MWAWColor(0x004066); |
| 756 |
grad.m_colors[1]=MWAWColor(0x4c4cff); |
| 757 |
grad.m_colors[2]=MWAWColor(0x6600cc); |
| 758 |
m_gradientList.push_back(grad); |
| 759 |
// grad44 |
| 760 |
grad=Gradient(0,4,135,0); |
| 761 |
grad.m_colors[0]=MWAWColor(0x330066); |
| 762 |
grad.m_colors[1]=MWAWColor(0xa64cff); |
| 763 |
grad.m_colors[2]=MWAWColor(0xffff99); |
| 764 |
grad.m_colors[3]=MWAWColor(0xccccff); |
| 765 |
m_gradientList.push_back(grad); |
| 766 |
// grad45 |
| 767 |
grad=Gradient(2,2,0,0); |
| 768 |
grad.m_colors[0]=MWAWColor(0x7f00ff); |
| 769 |
grad.m_colors[1]=MWAWColor(0x990066); |
| 770 |
grad.m_box=MWAWBox2i(MWAWVec2i(70,24),MWAWVec2i(78,30)); |
| 771 |
m_gradientList.push_back(grad); |
| 772 |
// grad46 |
| 773 |
grad=Gradient(2,2,0,0); |
| 774 |
grad.m_colors[0]=MWAWColor(0x7f00ff); |
| 775 |
grad.m_colors[1]=MWAWColor(0xff0000); |
| 776 |
grad.m_box=MWAWBox2i(MWAWVec2i(70,24),MWAWVec2i(78,30)); |
| 777 |
m_gradientList.push_back(grad); |
| 778 |
// grad47 |
| 779 |
grad=Gradient(1,3,166,0); |
| 780 |
grad.m_colors[0]=MWAWColor(0x008699); |
| 781 |
grad.m_colors[1]=MWAWColor(0x4c9900); |
| 782 |
grad.m_colors[2]=MWAWColor(0x990066); |
| 783 |
m_gradientList.push_back(grad); |
| 784 |
// grad48 |
| 785 |
grad=Gradient(0,3,180,0); |
| 786 |
grad.m_colors[0]=MWAWColor(0xcc99ff); |
| 787 |
grad.m_colors[1]=MWAWColor(0xff7f00); |
| 788 |
grad.m_colors[2]=MWAWColor(0xff0000); |
| 789 |
m_gradientList.push_back(grad); |
| 790 |
// grad49 |
| 791 |
grad=Gradient(0,2,180,0); |
| 792 |
grad.m_colors[0]=MWAWColor(0xffffff); |
| 793 |
grad.m_colors[1]=MWAWColor(0xffff00); |
| 794 |
m_gradientList.push_back(grad); |
| 795 |
// grad50 |
| 796 |
grad=Gradient(0,4,270,0); |
| 797 |
grad.m_colors[0]=MWAWColor(0x000000); |
| 798 |
grad.m_colors[1]=MWAWColor(0xa64cff); |
| 799 |
grad.m_colors[2]=MWAWColor(0x330066); |
| 800 |
grad.m_colors[3]=MWAWColor(0x0000dd); |
| 801 |
m_gradientList.push_back(grad); |
| 802 |
// grad51 |
| 803 |
grad=Gradient(0,3,315,0); |
| 804 |
grad.m_colors[0]=MWAWColor(0x4cff4c); |
| 805 |
grad.m_colors[1]=MWAWColor(0x4cffd3); |
| 806 |
grad.m_colors[2]=MWAWColor(0x005966); |
| 807 |
m_gradientList.push_back(grad); |
| 808 |
// grad52 |
| 809 |
grad=Gradient(0,2,225,0); |
| 810 |
grad.m_colors[0]=MWAWColor(0x990066); |
| 811 |
grad.m_colors[1]=MWAWColor(0x0000ff); |
| 812 |
m_gradientList.push_back(grad); |
| 813 |
// grad53 |
| 814 |
grad=Gradient(2,4,0,0); |
| 815 |
grad.m_colors[0]=MWAWColor(0xfff399); |
| 816 |
grad.m_colors[1]=MWAWColor(0xffc000); |
| 817 |
grad.m_colors[2]=MWAWColor(0xff0000); |
| 818 |
grad.m_colors[3]=MWAWColor(0x661900); |
| 819 |
grad.m_box=MWAWBox2i(MWAWVec2i(90,43),MWAWVec2i(100,50)); |
| 820 |
m_gradientList.push_back(grad); |
| 821 |
// grad54 |
| 822 |
grad=Gradient(2,2,0,0); |
| 823 |
grad.m_colors[0]=MWAWColor(0xffff4c); |
| 824 |
grad.m_colors[1]=MWAWColor(0xff00aa); |
| 825 |
grad.m_box=MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(7,7)); |
| 826 |
m_gradientList.push_back(grad); |
| 827 |
// grad55 |
| 828 |
grad=Gradient(1,4,360,0); |
| 829 |
grad.m_colors[0]=MWAWColor(0x003ecc); |
| 830 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 831 |
grad.m_colors[2]=MWAWColor(0x00ffc0); |
| 832 |
grad.m_colors[3]=MWAWColor(0x990066); |
| 833 |
m_gradientList.push_back(grad); |
| 834 |
// grad56 |
| 835 |
grad=Gradient(0,3,270,0); |
| 836 |
grad.m_colors[0]=MWAWColor(0x0c0c0c); |
| 837 |
grad.m_colors[1]=MWAWColor(0x6633ff); |
| 838 |
grad.m_colors[2]=MWAWColor(0x666600); |
| 839 |
m_gradientList.push_back(grad); |
| 840 |
// grad57 |
| 841 |
grad=Gradient(0,4,90,0); |
| 842 |
grad.m_colors[0]=MWAWColor(0x00ff7f); |
| 843 |
grad.m_colors[1]=MWAWColor(0x000000); |
| 844 |
grad.m_colors[2]=MWAWColor(0x000000); |
| 845 |
grad.m_colors[3]=MWAWColor(0xff0000); |
| 846 |
m_gradientList.push_back(grad); |
| 847 |
// grad58 |
| 848 |
grad=Gradient(0,4,0,0); |
| 849 |
grad.m_colors[0]=MWAWColor(0xff794c); |
| 850 |
grad.m_colors[1]=MWAWColor(0xff9999); |
| 851 |
grad.m_colors[2]=MWAWColor(0x00ffff); |
| 852 |
grad.m_colors[3]=MWAWColor(0x6600cc); |
| 853 |
m_gradientList.push_back(grad); |
| 854 |
// grad59 |
| 855 |
grad=Gradient(0,2,45,0.958786f); |
| 856 |
grad.m_colors[0]=MWAWColor(0xffff00); |
| 857 |
grad.m_colors[1]=MWAWColor(0xff00aa); |
| 858 |
m_gradientList.push_back(grad); |
| 859 |
// grad60 |
| 860 |
grad=Gradient(0,4,135,0); |
| 861 |
grad.m_colors[0]=MWAWColor(0x660066); |
| 862 |
grad.m_colors[1]=MWAWColor(0x006099); |
| 863 |
grad.m_colors[2]=MWAWColor(0xff00ff); |
| 864 |
grad.m_colors[3]=MWAWColor(0xff006a); |
| 865 |
m_gradientList.push_back(grad); |
| 866 |
// grad61 |
| 867 |
grad=Gradient(2,3,0,0); |
| 868 |
grad.m_colors[0]=MWAWColor(0xf3f3f3); |
| 869 |
grad.m_colors[1]=MWAWColor(0x99ffff); |
| 870 |
grad.m_colors[2]=MWAWColor(0xff99c4); |
| 871 |
grad.m_box=MWAWBox2i(MWAWVec2i(18,58),MWAWVec2i(25,89)); |
| 872 |
m_gradientList.push_back(grad); |
| 873 |
// grad62 |
| 874 |
grad=Gradient(2,3,0,0); |
| 875 |
grad.m_colors[0]=MWAWColor(0xff006a); |
| 876 |
grad.m_colors[1]=MWAWColor(0x660044); |
| 877 |
grad.m_colors[2]=MWAWColor(0x001f66); |
| 878 |
grad.m_box=MWAWBox2i(MWAWVec2i(0,0),MWAWVec2i(7,100)); |
| 879 |
m_gradientList.push_back(grad); |
| 880 |
// grad63 |
| 881 |
grad=Gradient(1,2,294,0); |
| 882 |
grad.m_colors[0]=MWAWColor(0x0000ff); |
| 883 |
grad.m_colors[1]=MWAWColor(0xccccff); |
| 884 |
grad.m_box=MWAWBox2i(MWAWVec2i(0,13),MWAWVec2i(0,29)); |
| 885 |
m_gradientList.push_back(grad); |
| 886 |
} |
| 887 |
|
| 888 |
void State::initBWPatterns() |
| 889 |
{ |
| 890 |
if (!m_BWPatternList.empty()) return; |
| 891 |
m_BWPatternList.resize(64); |
| 892 |
for (size_t i = 0; i < 64; i++) { |
| 893 |
static uint16_t const s_pattern[4*64] = { |
| 894 |
0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x7fff, 0xffff, 0xf7ff, 0xffff, 0x7fff, 0xf7ff, 0x7fff, 0xf7ff, |
| 895 |
0xffee, 0xffbb, 0xffee, 0xffbb, 0x77dd, 0x77dd, 0x77dd, 0x77dd, 0xaa55, 0xaa55, 0xaa55, 0xaa55, 0x8822, 0x8822, 0x8822, 0x8822, |
| 896 |
0xaa00, 0xaa00, 0xaa00, 0xaa00, 0xaa00, 0x4400, 0xaa00, 0x1100, 0x8800, 0xaa00, 0x8800, 0xaa00, 0x8800, 0x2200, 0x8800, 0x2200, |
| 897 |
0x8000, 0x0800, 0x8000, 0x0800, 0x8800, 0x0000, 0x8800, 0x0000, 0x8000, 0x0000, 0x0800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, |
| 898 |
0xeedd, 0xbb77, 0xeedd, 0xbb77, 0x3366, 0xcc99, 0x3366, 0xcc99, 0x1122, 0x4488, 0x1122, 0x4488, 0x8307, 0x0e1c, 0x3870, 0xe0c1, |
| 899 |
0x0306, 0x0c18, 0x3060, 0xc081, 0x0102, 0x0408, 0x1020, 0x4080, 0xffff, 0x0000, 0x0000, 0x0000, 0xff00, 0x0000, 0x0000, 0x0000, |
| 900 |
0x77bb, 0xddee, 0x77bb, 0xddee, 0x99cc, 0x6633, 0x99cc, 0x6633, 0x8844, 0x2211, 0x8844, 0x2211, 0xe070, 0x381c, 0x0e07, 0x83c1, |
| 901 |
0xc060, 0x3018, 0x0c06, 0x0381, 0x8040, 0x2010, 0x0804, 0x0201, 0xc0c0, 0xc0c0, 0xc0c0, 0xc0c0, 0x8080, 0x8080, 0x8080, 0x8080, |
| 902 |
0xffaa, 0xffaa, 0xffaa, 0xffaa, 0xe4e4, 0xe4e4, 0xe4e4, 0xe4e4, 0xffff, 0xff00, 0x00ff, 0x0000, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa, |
| 903 |
0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0x0000, 0xff00, 0x0000, 0x8888, 0x8888, 0x8888, 0x8888, 0xff80, 0x8080, 0x8080, 0x8080, |
| 904 |
0x4ecf, 0xfce4, 0x273f, 0xf372, 0x6006, 0x36b1, 0x8118, 0x1b63, 0x2004, 0x4002, 0x1080, 0x0801, 0x9060, 0x0609, 0x9060, 0x0609, |
| 905 |
0x8814, 0x2241, 0x8800, 0xaa00, 0x2050, 0x8888, 0x8888, 0x0502, 0xaa00, 0x8000, 0x8800, 0x8000, 0x2040, 0x8000, 0x0804, 0x0200, |
| 906 |
0xf0f0, 0xf0f0, 0x0f0f, 0x0f0f, 0x0077, 0x7777, 0x0077, 0x7777, 0xff88, 0x8888, 0xff88, 0x8888, 0xaa44, 0xaa11, 0xaa44, 0xaa11, |
| 907 |
0x8244, 0x2810, 0x2844, 0x8201, 0x8080, 0x413e, 0x0808, 0x14e3, 0x8142, 0x2418, 0x1020, 0x4080, 0x40a0, 0x0000, 0x040a, 0x0000, |
| 908 |
0x7789, 0x8f8f, 0x7798, 0xf8f8, 0xf1f8, 0x6cc6, 0x8f1f, 0x3663, 0xbf00, 0xbfbf, 0xb0b0, 0xb0b0, 0xff80, 0x8080, 0xff08, 0x0808, |
| 909 |
0x1020, 0x54aa, 0xff02, 0x0408, 0x0008, 0x142a, 0x552a, 0x1408, 0x55a0, 0x4040, 0x550a, 0x0404, 0x8244, 0x3944, 0x8201, 0x0101 |
| 910 |
}; |
| 911 |
MWAWGraphicStyle::Pattern pat; |
| 912 |
pat.m_dim=MWAWVec2i(8,8); |
| 913 |
pat.m_data.resize(8); |
| 914 |
pat.m_colors[0]=MWAWColor::white(); |
| 915 |
pat.m_colors[1]=MWAWColor::black(); |
| 916 |
|
| 917 |
uint16_t const *patPtr=&s_pattern[4*i]; |
| 918 |
for (size_t j=0; j<8; j+=2, ++patPtr) { |
| 919 |
pat.m_data[j]=uint8_t((*patPtr)>>8); |
| 920 |
pat.m_data[j+1]=uint8_t((*patPtr)&0xFF); |
| 921 |
} |
| 922 |
m_BWPatternList[i]=pat; |
| 923 |
} |
| 924 |
} |
| 925 |
|
| 926 |
} |
| 927 |
|
| 928 |
//////////////////////////////////////////////////////////// |
| 929 |
// constructor/destructor, ... |
| 930 |
//////////////////////////////////////////////////////////// |
| 931 |
ClarisDrawStyleManager::ClarisDrawStyleManager(ClarisDrawParser &parser) |
| 932 |
: m_parser(parser) |
| 933 |
, m_parserState(parser.getParserState()) |
| 934 |
, m_state(new ClarisDrawStyleManagerInternal::State) |
| 935 |
{ |
| 936 |
} |
| 937 |
|
| 938 |
ClarisDrawStyleManager::~ClarisDrawStyleManager() |
| 939 |
{ |
| 940 |
} |
| 941 |
|
| 942 |
void ClarisDrawStyleManager::setDefaultNumbers(int nColors, int nGradients) |
| 943 |
{ |
| 944 |
if (nColors==81||nColors==168||nColors==256) { |
| 945 |
m_state->m_numColors=nColors; |
| 946 |
// reset the color, as default font can have create some font |
| 947 |
m_state->m_colorList.clear(); |
| 948 |
} |
| 949 |
else if (nColors) { |
| 950 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::setDefaultNumbers: the number of colors seems bad\n")); |
| 951 |
} |
| 952 |
if (nGradients==32||nGradients==64) |
| 953 |
m_state->m_numGradients=nGradients; |
| 954 |
else if (nGradients) { |
| 955 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::setDefaultNumbers: the number of gradient seems bad\n")); |
| 956 |
} |
| 957 |
} |
| 958 |
//////////////////////////////////////////////////////////// |
| 959 |
// |
| 960 |
// Interface |
| 961 |
// |
| 962 |
//////////////////////////////////////////////////////////// |
| 963 |
bool ClarisDrawStyleManager::getColor(int cId, MWAWColor &color) const |
| 964 |
{ |
| 965 |
m_state->initColors(); |
| 966 |
if (cId<0||cId>=int(m_state->m_colorList.size())) { |
| 967 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::getColor: can not find color %d\n", cId)); |
| 968 |
return false; |
| 969 |
} |
| 970 |
color=m_state->m_colorList[size_t(cId)]; |
| 971 |
return true; |
| 972 |
} |
| 973 |
|
| 974 |
bool ClarisDrawStyleManager::getFont(int fId, MWAWFont &font) const |
| 975 |
{ |
| 976 |
if (fId==0) return false; // none |
| 977 |
if (fId<=0||fId>int(m_state->m_fontList.size())) { |
| 978 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::getFont: can not find font %d\n", fId)); |
| 979 |
return false; |
| 980 |
} |
| 981 |
font=m_state->m_fontList[size_t(fId-1)]; |
| 982 |
return true; |
| 983 |
} |
| 984 |
|
| 985 |
bool ClarisDrawStyleManager::getParagraph(int fId, MWAWParagraph ¶) const |
| 986 |
{ |
| 987 |
if (fId<0||fId>=int(m_state->m_paragraphList.size())) { |
| 988 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::getParagraph: can not find paragraph %d\n", fId)); |
| 989 |
return false; |
| 990 |
} |
| 991 |
para=m_state->m_paragraphList[size_t(fId)]; |
| 992 |
return true; |
| 993 |
} |
| 994 |
|
| 995 |
bool ClarisDrawStyleManager::getDash(int dId, std::vector<float> &dash) const |
| 996 |
{ |
| 997 |
if (dId==0) // a solid line |
| 998 |
return false; |
| 999 |
if (m_state->m_dashList.empty()) |
| 1000 |
m_state->initDashs(); |
| 1001 |
if (dId<=0||dId>int(m_state->m_dashList.size())) { |
| 1002 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::getDash: can not find dash %d\n", dId)); |
| 1003 |
return false; |
| 1004 |
} |
| 1005 |
dash=m_state->m_dashList[size_t(dId-1)]; |
| 1006 |
return true; |
| 1007 |
} |
| 1008 |
|
| 1009 |
bool ClarisDrawStyleManager::getPattern(int pId, MWAWGraphicStyle::Pattern &pattern) const |
| 1010 |
{ |
| 1011 |
if (pId==0) // no pattern |
| 1012 |
return false; |
| 1013 |
|
| 1014 |
m_state->initBWPatterns(); |
| 1015 |
if (pId<=0||pId>int(m_state->m_BWPatternList.size())) { |
| 1016 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::getPattern: can not find BW pattern %d\n", pId)); |
| 1017 |
return false; |
| 1018 |
} |
| 1019 |
pattern=m_state->m_BWPatternList[size_t(pId-1)]; |
| 1020 |
|
| 1021 |
return true; |
| 1022 |
} |
| 1023 |
|
| 1024 |
bool ClarisDrawStyleManager::updateGradient(int gId, MWAWGraphicStyle &style) const |
| 1025 |
{ |
| 1026 |
if (m_state->m_gradientList.empty()) |
| 1027 |
m_state->initGradients(); |
| 1028 |
if (gId<0 || gId>=int(m_state->m_gradientList.size())) { |
| 1029 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::updateGradient: can not find gradient %d\n", gId)); |
| 1030 |
return false; |
| 1031 |
} |
| 1032 |
auto const &gradient=m_state->m_gradientList[size_t(gId)]; |
| 1033 |
if (!gradient.update(style)) return false; |
| 1034 |
// try to update the color list |
| 1035 |
auto &finalGrad=style.m_gradient; |
| 1036 |
size_t numColors=finalGrad.m_stopList.size(); |
| 1037 |
if (numColors<=1) return true; |
| 1038 |
float f=1.f/float(numColors); |
| 1039 |
MWAWColor col=MWAWColor::barycenter(f,finalGrad.m_stopList[0].m_color,f,finalGrad.m_stopList[1].m_color); |
| 1040 |
for (size_t c=2; c<numColors; c++) |
| 1041 |
col=MWAWColor::barycenter(1,col,f,finalGrad.m_stopList[c].m_color); |
| 1042 |
style.setSurfaceColor(col); |
| 1043 |
return true; |
| 1044 |
} |
| 1045 |
|
| 1046 |
//////////////////////////////////////////////////////////// |
| 1047 |
// |
| 1048 |
// Intermediate level |
| 1049 |
// |
| 1050 |
//////////////////////////////////////////////////////////// |
| 1051 |
bool ClarisDrawStyleManager::readFontNames() |
| 1052 |
{ |
| 1053 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1054 |
long pos=input->tell(); |
| 1055 |
if (!input->checkPosition(pos+8)) return false; |
| 1056 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1057 |
libmwaw::DebugStream f; |
| 1058 |
f << "Entries(FNTM):"; |
| 1059 |
ClarisWksStruct::Struct header; |
| 1060 |
if (input->readULong(4) != 0x464e544d || !header.readHeader(input,true)) |
| 1061 |
return false; |
| 1062 |
if (header.m_size==0) { |
| 1063 |
ascFile.addPos(pos); |
| 1064 |
ascFile.addNote("_"); |
| 1065 |
return true; |
| 1066 |
} |
| 1067 |
long endPos=pos+4+header.m_size; |
| 1068 |
f << header; |
| 1069 |
ascFile.addPos(pos); |
| 1070 |
ascFile.addNote(f.str().c_str()); |
| 1071 |
|
| 1072 |
pos=input->tell(); |
| 1073 |
if (header.m_headerSize) { |
| 1074 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1075 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1076 |
} |
| 1077 |
if (header.m_dataSize!=72) { |
| 1078 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1079 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readFontNames: no sure how to read the data\n")); |
| 1080 |
ascFile.addPos(pos); |
| 1081 |
ascFile.addNote("FNTM-data:###"); |
| 1082 |
return true; |
| 1083 |
} |
| 1084 |
|
| 1085 |
for (int i=0; i<int(header.m_numData); ++i) { |
| 1086 |
pos=input->tell(); |
| 1087 |
f.str(""); |
| 1088 |
f << "FNTM-" << i << ":"; |
| 1089 |
auto fId=static_cast<int>(input->readULong(2)); |
| 1090 |
f << "fId=" << fId << ","; |
| 1091 |
auto val=static_cast<int>(input->readULong(2)); // always fId? |
| 1092 |
if (val!=fId) f << "fId2=" << val << ","; |
| 1093 |
for (int j=0; j<2; ++j) { // always 0? |
| 1094 |
val=static_cast<int>(input->readLong(2)); |
| 1095 |
if (val) f << "f" << j << "=" << val << ","; |
| 1096 |
} |
| 1097 |
auto sSz=static_cast<int>(input->readULong(1)); |
| 1098 |
if (!sSz || sSz+9>header.m_dataSize) { // sSz==0 is probably normal |
| 1099 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readFontNames: the string size seems bad\n")); |
| 1100 |
f << "###"; |
| 1101 |
} |
| 1102 |
else { |
| 1103 |
std::string name(""); |
| 1104 |
for (int s=0; s<sSz; ++s) name+=char(input->readULong(1)); |
| 1105 |
f << "'" << name << "'"; |
| 1106 |
m_parserState->m_fontConverter->setCorrespondance(fId, name); |
| 1107 |
} |
| 1108 |
input->seek(pos+header.m_dataSize, librevenge::RVNG_SEEK_SET); |
| 1109 |
ascFile.addPos(pos); |
| 1110 |
ascFile.addNote(f.str().c_str()); |
| 1111 |
} |
| 1112 |
return true; |
| 1113 |
} |
| 1114 |
|
| 1115 |
bool ClarisDrawStyleManager::readFontStyles() |
| 1116 |
{ |
| 1117 |
MWAWInputStreamPtr input = m_parserState->m_input; |
| 1118 |
long pos = input->tell(); |
| 1119 |
ClarisWksStruct::Struct header; |
| 1120 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=40)) { |
| 1121 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1122 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readFontStyles: can not read header\n")); |
| 1123 |
return false; |
| 1124 |
} |
| 1125 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1126 |
libmwaw::DebugStream f; |
| 1127 |
if (header.m_size==0) { |
| 1128 |
ascFile.addPos(pos); |
| 1129 |
ascFile.addNote("_"); |
| 1130 |
return true; |
| 1131 |
} |
| 1132 |
|
| 1133 |
long endPos = pos+4+header.m_size; |
| 1134 |
f << "Entries(FontStyle):" << header; |
| 1135 |
if (header.m_headerSize) { |
| 1136 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1137 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1138 |
} |
| 1139 |
ascFile.addPos(pos); |
| 1140 |
ascFile.addNote(f.str().c_str()); |
| 1141 |
|
| 1142 |
long debPos=input->tell(); |
| 1143 |
for (int i = 0; i < int(header.m_numData); i++) { |
| 1144 |
input->seek(debPos, librevenge::RVNG_SEEK_SET); |
| 1145 |
f.str(""); |
| 1146 |
f << "FontStyle-" << i << ":"; |
| 1147 |
auto fId=static_cast<int>(input->readULong(2)); |
| 1148 |
f << "fId=" << fId << ","; |
| 1149 |
auto val=static_cast<int>(input->readULong(2)); // always fId? |
| 1150 |
if (val!=fId) f << "fId2=" << val << ","; |
| 1151 |
val=static_cast<int>(input->readULong(2)); |
| 1152 |
if (val) f << "size=" << val << ","; |
| 1153 |
val=static_cast<int>(input->readULong(2)); |
| 1154 |
if (val!=0x2001) |
| 1155 |
f << "fl=" << std::hex << val << std::dec << ","; |
| 1156 |
auto sSz=static_cast<int>(input->readULong(1)); |
| 1157 |
if (!sSz || sSz+9>header.m_dataSize) { |
| 1158 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readFontStyles: the string size seems bad\n")); |
| 1159 |
f << "###"; |
| 1160 |
} |
| 1161 |
else { |
| 1162 |
std::string name(""); |
| 1163 |
for (int s=0; s<sSz; ++s) name+=char(input->readULong(1)); |
| 1164 |
f << "'" << name << "'"; |
| 1165 |
} |
| 1166 |
ascFile.addPos(debPos); |
| 1167 |
ascFile.addNote(f.str().c_str()); |
| 1168 |
debPos += header.m_dataSize; |
| 1169 |
} |
| 1170 |
input->seek(endPos,librevenge::RVNG_SEEK_SET); |
| 1171 |
return true; |
| 1172 |
} |
| 1173 |
|
| 1174 |
//////////////////////////////////////////////////////////// |
| 1175 |
// styles/settings present in data/rsrc fork |
| 1176 |
//////////////////////////////////////////////////////////// |
| 1177 |
|
| 1178 |
bool ClarisDrawStyleManager::readArrows() |
| 1179 |
{ |
| 1180 |
MWAWInputStreamPtr input = m_parserState->m_input; |
| 1181 |
long pos=input->tell(); |
| 1182 |
ClarisWksStruct::Struct header; |
| 1183 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1184 |
libmwaw::DebugStream f; |
| 1185 |
f << "Entries(Arrow):"; |
| 1186 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=20)) { |
| 1187 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readArrows: the data size seems bad\n")); |
| 1188 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1189 |
f << "###"; |
| 1190 |
ascFile.addPos(pos); |
| 1191 |
ascFile.addNote(f.str().c_str()); |
| 1192 |
return false; |
| 1193 |
} |
| 1194 |
|
| 1195 |
if (header.m_dataSize==0) { |
| 1196 |
ascFile.addPos(pos); |
| 1197 |
ascFile.addNote("_"); |
| 1198 |
return true; |
| 1199 |
} |
| 1200 |
long endPos=pos+4+header.m_size; |
| 1201 |
f << header; |
| 1202 |
if (header.m_headerSize) { |
| 1203 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1204 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1205 |
} |
| 1206 |
|
| 1207 |
ascFile.addPos(pos); |
| 1208 |
ascFile.addNote(f.str().c_str()); |
| 1209 |
for (int i=0; i<int(header.m_numData); ++i) { |
| 1210 |
pos=input->tell(); |
| 1211 |
f.str(""); |
| 1212 |
f << "Arrow-A" << i+1 << ","; |
| 1213 |
double value; |
| 1214 |
bool isNAN; |
| 1215 |
if (!input->readDouble8(value, isNAN)) |
| 1216 |
f << "###,"; |
| 1217 |
else |
| 1218 |
f << value << ","; |
| 1219 |
long val=input->readLong(4); |
| 1220 |
if (val) f<<"id=" << val << ","; |
| 1221 |
float pt[2]; // position of the symetric point in the arrow head |
| 1222 |
for (auto &p : pt) p=float(input->readULong(4))/256.f; |
| 1223 |
f << "pt=" << pt[1] << "x" << pt[0] << ","; |
| 1224 |
ascFile.addPos(pos); |
| 1225 |
ascFile.addNote(f.str().c_str()); |
| 1226 |
} |
| 1227 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1228 |
return true; |
| 1229 |
} |
| 1230 |
|
| 1231 |
bool ClarisDrawStyleManager::readDashs() |
| 1232 |
{ |
| 1233 |
MWAWInputStreamPtr input = m_parserState->m_input; |
| 1234 |
long pos=input->tell(); |
| 1235 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1236 |
libmwaw::DebugStream f; |
| 1237 |
f << "Entries(Dash):"; |
| 1238 |
ClarisWksStruct::Struct header; |
| 1239 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=28)) { |
| 1240 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readDashs: the data size seems bad\n")); |
| 1241 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1242 |
f << "###"; |
| 1243 |
ascFile.addPos(pos); |
| 1244 |
ascFile.addNote(f.str().c_str()); |
| 1245 |
return false; |
| 1246 |
} |
| 1247 |
if (header.m_size==0) { |
| 1248 |
ascFile.addPos(pos); |
| 1249 |
ascFile.addNote("_"); |
| 1250 |
return true; |
| 1251 |
} |
| 1252 |
long endPos=pos+4+header.m_size; |
| 1253 |
f << header; |
| 1254 |
if (header.m_headerSize) { |
| 1255 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1256 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1257 |
} |
| 1258 |
ascFile.addPos(pos); |
| 1259 |
ascFile.addNote(f.str().c_str()); |
| 1260 |
|
| 1261 |
for (int i=0; i<int(header.m_numData); ++i) { |
| 1262 |
pos=input->tell(); |
| 1263 |
f.str(""); |
| 1264 |
f << "Dash-D" << i+1 << ","; |
| 1265 |
long val=input->readLong(4); |
| 1266 |
if (val!=1) f<<"numUsed=" << val << ","; |
| 1267 |
f << "dash=["; |
| 1268 |
std::vector<float> dash; |
| 1269 |
for (int k=0; k<3; ++k) { |
| 1270 |
auto solid=long(input->readULong(4)); |
| 1271 |
auto empty=long(input->readULong(4)); |
| 1272 |
if (!solid && !empty) continue; |
| 1273 |
dash.push_back(float(solid)/65536.f); |
| 1274 |
dash.push_back(float(empty)/65536.f); |
| 1275 |
f << double(solid)/65536. << "x" << double(empty)/65536. << ","; |
| 1276 |
} |
| 1277 |
m_state->m_dashList.push_back(dash); |
| 1278 |
f << "],"; |
| 1279 |
ascFile.addPos(pos); |
| 1280 |
ascFile.addNote(f.str().c_str()); |
| 1281 |
} |
| 1282 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1283 |
return true; |
| 1284 |
} |
| 1285 |
|
| 1286 |
bool ClarisDrawStyleManager::readRulers() |
| 1287 |
{ |
| 1288 |
MWAWInputStreamPtr input = m_parserState->m_input; |
| 1289 |
long pos=input->tell(); |
| 1290 |
ClarisWksStruct::Struct header; |
| 1291 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1292 |
libmwaw::DebugStream f; |
| 1293 |
f << "Entries(RulerStyle):"; |
| 1294 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=28)) { |
| 1295 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readRulers: the data size seems bad\n")); |
| 1296 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1297 |
f << "###"; |
| 1298 |
ascFile.addPos(pos); |
| 1299 |
ascFile.addNote(f.str().c_str()); |
| 1300 |
return false; |
| 1301 |
} |
| 1302 |
if (header.m_dataSize==0) { |
| 1303 |
ascFile.addPos(pos); |
| 1304 |
ascFile.addNote("_"); |
| 1305 |
return true; |
| 1306 |
} |
| 1307 |
long endPos=pos+4+header.m_size; |
| 1308 |
f << header; |
| 1309 |
if (header.m_headerSize) { |
| 1310 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1311 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1312 |
} |
| 1313 |
ascFile.addPos(pos); |
| 1314 |
ascFile.addNote(f.str().c_str()); |
| 1315 |
for (int i=0; i<int(header.m_numData); ++i) { |
| 1316 |
pos=input->tell(); |
| 1317 |
f.str(""); |
| 1318 |
f << "RulerStyle-R" << i+1 << ":"; |
| 1319 |
auto numUsed=static_cast<int>(input->readULong(4)); |
| 1320 |
if (numUsed!=1) f << "numUsed=" << numUsed << ","; |
| 1321 |
for (int j=0; j<2; ++j) { |
| 1322 |
double value; |
| 1323 |
bool isNAN; |
| 1324 |
if (!input->readDouble10(value, isNAN)) |
| 1325 |
f << "###,"; |
| 1326 |
else |
| 1327 |
f << value << ","; |
| 1328 |
} |
| 1329 |
f << "num[subd]=" << input->readULong(2) << ","; |
| 1330 |
f << "fl=" << std::hex << input->readULong(2) << std::dec << ","; |
| 1331 |
ascFile.addPos(pos); |
| 1332 |
ascFile.addNote(f.str().c_str()); |
| 1333 |
} |
| 1334 |
input->seek(endPos, librevenge::RVNG_SEEK_SET); |
| 1335 |
return true; |
| 1336 |
} |
| 1337 |
|
| 1338 |
//////////////////////////////////////////////////////////// |
| 1339 |
// read file main structure |
| 1340 |
//////////////////////////////////////////////////////////// |
| 1341 |
bool ClarisDrawStyleManager::readColorList() |
| 1342 |
{ |
| 1343 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1344 |
long pos=input->tell(); |
| 1345 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1346 |
libmwaw::DebugStream f; |
| 1347 |
f << "Entries(ColorList):"; |
| 1348 |
ClarisWksStruct::Struct header; |
| 1349 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=6)) { |
| 1350 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readColorList: the data size seems bad\n")); |
| 1351 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1352 |
f << "###"; |
| 1353 |
ascFile.addPos(pos); |
| 1354 |
ascFile.addNote(f.str().c_str()); |
| 1355 |
return false; |
| 1356 |
} |
| 1357 |
if (header.m_size==0) { |
| 1358 |
ascFile.addPos(pos); |
| 1359 |
ascFile.addNote("_"); |
| 1360 |
return true; |
| 1361 |
} |
| 1362 |
long endPos=pos+4+header.m_size; |
| 1363 |
f << header; |
| 1364 |
if (header.m_headerSize) { |
| 1365 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1366 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1367 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1368 |
} |
| 1369 |
// only set color if the color numbering is unknown: ie. something this set is not the final set... |
| 1370 |
bool setColor=m_state->m_numColors==0; |
| 1371 |
if (setColor) |
| 1372 |
m_state->m_colorList.clear(); |
| 1373 |
for (int i=0; i < int(header.m_numData); ++i) { |
| 1374 |
unsigned char color[3]; |
| 1375 |
for (auto &col : color) col = static_cast<unsigned char>(input->readULong(2)/256); |
| 1376 |
MWAWColor col(color[0], color[1],color[2]); |
| 1377 |
f << col << ","; |
| 1378 |
if (setColor) |
| 1379 |
m_state->m_colorList.push_back(col); |
| 1380 |
} |
| 1381 |
ascFile.addPos(pos); |
| 1382 |
ascFile.addNote(f.str().c_str()); |
| 1383 |
input->seek(endPos,librevenge::RVNG_SEEK_SET); |
| 1384 |
return true; |
| 1385 |
} |
| 1386 |
|
| 1387 |
bool ClarisDrawStyleManager::readPatternList() |
| 1388 |
{ |
| 1389 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1390 |
long pos=input->tell(); |
| 1391 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1392 |
libmwaw::DebugStream f; |
| 1393 |
f << "Entries(PatternList):"; |
| 1394 |
ClarisWksStruct::Struct header; |
| 1395 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=8)) { |
| 1396 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readPatternList: the data size seems bad\n")); |
| 1397 |
input->seek(pos, librevenge::RVNG_SEEK_SET); |
| 1398 |
f << "###"; |
| 1399 |
ascFile.addPos(pos); |
| 1400 |
ascFile.addNote(f.str().c_str()); |
| 1401 |
return false; |
| 1402 |
} |
| 1403 |
if (header.m_size==0) { |
| 1404 |
ascFile.addPos(pos); |
| 1405 |
ascFile.addNote("_"); |
| 1406 |
return true; |
| 1407 |
} |
| 1408 |
long endPos=pos+4+header.m_size; |
| 1409 |
f << header; |
| 1410 |
if (header.m_headerSize) { |
| 1411 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1412 |
input->seek(header.m_headerSize, librevenge::RVNG_SEEK_CUR); |
| 1413 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1414 |
} |
| 1415 |
m_state->initBWPatterns(); |
| 1416 |
for (int i=0; i < int(header.m_numData); ++i) { |
| 1417 |
MWAWGraphicStyle::Pattern pattern; |
| 1418 |
pattern.m_colors[0]=MWAWColor::white(); |
| 1419 |
pattern.m_colors[1]=MWAWColor::black(); |
| 1420 |
pattern.m_dim=MWAWVec2i(8,8); |
| 1421 |
pattern.m_data.resize(8); |
| 1422 |
for (auto &data : pattern.m_data) data=static_cast<uint8_t>(input->readULong(1)); |
| 1423 |
m_state->m_BWPatternList.push_back(pattern); |
| 1424 |
f << "pat" << i+64 << "=[" << pattern << "],"; |
| 1425 |
} |
| 1426 |
ascFile.addPos(pos); |
| 1427 |
ascFile.addNote(f.str().c_str()); |
| 1428 |
input->seek(endPos,librevenge::RVNG_SEEK_SET); |
| 1429 |
return true; |
| 1430 |
} |
| 1431 |
|
| 1432 |
bool ClarisDrawStyleManager::readGradientList() |
| 1433 |
{ |
| 1434 |
MWAWInputStreamPtr &input= m_parserState->m_input; |
| 1435 |
long pos=input->tell(); |
| 1436 |
libmwaw::DebugFile &ascFile = m_parserState->m_asciiFile; |
| 1437 |
libmwaw::DebugStream f; |
| 1438 |
f << "Entries(GradientList):"; |
| 1439 |
ClarisWksStruct::Struct header; |
| 1440 |
if (!header.readHeader(input,false) || (header.m_size && header.m_dataSize!=0x28)) { |
| 1441 |
f << "###"; |
| 1442 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readGradientList: can read pattern size\n")); |
| 1443 |
ascFile.addPos(pos); |
| 1444 |
ascFile.addNote(f.str().c_str()); |
| 1445 |
input->seek(pos,librevenge::RVNG_SEEK_SET); |
| 1446 |
return false; |
| 1447 |
} |
| 1448 |
if (header.m_size==0) { |
| 1449 |
ascFile.addPos(pos); |
| 1450 |
ascFile.addNote("_"); |
| 1451 |
return true; |
| 1452 |
} |
| 1453 |
long endPos=pos+4+header.m_size; |
| 1454 |
f << header; |
| 1455 |
auto const numDefGrad=int(header.m_headerSize/2); |
| 1456 |
if (numDefGrad!=32 && numDefGrad!=64) { |
| 1457 |
f << "###"; |
| 1458 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readGradientList: unexpected pattern size\n")); |
| 1459 |
ascFile.addDelimiter(input->tell(),'|'); |
| 1460 |
ascFile.addPos(pos); |
| 1461 |
ascFile.addNote(f.str().c_str()); |
| 1462 |
input->seek(endPos,librevenge::RVNG_SEEK_SET); |
| 1463 |
return true; |
| 1464 |
} |
| 1465 |
for (int i=0; i < numDefGrad; ++i) { |
| 1466 |
auto val= int(input->readLong(2)); |
| 1467 |
if (val!=i) f << "grad" << i << "=" << val << ","; |
| 1468 |
} |
| 1469 |
|
| 1470 |
ascFile.addPos(pos); |
| 1471 |
ascFile.addNote(f.str().c_str()); |
| 1472 |
m_state->m_numGradients=numDefGrad; |
| 1473 |
m_state->initGradients(); |
| 1474 |
for (int i=0; i < int(header.m_numData); ++i) { |
| 1475 |
pos=input->tell(); |
| 1476 |
f.str(""); |
| 1477 |
f << "GradientList-" << numDefGrad+i << ":"; |
| 1478 |
ClarisDrawStyleManagerInternal::Gradient grad; |
| 1479 |
for (auto &j : grad.m_colors) { |
| 1480 |
unsigned char color[3]; |
| 1481 |
for (auto &col : color) col = static_cast<unsigned char>(input->readULong(2)/256); |
| 1482 |
j= MWAWColor(color[0], color[1],color[2]); |
| 1483 |
} |
| 1484 |
grad.m_numColors=static_cast<int>(input->readLong(1)); |
| 1485 |
grad.m_type=static_cast<int>(input->readLong(1)); |
| 1486 |
grad.m_angle=static_cast<int>(input->readLong(2)); |
| 1487 |
grad.m_decal=float(input->readLong(4))/65536.f; |
| 1488 |
int dim[4]; |
| 1489 |
for (auto &d : dim) d=static_cast<int>(input->readLong(2)); |
| 1490 |
grad.m_box=MWAWBox2i(MWAWVec2i(dim[0],dim[1]),MWAWVec2i(dim[2],dim[3])); |
| 1491 |
f << grad; |
| 1492 |
if (!grad.ok()) { |
| 1493 |
f << "##"; |
| 1494 |
MWAW_DEBUG_MSG(("ClarisDrawStyleManager::readGradientList: can read the number of color or type\n")); |
| 1495 |
ascFile.addPos(pos); |
| 1496 |
ascFile.addNote(f.str().c_str()); |
| 1497 |
input->seek(endPos,librevenge::RVNG_SEEK_SET); |
| 1498 |
return true; |
| 1499 |
} |
| 1500 |
m_state->m_gradientList.push_back(grad); |
| 1501 |
ascFile.addPos(pos); |
| 1502 |
ascFile.addNote(f.str().c_str()); |
| 1503 |
input->seek(pos+40, librevenge::RVNG_SEEK_SET); |
| 1504 |
} |
| 1505 |
input->seek(endPos,librevenge::RVNG_SEEK_SET); |
| 1506 |
return true; |
| 1507 |
} |
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |