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