xref: /AOO41X/main/sw/source/filter/ww8/ww8scan.hxx (revision 8b45e15366a4ad8487d7bf9dca498bd1c15753be)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
25 
26 #ifndef _WW8SCAN_HXX
27 #define _WW8SCAN_HXX
28 
29 #ifndef LONG_MAX
30 #include <limits.h>
31 #endif
32 #include <stack>
33 #include <vector>
34 #include <list>
35 #include <algorithm>
36 #include <tools/solar.h>        // UINTXX
37 #include <tools/datetime.hxx>
38 #include <tools/stream.hxx>
39 #include <tools/string.hxx>
40 #include <errhdl.hxx>       // ASSERT()
41 #include "hash_wrap.hxx"
42 #include "sortedarray.hxx"
43 
44 #ifndef WW8STRUC_HXX
45 #include "ww8struc.hxx"         // FIB, STSHI, STD...
46 #endif
47 #include <types.hxx>
48 
49 #include <unomid.h>
50 
51 #define APPEND_CONST_ASC(s) AppendAscii(RTL_CONSTASCII_STRINGPARAM(s))
52 #define ASSIGN_CONST_ASC(s) AssignAscii(RTL_CONSTASCII_STRINGPARAM(s))
53 #define CREATE_CONST_ASC(s) String::CreateFromAscii( \
54     RTL_CONSTASCII_STRINGPARAM(s))
55 
56 
57 
58 //--Line below which the code has meaningful comments
59 
60 //Commonly used string literals for stream and storage names in word docs
61 namespace SL
62 {
63 #   define DEFCONSTSTRINGARRAY(X) extern const char a##X[sizeof("" #X "")]
64     DEFCONSTSTRINGARRAY(ObjectPool);
65     DEFCONSTSTRINGARRAY(1Table);
66     DEFCONSTSTRINGARRAY(0Table);
67     DEFCONSTSTRINGARRAY(Data);
68     DEFCONSTSTRINGARRAY(CheckBox);
69     DEFCONSTSTRINGARRAY(ListBox);
70     DEFCONSTSTRINGARRAY(TextBox);
71     DEFCONSTSTRINGARRAY(TextField);
72     DEFCONSTSTRINGARRAY(MSMacroCmds);
73 }
74 
75 /**
76     winword strings are typically Belt and Braces strings preceeded with a
77     pascal style count, and ending with a c style 0 terminator. 16bit chars
78     and count for ww8+ and 8bit chars and count for ww7-. The count and 0
79     can be checked for integrity to catch errors (e.g. lotus created documents)
80     where in error 8bit strings are used instead of 16bits strings for style
81     names.
82 */
83 template<class C> class wwString
84 {
85 public:
86     static bool TestBeltAndBraces(const SvStream& rStrm);
87     //move the other string related code into this class as time goes by
88 };
89 
90 typedef wwString<sal_uInt16> ww8String;
91 
92 struct SprmInfo
93 {
94     sal_uInt16 nId;         ///< A ww8 sprm is hardcoded as 16bits
95     unsigned int nLen : 6;
96     unsigned int nVari : 2;
97 };
98 
99 struct SprmInfoHash
100 {
operator ()SprmInfoHash101     size_t operator()(const SprmInfo &a) const
102         {
103             return a.nId;
104         }
105 };
106 
107 typedef ww::WrappedHash<SprmInfo, SprmInfoHash> wwSprmSearcher;
108 typedef ww::WrappedHash<sal_uInt16> wwSprmSequence;
109 
110 /**
111     wwSprmParser knows how to take a sequence of bytes and split it up into
112     sprms and their arguments
113 */
114 class wwSprmParser
115 {
116 private:
117     ww::WordVersion meVersion;
118     sal_uInt8 mnDelta;
119     const wwSprmSearcher *mpKnownSprms;
120     static const wwSprmSearcher* GetWW8SprmSearcher();
121     static const wwSprmSearcher* GetWW6SprmSearcher();
122     static const wwSprmSearcher* GetWW2SprmSearcher();
123 
124     SprmInfo GetSprmInfo(sal_uInt16 nId) const;
125 
126     sal_uInt8 SprmDataOfs(sal_uInt16 nId) const;
127 
128     enum SprmType {L_FIX=0, L_VAR=1, L_VAR2=2};
129 public:
130     //7- ids are very different to 8+ ones
131     wwSprmParser(ww::WordVersion eVersion);
132     /// Return the SPRM id at the beginning of this byte sequence
133     sal_uInt16 GetSprmId(const sal_uInt8* pSp) const;
134 
135     sal_uInt16 GetSprmSize(sal_uInt16 nId, const sal_uInt8* pSprm) const;
136 
137     /// Get known len of a sprms head, the bytes of the sprm id + any bytes
138     /// reserved to hold a variable length
139     sal_uInt16 DistanceToData(sal_uInt16 nId) const;
140 
141     /// Get len of a sprms data area, ignoring the bytes of the sprm id and
142     /// ignoring any len bytes. Reports the remaining data after those bytes
143     sal_uInt16 GetSprmTailLen(sal_uInt16 nId, const sal_uInt8 * pSprm) const;
144 
145     /// The minimum acceptable sprm len possible for this type of parser
MinSprmLen() const146     int MinSprmLen() const { return (IsSevenMinus(meVersion)) ? 2 : 3; }
147 
getVersion() const148     inline int getVersion() const { return meVersion; } //cmc, I'm dubious about the usage of this, how can it be 0
149 };
150 
151 //--Line abovewhich the code has meaningful comments
152 
153 class  WW8Fib;
154 class  WW8ScannerBase;
155 class  WW8PLCFspecial;
156 struct WW8PLCFxDesc;
157 class  WW8PLCFx_PCD;
158 
159 String WW8ReadPString( SvStream& rStrm, rtl_TextEncoding eEnc,
160     bool bAtEndSeekRel1 = true);
161 
162 /**
163  The following method reads a 2Byte unicode string.  If bAtEndSeekRel1 is set,
164  exactly ONE byte is skipped If nChars is set then that number of characters
165  (not bytes) is read, if its not set, the first character read is the length
166 */
167 String WW8Read_xstz(SvStream& rStrm, sal_uInt16 nChars, bool bAtEndSeekRel1);
168 
169 /**
170  reads array of strings (see MS documentation: STring TaBle stored in File)
171  returns NOT the original pascal strings but an array of converted char*
172 
173  attention: the *extra data* of each string are SKIPPED and ignored
174  */
175 void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen,
176     sal_uInt16 nExtraLen, rtl_TextEncoding eCS, ::std::vector<String> &rArray,
177     ::std::vector<ww::bytes>* pExtraArray = 0, ::std::vector<String>* pValueArray = 0);
178 
179 struct WW8FieldDesc
180 {
181     long nLen;              ///< Gesamtlaenge ( zum Text ueberlesen )
182     WW8_CP nSCode;          ///< Anfang Befehlscode
183     WW8_CP nLCode;          ///< Laenge
184     WW8_CP nSRes;           ///< Anfang Ergebnis
185     WW8_CP nLRes;           ///< Laenge ( == 0, falls kein Ergebnis )
186     sal_uInt16 nId;             ///< WW-Id fuer Felder
187     sal_uInt8 nOpt;              ///< WW-Flags ( z.B.: vom User geaendert )
188     sal_uInt8 bCodeNest:1;       ///< Befehl rekursiv verwendet
189     sal_uInt8 bResNest:1;        ///< Befehl in Resultat eingefuegt
190 };
191 
192 struct WW8PLCFxSave1
193 {
194     sal_uLong nPLCFxPos;
195     sal_uLong nPLCFxPos2;       ///< fuer PLCF_Cp_Fkp: PieceIter-Pos
196     long nPLCFxMemOfs;
197     WW8_CP nStartCp;        ///< for cp based iterator like PAP and CHP
198     long nCpOfs;
199     WW8_FC nStartFC;
200     WW8_CP nAttrStart;
201     WW8_CP nAttrEnd;
202     bool bLineEnd;
203 };
204 
205 /**
206     u.a. fuer Felder, also genausoviele Attr wie Positionen,
207     falls Ctor-Param bNoEnd = false
208 */
209 class WW8PLCFspecial        // Iterator fuer PLCFs
210 {
211 private:
212     sal_Int32* pPLCF_PosArray;  ///< Pointer auf Pos-Array und auf ganze Struktur
213     sal_uInt8*  pPLCF_Contents;  ///< Pointer auf Inhalts-Array-Teil des Pos-Array
214     long nIMax;             ///< Anzahl der Elemente
215     long nIdx;              ///< Merker, wo wir gerade sind
216     long nStru;
217 public:
218     WW8PLCFspecial( SvStream* pSt, long nFilePos, long nPLCF,
219         long nStruct, long nStartPos = -1 );
~WW8PLCFspecial()220     ~WW8PLCFspecial() { delete[] pPLCF_PosArray; }
221     bool IsValid();
GetIdx() const222     long GetIdx() const { return nIdx; }
SetIdx(long nI)223     void SetIdx( long nI ) { nIdx = nI; }
GetIMax() const224     long GetIMax() const { return nIMax; }
225     bool SeekPos(long nPos);            // geht ueber FC- bzw. CP-Wert
226                                         // bzw. naechste groesseren Wert
227     bool SeekPosExact(long nPos);
Where() const228     sal_Int32 Where() const
229         { return ( nIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nIdx]; }
230     bool Get(WW8_CP& rStart, void*& rpValue) const;
231     bool GetData(long nIdx, WW8_CP& rPos, void*& rpValue) const;
232 
GetData(long nInIdx) const233     const void* GetData( long nInIdx ) const
234     {
235         return ( nInIdx >= nIMax ) ? 0
236             : (const void*)&pPLCF_Contents[nInIdx * nStru];
237     }
GetPos(long nInIdx) const238     sal_Int32 GetPos( long nInIdx ) const
239         { return ( nInIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nInIdx]; }
240 
operator ++(int)241     WW8PLCFspecial& operator ++( int ) { nIdx++; return *this; }
operator --(int)242     WW8PLCFspecial& operator --( int ) { nIdx--; return *this; }
243 };
244 
245 /** simple Iterator for SPRMs */
246 class WW8SprmIter
247 {
248 private:
249     const wwSprmParser &mrSprmParser;
250     // these members will be updated
251     const sal_uInt8* pSprms; // remaining part of the SPRMs ( == start of akt. SPRM)
252     const sal_uInt8* pAktParams; // start of akt. SPRM's parameters
253     sal_uInt16 nAktId;
254     sal_uInt16 nAktSize;
255 
256     long nRemLen;   // length of remaining SPRMs (including akt. SPRM)
257 
258     void UpdateMyMembers();
259 public:
260     explicit WW8SprmIter( const sal_uInt8* pSprms_, long nLen_,
261         const wwSprmParser &rSprmParser);
262     void  SetSprms( const sal_uInt8* pSprms_, long nLen_ );
263     const sal_uInt8* FindSprm(sal_uInt16 nId);
264     const sal_uInt8*  operator ++( int );
GetSprms() const265     const sal_uInt8* GetSprms() const
266         { return ( pSprms && (0 < nRemLen) ) ? pSprms : 0; }
GetAktParams() const267     const sal_uInt8* GetAktParams() const { return pAktParams; }
GetAktId() const268     sal_uInt16 GetAktId() const { return nAktId; }
269 private:
270     //No copying
271     WW8SprmIter(const WW8SprmIter&);
272     WW8SprmIter& operator=(const WW8SprmIter&);
273 };
274 
275 /* u.a. fuer FKPs auf normale Attr., also ein Attr weniger als Positionen */
276 class WW8PLCF                       // Iterator fuer PLCFs
277 {
278 private:
279     WW8_CP* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur
280     sal_uInt8* pPLCF_Contents;   // Pointer auf Inhalts-Array-Teil des Pos-Array
281     sal_Int32 nIMax;            // Anzahl der Elemente
282     sal_Int32 nIdx;
283     int nStru;
284 
285     void ReadPLCF( SvStream* pSt, WW8_FC nFilePos, sal_Int32 nPLCF );
286 
287     /*
288         Falls im Dok ein PLC fehlt und die FKPs solo dastehen,
289         machen wir uns hiermit einen PLC:
290     */
291     void GeneratePLCF( SvStream* pSt, sal_Int32 nPN, sal_Int32 ncpN );
292 
293     void MakeFailedPLCF();
294 public:
IsValidLength(sal_Int32 nPLCF)295     static bool IsValidLength( sal_Int32 nPLCF )
296     { return nPLCF >= 1 && nPLCF <= ( WW8_CP_MAX - 4 ); }
297 
298     WW8PLCF( SvStream* pSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
299         WW8_CP nStartPos = -1 );
300 
301     /*
302         folgender Ctor generiert ggfs. einen PLC aus nPN und ncpN
303     */
304     WW8PLCF( SvStream* pSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
305         WW8_CP nStartPos, sal_Int32 nPN, sal_Int32 ncpN );
306 
~WW8PLCF()307     ~WW8PLCF(){ delete[] pPLCF_PosArray; }
308 
309     bool IsValid();
310 
GetIdx() const311     sal_Int32 GetIdx() const { return nIdx; }
SetIdx(sal_Int32 nI)312     void SetIdx( sal_Int32 nI ) { nIdx = nI; }
GetIMax() const313     sal_Int32 GetIMax() const { return nIMax; }
314     bool SeekPos(WW8_CP nPos);
315     WW8_CP Where() const;
316     bool Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const;
operator ++(int)317     WW8PLCF& operator ++( int ) { if( nIdx < nIMax ) nIdx++; return *this; }
318 
GetData(sal_Int32 nInIdx) const319     const void* GetData( sal_Int32 nInIdx ) const
320     {
321         return ( nInIdx >= nIMax ) ? 0 :
322             (const void*)&pPLCF_Contents[nInIdx * nStru];
323     }
324 };
325 
326 /* for Piece Table (.i.e. FastSave Table) */
327 class WW8PLCFpcd
328 {
329 friend class WW8PLCFpcd_Iter;
330     sal_Int32* pPLCF_PosArray;  // Pointer auf Pos-Array und auf ganze Struktur
331     sal_uInt8*  pPLCF_Contents;  // Pointer auf Inhalts-Array-Teil des Pos-Array
332     long nIMax;
333     long nStru;
334 public:
335     WW8PLCFpcd( SvStream* pSt, long nFilePos, long nPLCF, long nStruct );
~WW8PLCFpcd()336     ~WW8PLCFpcd(){ delete[] pPLCF_PosArray; }
337     bool IsValid();
338 };
339 
340 /* mehrere WW8PLCFpcd_Iter koennen auf die gleiche WW8PLCFpcd zeigen !!!  */
341 class WW8PLCFpcd_Iter
342 {
343 private:
344     WW8PLCFpcd& rPLCF;
345     long nIdx;
346 
347     //No copying
348     WW8PLCFpcd_Iter(const WW8PLCFpcd_Iter&);
349     WW8PLCFpcd_Iter& operator=(const WW8PLCFpcd_Iter&);
350 public:
351     WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, long nStartPos = -1 );
GetIdx() const352     long GetIdx() const { return nIdx; }
SetIdx(long nI)353     void SetIdx( long nI ) { nIdx = nI; }
GetIMax() const354     long GetIMax() const { return rPLCF.nIMax; }
355     bool SeekPos(long nPos);
356     sal_Int32 Where() const;
357     bool Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const;
operator ++(int)358     WW8PLCFpcd_Iter& operator ++( int )
359     {
360         if( nIdx < rPLCF.nIMax )
361             nIdx++;
362         return *this;
363     }
364 };
365 
366 // PLCF-Typ:
367 enum ePLCFT{ CHP=0, PAP, SEP, /*HED, FNR, ENR,*/ PLCF_END };
368 
369 //Its hardcoded that eFTN be the first one: A very poor hack, needs to be fixed
370 enum eExtSprm { eFTN = 256, eEDN = 257, eFLD = 258, eBKN = 259, eAND = 260 };
371 
372 /*
373     pure virtual:
374 */
375 class WW8PLCFx              // virtueller Iterator fuer Piece Table Exceptions
376 {
377 private:
378     ww::WordVersion meVer;  // Version number of FIB
379     bool bIsSprm;           // PLCF von Sprms oder von anderem ( Footnote, ... )
380     WW8_FC nStartFc;
381     bool bDirty;
382 
383     //No copying
384     WW8PLCFx(const WW8PLCFx&);
385     WW8PLCFx& operator=(const WW8PLCFx&);
386 public:
WW8PLCFx(ww::WordVersion eVersion,bool bSprm)387     WW8PLCFx(ww::WordVersion eVersion, bool bSprm)
388         : meVer(eVersion), bIsSprm(bSprm), bDirty(false) {}
~WW8PLCFx()389     virtual ~WW8PLCFx() {}
IsSprm() const390     bool IsSprm() const { return bIsSprm; }
391     virtual sal_uLong GetIdx() const = 0;
392     virtual void SetIdx( sal_uLong nIdx ) = 0;
393     virtual sal_uLong GetIdx2() const;
394     virtual void SetIdx2( sal_uLong nIdx );
395     virtual bool SeekPos(WW8_CP nCpPos) = 0;
396     virtual WW8_FC Where() = 0;
397     virtual void GetSprms( WW8PLCFxDesc* p );
398     virtual long GetNoSprms( WW8_CP& rStart, WW8_CP&, sal_Int32& rLen );
399     virtual WW8PLCFx& operator ++( int ) = 0;
GetIstd() const400     virtual sal_uInt16 GetIstd() const { return 0xffff; }
401     virtual void Save( WW8PLCFxSave1& rSave ) const;
402     virtual void Restore( const WW8PLCFxSave1& rSave );
GetFIBVersion() const403     ww::WordVersion GetFIBVersion() const { return meVer; }
SetStartFc(WW8_FC nFc)404     void SetStartFc( WW8_FC nFc ) { nStartFc = nFc; }
GetStartFc() const405     WW8_FC GetStartFc() const { return nStartFc; }
SetDirty(bool bIn)406     void SetDirty(bool bIn) {bDirty=bIn;}
GetDirty() const407     bool GetDirty() const {return bDirty;}
408 };
409 
410 class WW8PLCFx_PCDAttrs : public WW8PLCFx
411 {
412 private:
413     WW8PLCFpcd_Iter* pPcdI;
414     WW8PLCFx_PCD* pPcd;
415     sal_uInt8** const pGrpprls;      // Attribute an Piece-Table
416     SVBT32 aShortSprm;          // mini storage: can contain ONE sprm with
417                                 // 1 byte param
418     sal_uInt16 nGrpprls;            // Attribut Anzahl davon
419 
420     //No copying
421     WW8PLCFx_PCDAttrs(const WW8PLCFx_PCDAttrs&);
422     WW8PLCFx_PCDAttrs& operator=(const WW8PLCFx_PCDAttrs&);
423 public:
424     WW8PLCFx_PCDAttrs(ww::WordVersion eVersion, WW8PLCFx_PCD* pPLCFx_PCD,
425         const WW8ScannerBase* pBase );
426     virtual sal_uLong GetIdx() const;
427     virtual void SetIdx( sal_uLong nI );
428     virtual bool SeekPos(WW8_CP nCpPos);
429     virtual WW8_FC Where();
430     virtual void GetSprms( WW8PLCFxDesc* p );
431     virtual WW8PLCFx& operator ++( int );
432 
GetIter() const433     WW8PLCFpcd_Iter* GetIter() const { return pPcdI; }
434 };
435 
436 class WW8PLCFx_PCD : public WW8PLCFx            // Iterator fuer Piece Table
437 {
438 private:
439     WW8PLCFpcd_Iter* pPcdI;
440     bool bVer67;
441     WW8_CP nClipStart;
442 
443     //No copying
444     WW8PLCFx_PCD(const WW8PLCFx_PCD&);
445     WW8PLCFx_PCD& operator=(const WW8PLCFx_PCD&);
446 public:
447     WW8PLCFx_PCD(ww::WordVersion eVersion, WW8PLCFpcd* pPLCFpcd,
448         WW8_CP nStartCp, bool bVer67P);
449     virtual ~WW8PLCFx_PCD();
450     virtual sal_uLong GetIMax() const;
451     virtual sal_uLong GetIdx() const;
452     virtual void SetIdx( sal_uLong nI );
453     virtual bool SeekPos(WW8_CP nCpPos);
454     virtual WW8_FC Where();
455     virtual long GetNoSprms( WW8_CP& rStart, WW8_CP&, sal_Int32& rLen );
456     virtual WW8PLCFx& operator ++( int );
457     WW8_CP AktPieceStartFc2Cp( WW8_FC nStartPos );
458     WW8_FC AktPieceStartCp2Fc( WW8_CP nCp );
459     void AktPieceFc2Cp(WW8_CP& rStartPos, WW8_CP& rEndPos,
460         const WW8ScannerBase *pSBase);
GetPLCFIter()461     WW8PLCFpcd_Iter* GetPLCFIter() { return pPcdI; }
SetClipStart(WW8_CP nIn)462     void SetClipStart(WW8_CP nIn) { nClipStart = nIn; }
GetClipStart()463     WW8_CP GetClipStart() { return nClipStart; }
464 
TransformPieceAddress(long nfc,bool & bIsUnicodeAddress)465     static sal_Int32 TransformPieceAddress(long nfc, bool& bIsUnicodeAddress)
466     {
467         bIsUnicodeAddress = 0 == (0x40000000 & nfc);
468         return bIsUnicodeAddress ?  nfc : (nfc & 0x3fffFFFF) / 2;
469     }
470 };
471 
472 /**
473  Iterator for Piece Table Exceptions of Fkps
474  works only with FCs, not with CPs !  ( Low-Level )
475 */
476 class WW8PLCFx_Fc_FKP : public WW8PLCFx
477 {
478 public:
479     class WW8Fkp        // Iterator for Formatted Disk Page
480     {
481     private:
482         class Entry
483         {
484         public:
485             WW8_FC mnFC;
486 
487             sal_uInt8* mpData;
488             sal_uInt16 mnLen;
489             sal_uInt16 mnIStd; // only for Fkp.Papx (actualy Style-Nr)
490             bool mbMustDelete;
491 
Entry(WW8_FC nFC)492             explicit Entry(WW8_FC nFC) : mnFC(nFC), mpData(0), mnLen(0),
493                 mnIStd(0), mbMustDelete(false) {}
494             Entry(const Entry &rEntry);
495             ~Entry();
496             bool operator<(const Entry& rEntry) const;
497             Entry& operator=(const Entry& rEntry);
498         };
499 
500         sal_uInt8 maRawData[512];
501         std::vector<Entry> maEntries;
502 
503         long nItemSize;     // entweder 1 Byte oder ein komplettes BX
504 
505         // Offset in Stream where last read of 52 bytes took place
506         long nFilePos;
507         sal_uInt8 mnIdx;         // Pos-Merker
508         ePLCFT ePLCF;
509         sal_uInt8 mnIMax;         // Anzahl der Eintraege
510 
511         wwSprmParser maSprmParser;
512     public:
513         WW8Fkp (ww::WordVersion eVersion, SvStream* pFKPStrm,
514             SvStream* pDataStrm, long _nFilePos, long nItemSiz, ePLCFT ePl,
515             WW8_FC nStartFc = -1);
516         void Reset(WW8_FC nPos);
GetFilePos() const517         long GetFilePos() const { return nFilePos; }
GetIdx() const518         sal_uInt8 GetIdx() const { return mnIdx; }
519         bool SetIdx(sal_uInt8 nI);
520         bool SeekPos(WW8_FC nFc);
Where() const521         WW8_FC Where() const
522         {
523             return (mnIdx < mnIMax) ? maEntries[mnIdx].mnFC : WW8_FC_MAX;
524         }
operator ++(int)525         WW8Fkp& operator ++( int )
526         {
527             if (mnIdx < mnIMax)
528                 mnIdx++;
529             return *this;
530         }
531         sal_uInt8* Get( WW8_FC& rStart, WW8_FC& rEnd, sal_Int32& rLen ) const;
GetIstd() const532         sal_uInt16 GetIstd() const { return maEntries[mnIdx].mnIStd; }
533 
534         /*
535             liefert einen echten Pointer auf das Sprm vom Typ nId,
536             falls ein solches im Fkp drin ist.
537         */
538         sal_uInt8* GetLenAndIStdAndSprms(sal_Int32& rLen) const;
539 
540         /*
541             ruft GetLenAndIStdAndSprms() auf...
542         */
543         const sal_uInt8* HasSprm( sal_uInt16 nId );
544         bool HasSprm(sal_uInt16 nId, std::vector<const sal_uInt8 *> &rResult);
545 
GetSprmParser() const546         const wwSprmParser &GetSprmParser() const { return maSprmParser; }
547     };
548 private:
549     SvStream* pFKPStrm;         // Input-File
550     SvStream* pDataStrm;        // Input-File
551     WW8PLCF* pPLCF;
552     WW8Fkp* pFkp;
553 
554     /*
555         #100042#
556         Keep a cache of eMaxCache entries of previously seen pFkps, which
557         speeds up considerably table parsing and load save plcfs for what turn
558         out to be small text frames, which frames generally are
559 
560         size      : cache hits
561         cache all : 19168 pap, 48 chp
562         == 100    : 19166 pap, 48 chp
563         == 50     : 18918 pap, 48 chp
564         == 10     : 18549 pap, 47 chp
565         == 5      : 18515 pap, 47 chp
566     */
567     typedef std::list<WW8Fkp*>::iterator myiter;
568     std::list<WW8Fkp*> maFkpCache;
569     enum Limits {eMaxCache = 5};
570 
571     bool NewFkp();
572 
573     //No copying
574     WW8PLCFx_Fc_FKP(const WW8PLCFx_Fc_FKP&);
575     WW8PLCFx_Fc_FKP& operator=(const WW8PLCFx_Fc_FKP&);
576 protected:
577     ePLCFT ePLCF;
578     WW8PLCFx_PCDAttrs* pPCDAttrs;
579 public:
580     WW8PLCFx_Fc_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
581         const WW8Fib& rFib, ePLCFT ePl, WW8_FC nStartFcL );
582     virtual ~WW8PLCFx_Fc_FKP();
583     bool HasValidPLCF();
584     virtual sal_uLong GetIdx() const;
585     virtual void SetIdx( sal_uLong nIdx );
586     virtual bool SeekPos(WW8_FC nFcPos);
587     virtual WW8_FC Where();
588     sal_uInt8* GetSprmsAndPos( WW8_FC& rStart, WW8_FC& rEnd, sal_Int32& rLen );
589     virtual WW8PLCFx& operator ++( int );
590     virtual sal_uInt16 GetIstd() const;
591     void GetPCDSprms( WW8PLCFxDesc& rDesc );
592     const sal_uInt8* HasSprm( sal_uInt16 nId );
593     bool HasSprm(sal_uInt16 nId, std::vector<const sal_uInt8 *> &rResult);
HasFkp() const594     bool HasFkp() const { return (0 != pFkp); }
595 };
596 
597 /// Iterator fuer Piece Table Exceptions of Fkps arbeitet auf CPs (High-Level)
598 class WW8PLCFx_Cp_FKP : public WW8PLCFx_Fc_FKP
599 {
600 private:
601     const WW8ScannerBase& rSBase;
602     WW8PLCFx_PCD* pPcd;
603     WW8PLCFpcd_Iter *pPieceIter;
604     WW8_CP nAttrStart, nAttrEnd;
605     sal_uInt8 bLineEnd : 1;
606     sal_uInt8 bComplex : 1;
607 
608     //No copying
609     WW8PLCFx_Cp_FKP(const WW8PLCFx_Cp_FKP&);
610     WW8PLCFx_Cp_FKP& operator=(const WW8PLCFx_Cp_FKP&);
611 public:
612     WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
613         const WW8ScannerBase& rBase,  ePLCFT ePl );
614     virtual ~WW8PLCFx_Cp_FKP();
615     void ResetAttrStartEnd();
616     sal_uLong GetPCDIMax() const;
617     sal_uLong GetPCDIdx() const;
618     void SetPCDIdx( sal_uLong nIdx );
619     virtual sal_uLong GetIdx2() const;
620     virtual void  SetIdx2( sal_uLong nIdx );
621     virtual bool SeekPos(WW8_CP nCpPos);
622     virtual WW8_CP Where();
623     virtual void GetSprms( WW8PLCFxDesc* p );
624     virtual WW8PLCFx& operator ++( int );
625     virtual void Save( WW8PLCFxSave1& rSave ) const;
626     virtual void Restore( const WW8PLCFxSave1& rSave );
627 };
628 
629 /// Iterator for Piece Table Exceptions of Sepx
630 class WW8PLCFx_SEPX : public WW8PLCFx
631 {
632 private:
633     wwSprmParser maSprmParser;
634     SvStream* pStrm;
635     WW8PLCF* pPLCF;
636     sal_uInt8* pSprms;
637     sal_uInt16 nArrMax;
638     sal_uInt16 nSprmSiz;
639 
640     //no copying
641     WW8PLCFx_SEPX(const WW8PLCFx_SEPX&);
642     WW8PLCFx_SEPX& operator=(const WW8PLCFx_SEPX&);
643 public:
644     WW8PLCFx_SEPX( SvStream* pSt, SvStream* pTblxySt, const WW8Fib& rFib,
645         WW8_CP nStartCp );
646     virtual ~WW8PLCFx_SEPX();
647     bool HasValidPLCF();
648     virtual sal_uLong GetIdx() const;
649     virtual void SetIdx( sal_uLong nIdx );
GetIMax() const650     long GetIMax() const { return ( pPLCF ) ? pPLCF->GetIMax() : 0; }
651     virtual bool SeekPos(WW8_CP nCpPos);
652     virtual WW8_FC Where();
653     virtual void GetSprms( WW8PLCFxDesc* p );
654     virtual WW8PLCFx& operator ++( int );
655     const sal_uInt8* HasSprm( sal_uInt16 nId ) const;
656     const sal_uInt8* HasSprm( sal_uInt16 nId, sal_uInt8 n2nd ) const;
657     const sal_uInt8* HasSprm( sal_uInt16 nId, const sal_uInt8* pOtherSprms,
658         long nOtherSprmSiz ) const;
659     bool Find4Sprms(sal_uInt16 nId1, sal_uInt16 nId2, sal_uInt16 nId3, sal_uInt16 nId4,
660                     sal_uInt8*& p1,   sal_uInt8*& p2,   sal_uInt8*& p3,   sal_uInt8*& p4 ) const;
661 };
662 
663 /// Iterator fuer Fuss-/Endnoten und Anmerkungen
664 class WW8PLCFx_SubDoc : public WW8PLCFx
665 {
666 private:
667     WW8PLCF* pRef;
668     WW8PLCF* pTxt;
669 
670     //No copying
671     WW8PLCFx_SubDoc(const WW8PLCFx_SubDoc&);
672     WW8PLCFx_SubDoc& operator=(const WW8PLCFx_SubDoc&);
673 public:
674     WW8PLCFx_SubDoc(SvStream* pSt, ww::WordVersion eVersion, WW8_CP nStartCp,
675     long nFcRef, long nLenRef, long nFcTxt, long nLenTxt, long nStruc = 0);
676     virtual ~WW8PLCFx_SubDoc();
677     bool HasValidPLCF();
678     virtual sal_uLong GetIdx() const;
679     virtual void SetIdx( sal_uLong nIdx );
680     virtual bool SeekPos(WW8_CP nCpPos);
681     virtual WW8_FC Where();
682 
683     // liefert Reference Descriptoren
GetData(long nIdx=-1) const684     const void* GetData( long nIdx = -1 ) const
685     {
686         return pRef ? pRef->GetData( -1L == nIdx ? pRef->GetIdx() : nIdx ) : 0;
687     }
688 
689     //liefert Angabe, wo Kopf und Fusszeilen-Text zu finden ist
690     bool Get(long& rStart, void*& rpValue) const;
691     virtual void GetSprms(WW8PLCFxDesc* p);
692     virtual WW8PLCFx& operator ++( int );
Count() const693     long Count() const { return ( pRef ) ? pRef->GetIMax() : 0; }
694 };
695 
696 /// Iterator for footnotes and endnotes
697 class WW8PLCFx_FLD : public WW8PLCFx
698 {
699 private:
700     WW8PLCFspecial* pPLCF;
701     const WW8Fib& rFib;
702     //No copying
703     WW8PLCFx_FLD(const WW8PLCFx_FLD&);
704     WW8PLCFx_FLD& operator=(const WW8PLCFx_FLD &);
705 public:
706     WW8PLCFx_FLD(SvStream* pSt, const WW8Fib& rMyFib, short nType);
707     virtual ~WW8PLCFx_FLD();
708     bool HasValidPLCF();
709     virtual sal_uLong GetIdx() const;
710     virtual void SetIdx( sal_uLong nIdx );
711     virtual bool SeekPos(WW8_CP nCpPos);
712     virtual WW8_FC Where();
713     virtual void GetSprms(WW8PLCFxDesc* p);
714     virtual WW8PLCFx& operator ++( int );
715     bool StartPosIsFieldStart();
716     bool EndPosIsFieldEnd(WW8_CP&);
717     bool GetPara(long nIdx, WW8FieldDesc& rF);
718 };
719 
720 enum eBookStatus { BOOK_NORMAL = 0, BOOK_IGNORE = 0x1, BOOK_FIELD = 0x2 };
721 
722 /// Iterator for Booknotes
723 class WW8PLCFx_Book : public WW8PLCFx
724 {
725 private:
726     WW8PLCFspecial* pBook[2];           // Start and End Position
727     ::std::vector<String> aBookNames;   // Name
728     eBookStatus* pStatus;
729     long nIMax;                         // Number of Booknotes
730     sal_uInt16 nIsEnd;
731     int nBookmarkId; // counter incremented by GetUniqueBookmarkName.
732 
733     //No copying
734     WW8PLCFx_Book(const WW8PLCFx_Book&);
735     WW8PLCFx_Book& operator=(const WW8PLCFx_Book&);
736 public:
737     WW8PLCFx_Book(SvStream* pTblSt,const WW8Fib& rFib);
738     virtual ~WW8PLCFx_Book();
739     bool HasValidPLCF();
GetIMax() const740     long GetIMax() const { return nIMax; }
741     virtual sal_uLong GetIdx() const;
742     virtual void SetIdx( sal_uLong nI );
743     virtual sal_uLong GetIdx2() const;
744     virtual void SetIdx2( sal_uLong nIdx );
745     virtual bool SeekPos(WW8_CP nCpPos);
746     virtual WW8_FC Where();
747     virtual long GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen );
748     virtual WW8PLCFx& operator ++( int );
749     const String* GetName() const;
GetStartPos() const750     WW8_CP GetStartPos() const
751         { return ( nIsEnd ) ? WW8_CP_MAX : pBook[0]->Where(); }
752     long GetLen() const;
GetIsEnd() const753     bool GetIsEnd() const { return nIsEnd ? true : false; }
754     long GetHandle() const;
755     void SetStatus( sal_uInt16 nIndex, eBookStatus eStat );
756     bool MapName(String& rName);
757     String GetBookmark(long nStart,long nEnd, sal_uInt16 &nIndex);
758     eBookStatus GetStatus() const;
759     String GetUniqueBookmarkName(String &suggestedName);
760 };
761 
762 /*
763     hiermit arbeiten wir draussen:
764 */
765 struct WW8PLCFManResult
766 {
767     WW8_CP nCpPos;      // Attribut-Anfangsposition
768     long nMemLen;       // Laenge dazu
769     long nCp2OrIdx;     // footnote-textpos oder Index in PLCF
770     WW8_CP nAktCp;      // wird nur vom Aufrufer benutzt
771     const sal_uInt8* pMemPos;// Mem-Pos fuer Sprms
772     sal_uInt16 nSprmId;     // Sprm-Id ( 0 = ungueltige Id -> ueberspringen! )
773                         // (2..255) oder Pseudo-Sprm-Id (256..260)
774                         // bzw. ab Winword-Ver8 die Sprm-Id (800..)
775     sal_uInt8 nFlags;        // Absatz- oder Section-Anfang
776 };
777 
778 enum ManMaskTypes
779 {
780     MAN_MASK_NEW_PAP = 1,       // neue Zeile
781     MAN_MASK_NEW_SEP = 2        // neue Section
782 };
783 
784 enum ManTypes // enums for PLCFMan-ctor
785 {
786     MAN_MAINTEXT = 0, MAN_FTN = 1, MAN_EDN = 2, MAN_HDFT = 3, MAN_AND = 4,
787     MAN_TXBX = 5, MAN_TXBX_HDFT = 6
788 };
789 
790 /*
791     hiermit arbeitet der Manager drinnen:
792 */
793 struct WW8PLCFxDesc
794 {
795     WW8PLCFx* pPLCFx;
796     ::std::stack<sal_uInt16>* pIdStk;  // Speicher fuer Attr-Id fuer Attr-Ende(n)
797     const sal_uInt8* pMemPos;// wo liegen die Sprm(s)
798     long nOrigSprmsLen;
799 
800     WW8_CP nStartPos;
801     WW8_CP nEndPos;
802 
803     WW8_CP nOrigStartPos;
804     WW8_CP nOrigEndPos;   // The ending character position of a paragraph is
805                           // always one before the end reported in the FKP,
806                           // also a character run that ends on the same location
807                           // as the paragraph mark is adjusted to end just before
808                           // the paragraph mark so as to handle their close
809                           // first. The value being used to determing where the
810                           // properties end is in nEndPos, but the original
811                           // unadjusted end character position is important as
812                           // it can be used as the beginning cp of the next set
813                           // of properties
814 
815     WW8_CP nCp2OrIdx;     // wo liegen die NoSprm(s)
816     sal_Int32 nSprmsLen;  // wie viele Bytes fuer weitere Sprms / Laenge Fussnote
817     long nCpOfs;          // fuer Offset Header .. Footnote
818     bool bFirstSprm;      // fuer Erkennung erster Sprm einer Gruppe
819     bool bRealLineEnd;    // false bei Pap-Piece-Ende
820     void Save( WW8PLCFxSave1& rSave ) const;
821     void Restore( const WW8PLCFxSave1& rSave );
822     //With nStartPos set to WW8_CP_MAX then in the case of a pap or chp
823     //GetSprms will not search for the sprms, but instead take the
824     //existing ones.
WW8PLCFxDescWW8PLCFxDesc825     WW8PLCFxDesc() : pIdStk(0), nStartPos(WW8_CP_MAX) {}
826     void ReduceByOffset();
827 };
828 
829 #ifndef DUMP
830 
831 struct WW8PLCFxSaveAll;
832 class WW8PLCFMan
833 {
834 public:
835     enum WW8PLCFManLimits {MAN_ANZ_PLCF = 10};
836 private:
837     wwSprmParser maSprmParser;
838     long nCpO;                      // Origin Cp -- the basis for nNewCp
839 
840     WW8_CP nLineEnd;                // zeigt *hinter* das <CR>
841     long nLastWhereIdxCp;           // last result of WhereIdx()
842     sal_uInt16 nPLCF;                   // so viele PLCFe werden verwaltet
843     ManTypes nManType;
844     bool mbDoingDrawTextBox;        //Normally we adjust the end of attributes
845                                     //so that the end of a paragraph occurs
846                                     //before the para end mark, but for
847                                     //drawboxes we want the true offsets
848 
849     WW8PLCFxDesc aD[MAN_ANZ_PLCF];
850     WW8PLCFxDesc *pChp, *pPap, *pSep, *pFld, *pFtn, *pEdn, *pBkm, *pPcd,
851         *pPcdA, *pAnd;
852     WW8PLCFspecial *pFdoa, *pTxbx, *pTxbxBkd,*pMagicTables, *pSubdocs;
853     sal_uInt8* pExtendedAtrds;
854 
855     const WW8Fib* pWwFib;
856 
857     sal_uInt16 WhereIdx(bool* pbStart=0, long* pPos=0) const;
858     void AdjustEnds(WW8PLCFxDesc& rDesc);
859     void GetNewSprms(WW8PLCFxDesc& rDesc);
860     void GetNewNoSprms(WW8PLCFxDesc& rDesc);
861     void GetSprmStart(short nIdx, WW8PLCFManResult* pRes) const;
862     void GetSprmEnd(short nIdx, WW8PLCFManResult* pRes) const;
863     void GetNoSprmStart(short nIdx, WW8PLCFManResult* pRes) const;
864     void GetNoSprmEnd(short nIdx, WW8PLCFManResult* pRes) const;
865     void AdvSprm(short nIdx, bool bStart);
866     void AdvNoSprm(short nIdx, bool bStart);
867     sal_uInt16 GetId(const WW8PLCFxDesc* p ) const;
868 public:
869     WW8PLCFMan(WW8ScannerBase* pBase, ManTypes nType, long nStartCp,
870         bool bDoingDrawTextBox = false);
871     ~WW8PLCFMan();
872 
873     /*
874         Where fragt, an welcher naechsten Position sich irgendein
875         Attr aendert...
876     */
877     WW8_CP Where() const;
878 
879     bool Get(WW8PLCFManResult* pResult) const;
880     WW8PLCFMan& operator ++( int );
881     sal_uInt16 GetColl() const; // index of actual Style
882     WW8PLCFx_FLD* GetFld() const;
GetEdn() const883     WW8PLCFx_SubDoc* GetEdn() const { return (WW8PLCFx_SubDoc*)pEdn->pPLCFx; }
GetFtn() const884     WW8PLCFx_SubDoc* GetFtn() const { return (WW8PLCFx_SubDoc*)pFtn->pPLCFx; }
GetAtn() const885     WW8PLCFx_SubDoc* GetAtn() const { return (WW8PLCFx_SubDoc*)pAnd->pPLCFx; }
GetBook() const886     WW8PLCFx_Book* GetBook() const { return (WW8PLCFx_Book*)pBkm->pPLCFx; }
GetCpOfs() const887     long GetCpOfs() const { return pChp->nCpOfs; }  // for Header/Footer...
888 
889     /* fragt, ob *aktueller Absatz* einen Sprm diesen Typs hat */
890     const sal_uInt8* HasParaSprm( sal_uInt16 nId ) const;
891 
892     /* fragt, ob *aktueller Textrun* einen Sprm diesen Typs hat */
893     const sal_uInt8* HasCharSprm( sal_uInt16 nId ) const;
894     bool HasCharSprm(sal_uInt16 nId, std::vector<const sal_uInt8 *> &rResult) const;
895 
GetChpPLCF() const896     WW8PLCFx_Cp_FKP* GetChpPLCF() const
897         { return (WW8PLCFx_Cp_FKP*)pChp->pPLCFx; }
GetPapPLCF() const898     WW8PLCFx_Cp_FKP* GetPapPLCF() const
899         { return (WW8PLCFx_Cp_FKP*)pPap->pPLCFx; }
GetSepPLCF() const900     WW8PLCFx_SEPX* GetSepPLCF() const
901         { return (WW8PLCFx_SEPX*)pSep->pPLCFx; }
GetPap() const902     WW8PLCFxDesc* GetPap() const { return pPap; }
903     bool TransferOpenSprms(std::stack<sal_uInt16> &rStack);
904     void SeekPos( long nNewCp );
905     void SaveAllPLCFx( WW8PLCFxSaveAll& rSave ) const;
906     void RestoreAllPLCFx( const WW8PLCFxSaveAll& rSave );
GetFdoa() const907     WW8PLCFspecial* GetFdoa() const { return pFdoa; }
GetTxbx() const908     WW8PLCFspecial* GetTxbx() const { return pTxbx; }
GetTxbxBkd() const909     WW8PLCFspecial* GetTxbxBkd() const { return pTxbxBkd; }
GetMagicTables() const910     WW8PLCFspecial* GetMagicTables() const { return pMagicTables; }
GetWkbPLCF() const911     WW8PLCFspecial* GetWkbPLCF() const { return pSubdocs; }
GetExtendedAtrds() const912     sal_uInt8* GetExtendedAtrds() const { return pExtendedAtrds; }
GetManType() const913     ManTypes GetManType() const { return nManType; }
GetDoingDrawTextBox() const914     bool GetDoingDrawTextBox() const { return mbDoingDrawTextBox; }
915 };
916 
917 struct WW8PLCFxSaveAll
918 {
919     WW8PLCFxSave1 aS[WW8PLCFMan::MAN_ANZ_PLCF];
920 };
921 
922 #endif // !DUMP
923 
924 class WW8ScannerBase
925 {
926 friend WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(ww::WordVersion eVersion,
927     WW8PLCFx_PCD* pPLCFx_PCD, const WW8ScannerBase* pBase );
928 friend WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream*, SvStream*, SvStream*,
929     const WW8ScannerBase&, ePLCFT );
930 
931 #ifndef DUMP
932 friend WW8PLCFMan::WW8PLCFMan(WW8ScannerBase*, ManTypes, long, bool);
933 friend class SwWw8ImplReader;
934 friend class SwWW8FltControlStack;
935 #endif
936 
937 private:
938     const WW8Fib* pWw8Fib;
939     WW8PLCFx_Cp_FKP*  pChpPLCF;         // Character-Attrs
940     WW8PLCFx_Cp_FKP*  pPapPLCF;         // Para-Attrs
941     WW8PLCFx_SEPX*    pSepPLCF;         // Section-Attrs
942     WW8PLCFx_SubDoc*  pFtnPLCF;         // Footnotes
943     WW8PLCFx_SubDoc*  pEdnPLCF;         // EndNotes
944     WW8PLCFx_SubDoc*  pAndPLCF;         // Anmerkungen
945     WW8PLCFx_FLD*     pFldPLCF;         // Fields in Main Text
946     WW8PLCFx_FLD*     pFldHdFtPLCF;     // Fields in Header / Footer
947     WW8PLCFx_FLD*     pFldTxbxPLCF;     // Fields in Textboxes in Main Text
948     WW8PLCFx_FLD*     pFldTxbxHdFtPLCF; // Fields in Textboxes in Header / Footer
949     WW8PLCFx_FLD*     pFldFtnPLCF;      // Fields in Footnotes
950     WW8PLCFx_FLD*     pFldEdnPLCF;      // Fields in Endnotes
951     WW8PLCFx_FLD*     pFldAndPLCF;      // Fields in Anmerkungen
952     WW8PLCFspecial*   pMainFdoa;        // Graphic Primitives in Main Text
953     WW8PLCFspecial*   pHdFtFdoa;        // Graphic Primitives in Header / Footer
954     WW8PLCFspecial*   pMainTxbx;        // Textboxen in Main Text
955     WW8PLCFspecial*   pMainTxbxBkd;     // Break-Deskriptoren fuer diese
956     WW8PLCFspecial*   pHdFtTxbx;        // TextBoxen in Header / Footer
957     WW8PLCFspecial*   pHdFtTxbxBkd;     // Break-Deskriptoren fuer diese
958     WW8PLCFspecial*   pMagicTables;     // Break-Deskriptoren fuer diese
959     WW8PLCFspecial*   pSubdocs;         // subdoc references in master document
960     sal_uInt8*             pExtendedAtrds;   // Extended ATRDs
961     WW8PLCFx_Book*    pBook;            // Bookmarks
962 
963     WW8PLCFpcd*         pPiecePLCF; // fuer FastSave ( Basis-PLCF ohne Iterator )
964     WW8PLCFpcd_Iter*    pPieceIter; // fuer FastSave ( Iterator dazu )
965     WW8PLCFx_PCD*       pPLCFx_PCD;     // dito
966     WW8PLCFx_PCDAttrs*  pPLCFx_PCDAttrs;
967 
968     sal_uInt8**              pPieceGrpprls;  // Attribute an Piece-Table
969     sal_uInt16              nPieceGrpprls;  // Anzahl davon
970 
971     WW8PLCFpcd* OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF );
972     void DeletePieceTable();
973 public:
974     WW8ScannerBase( SvStream* pSt, SvStream* pTblSt, SvStream* pDataSt,
975         const WW8Fib* pWwF );
976     ~WW8ScannerBase();
977 
978     bool IsValid(); // all WW8PLCF... valid?
979 
AreThereFootnotes() const980     bool AreThereFootnotes() const { return pFtnPLCF->Count() > 0; };
AreThereEndnotes() const981     bool AreThereEndnotes()  const { return pEdnPLCF->Count() > 0; };
982 
983     //If you use WW8Fc2Cp you are almost certainly doing the wrong thing
984     //when it comes to fastsaved files, avoid like the plague. For export
985     //given that we never write fastsaved files you can use it, otherwise
986     //I will beat you with a stick
987     WW8_CP WW8Fc2Cp(WW8_FC nFcPos) const ;
988     WW8_FC WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode = 0,
989         WW8_CP* pNextPieceCp = 0, bool* pTestFlag = 0) const;
990 
991     xub_StrLen WW8ReadString(SvStream& rStrm, String& rStr, WW8_CP nAktStartCp,
992         long nTotalLen, rtl_TextEncoding eEnc ) const;
993 
994 };
995 
996 /** FIB - the File Information Block
997 
998     The FIB contains a "magic word" and pointers to the various other parts of
999     the file, as well as information about the length of the file.
1000     The FIB starts at the beginning of the file.
1001 */
1002 class WW8Fib
1003 {
1004 public:
1005     /**
1006         Program-Version asked for by us:
1007         in Ctor we check if it matches the value of nFib
1008 
1009         6 == "WinWord 6 or WinWord 95",
1010         7 == "only WinWord 95"
1011         8 == "WinWord 97 or newer"
1012     */
1013     sal_uInt8 nVersion;
1014     /*
1015         error status
1016     */
1017     sal_uLong nFibError;
1018     /*
1019         vom Ctor aus dem FIB gelesene Daten
1020         (entspricht nur ungefaehr der tatsaechlichen Struktur
1021          des Winword-FIB)
1022     */
1023     sal_uInt16 wIdent;      // 0x0 int magic number
1024     /*
1025         File Information Block (FIB) values:
1026         WinWord 1.0 = 33
1027         WinWord 2.0 = 45
1028         WinWord 6.0c for 16bit = 101
1029         Word 6/32 bit = 104
1030         Word 95 = 104
1031         Word 97 = 193
1032         Word 2000 = 217
1033         Word 2002 = 257
1034         Word 2003 = 268
1035         Word 2007 = 274
1036     */
1037     sal_uInt16 nFib;        // 0x2 FIB version written
1038     sal_uInt16 nProduct;    // 0x4 product version written by
1039     sal_Int16 lid;          // 0x6 language stamp---localized version;
1040     WW8_PN pnNext;          // 0x8
1041 
1042     sal_uInt16 fDot :1;     // 0xa 0001
1043     sal_uInt16 fGlsy :1;
1044     sal_uInt16 fComplex :1; // 0004 when 1, file is in complex, fast-saved format.
1045     sal_uInt16 fHasPic :1;  // 0008 file contains 1 or more pictures
1046     sal_uInt16 cQuickSaves :4; // 00F0 count of times file was quicksaved
1047     sal_uInt16 fEncrypted :1; //0100 1 if file is encrypted, 0 if not
1048     sal_uInt16 fWhichTblStm :1; //0200 When 0, this fib refers to the table stream
1049     sal_uInt16 fReadOnlyRecommended :1;
1050     sal_uInt16 fWriteReservation :1;
1051                                                     // named "0Table", when 1, this fib refers to the
1052                                                     // table stream named "1Table". Normally, a file
1053                                                     // will have only one table stream, but under unusual
1054                                                     // circumstances a file may have table streams with
1055                                                     // both names. In that case, this flag must be used
1056                                                     // to decide which table stream is valid.
1057 
1058     sal_uInt16 fExtChar :1; // 1000 =1, when using extended character set in file
1059     sal_uInt16 fFarEast :1; // 4000 =1, probably, when far-East language vaiants of Word is used to create a file #i90932#
1060 
1061     sal_uInt16 fObfuscated :1; // 8000=1. specifies whether the document is obfuscated using XOR obfuscation. otherwise this bit MUST be ignored.
1062 
1063     sal_uInt16 nFibBack;    // 0xc
1064     sal_uInt16 nHash;       // 0xe  file encrypted hash
1065     sal_uInt16 nKey;        // 0x10  file encrypted key
1066     sal_uInt8 envr;         // 0x12 environment in which file was created
1067                                     //      0 created by Win Word / 1 created by Mac Word
1068     sal_uInt8 fMac              :1;          // 0x13 when 1, this file was last saved in the Mac environment
1069     sal_uInt8 fEmptySpecial     :1;
1070     sal_uInt8 fLoadOverridePage :1;
1071     sal_uInt8 fFuturesavedUndo  :1;
1072     sal_uInt8 fWord97Saved      :1;
1073     sal_uInt8 fWord2000Saved    :1;
1074     sal_uInt8 :2;
1075 
1076     sal_uInt16 chse;        // 0x14 default extended character set id for text in document stream. (overidden by chp.chse)
1077                         //      0 = ANSI  / 256 Macintosh character set.
1078     sal_uInt16 chseTables;  // 0x16 default extended character set id for text in
1079                         //      internal data structures: 0 = ANSI, 256 = Macintosh
1080     WW8_FC fcMin;           // 0x18 file offset of first character of text
1081     WW8_FC fcMac;           // 0x1c file offset of last character of text + 1
1082 
1083     // Einschub fuer WW8 *****************************************************
1084     sal_uInt16 csw;             // Count of fields in the array of "shorts"
1085 
1086     // Marke: "rgsw" Beginning of the array of shorts
1087     sal_uInt16 wMagicCreated;                   // unique number Identifying the File's creator
1088                                                                 // 0x6A62 is the creator ID for Word and is reserved.
1089                                                                 // Other creators should choose a different value.
1090     sal_uInt16 wMagicRevised;                   // identifies the File's last modifier
1091   sal_uInt16 wMagicCreatedPrivate;  // private data
1092     sal_uInt16 wMagicRevisedPrivate;    // private data
1093     /*
1094     sal_Int16  pnFbpChpFirst_W6;            // not used
1095     sal_Int16  pnChpFirst_W6;                   // not used
1096     sal_Int16  cpnBteChp_W6;                    // not used
1097     sal_Int16  pnFbpPapFirst_W6;            // not used
1098     sal_Int16  pnPapFirst_W6;                   // not used
1099     sal_Int16  cpnBtePap_W6;                    // not used
1100     sal_Int16  pnFbpLvcFirst_W6;            // not used
1101     sal_Int16  pnLvcFirst_W6;                   // not used
1102     sal_Int16  cpnBteLvc_W6;                    // not used
1103     */
1104     sal_Int16  lidFE;                                   // Language id if document was written by Far East version
1105                                                                 // of Word (i.e. FIB.fFarEast is on)
1106     sal_uInt16 clw;                                     // Number of fields in the array of longs
1107 
1108     // Ende des Einschubs fuer WW8 *******************************************
1109 
1110     // Marke: "rglw" Beginning of the array of longs
1111     WW8_FC cbMac;           // 0x20 file offset of last byte written to file + 1.
1112 
1113     // WW8_FC u4[4];        // 0x24
1114     WW8_CP ccpText;         // 0x34 length of main document text stream
1115     WW8_CP ccpFtn;          // 0x38 length of footnote subdocument text stream
1116     WW8_CP ccpHdr;          // 0x3c length of header subdocument text stream
1117     WW8_CP ccpMcr;          // 0x40 length of macro subdocument text stream
1118     WW8_CP ccpAtn;          // 0x44 length of annotation subdocument text stream
1119     WW8_CP ccpEdn;          // 0x48 length of endnote subdocument text stream
1120     WW8_CP ccpTxbx;         // 0x4c length of textbox subdocument text stream
1121     WW8_CP ccpHdrTxbx;      // 0x50 length of header textbox subdocument text stream
1122 
1123     // Einschub fuer WW8 *****************************************************
1124     sal_Int32  pnFbpChpFirst;   // when there was insufficient memory for Word to expand
1125                                                 // the PLCFbte at save time, the PLCFbte is written
1126                                                 // to the file in a linked list of 512-byte pieces
1127                                                 // starting with this pn.
1128     /*
1129     // folgende Felder existieren zwar so in der Datei,
1130     // wir benutzen jedoch unten deklarierte General-Variablen
1131     // fuer Ver67 und Ver8 gemeinsam.
1132     sal_Int32  pnChpFirst;      // the page number of the lowest numbered page in the
1133                                                         // document that records CHPX FKP information
1134     sal_Int32  cpnBteChp;           // count of CHPX FKPs recorded in file. In non-complex
1135                                                         // files if the number of entries in the PLCFbteChpx
1136                                                         // is less than this, the PLCFbteChpx is incomplete.
1137     */
1138     sal_Int32  pnFbpPapFirst;   // when there was insufficient memory for Word to expand
1139                                                 // the PLCFbte at save time, the PLCFbte is written to
1140                                                 // the file in a linked list of 512-byte pieces
1141                                                 // starting with this pn
1142     /*
1143     // folgende Felder existieren zwar so in der Datei,
1144     // wir benutzen jedoch unten deklarierte General-Variablen
1145     // fuer Ver67 und Ver8 gemeinsam.
1146     sal_Int32  pnPapFirst;      // the page number of the lowest numbered page in the
1147                                                         // document that records PAPX FKP information
1148     sal_Int32  cpnBtePap;       // count of PAPX FKPs recorded in file. In non-complex
1149                                                         // files if the number of entries in the PLCFbtePapx is
1150                                                         // less than this, the PLCFbtePapx is incomplete.
1151     */
1152     sal_Int32  pnFbpLvcFirst;   // when there was insufficient memory for Word to expand
1153                                                 // the PLCFbte at save time, the PLCFbte is written to
1154                                                 // the file in a linked list of 512-byte pieces
1155                                                 // starting with this pn
1156     sal_Int32  pnLvcFirst;          // the page number of the lowest numbered page in the
1157                                                 // document that records LVC FKP information
1158     sal_Int32  cpnBteLvc;           // count of LVC FKPs recorded in file. In non-complex
1159                                                 // files if the number of entries in the PLCFbtePapx is
1160                                                 // less than this, the PLCFbtePapx is incomplete.
1161     sal_Int32  fcIslandFirst;   // ?
1162     sal_Int32  fcIslandLim;     // ?
1163     sal_uInt16 cfclcb;              // Number of fields in the array of FC/LCB pairs.
1164 
1165     // Ende des Einschubs fuer WW8 *******************************************
1166 
1167     // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
1168     WW8_FC fcStshfOrig;     // file offset of original allocation for STSH in table
1169                                                 // stream. During fast save Word will attempt to reuse
1170                                                 // this allocation if STSH is small enough to fit.
1171     sal_Int32 lcbStshfOrig; // 0x5c count of bytes of original STSH allocation
1172     WW8_FC fcStshf;         // 0x60 file offset of STSH in file.
1173     sal_Int32 lcbStshf;     // 0x64 count of bytes of current STSH allocation
1174     WW8_FC fcPlcffndRef;    // 0x68 file offset of footnote reference PLCF.
1175     sal_Int32 lcbPlcffndRef;    // 0x6c count of bytes of footnote reference PLCF
1176                         //      == 0 if no footnotes defined in document.
1177 
1178     WW8_FC fcPlcffndTxt;    // 0x70 file offset of footnote text PLCF.
1179     sal_Int32 lcbPlcffndTxt;    // 0x74 count of bytes of footnote text PLCF.
1180                         //      == 0 if no footnotes defined in document
1181 
1182     WW8_FC fcPlcfandRef;    // 0x78 file offset of annotation reference PLCF.
1183     sal_Int32 lcbPlcfandRef;    // 0x7c count of bytes of annotation reference PLCF.
1184 
1185     WW8_FC fcPlcfandTxt;    // 0x80 file offset of annotation text PLCF.
1186     sal_Int32 lcbPlcfandTxt;    // 0x84 count of bytes of the annotation text PLCF
1187 
1188     WW8_FC fcPlcfsed;       // 8x88 file offset of section descriptor PLCF.
1189     sal_Int32 lcbPlcfsed;   // 0x8c count of bytes of section descriptor PLCF.
1190 
1191     WW8_FC fcPlcfpad;       // 0x90 file offset of paragraph descriptor PLCF
1192     sal_Int32 lcbPlcfpad;   // 0x94 count of bytes of paragraph descriptor PLCF.
1193                         // ==0 if file was never viewed in Outline view.
1194                         // Should not be written by third party creators
1195 
1196     WW8_FC fcPlcfphe;       // 0x98 file offset of PLCF of paragraph heights.
1197     sal_Int32 lcbPlcfphe;   // 0x9c count of bytes of paragraph height PLCF.
1198                         // ==0 when file is non-complex.
1199 
1200     WW8_FC fcSttbfglsy;     // 0xa0 file offset of glossary string table.
1201     sal_Int32 lcbSttbfglsy; // 0xa4 count of bytes of glossary string table.
1202                         //      == 0 for non-glossary documents.
1203                         //      !=0 for glossary documents.
1204 
1205     WW8_FC fcPlcfglsy;      // 0xa8 file offset of glossary PLCF.
1206     sal_Int32 lcbPlcfglsy;  // 0xac count of bytes of glossary PLCF.
1207                         //      == 0 for non-glossary documents.
1208                         //      !=0 for glossary documents.
1209 
1210     WW8_FC fcPlcfhdd;       // 0xb0 byte offset of header PLCF.
1211     sal_Int32 lcbPlcfhdd;   // 0xb4 count of bytes of header PLCF.
1212                         //      == 0 if document contains no headers
1213 
1214     WW8_FC fcPlcfbteChpx;   // 0xb8 file offset of character property bin table.PLCF.
1215     sal_Int32 lcbPlcfbteChpx;// 0xbc count of bytes of character property bin table PLCF.
1216 
1217     WW8_FC fcPlcfbtePapx;   // 0xc0 file offset of paragraph property bin table.PLCF.
1218     sal_Int32 lcbPlcfbtePapx;// 0xc4 count of bytes of paragraph  property bin table PLCF.
1219 
1220     WW8_FC fcPlcfsea;       // 0xc8 file offset of PLCF reserved for private use. The SEA is 6 bytes long.
1221     sal_Int32 lcbPlcfsea;   // 0xcc count of bytes of private use PLCF.
1222 
1223     WW8_FC fcSttbfffn;      // 0xd0 file offset of font information STTBF. See the FFN file structure definition.
1224     sal_Int32 lcbSttbfffn;  // 0xd4 count of bytes in sttbfffn.
1225 
1226     WW8_FC fcPlcffldMom;    // 0xd8 offset in doc stream to the PLCF of field positions in the main document.
1227     sal_Int32 lcbPlcffldMom;    // 0xdc
1228 
1229     WW8_FC fcPlcffldHdr;    // 0xe0 offset in doc stream to the PLCF of field positions in the header subdocument.
1230     sal_Int32 lcbPlcffldHdr;    // 0xe4
1231 
1232     WW8_FC fcPlcffldFtn;    // 0xe8 offset in doc stream to the PLCF of field positions in the footnote subdocument.
1233     sal_Int32 lcbPlcffldFtn;    // 0xec
1234 
1235     WW8_FC fcPlcffldAtn;    // 0xf0 offset in doc stream to the PLCF of field positions in the annotation subdocument.
1236     sal_Int32 lcbPlcffldAtn;    // 0xf4
1237 
1238     WW8_FC fcPlcffldMcr;    // 0xf8 offset in doc stream to the PLCF of field positions in the macro subdocument.
1239     sal_Int32 lcbPlcffldMcr;    // 9xfc
1240 
1241     WW8_FC fcSttbfbkmk; // 0x100 offset in document stream of the STTBF that records bookmark names in the main document
1242     sal_Int32 lcbSttbfbkmk; // 0x104
1243 
1244     WW8_FC fcPlcfbkf;   // 0x108 offset in document stream of the PLCF that records the beginning CP offsets of bookmarks in the main document. See BKF
1245     sal_Int32 lcbPlcfbkf;   // 0x10c
1246 
1247     WW8_FC fcPlcfbkl;   // 0x110 offset in document stream of the PLCF that records the ending CP offsets of bookmarks recorded in the main document. See the BKL structure definition.
1248     sal_Int32 lcbPlcfbkl;   // 0x114 sal_Int32
1249 
1250     WW8_FC fcCmds;      // 0x118 FC
1251     sal_Int32 lcbCmds;      // 0x11c
1252 
1253     WW8_FC fcPlcfmcr;       // 0x120 FC
1254     sal_Int32 lcbPlcfmcr;       // 0x124
1255 
1256     WW8_FC fcSttbfmcr;  // 0x128 FC
1257     sal_Int32 lcbSttbfmcr;  // 0x12c
1258 
1259     WW8_FC fcPrDrvr;        // 0x130 file offset of the printer driver information (names of drivers, port etc...)
1260     sal_Int32 lcbPrDrvr;        // 0x134 count of bytes of the printer driver information (names of drivers, port etc...)
1261 
1262     WW8_FC fcPrEnvPort; // 0x138 file offset of the print environment in portrait mode.
1263     sal_Int32 lcbPrEnvPort; // 0x13c count of bytes of the print environment in portrait mode.
1264 
1265     WW8_FC fcPrEnvLand; // 0x140 file offset of the print environment in landscape mode.
1266     sal_Int32 lcbPrEnvLand; // 0x144 count of bytes of the print environment in landscape mode.
1267 
1268     WW8_FC fcWss;       // 0x148 file offset of Window Save State data structure. See WSS.
1269     sal_Int32 lcbWss;       // 0x14c count of bytes of WSS. ==0 if unable to store the window state.
1270 
1271     WW8_FC fcDop;       // 0x150 file offset of document property data structure.
1272     sal_uInt32 lcbDop;       // 0x154 count of bytes of document properties.
1273         // cbDOP is 84 when nFib < 103
1274 
1275 
1276     WW8_FC fcSttbfAssoc;    // 0x158 offset to STTBF of associated strings. See STTBFASSOC.
1277     sal_Int32 lcbSttbfAssoc; // 0x15C
1278 
1279     WW8_FC fcClx;           // 0x160 file  offset of beginning of information for complex files.
1280     sal_Int32 lcbClx;       // 0x164 count of bytes of complex file information. 0 if file is non-complex.
1281 
1282     WW8_FC fcPlcfpgdFtn;    // 0x168 file offset of page descriptor PLCF for footnote subdocument.
1283     sal_Int32 lcbPlcfpgdFtn;    // 0x16C count of bytes of page descriptor PLCF for footnote subdocument.
1284                         //  ==0 if document has not been paginated. The length of the PGD is 8 bytes.
1285 
1286     WW8_FC fcAutosaveSource;    // 0x170 file offset of the name of the original file.
1287     sal_Int32 lcbAutosaveSource;    // 0x174 count of bytes of the name of the original file.
1288 
1289     WW8_FC fcGrpStAtnOwners;    // 0x178 group of strings recording the names of the owners of annotations
1290     sal_Int32 lcbGrpStAtnOwners;    // 0x17C count of bytes of the group of strings
1291 
1292     WW8_FC fcSttbfAtnbkmk;  // 0x180 file offset of the sttbf that records names of bookmarks in the annotation subdocument
1293     sal_Int32 lcbSttbfAtnbkmk;  // 0x184 length in bytes of the sttbf that records names of bookmarks in the annotation subdocument
1294 
1295     // Einschubs fuer WW67 ***************************************************
1296 
1297     // sal_Int16 wSpare4Fib;    // Reserve, muss hier nicht deklariert werden
1298 
1299     /*
1300     // folgende Felder existieren zwar so in der Datei,
1301     // wir benutzen jedoch unten deklarierte General-Variablen
1302     // fuer Ver67 und Ver8 gemeinsam.
1303     WW8_PN pnChpFirst;  // the page number of the lowest numbered page in
1304                                                         // the document that records CHPX FKP information
1305     WW8_PN pnPapFirst;  // the page number of the lowest numbered page in
1306                                                         // the document that records PAPX FKP information
1307 
1308     WW8_PN cpnBteChp;       // count of CHPX FKPs recorded in file. In non-complex
1309                                                         // files if the number of entries in the PLCFbteChpx is
1310                                                         // less than this, the PLCFbteChpx  is incomplete.
1311     WW8_PN cpnBtePap;       // count of PAPX FKPs recorded in file. In non-complex
1312                                                         // files if the number of entries in the PLCFbtePapx is
1313                                                         // less than this, the PLCFbtePapx  is incomplete.
1314     */
1315 
1316     // Ende des Einschubs fuer WW67 ******************************************
1317 
1318     WW8_FC fcPlcfdoaMom;    // 0x192 file offset of the  FDOA (drawn object) PLCF for main document.
1319                         //  ==0 if document has no drawn objects. The length of the FDOA is 6 bytes.
1320                         // ab Ver8 unused
1321     sal_Int32 lcbPlcfdoaMom;    // 0x196 length in bytes of the FDOA PLCF of the main document
1322                                                 // ab Ver8 unused
1323     WW8_FC fcPlcfdoaHdr;    // 0x19A file offset of the  FDOA (drawn object) PLCF for the header document.
1324                         //  ==0 if document has no drawn objects. The length of the FDOA is 6 bytes.
1325                         // ab Ver8 unused
1326     sal_Int32 lcbPlcfdoaHdr;    // 0x19E length in bytes of the FDOA PLCF of the header document
1327                                                 // ab Ver8 unused
1328 
1329     WW8_FC fcPlcfspaMom;        // offset in table stream of the FSPA PLCF for main document.
1330                                                 // == 0 if document has no office art objects
1331                                                         // war in Ver67 nur leere Reserve
1332     sal_Int32 lcbPlcfspaMom;        // length in bytes of the FSPA PLCF of the main document
1333                                                         // war in Ver67 nur leere Reserve
1334     WW8_FC fcPlcfspaHdr;        // offset in table stream of the FSPA PLCF for header document.
1335                                                 // == 0 if document has no office art objects
1336                                                         // war in Ver67 nur leere Reserve
1337     sal_Int32 lcbPlcfspaHdr;        // length in bytes of the FSPA PLCF of the header document
1338                                                         // war in Ver67 nur leere Reserve
1339 
1340     WW8_FC fcPlcfAtnbkf;    // 0x1B2 file offset of BKF (bookmark first) PLCF of the annotation subdocument
1341     sal_Int32 lcbPlcfAtnbkf;    // 0x1B6 length in bytes of BKF (bookmark first) PLCF of the annotation subdocument
1342 
1343     WW8_FC fcPlcfAtnbkl;    // 0x1BA file offset of BKL (bookmark last) PLCF of the annotation subdocument
1344     sal_Int32 lcbPlcfAtnbkl;    // 0x1BE length in bytes of BKL (bookmark first) PLCF of the annotation subdocument
1345 
1346     WW8_FC fcPms;       // 0x1C2 file offset of PMS (Print Merge State) information block
1347     sal_Int32 lcbPMS;       // 0x1C6 length in bytes of PMS
1348 
1349     WW8_FC fcFormFldSttbf;  // 0x1CA file offset of form field Sttbf which contains strings used in form field dropdown controls
1350     sal_Int32 lcbFormFldSttbf;  // 0x1CE length in bytes of form field Sttbf
1351 
1352     WW8_FC fcPlcfendRef;    // 0x1D2 file offset of PLCFendRef which points to endnote references in the main document stream
1353     sal_Int32 lcbPlcfendRef;    // 0x1D6
1354 
1355     WW8_FC fcPlcfendTxt;    // 0x1DA file offset of PLCFendRef which points to endnote text  in the endnote document
1356                         //       stream which corresponds with the PLCFendRef
1357     sal_Int32 lcbPlcfendTxt;    // 0x1DE
1358 
1359     WW8_FC fcPlcffldEdn;    // 0x1E2 offset to PLCF of field positions in the endnote subdoc
1360     sal_Int32 lcbPlcffldEdn;    // 0x1E6
1361 
1362     WW8_FC  fcPlcfpgdEdn;   // 0x1EA offset to PLCF of page boundaries in the endnote subdoc.
1363     sal_Int32 lcbPlcfpgdEdn;        // 0x1EE
1364 
1365 
1366     WW8_FC fcDggInfo;           // offset in table stream of the office art object table data.
1367                                                 // The format of office art object table data is found in a separate document.
1368                                                         // war in Ver67 nur leere Reserve
1369     sal_Int32 lcbDggInfo;           // length in bytes of the office art object table data
1370                                                         // war in Ver67 nur leere Reserve
1371 
1372     WW8_FC fcSttbfRMark;        // 0x1fa offset to STTBF that records the author abbreviations...
1373     sal_Int32 lcbSttbfRMark;        // 0x1fe
1374     WW8_FC fcSttbfCaption;  // 0x202 offset to STTBF that records caption titles...
1375     sal_Int32 lcbSttbfCaption;  // 0x206
1376     WW8_FC fcSttbAutoCaption;   // offset in table stream to the STTBF that records the object names and
1377                                                         // indices into the caption STTBF for objects which get auto captions.
1378     sal_Int32 lcbSttbAutoCaption;   // 0x20e
1379 
1380     WW8_FC fcPlcfwkb;       // 0x212 offset to PLCF that describes the boundaries of contributing documents...
1381     sal_Int32 lcbPlcfwkb;       // 0x216
1382 
1383     WW8_FC fcPlcfspl;       // offset in table stream of PLCF (of SPLS structures) that records spell check state
1384                                                         // war in Ver67 nur leere Reserve
1385     sal_Int32 lcbPlcfspl;                   // war in Ver67 nur leere Reserve
1386 
1387     WW8_FC fcPlcftxbxTxt;   // 0x222 ...PLCF of beginning CP in the text box subdoc
1388     sal_Int32 lcbPlcftxbxTxt;   // 0x226
1389     WW8_FC fcPlcffldTxbx;   // 0x22a ...PLCF of field boundaries recorded in the textbox subdoc.
1390     sal_Int32 lcbPlcffldTxbx;   // 0x22e
1391     WW8_FC fcPlcfHdrtxbxTxt;// 0x232 ...PLCF of beginning CP in the header text box subdoc
1392     sal_Int32 lcbPlcfHdrtxbxTxt;// 0x236
1393     WW8_FC fcPlcffldHdrTxbx;// 0x23a ...PLCF of field boundaries recorded in the header textbox subdoc.
1394     sal_Int32 lcbPlcffldHdrTxbx;// 0x23e
1395     WW8_FC fcStwUser;
1396     sal_uInt32 lcbStwUser;
1397     WW8_FC fcSttbttmbd;
1398     sal_uInt32 lcbSttbttmbd;
1399 
1400     WW8_FC fcSttbFnm;       // 0x02da offset in the table stream of masters subdocument names
1401     sal_Int32 lcbSttbFnm;       // 0x02de length
1402 
1403     /*
1404         spezielle Listenverwaltung fuer WW8
1405     */
1406     WW8_FC fcPlcfLst;       // 0x02e2 offset in the table stream of list format information.
1407     sal_Int32 lcbPlcfLst;       // 0x02e6 length
1408     WW8_FC fcPlfLfo;        // 0x02ea offset in the table stream of list format override information.
1409     sal_Int32 lcbPlfLfo;        // 0x02ee length
1410     /*
1411         spezielle Break-Verwaltung fuer Text-Box-Stories in WW8
1412     */
1413     WW8_FC fcPlcftxbxBkd;   // 0x02f2 PLCF fuer TextBox-Break-Deskriptoren im Maintext
1414     sal_Int32 lcbPlcftxbxBkd;   // 0x02f6
1415     WW8_FC fcPlcfHdrtxbxBkd;// 0x02fa PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
1416     sal_Int32 lcbPlcfHdrtxbxBkd;// 0x02fe
1417 
1418     // 0x302 - 372 == ignore
1419     /*
1420         ListNames (skip to here!)
1421     */
1422     WW8_FC fcSttbListNames;// 0x0372 PLCF for Listname Table
1423     sal_Int32 lcbSttbListNames;// 0x0376
1424 
1425     WW8_FC fcPlcfTch;
1426     sal_Int32 lcbPlcfTch;
1427 
1428     // 0x38A - 41A == ignore
1429     WW8_FC fcAtrdExtra;
1430     sal_uInt32 lcbAtrdExtra;
1431 
1432     // 0x422 - 0x4D4 == ignore
1433     WW8_FC fcHplxsdr;    //bizarrely, word xp seems to require this set to shows dates from AtrdExtra
1434     sal_uInt32 lcbHplxsdr;
1435 
1436     /*
1437         General-Varaiblen, die fuer Ver67 und Ver8 verwendet werden,
1438         obwohl sie in der jeweiligen DATEI verschiedene Groesse haben:
1439     */
1440     sal_Int32 pnChpFirst;
1441     sal_Int32 pnPapFirst;
1442     sal_Int32 cpnBteChp;
1443     sal_Int32 cpnBtePap;
1444     /*
1445         The actual nFib, moved here because some readers assumed
1446         they couldn't read any format with nFib > some constant
1447     */
1448     sal_uInt16 nFib_actual; // 0x05bc #i56856#
1449     /*
1450         nun wird lediglich noch ein Ctor benoetigt
1451     */
1452     WW8Fib( SvStream& rStrm, sal_uInt8 nWantedVersion,sal_uInt32 nOffset=0 );
1453 
1454     /* leider falsch, man braucht auch noch einen fuer den Export */
1455     WW8Fib( sal_uInt8 nVersion = 6 );
1456     bool WriteHeader(SvStream& rStrm);
1457     bool Write(SvStream& rStrm);
1458     static rtl_TextEncoding GetFIBCharset(sal_uInt16 chs);
1459     ww::WordVersion GetFIBVersion() const;
1460     WW8_CP GetBaseCp(ManTypes nType) const;
1461 };
1462 
1463 class WW8Style
1464 {
1465 protected:
1466     WW8Fib& rFib;
1467     SvStream& rSt;
1468     long nStyleStart;
1469     long nStyleLen;
1470 
1471     sal_uInt16  cstd;                      // Count of styles in stylesheet
1472     sal_uInt16  cbSTDBaseInFile;           // Length of STD Base as stored in a file
1473     sal_uInt16  fStdStylenamesWritten : 1; // Are built-in stylenames stored?
1474     sal_uInt16  : 15;                      // Spare flags
1475     sal_uInt16  stiMaxWhenSaved;           // Max sti known when file was written
1476     sal_uInt16  istdMaxFixedWhenSaved;     // How many fixed-index istds are there?
1477     sal_uInt16  nVerBuiltInNamesWhenSaved; // Current version of built-in stylenames
1478     // ftc used by StandardChpStsh for this document
1479     sal_uInt16  ftcAsci;
1480     // CJK ftc used by StandardChpStsh for this document
1481     sal_uInt16  ftcFE;
1482     // CTL/Other ftc used by StandardChpStsh for this document
1483     sal_uInt16  ftcOther;
1484     // CTL ftc used by StandardChpStsh for this document
1485     sal_uInt16  ftcBi;
1486 
1487     //No copying
1488     WW8Style(const WW8Style&);
1489     WW8Style& operator=(const WW8Style&);
1490 public:
1491     WW8Style( SvStream& rSt, WW8Fib& rFibPara );
1492     WW8_STD* Read1STDFixed( short& rSkip, short* pcbStd );
1493     WW8_STD* Read1Style( short& rSkip, String* pString, short* pcbStd );
GetCount() const1494     sal_uInt16 GetCount() const { return cstd; }
1495 };
1496 
1497 class WW8Fonts
1498 {
1499 protected:
1500     WW8_FFN* pFontA;    // Array of Pointers to Font Description
1501     sal_uInt16 nMax;        // Array-Size
1502 public:
1503     WW8Fonts( SvStream& rSt, WW8Fib& rFib );
~WW8Fonts()1504     ~WW8Fonts() { delete[] pFontA; }
1505     const WW8_FFN* GetFont( sal_uInt16 nNum ) const;
GetMax() const1506     sal_uInt16 GetMax() const { return nMax; }
1507 };
1508 
1509 typedef sal_uInt8 HdFtFlags;
1510 namespace nsHdFtFlags
1511 {
1512     const HdFtFlags WW8_HEADER_EVEN     = 0x01;
1513     const HdFtFlags WW8_HEADER_ODD      = 0x02;
1514     const HdFtFlags WW8_FOOTER_EVEN     = 0x04;
1515     const HdFtFlags WW8_FOOTER_ODD      = 0x08;
1516     const HdFtFlags WW8_HEADER_FIRST    = 0x10;
1517     const HdFtFlags WW8_FOOTER_FIRST    = 0x20;
1518 }
1519 
1520 /// Document Properties
1521 class WW8Dop
1522 {
1523 public:
1524     /* Error Status */
1525     sal_uLong nDopError;
1526     /*
1527     Corresponds only roughly to the actual structure of the Winword DOP,
1528     the winword FIB version matters to what exists.
1529     */
1530     // Initialisier-Dummy:
1531     sal_uInt8    nDataStart;
1532     //-------------------------
1533     sal_uInt16  fFacingPages : 1;   // 1 when facing pages should be printed
1534     sal_uInt16  fWidowControl : 1;  // 1 when widow control is in effect. 0 when widow control disabled.
1535     sal_uInt16  fPMHMainDoc : 1;    // 1 when doc is a main doc for Print Merge Helper, 0 when not; default=0
1536     sal_uInt16  grfSuppression : 2; // 0 Default line suppression storage; 0= form letter line suppression; 1= no line suppression; default=0
1537     sal_uInt16  fpc : 2;            // 1 footnote position code: 0 as endnotes, 1 at bottom of page, 2 immediately beneath text
1538     sal_uInt16  : 1;                // 0 unused
1539     //-------------------------
1540     sal_uInt16  grpfIhdt : 8;           // 0 specification of document headers and footers. See explanation under Headers and Footers topic.
1541     //-------------------------
1542     sal_uInt16  rncFtn : 2;         // 0 restart index for footnotes, 0 don't restart note numbering, 1 section, 2 page
1543     sal_uInt16  nFtn : 14;          // 1 initial footnote number for document
1544     sal_uInt16  fOutlineDirtySave : 1; // when 1, indicates that information in the hPLCFpad should be refreshed since outline has been dirtied
1545     sal_uInt16  : 7;                //   reserved
1546     sal_uInt16  fOnlyMacPics : 1;   //   when 1, Word believes all pictures recorded in the document were created on a Macintosh
1547     sal_uInt16  fOnlyWinPics : 1;   //   when 1, Word believes all pictures recorded in the document were created in Windows
1548     sal_uInt16  fLabelDoc : 1;      //   when 1, document was created as a print merge labels document
1549     sal_uInt16  fHyphCapitals : 1;  //   when 1, Word is allowed to hyphenate words that are capitalized. When 0, capitalized may not be hyphenated
1550     sal_uInt16  fAutoHyphen : 1;    //   when 1, Word will hyphenate newly typed text as a background task
1551     sal_uInt16  fFormNoFields : 1;
1552     sal_uInt16  fLinkStyles : 1;    //   when 1, Word will merge styles from its template
1553     sal_uInt16  fRevMarking : 1;    //   when 1, Word will mark revisions as the document is edited
1554     sal_uInt16  fBackup : 1;        //   always make backup when document saved when 1.
1555     sal_uInt16  fExactCWords : 1;
1556     sal_uInt16  fPagHidden : 1;     //
1557     sal_uInt16  fPagResults : 1;
1558     sal_uInt16  fLockAtn : 1;       //   when 1, annotations are locked for editing
1559     sal_uInt16  fMirrorMargins : 1; //   swap margins on left/right pages when 1.
1560     sal_uInt16  fReadOnlyRecommended : 1;// user has recommended that this doc be opened read-only when 1
1561     sal_uInt16  fDfltTrueType : 1;  //   when 1, use TrueType fonts by default (flag obeyed only when doc was created by WinWord 2.x)
1562     sal_uInt16  fPagSuppressTopSpacing : 1;//when 1, file created with SUPPRESSTOPSPACING=YES in win.ini. (flag obeyed only when doc was created by WinWord 2.x).
1563     sal_uInt16  fProtEnabled : 1;   //   when 1, document is protected from edit operations
1564     sal_uInt16  fDispFormFldSel : 1;//   when 1, restrict selections to occur only within form fields
1565     sal_uInt16  fRMView : 1;        //   when 1, show revision markings on screen
1566     sal_uInt16  fRMPrint : 1;       //   when 1, print revision marks when document is printed
1567     sal_uInt16  fWriteReservation : 1;
1568     sal_uInt16  fLockRev : 1;       //   when 1, the current revision marking state is locked
1569     sal_uInt16  fEmbedFonts : 1;    //   when 1, document contains embedded True Type fonts
1570     //    compatability options
1571     sal_uInt16 copts_fNoTabForInd : 1;          //    when 1, don�t add automatic tab stops for hanging indent
1572     sal_uInt16 copts_fNoSpaceRaiseLower : 1;        //    when 1, don�t add extra space for raised or lowered characters
1573     sal_uInt16 copts_fSupressSpbfAfterPgBrk : 1;    // when 1, supress the paragraph Space Before and Space After options after a page break
1574     sal_uInt16 copts_fWrapTrailSpaces : 1;      //    when 1, wrap trailing spaces at the end of a line to the next line
1575     sal_uInt16 copts_fMapPrintTextColor : 1;        //    when 1, print colors as black on non-color printers
1576     sal_uInt16 copts_fNoColumnBalance : 1;      //    when 1, don�t balance columns for Continuous Section starts
1577     sal_uInt16 copts_fConvMailMergeEsc : 1;
1578     sal_uInt16 copts_fSupressTopSpacing : 1;        //    when 1, supress extra line spacing at top of page
1579     sal_uInt16 copts_fOrigWordTableRules : 1;   //    when 1, combine table borders like Word 5.x for the Macintosh
1580     sal_uInt16 copts_fTransparentMetafiles : 1; //    when 1, don�t blank area between metafile pictures
1581     sal_uInt16 copts_fShowBreaksInFrames : 1;   //    when 1, show hard page or column breaks in frames
1582     sal_uInt16 copts_fSwapBordersFacingPgs : 1; //    when 1, swap left and right pages on odd facing pages
1583     sal_uInt16 copts_fExpShRtn : 1;             //    when 1, expand character spaces on the line ending SHIFT+RETURN  // #i56856#
1584 
1585     sal_Int16  dxaTab;              // 720 twips    default tab width
1586     sal_uInt16 wSpare;              //
1587     sal_uInt16 dxaHotZ;         //      width of hyphenation hot zone measured in twips
1588     sal_uInt16 cConsecHypLim;       //      number of lines allowed to have consecutive hyphens
1589     sal_uInt16 wSpare2;         //      reserved
1590     sal_Int32   dttmCreated;        // DTTM date and time document was created
1591     sal_Int32   dttmRevised;        // DTTM date and time document was last revised
1592     sal_Int32   dttmLastPrint;      // DTTM date and time document was last printed
1593     sal_Int16   nRevision;          //      number of times document has been revised since its creation
1594     sal_Int32   tmEdited;           //      time document was last edited
1595     sal_Int32   cWords;             //      count of words tallied by last Word Count execution
1596     sal_Int32   cCh;                //      count of characters tallied by last Word Count execution
1597     sal_Int16   cPg;                //      count of pages tallied by last Word Count execution
1598     sal_Int32   cParas;             //      count of paragraphs tallied by last Word Count execution
1599     sal_uInt16 rncEdn : 2;          //      restart endnote number code: 0 don�t restart endnote numbering, 1 section, 2 page
1600     sal_uInt16 nEdn : 14;           //      beginning endnote number
1601     sal_uInt16 epc : 2;         //      endnote position code: 0 at end of section, 3 at end of document
1602     // sal_uInt16 nfcFtnRef : 4;        //      number format code for auto footnotes: 0 Arabic, 1 Upper case Roman, 2 Lower case Roman
1603                                 //      3 Upper case Letter, 4 Lower case Letter
1604                                 // ersetzt durch gleichlautendes Feld unten
1605     // sal_uInt16 nfcEdnRef : 4;        //      number format code for auto endnotes: 0 Arabic, 1 Upper case Roman, 2 Lower case Roman
1606                                 //      3 Upper case Letter, 4 Lower case Letter
1607                                 // ersetzt durch gleichlautendes Feld unten
1608     sal_uInt16 fPrintFormData : 1;  //      only print data inside of form fields
1609     sal_uInt16 fSaveFormData : 1;   //      only save document data that is inside of a form field.
1610     sal_uInt16 fShadeFormData : 1;  //      shade form fields
1611     sal_uInt16 : 2;             //      reserved
1612     sal_uInt16 fWCFtnEdn : 1;       //      when 1, include footnotes and endnotes in word count
1613     sal_Int32   cLines;             //      count of lines tallied by last Word Count operation
1614     sal_Int32   cWordsFtnEnd;       //      count of words in footnotes and endnotes tallied by last Word Count operation
1615     sal_Int32   cChFtnEdn;          //      count of characters in footnotes and endnotes tallied by last Word Count operation
1616     sal_Int16   cPgFtnEdn;          //      count of pages in footnotes and endnotes tallied by last Word Count operation
1617     sal_Int32   cParasFtnEdn;       //      count of paragraphs in footnotes and endnotes tallied by last Word Count operation
1618     sal_Int32   cLinesFtnEdn;       //      count of paragraphs in footnotes and endnotes tallied by last Word Count operation
1619     sal_Int32   lKeyProtDoc;        //      document protection password key, only valid if dop.fProtEnabled, dop.fLockAtn or dop.fLockRev are 1.
1620     sal_uInt16  wvkSaved : 3;       //      document view kind: 0 Normal view, 1 Outline view, 2 Page View
1621     sal_uInt16  wScaleSaved : 9;    //
1622     sal_uInt16  zkSaved : 2;
1623     sal_uInt16  fRotateFontW6 : 1;
1624     sal_uInt16  iGutterPos : 1 ;
1625 
1626     // hier sollte bei nFib < 103   Schluss sein, sonst ist Datei fehlerhaft!
1627 
1628     /*
1629         bei nFib >= 103 gehts weiter:
1630     */
1631     sal_uInt32 fNoTabForInd                             :1; // see above in compatability options
1632     sal_uInt32 fNoSpaceRaiseLower                   :1; // see above
1633     sal_uInt32 fSupressSpbfAfterPageBreak   :1; // see above
1634     sal_uInt32 fWrapTrailSpaces                     :1; // see above
1635     sal_uInt32 fMapPrintTextColor                   :1; // see above
1636     sal_uInt32 fNoColumnBalance                     :1; // see above
1637     sal_uInt32 fConvMailMergeEsc                    :1; // see above
1638     sal_uInt32 fSupressTopSpacing                   :1; // see above
1639     sal_uInt32 fOrigWordTableRules              :1; // see above
1640     sal_uInt32 fTransparentMetafiles            :1; // see above
1641     sal_uInt32 fShowBreaksInFrames              :1; // see above
1642     sal_uInt32 fSwapBordersFacingPgs            :1; // see above
1643     sal_uInt32 fCompatabilityOptions_Unknown1_13    :1; // #i78591#
1644     sal_uInt32 fExpShRtn                :1; // #i78591# and #i56856#
1645     sal_uInt32 fCompatabilityOptions_Unknown1_15    :1; // #i78591#
1646     sal_uInt32 fCompatabilityOptions_Unknown1_16    :1; // #i78591#
1647     sal_uInt32 fSuppressTopSpacingMac5      :1; // Suppress extra line spacing at top
1648                                                                                 // of page like MacWord 5.x
1649     sal_uInt32 fTruncDxaExpand                      :1; // Expand/Condense by whole number of points
1650     sal_uInt32 fPrintBodyBeforeHdr              :1; // Print body text before header/footer
1651     sal_uInt32 fNoLeading                                   :1; // Don't add extra spacebetween rows of text
1652     sal_uInt32 fCompatabilityOptions_Unknown1_21    :1; // #i78591#
1653     sal_uInt32 fMWSmallCaps : 1;    // Use larger small caps like MacWord 5.x
1654     sal_uInt32 fCompatabilityOptions_Unknown1_23    :1; // #i78591#
1655     sal_uInt32 fCompatabilityOptions_Unknown1_24    :1; // #i78591#
1656     sal_uInt32 fCompatabilityOptions_Unknown1_25    :1; // #i78591#
1657     sal_uInt32 fCompatabilityOptions_Unknown1_26    :1; // #i78591#
1658     sal_uInt32 fCompatabilityOptions_Unknown1_27    :1; // #i78591#
1659     sal_uInt32 fCompatabilityOptions_Unknown1_28    :1; // #i78591#
1660     sal_uInt32 fCompatabilityOptions_Unknown1_29    :1; // #i78591#
1661     sal_uInt32 fCompatabilityOptions_Unknown1_30    :1; // #i78591#
1662     sal_uInt32 fCompatabilityOptions_Unknown1_31    :1; // #i78591#
1663     sal_uInt32 fUsePrinterMetrics : 1;  //The magic option
1664 
1665     // hier sollte bei nFib <= 105  Schluss sein, sonst ist Datei fehlerhaft!
1666 
1667     /*
1668         bei nFib > 105 gehts weiter:
1669     */
1670     sal_Int16   adt;                // Autoformat Document Type:
1671                                     // 0 for normal.
1672                                     // 1 for letter, and
1673                                     // 2 for email.
1674     WW8DopTypography doptypography; // see WW8STRUC.HXX
1675     WW8_DOGRID        dogrid;       // see WW8STRUC.HXX
1676     sal_uInt16                      :1; // reserved
1677     sal_uInt16 lvl                  :4; // Which outline levels are showing in outline view
1678     sal_uInt16                      :4; // reserved
1679     sal_uInt16 fHtmlDoc             :1; // This file is based upon an HTML file
1680     sal_uInt16                      :1; // reserved
1681     sal_uInt16 fSnapBorder          :1; // Snap table and page borders to page border
1682     sal_uInt16 fIncludeHeader       :1; // Place header inside page border
1683     sal_uInt16 fIncludeFooter       :1; // Place footer inside page border
1684     sal_uInt16 fForcePageSizePag    :1; // Are we in online view
1685     sal_uInt16 fMinFontSizePag      :1; // Are we auto-promoting fonts to >= hpsZoonFontPag?
1686     sal_uInt16 fHaveVersions            :1; // versioning is turned on
1687     sal_uInt16 fAutoVersion             :1; // autoversioning is enabled
1688     sal_uInt16 : 14;    // reserved
1689     // Skip 12 Bytes here: ASUMI
1690     sal_Int32 cChWS;
1691     sal_Int32 cChWSFtnEdn;
1692     sal_Int32 grfDocEvents;
1693     // Skip 4+30+8 Bytes here
1694     sal_Int32 cDBC;
1695     sal_Int32 cDBCFtnEdn;
1696     // Skip 4 Bytes here
1697     sal_Int16 nfcFtnRef;
1698     sal_Int16 nfcEdnRef;
1699     sal_Int16 hpsZoonFontPag;
1700     sal_Int16 dywDispPag;
1701 
1702     sal_uInt32 fCompatabilityOptions_Unknown2_1 :1; // #i78591#
1703     sal_uInt32 fCompatabilityOptions_Unknown2_2 :1; // #i78591#
1704     sal_uInt32 fDontUseHTMLAutoSpacing:1;
1705     sal_uInt32 fCompatabilityOptions_Unknown2_4 :1; // #i78591#
1706     sal_uInt32 fCompatabilityOptions_Unknown2_5 :1; // #i78591#
1707     sal_uInt32 fCompatabilityOptions_Unknown2_6 :1; // #i78591#
1708     sal_uInt32 fCompatabilityOptions_Unknown2_7 :1; // #i78591#
1709     sal_uInt32 fCompatabilityOptions_Unknown2_8 :1; // #i78591#
1710     sal_uInt32 fCompatabilityOptions_Unknown2_9 :1; // #i78591#
1711     sal_uInt32 fCompatabilityOptions_Unknown2_10    :1; // #i78591#
1712     sal_uInt32 fCompatabilityOptions_Unknown2_11    :1; // #i78591#
1713     sal_uInt32 fCompatabilityOptions_Unknown2_12    :1; // #i78591#
1714     sal_uInt32 fCompatabilityOptions_Unknown2_13    :1; // #i78591#
1715     sal_uInt32 fCompatabilityOptions_Unknown2_14    :1; // #i78591#
1716     sal_uInt32 fCompatabilityOptions_Unknown2_15    :1; // #i78591#
1717     sal_uInt32 fCompatabilityOptions_Unknown2_16    :1; // #i78591#
1718     sal_uInt32 fCompatabilityOptions_Unknown2_17    :1; // #i78591#
1719     sal_uInt32 fCompatabilityOptions_Unknown2_18    :1; // #i78591#
1720     sal_uInt32 fCompatabilityOptions_Unknown2_19    :1; // #i78591#
1721     sal_uInt32 fCompatabilityOptions_Unknown2_20    :1; // #i78591#
1722     sal_uInt32 fCompatabilityOptions_Unknown2_21    :1; // #i78591#
1723     sal_uInt32 fCompatabilityOptions_Unknown2_22    :1; // #i78591#
1724     sal_uInt32 fCompatabilityOptions_Unknown2_23    :1; // #i78591#
1725     sal_uInt32 fCompatabilityOptions_Unknown2_24    :1; // #i78591#
1726     sal_uInt32 fCompatabilityOptions_Unknown2_25    :1; // #i78591#
1727     sal_uInt32 fCompatabilityOptions_Unknown2_26    :1; // #i78591#
1728     sal_uInt32 fCompatabilityOptions_Unknown2_27    :1; // #i78591#
1729     sal_uInt32 fCompatabilityOptions_Unknown2_28    :1; // #i78591#
1730     sal_uInt32 fCompatabilityOptions_Unknown2_29    :1; // #i78591#
1731     sal_uInt32 fCompatabilityOptions_Unknown2_30    :1; // #i78591#
1732     sal_uInt32 fCompatabilityOptions_Unknown2_31    :1; // #i78591#
1733     sal_uInt32 fCompatabilityOptions_Unknown2_32    :1; // #i78591#
1734 
1735     sal_uInt16 fUnknown3:15;
1736     sal_uInt16 fUseBackGroundInAllmodes:1;
1737 
1738     sal_uInt16 fDoNotEmbedSystemFont:1;
1739     sal_uInt16 fWordCompat:1;
1740     sal_uInt16 fLiveRecover:1;
1741     sal_uInt16 fEmbedFactoids:1;
1742     sal_uInt16 fFactoidXML:1;
1743     sal_uInt16 fFactoidAllDone:1;
1744     sal_uInt16 fFolioPrint:1;
1745     sal_uInt16 fReverseFolio:1;
1746     sal_uInt16 iTextLineEnding:3;
1747     sal_uInt16 fHideFcc:1;
1748     sal_uInt16 fAcetateShowMarkup:1;
1749     sal_uInt16 fAcetateShowAtn:1;
1750     sal_uInt16 fAcetateShowInsDel:1;
1751     sal_uInt16 fAcetateShowProps:1;
1752 
1753     // 2. Initialisier-Dummy:
1754     sal_uInt8    nDataEnd;
1755 
1756     bool bUseThaiLineBreakingRules;
1757 
1758     /* Constructor for importing, needs to know the version of word used */
1759     WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize);
1760 
1761     /* Constructs default DOP suitable for exporting */
1762     WW8Dop();
1763     bool Write(SvStream& rStrm, WW8Fib& rFib) const;
1764 public:
1765     sal_uInt32 GetCompatabilityOptions() const;
1766     void SetCompatabilityOptions(sal_uInt32 a32Bit);
1767     // i#78591#
1768     sal_uInt32 GetCompatabilityOptions2() const;
1769     void SetCompatabilityOptions2(sal_uInt32 a32Bit);
1770 };
1771 
1772 class WW8PLCF_HdFt
1773 {
1774 private:
1775     WW8PLCF aPLCF;
1776     long nTextOfs;
1777     short nIdxOffset;
1778 public:
1779     WW8PLCF_HdFt( SvStream* pSt, WW8Fib& rFib, WW8Dop& rDop );
1780     bool GetTextPos(sal_uInt8 grpfIhdt, sal_uInt8 nWhich, WW8_CP& rStart, long& rLen);
1781     bool GetTextPosExact(short nIdx, WW8_CP& rStart, long& rLen);
1782     void UpdateIndex( sal_uInt8 grpfIhdt );
1783 };
1784 
1785 void SwapQuotesInField(String &rFmt);
1786 
1787 Word2CHPX ReadWord2Chpx(SvStream &rSt, sal_Size nOffset, sal_uInt8 nSize);
1788 std::vector<sal_uInt8> ChpxToSprms(const Word2CHPX &rChpx);
1789 
1790 sal_uLong SafeReadString(ByteString &rStr,sal_uInt16 nLen,SvStream &rStrm);
1791 
1792 //MS has a (slightly) inaccurate view of how many twips
1793 //are in the default letter size of a page
1794 const sal_uInt16 lLetterWidth = 12242;
1795 const sal_uInt16 lLetterHeight = 15842;
1796 
1797 #endif
1798 
1799 /* vi:set tabstop=4 shiftwidth=4 expandtab: */
1800