bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / filter / ww1 / w1class.hxx
blob804220ba7e6d9c9fad99cdb7eaec924f9414db30
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <tools/string.hxx>
21 // local
22 #include <w1struct.hxx>
24 #ifdef DUMP
25 #include <fstream.h>
26 #endif
28 #include <ostream>
30 namespace editeng { class SvxBorderLine; }
32 class SvxFontItem;
33 class SvxBoxItem;
34 class SvStream;
35 class SwField;
36 class Ww1Annotation;
37 class Ww1AtnText;
38 class Ww1Chp;
39 class Ww1DocText;
40 class Ww1Dop;
41 class Ww1Fib;
42 class Ww1Fkp;
43 class Ww1FkpChp;
44 class Ww1FkpPap;
45 class Ww1Fonts;
46 class Ww1Manager;
47 class Ww1McrText;
48 class Ww1Pap;
49 class Ww1PlainText;
50 class Ww1Plc;
51 class Ww1PlcAnnotationRef;
52 class Ww1PlcAnnotationTxt;
53 class Ww1PlcChp;
54 class Ww1PlcFields;
55 class Ww1PlcFootnoteRef;
56 class Ww1PlcFootnoteTxt;
57 class Ww1PlcGlossary;
58 class Ww1PlcHdd;
59 class Ww1PlcPap;
60 class Ww1PlcSep;
61 class Ww1Shell;
62 class Ww1Sprm;
63 class Ww1SprmPapx;
64 class Ww1SprmSep;
65 class Ww1Style;
66 class Ww1StyleSheet;
68 ///////////////////////////////////////////////////////////////////////
70 // nach moeglichkeit wurden in diesem modul methoden aehnlicher
71 // funktionalitaet gleich benannt. Die namen wurden wenn moeglich vom
72 // ww-filter uebernommen.
73 // Where() gibt die position eines elements. dies kann sowohl eine
74 // seek-position im stream als auch ein relativer offset sein, da dies
75 // bei word durcheinander geht. die methoden sind durch kommentare
76 // gekennzeichnet, ob sie sich auf positionen in der datei oder
77 // innerhalb des textes beziehen. vorsicht: innerhalb des textes kann
78 // verschiedene texte in der datei bedeuten.
79 // Count() gibt die anzahl der elemente zurueck. vorsicht bei
80 // n/n-1-feldern (word speichert strukturen gern in doppel-arrays, in
81 // denen das erste n elemente, das zweite jedoch n-1 elemente
82 // enthaelt.
83 // Fill() fuellt uebergebene referenzen mit daten aus den
84 // word-strukturen.
85 // GetData() gibt zeiger auf den datenbereich zurueck
86 // GetError() gibt zurueck, ob fehler aufgetreten ist
87 // Start(), Stop(), Out(), op<< siehe modul w1filter
88 // Dump() siehe modul w1dump
91 /////////////////////////////////////////////////////////////////// Fib
93 // file information block: wurzel des uebels: steht am beginn der
94 // datei (seek(0)) und enthaelt alle positionen der strukturen der
95 // datei
97 class Ww1Fib
99 W1_FIB aFib;
100 sal_Bool bOK;
101 SvStream& rStream;
102 public:
103 Ww1Fib(SvStream&);
104 friend std::ostream& operator <<(std::ostream&, Ww1Fib&);
105 W1_FIB& GetFIB() { return aFib; }
106 sal_Bool GetError() { return !bOK; }
107 SvStream& GetStream() { return rStream; }
110 /////////////////////////////////////////////////////////////////// Dop
112 // document property: eigenschaften des gesamten dokuments
114 class Ww1Dop
116 W1_DOP aDop;
117 Ww1Fib& rFib;
118 sal_Bool bOK;
119 public:
120 Ww1Dop(Ww1Fib&);
121 sal_Bool GetError() {
122 return !bOK; }
123 W1_DOP& GetDOP() {
124 return aDop; }
125 friend std::ostream& operator <<(std::ostream&, Ww1Dop&);
126 void Out(Ww1Shell&);
129 ///////////////////////////////////////////////////////////// PlainText
131 // ww-dateien koennen mehrere textbloecke enthalten (main-text,
132 // fusznoten etc). PlainText vereinigt die gemeinsamkeiten
134 class Ww1PlainText
136 protected:
137 Ww1Fib& rFib;
138 sal_uLong ulFilePos;
139 sal_uLong ulCountBytes;
140 sal_uLong ulSeek;
141 sal_Bool bOK;
142 public:
143 Ww1PlainText(Ww1Fib& rWwFib, sal_uLong nFilePos, sal_uLong nCountBytes);
144 // innerhalb des textes
145 sal_uLong Where() const { return ulSeek; }
146 void Seek( sal_uLong ulNew )
148 OSL_ENSURE(ulNew < ulCountBytes, "Ww1PlainText");
149 if (ulNew < ulCountBytes)
150 ulSeek = ulNew;
153 sal_uLong Count() const { return ulCountBytes; }
154 void SetCount(sal_uLong ulNew)
156 ulNew += ulSeek;
157 if (ulCountBytes > ulNew)
158 ulCountBytes = ulNew;
160 void operator++()
162 OSL_ENSURE(ulSeek+1<ulCountBytes, "Ww1PlainText");
163 ulSeek++;
165 sal_Bool GetError() { return !bOK; }
166 sal_Unicode Out( Ww1Shell&, sal_uLong& );
167 sal_Unicode Out( String&, sal_uLong=0xffffffff);
168 sal_Unicode Out( sal_Unicode& );
169 friend std::ostream& operator <<(std::ostream&, Ww1PlainText&);
170 String& Fill( String&, sal_uLong=0, sal_uLong=0xffffffff );
171 sal_Unicode operator []( sal_uLong );
172 String GetText( sal_uLong ulOffset, sal_uLong nLen ) const;
174 enum Consts { MinChar = 32 };
175 static bool IsChar( sal_Unicode c ) { return c >= MinChar; }
178 /////////////////////////////////////////////////////////////// DocText
179 class Ww1DocText : public Ww1PlainText
181 public:
182 Ww1DocText(Ww1Fib& rFibL) :
183 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet(),
184 rFibL.GetFIB().ccpTextGet()) {
188 /////////////////////////////////////////////////////////////// FtnText
189 class Ww1FtnText : public Ww1PlainText
191 public:
192 sal_uLong Offset(Ww1Fib& rFibL) {
193 return rFibL.GetFIB().ccpTextGet(); }
194 Ww1FtnText(Ww1Fib& rFibL) :
195 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
196 Offset(rFibL), rFibL.GetFIB().ccpFtnGet()) {
200 /////////////////////////////////////////////////////////////// HddText
201 class Ww1HddText : public Ww1PlainText
203 public:
204 sal_uLong Offset(Ww1Fib& rFibL) {
205 return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet(); }
206 Ww1HddText(Ww1Fib& rFibL) :
207 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
208 Offset(rFibL), rFibL.GetFIB().ccpHddGet()) {
212 /////////////////////////////////////////////////////////////// McrText
213 class Ww1McrText : public Ww1PlainText
215 public:
216 sal_uLong Offset(Ww1Fib& rFibL) {
217 return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet()
218 + rFibL.GetFIB().ccpHddGet(); }
219 Ww1McrText(Ww1Fib& rFibL) :
220 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
221 Offset(rFibL), rFibL.GetFIB().ccpMcrGet()) {
225 /////////////////////////////////////////////////////////////// AtnText
226 class Ww1AtnText : public Ww1PlainText
228 public:
229 sal_uLong Offset(Ww1Fib& rFibL) {
230 return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet()
231 + rFibL.GetFIB().ccpHddGet() + rFibL.GetFIB().ccpMcrGet(); }
232 Ww1AtnText(Ww1Fib& rFibL) :
233 Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() +
234 Offset(rFibL), rFibL.GetFIB().ccpAtnGet()) {
238 ///////////////////////////////////////////////////////////////// Style
240 // ein einzelner style oder vorlage
242 class Ww1Style
244 String aName;
245 W1_CHP aChpx;
246 Ww1SprmPapx* pPapx;
247 Ww1StyleSheet* pParent;
248 sal_uInt8 stcBase;
249 sal_uInt8 stcNext;
250 sal_Bool bUsed;
251 public:
252 Ww1Style();
253 ~Ww1Style();
254 bool IsUsed() const { return bUsed; }
255 void SetDefaults(sal_uInt8);
256 void SetParent(Ww1StyleSheet* newParent) { pParent = newParent; }
257 void SetName(const String& rName) { bUsed = sal_True; aName = rName; }
258 const String& GetName() const { return aName; }
259 Ww1Style& GetBase();
260 sal_uInt16 GetnBase() const { return stcBase; }
261 sal_uInt16 GetnNext() const { return stcNext; }
262 sal_uInt16 ReadName(sal_uInt8*&, sal_uInt16&, sal_uInt16 stc);
263 sal_uInt16 ReadChpx(sal_uInt8*&, sal_uInt16&);
264 sal_uInt16 ReadPapx(sal_uInt8*&, sal_uInt16&);
265 sal_uInt16 ReadEstcp(sal_uInt8*&, sal_uInt16&);
266 friend std::ostream& operator <<(std::ostream&, Ww1Style&);
267 void Out(Ww1Shell&, Ww1Manager&);
270 //////////////////////////////////////////////////////////// StyleSheet
272 // die sammlung aller vorlagen (max. 256)
274 class Ww1StyleSheet
276 Ww1Style aStyles[256];
277 sal_uInt16 cstcStd; // count style code standard
278 Ww1Fib& rFib;
279 sal_Bool bOK;
280 sal_uInt16 ReadNames(sal_uInt8*&, sal_uInt16&);
281 sal_uInt16 ReadChpx(sal_uInt8*&, sal_uInt16&);
282 sal_uInt16 ReadPapx(sal_uInt8*&, sal_uInt16&);
283 sal_uInt16 ReadEstcp(sal_uInt8*&, sal_uInt16&);
285 void OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc);
286 void OutOne(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc);
287 void OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc,
288 sal_uInt8* pbStopRecur );
289 public:
290 Ww1StyleSheet(Ww1Fib& rFib);
291 Ww1Style& GetStyle(sal_uInt16 stc) {
292 return aStyles[stc]; }
293 sal_uInt16 Count() {
294 return 256; }
295 friend std::ostream& operator <<(std::ostream&, Ww1StyleSheet&);
296 void Out(Ww1Shell&, Ww1Manager&);
297 friend class Ww1Style;
298 sal_Bool GetError() {
299 return !bOK; }
302 ///////////////////////////////////////////////////////////////// Fonts
304 // ww kennt nur font-nummern beim formatieren. nebenher gibts ein
305 // array von fonts, damit man aus der nummer einen konkreten font
306 // machen kann.
308 class Ww1Fonts
310 protected:
311 W1_FFN** pFontA; // Array of Pointers to Font Description
312 Ww1Fib& rFib;
313 sal_uLong nFieldFlags;
314 sal_uInt16 nMax; // Array-Groesse
315 sal_Bool bOK;
316 public:
317 Ww1Fonts(Ww1Fib&, sal_uLong nFieldFlgs);
318 ~Ww1Fonts() {
319 if (pFontA)
320 DELETEZ(pFontA[0]);
321 DELETEZ(pFontA); }
322 W1_FFN* GetFFN(sal_uInt16 nNum);
323 sal_uInt16 Count() {
324 return nMax; }
325 friend std::ostream& operator <<(std::ostream&, Ww1Fonts&);
326 sal_Bool GetError() {
327 return !bOK; }
328 SvxFontItem GetFont(sal_uInt16);
331 //////////////////////////////////////////////////////////// SingleSprm
333 // diese klassen ersetzen die aSprmTab etc des ww6-filters. die
334 // funktionspointer sind hier virtuale methoden, fuer die typen (byte,
335 // word, var-sized etc) gibt es abgeleitete klassen. diese haben
336 // methoden zum bestimmen der groesze, dumpen und shell-ausgeben der
337 // Sprms.
338 // die klassen werden mit new (in InitTab()) erzeugt und nach ihrem
339 // code in die tabelle gestellt. zum aktivieren ruft man nun nur noch
340 // die entsprechende methode des objektes in der tabelle auf.
341 // wohlgemerkt: SingleSprms sind die _beschreibung_ und _funktion_ der
342 // Sprms, nicht deren inhalt. dieser musz uebergeben werden an die
343 // einzelnen methoden wie Size, Dump und Start/Stop.
345 class Ww1SingleSprm
347 public:
348 #ifdef DUMP
350 // allein die virtuellen methoden stehen in der vtab, also je nachdem,
351 // ob fuer dumper oder filter uebersetzt wird ausblenden: das spart
352 // platz. ausserdem stehen die methoden fuer dumper bzw filter in
353 // verschiedenen modulen, die im jeweils anderen projekt nicht
354 // uebersetzt werden. das diese dann beim linken nicht zur verfuegung
355 // stehen faellt dann auch nicht auf. Der Namensstring ist nur im
356 // Dumper noetig: weg damit im Filter.
358 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
359 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
360 virtual std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
361 const sal_Char* sName;
362 #else
363 virtual void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
364 virtual void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
365 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
366 #endif
367 virtual sal_uInt16 Size(sal_uInt8*);
368 sal_uInt16 nCountBytes;
370 Ww1SingleSprm(sal_uInt16 nBytes, const sal_Char* /*pName*/ = 0 )
371 : nCountBytes(nBytes)
372 #ifdef DUMP
373 , sName( pName)
374 #endif
377 virtual ~Ww1SingleSprm();
380 class Ww1SingleSprmByteSized : public Ww1SingleSprm {
381 public:
382 sal_uInt16 Size(sal_uInt8*);
383 Ww1SingleSprmByteSized(sal_uInt16 nBytes, sal_Char* sName = 0) :
384 Ww1SingleSprm(nBytes, sName) {
388 class Ww1SingleSprmWordSized : public Ww1SingleSprm {
389 public:
390 sal_uInt16 Size(sal_uInt8*);
391 Ww1SingleSprmWordSized(sal_uInt16 nBytes, sal_Char* sName = 0) :
392 Ww1SingleSprm(nBytes, sName) {
396 class Ww1SingleSprmByte : public Ww1SingleSprm {
397 public:
398 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
399 Ww1SingleSprmByte(sal_Char* sName = 0) :
400 Ww1SingleSprm(1, sName) {
404 class Ww1SingleSprmBool : public Ww1SingleSprmByte {
405 public:
406 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
407 Ww1SingleSprmBool(sal_Char* sName = 0) :
408 Ww1SingleSprmByte(sName) {
412 class Ww1SingleSprm4State : public Ww1SingleSprmByte {
413 public:
414 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
415 Ww1SingleSprm4State(sal_Char* sName = 0) :
416 Ww1SingleSprmByte(sName) {
420 class Ww1SingleSprmWord : public Ww1SingleSprm {
421 public:
422 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
423 Ww1SingleSprmWord(sal_Char* sName = 0)
424 : Ww1SingleSprm(2, sName) {}
427 class Ww1SingleSprmLong : public Ww1SingleSprm {
428 public:
429 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
430 Ww1SingleSprmLong(sal_Char* sName = 0) :
431 Ww1SingleSprm(4, sName) {
435 class Ww1SingleSprmTab : public Ww1SingleSprm {
436 public:
437 std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16);
438 sal_uInt16 Size(sal_uInt8*);
439 Ww1SingleSprmTab(sal_uInt16 nBytes, sal_Char* sName = 0) :
440 Ww1SingleSprm(nBytes, sName) {
444 class Ww1SingleSprmPJc : public Ww1SingleSprmByte {
445 public:
446 Ww1SingleSprmPJc(sal_Char* sName) :
447 Ww1SingleSprmByte(sName) {
449 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
450 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
453 class Ww1SingleSprmPDxa : public Ww1SingleSprmWord {
454 public:
455 Ww1SingleSprmPDxa(sal_Char* sName) :
456 Ww1SingleSprmWord(sName) {
458 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
461 class Ww1SingleSprmPDxaRight : public Ww1SingleSprmPDxa {
462 public:
463 Ww1SingleSprmPDxaRight(sal_Char* sName) :
464 Ww1SingleSprmPDxa(sName) {
466 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
469 class Ww1SingleSprmPDxaLeft : public Ww1SingleSprmPDxa {
470 public:
471 Ww1SingleSprmPDxaLeft(sal_Char* sName) :
472 Ww1SingleSprmPDxa(sName) {
474 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
477 class Ww1SingleSprmPDxaLeft1 : public Ww1SingleSprmPDxa {
478 public:
479 Ww1SingleSprmPDxaLeft1(sal_Char* sName) :
480 Ww1SingleSprmPDxa(sName) {
482 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
485 class Ww1SingleSprmPFKeep : public Ww1SingleSprmBool {
486 public:
487 Ww1SingleSprmPFKeep(sal_Char* sName) :
488 Ww1SingleSprmBool(sName) {
490 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
491 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
494 class Ww1SingleSprmPFKeepFollow : public Ww1SingleSprmBool {
495 public:
496 Ww1SingleSprmPFKeepFollow(sal_Char* sName) :
497 Ww1SingleSprmBool(sName) {
499 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
500 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
503 class Ww1SingleSprmPPageBreakBefore : public Ww1SingleSprmBool {
504 public:
505 Ww1SingleSprmPPageBreakBefore(sal_Char* sName) :
506 Ww1SingleSprmBool(sName) {
508 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
509 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
512 class Ww1SingleSprmPBrc : public Ww1SingleSprmWord {
513 protected:
514 // spezielle start-routine, je nach sprm verschieden versorgt
515 // mit einem BoxItem.
516 void Start(Ww1Shell&, sal_uInt8, W1_BRC10*, sal_uInt16, Ww1Manager&, SvxBoxItem&);
517 void Start(Ww1Shell&, sal_uInt8, W1_BRC*, sal_uInt16, Ww1Manager&, SvxBoxItem&);
519 using Ww1SingleSprm::Start;
521 public:
522 Ww1SingleSprmPBrc(sal_Char* sName) :
523 Ww1SingleSprmWord(sName) {
525 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
526 // SetBorder() wird auch fuer Tabellen gebraucht, deshalb public
527 static editeng::SvxBorderLine* SetBorder(editeng::SvxBorderLine*, W1_BRC10*);
530 #define BRC_TOP ((sal_uInt16)0)
531 #define BRC_LEFT ((sal_uInt16)1)
532 #define BRC_BOTTOM ((sal_uInt16)2)
533 #define BRC_RIGHT ((sal_uInt16)3)
534 #define BRC_ANZ ((sal_uInt16)BRC_RIGHT-BRC_TOP+1)
536 // Die BRC-struktur fuer 1.0 versionen von word sind verschieden von
537 // denen der folgenden versionen. diese werden zum glueck aber auch
538 // von anderen sprms abgerufen.
539 // SH: Ab sofort alle 4 Umrandungen ueber nur 1 Klasse.
540 class Ww1SingleSprmPBrc10 : public Ww1SingleSprmPBrc
542 sal_uInt16 nLine; // BRC_TOP, BRC_LEFT, ...
544 using Ww1SingleSprmPBrc::Start;
546 public:
547 Ww1SingleSprmPBrc10(sal_uInt16 nL, sal_Char* sName)
548 : Ww1SingleSprmPBrc(sName), nLine(nL) {}
550 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
553 class Ww1SingleSprmParaSpace : public Ww1SingleSprmWord {
554 public:
555 Ww1SingleSprmParaSpace(sal_Char* sName)
556 : Ww1SingleSprmWord(sName) {}
557 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
560 class Ww1SingleSprmPDyaBefore : public Ww1SingleSprmParaSpace {
561 public:
562 Ww1SingleSprmPDyaBefore(sal_Char* sName)
563 : Ww1SingleSprmParaSpace(sName) {}
564 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
567 class Ww1SingleSprmPDyaAfter : public Ww1SingleSprmParaSpace {
568 public:
569 Ww1SingleSprmPDyaAfter(sal_Char* sName) :
570 Ww1SingleSprmParaSpace(sName) {
572 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
575 class Ww1SingleSprmPDyaLine : public Ww1SingleSprmWord {
576 public:
577 Ww1SingleSprmPDyaLine(sal_Char* sName) :
578 Ww1SingleSprmWord(sName) {
580 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
581 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
584 class Ww1SingleSprmPChgTabsPapx : public Ww1SingleSprmByteSized {
585 public:
586 Ww1SingleSprmPChgTabsPapx(sal_Char* sName) :
587 Ww1SingleSprmByteSized(0, sName) {
589 // Size() ist noch nicht aktiviert !!
590 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
591 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
594 class Ww1SingleSprmSGprfIhdt : public Ww1SingleSprmByte {
595 public:
596 Ww1SingleSprmSGprfIhdt(sal_Char* sName) :
597 Ww1SingleSprmByte(sName) {
599 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
602 class Ww1SingleSprmSColumns : public Ww1SingleSprmWord {
603 public:
604 Ww1SingleSprmSColumns(sal_Char* sName) :
605 Ww1SingleSprmWord(sName) {
607 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
610 class Ww1SingleSprmPFInTable : public Ww1SingleSprmBool {
611 public:
612 Ww1SingleSprmPFInTable(sal_Char* sName) :
613 Ww1SingleSprmBool(sName) {
615 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
616 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
619 class Ww1SingleSprmPTtp : public Ww1SingleSprmBool {
620 public:
621 Ww1SingleSprmPTtp(sal_Char* sName) :
622 Ww1SingleSprmBool(sName) {
624 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
625 void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
628 class Ww1SingleSprmTJc : public Ww1SingleSprmWord {
629 public:
630 Ww1SingleSprmTJc(sal_Char* sName)
631 : Ww1SingleSprmWord(sName) {}
634 class Ww1SingleSprmTDxaGapHalf : public Ww1SingleSprmWord {
635 public:
636 Ww1SingleSprmTDxaGapHalf(sal_Char* sName) :
637 Ww1SingleSprmWord(sName) {
639 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
642 class Ww1SingleSprmTDefTable10 : public Ww1SingleSprmWordSized {
643 public:
644 Ww1SingleSprmTDefTable10(sal_Char* sName) :
645 Ww1SingleSprmWordSized(0, sName) {
647 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
650 class Ww1SingleSprmTDyaRowHeight : public Ww1SingleSprmWord {
651 public:
652 Ww1SingleSprmTDyaRowHeight(sal_Char* sName) :
653 Ww1SingleSprmWord(sName) {
655 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
658 // Klassendefinitionen fuer Tabellen-Fastsave-Attribute
659 // Da wir kein Fastsave unterstuetzen, brauchen wir's nicht
661 // Klassendefinitionen fuer Apos ( == Flys )
663 class Ww1SingleSprmPpc : public Ww1SingleSprmByte {
664 public:
665 Ww1SingleSprmPpc(sal_Char* sName) :
666 Ww1SingleSprmByte(sName) {
668 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
671 class Ww1SingleSprmPDxaAbs : public Ww1SingleSprmWord {
672 public:
673 Ww1SingleSprmPDxaAbs(sal_Char* sName) :
674 Ww1SingleSprmWord(sName) {
676 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
679 class Ww1SingleSprmPDyaAbs : public Ww1SingleSprmWord {
680 public:
681 Ww1SingleSprmPDyaAbs(sal_Char* sName) :
682 Ww1SingleSprmWord(sName) {
684 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
687 class Ww1SingleSprmPDxaWidth : public Ww1SingleSprmWord {
688 public:
689 Ww1SingleSprmPDxaWidth(sal_Char* sName) :
690 Ww1SingleSprmWord(sName) {
692 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
695 class Ww1SingleSprmPFromText : public Ww1SingleSprmWord {
696 public:
697 Ww1SingleSprmPFromText(sal_Char* sName) :
698 Ww1SingleSprmWord(sName) {
700 void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&);
703 ////////////////////////////////////////////////////////////////// Sprm
705 // der tatsaechlich in der datei auftretende datentyp Sprm
707 class Ww1Sprm
709 sal_Bool ReCalc();
710 static Ww1SingleSprm* aTab[256];
711 static Ww1SingleSprm* pSingleSprm;
712 protected:
713 static void InitTab();
714 Ww1SingleSprm& GetTab(sal_uInt16 nId)
716 if( !pSingleSprm )
717 InitTab();
718 return aTab[ nId ] ? *aTab[nId] : *pSingleSprm;
721 sal_uInt8* p;
722 sal_uInt16 nCountBytes;
723 sal_Bool bOK;
724 sal_uInt16* pArr;
725 sal_uInt16 count;
726 // ohne Token, mit laengen-byte/word
727 sal_uInt16 GetSize(sal_uInt8 nId, sal_uInt8* pSprm);
728 // mit Token und LaengenByte
729 sal_uInt16 GetSizeBrutto(sal_uInt8* pSprm) {
730 sal_uInt8 nId = *pSprm++;
731 return GetSize(nId, pSprm) + 1; }
732 // gibt fuer nTh element id, size & zeiger auf daten:
733 // sal_Bool Fill(sal_uInt16, sal_uInt8&, sal_uInt16&, sal_uInt8*&);
734 public:
735 // SH: brauche ich public
736 // gibt fuer nTh element id, size & zeiger auf daten:
737 sal_Bool Fill(sal_uInt16, sal_uInt8&, sal_uInt16&, sal_uInt8*&);
739 Ww1Sprm(sal_uInt8*, sal_uInt16);
740 Ww1Sprm(SvStream&, sal_uLong);
741 ~Ww1Sprm();
742 friend std::ostream& operator <<(std::ostream&, Ww1Sprm&);
743 void Start(Ww1Shell&, Ww1Manager&);
744 void Start(Ww1Shell&, Ww1Manager&, sal_uInt16);
745 void Stop(Ww1Shell&, Ww1Manager&);
746 bool IsUsed() {
747 return nCountBytes != 255; }
748 sal_uInt16 Count() {
749 return count; }
750 sal_Bool GetError() {
751 return !bOK; }
752 static void DeinitTab();
755 /////////////////////////////////////////////////////////////// Picture
757 // der wrapper um den datentyp PIC, eine struktur, die am beginn eines
758 // bild-dateinamens oder eines eingebetteten bildes steht.
760 class Ww1Picture
762 sal_Bool bOK;
763 W1_PIC* pPic;
764 public:
765 Ww1Picture(SvStream&, sal_uLong);
766 ~Ww1Picture() {
768 sal_Bool GetError() {
769 return !bOK; }
770 friend std::ostream& operator <<(std::ostream&, Ww1Picture&);
771 void Out(Ww1Shell&, Ww1Manager&);
772 void WriteBmp(SvStream&);
775 /////////////////////////////////////////////////////////////////// Plc
777 // eine der wichtigen array-strukturen der ww-dateien. sie beinhalten
778 // n+1 dateipositionen und n attribute, die zwischen den
779 // dateipositionen gelten.
781 class Ww1Plc
783 sal_uInt8* p;
784 sal_uInt16 nCountBytes;
785 sal_uInt16 iMac;
786 sal_uInt16 nItemSize;
787 sal_Bool bOK;
788 protected:
789 Ww1Fib& rFib;
790 sal_uInt8* GetData(sal_uInt16);
791 public:
792 Ww1Plc(Ww1Fib&, sal_uLong, sal_uInt16, sal_uInt16);
793 ~Ww1Plc();
794 friend std::ostream& operator <<(std::ostream&, Ww1Plc&);
795 sal_uLong Where(sal_uInt16); // wie im jeweiligen plc
796 void Seek(sal_uLong, sal_uInt16&);
797 void Fill(sal_uInt16 nIndex, sal_uLong& begin, sal_uLong& end) {
798 begin = Where(nIndex);
799 end = Where(nIndex+1); }
800 sal_uInt16 Count() {
801 return iMac; }
802 sal_Bool GetError() {
803 return !bOK; }
806 // Size Tabs from Sven:
807 // CHP, PAP, SEP, HED, FNR, FNT
808 //Plc 2, 2, 6, 0, 2, 0
809 //Fkp 1, 1, 0, 0, 0, 0
811 /////////////////////////////////////////////////////////// PlcGlossary
812 class Ww1PlcGlossary : public Ww1Plc
814 public:
815 Ww1PlcGlossary(Ww1Fib& rFibL) :
816 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfglsyGet(),
817 rFibL.GetFIB().cbPlcfglsyGet(), 0) {
821 ////////////////////////////////////////////////////// PlcAnnotationRef
822 class Ww1PlcAnnotationRef : public Ww1Plc
824 public:
825 Ww1PlcAnnotationRef(Ww1Fib& rFibL) :
826 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandRefGet(),
827 rFibL.GetFIB().cbPlcfandRefGet(), 0) {
831 ////////////////////////////////////////////////////// PlcAnnotationTxt
832 class Ww1PlcAnnotationTxt : public Ww1Plc
834 public:
835 Ww1PlcAnnotationTxt(Ww1Fib& rFibL) :
836 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandTxtGet(),
837 rFibL.GetFIB().cbPlcfandTxtGet(), 0) {
841 ///////////////////////////////////////////////////////// PlcAnnotation
842 class Ww1Annotation {
843 Ww1PlcAnnotationRef aRef;
844 Ww1PlcAnnotationTxt aTxt;
845 public:
846 Ww1Annotation(Ww1Fib& rFib) :
847 aRef(rFib),
848 aTxt(rFib) {
850 friend std::ostream& operator <<(std::ostream&, Ww1Annotation&);
853 //////////////////////////////////////////////////////////////// PlcSep
854 class Ww1PlcSep : public Ww1Plc
856 public:
857 Ww1PlcSep(Ww1Fib& rFibL):
858 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfsedGet(),
859 rFibL.GetFIB().cbPlcfsedGet(), 6) {
861 friend std::ostream& operator <<(std::ostream&, Ww1PlcSep&);
864 //////////////////////////////////////////////////////////////// PlcChp
865 class Ww1PlcChp : public Ww1Plc
867 public:
868 Ww1PlcChp(Ww1Fib& rFibL) :
869 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbteChpxGet(),
870 rFibL.GetFIB().cbPlcfbteChpxGet(), 2) {
872 friend std::ostream& operator <<(std::ostream&, Ww1PlcChp&);
875 //////////////////////////////////////////////////////////////// PlcPap
876 class Ww1PlcPap : public Ww1Plc
878 public:
879 Ww1PlcPap(Ww1Fib& rFibL) :
880 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbtePapxGet(),
881 rFibL.GetFIB().cbPlcfbtePapxGet(), 2) {
883 friend std::ostream& operator <<(std::ostream&, Ww1PlcPap&);
886 //////////////////////////////////////////////////////// PlcFootnoteRef
887 class Ww1PlcFootnoteRef : public Ww1Plc
889 public:
890 Ww1PlcFootnoteRef(Ww1Fib& rFibL) :
891 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndRefGet(),
892 rFibL.GetFIB().cbPlcffndRefGet(), 2) {
894 friend std::ostream& operator <<(std::ostream&, Ww1PlcFootnoteRef&);
897 //////////////////////////////////////////////////////// PlcFootnoteTxt
898 class Ww1PlcFootnoteTxt : public Ww1Plc
900 public:
901 Ww1PlcFootnoteTxt(Ww1Fib& rFibL) :
902 Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndTxtGet(),
903 rFibL.GetFIB().cbPlcffndTxtGet(), 0) {
905 friend std::ostream& operator <<(std::ostream&, Ww1PlcFootnoteTxt&);
908 ///////////////////////////////////////////////////////////// PlcFields
909 class Ww1PlcFields : public Ww1Plc
911 public:
912 Ww1PlcFields(Ww1Fib& rFibL, sal_uLong start, sal_uInt16 nBytes)
913 : Ww1Plc(rFibL, start, nBytes, 2)
915 W1_FLD* GetData(sal_uInt16 nIndex)
916 { return (W1_FLD*)Ww1Plc::GetData(nIndex); }
917 sal_uLong Where(sal_uInt16 nIndex) // absolut im file
918 { return Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet(); }
919 friend std::ostream& operator <<(std::ostream&, Ww1PlcFields&);
922 ///////////////////////////////////////////////////////////// PlcBookmarks
923 class Ww1StringList
925 sal_Char** pIdxA;
926 sal_uInt16 nMax;
927 public:
928 Ww1StringList( SvStream& rSt, sal_uLong nFc, sal_uInt16 nCb );
929 ~Ww1StringList()
930 { if( pIdxA ) { delete pIdxA[0]; delete pIdxA; } }
931 const String GetStr( sal_uInt16 nNum ) const;
932 sal_uInt16 Count() const { return nMax; }
933 sal_Bool GetError() const { return (nMax != 0) && !pIdxA; }
936 class Ww1PlcBookmarkTxt: public Ww1StringList
938 public:
939 Ww1PlcBookmarkTxt(Ww1Fib& rFib) :
940 Ww1StringList( rFib.GetStream(), rFib.GetFIB().fcSttbfbkmkGet(),
941 rFib.GetFIB().cbSttbfbkmkGet() )
945 class Ww1PlcBookmarkPos : public Ww1Plc
947 public:
948 Ww1PlcBookmarkPos(Ww1Fib& _rFib, sal_uLong start, sal_uInt16 nBytes, sal_Bool bEnd)
949 : Ww1Plc(_rFib, start, nBytes, (bEnd) ? 0 : 2)
952 sal_uInt8* GetData(sal_uInt16 nIndex) { return Ww1Plc::GetData(nIndex); }
953 // Position als CP
954 sal_uLong WhereCP(sal_uInt16 nIndex) { return Ww1Plc::Where(nIndex); }
955 // absolut im file
956 sal_uLong Where(sal_uInt16 nIndex)
958 return ( nIndex < Count() )
959 ? Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet()
960 : 0xffffffff;
964 //////////////////////////////////////////////////////////////// PlcHdd
965 class Ww1PlcHdd : public Ww1Plc
967 public:
968 Ww1PlcHdd(Ww1Fib& rFibL)
969 : Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfhddGet(),
970 rFibL.GetFIB().cbPlcfhddGet(), 0)
974 /////////////////////////////////////////////////////////////////// Fkp
976 // aehnlich den plcs aufgebaute arrays, die sich auf eine groesze von
977 // 512 byte beschraenken.
979 class Ww1Fkp
981 protected:
982 sal_uInt8 aFkp[512];
983 sal_uInt16 nItemSize;
984 sal_Bool bOK;
985 sal_uInt8* GetData(sal_uInt16);
986 public:
987 Ww1Fkp(SvStream&, sal_uLong, sal_uInt16);
988 friend std::ostream& operator <<(std::ostream&, Ww1Fkp&);
989 sal_uInt16 Count() const { return SVBT8ToByte(aFkp+511); }
990 sal_uLong Where(sal_uInt16); // wie im entsprechenden fkp
993 //////////////////////////////////////////////////////////////// FkpPap
994 class Ww1FkpPap : public Ww1Fkp
996 public:
997 Ww1FkpPap(SvStream& rStream, sal_uLong ulFilePos)
998 : Ww1Fkp(rStream, ulFilePos, 1)
1000 friend std::ostream& operator <<(std::ostream&, Ww1FkpPap&);
1001 sal_Bool Fill(sal_uInt16, sal_uInt8*&, sal_uInt16&);
1004 //////////////////////////////////////////////////////////////// FkpChp
1005 class Ww1FkpChp : public Ww1Fkp
1007 #ifdef DUMP
1008 SvStream& rStream;
1009 SvStream& GetStream() { return rStream; }
1010 #endif
1011 public:
1012 Ww1FkpChp(SvStream& rStream, sal_uLong ulFilePos)
1013 : Ww1Fkp(rStream, ulFilePos, 1)
1014 #ifdef DUMP
1015 , rStream(rStream)
1016 #endif
1019 friend std::ostream& operator <<(std::ostream&, Ww1FkpChp&);
1020 sal_Bool Fill(sal_uInt16, W1_CHP&);
1023 ////////////////////////////////////////////////////////////// SprmPapx
1024 class Ww1SprmPapx : public Ww1Sprm
1026 W1_PAPX aPapx;
1027 sal_uInt8* Sprm(sal_uInt8* p, sal_uInt16 nSize);
1028 sal_uInt16 SprmSize(sal_uInt8* p, sal_uInt16 nSize);
1029 public:
1030 Ww1SprmPapx(sal_uInt8* p, sal_uInt16 nSize);
1031 friend std::ostream& operator <<(std::ostream&, Ww1SprmPapx&);
1032 void Start(Ww1Shell&, Ww1Manager&);
1033 void Stop(Ww1Shell&, Ww1Manager&);
1036 /////////////////////////////////////////////////////////////// SprmSep
1037 class Ww1SprmSep : public Ww1Sprm
1039 public:
1040 Ww1SprmSep(Ww1Fib& rFib, sal_uLong ulFilePos)
1041 : Ww1Sprm(rFib.GetStream(), ulFilePos)
1043 friend std::ostream& operator <<(std::ostream&, Ww1SprmSep&);
1046 ///////////////////////////////////////////////////////////////// Assoc
1047 class Ww1Assoc
1049 enum fields { FileNext, Dot, Title, Subject, KeyWords, Comments,
1050 Author, LastRevBy, DataDoc, HeaderDoc, Criteria1, Criteria2,
1051 Criteria3, Criteria4, Criteria5, Criteria6, Criteria7, MaxFields };
1053 Ww1Fib& rFib;
1054 sal_Char* pBuffer;
1055 sal_Char* pStrTbl[ MaxFields ];
1056 sal_Bool bOK;
1058 String GetStr(sal_uInt16);
1060 public:
1061 Ww1Assoc(Ww1Fib&);
1062 ~Ww1Assoc() { delete pBuffer; }
1063 sal_Bool GetError() const { return !bOK; }
1064 friend std::ostream& operator <<(std::ostream&, Ww1Assoc&);
1065 void Out(Ww1Shell&);
1068 ////////////////////////////////////////////////////////// HeaderFooter
1070 // Header/Footer/Footnoteseparators sind einer nach dem naechsten in
1071 // einem eigenen text gespeichert. ein plc trennt diesen text in
1072 // einzelne teile. diese werden durchnummeriert als ihdd. nun gibt es
1073 // 9 verschiedene funktionen fuer diese texte. wird eine davon
1074 // angefordert, ist es der erste, beim naechstern der 2 ihdd und so
1075 // weiter. welcher textteil also welcher typ sein wird laeszt sich
1076 // nur bei sequenziellem lesen der datei bestimmen. die 9 typen sind:
1077 // fusznoten-trenner, folge-fusznoten-trenner, folge-fusznoten-notiz,
1078 // gerade-seiten kopfzeilen, ungerade seiten kopfzeilen, dto 2*
1079 // fuszzeilen, kopf & fuszzeilen, wenn erste seite andere zeilen hat.
1080 // HeaderFooter merkt sich fuer jede der 9 die momentane einstellung
1081 // (jedoch nicht die alten) und den naechstvergebbaren ihdd. ist ein
1082 // teil nicht vorhanden bekommt er den wert 0xffff.
1084 class Ww1HeaderFooter : public Ww1PlcHdd
1086 sal_uInt16 nextIhdd; // naechster textteil im HddText
1087 sal_uInt16 nFtnSep; // fusznoten trenner
1088 sal_uInt16 nFtnFollowSep; // folge fusznoten trenner
1089 sal_uInt16 nFtnNote; // folgefunsznotennotiz
1090 sal_uInt16 nEvenHeadL; // kopfzeilen grader seiten
1091 sal_uInt16 nOddHeadL; // kopfzeilen ungrader seiten
1092 sal_uInt16 nEvenFootL; // fuszzeilen grader seiten
1093 sal_uInt16 nOddFootL; // fuszzeilen ungerader seiten
1094 sal_uInt16 nFirstHeadL; // kopfzeilen der ersten seite
1095 sal_uInt16 nFirstFootL; // fuszzeilen der ersten seite
1096 enum HeaderFooterMode {
1097 None, FtnSep, FtnFollowSep, FtnNote, EvenHeadL, OddHeadL,
1098 EvenFootL, OddFootL, FirstHeadL, MaxHeaderFooterMode
1099 } eHeaderFooterMode;
1101 public:
1102 Ww1HeaderFooter(Ww1Fib& rFibL, sal_uInt16 grpfIhdt)
1103 : Ww1PlcHdd(rFibL),
1104 nextIhdd(0),
1105 nFtnSep(0xffff),
1106 nFtnFollowSep(0xffff),
1107 nFtnNote(0xffff),
1108 nEvenHeadL(0xffff),
1109 nOddHeadL(0xffff),
1110 nEvenFootL(0xffff),
1111 nOddFootL(0xffff),
1112 nFirstHeadL(0xffff),
1113 nFirstFootL(0xffff),
1114 eHeaderFooterMode(None)
1116 if (grpfIhdt & 0x0001) nFtnSep = nextIhdd++;
1117 if (grpfIhdt & 0x0002) nFtnFollowSep = nextIhdd++;
1118 if (grpfIhdt & 0x0004) nFtnNote = nextIhdd++;
1120 void SetGrpfIhdt(sal_uInt16 grpfIhdt)
1122 if (grpfIhdt & 0x0001) nEvenHeadL = nextIhdd++;
1123 if (grpfIhdt & 0x0002) nOddHeadL = nextIhdd++;
1124 if (grpfIhdt & 0x0004) nEvenFootL = nextIhdd++;
1125 if (grpfIhdt & 0x0008) nOddFootL = nextIhdd++;
1126 if (grpfIhdt & 0x0010) nFirstHeadL = nextIhdd++;
1127 if (grpfIhdt & 0x0020) nFirstFootL = nextIhdd++;
1128 OSL_ENSURE(nextIhdd<=Count(), "Ww1HeaderFooter");
1130 sal_Bool operator++()
1132 sal_Bool bRet = sal_True;
1133 eHeaderFooterMode = (HeaderFooterMode)((short)eHeaderFooterMode + 1);
1134 if( eHeaderFooterMode == MaxHeaderFooterMode)
1136 eHeaderFooterMode = None;
1137 bRet = sal_False;
1139 return bRet;
1141 sal_Bool FillFtnSep(sal_uLong& begin, sal_uLong& end)
1143 if (nFtnSep == 0xffff)
1144 return sal_False;
1145 Fill(nFtnSep, begin, end);
1146 return sal_True;
1148 sal_Bool FillFtnFollowSep(sal_uLong& begin, sal_uLong& end)
1150 if (nFtnFollowSep == 0xffff)
1151 return sal_False;
1152 Fill(nFtnFollowSep, begin, end);
1153 return sal_True;
1155 sal_Bool FillFtnNote(sal_uLong& begin, sal_uLong& end)
1157 if (nFtnNote == 0xffff)
1158 return sal_False;
1159 Fill(nFtnNote, begin, end);
1160 return sal_True;
1162 sal_Bool FillEvenHeadL(sal_uLong& begin, sal_uLong& end)
1164 if (nEvenHeadL == 0xffff)
1165 return sal_False;
1166 Fill(nEvenHeadL, begin, end);
1167 return sal_True;
1169 sal_Bool FillOddHeadL(sal_uLong& begin, sal_uLong& end)
1171 if (nOddHeadL == 0xffff)
1172 return sal_False;
1173 Fill(nOddHeadL, begin, end);
1174 return sal_True;
1176 sal_Bool FillEvenFootL(sal_uLong& begin, sal_uLong& end)
1178 if (nEvenFootL == 0xffff)
1179 return sal_False;
1180 Fill(nEvenFootL, begin, end);
1181 return sal_True;
1183 sal_Bool FillOddFootL(sal_uLong& begin, sal_uLong& end)
1185 if (nOddFootL == 0xffff)
1186 return sal_False;
1187 Fill(nOddFootL, begin, end);
1188 return sal_True;
1190 sal_Bool FillFirstHeadL(sal_uLong& begin, sal_uLong& end)
1192 if (nFirstHeadL == 0xffff)
1193 return sal_False;
1194 Fill(nFirstHeadL, begin, end);
1195 return sal_True;
1197 sal_Bool FillFirstFootL(sal_uLong& begin, sal_uLong& end)
1199 if (nFirstFootL == 0xffff)
1200 return sal_False;
1201 Fill(nFirstFootL, begin, end);
1202 return sal_True;
1204 void Start(Ww1Shell&, Ww1Manager&);
1205 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1208 //////////////////////////////////////////////////////////////// Fields
1209 class Ww1Fields : public Ww1PlcFields
1211 sal_uInt16 nPlcIndex;
1212 String sErgebnis; // das von word errechnete ergebniss
1213 SwField* pField;
1214 sal_uLong Where(sal_uInt16 nIndex) // innerhalb des textes
1215 { return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); }
1217 public:
1218 Ww1Fields(Ww1Fib& rFibL, sal_uLong ulFilePos, sal_uInt16 nBytes)
1219 : Ww1PlcFields(rFibL, ulFilePos, nBytes), nPlcIndex(0), pField(0)
1221 // innerhalb des textes
1222 sal_uLong Where() { return Where(nPlcIndex); }
1223 void operator++()
1225 OSL_ENSURE(nPlcIndex+1 <= Count(), "Ww1Fields");
1226 nPlcIndex++;
1228 void Seek(sal_uLong ulNew) { Ww1PlcFields::Seek(ulNew, nPlcIndex); }
1229 W1_FLD* GetData()
1231 OSL_ENSURE(nPlcIndex < Count(), "Ww1Fields");
1232 return Ww1PlcFields::GetData(nPlcIndex);
1234 sal_uLong GetLength();
1235 friend std::ostream& operator <<(std::ostream&, Ww1Manager&);
1236 void Start(Ww1Shell&, Ww1Manager&);
1237 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1238 void Out(Ww1Shell&, Ww1Manager&, sal_uInt16=0);
1241 class Ww1TextFields : public Ww1Fields
1243 public:
1244 Ww1TextFields(Ww1Fib& rFibL)
1245 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMomGet(),
1246 rFibL.GetFIB().cbPlcffldMomGet())
1250 class Ww1FootnoteFields : public Ww1Fields
1252 public:
1253 Ww1FootnoteFields(Ww1Fib& rFibL)
1254 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldFtnGet(),
1255 rFibL.GetFIB().cbPlcffldFtnGet())
1259 class Ww1HeaderFooterFields : public Ww1Fields
1261 public:
1262 Ww1HeaderFooterFields(Ww1Fib& rFibL)
1263 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldHdrGet(),
1264 rFibL.GetFIB().cbPlcffldHdrGet())
1268 class Ww1MacroFields : public Ww1Fields
1270 public:
1271 Ww1MacroFields(Ww1Fib& rFibL)
1272 : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMcrGet(),
1273 rFibL.GetFIB().cbPlcffldMcrGet())
1277 //////////////////////////////////////////////////////////////// Bookmarks
1278 class Ww1Bookmarks
1280 Ww1PlcBookmarkTxt aNames;
1281 Ww1PlcBookmarkPos* pPos[2];
1282 Ww1Fib& rFib;
1284 sal_uInt16 nPlcIdx[2];
1285 sal_uInt16 nIsEnd;
1286 sal_Bool bOK;
1287 public:
1288 Ww1Bookmarks(Ww1Fib& rFib);
1289 ~Ww1Bookmarks()
1291 delete pPos[1];
1292 delete pPos[0];
1294 sal_uLong Where() const { return pPos[nIsEnd]->WhereCP(nPlcIdx[nIsEnd]); }
1295 void operator++();
1296 sal_Bool GetError() const { return !bOK; }
1297 long GetHandle() const;
1298 sal_Bool GetIsEnd() const { return ( nIsEnd ) ? sal_True : sal_False; }
1299 const String GetName() const;
1300 long Len() const;
1301 friend std::ostream& operator <<(std::ostream&, Ww1Bookmarks&);
1302 void Start(Ww1Shell&, Ww1Manager&);
1303 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1304 void Out(Ww1Shell&, Ww1Manager&, sal_uInt16=0);
1307 ///////////////////////////////////////////////////////////// Footnotes
1308 class Ww1Footnotes : public Ww1PlcFootnoteRef
1310 sal_uInt16 nPlcIndex;
1311 Ww1PlcFootnoteTxt aText;
1312 sal_Bool bStarted;
1313 public:
1314 Ww1Footnotes(Ww1Fib& rFibL)
1315 : Ww1PlcFootnoteRef(rFibL), nPlcIndex(0), aText(rFibL), bStarted(sal_False)
1317 // innerhalb des textes
1318 sal_uLong Where()
1320 sal_uLong ulRet = 0xffffffff;
1321 if (Count())
1322 ulRet = Ww1PlcFootnoteRef::Where(nPlcIndex);
1323 return ulRet;
1325 void operator++()
1327 OSL_ENSURE(nPlcIndex+1 <= Count(), "Ww1Footnotes");
1328 nPlcIndex++;
1330 void Start(Ww1Shell&, Ww1Manager&);
1331 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1334 /////////////////////////////////////////////////////////////////// Sep
1335 class Ww1Sep : public Ww1PlcSep
1337 Ww1HeaderFooter aHdd;
1338 sal_uInt16 nPlcIndex;
1339 public:
1340 Ww1Sep(Ww1Fib& rFibL, sal_uInt16 grpfIhdt)
1341 : Ww1PlcSep(rFibL), aHdd(rFibL, grpfIhdt), nPlcIndex(0) {}
1343 Ww1HeaderFooter& GetHdd() { return aHdd; }
1344 void operator++() { nPlcIndex++; }
1345 sal_uInt8* GetData() { return Ww1PlcSep::GetData(nPlcIndex); }
1346 // innerhalb des textes
1347 sal_uLong Where() { return Ww1PlcSep::Where(nPlcIndex); }
1348 void SetGrpfIhdt(sal_uInt8 grpfIhdt)
1350 GetHdd().SetGrpfIhdt(grpfIhdt);
1352 void Start(Ww1Shell&, Ww1Manager&);
1353 void Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
1354 { aHdd.Stop(rOut, rMan, c); }
1357 /////////////////////////////////////////////////////////////////// Pap
1358 class Ww1Pap : public Ww1PlcPap
1360 sal_uInt16 nPlcIndex;
1361 sal_uInt16 nPushedPlcIndex;
1362 sal_uInt16 nFkpIndex;
1363 sal_uInt16 nPushedFkpIndex;
1364 sal_uLong ulOffset;
1365 Ww1FkpPap* pPap;
1367 sal_Bool FindSprm(sal_uInt16 nId, sal_uInt8* pStart, sal_uInt8* pEnd);
1368 void UpdateIdx()
1370 if (pPap && nFkpIndex >= pPap->Count() )
1372 delete pPap;
1373 pPap = NULL;
1374 nPlcIndex++;
1376 if( !pPap )
1377 Where();
1379 sal_Bool HasId0(sal_uInt16 nId);
1381 public:
1382 Ww1Pap(Ww1Fib& rFib);
1383 ~Ww1Pap() { delete pPap; }
1384 sal_uLong Where( sal_Bool bSetIndex = sal_True ); // innerhalb des textes
1385 void operator++();
1386 sal_Bool FillStart(sal_uInt8*& pB, sal_uInt16& nSize)
1388 UpdateIdx();
1389 return pPap->Fill(nFkpIndex, pB, nSize);
1391 sal_Bool FillStop(sal_uInt8*& pB, sal_uInt16& nSize)
1393 return nFkpIndex ? pPap->Fill(nFkpIndex-1, pB, nSize) : sal_False;
1395 void Start(Ww1Shell&, Ww1Manager&);
1396 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1397 void Seek(sal_uLong);
1398 void Push(sal_uLong ulOffsetTmp = 0)
1400 OSL_ENSURE(!Pushed(), "Ww1Pap");
1401 nPushedPlcIndex = nPlcIndex;
1402 nPushedFkpIndex = nFkpIndex;
1403 Seek(ulOffsetTmp);
1404 ulOffset = ulOffsetTmp;
1405 delete pPap;
1406 pPap = NULL;
1408 sal_Bool Pushed()
1410 return nPushedPlcIndex != 0xffff;
1412 void Pop()
1414 OSL_ENSURE(Pushed(), "Ww1Pap");
1415 ulOffset = 0;
1416 nPlcIndex = nPushedPlcIndex;
1417 nFkpIndex = nPushedFkpIndex;
1418 nPushedPlcIndex = 0xffff;
1419 nPushedFkpIndex = 0xffff;
1420 delete pPap;
1421 pPap = NULL;
1422 Where( sal_False );
1424 sal_Bool HasId(sal_uInt16 nId);
1427 /////////////////////////////////////////////////////////////////// Chp
1428 class Ww1Chp : public Ww1PlcChp
1430 sal_uInt16 nPlcIndex;
1431 sal_uInt16 nPushedPlcIndex;
1432 sal_uInt16 nFkpIndex;
1433 sal_uInt16 nPushedFkpIndex;
1434 sal_uLong ulOffset;
1435 Ww1FkpChp* pChp;
1436 void UpdateIdx()
1438 if (pChp && nFkpIndex >= pChp->Count() )
1440 delete pChp;
1441 pChp = NULL;
1442 nPlcIndex++;
1444 if( !pChp )
1445 Where();
1448 public:
1449 Ww1Chp( Ww1Fib& rFib );
1450 ~Ww1Chp() { delete pChp; }
1451 sal_uLong Where( sal_Bool bSetIndex = sal_True ); // innerhalb des textes
1452 void operator++();
1453 sal_Bool FillStart(W1_CHP& rChp)
1455 UpdateIdx();
1456 return pChp->Fill(nFkpIndex, rChp);
1458 sal_Bool FillStop(W1_CHP& rChp)
1459 { return nFkpIndex ? pChp->Fill(nFkpIndex-1, rChp) : sal_False; }
1460 void Start(Ww1Shell&, Ww1Manager&);
1461 void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&);
1462 void Seek(sal_uLong);
1463 void Push(sal_uLong ulOffsetTmp = 0)
1465 OSL_ENSURE(!Pushed(), "Ww1Chp");
1466 nPushedPlcIndex = nPlcIndex;
1467 nPushedFkpIndex = nFkpIndex;
1468 Seek(ulOffsetTmp);
1469 ulOffset = ulOffsetTmp;
1470 delete pChp;
1471 pChp = NULL;
1473 sal_Bool Pushed() { return nPushedPlcIndex != 0xffff; }
1474 void Pop()
1476 OSL_ENSURE(Pushed(), "Ww1Chp");
1477 ulOffset = 0;
1478 nPlcIndex = nPushedPlcIndex;
1479 nFkpIndex = nPushedFkpIndex;
1480 nPushedPlcIndex = 0xffff;
1481 nPushedFkpIndex = 0xffff;
1482 delete pChp;
1483 pChp = NULL;
1484 Where( sal_False );
1488 /////////////////////////////////////////////////////////////// Manager
1490 // zentraler aufhaenger der ww-seite des filters, konstruiert aus dem
1491 // inputstream (ww-datei) enthaelt er alles, was noetig ist, um in die
1492 // shell (pm-seite) gepiped zu werden.
1494 class Ww1Manager
1496 sal_Bool bOK;
1497 bool bInTtp;
1498 bool bInStyle;
1499 bool bStopAll;
1500 Ww1Fib aFib;
1501 Ww1Dop aDop;
1502 Ww1Fonts aFonts;
1503 // ab jetzt alles paarig, fuer 'pushed':
1504 Ww1DocText aDoc;
1505 Ww1PlainText* pDoc;
1506 sal_uLong ulDocSeek;
1507 sal_uLong* pSeek;
1508 Ww1TextFields aFld;
1509 Ww1Fields* pFld;
1510 // selbst 'push'bar:
1511 Ww1Chp aChp;
1512 Ww1Pap aPap;
1513 // nicht in textbereichen vorhanden, wenn ge'pushed'
1514 Ww1Footnotes aFtn;
1515 Ww1Bookmarks aBooks;
1516 Ww1Sep aSep;
1518 void OutStop( Ww1Shell&, sal_Unicode );
1519 void OutStart( Ww1Shell& );
1520 void Out(Ww1Shell&, sal_Unicode );
1522 public:
1523 Ww1Manager(SvStream& rStrm, sal_uLong nFieldFlgs);
1524 sal_Bool GetError() const { return !bOK; }
1526 // Fuer Tabellen
1527 void SetInTtp(bool bSet = true) { bInTtp = bSet; }
1528 bool IsInTtp() const { return bInTtp; }
1529 void SetInStyle(bool bSet = true) { bInStyle = bSet; }
1530 bool IsInStyle() const { return bInStyle; }
1531 void SetStopAll(bool bSet = true) { bStopAll = bSet; }
1532 bool IsStopAll() const { return bStopAll; }
1533 sal_Bool HasInTable();
1534 sal_Bool HasTtp();
1535 sal_Bool LastHasTtp();
1537 // Fuer Flys
1538 sal_Bool HasPPc();
1539 sal_Bool HasPDxaAbs();
1541 Ww1Fib& GetFib() { return aFib; }
1542 Ww1PlainText& GetText() { return *pDoc; }
1543 Ww1Dop& GetDop() { return aDop; }
1544 Ww1Sep& GetSep() { return aSep; }
1545 // innerhalb des textes
1546 sal_uLong Where() { return pDoc->Where(); }
1547 void Fill( sal_Unicode& rChr ) { pDoc->Out( rChr ); }
1548 sal_uInt8 Fill( String& rStr, sal_uLong ulLen)
1550 ulLen += pDoc->Where();
1551 return sal::static_int_cast< sal_uInt8 >(pDoc->Out(rStr, ulLen));
1553 SvxFontItem GetFont(sal_uInt16 nFCode);
1554 friend Ww1Shell& operator <<(Ww1Shell&, Ww1Manager&);
1555 friend std::ostream& operator <<(std::ostream&, Ww1Manager&);
1556 sal_Bool Pushed() { return pDoc != &aDoc; }
1557 void Pop();
1558 void Push0(Ww1PlainText* pDoc, sal_uLong, Ww1Fields* = 0);
1559 void Push1(Ww1PlainText* pDoc, sal_uLong ulSeek, sal_uLong ulSeek2 = 0,
1560 Ww1Fields* = 0);
1563 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */