LCOV - code coverage report
Current view: top level - sw/source/filter/ww1 - w1class.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 681 0.0 %
Date: 2012-08-25 Functions: 0 72 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 626 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <string.h>
      31                 :            : #include <rtl/strbuf.hxx>
      32                 :            : #include <rtl/ustring.hxx>
      33                 :            : #include <tools/stream.hxx>
      34                 :            : #include <w1class.hxx>
      35                 :            : 
      36                 :            : 
      37                 :            : #ifdef DUMP
      38                 :            : static const sal_Char* pUnknown = "?";
      39                 :            : #define DUMPNAME(s) s
      40                 :            : #else
      41                 :            : #define DUMPNAME(s) 0
      42                 :            : #endif
      43                 :            : 
      44                 :            : Ww1SingleSprm* Ww1Sprm::aTab[ 256 ];
      45                 :            : Ww1SingleSprm* Ww1Sprm::pSingleSprm = 0;
      46                 :            : 
      47                 :            : 
      48                 :            : 
      49                 :            : /////////////////////////////////////////////////////////////////// Fib
      50                 :          0 : Ww1Fib::Ww1Fib( SvStream& _rStream )
      51                 :          0 :     : rStream(_rStream)
      52                 :            : {
      53                 :          0 :     bOK = 0 == rStream.Seek(0) &&
      54 [ #  # ][ #  # ]:          0 :           rStream.Read( &aFib, sizeof( aFib )) == sizeof( aFib );
      55                 :          0 : }
      56                 :            : 
      57                 :            : ///////////////////////////////////////////////////////////// PlainText
      58                 :            : 
      59                 :          0 : Ww1PlainText::Ww1PlainText(Ww1Fib& rWwFib, sal_uLong nFilePos, sal_uLong nCountBytes)
      60                 :            :     : rFib(rWwFib), ulFilePos(nFilePos), ulCountBytes(nCountBytes),
      61                 :          0 :     ulSeek(0), bOK(true)
      62                 :            : {
      63                 :          0 : }
      64                 :            : 
      65                 :          0 : sal_Unicode Ww1PlainText::operator [] ( sal_uLong ulOffset )
      66                 :            : {
      67                 :            :     OSL_ENSURE( ulOffset<Count(), "Ww1PlainText" );
      68                 :            :     sal_Unicode cRet;
      69                 :            :     sal_Char cRead;
      70 [ #  # ][ #  # ]:          0 :     if( rFib.GetStream().Seek( ulFilePos + ulOffset ) == ulFilePos+ulOffset &&
         [ #  # ][ #  # ]
      71         [ #  # ]:          0 :         rFib.GetStream().Read( &cRead, sizeof( cRead ) ) == sizeof( cRead ) )
      72                 :            :     {
      73         [ #  # ]:          0 :         cRet = rtl::OUString(&cRead, 1, RTL_TEXTENCODING_MS_1252).toChar();
      74                 :            :     }
      75                 :            :     else
      76                 :          0 :         cRet = ' ';
      77                 :          0 :     return cRet;
      78                 :            : }
      79                 :            : 
      80                 :          0 : String Ww1PlainText::GetText( sal_uLong ulOffset, sal_uLong nLen ) const
      81                 :            : {
      82                 :            :     OSL_ENSURE(ulOffset+nLen<Count(), "Ww1PlainText");
      83                 :            : 
      84                 :          0 :     sal_Size nPos = ulFilePos+ulOffset;
      85                 :            : 
      86                 :          0 :     bool bSeekOk = rFib.GetStream().Seek(nPos) == nPos;
      87                 :            :     return bSeekOk ?
      88                 :          0 :         read_uInt8s_ToOUString(rFib.GetStream(), nLen, RTL_TEXTENCODING_MS_1252) :
      89 [ #  # ][ #  # ]:          0 :         rtl::OUString();
      90                 :            : }
      91                 :            : 
      92                 :            : ///////////////////////////////////////////////////////////////// Style
      93                 :          0 : Ww1Style::Ww1Style()
      94                 :          0 :     : pPapx(0), pParent(0), stcBase(0), stcNext(0), bUsed(false)
      95                 :            : {
      96                 :          0 : }
      97                 :            : 
      98                 :          0 : Ww1Style::~Ww1Style()
      99                 :            : {
     100 [ #  # ][ #  # ]:          0 :     delete pPapx;
     101                 :          0 : }
     102                 :            : 
     103                 :          0 : void Ww1Style::SetDefaults(sal_uInt8 stc)
     104                 :            : {
     105         [ #  # ]:          0 :     if( 222 == stc )
     106                 :            :     {
     107                 :          0 :         stcBase = 222;
     108                 :          0 :         stcNext = 222;
     109                 :          0 :         aChpx.hpsSet(20);
     110                 :            :     }
     111                 :          0 : }
     112                 :            : 
     113                 :          0 : sal_uInt16 Ww1Style::ReadName( sal_uInt8*&p, sal_uInt16& rnCountBytes, sal_uInt16 stc )
     114                 :            : {
     115                 :          0 :     sal_uInt8 nCountBytes = SVBT8ToByte(p);
     116                 :          0 :     p++;
     117                 :          0 :     rnCountBytes--;
     118         [ #  # ]:          0 :     if( !nCountBytes ) // default
     119                 :            :     {
     120                 :            :         static const sal_Char* const names[] =
     121                 :            :         {
     122                 :            :             "W1 Null",  //222
     123                 :            :             "W1 Annotation reference",  //223
     124                 :            :             "W1 Annotation text",  //224
     125                 :            :             "W1 Table of contents 8",  //225
     126                 :            :             "W1 Table of contents 7",  //226
     127                 :            :             "W1 Table of contents 6",  //227
     128                 :            :             "W1 Table of contents 5",  //228
     129                 :            :             "W1 Table of contents 4",  //229
     130                 :            :             "W1 Table of contents 3",  //230
     131                 :            :             "W1 Table of contents 2",  //231
     132                 :            :             "W1 Table of contents 1",  //232
     133                 :            :             "W1 Index 7",  //233
     134                 :            :             "W1 Index 6",  //234
     135                 :            :             "W1 Index 5",  //235
     136                 :            :             "W1 Index 4",  //236
     137                 :            :             "W1 Index 3",  //237
     138                 :            :             "W1 Index 2",  //238
     139                 :            :             "W1 Index 1",  //239
     140                 :            :             "W1 Line number",  //240
     141                 :            :             "W1 Index heading",  //241
     142                 :            :             "W1 Footer",  //242
     143                 :            :             "W1 Header",  //243
     144                 :            :             "W1 Footnote reference",  //244
     145                 :            :             "W1 Footnote text",  //245
     146                 :            :             "W1 Heading 9",  //246
     147                 :            :             "W1 Heading 8",  //247
     148                 :            :             "W1 Heading 7",  //248
     149                 :            :             "W1 Heading 6",  //249
     150                 :            :             "W1 Heading 5",  //250
     151                 :            :             "W1 Heading 4",  //251
     152                 :            :             "W1 Heading 3",  //252
     153                 :            :             "W1 Heading 2",  //253
     154                 :            :             "W1 Heading 1",  //254
     155                 :            :             "W1 Normal indent"  //255
     156                 :            :             };//256
     157                 :            : 
     158                 :            :         const sal_Char* pStr;
     159                 :          0 :         size_t nSize(stc);
     160         [ #  # ]:          0 :         if (!nSize)
     161                 :          0 :             pStr = "W1 Normal";
     162         [ #  # ]:          0 :         else if (nSize - 222 >= SAL_N_ELEMENTS(names))
     163                 :          0 :             pStr = "?";
     164                 :            :         else
     165                 :          0 :             pStr = names[nSize-222];
     166         [ #  # ]:          0 :         SetName(String(pStr, RTL_TEXTENCODING_MS_1252));
     167                 :            :     }
     168         [ #  # ]:          0 :     else if( 255 > nCountBytes ) // unused
     169                 :            :     {
     170         [ #  # ]:          0 :         SetName( String( (sal_Char*)p, nCountBytes, RTL_TEXTENCODING_MS_1252 ));
     171                 :          0 :         p += nCountBytes;
     172                 :            :         OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1Style");
     173                 :          0 :         rnCountBytes = rnCountBytes - nCountBytes;
     174                 :            :     }
     175                 :          0 :     return 0;
     176                 :            : }
     177                 :            : 
     178                 :          0 : sal_uInt16 Ww1Style::ReadChpx( sal_uInt8*&p, sal_uInt16& rnCountBytes )
     179                 :            : {
     180                 :          0 :     sal_uInt16 nCountBytes = SVBT8ToByte(p);
     181                 :          0 :     p++;
     182                 :          0 :     rnCountBytes--;
     183 [ #  # ][ #  # ]:          0 :     if (nCountBytes != 255 // unused
     184                 :            :      && nCountBytes != 0) // default
     185                 :            :     {
     186         [ #  # ]:          0 :         if (nCountBytes > sizeof(aChpx))
     187                 :          0 :             nCountBytes = sizeof(aChpx);
     188                 :          0 :         memcpy( &aChpx, p, nCountBytes );
     189                 :          0 :         p += nCountBytes;
     190                 :            :         OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1Style");
     191                 :          0 :         rnCountBytes = rnCountBytes - nCountBytes;
     192                 :            :     }
     193                 :          0 :     return 0;
     194                 :            : }
     195                 :            : 
     196                 :          0 : sal_uInt16 Ww1Style::ReadPapx(sal_uInt8*&p, sal_uInt16& rnCountBytes)
     197                 :            : {
     198                 :          0 :     sal_uInt16 nCountBytes = SVBT8ToByte(p);
     199                 :          0 :     p++;
     200                 :          0 :     rnCountBytes--;
     201         [ #  # ]:          0 :     if (nCountBytes != 255)
     202                 :            :     {
     203         [ #  # ]:          0 :         pPapx = new Ww1SprmPapx(p, nCountBytes);
     204                 :          0 :         p += nCountBytes;
     205                 :            :         OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1Style");
     206                 :          0 :         rnCountBytes = rnCountBytes - nCountBytes;
     207                 :            :     }
     208                 :            :     else
     209         [ #  # ]:          0 :         pPapx = new Ww1SprmPapx(p, 0);
     210                 :          0 :     return 0;
     211                 :            : }
     212                 :            : 
     213                 :          0 : sal_uInt16 Ww1Style::ReadEstcp(sal_uInt8*&p, sal_uInt16& rnCountBytes)
     214                 :            : {
     215                 :          0 :     stcNext = SVBT8ToByte(p);
     216                 :          0 :     p++;
     217                 :          0 :     rnCountBytes--;
     218                 :          0 :     stcBase = SVBT8ToByte(p);
     219                 :          0 :     p++;
     220                 :            :     OSL_ENSURE(rnCountBytes>0, "Ww1Style");
     221                 :          0 :     rnCountBytes--;
     222                 :          0 :     return 0;
     223                 :            : }
     224                 :            : 
     225                 :            : //////////////////////////////////////////////////////////// StyleSheet
     226                 :          0 : Ww1StyleSheet::Ww1StyleSheet(Ww1Fib& _rFib)
     227                 :            :     : cstcStd(0),
     228                 :            :     rFib(_rFib),
     229 [ #  # ][ #  #  :          0 :     bOK(sal_False)
             #  #  #  # ]
     230                 :            : {
     231                 :          0 :     sal_uInt16 cbStshf = rFib.GetFIB().cbStshfGet();
     232                 :            :     OSL_ENSURE(cbStshf>=17, "Ww1StyleSheet");
     233         [ #  # ]:          0 :     for (sal_uInt16 stc=0;stc<Count();stc++)
     234                 :            :     {
     235                 :          0 :         aStyles[stc].SetParent(this);
     236                 :          0 :         aStyles[stc].SetDefaults((sal_uInt8)stc);
     237                 :            :     }
     238                 :          0 :     sal_uInt8* del = NULL;
     239   [ #  #  #  # ]:          0 :     if (rFib.GetStream().Seek(rFib.GetFIB().fcStshfGet())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     240                 :          0 :       == (sal_uLong)rFib.GetFIB().fcStshfGet()
     241                 :          0 :      && (del = new sal_uInt8[cbStshf]) != NULL
     242         [ #  # ]:          0 :      && rFib.GetStream().Read(del, cbStshf) == (sal_uLong)cbStshf)
     243                 :            :         {
     244                 :          0 :         sal_uInt8* p = del;
     245                 :          0 :             cstcStd = SVBT16ToShort(p);
     246                 :          0 :             p += sizeof(SVBT16);
     247                 :          0 :             cbStshf -= sizeof(SVBT16);
     248         [ #  # ]:          0 :             ReadNames(p, cbStshf);
     249                 :          0 :             ReadChpx(p, cbStshf);
     250         [ #  # ]:          0 :             ReadPapx(p, cbStshf);
     251                 :          0 :             ReadEstcp(p, cbStshf);
     252                 :            :             OSL_ENSURE(cbStshf==0, "Ww1StyleSheet");
     253                 :          0 :             bOK = cbStshf == 0;
     254                 :            :         }
     255         [ #  # ]:          0 :     delete [] del;
     256   [ #  #  #  # ]:          0 : }
     257                 :            : 
     258                 :          0 : sal_uInt16 Ww1StyleSheet::ReadNames( sal_uInt8*& p, sal_uInt16& rnCountBytes )
     259                 :            : {
     260                 :          0 :     sal_uInt16 nCountBytes = SVBT16ToShort(p);
     261                 :          0 :     p += sizeof(SVBT16);
     262                 :            :     OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1StyleSheet");
     263                 :          0 :     rnCountBytes = rnCountBytes - nCountBytes;
     264                 :          0 :     nCountBytes = nCountBytes - sizeof(SVBT16);
     265                 :          0 :     sal_uInt16 stcp = 0;
     266         [ #  # ]:          0 :     while (nCountBytes > 0)
     267                 :            :     {
     268                 :          0 :         sal_uInt16 stc = (stcp - cstcStd) & 255;
     269         [ #  # ]:          0 :         aStyles[stc].ReadName(p, nCountBytes, stc);
     270                 :          0 :         stcp++;
     271                 :            :     }
     272                 :            :     OSL_ENSURE(nCountBytes==0, "Ww1StyleSheet");
     273                 :          0 :     return 0;
     274                 :            : }
     275                 :            : 
     276                 :          0 : sal_uInt16 Ww1StyleSheet::ReadChpx(sal_uInt8*& p, sal_uInt16& rnCountBytes)
     277                 :            : {
     278                 :          0 :     sal_uInt16 nCountBytes = SVBT16ToShort(p);
     279                 :          0 :     p += sizeof(SVBT16);
     280                 :            :     OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1StyleSheet");
     281                 :          0 :     rnCountBytes = rnCountBytes - nCountBytes;
     282                 :          0 :     nCountBytes = nCountBytes - sizeof(SVBT16);
     283                 :          0 :     sal_uInt16 stcp = 0;
     284         [ #  # ]:          0 :     while (nCountBytes > 0)
     285                 :            :     {
     286                 :          0 :         sal_uInt16 stc = (stcp - cstcStd) & 255;
     287                 :          0 :         aStyles[stc].ReadChpx(p, nCountBytes);
     288                 :          0 :         stcp++;
     289                 :            :     }
     290                 :            :     OSL_ENSURE(nCountBytes == 0, "Ww1StyleSheet");
     291                 :          0 :     return 0;
     292                 :            : }
     293                 :            : 
     294                 :          0 : sal_uInt16 Ww1StyleSheet::ReadPapx(sal_uInt8*& p, sal_uInt16& rnCountBytes)
     295                 :            : {
     296                 :          0 :     sal_uInt16 nCountBytes = SVBT16ToShort(p);
     297                 :          0 :     p += sizeof(SVBT16);
     298                 :            :     OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1StyleSheet");
     299                 :          0 :     rnCountBytes = rnCountBytes - nCountBytes;
     300                 :          0 :     nCountBytes = nCountBytes - sizeof(SVBT16);
     301                 :          0 :     sal_uInt16 stcp = 0;
     302         [ #  # ]:          0 :     while (nCountBytes > 0)
     303                 :            :     {
     304                 :          0 :         sal_uInt16 stc = (stcp - cstcStd) & 255;
     305         [ #  # ]:          0 :         aStyles[stc].ReadPapx(p, nCountBytes);
     306                 :          0 :         stcp++;
     307                 :            :     }
     308                 :            :     OSL_ENSURE(nCountBytes == 0, "Ww1StyleSheet");
     309                 :          0 :     return 0;
     310                 :            : }
     311                 :            : 
     312                 :          0 : sal_uInt16 Ww1StyleSheet::ReadEstcp(sal_uInt8*& p, sal_uInt16& rnCountBytes)
     313                 :            : {
     314                 :          0 :     sal_uInt16 iMac = SVBT16ToShort(p);
     315                 :          0 :     p += sizeof(SVBT16);
     316                 :            :     OSL_ENSURE(rnCountBytes>=sizeof(SVBT16), "Ww1StyleSheet");
     317                 :          0 :     rnCountBytes -= sizeof(SVBT16);
     318         [ #  # ]:          0 :     for (sal_uInt16 stcp=0;stcp<iMac;stcp++)
     319                 :            :     {
     320                 :          0 :         sal_uInt16 stc = (stcp - cstcStd) & 255;
     321                 :          0 :         aStyles[stc].ReadEstcp(p, rnCountBytes);
     322                 :            :     }
     323                 :            :     OSL_ENSURE(rnCountBytes==0, "Ww1StyleSheet");
     324                 :          0 :     return 0;
     325                 :            : }
     326                 :            : 
     327                 :            : ///////////////////////////////////////////////////////////////// Fonts
     328                 :            : 
     329                 :          0 : Ww1Fonts::Ww1Fonts(Ww1Fib& rInFib, sal_uLong nFieldFlgs)
     330                 :          0 :     : pFontA(0), rFib(rInFib), nFieldFlags(nFieldFlgs), nMax(0), bOK(false)
     331                 :            : {
     332         [ #  # ]:          0 :     if(rFib.GetFIB().cbSttbfffnGet() > 2 ) // ueberhaupt fonts?
     333                 :            :     {
     334                 :            :         SVBT16 nCountBytes;
     335                 :            :         OSL_ENSURE(rFib.GetFIB().cbSttbfffnGet() > sizeof(nCountBytes), "Ww1Fonts");
     336   [ #  #  #  # ]:          0 :         if (rFib.GetStream().Seek(rFib.GetFIB().fcSttbfffnGet())
     337                 :          0 :          == (sal_uLong)rFib.GetFIB().fcSttbfffnGet())
     338 [ #  # ][ #  # ]:          0 :             if (rFib.GetStream().Read(nCountBytes, sizeof(nCountBytes))
     339                 :            :              == sizeof(nCountBytes)) // Laenge steht hier nochmal
     340                 :            :             {
     341                 :            :                 OSL_ENSURE(SVBT16ToShort(nCountBytes)
     342                 :            :                  == rFib.GetFIB().cbSttbfffnGet(), "redundant-size missmatch");
     343                 :            :                  // hoffentlich sind sie immer gleich
     344                 :          0 :                 W1_FFN* pA = (W1_FFN*)new char[rFib.GetFIB().cbSttbfffnGet()
     345         [ #  # ]:          0 :                  - sizeof(nCountBytes)]; // Alloziere Font-Array
     346                 :            :                 //~ Ww1: new-NULL
     347                 :          0 :                 if (rFib.GetStream().Read(pA, rFib.GetFIB().cbSttbfffnGet()
     348         [ #  # ]:          0 :                  - sizeof(nCountBytes)) == (sal_uLong)rFib.GetFIB().cbSttbfffnGet()
     349                 :            :                  - sizeof(nCountBytes)) // lese alle Fonts
     350                 :            :                 {} //nothing
     351                 :            : 
     352                 :          0 :                 long nLeft = rFib.GetFIB().cbSttbfffnGet()
     353                 :          0 :                  - sizeof(nCountBytes); // Zaehle, wieviele Fonts enthalten
     354                 :          0 :                 W1_FFN* p = pA;
     355                 :          0 :                 while (1)
     356                 :            :                 {
     357                 :            :                     sal_uInt16 nNextSiz;
     358                 :          0 :                     nNextSiz = p->cbFfnM1Get() + 1;
     359         [ #  # ]:          0 :                     if(nNextSiz > nLeft)
     360                 :          0 :                         break;
     361                 :          0 :                     nMax++;
     362                 :          0 :                     nLeft -= nNextSiz;
     363         [ #  # ]:          0 :                     if(nLeft < 1)           // naechste Laenge muss gelesen werden koennen
     364                 :          0 :                         break;
     365                 :          0 :                     p = (W1_FFN *)(((char*)p) + nNextSiz);
     366                 :            :                 }
     367         [ #  # ]:          0 :                 if (nMax)
     368                 :            :                 {
     369         [ #  # ]:          0 :                     pFontA = new W1_FFN*[nMax];         // alloziere Index-Array
     370                 :            :                     //~ Ww1: new-NULL
     371                 :          0 :                     pFontA[0] = pA;                     // fuelle Index-Array
     372                 :            :                     sal_uInt16 i;
     373         [ #  # ]:          0 :                     for(i=1, p=pA; i<nMax; i++)
     374                 :            :                     {
     375                 :          0 :                         p = (W1_FFN*)(((char*)p) + p->cbFfnM1Get() + 1);
     376                 :          0 :                         pFontA[i] = p;
     377                 :            :                     }
     378                 :            :                 }
     379                 :            :                 else
     380                 :          0 :                     pFontA = 0; // Keine Eintraege -> kein Array
     381                 :            :             }
     382                 :            :     }
     383                 :          0 :     bOK = sal_True;
     384                 :          0 : }
     385                 :            : 
     386                 :          0 : W1_FFN* Ww1Fonts::GetFFN(sal_uInt16 nNum)
     387                 :            : {
     388                 :          0 :     W1_FFN* pRet = NULL;
     389         [ #  # ]:          0 :     if (pFontA)
     390         [ #  # ]:          0 :         if (nNum < nMax)
     391                 :          0 :             pRet = pFontA[nNum];
     392                 :          0 :     return pRet;
     393                 :            : }
     394                 :            : 
     395                 :            : /////////////////////////////////////////////////////////////////// DOP
     396                 :          0 : Ww1Dop::Ww1Dop(Ww1Fib& _rFib)
     397                 :          0 :     : rFib(_rFib)
     398                 :            : {
     399                 :            :     long nRead;
     400                 :          0 :     memset(&aDop, 0, sizeof(aDop)); // set defaults
     401         [ #  # ]:          0 :     if(rFib.GetFIB().cbDopGet() >= sizeof(aDop))
     402                 :          0 :         nRead = sizeof(aDop);
     403                 :            :     else
     404                 :          0 :         nRead = rFib.GetFIB().cbDopGet();
     405                 :          0 :     bOK = rFib.GetStream().Seek(rFib.GetFIB().fcDopGet()) ==
     406                 :          0 :                 (sal_uLong)rFib.GetFIB().fcDopGet() &&
     407 [ #  # ][ #  # ]:          0 :             rFib.GetStream().Read(&aDop, nRead) == (sal_uLong)nRead;
     408                 :          0 : }
     409                 :            : 
     410                 :            : /////////////////////////////////////////////////////////////// Picture
     411                 :          0 : Ww1Picture::Ww1Picture(SvStream& rStream, sal_uLong ulFilePos)
     412                 :          0 :     : bOK(false), pPic(0)
     413                 :            : {
     414                 :          0 :     ulFilePos &= 0xffffff; //~ ww1: warum auch immer - im highbyte steht eine 5?!?!
     415                 :            :     SVBT32 lcb;
     416 [ #  # ][ #  # ]:          0 :     if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos)
     417 [ #  # ][ #  # ]:          0 :         if (rStream.Read(&lcb, sizeof(lcb)) == (sal_uLong)sizeof(lcb))
     418                 :            :             if (sizeof(int)>=4 || SVBT32ToUInt32(lcb) < 0x8000) //~ mdt: 64K & 16bit
     419 [ #  # ][ #  # ]:          0 :                 if ((pPic = (W1_PIC*)(new sal_uInt8[SVBT32ToUInt32(lcb)])) != NULL)
     420 [ #  # ][ #  # ]:          0 :                     if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos)
     421 [ #  # ][ #  # ]:          0 :                         if (rStream.Read(pPic, SVBT32ToUInt32(lcb)) == (sal_uLong)SVBT32ToUInt32(lcb))
     422                 :            :                         {
     423                 :            :                             OSL_ENSURE(pPic->cbHeaderGet()==sizeof(*pPic)-sizeof(pPic->rgb), "Ww1Picture");
     424                 :          0 :                             bOK = true;
     425                 :            :                         }
     426                 :          0 : }
     427                 :            : 
     428                 :            : ////////////////////////////////////////////////////////////////// Sprm
     429                 :          0 : Ww1Sprm::Ww1Sprm(sal_uInt8* x, sal_uInt16 _nCountBytes)
     430                 :            :     : p(NULL),
     431                 :            :     nCountBytes(_nCountBytes),
     432                 :            :     bOK(sal_False),
     433                 :            :     pArr(NULL),
     434                 :          0 :     count(0)
     435                 :            : {
     436         [ #  # ]:          0 :     if (nCountBytes == 0)
     437                 :          0 :         bOK = sal_True;
     438                 :            :     else
     439         [ #  # ]:          0 :         if ((p = new sal_uInt8[nCountBytes]) != NULL)
     440                 :            :         {
     441                 :          0 :             memcpy(p, x, nCountBytes);
     442         [ #  # ]:          0 :             if (ReCalc())
     443                 :          0 :                 bOK = sal_True;
     444                 :            :         }
     445                 :          0 : }
     446                 :            : 
     447                 :          0 : Ww1Sprm::Ww1Sprm(SvStream& rStream, sal_uLong ulFilePos)
     448                 :            :     : p(NULL),
     449                 :            :     nCountBytes(0),
     450                 :            :     bOK(sal_False),
     451                 :            :     pArr(NULL),
     452                 :          0 :     count(0)
     453                 :            : {
     454                 :            :     SVBT8 x;
     455                 :          0 :     ByteToSVBT8(0, x);
     456 [ #  # ][ #  # ]:          0 :     if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos)
     457 [ #  # ][ #  # ]:          0 :         if (rStream.Read(&x, sizeof(x)) == (sal_uLong)sizeof(x))
     458 [ #  # ][ #  # ]:          0 :             if ((nCountBytes = SVBT8ToByte(x)) == 255
         [ #  # ][ #  # ]
     459                 :          0 :              || !nCountBytes
     460         [ #  # ]:          0 :              || (p = new sal_uInt8[nCountBytes]) != NULL)
     461 [ #  # ][ #  # ]:          0 :                 if (nCountBytes == 255
         [ #  # ][ #  # ]
     462                 :          0 :                  || !nCountBytes
     463         [ #  # ]:          0 :                  || rStream.Read(p, nCountBytes) == (sal_uLong)nCountBytes)
     464 [ #  # ][ #  # ]:          0 :                     if (ReCalc())
     465                 :          0 :                         bOK = sal_True;
     466                 :          0 : }
     467                 :            : 
     468                 :          0 : Ww1Sprm::~Ww1Sprm()
     469                 :            : {
     470                 :          0 :     delete pArr;
     471                 :          0 :     delete p;
     472                 :          0 : }
     473                 :            : 
     474                 :          0 : sal_uInt16 Ww1SingleSprm::Size(sal_uInt8* /*pSprm*/)
     475                 :            : {
     476                 :          0 :     return nCountBytes;
     477                 :            : }
     478                 :            : 
     479                 :          0 : Ww1SingleSprm::~Ww1SingleSprm()
     480                 :            : {
     481         [ #  # ]:          0 : }
     482                 :            : 
     483                 :          0 : sal_uInt16 Ww1SingleSprmTab::Size(sal_uInt8* pSprm) // Doc 24/25, Fastsave-Sprm
     484                 :            : {
     485                 :            :     OSL_ENSURE(nCountBytes==0, "Ww1SingleSprmTab");
     486                 :          0 :     sal_uInt16 nRet = sizeof(SVBT8);
     487                 :          0 :     sal_uInt16 nSize = SVBT8ToByte(pSprm);
     488         [ #  # ]:          0 :     if (nSize != 255)
     489                 :          0 :         nRet = nRet + nSize;
     490                 :            :     else
     491                 :            :     {
     492                 :          0 :         sal_uInt16 nDel = SVBT8ToByte(pSprm+1) * 4;
     493                 :          0 :         sal_uInt16 nIns = SVBT8ToByte(pSprm + 3 + nDel) * 3;
     494                 :          0 :         nRet += nDel + nIns;
     495                 :            :     }
     496                 :            :     OSL_ENSURE(nRet <= 354, "Ww1SingleSprmTab");
     497         [ #  # ]:          0 :     if (nRet > 354)
     498                 :          0 :         nRet = 0;
     499                 :          0 :     return nRet;
     500                 :            : }
     501                 :            : 
     502                 :          0 : sal_uInt16 Ww1SingleSprmByteSized::Size(sal_uInt8* pSprm)
     503                 :            : {
     504                 :            :     sal_uInt16 nRet;
     505                 :          0 :     nRet = SVBT8ToByte(pSprm);
     506                 :          0 :     nRet += sizeof(SVBT8);  // var. l. byte-size
     507                 :          0 :     nRet = nRet + nCountBytes;
     508                 :          0 :     return nRet;
     509                 :            : }
     510                 :            : 
     511                 :          0 : sal_uInt16 Ww1SingleSprmWordSized::Size(sal_uInt8* pSprm)
     512                 :            : {
     513                 :            :     sal_uInt16 nRet;
     514                 :          0 :     nRet = SVBT16ToShort(pSprm);
     515                 :          0 :     nRet += sizeof(SVBT16);  // var. l. word-size
     516                 :          0 :     nRet = nRet + nCountBytes;
     517                 :          0 :     return nRet;
     518                 :            : }
     519                 :            : 
     520                 :            : static sal_uInt8 nLast = 0;
     521                 :            : static sal_uInt8 nCurrent = 0;
     522                 :          0 : sal_uInt16 Ww1Sprm::GetSize(sal_uInt8 nId, sal_uInt8* pSprm)
     523                 :            : {
     524                 :          0 :     sal_uInt16 nL = 0;
     525                 :          0 :     nL = GetTab(nId).Size(pSprm);
     526                 :          0 :     nLast = nCurrent;
     527                 :          0 :     nCurrent = nId;
     528                 :          0 :     return nL;
     529                 :            : }
     530                 :            : 
     531                 :          0 : sal_Bool Ww1Sprm::Fill(sal_uInt16 index, sal_uInt8& nId, sal_uInt16& nL, sal_uInt8*& pSprm)
     532                 :            : {
     533                 :            :     OSL_ENSURE(index < Count(), "Ww1Sprm");
     534                 :          0 :     pSprm = p + pArr[index];
     535                 :          0 :     nId = SVBT8ToByte(pSprm);
     536                 :          0 :     pSprm++;
     537                 :          0 :     nL = GetTab(nId).Size(pSprm);
     538                 :          0 :     return sal_True;
     539                 :            : }
     540                 :            : 
     541                 :          0 : sal_Bool Ww1Sprm::ReCalc()
     542                 :            : {
     543                 :          0 :     sal_Bool bRet = sal_True;
     544                 :          0 :     delete pArr;
     545                 :          0 :     pArr = NULL;
     546                 :          0 :     count = 0;
     547         [ #  # ]:          0 :     if (nCountBytes != 255) // not unused?
     548                 :            :     {
     549                 :          0 :         sal_uInt16 cbsik = nCountBytes;
     550                 :          0 :         sal_uInt8* psik = p;
     551         [ #  # ]:          0 :         while (cbsik > 0)
     552                 :            :         {
     553                 :          0 :             sal_uInt16 iLen = GetSizeBrutto(psik);
     554                 :            :             OSL_ENSURE(iLen<=cbsik, "Ww1Sprm");
     555         [ #  # ]:          0 :             if (iLen > cbsik)
     556                 :          0 :                 cbsik = 0; // ignore the rest: we are wrong...
     557                 :            :             else
     558                 :            :             {
     559                 :          0 :                 psik += iLen;
     560                 :          0 :                 cbsik = cbsik - iLen;
     561                 :          0 :                 count++;
     562                 :            :             }
     563                 :            :         }
     564   [ #  #  #  # ]:          0 :         if (bRet
                 [ #  # ]
     565                 :          0 :          && (pArr = new sal_uInt16[count]) != NULL)
     566                 :            :         {
     567                 :          0 :             cbsik = nCountBytes;
     568                 :          0 :             sal_uInt16 offset = 0;
     569                 :          0 :             sal_uInt16 current = 0;
     570                 :          0 :             psik = p;
     571         [ #  # ]:          0 :             while (current<count)
     572                 :            :             {
     573                 :          0 :                 pArr[current++] = offset;
     574                 :          0 :                 sal_uInt16 iLen = GetSizeBrutto(psik);
     575                 :          0 :                 psik += iLen;
     576         [ #  # ]:          0 :                 if (iLen > cbsik)
     577                 :          0 :                     cbsik = 0;
     578                 :            :                 else
     579                 :          0 :                     cbsik = cbsik - iLen;
     580                 :          0 :                 offset = offset + iLen;
     581                 :            :             }
     582                 :            : 
     583                 :            :         }
     584                 :            :         else
     585                 :          0 :             count = 0;
     586                 :            :     }
     587                 :          0 :     return bRet;
     588                 :            : }
     589                 :            : 
     590                 :          0 : void Ww1Sprm::DeinitTab()
     591                 :            : {
     592         [ #  # ]:          0 :     for (size_t i=0; i < SAL_N_ELEMENTS(aTab); ++i)
     593         [ #  # ]:          0 :         delete aTab[i];
     594                 :          0 :     memset(aTab, 0, SAL_N_ELEMENTS(aTab));
     595         [ #  # ]:          0 :     delete pSingleSprm;
     596                 :          0 : }
     597                 :            : 
     598                 :          0 : void Ww1Sprm::InitTab()
     599                 :            : {
     600                 :          0 :     memset(aTab, 0, SAL_N_ELEMENTS(aTab));
     601                 :          0 :     pSingleSprm = new Ww1SingleSprm( 0, DUMPNAME(pUnknown));
     602                 :            : 
     603         [ #  # ]:          0 :     aTab[  2] = new Ww1SingleSprmByte(DUMPNAME("sprmPStc")); //   2 pap.istd (style code)
     604         [ #  # ]:          0 :     aTab[  3] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPIstdPermute")); //   3 pap.istd    permutation
     605         [ #  # ]:          0 :     aTab[  4] = new Ww1SingleSprmByte(DUMPNAME("sprmPIncLevel")); //   4 pap.istddifference
     606         [ #  # ]:          0 :     aTab[  5] = new Ww1SingleSprmPJc(DUMPNAME("sprmPJc")); //   5 pap.jc (justification)
     607         [ #  # ]:          0 :     aTab[  6] = new Ww1SingleSprmBool(DUMPNAME("sprmPFSideBySide")); //   6 pap.fSideBySide
     608         [ #  # ]:          0 :     aTab[  7] = new Ww1SingleSprmPFKeep(DUMPNAME("sprmPFKeep")); //   7 pap.fKeep
     609         [ #  # ]:          0 :     aTab[  8] = new Ww1SingleSprmPFKeepFollow(DUMPNAME("sprmPFKeepFollow")); //   8 pap.fKeepFollow
     610         [ #  # ]:          0 :     aTab[  9] = new Ww1SingleSprmPPageBreakBefore(DUMPNAME("sprmPPageBreakBefore")); //   9 pap.fPageBreakBefore
     611         [ #  # ]:          0 :     aTab[ 10] = new Ww1SingleSprmByte(DUMPNAME("sprmPBrcl")); //  10 pap.brcl
     612         [ #  # ]:          0 :     aTab[ 11] = new Ww1SingleSprmByte(DUMPNAME("sprmPBrcp")); //  11 pap.brcp
     613         [ #  # ]:          0 :     aTab[ 12] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPAnld")); //  12 pap.anld (ANLD structure)
     614         [ #  # ]:          0 :     aTab[ 13] = new Ww1SingleSprmByte(DUMPNAME("sprmPNLvlAnm")); //  13 pap.nLvlAnm nn
     615         [ #  # ]:          0 :     aTab[ 14] = new Ww1SingleSprmBool(DUMPNAME("sprmPFNoLineNumb")); //  14 ap.fNoLnn
     616         [ #  # ]:          0 :     aTab[ 15] = new Ww1SingleSprmPChgTabsPapx(DUMPNAME("sprmPChgTabsPapx")); //  15 pap.itbdMac, ...
     617         [ #  # ]:          0 :     aTab[ 16] = new Ww1SingleSprmPDxaRight(DUMPNAME("sprmPDxaRight")); //  16 pap.dxaRight
     618         [ #  # ]:          0 :     aTab[ 17] = new Ww1SingleSprmPDxaLeft(DUMPNAME("sprmPDxaLeft")); //  17 pap.dxaLeft
     619         [ #  # ]:          0 :     aTab[ 18] = new Ww1SingleSprmWord(DUMPNAME("sprmPNest")); //  18 pap.dxaNest
     620         [ #  # ]:          0 :     aTab[ 19] = new Ww1SingleSprmPDxaLeft1(DUMPNAME("sprmPDxaLeft1")); //  19 pap.dxaLeft1
     621         [ #  # ]:          0 :     aTab[ 20] = new Ww1SingleSprmPDyaLine(DUMPNAME("sprmPDyaLine")); //  20 pap.lspd    an LSPD
     622         [ #  # ]:          0 :     aTab[ 21] = new Ww1SingleSprmPDyaBefore(DUMPNAME("sprmPDyaBefore")); //  21 pap.dyaBefore
     623         [ #  # ]:          0 :     aTab[ 22] = new Ww1SingleSprmPDyaAfter(DUMPNAME("sprmPDyaAfter")); //  22 pap.dyaAfter
     624         [ #  # ]:          0 :     aTab[ 23] = new Ww1SingleSprmTab(0, DUMPNAME(pUnknown)); // 23 pap.itbdMac, pap.rgdxaTab
     625         [ #  # ]:          0 :     aTab[ 24] = new Ww1SingleSprmPFInTable(DUMPNAME("sprmPFInTable")); //  24 pap.fInTable
     626         [ #  # ]:          0 :     aTab[ 25] = new Ww1SingleSprmPTtp(DUMPNAME("sprmPTtp")); //  25 pap.fTtp
     627         [ #  # ]:          0 :     aTab[ 26] = new Ww1SingleSprmPDxaAbs(DUMPNAME("sprmPDxaAbs")); //  26 pap.dxaAbs
     628         [ #  # ]:          0 :     aTab[ 27] = new Ww1SingleSprmPDyaAbs(DUMPNAME("sprmPDyaAbs")); //  27 pap.dyaAbs
     629         [ #  # ]:          0 :     aTab[ 28] = new Ww1SingleSprmPDxaWidth(DUMPNAME("sprmPDxaWidth")); //  28 pap.dxaWidth
     630         [ #  # ]:          0 :     aTab[ 29] = new Ww1SingleSprmPpc(DUMPNAME("sprmPPc")); //  29 pap.pcHorz, pap.pcVert
     631         [ #  # ]:          0 :     aTab[ 30] = new Ww1SingleSprmPBrc10(BRC_TOP, DUMPNAME("sprmPBrcTop10")); //  30 pap.brcTop BRC10
     632         [ #  # ]:          0 :     aTab[ 31] = new Ww1SingleSprmPBrc10(BRC_LEFT, DUMPNAME("sprmPBrcLeft10")); //  31 pap.brcLeft BRC10
     633         [ #  # ]:          0 :     aTab[ 32] = new Ww1SingleSprmPBrc10(BRC_BOTTOM, DUMPNAME("sprmPBrcBottom10")); //  32 pap.brcBottom BRC10
     634         [ #  # ]:          0 :     aTab[ 33] = new Ww1SingleSprmPBrc10(BRC_RIGHT, DUMPNAME("sprmPBrcRight10")); //  33 pap.brcRight BRC10
     635         [ #  # ]:          0 :     aTab[ 34] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBetween10")); //  34 pap.brcBetween BRC10
     636         [ #  # ]:          0 :     aTab[ 35] = new Ww1SingleSprmPBrc10(BRC_LEFT, DUMPNAME("sprmPBrcBar10")); //  35 pap.brcBar BRC10
     637         [ #  # ]:          0 :     aTab[ 36] = new Ww1SingleSprmPFromText(DUMPNAME("sprmPFromText10")); //  36 pap.dxaFromText dxa
     638         [ #  # ]:          0 :     aTab[ 37] = new Ww1SingleSprmByte(DUMPNAME("sprmPWr")); //  37 pap.wr wr
     639         [ #  # ]:          0 :     aTab[ 38] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcTop")); //  38 pap.brcTop BRC
     640         [ #  # ]:          0 :     aTab[ 39] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcLeft")); //  39 pap.brcLeft BRC
     641         [ #  # ]:          0 :     aTab[ 40] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBottom")); //  40 pap.brcBottom BRC
     642         [ #  # ]:          0 :     aTab[ 41] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcRight")); //  41 pap.brcRight BRC
     643         [ #  # ]:          0 :     aTab[ 42] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBetween")); //  42 pap.brcBetween BRC
     644         [ #  # ]:          0 :     aTab[ 43] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBar")); //  43 pap.brcBar BRC word
     645         [ #  # ]:          0 :     aTab[ 44] = new Ww1SingleSprmBool(DUMPNAME("sprmPFNoAutoHyph")); //  44 pap.fNoAutoHyph
     646         [ #  # ]:          0 :     aTab[ 45] = new Ww1SingleSprmWord(DUMPNAME("sprmPWHeightAbs")); //  45 pap.wHeightAbs w
     647         [ #  # ]:          0 :     aTab[ 46] = new Ww1SingleSprmWord(DUMPNAME("sprmPDcs")); //  46 pap.dcs DCS
     648         [ #  # ]:          0 :     aTab[ 47] = new Ww1SingleSprmWord(DUMPNAME("sprmPShd")); //  47 pap.shd SHD
     649         [ #  # ]:          0 :     aTab[ 48] = new Ww1SingleSprmWord(DUMPNAME("sprmPDyaFromText")); //  48 pap.dyaFromText dya
     650         [ #  # ]:          0 :     aTab[ 49] = new Ww1SingleSprmWord(DUMPNAME("sprmPDxaFromText")); //  49 pap.dxaFromText dxa
     651         [ #  # ]:          0 :     aTab[ 50] = new Ww1SingleSprmBool(DUMPNAME("sprmPFLocked")); //  50 pap.fLocked 0 or 1 byte
     652         [ #  # ]:          0 :     aTab[ 51] = new Ww1SingleSprmBool(DUMPNAME("sprmPFWidowControl")); //  51 pap.fWidowControl 0 or 1 byte
     653                 :            : 
     654         [ #  # ]:          0 :     aTab[ 57] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmCDefault")); //  57 whole CHP (see below) none variable length
     655                 :          0 :     aTab[ 58] = new Ww1SingleSprm(0, DUMPNAME("sprmCPlain")); //  58 whole CHP (see below) none 0
     656                 :            : 
     657         [ #  # ]:          0 :     aTab[ 60] = new Ww1SingleSprm4State(DUMPNAME("sprmCFBold")); //  60 chp.fBold 0,1, 128, or 129 (see below) byte
     658         [ #  # ]:          0 :     aTab[ 61] = new Ww1SingleSprm4State(DUMPNAME("sprmCFItalic")); //  61 chp.fItalic 0,1, 128, or 129 (see below) byte
     659         [ #  # ]:          0 :     aTab[ 62] = new Ww1SingleSprm4State(DUMPNAME("sprmCFStrike")); //  62 chp.fStrike 0,1, 128, or 129 (see below) byte
     660         [ #  # ]:          0 :     aTab[ 63] = new Ww1SingleSprm4State(DUMPNAME("sprmCFOutline")); //  63 chp.fOutline 0,1, 128, or 129 (see below) byte
     661         [ #  # ]:          0 :     aTab[ 64] = new Ww1SingleSprm4State(DUMPNAME("sprmCFShadow")); //  64 chp.fShadow 0,1, 128, or 129 (see below) byte
     662         [ #  # ]:          0 :     aTab[ 65] = new Ww1SingleSprm4State(DUMPNAME("sprmCFSmallCaps")); //  65 chp.fSmallCaps 0,1, 128, or 129 (see below) byte
     663         [ #  # ]:          0 :     aTab[ 66] = new Ww1SingleSprm4State(DUMPNAME("sprmCFCaps")); //  66 chp.fCaps 0,1, 128, or 129 (see below) byte
     664         [ #  # ]:          0 :     aTab[ 67] = new Ww1SingleSprm4State(DUMPNAME("sprmCFVanish")); //  67 chp.fVanish 0,1, 128, or 129 (see below) byte
     665         [ #  # ]:          0 :     aTab[ 68] = new Ww1SingleSprmWord(DUMPNAME("sprmCFtc")); //  68 chp.ftc ftc word
     666         [ #  # ]:          0 :     aTab[ 69] = new Ww1SingleSprmByte(DUMPNAME("sprmCKul")); //  69 chp.kul kul byte
     667                 :          0 :     aTab[ 70] = new Ww1SingleSprm(3, DUMPNAME("sprmCSizePos")); //  70 chp.hps, chp.hpsPos (see below) 3 bytes
     668         [ #  # ]:          0 :     aTab[ 71] = new Ww1SingleSprmWord(DUMPNAME("sprmCDxaSpace")); //  71 chp.dxaSpace dxa word
     669         [ #  # ]:          0 :     aTab[ 72] = new Ww1SingleSprmWord(DUMPNAME("//")); //  72 //
     670         [ #  # ]:          0 :     aTab[ 73] = new Ww1SingleSprmByte(DUMPNAME("sprmCIco")); //  73 chp.ico ico byte
     671         [ #  # ]:          0 :     aTab[ 74] = new Ww1SingleSprmByte(DUMPNAME("sprmCHps")); //  74 chp.hps hps !byte!
     672         [ #  # ]:          0 :     aTab[ 75] = new Ww1SingleSprmByte(DUMPNAME("sprmCHpsInc")); //  75 chp.hps (see below) byte
     673         [ #  # ]:          0 :     aTab[ 76] = new Ww1SingleSprmWord(DUMPNAME("sprmCHpsPos")); //  76 chp.hpsPos hps !word!
     674         [ #  # ]:          0 :     aTab[ 77] = new Ww1SingleSprmByte(DUMPNAME("sprmCHpsPosAdj")); //  77 chp.hpsPos hps (see below) byte
     675         [ #  # ]:          0 :     aTab[ 78] = new Ww1SingleSprmByteSized(0, DUMPNAME(pUnknown)); //  78 ?chp.fBold, chp.fItalic, chp.fSmallCaps, ...
     676                 :            : 
     677         [ #  # ]:          0 :     aTab[ 94] = new Ww1SingleSprmByte(DUMPNAME("sprmPicBrcl")); //  94 pic.brcl brcl (see PIC structure definition) byte
     678         [ #  # ]:          0 :     aTab[ 95] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPicScale")); //  95 pic.mx, pic.my, pic.dxaCropleft,
     679                 :            : 
     680         [ #  # ]:          0 :     aTab[117] = new Ww1SingleSprmByte(DUMPNAME("sprmSBkc")); // 117 sep.bkc bkc byte
     681         [ #  # ]:          0 :     aTab[118] = new Ww1SingleSprmBool(DUMPNAME("sprmSFTitlePage")); // 118 sep.fTitlePage 0 or 1 byte
     682         [ #  # ]:          0 :     aTab[119] = new Ww1SingleSprmSColumns(DUMPNAME("sprmSCcolumns")); // 119 sep.ccolM1 # of cols - 1 word
     683         [ #  # ]:          0 :     aTab[120] = new Ww1SingleSprmWord(DUMPNAME("sprmSDxaColumns")); // 120 sep.dxaColumns dxa word
     684                 :            : 
     685         [ #  # ]:          0 :     aTab[122] = new Ww1SingleSprmByte(DUMPNAME("sprmSNfcPgn")); // 122 sep.nfcPgn nfc byte
     686                 :            : 
     687         [ #  # ]:          0 :     aTab[125] = new Ww1SingleSprmBool(DUMPNAME("sprmSFPgnRestart")); // 125 sep.fPgnRestart 0 or 1 byte
     688         [ #  # ]:          0 :     aTab[126] = new Ww1SingleSprmBool(DUMPNAME("sprmSFEndnote")); // 126 sep.fEndnote 0 or 1 byte
     689         [ #  # ]:          0 :     aTab[127] = new Ww1SingleSprmByte(DUMPNAME("sprmSLnc")); // 127 sep.lnc lnc byte
     690         [ #  # ]:          0 :     aTab[128] = new Ww1SingleSprmSGprfIhdt(DUMPNAME("sprmSGprfIhdt")); // 128 sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
     691         [ #  # ]:          0 :     aTab[129] = new Ww1SingleSprmWord(DUMPNAME("sprmSNLnnMod")); // 129 sep.nLnnMod non-neg int. word
     692         [ #  # ]:          0 :     aTab[130] = new Ww1SingleSprmWord(DUMPNAME("sprmSDxaLnn")); // 130 sep.dxaLnn dxa word
     693         [ #  # ]:          0 :     aTab[131] = new Ww1SingleSprmWord(DUMPNAME("sprmSDyaHdrTop")); // 131 sep.dyaHdrTop dya word
     694         [ #  # ]:          0 :     aTab[132] = new Ww1SingleSprmWord(DUMPNAME("sprmSDyaHdrBottom")); // 132 sep.dyaHdrBottom dya word
     695         [ #  # ]:          0 :     aTab[133] = new Ww1SingleSprmBool(DUMPNAME("sprmSLBetween")); // 133 sep.fLBetween 0 or 1 byte
     696         [ #  # ]:          0 :     aTab[134] = new Ww1SingleSprmByte(DUMPNAME("sprmSVjc")); // 134 sep.vjc vjc byte
     697         [ #  # ]:          0 :     aTab[135] = new Ww1SingleSprmWord(DUMPNAME("sprmSLnnMin")); // 135 sep.lnnMin lnn word
     698         [ #  # ]:          0 :     aTab[136] = new Ww1SingleSprmWord(DUMPNAME("sprmSPgnStart")); // 136 sep.pgnStart pgn word
     699                 :            : 
     700         [ #  # ]:          0 :     aTab[146] = new Ww1SingleSprmWord(DUMPNAME("sprmTJc")); // 146 tap.jc jc word (low order byte is significant)
     701         [ #  # ]:          0 :     aTab[147] = new Ww1SingleSprmWord(DUMPNAME("sprmTDxaLeft")); // 147 tap.rgdxaCenter (see below) dxa word
     702         [ #  # ]:          0 :     aTab[148] = new Ww1SingleSprmWord(DUMPNAME("sprmTDxaGapHalf")); // 148 tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
     703                 :            : 
     704         [ #  # ]:          0 :     aTab[152] = new Ww1SingleSprmTDefTable10(DUMPNAME("sprmTDefTable10")); // 152 tap.rgdxaCenter, tap.rgtc complex (see below) variable length
     705         [ #  # ]:          0 :     aTab[153] = new Ww1SingleSprmWord(DUMPNAME("sprmTDyaRowHeight")); // 153 tap.dyaRowHeight dya word
     706                 :            : 
     707                 :          0 :     aTab[158] = new Ww1SingleSprm(4, DUMPNAME("sprmTInsert")); // 158 tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
     708         [ #  # ]:          0 :     aTab[159] = new Ww1SingleSprmWord(DUMPNAME("sprmTDelete")); // 159 tap.rgdxaCenter, tap.rgtc complex (see below) word
     709                 :          0 :     aTab[160] = new Ww1SingleSprm(4, DUMPNAME("sprmTDxaCol")); // 160 tap.rgdxaCenter complex (see below) 4 bytes
     710         [ #  # ]:          0 :     aTab[161] = new Ww1SingleSprmWord(DUMPNAME("sprmTMerge")); // 161 tap.fFirstMerged, tap.fMerged complex (see below) word
     711         [ #  # ]:          0 :     aTab[162] = new Ww1SingleSprmWord(DUMPNAME("sprmTSplit")); // 162 tap.fFirstMerged, tap.fMerged complex (see below) word
     712                 :          0 :     aTab[163] = new Ww1SingleSprm(5, DUMPNAME("sprmTSetBrc10")); // 163 tap.rgtc[].rgbrc complex (see below) 5 bytes
     713                 :          0 : }
     714                 :            : 
     715                 :            : ////////////////////////////////////////////////////////////// SprmPapx
     716                 :          0 : Ww1SprmPapx::Ww1SprmPapx(sal_uInt8* pByte, sal_uInt16 nSize) :
     717                 :          0 :     Ww1Sprm(Sprm(pByte, nSize), SprmSize(pByte, nSize))
     718                 :            : {
     719                 :          0 :     memset(&aPapx, 0, sizeof(aPapx));
     720         [ #  # ]:          0 :     memcpy(&aPapx, pByte, nSize<sizeof(aPapx)?nSize:sizeof(aPapx));
     721                 :          0 : }
     722                 :            : 
     723                 :          0 : sal_uInt16 Ww1SprmPapx::SprmSize(sal_uInt8*, sal_uInt16 nSize)
     724                 :            : {
     725                 :          0 :     sal_uInt16 nRet = 0;
     726         [ #  # ]:          0 :     if (nSize >= sizeof(W1_PAPX))
     727                 :          0 :         nRet = nSize - ( sizeof(W1_PAPX) - 1 ); // im W1_PAPX ist das
     728                 :            :                                                 // 1. SprmByte enthalten
     729                 :          0 :     return nRet;
     730                 :            : }
     731                 :            : 
     732                 :          0 : sal_uInt8* Ww1SprmPapx::Sprm(sal_uInt8* pByte, sal_uInt16 nSize)
     733                 :            : {
     734                 :          0 :     sal_uInt8* pRet = NULL;
     735         [ #  # ]:          0 :     if (nSize >= sizeof(W1_PAPX))
     736                 :          0 :         pRet = ((W1_PAPX*)(pByte))->grpprlGet();
     737                 :          0 :     return pRet;
     738                 :            : }
     739                 :            : 
     740                 :            : /////////////////////////////////////////////////////////////////// Plc
     741                 :          0 : Ww1Plc::Ww1Plc(Ww1Fib& rInFib, sal_uLong ulFilePos, sal_uInt16 nInCountBytes,
     742                 :            :     sal_uInt16 nInItemSize)
     743                 :            :     : p(0), nCountBytes(nInCountBytes), iMac(0), nItemSize(nInItemSize),
     744                 :          0 :     bOK(false), rFib(rInFib)
     745                 :            : {
     746         [ #  # ]:          0 :     if (!nCountBytes)
     747                 :          0 :         bOK = true;
     748                 :            :     else
     749                 :            :     {
     750         [ #  # ]:          0 :         if (rFib.GetStream().Seek(ulFilePos) == (sal_uLong)ulFilePos)
     751                 :            :         {
     752         [ #  # ]:          0 :             if ((p = new sal_uInt8[nCountBytes]) != NULL)
     753                 :            :             {
     754         [ #  # ]:          0 :                 if (rFib.GetStream().Read(p, nCountBytes) == (sal_uLong)nCountBytes)
     755                 :            :                 {
     756                 :          0 :                     bOK = true;
     757                 :            :                     iMac = (nCountBytes -
     758                 :          0 :                         sizeof(SVBT32)) / (sizeof(SVBT32) + nItemSize);
     759                 :            :                     OSL_ENSURE(iMac * ((sal_uInt16)sizeof(sal_uLong) + nItemSize) +
     760                 :            :                      (sal_uInt16)sizeof(SVBT32) == nCountBytes, "Ww1Plc");
     761                 :            :                 }
     762                 :            :             }
     763                 :            :         }
     764                 :            :     }
     765                 :          0 : }
     766                 :            : 
     767                 :          0 : Ww1Plc::~Ww1Plc()
     768                 :            : {
     769                 :          0 :     delete p;
     770                 :          0 : }
     771                 :            : 
     772                 :          0 : void Ww1Plc::Seek(sal_uLong ulSeek, sal_uInt16& nIndex)
     773                 :            : {
     774         [ #  # ]:          0 :     if (iMac)
     775 [ #  # ][ #  # ]:          0 :         for (;nIndex <= iMac && Where(nIndex) < ulSeek;nIndex++)
                 [ #  # ]
     776                 :            :             ;
     777                 :          0 : }
     778                 :            : 
     779                 :          0 : sal_uLong Ww1Plc::Where(sal_uInt16 nIndex)
     780                 :            : {
     781                 :          0 :     sal_uLong ulRet = 0xffffffff;
     782                 :            :     OSL_ENSURE(nIndex <= iMac, "index out of bounds");
     783 [ #  # ][ #  # ]:          0 :     if (iMac && nIndex <= iMac)
     784                 :          0 :         ulRet = SVBT32ToUInt32(p + sizeof(SVBT32) * nIndex);
     785                 :          0 :     return ulRet;
     786                 :            : }
     787                 :            : 
     788                 :          0 : sal_uInt8* Ww1Plc::GetData(sal_uInt16 nIndex)
     789                 :            : {
     790                 :          0 :     sal_uInt8* pRet = NULL;
     791                 :            :     OSL_ENSURE(nIndex < iMac, "index out of bounds");
     792         [ #  # ]:          0 :     if (nIndex < iMac)
     793                 :            :         pRet = p + (iMac + 1) * sizeof(SVBT32) +
     794                 :          0 :          nIndex * nItemSize; // Pointer auf Inhalts-Array
     795                 :          0 :     return pRet;
     796                 :            : }
     797                 :            : 
     798                 :            : ///////////////////////////////////////////////////////////// PlcBookmarks
     799                 :            : // class Ww1StringList liest im Ctor eine Anzahl von P-Strings aus dem Stream
     800                 :            : // in den Speicher und patcht sie zu C-Strings um.
     801                 :            : // Die Anzahl wird in nMax zurueckgeliefert.
     802                 :            : // im Index 0 stehen alle Strings nacheinander, ab Index 1 werden
     803                 :            : // die einzelnen Strings referenziert.
     804                 :          0 : Ww1StringList::Ww1StringList( SvStream& rSt, sal_uLong nFc, sal_uInt16 nCb )
     805                 :          0 :     : pIdxA(0), nMax(0)
     806                 :            : {
     807         [ #  # ]:          0 :     if( nCb > 2 )            // ueberhaupt Eintraege ?
     808                 :            :     {
     809                 :            :         SVBT16 nCountBytes;
     810                 :            :         OSL_ENSURE(nCb > sizeof(nCountBytes), "Ww1StringList");
     811 [ #  # ][ #  # ]:          0 :         if (rSt.Seek(nFc) == (sal_uLong)nFc)
     812 [ #  # ][ #  # ]:          0 :             if (rSt.Read(nCountBytes, sizeof(nCountBytes))
     813                 :            :                      == sizeof(nCountBytes)) // Laenge steht hier nochmal
     814                 :            :             {
     815                 :            :                 OSL_ENSURE(SVBT16ToShort(nCountBytes)
     816                 :            :                          == nCb, "redundant-size missmatch");
     817                 :            :                                     // hoffentlich sind sie immer gleich
     818         [ #  # ]:          0 :                 sal_Char* pA = new sal_Char[nCb - sizeof(nCountBytes) + 1];
     819                 :            :                                     // Alloziere PString-Array
     820                 :            :                 //~ Ww1: new-NULL
     821         [ #  # ]:          0 :                 if (rSt.Read(pA, nCb - sizeof(nCountBytes))
     822                 :            :                         == (sal_uLong)nCb - sizeof(nCountBytes))    // lese alle
     823                 :            :                 {}// do nothing
     824                 :            :                                     // Zaehle, wieviele Fonts enthalten
     825                 :          0 :                 long nLeft = nCb - sizeof(nCountBytes);
     826                 :          0 :                 sal_Char* p = pA;
     827                 :          0 :                 while (1)
     828                 :            :                 {
     829                 :            :                     sal_uInt16 nNextSiz;
     830                 :          0 :                     nNextSiz = *p + 1;
     831         [ #  # ]:          0 :                     if(nNextSiz > nLeft)
     832                 :          0 :                         break;
     833                 :          0 :                     nMax++;
     834                 :          0 :                     nLeft -= nNextSiz;
     835         [ #  # ]:          0 :                     if(nLeft < 1)           // naechste Laenge muss gelesen werden koennen
     836                 :          0 :                         break;
     837                 :          0 :                     p = p + nNextSiz;
     838                 :            :                 }
     839         [ #  # ]:          0 :                 if (nMax)
     840                 :            :                 {
     841         [ #  # ]:          0 :                     pIdxA = new sal_Char*[nMax+1];      // alloziere Index-Array
     842                 :          0 :                     pIdxA[0] = pA;                      // Index 0 : alles
     843                 :            :                                                         // ab Index 1 C-Strings
     844                 :          0 :                     pIdxA[1] = pA + 1;                  // fuelle Index-Array
     845                 :          0 :                     sal_uInt16 i = 2;
     846                 :          0 :                     p = pA;
     847                 :          0 :                     sal_uInt8 nL = *p;
     848                 :          0 :                     while(1)
     849                 :            :                     {
     850                 :          0 :                         p += nL + 1;                    // Neues Laengen-Byte
     851                 :          0 :                         nL = *p;                        // merke Laenge
     852                 :          0 :                         *p = '\0';                      // mach C-String draus
     853         [ #  # ]:          0 :                         if( i > nMax )
     854                 :          0 :                             break;
     855                 :          0 :                         pIdxA[i] = p + 1;               // Ptr auf C-String
     856                 :          0 :                         i++;
     857                 :            :                     }
     858                 :            :                 }
     859                 :            :                 else
     860                 :          0 :                     pIdxA = 0;  // Keine Eintraege -> kein Array
     861                 :            :             }
     862                 :            :     }
     863                 :          0 : }
     864                 :          0 : const String Ww1StringList::GetStr( sal_uInt16 nNum ) const
     865                 :            : {
     866                 :          0 :     String sRet;
     867         [ #  # ]:          0 :     if( nNum <= nMax )
     868 [ #  # ][ #  # ]:          0 :         sRet = String( pIdxA[ nNum+1 ], RTL_TEXTENCODING_MS_1252 );
                 [ #  # ]
     869                 :          0 :     return sRet;
     870                 :            : }
     871                 :            : 
     872                 :          0 : Ww1Bookmarks::Ww1Bookmarks(Ww1Fib& rInFib)
     873                 :          0 :     : aNames(rInFib), rFib(rInFib), nIsEnd(0)
     874                 :            : {
     875                 :          0 :     pPos[0] = new Ww1PlcBookmarkPos(rFib, rFib.GetFIB().fcPlcfbkfGet(),
     876 [ #  # ][ #  # ]:          0 :                                     rFib.GetFIB().cbPlcfbkfGet(), sal_False);
     877                 :          0 :     nPlcIdx[0] = 0;
     878                 :          0 :     pPos[1] = new Ww1PlcBookmarkPos(rFib, rFib.GetFIB().fcPlcfbklGet(),
     879 [ #  # ][ #  # ]:          0 :                                     rFib.GetFIB().cbPlcfbklGet(), sal_True);
     880                 :          0 :     nPlcIdx[1] = 0;
     881 [ #  # ][ #  # ]:          0 :     bOK = !aNames.GetError() && !pPos[0]->GetError() && !pPos[1]->GetError();
                 [ #  # ]
     882                 :          0 : }
     883                 :            : 
     884                 :            : // Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
     885                 :            : // sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
     886                 :            : // Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
     887                 :            : // erst der Anfang und dann das Ende gefunden werden.
     888                 :            : // Der Fall: ][
     889                 :            : //            [...]
     890                 :            : //           ][
     891                 :            : // ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
     892                 :            : // vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
     893                 :            : // oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
     894                 :            : // noetig wird.
     895                 :          0 : void Ww1Bookmarks::operator ++( int )
     896                 :            : {
     897         [ #  # ]:          0 :     if( bOK )
     898                 :            :     {
     899                 :          0 :         nPlcIdx[nIsEnd]++;
     900                 :            : 
     901                 :          0 :         sal_uLong l0 = pPos[0]->Where(nPlcIdx[0]);
     902                 :          0 :         sal_uLong l1 = pPos[1]->Where(nPlcIdx[1]);
     903         [ #  # ]:          0 :         if( l0 < l1 )
     904                 :          0 :             nIsEnd = 0;
     905         [ #  # ]:          0 :         else if( l1 < l0 )
     906                 :          0 :             nIsEnd = 1;
     907                 :            :         else
     908                 :          0 :             nIsEnd = ( nIsEnd ) ? 0 : 1;
     909                 :            :     }
     910                 :          0 : }
     911                 :            : 
     912                 :          0 : long Ww1Bookmarks::GetHandle() const
     913                 :            : {
     914         [ #  # ]:          0 :     if( bOK )
     915                 :            :     {
     916         [ #  # ]:          0 :         if( nIsEnd )
     917                 :          0 :             return nPlcIdx[1];
     918                 :            : 
     919                 :          0 :         const sal_uInt8* p = pPos[0]->GetData( nPlcIdx[0] );
     920         [ #  # ]:          0 :         if( p )
     921                 :          0 :             return SVBT16ToShort( p );
     922                 :            :     }
     923                 :          0 :     return LONG_MAX;
     924                 :            : }
     925                 :            : 
     926                 :          0 : long Ww1Bookmarks::Len() const
     927                 :            : {
     928         [ #  # ]:          0 :     if( nIsEnd )
     929                 :            :     {
     930                 :            :         OSL_ENSURE( sal_False, "Falscher Aufruf (1) von Ww1Bookmarks::Len()" );
     931                 :          0 :         return 0;
     932                 :            :     }
     933                 :          0 :     sal_uInt16 nEndIdx = SVBT16ToShort(pPos[0]->GetData(nPlcIdx[0]));
     934                 :          0 :     return pPos[1]->Where(nEndIdx) - pPos[0]->Where(nPlcIdx[0]);
     935                 :            : }
     936                 :            : 
     937                 :          0 : const String Ww1Bookmarks::GetName() const
     938                 :            : {
     939         [ #  # ]:          0 :     if( nIsEnd )
     940         [ #  # ]:          0 :         return rtl::OUString("???");
     941                 :          0 :     return aNames.GetStr( nPlcIdx[0] );
     942                 :            : }
     943                 :            : 
     944                 :            : /////////////////////////////////////////////////////////////////// Fkp
     945                 :          0 : Ww1Fkp::Ww1Fkp(SvStream& rStream, sal_uLong ulFilePos, sal_uInt16 _nItemSize) :
     946                 :            :     nItemSize(_nItemSize),
     947                 :          0 :     bOK(sal_False)
     948                 :            : {
     949         [ #  # ]:          0 :     if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos)
     950         [ #  # ]:          0 :         if (rStream.Read(aFkp, sizeof(aFkp)) == sizeof(aFkp))
     951                 :          0 :             bOK = sal_True;
     952                 :          0 : }
     953                 :            : 
     954                 :          0 : sal_uLong Ww1Fkp::Where(sal_uInt16 nIndex)
     955                 :            : {
     956                 :          0 :     sal_uLong lRet = 0xffffffff;
     957                 :            :     OSL_ENSURE(nIndex<=Count(), "index out of bounds");
     958         [ #  # ]:          0 :     if (nIndex<=Count())
     959                 :          0 :         lRet = SVBT32ToUInt32(aFkp+nIndex*sizeof(SVBT32));
     960                 :          0 :     return lRet;
     961                 :            : }
     962                 :            : 
     963                 :          0 : sal_uInt8* Ww1Fkp::GetData(sal_uInt16 nIndex)
     964                 :            : {
     965                 :          0 :     sal_uInt8* pRet = NULL;
     966                 :            :     OSL_ENSURE(nIndex<=Count(), "index out of bounds");
     967         [ #  # ]:          0 :     if (nIndex<=Count())
     968                 :          0 :         pRet = aFkp + (Count()+1) * sizeof(SVBT32) +
     969                 :          0 :          nIndex * nItemSize; // beginn der strukturen
     970                 :          0 :     return pRet;
     971                 :            : }
     972                 :            : 
     973                 :            : //////////////////////////////////////////////////////////////// FkpPap
     974                 :          0 : sal_Bool Ww1FkpPap::Fill(sal_uInt16 nIndex, sal_uInt8*& p, sal_uInt16& rnCountBytes)
     975                 :            : {
     976                 :            :     OSL_ENSURE( nIndex < Count(), "Ww1FkpPap::Fill() Index out of Range" );
     977                 :          0 :     sal_uInt16 nOffset = SVBT8ToByte(GetData(nIndex)) * 2;
     978         [ #  # ]:          0 :     if (nOffset)
     979                 :            :     {
     980                 :            :         OSL_ENSURE(nOffset>(sal_uInt16)(Count()*sizeof(SVBT32)), "calc error");
     981                 :          0 :         rnCountBytes = SVBT8ToByte(aFkp+nOffset) * 2;
     982                 :          0 :         nOffset += sizeof(SVBT8);
     983         [ #  # ]:          0 :         if( nOffset + rnCountBytes < 511 )  // SH: Assert schlug 1 zu frueh zu
     984                 :          0 :             rnCountBytes++;                 // SH: Ich weiss nicht genau,
     985                 :            :                                             // ob das letzte Byte des PAPX
     986                 :            :                                             // genutzt wird, aber so vergessen
     987                 :            :                                             // wir keins und sind trotzdem
     988                 :            :                                             // auf der sicheren Seite
     989                 :            :         OSL_ENSURE(nOffset+rnCountBytes <= 511, "calc error");
     990                 :          0 :         p = aFkp + nOffset;
     991                 :            :     }
     992                 :            :     else
     993                 :            :     {
     994                 :          0 :         p = NULL;
     995                 :          0 :         rnCountBytes = 0;
     996                 :            :     }
     997                 :          0 :     return sal_True;
     998                 :            : }
     999                 :            : 
    1000                 :            : //////////////////////////////////////////////////////////////// FkpChp
    1001                 :          0 : sal_Bool Ww1FkpChp::Fill(sal_uInt16 nIndex, W1_CHP& aChp)
    1002                 :            : {
    1003                 :            :     OSL_ENSURE( nIndex < Count(), "Ww1FkpChp::Fill() Index out of Range" );
    1004                 :          0 :     memset(&aChp, 0, sizeof(aChp)); // Default, da verkuerzt gespeichert
    1005                 :          0 :     sal_uInt16 nOffset = GetData(nIndex)[0] * 2;
    1006         [ #  # ]:          0 :     if (nOffset)
    1007                 :            :     {
    1008                 :            :         OSL_ENSURE(nOffset>(sal_uInt16)(Count()*sizeof(SVBT32)), "calc error");
    1009                 :          0 :         sal_uInt16 nCountBytes = aFkp[nOffset];
    1010                 :          0 :         nOffset += sizeof(SVBT8);
    1011                 :            :         OSL_ENSURE(nCountBytes <= 511-nOffset, "calc error");
    1012                 :            :         OSL_ENSURE(nCountBytes <= sizeof(aChp), "calc error");
    1013                 :          0 :         memcpy(&aChp, aFkp+nOffset, nCountBytes);
    1014                 :            :     }
    1015                 :          0 :     return sal_True;
    1016                 :            : }
    1017                 :            : 
    1018                 :            : ///////////////////////////////////////////////////////////////// Assoc
    1019                 :          0 : Ww1Assoc::Ww1Assoc(Ww1Fib& _rFib)
    1020                 :          0 :     : rFib(_rFib), pBuffer(NULL), bOK(sal_False)
    1021                 :            : {
    1022                 :          0 :     sal_uInt16 cb = rFib.GetFIB().cbSttbfAssocGet();
    1023                 :            :     sal_uInt16 i;
    1024                 :            : 
    1025         [ #  # ]:          0 :     for ( i = 0; i < MaxFields; i++ )
    1026                 :          0 :         pStrTbl[i] = NULL;
    1027   [ #  #  #  #  :          0 :     if ((pBuffer = new sal_Char[cb]) != NULL
           #  # ][ #  # ]
    1028                 :          0 :      && rFib.GetStream().Seek(rFib.GetFIB().fcSttbfAssocGet()) ==
    1029                 :          0 :         rFib.GetFIB().fcSttbfAssocGet()
    1030                 :          0 :      && rFib.GetStream().Read(pBuffer, cb) == cb)
    1031                 :            :     {
    1032                 :            :         sal_uInt16 j;
    1033                 :            :         OSL_ENSURE( cb == SVBT16ToShort( *(SVBT16*)pBuffer ), "size missmatch");
    1034 [ #  # ][ #  # ]:          0 :         for (i=0,j=sizeof(SVBT16);j<cb && i<Criteria1;i++)
                 [ #  # ]
    1035                 :            :         {
    1036                 :          0 :             pStrTbl[i] = pBuffer+j;
    1037                 :          0 :             j += (*pBuffer + j) + 1;
    1038                 :            :         }
    1039                 :          0 :         bOK = sal_True;
    1040                 :            :     }
    1041                 :          0 : }
    1042                 :            : 
    1043                 :          0 : String Ww1Assoc::GetStr(sal_uInt16 code)
    1044                 :            : {
    1045                 :          0 :     rtl::OStringBuffer sRet;
    1046                 :            :     OSL_ENSURE(code<MaxFields, "out of range");
    1047         [ #  # ]:          0 :     if (pStrTbl[code] != NULL)
    1048         [ #  # ]:          0 :         for( sal_uInt16 i=0;i<pStrTbl[code][0];i++ )
    1049         [ #  # ]:          0 :             sRet.append(pStrTbl[code][i+1]);
    1050                 :            :     return rtl::OStringToOUString(sRet.makeStringAndClear(),
    1051 [ #  # ][ #  # ]:          0 :         RTL_TEXTENCODING_MS_1252);
    1052                 :            : }
    1053                 :            : 
    1054                 :            : /////////////////////////////////////////////////////////////////// Pap
    1055                 :          0 : Ww1Pap::Ww1Pap(Ww1Fib& _rFib)
    1056                 :            :     : Ww1PlcPap(_rFib), nPlcIndex(0), nPushedPlcIndex(0xffff), nFkpIndex(0),
    1057                 :          0 :     nPushedFkpIndex(0xffff), ulOffset(0), pPap(0)
    1058                 :            : {
    1059                 :          0 : }
    1060                 :            : 
    1061                 :          0 : void Ww1Pap::Seek(sal_uLong ulSeek)
    1062                 :            : {
    1063         [ #  # ]:          0 :     while (ulSeek > Where())
    1064                 :          0 :         (*this)++;
    1065                 :          0 : }
    1066                 :            : 
    1067                 :            : // SH: Where hat einen Parameter mitbekommen, der sagt, ob bei Neuanlegen eines
    1068                 :            : // Fkps der zugehoerige Index auf 0 gesetzt werden soll
    1069                 :            : // ( darf fuer Push/Pop nicht passieren )
    1070                 :            : // Ein eleganterer Weg faellt mir auf die Schnelle nicht ein
    1071                 :          0 : sal_uLong Ww1Pap::Where( sal_Bool bSetIndex )
    1072                 :            : {
    1073                 :          0 :     sal_uLong ulRet = 0xffffffff;
    1074         [ #  # ]:          0 :     if (pPap == NULL)
    1075         [ #  # ]:          0 :         if (nPlcIndex < Count())
    1076                 :            :         {
    1077                 :          0 :             pPap = new Ww1FkpPap(rFib.GetStream(),
    1078         [ #  # ]:          0 :                         SVBT16ToShort(GetData(nPlcIndex)) << 9);
    1079         [ #  # ]:          0 :             if( bSetIndex )
    1080                 :          0 :                 nFkpIndex = 0;
    1081                 :            :         }
    1082         [ #  # ]:          0 :     if (pPap != NULL)
    1083         [ #  # ]:          0 :         if (nFkpIndex <= pPap->Count())
    1084                 :          0 :             ulRet = pPap->Where(nFkpIndex) - rFib.GetFIB().fcMinGet();
    1085                 :          0 :     return ulRet;
    1086                 :            : }
    1087                 :            : 
    1088                 :          0 : void Ww1Pap::operator++(int)
    1089                 :            : {
    1090         [ #  # ]:          0 :     if (pPap != NULL)
    1091         [ #  # ]:          0 :         if (++nFkpIndex > pPap->Count())
    1092                 :            :         {
    1093                 :          0 :             delete pPap;
    1094                 :          0 :             pPap = NULL;
    1095                 :          0 :             nPlcIndex++;
    1096                 :            :         }
    1097                 :          0 : }
    1098                 :            : 
    1099                 :            : // SH: FindSprm sucht in grpprl nach Sprm nId
    1100                 :            : // Rueckgabe: Pointer oder 0
    1101                 :          0 : sal_Bool Ww1Pap::FindSprm(sal_uInt16 nId, sal_uInt8* pStart, sal_uInt8* pEnd)
    1102                 :            : {
    1103         [ #  # ]:          0 :     Ww1Sprm aSprm( pStart, static_cast< sal_uInt16 >(pEnd-pStart) );
    1104                 :          0 :     sal_uInt16 nC = aSprm.Count();
    1105                 :            :     sal_uInt16 i;
    1106                 :            :     sal_uInt8 nI;
    1107                 :            :     sal_uInt16 nLen;
    1108                 :            :     sal_uInt8 *pData;
    1109         [ #  # ]:          0 :     for( i = 0; i < nC; i++ ){
    1110         [ #  # ]:          0 :         aSprm.Fill( i, nI, nLen, pData );
    1111         [ #  # ]:          0 :         if( nI == nId )
    1112                 :          0 :             return sal_True;
    1113                 :            :     }
    1114                 :          0 :     return sal_False;
    1115                 :            : }
    1116                 :            : 
    1117                 :          0 : sal_Bool Ww1Pap::HasId0(sal_uInt16 nId)
    1118                 :            : {
    1119                 :          0 :     sal_Bool bRet = sal_False;
    1120         [ #  # ]:          0 :     UpdateIdx();
    1121                 :            : 
    1122         [ #  # ]:          0 :     if( !pPap ){
    1123                 :            :         OSL_ENSURE( sal_False, "Ww1Pap::HasId():: kann kein pPap erzeugen" );
    1124                 :          0 :         return sal_False;
    1125                 :            :     }
    1126                 :            : 
    1127                 :            :     sal_uInt8* pByte;
    1128                 :            :     sal_uInt16 n;
    1129         [ #  # ]:          0 :     if( pPap->Fill(nFkpIndex, pByte, n) ){
    1130                 :          0 :         sal_uInt8* p2 = ((W1_PAPX*)(pByte))->grpprlGet(); // SH: Offset fehlte
    1131         [ #  # ]:          0 :         bRet = FindSprm( nId, p2, pByte + n );
    1132                 :            :     }
    1133                 :          0 :     return bRet;
    1134                 :            : }
    1135                 :            : 
    1136                 :          0 : sal_Bool Ww1Pap::HasId(sal_uInt16 nId)
    1137                 :            : {
    1138                 :          0 :     sal_Bool bRet = sal_False;
    1139                 :          0 :     sal_uInt16 nPushedPlcIndex2 = nPlcIndex;
    1140                 :          0 :     sal_uInt16 nPushedFkpIndex2 = nFkpIndex;
    1141                 :          0 :     bRet = HasId0( nId );
    1142         [ #  # ]:          0 :     if (nPlcIndex != nPushedPlcIndex2)
    1143                 :            :     {
    1144                 :          0 :         delete pPap;
    1145                 :          0 :         pPap = NULL;
    1146                 :            :     }
    1147                 :          0 :     nPlcIndex = nPushedPlcIndex2;
    1148                 :          0 :     nFkpIndex = nPushedFkpIndex2;
    1149                 :          0 :     Where( sal_False );
    1150                 :          0 :     return bRet;
    1151                 :            : }
    1152                 :            : 
    1153                 :            : /////////////////////////////////////////////////////////////////// Chp
    1154                 :          0 : Ww1Chp::Ww1Chp(Ww1Fib& _rFib)
    1155                 :            :     : Ww1PlcChp(_rFib), nPlcIndex(0), nPushedPlcIndex(0xffff), nFkpIndex(0),
    1156                 :          0 :     nPushedFkpIndex(0xffff), ulOffset(0), pChp(0)
    1157                 :            : {
    1158                 :          0 : }
    1159                 :            : 
    1160                 :          0 : void Ww1Chp::Seek(sal_uLong ulSeek)
    1161                 :            : {
    1162         [ #  # ]:          0 :     while (ulSeek > Where())
    1163                 :          0 :         (*this)++;
    1164                 :          0 : }
    1165                 :            : 
    1166                 :            : // SH: Where hat einen Parameter mitbekommen, der sagt, ob bei Neuanlegen eines
    1167                 :            : // Fkps der zugehoerige Index auf 0 gesetzt werden soll
    1168                 :            : // ( darf fuer Push/Pop nicht passieren )
    1169                 :            : // Ein eleganterer Weg faellt mir auf die Schnelle nicht ein
    1170                 :          0 : sal_uLong Ww1Chp::Where( sal_Bool bSetIndex )
    1171                 :            : {
    1172                 :          0 :     sal_uLong ulRet = 0xffffffff;
    1173         [ #  # ]:          0 :     if (pChp == NULL)
    1174         [ #  # ]:          0 :         if (nPlcIndex < Count())
    1175                 :            :         {
    1176                 :          0 :             pChp = new Ww1FkpChp(rFib.GetStream(),
    1177         [ #  # ]:          0 :                         SVBT16ToShort(GetData(nPlcIndex)) << 9);
    1178         [ #  # ]:          0 :             if( bSetIndex )
    1179                 :          0 :                 nFkpIndex = 0;
    1180                 :            :         }
    1181         [ #  # ]:          0 :     if (pChp != NULL)
    1182         [ #  # ]:          0 :         if (nFkpIndex <= pChp->Count())
    1183                 :          0 :             ulRet = pChp->Where(nFkpIndex) -
    1184                 :          0 :                      rFib.GetFIB().fcMinGet() - ulOffset;
    1185                 :          0 :     return ulRet;
    1186                 :            : }
    1187                 :            : 
    1188                 :          0 : void Ww1Chp::operator++(int)
    1189                 :            : {
    1190         [ #  # ]:          0 :     if (pChp != NULL)
    1191         [ #  # ]:          0 :         if (++nFkpIndex > pChp->Count())
    1192                 :            :         {
    1193                 :          0 :             delete pChp;
    1194                 :          0 :             pChp = NULL;
    1195                 :          0 :             nPlcIndex++;
    1196                 :            :         }
    1197                 :          0 : }
    1198                 :            : 
    1199                 :            : ////////////////////////////////////////////////////////////// Manager
    1200                 :          0 : Ww1Manager::Ww1Manager(SvStream& rStrm, sal_uLong nFieldFlgs)
    1201                 :            :     : bOK(sal_False), bInTtp(sal_False), bInStyle(sal_False), bStopAll(sal_False), aFib(rStrm),
    1202                 :            :     aDop(aFib), aFonts(aFib, nFieldFlgs), aDoc(aFib), pDoc(&aDoc),
    1203                 :            :     ulDocSeek(0), pSeek(&ulDocSeek), aFld(aFib), pFld(&aFld), aChp(aFib),
    1204                 :            :     aPap(aFib), aFtn(aFib), aBooks(aFib),
    1205 [ #  # ][ #  # ]:          0 :     aSep(aFib, aDop.GetDOP().grpfIhdtGet())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1206                 :            : {
    1207                 :          0 :     bOK =  !aFib.GetError()
    1208                 :          0 :         && !aFib.GetFIB().fComplexGet()
    1209                 :          0 :         && !aDoc.GetError()
    1210                 :          0 :         && !aSep.GetError()
    1211                 :          0 :         && !aPap.GetError()
    1212                 :          0 :         && !aChp.GetError()
    1213                 :          0 :         && !aFld.GetError()
    1214                 :          0 :         && !aFtn.GetError()
    1215 [ #  # ][ #  #  :          0 :         && !aBooks.GetError();
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
    1216                 :          0 : }
    1217                 :            : 
    1218                 :          0 : sal_Bool Ww1Manager::HasInTable()
    1219                 :            : {
    1220                 :          0 :     return aPap.HasId(24); // Ww1SingleSprmPFInTable
    1221                 :            : }
    1222                 :            : 
    1223                 :          0 : sal_Bool Ww1Manager::HasTtp()
    1224                 :            : {
    1225                 :          0 :     return aPap.HasId(25); // Ww1SingleSprmPTtp
    1226                 :            : }
    1227                 :            : 
    1228                 :          0 : sal_Bool Ww1Manager::HasPPc()
    1229                 :            : {
    1230                 :          0 :     return aPap.HasId(29); // Ww1SingleSprmPPc
    1231                 :            : }
    1232                 :            : 
    1233                 :          0 : sal_Bool Ww1Manager::HasPDxaAbs()
    1234                 :            : {
    1235                 :          0 :     return aPap.HasId(26); // Ww1SingleSprmPDxaAbs
    1236                 :            : }
    1237                 :            : 
    1238                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10