xref: /trunk/main/sw/source/filter/ww1/w1class.hxx (revision 1d2dbeb0)
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 #include <tools/string.hxx>
24 #include <tools/debug.hxx>
25 
26 // local
27 #ifndef _W1STRUCT_HXX
28 #include <w1struct.hxx>
29 #endif
30 
31 #ifdef DUMP
32 #include <fstream.h>
33 #endif
34 
35 #include <ostream>
36 
37 using std::ostream;
38 
39 class SvxFontItem;
40 class SvxBorderLine;
41 class SvxBoxItem;
42 class SvStream;
43 class SwField;
44 class Ww1Annotation;
45 class Ww1AtnText;
46 class Ww1Chp;
47 class Ww1DocText;
48 class Ww1Dop;
49 class Ww1Fib;
50 class Ww1Fkp;
51 class Ww1FkpChp;
52 class Ww1FkpPap;
53 class Ww1Fonts;
54 class Ww1Manager;
55 class Ww1McrText;
56 class Ww1Pap;
57 class Ww1PlainText;
58 class Ww1Plc;
59 class Ww1PlcAnnotationRef;
60 class Ww1PlcAnnotationTxt;
61 class Ww1PlcChp;
62 class Ww1PlcFields;
63 class Ww1PlcFootnoteRef;
64 class Ww1PlcFootnoteTxt;
65 class Ww1PlcGlossary;
66 class Ww1PlcHdd;
67 class Ww1PlcPap;
68 class Ww1PlcSep;
69 class Ww1Shell;
70 class Ww1Sprm;
71 class Ww1SprmPapx;
72 class Ww1SprmSep;
73 class Ww1Style;
74 class Ww1StyleSheet;
75 
76 ///////////////////////////////////////////////////////////////////////
77 //
78 // nach moeglichkeit wurden in diesem modul methoden aehnlicher
79 // funktionalitaet gleich benannt. Die namen wurden wenn moeglich vom
80 // ww-filter uebernommen.
81 // Where() gibt die position eines elements. dies kann sowohl eine
82 // seek-position im stream als auch ein relativer offset sein, da dies
83 // bei word durcheinander geht.  die methoden sind durch kommentare
84 // gekennzeichnet, ob sie sich auf positionen in der datei oder
85 // innerhalb des textes beziehen. vorsicht: innerhalb des textes kann
86 // verschiedene texte in der datei bedeuten.
87 // Count() gibt die anzahl der elemente zurueck. vorsicht bei
88 // n/n-1-feldern (word speichert strukturen gern in doppel-arrays, in
89 // denen das erste n elemente, das zweite jedoch n-1 elemente
90 // enthaelt.
91 // Fill() fuellt uebergebene referenzen mit daten aus den
92 // word-strukturen.
93 // GetData() gibt zeiger auf den datenbereich zurueck
94 // GetError() gibt zurueck, ob fehler aufgetreten ist
95 // Start(), Stop(), Out(), op<< siehe modul w1filter
96 // Dump() siehe modul w1dump
97 //
98 
99 /////////////////////////////////////////////////////////////////// Fib
100 //
101 // file information block: wurzel des uebels: steht am beginn der
102 // datei (seek(0)) und enthaelt alle positionen der strukturen der
103 // datei
104 //
105 class Ww1Fib
106 {
107 	W1_FIB aFib;
108 	sal_Bool bOK;
109 	SvStream& rStream;
110 public:
111 	Ww1Fib(SvStream&);
112 	friend ostream& operator <<(ostream&, Ww1Fib&);
GetFIB()113 	W1_FIB& GetFIB() 		{ return aFib; }
GetError()114 	sal_Bool GetError() 		{ return !bOK; }
GetStream()115 	SvStream& GetStream() 	{ return rStream; }
116 };
117 
118 /////////////////////////////////////////////////////////////////// Dop
119 //
120 // document property: eigenschaften des gesamten dokuments
121 //
122 class Ww1Dop
123 {
124 	W1_DOP aDop;
125 	Ww1Fib& rFib;
126 	sal_Bool bOK;
127 public:
128 	Ww1Dop(Ww1Fib&);
GetError()129 	sal_Bool GetError() {
130 		return !bOK; }
GetDOP()131 	W1_DOP& GetDOP() {
132 		return aDop; }
133 	friend ostream& operator <<(ostream&, Ww1Dop&);
134 	void Out(Ww1Shell&);
135 };
136 
137 ///////////////////////////////////////////////////////////// PlainText
138 //
139 // ww-dateien koennen mehrere textbloecke enthalten (main-text,
140 // fusznoten etc). PlainText vereinigt die gemeinsamkeiten
141 //
142 class Ww1PlainText
143 {
144 protected:
145 	Ww1Fib& rFib;
146 	sal_uLong ulFilePos;
147 	sal_uLong ulCountBytes;
148 	sal_uLong ulSeek;
149 	sal_Bool bOK;
150 public:
151 	Ww1PlainText(Ww1Fib& rWwFib, sal_uLong nFilePos, sal_uLong nCountBytes);
152 	// innerhalb des textes
Where() const153 	sal_uLong Where() const					{ return ulSeek; }
Seek(sal_uLong ulNew)154 	void Seek( sal_uLong ulNew )
155 		{
156 			DBG_ASSERT(ulNew < ulCountBytes, "Ww1PlainText");
157 			if (ulNew < ulCountBytes)
158 				ulSeek = ulNew;
159 		}
160 
Count() const161 	sal_uLong Count() const 				{ return ulCountBytes; }
SetCount(sal_uLong ulNew)162 	void SetCount(sal_uLong ulNew)
163 		{
164 			ulNew += ulSeek;
165 			if (ulCountBytes > ulNew)
166 				ulCountBytes = ulNew;
167 		}
operator ++(int)168 	void operator++(int)
169 	{
170 		DBG_ASSERT(ulSeek+1<ulCountBytes, "Ww1PlainText");
171 		ulSeek++;
172 	}
GetError()173 	sal_Bool GetError() 					{ return !bOK; }
174 	sal_Unicode Out( Ww1Shell&, sal_uLong& );
175 	sal_Unicode Out( String&, sal_uLong=0xffffffff);
176 	sal_Unicode Out( sal_Unicode& );
177 	friend ostream& operator <<(ostream&, Ww1PlainText&);
178 	String& Fill( String&, sal_uLong=0, sal_uLong=0xffffffff );
179 	sal_Unicode operator []( sal_uLong );
180 	String GetText( sal_uLong ulOffset, sal_uLong nLen ) const;
181 
182 	enum Consts { MinChar = 32 };
IsChar(sal_Unicode c)183 	static sal_Bool IsChar( sal_Unicode c ) 	{ return c >= MinChar; }
184 };
185 
186 /////////////////////////////////////////////////////////////// DocText
187 class Ww1DocText : public Ww1PlainText
188 {
189 public:
Ww1DocText(Ww1Fib & rFibL)190     Ww1DocText(Ww1Fib& rFibL) :
191         Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet(),
192          rFibL.GetFIB().ccpTextGet()) {
193 		}
194 };
195 
196 /////////////////////////////////////////////////////////////// FtnText
197 class Ww1FtnText : public Ww1PlainText
198 {
199 public:
Offset(Ww1Fib & rFibL)200     sal_uLong Offset(Ww1Fib& rFibL) {
201         return rFibL.GetFIB().ccpTextGet(); }
Ww1FtnText(Ww1Fib & rFibL)202     Ww1FtnText(Ww1Fib& rFibL) :
203         Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
204          Offset(rFibL), rFibL.GetFIB().ccpFtnGet()) {
205 		}
206 };
207 
208 /////////////////////////////////////////////////////////////// HddText
209 class Ww1HddText : public Ww1PlainText
210 {
211 public:
Offset(Ww1Fib & rFibL)212     sal_uLong Offset(Ww1Fib& rFibL) {
213         return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet(); }
Ww1HddText(Ww1Fib & rFibL)214     Ww1HddText(Ww1Fib& rFibL) :
215         Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
216          Offset(rFibL), rFibL.GetFIB().ccpHddGet()) {
217 		}
218 };
219 
220 /////////////////////////////////////////////////////////////// McrText
221 class Ww1McrText : public Ww1PlainText
222 {
223 public:
Offset(Ww1Fib & rFibL)224     sal_uLong Offset(Ww1Fib& rFibL) {
225         return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet()
226          + rFibL.GetFIB().ccpHddGet(); }
Ww1McrText(Ww1Fib & rFibL)227     Ww1McrText(Ww1Fib& rFibL) :
228         Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
229          Offset(rFibL), rFibL.GetFIB().ccpMcrGet()) {
230 		}
231 };
232 
233 /////////////////////////////////////////////////////////////// AtnText
234 class Ww1AtnText : public Ww1PlainText
235 {
236 public:
Offset(Ww1Fib & rFibL)237     sal_uLong Offset(Ww1Fib& rFibL) {
238         return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet()
239          + rFibL.GetFIB().ccpHddGet() + rFibL.GetFIB().ccpMcrGet(); }
Ww1AtnText(Ww1Fib & rFibL)240     Ww1AtnText(Ww1Fib& rFibL) :
241         Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
242          Offset(rFibL), rFibL.GetFIB().ccpAtnGet()) {
243 		}
244 };
245 
246 ///////////////////////////////////////////////////////////////// Style
247 //
248 // ein einzelner style oder vorlage
249 //
250 class Ww1Style
251 {
252 	String aName;
253 	W1_CHP aChpx;
254 	Ww1SprmPapx* pPapx;
255 	Ww1StyleSheet* pParent;
256 	sal_uInt8 stcBase;
257 	sal_uInt8 stcNext;
258 	sal_Bool bUsed;
259 public:
260 	Ww1Style();
261 	~Ww1Style();
IsUsed() const262 	sal_Bool IsUsed() const					{ return bUsed; }
263 	void SetDefaults(sal_uInt8);
SetParent(Ww1StyleSheet * newParent)264 	void SetParent(Ww1StyleSheet* newParent) 	{ pParent = newParent; }
SetName(const String & rName)265 	void SetName(const String& rName) 	{ bUsed = sal_True; aName = rName; }
GetName() const266 	const String& GetName() const		{ return aName; }
267 //	Ww1Style& GetNext();
268 	Ww1Style& GetBase();
GetnBase() const269 	sal_uInt16 GetnBase() const				{ return stcBase; }
GetnNext() const270 	sal_uInt16 GetnNext() const				{ return stcNext; }
271 	sal_uInt16 ReadName(sal_uInt8*&, sal_uInt16&, sal_uInt16 stc);
272 	sal_uInt16 ReadChpx(sal_uInt8*&, sal_uInt16&);
273 	sal_uInt16 ReadPapx(sal_uInt8*&, sal_uInt16&);
274 	sal_uInt16 ReadEstcp(sal_uInt8*&, sal_uInt16&);
275 	friend ostream& operator <<(ostream&, Ww1Style&);
276 	void Out(Ww1Shell&, Ww1Manager&);
277 };
278 
279 //////////////////////////////////////////////////////////// StyleSheet
280 //
281 // die sammlung aller vorlagen (max. 256)
282 //
283 class Ww1StyleSheet
284 {
285 	Ww1Style aStyles[256];
286 	sal_uInt16 cstcStd; // count style code standard
287 	Ww1Fib& rFib;
288 	sal_Bool bOK;
289 	sal_uInt16 ReadNames(sal_uInt8*&, sal_uInt16&);
290 	sal_uInt16 ReadChpx(sal_uInt8*&, sal_uInt16&);
291 	sal_uInt16 ReadPapx(sal_uInt8*&, sal_uInt16&);
292 	sal_uInt16 ReadEstcp(sal_uInt8*&, sal_uInt16&);
293 
294 	void OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc);
295 	void OutOne(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc);
296 	void OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc,
297 						sal_uInt8* pbStopRecur );
298 public:
299 	Ww1StyleSheet(Ww1Fib& rFib);
GetStyle(sal_uInt16 stc)300 	Ww1Style& GetStyle(sal_uInt16 stc) {
301 		return aStyles[stc]; }
Count()302 	sal_uInt16 Count() {
303 		return 256; }
304 	friend ostream& operator <<(ostream&, Ww1StyleSheet&);
305 	void Out(Ww1Shell&, Ww1Manager&);
306 	friend class Ww1Style;
GetError()307 	sal_Bool GetError() {
308 		return !bOK; }
309 };
310 
311 ///////////////////////////////////////////////////////////////// Fonts
312 //
313 // ww kennt nur font-nummern beim formatieren. nebenher gibts ein
314 // array von fonts, damit man aus der nummer einen konkreten font
315 // machen kann.
316 //
317 class Ww1Fonts
318 {
319 protected:
320 	W1_FFN** pFontA; // Array of Pointers to Font Description
321 	Ww1Fib& rFib;
322 	sal_uLong nFieldFlags;
323 	sal_uInt16 nMax; // Array-Groesse
324 	sal_Bool bOK;
325 public:
326 	Ww1Fonts(Ww1Fib&, sal_uLong nFieldFlgs);
~Ww1Fonts()327 	~Ww1Fonts() {
328 		if (pFontA)
329 			DELETEZ(pFontA[0]);
330 		DELETEZ(pFontA); }
331 	W1_FFN* GetFFN(sal_uInt16 nNum);
Count()332 	sal_uInt16 Count() {
333 		return nMax; }
334 	friend ostream& operator <<(ostream&, Ww1Fonts&);
GetError()335 	sal_Bool GetError() {
336 		return !bOK; }
337 	SvxFontItem GetFont(sal_uInt16);
338 };
339 
340 //////////////////////////////////////////////////////////// SingleSprm
341 //
342 // diese klassen ersetzen die aSprmTab etc des ww6-filters. die
343 // funktionspointer sind hier virtuale methoden, fuer die typen (byte,
344 // word, var-sized etc) gibt es abgeleitete klassen. diese haben
345 // methoden zum bestimmen der groesze, dumpen und shell-ausgeben der
346 // Sprms.
347 // die klassen werden mit new (in InitTab()) erzeugt und nach ihrem
348 // code in die tabelle gestellt. zum aktivieren ruft man nun nur noch
349 // die entsprechende methode des objektes in der tabelle auf.
350 // wohlgemerkt: SingleSprms sind die _beschreibung_ und _funktion_ der
351 // Sprms, nicht deren inhalt. dieser musz uebergeben werden an die
352 // einzelnen methoden wie Size, Dump und Start/Stop.
353 //
354 class Ww1SingleSprm
355 {
356 public:
357 #ifdef DUMP
358 //
359 // allein die virtuellen methoden stehen in der vtab, also je nachdem,
360 // ob fuer dumper oder filter uebersetzt wird ausblenden: das spart
361 // platz. ausserdem stehen die methoden fuer dumper bzw filter in
362 // verschiedenen modulen, die im jeweils anderen projekt nicht
363 // uebersetzt werden. das diese dann beim linken nicht zur verfuegung
364 // stehen faellt dann auch nicht auf. Der Namensstring ist nur im
365 // Dumper noetig: weg damit im Filter.
366 //
367 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
368 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
369 	virtual ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
370 	const sal_Char* sName;
371 #else
372 	virtual void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
373 	virtual void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
374 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
375 #endif
376 	virtual sal_uInt16 Size(sal_uInt8*);
377 	sal_uInt16 nCountBytes;
378 
Ww1SingleSprm(sal_uInt16 nBytes,const sal_Char * =0)379     Ww1SingleSprm(sal_uInt16 nBytes, const sal_Char* /*pName*/ = 0 )
380         : nCountBytes(nBytes)
381 #ifdef DUMP
382 		, sName( pName)
383 #endif
384 		{
385 		}
386 };
387 
388 class Ww1SingleSprmByteSized : public Ww1SingleSprm {
389 public:
390 //	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
391 	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmByteSized(sal_uInt16 nBytes,sal_Char * sName=0)392     Ww1SingleSprmByteSized(sal_uInt16 nBytes, sal_Char* sName = 0) :
393         Ww1SingleSprm(nBytes, sName) {
394 		}
395 };
396 
397 class Ww1SingleSprmWordSized : public Ww1SingleSprm {
398 public:
399 //	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
400 	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmWordSized(sal_uInt16 nBytes,sal_Char * sName=0)401     Ww1SingleSprmWordSized(sal_uInt16 nBytes, sal_Char* sName = 0) :
402         Ww1SingleSprm(nBytes, sName) {
403 		}
404 };
405 
406 class Ww1SingleSprmByte : public Ww1SingleSprm {
407 public:
408 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
409 //	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmByte(sal_Char * sName=0)410 	Ww1SingleSprmByte(sal_Char* sName = 0) :
411 		Ww1SingleSprm(1, sName) {
412 		}
413 };
414 
415 class Ww1SingleSprmBool : public Ww1SingleSprmByte {
416 public:
417 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
418 //	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmBool(sal_Char * sName=0)419 	Ww1SingleSprmBool(sal_Char* sName = 0) :
420 		Ww1SingleSprmByte(sName) {
421 		}
422 };
423 
424 class Ww1SingleSprm4State : public Ww1SingleSprmByte {
425 public:
426 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
427 //	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprm4State(sal_Char * sName=0)428 	Ww1SingleSprm4State(sal_Char* sName = 0) :
429 		Ww1SingleSprmByte(sName) {
430 		}
431 };
432 
433 class Ww1SingleSprmWord : public Ww1SingleSprm {
434 public:
435 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
436 //	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmWord(sal_Char * sName=0)437 	Ww1SingleSprmWord(sal_Char* sName = 0)
438 	: Ww1SingleSprm(2, sName) {}
439 };
440 
441 class Ww1SingleSprmLong : public Ww1SingleSprm {
442 public:
443 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
444 //	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmLong(sal_Char * sName=0)445 	Ww1SingleSprmLong(sal_Char* sName = 0) :
446 		Ww1SingleSprm(4, sName) {
447 		}
448 };
449 
450 class Ww1SingleSprmTab : public Ww1SingleSprm {
451 public:
452 	ostream& Dump(ostream&, sal_uInt8*, sal_uInt16);
453 	sal_uInt16 Size(sal_uInt8*);
Ww1SingleSprmTab(sal_uInt16 nBytes,sal_Char * sName=0)454     Ww1SingleSprmTab(sal_uInt16 nBytes, sal_Char* sName = 0) :
455         Ww1SingleSprm(nBytes, sName) {
456 		}
457 };
458 
459 class Ww1SingleSprmPJc : public Ww1SingleSprmByte {
460 public:
Ww1SingleSprmPJc(sal_Char * sName)461 	Ww1SingleSprmPJc(sal_Char* sName) :
462 		Ww1SingleSprmByte(sName) {
463 		}
464 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
465 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
466 };
467 
468 class Ww1SingleSprmPDxa : public Ww1SingleSprmWord {
469 public:
Ww1SingleSprmPDxa(sal_Char * sName)470 	Ww1SingleSprmPDxa(sal_Char* sName) :
471 		Ww1SingleSprmWord(sName) {
472 		}
473 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
474 };
475 
476 class Ww1SingleSprmPDxaRight : public Ww1SingleSprmPDxa {
477 public:
Ww1SingleSprmPDxaRight(sal_Char * sName)478 	Ww1SingleSprmPDxaRight(sal_Char* sName) :
479 		Ww1SingleSprmPDxa(sName) {
480 		}
481 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
482 };
483 
484 class Ww1SingleSprmPDxaLeft : public Ww1SingleSprmPDxa {
485 public:
Ww1SingleSprmPDxaLeft(sal_Char * sName)486 	Ww1SingleSprmPDxaLeft(sal_Char* sName) :
487 		Ww1SingleSprmPDxa(sName) {
488 		}
489 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
490 };
491 
492 class Ww1SingleSprmPDxaLeft1 : public Ww1SingleSprmPDxa {
493 public:
Ww1SingleSprmPDxaLeft1(sal_Char * sName)494 	Ww1SingleSprmPDxaLeft1(sal_Char* sName) :
495 		Ww1SingleSprmPDxa(sName) {
496 		}
497 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
498 };
499 
500 class Ww1SingleSprmPFKeep : public Ww1SingleSprmBool {
501 public:
Ww1SingleSprmPFKeep(sal_Char * sName)502 	Ww1SingleSprmPFKeep(sal_Char* sName) :
503 		Ww1SingleSprmBool(sName) {
504 		}
505 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
506 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
507 };
508 
509 class Ww1SingleSprmPFKeepFollow : public Ww1SingleSprmBool {
510 public:
Ww1SingleSprmPFKeepFollow(sal_Char * sName)511 	Ww1SingleSprmPFKeepFollow(sal_Char* sName) :
512 		Ww1SingleSprmBool(sName) {
513 		}
514 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
515 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
516 };
517 
518 class Ww1SingleSprmPPageBreakBefore : public Ww1SingleSprmBool {
519 public:
Ww1SingleSprmPPageBreakBefore(sal_Char * sName)520 	Ww1SingleSprmPPageBreakBefore(sal_Char* sName) :
521 		Ww1SingleSprmBool(sName) {
522 		}
523 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
524 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
525 };
526 
527 class Ww1SingleSprmPBrc : public Ww1SingleSprmWord {
528 protected:
529 //	SvxBorderLine* SetBorder(SvxBorderLine*, W1_BRC*);
530 	// spezielle start-routine, je nach sprm verschieden versorgt
531 	// mit einem BoxItem.
532 	void Start(Ww1Shell&, sal_uInt8, W1_BRC10*, sal_uInt16, Ww1Manager&, SvxBoxItem&);
533 	void Start(Ww1Shell&, sal_uInt8, W1_BRC*, sal_uInt16, Ww1Manager&, SvxBoxItem&);
534 
535     using Ww1SingleSprm::Start;
536 
537 public:
Ww1SingleSprmPBrc(sal_Char * sName)538 	Ww1SingleSprmPBrc(sal_Char* sName) :
539 		Ww1SingleSprmWord(sName) {
540 		}
541 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
542 	// SetBorder() wird auch fuer Tabellen gebraucht, deshalb public
543 	static SvxBorderLine* SetBorder(SvxBorderLine*, W1_BRC10*);
544 };
545 
546 #define BRC_TOP ((sal_uInt16)0)
547 #define BRC_LEFT ((sal_uInt16)1)
548 #define BRC_BOTTOM ((sal_uInt16)2)
549 #define BRC_RIGHT ((sal_uInt16)3)
550 #define BRC_ANZ ((sal_uInt16)BRC_RIGHT-BRC_TOP+1)
551 
552 // Die BRC-struktur fuer 1.0 versionen von word sind verschieden von
553 // denen der folgenden versionen. diese werden zum glueck aber auch
554 // von anderen sprms abgerufen.
555 // SH: Ab sofort alle 4 Umrandungen ueber nur 1 Klasse.
556 class Ww1SingleSprmPBrc10 : public Ww1SingleSprmPBrc
557 {
558 	sal_uInt16 nLine;	// BRC_TOP, BRC_LEFT, ...
559 
560 	using Ww1SingleSprmPBrc::Start;
561 
562 public:
Ww1SingleSprmPBrc10(sal_uInt16 nL,sal_Char * sName)563 	Ww1SingleSprmPBrc10(sal_uInt16 nL, sal_Char* sName)
564 	: Ww1SingleSprmPBrc(sName), nLine(nL) {}
565 
566 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
567 };
568 
569 class Ww1SingleSprmParaSpace : public Ww1SingleSprmWord {
570 public:
Ww1SingleSprmParaSpace(sal_Char * sName)571 	Ww1SingleSprmParaSpace(sal_Char* sName)
572 	: Ww1SingleSprmWord(sName) {}
573 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
574 };
575 
576 class Ww1SingleSprmPDyaBefore : public Ww1SingleSprmParaSpace {
577 public:
Ww1SingleSprmPDyaBefore(sal_Char * sName)578 	Ww1SingleSprmPDyaBefore(sal_Char* sName)
579 	: Ww1SingleSprmParaSpace(sName) {}
580 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
581 };
582 
583 class Ww1SingleSprmPDyaAfter : public Ww1SingleSprmParaSpace {
584 public:
Ww1SingleSprmPDyaAfter(sal_Char * sName)585 	Ww1SingleSprmPDyaAfter(sal_Char* sName) :
586 		Ww1SingleSprmParaSpace(sName) {
587 		}
588 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
589 };
590 
591 class Ww1SingleSprmPDyaLine : public Ww1SingleSprmWord {
592 public:
Ww1SingleSprmPDyaLine(sal_Char * sName)593 	Ww1SingleSprmPDyaLine(sal_Char* sName) :
594 		Ww1SingleSprmWord(sName) {
595 		}
596 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
597 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
598 };
599 
600 class Ww1SingleSprmPChgTabsPapx : public Ww1SingleSprmByteSized {
601 public:
Ww1SingleSprmPChgTabsPapx(sal_Char * sName)602 	Ww1SingleSprmPChgTabsPapx(sal_Char* sName) :
603 		Ww1SingleSprmByteSized(0, sName) {
604 		}
605   // Size() ist noch nicht aktiviert !!
606 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
607 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
608 };
609 
610 class Ww1SingleSprmSGprfIhdt : public Ww1SingleSprmByte {
611 public:
Ww1SingleSprmSGprfIhdt(sal_Char * sName)612 	Ww1SingleSprmSGprfIhdt(sal_Char* sName) :
613 		Ww1SingleSprmByte(sName) {
614 		}
615 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
616 };
617 
618 class Ww1SingleSprmSColumns : public Ww1SingleSprmWord {
619 public:
Ww1SingleSprmSColumns(sal_Char * sName)620 	Ww1SingleSprmSColumns(sal_Char* sName) :
621 		Ww1SingleSprmWord(sName) {
622 		}
623 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
624 };
625 
626 class Ww1SingleSprmPFInTable : public Ww1SingleSprmBool {
627 public:
Ww1SingleSprmPFInTable(sal_Char * sName)628 	Ww1SingleSprmPFInTable(sal_Char* sName) :
629 		Ww1SingleSprmBool(sName) {
630 		}
631 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
632 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
633 };
634 
635 class Ww1SingleSprmPTtp : public Ww1SingleSprmBool {
636 public:
Ww1SingleSprmPTtp(sal_Char * sName)637 	Ww1SingleSprmPTtp(sal_Char* sName) :
638 		Ww1SingleSprmBool(sName) {
639 		}
640 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
641 	void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
642 };
643 
644 class Ww1SingleSprmTJc : public Ww1SingleSprmWord {
645 public:
Ww1SingleSprmTJc(sal_Char * sName)646 	Ww1SingleSprmTJc(sal_Char* sName)
647 	: Ww1SingleSprmWord(sName) {}
648 };
649 
650 //class Ww1SingleSprmTDxaLeft : public Ww1SingleSprmWord {
651 //public:
652 //	Ww1SingleSprmTDxaLeft(sal_Char* sName) :
653 //		Ww1SingleSprmWord(sName) {
654 //		}
655 //	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
656 //};
657 
658 class Ww1SingleSprmTDxaGapHalf : public Ww1SingleSprmWord {
659 public:
Ww1SingleSprmTDxaGapHalf(sal_Char * sName)660 	Ww1SingleSprmTDxaGapHalf(sal_Char* sName) :
661 		Ww1SingleSprmWord(sName) {
662 		}
663 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
664 };
665 
666 class Ww1SingleSprmTDefTable10 : public Ww1SingleSprmWordSized {
667 public:
Ww1SingleSprmTDefTable10(sal_Char * sName)668 	Ww1SingleSprmTDefTable10(sal_Char* sName) :
669 		Ww1SingleSprmWordSized(0, sName) {
670 		}
671 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
672 };
673 
674 class Ww1SingleSprmTDyaRowHeight : public Ww1SingleSprmWord {
675 public:
Ww1SingleSprmTDyaRowHeight(sal_Char * sName)676 	Ww1SingleSprmTDyaRowHeight(sal_Char* sName) :
677 		Ww1SingleSprmWord(sName) {
678 		}
679 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
680 };
681 
682 // Klassendefinitionen fuer Tabellen-Fastsave-Attribute
683 // Da wir kein Fastsave unterstuetzen, brauchen wir's nicht
684 
685 #if 0
686 
687 class Ww1SingleSprmTInsert : public Ww1SingleSprm {
688 public:
689 	Ww1SingleSprmTInsert(sal_Char* sName) :
690 		Ww1SingleSprm(4, sName) {
691 		}
692 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
693 };
694 
695 class Ww1SingleSprmTDelete : public Ww1SingleSprmWord {
696 public:
697 	Ww1SingleSprmTDelete(sal_Char* sName) :
698 		Ww1SingleSprmWord(sName) {
699 		}
700 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
701 };
702 
703 class Ww1SingleSprmTDxaCol : public Ww1SingleSprm {
704 public:
705 	Ww1SingleSprmTDxaCol(sal_Char* sName) :
706 		Ww1SingleSprm(4, sName) {
707 		}
708 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
709 };
710 
711 class Ww1SingleSprmTMerge : public Ww1SingleSprmWord {
712 public:
713 	Ww1SingleSprmTMerge(sal_Char* sName) :
714 		Ww1SingleSprmWord(sName) {
715 		}
716 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
717 };
718 
719 class Ww1SingleSprmTSplit : public Ww1SingleSprmWord {
720 public:
721 	Ww1SingleSprmTSplit(sal_Char* sName) :
722 		Ww1SingleSprmWord(sName) {
723 		}
724 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
725 };
726 
727 class Ww1SingleSprmTSetBrc10 : public Ww1SingleSprm {
728 public:
729 	Ww1SingleSprmTSetBrc10(sal_Char* sName) :
730 		Ww1SingleSprm(5, sName) {
731 		}
732 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
733 };
734 #endif // 0
735 
736 // Klassendefinitionen fuer Apos ( == Flys )
737 
738 class Ww1SingleSprmPpc : public Ww1SingleSprmByte {
739 public:
Ww1SingleSprmPpc(sal_Char * sName)740 	Ww1SingleSprmPpc(sal_Char* sName) :
741 		Ww1SingleSprmByte(sName) {
742 		}
743 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
744 };
745 
746 class Ww1SingleSprmPDxaAbs : public Ww1SingleSprmWord {
747 public:
Ww1SingleSprmPDxaAbs(sal_Char * sName)748 	Ww1SingleSprmPDxaAbs(sal_Char* sName) :
749 		Ww1SingleSprmWord(sName) {
750 		}
751 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
752 };
753 
754 class Ww1SingleSprmPDyaAbs : public Ww1SingleSprmWord {
755 public:
Ww1SingleSprmPDyaAbs(sal_Char * sName)756 	Ww1SingleSprmPDyaAbs(sal_Char* sName) :
757 		Ww1SingleSprmWord(sName) {
758 		}
759 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
760 };
761 
762 class Ww1SingleSprmPDxaWidth : public Ww1SingleSprmWord {
763 public:
Ww1SingleSprmPDxaWidth(sal_Char * sName)764 	Ww1SingleSprmPDxaWidth(sal_Char* sName) :
765 		Ww1SingleSprmWord(sName) {
766 		}
767 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
768 };
769 
770 class Ww1SingleSprmPFromText : public Ww1SingleSprmWord {
771 public:
Ww1SingleSprmPFromText(sal_Char * sName)772 	Ww1SingleSprmPFromText(sal_Char* sName) :
773 		Ww1SingleSprmWord(sName) {
774 		}
775 	void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
776 };
777 
778 ////////////////////////////////////////////////////////////////// Sprm
779 //
780 // der tatsaechlich in der datei auftretende datentyp Sprm
781 //
782 class Ww1Sprm
783 {
784 	sal_Bool ReCalc();
785 	static Ww1SingleSprm* aTab[256];
786 	static Ww1SingleSprm* pSingleSprm;
787 protected:
788 	static void InitTab();
GetTab(sal_uInt16 nId)789 	Ww1SingleSprm& GetTab(sal_uInt16 nId)
790 	{
791 		if( !pSingleSprm )
792 			InitTab();
793 		return aTab[ nId ] ? *aTab[nId] : *pSingleSprm;
794 	}
795 
796 	sal_uInt8* p;
797 	sal_uInt16 nCountBytes;
798 	sal_Bool bOK;
799 	sal_uInt16* pArr;
800 	sal_uInt16 count;
801 // ohne Token, mit laengen-byte/word
802 	sal_uInt16 GetSize(sal_uInt8 nId, sal_uInt8* pSprm);
803 // mit Token und LaengenByte
GetSizeBrutto(sal_uInt8 * pSprm)804 	sal_uInt16 GetSizeBrutto(sal_uInt8* pSprm) {
805 		sal_uInt8 nId = *pSprm++;
806 		return GetSize(nId, pSprm) + 1; }
807 // gibt fuer nTh element id, size & zeiger auf daten:
808 //	sal_Bool Fill(sal_uInt16, sal_uInt8&, sal_uInt16&, sal_uInt8*&);
809 public:
810 // SH: brauche ich public
811 // gibt fuer nTh element id, size & zeiger auf daten:
812 	sal_Bool Fill(sal_uInt16, sal_uInt8&, sal_uInt16&, sal_uInt8*&);
813 
814 	Ww1Sprm(sal_uInt8*, sal_uInt16);
815 	Ww1Sprm(SvStream&, sal_uLong);
816 	~Ww1Sprm();
817 	friend ostream& operator <<(ostream&, Ww1Sprm&);
818 	void Start(Ww1Shell&, Ww1Manager&);
819 	void Start(Ww1Shell&, Ww1Manager&, sal_uInt16);
820 	void Stop(Ww1Shell&, Ww1Manager&);
IsUsed()821 	sal_Bool IsUsed() {
822 		return nCountBytes != 255; }
Count()823 	sal_uInt16 Count() {
824 		return count; }
GetError()825 	sal_Bool GetError() {
826 		return !bOK; }
827 	static void DeinitTab();
828 };
829 
830 /////////////////////////////////////////////////////////////// Picture
831 //
832 // der wrapper um den datentyp PIC, eine struktur, die am beginn eines
833 // bild-dateinamens oder eines eingebetteten bildes steht.
834 //
835 class Ww1Picture
836 {
837 	sal_Bool bOK;
838 	W1_PIC* pPic;
839 public:
840 	Ww1Picture(SvStream&, sal_uLong);
~Ww1Picture()841 	~Ww1Picture() {
842 		}
GetError()843 	sal_Bool GetError() {
844 		return !bOK; }
845 	friend ostream& operator <<(ostream&, Ww1Picture&);
846 	void Out(Ww1Shell&, Ww1Manager&);
847 	void WriteBmp(SvStream&);
848 };
849 
850 /////////////////////////////////////////////////////////////////// Plc
851 //
852 // eine der wichtigen array-strukturen der ww-dateien. sie beinhalten
853 // n+1 dateipositionen und n attribute, die zwischen den
854 // dateipositionen gelten.
855 //
856 class Ww1Plc
857 {
858 	sal_uInt8* p;
859 	sal_uInt16 nCountBytes;
860 	sal_uInt16 iMac;
861 	sal_uInt16 nItemSize;
862 	sal_Bool bOK;
863 protected:
864 	Ww1Fib& rFib;
865 	sal_uInt8* GetData(sal_uInt16);
866 public:
867 	Ww1Plc(Ww1Fib&, sal_uLong, sal_uInt16, sal_uInt16);
868 	~Ww1Plc();
869 	friend ostream& operator <<(ostream&, Ww1Plc&);
870 	sal_uLong Where(sal_uInt16); // wie im jeweiligen plc
871 	void Seek(sal_uLong, sal_uInt16&);
Fill(sal_uInt16 nIndex,sal_uLong & begin,sal_uLong & end)872 	void Fill(sal_uInt16 nIndex, sal_uLong& begin, sal_uLong& end) {
873 		begin = Where(nIndex);
874 		end = Where(nIndex+1); }
Count()875 	sal_uInt16 Count() {
876 		return iMac; }
GetError()877 	sal_Bool GetError() {
878 		return !bOK; }
879 };
880 
881 // Size Tabs from Sven:
882 //    CHP, PAP, SEP, HED, FNR, FNT
883 //Plc 2,   2,   6,   0,   2,   0
884 //Fkp 1,   1,   0,   0,   0,   0
885 
886 /////////////////////////////////////////////////////////// PlcGlossary
887 class Ww1PlcGlossary : public Ww1Plc
888 {
889 public:
Ww1PlcGlossary(Ww1Fib & rFibL)890     Ww1PlcGlossary(Ww1Fib& rFibL) :
891         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfglsyGet(),
892          rFibL.GetFIB().cbPlcfglsyGet(), 0) {
893 		}
894 };
895 
896 ////////////////////////////////////////////////////// PlcAnnotationRef
897 class Ww1PlcAnnotationRef : public Ww1Plc
898 {
899 public:
Ww1PlcAnnotationRef(Ww1Fib & rFibL)900     Ww1PlcAnnotationRef(Ww1Fib& rFibL) :
901         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandRefGet(),
902          rFibL.GetFIB().cbPlcfandRefGet(), 0) {
903 		}
904 };
905 
906 ////////////////////////////////////////////////////// PlcAnnotationTxt
907 class Ww1PlcAnnotationTxt : public Ww1Plc
908 {
909 public:
Ww1PlcAnnotationTxt(Ww1Fib & rFibL)910     Ww1PlcAnnotationTxt(Ww1Fib& rFibL) :
911         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandTxtGet(),
912          rFibL.GetFIB().cbPlcfandTxtGet(), 0) {
913 		}
914 };
915 
916 ///////////////////////////////////////////////////////// PlcAnnotation
917 class Ww1Annotation {
918 	Ww1PlcAnnotationRef aRef;
919 	Ww1PlcAnnotationTxt aTxt;
920 public:
Ww1Annotation(Ww1Fib & rFib)921 	Ww1Annotation(Ww1Fib& rFib) :
922 		aRef(rFib),
923 		aTxt(rFib) {
924 		}
925 	friend ostream& operator <<(ostream&, Ww1Annotation&);
926 };
927 
928 //////////////////////////////////////////////////////////////// PlcSep
929 class Ww1PlcSep : public Ww1Plc
930 {
931 public:
Ww1PlcSep(Ww1Fib & rFibL)932     Ww1PlcSep(Ww1Fib& rFibL):
933         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfsedGet(),
934          rFibL.GetFIB().cbPlcfsedGet(), 6) {
935 		}
936 	friend ostream& operator <<(ostream&, Ww1PlcSep&);
937 };
938 
939 //////////////////////////////////////////////////////////////// PlcChp
940 class Ww1PlcChp : public Ww1Plc
941 {
942 public:
Ww1PlcChp(Ww1Fib & rFibL)943     Ww1PlcChp(Ww1Fib& rFibL) :
944         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbteChpxGet(),
945          rFibL.GetFIB().cbPlcfbteChpxGet(), 2) {
946 		}
947 	friend ostream& operator <<(ostream&, Ww1PlcChp&);
948 };
949 
950 //////////////////////////////////////////////////////////////// PlcPap
951 class Ww1PlcPap : public Ww1Plc
952 {
953 public:
Ww1PlcPap(Ww1Fib & rFibL)954     Ww1PlcPap(Ww1Fib& rFibL) :
955         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbtePapxGet(),
956          rFibL.GetFIB().cbPlcfbtePapxGet(), 2) {
957 		}
958 	friend ostream& operator <<(ostream&, Ww1PlcPap&);
959 };
960 
961 //////////////////////////////////////////////////////// PlcFootnoteRef
962 class Ww1PlcFootnoteRef : public Ww1Plc
963 {
964 public:
Ww1PlcFootnoteRef(Ww1Fib & rFibL)965     Ww1PlcFootnoteRef(Ww1Fib& rFibL) :
966         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndRefGet(),
967          rFibL.GetFIB().cbPlcffndRefGet(), 2) {
968 		}
969 	friend ostream& operator <<(ostream&, Ww1PlcFootnoteRef&);
970 };
971 
972 //////////////////////////////////////////////////////// PlcFootnoteTxt
973 class Ww1PlcFootnoteTxt : public Ww1Plc
974 {
975 public:
Ww1PlcFootnoteTxt(Ww1Fib & rFibL)976     Ww1PlcFootnoteTxt(Ww1Fib& rFibL) :
977         Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndTxtGet(),
978          rFibL.GetFIB().cbPlcffndTxtGet(), 0) {
979 		}
980 	friend ostream& operator <<(ostream&, Ww1PlcFootnoteTxt&);
981 };
982 
983 ///////////////////////////////////////////////////////////// PlcFields
984 class Ww1PlcFields : public Ww1Plc
985 {
986 	//sal_uInt16 Fill(sal_uInt16, sal_uInt8&, String&, String&, String&);
987 public:
Ww1PlcFields(Ww1Fib & rFibL,sal_uLong start,sal_uInt16 nBytes)988     Ww1PlcFields(Ww1Fib& rFibL, sal_uLong start, sal_uInt16 nBytes)
989         : Ww1Plc(rFibL, start, nBytes, 2)
990 	{}
GetData(sal_uInt16 nIndex)991 	W1_FLD* GetData(sal_uInt16 nIndex)
992 		{ return (W1_FLD*)Ww1Plc::GetData(nIndex); }
Where(sal_uInt16 nIndex)993 	sal_uLong Where(sal_uInt16 nIndex)  // absolut im file
994 		{ return Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet(); }
995 	friend ostream& operator <<(ostream&, Ww1PlcFields&);
996 };
997 
998 ///////////////////////////////////////////////////////////// PlcBookmarks
999 class Ww1StringList
1000 {
1001 	sal_Char** pIdxA;
1002 	sal_uInt16 nMax;
1003 public:
1004 	Ww1StringList( SvStream& rSt, sal_uLong nFc, sal_uInt16 nCb );
~Ww1StringList()1005 	~Ww1StringList()
1006 		{ 	if( pIdxA )	{ delete pIdxA[0]; delete pIdxA; } }
1007 	const String GetStr( sal_uInt16 nNum ) const;
Count() const1008 	sal_uInt16 Count() const 	{ return nMax; }
GetError() const1009 	sal_Bool GetError() const 	{ return (nMax != 0) && !pIdxA; }
1010 };
1011 
1012 class Ww1PlcBookmarkTxt: public Ww1StringList
1013 {
1014 public:
Ww1PlcBookmarkTxt(Ww1Fib & rFib)1015 	Ww1PlcBookmarkTxt(Ww1Fib& rFib) :
1016 		Ww1StringList( rFib.GetStream(), rFib.GetFIB().fcSttbfbkmkGet(),
1017 					   rFib.GetFIB().cbSttbfbkmkGet() )
1018 	{}
1019 };
1020 
1021 class Ww1PlcBookmarkPos : public Ww1Plc
1022 {
1023 //	sal_uInt16 Fill(sal_uInt16, sal_uInt8&, String&, String&, String&);
1024 public:
Ww1PlcBookmarkPos(Ww1Fib & _rFib,sal_uLong start,sal_uInt16 nBytes,sal_Bool bEnd)1025     Ww1PlcBookmarkPos(Ww1Fib& _rFib, sal_uLong start, sal_uInt16 nBytes, sal_Bool bEnd)
1026         : Ww1Plc(_rFib, start, nBytes, (bEnd) ? 0 : 2)
1027 	{}
1028 
GetData(sal_uInt16 nIndex)1029 	sal_uInt8* GetData(sal_uInt16 nIndex) 	{	return Ww1Plc::GetData(nIndex); }
1030 	// Position als CP
WhereCP(sal_uInt16 nIndex)1031 	sal_uLong WhereCP(sal_uInt16 nIndex) 	{ return Ww1Plc::Where(nIndex); }
1032 	// absolut im file
Where(sal_uInt16 nIndex)1033 	sal_uLong Where(sal_uInt16 nIndex)
1034 	{
1035 		return ( nIndex < Count() )
1036 			   ? Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet()
1037 			   : 0xffffffff;
1038 	}
1039 //	friend ostream& operator <<(ostream&, Ww1PlcBookmarks&);
1040 };
1041 
1042 //////////////////////////////////////////////////////////////// PlcHdd
1043 class Ww1PlcHdd : public Ww1Plc
1044 {
1045 public:
Ww1PlcHdd(Ww1Fib & rFibL)1046     Ww1PlcHdd(Ww1Fib& rFibL)
1047         : Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfhddGet(),
1048                     rFibL.GetFIB().cbPlcfhddGet(), 0)
1049 	{}
1050 };
1051 
1052 /////////////////////////////////////////////////////////////////// Fkp
1053 //
1054 // aehnlich den plcs aufgebaute arrays, die sich auf eine groesze von
1055 // 512 byte beschraenken.
1056 //
1057 class Ww1Fkp
1058 {
1059 protected:
1060 	sal_uInt8 aFkp[512];
1061 	sal_uInt16 nItemSize;
1062 	sal_Bool bOK;
1063 	sal_uInt8* GetData(sal_uInt16);
1064 public:
1065 	Ww1Fkp(SvStream&, sal_uLong, sal_uInt16);
1066 	friend ostream& operator <<(ostream&, Ww1Fkp&);
Count() const1067 	sal_uInt16 Count() const			{ return SVBT8ToByte(aFkp+511); }
1068 	sal_uLong Where(sal_uInt16); // wie im entsprechenden fkp
1069 };
1070 
1071 //////////////////////////////////////////////////////////////// FkpPap
1072 class Ww1FkpPap : public Ww1Fkp
1073 {
1074 public:
Ww1FkpPap(SvStream & rStream,sal_uLong ulFilePos)1075 	Ww1FkpPap(SvStream& rStream, sal_uLong ulFilePos)
1076 		: Ww1Fkp(rStream, ulFilePos, 1)
1077 	{}
1078 	friend ostream& operator <<(ostream&, Ww1FkpPap&);
1079 	sal_Bool Fill(sal_uInt16,  sal_uInt8*&, sal_uInt16&);
1080 };
1081 
1082 //////////////////////////////////////////////////////////////// FkpChp
1083 class Ww1FkpChp : public Ww1Fkp
1084 {
1085 #ifdef DUMP
1086 	SvStream& rStream;
GetStream()1087 	SvStream& GetStream() 	{ return rStream; }
1088 #endif
1089 public:
Ww1FkpChp(SvStream & rStream,sal_uLong ulFilePos)1090 	Ww1FkpChp(SvStream& rStream, sal_uLong ulFilePos)
1091 		: Ww1Fkp(rStream, ulFilePos, 1)
1092 #ifdef DUMP
1093 		, rStream(rStream)
1094 #endif
1095 	{}
1096 
1097 	friend ostream& operator <<(ostream&, Ww1FkpChp&);
1098 	sal_Bool Fill(sal_uInt16, W1_CHP&);
1099 };
1100 
1101 ////////////////////////////////////////////////////////////// SprmPapx
1102 class Ww1SprmPapx : public Ww1Sprm
1103 {
1104 	W1_PAPX aPapx;
1105 	sal_uInt8* Sprm(sal_uInt8* p, sal_uInt16 nSize);
1106 	sal_uInt16 SprmSize(sal_uInt8* p, sal_uInt16 nSize);
1107 public:
1108 	Ww1SprmPapx(sal_uInt8* p, sal_uInt16 nSize);
1109 	friend ostream& operator <<(ostream&, Ww1SprmPapx&);
1110 	void Start(Ww1Shell&, Ww1Manager&);
1111 	void Stop(Ww1Shell&, Ww1Manager&);
1112 };
1113 
1114 /////////////////////////////////////////////////////////////// SprmSep
1115 class Ww1SprmSep : public Ww1Sprm
1116 {
1117 public:
Ww1SprmSep(Ww1Fib & rFib,sal_uLong ulFilePos)1118 	Ww1SprmSep(Ww1Fib& rFib, sal_uLong ulFilePos)
1119 		: Ww1Sprm(rFib.GetStream(), ulFilePos)
1120 	{}
1121 	friend ostream& operator <<(ostream&, Ww1SprmSep&);
1122 };
1123 
1124 ///////////////////////////////////////////////////////////////// Assoc
1125 class Ww1Assoc
1126 {
1127 	enum fields { FileNext, Dot, Title, Subject, KeyWords, Comments,
1128 		Author, LastRevBy, DataDoc, HeaderDoc, Criteria1, Criteria2,
1129 		Criteria3, Criteria4, Criteria5, Criteria6, Criteria7, MaxFields };
1130 
1131 	Ww1Fib& rFib;
1132 	sal_Char* pBuffer;
1133 	sal_Char* pStrTbl[ MaxFields ];
1134 	sal_Bool bOK;
1135 
1136 	String GetStr(sal_uInt16);
1137 
1138 public:
1139 	Ww1Assoc(Ww1Fib&);
~Ww1Assoc()1140 	~Ww1Assoc() 			{ delete pBuffer; }
GetError() const1141 	sal_Bool GetError() const 	{ return !bOK; }
1142 	friend ostream& operator <<(ostream&, Ww1Assoc&);
1143 	void Out(Ww1Shell&);
1144 };
1145 
1146 ////////////////////////////////////////////////////////// HeaderFooter
1147 //
1148 // Header/Footer/Footnoteseparators sind einer nach dem naechsten in
1149 // einem eigenen text gespeichert. ein plc trennt diesen text in
1150 // einzelne teile.  diese werden durchnummeriert als ihdd. nun gibt es
1151 // 9 verschiedene funktionen fuer diese texte. wird eine davon
1152 // angefordert, ist es der erste, beim naechstern der 2 ihdd und so
1153 // weiter.  welcher textteil also welcher typ sein wird laeszt sich
1154 // nur bei sequenziellem lesen der datei bestimmen. die 9 typen sind:
1155 // fusznoten-trenner, folge-fusznoten-trenner, folge-fusznoten-notiz,
1156 // gerade-seiten kopfzeilen, ungerade seiten kopfzeilen, dto 2*
1157 // fuszzeilen, kopf & fuszzeilen, wenn erste seite andere zeilen hat.
1158 // HeaderFooter merkt sich fuer jede der 9 die momentane einstellung
1159 // (jedoch nicht die alten) und den naechstvergebbaren ihdd.  ist ein
1160 // teil nicht vorhanden bekommt er den wert 0xffff.
1161 //
1162 class Ww1HeaderFooter : public Ww1PlcHdd
1163 {
1164 	sal_uInt16 nextIhdd; // naechster textteil im HddText
1165 	sal_uInt16 nFtnSep; // fusznoten trenner
1166 	sal_uInt16 nFtnFollowSep; // folge fusznoten trenner
1167 	sal_uInt16 nFtnNote; // folgefunsznotennotiz
1168 	sal_uInt16 nEvenHeadL; // kopfzeilen grader seiten
1169 	sal_uInt16 nOddHeadL; // kopfzeilen ungrader seiten
1170 	sal_uInt16 nEvenFootL; // fuszzeilen grader seiten
1171 	sal_uInt16 nOddFootL; // fuszzeilen ungerader seiten
1172 	sal_uInt16 nFirstHeadL; // kopfzeilen der ersten seite
1173 	sal_uInt16 nFirstFootL; // fuszzeilen der ersten seite
1174 	enum HeaderFooterMode {
1175 		None, FtnSep, FtnFollowSep, FtnNote, EvenHeadL, OddHeadL,
1176 		EvenFootL, OddFootL, FirstHeadL, MaxHeaderFooterMode
1177 	} eHeaderFooterMode;
1178 
1179 public:
Ww1HeaderFooter(Ww1Fib & rFibL,sal_uInt16 grpfIhdt)1180     Ww1HeaderFooter(Ww1Fib& rFibL, sal_uInt16 grpfIhdt)
1181         : Ww1PlcHdd(rFibL),
1182 		nextIhdd(0),
1183 		nFtnSep(0xffff),
1184 		nFtnFollowSep(0xffff),
1185 		nFtnNote(0xffff),
1186 		nEvenHeadL(0xffff),
1187 		nOddHeadL(0xffff),
1188 		nEvenFootL(0xffff),
1189 		nOddFootL(0xffff),
1190 		nFirstHeadL(0xffff),
1191 		nFirstFootL(0xffff),
1192 		eHeaderFooterMode(None)
1193 	{
1194 		if (grpfIhdt & 0x0001) nFtnSep = nextIhdd++;
1195 		if (grpfIhdt & 0x0002) nFtnFollowSep = nextIhdd++;
1196 		if (grpfIhdt & 0x0004) nFtnNote = nextIhdd++;
1197 	}
1198 //	~Ww1HeaderFooter() {}
SetGrpfIhdt(sal_uInt16 grpfIhdt)1199 	void SetGrpfIhdt(sal_uInt16 grpfIhdt)
1200 	{
1201 		if (grpfIhdt & 0x0001) nEvenHeadL = nextIhdd++;
1202 		if (grpfIhdt & 0x0002) nOddHeadL = nextIhdd++;
1203 		if (grpfIhdt & 0x0004) nEvenFootL = nextIhdd++;
1204 		if (grpfIhdt & 0x0008) nOddFootL = nextIhdd++;
1205 		if (grpfIhdt & 0x0010) nFirstHeadL = nextIhdd++;
1206 		if (grpfIhdt & 0x0020) nFirstFootL = nextIhdd++;
1207 		DBG_ASSERT(nextIhdd<=Count(), "Ww1HeaderFooter");
1208 	}
operator ++(int)1209 	sal_Bool operator++(int)
1210 	{
1211 		sal_Bool bRet = sal_True;
1212 		eHeaderFooterMode = (HeaderFooterMode)((short)eHeaderFooterMode + 1);
1213 		if( eHeaderFooterMode == MaxHeaderFooterMode)
1214 		{
1215 			eHeaderFooterMode = None;
1216 			bRet = sal_False;
1217 		}
1218 		return bRet;
1219 	}
FillFtnSep(sal_uLong & begin,sal_uLong & end)1220 	sal_Bool FillFtnSep(sal_uLong& begin, sal_uLong& end)
1221 	{
1222 		if (nFtnSep == 0xffff)
1223 			return sal_False;
1224 		Fill(nFtnSep, begin, end);
1225 		return sal_True;
1226 	}
FillFtnFollowSep(sal_uLong & begin,sal_uLong & end)1227 	sal_Bool FillFtnFollowSep(sal_uLong& begin, sal_uLong& end)
1228 	{
1229 		if (nFtnFollowSep == 0xffff)
1230 			return sal_False;
1231 		Fill(nFtnFollowSep, begin, end);
1232 		return sal_True;
1233 	}
FillFtnNote(sal_uLong & begin,sal_uLong & end)1234 	sal_Bool FillFtnNote(sal_uLong& begin, sal_uLong& end)
1235 	{
1236 		if (nFtnNote == 0xffff)
1237 			return sal_False;
1238 		Fill(nFtnNote, begin, end);
1239 		return sal_True;
1240 	}
FillEvenHeadL(sal_uLong & begin,sal_uLong & end)1241 	sal_Bool FillEvenHeadL(sal_uLong& begin, sal_uLong& end)
1242 	{
1243 		if (nEvenHeadL == 0xffff)
1244 			return sal_False;
1245 		Fill(nEvenHeadL, begin, end);
1246 		return sal_True;
1247 	}
FillOddHeadL(sal_uLong & begin,sal_uLong & end)1248 	sal_Bool FillOddHeadL(sal_uLong& begin, sal_uLong& end)
1249 	{
1250 		if (nOddHeadL == 0xffff)
1251 			return sal_False;
1252 		Fill(nOddHeadL, begin, end);
1253 		return sal_True;
1254 	}
FillEvenFootL(sal_uLong & begin,sal_uLong & end)1255 	sal_Bool FillEvenFootL(sal_uLong& begin, sal_uLong& end)
1256 	{
1257 		if (nEvenFootL == 0xffff)
1258 			return sal_False;
1259 		Fill(nEvenFootL, begin, end);
1260 		return sal_True;
1261 	}
FillOddFootL(sal_uLong & begin,sal_uLong & end)1262 	sal_Bool FillOddFootL(sal_uLong& begin, sal_uLong& end)
1263 	{
1264 		if (nOddFootL == 0xffff)
1265 			return sal_False;
1266 		Fill(nOddFootL, begin, end);
1267 		return sal_True;
1268 	}
FillFirstHeadL(sal_uLong & begin,sal_uLong & end)1269 	sal_Bool FillFirstHeadL(sal_uLong& begin, sal_uLong& end)
1270 	{
1271 		if (nFirstHeadL == 0xffff)
1272 			return sal_False;
1273 		Fill(nFirstHeadL, begin, end);
1274 		return sal_True;
1275 	}
FillFirstFootL(sal_uLong & begin,sal_uLong & end)1276 	sal_Bool FillFirstFootL(sal_uLong& begin, sal_uLong& end)
1277 	{
1278 		if (nFirstFootL == 0xffff)
1279 			return sal_False;
1280 		Fill(nFirstFootL, begin, end);
1281 		return sal_True;
1282 	}
1283 	void Start(Ww1Shell&, Ww1Manager&);
1284 	void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1285 };
1286 
1287 //////////////////////////////////////////////////////////////// Fields
1288 class Ww1Fields : public Ww1PlcFields
1289 {
1290 	sal_uInt16 nPlcIndex;
1291 	String sErgebnis; // das von word errechnete ergebniss
1292 	SwField* pField;
Where(sal_uInt16 nIndex)1293 	sal_uLong Where(sal_uInt16 nIndex)  // innerhalb des textes
1294 		{ return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
1295 
1296 public:
Ww1Fields(Ww1Fib & rFibL,sal_uLong ulFilePos,sal_uInt16 nBytes)1297     Ww1Fields(Ww1Fib& rFibL, sal_uLong ulFilePos, sal_uInt16 nBytes)
1298         : Ww1PlcFields(rFibL, ulFilePos, nBytes), nPlcIndex(0), pField(0)
1299 	{}
1300 //	~Ww1Fields() {}
1301 	// innerhalb des textes
Where()1302 	sal_uLong Where() 		{ return Where(nPlcIndex); }
operator ++(int)1303 	void operator++(int)
1304 	{
1305 		DBG_ASSERT(nPlcIndex+1 <= Count(), "Ww1Fields");
1306 		nPlcIndex++;
1307 	}
Seek(sal_uLong ulNew)1308 	void Seek(sal_uLong ulNew) 		{ Ww1PlcFields::Seek(ulNew, nPlcIndex); }
GetData()1309 	W1_FLD* GetData()
1310 	{
1311 		DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
1312 		return Ww1PlcFields::GetData(nPlcIndex);
1313 	}
1314 	sal_uLong GetLength();
1315 	friend ostream& operator <<(ostream&, Ww1Manager&);
1316 	void Start(Ww1Shell&, Ww1Manager&);
1317 	void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1318 	void Out(Ww1Shell&, Ww1Manager&, sal_uInt16=0);
1319 };
1320 
1321 class Ww1TextFields : public Ww1Fields
1322 {
1323 public:
Ww1TextFields(Ww1Fib & rFibL)1324     Ww1TextFields(Ww1Fib& rFibL)
1325         : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMomGet(),
1326                     rFibL.GetFIB().cbPlcffldMomGet())
1327 	{}
1328 };
1329 
1330 class Ww1FootnoteFields : public Ww1Fields
1331 {
1332 public:
Ww1FootnoteFields(Ww1Fib & rFibL)1333     Ww1FootnoteFields(Ww1Fib& rFibL)
1334         : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldFtnGet(),
1335                     rFibL.GetFIB().cbPlcffldFtnGet())
1336 	{}
1337 };
1338 
1339 class Ww1HeaderFooterFields : public Ww1Fields
1340 {
1341 public:
Ww1HeaderFooterFields(Ww1Fib & rFibL)1342     Ww1HeaderFooterFields(Ww1Fib& rFibL)
1343         : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldHdrGet(),
1344                     rFibL.GetFIB().cbPlcffldHdrGet())
1345 	{}
1346 };
1347 
1348 class Ww1MacroFields : public Ww1Fields
1349 {
1350 public:
Ww1MacroFields(Ww1Fib & rFibL)1351     Ww1MacroFields(Ww1Fib& rFibL)
1352         : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMcrGet(),
1353                     rFibL.GetFIB().cbPlcffldMcrGet())
1354 	{}
1355 };
1356 
1357 //////////////////////////////////////////////////////////////// Bookmarks
1358 class Ww1Bookmarks
1359 {
1360 	Ww1PlcBookmarkTxt aNames;
1361 	Ww1PlcBookmarkPos* pPos[2];
1362 	Ww1Fib& rFib;
1363 
1364 	sal_uInt16 nPlcIdx[2];
1365 	sal_uInt16 nIsEnd;
1366 	sal_Bool bOK;
1367 //	sal_uLong Where(sal_uInt16 nIndex) { // innerhalb des textes
1368 //		return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
1369 public:
1370 	Ww1Bookmarks(Ww1Fib& rFib);
~Ww1Bookmarks()1371 	~Ww1Bookmarks()
1372 	{
1373 			delete pPos[1];
1374 			delete pPos[0];
1375 	}
Where() const1376 	sal_uLong Where() const 	{ return pPos[nIsEnd]->WhereCP(nPlcIdx[nIsEnd]); }
1377 	void operator++(int);
GetError() const1378 	sal_Bool GetError() const 	{ return !bOK; }
1379 	long GetHandle() const;
GetIsEnd() const1380 	sal_Bool GetIsEnd() const 	{ return ( nIsEnd ) ? sal_True : sal_False; }
1381 	const String GetName() const;
1382 	long Len() const;
1383 	friend ostream& operator <<(ostream&, Ww1Bookmarks&);
1384 	void Start(Ww1Shell&, Ww1Manager&);
1385 	void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1386 	void Out(Ww1Shell&, Ww1Manager&, sal_uInt16=0);
1387 };
1388 
1389 ///////////////////////////////////////////////////////////// Footnotes
1390 class Ww1Footnotes : public Ww1PlcFootnoteRef
1391 {
1392 	sal_uInt16 nPlcIndex;
1393 	Ww1PlcFootnoteTxt aText;
1394 	sal_Bool bStarted;
1395 public:
Ww1Footnotes(Ww1Fib & rFibL)1396     Ww1Footnotes(Ww1Fib& rFibL)
1397         : Ww1PlcFootnoteRef(rFibL), nPlcIndex(0), aText(rFibL), bStarted(sal_False)
1398 	{}
1399 //	~Ww1Footnotes() {}
1400 	// innerhalb des textes
Where()1401 	sal_uLong Where()
1402 	{
1403 		sal_uLong ulRet = 0xffffffff;
1404 		if (Count())
1405 			ulRet = Ww1PlcFootnoteRef::Where(nPlcIndex);
1406 		return ulRet;
1407 	}
operator ++(int)1408 	void operator++(int)
1409 	{
1410 		DBG_ASSERT(nPlcIndex+1 <= Count(), "Ww1Footnotes");
1411 		nPlcIndex++;
1412 	}
1413 	void Start(Ww1Shell&, Ww1Manager&);
1414 	void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1415 };
1416 
1417 /////////////////////////////////////////////////////////////////// Sep
1418 class Ww1Sep : public Ww1PlcSep
1419 {
1420 	Ww1HeaderFooter aHdd;
1421 	sal_uInt16 nPlcIndex;
1422 public:
Ww1Sep(Ww1Fib & rFibL,sal_uInt16 grpfIhdt)1423     Ww1Sep(Ww1Fib& rFibL, sal_uInt16 grpfIhdt)
1424     : Ww1PlcSep(rFibL), aHdd(rFibL, grpfIhdt), nPlcIndex(0) {}
1425 
GetHdd()1426 	Ww1HeaderFooter& GetHdd() 	{ return aHdd; }
operator ++(int)1427 	void operator++(int) 		{ nPlcIndex++; }
GetData()1428 	sal_uInt8* GetData() 			{ return Ww1PlcSep::GetData(nPlcIndex); }
1429 	// innerhalb des textes
Where()1430 	sal_uLong Where() 				{ return Ww1PlcSep::Where(nPlcIndex); }
SetGrpfIhdt(sal_uInt8 grpfIhdt)1431 	void SetGrpfIhdt(sal_uInt8 grpfIhdt)
1432 	{
1433 		GetHdd().SetGrpfIhdt(grpfIhdt);
1434 //		GetHdd().Start(rOut, rMan);
1435 	}
1436 	void Start(Ww1Shell&, Ww1Manager&);
Stop(Ww1Shell & rOut,Ww1Manager & rMan,sal_Unicode & c)1437 	void Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
1438 		{ aHdd.Stop(rOut, rMan, c); }
1439 };
1440 
1441 /////////////////////////////////////////////////////////////////// Pap
1442 class Ww1Pap : public Ww1PlcPap
1443 {
1444 	sal_uInt16 nPlcIndex;
1445 	sal_uInt16 nPushedPlcIndex;
1446 	sal_uInt16 nFkpIndex;
1447 	sal_uInt16 nPushedFkpIndex;
1448 	sal_uLong ulOffset;
1449 	Ww1FkpPap* pPap;
1450 
1451 	sal_Bool FindSprm(sal_uInt16 nId, sal_uInt8* pStart, sal_uInt8* pEnd);
UpdateIdx()1452 	void UpdateIdx()
1453 	{
1454 		if (pPap && nFkpIndex >= pPap->Count() )
1455 		{
1456 			delete pPap;
1457 			pPap = NULL;
1458 			nPlcIndex++;
1459 		}
1460 		if( !pPap )
1461 			Where();
1462 	}
1463 	sal_Bool HasId0(sal_uInt16 nId);
1464 
1465 public:
1466 	Ww1Pap(Ww1Fib& rFib);
~Ww1Pap()1467 	~Ww1Pap() 	{ delete pPap; }
1468 	sal_uLong Where( sal_Bool bSetIndex = sal_True ); // innerhalb des textes
1469 	void operator++(int);
FillStart(sal_uInt8 * & pB,sal_uInt16 & nSize)1470     sal_Bool FillStart(sal_uInt8*& pB, sal_uInt16& nSize)
1471 	{
1472 		UpdateIdx();
1473         return pPap->Fill(nFkpIndex, pB, nSize);
1474 	}
FillStop(sal_uInt8 * & pB,sal_uInt16 & nSize)1475     sal_Bool FillStop(sal_uInt8*& pB, sal_uInt16& nSize)
1476 	{
1477         return nFkpIndex ? pPap->Fill(nFkpIndex-1, pB, nSize) : sal_False;
1478 	}
1479 	void Start(Ww1Shell&, Ww1Manager&);
1480 	void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1481 	void Seek(sal_uLong);
Push(sal_uLong ulOffsetTmp=0)1482     void Push(sal_uLong ulOffsetTmp = 0)
1483 	{
1484 		DBG_ASSERT(!Pushed(), "Ww1Pap");
1485 		nPushedPlcIndex = nPlcIndex;
1486 		nPushedFkpIndex = nFkpIndex;
1487         Seek(ulOffsetTmp);
1488         ulOffset = ulOffsetTmp;
1489 		delete pPap;
1490 		pPap = NULL;
1491 	}
Pushed()1492 	sal_Bool Pushed()
1493 	{
1494 		return nPushedPlcIndex != 0xffff;
1495 	}
Pop()1496 	void Pop()
1497 	{
1498 		DBG_ASSERT(Pushed(), "Ww1Pap");
1499 		ulOffset = 0;
1500 		nPlcIndex = nPushedPlcIndex;
1501 		nFkpIndex = nPushedFkpIndex;
1502 		nPushedPlcIndex = 0xffff;
1503 		nPushedFkpIndex = 0xffff;
1504 		delete pPap;
1505 		pPap = NULL;
1506 		Where( sal_False );
1507 	}
1508 	sal_Bool HasId(sal_uInt16 nId);
1509 };
1510 
1511 /////////////////////////////////////////////////////////////////// Chp
1512 class Ww1Chp : public Ww1PlcChp
1513 {
1514 	sal_uInt16 nPlcIndex;
1515 	sal_uInt16 nPushedPlcIndex;
1516 	sal_uInt16 nFkpIndex;
1517 	sal_uInt16 nPushedFkpIndex;
1518 	sal_uLong ulOffset;
1519 	Ww1FkpChp* pChp;
UpdateIdx()1520 	void UpdateIdx()
1521 	{
1522 		if (pChp && nFkpIndex >= pChp->Count() )
1523 		{
1524 			delete pChp;
1525 			pChp = NULL;
1526 			nPlcIndex++;
1527 		}
1528 		if( !pChp )
1529 			Where();
1530 	}
1531 
1532 public:
1533 	Ww1Chp( Ww1Fib& rFib );
~Ww1Chp()1534 	~Ww1Chp() 	{ delete pChp; }
1535 	sal_uLong Where( sal_Bool bSetIndex = sal_True ); // innerhalb des textes
1536 	void operator++(int);
FillStart(W1_CHP & rChp)1537 	sal_Bool FillStart(W1_CHP& rChp)
1538 	{
1539 		UpdateIdx();
1540 		return pChp->Fill(nFkpIndex, rChp);
1541 	}
FillStop(W1_CHP & rChp)1542 	sal_Bool FillStop(W1_CHP& rChp)
1543 	{ return nFkpIndex ? pChp->Fill(nFkpIndex-1, rChp) : sal_False;  }
1544 	void Start(Ww1Shell&, Ww1Manager&);
1545 	void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1546 	void Seek(sal_uLong);
Push(sal_uLong ulOffsetTmp=0)1547     void Push(sal_uLong ulOffsetTmp = 0)
1548 	{
1549 		DBG_ASSERT(!Pushed(), "Ww1Chp");
1550 		nPushedPlcIndex = nPlcIndex;
1551 		nPushedFkpIndex = nFkpIndex;
1552         Seek(ulOffsetTmp);
1553         ulOffset = ulOffsetTmp;
1554 		delete pChp;
1555 		pChp = NULL;
1556 	}
Pushed()1557 	sal_Bool Pushed()  				{ return nPushedPlcIndex != 0xffff; }
Pop()1558 	void Pop()
1559 	{
1560 		DBG_ASSERT(Pushed(), "Ww1Chp");
1561 		ulOffset = 0;
1562 		nPlcIndex = nPushedPlcIndex;
1563 		nFkpIndex = nPushedFkpIndex;
1564 		nPushedPlcIndex = 0xffff;
1565 		nPushedFkpIndex = 0xffff;
1566 		delete pChp;
1567 		pChp = NULL;
1568 		Where( sal_False );
1569 	}
1570 };
1571 
1572 /////////////////////////////////////////////////////////////// Manager
1573 //
1574 // zentraler aufhaenger der ww-seite des filters, konstruiert aus dem
1575 // inputstream (ww-datei) enthaelt er alles, was noetig ist, um in die
1576 // shell (pm-seite) gepiped zu werden.
1577 //
1578 class Ww1Manager
1579 {
1580 	sal_Bool bOK;
1581 	sal_Bool bInTtp;
1582 	sal_Bool bInStyle;
1583 	sal_Bool bStopAll;
1584 	Ww1Fib aFib;
1585 	Ww1Dop aDop;
1586 	Ww1Fonts aFonts;
1587 // ab jetzt alles paarig, fuer 'pushed':
1588 	Ww1DocText aDoc;
1589 	Ww1PlainText* pDoc;
1590 	sal_uLong ulDocSeek;
1591 	sal_uLong* pSeek;
1592 	Ww1TextFields aFld;
1593 	Ww1Fields* pFld;
1594 // selbst 'push'bar:
1595 	Ww1Chp aChp;
1596 	Ww1Pap aPap;
1597 // nicht in textbereichen vorhanden, wenn ge'pushed'
1598 	Ww1Footnotes aFtn;
1599 	Ww1Bookmarks aBooks;
1600 	Ww1Sep aSep;
1601 
1602 	void OutStop( Ww1Shell&, sal_Unicode );
1603 	void OutStart( Ww1Shell& );
1604 	void Out(Ww1Shell&, sal_Unicode );
1605 
1606 public:
1607 	Ww1Manager(SvStream& rStrm, sal_uLong nFieldFlgs);
GetError() const1608 	sal_Bool GetError() const 		{ return !bOK; }
1609 
1610 // Fuer Tabellen
SetInTtp(sal_Bool bSet=sal_True)1611 	void SetInTtp(sal_Bool bSet = sal_True) 	{ bInTtp = bSet; }
IsInTtp() const1612 	sal_Bool IsInTtp() const				{ return bInTtp; }
SetInStyle(sal_Bool bSet=sal_True)1613 	void SetInStyle(sal_Bool bSet = sal_True) 	{ bInStyle = bSet; }
IsInStyle() const1614 	sal_Bool IsInStyle() const 				{ return bInStyle; }
SetStopAll(sal_Bool bSet=sal_True)1615 	void SetStopAll(sal_Bool bSet = sal_True) 	{ bStopAll = bSet; }
IsStopAll() const1616 	sal_Bool IsStopAll() const 				{ return bStopAll; }
1617 	sal_Bool HasInTable();
1618 	sal_Bool HasTtp();
1619 	sal_Bool LastHasTtp();
1620 
1621 // Fuer Flys
1622 	sal_Bool HasPPc();
1623 	sal_Bool HasPDxaAbs();
1624 
GetFib()1625 	Ww1Fib& GetFib() 					{ return aFib; }
GetText()1626 	Ww1PlainText& GetText() 			{ return *pDoc; }
GetDop()1627 	Ww1Dop& GetDop() 					{ return aDop; }
GetSep()1628 	Ww1Sep& GetSep() 					{ return aSep; }
1629 	// innerhalb des textes
Where()1630 	sal_uLong Where() 						{ return pDoc->Where(); }
Fill(sal_Unicode & rChr)1631 	void Fill( sal_Unicode& rChr ) 		{ pDoc->Out( rChr ); }
Fill(String & rStr,sal_uLong ulLen)1632 	sal_uInt8 Fill( String& rStr, sal_uLong ulLen)
1633 	{
1634 		ulLen += pDoc->Where();
1635         return sal::static_int_cast< sal_uInt8 >(pDoc->Out(rStr, ulLen));
1636 	}
1637 	SvxFontItem GetFont(sal_uInt16 nFCode);
1638 	friend Ww1Shell& operator <<(Ww1Shell&, Ww1Manager&);
1639 	friend ostream& operator <<(ostream&, Ww1Manager&);
Pushed()1640 	sal_Bool Pushed() 						{ return pDoc != &aDoc; }
1641 	void Pop();
1642 	void Push0(Ww1PlainText* pDoc, sal_uLong, Ww1Fields* = 0);
1643 	void Push1(Ww1PlainText* pDoc, sal_uLong ulSeek, sal_uLong ulSeek2 = 0,
1644 			   Ww1Fields* = 0);
1645 };
1646