update dev300-m58
[ooovba.git] / sw / source / filter / ww1 / w1class.hxx
blob11664f3f6a51cf69cea69a10071954a82ef48984
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: w1class.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <tools/string.hxx>
31 #include <tools/debug.hxx>
33 // local
34 #ifndef _W1STRUCT_HXX
35 #include <w1struct.hxx>
36 #endif
38 #ifdef DUMP
39 #include <fstream.h>
40 #endif
42 #include <ostream>
44 using std::ostream;
46 class SvxFontItem;
47 class SvxBorderLine;
48 class SvxBoxItem;
49 class SvStream;
50 class SwField;
51 class Ww1Annotation;
52 class Ww1AtnText;
53 class Ww1Chp;
54 class Ww1DocText;
55 class Ww1Dop;
56 class Ww1Fib;
57 class Ww1Fkp;
58 class Ww1FkpChp;
59 class Ww1FkpPap;
60 class Ww1Fonts;
61 class Ww1Manager;
62 class Ww1McrText;
63 class Ww1Pap;
64 class Ww1PlainText;
65 class Ww1Plc;
66 class Ww1PlcAnnotationRef;
67 class Ww1PlcAnnotationTxt;
68 class Ww1PlcChp;
69 class Ww1PlcFields;
70 class Ww1PlcFootnoteRef;
71 class Ww1PlcFootnoteTxt;
72 class Ww1PlcGlossary;
73 class Ww1PlcHdd;
74 class Ww1PlcPap;
75 class Ww1PlcSep;
76 class Ww1Shell;
77 class Ww1Sprm;
78 class Ww1SprmPapx;
79 class Ww1SprmSep;
80 class Ww1Style;
81 class Ww1StyleSheet;
83 ///////////////////////////////////////////////////////////////////////
85 // nach moeglichkeit wurden in diesem modul methoden aehnlicher
86 // funktionalitaet gleich benannt. Die namen wurden wenn moeglich vom
87 // ww-filter uebernommen.
88 // Where() gibt die position eines elements. dies kann sowohl eine
89 // seek-position im stream als auch ein relativer offset sein, da dies
90 // bei word durcheinander geht. die methoden sind durch kommentare
91 // gekennzeichnet, ob sie sich auf positionen in der datei oder
92 // innerhalb des textes beziehen. vorsicht: innerhalb des textes kann
93 // verschiedene texte in der datei bedeuten.
94 // Count() gibt die anzahl der elemente zurueck. vorsicht bei
95 // n/n-1-feldern (word speichert strukturen gern in doppel-arrays, in
96 // denen das erste n elemente, das zweite jedoch n-1 elemente
97 // enthaelt.
98 // Fill() fuellt uebergebene referenzen mit daten aus den
99 // word-strukturen.
100 // GetData() gibt zeiger auf den datenbereich zurueck
101 // GetError() gibt zurueck, ob fehler aufgetreten ist
102 // Start(), Stop(), Out(), op<< siehe modul w1filter
103 // Dump() siehe modul w1dump
106 /////////////////////////////////////////////////////////////////// Fib
108 // file information block: wurzel des uebels: steht am beginn der
109 // datei (seek(0)) und enthaelt alle positionen der strukturen der
110 // datei
112 class Ww1Fib
114 W1_FIB aFib;
115 BOOL bOK;
116 SvStream& rStream;
117 public:
118 Ww1Fib(SvStream&);
119 friend ostream& operator <<(ostream&, Ww1Fib&);
120 W1_FIB& GetFIB() { return aFib; }
121 BOOL GetError() { return !bOK; }
122 SvStream& GetStream() { return rStream; }
125 /////////////////////////////////////////////////////////////////// Dop
127 // document property: eigenschaften des gesamten dokuments
129 class Ww1Dop
131 W1_DOP aDop;
132 Ww1Fib& rFib;
133 BOOL bOK;
134 public:
135 Ww1Dop(Ww1Fib&);
136 BOOL GetError() {
137 return !bOK; }
138 W1_DOP& GetDOP() {
139 return aDop; }
140 friend ostream& operator <<(ostream&, Ww1Dop&);
141 void Out(Ww1Shell&);
144 ///////////////////////////////////////////////////////////// PlainText
146 // ww-dateien koennen mehrere textbloecke enthalten (main-text,
147 // fusznoten etc). PlainText vereinigt die gemeinsamkeiten
149 class Ww1PlainText
151 protected:
152 Ww1Fib& rFib;
153 ULONG ulFilePos;
154 ULONG ulCountBytes;
155 ULONG ulSeek;
156 BOOL bOK;
157 public:
158 Ww1PlainText(Ww1Fib& rWwFib, ULONG nFilePos, ULONG nCountBytes);
159 // innerhalb des textes
160 ULONG Where() const { return ulSeek; }
161 void Seek( ULONG ulNew )
163 DBG_ASSERT(ulNew < ulCountBytes, "Ww1PlainText");
164 if (ulNew < ulCountBytes)
165 ulSeek = ulNew;
168 ULONG Count() const { return ulCountBytes; }
169 void SetCount(ULONG ulNew)
171 ulNew += ulSeek;
172 if (ulCountBytes > ulNew)
173 ulCountBytes = ulNew;
175 void operator++(int)
177 DBG_ASSERT(ulSeek+1<ulCountBytes, "Ww1PlainText");
178 ulSeek++;
180 BOOL GetError() { return !bOK; }
181 sal_Unicode Out( Ww1Shell&, ULONG& );
182 sal_Unicode Out( String&, ULONG=0xffffffff);
183 sal_Unicode Out( sal_Unicode& );
184 friend ostream& operator <<(ostream&, Ww1PlainText&);
185 String& Fill( String&, ULONG=0, ULONG=0xffffffff );
186 sal_Unicode operator []( ULONG );
187 String GetText( ULONG ulOffset, ULONG nLen ) const;
189 enum Consts { MinChar = 32 };
190 static BOOL IsChar( sal_Unicode c ) { return c >= MinChar; }
193 /////////////////////////////////////////////////////////////// DocText
194 class Ww1DocText : public Ww1PlainText
196 public:
197 Ww1DocText(Ww1Fib& rFibL) :
198 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet(),
199 rFibL.GetFIB().ccpTextGet()) {
203 /////////////////////////////////////////////////////////////// FtnText
204 class Ww1FtnText : public Ww1PlainText
206 public:
207 ULONG Offset(Ww1Fib& rFibL) {
208 return rFibL.GetFIB().ccpTextGet(); }
209 Ww1FtnText(Ww1Fib& rFibL) :
210 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
211 Offset(rFibL), rFibL.GetFIB().ccpFtnGet()) {
215 /////////////////////////////////////////////////////////////// HddText
216 class Ww1HddText : public Ww1PlainText
218 public:
219 ULONG Offset(Ww1Fib& rFibL) {
220 return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet(); }
221 Ww1HddText(Ww1Fib& rFibL) :
222 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
223 Offset(rFibL), rFibL.GetFIB().ccpHddGet()) {
227 /////////////////////////////////////////////////////////////// McrText
228 class Ww1McrText : public Ww1PlainText
230 public:
231 ULONG Offset(Ww1Fib& rFibL) {
232 return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet()
233 + rFibL.GetFIB().ccpHddGet(); }
234 Ww1McrText(Ww1Fib& rFibL) :
235 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
236 Offset(rFibL), rFibL.GetFIB().ccpMcrGet()) {
240 /////////////////////////////////////////////////////////////// AtnText
241 class Ww1AtnText : public Ww1PlainText
243 public:
244 ULONG Offset(Ww1Fib& rFibL) {
245 return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet()
246 + rFibL.GetFIB().ccpHddGet() + rFibL.GetFIB().ccpMcrGet(); }
247 Ww1AtnText(Ww1Fib& rFibL) :
248 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
249 Offset(rFibL), rFibL.GetFIB().ccpAtnGet()) {
253 ///////////////////////////////////////////////////////////////// Style
255 // ein einzelner style oder vorlage
257 class Ww1Style
259 String aName;
260 W1_CHP aChpx;
261 Ww1SprmPapx* pPapx;
262 Ww1StyleSheet* pParent;
263 BYTE stcBase;
264 BYTE stcNext;
265 BOOL bUsed;
266 public:
267 Ww1Style();
268 ~Ww1Style();
269 BOOL IsUsed() const { return bUsed; }
270 void SetDefaults(BYTE);
271 void SetParent(Ww1StyleSheet* newParent) { pParent = newParent; }
272 void SetName(const String& rName) { bUsed = TRUE; aName = rName; }
273 const String& GetName() const { return aName; }
274 // Ww1Style& GetNext();
275 Ww1Style& GetBase();
276 USHORT GetnBase() const { return stcBase; }
277 USHORT GetnNext() const { return stcNext; }
278 USHORT ReadName(BYTE*&, USHORT&, USHORT stc);
279 USHORT ReadChpx(BYTE*&, USHORT&);
280 USHORT ReadPapx(BYTE*&, USHORT&);
281 USHORT ReadEstcp(BYTE*&, USHORT&);
282 friend ostream& operator <<(ostream&, Ww1Style&);
283 void Out(Ww1Shell&, Ww1Manager&);
286 //////////////////////////////////////////////////////////// StyleSheet
288 // die sammlung aller vorlagen (max. 256)
290 class Ww1StyleSheet
292 Ww1Style aStyles[256];
293 USHORT cstcStd; // count style code standard
294 Ww1Fib& rFib;
295 BOOL bOK;
296 USHORT ReadNames(BYTE*&, USHORT&);
297 USHORT ReadChpx(BYTE*&, USHORT&);
298 USHORT ReadPapx(BYTE*&, USHORT&);
299 USHORT ReadEstcp(BYTE*&, USHORT&);
301 void OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc);
302 void OutOne(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc);
303 void OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc,
304 BYTE* pbStopRecur );
305 public:
306 Ww1StyleSheet(Ww1Fib& rFib);
307 Ww1Style& GetStyle(USHORT stc) {
308 return aStyles[stc]; }
309 USHORT Count() {
310 return 256; }
311 friend ostream& operator <<(ostream&, Ww1StyleSheet&);
312 void Out(Ww1Shell&, Ww1Manager&);
313 friend class Ww1Style;
314 BOOL GetError() {
315 return !bOK; }
318 ///////////////////////////////////////////////////////////////// Fonts
320 // ww kennt nur font-nummern beim formatieren. nebenher gibts ein
321 // array von fonts, damit man aus der nummer einen konkreten font
322 // machen kann.
324 class Ww1Fonts
326 protected:
327 W1_FFN** pFontA; // Array of Pointers to Font Description
328 Ww1Fib& rFib;
329 ULONG nFieldFlags;
330 USHORT nMax; // Array-Groesse
331 BOOL bOK;
332 public:
333 Ww1Fonts(Ww1Fib&, ULONG nFieldFlgs);
334 ~Ww1Fonts() {
335 if (pFontA)
336 DELETEZ(pFontA[0]);
337 DELETEZ(pFontA); }
338 W1_FFN* GetFFN(USHORT nNum);
339 USHORT Count() {
340 return nMax; }
341 friend ostream& operator <<(ostream&, Ww1Fonts&);
342 BOOL GetError() {
343 return !bOK; }
344 SvxFontItem GetFont(USHORT);
347 //////////////////////////////////////////////////////////// SingleSprm
349 // diese klassen ersetzen die aSprmTab etc des ww6-filters. die
350 // funktionspointer sind hier virtuale methoden, fuer die typen (byte,
351 // word, var-sized etc) gibt es abgeleitete klassen. diese haben
352 // methoden zum bestimmen der groesze, dumpen und shell-ausgeben der
353 // Sprms.
354 // die klassen werden mit new (in InitTab()) erzeugt und nach ihrem
355 // code in die tabelle gestellt. zum aktivieren ruft man nun nur noch
356 // die entsprechende methode des objektes in der tabelle auf.
357 // wohlgemerkt: SingleSprms sind die _beschreibung_ und _funktion_ der
358 // Sprms, nicht deren inhalt. dieser musz uebergeben werden an die
359 // einzelnen methoden wie Size, Dump und Start/Stop.
361 class Ww1SingleSprm
363 public:
364 #ifdef DUMP
366 // allein die virtuellen methoden stehen in der vtab, also je nachdem,
367 // ob fuer dumper oder filter uebersetzt wird ausblenden: das spart
368 // platz. ausserdem stehen die methoden fuer dumper bzw filter in
369 // verschiedenen modulen, die im jeweils anderen projekt nicht
370 // uebersetzt werden. das diese dann beim linken nicht zur verfuegung
371 // stehen faellt dann auch nicht auf. Der Namensstring ist nur im
372 // Dumper noetig: weg damit im Filter.
374 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
375 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
376 virtual ostream& Dump(ostream&, BYTE*, USHORT);
377 const sal_Char* sName;
378 #else
379 virtual void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
380 virtual void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
381 ostream& Dump(ostream&, BYTE*, USHORT);
382 #endif
383 virtual USHORT Size(BYTE*);
384 USHORT nCountBytes;
386 Ww1SingleSprm(USHORT nBytes, const sal_Char* /*pName*/ = 0 )
387 : nCountBytes(nBytes)
388 #ifdef DUMP
389 , sName( pName)
390 #endif
395 class Ww1SingleSprmByteSized : public Ww1SingleSprm {
396 public:
397 // ostream& Dump(ostream&, BYTE*, USHORT);
398 USHORT Size(BYTE*);
399 Ww1SingleSprmByteSized(USHORT nBytes, sal_Char* sName = 0) :
400 Ww1SingleSprm(nBytes, sName) {
404 class Ww1SingleSprmWordSized : public Ww1SingleSprm {
405 public:
406 // ostream& Dump(ostream&, BYTE*, USHORT);
407 USHORT Size(BYTE*);
408 Ww1SingleSprmWordSized(USHORT nBytes, sal_Char* sName = 0) :
409 Ww1SingleSprm(nBytes, sName) {
413 class Ww1SingleSprmByte : public Ww1SingleSprm {
414 public:
415 ostream& Dump(ostream&, BYTE*, USHORT);
416 // USHORT Size(BYTE*);
417 Ww1SingleSprmByte(sal_Char* sName = 0) :
418 Ww1SingleSprm(1, sName) {
422 class Ww1SingleSprmBool : public Ww1SingleSprmByte {
423 public:
424 ostream& Dump(ostream&, BYTE*, USHORT);
425 // USHORT Size(BYTE*);
426 Ww1SingleSprmBool(sal_Char* sName = 0) :
427 Ww1SingleSprmByte(sName) {
431 class Ww1SingleSprm4State : public Ww1SingleSprmByte {
432 public:
433 ostream& Dump(ostream&, BYTE*, USHORT);
434 // USHORT Size(BYTE*);
435 Ww1SingleSprm4State(sal_Char* sName = 0) :
436 Ww1SingleSprmByte(sName) {
440 class Ww1SingleSprmWord : public Ww1SingleSprm {
441 public:
442 ostream& Dump(ostream&, BYTE*, USHORT);
443 // USHORT Size(BYTE*);
444 Ww1SingleSprmWord(sal_Char* sName = 0)
445 : Ww1SingleSprm(2, sName) {}
448 class Ww1SingleSprmLong : public Ww1SingleSprm {
449 public:
450 ostream& Dump(ostream&, BYTE*, USHORT);
451 // USHORT Size(BYTE*);
452 Ww1SingleSprmLong(sal_Char* sName = 0) :
453 Ww1SingleSprm(4, sName) {
457 class Ww1SingleSprmTab : public Ww1SingleSprm {
458 public:
459 ostream& Dump(ostream&, BYTE*, USHORT);
460 USHORT Size(BYTE*);
461 Ww1SingleSprmTab(USHORT nBytes, sal_Char* sName = 0) :
462 Ww1SingleSprm(nBytes, sName) {
466 class Ww1SingleSprmPJc : public Ww1SingleSprmByte {
467 public:
468 Ww1SingleSprmPJc(sal_Char* sName) :
469 Ww1SingleSprmByte(sName) {
471 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
472 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
475 class Ww1SingleSprmPDxa : public Ww1SingleSprmWord {
476 public:
477 Ww1SingleSprmPDxa(sal_Char* sName) :
478 Ww1SingleSprmWord(sName) {
480 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
483 class Ww1SingleSprmPDxaRight : public Ww1SingleSprmPDxa {
484 public:
485 Ww1SingleSprmPDxaRight(sal_Char* sName) :
486 Ww1SingleSprmPDxa(sName) {
488 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
491 class Ww1SingleSprmPDxaLeft : public Ww1SingleSprmPDxa {
492 public:
493 Ww1SingleSprmPDxaLeft(sal_Char* sName) :
494 Ww1SingleSprmPDxa(sName) {
496 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
499 class Ww1SingleSprmPDxaLeft1 : public Ww1SingleSprmPDxa {
500 public:
501 Ww1SingleSprmPDxaLeft1(sal_Char* sName) :
502 Ww1SingleSprmPDxa(sName) {
504 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
507 class Ww1SingleSprmPFKeep : public Ww1SingleSprmBool {
508 public:
509 Ww1SingleSprmPFKeep(sal_Char* sName) :
510 Ww1SingleSprmBool(sName) {
512 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
513 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
516 class Ww1SingleSprmPFKeepFollow : public Ww1SingleSprmBool {
517 public:
518 Ww1SingleSprmPFKeepFollow(sal_Char* sName) :
519 Ww1SingleSprmBool(sName) {
521 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
522 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
525 class Ww1SingleSprmPPageBreakBefore : public Ww1SingleSprmBool {
526 public:
527 Ww1SingleSprmPPageBreakBefore(sal_Char* sName) :
528 Ww1SingleSprmBool(sName) {
530 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
531 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
534 class Ww1SingleSprmPBrc : public Ww1SingleSprmWord {
535 protected:
536 // SvxBorderLine* SetBorder(SvxBorderLine*, W1_BRC*);
537 // spezielle start-routine, je nach sprm verschieden versorgt
538 // mit einem BoxItem.
539 void Start(Ww1Shell&, BYTE, W1_BRC10*, USHORT, Ww1Manager&, SvxBoxItem&);
540 void Start(Ww1Shell&, BYTE, W1_BRC*, USHORT, Ww1Manager&, SvxBoxItem&);
542 using Ww1SingleSprm::Start;
544 public:
545 Ww1SingleSprmPBrc(sal_Char* sName) :
546 Ww1SingleSprmWord(sName) {
548 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
549 // SetBorder() wird auch fuer Tabellen gebraucht, deshalb public
550 static SvxBorderLine* SetBorder(SvxBorderLine*, W1_BRC10*);
553 #define BRC_TOP ((USHORT)0)
554 #define BRC_LEFT ((USHORT)1)
555 #define BRC_BOTTOM ((USHORT)2)
556 #define BRC_RIGHT ((USHORT)3)
557 #define BRC_ANZ ((USHORT)BRC_RIGHT-BRC_TOP+1)
559 // Die BRC-struktur fuer 1.0 versionen von word sind verschieden von
560 // denen der folgenden versionen. diese werden zum glueck aber auch
561 // von anderen sprms abgerufen.
562 // SH: Ab sofort alle 4 Umrandungen ueber nur 1 Klasse.
563 class Ww1SingleSprmPBrc10 : public Ww1SingleSprmPBrc
565 USHORT nLine; // BRC_TOP, BRC_LEFT, ...
567 using Ww1SingleSprmPBrc::Start;
569 public:
570 Ww1SingleSprmPBrc10(USHORT nL, sal_Char* sName)
571 : Ww1SingleSprmPBrc(sName), nLine(nL) {}
573 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
576 class Ww1SingleSprmParaSpace : public Ww1SingleSprmWord {
577 public:
578 Ww1SingleSprmParaSpace(sal_Char* sName)
579 : Ww1SingleSprmWord(sName) {}
580 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
583 class Ww1SingleSprmPDyaBefore : public Ww1SingleSprmParaSpace {
584 public:
585 Ww1SingleSprmPDyaBefore(sal_Char* sName)
586 : Ww1SingleSprmParaSpace(sName) {}
587 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
590 class Ww1SingleSprmPDyaAfter : public Ww1SingleSprmParaSpace {
591 public:
592 Ww1SingleSprmPDyaAfter(sal_Char* sName) :
593 Ww1SingleSprmParaSpace(sName) {
595 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
598 class Ww1SingleSprmPDyaLine : public Ww1SingleSprmWord {
599 public:
600 Ww1SingleSprmPDyaLine(sal_Char* sName) :
601 Ww1SingleSprmWord(sName) {
603 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
604 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
607 class Ww1SingleSprmPChgTabsPapx : public Ww1SingleSprmByteSized {
608 public:
609 Ww1SingleSprmPChgTabsPapx(sal_Char* sName) :
610 Ww1SingleSprmByteSized(0, sName) {
612 // Size() ist noch nicht aktiviert !!
613 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
614 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
617 class Ww1SingleSprmSGprfIhdt : public Ww1SingleSprmByte {
618 public:
619 Ww1SingleSprmSGprfIhdt(sal_Char* sName) :
620 Ww1SingleSprmByte(sName) {
622 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
625 class Ww1SingleSprmSColumns : public Ww1SingleSprmWord {
626 public:
627 Ww1SingleSprmSColumns(sal_Char* sName) :
628 Ww1SingleSprmWord(sName) {
630 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
633 class Ww1SingleSprmPFInTable : public Ww1SingleSprmBool {
634 public:
635 Ww1SingleSprmPFInTable(sal_Char* sName) :
636 Ww1SingleSprmBool(sName) {
638 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
639 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
642 class Ww1SingleSprmPTtp : public Ww1SingleSprmBool {
643 public:
644 Ww1SingleSprmPTtp(sal_Char* sName) :
645 Ww1SingleSprmBool(sName) {
647 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
648 void Stop(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
651 class Ww1SingleSprmTJc : public Ww1SingleSprmWord {
652 public:
653 Ww1SingleSprmTJc(sal_Char* sName)
654 : Ww1SingleSprmWord(sName) {}
657 //class Ww1SingleSprmTDxaLeft : public Ww1SingleSprmWord {
658 //public:
659 // Ww1SingleSprmTDxaLeft(sal_Char* sName) :
660 // Ww1SingleSprmWord(sName) {
661 // }
662 // void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
663 //};
665 class Ww1SingleSprmTDxaGapHalf : public Ww1SingleSprmWord {
666 public:
667 Ww1SingleSprmTDxaGapHalf(sal_Char* sName) :
668 Ww1SingleSprmWord(sName) {
670 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
673 class Ww1SingleSprmTDefTable10 : public Ww1SingleSprmWordSized {
674 public:
675 Ww1SingleSprmTDefTable10(sal_Char* sName) :
676 Ww1SingleSprmWordSized(0, sName) {
678 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
681 class Ww1SingleSprmTDyaRowHeight : public Ww1SingleSprmWord {
682 public:
683 Ww1SingleSprmTDyaRowHeight(sal_Char* sName) :
684 Ww1SingleSprmWord(sName) {
686 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
689 // Klassendefinitionen fuer Tabellen-Fastsave-Attribute
690 // Da wir kein Fastsave unterstuetzen, brauchen wir's nicht
692 #if 0
694 class Ww1SingleSprmTInsert : public Ww1SingleSprm {
695 public:
696 Ww1SingleSprmTInsert(sal_Char* sName) :
697 Ww1SingleSprm(4, sName) {
699 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
702 class Ww1SingleSprmTDelete : public Ww1SingleSprmWord {
703 public:
704 Ww1SingleSprmTDelete(sal_Char* sName) :
705 Ww1SingleSprmWord(sName) {
707 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
710 class Ww1SingleSprmTDxaCol : public Ww1SingleSprm {
711 public:
712 Ww1SingleSprmTDxaCol(sal_Char* sName) :
713 Ww1SingleSprm(4, sName) {
715 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
718 class Ww1SingleSprmTMerge : public Ww1SingleSprmWord {
719 public:
720 Ww1SingleSprmTMerge(sal_Char* sName) :
721 Ww1SingleSprmWord(sName) {
723 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
726 class Ww1SingleSprmTSplit : public Ww1SingleSprmWord {
727 public:
728 Ww1SingleSprmTSplit(sal_Char* sName) :
729 Ww1SingleSprmWord(sName) {
731 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
734 class Ww1SingleSprmTSetBrc10 : public Ww1SingleSprm {
735 public:
736 Ww1SingleSprmTSetBrc10(sal_Char* sName) :
737 Ww1SingleSprm(5, sName) {
739 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
741 #endif // 0
743 // Klassendefinitionen fuer Apos ( == Flys )
745 class Ww1SingleSprmPpc : public Ww1SingleSprmByte {
746 public:
747 Ww1SingleSprmPpc(sal_Char* sName) :
748 Ww1SingleSprmByte(sName) {
750 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
753 class Ww1SingleSprmPDxaAbs : public Ww1SingleSprmWord {
754 public:
755 Ww1SingleSprmPDxaAbs(sal_Char* sName) :
756 Ww1SingleSprmWord(sName) {
758 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
761 class Ww1SingleSprmPDyaAbs : public Ww1SingleSprmWord {
762 public:
763 Ww1SingleSprmPDyaAbs(sal_Char* sName) :
764 Ww1SingleSprmWord(sName) {
766 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
769 class Ww1SingleSprmPDxaWidth : public Ww1SingleSprmWord {
770 public:
771 Ww1SingleSprmPDxaWidth(sal_Char* sName) :
772 Ww1SingleSprmWord(sName) {
774 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
777 class Ww1SingleSprmPFromText : public Ww1SingleSprmWord {
778 public:
779 Ww1SingleSprmPFromText(sal_Char* sName) :
780 Ww1SingleSprmWord(sName) {
782 void Start(Ww1Shell&, BYTE, BYTE*, USHORT, Ww1Manager&);
785 ////////////////////////////////////////////////////////////////// Sprm
787 // der tatsaechlich in der datei auftretende datentyp Sprm
789 class Ww1Sprm
791 BOOL ReCalc();
792 static Ww1SingleSprm* aTab[256];
793 static Ww1SingleSprm* pSingleSprm;
794 protected:
795 static void InitTab();
796 Ww1SingleSprm& GetTab(USHORT nId)
798 if( !pSingleSprm )
799 InitTab();
800 return aTab[ nId ] ? *aTab[nId] : *pSingleSprm;
803 BYTE* p;
804 USHORT nCountBytes;
805 BOOL bOK;
806 USHORT* pArr;
807 USHORT count;
808 // ohne Token, mit laengen-byte/word
809 USHORT GetSize(BYTE nId, BYTE* pSprm);
810 // mit Token und LaengenByte
811 USHORT GetSizeBrutto(BYTE* pSprm) {
812 BYTE nId = *pSprm++;
813 return GetSize(nId, pSprm) + 1; }
814 // gibt fuer nTh element id, size & zeiger auf daten:
815 // BOOL Fill(USHORT, BYTE&, USHORT&, BYTE*&);
816 public:
817 // SH: brauche ich public
818 // gibt fuer nTh element id, size & zeiger auf daten:
819 BOOL Fill(USHORT, BYTE&, USHORT&, BYTE*&);
821 Ww1Sprm(BYTE*, USHORT);
822 Ww1Sprm(SvStream&, ULONG);
823 ~Ww1Sprm();
824 friend ostream& operator <<(ostream&, Ww1Sprm&);
825 void Start(Ww1Shell&, Ww1Manager&);
826 void Start(Ww1Shell&, Ww1Manager&, USHORT);
827 void Stop(Ww1Shell&, Ww1Manager&);
828 BOOL IsUsed() {
829 return nCountBytes != 255; }
830 USHORT Count() {
831 return count; }
832 BOOL GetError() {
833 return !bOK; }
834 static void DeinitTab();
837 /////////////////////////////////////////////////////////////// Picture
839 // der wrapper um den datentyp PIC, eine struktur, die am beginn eines
840 // bild-dateinamens oder eines eingebetteten bildes steht.
842 class Ww1Picture
844 BOOL bOK;
845 W1_PIC* pPic;
846 public:
847 Ww1Picture(SvStream&, ULONG);
848 ~Ww1Picture() {
850 BOOL GetError() {
851 return !bOK; }
852 friend ostream& operator <<(ostream&, Ww1Picture&);
853 void Out(Ww1Shell&, Ww1Manager&);
854 void WriteBmp(SvStream&);
857 /////////////////////////////////////////////////////////////////// Plc
859 // eine der wichtigen array-strukturen der ww-dateien. sie beinhalten
860 // n+1 dateipositionen und n attribute, die zwischen den
861 // dateipositionen gelten.
863 class Ww1Plc
865 BYTE* p;
866 USHORT nCountBytes;
867 USHORT iMac;
868 USHORT nItemSize;
869 BOOL bOK;
870 protected:
871 Ww1Fib& rFib;
872 BYTE* GetData(USHORT);
873 public:
874 Ww1Plc(Ww1Fib&, ULONG, USHORT, USHORT);
875 ~Ww1Plc();
876 friend ostream& operator <<(ostream&, Ww1Plc&);
877 ULONG Where(USHORT); // wie im jeweiligen plc
878 void Seek(ULONG, USHORT&);
879 void Fill(USHORT nIndex, ULONG& begin, ULONG& end) {
880 begin = Where(nIndex);
881 end = Where(nIndex+1); }
882 USHORT Count() {
883 return iMac; }
884 BOOL GetError() {
885 return !bOK; }
888 // Size Tabs from Sven:
889 // CHP, PAP, SEP, HED, FNR, FNT
890 //Plc 2, 2, 6, 0, 2, 0
891 //Fkp 1, 1, 0, 0, 0, 0
893 /////////////////////////////////////////////////////////// PlcGlossary
894 class Ww1PlcGlossary : public Ww1Plc
896 public:
897 Ww1PlcGlossary(Ww1Fib& rFibL) :
898 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfglsyGet(),
899 rFibL.GetFIB().cbPlcfglsyGet(), 0) {
903 ////////////////////////////////////////////////////// PlcAnnotationRef
904 class Ww1PlcAnnotationRef : public Ww1Plc
906 public:
907 Ww1PlcAnnotationRef(Ww1Fib& rFibL) :
908 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandRefGet(),
909 rFibL.GetFIB().cbPlcfandRefGet(), 0) {
913 ////////////////////////////////////////////////////// PlcAnnotationTxt
914 class Ww1PlcAnnotationTxt : public Ww1Plc
916 public:
917 Ww1PlcAnnotationTxt(Ww1Fib& rFibL) :
918 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandTxtGet(),
919 rFibL.GetFIB().cbPlcfandTxtGet(), 0) {
923 ///////////////////////////////////////////////////////// PlcAnnotation
924 class Ww1Annotation {
925 Ww1PlcAnnotationRef aRef;
926 Ww1PlcAnnotationTxt aTxt;
927 public:
928 Ww1Annotation(Ww1Fib& rFib) :
929 aRef(rFib),
930 aTxt(rFib) {
932 friend ostream& operator <<(ostream&, Ww1Annotation&);
935 //////////////////////////////////////////////////////////////// PlcSep
936 class Ww1PlcSep : public Ww1Plc
938 public:
939 Ww1PlcSep(Ww1Fib& rFibL):
940 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfsedGet(),
941 rFibL.GetFIB().cbPlcfsedGet(), 6) {
943 friend ostream& operator <<(ostream&, Ww1PlcSep&);
946 //////////////////////////////////////////////////////////////// PlcChp
947 class Ww1PlcChp : public Ww1Plc
949 public:
950 Ww1PlcChp(Ww1Fib& rFibL) :
951 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbteChpxGet(),
952 rFibL.GetFIB().cbPlcfbteChpxGet(), 2) {
954 friend ostream& operator <<(ostream&, Ww1PlcChp&);
957 //////////////////////////////////////////////////////////////// PlcPap
958 class Ww1PlcPap : public Ww1Plc
960 public:
961 Ww1PlcPap(Ww1Fib& rFibL) :
962 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbtePapxGet(),
963 rFibL.GetFIB().cbPlcfbtePapxGet(), 2) {
965 friend ostream& operator <<(ostream&, Ww1PlcPap&);
968 //////////////////////////////////////////////////////// PlcFootnoteRef
969 class Ww1PlcFootnoteRef : public Ww1Plc
971 public:
972 Ww1PlcFootnoteRef(Ww1Fib& rFibL) :
973 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndRefGet(),
974 rFibL.GetFIB().cbPlcffndRefGet(), 2) {
976 friend ostream& operator <<(ostream&, Ww1PlcFootnoteRef&);
979 //////////////////////////////////////////////////////// PlcFootnoteTxt
980 class Ww1PlcFootnoteTxt : public Ww1Plc
982 public:
983 Ww1PlcFootnoteTxt(Ww1Fib& rFibL) :
984 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndTxtGet(),
985 rFibL.GetFIB().cbPlcffndTxtGet(), 0) {
987 friend ostream& operator <<(ostream&, Ww1PlcFootnoteTxt&);
990 ///////////////////////////////////////////////////////////// PlcFields
991 class Ww1PlcFields : public Ww1Plc
993 //USHORT Fill(USHORT, BYTE&, String&, String&, String&);
994 public:
995 Ww1PlcFields(Ww1Fib& rFibL, ULONG start, USHORT nBytes)
996 : Ww1Plc(rFibL, start, nBytes, 2)
998 W1_FLD* GetData(USHORT nIndex)
999 { return (W1_FLD*)Ww1Plc::GetData(nIndex); }
1000 ULONG Where(USHORT nIndex) // absolut im file
1001 { return Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet(); }
1002 friend ostream& operator <<(ostream&, Ww1PlcFields&);
1005 ///////////////////////////////////////////////////////////// PlcBookmarks
1006 class Ww1StringList
1008 sal_Char** pIdxA;
1009 USHORT nMax;
1010 public:
1011 Ww1StringList( SvStream& rSt, ULONG nFc, USHORT nCb );
1012 ~Ww1StringList()
1013 { if( pIdxA ) { delete pIdxA[0]; delete pIdxA; } }
1014 const String GetStr( USHORT nNum ) const;
1015 USHORT Count() const { return nMax; }
1016 BOOL GetError() const { return (nMax != 0) && !pIdxA; }
1019 class Ww1PlcBookmarkTxt: public Ww1StringList
1021 public:
1022 Ww1PlcBookmarkTxt(Ww1Fib& rFib) :
1023 Ww1StringList( rFib.GetStream(), rFib.GetFIB().fcSttbfbkmkGet(),
1024 rFib.GetFIB().cbSttbfbkmkGet() )
1028 class Ww1PlcBookmarkPos : public Ww1Plc
1030 // USHORT Fill(USHORT, BYTE&, String&, String&, String&);
1031 public:
1032 Ww1PlcBookmarkPos(Ww1Fib& _rFib, ULONG start, USHORT nBytes, BOOL bEnd)
1033 : Ww1Plc(_rFib, start, nBytes, (bEnd) ? 0 : 2)
1036 BYTE* GetData(USHORT nIndex) { return Ww1Plc::GetData(nIndex); }
1037 // Position als CP
1038 ULONG WhereCP(USHORT nIndex) { return Ww1Plc::Where(nIndex); }
1039 // absolut im file
1040 ULONG Where(USHORT nIndex)
1042 return ( nIndex < Count() )
1043 ? Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet()
1044 : 0xffffffff;
1046 // friend ostream& operator <<(ostream&, Ww1PlcBookmarks&);
1049 //////////////////////////////////////////////////////////////// PlcHdd
1050 class Ww1PlcHdd : public Ww1Plc
1052 public:
1053 Ww1PlcHdd(Ww1Fib& rFibL)
1054 : Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfhddGet(),
1055 rFibL.GetFIB().cbPlcfhddGet(), 0)
1059 /////////////////////////////////////////////////////////////////// Fkp
1061 // aehnlich den plcs aufgebaute arrays, die sich auf eine groesze von
1062 // 512 byte beschraenken.
1064 class Ww1Fkp
1066 protected:
1067 BYTE aFkp[512];
1068 USHORT nItemSize;
1069 BOOL bOK;
1070 BYTE* GetData(USHORT);
1071 public:
1072 Ww1Fkp(SvStream&, ULONG, USHORT);
1073 friend ostream& operator <<(ostream&, Ww1Fkp&);
1074 USHORT Count() const { return SVBT8ToByte(aFkp+511); }
1075 ULONG Where(USHORT); // wie im entsprechenden fkp
1078 //////////////////////////////////////////////////////////////// FkpPap
1079 class Ww1FkpPap : public Ww1Fkp
1081 public:
1082 Ww1FkpPap(SvStream& rStream, ULONG ulFilePos)
1083 : Ww1Fkp(rStream, ulFilePos, 1)
1085 friend ostream& operator <<(ostream&, Ww1FkpPap&);
1086 BOOL Fill(USHORT, BYTE*&, USHORT&);
1089 //////////////////////////////////////////////////////////////// FkpChp
1090 class Ww1FkpChp : public Ww1Fkp
1092 #ifdef DUMP
1093 SvStream& rStream;
1094 SvStream& GetStream() { return rStream; }
1095 #endif
1096 public:
1097 Ww1FkpChp(SvStream& rStream, ULONG ulFilePos)
1098 : Ww1Fkp(rStream, ulFilePos, 1)
1099 #ifdef DUMP
1100 , rStream(rStream)
1101 #endif
1104 friend ostream& operator <<(ostream&, Ww1FkpChp&);
1105 BOOL Fill(USHORT, W1_CHP&);
1108 ////////////////////////////////////////////////////////////// SprmPapx
1109 class Ww1SprmPapx : public Ww1Sprm
1111 W1_PAPX aPapx;
1112 BYTE* Sprm(BYTE* p, USHORT nSize);
1113 USHORT SprmSize(BYTE* p, USHORT nSize);
1114 public:
1115 Ww1SprmPapx(BYTE* p, USHORT nSize);
1116 friend ostream& operator <<(ostream&, Ww1SprmPapx&);
1117 void Start(Ww1Shell&, Ww1Manager&);
1118 void Stop(Ww1Shell&, Ww1Manager&);
1121 /////////////////////////////////////////////////////////////// SprmSep
1122 class Ww1SprmSep : public Ww1Sprm
1124 public:
1125 Ww1SprmSep(Ww1Fib& rFib, ULONG ulFilePos)
1126 : Ww1Sprm(rFib.GetStream(), ulFilePos)
1128 friend ostream& operator <<(ostream&, Ww1SprmSep&);
1131 ///////////////////////////////////////////////////////////////// Assoc
1132 class Ww1Assoc
1134 enum fields { FileNext, Dot, Title, Subject, KeyWords, Comments,
1135 Author, LastRevBy, DataDoc, HeaderDoc, Criteria1, Criteria2,
1136 Criteria3, Criteria4, Criteria5, Criteria6, Criteria7, MaxFields };
1138 Ww1Fib& rFib;
1139 sal_Char* pBuffer;
1140 sal_Char* pStrTbl[ MaxFields ];
1141 BOOL bOK;
1143 String GetStr(USHORT);
1145 public:
1146 Ww1Assoc(Ww1Fib&);
1147 ~Ww1Assoc() { delete pBuffer; }
1148 BOOL GetError() const { return !bOK; }
1149 friend ostream& operator <<(ostream&, Ww1Assoc&);
1150 void Out(Ww1Shell&);
1153 ////////////////////////////////////////////////////////// HeaderFooter
1155 // Header/Footer/Footnoteseparators sind einer nach dem naechsten in
1156 // einem eigenen text gespeichert. ein plc trennt diesen text in
1157 // einzelne teile. diese werden durchnummeriert als ihdd. nun gibt es
1158 // 9 verschiedene funktionen fuer diese texte. wird eine davon
1159 // angefordert, ist es der erste, beim naechstern der 2 ihdd und so
1160 // weiter. welcher textteil also welcher typ sein wird laeszt sich
1161 // nur bei sequenziellem lesen der datei bestimmen. die 9 typen sind:
1162 // fusznoten-trenner, folge-fusznoten-trenner, folge-fusznoten-notiz,
1163 // gerade-seiten kopfzeilen, ungerade seiten kopfzeilen, dto 2*
1164 // fuszzeilen, kopf & fuszzeilen, wenn erste seite andere zeilen hat.
1165 // HeaderFooter merkt sich fuer jede der 9 die momentane einstellung
1166 // (jedoch nicht die alten) und den naechstvergebbaren ihdd. ist ein
1167 // teil nicht vorhanden bekommt er den wert 0xffff.
1169 class Ww1HeaderFooter : public Ww1PlcHdd
1171 USHORT nextIhdd; // naechster textteil im HddText
1172 USHORT nFtnSep; // fusznoten trenner
1173 USHORT nFtnFollowSep; // folge fusznoten trenner
1174 USHORT nFtnNote; // folgefunsznotennotiz
1175 USHORT nEvenHeadL; // kopfzeilen grader seiten
1176 USHORT nOddHeadL; // kopfzeilen ungrader seiten
1177 USHORT nEvenFootL; // fuszzeilen grader seiten
1178 USHORT nOddFootL; // fuszzeilen ungerader seiten
1179 USHORT nFirstHeadL; // kopfzeilen der ersten seite
1180 USHORT nFirstFootL; // fuszzeilen der ersten seite
1181 enum HeaderFooterMode {
1182 None, FtnSep, FtnFollowSep, FtnNote, EvenHeadL, OddHeadL,
1183 EvenFootL, OddFootL, FirstHeadL, MaxHeaderFooterMode
1184 } eHeaderFooterMode;
1186 public:
1187 Ww1HeaderFooter(Ww1Fib& rFibL, USHORT grpfIhdt)
1188 : Ww1PlcHdd(rFibL),
1189 nextIhdd(0),
1190 nFtnSep(0xffff),
1191 nFtnFollowSep(0xffff),
1192 nFtnNote(0xffff),
1193 nEvenHeadL(0xffff),
1194 nOddHeadL(0xffff),
1195 nEvenFootL(0xffff),
1196 nOddFootL(0xffff),
1197 nFirstHeadL(0xffff),
1198 nFirstFootL(0xffff),
1199 eHeaderFooterMode(None)
1201 if (grpfIhdt & 0x0001) nFtnSep = nextIhdd++;
1202 if (grpfIhdt & 0x0002) nFtnFollowSep = nextIhdd++;
1203 if (grpfIhdt & 0x0004) nFtnNote = nextIhdd++;
1205 // ~Ww1HeaderFooter() {}
1206 void SetGrpfIhdt(USHORT grpfIhdt)
1208 if (grpfIhdt & 0x0001) nEvenHeadL = nextIhdd++;
1209 if (grpfIhdt & 0x0002) nOddHeadL = nextIhdd++;
1210 if (grpfIhdt & 0x0004) nEvenFootL = nextIhdd++;
1211 if (grpfIhdt & 0x0008) nOddFootL = nextIhdd++;
1212 if (grpfIhdt & 0x0010) nFirstHeadL = nextIhdd++;
1213 if (grpfIhdt & 0x0020) nFirstFootL = nextIhdd++;
1214 DBG_ASSERT(nextIhdd<=Count(), "Ww1HeaderFooter");
1216 BOOL operator++(int)
1218 BOOL bRet = TRUE;
1219 eHeaderFooterMode = (HeaderFooterMode)((short)eHeaderFooterMode + 1);
1220 if( eHeaderFooterMode == MaxHeaderFooterMode)
1222 eHeaderFooterMode = None;
1223 bRet = FALSE;
1225 return bRet;
1227 BOOL FillFtnSep(ULONG& begin, ULONG& end)
1229 if (nFtnSep == 0xffff)
1230 return FALSE;
1231 Fill(nFtnSep, begin, end);
1232 return TRUE;
1234 BOOL FillFtnFollowSep(ULONG& begin, ULONG& end)
1236 if (nFtnFollowSep == 0xffff)
1237 return FALSE;
1238 Fill(nFtnFollowSep, begin, end);
1239 return TRUE;
1241 BOOL FillFtnNote(ULONG& begin, ULONG& end)
1243 if (nFtnNote == 0xffff)
1244 return FALSE;
1245 Fill(nFtnNote, begin, end);
1246 return TRUE;
1248 BOOL FillEvenHeadL(ULONG& begin, ULONG& end)
1250 if (nEvenHeadL == 0xffff)
1251 return FALSE;
1252 Fill(nEvenHeadL, begin, end);
1253 return TRUE;
1255 BOOL FillOddHeadL(ULONG& begin, ULONG& end)
1257 if (nOddHeadL == 0xffff)
1258 return FALSE;
1259 Fill(nOddHeadL, begin, end);
1260 return TRUE;
1262 BOOL FillEvenFootL(ULONG& begin, ULONG& end)
1264 if (nEvenFootL == 0xffff)
1265 return FALSE;
1266 Fill(nEvenFootL, begin, end);
1267 return TRUE;
1269 BOOL FillOddFootL(ULONG& begin, ULONG& end)
1271 if (nOddFootL == 0xffff)
1272 return FALSE;
1273 Fill(nOddFootL, begin, end);
1274 return TRUE;
1276 BOOL FillFirstHeadL(ULONG& begin, ULONG& end)
1278 if (nFirstHeadL == 0xffff)
1279 return FALSE;
1280 Fill(nFirstHeadL, begin, end);
1281 return TRUE;
1283 BOOL FillFirstFootL(ULONG& begin, ULONG& end)
1285 if (nFirstFootL == 0xffff)
1286 return FALSE;
1287 Fill(nFirstFootL, begin, end);
1288 return TRUE;
1290 void Start(Ww1Shell&, Ww1Manager&);
1291 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1294 //////////////////////////////////////////////////////////////// Fields
1295 class Ww1Fields : public Ww1PlcFields
1297 USHORT nPlcIndex;
1298 String sErgebnis; // das von word errechnete ergebniss
1299 SwField* pField;
1300 ULONG Where(USHORT nIndex) // innerhalb des textes
1301 { return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
1303 public:
1304 Ww1Fields(Ww1Fib& rFibL, ULONG ulFilePos, USHORT nBytes)
1305 : Ww1PlcFields(rFibL, ulFilePos, nBytes), nPlcIndex(0), pField(0)
1307 // ~Ww1Fields() {}
1308 // innerhalb des textes
1309 ULONG Where() { return Where(nPlcIndex); }
1310 void operator++(int)
1312 DBG_ASSERT(nPlcIndex+1 <= Count(), "Ww1Fields");
1313 nPlcIndex++;
1315 void Seek(ULONG ulNew) { Ww1PlcFields::Seek(ulNew, nPlcIndex); }
1316 W1_FLD* GetData()
1318 DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
1319 return Ww1PlcFields::GetData(nPlcIndex);
1321 ULONG GetLength();
1322 friend ostream& operator <<(ostream&, Ww1Manager&);
1323 void Start(Ww1Shell&, Ww1Manager&);
1324 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1325 void Out(Ww1Shell&, Ww1Manager&, USHORT=0);
1328 class Ww1TextFields : public Ww1Fields
1330 public:
1331 Ww1TextFields(Ww1Fib& rFibL)
1332 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMomGet(),
1333 rFibL.GetFIB().cbPlcffldMomGet())
1337 class Ww1FootnoteFields : public Ww1Fields
1339 public:
1340 Ww1FootnoteFields(Ww1Fib& rFibL)
1341 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldFtnGet(),
1342 rFibL.GetFIB().cbPlcffldFtnGet())
1346 class Ww1HeaderFooterFields : public Ww1Fields
1348 public:
1349 Ww1HeaderFooterFields(Ww1Fib& rFibL)
1350 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldHdrGet(),
1351 rFibL.GetFIB().cbPlcffldHdrGet())
1355 class Ww1MacroFields : public Ww1Fields
1357 public:
1358 Ww1MacroFields(Ww1Fib& rFibL)
1359 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMcrGet(),
1360 rFibL.GetFIB().cbPlcffldMcrGet())
1364 //////////////////////////////////////////////////////////////// Bookmarks
1365 class Ww1Bookmarks
1367 Ww1PlcBookmarkTxt aNames;
1368 Ww1PlcBookmarkPos* pPos[2];
1369 Ww1Fib& rFib;
1371 USHORT nPlcIdx[2];
1372 USHORT nIsEnd;
1373 BOOL bOK;
1374 // ULONG Where(USHORT nIndex) { // innerhalb des textes
1375 // return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
1376 public:
1377 Ww1Bookmarks(Ww1Fib& rFib);
1378 ~Ww1Bookmarks()
1380 delete pPos[1];
1381 delete pPos[0];
1383 ULONG Where() const { return pPos[nIsEnd]->WhereCP(nPlcIdx[nIsEnd]); }
1384 void operator++(int);
1385 BOOL GetError() const { return !bOK; }
1386 long GetHandle() const;
1387 BOOL GetIsEnd() const { return ( nIsEnd ) ? TRUE : FALSE; }
1388 const String GetName() const;
1389 long Len() const;
1390 friend ostream& operator <<(ostream&, Ww1Bookmarks&);
1391 void Start(Ww1Shell&, Ww1Manager&);
1392 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1393 void Out(Ww1Shell&, Ww1Manager&, USHORT=0);
1396 ///////////////////////////////////////////////////////////// Footnotes
1397 class Ww1Footnotes : public Ww1PlcFootnoteRef
1399 USHORT nPlcIndex;
1400 Ww1PlcFootnoteTxt aText;
1401 BOOL bStarted;
1402 public:
1403 Ww1Footnotes(Ww1Fib& rFibL)
1404 : Ww1PlcFootnoteRef(rFibL), nPlcIndex(0), aText(rFibL), bStarted(FALSE)
1406 // ~Ww1Footnotes() {}
1407 // innerhalb des textes
1408 ULONG Where()
1410 ULONG ulRet = 0xffffffff;
1411 if (Count())
1412 ulRet = Ww1PlcFootnoteRef::Where(nPlcIndex);
1413 return ulRet;
1415 void operator++(int)
1417 DBG_ASSERT(nPlcIndex+1 <= Count(), "Ww1Footnotes");
1418 nPlcIndex++;
1420 void Start(Ww1Shell&, Ww1Manager&);
1421 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1424 /////////////////////////////////////////////////////////////////// Sep
1425 class Ww1Sep : public Ww1PlcSep
1427 Ww1HeaderFooter aHdd;
1428 USHORT nPlcIndex;
1429 public:
1430 Ww1Sep(Ww1Fib& rFibL, USHORT grpfIhdt)
1431 : Ww1PlcSep(rFibL), aHdd(rFibL, grpfIhdt), nPlcIndex(0) {}
1433 Ww1HeaderFooter& GetHdd() { return aHdd; }
1434 void operator++(int) { nPlcIndex++; }
1435 BYTE* GetData() { return Ww1PlcSep::GetData(nPlcIndex); }
1436 // innerhalb des textes
1437 ULONG Where() { return Ww1PlcSep::Where(nPlcIndex); }
1438 void SetGrpfIhdt(BYTE grpfIhdt)
1440 GetHdd().SetGrpfIhdt(grpfIhdt);
1441 // GetHdd().Start(rOut, rMan);
1443 void Start(Ww1Shell&, Ww1Manager&);
1444 void Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
1445 { aHdd.Stop(rOut, rMan, c); }
1448 /////////////////////////////////////////////////////////////////// Pap
1449 class Ww1Pap : public Ww1PlcPap
1451 USHORT nPlcIndex;
1452 USHORT nPushedPlcIndex;
1453 USHORT nFkpIndex;
1454 USHORT nPushedFkpIndex;
1455 ULONG ulOffset;
1456 Ww1FkpPap* pPap;
1458 BOOL FindSprm(USHORT nId, BYTE* pStart, BYTE* pEnd);
1459 void UpdateIdx()
1461 if (pPap && nFkpIndex >= pPap->Count() )
1463 delete pPap;
1464 pPap = NULL;
1465 nPlcIndex++;
1467 if( !pPap )
1468 Where();
1470 BOOL HasId0(USHORT nId);
1472 public:
1473 Ww1Pap(Ww1Fib& rFib);
1474 ~Ww1Pap() { delete pPap; }
1475 ULONG Where( BOOL bSetIndex = TRUE ); // innerhalb des textes
1476 void operator++(int);
1477 BOOL FillStart(BYTE*& pB, USHORT& nSize)
1479 UpdateIdx();
1480 return pPap->Fill(nFkpIndex, pB, nSize);
1482 BOOL FillStop(BYTE*& pB, USHORT& nSize)
1484 return nFkpIndex ? pPap->Fill(nFkpIndex-1, pB, nSize) : FALSE;
1486 void Start(Ww1Shell&, Ww1Manager&);
1487 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1488 void Seek(ULONG);
1489 void Push(ULONG ulOffsetTmp = 0)
1491 DBG_ASSERT(!Pushed(), "Ww1Pap");
1492 nPushedPlcIndex = nPlcIndex;
1493 nPushedFkpIndex = nFkpIndex;
1494 Seek(ulOffsetTmp);
1495 ulOffset = ulOffsetTmp;
1496 delete pPap;
1497 pPap = NULL;
1499 BOOL Pushed()
1501 return nPushedPlcIndex != 0xffff;
1503 void Pop()
1505 DBG_ASSERT(Pushed(), "Ww1Pap");
1506 ulOffset = 0;
1507 nPlcIndex = nPushedPlcIndex;
1508 nFkpIndex = nPushedFkpIndex;
1509 nPushedPlcIndex = 0xffff;
1510 nPushedFkpIndex = 0xffff;
1511 delete pPap;
1512 pPap = NULL;
1513 Where( FALSE );
1515 BOOL HasId(USHORT nId);
1518 /////////////////////////////////////////////////////////////////// Chp
1519 class Ww1Chp : public Ww1PlcChp
1521 USHORT nPlcIndex;
1522 USHORT nPushedPlcIndex;
1523 USHORT nFkpIndex;
1524 USHORT nPushedFkpIndex;
1525 ULONG ulOffset;
1526 Ww1FkpChp* pChp;
1527 void UpdateIdx()
1529 if (pChp && nFkpIndex >= pChp->Count() )
1531 delete pChp;
1532 pChp = NULL;
1533 nPlcIndex++;
1535 if( !pChp )
1536 Where();
1539 public:
1540 Ww1Chp( Ww1Fib& rFib );
1541 ~Ww1Chp() { delete pChp; }
1542 ULONG Where( BOOL bSetIndex = TRUE ); // innerhalb des textes
1543 void operator++(int);
1544 BOOL FillStart(W1_CHP& rChp)
1546 UpdateIdx();
1547 return pChp->Fill(nFkpIndex, rChp);
1549 BOOL FillStop(W1_CHP& rChp)
1550 { return nFkpIndex ? pChp->Fill(nFkpIndex-1, rChp) : FALSE; }
1551 void Start(Ww1Shell&, Ww1Manager&);
1552 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1553 void Seek(ULONG);
1554 void Push(ULONG ulOffsetTmp = 0)
1556 DBG_ASSERT(!Pushed(), "Ww1Chp");
1557 nPushedPlcIndex = nPlcIndex;
1558 nPushedFkpIndex = nFkpIndex;
1559 Seek(ulOffsetTmp);
1560 ulOffset = ulOffsetTmp;
1561 delete pChp;
1562 pChp = NULL;
1564 BOOL Pushed() { return nPushedPlcIndex != 0xffff; }
1565 void Pop()
1567 DBG_ASSERT(Pushed(), "Ww1Chp");
1568 ulOffset = 0;
1569 nPlcIndex = nPushedPlcIndex;
1570 nFkpIndex = nPushedFkpIndex;
1571 nPushedPlcIndex = 0xffff;
1572 nPushedFkpIndex = 0xffff;
1573 delete pChp;
1574 pChp = NULL;
1575 Where( FALSE );
1579 /////////////////////////////////////////////////////////////// Manager
1581 // zentraler aufhaenger der ww-seite des filters, konstruiert aus dem
1582 // inputstream (ww-datei) enthaelt er alles, was noetig ist, um in die
1583 // shell (pm-seite) gepiped zu werden.
1585 class Ww1Manager
1587 BOOL bOK;
1588 BOOL bInTtp;
1589 BOOL bInStyle;
1590 BOOL bStopAll;
1591 Ww1Fib aFib;
1592 Ww1Dop aDop;
1593 Ww1Fonts aFonts;
1594 // ab jetzt alles paarig, fuer 'pushed':
1595 Ww1DocText aDoc;
1596 Ww1PlainText* pDoc;
1597 ULONG ulDocSeek;
1598 ULONG* pSeek;
1599 Ww1TextFields aFld;
1600 Ww1Fields* pFld;
1601 // selbst 'push'bar:
1602 Ww1Chp aChp;
1603 Ww1Pap aPap;
1604 // nicht in textbereichen vorhanden, wenn ge'pushed'
1605 Ww1Footnotes aFtn;
1606 Ww1Bookmarks aBooks;
1607 Ww1Sep aSep;
1609 void OutStop( Ww1Shell&, sal_Unicode );
1610 void OutStart( Ww1Shell& );
1611 void Out(Ww1Shell&, sal_Unicode );
1613 public:
1614 Ww1Manager(SvStream& rStrm, ULONG nFieldFlgs);
1615 BOOL GetError() const { return !bOK; }
1617 // Fuer Tabellen
1618 void SetInTtp(BOOL bSet = TRUE) { bInTtp = bSet; }
1619 BOOL IsInTtp() const { return bInTtp; }
1620 void SetInStyle(BOOL bSet = TRUE) { bInStyle = bSet; }
1621 BOOL IsInStyle() const { return bInStyle; }
1622 void SetStopAll(BOOL bSet = TRUE) { bStopAll = bSet; }
1623 BOOL IsStopAll() const { return bStopAll; }
1624 BOOL HasInTable();
1625 BOOL HasTtp();
1626 BOOL LastHasTtp();
1628 // Fuer Flys
1629 BOOL HasPPc();
1630 BOOL HasPDxaAbs();
1632 Ww1Fib& GetFib() { return aFib; }
1633 Ww1PlainText& GetText() { return *pDoc; }
1634 Ww1Dop& GetDop() { return aDop; }
1635 Ww1Sep& GetSep() { return aSep; }
1636 // innerhalb des textes
1637 ULONG Where() { return pDoc->Where(); }
1638 void Fill( sal_Unicode& rChr ) { pDoc->Out( rChr ); }
1639 BYTE Fill( String& rStr, ULONG ulLen)
1641 ulLen += pDoc->Where();
1642 return sal::static_int_cast< BYTE >(pDoc->Out(rStr, ulLen));
1644 SvxFontItem GetFont(USHORT nFCode);
1645 friend Ww1Shell& operator <<(Ww1Shell&, Ww1Manager&);
1646 friend ostream& operator <<(ostream&, Ww1Manager&);
1647 BOOL Pushed() { return pDoc != &aDoc; }
1648 void Pop();
1649 void Push0(Ww1PlainText* pDoc, ULONG, Ww1Fields* = 0);
1650 void Push1(Ww1PlainText* pDoc, ULONG ulSeek, ULONG ulSeek2 = 0,
1651 Ww1Fields* = 0);