2
Copyright (C) 2000, S.R.Haque <shaheedhaque@hotmail.com>.
3
This file is part of the KDE project
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
24
#include <qdatastream.h>
27
#include <qpointarray.h>
38
m_images.setAutoDelete(true);
39
m_opt = new Options(*this);
46
delete [] m_shape.data;
53
QDataStream &operands)
55
static const char *funcTab[] =
58
"RECTANGLE", // Rectangle
59
"ROUNDRECTANGLE", // Roundrectangle
62
"ISOCELESTRIANGLE", // Isocelestriangle
63
"RIGHTTRIANGLE", // Righttriangle
64
"PARALLELOGRAM", // Parallelogram
65
"TRAPEZOID", // Trapezoid
71
"THICKARROW", // Thickarrow
72
"HOMEPLATE", // Homeplate
81
"TEXTSIMPLE", // Textsimple
82
"TEXTOCTAGON", // Textoctagon
83
"TEXTHEXAGON", // Texthexagon
84
"TEXTCURVE", // Textcurve
85
"TEXTWAVE", // Textwave
86
"TEXTRING", // Textring
87
"TEXTONCURVE", // Textoncurve
88
"TEXTONRING", // Textonring
89
"STRAIGHTCONNECTOR1", // Straightconnector1
90
"BENTCONNECTOR2", // Bentconnector2
91
"BENTCONNECTOR3", // Bentconnector3
92
"BENTCONNECTOR4", // Bentconnector4
93
"BENTCONNECTOR5", // Bentconnector5
94
"CURVEDCONNECTOR2", // Curvedconnector2
95
"CURVEDCONNECTOR3", // Curvedconnector3
96
"CURVEDCONNECTOR4", // Curvedconnector4
97
"CURVEDCONNECTOR5", // Curvedconnector5
98
"CALLOUT1", // Callout1
99
"CALLOUT2", // Callout2
100
"CALLOUT3", // Callout3
101
"ACCENTCALLOUT1", // Accentcallout1
102
"ACCENTCALLOUT2", // Accentcallout2
103
"ACCENTCALLOUT3", // Accentcallout3
104
"BORDERCALLOUT1", // bordercallout1
105
"BORDERCALLOUT2", // Bordercallout2
106
"BORDERCALLOUT3", // Bordercallout3
107
"ACCENTBORDERCALLOUT1", // Accentbordercallout1
108
"ACCENTBORDERCALLOUT2", // Accentbordercallout2
109
"ACCENTBORDERCALLOUT3", // Accentbordercallout3
111
"RIBBON2", // Ribbon2
112
"CHEVRON", // Chevron
113
"PENTAGON", // Pentagon
114
"NOSMOKING", // Nosmoking
118
"WEDGERECTCALLOUT", // Wedgerectcallout
119
"WEDGERRECTCALLOUT", // Wedgerrectcallout
120
"WEDGEELLIPSECALLOUT", // Wedgeellipsecallout
122
"FOLDEDCORNER", // Foldedcorner
123
"LEFTARROW", // Leftarrow
124
"DOWNARROW", // Downarrow
125
"UPARROW", // Uparrow
126
"LEFTRIGHTARROW", // Leftrightarrow
127
"UPDOWNARROW", // Updownarrow
128
"IRREGULARSEAL1", // Irregularseal1
129
"IRREGULARSEAL2", // Irregularseal2
130
"LIGHTNINGBOLT", // Lightningbolt
132
"PICTUREFRAME", // PictureFrame
133
"QUADARROW", // Quadarrow
134
"LEFTARROWCALLOUT", // Leftarrowcallout
135
"RIGHTARROWCALLOUT", // Rightarrowcallout
136
"UPARROWCALLOUT", // Uparrowcallout
137
"DOWNARROWCALLOUT", // Downarrowcallout
138
"LEFTRIGHTARROWCALLOUT", // Leftrightarrowcallout
139
"UPDOWNARROWCALLOUT", // Updownarrowcallout
140
"QUADARROWCALLOUT", // Quadarrowcallout
142
"LEFTBRACKET", // Leftbracket
143
"RIGHTBRACKET", // Rightbracket
144
"LEFTBRACE", // Leftbrace
145
"RIGHTBRACE", // Rightbrace
146
"LEFTUPARROW", // Leftuparrow
147
"BENTUPARROW", // Bentuparrow
148
"BENTARROW", // Bentarrow
150
"STRIPEDRIGHTARROW", // Stripedrightarrow
151
"NOTCHEDRIGHTARROW", // Notchedrightarrow
152
"BLOCKARC", // Blockarc
153
"SMILEYFACE", // Smileyface
154
"VERTICALSCROLL", // Verticalscroll
155
"HORIZONTALSCROLL", // Horizontalscroll
156
"CIRCULARARROW", // Circulararrow
157
"NOTCHEDCIRCULARARROW", // Notchedcirculararrow
158
"UTURNARROW", // Uturnarrow
159
"CURVEDRIGHTARROW", // Curvedrightarrow
160
"CURVEDLEFTARROW", // Curvedleftarrow
161
"CURVEDUPARROW", // Curveduparrow
162
"CURVEDDOWNARROW", // Curveddownarrow
163
"CLOUDCALLOUT", // Cloudcallout
164
"ELLIPSERIBBON", // Ellipseribbon
165
"ELLIPSERIBBON2", // Ellipseribbon2
166
"FLOWCHARTPROCESS", // Flowchartprocess
167
"FLOWCHARTDECISION", // Flowchartdecision
168
"FLOWCHARTINPUTOUTPUT", // Flowchartinputoutput
169
"FLOWCHARTPREDEFINEDPROCESS", // Flowchartpredefinedprocess
170
"FLOWCHARTINTERNALSTORAGE", // Flowchartinternalstorage
171
"FLOWCHARTDOCUMENT", // Flowchartdocument
172
"FLOWCHARTMULTIDOCUMENT", // Flowchartmultidocument
173
"FLOWCHARTTERMINATOR", // Flowchartterminator
174
"FLOWCHARTPREPARATION", // Flowchartpreparation
175
"FLOWCHARTMANUALINPUT", // Flowchartmanualinput
176
"FLOWCHARTMANUALOPERATION", // Flowchartmanualoperation
177
"FLOWCHARTCONNECTOR", // Flowchartconnector
178
"FLOWCHARTPUNCHEDCARD", // Flowchartpunchedcard
179
"FLOWCHARTPUNCHEDTAPE", // Flowchartpunchedtape
180
"FLOWCHARTSUMMINGJUNCTION", // Flowchartsummingjunction
181
"FLOWCHARTOR", // Flowchartor
182
"FLOWCHARTCOLLATE", // Flowchartcollate
183
"FLOWCHARTSORT", // Flowchartsort
184
"FLOWCHARTEXTRACT", // Flowchartextract
185
"FLOWCHARTMERGE", // Flowchartmerge
186
"FLOWCHARTOFFLINESTORAGE", // Flowchartofflinestorage
187
"FLOWCHARTONLINESTORAGE", // Flowchartonlinestorage
188
"FLOWCHARTMAGNETICTAPE", // Flowchartmagnetictape
189
"FLOWCHARTMAGNETICDISK", // Flowchartmagneticdisk
190
"FLOWCHARTMAGNETICDRUM", // Flowchartmagneticdrum
191
"FLOWCHARTDISPLAY", // Flowchartdisplay
192
"FLOWCHARTDELAY", // Flowchartdelay
193
"TEXTPLAINTEXT", // Textplaintext
194
"TEXTSTOP", // Textstop
195
"TEXTTRIANGLE", // Texttriangle
196
"TEXTTRIANGLEINVERTED", // Texttriangleinverted
197
"TEXTCHEVRON", // Textchevron
198
"TEXTCHEVRONINVERTED", // Textchevroninverted
199
"TEXTRINGINSIDE", // Textringinside
200
"TEXTRINGOUTSIDE", // Textringoutside
201
"TEXTARCHUPCURVE", // Textarchupcurve
202
"TEXTARCHDOWNCURVE", // Textarchdowncurve
203
"TEXTCIRCLECURVE", // Textcirclecurve
204
"TEXTBUTTONCURVE", // Textbuttoncurve
205
"TEXTARCHUPPOUR", // Textarchuppour
206
"TEXTARCHDOWNPOUR", // Textarchdownpour
207
"TEXTCIRCLEPOUR", // Textcirclepour
208
"TEXTBUTTONPOUR", // Textbuttonpour
209
"TEXTCURVEUP", // Textcurveup
210
"TEXTCURVEDOWN", // Textcurvedown
211
"TEXTCASCADEUP", // Textcascadeup
212
"TEXTCASCADEDOWN", // Textcascadedown
213
"TEXTWAVE1", // Textwave1
214
"TEXTWAVE2", // Textwave2
215
"TEXTWAVE3", // Textwave3
216
"TEXTWAVE4", // Textwave4
217
"TEXTINFLATE", // Textinflate
218
"TEXTDEFLATE", // Textdeflate
219
"TEXTINFLATEBOTTOM", // Textinflatebottom
220
"TEXTDEFLATEBOTTOM", // Textdeflatebottom
221
"TEXTINFLATETOP", // Textinflatetop
222
"TEXTDEFLATETOP", // Textdeflatetop
223
"TEXTDEFLATEINFLATE", // Textdeflateinflate
224
"TEXTDEFLATEINFLATEDEFLATE", // Textdeflateinflatedeflate
225
"TEXTFADERIGHT", // Textfaderight
226
"TEXTFADELEFT", // Textfadeleft
227
"TEXTFADEUP", // Textfadeup
228
"TEXTFADEDOWN", // Textfadedown
229
"TEXTSLANTUP", // Textslantup
230
"TEXTSLANTDOWN", // Textslantdown
231
"TEXTCANUP", // Textcanup
232
"TEXTCANDOWN", // Textcandown
233
"FLOWCHARTALTERNATEPROCESS", // Flowchartalternateprocess
234
"FLOWCHARTOFFPAGECONNECTOR", // Flowchartoffpageconnector
235
"CALLOUT90", // Callout90
236
"ACCENTCALLOUT90", // Accentcallout90
237
"BORDERCALLOUT90", // Bordercallout90
238
"ACCENTBORDERCALLOUT90", // Accentbordercallout90
239
"LEFTRIGHTUPARROW", // Leftrightuparrow
242
"BRACKETPAIR", // Bracketpair
243
"BRACEPAIR", // Bracepair
245
"DOUBLEWAVE", // Doublewave
246
"ACTIONBUTTONBLANK", // Actionbuttonblank
247
"ACTIONBUTTONHOME", // Actionbuttonhome
248
"ACTIONBUTTONHELP", // Actionbuttonhelp
249
"ACTIONBUTTONINFORMATION", // Actionbuttoninformation
250
"ACTIONBUTTONFORWARDNEXT", // Actionbuttonforwardnext
251
"ACTIONBUTTONBACKPREVIOUS", // Actionbuttonbackprevious
252
"ACTIONBUTTONEND", // Actionbuttonend
253
"ACTIONBUTTONBEGINNING", // Actionbuttonbeginning
254
"ACTIONBUTTONRETURN", // Actionbuttonreturn
255
"ACTIONBUTTONDOCUMENT", // Actionbuttondocument
256
"ACTIONBUTTONSOUND", // Actionbuttonsound
257
"ACTIONBUTTONMOVIE", // Actionbuttonmovie
258
"HOSTCONTROL", // Hostcontrol
259
"TEXTBOX", // Textbox
263
U32 spid; // The shape id
269
U32 fGroup : 1; // This shape is a group shape
270
U32 fChild : 1; // Not a top-level shape
271
U32 fPatriarch : 1; // This is the topmost group shape.
272
// Exactly one of these per drawing.
273
U32 fDeleted : 1; // The shape has been deleted
274
U32 fOleShape : 1; // The shape is an OLE object
275
U32 fHaveMaster : 1; // Shape has a hspMaster property
276
U32 fFlipH : 1; // Shape is flipped horizontally
277
U32 fFlipV : 1; // Shape is flipped vertically
278
U32 fConnector : 1; // Connector type of shape
279
U32 fHaveAnchor : 1; // Shape has an anchor of some kind
280
U32 fBackground : 1; // Background shape
281
U32 fHaveSpt : 1; // Shape has a shape type property
282
U32 reserved : 20; // Not yet used
287
// Scan lookup table for operation.
289
operands >> data.spid >> data.grfPersistent.info;
290
bytes -= sizeof(data);
291
kdDebug(s_area) << "shape-id: " << data.spid << " type: " << funcTab[shapeType] << " (" << shapeType << ")" <<
292
(data.grfPersistent.fields.fGroup ? " group" : "") <<
293
(data.grfPersistent.fields.fChild ? " child" : "") <<
294
(data.grfPersistent.fields.fPatriarch ? " patriarch" : "") <<
295
(data.grfPersistent.fields.fDeleted ? " deleted" : "") <<
296
(data.grfPersistent.fields.fOleShape ? " oleshape" : "") <<
297
(data.grfPersistent.fields.fHaveMaster ? " master" : "") <<
298
(data.grfPersistent.fields.fFlipH ? " flipv" : "") <<
299
(data.grfPersistent.fields.fConnector ? " connector" : "") <<
300
(data.grfPersistent.fields.fHaveAnchor ? " anchor" : "") <<
301
(data.grfPersistent.fields.fBackground ? " background" : "") <<
302
(data.grfPersistent.fields.fHaveSpt ? " spt" : "") <<
303
" operands: " << bytes << endl;
304
if (data.grfPersistent.fields.fDeleted)
306
if ((!m_isRequiredDrawing) && (m_requestedShapeId != data.spid))
309
// An active shape! Let's draw it...
314
if (m_opt->m_pVertices)
316
gotPolyline(m_dc, *m_opt->m_pVertices);
325
topLeft = normalisePoint(operands);
326
size = normaliseSize(operands);
328
QRect rect(topLeft, size);
329
QPointArray points(4);
331
points.setPoint(0, topLeft);
332
points.setPoint(1, rect.topRight());
333
points.setPoint(2, rect.bottomRight());
334
points.setPoint(3, rect.bottomLeft());
335
gotRectangle(m_dc, points);
343
lineTo = normalisePoint(operands);
345
QPointArray points(2);
347
points.setPoint(0, lineFrom);
348
points.setPoint(1, lineTo);
349
gotPolyline(m_dc, points);
357
void Msod::invokeHandler(
360
QDataStream &operands)
362
typedef void (Msod::*method)(Header &op, U32 bytes, QDataStream &operands);
367
unsigned short opcode;
371
static const opcodeEntry funcTab[] =
373
{ "ALIGNRULE", 0xF013, &Msod::opAlignrule },
374
{ "ANCHOR", 0xF00E, &Msod::opAnchor },
375
{ "ARCRULE", 0xF014, &Msod::opArcrule },
376
{ "BSE", 0xF007, &Msod::opBse },
377
{ "BSTORECONTAINER", 0xF001, &Msod::opBstorecontainer },
378
{ "CALLOUTRULE", 0xF017, &Msod::opCalloutrule },
379
{ "CHILDANCHOR", 0xF00F, &Msod::opChildanchor },
380
{ "CLIENTANCHOR", 0xF010, &Msod::opClientanchor },
381
{ "CLIENTDATA", 0xF011, &Msod::opClientdata },
382
{ "CLIENTRULE", 0xF015, &Msod::opClientrule },
383
{ "CLIENTTEXTBOX", 0xF00D, &Msod::opClienttextbox },
384
{ "CLSID", 0xF016, &Msod::opClsid },
385
{ "COLORMRU", 0xF11A, &Msod::opColormru },
386
{ "CONNECTORRULE", 0xF012, &Msod::opConnectorrule },
387
{ "DELETEDPSPL", 0xF11D, &Msod::opDeletedpspl },
388
{ "DG", 0xF008, &Msod::opDg },
389
{ "DGCONTAINER", 0xF002, &Msod::opDgcontainer },
390
{ "DGG", 0xF006, &Msod::opDgg },
391
{ "DGGCONTAINER", 0xF000, &Msod::opDggcontainer },
392
{ "OLEOBJECT", 0xF11F, &Msod::opOleobject },
393
{ "OPT", 0xF00B, &Msod::opOpt },
394
{ "REGROUPITEMS", 0xF118, &Msod::opRegroupitems },
395
{ "SELECTION", 0xF119, &Msod::opSelection },
396
{ "SOLVERCONTAINER", 0xF005, &Msod::opSolvercontainer },
397
{ "SP", 0xF00A, &Msod::opSp },
398
{ "SPCONTAINER", 0xF004, &Msod::opSpcontainer },
399
{ "SPGR", 0xF009, &Msod::opSpgr },
400
{ "SPGRCONTAINER", 0xF003, &Msod::opSpgrcontainer },
401
{ "SPLITMENUCOLORS", 0xF11E, &Msod::opSplitmenucolors },
402
{ "TEXTBOX", 0xF00C, &Msod::opTextbox },
404
{ "BLIP", 0, &Msod::opBlip }
409
// Scan lookup table for operation.
411
for (i = 0; funcTab[i].name; i++)
413
if (funcTab[i].opcode == op.opcode.fields.fbt)
421
result = funcTab[i].handler;
422
if (!result && (op.opcode.fields.fbt >= 0xF018) && (0xF117 >= op.opcode.fields.fbt))
423
result = funcTab[++i].handler;
427
kdWarning(s_area) << "invokeHandler: unsupported opcode: " <<
429
" operands: " << bytes << endl;
431
kdWarning(s_area) << "invokeHandler: unsupported opcode: 0x" <<
432
QString::number(op.opcode.fields.fbt, 16) <<
433
" operands: " << bytes << endl;
435
// Skip data we cannot use.
437
skip(bytes, operands);
441
kdDebug(s_area) << "invokeHandler: opcode: " << funcTab[i].name <<
442
" operands: " << bytes << endl;
443
(this->*result)(op, bytes, operands);
447
QPoint Msod::normalisePoint(
448
QDataStream &operands)
454
return QPoint(x / m_dpi, y / m_dpi);
457
QSize Msod::normaliseSize(
458
QDataStream &operands)
463
operands >> width >> height;
464
return QSize(width / m_dpi, height / m_dpi);
470
const char *delayStream)
473
if (!in.open(IO_ReadOnly))
475
kdError(s_area) << "Unable to open input file!" << endl;
479
QDataStream stream(&in);
480
bool result = parse(shapeId, stream, in.size(), delayStream);
489
const char *delayStream)
491
stream.setByteOrder(QDataStream::LittleEndian); // Great, I love Qt !
492
m_requestedShapeId = shapeId;
493
m_isRequiredDrawing = false;
494
m_delayStream = delayStream;
506
walk(size - m_dggError, stream);
510
void Msod::opAlignrule(
513
QDataStream &operands)
515
skip(bytes, operands);
521
QDataStream &operands)
523
skip(bytes, operands);
526
void Msod::opArcrule(
529
QDataStream &operands)
531
skip(bytes, operands);
534
void Msod::opBlip(Header &, U32 bytes, QDataStream &operands)
538
msobiWMF = 0x216, // Metafile header then compressed WMF.
539
msobiEMF = 0x3D4, // Metafile header then compressed EMF.
540
msobiPICT = 0x542, // Metafile header then compressed PICT.
541
msobiPNG = 0x6E0, // One byte tag then PNG data.
542
msobiJPEG = 0x46A, // One byte tag then JFIF data.
543
msobiDIB = 0x7A8, // One byte tag then DIB data.
544
msobiClient = 0x800 // Clients should set this bit.
548
msocompressionDeflate,
549
msocompressionNone = 254,
551
} MSOBLIPCOMPRESSION;
575
// Skip any explicit primary header (m_rgbUidprimary).
580
hasPrimaryId = (m_blipType ^ msobiEMF) != 0;
583
hasPrimaryId = (m_blipType ^ msobiWMF) != 0;
586
hasPrimaryId = (m_blipType ^ msobiPICT) != 0;
589
hasPrimaryId = (m_blipType ^ msobiJPEG) != 0;
592
hasPrimaryId = (m_blipType ^ msobiPNG) != 0;
595
hasPrimaryId = (m_blipType ^ msobiDIB) != 0;
598
hasPrimaryId = (m_blipType ^ msobiClient) != 0;
607
// Process the rest of the header.
609
data.compression = msocompressionNone;
617
operands >> data.bounds.x >> data.bounds.y >> data.bounds.w >> data.bounds.h;
618
operands >> data.ptSize.w >> data.ptSize.h;
619
operands >> data.cbSave;
620
operands >> data.compression >> data.filter;
633
// Work out the file type.
635
Image *image = new Image();
639
image->extension = "emf";
642
image->extension = "wmf";
645
image->extension = "pic";
648
image->extension = "jpg";
651
image->extension = "png";
654
image->extension = "dib";
657
image->extension = "img";
660
image->length = bytes - length;
661
image->data = new char[image->length];
662
operands.readRawBytes((char *)image->data, image->length);
663
if (data.compression == msocompressionDeflate)
666
uLongf destLen = data.cb;
669
tmp = new char[data.cb];
670
result = uncompress((U8 *)tmp, &destLen, (U8 *)image->data, image->length);
673
kdError(s_area) << "opBlip: uncompress failed: " << result << endl;
675
if (destLen != data.cb)
677
kdError(s_area) << "opBlip: uncompressed " << destLen << " instead of " << data.cb << endl;
679
delete [] image->data;
681
image->length = destLen;
683
m_images.resize(m_images.size() + 1);
684
m_images.insert(m_images.size() - 1, image);
687
// FBSE - File Blip Store Entry
689
void Msod::opBse(Header &op, U32 bytes, QDataStream &operands)
693
U8 btWin32; // Required type on Win32.
694
U8 btMacOS; // Required type on Mac.
695
U8 rgbUid[16]; // Identifier of blip.
696
U16 tag; // currently unused.
697
U32 size; // Blip size in stream.
698
U32 cRef; // Reference count on the blip.
699
U32 foDelay; // File offset in the delay stream.
700
U8 usage; // How this blip is used (MSOBLIPUSAGE).
701
U8 cbName; // length of the blip name.
702
U8 unused2; // for the future.
703
U8 unused3; // for the future.
707
// Work out the type of the BLIP.
709
m_blipType = static_cast<MSOBLIPTYPE>(op.opcode.fields.inst);
710
operands >> data.btWin32 >> data.btMacOS;
711
for (i = 0; i < sizeof(data.rgbUid); i++)
712
operands >> data.rgbUid[i];
713
operands >> data.tag >> data.size;
714
operands >> data.cRef >> data.foDelay;
715
operands >> data.usage >> data.cbName;
716
operands >> data.unused2 >> data.unused2;
718
// If the Blip is not in this drawing file, process it "manually".
722
// The m_pib refers to images by number, which includes images
723
// that are no longer here. Thus, we fake these out so that any
724
// references to non-deleted images are still valid (!!!).
726
if (data.size && data.cRef)
729
bytes.setRawData(m_delayStream + data.foDelay, data.size);
730
QDataStream stream(bytes, IO_ReadOnly);
731
stream.setByteOrder(QDataStream::LittleEndian);
732
walk(data.size, stream);
733
bytes.resetRawData(m_delayStream + data.foDelay, data.size);
737
m_images.resize(m_images.size() + 1);
738
m_images.insert(m_images.size() - 1, 0L);
741
skip(bytes - sizeof(data), operands);
744
void Msod::opBstorecontainer(Header &, U32 bytes, QDataStream &operands)
746
walk(bytes, operands);
749
void Msod::opCalloutrule(
752
QDataStream &operands)
754
skip(bytes, operands);
757
void Msod::opChildanchor(
760
QDataStream &operands)
762
skip(bytes, operands);
765
void Msod::opClientanchor(Header &, U32 bytes, QDataStream &operands)
772
operands >> data.unknown;
773
kdDebug(s_area) << "client anchor: " << data.unknown << endl;
774
skip(bytes - sizeof(data), operands);
777
void Msod::opClientdata(Header &, U32 bytes, QDataStream &operands)
784
operands >> data.unknown;
785
kdDebug(s_area) << "client data: " << data.unknown << endl;
786
skip(bytes - sizeof(data), operands);
789
void Msod::opClientrule(
792
QDataStream &operands)
794
skip(bytes, operands);
797
void Msod::opClienttextbox(
800
QDataStream &operands)
807
operands >> data.unknown;
808
kdDebug(s_area) << "client textbox: 0x" << QString::number(data.unknown,16) << endl;
809
skip(bytes - sizeof(data), operands);
815
QDataStream &operands)
817
skip(bytes, operands);
820
void Msod::opColormru(
823
QDataStream &operands)
825
skip(bytes, operands);
828
void Msod::opConnectorrule(
831
QDataStream &operands)
833
skip(bytes, operands);
836
void Msod::opDeletedpspl(
839
QDataStream &operands)
841
skip(bytes, operands);
846
void Msod::opDg(Header &, U32 bytes, QDataStream &operands)
850
U32 csp; // The number of shapes in this drawing.
851
U32 spidCur; // The last shape ID given to an SP in this DG.
854
operands >> data.csp >> data.spidCur;
855
kdDebug(s_area) << "drawing id: " << data.spidCur << endl;
856
m_isRequiredDrawing = (m_requestedShapeId == data.spidCur);
857
if (m_isRequiredDrawing)
859
kdDebug(s_area) << "found requested drawing" << endl;
861
skip(bytes - sizeof(data), operands);
864
void Msod::opDgcontainer(Header &, U32 bytes, QDataStream &operands)
866
walk(bytes, operands);
871
void Msod::opDgg(Header &, U32 bytes, QDataStream &operands)
875
U32 spidMax; // The current maximum shape ID.
876
U32 cidcl; // The number of ID clusters (FIDCLs).
877
U32 cspSaved; // The total number of shapes saved.
878
// (including deleted shapes, if undo
879
// information was saved).
880
U32 cdgSaved; // The total number of drawings saved.
883
// File ID Cluster - used to save IDCLs
887
U32 dgid; // DG owning the SPIDs in this cluster
888
U32 cspidCur; // number of SPIDs used so far
892
operands >> data.spidMax >> data.cidcl >> data.cspSaved >> data.cdgSaved;
893
kdDebug(s_area) << data.cspSaved << " shapes in " <<
894
data.cidcl - 1 << " clusters in " <<
895
data.cdgSaved << " drawings" << endl;
896
for (i = 0; i < data.cidcl - 1; i++)
898
operands >> data1.dgid >> data1.cspidCur;
900
skip(bytes - sizeof(data) - (data.cidcl - 1) * sizeof(data1), operands);
903
void Msod::opDggcontainer(Header &, U32 bytes, QDataStream &operands)
905
walk(bytes, operands);
908
void Msod::opOleobject(
911
QDataStream &operands)
913
skip(bytes, operands);
916
void Msod::opOpt(Header &, U32 bytes, QDataStream &operands)
918
m_opt->walk(bytes, operands);
921
void Msod::opRegroupitems(
924
QDataStream &operands)
926
skip(bytes, operands);
929
void Msod::opSelection(
932
QDataStream &operands)
934
skip(bytes, operands);
937
void Msod::opSolvercontainer(Header &, U32 bytes, QDataStream &operands)
939
walk(bytes, operands);
942
void Msod::opSp(Header &op, U32 bytes, QDataStream &operands)
944
// We want to defer the act of drawing a shape until we have seen any options
945
// that may affect it. Thus, we merely store the data away, and let opSpContainer
946
// do all the ahrd work.
948
m_shape.type = op.opcode.fields.inst;
949
m_shape.length = bytes;
950
m_shape.data = new char [bytes];
951
operands.readRawBytes(m_shape.data, bytes);
954
void Msod::opSpcontainer(Header &, U32 bytes, QDataStream &operands)
956
walk(bytes, operands);
958
// Having gathered all the information for this shape, we can now draw it.
962
a.setRawData(m_shape.data, m_shape.length);
963
QDataStream s(a, IO_ReadOnly);
964
s.setByteOrder(QDataStream::LittleEndian); // Great, I love Qt !
965
drawShape(m_shape.type, m_shape.length, s);
966
a.resetRawData(m_shape.data, m_shape.length);
967
delete [] m_shape.data;
971
void Msod::opSpgr(Header &, U32 bytes, QDataStream &operands)
981
operands >> data.x >> data.y >> data.w >> data.h;
982
skip(bytes - sizeof(data), operands);
985
void Msod::opSpgrcontainer(Header &, U32 bytes, QDataStream &operands)
987
walk(bytes, operands);
990
void Msod::opSplitmenucolors(Header &, U32 bytes, QDataStream &operands)
1000
operands >> data.fill >> data.line >> data.shadow >> data.threeDee;
1001
skip(bytes - sizeof(data), operands);
1002
skip(m_dggError, operands);
1005
void Msod::opTextbox(
1008
QDataStream &operands)
1010
skip(bytes, operands);
1013
void Msod::skip(U32 bytes, QDataStream &operands)
1017
kdError(s_area) << "skip: " << (int)bytes << endl;
1025
kdDebug(s_area) << "skip: " << bytes << endl;
1026
for (i = 0; i < bytes; i++)
1028
operands >> discard;
1033
void Msod::walk(U32 bytes, QDataStream &operands)
1038
while (length < bytes)
1040
operands >> op.opcode.info >> op.cbLength;
1041
if (op.opcode.fields.fbt == 0)
1044
// Package the arguments...
1046
invokeHandler(op, op.cbLength, operands);
1047
length += op.cbLength + 8;
1051
Msod::Options::Options(
1059
Msod::Options::~Options()
1064
double Msod::Options::from1616ToDouble(U32 value)
1066
return (value >> 16) + 65535.0 / (double)(value & 0xffff);
1069
void Msod::Options::initialise()
1076
m_pibName = QString::null;
1079
m_fNoHitTestPicture = false;
1080
m_pictureGray = false;
1081
m_pictureBiLevel = false;
1082
m_pictureActive = false;
1087
m_geoBottom = 21600;
1095
m_fFillShadeShapeOK = false;
1099
m_fHitTestFill = true;
1101
m_fillUseRect = false;
1102
m_fNoFillHitTest = false;
1105
m_lineBackColor = 0xffffff;
1109
m_fArrowheadsOK = false;
1111
m_fHitTestLine = true;
1112
m_lineFillShape = true;
1113
m_fNoLineDrawDash = false;
1118
m_fPreferRelativeResize = false;
1119
m_fLockShapeType = false;
1120
m_fDeleteAttachedObject = false;
1121
m_fBackground = false;
1124
void Msod::Options::walk(U32 bytes, QDataStream &operands)
1128
U16 complexLength = 0;
1130
// Reset all options to default values.
1134
// First process all simple options, and add all complex options to a list.
1136
QList<Header> complexOpts;
1137
complexOpts.setAutoDelete(true);
1139
while (length + complexLength < (int)bytes)
1141
operands >> op.opcode.info >> op.value;
1144
// Defer processing of complex options.
1146
if (op.opcode.fields.fComplex)
1148
complexLength += op.value;
1149
complexOpts.append(new Header(op));
1153
// Now squirrel away the option value.
1155
unsupported = false;
1156
switch (op.opcode.fields.pid)
1159
m_rotation = from1616ToDouble(op.value);
1163
kdDebug(s_area) << "textbox: 0x" << QString::number(op.value,16) << endl;
1166
if (op.opcode.fields.fBid)
1169
if (m_parent.m_isRequiredDrawing)
1171
Image *image = m_parent.m_images[m_pib - 1];
1173
// If it is an embedded WMF we don't bother with the
1174
// part; we just extract it as more vector graphics.
1176
if (image->extension == "wmf")
1179
a.setRawData(image->data, image->length);
1180
QDataStream s(a, IO_ReadOnly);
1181
m_parent.KWmf::parse(s, image->length);
1182
a.resetRawData(image->data, image->length);
1186
m_parent.gotPicture(
1196
kdError(s_area) << "Cannot handle IMsoBlip" << endl;
1200
m_pibFlags = op.value;
1203
m_pictureId = op.value;
1206
m_fNoHitTestPicture = (op.value & 0x0008) != 0;
1207
m_pictureGray = (op.value & 0x0004) != 0;
1208
m_pictureBiLevel = (op.value & 0x0002) != 0;
1209
m_pictureActive = (op.value & 0x0001) != 0;
1212
m_geoLeft = op.value;
1215
m_geoTop = op.value;
1218
m_geoRight = op.value;
1221
m_geoBottom = op.value;
1224
m_shapePath = op.value;
1227
m_fShadowOK = (op.value & 0x0020) != 0;
1228
m_f3DOK = (op.value & 0x0010) != 0;
1229
m_fLineOK = (op.value & 0x0008) != 0;
1230
m_fGTextOK = (op.value & 0x0004) != 0;
1231
m_fFillShadeShapeOK = (op.value & 0x0002) != 0;
1232
m_fFillOK = (op.value & 0x0001) != 0;
1235
m_fFilled = (op.value & 0x0010) != 0;
1236
m_fHitTestFill = (op.value & 0x0008) != 0;
1237
m_fillShape = (op.value & 0x0004) != 0;
1238
m_fillUseRect = (op.value & 0x0002) != 0;
1239
m_fNoFillHitTest = (op.value & 0x0001) != 0;
1242
m_lineColor = op.value;
1245
m_lineBackColor = op.value;
1248
m_lineType = op.value;
1251
m_lineWidth = op.value;
1254
m_fArrowheadsOK = (op.value & 0x0010) != 0;
1255
m_fLine = (op.value & 0x0008) != 0;
1256
m_fHitTestLine = (op.value & 0x0004) != 0;
1257
m_lineFillShape = (op.value & 0x0002) != 0;
1258
m_fNoLineDrawDash = (op.value & 0x0001) != 0;
1261
m_bWMode = op.value;
1264
m_fOleIcon = (op.value & 0x0010) != 0;
1265
m_fPreferRelativeResize = (op.value & 0x0008) != 0;
1266
m_fLockShapeType = (op.value & 0x0004) != 0;
1267
m_fDeleteAttachedObject = (op.value & 0x0002) != 0;
1268
m_fBackground = (op.value & 0x0001) != 0;
1272
kdWarning(s_area) << "unsupported simple option: " <<
1273
op.opcode.fields.pid << endl;
1277
kdDebug(s_area) << "simple option: " <<
1278
op.opcode.fields.pid << endl;
1281
// Now empty the list of complex options.
1283
while (complexOpts.count())
1288
op = *complexOpts.getFirst();
1289
complexOpts.removeFirst();
1290
unsupported = false;
1291
switch (op.opcode.fields.pid)
1299
m_pibName += QChar(t16);
1303
m_pVertices = new QPointArray(op.value / 4);
1304
for (i = 0; i < m_pVertices->count(); i++)
1306
m_pVertices->setPoint(i, m_parent.normalisePoint(operands));
1314
m_parent.skip(i * t16, operands);
1318
kdWarning(s_area) << "unsupported complex option: " <<
1319
op.opcode.fields.pid << " operands: " << op.value << endl;
1320
m_parent.skip(op.value, operands);
1324
kdDebug(s_area) << "complex option: " <<
1325
op.opcode.fields.pid << " operands: " << op.value << endl;
1326
complexLength -= op.value;