1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include <stdio.h> // getchar
28
29 //#include "defs.hxx"
30 #include <tools/solar.h> // sal_uInt8
31 //#include "wwscan.hxx" // aWwStor
32 #include "ww8dout.hxx"
33 #include <tools/stream.hxx>
34
35 #include <sot/storage.hxx>
36
37 extern SvStorageStreamRef xStrm;
38 extern SvStorageStreamRef xTableStream;
39 extern SvStorageStreamRef xDataStream; // ist bei Ver6-7 mit xStrm identisch,
40 void DumpSprms( sal_uInt8 nVersion, SvStream& rSt, short nLen );
41
42 ostream* pOut = 0;
43
44 #define DumpVer8
45
46 //-----------------------------------------
47 // Streams
48 //-----------------------------------------
49
50
51 static int level = 0;
52 static long lastpos = -1;
53
endl1(ostream & s)54 ostream& __cdecl endl1( ostream& s ){
55 //ostream& endl1( ostream& s ) {
56 s << endl;
57 return s;
58 }
59
hex2(ostream & s)60 ostream& __cdecl hex2( ostream& s ) {
61 s.width( 2 ); s.fill( (const char)250 );
62 s << hex;
63 return s;
64 }
65
hex4(ostream & s)66 ostream& __cdecl hex4( ostream& s ) {
67 s.width( 4 ); s.fill( (const char)250 );
68 s << hex ;
69 return s;
70 }
71
hex6(ostream & s)72 ostream& __cdecl hex6( ostream& s ) {
73 s.width( 6 ); s.fill( (const char)250 );
74 s << hex ;
75 return s;
76 }
77
hex8(ostream & s)78 ostream& __cdecl hex8( ostream& s ) {
79 s.width( 8 ); s.fill( (const char)250 );
80 s << hex ;
81 return s;
82 }
83
dec2(ostream & s)84 ostream& __cdecl dec2( ostream& s ) {
85 s << dec;
86 s.width( 0 ); s.fill( 0 );
87 return s;
88 }
89
filepos(ostream & s,SvStream & rSt)90 ostream& __cdecl filepos( ostream& s, SvStream& rSt ) {
91 long pos = rSt.Tell();
92
93 if ( pos != lastpos ){
94 #ifndef DumpVer8
95 if( &rSt == &xStrm )
96 s << "D";
97 else
98 s << "T";
99 #endif
100 s.width( 6 );
101 s.fill( (const char)250 );
102 s << hex << pos << dec << ' ';
103 s.width( 0 ); s.fill( 0 );
104 lastpos = pos;
105 }else{
106 #ifndef DumpVer8
107 s << " ";
108 #else
109 s << " ";
110 #endif
111 }
112 return s;
113 }
114
indent(ostream & s,SvStream & rSt)115 ostream& __cdecl indent( ostream& s, SvStream& rSt ) {
116 filepos( s, rSt );
117 for( int i = 0; i < level; i++ ) s << " ";
118 return s;
119 }
120
indent1(ostream & s)121 ostream& __cdecl indent1( ostream& s ) {
122 for( int i = 0; i < level; i++ ) s << " ";
123 return s;
124 }
125
indent2(ostream & s)126 ostream& __cdecl indent2( ostream& s ) {
127 #ifndef DumpVer8
128 s << " " << indent1;
129 #else
130 s << " " << indent1;
131 #endif
132 return s;
133 }
134
begin(ostream & s,SvStream & rSt)135 ostream& __cdecl begin( ostream& s, SvStream& rSt ) { indent( s, rSt ) << "BEGIN "; level++; return s; }
136
137 // begin1 ohne indent
begin1(ostream & s)138 ostream& __cdecl begin1( ostream& s ) { s << "BEGIN "; level++; return s; }
139
140 // begin2 ohne Nummer
begin2(ostream & s)141 ostream& __cdecl begin2( ostream& s ) { s << indent2 << "BEGIN "; level++; return s; }
142
end(ostream & s,SvStream & rSt)143 ostream& __cdecl end( ostream& s, SvStream& rSt ) { level--; return indent( s, rSt ) << "END "; }
144
145 // end1 ohne filepos
end1(ostream & s)146 ostream& __cdecl end1( ostream& s ) { level--; return s << indent1 << "END "; }
147
148 // end2 ohne Nummer
end2(ostream & s)149 ostream& __cdecl end2( ostream& s ) { level--; return s << indent2 << "END "; }
150
151 //-----------------------------------------
152 // Ausgabe-Funktionen
153 //-----------------------------------------
154
OutBool(SvStream & rSt,short)155 void OutBool( SvStream& rSt, short )
156 {
157 sal_uInt8 nPara;
158
159 rSt.Read( &nPara, sizeof( nPara ) );
160 switch( nPara ){
161 case 0: *pOut << "F"; break;
162 case 1: *pOut << "T"; break;
163 default: *pOut << "ERROR:" << (sal_uInt16)nPara; break;
164 }
165 }
166
OutBool4(SvStream & rSt,short)167 void OutBool4( SvStream& rSt, short )
168 {
169 sal_uInt8 nPara;
170
171 rSt.Read( &nPara, sizeof( nPara ) );
172 switch( nPara ){
173 case 0: *pOut << "F"; break;
174 case 1: *pOut << "T"; break;
175 case 128: *pOut << "==Style"; break;
176 case 129: *pOut << "!=Style"; break;
177 default: *pOut << "ERROR:" << (sal_uInt16)nPara; break;
178 }
179 }
180
OutByte(SvStream & rSt,short)181 void OutByte( SvStream& rSt, short )
182 {
183 sal_uInt8 nPara;
184
185 rSt.Read( &nPara, sizeof( nPara ) );
186 *pOut << (sal_uInt16)nPara;
187 }
188
OutShort(SvStream & rSt,short)189 void OutShort( SvStream& rSt, short )
190 {
191 short nPara;
192
193 rSt.Read( &nPara, sizeof( nPara ) );
194 *pOut << nPara;
195 }
196
OutShorts(SvStream & rSt,short nLen)197 void OutShorts( SvStream& rSt, short nLen )
198 {
199 sal_Int16 nPara;
200
201 for( short i = 0; i < nLen / 2; i++ ){
202 rSt.Read( &nPara, sizeof( nPara ) );
203 *pOut << nPara << ' ';
204 }
205 }
206
OutWord(SvStream & rSt,short)207 void OutWord( SvStream& rSt, short )
208 {
209 sal_uInt16 nPara;
210
211 rSt.Read( &nPara, sizeof( nPara ) );
212 *pOut << nPara;
213 }
214
OutWords(SvStream & rSt,short nLen)215 void OutWords( SvStream& rSt, short nLen )
216 {
217 sal_uInt16 nPara;
218
219 for( short i = 0; i < nLen / 2; i++ ){
220 rSt.Read( &nPara, sizeof( nPara ) );
221 *pOut << nPara;
222 }
223 }
224
OutWordHex(SvStream & rSt,short)225 void OutWordHex( SvStream& rSt, short )
226 {
227 sal_uInt16 nPara;
228
229 rSt.Read( &nPara, sizeof( nPara ) );
230 *pOut << "0x" << hex4 << nPara << dec;
231 }
232
OutWordsHex(SvStream & rSt,short nLen)233 void OutWordsHex( SvStream& rSt, short nLen )
234 {
235 sal_uInt16 nPara;
236 nLen /= sizeof( nPara );
237 for( short i = 0; i < nLen; i++ ){
238 rSt.Read( &nPara, sizeof( nPara ) );
239 *pOut << "0x" << hex4 << nPara << dec;
240 if( i < nLen - 1 )
241 *pOut << ' ';
242 }
243 }
244
OutLongsHex(SvStream & rSt,short nLen)245 void OutLongsHex( SvStream& rSt, short nLen )
246 {
247 long nPara;
248 nLen /= sizeof( nPara );
249 for( short i = 0; i < nLen; i++ )
250 {
251 rSt.Read( &nPara, sizeof( nPara ) );
252 *pOut << "0x" << hex8 << nPara << dec;
253 if( i < nLen - 1 )
254 *pOut << ' ';
255 }
256 }
257
OutLongHex(SvStream & rSt,short)258 void OutLongHex( SvStream& rSt, short )
259 {
260 sal_uLong nPara;
261
262 rSt.Read( &nPara, sizeof( nPara ) );
263 *pOut << "0x" << hex8 << nPara << dec;
264 }
265
OutTab68(SvStream & rSt,short)266 void OutTab68( SvStream& rSt, short )
267 {
268 sal_uLong nPara;
269
270 rSt.Read( &nPara, sizeof( nPara ) );
271 if( nPara == 0 )
272 *pOut << "None";
273 else
274 *pOut << "0x" << hex8 << nPara << dec;
275 }
276
277
OutTab(SvStream & rSt,short)278 void OutTab( SvStream& rSt, short )
279 {
280 sal_uInt8 nDel, nIns, nType;
281 short nPos, i;
282
283 rSt.Read( &nDel, sizeof( nDel ) );
284 *pOut << "Del " << (sal_uInt16)nDel;
285 if ( nDel ) *pOut << ": ";
286 else *pOut << ", ";
287
288 for( i=1; i<=nDel; i++){
289 rSt.Read( &nPos, sizeof( nPos ) );
290 *pOut << nPos;
291 if( i<nDel ) *pOut << ',';
292 else *pOut << ' ';
293 }
294 rSt.Read( &nIns, sizeof( nIns ) );
295 *pOut << "Ins " << (sal_uInt16)nIns;
296 if ( nIns ) *pOut << ": ";
297
298 for( i=1; i<=nIns; i++){
299 rSt.Read( &nPos, sizeof( nPos ) );
300 *pOut << nPos;
301 if( i<nIns ) *pOut << ',';
302 else *pOut << ' ';
303 }
304 if ( nIns ) *pOut << "Typ: ";
305
306 for( i=1; i<=nIns; i++){
307 rSt.Read( &nType, sizeof( nType ) );
308 *pOut << (sal_uInt16)nType;
309 if( i<nIns ) *pOut << ',';
310 else *pOut << ' ';
311 }
312
313 // nSiz = 1 + 2 * nDel + 1 + nIns * 3; // genaue Laenge,
314 // stimmt auch bei Laenge > 256
315 // bei diesem Tab-Befehl anscheinend nicht noetig
316 }
317
OutTab190(SvStream & rSt,short nLen)318 void OutTab190( SvStream& rSt, short nLen )
319 {
320 sal_uInt8 nCols;
321 rSt.Read( &nCols, sizeof( nCols ) );
322 *pOut << (sal_uInt16)nCols << " Cols: ";
323
324 short nPos, i;
325 for( i = 0; i <= nCols; i++ ){
326 rSt.Read( &nPos, sizeof( nPos ) );
327 *pOut << nPos;
328 if( i < nCols )
329 *pOut << ", ";
330 }
331 *pOut << dec << "; ";
332 for( i = 0; i < nCols; i++ ){
333 *pOut << "Col " << i << " TC: ";
334 OutWordsHex( rSt, 10 );
335 if( i < nCols - 1 )
336 *pOut << "; ";
337 }
338 }
339
OutTab191(SvStream & rSt,short nLen)340 void OutTab191( SvStream& rSt, short nLen )
341 {
342 sal_uInt8 nCols;
343 rSt.Read( &nCols, sizeof( nCols ) );
344 *pOut << (sal_uInt16)nCols << " Cols, SHDs: ";
345 OutWordsHex( rSt, ( nCols + 1 ) * 2 );
346 }
347
OutTab192(SvStream & rSt,short)348 void OutTab192( SvStream& rSt, short )
349 {
350 OutWord( rSt, 0 );
351 OutWordHex( rSt, 0 );
352 }
353
OutHugeHex(SvStream & rSt,short nLen)354 void OutHugeHex( SvStream& rSt, short nLen )
355 {
356 long nPos;
357 rSt.Read( &nPos, sizeof( nPos ) );
358
359 long nCurr = xDataStream->Tell();
360 xDataStream->Seek( nPos );
361
362 xDataStream->Read( &nLen, sizeof( nLen ) );
363
364 // *pOut << ", Len max: " << nLen << ", ID:" << nIStd << endl1;
365 *pOut << endl1;
366 DumpSprms( 8, *xDataStream, nLen );
367
368 xDataStream->Seek( nCurr );
369 }
370
OutTabD608(SvStream & rSt,short nLen)371 void OutTabD608( SvStream& rSt, short nLen )
372 {
373 sal_uInt8 nHi, nCols;
374 rSt.Read( &nHi, sizeof( nHi ) );
375 // nLen += ((short)nHi) << 8;
376
377 rSt.Read( &nCols, sizeof( nCols ) );
378 *pOut << " Cols: " << (short)nCols << ' ' << endl1 << indent2;
379
380 short nPos, i;
381 for( i = 0; i <= nCols; ++i )
382 {
383 rSt.Read( &nPos, sizeof( nPos ) );
384 *pOut << nPos;
385 if( i < nCols )
386 *pOut << ", ";
387 }
388 nLen -= ( nCols + 1 ) * 2;
389 nLen /= 20;
390
391 for( i = 0; i < nLen; ++i )
392 {
393 *pOut << endl1 << indent2 << "Col " << i << " TC: ";
394 OutLongsHex( rSt, 20 );
395 if( i < nLen - 1 )
396 *pOut << "; ";
397 }
398 }
399
OutTabD609(SvStream & rSt,short nLen)400 void OutTabD609( SvStream& rSt, short nLen )
401 {
402 *pOut << " Brush(FBS): ";
403 for( short i = 0; i < nLen / 2; ++i )
404 {
405 sal_uInt16 nVal;
406 rSt.Read( &nVal, sizeof( nVal ) );
407 *pOut << (nVal & 0x1f);
408 *pOut << "|" << ((nVal >> 5) & 0x1f);
409 *pOut << "|" << ((nVal >> 10) & 0x3f);
410 if( i < nLen )
411 *pOut << ", ";
412 }
413 }
414
415
416