LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - ww8scan.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 109 122 89.3 %
Date: 2014-11-03 Functions: 76 85 89.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10