LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - ww8par6.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1827 2277 80.2 %
Date: 2014-11-03 Functions: 139 143 97.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <stdlib.h>
      21             : #include <svl/itemiter.hxx>
      22             : #include <rtl/tencinfo.h>
      23             : 
      24             : #include <hintids.hxx>
      25             : #include <editeng/lspcitem.hxx>
      26             : #include <editeng/wrlmitem.hxx>
      27             : #include <editeng/udlnitem.hxx>
      28             : #include <editeng/kernitem.hxx>
      29             : #include <editeng/langitem.hxx>
      30             : #include <editeng/cmapitem.hxx>
      31             : #include <editeng/shdditem.hxx>
      32             : #include <editeng/contouritem.hxx>
      33             : #include <editeng/crossedoutitem.hxx>
      34             : #include <editeng/postitem.hxx>
      35             : #include <editeng/wghtitem.hxx>
      36             : #include <editeng/colritem.hxx>
      37             : #include <editeng/brushitem.hxx>
      38             : #include <editeng/spltitem.hxx>
      39             : #include <editeng/keepitem.hxx>
      40             : #include <editeng/orphitem.hxx>
      41             : #include <editeng/widwitem.hxx>
      42             : #include <editeng/adjustitem.hxx>
      43             : #include <editeng/escapementitem.hxx>
      44             : #include <editeng/fhgtitem.hxx>
      45             : #include <editeng/fontitem.hxx>
      46             : #include <editeng/shaditem.hxx>
      47             : #include <editeng/boxitem.hxx>
      48             : #include <editeng/ulspitem.hxx>
      49             : #include <editeng/lrspitem.hxx>
      50             : #include <editeng/tstpitem.hxx>
      51             : #include <editeng/autokernitem.hxx>
      52             : #include <editeng/paperinf.hxx>
      53             : #include <editeng/emphasismarkitem.hxx>
      54             : #include <editeng/forbiddenruleitem.hxx>
      55             : #include <editeng/twolinesitem.hxx>
      56             : #include <editeng/scriptspaceitem.hxx>
      57             : #include <editeng/hngpnctitem.hxx>
      58             : #include <editeng/pbinitem.hxx>
      59             : #include <editeng/charscaleitem.hxx>
      60             : #include <editeng/charrotateitem.hxx>
      61             : #include <editeng/charreliefitem.hxx>
      62             : #include <editeng/blinkitem.hxx>
      63             : #include <editeng/hyphenzoneitem.hxx>
      64             : #include <editeng/paravertalignitem.hxx>
      65             : #include <editeng/pgrditem.hxx>
      66             : #include <editeng/frmdiritem.hxx>
      67             : #include <editeng/charhiddenitem.hxx>
      68             : #include <i18nlangtag/mslangid.hxx>
      69             : #include <sprmids.hxx>
      70             : #include <fmtpdsc.hxx>
      71             : #include <node.hxx>
      72             : #include <ndtxt.hxx>
      73             : #include <pam.hxx>
      74             : #include <doc.hxx>
      75             : #include <IDocumentSettingAccess.hxx>
      76             : #include <pagedesc.hxx>
      77             : #include <fmtanchr.hxx>
      78             : #include <fmtcntnt.hxx>
      79             : #include <fchrfmt.hxx>
      80             : #include <fmthdft.hxx>
      81             : #include <fmtclds.hxx>
      82             : #include <fmtftntx.hxx>
      83             : #include <frmatr.hxx>
      84             : #include <section.hxx>
      85             : #include <lineinfo.hxx>
      86             : #include <fmtline.hxx>
      87             : #include <txatbase.hxx>
      88             : #include <fmtflcnt.hxx>
      89             : #include <fmtclbl.hxx>
      90             : #include <tgrditem.hxx>
      91             : #include <hfspacingitem.hxx>
      92             : #include <swtable.hxx>
      93             : #include <fltini.hxx>
      94             : #include "writerhelper.hxx"
      95             : #include "writerwordglue.hxx"
      96             : #include "ww8scan.hxx"
      97             : #include "ww8par2.hxx"
      98             : #include "ww8graf.hxx"
      99             : 
     100             : #include <fmtwrapinfluenceonobjpos.hxx>
     101             : 
     102             : using namespace sw::util;
     103             : using namespace sw::types;
     104             : using namespace ::com::sun::star;
     105             : using namespace nsHdFtFlags;
     106             : 
     107             : //              diverses
     108             : 
     109             : #define MM_250 1417             // WW-Default fuer Hor. Seitenraender: 2.5 cm
     110             : #define MM_200 1134             // WW-Default fuer u.Seitenrand: 2.0 cm
     111             : 
     112             : 
     113             : static sal_uInt8 lcl_ReadBorders(bool bVer67, WW8_BRCVer9* brc, WW8PLCFx_Cp_FKP* pPap,
     114             :     const WW8RStyle* pSty = 0, const WW8PLCFx_SEPX* pSep = 0);
     115             : 
     116       11992 : ColorData SwWW8ImplReader::GetCol(sal_uInt8 nIco)
     117             : {
     118             :     static const ColorData eSwWW8ColA[] =
     119             :     {
     120             :         COL_AUTO, COL_BLACK, COL_LIGHTBLUE, COL_LIGHTCYAN, COL_LIGHTGREEN,
     121             :         COL_LIGHTMAGENTA, COL_LIGHTRED, COL_YELLOW, COL_WHITE, COL_BLUE,
     122             :         COL_CYAN, COL_GREEN, COL_MAGENTA, COL_RED, COL_BROWN, COL_GRAY,
     123             :         COL_LIGHTGRAY
     124             :     };
     125             :     SAL_WARN_IF(
     126             :         nIco >= SAL_N_ELEMENTS(eSwWW8ColA), "sw.ww8",
     127             :         "ico " << sal_uInt32(nIco) << " >= " << SAL_N_ELEMENTS(eSwWW8ColA));
     128       11992 :     return nIco < SAL_N_ELEMENTS(eSwWW8ColA) ? eSwWW8ColA[nIco] : COL_AUTO;
     129             : }
     130             : 
     131         444 : inline sal_uInt32 MSRoundTweak(sal_uInt32 x)
     132             : {
     133         444 :     return x;
     134             : }
     135             : 
     136             : // Seiten - Attribute, die nicht ueber die Attribut-Verwaltung, sondern
     137             : //  ueber ...->HasSprm abgearbeitet werden
     138             : //  ( ausser OLST, dass weiterhin ein normales Attribut ist )
     139         886 : static short ReadSprm( const WW8PLCFx_SEPX* pSep, sal_uInt16 nId, short nDefaultVal )
     140             : {
     141         886 :     const sal_uInt8* pS = pSep->HasSprm( nId );          // sprm da ?
     142         886 :     short nVal = ( pS ) ? SVBT16ToShort( pS ) : nDefaultVal;
     143         886 :     return nVal;
     144             : }
     145             : 
     146        2656 : static sal_uInt16 ReadUSprm( const WW8PLCFx_SEPX* pSep, sal_uInt16 nId, short nDefaultVal )
     147             : {
     148        2656 :     const sal_uInt8* pS = pSep->HasSprm( nId );          // sprm da ?
     149        2656 :     sal_uInt16 nVal = ( pS ) ? SVBT16ToShort( pS ) : nDefaultVal;
     150        2656 :     return nVal;
     151             : }
     152             : 
     153        1994 : static sal_uInt8 ReadBSprm( const WW8PLCFx_SEPX* pSep, sal_uInt16 nId, sal_uInt8 nDefaultVal )
     154             : {
     155        1994 :     const sal_uInt8* pS = pSep->HasSprm( nId );          // sprm da ?
     156        1994 :     sal_uInt8 nVal = pS ? *pS : nDefaultVal;
     157        1994 :     return nVal;
     158             : }
     159             : 
     160         220 : void wwSection::SetDirection()
     161             : {
     162             :     //sprmSTextFlow
     163         220 :     switch (maSep.wTextFlow)
     164             :     {
     165             :         default:
     166             :             OSL_ENSURE(false, "Unknown layout type");
     167             :             //fall-through
     168             :         case 0:
     169         220 :             meDir=FRMDIR_HORI_LEFT_TOP;
     170         220 :             break;
     171             :         case 1:
     172           0 :             meDir=FRMDIR_VERT_TOP_RIGHT;
     173           0 :             break;
     174             :         case 2:
     175             :             //asian letters are not rotated, western are. We can't import
     176             :             //bottom to top going left to right, we can't do this in
     177             :             //pages, (in drawboxes we could partly hack it with a rotated
     178             :             //drawing box, though not frame)
     179           0 :             meDir=FRMDIR_VERT_TOP_RIGHT;
     180           0 :             break;
     181             :         case 3:
     182             :             //asian letters are not rotated, western are. We can't import
     183           0 :             meDir=FRMDIR_VERT_TOP_RIGHT;
     184           0 :             break;
     185             :         case 4:
     186             :             //asian letters are rotated, western not. We can't import
     187           0 :             meDir=FRMDIR_HORI_LEFT_TOP;
     188           0 :             break;
     189             :     }
     190             : 
     191         220 :     sal_uInt8 nRTLPgn = maSep.fBiDi;
     192         220 :     if ((meDir == FRMDIR_HORI_LEFT_TOP) && nRTLPgn)
     193           0 :         meDir = FRMDIR_HORI_RIGHT_TOP;
     194         220 : }
     195             : 
     196         450 : bool wwSection::IsVertical() const
     197             : {
     198         450 :     if (meDir == FRMDIR_VERT_TOP_RIGHT || meDir == FRMDIR_VERT_TOP_LEFT)
     199           0 :         return true;
     200         450 :     return false;
     201             : }
     202             : 
     203             : /*
     204             :   This is something of festering mapping, I'm open to better ways of doing it,
     205             :   but primarily the grid in writer is different to that in word. In writer the
     206             :   grid elements are squares with ruby rows inbetween. While in word there is no
     207             :   ruby stuff, and the elements are rectangles. By misusing the ruby row I can
     208             :   handle distortions in one direction, but its all a bit of a mess:
     209             : */
     210         220 : void SwWW8ImplReader::SetDocumentGrid(SwFrmFmt &rFmt, const wwSection &rSection)
     211             : {
     212         220 :     if (bVer67)
     213         222 :         return;
     214             : 
     215         218 :     rFmt.SetFmtAttr(SvxFrameDirectionItem(rSection.meDir, RES_FRAMEDIR));
     216             : 
     217         218 :     SwTwips nTextareaHeight = rFmt.GetFrmSize().GetHeight();
     218         218 :     const SvxULSpaceItem &rUL = ItemGet<SvxULSpaceItem>(rFmt, RES_UL_SPACE);
     219         218 :     nTextareaHeight -= rUL.GetUpper();
     220         218 :     nTextareaHeight -= rUL.GetLower();
     221             : 
     222         218 :     SwTwips nTextareaWidth = rFmt.GetFrmSize().GetWidth();
     223         218 :     const SvxLRSpaceItem &rLR = ItemGet<SvxLRSpaceItem>(rFmt, RES_LR_SPACE);
     224         218 :     nTextareaWidth -= rLR.GetLeft();
     225         218 :     nTextareaWidth -= rLR.GetRight();
     226             : 
     227         218 :     if (rSection.IsVertical())
     228           0 :         std::swap(nTextareaHeight, nTextareaWidth);
     229             : 
     230         218 :     SwTextGridItem aGrid;
     231         218 :     aGrid.SetDisplayGrid(false);
     232         218 :     aGrid.SetPrintGrid(false);
     233         218 :     SwTextGrid eType=GRID_NONE;
     234             : 
     235         218 :     switch (rSection.maSep.clm)
     236             :     {
     237             :         case 0:
     238         214 :             eType = GRID_NONE;
     239         214 :             break;
     240             :         default:
     241             :             OSL_ENSURE(false, "Unknown grid type");
     242             :             //fall-through
     243             :         case 3:
     244           0 :             eType = GRID_LINES_CHARS;
     245           0 :             aGrid.SetSnapToChars(true);
     246           0 :             break;
     247             :         case 1:
     248           0 :             eType = GRID_LINES_CHARS;
     249           0 :             aGrid.SetSnapToChars(false);
     250           0 :             break;
     251             :         case 2:
     252           4 :             eType = GRID_LINES_ONLY;
     253           4 :             break;
     254             :     }
     255             : 
     256         218 :     aGrid.SetGridType(eType);
     257             : 
     258             :     // seem to not add external leading in word, or the character would run across
     259             :     // two line in some cases.
     260         218 :     if (eType != GRID_NONE)
     261           4 :         rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::ADD_EXT_LEADING, false);
     262             : 
     263             :     //force to set document as standard page mode
     264         218 :     bool bSquaredMode = false;
     265         218 :     rDoc.SetDefaultPageMode( bSquaredMode );
     266         218 :     aGrid.SetSquaredMode( bSquaredMode );
     267             : 
     268             :     //Get the size of word's default styles font
     269         218 :     sal_uInt32 nCharWidth=240;
     270         218 :     for (sal_uInt16 nI = 0; nI < pStyles->GetCount(); ++nI)
     271             :     {
     272         436 :         if (vColl[nI].bValid && vColl[nI].pFmt &&
     273         218 :             vColl[nI].IsWW8BuiltInDefaultStyle())
     274             :         {
     275         218 :             nCharWidth = ItemGet<SvxFontHeightItem>(*(vColl[nI].pFmt),
     276         218 :                 RES_CHRATR_CJK_FONTSIZE).GetHeight();
     277         218 :             break;
     278             :         }
     279             :     }
     280             : 
     281             :     //dxtCharSpace
     282         218 :     if (rSection.maSep.dxtCharSpace)
     283             :     {
     284          12 :         sal_uInt32 nCharSpace = rSection.maSep.dxtCharSpace;
     285             :         //main lives in top 20 bits, and is signed.
     286          12 :         sal_Int32 nMain = (nCharSpace & 0xFFFFF000);
     287          12 :         nMain/=0x1000;
     288          12 :         nCharWidth += nMain*20;
     289             : 
     290          12 :         int nFraction = (nCharSpace & 0x00000FFF);
     291          12 :         nFraction = (nFraction*20)/0xFFF;
     292          12 :         nCharWidth += nFraction;
     293             :     }
     294             : 
     295         218 :     aGrid.SetBaseWidth( writer_cast<sal_uInt16>(nCharWidth));
     296             : 
     297             :     //sep.dyaLinePitch
     298         218 :     sal_Int32 nLinePitch = rSection.maSep.dyaLinePitch;
     299         218 :     if (nLinePitch >= 1 && nLinePitch <= 31680)
     300             :     {
     301         216 :         aGrid.SetLines(writer_cast<sal_uInt16>(nTextareaHeight/nLinePitch));
     302         216 :         aGrid.SetBaseHeight(writer_cast<sal_uInt16>(nLinePitch));
     303             :     }
     304             : 
     305         218 :     sal_Int32 nRubyHeight = 0;
     306         218 :     aGrid.SetRubyHeight(writer_cast<sal_uInt16>(nRubyHeight));
     307             : 
     308         218 :     rFmt.SetFmtAttr(aGrid);
     309             : }
     310             : 
     311        1466 : void SwWW8ImplReader::Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nLen)
     312             : {
     313        1466 :     if( nLen < 0 )
     314         696 :         pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_FRAMEDIR);
     315             :     else
     316             :     {
     317             :         SvxFrameDirection eDir =
     318         770 :             *pData ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
     319         770 :         NewAttr(SvxFrameDirectionItem(eDir, RES_FRAMEDIR));
     320             :     }
     321        1466 : }
     322             : 
     323         222 : bool wwSectionManager::SetCols(SwFrmFmt &rFmt, const wwSection &rSection,
     324             :     sal_uInt32 nNetWidth) const
     325             : {
     326             :     //sprmSCcolumns - number of columns - 1
     327         222 :     const sal_Int16 nCols = rSection.NoCols();
     328             : 
     329         222 :     if (nCols < 2)          //check for no columns or other weird state
     330         210 :         return false;
     331             : 
     332          12 :     SwFmtCol aCol;                      // Create SwFmtCol
     333             : 
     334             :     //sprmSDxaColumns   - Default distance is 1.25 cm
     335          12 :     sal_Int32 nColSpace = rSection.StandardColSeparation();
     336             : 
     337          12 :     const SEPr& rSep = rSection.maSep;
     338             : 
     339             :     // sprmSLBetween
     340          12 :     if (rSep.fLBetween)
     341             :     {
     342           0 :         aCol.SetLineAdj(COLADJ_TOP);      // Line
     343           0 :         aCol.SetLineHeight(100);
     344           0 :         aCol.SetLineColor(Color(COL_BLACK));
     345           0 :         aCol.SetLineWidth(1);
     346             :     }
     347             : 
     348          12 :     aCol.Init(nCols, writer_cast<sal_uInt16>(nColSpace),
     349          24 :         writer_cast<sal_uInt16>(nNetWidth));
     350             : 
     351             :     // sprmSFEvenlySpaced
     352          12 :     if (!rSep.fEvenlySpaced)
     353             :     {
     354          12 :         aCol._SetOrtho(false);
     355          12 :         const sal_uInt16 maxIdx = SAL_N_ELEMENTS(rSep.rgdxaColumnWidthSpacing);
     356          36 :         for (sal_uInt16 i = 0, nIdx = 1; i < nCols && nIdx < maxIdx; i++, nIdx+=2 )
     357             :         {
     358          24 :             SwColumn* pCol = &aCol.GetColumns()[i];
     359          24 :             const sal_Int32 nLeft = rSep.rgdxaColumnWidthSpacing[nIdx-1]/2;
     360          24 :             const sal_Int32 nRight = rSep.rgdxaColumnWidthSpacing[nIdx+1]/2;
     361          24 :             const sal_Int32 nWishWidth = rSep.rgdxaColumnWidthSpacing[nIdx]
     362          48 :                 + nLeft + nRight;
     363          24 :             pCol->SetWishWidth(writer_cast<sal_uInt16>(nWishWidth));
     364          24 :             pCol->SetLeft(writer_cast<sal_uInt16>(nLeft));
     365          24 :             pCol->SetRight(writer_cast<sal_uInt16>(nRight));
     366             :         }
     367          12 :         aCol.SetWishWidth(writer_cast<sal_uInt16>(nNetWidth));
     368             :     }
     369          12 :     rFmt.SetFmtAttr(aCol);
     370          12 :     return true;
     371             : }
     372             : 
     373         222 : void wwSectionManager::SetLeftRight(wwSection &rSection)
     374             : {
     375             :     // 3. LR-Raender
     376         222 :     sal_uInt32 nWWLe = MSRoundTweak(rSection.maSep.dxaLeft);
     377         222 :     sal_uInt32 nWWRi = MSRoundTweak(rSection.maSep.dxaRight);
     378         222 :     sal_uInt32 nWWGu = rSection.maSep.dzaGutter;
     379             : 
     380             :     /*
     381             :     fRTLGutter is set if the gutter is on the right, the gutter is otherwise
     382             :     placed on the left unless the global dop options are to put it on top, that
     383             :     case is handled in GetPageULData.
     384             :     */
     385         222 :     if (rSection.maSep.fRTLGutter)
     386           0 :         nWWRi += nWWGu;
     387         222 :     else if (!mrReader.pWDop->iGutterPos)
     388         220 :         nWWLe += nWWGu;
     389             : 
     390             :     // Left / Right
     391         222 :     if ((rSection.nPgWidth - nWWLe - nWWRi) < MINLAY)
     392             :     {
     393             :         /*
     394             :         There are some label templates which are "broken", they specify
     395             :         margins which make no sense e.g. Left 16.10cm, Right 16.10cm. So the
     396             :         space left between the margins is less than 0 In word the left margin
     397             :         is honoured and if the right margin would be past the left margin is
     398             :         left at the left margin position.
     399             : 
     400             :         Now this will work fine for importing, layout and exporting, *but* the
     401             :         page layout dialog has a hardcoded minimum page width of 0.5cm so it
     402             :         will report a different value than what is actually being used. i.e.
     403             :         it will add up the values to give a wider page than is actually being
     404             :         used.
     405             :         */
     406           0 :         nWWRi = rSection.nPgWidth - nWWLe - MINLAY;
     407             :     }
     408             : 
     409         222 :     rSection.nPgLeft = nWWLe;
     410         222 :     rSection.nPgRight = nWWRi;
     411         222 : }
     412             : 
     413         220 : void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrmFmt &rFmt,
     414             :     const wwSection &rSection, bool bIgnoreCols) const
     415             : {
     416             :     // 1. Orientierung
     417         220 :     rInPageDesc.SetLandscape(rSection.IsLandScape());
     418             : 
     419             :     // 2. Papiergroesse
     420         220 :     SwFmtFrmSize aSz( rFmt.GetFrmSize() );
     421         220 :     aSz.SetWidth(rSection.GetPageWidth());
     422         220 :     aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight()));
     423         220 :     rFmt.SetFmtAttr(aSz);
     424             : 
     425             :     rFmt.SetFmtAttr(
     426         220 :         SvxLRSpaceItem(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, RES_LR_SPACE));
     427             : 
     428         220 :     if (!bIgnoreCols)
     429         214 :         SetCols(rFmt, rSection, rSection.GetTextAreaWidth());
     430         220 : }
     431             : 
     432          80 : static sal_uInt16 lcl_MakeSafeNegativeSpacing(sal_uInt16 nIn)
     433             : {
     434          80 :     if (nIn > SHRT_MAX)
     435           0 :         nIn = 0;
     436          80 :     return nIn;
     437             : }
     438             : 
     439         440 : void SwWW8ImplReader::SetPageBorder(SwFrmFmt &rFmt, const wwSection &rSection) const
     440             : {
     441         440 :     if (!IsBorder(rSection.brc))
     442         868 :         return;
     443             : 
     444          12 :     SfxItemSet aSet(rFmt.GetAttrSet());
     445          12 :     short aSizeArray[5]={0};
     446          12 :     SetFlyBordersShadow(aSet, rSection.brc, &aSizeArray[0]);
     447          24 :     SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
     448          24 :     SvxULSpaceItem aUL(ItemGet<SvxULSpaceItem>(aSet, RES_UL_SPACE));
     449             : 
     450          24 :     SvxBoxItem aBox(ItemGet<SvxBoxItem>(aSet, RES_BOX));
     451          12 :     short aOriginalBottomMargin = aBox.GetDistance(BOX_LINE_BOTTOM);
     452             : 
     453          12 :     if (rSection.maSep.pgbOffsetFrom == 1)
     454             :     {
     455             :         sal_uInt16 nDist;
     456           8 :         if (aBox.GetLeft())
     457             :         {
     458           8 :             nDist = aBox.GetDistance(BOX_LINE_LEFT);
     459           8 :             aBox.SetDistance(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aLR.GetLeft() - nDist)), BOX_LINE_LEFT);
     460             :             aSizeArray[WW8_LEFT] =
     461           8 :                 aSizeArray[WW8_LEFT] - nDist + aBox.GetDistance(BOX_LINE_LEFT);
     462             :         }
     463             : 
     464           8 :         if (aBox.GetRight())
     465             :         {
     466           8 :             nDist = aBox.GetDistance(BOX_LINE_RIGHT);
     467           8 :             aBox.SetDistance(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aLR.GetRight() - nDist)), BOX_LINE_RIGHT);
     468             :             aSizeArray[WW8_RIGHT] =
     469           8 :                 aSizeArray[WW8_RIGHT] - nDist + aBox.GetDistance(BOX_LINE_RIGHT);
     470             :         }
     471             : 
     472           8 :         if (aBox.GetTop())
     473             :         {
     474           8 :             nDist = aBox.GetDistance(BOX_LINE_TOP);
     475           8 :             aBox.SetDistance(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aUL.GetUpper() - nDist)), BOX_LINE_TOP);
     476             :             aSizeArray[WW8_TOP] =
     477           8 :                 aSizeArray[WW8_TOP] - nDist + aBox.GetDistance(BOX_LINE_TOP);
     478             :         }
     479             : 
     480           8 :         if (aBox.GetBottom())
     481             :         {
     482           8 :             nDist = aBox.GetDistance(BOX_LINE_BOTTOM);
     483           8 :             aBox.SetDistance(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aUL.GetLower() - nDist)), BOX_LINE_BOTTOM);
     484             :             aSizeArray[WW8_BOT] =
     485           8 :                 aSizeArray[WW8_BOT] - nDist + aBox.GetDistance(BOX_LINE_BOTTOM);
     486             :         }
     487             : 
     488           8 :         aSet.Put(aBox);
     489             :     }
     490             : 
     491          12 :     if (aBox.GetLeft())
     492          12 :         aLR.SetLeft(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aLR.GetLeft() - aSizeArray[WW8_LEFT])));
     493          12 :     if (aBox.GetRight())
     494          12 :         aLR.SetRight(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aLR.GetRight() - aSizeArray[WW8_RIGHT])));
     495          12 :     if (aBox.GetTop())
     496          12 :         aUL.SetUpper(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aUL.GetUpper() - aSizeArray[WW8_TOP])));
     497          12 :     if (aBox.GetBottom())
     498             :     {
     499             :         //#i30088# and #i30074# - do a final sanity check on
     500             :         //bottom value. Do not allow a resulting zero if bottom
     501             :         //Border margin value was not originally zero.
     502          12 :         if(aUL.GetLower() != 0)
     503          12 :             aUL.SetLower(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aUL.GetLower() - aSizeArray[WW8_BOT])));
     504             :         else
     505           0 :             aUL.SetLower(lcl_MakeSafeNegativeSpacing(static_cast<sal_uInt16>(aOriginalBottomMargin - aSizeArray[WW8_BOT])));
     506             :     }
     507             : 
     508          12 :     aSet.Put(aLR);
     509          12 :     aSet.Put(aUL);
     510          24 :     rFmt.SetFmtAttr(aSet);
     511             : }
     512             : 
     513         220 : void wwSectionManager::GetPageULData(const wwSection &rSection,
     514             :     wwSectionManager::wwULSpaceData& rData) const
     515             : {
     516         220 :     sal_Int32 nWWUp = rSection.maSep.dyaTop;
     517         220 :     sal_Int32 nWWLo = rSection.maSep.dyaBottom;
     518         220 :     sal_uInt32 nWWHTop = rSection.maSep.dyaHdrTop;
     519         220 :     sal_uInt32 nWWFBot = rSection.maSep.dyaHdrBottom;
     520             : 
     521             :     /*
     522             :     If there is gutter in 97+ and the dop says put it on top then get the
     523             :     gutter distance and set it to the top margin. When we are "two pages
     524             :     in one" the gutter is put at the top of odd pages, and bottom of
     525             :     even pages, something we cannot do. So we will put it on top of all
     526             :     pages, that way the pages are at least the right size.
     527             :     */
     528         220 :     if (
     529         438 :          (!mrReader.bVer67 && mrReader.pWDop->iGutterPos &&
     530             :          rSection.maSep.fRTLGutter)
     531             :        )
     532             :     {
     533           0 :         nWWUp += rSection.maSep.dzaGutter;
     534             :     }
     535             : 
     536         220 :     rData.bHasHeader = (rSection.maSep.grpfIhdt &
     537         220 :         (WW8_HEADER_EVEN | WW8_HEADER_ODD | WW8_HEADER_FIRST)) != 0;
     538             : 
     539         220 :     if( rData.bHasHeader )
     540             :     {
     541          74 :         rData.nSwUp  = nWWHTop;             // Header -> umrechnen
     542             :         // #i19922# - correction:
     543             :         // consider that <nWWUp> can be negative, compare only if it's positive
     544         148 :         if ( nWWUp > 0 &&
     545          74 :              static_cast<sal_uInt32>(abs(nWWUp)) >= nWWHTop )
     546          70 :             rData.nSwHLo = nWWUp - nWWHTop;
     547             :         else
     548           4 :             rData.nSwHLo = 0;
     549             : 
     550             :         // #i19922# - minimum page header height is now 1mm
     551             :         // use new constant <cMinHdFtHeight>
     552          74 :         if (rData.nSwHLo < sal::static_int_cast< sal_uInt32 >(cMinHdFtHeight))
     553          10 :             rData.nSwHLo = sal::static_int_cast< sal_uInt32 >(cMinHdFtHeight);
     554             :     }
     555             :     else // kein Header -> Up einfach uebernehmen
     556         146 :         rData.nSwUp = std::abs(nWWUp);
     557             : 
     558         220 :     rData.bHasFooter = (rSection.maSep.grpfIhdt &
     559         220 :         (WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST)) != 0;
     560             : 
     561         220 :     if( rData.bHasFooter )
     562             :     {
     563          74 :         rData.nSwLo = nWWFBot;              // Footer -> Umrechnen
     564             :         // #i19922# - correction: consider that <nWWLo> can be negative, compare only if it's positive
     565         148 :         if ( nWWLo > 0 &&
     566          74 :              static_cast<sal_uInt32>(abs(nWWLo)) >= nWWFBot )
     567          72 :             rData.nSwFUp = nWWLo - nWWFBot;
     568             :         else
     569           2 :             rData.nSwFUp = 0;
     570             : 
     571             :         // #i19922# - minimum page header height is now 1mm
     572             :         // use new constant <cMinHdFtHeight>
     573          74 :         if (rData.nSwFUp < sal::static_int_cast< sal_uInt32 >(cMinHdFtHeight))
     574          10 :             rData.nSwFUp = sal::static_int_cast< sal_uInt32 >(cMinHdFtHeight);
     575             :     }
     576             :     else // kein Footer -> Lo einfach uebernehmen
     577         146 :         rData.nSwLo = std::abs(nWWLo);
     578         220 : }
     579             : 
     580         220 : void wwSectionManager::SetPageULSpaceItems(SwFrmFmt &rFmt,
     581             :     wwSectionManager::wwULSpaceData& rData, const wwSection &rSection) const
     582             : {
     583         220 :     if (rData.bHasHeader)               // ... und Header-Lower setzen
     584             :     {
     585             :         //Kopfzeilenhoehe minimal sezten
     586          74 :         if (SwFrmFmt* pHdFmt = (SwFrmFmt*)rFmt.GetHeader().GetHeaderFmt())
     587             :         {
     588          72 :             SvxULSpaceItem aHdUL(pHdFmt->GetULSpace());
     589          72 :             if (!rSection.IsFixedHeightHeader())    //normal
     590             :             {
     591          72 :                 pHdFmt->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, 0, rData.nSwHLo));
     592             :                 // #i19922# - minimum page header height is now 1mm
     593             :                 // use new constant <cMinHdFtHeight>
     594          72 :                 aHdUL.SetLower( writer_cast<sal_uInt16>(rData.nSwHLo - cMinHdFtHeight) );
     595             :                 pHdFmt->SetFmtAttr(SwHeaderAndFooterEatSpacingItem(
     596          72 :                     RES_HEADER_FOOTER_EAT_SPACING, true));
     597             :             }
     598             :             else
     599             :             {
     600             :                 // #i48832# - set correct spacing between header and body.
     601           0 :                 const SwTwips nHdLowerSpace( std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo );
     602           0 :                 pHdFmt->SetFmtAttr(SwFmtFrmSize(ATT_FIX_SIZE, 0, rData.nSwHLo + nHdLowerSpace));
     603           0 :                 aHdUL.SetLower( static_cast< sal_uInt16 >(nHdLowerSpace) );
     604             :                 pHdFmt->SetFmtAttr(SwHeaderAndFooterEatSpacingItem(
     605           0 :                     RES_HEADER_FOOTER_EAT_SPACING, false));
     606             :             }
     607          72 :             pHdFmt->SetFmtAttr(aHdUL);
     608             :         }
     609             :     }
     610             : 
     611         220 :     if (rData.bHasFooter)               // ... und Footer-Upper setzen
     612             :     {
     613          74 :         if (SwFrmFmt* pFtFmt = (SwFrmFmt*)rFmt.GetFooter().GetFooterFmt())
     614             :         {
     615          74 :             SvxULSpaceItem aFtUL(pFtFmt->GetULSpace());
     616          74 :             if (!rSection.IsFixedHeightFooter())    //normal
     617             :             {
     618          74 :                 pFtFmt->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, 0, rData.nSwFUp));
     619             :                 // #i19922# - minimum page header height is now 1mm
     620             :                 // use new constant <cMinHdFtHeight>
     621          74 :                 aFtUL.SetUpper( writer_cast<sal_uInt16>(rData.nSwFUp - cMinHdFtHeight) );
     622             :                 pFtFmt->SetFmtAttr(SwHeaderAndFooterEatSpacingItem(
     623          74 :                     RES_HEADER_FOOTER_EAT_SPACING, true));
     624             :             }
     625             :             else
     626             :             {
     627             :                 // #i48832# - set correct spacing between footer and body.
     628           0 :                 const SwTwips nFtUpperSpace( std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp );
     629           0 :                 pFtFmt->SetFmtAttr(SwFmtFrmSize(ATT_FIX_SIZE, 0, rData.nSwFUp + nFtUpperSpace));
     630           0 :                 aFtUL.SetUpper( static_cast< sal_uInt16 >(nFtUpperSpace) );
     631             :                 pFtFmt->SetFmtAttr(SwHeaderAndFooterEatSpacingItem(
     632           0 :                     RES_HEADER_FOOTER_EAT_SPACING, false));
     633             :             }
     634          74 :             pFtFmt->SetFmtAttr(aFtUL);
     635             :         }
     636             :     }
     637             : 
     638         220 :     SvxULSpaceItem aUL(writer_cast<sal_uInt16>(rData.nSwUp),
     639         440 :         writer_cast<sal_uInt16>(rData.nSwLo), RES_UL_SPACE);
     640         220 :     rFmt.SetFmtAttr(aUL);
     641         220 : }
     642             : 
     643           8 : SwSectionFmt *wwSectionManager::InsertSection(
     644             :     SwPaM& rMyPaM, wwSection &rSection)
     645             : {
     646             :     SwSectionData aSection( CONTENT_SECTION,
     647           8 :             mrReader.rDoc.GetUniqueSectionName() );
     648             : 
     649          16 :     SfxItemSet aSet( mrReader.rDoc.GetAttrPool(), aFrmFmtSetRange );
     650             : 
     651           8 :     bool nRTLPgn = !maSegments.empty() && maSegments.back().IsBiDi();
     652             :     aSet.Put(SvxFrameDirectionItem(
     653           8 :         nRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR));
     654             : 
     655           8 :     if (2 == mrReader.pWDop->fpc)
     656           0 :         aSet.Put( SwFmtFtnAtTxtEnd(FTNEND_ATTXTEND));
     657           8 :     if (0 == mrReader.pWDop->epc)
     658           0 :         aSet.Put( SwFmtEndAtTxtEnd(FTNEND_ATTXTEND));
     659             : 
     660           8 :     aSection.SetProtectFlag(SectionIsProtected(rSection));
     661             : 
     662             :     rSection.mpSection =
     663           8 :         mrReader.rDoc.InsertSwSection( rMyPaM, aSection, 0, & aSet );
     664             :     OSL_ENSURE(rSection.mpSection, "section not inserted!");
     665           8 :     if (!rSection.mpSection)
     666           0 :         return 0;
     667             : 
     668           8 :     SwPageDesc *pPage = 0;
     669           8 :     mySegrIter aEnd = maSegments.rend();
     670          10 :     for (mySegrIter aIter = maSegments.rbegin(); aIter != aEnd; ++aIter)
     671             :     {
     672          10 :         if (0 != (pPage = aIter->mpPage))
     673           8 :             break;
     674             :     }
     675             : 
     676             :     OSL_ENSURE(pPage, "no page outside this section!");
     677             : 
     678           8 :     if (!pPage)
     679           0 :         pPage = &mrReader.rDoc.GetPageDesc(0);
     680             : 
     681           8 :     if (!pPage)
     682           0 :         return 0;
     683             : 
     684           8 :     SwSectionFmt *pFmt = rSection.mpSection->GetFmt();
     685             :     OSL_ENSURE(pFmt, "impossible");
     686           8 :     if (!pFmt)
     687           0 :         return 0;
     688             : 
     689           8 :     SwFrmFmt& rFmt = pPage->GetMaster();
     690           8 :     const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
     691           8 :     long nPageLeft  = rLR.GetLeft();
     692           8 :     long nPageRight = rLR.GetRight();
     693           8 :     long nSectionLeft = rSection.GetPageLeft() - nPageLeft;
     694           8 :     long nSectionRight = rSection.GetPageRight() - nPageRight;
     695           8 :     if ((nSectionLeft != 0) || (nSectionRight != 0))
     696             :     {
     697           0 :         SvxLRSpaceItem aLR(nSectionLeft, nSectionRight, 0, 0, RES_LR_SPACE);
     698           0 :         pFmt->SetFmtAttr(aLR);
     699             :     }
     700             : 
     701           8 :     SetCols(*pFmt, rSection, rSection.GetTextAreaWidth());
     702          16 :     return pFmt;
     703             : }
     704             : 
     705         222 : void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection)
     706             : {
     707             :     // check if Line Numbering must be activated or resetted
     708         222 :     if (mbNewDoc && rSection.maSep.nLnnMod)
     709             :     {
     710             :         // restart-numbering-mode: 0 per page, 1 per section, 2 never restart
     711           0 :         bool bRestartLnNumPerSection = (1 == rSection.maSep.lnc);
     712             : 
     713           0 :         if (bNoLnNumYet)
     714             :         {
     715           0 :             SwLineNumberInfo aInfo( rDoc.GetLineNumberInfo() );
     716             : 
     717           0 :             aInfo.SetPaintLineNumbers(true);
     718             : 
     719           0 :             aInfo.SetRestartEachPage(rSection.maSep.lnc == 0);
     720             : 
     721           0 :             aInfo.SetPosFromLeft(writer_cast<sal_uInt16>(rSection.maSep.dxaLnn));
     722             : 
     723             :             //Paint only for every n line
     724           0 :             aInfo.SetCountBy(rSection.maSep.nLnnMod);
     725             : 
     726             :             // to be defaulted features ( HARDCODED in MS Word 6,7,8,9 )
     727           0 :             aInfo.SetCountBlankLines(true);
     728           0 :             aInfo.SetCountInFlys(false);
     729           0 :             aInfo.SetPos( LINENUMBER_POS_LEFT );
     730           0 :             SvxNumberType aNumType; // this sets SVX_NUM_ARABIC per default
     731           0 :             aInfo.SetNumType( aNumType );
     732             : 
     733           0 :             rDoc.SetLineNumberInfo( aInfo );
     734           0 :             bNoLnNumYet = false;
     735             :         }
     736             : 
     737           0 :         if (
     738           0 :             (0 < rSection.maSep.lnnMin) ||
     739           0 :             (bRestartLnNumPerSection && !bNoLnNumYet)
     740             :            )
     741             :         {
     742           0 :             SwFmtLineNumber aLN;
     743           0 :             if (const SwFmtLineNumber* pLN
     744           0 :                 = (const SwFmtLineNumber*)GetFmtAttr(RES_LINENUMBER))
     745             :             {
     746           0 :                 aLN.SetCountLines( pLN->IsCount() );
     747             :             }
     748           0 :             aLN.SetStartValue(1 + rSection.maSep.lnnMin);
     749           0 :             NewAttr(aLN);
     750           0 :             pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_LINENUMBER);
     751             :         }
     752           0 :         bNoLnNumYet = false;
     753             :     }
     754         222 : }
     755             : 
     756         444 : wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.nNode),
     757             :     mpSection(0), mpPage(0), meDir(FRMDIR_HORI_LEFT_TOP), mLinkId(0),
     758         888 :     nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width()),
     759        1332 :     nPgLeft(MM_250), nPgRight(MM_250), mnBorders(0), mbHasFootnote(false)
     760             : {
     761         444 : }
     762             : 
     763         220 : void wwSectionManager::SetNumberingType(const wwSection &rNewSection,
     764             :     SwPageDesc &rPageDesc) const
     765             : {
     766             :     // Seitennummernformat speichern
     767             :     static const SvxExtNumType aNumTyp[5] =
     768             :     {
     769             :         SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER,
     770             :         SVX_NUM_CHARS_UPPER_LETTER_N, SVX_NUM_CHARS_LOWER_LETTER_N
     771             :     };
     772             : 
     773         220 :     SvxNumberType aType;
     774         220 :     aType.SetNumberingType( static_cast< sal_Int16 >(aNumTyp[rNewSection.maSep.nfcPgn]) );
     775         220 :     rPageDesc.SetNumType(aType);
     776         220 : }
     777             : 
     778             : // Bei jedem Abschnittswechsel ( auch am Anfang eines Dokuments ) wird
     779             : // CreateSep gerufen, dass dann den / die Pagedesc(s) erzeugt und
     780             : // mit Attributen un KF-Texten fuellt.
     781             : // Dieses Vorgehen ist noetig geworden, da die UEbersetzung der verschiedenen
     782             : // Seiten-Attribute zu stark verflochten ist.
     783         222 : void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/)
     784             : {
     785             :     /*
     786             :     #i1909# section/page breaks should not occur in tables or subpage
     787             :     elements like frames. Word itself ignores them in this case. The bug is
     788             :     more likely that this filter created such documents in the past!
     789             :     */
     790         222 :     if (mrReader.nInTable || mrReader.bTxbxFlySection || mrReader.InLocalApo())
     791           0 :         return;
     792             : 
     793         222 :     WW8PLCFx_SEPX* pSep = mrReader.pPlcxMan->GetSepPLCF();
     794             :     OSL_ENSURE(pSep, "impossible!");
     795         222 :     if (!pSep)
     796           0 :         return;
     797             : 
     798         222 :     if (!maSegments.empty() && mrReader.mpLastAnchorPos.get() && *mrReader.mpLastAnchorPos == *mrReader.pPaM->GetPoint())
     799             :     {
     800           2 :         bool insert = true;
     801           2 :         SwPaM pam( *mrReader.mpLastAnchorPos );
     802           2 :         if( pam.Move(fnMoveBackward, fnGoNode))
     803           2 :             if( SwTxtNode* txtNode = pam.GetPoint()->nNode.GetNode().GetTxtNode())
     804           2 :                 if( txtNode->Len() == 0 )
     805           0 :                     insert = false;
     806           2 :         if( insert )
     807           2 :             mrReader.AppendTxtNode(*mrReader.pPaM->GetPoint());
     808             :     }
     809             : 
     810         222 :     ww::WordVersion eVer = mrReader.GetFib().GetFIBVersion();
     811             : 
     812             :     // M.M. Create a linked section if the WkbPLCF
     813             :     // has an entry for one at this cp
     814         222 :     WW8PLCFspecial* pWkb = mrReader.pPlcxMan->GetWkbPLCF();
     815         222 :     if (pWkb && pWkb->SeekPosExact(nTxtPos) &&
     816           0 :             pWkb->Where() == nTxtPos)
     817             :     {
     818             :         void* pData;
     819             :         WW8_CP nTest;
     820           0 :         bool bSuccess = pWkb->Get(nTest, pData);
     821           0 :         if (!bSuccess)
     822           0 :             return;
     823           0 :         OUString sSectionName = mrReader.aLinkStringMap[SVBT16ToShort( ((WW8_WKB*)pData)->nLinkId) ];
     824           0 :         sSectionName = mrReader.ConvertFFileName(sSectionName);
     825           0 :         SwSectionData aSection(FILE_LINK_SECTION, sSectionName);
     826           0 :         aSection.SetLinkFileName( sSectionName );
     827           0 :         aSection.SetProtectFlag(true);
     828             :         // #i19922# - improvement: return value of method <Insert> not used.
     829           0 :         mrReader.rDoc.InsertSwSection(*mrReader.pPaM, aSection, 0, 0, false);
     830             :     }
     831             : 
     832         222 :     wwSection aLastSection(*mrReader.pPaM->GetPoint());
     833         222 :     if (!maSegments.empty())
     834          38 :         aLastSection = maSegments.back();
     835             : 
     836             :     //Here
     837         222 :     sal_uInt16 nLIdx = ( ( mrReader.pWwFib->lid & 0xff ) == 0x9 ) ? 1 : 0;
     838             : 
     839             :     //BEGIN read section values
     840         444 :     wwSection aNewSection(*mrReader.pPaM->GetPoint());
     841             : 
     842             :     static const sal_uInt16 aVer2Ids0[] =
     843             :     {
     844             :         /*sprmSBkc*/           117,
     845             :         /*sprmSFTitlePage*/    118,
     846             :         /*sprmSNfcPgn*/        122,
     847             :         /*sprmSCcolumns*/      119,
     848             :         /*sprmSDxaColumns*/    120,
     849             :         /*sprmSLBetween*/      133
     850             :     };
     851             : 
     852             :     static const sal_uInt16 aVer67Ids0[] =
     853             :     {
     854             :         /*sprmSBkc*/           142,
     855             :         /*sprmSFTitlePage*/    143,
     856             :         /*sprmSNfcPgn*/        147,
     857             :         /*sprmSCcolumns*/      144,
     858             :         /*sprmSDxaColumns*/    145,
     859             :         /*sprmSLBetween*/      158
     860             :     };
     861             : 
     862             :     static const sal_uInt16 aVer8Ids0[] =
     863             :     {
     864             :         /*sprmSBkc*/           0x3009,
     865             :         /*sprmSFTitlePage*/    0x300A,
     866             :         /*sprmSNfcPgn*/        0x300E,
     867             :         /*sprmSCcolumns*/      0x500B,
     868             :         /*sprmSDxaColumns*/    0x900C,
     869             :         /*sprmSLBetween*/      0x3019
     870             :     };
     871             : 
     872         222 :     const sal_uInt16* pIds = eVer <= ww::eWW2 ? aVer2Ids0 : eVer <= ww::eWW7 ? aVer67Ids0 : aVer8Ids0;
     873             : 
     874         222 :     if (!maSegments.empty())
     875             :     {
     876             :         // Type of break: break codes are:
     877             :         // 0 No break
     878             :         // 1 New column
     879             :         // 2 New page
     880             :         // 3 Even page
     881             :         // 4 Odd page
     882          38 :         if (const sal_uInt8* pSprmBkc = pSep->HasSprm(pIds[0]))
     883          12 :             aNewSection.maSep.bkc = *pSprmBkc;
     884             :     }
     885             : 
     886             :     // Has a table page
     887             :     aNewSection.maSep.fTitlePage =
     888         222 :         (0 != ReadBSprm( pSep, pIds[1], 0 ));
     889             : 
     890             :     // sprmSNfcPgn
     891         222 :     aNewSection.maSep.nfcPgn = ReadBSprm( pSep, pIds[2], 0 );
     892         222 :     if (aNewSection.maSep.nfcPgn > 4)
     893           0 :         aNewSection.maSep.nfcPgn = 0;
     894             : 
     895         222 :     aNewSection.maSep.fUnlocked = eVer > ww::eWW2 ? ReadBSprm(pSep, (eVer <= ww::eWW7 ? 139 : 0x3006), 0 ) : 0;
     896             : 
     897             :     // sprmSFBiDi
     898         222 :     aNewSection.maSep.fBiDi = eVer >= ww::eWW8 ? ReadBSprm(pSep, 0x3228, 0) : 0;
     899             : 
     900             :     // Reading section property sprmSCcolumns - one less than the number of columns in the section.
     901             :     // It must be less than MAX_NO_OF_SEP_COLUMNS according the WW8 specification.
     902         222 :     aNewSection.maSep.ccolM1 = ReadSprm(pSep, pIds[3], 0 );
     903         222 :     if ( aNewSection.maSep.ccolM1 >= MAX_NO_OF_SEP_COLUMNS )
     904             :     {
     905             :         // clip to max
     906           0 :         aNewSection.maSep.ccolM1 = MAX_NO_OF_SEP_COLUMNS-1;
     907             :     }
     908             : 
     909             :     //sprmSDxaColumns   - Default-Abstand 1.25 cm
     910         222 :     aNewSection.maSep.dxaColumns = ReadUSprm( pSep, pIds[4], 708 );
     911             : 
     912             :     // sprmSLBetween
     913         222 :     aNewSection.maSep.fLBetween = ReadBSprm(pSep, pIds[5], 0 );
     914             : 
     915         222 :     if (eVer >= ww::eWW6)
     916             :     {
     917             :         // sprmSFEvenlySpaced
     918             :         aNewSection.maSep.fEvenlySpaced =
     919         220 :             sal_uInt8(ReadBSprm(pSep, (eVer <= ww::eWW7 ? 138 : 0x3005), 1) ? true : false);
     920             : 
     921         220 :         if (aNewSection.maSep.ccolM1 > 0 && !aNewSection.maSep.fEvenlySpaced)
     922             :         {
     923          10 :             int nColumnDataIdx = 0;
     924          10 :             aNewSection.maSep.rgdxaColumnWidthSpacing[nColumnDataIdx] = 0;
     925             : 
     926          10 :             const sal_uInt16 nColumnWidthSprmId = ( eVer <= ww::eWW7 ? 136 : 0xF203 );
     927          10 :             const sal_uInt16 nColumnSpacingSprmId = ( eVer <= ww::eWW7 ? 137 : 0xF204 );
     928          10 :             const sal_uInt8 nColumnCount = static_cast< sal_uInt8 >(aNewSection.maSep.ccolM1 + 1);
     929          30 :             for ( sal_uInt8 nColumn = 0; nColumn < nColumnCount; ++nColumn )
     930             :             {
     931             :                 //sprmSDxaColWidth
     932          20 :                 const sal_uInt8* pSW = pSep->HasSprm( nColumnWidthSprmId, nColumn );
     933             : 
     934             :                 OSL_ENSURE( pSW, "+Sprm 136 (bzw. 0xF203) (ColWidth) fehlt" );
     935          20 :                 sal_uInt16 nWidth = pSW ? SVBT16ToShort(pSW + 1) : 1440;
     936             : 
     937          20 :                 aNewSection.maSep.rgdxaColumnWidthSpacing[++nColumnDataIdx] = nWidth;
     938             : 
     939          20 :                 if ( nColumn < nColumnCount - 1 )
     940             :                 {
     941             :                     //sprmSDxaColSpacing
     942          10 :                     const sal_uInt8* pSD = pSep->HasSprm( nColumnSpacingSprmId, nColumn );
     943             : 
     944             :                     OSL_ENSURE( pSD, "+Sprm 137 (bzw. 0xF204) (Colspacing) fehlt" );
     945          10 :                     if( pSD )
     946             :                     {
     947          10 :                         nWidth = SVBT16ToShort(pSD + 1);
     948          10 :                         aNewSection.maSep.rgdxaColumnWidthSpacing[++nColumnDataIdx] = nWidth;
     949             :                     }
     950             :                 }
     951             :             }
     952             :         }
     953             :     }
     954             : 
     955             :     static const sal_uInt16 aVer2Ids1[] =
     956             :     {
     957             :         /*sprmSBOrientation*/   137,
     958             :         /*sprmSXaPage*/         139,
     959             :         /*sprmSYaPage*/         140,
     960             :         /*sprmSDxaLeft*/        141,
     961             :         /*sprmSDxaRight*/       142,
     962             :         /*sprmSDzaGutter*/      145,
     963             :         /*sprmSFPgnRestart*/    125,
     964             :         /*sprmSPgnStart*/       136,
     965             :         /*sprmSDmBinFirst*/     115,
     966             :         /*sprmSDmBinOther*/     116
     967             :     };
     968             : 
     969             :     static const sal_uInt16 aVer67Ids1[] =
     970             :     {
     971             :         /*sprmSBOrientation*/   162,
     972             :         /*sprmSXaPage*/         164,
     973             :         /*sprmSYaPage*/         165,
     974             :         /*sprmSDxaLeft*/        166,
     975             :         /*sprmSDxaRight*/       167,
     976             :         /*sprmSDzaGutter*/      170,
     977             :         /*sprmSFPgnRestart*/    150,
     978             :         /*sprmSPgnStart*/       161,
     979             :         /*sprmSDmBinFirst*/     140,
     980             :         /*sprmSDmBinOther*/     141
     981             :     };
     982             : 
     983             :     static const sal_uInt16 aVer8Ids1[] =
     984             :     {
     985             :         /*sprmSBOrientation*/   0x301d,
     986             :         /*sprmSXaPage*/         0xB01F,
     987             :         /*sprmSYaPage*/         0xB020,
     988             :         /*sprmSDxaLeft*/        0xB021,
     989             :         /*sprmSDxaRight*/       0xB022,
     990             :         /*sprmSDzaGutter*/      0xB025,
     991             :         /*sprmSFPgnRestart*/    0x3011,
     992             :         /*sprmSPgnStart*/       0x501C,
     993             :            /*sprmSDmBinFirst*/     0x5007,
     994             :         /*sprmSDmBinOther*/     0x5008
     995             :     };
     996             : 
     997         222 :     pIds = eVer <= ww::eWW2 ? aVer2Ids1 : eVer <= ww::eWW7 ? aVer67Ids1 : aVer8Ids1;
     998             : 
     999             :                                             // 1. Orientierung
    1000         222 :     aNewSection.maSep.dmOrientPage = ReadBSprm(pSep, pIds[0], 0);
    1001             : 
    1002             :     // 2. Papiergroesse
    1003         222 :     aNewSection.maSep.xaPage = ReadUSprm(pSep, pIds[1], lLetterWidth);
    1004         222 :     aNewSection.nPgWidth = SvxPaperInfo::GetSloppyPaperDimension(aNewSection.maSep.xaPage);
    1005             : 
    1006         222 :     aNewSection.maSep.yaPage = ReadUSprm(pSep, pIds[2], lLetterHeight);
    1007             : 
    1008             :     // 3. LR-Raender
    1009             :     static const sal_uInt16 nLef[] = { MM_250, 1800 };
    1010             :     static const sal_uInt16 nRig[] = { MM_250, 1800 };
    1011             : 
    1012         222 :     aNewSection.maSep.dxaLeft = ReadUSprm( pSep, pIds[3], nLef[nLIdx]);
    1013         222 :     aNewSection.maSep.dxaRight = ReadUSprm( pSep, pIds[4], nRig[nLIdx]);
    1014             : 
    1015             :     // 2pages in 1sheet hackery ?
    1016             :     // #i31806# but only swap if 2page in 1sheet is enabled.
    1017             :     // its not clear if dmOrientPage is the correct member to
    1018             :     // decide on this but I am not about to 2nd guess cmc.
    1019         222 :     if(mrReader.pWDop->doptypography.f2on1 &&
    1020           0 :             aNewSection.maSep.dmOrientPage == 2)
    1021           0 :         std::swap(aNewSection.maSep.dxaLeft, aNewSection.maSep.dxaRight);
    1022             : 
    1023         222 :     aNewSection.maSep.dzaGutter = ReadUSprm( pSep, pIds[5], 0);
    1024             : 
    1025         222 :     aNewSection.maSep.fRTLGutter = static_cast< sal_uInt8 >(eVer >= ww::eWW8 ? ReadUSprm( pSep, 0x322A, 0 ) : 0);
    1026             : 
    1027             :     // Page Number Restarts - sprmSFPgnRestart
    1028         222 :     aNewSection.maSep.fPgnRestart = ReadBSprm(pSep, pIds[6], 0);
    1029             : 
    1030         222 :     aNewSection.maSep.pgnStart = ReadBSprm( pSep, pIds[7], 0 );
    1031             : 
    1032         222 :     if (eVer >= ww::eWW6)
    1033             :     {
    1034         220 :         if (const sal_uInt8* p = pSep->HasSprm( (eVer <= ww::eWW7 ? 132 : 0x3001) ))
    1035           0 :             aNewSection.maSep.iHeadingPgn = *p;
    1036             : 
    1037         220 :         if (const sal_uInt8* p = pSep->HasSprm( (eVer <= ww::eWW7 ? 131 : 0x3000) ))
    1038           0 :             aNewSection.maSep.cnsPgn = *p;
    1039             :     }
    1040             : 
    1041         222 :     if(const sal_uInt8* pSprmSDmBinFirst = pSep->HasSprm( pIds[8] ))
    1042           8 :         aNewSection.maSep.dmBinFirst = *pSprmSDmBinFirst;
    1043             : 
    1044         222 :     if (const sal_uInt8* pSprmSDmBinOther = pSep->HasSprm( pIds[9] ))
    1045           6 :         aNewSection.maSep.dmBinOther = *pSprmSDmBinOther;
    1046             : 
    1047             :     static const sal_uInt16 nTop[] = { MM_250, 1440 };
    1048             :     static const sal_uInt16 nBot[] = { MM_200, 1440 };
    1049             : 
    1050             :     static const sal_uInt16 aVer2Ids2[] =
    1051             :     {
    1052             :         /*sprmSDyaTop*/         143,
    1053             :         /*sprmSDyaBottom*/      144,
    1054             :         /*sprmSDyaHdrTop*/      131,
    1055             :         /*sprmSDyaHdrBottom*/   132,
    1056             :         /*sprmSNLnnMod*/        129,
    1057             :         /*sprmSLnc*/            127,
    1058             :         /*sprmSDxaLnn*/         130,
    1059             :         /*sprmSLnnMin*/         135
    1060             :     };
    1061             : 
    1062             :     static const sal_uInt16 aVer67Ids2[] =
    1063             :     {
    1064             :         /*sprmSDyaTop*/         168,
    1065             :         /*sprmSDyaBottom*/      169,
    1066             :         /*sprmSDyaHdrTop*/      156,
    1067             :         /*sprmSDyaHdrBottom*/   157,
    1068             :         /*sprmSNLnnMod*/        154,
    1069             :         /*sprmSLnc*/            152,
    1070             :         /*sprmSDxaLnn*/         155,
    1071             :         /*sprmSLnnMin*/         160
    1072             :     };
    1073             :     static const sal_uInt16 aVer8Ids2[] =
    1074             :     {
    1075             :         /*sprmSDyaTop*/         0x9023,
    1076             :         /*sprmSDyaBottom*/      0x9024,
    1077             :         /*sprmSDyaHdrTop*/      0xB017,
    1078             :         /*sprmSDyaHdrBottom*/   0xB018,
    1079             :         /*sprmSNLnnMod*/        0x5015,
    1080             :         /*sprmSLnc*/            0x3013,
    1081             :         /*sprmSDxaLnn*/         0x9016,
    1082             :         /*sprmSLnnMin*/         0x501B
    1083             :     };
    1084             : 
    1085         222 :     pIds = eVer <= ww::eWW2 ? aVer2Ids2 : eVer <= ww::eWW7 ? aVer67Ids2 : aVer8Ids2;
    1086             : 
    1087         222 :     aNewSection.maSep.dyaTop = ReadSprm( pSep, pIds[0], nTop[nLIdx] );
    1088         222 :     aNewSection.maSep.dyaBottom = ReadSprm( pSep, pIds[1], nBot[nLIdx] );
    1089         222 :     aNewSection.maSep.dyaHdrTop = ReadUSprm( pSep, pIds[2], 720 );
    1090         222 :     aNewSection.maSep.dyaHdrBottom = ReadUSprm( pSep, pIds[3], 720 );
    1091             : 
    1092         222 :     if (eVer >= ww::eWW8)
    1093             :     {
    1094         220 :         aNewSection.maSep.wTextFlow = ReadUSprm(pSep, 0x5033, 0);
    1095         220 :         aNewSection.maSep.clm = ReadUSprm( pSep, 0x5032, 0 );
    1096         220 :         aNewSection.maSep.dyaLinePitch = ReadUSprm(pSep, 0x9031, 360);
    1097         220 :         if (const sal_uInt8* pS = pSep->HasSprm(0x7030))
    1098          60 :             aNewSection.maSep.dxtCharSpace = SVBT32ToUInt32(pS);
    1099             : 
    1100             :         //sprmSPgbProp
    1101         220 :         sal_uInt16 pgbProp = ReadSprm( pSep, 0x522F, 0 );
    1102         220 :         aNewSection.maSep.pgbApplyTo = pgbProp & 0x0007;
    1103         220 :         aNewSection.maSep.pgbPageDepth = (pgbProp & 0x0018) >> 3;
    1104         220 :         aNewSection.maSep.pgbOffsetFrom = (pgbProp & 0x00E0) >> 5;
    1105             : 
    1106             :         aNewSection.mnBorders =
    1107         220 :             ::lcl_ReadBorders(eVer <= ww::eWW7, aNewSection.brc, 0, 0, pSep);
    1108             :     }
    1109             : 
    1110             :     // check if Line Numbering must be activated or resetted
    1111         222 :     if (const sal_uInt8* pSprmSNLnnMod = pSep->HasSprm( pIds[4] ))
    1112           0 :         aNewSection.maSep.nLnnMod = *pSprmSNLnnMod;
    1113             : 
    1114         222 :     if (const sal_uInt8* pSprmSLnc = pSep->HasSprm( pIds[5] ))
    1115           0 :         aNewSection.maSep.lnc = *pSprmSLnc;
    1116             : 
    1117         222 :     if (const sal_uInt8* pSprmSDxaLnn = pSep->HasSprm( pIds[6] ))
    1118           0 :         aNewSection.maSep.dxaLnn = SVBT16ToShort( pSprmSDxaLnn );
    1119             : 
    1120         222 :     if (const sal_uInt8* pSprmSLnnMin = pSep->HasSprm( pIds[7] ))
    1121           0 :         aNewSection.maSep.lnnMin = *pSprmSLnnMin;
    1122             : 
    1123         222 :     if (eVer <= ww::eWW7)
    1124           2 :         aNewSection.maSep.grpfIhdt = ReadBSprm(pSep, eVer <= ww::eWW2 ? 128 : 153, 0);
    1125         220 :     else if (mrReader.pHdFt)
    1126             :     {
    1127             :         aNewSection.maSep.grpfIhdt = WW8_HEADER_ODD | WW8_FOOTER_ODD
    1128         104 :             | WW8_HEADER_FIRST | WW8_FOOTER_FIRST;
    1129             : 
    1130             :         // It is possible for a first page header to be provided
    1131             :         // for this section, but not actually shown in this section.  In this
    1132             :         // case (aNewSection.maSep.grpfIhdt & WW8_HEADER_FIRST) will be nonzero
    1133             :         // but aNewSection.HasTitlePage() will be false.
    1134             :         // Likewise for first page footer.
    1135             : 
    1136         104 :         if (mrReader.pWDop->fFacingPages)
    1137          34 :             aNewSection.maSep.grpfIhdt |= WW8_HEADER_EVEN | WW8_FOOTER_EVEN;
    1138             : 
    1139             :         //See if we have a header or footer for each enabled possibility
    1140             :         //if we do not then we inherit the previous sections header/footer,
    1141         728 :         for (int nI = 0, nMask = 1; nI < 6; ++nI, nMask <<= 1)
    1142             :         {
    1143         624 :             if (aNewSection.maSep.grpfIhdt & nMask)
    1144             :             {
    1145             :                 WW8_CP nStart;
    1146             :                 long nLen;
    1147         484 :                 mrReader.pHdFt->GetTextPosExact( static_cast< short >(nI + ( maSegments.size() + 1) * 6), nStart, nLen);
    1148             :                 //No header or footer, inherit pervious one, or set to zero
    1149             :                 //if no previous one
    1150         484 :                 if (!nLen)
    1151             :                 {
    1152         202 :                     if (
    1153         250 :                         maSegments.empty() ||
    1154          48 :                         !(maSegments.back().maSep.grpfIhdt & nMask)
    1155             :                        )
    1156             :                     {
    1157         170 :                         aNewSection.maSep.grpfIhdt &= ~nMask;
    1158             :                     }
    1159             :                 }
    1160             :             }
    1161             :         }
    1162             :     }
    1163             : 
    1164         222 :     SetLeftRight(aNewSection);
    1165             :     //END read section values
    1166             : 
    1167         222 :     if (eVer >= ww::eWW8)
    1168         220 :         aNewSection.SetDirection();
    1169             : 
    1170         222 :     mrReader.HandleLineNumbering(aNewSection);
    1171         444 :     maSegments.push_back(aNewSection);
    1172             : }
    1173             : 
    1174          32 : void SwWW8ImplReader::CopyPageDescHdFt(const SwPageDesc* pOrgPageDesc,
    1175             :     SwPageDesc* pNewPageDesc, sal_uInt8 nCode )
    1176             : {
    1177             :     // copy odd header content section
    1178          32 :     if( nCode & WW8_HEADER_ODD )
    1179             :     {
    1180           8 :         rDoc.CopyHeader(pOrgPageDesc->GetMaster(),
    1181          16 :                         pNewPageDesc->GetMaster() );
    1182             :     }
    1183             :     // copy odd footer content section
    1184          32 :     if( nCode & WW8_FOOTER_ODD )
    1185             :     {
    1186           2 :         rDoc.CopyFooter(pOrgPageDesc->GetMaster(),
    1187           4 :                         pNewPageDesc->GetMaster());
    1188             :     }
    1189             :     // copy even header content section
    1190          32 :     if( nCode & WW8_HEADER_EVEN )
    1191             :     {
    1192           0 :         rDoc.CopyHeader(pOrgPageDesc->GetLeft(),
    1193           0 :                         pNewPageDesc->GetLeft());
    1194             :     }
    1195             :     // copy even footer content section
    1196          32 :     if( nCode & WW8_FOOTER_EVEN )
    1197             :     {
    1198           0 :         rDoc.CopyFooter(pOrgPageDesc->GetLeft(),
    1199           0 :                         pNewPageDesc->GetLeft());
    1200             :     }
    1201             :     // copy first page header content section
    1202          32 :     if( nCode & WW8_HEADER_FIRST )
    1203             :     {
    1204          12 :         rDoc.CopyHeader(pOrgPageDesc->GetFirstMaster(),
    1205          24 :                         pNewPageDesc->GetFirstMaster());
    1206             :     }
    1207             :     // copy first page footer content section
    1208          32 :     if( nCode & WW8_FOOTER_FIRST )
    1209             :     {
    1210          10 :         rDoc.CopyFooter(pOrgPageDesc->GetFirstMaster(),
    1211          20 :                         pNewPageDesc->GetFirstMaster());
    1212             :     }
    1213          32 : }
    1214             : 
    1215             : //   Hilfsroutinen fuer Grafiken und Apos und Tabellen
    1216             : 
    1217             : // Read BoRder Control structure
    1218             : // nBrcVer should be set to the version of the BRC record being read (6, 8 or 9)
    1219             : // This will be converted to the latest format (9).
    1220        4012 : static bool _SetWW8_BRC(int nBrcVer, WW8_BRCVer9& rVar, const sal_uInt8* pS)
    1221             : {
    1222             : 
    1223        4012 :     if( pS )
    1224             :     {
    1225         826 :         if ( nBrcVer == 9 )
    1226         424 :             rVar = *(const WW8_BRCVer9*)pS;
    1227         402 :         else if( nBrcVer == 8 )
    1228         402 :             rVar = *(const WW8_BRC*)pS;
    1229             :         else // nBrcVer == 6
    1230           0 :             rVar = WW8_BRC(*(const WW8_BRCVer6*)pS);
    1231             :     }
    1232             : 
    1233        4012 :     return 0 != pS;
    1234             : }
    1235             : 
    1236         612 : static sal_uInt8 lcl_ReadBorders(bool bVer67, WW8_BRCVer9* brc, WW8PLCFx_Cp_FKP* pPap,
    1237             :     const WW8RStyle* pSty, const WW8PLCFx_SEPX* pSep)
    1238             : {
    1239             : 
    1240             : //returns a sal_uInt8 filled with a bit for each position that had a sprm
    1241             : //setting that border
    1242             : 
    1243         612 :     sal_uInt8 nBorder = 0;
    1244         612 :     if( pSep )
    1245             :     {
    1246         220 :         if( !bVer67 )
    1247             :         {
    1248             :             sal_uInt8* pSprm[4];
    1249             : 
    1250         220 :             if( pSep->Find4Sprms(
    1251             :                     NS_sprm::LN_SBrcTop80, NS_sprm::LN_SBrcLeft80,
    1252             :                     NS_sprm::LN_SBrcBottom80, NS_sprm::LN_SBrcRight80,
    1253             :                     pSprm[0], pSprm[1], pSprm[2], pSprm[3] ) )
    1254             :             {
    1255          30 :                 for( int i = 0; i < 4; ++i )
    1256          24 :                     nBorder |= int(_SetWW8_BRC( 8, brc[ i ], pSprm[ i ] ))<<i;
    1257             :             }
    1258             :             // Version 9 BRCs if present will override version 8
    1259         220 :             if( pSep->Find4Sprms(
    1260             :                     NS_sprm::LN_SBrcTop, NS_sprm::LN_SBrcLeft,
    1261             :                     NS_sprm::LN_SBrcBottom, NS_sprm::LN_SBrcRight,
    1262             :                     pSprm[0], pSprm[1], pSprm[2], pSprm[3] ) )
    1263             :             {
    1264          30 :                 for( int i = 0; i < 4; ++i )
    1265          24 :                     nBorder |= int(_SetWW8_BRC( 9, brc[ i ], pSprm[ i ] ))<<i;
    1266             :             }
    1267             :         }
    1268             :     }
    1269             :     else
    1270             :     {
    1271             : 
    1272             :         static const sal_uInt16 aVer67Ids[5] = { 38, 39, 40, 41, 42 };
    1273             : 
    1274             :         static const sal_uInt16 aVer8Ids[5] =
    1275             :                 { 0x6424, 0x6425, 0x6426, 0x6427, 0x6428 };
    1276             : 
    1277             :         static const sal_uInt16 aVer9Ids[5] =
    1278             :                 { 0xC64E, 0xC64F, 0xC650, 0xC651, 0xC652 };
    1279             : 
    1280         392 :         if( pPap )
    1281             :         {
    1282         312 :             if (bVer67)
    1283             :             {
    1284           0 :                 for( int i = 0; i < 5; ++i )
    1285           0 :                     nBorder |= int(_SetWW8_BRC( 6 , brc[ i ], pPap->HasSprm( aVer67Ids[ i ] )))<<i;
    1286             :             }
    1287             :             else
    1288             :             {
    1289        1872 :                 for( int i = 0; i < 5; ++i )
    1290        1560 :                     nBorder |= int(_SetWW8_BRC( 8 , brc[ i ], pPap->HasSprm( aVer8Ids[ i ] )))<<i;
    1291             :                 // Version 9 BRCs if present will override version 8
    1292        1872 :                 for( int i = 0; i < 5; ++i )
    1293        1560 :                     nBorder |= int(_SetWW8_BRC( 9 , brc[ i ], pPap->HasSprm( aVer9Ids[ i ] )))<<i;
    1294             :             }
    1295             :         }
    1296          80 :         else if( pSty )
    1297             :         {
    1298          80 :             if (bVer67)
    1299             :             {
    1300           0 :                 for( int i = 0; i < 5; ++i )
    1301           0 :                     nBorder |= int(_SetWW8_BRC( 6 , brc[ i ], pSty->HasParaSprm( aVer67Ids[ i ] )))<<i;
    1302             :             }
    1303             :             else
    1304             :             {
    1305         480 :                 for( int i = 0; i < 5; ++i )
    1306         400 :                     nBorder |= int(_SetWW8_BRC( 8 , brc[ i ], pSty->HasParaSprm( aVer8Ids[ i ] )))<<i;
    1307             :                 // Version 9 BRCs if present will override version 8
    1308         480 :                 for( int i = 0; i < 5; ++i )
    1309         400 :                     nBorder |= int(_SetWW8_BRC( 9 , brc[ i ], pSty->HasParaSprm( aVer9Ids[ i ] )))<<i;
    1310             :             }
    1311             :         }
    1312             :         else {
    1313             :             OSL_ENSURE( pSty || pPap, "WW8PLCFx_Cp_FKP and WW8RStyle "
    1314             :                                "and WW8PLCFx_SEPX is 0" );
    1315             :         }
    1316             :     }
    1317             : 
    1318         612 :     return nBorder;
    1319             : }
    1320             : 
    1321        5470 : void GetLineIndex(SvxBoxItem &rBox, short nLineThickness, short nSpace,
    1322             :     sal_uInt32 cv, short nIdx, sal_uInt16 nOOIndex, sal_uInt16 nWWIndex,
    1323             :     short *pSize=0)
    1324             : {
    1325             :     // LO cannot handle outset/inset (new in WW9 BRC) so fall back same as WW8
    1326        5470 :     if ( nIdx == 0x1A || nIdx == 0x1B )
    1327             :     {
    1328           2 :         nIdx = (nIdx == 0x1A) ? 0x12 : 0x11;
    1329           2 :         cv = 0xc0c0c0;
    1330             :     }
    1331             : 
    1332             :     ::editeng::SvxBorderStyle const eStyle(
    1333        5470 :             ::editeng::ConvertBorderStyleFromWord(nIdx));
    1334             : 
    1335        5470 :     ::editeng::SvxBorderLine aLine;
    1336        5470 :     aLine.SetBorderLineStyle( eStyle );
    1337             :     double const fConverted( (table::BorderLineStyle::NONE == eStyle) ? 0.0 :
    1338        5470 :         ::editeng::ConvertBorderWidthFromWord(eStyle, nLineThickness, nIdx));
    1339        5470 :     aLine.SetWidth(fConverted);
    1340             : 
    1341             :     //No AUTO for borders as yet, so if AUTO, use BLACK
    1342        5470 :     ColorData col = (cv==0xff000000) ? COL_BLACK : msfilter::util::BGRToRGB(cv);
    1343             : 
    1344        5470 :     aLine.SetColor(col);
    1345             : 
    1346        5470 :     if (pSize)
    1347         392 :         pSize[nWWIndex] = fConverted + nSpace;
    1348             : 
    1349        5470 :     rBox.SetLine(&aLine, nOOIndex);
    1350        5470 :     rBox.SetDistance(nSpace, nOOIndex);
    1351             : 
    1352        5470 : }
    1353             : 
    1354        5470 : void Set1Border(SvxBoxItem &rBox, const WW8_BRCVer9& rBor, sal_uInt16 nOOIndex,
    1355             :     sal_uInt16 nWWIndex, short *pSize, const bool bIgnoreSpace)
    1356             : {
    1357             :     short nSpace;
    1358        5470 :     short nLineThickness = rBor.DetermineBorderProperties(&nSpace);
    1359             : 
    1360             :     GetLineIndex(rBox, nLineThickness, bIgnoreSpace ? 0 : nSpace,
    1361        5470 :         rBor.cv(), rBor.brcType(), nOOIndex, nWWIndex, pSize );
    1362             : 
    1363        5470 : }
    1364             : 
    1365        2564 : static bool lcl_IsBorder(const WW8_BRCVer9* pbrc, bool bChkBtwn = false)
    1366             : {
    1367        3700 :     return pbrc[WW8_TOP  ].brcType() ||         // brcType  != 0
    1368        2164 :            pbrc[WW8_LEFT ].brcType() ||
    1369        1870 :            pbrc[WW8_BOT  ].brcType() ||
    1370        5970 :            pbrc[WW8_RIGHT].brcType() ||
    1371        2570 :            (bChkBtwn && pbrc[WW8_BETW ].brcType());
    1372             : }
    1373             : 
    1374        2560 : bool SwWW8ImplReader::IsBorder(const WW8_BRCVer9* pbrc, bool bChkBtwn) const
    1375             : {
    1376        2560 :     return lcl_IsBorder(pbrc, bChkBtwn);
    1377             : }
    1378             : 
    1379        1728 : bool SwWW8ImplReader::SetBorder(SvxBoxItem& rBox, const WW8_BRCVer9* pbrc,
    1380             :     short *pSizeArray, sal_uInt8 nSetBorders) const
    1381             : {
    1382        1728 :     bool bChange = false;
    1383             :     static const sal_uInt16 aIdArr[ 10 ] =
    1384             :     {
    1385             :         WW8_TOP,    BOX_LINE_TOP,
    1386             :         WW8_LEFT,   BOX_LINE_LEFT,
    1387             :         WW8_RIGHT,  BOX_LINE_RIGHT,
    1388             :         WW8_BOT,    BOX_LINE_BOTTOM,
    1389             :         WW8_BETW,   BOX_LINE_BOTTOM
    1390             :     };
    1391             : 
    1392        8640 :     for( int i = 0, nEnd = 8; i < nEnd; i += 2 )
    1393             :     {
    1394             :         // ungueltige Borders ausfiltern
    1395        6912 :         const WW8_BRCVer9& rB = pbrc[ aIdArr[ i ] ];
    1396        6912 :         if( !rB.isNil() && rB.brcType() )
    1397             :         {
    1398        5310 :             Set1Border(rBox, rB, aIdArr[i+1], aIdArr[i], pSizeArray, false);
    1399        5310 :             bChange = true;
    1400             :         }
    1401        1602 :         else if ( nSetBorders & (1 << aIdArr[i]) )
    1402             :         {
    1403             :             /*
    1404             :             ##826##, ##653##
    1405             : 
    1406             :             If a style has borders set,and the para attributes attempt remove
    1407             :             the borders, then this is perfectably acceptable, so we shouldn't
    1408             :             ignore this blank entry
    1409             : 
    1410             :             nSetBorders has a bit set for each location that a sprm set a
    1411             :             border, so with a sprm set, but no border, then disable the
    1412             :             appropriate border
    1413             :             */
    1414        1424 :             rBox.SetLine( 0, aIdArr[ i+1 ] );
    1415             :         }
    1416             :     }
    1417        1728 :     return bChange;
    1418             : }
    1419             : 
    1420         192 : bool SwWW8ImplReader::SetShadow(SvxShadowItem& rShadow, const short *pSizeArray,
    1421             :     const WW8_BRCVer9& aRightBrc) const
    1422             : {
    1423         192 :     bool bRet = aRightBrc.fShadow() && pSizeArray && pSizeArray[WW8_RIGHT];
    1424         192 :     if (bRet)
    1425             :     {
    1426          24 :         rShadow.SetColor(Color(COL_BLACK));
    1427             :     //i120718
    1428          24 :         short nVal = aRightBrc.DetermineBorderProperties();
    1429             :     //End
    1430          24 :         if (nVal < 0x10)
    1431           0 :             nVal = 0x10;
    1432          24 :         rShadow.SetWidth(nVal);
    1433          24 :         rShadow.SetLocation(SVX_SHADOW_BOTTOMRIGHT);
    1434          24 :         bRet = true;
    1435             :     }
    1436         192 :     return bRet;
    1437             : }
    1438             : 
    1439         136 : void SwWW8ImplReader::GetBorderDistance(const WW8_BRCVer9* pbrc,
    1440             :     Rectangle& rInnerDist) const
    1441             : {
    1442         136 :     rInnerDist = Rectangle( pbrc[ 1 ].dptSpace() * 20,
    1443         136 :                             pbrc[ 0 ].dptSpace() * 20,
    1444         136 :                             pbrc[ 3 ].dptSpace() * 20,
    1445         544 :                             pbrc[ 2 ].dptSpace() * 20 );
    1446         136 : }
    1447             : 
    1448          84 : bool SwWW8ImplReader::SetFlyBordersShadow(SfxItemSet& rFlySet,
    1449             :     const WW8_BRCVer9 *pbrc, short *pSizeArray) const
    1450             : {
    1451          84 :     bool bShadowed = false;
    1452          84 :     if (IsBorder(pbrc))
    1453             :     {
    1454          16 :         SvxBoxItem aBox( RES_BOX );
    1455          16 :         SetBorder(aBox, pbrc, pSizeArray);
    1456             : 
    1457          16 :         rFlySet.Put( aBox );
    1458             : 
    1459             :         // fShadow
    1460          32 :         SvxShadowItem aShadow( RES_SHADOW );
    1461          16 :         if( SetShadow( aShadow, pSizeArray, pbrc[WW8_RIGHT] ))
    1462             :         {
    1463           0 :             bShadowed = true;
    1464           0 :             rFlySet.Put( aShadow );
    1465          16 :         }
    1466             :     }
    1467          84 :     return bShadowed;
    1468             : }
    1469             : 
    1470             : //              APOs
    1471             : 
    1472             :                             // fuer Berechnung der minimalen FrameSize
    1473             : #define MAX_BORDER_SIZE 210         // so breit ist max. der Border
    1474             : #define MAX_EMPTY_BORDER 10         // fuer +-1-Fehler, mindestens 1
    1475             : 
    1476          48 : static void FlySecur1(short& rSize, const bool bBorder)
    1477             : {
    1478             :     short nMin = MINFLY +
    1479          48 :         (bBorder ? MAX_BORDER_SIZE : MAX_EMPTY_BORDER);
    1480             : 
    1481          48 :     if ( rSize < nMin )
    1482          22 :         rSize = nMin;
    1483          48 : }
    1484             : 
    1485        1984 : inline bool SetValSprm( sal_Int16* pVar, WW8PLCFx_Cp_FKP* pPap, sal_uInt16 nId )
    1486             : {
    1487        1984 :     const sal_uInt8* pS = pPap->HasSprm( nId );
    1488        1984 :     if( pS )
    1489         710 :         *pVar = (sal_Int16)SVBT16ToShort( pS );
    1490        1984 :     return ( pS != 0 );
    1491             : }
    1492             : 
    1493          64 : inline bool SetValSprm( sal_Int16* pVar, const WW8RStyle* pStyle, sal_uInt16 nId )
    1494             : {
    1495          64 :     const sal_uInt8* pS = pStyle->HasParaSprm( nId );
    1496          64 :     if( pS )
    1497          44 :         *pVar = (sal_Int16)SVBT16ToShort( pS );
    1498          64 :     return ( pS != 0 );
    1499             : }
    1500             : 
    1501             : /*
    1502             : #i1930 revealed that sprm 0x360D as used in tables can affect the frame
    1503             : around the table. Its full structure is not fully understood as yet.
    1504             : */
    1505         286 : void WW8FlyPara::ApplyTabPos(const WW8_TablePos *pTabPos)
    1506             : {
    1507         286 :     if (pTabPos)
    1508             :     {
    1509         262 :         nSp26 = pTabPos->nSp26;
    1510         262 :         nSp27 = pTabPos->nSp27;
    1511         262 :         nSp29 = pTabPos->nSp29;
    1512         262 :         nLeMgn = pTabPos->nLeMgn;
    1513         262 :         nRiMgn = pTabPos->nRiMgn;
    1514         262 :         nUpMgn = pTabPos->nUpMgn;
    1515         262 :         nLoMgn = pTabPos->nLoMgn;
    1516         262 :         nSp37 = pTabPos->nSp37;
    1517             :     }
    1518         286 : }
    1519             : 
    1520         554 : WW8FlyPara::WW8FlyPara(bool bIsVer67, const WW8FlyPara* pSrc /* = 0 */)
    1521             : {
    1522         554 :     if ( pSrc )
    1523          12 :         memcpy( this, pSrc, sizeof( WW8FlyPara ) ); // Copy-Ctor
    1524             :     else
    1525             :     {
    1526         542 :         memset( this, 0, sizeof( WW8FlyPara ) );    // Default-Ctor
    1527         542 :         nSp37 = 2;                                  // Default: Umfluss
    1528             :     }
    1529         554 :     bVer67 = bIsVer67;
    1530         554 : }
    1531             : 
    1532         294 : bool WW8FlyPara::operator==(const WW8FlyPara& rSrc) const
    1533             : {
    1534             :     /*
    1535             :      Compare the parts that word seems to compare for equivalence.
    1536             :      Interestingly being autoheight or absolute height (the & 0x7fff) doesn't
    1537             :      matter to word
    1538             :     */
    1539             :     return
    1540             :        (
    1541         536 :          (nSp26 == rSrc.nSp26) &&
    1542         276 :          (nSp27 == rSrc.nSp27) &&
    1543          68 :          ((nSp45 & 0x7fff) == (rSrc.nSp45 & 0x7fff)) &&
    1544          68 :          (nSp28 == rSrc.nSp28) &&
    1545          68 :          (nLeMgn == rSrc.nLeMgn) &&
    1546          68 :          (nRiMgn == rSrc.nRiMgn) &&
    1547          68 :          (nUpMgn == rSrc.nUpMgn) &&
    1548          68 :          (nLoMgn == rSrc.nLoMgn) &&
    1549         362 :          (nSp29 == rSrc.nSp29) &&
    1550          34 :          (nSp37 == rSrc.nSp37)
    1551         294 :        );
    1552             : }
    1553             : 
    1554             : // Read fuer normalen Text
    1555         248 : void WW8FlyPara::Read(sal_uInt8 nOrigSp29, WW8PLCFx_Cp_FKP* pPap)
    1556             : {
    1557         248 :     const sal_uInt8* pS = 0;
    1558         248 :     if( bVer67 )
    1559             :     {
    1560           0 :         SetValSprm( &nSp26, pPap, 26 ); // X-Position   //sprmPDxaAbs
    1561             :         //set in me or in parent style
    1562           0 :         mbVertSet |= SetValSprm( &nSp27, pPap, 27 );    // Y-Position   //sprmPDyaAbs
    1563           0 :         SetValSprm( &nSp45, pPap, 45 ); // Hoehe        //sprmPWHeightAbs
    1564           0 :         SetValSprm( &nSp28, pPap, 28 ); // Breite       //sprmPDxaWidth
    1565           0 :         SetValSprm( &nLeMgn, pPap, 49 ); // L-Raender   //sprmPDxaFromText
    1566           0 :         SetValSprm( &nRiMgn, pPap, 49 ); // R-Raender   //sprmPDxaFromText
    1567           0 :         SetValSprm( &nUpMgn, pPap, 48 ); // U-Raender   //sprmPDyaFromText
    1568           0 :         SetValSprm( &nLoMgn, pPap, 48 ); // D-Raender   //sprmPDyaFromText
    1569             : 
    1570           0 :         pS = pPap->HasSprm( 37 );                       //sprmPWr
    1571           0 :         if( pS )
    1572           0 :             nSp37 = *pS;
    1573             :     }
    1574             :     else
    1575             :     {
    1576         248 :         SetValSprm( &nSp26, pPap, NS_sprm::LN_PDxaAbs ); // X-Position
    1577             :         //set in me or in parent style
    1578         248 :         mbVertSet |= SetValSprm( &nSp27, pPap, NS_sprm::LN_PDyaAbs );    // Y-Position
    1579         248 :         SetValSprm( &nSp45, pPap, NS_sprm::LN_PWHeightAbs ); // Hoehe
    1580         248 :         SetValSprm( &nSp28, pPap, NS_sprm::LN_PDxaWidth ); // Breite
    1581         248 :         SetValSprm( &nLeMgn, pPap, NS_sprm::LN_PDxaFromText );    // L-Raender
    1582         248 :         SetValSprm( &nRiMgn, pPap, NS_sprm::LN_PDxaFromText );    // R-Raender
    1583         248 :         SetValSprm( &nUpMgn, pPap, NS_sprm::LN_PDyaFromText );    // U-Raender
    1584         248 :         SetValSprm( &nLoMgn, pPap, NS_sprm::LN_PDyaFromText );    // D-Raender
    1585             : 
    1586         248 :         pS = pPap->HasSprm( NS_sprm::LN_PWr );                               // Umfluss
    1587         248 :         if( pS )
    1588         232 :             nSp37 = *pS;
    1589             :     }
    1590             : 
    1591         248 :     if( ::lcl_ReadBorders( bVer67, brc, pPap ))     // Umrandung
    1592           4 :         bBorderLines = ::lcl_IsBorder( brc );
    1593             : 
    1594             :     /*
    1595             :      #i8798#
    1596             :      Appears that with no dyaAbs set then the actual vert anchoring set is
    1597             :      ignored and we remain relative to text, so if that is the case we are 0
    1598             :      from para anchor, so we update the frame to have explicitly this type of
    1599             :      anchoring
    1600             :     */
    1601         248 :     if (!mbVertSet)
    1602           0 :         nSp29 = (nOrigSp29 & 0xCF) | 0x20;
    1603             :     else
    1604         248 :         nSp29 = nOrigSp29;
    1605         248 : }
    1606             : 
    1607         214 : void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
    1608             : {
    1609         214 :     WW8PLCFMan* pPlcxMan = pIo->pPlcxMan;
    1610         214 :     WW8PLCFx_Cp_FKP* pPap = pPlcxMan->GetPapPLCF();
    1611             : 
    1612         214 :     Read(nOrigSp29, pPap);    // Lies Apo-Parameter
    1613             : 
    1614             :     do{             // Block zum rausspringen
    1615         214 :         if( nSp45 != 0 /* || nSp28 != 0 */ )
    1616          20 :             break;                      // bGrafApo nur bei Hoehe automatisch
    1617         206 :         if( pIo->pWwFib->fComplex )
    1618           4 :             break;                      // (*pPap)++ geht bei FastSave schief
    1619             :                                         // -> bei FastSave kein Test auf Grafik-APO
    1620         202 :         SvStream* pIoStrm = pIo->pStrm;
    1621         202 :         sal_uLong nPos = pIoStrm->Tell();
    1622             :         WW8PLCFxSave1 aSave;
    1623         202 :         pPlcxMan->GetPap()->Save( aSave );
    1624         202 :         bGrafApo = false;
    1625             : 
    1626             :         do{             // Block zum rausspringen
    1627             :             sal_uInt8 nTxt[2];
    1628             : 
    1629         202 :             if (!checkRead(*pIoStrm, nTxt, 2)) // lies Text
    1630         202 :                 break;
    1631             : 
    1632         202 :             if( nTxt[0] != 0x01 || nTxt[1] != 0x0d )// nur Grafik + CR ?
    1633             :                 break;                              // Nein
    1634             : 
    1635           0 :             pPap->advance();                        // Naechste Zeile
    1636             : 
    1637             :             // In APO ?
    1638             :             //sprmPPc
    1639           0 :             const sal_uInt8* pS = pPap->HasSprm( bVer67 ? 29 : 0x261B );
    1640             : 
    1641             :             // Nein -> Grafik-Apo
    1642           0 :             if (!pS)
    1643             :             {
    1644           0 :                 bGrafApo = true;
    1645           0 :                 break;                              // Ende des APO
    1646             :             }
    1647             : 
    1648           0 :             ww::WordVersion eVer = pIo->GetFib().GetFIBVersion();
    1649           0 :             WW8FlyPara *pNowStyleApo=0;
    1650           0 :             sal_uInt16 nColl = pPap->GetIstd();
    1651           0 :             ww::sti eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
    1652           0 :             while (eSti != ww::stiNil && nColl < pIo->vColl.size() && 0 == (pNowStyleApo = pIo->vColl[nColl].pWWFly))
    1653             :             {
    1654           0 :                 nColl = pIo->vColl[nColl].nBase;
    1655           0 :                 eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
    1656             :             }
    1657             : 
    1658           0 :             WW8FlyPara aF(bVer67, pNowStyleApo);
    1659             :                                                 // Neuer FlaPara zum Vergleich
    1660           0 :             aF.Read( *pS, pPap );               // WWPara fuer neuen Para
    1661           0 :             if( !( aF == *this ) )              // selber APO ? ( oder neuer ? )
    1662           0 :                 bGrafApo = true;                // nein -> 1-zeiliger APO
    1663             :                                                 //      -> Grafik-APO
    1664             :         }
    1665             :         while( false );                             // Block zum rausspringen
    1666             : 
    1667         202 :         pPlcxMan->GetPap()->Restore( aSave );
    1668         202 :         pIoStrm->Seek( nPos );
    1669             :     }while( false );                                    // Block zum rausspringen
    1670         214 : }
    1671             : 
    1672             : // Read fuer Apo-Defs in Styledefs
    1673           8 : void WW8FlyPara::Read(sal_uInt8 nOrigSp29, WW8RStyle* pStyle)
    1674             : {
    1675           8 :     const sal_uInt8* pS = 0;
    1676           8 :     if (bVer67)
    1677             :     {
    1678           0 :         SetValSprm( &nSp26, pStyle, 26 );   // X-Position
    1679             :         //set in me or in parent style
    1680           0 :         mbVertSet |= SetValSprm(&nSp27, pStyle, 27);    // Y-Position
    1681           0 :         SetValSprm( &nSp45, pStyle, 45 );   // Hoehe
    1682           0 :         SetValSprm( &nSp28, pStyle, 28 );   // Breite
    1683           0 :         SetValSprm( &nLeMgn,    pStyle, 49 );   // L-Raender
    1684           0 :         SetValSprm( &nRiMgn,    pStyle, 49 );   // R-Raender
    1685           0 :         SetValSprm( &nUpMgn,    pStyle, 48 );   // U-Raender
    1686           0 :         SetValSprm( &nLoMgn,    pStyle, 48 );   // D-Raender
    1687             : 
    1688           0 :         pS = pStyle->HasParaSprm( 37 );             // Umfluss
    1689           0 :         if( pS )
    1690           0 :             nSp37 = *pS;
    1691             :     }
    1692             :     else
    1693             :     {
    1694           8 :         SetValSprm( &nSp26, pStyle, 0x8418 );   // X-Position
    1695             :         //set in me or in parent style
    1696           8 :         mbVertSet |= SetValSprm(&nSp27, pStyle, 0x8419);    // Y-Position
    1697           8 :         SetValSprm( &nSp45, pStyle, 0x442B );   // Hoehe
    1698           8 :         SetValSprm( &nSp28, pStyle, 0x841A );   // Breite
    1699           8 :         SetValSprm( &nLeMgn, pStyle, 0x842F );  // L-Raender
    1700           8 :         SetValSprm( &nRiMgn, pStyle, 0x842F );  // R-Raender
    1701           8 :         SetValSprm( &nUpMgn, pStyle, 0x842E );  // U-Raender
    1702           8 :         SetValSprm( &nLoMgn, pStyle, 0x842E );  // D-Raender
    1703             : 
    1704           8 :         pS = pStyle->HasParaSprm( 0x2423 );             // Umfluss
    1705           8 :         if( pS )
    1706           2 :             nSp37 = *pS;
    1707             :     }
    1708             : 
    1709           8 :     if (::lcl_ReadBorders(bVer67, brc, 0, pStyle))      // Umrandung
    1710           0 :         bBorderLines = ::lcl_IsBorder(brc);
    1711             : 
    1712             :     /*
    1713             :      #i8798#
    1714             :      Appears that with no dyaAbs set then the actual vert anchoring set is
    1715             :      ignored and we remain relative to text, so if that is the case we are 0
    1716             :      from para anchor, so we update the frame to have explicitly this type of
    1717             :      anchoring
    1718             :     */
    1719           8 :     if (!mbVertSet)
    1720           0 :         nSp29 = (nOrigSp29 & 0xCF) | 0x20;
    1721             :     else
    1722           8 :         nSp29 = nOrigSp29;
    1723           8 : }
    1724             : 
    1725         260 : bool WW8FlyPara::IsEmpty() const
    1726             : {
    1727         260 :     WW8FlyPara aEmpty(bVer67);
    1728             :     /*
    1729             :      wr of 0 like 2 appears to me to be equivalent for checking here. See
    1730             :      #107103# if wrong, so given that the empty is 2, if we are 0 then set
    1731             :      empty to 0 to make 0 equiv to 2 for empty checking
    1732             :     */
    1733             :     OSL_ENSURE(aEmpty.nSp37 == 2, "this is not what we expect for nSp37");
    1734         260 :     if (this->nSp37 == 0)
    1735           0 :         aEmpty.nSp37 = 0;
    1736         260 :     if (aEmpty == *this)
    1737           0 :         return true;
    1738         260 :     return false;
    1739             : }
    1740             : 
    1741             : // #i18732# - changes made on behalf of CMC
    1742          24 : WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
    1743             :                             SwWW8ImplReader& rIo,
    1744             :                             WW8FlyPara& rWW,
    1745             :                             const sal_uInt32 nWWPgTop,
    1746             :                             const sal_uInt32 nPgLeft,
    1747             :                             const sal_uInt32 nPgWidth,
    1748             :                             const sal_Int32 nIniFlyDx,
    1749             :                             const sal_Int32 nIniFlyDy )
    1750             : {
    1751             :     (void) nPgLeft;
    1752             : 
    1753          24 :     memset( this, 0, sizeof( WW8SwFlyPara ) );  // Initialisieren
    1754          24 :     nNewNetWidth = MINFLY;                    // Minimum
    1755             : 
    1756          24 :     eSurround = ( rWW.nSp37 > 1 ) ? SURROUND_IDEAL : SURROUND_NONE;
    1757             :     //#i119466 mapping "Around" wrap setting to "Parallel" for table
    1758          24 :     const bool bIsTable = rIo.pPlcxMan->HasParaSprm(0x2416);
    1759          24 :     if (  bIsTable && rWW.nSp37 == 2 )
    1760          16 :         eSurround = SURROUND_PARALLEL;
    1761             : 
    1762             :     /*
    1763             :      #95905#, #83307# seems to have gone away now, so reenable parallel
    1764             :      wrapping support for frames in headers/footers. I don't know if we truly
    1765             :      have an explicitly specified behaviour for these circumstances.
    1766             :     */
    1767             : 
    1768          24 :     nHeight = rWW.nSp45;
    1769          24 :     if( nHeight & 0x8000 )
    1770             :     {
    1771           0 :         nHeight &= 0x7fff;
    1772           0 :         eHeightFix = ATT_MIN_SIZE;
    1773             :     }
    1774             :     else
    1775          24 :         eHeightFix = ATT_FIX_SIZE;
    1776             : 
    1777          24 :     if( nHeight <= MINFLY )
    1778             :     {                           // keine Angabe oder Stuss
    1779          22 :         eHeightFix = ATT_MIN_SIZE;
    1780          22 :         nHeight = MINFLY;
    1781             :     }
    1782             : 
    1783          24 :     nWidth = nNetWidth = rWW.nSp28;
    1784          24 :     if( nWidth <= 10 )                              // Auto-Breite
    1785             :     {
    1786          22 :         bAutoWidth = true;
    1787             :         nWidth = nNetWidth =
    1788          22 :             msword_cast<sal_Int16>((nPgWidth ? nPgWidth : 2268)); // 4 cm
    1789             :     }
    1790          24 :     if( nWidth <= MINFLY )
    1791           0 :         nWidth = nNetWidth = MINFLY;              // Minimale Breite
    1792             : 
    1793          24 :     eVAlign = text::VertOrientation::NONE;                            // Defaults
    1794          24 :     eHAlign = text::HoriOrientation::NONE;
    1795          24 :     nYPos = 0;
    1796          24 :     nXPos = 0;
    1797             : 
    1798          24 :     nRiMgn = rWW.nRiMgn;
    1799          24 :     nLeMgn = rWW.nLeMgn;
    1800          24 :     nLoMgn = rWW.nLoMgn;
    1801          24 :     nUpMgn = rWW.nUpMgn;
    1802             : 
    1803             :     /*
    1804             :     See issue #i9178# for the 9 anchoring options, and make sure they stay
    1805             :     working if you modify the anchoring logic here.
    1806             :     */
    1807             : 
    1808             :     // Wenn der Fly links, rechts, oben oder unten aligned ist,
    1809             :     // wird der aeussere Textabstand ignoriert, da sonst
    1810             :     // der Fly an falscher Position landen wuerde
    1811             :     // Problematisch wird es nur bei Innen/Aussen
    1812             : 
    1813             :     // Bindung
    1814          24 :     nYBind = (( rWW.nSp29 & 0x30 ) >> 4);
    1815             :     //#i53725# - absolute positioned objects have to be
    1816             :     // anchored at-paragraph to assure its correct anchor position.
    1817          24 :     eAnchor = FLY_AT_PARA;
    1818          24 :     rIo.mpLastAnchorPos.reset( new SwPosition(*rPaM.GetPoint()));
    1819             : 
    1820          24 :     switch (nYBind)
    1821             :     {
    1822             :         case 0:     //relative to margin
    1823           2 :             eVRel = text::RelOrientation::PAGE_PRINT_AREA;
    1824           2 :             break;
    1825             :         case 1:     //relative to page
    1826           2 :             eVRel = text::RelOrientation::PAGE_FRAME;
    1827           2 :             break;
    1828             :         default:    //relative to text
    1829          20 :             eVRel = text::RelOrientation::FRAME;
    1830          20 :             break;
    1831             :     }
    1832             : 
    1833             : // #i18732#
    1834          24 :     switch( rWW.nSp27 )             // besondere Y-Positionen ?
    1835             :     {
    1836             :         case -4:
    1837           0 :             eVAlign = text::VertOrientation::TOP;
    1838           0 :             if (nYBind < 2)
    1839           0 :                 nUpMgn = 0;
    1840           0 :             break;  // oben
    1841             :         case -8:
    1842           2 :             eVAlign = text::VertOrientation::CENTER;
    1843           2 :             break;  // zentriert
    1844             :         case -12:
    1845           2 :             eVAlign = text::VertOrientation::BOTTOM;
    1846           2 :             if (nYBind < 2)
    1847           2 :                 nLoMgn = 0;
    1848           2 :             break;  // unten
    1849             :         default:
    1850          20 :             nYPos = rWW.nSp27 + (short)nIniFlyDy;
    1851          20 :             break;  // Korrekturen per Ini-Datei
    1852             :     }
    1853             : 
    1854          24 :     switch( rWW.nSp26 )                 // besondere X-Positionen ?
    1855             :     {
    1856             :         case 0:
    1857          12 :             eHAlign = text::HoriOrientation::LEFT;
    1858          12 :             nLeMgn = 0;
    1859          12 :             break;  // links
    1860             :         case -4:
    1861          10 :             eHAlign = text::HoriOrientation::CENTER;
    1862          10 :             break;  // zentriert
    1863             :         case -8:
    1864           0 :             eHAlign = text::HoriOrientation::RIGHT;
    1865           0 :             nRiMgn = 0;
    1866           0 :             break;  // rechts
    1867             :         case -12:
    1868           0 :             eHAlign = text::HoriOrientation::LEFT;
    1869           0 :             bToggelPos = true;
    1870           0 :             break;  // innen
    1871             :         case -16:
    1872           0 :             eHAlign = text::HoriOrientation::RIGHT;
    1873           0 :             bToggelPos = true;
    1874           0 :             break;  // aussen
    1875             :         default:
    1876           2 :             nXPos = rWW.nSp26 + (short)nIniFlyDx;
    1877           2 :             break;  // Korrekturen per Ini-Datei
    1878             :     }
    1879             : 
    1880          24 :     nXBind = ( rWW.nSp29 & 0xc0 ) >> 6;
    1881             : // #i18732#
    1882          24 :     switch (nXBind)           // X - Bindung -> Koordinatentransformation
    1883             :     {
    1884             :         case 0:     //relative to column
    1885          10 :             eHRel = text::RelOrientation::FRAME;
    1886          10 :             break;
    1887             :         case 1:     //relative to margin
    1888          12 :             eHRel = text::RelOrientation::PAGE_PRINT_AREA;
    1889          12 :             break;
    1890             :         default:    //relative to page
    1891           2 :             eHRel = text::RelOrientation::PAGE_FRAME;
    1892           2 :             break;
    1893             :     }
    1894             : 
    1895             :     // #i36649# - adjustments for certain horizontal alignments
    1896             :     // Note: These special adjustments found by an investigation of documents
    1897             :     //       containing frames with different left/right border distances and
    1898             :     //       distances to text. The outcome is some how strange.
    1899             :     // Note: These adjustments causes wrong horizontal positions for frames,
    1900             :     //       which are aligned inside|outside to page|margin on even pages,
    1901             :     //       the left and right border distances are different.
    1902             :     // no adjustments possible, if frame has automatic width.
    1903             :     // determine left border distance
    1904          24 :     sal_Int16 nLeBorderMgn( 0L );
    1905          24 :     if ( !bAutoWidth )
    1906             :     {
    1907           2 :         WW8_BRCVer9 &rBrc = rWW.brc[WW8_LEFT];
    1908           2 :         sal_Int16 nTemp = rBrc.DetermineBorderProperties(&nLeBorderMgn);
    1909           2 :         nLeBorderMgn = nLeBorderMgn + nTemp;
    1910             :     }
    1911             :     // determine right border distance
    1912          24 :     sal_Int16 nRiBorderMgn( 0L );
    1913          24 :     if ( !bAutoWidth )
    1914             :     {
    1915           2 :         WW8_BRCVer9 &rBrc = rWW.brc[WW8_RIGHT];
    1916           2 :         sal_Int16 nTemp = rBrc.DetermineBorderProperties(&nRiBorderMgn);
    1917           2 :         nRiBorderMgn = nRiBorderMgn + nTemp;
    1918             :     }
    1919          24 :     if ( !bAutoWidth && eHAlign == text::HoriOrientation::LEFT && eHRel == text::RelOrientation::PAGE_FRAME )
    1920             :     {
    1921             :         // convert 'left to page' to
    1922             :         // 'from left -<width>-<2*left border distance>-<right wrap distance>
    1923             :         // to page text area'
    1924           0 :         eHAlign = text::HoriOrientation::NONE;
    1925           0 :         eHRel = text::RelOrientation::PAGE_PRINT_AREA;
    1926           0 :         nXPos = -nWidth - (2*nLeBorderMgn) - rWW.nRiMgn;
    1927             :         // re-set left wrap distance
    1928           0 :         nLeMgn = rWW.nLeMgn;
    1929             :     }
    1930          24 :     else if ( !bAutoWidth && eHAlign == text::HoriOrientation::RIGHT && eHRel == text::RelOrientation::PAGE_FRAME )
    1931             :     {
    1932             :         // convert 'right to page' to
    1933             :         // 'from left <right border distance-left border distance>+<left wrap distance>
    1934             :         // to right page border'
    1935           0 :         eHAlign = text::HoriOrientation::NONE;
    1936           0 :         eHRel = text::RelOrientation::PAGE_RIGHT;
    1937           0 :         nXPos = ( nRiBorderMgn - nLeBorderMgn ) + rWW.nLeMgn;
    1938             :         // re-set right wrap distance
    1939           0 :         nRiMgn = rWW.nRiMgn;
    1940             :     }
    1941          24 :     else if ( !bAutoWidth && eHAlign == text::HoriOrientation::LEFT && eHRel == text::RelOrientation::PAGE_PRINT_AREA )
    1942             :     {
    1943             :         // convert 'left to margin' to
    1944             :         // 'from left -<left border distance> to page text area'
    1945           0 :         eHAlign = text::HoriOrientation::NONE;
    1946           0 :         eHRel = text::RelOrientation::PAGE_PRINT_AREA;
    1947           0 :         nXPos = -nLeBorderMgn;
    1948             :         // re-set left wrap distance
    1949           0 :         nLeMgn = rWW.nLeMgn;
    1950             :     }
    1951          24 :     else if ( !bAutoWidth && eHAlign == text::HoriOrientation::RIGHT && eHRel == text::RelOrientation::PAGE_PRINT_AREA )
    1952             :     {
    1953             :         // convert 'right to margin' to
    1954             :         // 'from left -<width>-<left border distance> to right page border'
    1955           0 :         eHAlign = text::HoriOrientation::NONE;
    1956           0 :         eHRel = text::RelOrientation::PAGE_RIGHT;
    1957           0 :         nXPos = -nWidth - nLeBorderMgn;
    1958             :         // re-set right wrap distance
    1959           0 :         nRiMgn = rWW.nRiMgn;
    1960             :     }
    1961          24 :     else if (rWW.bBorderLines)
    1962             :     {
    1963             :         /*
    1964             :         #i582#
    1965             :         Word has a curious bug where the offset stored do not take into
    1966             :         account the internal distance from the corner both
    1967             :         */
    1968           0 :         WW8_BRCVer9 &rBrc = rWW.brc[WW8_LEFT];
    1969           0 :         sal_Int16 nLeLMgn = 0;
    1970           0 :         sal_Int16 nTemp = rBrc.DetermineBorderProperties(&nLeLMgn);
    1971           0 :         nLeLMgn = nLeLMgn + nTemp;
    1972             : 
    1973           0 :         if (nLeLMgn)
    1974             :         {
    1975           0 :             if (eHAlign == text::HoriOrientation::LEFT)
    1976           0 :                 eHAlign = text::HoriOrientation::NONE;
    1977           0 :             nXPos = nXPos - nLeLMgn;
    1978             :         }
    1979             :     }
    1980             : 
    1981             :     // adjustments for certain vertical alignments
    1982          24 :     if ( eVAlign == text::VertOrientation::NONE && eVRel == text::RelOrientation::PAGE_PRINT_AREA )
    1983             :     {
    1984             :         // convert "<X> from top page text area" to
    1985             :         // "<X + page top margin> from page"
    1986           0 :         eVRel = text::RelOrientation::PAGE_FRAME;
    1987           0 :         nYPos = static_cast< sal_Int16 >( nYPos + nWWPgTop );
    1988             :     }
    1989             : 
    1990          24 :     FlySecur1( nWidth, rWW.bBorderLines );          // passen Raender ?
    1991          24 :     FlySecur1( nHeight, rWW.bBorderLines );
    1992             : 
    1993          24 : }
    1994             : 
    1995             : // hat ein Fly in WW eine automatische Breite, dann muss das durch
    1996             : // nachtraegliches Anpassen der ( im SW festen ) Fly-Breite simuliert werden.
    1997             : // Dabei kann die Fly-Breite groesser oder kleiner werden, da der Default-Wert
    1998             : // ohne Wissen ueber den Inhalt eingesetzt wird.
    1999           6 : void WW8SwFlyPara::BoxUpWidth( long nInWidth )
    2000             : {
    2001           6 :     if( bAutoWidth && nInWidth > nNewNetWidth )
    2002           6 :         nNewNetWidth = nInWidth;
    2003           6 : };
    2004             : 
    2005             : // Die Klasse WW8FlySet ist von SfxItemSet abgeleitet und stellt auch
    2006             : // im Prizip nicht mehr zur Verfuegung, ist aber fuer mich besser
    2007             : // zu handeln
    2008             : // WW8FlySet-ctor fuer Apos und Graf-Apos
    2009          24 : WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
    2010             :     const WW8SwFlyPara* pFS, bool bGraf)
    2011          24 :     : SfxItemSet(rReader.rDoc.GetAttrPool(),RES_FRMATR_BEGIN,RES_FRMATR_END-1)
    2012             : {
    2013          24 :     if (!rReader.mbNewDoc)
    2014           0 :         Reader::ResetFrmFmtAttrs(*this);    // Abstand/Umrandung raus
    2015             :                                             // Position
    2016          24 :     Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR));
    2017             : 
    2018             : /*Below can all go when we have from left in rtl mode*/
    2019          24 :     SwTwips nXPos = pFS->nXPos;
    2020          24 :     sal_Int16 eHRel = pFS->eHRel;
    2021          24 :     rReader.MiserableRTLGraphicsHack(nXPos, pFS->nWidth, pFS->eHAlign, eHRel);
    2022             : /*Above can all go when we have from left in rtl mode*/
    2023          24 :     Put( SwFmtHoriOrient(nXPos, pFS->eHAlign, pFS->eHRel, pFS->bToggelPos ));
    2024          24 :     Put( SwFmtVertOrient( pFS->nYPos, pFS->eVAlign, pFS->eVRel ) );
    2025             : 
    2026          24 :     if (pFS->nLeMgn || pFS->nRiMgn)     // Raender setzen
    2027          18 :         Put(SvxLRSpaceItem(pFS->nLeMgn, pFS->nRiMgn, 0, 0, RES_LR_SPACE));
    2028             : 
    2029          24 :     if (pFS->nUpMgn || pFS->nLoMgn)
    2030           0 :         Put(SvxULSpaceItem(pFS->nUpMgn, pFS->nLoMgn, RES_UL_SPACE));
    2031             : 
    2032             :     //we no longer need to hack around the header/footer problems
    2033          24 :     SwFmtSurround aSurround(pFS->eSurround);
    2034          24 :     if ( pFS->eSurround == SURROUND_IDEAL )
    2035           8 :         aSurround.SetAnchorOnly( true );
    2036          24 :     Put( aSurround );
    2037             : 
    2038          24 :     short aSizeArray[5]={0};
    2039          24 :     rReader.SetFlyBordersShadow(*this,pFW->brc,&aSizeArray[0]);
    2040             : 
    2041             :     // der 5. Parameter ist immer 0, daher geht beim Cast nix verloren
    2042             : 
    2043             :     // #i27767#
    2044             :     // #i35017# - constant name has changed
    2045             :     Put( SwFmtWrapInfluenceOnObjPos(
    2046          24 :                 text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ) );
    2047             : 
    2048          24 :     if( !bGraf )
    2049             :     {
    2050          24 :         Put( SwFmtAnchor(pFS->eAnchor) );
    2051             :         // Groesse einstellen
    2052             : 
    2053             :         //Ordinarily with frames, the border width and spacing is
    2054             :         //placed outside the frame, making it larger. With these
    2055             :         //types of frames, the left right thickness and space makes
    2056             :         //it wider, but the top bottom spacing and border thickness
    2057             :         //is placed inside.
    2058          48 :         Put( SwFmtFrmSize( pFS->eHeightFix, pFS->nWidth +
    2059          48 :             aSizeArray[WW8_LEFT] + aSizeArray[WW8_RIGHT],
    2060          48 :             pFS->nHeight));
    2061          24 :     }
    2062          24 : }
    2063             : 
    2064             : // WW8FlySet-ctor fuer zeichengebundene Grafiken
    2065          48 : WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM,
    2066             :     const WW8_PIC& rPic, long nWidth, long nHeight )
    2067          48 :     : SfxItemSet(rReader.rDoc.GetAttrPool(),RES_FRMATR_BEGIN,RES_FRMATR_END-1)
    2068             : {
    2069          48 :     Init(rReader, pPaM);
    2070             : 
    2071          48 :     Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR));
    2072             : 
    2073          48 :     short aSizeArray[5]={0};
    2074             :     /*
    2075             :     If we have set borders then in word the graphic is displaced from the left
    2076             :     and top the width of the borders of those sides, and then the shadow
    2077             :     itself is drawn to the bottom and right of the displaced graphic.  In word
    2078             :     the total size is that of the graphic plus the borders, plus the total
    2079             :     shadow around all edges, for this translation the top and left shadow
    2080             :     region is translated spacing around the graphic to those sides, and the
    2081             :     bottom and right shadow size is added to the graphic size.
    2082             :     */
    2083          48 :     WW8_BRCVer9 brcVer9[4];
    2084         240 :     for (int i = 0; i < 4; i++)
    2085         192 :         brcVer9[i] = rPic.rgbrc[i];
    2086          48 :     if (rReader.SetFlyBordersShadow( *this, brcVer9, &aSizeArray[0]))
    2087             :     {
    2088           0 :         Put(SvxLRSpaceItem( aSizeArray[WW8_LEFT], 0, 0, 0, RES_LR_SPACE ) );
    2089           0 :         Put(SvxULSpaceItem( aSizeArray[WW8_TOP], 0, RES_UL_SPACE ));
    2090           0 :         aSizeArray[WW8_RIGHT]*=2;
    2091           0 :         aSizeArray[WW8_BOT]*=2;
    2092             :     }
    2093             : 
    2094          48 :     Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth+aSizeArray[WW8_LEFT]+
    2095          96 :         aSizeArray[WW8_RIGHT], nHeight+aSizeArray[WW8_TOP]
    2096          96 :         + aSizeArray[WW8_BOT]) );
    2097          48 : }
    2098             : 
    2099          48 : void WW8FlySet::Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM)
    2100             : {
    2101          48 :     if (!rReader.mbNewDoc)
    2102           0 :         Reader::ResetFrmFmtAttrs(*this);  // Abstand/Umrandung raus
    2103             : 
    2104          48 :     Put(SvxLRSpaceItem(RES_LR_SPACE)); //inline writer ole2 objects start with 0.2cm l/r
    2105          48 :     SwFmtAnchor aAnchor(FLY_AS_CHAR);
    2106             : 
    2107          48 :     aAnchor.SetAnchor(pPaM->GetPoint());
    2108          48 :     Put(aAnchor);
    2109             : 
    2110             :     //The horizontal default is on the baseline, the vertical is centered
    2111             :     //around the character center it appears
    2112          48 :     if (rReader.maSectionManager.CurrentSectionIsVertical())
    2113           0 :         Put(SwFmtVertOrient(0, text::VertOrientation::CHAR_CENTER,text::RelOrientation::CHAR));
    2114             :     else
    2115          48 :         Put(SwFmtVertOrient(0, text::VertOrientation::TOP, text::RelOrientation::FRAME));
    2116          48 : }
    2117             : 
    2118         332 : WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk)
    2119             :     : pCtrlStck(pStk),
    2120         332 :     aChrSet(rDoc.GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END - 1 ),
    2121         664 :     aParSet(rDoc.GetAttrPool(), RES_PARATR_BEGIN, RES_PARATR_END - 1 )
    2122             : {
    2123             :     //Close any open character properties and duplicate them inside the
    2124             :     //first table cell
    2125         332 :     size_t nCnt = pCtrlStck->size();
    2126        1472 :     for (size_t i=0; i < nCnt; ++i)
    2127             :     {
    2128        1140 :         const SwFltStackEntry& rEntry = (*pCtrlStck)[ i ];
    2129        1140 :         if (rEntry.bOpen)
    2130             :         {
    2131          46 :             if (isCHRATR(rEntry.pAttr->Which()))
    2132             :             {
    2133          46 :                 aChrSet.Put( *rEntry.pAttr );
    2134             : 
    2135             :             }
    2136           0 :             else if (isPARATR(rEntry.pAttr->Which()))
    2137             :             {
    2138           0 :                 aParSet.Put( *rEntry.pAttr );
    2139             :             }
    2140             :         }
    2141             :     }
    2142         332 : }
    2143             : 
    2144         332 : void WW8DupProperties::Insert(const SwPosition &rPos)
    2145             : {
    2146         332 :     const SfxItemSet *pSet=&aChrSet;
    2147         996 :     for(int i=0;i<2;i++)
    2148             :     {
    2149         664 :         if (i==1)
    2150         332 :             pSet = &aParSet;
    2151             : 
    2152         664 :         if( pSet->Count() )
    2153             :         {
    2154          22 :             SfxItemIter aIter( *pSet );
    2155          22 :             const SfxPoolItem* pItem = aIter.GetCurItem();
    2156          46 :             do
    2157             :             {
    2158          46 :                 pCtrlStck->NewAttr(rPos, *pItem);
    2159          68 :             }while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
    2160             :         }
    2161             :     }
    2162         332 : }
    2163             : 
    2164          26 : void SwWW8ImplReader::MoveInsideFly(const SwFrmFmt *pFlyFmt)
    2165             : {
    2166          26 :     WW8DupProperties aDup(rDoc,pCtrlStck);
    2167             : 
    2168          26 :     pCtrlStck->SetAttr(*pPaM->GetPoint(), 0, false);
    2169             : 
    2170             :     // Setze Pam in den FlyFrame
    2171          26 :     const SwFmtCntnt& rCntnt = pFlyFmt->GetCntnt();
    2172             :     OSL_ENSURE( rCntnt.GetCntntIdx(), "Kein Inhalt vorbereitet." );
    2173          26 :     pPaM->GetPoint()->nNode = rCntnt.GetCntntIdx()->GetIndex() + 1;
    2174          26 :     pPaM->GetPoint()->nContent.Assign( pPaM->GetCntntNode(), 0 );
    2175             : 
    2176          26 :     aDup.Insert(*pPaM->GetPoint());
    2177          26 : }
    2178             : 
    2179          36 : SwTwips SwWW8ImplReader::MoveOutsideFly(SwFrmFmt *pFlyFmt,
    2180             :     const SwPosition &rPos, bool bTableJoin)
    2181             : {
    2182          36 :     SwTwips nRetWidth = 0;
    2183          36 :     if (!pFlyFmt)
    2184          10 :         return nRetWidth;
    2185             :     // Alle Attribute schliessen, da sonst Attribute entstehen koennen,
    2186             :     // die aus Flys rausragen
    2187          26 :     WW8DupProperties aDup(rDoc,pCtrlStck);
    2188          26 :     pCtrlStck->SetAttr(*pPaM->GetPoint(), 0, false);
    2189             : 
    2190             :     /*
    2191             :     #i1291
    2192             :     If this fly frame consists entirely of one table inside a frame
    2193             :     followed by an empty paragraph then we want to delete the empty
    2194             :     paragraph so as to get the frame to autoshrink to the size of the
    2195             :     table to emulate words behaviour closer.
    2196             :     */
    2197          26 :     if (bTableJoin)
    2198             :     {
    2199          14 :         const SwNodeIndex* pNodeIndex = pFlyFmt->GetCntnt().
    2200          14 :             GetCntntIdx();
    2201          14 :         if (pNodeIndex)
    2202             :         {
    2203          14 :             SwNodeIndex aIdx( *pNodeIndex, 1 ),
    2204          28 :             aEnd( *pNodeIndex->GetNode().EndOfSectionNode() );
    2205             : 
    2206          14 :             if (aIdx < aEnd)
    2207             :             {
    2208          14 :                 if(aIdx.GetNode().IsTableNode())
    2209             :                 {
    2210           6 :                     SwTableNode *pTable = aIdx.GetNode().GetTableNode();
    2211           6 :                     aIdx = *aIdx.GetNode().EndOfSectionNode();
    2212           6 :                     ++aIdx;
    2213           6 :                     if ( (aIdx < aEnd) && aIdx.GetNode().IsTxtNode() )
    2214             :                     {
    2215           6 :                         SwTxtNode *pNd = aIdx.GetNode().GetTxtNode();
    2216           6 :                         ++aIdx;
    2217           6 :                         if (aIdx == aEnd && pNd && pNd->GetTxt().isEmpty())
    2218             :                         {
    2219             :                             //An extra pre-created by writer unused paragraph
    2220             : 
    2221             :                             //delete after import is complete rather than now
    2222             :                             //to avoid the complication of managing uncommitted
    2223             :                             //ctrlstack properties that refer to it.
    2224           6 :                             m_aExtraneousParas.push_back(pNd);
    2225             : 
    2226           6 :                             SwTable& rTable = pTable->GetTable();
    2227           6 :                             SwFrmFmt* pTblFmt = rTable.GetFrmFmt();
    2228             : 
    2229           6 :                             if (pTblFmt)
    2230             :                             {
    2231           6 :                                 SwFmtFrmSize aSize = pTblFmt->GetFrmSize();
    2232           6 :                                 aSize.SetHeightSizeType(ATT_MIN_SIZE);
    2233           6 :                                 aSize.SetHeight(MINLAY);
    2234           6 :                                 pFlyFmt->SetFmtAttr(aSize);
    2235          12 :                                 SwFmtHoriOrient aHori = pTblFmt->GetHoriOrient();
    2236             :                                 // passing the table orientaion of
    2237             :                                 // LEFT_AND_WIDTH to the frame seems to
    2238             :                                 // work better than FULL, especially if the
    2239             :                                 // table width exceeds the page width, however
    2240             :                                 // I am not brave enough to set it in all
    2241             :                                 // instances
    2242           6 :                                 pTblFmt->SetFmtAttr( SwFmtHoriOrient(0, ( aHori.GetHoriOrient() == text::HoriOrientation::LEFT_AND_WIDTH ) ? ::text::HoriOrientation::LEFT_AND_WIDTH : text::HoriOrientation::FULL ) );
    2243          12 :                                 nRetWidth = aSize.GetWidth();
    2244             :                             }
    2245             :                         }
    2246             :                     }
    2247             :                 }
    2248          14 :             }
    2249             :         }
    2250             :     }
    2251             : 
    2252          26 :     *pPaM->GetPoint() = rPos;
    2253          26 :     aDup.Insert(*pPaM->GetPoint());
    2254          26 :     return nRetWidth;
    2255             : }
    2256             : 
    2257         252 : WW8FlyPara *SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo,
    2258             :     const WW8_TablePos *pTabPos)
    2259             : {
    2260         252 :     WW8FlyPara *pRet = 0;
    2261             :     OSL_ENSURE(rApo.HasFrame() || pTabPos,
    2262             :         "If no frame found, *MUST* be in a table");
    2263             : 
    2264         252 :     pRet = new WW8FlyPara(bVer67, rApo.mpStyleApo);
    2265             : 
    2266             :     // APO-Parameter ermitteln und Test auf bGrafApo
    2267         252 :     if (rApo.HasFrame())
    2268         214 :         pRet->ReadFull(rApo.m_nSprm29, this);
    2269             : 
    2270         252 :     pRet->ApplyTabPos(pTabPos);
    2271             : 
    2272         252 :     if (pRet->IsEmpty())
    2273           0 :         delete pRet, pRet = 0;
    2274         252 :     return pRet;
    2275             : }
    2276             : 
    2277          24 : bool SwWW8ImplReader::IsDropCap()
    2278             : {
    2279             :     // Find the DCS (Drop Cap Specifier) for the paragraph
    2280             :     // if does not exist or if the first three bits are 0
    2281             :     // then there is no dropcap on the paragraph
    2282          24 :     WW8PLCFx_Cp_FKP *pPap = pPlcxMan ? pPlcxMan->GetPapPLCF() : 0;
    2283          24 :     if (pPap)
    2284             :     {
    2285             :         const sal_uInt8 *pDCS;
    2286          24 :         if (bVer67)
    2287           0 :             pDCS = pPap->HasSprm(46);
    2288             :         else
    2289          24 :             pDCS = pPlcxMan->GetPapPLCF()->HasSprm(0x442C);
    2290          24 :         if(pDCS)
    2291             :         {
    2292             :             /*
    2293             :               fdct   short :3   0007     drop cap type
    2294             :                                          0 no drop cap
    2295             :                                          1 normal drop cap
    2296             :                                          2 drop cap in margin
    2297             :             */
    2298           0 :             short nDCS = SVBT16ToShort( pDCS );
    2299           0 :             if (nDCS & 7)
    2300           0 :                 return true;
    2301             :         }
    2302             :     }
    2303          24 :     return false;
    2304             : }
    2305             : 
    2306          24 : bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
    2307             :     const WW8_TablePos *pTabPos,
    2308             :     SvxULSpaceItem* pULSpaceItem)
    2309             : {
    2310          24 :     if (0 == (pWFlyPara = ConstructApo(rApo, pTabPos)))
    2311           0 :         return false;
    2312             : 
    2313             :     // <WW8SwFlyPara> constructor has changed - new 4th parameter
    2314             :     // containing WW8 page top margin.
    2315             :     pSFlyPara = new WW8SwFlyPara( *pPaM, *this, *pWFlyPara,
    2316          24 :                                   maSectionManager.GetWWPageTopMargin(),
    2317          24 :                                   maSectionManager.GetPageLeft(),
    2318          24 :                                   maSectionManager.GetTextAreaWidth(),
    2319          72 :                                   nIniFlyDx, nIniFlyDy);
    2320             : 
    2321             :     // If this paragraph is a Dropcap set the flag and we will deal with it later
    2322          24 :     if (IsDropCap())
    2323             :     {
    2324           0 :         bDropCap = true;
    2325           0 :         pAktItemSet = new SfxItemSet( rDoc.GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_END - 1 );
    2326           0 :         return false;
    2327             :     }
    2328             : 
    2329          24 :     if( !pWFlyPara->bGrafApo )
    2330             :     {
    2331             : 
    2332             :         // Innerhalb des GrafApo muessen Textattribute ignoriert werden, da
    2333             :         // sie sonst auf den folgenden Zeilen landen.  Der Rahmen wird nur
    2334             :         // eingefuegt, wenn er *nicht* nur zum Positionieren einer einzelnen
    2335             :         // Grafik dient.  Ist es ein Grafik-Rahmen, dann werden pWFlyPara und
    2336             :         // pSFlyPara behalten und die
    2337             :         // daraus resultierenden Attribute beim Einfuegen der Grafik auf die
    2338             :         // Grafik angewendet.
    2339             : 
    2340          24 :         WW8FlySet aFlySet(*this, pWFlyPara, pSFlyPara, false);
    2341             : 
    2342          24 :         if (pTabPos && pTabPos->bNoFly)
    2343             :         {
    2344          10 :             pSFlyPara->pFlyFmt = 0;
    2345          10 :             if (pULSpaceItem)
    2346             :             {
    2347             :                 // Word positioned tables can have a position (like a
    2348             :                 // fly-frame), but they also support flowing across multiple
    2349             :                 // pages. If we decide to import this as a normal table (so it
    2350             :                 // can flow across multiple pages), then turn the vertical
    2351             :                 // orientation position of the fly into a table upper margin.
    2352          10 :                 const SfxPoolItem* pItem = 0;
    2353          10 :                 if (aFlySet.HasItem(RES_VERT_ORIENT, &pItem))
    2354             :                 {
    2355          10 :                     const SwFmtVertOrient* pOrient = static_cast<const SwFmtVertOrient*>(pItem);
    2356          10 :                     if (pOrient->GetPos() != 0)
    2357           8 :                         pULSpaceItem->SetUpper(pOrient->GetPos());
    2358             :                 }
    2359          10 :             }
    2360             :         }
    2361             :         else
    2362             :         {
    2363             :             pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,
    2364          14 :                     pPaM->GetPoint(), &aFlySet );
    2365             :             OSL_ENSURE(pSFlyPara->pFlyFmt->GetAnchor().GetAnchorId() ==
    2366             :                     pSFlyPara->eAnchor, "Not the anchor type requested!");
    2367             :         }
    2368             : 
    2369          24 :         if (pSFlyPara->pFlyFmt)
    2370             :         {
    2371          14 :             if (!pDrawModel)
    2372          12 :                 GrafikCtor();
    2373             : 
    2374          14 :             SdrObject* pOurNewObject = CreateContactObject(pSFlyPara->pFlyFmt);
    2375          14 :             pWWZOrder->InsertTextLayerObject(pOurNewObject);
    2376             :         }
    2377             : 
    2378          24 :         if (FLY_AS_CHAR != pSFlyPara->eAnchor && pSFlyPara->pFlyFmt)
    2379             :         {
    2380          14 :             pAnchorStck->AddAnchor(*pPaM->GetPoint(),pSFlyPara->pFlyFmt);
    2381             :         }
    2382             : 
    2383             :         // remember Pos in body text
    2384          24 :         pSFlyPara->pMainTextPos = new SwPosition( *pPaM->GetPoint() );
    2385             : 
    2386             :         //remove fltanchors, otherwise they will be closed inside the
    2387             :         //frame, which makes no sense, restore them after the frame is
    2388             :         //closed
    2389          24 :         pSFlyPara->pOldAnchorStck = pAnchorStck;
    2390          24 :         pAnchorStck = new SwWW8FltAnchorStack(&rDoc, nFieldFlags);
    2391             : 
    2392          24 :         if (pSFlyPara->pFlyFmt)
    2393          14 :             MoveInsideFly(pSFlyPara->pFlyFmt);
    2394             : 
    2395             :         // 1) ReadText() wird nicht wie beim W4W-Reader rekursiv aufgerufen,
    2396             :         //    da die Laenge des Apo zu diesen Zeitpunkt noch nicht feststeht,
    2397             :         //    ReadText() diese Angabe aber braucht.
    2398             :         // 2) Der CtrlStck wird nicht neu erzeugt.
    2399             :         //    die Char-Attribute laufen weiter ( AErger mit SW-Attributen )
    2400             :         //    Paraattribute muessten am Ende jeden Absatzes zurueckgesetzt
    2401             :         //    sein, d.h. es duerften am Absatzende keine Paraattribute
    2402             :         //    auf dem Stack liegen
    2403             :     }
    2404          24 :     return true;
    2405             : }
    2406             : 
    2407         486 : void wwSectionManager::JoinNode(const SwPosition &rPos, const SwNode &rNode)
    2408             : {
    2409         486 :     if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.nNode))
    2410           0 :         maSegments.back().maStart = SwNodeIndex(rNode);
    2411         486 : }
    2412             : 
    2413         486 : bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr)
    2414             : {
    2415         486 :     bool bRet = false;
    2416         486 :     rPam.GetPoint()->nContent = 0;          // an den Anfang der Zeile gehen
    2417             : 
    2418         486 :     SwNodeIndex aPref(rPam.GetPoint()->nNode, -1);
    2419             : 
    2420         486 :     if (SwTxtNode* pNode = aPref.GetNode().GetTxtNode())
    2421             :     {
    2422         486 :         maSectionManager.JoinNode(*rPam.GetPoint(), aPref.GetNode());
    2423         486 :         rPam.GetPoint()->nNode = aPref;
    2424         486 :         rPam.GetPoint()->nContent.Assign(pNode, pNode->GetTxt().getLength());
    2425         486 :         if (bStealAttr)
    2426           0 :             pCtrlStck->StealAttr(rPam.GetPoint()->nNode);
    2427             : 
    2428         486 :         pNode->JoinNext();
    2429             : 
    2430         486 :         bRet = true;
    2431             :     }
    2432         486 :     return bRet;
    2433             : }
    2434             : 
    2435          24 : void SwWW8ImplReader::StopApo()
    2436             : {
    2437             :     OSL_ENSURE(pWFlyPara, "no pWFlyPara to close");
    2438          24 :     if (!pWFlyPara)
    2439           0 :         return;
    2440          24 :     if (pWFlyPara->bGrafApo)
    2441             :     {
    2442             :         // Grafik-Rahmen, der *nicht* eingefuegt wurde leeren Absatz incl.
    2443             :         // Attributen entfernen
    2444           0 :         JoinNode(*pPaM, true);
    2445             : 
    2446             :     }
    2447             :     else
    2448             :     {
    2449          24 :         if (!pSFlyPara->pMainTextPos || !pWFlyPara)
    2450             :         {
    2451             :             OSL_ENSURE( pSFlyPara->pMainTextPos, "StopApo: pMainTextPos ist 0" );
    2452             :             OSL_ENSURE( pWFlyPara, "StopApo: pWFlyPara ist 0" );
    2453           0 :             return;
    2454             :         }
    2455             : 
    2456             :         /*
    2457             :         What we are doing with this temporary nodeindex is as follows: The
    2458             :         stack of attributes normally only places them into the document when
    2459             :         the current insertion point has passed them by. Otherwise the end
    2460             :         point of the attribute gets pushed along with the insertion point. The
    2461             :         insertion point is moved and the properties committed during
    2462             :         MoveOutsideFly. We also may want to remove the final paragraph in the
    2463             :         frame, but we need to wait until the properties for that frame text
    2464             :         have been committed otherwise they will be lost. So we first get a
    2465             :         handle to the last the filter inserted. After the attributes are
    2466             :         committed, if that paragraph exists we join it with the para after it
    2467             :         that comes with the frame by default so that as normal we don't end up
    2468             :         with one more paragraph than we wanted.
    2469             :         */
    2470          24 :         SwNodeIndex aPref(pPaM->GetPoint()->nNode, -1);
    2471             : 
    2472             :         SwTwips nNewWidth =
    2473          24 :             MoveOutsideFly(pSFlyPara->pFlyFmt, *pSFlyPara->pMainTextPos);
    2474          24 :         if (nNewWidth)
    2475           6 :             pSFlyPara->BoxUpWidth(nNewWidth);
    2476             : 
    2477          24 :         Color aBg(0xFE, 0xFF, 0xFF, 0xFF);  //Transparent by default
    2478             : 
    2479          24 :         SwTxtNode* pNd = aPref.GetNode().GetTxtNode();
    2480          32 :         if (pNd && &pPaM->GetPoint()->nNode.GetNode()
    2481           8 :                         != &pSFlyPara->pMainTextPos->nNode.GetNode())
    2482             :         {
    2483             :             /*
    2484             :             #i582#
    2485             :             Take the last paragraph background colour and fill the frame with
    2486             :             it.  Otherwise, make it transparent, this appears to be how MSWord
    2487             :             works
    2488             :             */
    2489           0 :             const SfxPoolItem &rItm = pNd->SwCntntNode::GetAttr(RES_BACKGROUND);
    2490           0 :             const SvxBrushItem &rBrush = (const SvxBrushItem&)(rItm);
    2491           0 :             if (rBrush.GetColor().GetColor() != COL_AUTO)
    2492           0 :                 aBg = rBrush.GetColor();
    2493             : 
    2494             :             //Get rid of extra empty paragraph
    2495           0 :             pNd->JoinNext();
    2496             :         }
    2497             : 
    2498          24 :         if (pSFlyPara->pFlyFmt)
    2499          14 :             pSFlyPara->pFlyFmt->SetFmtAttr(SvxBrushItem(aBg, RES_BACKGROUND));
    2500             : 
    2501          24 :         DeleteAnchorStk();
    2502          24 :         pAnchorStck = pSFlyPara->pOldAnchorStck;
    2503             : 
    2504             :         // When inserting a graphic into the fly frame using the auto
    2505             :         // function, the extension of the SW-fly has to be set
    2506             :         // manually as the SW fly has no auto function to adjust the
    2507             :         // frame´s size.
    2508          24 :         if( pSFlyPara->nNewNetWidth > MINFLY )    // BoxUpWidth ?
    2509             :         {
    2510           6 :             long nW = pSFlyPara->nNewNetWidth;
    2511           6 :             nW += pSFlyPara->nWidth - pSFlyPara->nNetWidth;   // Rand dazu
    2512             :             pSFlyPara->pFlyFmt->SetFmtAttr(
    2513           6 :                 SwFmtFrmSize( pSFlyPara->eHeightFix, nW, pSFlyPara->nHeight ) );
    2514             :         }
    2515             :         /*
    2516             :         Word set *no* width meaning its an automatic width. The
    2517             :         SwFlyPara reader will have already set a fallback width of the
    2518             :         printable regions width, so we should reuse it. Despite the related
    2519             :         problems with layout addressed with a hack in WW8FlyPara's constructor
    2520             :         #i27204# Added AutoWidth setting. Left the old CalculateFlySize in place
    2521             :         so that if the user unselects autowidth, the width doesn't max out
    2522             :         */
    2523          18 :         else if( !pWFlyPara->nSp28 && pSFlyPara->pFlyFmt)
    2524             :         {
    2525             :             using namespace sw::util;
    2526           6 :             SfxItemSet aFlySet( pSFlyPara->pFlyFmt->GetAttrSet() );
    2527             : 
    2528          12 :             SwFmtFrmSize aSize(ItemGet<SwFmtFrmSize>(aFlySet, RES_FRM_SIZE));
    2529             : 
    2530           6 :             aFlySet.ClearItem(RES_FRM_SIZE);
    2531             : 
    2532             :             CalculateFlySize(aFlySet, pSFlyPara->pMainTextPos->nNode,
    2533           6 :                 pSFlyPara->nWidth);
    2534             : 
    2535           6 :             nNewWidth = ItemGet<SwFmtFrmSize>(aFlySet, RES_FRM_SIZE).GetWidth();
    2536             : 
    2537           6 :             aSize.SetWidth(nNewWidth);
    2538           6 :             aSize.SetWidthSizeType(ATT_VAR_SIZE);
    2539             : 
    2540          12 :             pSFlyPara->pFlyFmt->SetFmtAttr(aSize);
    2541             :         }
    2542             : 
    2543          24 :         delete pSFlyPara->pMainTextPos, pSFlyPara->pMainTextPos = 0;
    2544             : 
    2545             : // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden,
    2546             : // wird in fltshell.cxx beim Setzen des FltAnchor-Attributes
    2547             : // pFlyFrm->MakeFrms() gerufen
    2548             : 
    2549             :     }
    2550             : 
    2551             :     //#i8062#
    2552          24 :     if (pSFlyPara && pSFlyPara->pFlyFmt)
    2553          14 :         pFmtOfJustInsertedApo = pSFlyPara->pFlyFmt;
    2554             : 
    2555          24 :     DELETEZ( pSFlyPara );
    2556          24 :     DELETEZ( pWFlyPara );
    2557             : }
    2558             : 
    2559             : // TestSameApo() beantwortet die Frage, ob es dasselbe APO oder ein neues ist
    2560          34 : bool SwWW8ImplReader::TestSameApo(const ApoTestResults &rApo,
    2561             :     const WW8_TablePos *pTabPos)
    2562             : {
    2563          34 :     if( !pWFlyPara )
    2564             :     {
    2565             :         OSL_ENSURE( pWFlyPara, " Wo ist mein pWFlyPara ? " );
    2566           0 :         return true;
    2567             :     }
    2568             : 
    2569             :     // Es muss ein kompletter Vergleich ( ausser Borders ) stattfinden, um
    2570             :     // alle Kombinationen Style / Hart richtig einzuordnen. Deshalb wird ein
    2571             :     // temporaerer WW8FlyPara angelegt ( abh. ob Style oder nicht ), darauf
    2572             :     // die harten Attrs angewendet, und dann verglichen
    2573             : 
    2574             :     // Zum Vergleich
    2575          34 :     WW8FlyPara aF(bVer67, rApo.mpStyleApo);
    2576             :     // WWPara fuer akt. Para
    2577          34 :     if (rApo.HasFrame())
    2578          34 :         aF.Read(rApo.m_nSprm29, pPlcxMan->GetPapPLCF());
    2579          34 :     aF.ApplyTabPos(pTabPos);
    2580             : 
    2581          34 :     return aF == *pWFlyPara;
    2582             : }
    2583             : 
    2584       67294 : void SwWW8ImplReader::NewAttr( const SfxPoolItem& rAttr,
    2585             :                                const bool bFirstLineOfStSet,
    2586             :                                const bool bLeftIndentSet )
    2587             : {
    2588       67294 :     if( !bNoAttrImport ) // zum Ignorieren von Styles beim Doc-Einfuegen
    2589             :     {
    2590       67232 :         if (pAktColl)
    2591             :         {
    2592             :             OSL_ENSURE(rAttr.Which() != RES_FLTR_REDLINE, "redline in style!");
    2593       13472 :             pAktColl->SetFmtAttr(rAttr);
    2594             :         }
    2595       53760 :         else if (pAktItemSet)
    2596             :         {
    2597        7854 :             pAktItemSet->Put(rAttr);
    2598             :         }
    2599       45906 :         else if (rAttr.Which() == RES_FLTR_REDLINE)
    2600             :         {
    2601          10 :             mpRedlineStack->open(*pPaM->GetPoint(), rAttr);
    2602             :         }
    2603             :         else
    2604             :         {
    2605       45896 :             pCtrlStck->NewAttr(*pPaM->GetPoint(), rAttr);
    2606             :             // #i103711#
    2607       45896 :             if ( bFirstLineOfStSet )
    2608             :             {
    2609         538 :                 const SwNode* pNd = &(pPaM->GetPoint()->nNode.GetNode());
    2610         538 :                 maTxtNodesHavingFirstLineOfstSet.insert( pNd );
    2611             :             }
    2612             :             // #i105414#
    2613       45896 :             if ( bLeftIndentSet )
    2614             :             {
    2615        1666 :                 const SwNode* pNd = &(pPaM->GetPoint()->nNode.GetNode());
    2616        1666 :                 maTxtNodesHavingLeftIndentSet.insert( pNd );
    2617             :             }
    2618             :         }
    2619             : 
    2620       67232 :         if (mpPostProcessAttrsInfo && mpPostProcessAttrsInfo->mbCopy)
    2621           0 :             mpPostProcessAttrsInfo->mItemSet.Put(rAttr);
    2622             :     }
    2623       67294 : }
    2624             : 
    2625             : // holt Attribut aus der FmtColl / Stack / Doc
    2626       38814 : const SfxPoolItem* SwWW8ImplReader::GetFmtAttr( sal_uInt16 nWhich )
    2627             : {
    2628       38814 :     const SfxPoolItem* pRet = 0;
    2629       38814 :     if (pAktColl)
    2630        3748 :         pRet = &(pAktColl->GetFmtAttr(nWhich));
    2631       35066 :     else if (pAktItemSet)
    2632             :     {
    2633           0 :         pRet = pAktItemSet->GetItem(nWhich);
    2634           0 :         if (!pRet)
    2635           0 :             pRet = pStandardFmtColl ? &(pStandardFmtColl->GetFmtAttr(nWhich)) : 0;
    2636           0 :         if (!pRet)
    2637           0 :             pRet = &rDoc.GetAttrPool().GetDefaultItem(nWhich);
    2638             :     }
    2639       35066 :     else if (pPlcxMan && pPlcxMan->GetDoingDrawTextBox())
    2640             :     {
    2641         216 :         pRet = pCtrlStck->GetStackAttr(*pPaM->GetPoint(), nWhich);
    2642         216 :         if (!pRet)
    2643             :         {
    2644         372 :             if (nAktColl < vColl.size() && vColl[nAktColl].pFmt &&
    2645         186 :                 vColl[nAktColl].bColl)
    2646             :             {
    2647         186 :                 pRet = &(vColl[nAktColl].pFmt->GetFmtAttr(nWhich));
    2648             :             }
    2649             :         }
    2650         216 :         if (!pRet)
    2651           0 :             pRet = pStandardFmtColl ? &(pStandardFmtColl->GetFmtAttr(nWhich)) : 0;
    2652         216 :         if (!pRet)
    2653           0 :             pRet = &rDoc.GetAttrPool().GetDefaultItem(nWhich);
    2654             :     }
    2655             :     else
    2656       34850 :         pRet = pCtrlStck->GetFmtAttr(*pPaM->GetPoint(), nWhich);
    2657       38814 :     return pRet;
    2658             : }
    2659             : 
    2660             : // Die Methoden erhalten die Token-Id und die Laenge der noch folgenden
    2661             : // Parameter gemaess Tabelle in WWScan.cxx als Parameter
    2662        1036 : void SwWW8ImplReader::Read_Special(sal_uInt16, const sal_uInt8* pData, short nLen)
    2663             : {
    2664        1036 :     if( nLen < 0 )
    2665             :     {
    2666         518 :         bSpec = false;
    2667        1554 :         return;
    2668             :     }
    2669         518 :     bSpec = ( *pData != 0 );
    2670             : }
    2671             : 
    2672             : // Read_Obj wird fuer fObj und fuer fOle2 benutzt !
    2673          72 : void SwWW8ImplReader::Read_Obj(sal_uInt16 , const sal_uInt8* pData, short nLen)
    2674             : {
    2675          72 :     if( nLen < 0 )
    2676          36 :         bObj = false;
    2677             :     else
    2678             :     {
    2679          36 :         bObj = 0 != *pData;
    2680             : 
    2681          36 :         if( bObj && nPicLocFc && bEmbeddObj )
    2682             :         {
    2683          36 :             if (!maFieldStack.empty() && maFieldStack.back().mnFieldId == 56)
    2684             :             {
    2685             :                 // For LINK fields, store the nObjLocFc value in the field entry
    2686           0 :                 maFieldStack.back().mnObjLocFc = nPicLocFc;
    2687             :             }
    2688             :             else
    2689             :             {
    2690          36 :                 nObjLocFc = nPicLocFc;
    2691             :             }
    2692             :         }
    2693             :     }
    2694          72 : }
    2695             : 
    2696         906 : void SwWW8ImplReader::Read_PicLoc(sal_uInt16 , const sal_uInt8* pData, short nLen )
    2697             : {
    2698         906 :     if( nLen < 0 )
    2699             :     {
    2700         446 :         nPicLocFc = 0;
    2701         446 :         bSpec = false;  // Stimmt das immer ?
    2702             :     }
    2703             :     else
    2704             :     {
    2705         460 :         nPicLocFc = SVBT32ToUInt32( pData );
    2706         460 :         bSpec = true;
    2707             : 
    2708         460 :         if( bObj && nPicLocFc && bEmbeddObj )
    2709           0 :             nObjLocFc = nPicLocFc;
    2710             :     }
    2711         906 : }
    2712             : 
    2713         200 : void SwWW8ImplReader::Read_POutLvl(sal_uInt16, const sal_uInt8* pData, short nLen )
    2714             : {
    2715         200 :     if (nLen < 0)
    2716             :     {
    2717           0 :         pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_PARATR_OUTLINELEVEL);
    2718         200 :         return;
    2719             :     }
    2720             : 
    2721         200 :     if (pAktColl != NULL)
    2722             :     {
    2723         200 :         SwWW8StyInf* pSI = GetStyle(nAktColl);
    2724         200 :         if (pSI != NULL)
    2725             :         {
    2726             :             pSI->mnWW8OutlineLevel =
    2727         200 :                     static_cast< sal_uInt8 >( ( pData ? *pData : 0 ) );
    2728         200 :             NewAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL, SwWW8StyInf::WW8OutlineLevelToOutlinelevel( pSI->mnWW8OutlineLevel ) ) );
    2729             :         }
    2730             :     }
    2731           0 :     else if (pPaM != NULL)
    2732             :     {
    2733             :         const sal_uInt8 nOutlineLevel
    2734             :             = SwWW8StyInf::WW8OutlineLevelToOutlinelevel(
    2735           0 :                 static_cast<sal_uInt8>((pData ? *pData : 0)));
    2736           0 :         NewAttr(SfxUInt16Item(RES_PARATR_OUTLINELEVEL, nOutlineLevel));
    2737             :     }
    2738             : }
    2739             : 
    2740           0 : void SwWW8ImplReader::Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen )
    2741             : {
    2742           0 :     if( !bIgnoreText )
    2743             :     {
    2744           0 :         if( nLen < 0 )
    2745             :         {
    2746             :             //otherwise disable after we print the char
    2747           0 :             if (pPlcxMan && pPlcxMan->GetDoingDrawTextBox())
    2748           0 :                 pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
    2749           0 :             bSymbol = false;
    2750             :         }
    2751             :         else
    2752             :         {
    2753             :             // Make new Font-Atribut
    2754             :             // (will be closed in SwWW8ImplReader::ReadChars() )
    2755             : 
    2756             :             //Will not be added to the charencoding stack, for styles the real
    2757             :             //font setting will be put in as the styles charset, and for plain
    2758             :             //text encoding for symbols is moot. Drawing boxes will check bSymbol
    2759             :             //themselves so they don't need to add it to the stack either.
    2760           0 :             if (SetNewFontAttr(SVBT16ToShort( pData ), false, RES_CHRATR_FONT))
    2761             :             {
    2762           0 :                 if( bVer67 )
    2763             :                 {
    2764             :                     //convert single byte from MS1252 to Unicode
    2765             :                     cSymbol = OUString(
    2766             :                         reinterpret_cast<const sal_Char*>(pData+2), 1,
    2767           0 :                         RTL_TEXTENCODING_MS_1252).toChar();
    2768             :                 }
    2769             :                 else
    2770             :                 {
    2771             :                     //already is Unicode
    2772           0 :                     cSymbol = SVBT16ToShort( pData+2 );
    2773             :                 }
    2774           0 :                 bSymbol = true;
    2775             :             }
    2776             :         }
    2777             :     }
    2778           0 : }
    2779             : 
    2780        5760 : SwWW8StyInf *SwWW8ImplReader::GetStyle(sal_uInt16 nColl) const
    2781             : {
    2782        5760 :     return const_cast<SwWW8StyInf *>(nColl < vColl.size() ? &vColl[nColl] : 0);
    2783             : }
    2784             : 
    2785             : // Read_BoldUsw fuer Italic, Bold, Kapitaelchen, Versalien, durchgestrichen,
    2786             : // Contour und Shadow
    2787        6316 : void SwWW8ImplReader::Read_BoldUsw( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    2788             : {
    2789        6316 :     const int nContigiousWestern = 8;
    2790        6316 :     const int nWestern = nContigiousWestern + 1;
    2791        6316 :     const int nEastern = 2;
    2792        6316 :     const int nCTL = 2;
    2793        6316 :     const int nIds = nWestern + nEastern + nCTL;
    2794             :     static const sal_uInt16 nEndIds[ nIds ] =
    2795             :     {
    2796             :         RES_CHRATR_WEIGHT,          RES_CHRATR_POSTURE,
    2797             :         RES_CHRATR_CROSSEDOUT,      RES_CHRATR_CONTOUR,
    2798             :         RES_CHRATR_SHADOWED,        RES_CHRATR_CASEMAP,
    2799             :         RES_CHRATR_CASEMAP,         RES_CHRATR_HIDDEN,
    2800             : 
    2801             :         RES_CHRATR_CROSSEDOUT,
    2802             : 
    2803             :         RES_CHRATR_CJK_WEIGHT,      RES_CHRATR_CJK_POSTURE,
    2804             : 
    2805             :         RES_CHRATR_CTL_WEIGHT,      RES_CHRATR_CTL_POSTURE
    2806             :     };
    2807             : 
    2808        6316 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    2809             : 
    2810             :     sal_uInt8 nI;
    2811             :     // die Attribut-Nr fuer "doppelt durchgestrichen" tanzt aus der Reihe
    2812        6316 :     if (0x2A53 == nId)
    2813          12 :         nI = nContigiousWestern;               // The out of sequence western id
    2814             :     else
    2815             :     {
    2816             :         // The contiguous western ids
    2817        6304 :         if (eVersion <= ww::eWW2)
    2818        2632 :             nI = static_cast< sal_uInt8 >(nId - 60);
    2819        3672 :         else if (eVersion < ww::eWW8)
    2820           0 :             nI = static_cast< sal_uInt8 >(nId - 85);
    2821             :         else
    2822        3672 :             nI = static_cast< sal_uInt8 >(nId - 0x0835);
    2823             :     }
    2824             : 
    2825        6316 :     sal_uInt16 nMask = 1 << nI;
    2826             : 
    2827        6316 :     if (nLen < 0)
    2828             :     {
    2829        2752 :         if (nI < 2)
    2830             :         {
    2831        1784 :             if (eVersion <= ww::eWW6)
    2832             :             {
    2833             :                 // reset the CTL Weight and Posture, because they are the same as their
    2834             :                 // western equivalents in ww6
    2835         372 :                 pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nWestern + nEastern + nI ] );
    2836             :             }
    2837             :             // reset the CJK Weight and Posture, because they are the same as their
    2838             :             // western equivalents in word
    2839        1784 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nWestern + nI ] );
    2840             :         }
    2841        2752 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nI ] );
    2842        2752 :         pCtrlStck->SetToggleAttr(nI, false);
    2843        9068 :         return;
    2844             :     }
    2845             :     // Wert: 0 = Aus, 1 = An, 128 = Wie Style, 129 entgegen Style
    2846        3564 :     bool bOn = *pData & 1;
    2847        3564 :     SwWW8StyInf* pSI = GetStyle(nAktColl);
    2848        3564 :     if (pPlcxMan && eVersion > ww::eWW2)
    2849             :     {
    2850             :         const sal_uInt8 *pCharIstd =
    2851        1512 :             pPlcxMan->GetChpPLCF()->HasSprm(bVer67 ? 80 : 0x4A30);
    2852        1512 :         if (pCharIstd)
    2853           0 :             pSI = GetStyle(SVBT16ToShort(pCharIstd));
    2854             :     }
    2855             : 
    2856        3564 :     if( pAktColl )                          // StyleDef -> Flags merken
    2857             :     {
    2858         578 :         if (pSI)
    2859             :         {
    2860             :             // The style based on has Bit 7 set ?
    2861         578 :             if (
    2862         916 :                 pSI->nBase < vColl.size() && (*pData & 0x80) &&
    2863         338 :                 (vColl[pSI->nBase].n81Flags & nMask)
    2864             :                )
    2865             :             {
    2866           8 :                 bOn = !bOn;                     // umdrehen
    2867             :             }
    2868             : 
    2869         578 :             if (bOn)
    2870         534 :                 pSI->n81Flags |= nMask;         // Flag setzen
    2871             :             else
    2872          44 :                 pSI->n81Flags &= ~nMask;        // Flag loeschen
    2873             :        }
    2874             :     }
    2875             :     else
    2876             :     {
    2877             : 
    2878             :         // im Text -> Flags abfragen
    2879        2986 :         if( *pData & 0x80 )                 // Bit 7 gesetzt ?
    2880             :         {
    2881        2428 :             if (pSI && pSI->n81Flags & nMask)       // und in StyleDef an ?
    2882          26 :                 bOn = !bOn;                 // dann invertieren
    2883             :             // am Stack vermerken, das dieses ein Toggle-Attribut ist
    2884        2428 :             pCtrlStck->SetToggleAttr(nI, true);
    2885             :         }
    2886             :     }
    2887             : 
    2888        3564 :     SetToggleAttr( nI, bOn );
    2889             : }
    2890             : 
    2891        4316 : void SwWW8ImplReader::Read_Bidi(sal_uInt16, const sal_uInt8* pData, short nLen)
    2892             : {
    2893        4316 :     if( nLen < 0 )  //Property end
    2894             :     {
    2895        2158 :         bBidi = false;
    2896        2158 :         pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_CHRATR_BIDIRTL);
    2897             :     }
    2898             :     else    //Property start
    2899             :     {
    2900        2158 :         bBidi = true;
    2901        2158 :         sal_uInt8 nBidi = *pData;
    2902        2158 :         NewAttr( SfxInt16Item( RES_CHRATR_BIDIRTL, (nBidi!=0)? 1 : 0 ) );
    2903             :     }
    2904        4316 : }
    2905             : 
    2906             : // Read_BoldUsw for BiDi Italic, Bold
    2907        1878 : void SwWW8ImplReader::Read_BoldBiDiUsw(sal_uInt16 nId, const sal_uInt8* pData,
    2908             :     short nLen)
    2909             : {
    2910             :     static const sal_uInt16 nEndIds[2] =
    2911             :     {
    2912             :         RES_CHRATR_CTL_WEIGHT, RES_CHRATR_CTL_POSTURE,
    2913             :     };
    2914             : 
    2915             :     sal_uInt8 nI;
    2916        1878 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    2917        1878 :     if (eVersion <= ww::eWW2)
    2918         752 :         nI = static_cast< sal_uInt8 >(nId - 80);
    2919        1126 :     else if (eVersion < ww::eWW8)
    2920           0 :         nI = static_cast< sal_uInt8 >(nId - 111);
    2921             :     else
    2922        1126 :         nI = static_cast< sal_uInt8 >(nId - 0x085C);
    2923             : 
    2924             :     OSL_ENSURE(nI <= 1, "not happening");
    2925        1878 :     if (nI > 1)
    2926           0 :         return;
    2927             : 
    2928        1878 :     sal_uInt16 nMask = 1 << nI;
    2929             : 
    2930        1878 :     if( nLen < 0 )
    2931             :     {
    2932         738 :         pCtrlStck->SetAttr(*pPaM->GetPoint(),nEndIds[nI]);
    2933         738 :         pCtrlStck->SetToggleBiDiAttr(nI, false);
    2934         738 :         return;
    2935             :     }
    2936        1140 :     bool bOn = *pData & 1;
    2937        1140 :     SwWW8StyInf* pSI = GetStyle(nAktColl);
    2938        1140 :     if (pPlcxMan)
    2939             :     {
    2940             :         const sal_uInt8 *pCharIstd =
    2941         774 :             pPlcxMan->GetChpPLCF()->HasSprm(bVer67 ? 80 : 0x4A30);
    2942         774 :         if (pCharIstd)
    2943         372 :             pSI = GetStyle(SVBT16ToShort(pCharIstd));
    2944             :     }
    2945             : 
    2946        1140 :     if (pAktColl && eVersion > ww::eWW2)        // StyleDef -> Flags merken
    2947             :     {
    2948         644 :         if (pSI)
    2949             :         {
    2950         644 :             if( pSI->nBase < vColl.size()             // Style Based on
    2951         298 :                 && ( *pData & 0x80 )            // Bit 7 gesetzt ?
    2952         498 :                 && ( vColl[pSI->nBase].n81BiDiFlags & nMask ) ) // BasisMaske ?
    2953          20 :                     bOn = !bOn;                     // umdrehen
    2954             : 
    2955         322 :             if( bOn )
    2956         302 :                 pSI->n81BiDiFlags |= nMask;         // Flag setzen
    2957             :             else
    2958          20 :                 pSI->n81BiDiFlags &= ~nMask;        // Flag loeschen
    2959             :         }
    2960             :     }
    2961             :     else
    2962             :     {
    2963             : 
    2964             :         // im Text -> Flags abfragen
    2965         818 :         if (*pData & 0x80)                  // Bit 7 gesetzt ?
    2966             :         {
    2967         770 :             if (pSI && pSI->n81BiDiFlags & nMask) // und in StyleDef an ?
    2968           8 :                 bOn = !bOn;                     // dann invertieren
    2969             :             // am Stack vermerken, das dieses ein Toggle-Attribut ist
    2970         770 :             pCtrlStck->SetToggleBiDiAttr(nI, true);
    2971             :         }
    2972             :     }
    2973             : 
    2974        1140 :     SetToggleBiDiAttr(nI, bOn);
    2975             : }
    2976             : 
    2977        1146 : void SwWW8ImplReader::SetToggleBiDiAttr(sal_uInt8 nAttrId, bool bOn)
    2978             : {
    2979        1146 :     switch (nAttrId)
    2980             :     {
    2981             :         case 0:
    2982             :             {
    2983         814 :                 SvxWeightItem aAttr( bOn ? WEIGHT_BOLD : WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
    2984         814 :                 aAttr.SetWhich( RES_CHRATR_CTL_WEIGHT );
    2985         814 :                 NewAttr( aAttr );
    2986             :             }
    2987         814 :             break;
    2988             :         case 1:
    2989             :             {
    2990         332 :                 SvxPostureItem aAttr( bOn ? ITALIC_NORMAL : ITALIC_NONE, RES_CHRATR_POSTURE );
    2991         332 :                 aAttr.SetWhich( RES_CHRATR_CTL_POSTURE );
    2992         332 :                 NewAttr( aAttr );
    2993             :             }
    2994         332 :             break;
    2995             :         default:
    2996             :             OSL_ENSURE(false, "Unhandled unknown bidi toggle attribute");
    2997           0 :             break;
    2998             : 
    2999             :     }
    3000        1146 : }
    3001             : 
    3002        3596 : void SwWW8ImplReader::SetToggleAttr(sal_uInt8 nAttrId, bool bOn)
    3003             : {
    3004        3596 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    3005             : 
    3006        3596 :     switch (nAttrId)
    3007             :     {
    3008             :         case 0:
    3009             :             {
    3010        1722 :                 SvxWeightItem aAttr( bOn ? WEIGHT_BOLD : WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
    3011        1722 :                 NewAttr( aAttr );
    3012        1722 :                 aAttr.SetWhich( RES_CHRATR_CJK_WEIGHT );
    3013        1722 :                 NewAttr( aAttr );
    3014        1722 :                 if (eVersion <= ww::eWW6)
    3015             :                 {
    3016         190 :                     aAttr.SetWhich( RES_CHRATR_CTL_WEIGHT );
    3017         190 :                     NewAttr( aAttr );
    3018        1722 :                 }
    3019             :             }
    3020        1722 :             break;
    3021             :         case 1:
    3022             :             {
    3023         814 :                 SvxPostureItem aAttr( bOn ? ITALIC_NORMAL : ITALIC_NONE, RES_CHRATR_POSTURE );
    3024         814 :                 NewAttr( aAttr );
    3025         814 :                 aAttr.SetWhich( RES_CHRATR_CJK_POSTURE );
    3026         814 :                 NewAttr( aAttr );
    3027         814 :                 if (eVersion <= ww::eWW6)
    3028             :                 {
    3029         190 :                     aAttr.SetWhich( RES_CHRATR_CTL_POSTURE );
    3030         190 :                     NewAttr( aAttr );
    3031         814 :                 }
    3032             :             }
    3033         814 :             break;
    3034             :         case 2:
    3035         198 :             NewAttr(SvxCrossedOutItem(bOn ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT));
    3036         198 :             break;
    3037             :         case 3:
    3038         198 :             NewAttr( SvxContourItem( bOn, RES_CHRATR_CONTOUR ) );
    3039         198 :             break;
    3040             :         case 4:
    3041          16 :             NewAttr( SvxShadowedItem( bOn, RES_CHRATR_SHADOWED ) );
    3042          16 :             break;
    3043             :         case 5:
    3044             :             NewAttr( SvxCaseMapItem( bOn ? SVX_CASEMAP_KAPITAELCHEN
    3045         190 :                                               : SVX_CASEMAP_NOT_MAPPED, RES_CHRATR_CASEMAP ) );
    3046         190 :             break;
    3047             :         case 6:
    3048             :             NewAttr( SvxCaseMapItem( bOn ? SVX_CASEMAP_VERSALIEN
    3049         216 :                                              : SVX_CASEMAP_NOT_MAPPED, RES_CHRATR_CASEMAP ) );
    3050         216 :             break;
    3051             :         case 7:
    3052         230 :             NewAttr(SvxCharHiddenItem(bOn, RES_CHRATR_HIDDEN));
    3053         230 :             break;
    3054             :         case 8:
    3055             :             NewAttr( SvxCrossedOutItem( bOn ? STRIKEOUT_DOUBLE
    3056          12 :                                                 : STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ) );
    3057          12 :             break;
    3058             :         default:
    3059             :             OSL_ENSURE(false, "Unhandled unknown toggle attribute");
    3060           0 :             break;
    3061             :     }
    3062        3596 : }
    3063             : 
    3064          42 : void SwWW8ImplReader::_ChkToggleAttr( sal_uInt16 nOldStyle81Mask,
    3065             :                                         sal_uInt16 nNewStyle81Mask )
    3066             : {
    3067          42 :     sal_uInt16 i = 1, nToggleAttrFlags = pCtrlStck->GetToggleAttrFlags();
    3068         336 :     for (sal_uInt8 n = 0; n < 7; ++n, i <<= 1)
    3069             :     {
    3070         294 :         if (
    3071          42 :             (i & nToggleAttrFlags) &&
    3072          42 :             ((i & nOldStyle81Mask) != (i & nNewStyle81Mask))
    3073             :            )
    3074             :         {
    3075          32 :             SetToggleAttr(n, (i & nOldStyle81Mask));
    3076             :         }
    3077             :     }
    3078          42 : }
    3079             : 
    3080           6 : void SwWW8ImplReader::_ChkToggleBiDiAttr( sal_uInt16 nOldStyle81Mask,
    3081             :                                         sal_uInt16 nNewStyle81Mask )
    3082             : {
    3083           6 :     sal_uInt16 i = 1, nToggleAttrFlags = pCtrlStck->GetToggleBiDiAttrFlags();
    3084          48 :     for (sal_uInt8 n = 0; n < 7; ++n, i <<= 1)
    3085             :     {
    3086          42 :         if (
    3087           6 :             (i & nToggleAttrFlags) &&
    3088           6 :             ((i & nOldStyle81Mask) != (i & nNewStyle81Mask))
    3089             :            )
    3090             :         {
    3091           6 :             SetToggleBiDiAttr(n, (i & nOldStyle81Mask));
    3092             :         }
    3093             :     }
    3094           6 : }
    3095             : 
    3096          76 : void SwWW8ImplReader::Read_SubSuper( sal_uInt16, const sal_uInt8* pData, short nLen )
    3097             : {
    3098          76 :     if( nLen < 0 ){
    3099          20 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_ESCAPEMENT );
    3100          96 :         return;
    3101             :     }
    3102             : 
    3103             :     short nEs;
    3104             :     sal_uInt8 nProp;
    3105          56 :     switch( *pData )
    3106             :     {
    3107             :         case 1:
    3108          42 :             nEs = DFLT_ESC_AUTO_SUPER;
    3109          42 :             nProp = DFLT_ESC_PROP;
    3110          42 :             break;
    3111             :         case 2:
    3112           0 :             nEs = DFLT_ESC_AUTO_SUB;
    3113           0 :             nProp = DFLT_ESC_PROP;
    3114           0 :             break;
    3115             :         default:
    3116          14 :             nEs = 0;
    3117          14 :             nProp = 100;
    3118          14 :             break;
    3119             :     }
    3120          56 :     NewAttr( SvxEscapementItem( nEs, nProp, RES_CHRATR_ESCAPEMENT ) );
    3121             : }
    3122             : 
    3123          30 : SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion)
    3124             : {
    3125             :     /*
    3126             :     For inline graphics and objects word has a hacked in feature to use
    3127             :     subscripting to force the graphic into a centered position on the line, so
    3128             :     we must check when applying sub/super to see if it the subscript range
    3129             :     contains only a single graphic, and if that graphic is anchored as
    3130             :     FLY_AS_CHAR and then we can change its anchoring to centered in the line.
    3131             :     */
    3132          30 :     SwFrmFmt *pRet=0;
    3133          30 :     SwNodeIndex aBegin(rRegion.Start()->nNode);
    3134          30 :     const sal_Int32 nBegin(rRegion.Start()->nContent.GetIndex());
    3135          60 :     SwNodeIndex aEnd(rRegion.End()->nNode);
    3136          30 :     const sal_Int32 nEnd(rRegion.End()->nContent.GetIndex());
    3137             :     const SwTxtNode* pTNd;
    3138             :     const SwTxtAttr* pTFlyAttr;
    3139          30 :     if (
    3140          60 :          aBegin == aEnd && nBegin == nEnd - 1 &&
    3141          30 :          0 != (pTNd = aBegin.GetNode().GetTxtNode()) &&
    3142             :          0 != (pTFlyAttr = pTNd->GetTxtAttrForCharAt(nBegin, RES_TXTATR_FLYCNT))
    3143             :        )
    3144             :     {
    3145           0 :         const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt();
    3146           0 :         SwFrmFmt *pFlyFmt = rFly.GetFrmFmt();
    3147           0 :         if (pFlyFmt &&
    3148           0 :             (FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId()))
    3149             :         {
    3150           0 :             pRet = pFlyFmt;
    3151             :         }
    3152             :     }
    3153          60 :     return pRet;
    3154             : }
    3155             : 
    3156          16 : bool SwWW8ImplReader::ConvertSubToGraphicPlacement()
    3157             : {
    3158             :     /*
    3159             :     For inline graphics and objects word has a hacked in feature to use
    3160             :     subscripting to force the graphic into a centered position on the line, so
    3161             :     we must check when applying sub/super to see if it the subscript range
    3162             :     contains only a single graphic, and if that graphic is anchored as
    3163             :     FLY_AS_CHAR and then we can change its anchoring to centered in the line.
    3164             :     */
    3165          16 :     bool bIsGraphicPlacementHack = false;
    3166             :     sal_uInt16 nPos;
    3167          16 :     if (pCtrlStck->GetFmtStackAttr(RES_CHRATR_ESCAPEMENT, &nPos))
    3168             :     {
    3169          16 :         SwPaM aRegion(*pPaM->GetPoint());
    3170             : 
    3171          32 :         SwFltPosition aMkPos((*pCtrlStck)[nPos].m_aMkPos);
    3172          32 :         SwFltPosition aPtPos(*pPaM->GetPoint());
    3173             : 
    3174          16 :         SwFrmFmt *pFlyFmt = 0;
    3175          16 :         if (
    3176          16 :              SwFltStackEntry::MakeRegion(&rDoc,aRegion,false,aMkPos,aPtPos) &&
    3177             :              0 != (pFlyFmt = ContainsSingleInlineGraphic(aRegion))
    3178             :            )
    3179             :         {
    3180           0 :             pCtrlStck->DeleteAndDestroy(nPos);
    3181           0 :             pFlyFmt->SetFmtAttr(SwFmtVertOrient(0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::CHAR));
    3182           0 :             bIsGraphicPlacementHack = true;
    3183          16 :         }
    3184             :     }
    3185          16 :     return bIsGraphicPlacementHack;
    3186             : }
    3187             : 
    3188          46 : void SwWW8ImplReader::Read_SubSuperProp( sal_uInt16, const sal_uInt8* pData, short nLen )
    3189             : {
    3190          46 :     if( nLen < 0 )
    3191             :     {
    3192          16 :         if (!ConvertSubToGraphicPlacement())
    3193          16 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_ESCAPEMENT );
    3194          62 :         return;
    3195             :     }
    3196             : 
    3197          30 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    3198             : 
    3199             :     // Font-Position in HalfPoints
    3200          30 :     short nPos = eVersion <= ww::eWW2 ? static_cast< sal_Int8 >( *pData ) : SVBT16ToShort( pData );
    3201          30 :     sal_Int32 nPos2 = nPos * ( 10 * 100 );      // HalfPoints in 100 * tw
    3202             :     const SvxFontHeightItem* pF
    3203          30 :         = (const SvxFontHeightItem*)GetFmtAttr(RES_CHRATR_FONTSIZE);
    3204             :     OSL_ENSURE(pF, "Expected to have the fontheight available here");
    3205             : 
    3206             :     // #i59022: Check ensure nHeight != 0. Div by zero otherwise.
    3207          30 :     sal_Int32 nHeight = 240;
    3208          30 :     if (pF != NULL && pF->GetHeight() != 0)
    3209          30 :         nHeight = pF->GetHeight();
    3210          30 :     nPos2 /= nHeight;                       // ... nun in % ( gerundet )
    3211          30 :     if( nPos2 > 100 )                       // zur Sicherheit
    3212           0 :         nPos2 = 100;
    3213          30 :     if( nPos2 < -100 )
    3214           0 :         nPos2 = -100;
    3215          30 :     SvxEscapementItem aEs( (short)nPos2, 100, RES_CHRATR_ESCAPEMENT );
    3216          30 :     NewAttr( aEs );
    3217             : }
    3218             : 
    3219         726 : void SwWW8ImplReader::Read_Underline( sal_uInt16, const sal_uInt8* pData, short nLen )
    3220             : {
    3221         726 :     FontUnderline eUnderline = UNDERLINE_NONE;
    3222         726 :     bool bWordLine = false;
    3223         726 :     if( pData )
    3224             :     {
    3225             :         // Parameter:  0 = none,    1 = single,  2 = by Word,
    3226             :                     // 3 = double,  4 = dotted,  5 = hidden
    3227             :                     // 6 = thick,   7 = dash,    8 = dot(not used)
    3228             :                     // 9 = dotdash 10 = dotdotdash 11 = wave
    3229         492 :         switch( *pData )
    3230             :         {
    3231           0 :             case 2: bWordLine = true;       // no break;
    3232         350 :             case 1: eUnderline = (FontUnderline)UNDERLINE_SINGLE;       break;
    3233           4 :             case 3: eUnderline = (FontUnderline)UNDERLINE_DOUBLE;       break;
    3234           0 :             case 4: eUnderline = (FontUnderline)UNDERLINE_DOTTED;       break;
    3235           0 :             case 7: eUnderline = (FontUnderline)UNDERLINE_DASH;         break;
    3236           0 :             case 9: eUnderline = (FontUnderline)UNDERLINE_DASHDOT;      break;
    3237           0 :             case 10:eUnderline = (FontUnderline)UNDERLINE_DASHDOTDOT;   break;
    3238           0 :             case 6: eUnderline = (FontUnderline)UNDERLINE_BOLD;         break;
    3239           0 :             case 11:eUnderline = (FontUnderline)UNDERLINE_WAVE;         break;
    3240           0 :             case 20:eUnderline = (FontUnderline)UNDERLINE_BOLDDOTTED;   break;
    3241           0 :             case 23:eUnderline = (FontUnderline)UNDERLINE_BOLDDASH;     break;
    3242           0 :             case 39:eUnderline = (FontUnderline)UNDERLINE_LONGDASH;     break;
    3243           0 :             case 55:eUnderline = (FontUnderline)UNDERLINE_BOLDLONGDASH; break;
    3244           0 :             case 25:eUnderline = (FontUnderline)UNDERLINE_BOLDDASHDOT;  break;
    3245           0 :             case 26:eUnderline = (FontUnderline)UNDERLINE_BOLDDASHDOTDOT;break;
    3246           0 :             case 27:eUnderline = (FontUnderline)UNDERLINE_BOLDWAVE;     break;
    3247           0 :             case 43:eUnderline = (FontUnderline)UNDERLINE_DOUBLEWAVE;   break;
    3248             :         }
    3249             :     }
    3250             : 
    3251             :     // dann Stack ggfs. verwursteln und exit!
    3252         726 :     if( nLen < 0 )
    3253             :     {
    3254         234 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_UNDERLINE );
    3255         234 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_WORDLINEMODE );
    3256             :     }
    3257             :     else
    3258             :     {
    3259         492 :         NewAttr( SvxUnderlineItem( eUnderline, RES_CHRATR_UNDERLINE ));
    3260         492 :         if( bWordLine )
    3261           0 :             NewAttr(SvxWordLineModeItem(true, RES_CHRATR_WORDLINEMODE));
    3262             :     }
    3263         726 : }
    3264             : 
    3265             : /*
    3266             : //The last three vary, measurements, rotation ? ?
    3267             : NoBracket   78 CA 06 -  02 00 00 02 34 52
    3268             : ()          78 CA 06 -  02 01 00 02 34 52
    3269             : []          78 CA 06 -  02 02 00 02 34 52
    3270             : <>          78 CA 06 -  02 03 00 02 34 52
    3271             : {}          78 CA 06 -  02 04 00 02 34 52
    3272             : */
    3273           0 : void SwWW8ImplReader::Read_DoubleLine_Rotate( sal_uInt16, const sal_uInt8* pData,
    3274             :     short nLen )
    3275             : {
    3276           0 :     if( nLen < 0 ) // close the tag
    3277             :     {
    3278           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_TWO_LINES );
    3279           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_ROTATE );
    3280             :     }
    3281           0 :     else if( pData && 6 == nLen )
    3282             :     {
    3283           0 :         switch( *pData )
    3284             :         {
    3285             :         case 2:                     // double line
    3286             :             {
    3287           0 :                 sal_Unicode cStt = 0, cEnd = 0;
    3288           0 :                 switch( SVBT16ToShort( pData+1 ) )
    3289             :                 {
    3290           0 :                 case 1: cStt = '(', cEnd = ')'; break;
    3291           0 :                 case 2: cStt = '[', cEnd = ']'; break;
    3292           0 :                 case 3: cStt = '<', cEnd = '>'; break;
    3293           0 :                 case 4: cStt = '{', cEnd = '}'; break;
    3294             :                 }
    3295           0 :                 NewAttr( SvxTwoLinesItem( true, cStt, cEnd, RES_CHRATR_TWO_LINES ));
    3296             :             }
    3297           0 :             break;
    3298             : 
    3299             :         case 1:                         // rotated characters
    3300             :             {
    3301           0 :                 bool bFitToLine = 0 != *(pData+1);
    3302           0 :                 NewAttr( SvxCharRotateItem( 900, bFitToLine, RES_CHRATR_ROTATE ));
    3303             :             }
    3304           0 :             break;
    3305             :         }
    3306             :     }
    3307           0 : }
    3308             : 
    3309        4774 : void SwWW8ImplReader::Read_TxtColor( sal_uInt16, const sal_uInt8* pData, short nLen )
    3310             : {
    3311             :     //Has newer colour variant, ignore this old variant
    3312        4774 :     if (!bVer67 && pPlcxMan && pPlcxMan->GetChpPLCF()->HasSprm(NS_sprm::LN_CCv))
    3313        9242 :         return;
    3314             : 
    3315         306 :     if( nLen < 0 )
    3316          12 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
    3317             :     else
    3318             :     {
    3319         294 :         sal_uInt8 b = *pData;            // Parameter: 0 = Auto, 1..16 Farben
    3320             : 
    3321         294 :         if( b > 16 )                // unbekannt -> Black
    3322           0 :             b = 0;
    3323             : 
    3324         294 :         NewAttr( SvxColorItem(Color(GetCol(b)), RES_CHRATR_COLOR));
    3325         294 :         if (pAktColl && pStyles)
    3326         242 :             pStyles->bTxtColChanged = true;
    3327             :     }
    3328             : }
    3329             : 
    3330        4610 : void SwWW8ImplReader::Read_TxtForeColor(sal_uInt16, const sal_uInt8* pData, short nLen)
    3331             : {
    3332        4610 :     if( nLen < 0 )
    3333        2186 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
    3334             :     else
    3335             :     {
    3336        2424 :         Color aColor(msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)));
    3337        2424 :         NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR));
    3338        2424 :         if (pAktColl && pStyles)
    3339         136 :             pStyles->bTxtColChanged = true;
    3340             :     }
    3341        4610 : }
    3342             : 
    3343           2 : void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, short nLen)
    3344             : {
    3345           2 :     if( nLen < 0 )
    3346             :     {
    3347             :         //because the UnderlineColor is not a standalone attribute in SW, it belongs to the underline attribute.
    3348             :         //And, the .doc file stores attributes separately, this attribute ends here, the "underline"
    3349             :         //attribute also terminates (if the character next owns underline, that will be a new underline attribute).
    3350             :         //so nothing is left to be done here.
    3351           2 :         return;
    3352             :     }
    3353             :     else
    3354             :     {
    3355           2 :         if ( pAktColl ) //importing style
    3356             :         {
    3357           2 :             if( SfxItemState::SET == pAktColl->GetItemState( RES_CHRATR_UNDERLINE, false ) )
    3358             :             {
    3359           0 :                 const SwAttrSet& aSet = pAktColl->GetAttrSet();
    3360             :                 SvxUnderlineItem *pUnderline
    3361           0 :                     = (SvxUnderlineItem *)(aSet.Get( RES_CHRATR_UNDERLINE, false ).Clone());
    3362           0 :                 if(pUnderline){
    3363           0 :                     pUnderline->SetColor( Color( msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) ) );
    3364           0 :                     pAktColl->SetFmtAttr( *pUnderline );
    3365           0 :                     delete pUnderline;
    3366             :                 }
    3367             :             }
    3368             :         }
    3369           0 :         else if ( pAktItemSet )
    3370             :         {
    3371           0 :             if ( SfxItemState::SET == pAktItemSet->GetItemState( RES_CHRATR_UNDERLINE, false ) )
    3372             :             {
    3373             :                 SvxUnderlineItem *pUnderline
    3374           0 :                     = (SvxUnderlineItem *)(pAktItemSet->Get( RES_CHRATR_UNDERLINE, false ) .Clone());
    3375           0 :                 if(pUnderline){
    3376           0 :                     pUnderline->SetColor( Color( msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) ) );
    3377           0 :                     pAktItemSet->Put( *pUnderline );
    3378           0 :                     delete pUnderline;
    3379             :                 }
    3380             :             }
    3381             :         }
    3382             :         else
    3383             :         {
    3384           0 :             SvxUnderlineItem* pUnderlineAttr = (SvxUnderlineItem*)pCtrlStck->GetOpenStackAttr( *pPaM->GetPoint(), RES_CHRATR_UNDERLINE );
    3385           0 :             if( pUnderlineAttr != NULL )
    3386           0 :                 pUnderlineAttr->SetColor( Color( msfilter::util::BGRToRGB(SVBT32ToUInt32( pData ))));
    3387             :         }
    3388             :     }
    3389             : }
    3390       15822 : bool SwWW8ImplReader::GetFontParams( sal_uInt16 nFCode, FontFamily& reFamily,
    3391             :     OUString& rName, FontPitch& rePitch, rtl_TextEncoding& reCharSet )
    3392             : {
    3393             :     // Die Defines, aus denen diese Tabellen erzeugt werden, stehen in windows.h
    3394             :     static const FontPitch ePitchA[] =
    3395             :     {
    3396             :         PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, PITCH_DONTKNOW
    3397             :     };
    3398             : 
    3399             :     static const FontFamily eFamilyA[] =
    3400             :     {
    3401             :         FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
    3402             :         FAMILY_SCRIPT, FAMILY_DECORATIVE, FAMILY_DONTKNOW, FAMILY_DONTKNOW
    3403             :     };
    3404             : 
    3405       15822 :     const WW8_FFN* pF = pFonts->GetFont( nFCode );  // Info dazu
    3406       15822 :     if( !pF )                                   // FontNummer unbekannt ?
    3407         330 :         return false;                           // dann ignorieren
    3408             : 
    3409       15492 :     rName = pF->sFontname;
    3410             : 
    3411             :     // pF->prg : Pitch
    3412       15492 :     rePitch = ePitchA[pF->prg];
    3413             : 
    3414             :     // pF->chs: Charset
    3415       15492 :     if( 77 == pF->chs )             // Mac-Font im Mac-Charset oder
    3416           6 :         reCharSet = eTextCharSet;   // auf ANSI-Charset uebersetzt
    3417             :     else
    3418             :     { // patch from cmc for #i52786#
    3419             :         // #i52786#, for word 67 we'll assume that ANSI is basically invalid,
    3420             :         // might be true for (above) mac as well, but would need a mac example
    3421             :         // that exercises this to be sure
    3422       15486 :         if (bVer67 && pF->chs == 0)
    3423           0 :             reCharSet = RTL_TEXTENCODING_DONTKNOW;
    3424             :         else
    3425       15486 :             reCharSet = rtl_getTextEncodingFromWindowsCharset( pF->chs );
    3426             :     }
    3427             : 
    3428             :     // Make sure charset is not set in case of Symbol, otherwise in case a
    3429             :     // character is missing in our OpenSymbol, the character won't be replaced.
    3430       15492 :     if (reCharSet == RTL_TEXTENCODING_SYMBOL && rName == "Symbol")
    3431        1152 :         reCharSet = RTL_TEXTENCODING_DONTKNOW;
    3432             : 
    3433             :     // make sure Font Family Code is set correctly
    3434             :     // at least for the most important fonts
    3435             :     // ( might be set wrong when Doc was not created by
    3436             :     //   Winword but by third party program like Applixware... )
    3437       46476 :     if (rName.startsWithIgnoreAsciiCase("Tms Rmn") ||
    3438       30984 :         rName.startsWithIgnoreAsciiCase("Timmons") ||
    3439       30980 :         rName.startsWithIgnoreAsciiCase("CG Times") ||
    3440       30976 :         rName.startsWithIgnoreAsciiCase("MS Serif") ||
    3441       30976 :         rName.startsWithIgnoreAsciiCase("Garamond") ||
    3442       46468 :         rName.startsWithIgnoreAsciiCase("Times Roman") ||
    3443       15488 :         rName.startsWithIgnoreAsciiCase("Times New Roman"))
    3444             :     {
    3445        1314 :         reFamily = FAMILY_ROMAN;
    3446             :     }
    3447       42402 :     else if (rName.startsWithIgnoreAsciiCase("Helv") ||
    3448       21310 :              rName.startsWithIgnoreAsciiCase("Arial") ||
    3449       14516 :              rName.startsWithIgnoreAsciiCase("Univers") ||
    3450       14504 :              rName.startsWithIgnoreAsciiCase("LinePrinter") ||
    3451       14488 :              rName.startsWithIgnoreAsciiCase("Lucida Sans") ||
    3452       28650 :              rName.startsWithIgnoreAsciiCase("Small Fonts") ||
    3453        7236 :              rName.startsWithIgnoreAsciiCase("MS Sans Serif"))
    3454             :     {
    3455        6942 :         reFamily = FAMILY_SWISS;
    3456             :     }
    3457             :     else
    3458             :     {
    3459        7236 :         reFamily = eFamilyA[pF->ff];
    3460             :     }
    3461             : 
    3462       15492 :     return true;
    3463             : }
    3464             : 
    3465       15822 : bool SwWW8ImplReader::SetNewFontAttr(sal_uInt16 nFCode, bool bSetEnums,
    3466             :     sal_uInt16 nWhich)
    3467             : {
    3468             :     FontFamily eFamily;
    3469       15822 :     OUString aName;
    3470             :     FontPitch ePitch;
    3471             :     rtl_TextEncoding eSrcCharSet;
    3472             : 
    3473       15822 :     if( !GetFontParams( nFCode, eFamily, aName, ePitch, eSrcCharSet ) )
    3474             :     {
    3475             :         //If we fail (and are not doing a style) then put something into the
    3476             :         //character encodings stack anyway so that the property end that pops
    3477             :         //off the stack will keep in sync
    3478         330 :         if (!pAktColl && IsListOrDropcap())
    3479             :         {
    3480         236 :             if (nWhich == RES_CHRATR_CJK_FONT)
    3481             :             {
    3482           0 :                 if (!maFontSrcCJKCharSets.empty())
    3483             :                 {
    3484           0 :                     eSrcCharSet = maFontSrcCJKCharSets.top();
    3485             :                 }
    3486             :                 else
    3487             :                 {
    3488           0 :                     eSrcCharSet = RTL_TEXTENCODING_DONTKNOW;
    3489             :                 }
    3490             : 
    3491           0 :                 maFontSrcCJKCharSets.push(eSrcCharSet);
    3492             :             }
    3493             :             else
    3494             :             {
    3495         236 :                 if (!maFontSrcCharSets.empty())
    3496             :                 {
    3497         118 :                     eSrcCharSet = maFontSrcCharSets.top();
    3498             :                 }
    3499             :                 else
    3500             :                 {
    3501         118 :                     eSrcCharSet = RTL_TEXTENCODING_DONTKNOW;
    3502             :                 }
    3503             : 
    3504         236 :                 maFontSrcCharSets.push(eSrcCharSet);
    3505             :             }
    3506             :         }
    3507         330 :         return false;
    3508             :     }
    3509             : 
    3510       15492 :     rtl_TextEncoding eDstCharSet = eSrcCharSet;
    3511             : 
    3512       30984 :     SvxFontItem aFont( eFamily, aName, OUString(), ePitch, eDstCharSet, nWhich);
    3513             : 
    3514       15492 :     if( bSetEnums )
    3515             :     {
    3516       15492 :         if( pAktColl && nAktColl < vColl.size() ) // StyleDef
    3517             :         {
    3518        2960 :             switch(nWhich)
    3519             :             {
    3520             :                 default:
    3521             :                 case RES_CHRATR_FONT:
    3522         848 :                     vColl[nAktColl].eLTRFontSrcCharSet = eSrcCharSet;
    3523         848 :                     break;
    3524             :                 case RES_CHRATR_CTL_FONT:
    3525        1704 :                     vColl[nAktColl].eRTLFontSrcCharSet = eSrcCharSet;
    3526        1704 :                     break;
    3527             :                 case RES_CHRATR_CJK_FONT:
    3528         408 :                     vColl[nAktColl].eCJKFontSrcCharSet = eSrcCharSet;
    3529         408 :                     break;
    3530             :             }
    3531             :         }
    3532       12532 :         else if (IsListOrDropcap())
    3533             :         {
    3534             :             //Add character text encoding to stack
    3535        9746 :             if (nWhich  == RES_CHRATR_CJK_FONT)
    3536         120 :                 maFontSrcCJKCharSets.push(eSrcCharSet);
    3537             :             else
    3538        9626 :                 maFontSrcCharSets.push(eSrcCharSet);
    3539             :         }
    3540             :     }
    3541             : 
    3542       15492 :     NewAttr( aFont );                       // ...und 'reinsetzen
    3543             : 
    3544       31314 :     return true;
    3545             : }
    3546             : 
    3547        9512 : void SwWW8ImplReader::ResetCharSetVars()
    3548             : {
    3549             :     OSL_ENSURE(!maFontSrcCharSets.empty(),"no charset to remove");
    3550        9512 :     if (!maFontSrcCharSets.empty())
    3551        9512 :         maFontSrcCharSets.pop();
    3552        9512 : }
    3553             : 
    3554         102 : void SwWW8ImplReader::ResetCJKCharSetVars()
    3555             : {
    3556             :     OSL_ENSURE(!maFontSrcCJKCharSets.empty(),"no charset to remove");
    3557         102 :     if (!maFontSrcCJKCharSets.empty())
    3558         102 :         maFontSrcCJKCharSets.pop();
    3559         102 : }
    3560             : 
    3561       15380 : void SwWW8ImplReader::openFont(sal_uInt16 nFCode, sal_uInt16 nId)
    3562             : {
    3563       15380 :     if (SetNewFontAttr(nFCode, true, nId) && pAktColl && pStyles)
    3564             :     {
    3565             :         // merken zur Simulation Default-Font
    3566        2566 :         if (RES_CHRATR_CJK_FONT == nId)
    3567         258 :             pStyles->bCJKFontChanged = true;
    3568        2308 :         else if (RES_CHRATR_CTL_FONT == nId)
    3569        1582 :             pStyles->bCTLFontChanged = true;
    3570             :         else
    3571         726 :             pStyles->bFontChanged = true;
    3572             :     }
    3573       15380 : }
    3574             : 
    3575        9614 : void SwWW8ImplReader::closeFont(sal_uInt16 nId)
    3576             : {
    3577        9614 :     pCtrlStck->SetAttr( *pPaM->GetPoint(), nId );
    3578        9614 :     if (nId == RES_CHRATR_CJK_FONT)
    3579         102 :         ResetCJKCharSetVars();
    3580             :     else
    3581        9512 :         ResetCharSetVars();
    3582        9614 : }
    3583             : 
    3584             : /*
    3585             :     Font ein oder ausschalten:
    3586             : */
    3587       25336 : void SwWW8ImplReader::Read_FontCode( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    3588             : {
    3589       25336 :     if (!bSymbol)           // falls bSymbol, gilt der am Symbol
    3590             :     {                       // (siehe sprmCSymbol) gesetzte Font !
    3591       25336 :         switch( nId )
    3592             :         {
    3593             :             case 113:       //WW7
    3594             :             case 0x4A51:    //"Other" font, override with BiDi if it exists
    3595             :             case 0x4A5E:    //BiDi Font
    3596       17454 :                 nId = RES_CHRATR_CTL_FONT;
    3597       17454 :                 break;
    3598             :             case 93:        //WW6
    3599             :             case 111:       //WW7
    3600             :             case 0x4A4f:
    3601        7054 :                 nId = RES_CHRATR_FONT;
    3602        7054 :                 break;
    3603             :             case 112:       //WW7
    3604             :             case 0x4A50:
    3605         486 :                 nId = RES_CHRATR_CJK_FONT;
    3606         486 :                 break;
    3607             :             default:
    3608       25678 :                 return ;
    3609             :         }
    3610             : 
    3611       24994 :         ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    3612             : 
    3613       24994 :         if( nLen < 0 ) // Ende des Attributes
    3614             :         {
    3615        9614 :             if (eVersion <= ww::eWW6)
    3616             :             {
    3617           0 :                 closeFont(RES_CHRATR_CTL_FONT);
    3618           0 :                 closeFont(RES_CHRATR_CJK_FONT);
    3619             :             }
    3620        9614 :             closeFont(nId);
    3621             :         }
    3622             :         else
    3623             :         {
    3624       15380 :             sal_uInt16 nFCode = SVBT16ToShort( pData );     // Font-Nummer
    3625       15380 :             openFont(nFCode, nId);
    3626       15380 :             if (eVersion <= ww::eWW6)
    3627             :             {
    3628           0 :                 openFont(nFCode, RES_CHRATR_CJK_FONT);
    3629           0 :                 openFont(nFCode, RES_CHRATR_CTL_FONT);
    3630             :             }
    3631             :         }
    3632             :     }
    3633             : }
    3634             : 
    3635       13984 : void SwWW8ImplReader::Read_FontSize( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    3636             : {
    3637       13984 :     switch( nId )
    3638             :     {
    3639             :         case 74:
    3640             :         case 99:
    3641             :         case 0x4a43:
    3642        9118 :             nId = RES_CHRATR_FONTSIZE;
    3643        9118 :             break;
    3644             :         case 85:  //WW2
    3645             :         case 116: //WW7
    3646             :         case 0x4a61:
    3647        4866 :             nId = RES_CHRATR_CTL_FONTSIZE;
    3648        4866 :             break;
    3649             :         default:
    3650       13984 :             return ;
    3651             :     }
    3652             : 
    3653       13984 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    3654             : 
    3655       13984 :     if( nLen < 0 )          // Ende des Attributes
    3656             :     {
    3657        5902 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), nId  );
    3658        5902 :         if (eVersion <= ww::eWW6) // reset additionally the CTL size
    3659         170 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_CTL_FONTSIZE );
    3660        5902 :         if (RES_CHRATR_FONTSIZE == nId)  // reset additionally the CJK size
    3661        3948 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_CJK_FONTSIZE );
    3662             :     }
    3663             :     else
    3664             :     {
    3665             :         // Font-Size in half points e.g. 10 = 1440 / ( 72 * 2 )
    3666        8082 :         sal_uInt16 nFSize = eVersion <= ww::eWW2 ? *pData : SVBT16ToShort(pData);
    3667        8082 :         nFSize*= 10;
    3668             : 
    3669        8082 :         SvxFontHeightItem aSz( nFSize, 100, nId );
    3670        8082 :         NewAttr( aSz );
    3671        8082 :         if (RES_CHRATR_FONTSIZE == nId)  // set additionally the CJK size
    3672             :         {
    3673        5170 :             aSz.SetWhich( RES_CHRATR_CJK_FONTSIZE );
    3674        5170 :             NewAttr( aSz );
    3675             :         }
    3676        8082 :         if (eVersion <= ww::eWW6) // set additionally the CTL size
    3677             :         {
    3678         172 :             aSz.SetWhich( RES_CHRATR_CTL_FONTSIZE );
    3679         172 :             NewAttr( aSz );
    3680             :         }
    3681        8082 :         if (pAktColl && pStyles)            // Style-Def ?
    3682             :         {
    3683             :             // merken zur Simulation Default-FontSize
    3684        1840 :             if (nId == RES_CHRATR_CTL_FONTSIZE)
    3685         854 :                 pStyles->bFCTLSizeChanged = true;
    3686             :             else
    3687             :             {
    3688         986 :                 pStyles->bFSizeChanged = true;
    3689         986 :                 if (eVersion <= ww::eWW6)
    3690           2 :                     pStyles->bFCTLSizeChanged= true;
    3691             :             }
    3692        8082 :         }
    3693             :     }
    3694             : }
    3695             : 
    3696           0 : void SwWW8ImplReader::Read_CharSet(sal_uInt16 , const sal_uInt8* pData, short nLen)
    3697             : {
    3698           0 :     if( nLen < 0 )
    3699             :     {                   // Ende des Attributes
    3700           0 :         eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
    3701           0 :         return;
    3702             :     }
    3703           0 :     sal_uInt8 nfChsDiff = *pData;
    3704             : 
    3705           0 :     if( nfChsDiff )
    3706           0 :         eHardCharSet = rtl_getTextEncodingFromWindowsCharset( *(pData + 1) );
    3707             :     else
    3708           0 :         eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
    3709             : }
    3710             : 
    3711        9702 : void SwWW8ImplReader::Read_Language( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    3712             : {
    3713        9702 :     switch( nId )
    3714             :     {
    3715             :         case 97:
    3716             :         case 0x486D: //sprmCRgLid0_80
    3717             :         case 0x4873: //Methinks, uncertain
    3718        3858 :             nId = RES_CHRATR_LANGUAGE;
    3719        3858 :             break;
    3720             :         case 0x486E: //sprmCRgLid1_80
    3721             :         case 0x4874: //Methinks, uncertain
    3722         558 :             nId = RES_CHRATR_CJK_LANGUAGE;
    3723         558 :             break;
    3724             :         case 83:
    3725             :         case 114:
    3726             :         case 0x485F:
    3727        5284 :             nId = RES_CHRATR_CTL_LANGUAGE;
    3728        5284 :             break;
    3729             :         default:
    3730        9704 :             return;
    3731             :     }
    3732             : 
    3733        9700 :     if( nLen < 0 )                  // Ende des Attributes
    3734        4224 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), nId );
    3735             :     else
    3736             :     {
    3737        5476 :         sal_uInt16 nLang = SVBT16ToShort( pData );  // Language-Id
    3738        5476 :         NewAttr(SvxLanguageItem((const LanguageType)nLang, nId));
    3739             :     }
    3740             : }
    3741             : 
    3742             : /*
    3743             :     Einschalten des Zeichen-Styles:
    3744             : */
    3745         128 : void SwWW8ImplReader::Read_CColl( sal_uInt16, const sal_uInt8* pData, short nLen )
    3746             : {
    3747         128 :     if( nLen < 0 ){                 // Ende des Attributes
    3748          64 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CHARFMT );
    3749          64 :         nCharFmt = -1;
    3750          64 :         return;
    3751             :     }
    3752          64 :     sal_uInt16 nId = SVBT16ToShort( pData );    // Style-Id (NICHT Sprm-Id!)
    3753             : 
    3754         192 :     if( nId >= vColl.size() || !vColl[nId].pFmt  // ungueltige Id ?
    3755         128 :         || vColl[nId].bColl )              // oder Para-Style ?
    3756           0 :         return;                             // dann ignorieren
    3757             : 
    3758             :     // if current on loading a TOX field, and current trying to apply a hyperlink character style,
    3759             :     // just ignore. For the hyperlinks inside TOX in MS Word is not same with a common hyperlink
    3760             :     // Character styles: without underline and blue font color. And such type style will be applied in others
    3761             :     // processes.
    3762          64 :     if (mbLoadingTOXCache && vColl[nId].GetWWStyleId() == ww::stiHyperlink)
    3763             :     {
    3764           0 :         return;
    3765             :     }
    3766             : 
    3767          64 :     NewAttr( SwFmtCharFmt( (SwCharFmt*)vColl[nId].pFmt ) );
    3768          64 :     nCharFmt = (short) nId;
    3769             : }
    3770             : 
    3771             : /*
    3772             :     enger oder weiter als normal:
    3773             : */
    3774          94 : void SwWW8ImplReader::Read_Kern( sal_uInt16, const sal_uInt8* pData, short nLen )
    3775             : {
    3776          94 :     if( nLen < 0 ){                 // Ende des Attributes
    3777           8 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_KERNING );
    3778         102 :         return;
    3779             :     }
    3780          86 :     sal_Int16 nKern = SVBT16ToShort( pData );    // Kerning in Twips
    3781          86 :     NewAttr( SvxKerningItem( nKern, RES_CHRATR_KERNING ) );
    3782             : }
    3783             : 
    3784         138 : void SwWW8ImplReader::Read_FontKern( sal_uInt16, const sal_uInt8* , short nLen )
    3785             : {
    3786         138 :     if( nLen < 0 ) // Ende des Attributes
    3787           8 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_AUTOKERN );
    3788             :     else
    3789         130 :         NewAttr(SvxAutoKernItem(true, RES_CHRATR_AUTOKERN));
    3790         138 : }
    3791             : 
    3792          56 : void SwWW8ImplReader::Read_CharShadow(  sal_uInt16, const sal_uInt8* pData, short nLen )
    3793             : {
    3794             :     //Has newer colour variant, ignore this old variant
    3795          56 :     if (!bVer67 && pPlcxMan && pPlcxMan->GetChpPLCF()->HasSprm(0xCA71))
    3796         112 :         return;
    3797             : 
    3798           0 :     if( nLen <= 0 )
    3799             :     {
    3800           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
    3801           0 :         if( bCharShdTxtCol )
    3802             :         {
    3803             :             // Zeichenfarbe auch
    3804           0 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
    3805           0 :             bCharShdTxtCol = false;
    3806             :         }
    3807             :     }
    3808             :     else
    3809             :     {
    3810           0 :         WW8_SHD aSHD;
    3811           0 :         aSHD.SetWWValue( *(SVBT16*)pData );
    3812           0 :         SwWW8Shade aSh( bVer67, aSHD );
    3813             : 
    3814           0 :         NewAttr( SvxBrushItem( aSh.aColor, RES_CHRATR_BACKGROUND ));
    3815             :     }
    3816             : }
    3817             : 
    3818          56 : void SwWW8ImplReader::Read_TxtBackColor(sal_uInt16, const sal_uInt8* pData, short nLen )
    3819             : {
    3820          56 :     if( nLen <= 0 )
    3821             :     {
    3822          28 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
    3823          28 :         if( bCharShdTxtCol )
    3824             :         {
    3825             :             // Zeichenfarbe auch
    3826           0 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
    3827           0 :             bCharShdTxtCol = false;
    3828             :         }
    3829             :     }
    3830             :     else
    3831             :     {
    3832             :         OSL_ENSURE(nLen == 10, "Len of para back colour not 10!");
    3833          28 :         if (nLen != 10)
    3834          56 :             return;
    3835          28 :         Color aColour(ExtractColour(pData, bVer67));
    3836          28 :         NewAttr(SvxBrushItem(aColour, RES_CHRATR_BACKGROUND));
    3837             :     }
    3838             : }
    3839             : 
    3840         628 : void SwWW8ImplReader::Read_CharHighlight(sal_uInt16, const sal_uInt8* pData, short nLen)
    3841             : {
    3842         628 :     if( nLen <= 0 )
    3843             :     {
    3844         314 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
    3845         314 :         if( bCharShdTxtCol )
    3846             :         {
    3847           0 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );  // Zeichenfarbe auch
    3848           0 :             bCharShdTxtCol = false;
    3849             :         }
    3850             :     }
    3851             :     else
    3852             :     {
    3853         314 :         sal_uInt8 b = *pData;            // Parameter: 0 = Auto, 1..16 Farben
    3854             : 
    3855         314 :         if( b > 16 )                // unbekannt -> Black
    3856           0 :             b = 0;                  // Auto -> Black
    3857             : 
    3858         314 :         Color aCol(GetCol(b));
    3859         314 :         NewAttr( SvxBrushItem( aCol , RES_CHRATR_BACKGROUND ));
    3860             :     }
    3861         628 : }
    3862             : 
    3863         188 : void SwWW8ImplReader::Read_NoLineNumb(sal_uInt16 , const sal_uInt8* pData, short nLen)
    3864             : {
    3865         188 :     if( nLen < 0 )  // Ende des Attributes
    3866             :     {
    3867           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_LINENUMBER );
    3868         188 :         return;
    3869             :     }
    3870         188 :     SwFmtLineNumber aLN;
    3871         188 :     if (const SwFmtLineNumber* pLN
    3872         188 :         = (const SwFmtLineNumber*)GetFmtAttr(RES_LINENUMBER))
    3873             :     {
    3874         188 :         aLN.SetStartValue( pLN->GetStartValue() );
    3875             :     }
    3876             : 
    3877         188 :     aLN.SetCountLines( pData && (0 == *pData) );
    3878         188 :     NewAttr( aLN );
    3879             : }
    3880             : 
    3881          78 : bool lcl_HasExplicitLeft(const WW8PLCFMan *pPlcxMan, bool bVer67)
    3882             : {
    3883          78 :     WW8PLCFx_Cp_FKP *pPap = pPlcxMan ? pPlcxMan->GetPapPLCF() : 0;
    3884          78 :     if (pPap)
    3885             :     {
    3886          78 :         if (bVer67)
    3887           0 :             return pPap->HasSprm(17);
    3888             :         else
    3889          78 :             return (pPap->HasSprm(0x840F) || pPap->HasSprm(0x845E));
    3890             :     }
    3891           0 :     return false;
    3892             : }
    3893             : // Sprm 16, 17
    3894        7204 : void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    3895             : {
    3896        7204 :     if (nLen < 0)  // End of the Attributes
    3897             :     {
    3898        3180 :         pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_LR_SPACE);
    3899        6360 :         return;
    3900             :     }
    3901             : 
    3902        4024 :     short nPara = SVBT16ToShort( pData );
    3903             : 
    3904        4024 :     SvxLRSpaceItem aLR( RES_LR_SPACE );
    3905        4024 :     const SfxPoolItem* pLR = GetFmtAttr(RES_LR_SPACE);
    3906        4024 :     if( pLR )
    3907        4024 :         aLR = *static_cast<const SvxLRSpaceItem*>(pLR);
    3908             : 
    3909             :     // Fix the regression issue: #i99822#: Discussion?
    3910             :     // Since the list level formatting doesn't apply into paragraph style
    3911             :     // for list levels of mode LABEL_ALIGNMENT.(see ww8par3.cxx
    3912             :     // W8ImplReader::RegisterNumFmtOnTxtNode).
    3913             :     // Need to apply the list format to the paragraph here.
    3914        4024 :     SwTxtNode* pTxtNode = pPaM->GetNode().GetTxtNode();
    3915        4024 :     if( pTxtNode && pTxtNode->AreListLevelIndentsApplicable() )
    3916             :     {
    3917         184 :         SwNumRule * pNumRule = pTxtNode->GetNumRule();
    3918         184 :         if( pNumRule )
    3919             :         {
    3920         184 :             sal_uInt8 nLvl = static_cast< sal_uInt8 >(pTxtNode->GetActualListLevel());
    3921         184 :             const SwNumFmt* pFmt = pNumRule->GetNumFmt( nLvl );
    3922         184 :             if ( pFmt && pFmt->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    3923             :             {
    3924         184 :                 aLR.SetTxtLeft( pFmt->GetIndentAt() );
    3925         184 :                 aLR.SetTxtFirstLineOfst( static_cast<short>(pFmt->GetFirstLineIndent()) );
    3926             :                 // make paragraph have hard-set indent attributes
    3927         184 :                 pTxtNode->SetAttr( aLR );
    3928             :             }
    3929             :         }
    3930             :     }
    3931             : 
    3932             :     /*
    3933             :     The older word sprms mean left/right, while the new ones mean before/after.
    3934             :     Writer now also works with before after, so when we see old left/right and
    3935             :     we're RTL. We swap them
    3936             :     */
    3937        4024 :     if (IsRightToLeft())
    3938             :     {
    3939        1420 :         switch (nId)
    3940             :         {
    3941             :             //Left becomes after;
    3942             :             case 17:
    3943           0 :                 nId = 16;
    3944           0 :                 break;
    3945             :             case 0x840F:
    3946         684 :                 nId = 0x840E;
    3947         684 :                 break;
    3948             :             //Right becomes before;
    3949             :             case 16:
    3950           0 :                 nId = 17;
    3951           0 :                 break;
    3952             :             case 0x840E:
    3953         684 :                 nId = 0x840F;
    3954         684 :                 break;
    3955             :         }
    3956             :     }
    3957             : 
    3958        4024 :     bool bFirstLinOfstSet( false ); // #i103711#
    3959        4024 :     bool bLeftIndentSet( false ); // #i105414#
    3960             : 
    3961        4024 :     switch (nId)
    3962             :     {
    3963             :         //sprmPDxaLeft
    3964             :         case     17:
    3965             :         case 0x840F:
    3966             :         case 0x845E:
    3967        2210 :             aLR.SetTxtLeft( nPara );
    3968        2210 :             if (pAktColl && nAktColl < vColl.size())
    3969             :             {
    3970         544 :                 vColl[nAktColl].bListReleventIndentSet = true;
    3971             :             }
    3972        2210 :             bLeftIndentSet = true;  // #i105414#
    3973        2210 :             break;
    3974             :         //sprmPDxaLeft1
    3975             :         case     19:
    3976             :         case 0x8411:
    3977             :         case 0x8460:
    3978             :             /*
    3979             :             As part of an attempt to break my spirit ww 8+ formats can contain
    3980             :             ww 7- lists. If they do and the list is part of the style, then
    3981             :             when removing the list from a paragraph of that style there
    3982             :             appears to be a bug where the hanging indent value which the list
    3983             :             set is still factored into the left indent of the paragraph. Its
    3984             :             not listed in the winword dialogs, but it is clearly there. So if
    3985             :             our style has a broken ww 7- list and we know that the list has
    3986             :             been removed then we will factor the original list applied hanging
    3987             :             into our calculation.
    3988             :             */
    3989         720 :             if (pPlcxMan && nAktColl < vColl.size() && vColl[nAktColl].bHasBrokenWW6List)
    3990             :             {
    3991           0 :                 const sal_uInt8 *pIsZeroed = pPlcxMan->GetPapPLCF()->HasSprm(0x460B);
    3992           0 :                 if (pIsZeroed && *pIsZeroed == 0)
    3993             :                 {
    3994             :                     const SvxLRSpaceItem &rLR =
    3995           0 :                         ItemGet<SvxLRSpaceItem>(*(vColl[nAktColl].pFmt),
    3996           0 :                         RES_LR_SPACE);
    3997           0 :                     nPara = nPara - rLR.GetTxtFirstLineOfst();
    3998             :                 }
    3999             :             }
    4000             : 
    4001         720 :             aLR.SetTxtFirstLineOfst(nPara);
    4002             : 
    4003         720 :             if (!pAktColl)
    4004             :             {
    4005         538 :                 if (const SwTxtNode* pNode = pPaM->GetNode().GetTxtNode())
    4006             :                 {
    4007         538 :                     if ( const SwNumFmt *pNumFmt = GetNumFmtFromTxtNode(*pNode) )
    4008             :                     {
    4009          78 :                         if (!lcl_HasExplicitLeft(pPlcxMan, bVer67))
    4010             :                         {
    4011           0 :                             aLR.SetTxtLeft(pNumFmt->GetIndentAt());
    4012             : 
    4013             :                             // If have not explicit left, set number format list tab position is doc default tab
    4014           0 :                             const SvxTabStopItem *pDefaultStopItem = (const SvxTabStopItem *)rDoc.GetAttrPool().GetPoolDefaultItem(RES_PARATR_TABSTOP);
    4015           0 :                             if ( pDefaultStopItem &&  pDefaultStopItem->Count() > 0 )
    4016           0 :                                 ((SwNumFmt*)(pNumFmt))->SetListtabPos( ((SvxTabStop&)(*pDefaultStopItem)[0]).GetTabPos() );
    4017             :                         }
    4018             :                     }
    4019             :                 }
    4020             :             }
    4021         720 :             if (pAktColl && nAktColl < vColl.size())
    4022             :             {
    4023         182 :                 vColl[nAktColl].bListReleventIndentSet = true;
    4024             :             }
    4025         720 :             bFirstLinOfstSet = true; // #i103711#
    4026         720 :             break;
    4027             :         //sprmPDxaRight
    4028             :         case     16:
    4029             :         case 0x840E:
    4030             :         case 0x845D:
    4031        1094 :             aLR.SetRight( nPara );
    4032        1094 :             break;
    4033             :         default:
    4034           0 :             return;
    4035             :     }
    4036             : 
    4037        4024 :     NewAttr( aLR, bFirstLinOfstSet, bLeftIndentSet ); // #i103711#, #i105414#
    4038             : }
    4039             : 
    4040             : // Sprm 20
    4041         942 : void SwWW8ImplReader::Read_LineSpace( sal_uInt16, const sal_uInt8* pData, short nLen )
    4042             : {
    4043             : // Kommentear siehe Read_UL()
    4044         942 :     if (bStyNormal && bWWBugNormal)
    4045         298 :         return;
    4046             : 
    4047         942 :     if( nLen < 0 ){
    4048         298 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_LINESPACING );
    4049         298 :         if( !( nIniFlags & WW8FL_NO_IMPLPASP ) )
    4050         298 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_UL_SPACE );
    4051         298 :         return;
    4052             :     }
    4053             : 
    4054         644 :     short nSpace = SVBT16ToShort( pData );
    4055         644 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    4056         644 :     short nMulti = (eVersion <= ww::eWW2) ? 1 : SVBT16ToShort( pData + 2 );
    4057             : 
    4058             :     SvxLineSpace eLnSpc;
    4059         644 :     if( 0 > nSpace )
    4060             :     {
    4061          34 :         nSpace = -nSpace;
    4062          34 :         eLnSpc = SVX_LINE_SPACE_FIX;
    4063             :     }
    4064             :     else
    4065         610 :         eLnSpc = SVX_LINE_SPACE_MIN;
    4066             : 
    4067             : // WW hat einen impliziten zusaetzlichen Absatzabstand abhaengig vom
    4068             : // Zeilenabstand. Er betraegt bei "genau", 0.8*Zeilenabstand "vor" und
    4069             : // 0.2*Zeilenabstand "nach".
    4070             : // Bei "Mindestens" sind es 1*Zeilenabstand "vor" und 0*Zeilenabstand "nach".
    4071             : // Bei Mehrfach sind es 0 "vor" und min( 0cm, FontSize*(nFach-1) ) "nach".
    4072             : 
    4073             : // SW hat auch einen impliziten Zeilenabstand. er betraegt bei "mindestens"
    4074             : // 1*Zeilenabstand "vor" und 0 "nach"
    4075             : // bei proportional betraegt er min( 0cm, FontSize*(nFach-1) ) sowohl "vor"
    4076             : // wie auch "nach"
    4077             : 
    4078         644 :     sal_uInt16 nSpaceTw = 0;
    4079             : 
    4080         644 :     SvxLineSpacingItem aLSpc( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING );
    4081             : 
    4082         644 :     if( 1 == nMulti )               // MultilineSpace ( proportional )
    4083             :     {
    4084         492 :         long n = nSpace * 10 / 24;  // WW: 240 = 100%, SW: 100 = 100%
    4085             : 
    4086             : // nach Absprache mit AMA ist die Begrenzung unsinnig
    4087         492 :         if( n>200 ) n = 200;        // SW_UI-Maximum
    4088         492 :         aLSpc.SetPropLineSpace( (const sal_uInt8)n );
    4089             :         const SvxFontHeightItem* pH = (const SvxFontHeightItem*)
    4090         492 :             GetFmtAttr( RES_CHRATR_FONTSIZE );
    4091         492 :         nSpaceTw = (sal_uInt16)( n * pH->GetHeight() / 100 );
    4092             :     }
    4093             :     else                            // Fixed / Minimum
    4094             :     {
    4095             :         // bei negativen Space ist der Abstand exakt, sonst minimum
    4096         152 :         nSpaceTw = (sal_uInt16)nSpace;
    4097         152 :         aLSpc.SetLineHeight( nSpaceTw );
    4098         152 :         aLSpc.GetLineSpaceRule() = eLnSpc;
    4099             :     }
    4100         644 :     NewAttr( aLSpc );
    4101         644 :     if( pSFlyPara )
    4102         114 :         pSFlyPara->nLineSpace = nSpaceTw;   // LineSpace fuer Graf-Apos
    4103             : }
    4104             : 
    4105             : //#i18519# AutoSpace value depends on Dop fDontUseHTMLAutoSpacing setting
    4106          84 : sal_uInt16 SwWW8ImplReader::GetParagraphAutoSpace(bool fDontUseHTMLAutoSpacing)
    4107             : {
    4108          84 :     if (fDontUseHTMLAutoSpacing)
    4109          60 :         return 100;  //Seems to be always 5points in this case
    4110             :     else
    4111          24 :         return 280;  //Seems to be always 14points in this case
    4112             : }
    4113             : 
    4114          42 : void SwWW8ImplReader::Read_ParaAutoBefore(sal_uInt16, const sal_uInt8 *pData, short nLen)
    4115             : {
    4116          42 :     if (nLen < 0)
    4117             :     {
    4118           0 :         pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_UL_SPACE);
    4119          42 :         return;
    4120             :     }
    4121             : 
    4122          42 :     if (*pData)
    4123             :     {
    4124          42 :         SvxULSpaceItem aUL(*(const SvxULSpaceItem*)GetFmtAttr(RES_UL_SPACE));
    4125          42 :         aUL.SetUpper(GetParagraphAutoSpace(pWDop->fDontUseHTMLAutoSpacing));
    4126          42 :         NewAttr(aUL);
    4127          42 :         if (pAktColl && nAktColl < vColl.size())
    4128          42 :             vColl[nAktColl].bParaAutoBefore = true;
    4129             :         else
    4130           0 :             bParaAutoBefore = true;
    4131             :     }
    4132             :     else
    4133             :     {
    4134           0 :         if (pAktColl && nAktColl < vColl.size())
    4135           0 :             vColl[nAktColl].bParaAutoBefore = false;
    4136             :         else
    4137           0 :             bParaAutoBefore = false;
    4138             :     }
    4139             : }
    4140             : 
    4141          42 : void SwWW8ImplReader::Read_ParaAutoAfter(sal_uInt16, const sal_uInt8 *pData, short nLen)
    4142             : {
    4143          42 :     if (nLen < 0)
    4144             :     {
    4145           0 :         pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_UL_SPACE);
    4146          42 :         return;
    4147             :     }
    4148             : 
    4149          42 :     if (*pData)
    4150             :     {
    4151          42 :         SvxULSpaceItem aUL(*(const SvxULSpaceItem*)GetFmtAttr(RES_UL_SPACE));
    4152          42 :         aUL.SetLower(GetParagraphAutoSpace(pWDop->fDontUseHTMLAutoSpacing));
    4153          42 :         NewAttr(aUL);
    4154          42 :         if (pAktColl && nAktColl < vColl.size())
    4155          42 :             vColl[nAktColl].bParaAutoAfter = true;
    4156             :         else
    4157           0 :             bParaAutoAfter = true;
    4158             :     }
    4159             :     else
    4160             :     {
    4161           0 :         if (pAktColl && nAktColl < vColl.size())
    4162           0 :             vColl[nAktColl].bParaAutoAfter = false;
    4163             :         else
    4164           0 :             bParaAutoAfter = false;
    4165             :     }
    4166             : }
    4167             : 
    4168             : // Sprm 21, 22
    4169        3272 : void SwWW8ImplReader::Read_UL( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    4170             : {
    4171             : // Nun eine Umpopelung eines WW-Fehlers: Bei nProduct == 0c03d wird
    4172             : // faelschlicherweise ein DyaAfter 240 ( delta y abstand after, amn.d.?b.)
    4173             : // im Style "Normal" eingefuegt, der
    4174             : // gar nicht da ist. Ueber das IniFlag WW8FL_NO_STY_DYA laesst sich dieses
    4175             : // Verhalten auch fuer andere WW-Versionen erzwingen
    4176             : //  OSL_ENSURE( !bStyNormal || bWWBugNormal, "+Dieses Doc deutet evtl. auf einen
    4177             : // Fehler in der benutzten WW-Version hin. Wenn sich die Styles <Standard> bzw.
    4178             : // <Normal> zwischen WW und SW im Absatz- oder Zeilenabstand unterscheiden,
    4179             : // dann bitte dieses Doc SH zukommen lassen." );
    4180             : // bWWBugNormal ist kein hinreichendes Kriterium dafuer, dass der
    4181             : // angegebene Abstand falsch ist
    4182             : 
    4183        3272 :     if( nLen < 0 )
    4184             :     {
    4185             :         // Ende des Attributes
    4186        1042 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_UL_SPACE );
    4187        2084 :         return;
    4188             :     }
    4189        2230 :     short nPara = SVBT16ToShort( pData );
    4190        2230 :     if( nPara < 0 )
    4191           0 :         nPara = -nPara;
    4192             : 
    4193        2230 :     SvxULSpaceItem aUL( *(const SvxULSpaceItem*)GetFmtAttr( RES_UL_SPACE ));
    4194             : 
    4195        2230 :     switch( nId )
    4196             :     {
    4197             :         //sprmPDyaBefore
    4198             :         case     21:
    4199             :         case 0xA413:
    4200         988 :             aUL.SetUpper( nPara );
    4201         988 :             break;
    4202             :         //sprmPDyaAfter
    4203             :         case     22:
    4204             :         case 0xA414:
    4205        1242 :             aUL.SetLower( nPara );
    4206        1242 :             break;
    4207             :         default:
    4208           0 :             return;
    4209             :     }
    4210             : 
    4211        2230 :     NewAttr( aUL );
    4212             : }
    4213             : 
    4214           6 : void SwWW8ImplReader::Read_ParaContextualSpacing( sal_uInt16, const sal_uInt8* pData, short nLen )
    4215             : {
    4216           6 :     if( nLen < 0 )
    4217             :     {
    4218           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_UL_SPACE );
    4219           6 :         return;
    4220             :     }
    4221           6 :     SvxULSpaceItem aUL( *(const SvxULSpaceItem*)GetFmtAttr( RES_UL_SPACE ));
    4222           6 :     aUL.SetContextValue(*pData);
    4223           6 :     NewAttr( aUL );
    4224             : }
    4225             : 
    4226        7918 : void SwWW8ImplReader::Read_IdctHint( sal_uInt16, const sal_uInt8* pData, short nLen )
    4227             : {
    4228             :     // sprmcidcthint (opcode 0x286f) specifies a script bias for the text in the run.
    4229             :     // for unicode characters that are shared between far east and non-far east scripts,
    4230             :     // this property determines what font and language the character will use.
    4231             :     // when this value is 0, text properties bias towards non-far east properties.
    4232             :     // when this value is 1, text properties bias towards far east properties.
    4233        7918 :     if( nLen < 0 )  //Property end
    4234             :     {
    4235        1904 :         pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_CHRATR_IDCTHINT);
    4236             :     }
    4237             :     else    //Property start
    4238             :     {
    4239        6014 :         sal_uInt8 nVal = *pData;
    4240        6014 :         NewAttr( SfxInt16Item( RES_CHRATR_IDCTHINT, (nVal!=0)? 1 : 0 ) );
    4241             :     }
    4242        7918 : }
    4243             : 
    4244        3322 : void SwWW8ImplReader::Read_Justify( sal_uInt16, const sal_uInt8* pData, short nLen )
    4245             : {
    4246        3322 :     if( nLen < 0 )
    4247             :     {
    4248        1154 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_ADJUST );
    4249        4476 :         return;
    4250             :     }
    4251             : 
    4252        2168 :     SvxAdjust eAdjust(SVX_ADJUST_LEFT);
    4253        2168 :     bool bDistributed = false;
    4254        2168 :     switch (*pData)
    4255             :     {
    4256             :         default:
    4257             :         case 0:
    4258          52 :             break;
    4259             :         case 1:
    4260        1210 :             eAdjust = SVX_ADJUST_CENTER;
    4261        1210 :             break;
    4262             :         case 2:
    4263         372 :             eAdjust = SVX_ADJUST_RIGHT;
    4264         372 :             break;
    4265             :         case 3:
    4266         534 :             eAdjust = SVX_ADJUST_BLOCK;
    4267         534 :             break;
    4268             :         case 4:
    4269           0 :             eAdjust = SVX_ADJUST_BLOCK;
    4270           0 :             bDistributed = true;
    4271           0 :             break;
    4272             :     }
    4273        2168 :     SvxAdjustItem aAdjust(eAdjust, RES_PARATR_ADJUST);
    4274        2168 :     if (bDistributed)
    4275           0 :         aAdjust.SetLastBlock(SVX_ADJUST_BLOCK);
    4276             : 
    4277        2168 :     NewAttr(aAdjust);
    4278             : }
    4279             : 
    4280        6088 : bool SwWW8ImplReader::IsRightToLeft()
    4281             : {
    4282        6088 :     bool bRTL = false;
    4283             :     const sal_uInt8 *pDir =
    4284        6088 :         pPlcxMan ? pPlcxMan->GetPapPLCF()->HasSprm(0x2441) : 0;
    4285        6088 :     if (pDir)
    4286        1862 :         bRTL = *pDir ? true : false;
    4287             :     else
    4288             :     {
    4289             :         const SvxFrameDirectionItem* pItem=
    4290        4226 :             (const SvxFrameDirectionItem*)GetFmtAttr(RES_FRAMEDIR);
    4291        4226 :         if (pItem && (pItem->GetValue() == FRMDIR_HORI_RIGHT_TOP))
    4292           0 :             bRTL = true;
    4293             :     }
    4294        6088 :     return bRTL;
    4295             : }
    4296             : 
    4297        1934 : void SwWW8ImplReader::Read_RTLJustify( sal_uInt16, const sal_uInt8* pData, short nLen )
    4298             : {
    4299        1934 :     if( nLen < 0 )
    4300             :     {
    4301         814 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_ADJUST );
    4302        2748 :         return;
    4303             :     }
    4304             : 
    4305             :     //If we are in a ltr paragraph this is the same as normal Justify,
    4306             :     //If we are in a rtl paragraph the meaning is reversed.
    4307        1120 :     if (!IsRightToLeft())
    4308         718 :         Read_Justify(0x2403 /*dummy*/, pData, nLen);
    4309             :     else
    4310             :     {
    4311         402 :         SvxAdjust eAdjust(SVX_ADJUST_RIGHT);
    4312         402 :         bool bDistributed = false;
    4313         402 :         switch (*pData)
    4314             :         {
    4315             :             default:
    4316             :             case 0:
    4317           0 :                 break;
    4318             :             case 1:
    4319         402 :                 eAdjust = SVX_ADJUST_CENTER;
    4320         402 :                 break;
    4321             :             case 2:
    4322           0 :                 eAdjust = SVX_ADJUST_LEFT;
    4323           0 :                 break;
    4324             :             case 3:
    4325           0 :                 eAdjust = SVX_ADJUST_BLOCK;
    4326           0 :                 break;
    4327             :             case 4:
    4328           0 :                 eAdjust = SVX_ADJUST_BLOCK;
    4329           0 :                 bDistributed = true;
    4330           0 :                 break;
    4331             :         }
    4332         402 :         SvxAdjustItem aAdjust(eAdjust, RES_PARATR_ADJUST);
    4333         402 :         if (bDistributed)
    4334           0 :             aAdjust.SetLastBlock(SVX_ADJUST_BLOCK);
    4335             : 
    4336         402 :         NewAttr(aAdjust);
    4337             :     }
    4338             : }
    4339             : 
    4340         422 : void SwWW8ImplReader::Read_BoolItem( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    4341             : {
    4342         422 :     switch( nId )
    4343             :     {
    4344             :         case 0x2433:
    4345          34 :             nId = RES_PARATR_FORBIDDEN_RULES;
    4346          34 :             break;
    4347             :         case 0x2435:
    4348         100 :             nId = RES_PARATR_HANGINGPUNCTUATION;
    4349         100 :             break;
    4350             :         case 0x2437:
    4351         288 :             nId = RES_PARATR_SCRIPTSPACE;
    4352         288 :             break;
    4353             :         default:
    4354             :             OSL_ENSURE( false, "wrong Id" );
    4355         422 :             return ;
    4356             :     }
    4357             : 
    4358         422 :     if( nLen < 0 )
    4359          26 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), nId );
    4360             :     else
    4361             :     {
    4362         396 :         SfxBoolItem* pI = (SfxBoolItem*)GetDfltAttr( nId )->Clone();
    4363         396 :         pI->SetValue( 0 != *pData );
    4364         396 :         NewAttr( *pI );
    4365         396 :         delete pI;
    4366             :     }
    4367             : }
    4368             : 
    4369           6 : void SwWW8ImplReader::Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short nLen )
    4370             : {
    4371           6 :     if( nLen < 0 )
    4372           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_EMPHASIS_MARK );
    4373             :     else
    4374             :     {
    4375             :         LanguageType nLang;
    4376             :         //Check to see if there is an up and coming cjk language property. If
    4377             :         //there is use it, if there is not fall back to the currently set one.
    4378             :         //Only the cjk language setting seems to matter to word, the western
    4379             :         //one is ignored
    4380             :         const sal_uInt8 *pLang =
    4381           6 :             pPlcxMan ? pPlcxMan->GetChpPLCF()->HasSprm(0x486E) : 0;
    4382             : 
    4383           6 :         if (pLang)
    4384           6 :             nLang = SVBT16ToShort( pLang );
    4385             :         else
    4386             :         {
    4387             :             nLang = ((const SvxLanguageItem *)
    4388           0 :                 GetFmtAttr(RES_CHRATR_CJK_LANGUAGE))->GetLanguage();
    4389             :         }
    4390             : 
    4391             :         sal_uInt16 nVal;
    4392           6 :         switch( *pData )
    4393             :         {
    4394             :         case 0:
    4395           6 :             nVal = EMPHASISMARK_NONE;
    4396           6 :             break;
    4397             :         case 2:
    4398           0 :             if (MsLangId::isKorean(nLang) || MsLangId::isTraditionalChinese(nLang))
    4399           0 :                 nVal = EMPHASISMARK_CIRCLE_ABOVE;
    4400           0 :             else if (nLang == LANGUAGE_JAPANESE)
    4401           0 :                 nVal = EMPHASISMARK_SIDE_DOTS;
    4402             :             else
    4403           0 :                 nVal = EMPHASISMARK_DOTS_BELOW;
    4404           0 :             break;
    4405             :         case 3:
    4406           0 :             nVal = EMPHASISMARK_CIRCLE_ABOVE;
    4407           0 :             break;
    4408             :         case 4:
    4409           0 :             nVal = EMPHASISMARK_DOTS_BELOW;
    4410           0 :             break;
    4411             :         case 1:
    4412           0 :             if (MsLangId::isSimplifiedChinese(nLang))
    4413           0 :                 nVal = EMPHASISMARK_DOTS_BELOW;
    4414             :             else
    4415           0 :                 nVal = EMPHASISMARK_DOTS_ABOVE;
    4416           0 :             break;
    4417             :         default:
    4418           0 :             nVal = EMPHASISMARK_DOTS_ABOVE;
    4419           0 :             break;
    4420             :         }
    4421             : 
    4422           6 :         NewAttr( SvxEmphasisMarkItem( nVal, RES_CHRATR_EMPHASIS_MARK ) );
    4423             :     }
    4424           6 : }
    4425             : 
    4426           8 : void SwWW8ImplReader::Read_ScaleWidth( sal_uInt16, const sal_uInt8* pData, short nLen )
    4427             : {
    4428           8 :     if( nLen < 0 )
    4429           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_SCALEW );
    4430             :     else
    4431             :     {
    4432           8 :         sal_uInt16 nVal = SVBT16ToShort( pData );
    4433             :         //The number must be between 1 and 600
    4434           8 :         if (nVal < 1 || nVal > 600)
    4435           0 :             nVal = 100;
    4436           8 :         NewAttr( SvxCharScaleWidthItem( nVal, RES_CHRATR_SCALEW ) );
    4437             :     }
    4438           8 : }
    4439             : 
    4440           4 : void SwWW8ImplReader::Read_Relief( sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    4441             : {
    4442           4 :     if( nLen < 0 )
    4443           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_RELIEF );
    4444             :     else
    4445             :     {
    4446           4 :         if( *pData )
    4447             :         {
    4448             : // not so eays because this is also a toggle attribute!
    4449             : //  2 x emboss on -> no emboss !!!
    4450             : // the actual value must be searched over the stack / template
    4451             : 
    4452             :             const SvxCharReliefItem* pOld = (const SvxCharReliefItem*)
    4453           0 :                                             GetFmtAttr( RES_CHRATR_RELIEF );
    4454             :             FontRelief nNewValue = 0x854 == nId ? RELIEF_ENGRAVED
    4455             :                                         : ( 0x858 == nId ? RELIEF_EMBOSSED
    4456           0 :                                                          : RELIEF_NONE );
    4457           0 :             if( pOld->GetValue() == nNewValue )
    4458             :             {
    4459           0 :                 if( RELIEF_NONE != nNewValue )
    4460           0 :                     nNewValue = RELIEF_NONE;
    4461             :             }
    4462           0 :             NewAttr( SvxCharReliefItem( nNewValue, RES_CHRATR_RELIEF ));
    4463             :         }
    4464             :     }
    4465           4 : }
    4466             : 
    4467           4 : void SwWW8ImplReader::Read_TxtAnim(sal_uInt16 /*nId*/, const sal_uInt8* pData, short nLen)
    4468             : {
    4469           4 :     if (nLen < 0)
    4470           0 :         pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_BLINK);
    4471             :     else
    4472             :     {
    4473           4 :         if (*pData)
    4474             :         {
    4475             :             bool bBlink;
    4476             : 
    4477             :             // The 7 animated text effects available in word all get
    4478             :             // mapped to a blinking text effect in StarOffice
    4479             :             // 0 no animation       1 Las Vegas lights
    4480             :             // 2 background blink   3 sparkle text
    4481             :             // 4 marching ants      5 marchine red ants
    4482             :             // 6 shimmer
    4483           0 :             if (*pData > 0 && *pData < 7 )
    4484           0 :                 bBlink = true;
    4485             :             else
    4486           0 :                 bBlink = false;
    4487             : 
    4488           0 :             NewAttr(SvxBlinkItem(bBlink, RES_CHRATR_BLINK));
    4489             :         }
    4490             :     }
    4491           4 : }
    4492             : 
    4493          14 : SwWW8Shade::SwWW8Shade(bool bVer67, const WW8_SHD& rSHD)
    4494             : {
    4495          14 :     sal_uInt8 b = rSHD.GetFore();
    4496             :     OSL_ENSURE(b < 17, "ww8: colour out of range");
    4497          14 :     if (b >= 17)
    4498           0 :         b = 0;
    4499             : 
    4500          14 :     ColorData nFore(SwWW8ImplReader::GetCol(b));
    4501             : 
    4502          14 :     b = rSHD.GetBack();
    4503             :     OSL_ENSURE(b < 17, "ww8: colour out of range");
    4504          14 :     if( b >=  17 )
    4505           0 :         b = 0;
    4506             : 
    4507          14 :     ColorData nBack(SwWW8ImplReader::GetCol(b));
    4508             : 
    4509          14 :     b = rSHD.GetStyle(bVer67);
    4510             : 
    4511          14 :     SetShade(nFore, nBack, b);
    4512          14 : }
    4513             : 
    4514        1198 : void SwWW8Shade::SetShade(ColorData nFore, ColorData nBack, sal_uInt16 nIndex)
    4515             : {
    4516             :     static const sal_uLong eMSGrayScale[] =
    4517             :     {
    4518             :         // Clear-Brush
    4519             :            0,   // 0    clear
    4520             :         // Solid-Brush
    4521             :         1000,   // 1    solid
    4522             :         // Percent values
    4523             :           50,   // 2    pct5
    4524             :          100,   // 3    pct10
    4525             :          200,   // 4    pct20
    4526             :          250,   // 5    pct25
    4527             :          300,   // 6    pct30
    4528             :          400,   // 7    pct40
    4529             :          500,   // 8    pct50
    4530             :          600,   // 9    pct60
    4531             :          700,   // 10   pct70
    4532             :          750,   // 11   pct75
    4533             :          800,   // 12   pct80
    4534             :          900,   // 13   pct90
    4535             :         // Special cases
    4536             :          333,   // 14   Dark Horizontal
    4537             :          333,   // 15   Dark Vertical
    4538             :          333,   // 16   Dark Forward Diagonal
    4539             :          333,   // 17   Dark Backward Diagonal
    4540             :          333,   // 18   Dark Cross
    4541             :          333,   // 19   Dark Diagonal Cross
    4542             :          333,   // 20   Horizontal
    4543             :          333,   // 21   Vertical
    4544             :          333,   // 22   Forward Diagonal
    4545             :          333,   // 23   Backward Diagonal
    4546             :          333,   // 24   Cross
    4547             :          333,   // 25   Diagonal Cross
    4548             :         // Undefined values in DOC spec-sheet
    4549             :          500,   // 26
    4550             :          500,   // 27
    4551             :          500,   // 28
    4552             :          500,   // 29
    4553             :          500,   // 30
    4554             :          500,   // 31
    4555             :          500,   // 32
    4556             :          500,   // 33
    4557             :          500,   // 34
    4558             :         // Different shading types
    4559             :           25,   // 35   [available in DOC, not available in DOCX]
    4560             :           75,   // 36   [available in DOC, not available in DOCX]
    4561             :          125,   // 37   pct12
    4562             :          150,   // 38   pct15
    4563             :          175,   // 39   [available in DOC, not available in DOCX]
    4564             :          225,   // 40   [available in DOC, not available in DOCX]
    4565             :          275,   // 41   [available in DOC, not available in DOCX]
    4566             :          325,   // 42   [available in DOC, not available in DOCX]
    4567             :          350,   // 43   pct35
    4568             :          375,   // 44   pct37
    4569             :          425,   // 45   [available in DOC, not available in DOCX]
    4570             :          450,   // 46   pct45
    4571             :          475,   // 47   [available in DOC, not available in DOCX]
    4572             :          525,   // 48   [available in DOC, not available in DOCX]
    4573             :          550,   // 49   pct55
    4574             :          575,   // 50   [available in DOC, not available in DOCX]
    4575             :          625,   // 51   pct62
    4576             :          650,   // 52   pct65
    4577             :          675,   // 53   [available in DOC, not available in DOCX]
    4578             :          725,   // 54   [available in DOC, not available in DOCX]
    4579             :          775,   // 55   [available in DOC, not available in DOCX]
    4580             :          825,   // 56   [available in DOC, not available in DOCX]
    4581             :          850,   // 57   pct85
    4582             :          875,   // 58   pct87
    4583             :          925,   // 59   [available in DOC, not available in DOCX]
    4584             :          950,   // 60   pct95
    4585             :          975    // 61   [available in DOC, not available in DOCX]
    4586             :     };// 62
    4587             : 
    4588             :     //NO auto for shading so Foreground: Auto = Black
    4589        1198 :     if (nFore == COL_AUTO)
    4590           6 :         nFore = COL_BLACK;
    4591             : 
    4592             :     //NO auto for shading so background: Auto = Weiss
    4593        1198 :     ColorData nUseBack = nBack;
    4594        1198 :     if (nUseBack == COL_AUTO)
    4595         660 :         nUseBack = COL_WHITE;
    4596             : 
    4597        1198 :     if( nIndex >= sizeof( eMSGrayScale ) / sizeof ( eMSGrayScale[ 0 ] ) )
    4598           0 :         nIndex = 0;
    4599             : 
    4600        1198 :     sal_uLong nWW8BrushStyle = eMSGrayScale[nIndex];
    4601             : 
    4602        1198 :     switch (nWW8BrushStyle)
    4603             :     {
    4604             :         case 0: // Null-Brush
    4605        1182 :             aColor.SetColor( nBack );
    4606        1182 :             break;
    4607             :         default:
    4608             :             {
    4609          16 :                 Color aForeColor(nFore);
    4610          16 :                 Color aBackColor(nUseBack);
    4611             : 
    4612          16 :                 sal_uInt32 nRed = aForeColor.GetRed() * nWW8BrushStyle;
    4613          16 :                 sal_uInt32 nGreen = aForeColor.GetGreen() * nWW8BrushStyle;
    4614          16 :                 sal_uInt32 nBlue = aForeColor.GetBlue() * nWW8BrushStyle;
    4615          16 :                 nRed += aBackColor.GetRed()  * (1000L - nWW8BrushStyle);
    4616          16 :                 nGreen += aBackColor.GetGreen()* (1000L - nWW8BrushStyle);
    4617          16 :                 nBlue += aBackColor.GetBlue() * (1000L - nWW8BrushStyle);
    4618             : 
    4619          16 :                 aColor.SetColor( RGB_COLORDATA( nRed/1000, nGreen/1000,
    4620          16 :                     nBlue/1000 ) );
    4621             :             }
    4622          16 :             break;
    4623             :     }
    4624        1198 : }
    4625             : 
    4626          94 : void SwWW8ImplReader::Read_Shade( sal_uInt16, const sal_uInt8* pData, short nLen )
    4627             : {
    4628          94 :     if (!bVer67 && pPlcxMan && pPlcxMan->GetPapPLCF()->HasSprm(0xC64D))
    4629         174 :         return;
    4630             : 
    4631          14 :     if (nLen <= 0)
    4632             :     {
    4633             :         // Ende des Attributes
    4634           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BACKGROUND );
    4635           0 :         if (bShdTxtCol)
    4636             :         {
    4637             :             // Zeichenfarbe auch
    4638           0 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
    4639           0 :             bShdTxtCol = false;
    4640             :         }
    4641             :     }
    4642             :     else
    4643             :     {
    4644          14 :         WW8_SHD aSHD;
    4645          14 :         aSHD.SetWWValue( *(SVBT16*)pData );
    4646          14 :         SwWW8Shade aSh( bVer67, aSHD );
    4647             : 
    4648          14 :         NewAttr(SvxBrushItem(aSh.aColor, RES_BACKGROUND));
    4649             :     }
    4650             : }
    4651             : 
    4652         102 : void SwWW8ImplReader::Read_ParaBackColor(sal_uInt16, const sal_uInt8* pData, short nLen)
    4653             : {
    4654         102 :     if (nLen <= 0)
    4655             :     {
    4656             :         // Ende des Attributes
    4657          40 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BACKGROUND );
    4658          40 :         if (bShdTxtCol)
    4659             :         {
    4660             :             // Zeichenfarbe auch
    4661           0 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
    4662           0 :             bShdTxtCol = false;
    4663             :         }
    4664             :     }
    4665             :     else
    4666             :     {
    4667             :         OSL_ENSURE(nLen == 10, "Len of para back colour not 10!");
    4668          62 :         if (nLen != 10)
    4669         102 :             return;
    4670          62 :         NewAttr(SvxBrushItem(Color(ExtractColour(pData, bVer67)), RES_BACKGROUND));
    4671             :     }
    4672             : }
    4673             : 
    4674        1184 : sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
    4675             : {
    4676             :     (void) bVer67; // unused in non-debug
    4677             :     OSL_ENSURE(bVer67 == false, "Impossible");
    4678        1184 :     sal_uInt32 nFore = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
    4679        1184 :     rpData+=4;
    4680        1184 :     sal_uInt32 nBack = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
    4681        1184 :     rpData+=4;
    4682        1184 :     sal_uInt16 nIndex = SVBT16ToShort(rpData);
    4683        1184 :     rpData+=2;
    4684             :     //Being a transparent background colour doesn't actually show the page
    4685             :     //background through, it merely acts like white
    4686        1184 :     if (nBack == 0xFF000000)
    4687         660 :         nBack = COL_AUTO;
    4688             :     OSL_ENSURE(nBack == COL_AUTO || !(nBack & 0xFF000000),
    4689             :         "ww8: don't know what to do with such a transparent bg colour, report");
    4690        1184 :     SwWW8Shade aShade(nFore, nBack, nIndex);
    4691        1184 :     return aShade.aColor.GetColor();
    4692             : }
    4693             : 
    4694        1070 : void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
    4695             : {
    4696        1070 :     if( nLen < 0 )
    4697             :     {
    4698         376 :         if( bHasBorder )
    4699             :         {
    4700          64 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BOX );
    4701          64 :             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_SHADOW );
    4702          64 :             bHasBorder = false;
    4703             :         }
    4704             :     }
    4705         694 :     else if( !bHasBorder )
    4706             :     {
    4707             :         // die Borders auf allen 4 Seiten werden gebuendelt.  dieses
    4708             :         // vereinfacht die Verwaltung, d.h. die Box muss nicht 4 mal auf den
    4709             :         // CtrlStack und wieder runter
    4710         136 :         bHasBorder = true;
    4711             : 
    4712         136 :         WW8_BRCVer9_5 aBrcs;   // Top, Left, Bottom, Right, Between
    4713             :         sal_uInt8 nBorder;
    4714             : 
    4715         136 :         if( pAktColl )
    4716          72 :             nBorder = ::lcl_ReadBorders(bVer67, aBrcs, 0, pStyles);
    4717             :         else
    4718          64 :             nBorder = ::lcl_ReadBorders(bVer67, aBrcs, pPlcxMan ? pPlcxMan->GetPapPLCF() : NULL);
    4719             : 
    4720         136 :         if( nBorder )                                   // Border
    4721             :         {
    4722         136 :             bool bIsB = IsBorder(aBrcs, true);
    4723         272 :             if (!InLocalApo() || !bIsB ||
    4724           0 :                 (pWFlyPara && !pWFlyPara->bBorderLines ))
    4725             :             {
    4726             :                 // in Apo keine Umrandungen *ein*-schalten, da ich
    4727             :                 // sonst die Flyumrandungen doppelt bekomme
    4728             :                 // aber nur wenn am Fly ein gesetzt ist, keine
    4729             :                 // uebernehmen. Sonst wird gar keine gesetzt!
    4730             : 
    4731             :                 // auch wenn kein Rand gesetzt ist, muss das Attribut gesetzt
    4732             :                 // werden, sonst ist kein hartes Ausschalten von Style-Attrs
    4733             :                 // moeglich
    4734             :                 const SvxBoxItem* pBox
    4735         136 :                     = (const SvxBoxItem*)GetFmtAttr( RES_BOX );
    4736         136 :                 SvxBoxItem aBox(RES_BOX);
    4737         136 :                 if (pBox)
    4738         136 :                     aBox = *pBox;
    4739         136 :                 short aSizeArray[5]={0};
    4740             : 
    4741         136 :                 SetBorder(aBox, aBrcs, &aSizeArray[0], nBorder);
    4742             : 
    4743         136 :                 Rectangle aInnerDist;
    4744         136 :                 GetBorderDistance( aBrcs, aInnerDist );
    4745             : 
    4746         136 :                 if ((nBorder & WW8_LEFT)==WW8_LEFT)
    4747         102 :                     aBox.SetDistance( (sal_uInt16)aInnerDist.Left(), BOX_LINE_LEFT );
    4748             : 
    4749             :                 if ((nBorder & WW8_TOP)==WW8_TOP)
    4750         136 :                     aBox.SetDistance( (sal_uInt16)aInnerDist.Top(), BOX_LINE_TOP );
    4751             : 
    4752         136 :                 if ((nBorder & WW8_RIGHT)==WW8_RIGHT)
    4753          76 :                     aBox.SetDistance( (sal_uInt16)aInnerDist.Right(), BOX_LINE_RIGHT );
    4754             : 
    4755         136 :                 if ((nBorder & WW8_BOT)==WW8_BOT)
    4756          76 :                     aBox.SetDistance( (sal_uInt16)aInnerDist.Bottom(), BOX_LINE_BOTTOM );
    4757             : 
    4758         136 :                 NewAttr( aBox );
    4759             : 
    4760         272 :                 SvxShadowItem aS(RES_SHADOW);
    4761         136 :                 if( SetShadow( aS, &aSizeArray[0], aBrcs[WW8_RIGHT] ) )
    4762         136 :                     NewAttr( aS );
    4763             :             }
    4764             :         }
    4765             :     }
    4766        1070 : }
    4767             : 
    4768          84 : void SwWW8ImplReader::Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, short nLen )
    4769             : {
    4770             :     //Ignore this old border type
    4771             :     //if (!bVer67 && pPlcxMan && pPlcxMan->GetChpPLCF()->HasSprm(0xCA72))
    4772             :     //    return;
    4773             : 
    4774          84 :     if( nLen < 0 )
    4775             :     {
    4776          40 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_BOX );
    4777          40 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_SHADOW );
    4778             :     }
    4779             :     else
    4780             :     {
    4781             :         const SvxBoxItem* pBox
    4782          44 :             = (const SvxBoxItem*)GetFmtAttr( RES_CHRATR_BOX );
    4783          44 :         if( pBox )
    4784             :         {
    4785          44 :             SvxBoxItem aBoxItem(RES_CHRATR_BOX);
    4786          44 :             aBoxItem = *pBox;
    4787          44 :             WW8_BRCVer9 aBrc;
    4788          44 :             int nBrcVer = (nId == NS_sprm::LN_CBrc) ? 9 : (bVer67 ? 6 : 8);
    4789             : 
    4790          44 :             _SetWW8_BRC(nBrcVer, aBrc, pData);
    4791             : 
    4792             :             // Border style is none -> no border, no shadow
    4793          44 :             if( editeng::ConvertBorderStyleFromWord(aBrc.brcType()) != table::BorderLineStyle::NONE )
    4794             :             {
    4795          40 :                 Set1Border(aBoxItem, aBrc, BOX_LINE_TOP, 0, 0, true);
    4796          40 :                 Set1Border(aBoxItem, aBrc, BOX_LINE_BOTTOM, 0, 0, true);
    4797          40 :                 Set1Border(aBoxItem, aBrc, BOX_LINE_LEFT, 0, 0, true);
    4798          40 :                 Set1Border(aBoxItem, aBrc, BOX_LINE_RIGHT, 0, 0, true);
    4799          40 :                 NewAttr( aBoxItem );
    4800             : 
    4801          40 :                 short aSizeArray[WW8_RIGHT+1]={0}; aSizeArray[WW8_RIGHT] = 1;
    4802          40 :                 SvxShadowItem aShadowItem(RES_CHRATR_SHADOW);
    4803          40 :                 if( SetShadow( aShadowItem, &aSizeArray[0], aBrc ) )
    4804          24 :                     NewAttr( aShadowItem );
    4805          44 :             }
    4806             :         }
    4807             :     }
    4808             : 
    4809          84 : }
    4810             : 
    4811         138 : void SwWW8ImplReader::Read_Hyphenation( sal_uInt16, const sal_uInt8* pData, short nLen )
    4812             : {
    4813             :     // set Hyphenation flag
    4814         138 :     if( nLen <= 0 )
    4815          28 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_HYPHENZONE );
    4816             :     else
    4817             :     {
    4818             :         SvxHyphenZoneItem aAttr(
    4819         110 :             *(const SvxHyphenZoneItem*)GetFmtAttr( RES_PARATR_HYPHENZONE ) );
    4820             : 
    4821         110 :         aAttr.SetHyphen( 0 == *pData ); // sic !
    4822             : 
    4823         110 :         if( !*pData )
    4824             :         {
    4825           2 :             aAttr.GetMinLead()    = 2;
    4826           2 :             aAttr.GetMinTrail()   = 2;
    4827           2 :             aAttr.GetMaxHyphens() = 0;
    4828             :         }
    4829             : 
    4830         110 :         NewAttr( aAttr );
    4831             :     }
    4832         138 : }
    4833             : 
    4834         156 : void SwWW8ImplReader::Read_WidowControl( sal_uInt16, const sal_uInt8* pData, short nLen )
    4835             : {
    4836         156 :     if( nLen <= 0 )
    4837             :     {
    4838          30 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_WIDOWS );
    4839          30 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_ORPHANS );
    4840             :     }
    4841             :     else
    4842             :     {
    4843         126 :         sal_uInt8 nL = ( *pData & 1 ) ? 2 : 0;
    4844             : 
    4845         126 :         NewAttr( SvxWidowsItem( nL, RES_PARATR_WIDOWS ) );     // Aus -> nLines = 0
    4846         126 :         NewAttr( SvxOrphansItem( nL, RES_PARATR_ORPHANS ) );
    4847             : 
    4848         126 :         if( pAktColl && pStyles )           // Style-Def ?
    4849          96 :             pStyles->bWidowsChanged = true; // merken zur Simulation
    4850             :                                             // Default-Widows
    4851             :     }
    4852         156 : }
    4853             : 
    4854         800 : void SwWW8ImplReader::Read_UsePgsuSettings(sal_uInt16,const sal_uInt8* pData,short nLen)
    4855             : {
    4856         800 :     if( nLen <= 0 )
    4857         396 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_SNAPTOGRID);
    4858             :     else
    4859             :     {
    4860         404 :         if(nInTable)
    4861         396 :             NewAttr( SvxParaGridItem(false, RES_PARATR_SNAPTOGRID) );
    4862             :         else
    4863           8 :             NewAttr( SvxParaGridItem(*pData, RES_PARATR_SNAPTOGRID) );
    4864             :     }
    4865         800 : }
    4866             : 
    4867          68 : void SwWW8ImplReader::Read_AlignFont( sal_uInt16, const sal_uInt8* pData, short nLen )
    4868             : {
    4869          68 :     if( nLen <= 0 )
    4870           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_VERTALIGN);
    4871             :     else
    4872             :     {
    4873          68 :         sal_uInt16 nVal = SVBT16ToShort( pData );
    4874          68 :         switch (nVal)
    4875             :         {
    4876             :             case 0:
    4877           0 :                 nVal = SvxParaVertAlignItem::TOP;
    4878           0 :                 break;
    4879             :             case 1:
    4880          18 :                 nVal = SvxParaVertAlignItem::CENTER;
    4881          18 :                 break;
    4882             :             case 2:
    4883           4 :                 nVal = SvxParaVertAlignItem::BASELINE;
    4884           4 :                 break;
    4885             :             case 3:
    4886           0 :                 nVal = SvxParaVertAlignItem::BOTTOM;
    4887           0 :                 break;
    4888             :             case 4:
    4889          46 :                 nVal = SvxParaVertAlignItem::AUTOMATIC;
    4890          46 :                 break;
    4891             :             default:
    4892           0 :                 nVal = SvxParaVertAlignItem::AUTOMATIC;
    4893             :                 OSL_ENSURE(false,"Unknown paragraph vertical align");
    4894           0 :                 break;
    4895             :         }
    4896          68 :         NewAttr( SvxParaVertAlignItem( nVal, RES_PARATR_VERTALIGN ) );
    4897             :     }
    4898          68 : }
    4899             : 
    4900          48 : void SwWW8ImplReader::Read_KeepLines( sal_uInt16, const sal_uInt8* pData, short nLen )
    4901             : {
    4902          48 :     if( nLen <= 0 )
    4903           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_PARATR_SPLIT );
    4904             :     else
    4905          48 :         NewAttr( SvxFmtSplitItem( ( *pData & 1 ) == 0, RES_PARATR_SPLIT ) );
    4906          48 : }
    4907             : 
    4908         254 : void SwWW8ImplReader::Read_KeepParas( sal_uInt16, const sal_uInt8* pData, short nLen )
    4909             : {
    4910         254 :     if( nLen <= 0 )
    4911           0 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_KEEP );
    4912             :     else
    4913         254 :         NewAttr( SvxFmtKeepItem( ( *pData & 1 ) != 0 , RES_KEEP) );
    4914         254 : }
    4915             : 
    4916          20 : void SwWW8ImplReader::Read_BreakBefore( sal_uInt16, const sal_uInt8* pData, short nLen )
    4917             : {
    4918          20 :     if( nLen <= 0 )
    4919          10 :         pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_BREAK );
    4920             :     else
    4921             :         NewAttr( SvxFmtBreakItem(
    4922          10 :                 ( *pData & 1 ) ? SVX_BREAK_PAGE_BEFORE : SVX_BREAK_NONE, RES_BREAK ) );
    4923          20 : }
    4924             : 
    4925         348 : void SwWW8ImplReader::Read_ApoPPC( sal_uInt16, const sal_uInt8* pData, short )
    4926             : {
    4927         348 :     if (pAktColl && nAktColl < vColl.size()) // only for Styledef, sonst anders geloest
    4928             :     {
    4929           8 :         SwWW8StyInf& rSI = vColl[nAktColl];
    4930           8 :         WW8FlyPara* pFly = rSI.pWWFly ? rSI.pWWFly : new WW8FlyPara(bVer67);
    4931           8 :         vColl[nAktColl].pWWFly = pFly;
    4932           8 :         pFly->Read(*pData, pStyles);
    4933           8 :         if (pFly->IsEmpty())
    4934           0 :             delete vColl[nAktColl].pWWFly, vColl[nAktColl].pWWFly = 0;
    4935             :     }
    4936         348 : }
    4937             : 
    4938        3644 : bool SwWW8ImplReader::ParseTabPos(WW8_TablePos *pTabPos, WW8PLCFx_Cp_FKP* pPap)
    4939             : {
    4940        3644 :     bool bRet = false;
    4941        3644 :     const sal_uInt8 *pRes=0;
    4942        3644 :     memset(pTabPos, 0, sizeof(WW8_TablePos));
    4943        3644 :     if (0 != (pRes = pPap->HasSprm(0x360D)))
    4944             :     {
    4945         216 :         pTabPos->nSp29 = *pRes;
    4946         216 :         pTabPos->nSp37 = 2;     //Possible fail area, always parallel wrap
    4947         216 :         if (0 != (pRes = pPap->HasSprm(0x940E)))
    4948          20 :             pTabPos->nSp26 = SVBT16ToShort(pRes);
    4949         216 :         if (0 != (pRes = pPap->HasSprm(0x940F)))
    4950         216 :             pTabPos->nSp27 = SVBT16ToShort(pRes);
    4951         216 :         if (0 != (pRes = pPap->HasSprm(0x9410)))
    4952         216 :             pTabPos->nLeMgn = SVBT16ToShort(pRes);
    4953         216 :         if (0 != (pRes = pPap->HasSprm(0x941E)))
    4954         216 :             pTabPos->nRiMgn = SVBT16ToShort(pRes);
    4955         216 :         if (0 != (pRes = pPap->HasSprm(0x9411)))
    4956           0 :             pTabPos->nUpMgn = SVBT16ToShort(pRes);
    4957         216 :         if (0 != (pRes = pPap->HasSprm(0x941F)))
    4958           0 :             pTabPos->nLoMgn = SVBT16ToShort(pRes);
    4959         216 :         bRet = true;
    4960             :     }
    4961        3644 :     if (0 != (pRes = pPap->HasSprm(NS_sprm::LN_TDefTable)))
    4962             :     {
    4963        3616 :         WW8TabBandDesc aDesc;
    4964        3616 :         aDesc.ReadDef(false, pRes);
    4965        3616 :         int nTableWidth = aDesc.nCenter[aDesc.nWwCols] - aDesc.nCenter[0];
    4966        3616 :         int nTextAreaWidth = maSectionManager.GetTextAreaWidth();
    4967             :         // If the table is wider than the text area, then don't create a fly
    4968             :         // for the table: no wrapping will be performed anyway, but multi-page
    4969             :         // tables will be broken.
    4970             :         // If there are columns, do create a fly, as the flow of the columns
    4971             :         // would otherwise restrict the table.
    4972        3616 :         pTabPos->bNoFly = nTableWidth >= nTextAreaWidth  && maSectionManager.CurrentSectionColCount() < 2;
    4973             :     }
    4974        3644 :     return bRet;
    4975             : }
    4976             : 
    4977             : // Seiten - Attribute werden nicht mehr als Attribute gehandhabt
    4978             : //  ( ausser OLST )
    4979         288 : long SwWW8ImplReader::ImportExtSprm(WW8PLCFManResult* pRes)
    4980             : {
    4981             :     // Arrays zum Lesen der erweiterten ( selbstdefinierten ) SPRMs
    4982             :     typedef long (SwWW8ImplReader:: *FNReadRecordExt)(WW8PLCFManResult*);
    4983             : 
    4984             :     static const FNReadRecordExt aWwSprmTab[] =
    4985             :     {
    4986             :         /* 0 (256) */   &SwWW8ImplReader::Read_Ftn,     // FootNote
    4987             :         /* 1 (257) */   &SwWW8ImplReader::Read_Ftn,     // EndNote
    4988             :         /* 2 (258) */   &SwWW8ImplReader::Read_Field,  // Feld
    4989             :         /* 3 (259) */   &SwWW8ImplReader::Read_Book,   // Bookmark
    4990             :         /* 4 (260) */   &SwWW8ImplReader::Read_And     // Annotation
    4991             :     };
    4992             : 
    4993         288 :     if( pRes->nSprmId < 280 )
    4994             :     {
    4995         288 :         sal_uInt8 nIdx = static_cast< sal_uInt8 >(pRes->nSprmId - eFTN);
    4996         288 :         if( nIdx < SAL_N_ELEMENTS(aWwSprmTab)
    4997         288 :             && aWwSprmTab[nIdx] )
    4998         288 :             return (this->*aWwSprmTab[nIdx])(pRes);
    4999             :         else
    5000           0 :             return 0;
    5001             :     }
    5002             :     else
    5003           0 :         return 0;
    5004             : }
    5005             : 
    5006         190 : void SwWW8ImplReader::EndExtSprm(sal_uInt16 nSprmId)
    5007             : {
    5008             :     typedef sal_uInt16 (SwWW8ImplReader:: *FNReadRecordExt)();
    5009             : 
    5010             :     static const FNReadRecordExt aWwSprmTab[] =
    5011             :     {
    5012             :         /* 0 (256) */   &SwWW8ImplReader::End_Ftn,      // FootNote
    5013             :         /* 1 (257) */   &SwWW8ImplReader::End_Ftn,      // EndNote
    5014             :         /* 2 (258) */   &SwWW8ImplReader::End_Field,  // Feld
    5015             :         /* 3 (259) */   0,   // Bookmark
    5016             :         /* 4 (260) */   0     // Annotation
    5017             :     };
    5018             : 
    5019         190 :     sal_uInt8 nIdx = static_cast< sal_uInt8 >(nSprmId - eFTN);
    5020         190 :     if( nIdx < SAL_N_ELEMENTS(aWwSprmTab)
    5021         190 :         && aWwSprmTab[nIdx] )
    5022         160 :         (this->*aWwSprmTab[nIdx])();
    5023         190 : }
    5024             : 
    5025             : // Arrays zum Lesen der SPRMs
    5026             : 
    5027             : // Funktion zum Einlesen von Sprms. Par1: SprmId
    5028             : typedef void (SwWW8ImplReader:: *FNReadRecord)( sal_uInt16, const sal_uInt8*, short );
    5029             : 
    5030             : struct SprmReadInfo
    5031             : {
    5032             :     sal_uInt16       nId;
    5033             :     FNReadRecord pReadFnc;
    5034             : };
    5035             : 
    5036     2539042 : bool operator<(const SprmReadInfo &rFirst, const SprmReadInfo &rSecond)
    5037             : {
    5038     2539042 :     return (rFirst.nId < rSecond.nId);
    5039             : }
    5040             : 
    5041             : typedef ww::SortedArray<SprmReadInfo> wwSprmDispatcher;
    5042             : 
    5043        4320 : const wwSprmDispatcher *GetWW2SprmDispatcher()
    5044             : {
    5045             :     static SprmReadInfo aSprms[] =
    5046             :     {
    5047             :           {0, 0},                                    // "0" Default bzw. Error
    5048             :                                                      //wird uebersprungen! ,
    5049             :           {2, &SwWW8ImplReader::Read_StyleCode},     //"sprmPIstd",  pap.istd
    5050             :                                                      //(style code)
    5051             :           {3, 0},                                    //"sprmPIstdPermute", pap.istd
    5052             :                                                      //permutation
    5053             :           {4, 0},                                    //"sprmPIncLv1",
    5054             :                                                      //pap.istddifference
    5055             :           {5, &SwWW8ImplReader::Read_Justify},       //"sprmPJc", pap.jc
    5056             :                                                      //(justification)
    5057             :           {6, 0},                                    //"sprmPFSideBySide",
    5058             :                                                      //pap.fSideBySide
    5059             :           {7, &SwWW8ImplReader::Read_KeepLines},     //"sprmPFKeep", pap.fKeep
    5060             :           {8, &SwWW8ImplReader::Read_KeepParas},     //"sprmPFKeepFollow ",
    5061             :                                                      //pap.fKeepFollow
    5062             :           {9, &SwWW8ImplReader::Read_BreakBefore},   //"sprmPPageBreakBefore",
    5063             :                                                      //pap.fPageBreakBefore
    5064             :          {10, 0},                                    //"sprmPBrcl", pap.brcl
    5065             :          {11, 0},                                    //"sprmPBrcp ", pap.brcp
    5066             :          {12, &SwWW8ImplReader::Read_ANLevelDesc},   //"sprmPAnld", pap.anld (ANLD
    5067             :                                                      //structure)
    5068             :          {13, &SwWW8ImplReader::Read_ANLevelNo},     //"sprmPNLvlAnm", pap.nLvlAnm
    5069             :                                                      //nn
    5070             :          {14, &SwWW8ImplReader::Read_NoLineNumb},    //"sprmPFNoLineNumb", ap.fNoLnn
    5071             :          {15, &SwWW8ImplReader::Read_Tab},           //"?sprmPChgTabsPapx",
    5072             :                                                      //pap.itbdMac, ...
    5073             :          {16, &SwWW8ImplReader::Read_LR},            //"sprmPDxaRight", pap.dxaRight
    5074             :          {17, &SwWW8ImplReader::Read_LR},            //"sprmPDxaLeft", pap.dxaLeft
    5075             :          {18, 0},                                    //"sprmPNest", pap.dxaLeft
    5076             :          {19, &SwWW8ImplReader::Read_LR},            //"sprmPDxaLeft1", pap.dxaLeft1
    5077             :          {20, &SwWW8ImplReader::Read_LineSpace},     //"sprmPDyaLine", pap.lspd
    5078             :                                                      //an LSPD
    5079             :          {21, &SwWW8ImplReader::Read_UL},            //"sprmPDyaBefore",
    5080             :                                                      //pap.dyaBefore
    5081             :          {22, &SwWW8ImplReader::Read_UL},            //"sprmPDyaAfter", pap.dyaAfter
    5082             :          {23, 0},                                    //"?sprmPChgTabs", pap.itbdMac,
    5083             :                                                      //pap.rgdxaTab, ...
    5084             :          {24, 0},                                    //"sprmPFInTable", pap.fInTable
    5085             :          {25, &SwWW8ImplReader::Read_TabRowEnd},     //"sprmPTtp", pap.fTtp
    5086             :          {26, 0},                                    //"sprmPDxaAbs", pap.dxaAbs
    5087             :          {27, 0},                                    //"sprmPDyaAbs", pap.dyaAbs
    5088             :          {28, 0},                                    //"sprmPDxaWidth", pap.dxaWidth
    5089             :          {29, &SwWW8ImplReader::Read_ApoPPC},        //"sprmPPc", pap.pcHorz,
    5090             :                                                      //pap.pcVert
    5091             :          {30, 0},                                    //"sprmPBrcTop10", pap.brcTop
    5092             :                                                      //BRC10
    5093             :          {31, 0},                                    //"sprmPBrcLeft10",
    5094             :                                                      //pap.brcLeft BRC10
    5095             :          {32, 0},                                    //"sprmPBrcBottom10",
    5096             :                                                      //pap.brcBottom BRC10
    5097             :          {33, 0},                                    //"sprmPBrcRight10",
    5098             :                                                      //pap.brcRight BRC10
    5099             :          {34, 0},                                    //"sprmPBrcBetween10",
    5100             :                                                      //pap.brcBetween BRC10
    5101             :          {35, 0},                                    //"sprmPBrcBar10", pap.brcBar
    5102             :                                                      //BRC10
    5103             :          {36, 0},                                    //"sprmPFromText10",
    5104             :                                                      //pap.dxaFromText dxa
    5105             :          {37, 0},                                    //"sprmPWr", pap.wr wr
    5106             :          {38, &SwWW8ImplReader::Read_Border},        //"sprmPBrcTop", pap.brcTop BRC
    5107             :          {39, &SwWW8ImplReader::Read_Border},        //"sprmPBrcLeft",
    5108             :                                                      //pap.brcLeft BRC
    5109             :          {40, &SwWW8ImplReader::Read_Border},        //"sprmPBrcBottom",
    5110             :                                                      //pap.brcBottom BRC
    5111             :          {41, &SwWW8ImplReader::Read_Border},        //"sprmPBrcRight",
    5112             :                                                      //pap.brcRight BRC
    5113             :          {42, &SwWW8ImplReader::Read_Border},        //"sprmPBrcBetween",
    5114             :                                                      //pap.brcBetween BRC
    5115             :          {43, 0},                                    //"sprmPBrcBar", pap.brcBar
    5116             :                                                      //BRC word
    5117             :          {44, &SwWW8ImplReader::Read_Hyphenation},   //"sprmPFNoAutoHyph",
    5118             :                                                      //pap.fNoAutoHyph
    5119             :          {45, 0},                                    //"sprmPWHeightAbs",
    5120             :                                                      //pap.wHeightAbs w
    5121             :          {46, 0},                                    //"sprmPDcs", pap.dcs DCS
    5122             :          {47, &SwWW8ImplReader::Read_Shade},         //"sprmPShd", pap.shd SHD
    5123             :          {48, 0},                                    //"sprmPDyaFromText",
    5124             :                                                      //pap.dyaFromText dya
    5125             :          {49, 0},                                    //"sprmPDxaFromText",
    5126             :                                                      //pap.dxaFromText dxa
    5127             :          {50, 0},                                    //"sprmPFLocked", pap.fLocked
    5128             :                                                      //0 or 1 byte
    5129             :          {51, &SwWW8ImplReader::Read_WidowControl},  //"sprmPFWidowControl",
    5130             :                                                      //pap.fWidowControl 0 or 1 byte
    5131             :          {52, 0},                                    //"?sprmPRuler 52",
    5132             :          {53, 0},                                    //"??53",
    5133             :          {54, 0},                                    //"??54",
    5134             :          {55, 0},                                    //"??55",
    5135             :          {56, 0},                                    //"??56",
    5136             :          {57, 0},                                    //"??57",
    5137             :          {58, 0},                                    //"??58",
    5138             :          {59, 0},                                    //"??59",
    5139             : 
    5140             :          {60, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFBold", chp.fBold 0,1,
    5141             :                                                      //128, or 129 byte
    5142             :          {61, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFItalic", chp.fItalic
    5143             :                                                      //0,1, 128, or 129 byte
    5144             :          {62, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFStrike", chp.fStrike
    5145             :                                                      //0,1, 128, or 129 byte
    5146             :          {63, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFOutline", chp.fOutline
    5147             :                                                      //0,1, 128, or 129 byte
    5148             :          {64, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFShadow", chp.fShadow
    5149             :                                                      //0,1, 128, or 129 byte
    5150             :          {65, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFSmallCaps",
    5151             :                                                      //chp.fSmallCaps 0,1, 128, or
    5152             :                                                      //129 byte
    5153             :          {66, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFCaps", chp.fCaps 0,1,
    5154             :                                                      //128, or 129 byte
    5155             :          {67, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFVanish", chp.fVanish
    5156             :                                                      //0,1, 128, or 129 byte
    5157             :          {68, &SwWW8ImplReader::Read_FontCode},      //"sprmCFtc", chp.ftc ftc word
    5158             :          {69, &SwWW8ImplReader::Read_Underline},     // "sprmCKul", chp.kul kul byte
    5159             :          {70, 0},                                    //"sprmCSizePos", chp.hps,
    5160             :                                                      //chp.hpsPos 3 bytes
    5161             :          {71, &SwWW8ImplReader::Read_Kern},          //"sprmCDxaSpace",
    5162             :                                                      //chp.dxaSpace dxa word
    5163             :          {72, &SwWW8ImplReader::Read_Language},      //"sprmCLid", chp.lid LID word
    5164             :          {73, &SwWW8ImplReader::Read_TxtColor},      //"sprmCIco", chp.ico ico byte
    5165             :          {74, &SwWW8ImplReader::Read_FontSize},      //"sprmCHps", chp.hps hps word!
    5166             :          {75, 0},                                    //"sprmCHpsInc", chp.hps byte
    5167             :          {76, &SwWW8ImplReader::Read_SubSuperProp},  //"sprmCHpsPos", chp.hpsPos
    5168             :                                                      //hps byte
    5169             :          {77, 0},                                    //"sprmCHpsPosAdj", chp.hpsPos
    5170             :                                                      //hps byte
    5171             :          {78, &SwWW8ImplReader::Read_Majority},      //"?sprmCMajority", chp.fBold,
    5172             :                                                      //chp.fItalic, chp.fSmallCaps
    5173             :          {80, &SwWW8ImplReader::Read_BoldBiDiUsw},   //sprmCFBoldBi
    5174             :          {81, &SwWW8ImplReader::Read_BoldBiDiUsw},   //sprmCFItalicBi
    5175             :          {82, &SwWW8ImplReader::Read_FontCode},      //sprmCFtcBi
    5176             :          {83, &SwWW8ImplReader::Read_Language},      //sprmClidBi
    5177             :          {84, &SwWW8ImplReader::Read_TxtColor},      //sprmCIcoBi
    5178             :          {85, &SwWW8ImplReader::Read_FontSize},      //sprmCHpsBi
    5179             :          {86, 0},                                    //sprmCFBiDi
    5180             :          {87, 0},                                    //sprmCFDiacColor
    5181             :          {94, 0},                                    //"sprmPicBrcl", pic.brcl brcl
    5182             :                                                      //(see PIC structure
    5183             :                                                      //definition) byte
    5184             :          {95, 0},                                    //"sprmPicScale", pic.mx,
    5185             :                                                      //pic.my, pic.dxaCropleft,
    5186             :          {96, 0},                                    //"sprmPicBrcTop", pic.brcTop
    5187             :                                                      //BRC word
    5188             :          {97, 0},                                    //"sprmPicBrcLeft",
    5189             :                                                      //pic.brcLeft BRC word
    5190             :          {98, 0},                                    //"sprmPicBrcBottom",
    5191             :                                                      //pic.brcBottom BRC word
    5192             :          {99, 0}                                     //"sprmPicBrcRight",
    5193             :     };
    5194             : 
    5195        4320 :     static wwSprmDispatcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0]));
    5196        4320 :     return &aSprmSrch;
    5197             : }
    5198             : 
    5199           0 : const wwSprmDispatcher *GetWW6SprmDispatcher()
    5200             : {
    5201             :     static SprmReadInfo aSprms[] =
    5202             :     {
    5203             :           {0, 0},                                    // "0" Default bzw. Error
    5204             :                                                      //wird uebersprungen! ,
    5205             :           {2, &SwWW8ImplReader::Read_StyleCode},     //"sprmPIstd",  pap.istd
    5206             :                                                      //(style code)
    5207             :           {3, 0},                                    //"sprmPIstdPermute", pap.istd
    5208             :                                                      //permutation
    5209             :           {4, 0},                                    //"sprmPIncLv1",
    5210             :                                                      //pap.istddifference
    5211             :           {5, &SwWW8ImplReader::Read_Justify},       //"sprmPJc", pap.jc
    5212             :                                                      //(justification)
    5213             :           {6, 0},                                    //"sprmPFSideBySide",
    5214             :                                                      //pap.fSideBySide
    5215             :           {7, &SwWW8ImplReader::Read_KeepLines},     //"sprmPFKeep", pap.fKeep
    5216             :           {8, &SwWW8ImplReader::Read_KeepParas},     //"sprmPFKeepFollow ",
    5217             :                                                      //pap.fKeepFollow
    5218             :           {9, &SwWW8ImplReader::Read_BreakBefore},   //"sprmPPageBreakBefore",
    5219             :                                                      //pap.fPageBreakBefore
    5220             :          {10, 0},                                    //"sprmPBrcl", pap.brcl
    5221             :          {11, 0},                                    //"sprmPBrcp ", pap.brcp
    5222             :          {12, &SwWW8ImplReader::Read_ANLevelDesc},   //"sprmPAnld", pap.anld (ANLD
    5223             :                                                      //structure)
    5224             :          {13, &SwWW8ImplReader::Read_ANLevelNo},     //"sprmPNLvlAnm", pap.nLvlAnm
    5225             :                                                      //nn
    5226             :          {14, &SwWW8ImplReader::Read_NoLineNumb},    //"sprmPFNoLineNumb", ap.fNoLnn
    5227             :          {15, &SwWW8ImplReader::Read_Tab},           //"?sprmPChgTabsPapx",
    5228             :                                                      //pap.itbdMac, ...
    5229             :          {16, &SwWW8ImplReader::Read_LR},            //"sprmPDxaRight", pap.dxaRight
    5230             :          {17, &SwWW8ImplReader::Read_LR},            //"sprmPDxaLeft", pap.dxaLeft
    5231             :          {18, 0},                                    //"sprmPNest", pap.dxaLeft
    5232             :          {19, &SwWW8ImplReader::Read_LR},            //"sprmPDxaLeft1", pap.dxaLeft1
    5233             :          {20, &SwWW8ImplReader::Read_LineSpace},     //"sprmPDyaLine", pap.lspd
    5234             :                                                      //an LSPD
    5235             :          {21, &SwWW8ImplReader::Read_UL},            //"sprmPDyaBefore",
    5236             :                                                      //pap.dyaBefore
    5237             :          {22, &SwWW8ImplReader::Read_UL},            //"sprmPDyaAfter", pap.dyaAfter
    5238             :          {23, 0},                                    //"?sprmPChgTabs", pap.itbdMac,
    5239             :                                                      //pap.rgdxaTab, ...
    5240             :          {24, 0},                                    //"sprmPFInTable", pap.fInTable
    5241             :          {25, &SwWW8ImplReader::Read_TabRowEnd},     //"sprmPTtp", pap.fTtp
    5242             :          {26, 0},                                    //"sprmPDxaAbs", pap.dxaAbs
    5243             :          {27, 0},                                    //"sprmPDyaAbs", pap.dyaAbs
    5244             :          {28, 0},                                    //"sprmPDxaWidth", pap.dxaWidth
    5245             :          {29, &SwWW8ImplReader::Read_ApoPPC},        //"sprmPPc", pap.pcHorz,
    5246             :                                                      //pap.pcVert
    5247             :          {30, 0},                                    //"sprmPBrcTop10", pap.brcTop
    5248             :                                                      //BRC10
    5249             :          {31, 0},                                    //"sprmPBrcLeft10",
    5250             :                                                      //pap.brcLeft BRC10
    5251             :          {32, 0},                                    //"sprmPBrcBottom10",
    5252             :                                                      //pap.brcBottom BRC10
    5253             :          {33, 0},                                    //"sprmPBrcRight10",
    5254             :                                                      //pap.brcRight BRC10
    5255             :          {34, 0},                                    //"sprmPBrcBetween10",
    5256             :                                                      //pap.brcBetween BRC10
    5257             :          {35, 0},                                    //"sprmPBrcBar10", pap.brcBar
    5258             :                                                      //BRC10
    5259             :          {36, 0},                                    //"sprmPFromText10",
    5260             :                                                      //pap.dxaFromText dxa
    5261             :          {37, 0},                                    //"sprmPWr", pap.wr wr
    5262             :          {38, &SwWW8ImplReader::Read_Border},        //"sprmPBrcTop", pap.brcTop BRC
    5263             :          {39, &SwWW8ImplReader::Read_Border},        //"sprmPBrcLeft",
    5264             :                                                      //pap.brcLeft BRC
    5265             :          {40, &SwWW8ImplReader::Read_Border},        //"sprmPBrcBottom",
    5266             :                                                      //pap.brcBottom BRC
    5267             :          {41, &SwWW8ImplReader::Read_Border},        //"sprmPBrcRight",
    5268             :                                                      //pap.brcRight BRC
    5269             :          {42, &SwWW8ImplReader::Read_Border},        //"sprmPBrcBetween",
    5270             :                                                      //pap.brcBetween BRC
    5271             :          {43, 0},                                    //"sprmPBrcBar", pap.brcBar
    5272             :                                                      //BRC word
    5273             :          {44, &SwWW8ImplReader::Read_Hyphenation},   //"sprmPFNoAutoHyph",
    5274             :                                                      //pap.fNoAutoHyph
    5275             :          {45, 0},                                    //"sprmPWHeightAbs",
    5276             :                                                      //pap.wHeightAbs w
    5277             :          {46, 0},                                    //"sprmPDcs", pap.dcs DCS
    5278             :          {47, &SwWW8ImplReader::Read_Shade},         //"sprmPShd", pap.shd SHD
    5279             :          {48, 0},                                    //"sprmPDyaFromText",
    5280             :                                                      //pap.dyaFromText dya
    5281             :          {49, 0},                                    //"sprmPDxaFromText",
    5282             :                                                      //pap.dxaFromText dxa
    5283             :          {50, 0},                                    //"sprmPFLocked", pap.fLocked
    5284             :                                                      //0 or 1 byte
    5285             :          {51, &SwWW8ImplReader::Read_WidowControl},  //"sprmPFWidowControl",
    5286             :                                                      //pap.fWidowControl 0 or 1 byte
    5287             :          {52, 0},                                    //"?sprmPRuler 52",
    5288             :          {53, 0},                                    //"??53",
    5289             :          {54, 0},                                    //"??54",
    5290             :          {55, 0},                                    //"??55",
    5291             :          {56, 0},                                    //"??56",
    5292             :          {57, 0},                                    //"??57",
    5293             :          {58, 0},                                    //"??58",
    5294             :          {59, 0},                                    //"??59",
    5295             :          {60, 0},                                    //"??60",
    5296             :          {61, 0},                                    //"??61",
    5297             :          {62, 0},                                    //"??62",
    5298             :          {63, 0},                                    //"??63",
    5299             :          {64, &SwWW8ImplReader::Read_ParaBiDi},      //"rtl bidi ?
    5300             :          {65, &SwWW8ImplReader::Read_CFRMarkDel},    //"sprmCFStrikeRM",
    5301             :                                                      //chp.fRMarkDel 1 or 0 bit
    5302             :          {66, &SwWW8ImplReader::Read_CFRMark},       //"sprmCFRMark", chp.fRMark
    5303             :                                                      //1 or 0 bit
    5304             :          {67, &SwWW8ImplReader::Read_FldVanish},     //"sprmCFFldVanish",
    5305             :                                                      //chp.fFldVanish 1 or 0 bit
    5306             :          {68, &SwWW8ImplReader::Read_PicLoc},        //"sprmCPicLocation",
    5307             :                                                      //chp.fcPic and chp.fSpec
    5308             :          {69, 0},                                    //"sprmCIbstRMark",
    5309             :                                                      //chp.ibstRMark index into
    5310             :                                                      //sttbRMark
    5311             :          {70, 0},                                    //"sprmCDttmRMark", chp.dttm
    5312             :                                                      //DTTM long
    5313             :          {71, 0},                                    //"sprmCFData", chp.fData 1 or
    5314             :                                                      //0 bit
    5315             :          {72, 0},                                    //"sprmCRMReason",
    5316             :                                                      //chp.idslRMReason an index to
    5317             :                                                      //a table
    5318             :          {73, &SwWW8ImplReader::Read_CharSet},       //"sprmCChse", chp.fChsDiff
    5319             :                                                      //and chp.chse 3 bytes
    5320             :          {74, &SwWW8ImplReader::Read_Symbol},        //"sprmCSymbol", chp.fSpec,
    5321             :                                                      //chp.chSym and chp.ftcSym
    5322             :          {75, &SwWW8ImplReader::Read_Obj},           //"sprmCFOle2", chp.fOle2 1
    5323             :                                                      //or 0 bit
    5324             :          {76, 0},                                    //"??76",
    5325             :          {77, 0},                                    //"??77",
    5326             :          {78, 0},                                    //"??78",
    5327             :          {79, 0},                                    //"??79",
    5328             :          {80, &SwWW8ImplReader::Read_CColl},         //"sprmCIstd", chp.istd istd,
    5329             :                                                      //see stylesheet definition
    5330             :                                                      //short
    5331             :          {81, 0},                                    //"sprmCIstdPermute", chp.istd
    5332             :                                                      //permutation vector
    5333             :          {82, 0},                                    //"sprmCDefault", whole CHP
    5334             :                                                      //none variable length
    5335             :          {83, 0},                                    //"sprmCPlain", whole CHP
    5336             :                                                      //none 0
    5337             :          {84, 0},                                    //"??84",
    5338             :          {85, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFBold", chp.fBold 0,1,
    5339             :                                                      //128, or 129 byte
    5340             :          {86, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFItalic", chp.fItalic
    5341             :                                                      //0,1, 128, or 129 byte
    5342             :          {87, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFStrike", chp.fStrike
    5343             :                                                      //0,1, 128, or 129 byte
    5344             :          {88, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFOutline", chp.fOutline
    5345             :                                                      //0,1, 128, or 129 byte
    5346             :          {89, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFShadow", chp.fShadow
    5347             :                                                      //0,1, 128, or 129 byte
    5348             :          {90, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFSmallCaps",
    5349             :                                                      //chp.fSmallCaps 0,1, 128, or
    5350             :                                                      //129 byte
    5351             :          {91, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFCaps", chp.fCaps 0,1,
    5352             :                                                      //128, or 129 byte
    5353             :          {92, &SwWW8ImplReader::Read_BoldUsw},       //"sprmCFVanish", chp.fVanish
    5354             :                                                      //0,1, 128, or 129 byte
    5355             :          {93, &SwWW8ImplReader::Read_FontCode},      //"sprmCFtc", chp.ftc ftc word
    5356             :          {94, &SwWW8ImplReader::Read_Underline},     // "sprmCKul", chp.kul kul byte
    5357             :          {95, 0},                                    //"sprmCSizePos", chp.hps,
    5358             :                                                      //chp.hpsPos 3 bytes
    5359             :          {96, &SwWW8ImplReader::Read_Kern},          //"sprmCDxaSpace",
    5360             :                                                      //chp.dxaSpace dxa word
    5361             :          {97, &SwWW8ImplReader::Read_Language},      //"sprmCLid", chp.lid LID word
    5362             :          {98, &SwWW8ImplReader::Read_TxtColor},      //"sprmCIco", chp.ico ico byte
    5363             :          {99, &SwWW8ImplReader::Read_FontSize},      //"sprmCHps", chp.hps hps word!
    5364             :         {100, 0},                                    //"sprmCHpsInc", chp.hps byte
    5365             :         {101, &SwWW8ImplReader::Read_SubSuperProp},  //"sprmCHpsPos", chp.hpsPos
    5366             :                                                      //hps byte
    5367             :         {102, 0},                                    //"sprmCHpsPosAdj", chp.hpsPos
    5368             :                                                      //hps byte
    5369             :         {103, &SwWW8ImplReader::Read_Majority},      //"?sprmCMajority", chp.fBold,
    5370             :                                                      //chp.fItalic, chp.fSmallCaps
    5371             :         {104, &SwWW8ImplReader::Read_SubSuper},      //"sprmCIss", chp.iss iss byte
    5372             :         {105, 0},                                    //"sprmCHpsNew50", chp.hps hps
    5373             :                                                      //variable width, length
    5374             :                                                      //always recorded as 2
    5375             :         {106, 0},                                    //"sprmCHpsInc1", chp.hps
    5376             :                                                      //complex variable width,
    5377             :                                                      //length always recorded as 2
    5378             :         {107, &SwWW8ImplReader::Read_FontKern},      //"sprmCHpsKern", chp.hpsKern
    5379             :                                                      //hps short
    5380             :         {108, &SwWW8ImplReader::Read_Majority},      //"sprmCMajority50", chp.fBold,
    5381             :                                                      //chp.fItalic, chp.fSmallCaps,
    5382             :                                                      // chp.fVanish, ...
    5383             :         {109, 0},                                    //"sprmCHpsMul", chp.hps
    5384             :                                                      //percentage to grow hps short
    5385             :         {110, 0},                                    //"sprmCCondHyhen", chp.ysri
    5386             :                                                      //ysri short
    5387             :         {111, &SwWW8ImplReader::Read_FontCode},      //ww7 font
    5388             :         {112, &SwWW8ImplReader::Read_FontCode},      //ww7 CJK font
    5389             :         {113, &SwWW8ImplReader::Read_FontCode},      //ww7 rtl font
    5390             :         {114, &SwWW8ImplReader::Read_Language},      //ww7 lid
    5391             :         {115, &SwWW8ImplReader::Read_TxtColor},      //ww7 rtl colour ?
    5392             :         {116, &SwWW8ImplReader::Read_FontSize},
    5393             :         {117, &SwWW8ImplReader::Read_Special},       //"sprmCFSpec", chp.fSpec 1
    5394             :                                                      //or 0 bit
    5395             :         {118, &SwWW8ImplReader::Read_Obj},           //"sprmCFObj", chp.fObj 1 or 0
    5396             :                                                      //bit
    5397             :         {119, 0},                                    //"sprmPicBrcl", pic.brcl brcl
    5398             :                                                      //(see PIC structure
    5399             :                                                      //definition) byte
    5400             :         {120, 0},                                    //"sprmPicScale", pic.mx,
    5401             :                                                      //pic.my, pic.dxaCropleft,
    5402             :         {121, 0},                                    //"sprmPicBrcTop", pic.brcTop
    5403             :                                                      //BRC word
    5404             :         {122, 0},                                    //"sprmPicBrcLeft",
    5405             :                                                      //pic.brcLeft BRC word
    5406             :         {123, 0},                                    //"sprmPicBrcBottom",
    5407             :                                                      //pic.brcBottom BRC word
    5408             :         {124, 0},                                    //"sprmPicBrcRight",
    5409             :                                                      //pic.brcRight BRC word
    5410             :         {125, 0},                                    //"??125",
    5411             :         {126, 0},                                    //"??126",
    5412             :         {127, 0},                                    //"??127",
    5413             :         {128, 0},                                    //"??128",
    5414             :         {129, 0},                                    //"??129",
    5415             :         {130, 0},                                    //"??130",
    5416             :         {131, 0},                                    //"sprmSScnsPgn", sep.cnsPgn
    5417             :                                                      //cns byte
    5418             :         {132, 0},                                    //"sprmSiHeadingPgn",
    5419             :                                                      //sep.iHeadingPgn heading
    5420             :                                                      //number level byte
    5421             :         {133, &SwWW8ImplReader::Read_OLST},          //"sprmSOlstAnm", sep.olstAnm
    5422             :                                                      //OLST variable length
    5423             :         {134, 0},                                    //"??135",
    5424             :         {135, 0},                                    //"??135",
    5425             :         {136, 0},                                    //"sprmSDxaColWidth",
    5426             :                                                      //sep.rgdxaColWidthSpacing
    5427             :                                                      //complex 3 bytes
    5428             :         {137, 0},                                    //"sprmSDxaColSpacing",
    5429             :                                                      //sep.rgdxaColWidthSpacing
    5430             :                                                      //complex 3 bytes
    5431             :         {138, 0},                                    //"sprmSFEvenlySpaced",
    5432             :                                                      //sep.fEvenlySpaced 1 or 0 byte
    5433             :         {139, 0},                                    //"sprmSFProtected",
    5434             :                                                      //sep.fUnlocked 1 or 0 byte
    5435             :         {140, 0},                                    //"sprmSDmBinFirst",
    5436             :                                                      //sep.dmBinFirst  word
    5437             :         {141, 0},                                    //"sprmSDmBinOther",
    5438             :                                                      //sep.dmBinOther  word
    5439             :         {142, 0},                                    //"sprmSBkc", sep.bkc bkc
    5440             :                                                      //byte BreakCode
    5441             :         {143, 0},                                    //"sprmSFTitlePage",
    5442             :                                                      //sep.fTitlePage 0 or 1 byte
    5443             :         {144, 0},                                    //"sprmSCcolumns", sep.ccolM1
    5444             :                                                      //# of cols - 1 word
    5445             :         {145, 0},                                    //"sprmSDxaColumns",
    5446             :                                                      //sep.dxaColumns dxa word
    5447             :         {146, 0},                                    //"sprmSFAutoPgn",
    5448             :                                                      //sep.fAutoPgn obsolete byte
    5449             :         {147, 0},                                    //"sprmSNfcPgn", sep.nfcPgn
    5450             :                                                      //nfc byte
    5451             :         {148, 0},                                    //"sprmSDyaPgn", sep.dyaPgn
    5452             :                                                      //dya short
    5453             :         {149, 0},                                    //"sprmSDxaPgn", sep.dxaPgn
    5454             :                                                      //dya short
    5455             :         {150, 0},                                    //"sprmSFPgnRestart",
    5456             :                                                      //sep.fPgnRestart 0 or 1 byte
    5457             :         {151, 0},                                    //"sprmSFEndnote", sep.fEndnote
    5458             :                                                      //0 or 1 byte
    5459             :         {152, 0},                                    //"sprmSLnc", sep.lnc lnc byte
    5460             :         {153, 0},                                    //"sprmSGprfIhdt", sep.grpfIhdt
    5461             :                                                      //grpfihdt byte
    5462             :         {154, 0},                                    //"sprmSNLnnMod", sep.nLnnMod
    5463             :                                                      //non-neg int. word
    5464             :         {155, 0},                                    //"sprmSDxaLnn", sep.dxaLnn
    5465             :                                                      //dxa word
    5466             :         {156, 0},                                    //"sprmSDyaHdrTop",
    5467             :                                                      //sep.dyaHdrTop dya word
    5468             :         {157, 0},                                    //"sprmSDyaHdrBottom",
    5469             :                                                      //sep.dyaHdrBottom dya word
    5470             :         {158, 0},                                    //"sprmSLBetween",
    5471             :                                                      //sep.fLBetween 0 or 1 byte
    5472             :         {159, 0},                                    //"sprmSVjc", sep.vjc vjc byte
    5473             :         {160, 0},                                    //"sprmSLnnMin", sep.lnnMin
    5474             :                                                      //lnn word
    5475             :         {161, 0},                                    //"sprmSPgnStart", sep.pgnStart
    5476             :                                                      //pgn word
    5477             :         {162, 0},                                    //"sprmSBOrientation",
    5478             :                                                      //sep.dmOrientPage dm byte
    5479             :         {163, 0},                                    //"?SprmSBCustomize 163", ?
    5480             :         {164, 0},                                    //"sprmSXaPage", sep.xaPage xa
    5481             :                                                      //word
    5482             :         {165, 0},                                    //"sprmSYaPage", sep.yaPage ya
    5483             :                                                      //word
    5484             :         {166, 0},                                    //"sprmSDxaLeft", sep.dxaLeft
    5485             :                                                      //dxa word
    5486             :         {167, 0},                                    //"sprmSDxaRight", sep.dxaRight
    5487             :                                                      //dxa word
    5488             :         {168, 0},                                    //"sprmSDyaTop", sep.dyaTop                                                     //dya word
    5489             :         {169, 0},                                    //"sprmSDyaBottom",
    5490             :                                                      //sep.dyaBottom dya word
    5491             :         {170, 0},                                    //"sprmSDzaGutter",
    5492             :                                                      //sep.dzaGutter dza word
    5493             :         {171, 0},                                    //"sprmSDMPaperReq",
    5494             :                                                      //sep.dmPaperReq dm word
    5495             :         {172, 0},                                    //"??172",
    5496             :         {173, 0},                                    //"??173",
    5497             :         {174, 0},                                    //"??174",
    5498             :         {175, 0},                                    //"??175",
    5499             :         {176, 0},                                    //"??176",
    5500             :         {177, 0},                                    //"??177",
    5501             :         {178, 0},                                    //"??178",
    5502             :         {179, 0},                                    //"??179",
    5503             :         {180, 0},                                    //"??180",
    5504             :         {181, 0},                                    //"??181",
    5505             :         {182, 0},                                    //"sprmTJc", tap.jc jc word
    5506             :                                                      //(low order byte is
    5507             :                                                      //significant)
    5508             :         {183, 0},                                    //"sprmTDxaLeft",
    5509             :                                                      //tap.rgdxaCenter dxa word
    5510             :         {184, 0},                                    //"sprmTDxaGapHalf",
    5511             :                                                      //tap.dxaGapHalf,
    5512             :                                                      //tap.rgdxaCenter dxa word
    5513             :         {185, 0},                                    //"sprmTFCantSplit"
    5514             :                                                      //tap.fCantSplit 1 or 0 byte
    5515             :         {186, 0},                                    //"sprmTTableHeader",
    5516             :                                                      //tap.fTableHeader 1 or 0 byte
    5517             :         {187, 0},                                    //"sprmTTableBorders",
    5518             :                                                      //tap.rgbrcTable complex
    5519             :                                                      //12 bytes
    5520             :         {188, 0},                                    //"sprmTDefTable10",
    5521             :                                                      //tap.rgdxaCenter, tap.rgtc
    5522             :                                                      //complex variable length
    5523             :         {189, 0},                                    //"sprmTDyaRowHeight",
    5524             :                                                      //tap.dyaRowHeight dya word
    5525             :         {190, 0},                                    //"?sprmTDefTable", tap.rgtc
    5526             :                                                      //complex
    5527             :         {191, 0},                                    //"?sprmTDefTableShd",
    5528             :                                                      //tap.rgshd complex
    5529             :         {192, 0},                                    //"sprmTTlp", tap.tlp TLP
    5530             :                                                      //4 bytes
    5531             :         {193, 0},                                    //"sprmTSetBrc",
    5532             :                                                      //tap.rgtc[].rgbrc complex
    5533             :                                                      //5 bytes
    5534             :         {194, 0},                                    //"sprmTInsert",
    5535             :                                                      //tap.rgdxaCenter,
    5536             :                                                      //tap.rgtc complex 4 bytes
    5537             :         {195, 0},                                    //"sprmTDelete",
    5538             :                                                      //tap.rgdxaCenter,
    5539             :                                                      //tap.rgtc complex word
    5540             :         {196, 0},                                    //"sprmTDxaCol",
    5541             :                                                      //tap.rgdxaCenter complex
    5542             :                                                      //4 bytes
    5543             :         {197, 0},                                    //"sprmTMerge",
    5544             :                                                      //tap.fFirstMerged,
    5545             :                                                      //tap.fMerged complex word
    5546             :         {198, 0},                                    //"sprmTSplit",
    5547             :                                                      //tap.fFirstMerged,
    5548             :                                                      //tap.fMerged complex word
    5549             :         {199, 0},                                    //"sprmTSetBrc10",
    5550             :                                                      //tap.rgtc[].rgbrc complex
    5551             :                                                      //5 bytes
    5552             :         {200, 0},                                    //"sprmTSetShd", tap.rgshd
    5553             :                                                      //complex 4 bytes
    5554             :         {207, 0},                                    //dunno
    5555             :     };
    5556             : 
    5557           0 :     static wwSprmDispatcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0]));
    5558           0 :     return &aSprmSrch;
    5559             : }
    5560             : 
    5561      180020 : const wwSprmDispatcher *GetWW8SprmDispatcher()
    5562             : {
    5563             :     static SprmReadInfo aSprms[] =
    5564             :     {
    5565             :         {0,      0},                                 // "0" Default bzw. Error
    5566             : 
    5567             :         {0x4600, &SwWW8ImplReader::Read_StyleCode},  //"sprmPIstd" pap.istd;istd
    5568             :                                                      //(style code);short;
    5569             :         {0xC601, 0},                                 //"sprmPIstdPermute" pap.istd;
    5570             :                                                      //permutation vector;
    5571             :                                                      //variable length;
    5572             :         {0x2602, 0},                                 //"sprmPIncLvl" pap.istd,
    5573             :                                                      //pap.lvl;difference between
    5574             :                                                      //istd of base PAP and istd of
    5575             :                                                      //PAP to be produced; byte;
    5576             :         {0x2403, &SwWW8ImplReader::Read_Justify},    //"sprmPJc" pap.jc;jc
    5577             :                                                      //(justification);byte;
    5578             :         {0x2404, 0},                                 //"sprmPFSideBySide"
    5579             :                                                      //pap.fSideBySide;0 or 1;byte;
    5580             :         {0x2405, &SwWW8ImplReader::Read_KeepLines},  //"sprmPFKeep" pap.fKeep;0 or
    5581             :                                                      //1;byte;
    5582             :         {0x2406, &SwWW8ImplReader::Read_KeepParas},  //"sprmPFKeepFollow"
    5583             :                                                      //pap.fKeepFollow;0 or 1;byte;
    5584             :         {0x2407, &SwWW8ImplReader::Read_BreakBefore},//"sprmPFPageBreakBefore"
    5585             :                                                      //pap.fPageBreakBefore;0 or 1;
    5586             :                                                      //byte;
    5587             :         {0x2408, 0},                                 //"sprmPBrcl" pap.brcl;brcl;
    5588             :                                                      //byte;
    5589             :         {0x2409, 0},                                 //"sprmPBrcp" pap.brcp;brcp;
    5590             :                                                      //byte;
    5591             :         {0x260A, &SwWW8ImplReader::Read_ListLevel},  //"sprmPIlvl" pap.ilvl;ilvl;
    5592             :                                                      //byte;
    5593             :         {0x460B, &SwWW8ImplReader::Read_LFOPosition},//"sprmPIlfo" pap.ilfo;ilfo
    5594             :                                                      //(list index) ;short;
    5595             :         {0x240C, &SwWW8ImplReader::Read_NoLineNumb}, //"sprmPFNoLineNumb"
    5596             :                                                      //pap.fNoLnn;0 or 1;byte;
    5597             :         {0xC60D, &SwWW8ImplReader::Read_Tab},        //"sprmPChgTabsPapx"
    5598             :                                                      //pap.itbdMac, pap.rgdxaTab,
    5599             :                                                      //pap.rgtbd;complex;variable
    5600             :                                                      //length
    5601             :         {0x840E, &SwWW8ImplReader::Read_LR},         //Word 97 version of "sprmPDxaRight" pap.dxaRight;
    5602             :                                                      //dxa;word;
    5603             :         {0x840F, &SwWW8ImplReader::Read_LR},         //Apparently Word 97 version of "sprmPDxaLeft" pap.dxaLeft;
    5604             :                                                      //dxa;word;
    5605             :         {0x4610, 0},                                 //"sprmPNest" pap.dxaLeft;
    5606             :                                                      //dxa;word;
    5607             :         {0x8411, &SwWW8ImplReader::Read_LR},         //Word 97 version of "sprmPDxaLeft1" pap.dxaLeft1;
    5608             :                                                      //dxa;word;
    5609             :         {0x6412, &SwWW8ImplReader::Read_LineSpace},  //"sprmPDyaLine" pap.lspd;
    5610             :                                                      //an LSPD, a long word
    5611             :                                                      //structure consisting of a
    5612             :                                                      //short of dyaLine followed by
    5613             :                                                      //a short of fMultLinespace;
    5614             :                                                      //long;
    5615             :         {0xA413, &SwWW8ImplReader::Read_UL},         //"sprmPDyaBefore"
    5616             :                                                      //pap.dyaBefore;dya;word;
    5617             :         {0xA414, &SwWW8ImplReader::Read_UL},         //"sprmPDyaAfter" pap.dyaAfter;
    5618             :                                                      //dya;word;
    5619             :         {0xC615, 0},                                 //"sprmPChgTabs" pap.itbdMac,
    5620             :                                                      //pap.rgdxaTab, pap.rgtbd;
    5621             :                                                      //complex;variable length;
    5622             :         {0x2416, 0},                                 //"sprmPFInTable" pap.fInTable;
    5623             :                                                      //0 or 1;byte;
    5624             :         {0x2417, &SwWW8ImplReader::Read_TabRowEnd},  //"sprmPFTtp" pap.fTtp;0 or 1;
    5625             :                                                      //byte;
    5626             :         {0x8418, 0},                                 //"sprmPDxaAbs" pap.dxaAbs;dxa;
    5627             :                                                      //word;
    5628             :         {0x8419, 0},                                 //"sprmPDyaAbs" pap.dyaAbs;dya;
    5629             :                                                      //word;
    5630             :         {0x841A, 0},                                 //"sprmPDxaWidth" pap.dxaWidth;
    5631             :                                                      //dxa;word;
    5632             :         {0x261B, &SwWW8ImplReader::Read_ApoPPC},     //"sprmPPc" pap.pcHorz,
    5633             :                                                      //pap.pcVert;complex;byte;
    5634             :         {0x461C, 0},                                 //"sprmPBrcTop10" pap.brcTop;
    5635             :                                                      //BRC10;word;
    5636             :         {0x461D, 0},                                 //"sprmPBrcLeft10" pap.brcLeft;
    5637             :                                                      //BRC10;word;
    5638             :         {0x461E, 0},                                 //"sprmPBrcBottom10"
    5639             :                                                      //pap.brcBottom;BRC10;word;
    5640             :         {0x461F, 0},                                 //"sprmPBrcRight10"
    5641             :                                                      //pap.brcRight;BRC10;word;
    5642             :         {0x4620, 0},                                 //"sprmPBrcBetween10"
    5643             :                                                      //pap.brcBetween;BRC10;word;
    5644             :         {0x4621, 0},                                 //"sprmPBrcBar10" pap.brcBar;
    5645             :                                                      //BRC10;word;
    5646             :         {0x4622, 0},                                 //"sprmPDxaFromText10"
    5647             :                                                      //pap.dxaFromText;dxa;word;
    5648             :         {0x2423, 0},                                 //"sprmPWr" pap.wr;wr;byte;
    5649             :         {0x6424, &SwWW8ImplReader::Read_Border},     //"sprmPBrcTop80" pap.brcTop;BRC;
    5650             :                                                      //long;
    5651             :         {0x6425, &SwWW8ImplReader::Read_Border},     //"sprmPBrcLeft80" pap.brcLeft;
    5652             :                                                      //BRC;long;
    5653             :         {0x6426, &SwWW8ImplReader::Read_Border},     //"sprmPBrcBottom80"
    5654             :                                                      //pap.brcBottom;BRC;long;
    5655             :         {0x6427, &SwWW8ImplReader::Read_Border},     //"sprmPBrcRight80" pap.brcRight;
    5656             :                                                      //BRC;long;
    5657             :         {0x6428, &SwWW8ImplReader::Read_Border},     //"sprmPBrcBetween80"
    5658             :                                                      //pap.brcBetween;BRC;long;
    5659             :         {0x6629, 0},                                 //"sprmPBrcBar" pap.brcBar;BRC;
    5660             :                                                      //long;
    5661             :         {0x242A, &SwWW8ImplReader::Read_Hyphenation},//"sprmPFNoAutoHyph"
    5662             :                                                      //pap.fNoAutoHyph;0 or 1;byte;
    5663             :         {0x442B, 0},                                 //"sprmPWHeightAbs"
    5664             :                                                      //pap.wHeightAbs;w;word;
    5665             :         {0x442C, 0},                                 //"sprmPDcs" pap.dcs;DCS;short;
    5666             :         {0x442D, &SwWW8ImplReader::Read_Shade},      //"sprmPShd" pap.shd;SHD;word;
    5667             :         {0x842E, 0},                                 //"sprmPDyaFromText"
    5668             :                                                      //pap.dyaFromText;dya;word;
    5669             :         {0x842F, 0},                                 //"sprmPDxaFromText"
    5670             :                                                      //pap.dxaFromText;dxa;word;
    5671             :         {0x2430, 0},                                 //"sprmPFLocked" pap.fLocked;
    5672             :                                                      //0 or 1;byte;
    5673             :         {0x2431, &SwWW8ImplReader::Read_WidowControl},//"sprmPFWidowControl"
    5674             :                                                      //pap.fWidowControl;0 or 1;byte
    5675             :         {0xC632, 0},                                 //"sprmPRuler" variable length;
    5676             :         {0x2433, &SwWW8ImplReader::Read_BoolItem},   //"sprmPFKinsoku" pap.fKinsoku;
    5677             :                                                      //0 or 1;byte;
    5678             :         {0x2434, 0},                                 //"sprmPFWordWrap"
    5679             :                                                      //pap.fWordWrap;0 or 1;byte;
    5680             :         {0x2435, &SwWW8ImplReader::Read_BoolItem},   //"sprmPFOverflowPunct"
    5681             :                                                      //pap.fOverflowPunct; 0 or 1;
    5682             :                                                      //byte;
    5683             :         {0x2436, 0},                                 //"sprmPFTopLinePunct"
    5684             :                                                      //pap.fTopLinePunct;0 or 1;byte
    5685             :         {0x2437, &SwWW8ImplReader::Read_BoolItem},   //"sprmPFAutoSpaceDE"
    5686             :                                                      //pap.fAutoSpaceDE;0 or 1;byte;
    5687             :         {0x2438, 0},                                 //"sprmPFAutoSpaceDN"
    5688             :                                                      //pap.fAutoSpaceDN;0 or 1;byte;
    5689             :         {NS_sprm::LN_PWAlignFont, &SwWW8ImplReader::Read_AlignFont},  //"sprmPWAlignFont"
    5690             :                                                      //pap.wAlignFont;iFa; word;
    5691             :         {0x443A, 0},                                 //"sprmPFrameTextFlow"
    5692             :                                                      //pap.fVertical pap.fBackward
    5693             :                                                      //pap.fRotateFont;complex; word
    5694             :         {0x243B, 0},                                 //"sprmPISnapBaseLine" obsolete
    5695             :                                                      //not applicable in Word97
    5696             :                                                      //and later versions;;byte;
    5697             :         {0xC63E, &SwWW8ImplReader::Read_ANLevelDesc},//"sprmPAnld" pap.anld;;
    5698             :                                                      //variable length;
    5699             :         {0xC63F, 0},                                 //"sprmPPropRMark"
    5700             :                                                      //pap.fPropRMark;complex;
    5701             :                                                      //variable length;
    5702             :         {0x2640,  &SwWW8ImplReader::Read_POutLvl},   //"sprmPOutLvl" pap.lvl;has no
    5703             :                                                      //effect if pap.istd is < 1 or
    5704             :                                                      //is > 9;byte;
    5705             :         {0x2441, &SwWW8ImplReader::Read_ParaBiDi},   //"sprmPFBiDi" ;;byte;
    5706             :         {0x2443, 0},                                 //"sprmPFNumRMIns"
    5707             :                                                      //pap.fNumRMIns;1 or 0;bit;
    5708             :         {0x2444, 0},                                 //"sprmPCrLf" ;;byte;
    5709             :         {0xC645, 0},                                 //"sprmPNumRM" pap.numrm;;
    5710             :                                                      //variable length;
    5711             :         {0x6645, 0},                                 //"sprmPHugePapx" ;fc in the
    5712             :                                                      //data stream to locate the
    5713             :                                                      //huge grpprl; long;
    5714             :         {0x6646, 0},                                 //"sprmPHugePapx" ;fc in the
    5715             :                                                      //data stream to locate the
    5716             :                                                      //huge grpprl; long;
    5717             :         {0x2447, &SwWW8ImplReader::Read_UsePgsuSettings},//"sprmPFUsePgsuSettings"
    5718             :                                                      //pap.fUsePgsuSettings;1 or 0;
    5719             :                                                      //byte;
    5720             :         {0x2448, 0},                                 //"sprmPFAdjustRight"
    5721             :                                                      //pap.fAdjustRight;1 or 0;byte;
    5722             :         {0x0800, &SwWW8ImplReader::Read_CFRMarkDel}, //"sprmCFRMarkDel"
    5723             :                                                      //chp.fRMarkDel;1 or 0;bit;
    5724             :         {0x0801, &SwWW8ImplReader::Read_CFRMark},    //"sprmCFRMark" chp.fRMark;1
    5725             :                                                      //or 0;bit;
    5726             :         {0x0802, &SwWW8ImplReader::Read_FldVanish},  //"sprmCFFldVanish"
    5727             :                                                      //chp.fFldVanish;1 or 0;bit;
    5728             :         {0x6A03, &SwWW8ImplReader::Read_PicLoc},     //"sprmCPicLocation" chp.fcPic
    5729             :                                                      //and chp.fSpec;variable
    5730             :                                                      //length, length recorded is
    5731             :                                                      //always 4;
    5732             :         {0x4804, 0},                                 //"sprmCIbstRMark"
    5733             :                                                      //chp.ibstRMark;index into
    5734             :                                                      //sttbRMark;short;
    5735             :         {0x6805, 0},                                 //"sprmCDttmRMark"
    5736             :                                                      //chp.dttmRMark;DTTM;long;
    5737             :         {0x0806, 0},                                 //"sprmCFData" chp.fData;1 or
    5738             :                                                      //0;bit;
    5739             :         {0x4807, 0},                                 //"sprmCIdslRMark"
    5740             :                                                      //chp.idslRMReason;an index to
    5741             :                                                      //a table of strings defined in
    5742             :                                                      //Word 6.0 executables;short;
    5743             :         {0xEA08, &SwWW8ImplReader::Read_CharSet},    //"sprmCChs" chp.fChsDiff and
    5744             :                                                      //chp.chse;3 bytes;
    5745             :         {0x6A09, &SwWW8ImplReader::Read_Symbol},     //"sprmCSymbol" chp.fSpec,
    5746             :                                                      //chp.xchSym and chp.ftcSym;
    5747             :                                                      //variable length, length
    5748             :                                                      //recorded is always 4;
    5749             :         {0x080A, &SwWW8ImplReader::Read_Obj},        //"sprmCFOle2" chp.fOle2;1 or
    5750             :                                                      //0;bit;
    5751             :       //0x480B,                                      //"sprmCIdCharType", obsolete:
    5752             :                                                      //not applicable in Word97
    5753             :                                                      //and later versions
    5754             :         {0x2A0C, &SwWW8ImplReader::Read_CharHighlight},//"sprmCHighlight"
    5755             :                                                      //chp.fHighlight,
    5756             :                                                      //chp.icoHighlight;ico
    5757             :                                                      //(fHighlight is set to 1 iff
    5758             :                                                      //ico is not 0);byte;
    5759             :         {0x680E, &SwWW8ImplReader::Read_PicLoc},     //"sprmCObjLocation" chp.fcObj;
    5760             :                                                      //FC;long;
    5761             :       //0x2A10, ? ? ?,                               //"sprmCFFtcAsciSymb"
    5762             :         {0x4A30, &SwWW8ImplReader::Read_CColl},      //"sprmCIstd" chp.istd;istd,
    5763             :                                                      //short;
    5764             :         {0xCA31, 0},                                 //"sprmCIstdPermute" chp.istd;
    5765             :                                                      //permutation vector; variable
    5766             :                                                      //length;
    5767             :         {0x2A32, 0},                                 //"sprmCDefault" whole CHP;none
    5768             :                                                      //;variable length;
    5769             :         {0x2A33, 0},                                 //"sprmCPlain" whole CHP;none;
    5770             :                                                      //Laenge: 0;
    5771             :         {0x2A34, &SwWW8ImplReader::Read_Emphasis},   //"sprmCKcd"
    5772             :         {0x0835, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFBold" chp.fBold;0,1,
    5773             :                                                      //128, or 129; byte;
    5774             :         {0x0836, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFItalic" chp.fItalic;0,
    5775             :                                                      //1, 128, or 129; byte;
    5776             :         {0x0837, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFStrike" chp.fStrike;0,
    5777             :                                                      //1, 128, or 129; byte;
    5778             :         {0x0838, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFOutline" chp.fOutline;
    5779             :                                                      //0,1, 128, or 129; byte;
    5780             :         {0x0839, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFShadow" chp.fShadow;0,
    5781             :                                                      //1, 128, or 129; byte;
    5782             :         {0x083A, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFSmallCaps"
    5783             :                                                      //chp.fSmallCaps;0,1, 128, or
    5784             :                                                      //129;byte;
    5785             :         {0x083B, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFCaps" chp.fCaps;0,1,
    5786             :                                                      //128, or 129; byte;
    5787             :         {0x083C, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFVanish" chp.fVanish;0,
    5788             :                                                      //1, 128, or 129; byte;
    5789             :       //0x4A3D, 0,                                   //"sprmCFtcDefault" ftc, only
    5790             :                                                      //used internally, never
    5791             :                                                      //stored in file;word;
    5792             :         {0x2A3E, &SwWW8ImplReader::Read_Underline},  //"sprmCKul" chp.kul;kul;byte;
    5793             :         {0xEA3F, 0},                                 //"sprmCSizePos" chp.hps,
    5794             :                                                      //chp.hpsPos;3 bytes;
    5795             :         {0x8840, &SwWW8ImplReader::Read_Kern},       //"sprmCDxaSpace" chp.dxaSpace;
    5796             :                                                      //dxa;word;
    5797             :         {0x4A41, &SwWW8ImplReader::Read_Language},   //"sprmCLid" ;only used
    5798             :                                                      //internally never stored;word;
    5799             :         {0x2A42, &SwWW8ImplReader::Read_TxtColor},   //"sprmCIco" chp.ico;ico;byte;
    5800             :         {0x4A43, &SwWW8ImplReader::Read_FontSize},   //"sprmCHps" chp.hps;hps;byte;
    5801             :         {0x2A44, 0},                                 //"sprmCHpsInc" chp.hps;byte;
    5802             :         {0x4845, &SwWW8ImplReader::Read_SubSuperProp},//"sprmCHpsPos" chp.hpsPos;
    5803             :                                                      //hps; byte;
    5804             :         {0x2A46, 0},                                 //"sprmCHpsPosAdj" chp.hpsPos;
    5805             :                                                      //hps; byte;
    5806             :         {0xCA47, &SwWW8ImplReader::Read_Majority},   //"sprmCMajority" chp.fBold,
    5807             :                                                      //chp.fItalic, chp.fSmallCaps,
    5808             :                                                      //chp.fVanish, chp.fStrike,
    5809             :                                                      //chp.fCaps, chp.rgftc,
    5810             :                                                      //chp.hps, chp.hpsPos, chp.kul,
    5811             :                                                      //chp.dxaSpace, chp.ico,
    5812             :                                                      //chp.rglid;complex;variable
    5813             :                                                      //length, length byte plus
    5814             :                                                      //size of following grpprl;
    5815             :         {0x2A48, &SwWW8ImplReader::Read_SubSuper},   //"sprmCIss" chp.iss;iss;byte;
    5816             :         {0xCA49, 0},                                 //"sprmCHpsNew50" chp.hps;hps;
    5817             :                                                      //variable width, length
    5818             :                                                      //always recorded as 2;
    5819             :         {0xCA4A, 0},                                 //"sprmCHpsInc1" chp.hps;
    5820             :                                                      //complex; variable width,
    5821             :                                                      //length always recorded as 2;
    5822             :         {0x484B, &SwWW8ImplReader::Read_FontKern},   //"sprmCHpsKern" chp.hpsKern;
    5823             :                                                      //hps;short;
    5824             :         {0xCA4C, &SwWW8ImplReader::Read_Majority},   //"sprmCMajority50" chp.fBold,
    5825             :                                                      //chp.fItalic, chp.fSmallCaps,
    5826             :                                                      //chp.fVanish, chp.fStrike,
    5827             :                                                      //chp.fCaps, chp.ftc, chp.hps,
    5828             :                                                      //chp.hpsPos, chp.kul,
    5829             :                                                      //chp.dxaSpace, chp.ico;
    5830             :                                                      //complex; variable length;
    5831             :         {0x4A4D, 0},                                 //"sprmCHpsMul" chp.hps;
    5832             :                                                      //percentage to grow hps;short;
    5833             :         {0x484E, 0},                                 //"sprmCYsri" chp.ysri;ysri;
    5834             :                                                      //short;
    5835             :         {0x4A4F, &SwWW8ImplReader::Read_FontCode},   //"sprmCRgFtc0" chp.rgftc[0];
    5836             :                                                      //ftc for ASCII text; short;
    5837             :         {0x4A50, &SwWW8ImplReader::Read_FontCode},   //"sprmCRgFtc1" chp.rgftc[1];
    5838             :                                                      //ftc for Far East text;short;
    5839             :         {0x4A51, &SwWW8ImplReader::Read_FontCode},   //"sprmCRgFtc2" chp.rgftc[2];
    5840             :                                                      //ftc for non-Far East text;
    5841             :                                                      //short;
    5842             :         {0x4852, &SwWW8ImplReader::Read_ScaleWidth}, //"sprmCCharScale"
    5843             :         {0x2A53, &SwWW8ImplReader::Read_BoldUsw},    //"sprmCFDStrike" chp.fDStrike;
    5844             :                                                      //;byte;
    5845             :         {0x0854, &SwWW8ImplReader::Read_Relief},     //"sprmCFImprint" chp.fImprint;
    5846             :                                                      //1 or 0;bit;
    5847             :         {0x0855, &SwWW8ImplReader::Read_Special},    //"sprmCFSpec" chp.fSpec;
    5848             :                                                      //1 or 0;bit;
    5849             :         {0x0856, &SwWW8ImplReader::Read_Obj},        //"sprmCFObj" chp.fObj;1 or 0;
    5850             :                                                      //bit;
    5851             :         {0xCA57, &SwWW8ImplReader::Read_CPropRMark}, //"sprmCPropRMark"
    5852             :                                                      //chp.fPropRMark,
    5853             :                                                      //chp.ibstPropRMark,
    5854             :                                                      //chp.dttmPropRMark;Complex;
    5855             :                                                      //variable length always
    5856             :                                                      //recorded as 7 bytes;
    5857             :         {0x0858, &SwWW8ImplReader::Read_Relief},     //"sprmCFEmboss" chp.fEmboss;
    5858             :                                                      //1 or 0;bit;
    5859             :         {0x2859, &SwWW8ImplReader::Read_TxtAnim},    //"sprmCSfxText" chp.sfxtText;
    5860             :                                                      //text animation;byte;
    5861             :         {0x085A, &SwWW8ImplReader::Read_Bidi},                                 //"sprmCFBiDi"
    5862             :         {0x085B, 0},                                 //"sprmCFDiacColor"
    5863             :         {0x085C, &SwWW8ImplReader::Read_BoldBiDiUsw},//"sprmCFBoldBi"
    5864             :         {0x085D, &SwWW8ImplReader::Read_BoldBiDiUsw},//"sprmCFItalicBi"
    5865             :         {0x4A5E, &SwWW8ImplReader::Read_FontCode},   //"sprmCFtcBi"
    5866             :         {0x485F, &SwWW8ImplReader::Read_Language},   //"sprmCLidBi"
    5867             :       //0x4A60, ? ? ?,                               //"sprmCIcoBi",
    5868             :         {0x4A61, &SwWW8ImplReader::Read_FontSize},   //"sprmCHpsBi"
    5869             :         {0xCA62, 0},                                 //"sprmCDispFldRMark"
    5870             :                                                      //chp.fDispFldRMark,
    5871             :                                                      //chp.ibstDispFldRMark,
    5872             :                                                      //chp.dttmDispFldRMark ;
    5873             :                                                      //Complex;variable length
    5874             :                                                      //always recorded as 39 bytes;
    5875             :         {0x4863, 0},                                 //"sprmCIbstRMarkDel"
    5876             :                                                      //chp.ibstRMarkDel;index into
    5877             :                                                      //sttbRMark;short;
    5878             :         {NS_sprm::LN_CDttmRMarkDel, 0},
    5879             :                                                      //chp.dttmRMarkDel;DTTM;long;
    5880             :         {0x6865, &SwWW8ImplReader::Read_CharBorder}, //"sprmCBrc80" chp.brc;BRC;long;
    5881             :         {0xca72, &SwWW8ImplReader::Read_CharBorder}, //"sprmCBrc" chp.brc;BRC;long;
    5882             :         {0x4866, &SwWW8ImplReader::Read_CharShadow}, //"sprmCShd80" chp.shd;SHD;short;
    5883             :         {0x4867, 0},                                 //"sprmCIdslRMarkDel"
    5884             :                                                      //chp.idslRMReasonDel;an index
    5885             :                                                      //to a table of strings
    5886             :                                                      //defined in Word 6.0
    5887             :                                                      //executables;short;
    5888             :         {0x0868, 0},                                 //"sprmCFUsePgsuSettings"
    5889             :                                                      //chp.fUsePgsuSettings; 1 or 0;
    5890             :                                                      //bit;
    5891             :         {0x486B, 0},                                 //"sprmCCpg" ;;word;
    5892             :         {0x486D, &SwWW8ImplReader::Read_Language},   //"sprmCRgLid0_80" chp.rglid[0];
    5893             :                                                      //LID: for non-Far East text;
    5894             :                                                      //word;
    5895             :         {0x486E, &SwWW8ImplReader::Read_Language},   //"sprmCRgLid1_80" chp.rglid[1];
    5896             :                                                      //LID: for Far East text;word;
    5897             :         {0x286F, &SwWW8ImplReader::Read_IdctHint},   //"sprmCIdctHint" chp.idctHint;
    5898             :                                                      //IDCT: byte;
    5899             :         {0x2E00, 0},                                 //"sprmPicBrcl" pic.brcl;brcl
    5900             :                                                      //(see PIC structure
    5901             :                                                      //definition);byte;
    5902             :         {0xCE01, 0},                                 //"sprmPicScale" pic.mx,
    5903             :                                                      //pic.my, pic.dxaCropleft,
    5904             :                                                      //pic.dyaCropTop
    5905             :                                                      //pic.dxaCropRight,
    5906             :                                                      //pic.dyaCropBottom;Complex;
    5907             :                                                      //length byte plus 12 bytes;
    5908             :         {0x6C02, 0},                                 //"sprmPicBrcTop80" pic.brcTop;
    5909             :                                                      //BRC;long;
    5910             :         {0x6C03, 0},                                 //"sprmPicBrcLeft80" pic.brcLeft;
    5911             :                                                      //BRC;long;
    5912             :         {0x6C04, 0},                                 //"sprmPicBrcBottom80"
    5913             :                                                      //pic.brcBottom;BRC;long;
    5914             :         {0x6C05, 0},                                 //"sprmPicBrcRight80"
    5915             :                                                      //pic.brcRight;BRC;long;
    5916             :         {0x3000, 0},                                 //"sprmScnsPgn" sep.cnsPgn;cns;
    5917             :                                                      //byte;
    5918             :         {0x3001, 0},                                 //"sprmSiHeadingPgn"
    5919             :                                                      //sep.iHeadingPgn;heading
    5920             :                                                      //number level;byte;
    5921             :         {0xD202, &SwWW8ImplReader::Read_OLST},       //"sprmSOlstAnm" sep.olstAnm;
    5922             :                                                      //OLST;variable length;
    5923             :         {0xF203, 0},                                 //"sprmSDxaColWidth"
    5924             :                                                      //sep.rgdxaColWidthSpacing;
    5925             :                                                      //complex; 3 bytes;
    5926             :         {0xF204, 0},                                 //"sprmSDxaColSpacing"
    5927             :                                                      //sep.rgdxaColWidthSpacing;
    5928             :                                                      //complex; 3 bytes;
    5929             :         {0x3005, 0},                                 //"sprmSFEvenlySpaced"
    5930             :                                                      //sep.fEvenlySpaced; 1 or 0;
    5931             :                                                      //byte;
    5932             :         {0x3006, 0},                                 //"sprmSFProtected"
    5933             :                                                      //sep.fUnlocked;1 or 0;byte;
    5934             :         {0x5007, 0},                                 //"sprmSDmBinFirst"
    5935             :                                                      //sep.dmBinFirst;;word;
    5936             :         {0x5008, 0},                                 //"sprmSDmBinOther"
    5937             :                                                      //sep.dmBinOther;;word;
    5938             :         {0x3009, 0},                                 //"sprmSBkc" sep.bkc;bkc;byte;
    5939             :         {0x300A, 0},                                 //"sprmSFTitlePage"
    5940             :                                                      //sep.fTitlePage;0 or 1;byte;
    5941             :         {0x500B, 0},                                 //"sprmSCcolumns" sep.ccolM1;
    5942             :                                                      //# of cols - 1;word;
    5943             :         {0x900C, 0},                                 //"sprmSDxaColumns"
    5944             :                                                      //sep.dxaColumns;dxa;word;
    5945             :         {0x300D, 0},                                 //"sprmSFAutoPgn" sep.fAutoPgn;
    5946             :                                                      //obsolete;byte;
    5947             :         {0x300E, 0},                                 //"sprmSNfcPgn" sep.nfcPgn;nfc;
    5948             :                                                      //byte;
    5949             :         {0xB00F, 0},                                 //"sprmSDyaPgn" sep.dyaPgn;dya;
    5950             :                                                      //short;
    5951             :         {0xB010, 0},                                 //"sprmSDxaPgn" sep.dxaPgn;dya;
    5952             :                                                      //short;
    5953             :         {0x3011, 0},                                 //"sprmSFPgnRestart"
    5954             :                                                      //sep.fPgnRestart;0 or 1;byte;
    5955             :         {0x3012, 0},                                 //"sprmSFEndnote" sep.fEndnote;
    5956             :                                                      //0 or 1;byte;
    5957             :         {0x3013, 0},                                 //"sprmSLnc" sep.lnc;lnc;byte;
    5958             :         {0x3014, 0},                                 //"sprmSGprfIhdt" sep.grpfIhdt;
    5959             :                                                      //grpfihdt; byte;
    5960             :         {0x5015, 0},                                 //"sprmSNLnnMod" sep.nLnnMod;
    5961             :                                                      //non-neg int.;word;
    5962             :         {0x9016, 0},                                 //"sprmSDxaLnn" sep.dxaLnn;dxa;
    5963             :                                                      //word;
    5964             :         {0xB017, 0},                                 //"sprmSDyaHdrTop"
    5965             :                                                      //sep.dyaHdrTop;dya;word;
    5966             :         {0xB018, 0},                                 //"sprmSDyaHdrBottom"
    5967             :                                                      //sep.dyaHdrBottom;dya;word;
    5968             :         {0x3019, 0},                                 //"sprmSLBetween"
    5969             :                                                      //sep.fLBetween;0 or 1;byte;
    5970             :         {0x301A, 0},                                 //"sprmSVjc" sep.vjc;vjc;byte;
    5971             :         {0x501B, 0},                                 //"sprmSLnnMin" sep.lnnMin;lnn;
    5972             :                                                      //word;
    5973             :         {0x501C, 0},                                 //"sprmSPgnStart" sep.pgnStart;
    5974             :                                                      //pgn;word;
    5975             :         {0x301D, 0},                                 //"sprmSBOrientation"
    5976             :                                                      //sep.dmOrientPage;dm;byte;
    5977             :       //0x301E, ? ? ?,                               //"sprmSBCustomize"
    5978             :         {0xB01F, 0},                                 //"sprmSXaPage" sep.xaPage;xa;
    5979             :                                                      //word;
    5980             :         {0xB020, 0},                                 //"sprmSYaPage" sep.yaPage;ya;
    5981             :                                                      //word;
    5982             :         {0x2205, 0},                                 //"sprmSDxaLeft" sep.dxaLeft;
    5983             :                                                      //dxa;word;
    5984             :         {0xB022, 0},                                 //"sprmSDxaRight" sep.dxaRight;
    5985             :                                                      //dxa;word;
    5986             :         {0x9023, 0},                                 //"sprmSDyaTop" sep.dyaTop;dya;
    5987             :                                                      //word;
    5988             :         {0x9024, 0},                                 //"sprmSDyaBottom"
    5989             :                                                      //sep.dyaBottom;dya;word;
    5990             :         {0xB025, 0},                                 //"sprmSDzaGutter"
    5991             :                                                      //sep.dzaGutter;dza;word;
    5992             :         {0x5026, 0},                                 //"sprmSDmPaperReq"
    5993             :                                                      //sep.dmPaperReq;dm;word;
    5994             :         {0xD227, 0},                                 //"sprmSPropRMark"
    5995             :                                                      //sep.fPropRMark,
    5996             :                                                      //sep.ibstPropRMark,
    5997             :                                                      //sep.dttmPropRMark ;complex;
    5998             :                                                      //variable length always
    5999             :                                                      //recorded as 7 bytes;
    6000             :       //0x3228, ? ? ?,                               //"sprmSFBiDi",
    6001             :       //0x3229, ? ? ?,                               //"sprmSFFacingCol"
    6002             :         {0x322A, 0},                                 //"sprmSFRTLGutter", set to 1
    6003             :                                                      //if gutter is on the right.
    6004             :         {0x702B, 0},                                 //"sprmSBrcTop80" sep.brcTop;BRC;
    6005             :                                                      //long;
    6006             :         {0x702C, 0},                                 //"sprmSBrcLeft80" sep.brcLeft;
    6007             :                                                      //BRC;long;
    6008             :         {0x702D, 0},                                 //"sprmSBrcBottom80"
    6009             :                                                      //sep.brcBottom;BRC;long;
    6010             :         {0x702E, 0},                                 //"sprmSBrcRight80" sep.brcRight;
    6011             :                                                      //BRC;long;
    6012             :         {0x522F, 0},                                 //"sprmSPgbProp" sep.pgbProp;
    6013             :                                                      //word;
    6014             :         {0x7030, 0},                                 //"sprmSDxtCharSpace"
    6015             :                                                      //sep.dxtCharSpace;dxt;long;
    6016             :         {0x9031, 0},                                 //"sprmSDyaLinePitch"
    6017             :                                                      //sep.dyaLinePitch;dya;
    6018             :                                                      //WRONG:long; RIGHT:short; !
    6019             :       //0x5032, ? ? ?,                               //"sprmSClm"
    6020             :         {0x5033, 0},                                 //"sprmSTextFlow"
    6021             :                                                      //sep.wTextFlow;complex ;short
    6022             :         {0x5400, 0},                                 //"sprmTJc90" tap.jc;jc;word (low
    6023             :                                                      //order byte is significant);
    6024             :         {0x9601, 0},                                 //"sprmTDxaLeft"
    6025             :                                                      //tap.rgdxaCenter; dxa; word;
    6026             :         {0x9602, 0},                                 //"sprmTDxaGapHalf"
    6027             :                                                      //tap.dxaGapHalf,
    6028             :                                                      //tap.rgdxaCenter; dxa; word;
    6029             :         {0x3403, 0},                                 //"sprmTFCantSplit"
    6030             :                                                      //tap.fCantSplit;1 or 0;byte;
    6031             :         {0x3404, 0},                                 //"sprmTTableHeader"
    6032             :                                                      //tap.fTableHeader;1 or 0;byte;
    6033             :         {0x3466, 0},                                 //"sprmTFCantSplit90"
    6034             :                                                      //tap.fCantSplit90;1 or 0;byte;
    6035             :         {0xD605, 0},                                 //"sprmTTableBorders80"
    6036             :                                                      //tap.rgbrcTable;complex;
    6037             :                                                      //24 bytes;
    6038             :         {0xD606, 0},                                 //"sprmTDefTable10"
    6039             :                                                      //tap.rgdxaCenter,
    6040             :                                                      //tap.rgtc;complex; variable
    6041             :                                                      //length;
    6042             :         {0x9407, 0},                                 //"sprmTDyaRowHeight"
    6043             :                                                      //tap.dyaRowHeight;dya;word;
    6044             :         {0xD608, 0},                                 //"sprmTDefTable"
    6045             :                                                      //tap.rgtc;complex
    6046             :         {0xD609, 0},                                 //"sprmTDefTableShd80"
    6047             :                                                      //tap.rgshd;complex
    6048             :         {0x740A, 0},                                 //"sprmTTlp" tap.tlp;TLP;
    6049             :                                                      //4 bytes;
    6050             :       //0x560B, ? ? ?,                               //"sprmTFBiDi"
    6051             :       //0x740C, ? ? ?,                               //"sprmTHTMLProps"
    6052             :         {0xD620, 0},                                 //"sprmTSetBrc80"
    6053             :                                                      //tap.rgtc[].rgbrc;complex;
    6054             :                                                      //5 bytes;
    6055             :         {0x7621, 0},                                 //"sprmTInsert"
    6056             :                                                      //tap.rgdxaCenter,
    6057             :                                                      //tap.rgtc;complex ;4 bytes;
    6058             :         {0x5622, 0},                                 //"sprmTDelete"
    6059             :                                                      //tap.rgdxaCenter,
    6060             :                                                      //tap.rgtc;complex ;word;
    6061             :         {0x7623, 0},                                 //"sprmTDxaCol"
    6062             :                                                      //tap.rgdxaCenter;complex;
    6063             :                                                      //4 bytes;
    6064             :         {0x5624, 0},                                 //"sprmTMerge"
    6065             :                                                      //tap.fFirstMerged,
    6066             :                                                      //tap.fMerged;complex; word;
    6067             :         {0x5625, 0},                                 //"sprmTSplit"
    6068             :                                                      //tap.fFirstMerged,
    6069             :                                                      //tap.fMerged;complex ;word;
    6070             :         {0xD626, 0},                                 //"sprmTSetBrc10"
    6071             :                                                      //tap.rgtc[].rgbrc;complex;
    6072             :                                                      //5 bytes;
    6073             :         {0x7627, 0},                                 //"sprmTSetShd80" tap.rgshd;
    6074             :                                                      //complex; 4 bytes;
    6075             :         {0x7628, 0},                                 //"sprmTSetShdOdd80"
    6076             :                                                      //tap.rgshd;complex;4 bytes;
    6077             :         {0x7629, 0},                                 //"sprmTTextFlow"
    6078             :                                                      //tap.rgtc[].fVertical
    6079             :                                                      //tap.rgtc[].fBackward
    6080             :                                                      //tap.rgtc[].fRotateFont
    6081             :                                                      //0 or 10 or 10 or 1;word;
    6082             :       //0xD62A, ? ? ?  ,                             //"sprmTDiagLine"
    6083             :         {0xD62B, 0},                                 //"sprmTVertMerge"
    6084             :                                                      //tap.rgtc[].vertMerge;complex;
    6085             :                                                      //variable length always
    6086             :                                                      //recorded as 2 bytes;
    6087             :         {0xD62C, 0},                                 //"sprmTVertAlign"
    6088             :                                                      //tap.rgtc[].vertAlign;complex
    6089             :                                                      //variable length always
    6090             :                                                      //recorded as 3 byte;
    6091             :         {NS_sprm::LN_CFELayout, &SwWW8ImplReader::Read_DoubleLine_Rotate},
    6092             :         {0x6649, 0},                                 //undocumented
    6093             :         {0xF614, 0},                                 //"sprmTTableWidth"
    6094             :                                                      //recorded as 3 bytes;
    6095             :         {0xD612, 0},                                 //"sprmTCellShd"
    6096             :         {0xD613, 0},                                 //"sprmTTableBorders"
    6097             :         {0xD61A, 0},                                 //undocumented
    6098             :         {0xD61B, 0},                                 //undocumented
    6099             :         {0xD61C, 0},                                 //undocumented
    6100             :         {0xD61D, 0},                                 //undocumented
    6101             :         {0xD634, 0},                                 //undocumented
    6102             :         {0xD632, 0},                                 //undocumented
    6103             :         {0xD238, 0},                                 //undocumented sep
    6104             :         {0xC64E, &SwWW8ImplReader::Read_Border},     //"sprmPBrcTop"
    6105             :         {0xC64F, &SwWW8ImplReader::Read_Border},     //"sprmPBrcLeft"
    6106             :         {0xC650, &SwWW8ImplReader::Read_Border},     //"sprmPBrcBottom"
    6107             :         {0xC651, &SwWW8ImplReader::Read_Border},     //"sprmPBrcRight"
    6108             :         {0xC652, &SwWW8ImplReader::Read_Border},     //"sprmPBorderBetween"
    6109             :         {0xF661, 0},                                 //undocumented
    6110             :         {0x4873, &SwWW8ImplReader::Read_Language},   //"sprmCRgLid0" chp.rglid[0];
    6111             :                                                      //LID: for non-Far East text;
    6112             :                                                      //(like a duplicate of 486D)
    6113             :         {0x4874, 0},                                 //"sprmCRgLid1" chp.rglid[1];
    6114             :                                                      //LID: for Far East text
    6115             :                                                      //(like a duplicate of 486E)
    6116             :         {0x6463, 0},                                 //undocumented
    6117             :         {0x2461, &SwWW8ImplReader::Read_RTLJustify}, //undoc, must be asian version
    6118             :                                                      //of "sprmPJc"
    6119             :         {0x845E, &SwWW8ImplReader::Read_LR},         //Apparently post-Word 97 version of "sprmPDxaLeft"
    6120             :         {0x8460, &SwWW8ImplReader::Read_LR},         //Post-Word 97 version of "sprmPDxaLeft1"
    6121             :         {0x845D, &SwWW8ImplReader::Read_LR},         //Post-Word 97 version of "sprmPDxaRight"
    6122             :         {0x3615, 0},                                 //undocumented
    6123             :         {0x360D, 0},                                 //undocumented
    6124             :         {0x940E, 0},                                 //undocumented
    6125             :         {0x940F, 0},                                 //undocumented
    6126             :         {0x9410, 0},                                 //undocumented
    6127             :         {0x703A, 0},                                 //undocumented
    6128             :         {0x303B, 0},                                 //undocumented
    6129             :         {0x244B, &SwWW8ImplReader::Read_TabCellEnd}, //undocumented, must be
    6130             :                                                      //subtable "sprmPFInTable"
    6131             :         {0x244C, &SwWW8ImplReader::Read_TabRowEnd},  //undocumented, must be
    6132             :                                                      // subtable "sprmPFTtp"
    6133             :         {0x6815, 0},                                 //undocumented
    6134             :         {0x6816, 0},                                 //undocumented
    6135             :         {NS_sprm::LN_CCv, &SwWW8ImplReader::Read_TxtForeColor},
    6136             :         {0x6877, &SwWW8ImplReader::Read_UnderlineColor},
    6137             :         {0xC64D, &SwWW8ImplReader::Read_ParaBackColor},
    6138             :         {0x6467, 0},                                 //undocumented
    6139             :         {0xF617, 0},                                 //undocumented
    6140             :         {0xD660, 0},                                 //undocumented
    6141             :         {0xD670, 0},                                 //undocumented
    6142             :         {0xCA71, &SwWW8ImplReader::Read_TxtBackColor},//"sprmCShd"
    6143             :         {0x303C, 0},                                 //undocumented
    6144             :         {0x245B, &SwWW8ImplReader::Read_ParaAutoBefore},//undocumented, para
    6145             :         {0x245C, &SwWW8ImplReader::Read_ParaAutoAfter},//undocumented, para
    6146             :         {0x246D, &SwWW8ImplReader::Read_ParaContextualSpacing} //"sprmPFContextualSpacing"
    6147             :     };
    6148             : 
    6149      180020 :     static wwSprmDispatcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0]));
    6150      180020 :     return &aSprmSrch;
    6151             : }
    6152             : 
    6153             : //      Hilfsroutinen : SPRM finden
    6154             : 
    6155      184340 : const SprmReadInfo& SwWW8ImplReader::GetSprmReadInfo(sal_uInt16 nId) const
    6156             : {
    6157      184340 :     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
    6158             :     const wwSprmDispatcher *pDispatcher;
    6159      184340 :     if (eVersion <= ww::eWW2)
    6160        4320 :         pDispatcher = GetWW2SprmDispatcher();
    6161      180020 :     else if (eVersion < ww::eWW8)
    6162           0 :         pDispatcher = GetWW6SprmDispatcher();
    6163             :     else
    6164      180020 :         pDispatcher = GetWW8SprmDispatcher();
    6165             : 
    6166      184340 :     SprmReadInfo aSrch = {0, 0};
    6167      184340 :     aSrch.nId = nId;
    6168      184340 :     const SprmReadInfo* pFound = pDispatcher->search(aSrch);
    6169             : 
    6170      184340 :     if (!pFound)
    6171             :     {
    6172       10888 :         aSrch.nId = 0;
    6173       10888 :         pFound = pDispatcher->search(aSrch);
    6174             :     }
    6175             : 
    6176      184340 :     return *pFound;
    6177             : }
    6178             : 
    6179             : //      Hilfsroutinen : SPRMs
    6180             : 
    6181       80678 : void SwWW8ImplReader::EndSprm( sal_uInt16 nId )
    6182             : {
    6183      161356 :     if( ( nId > 255 ) && ( nId < 0x0800 ) ) return;
    6184             : 
    6185       80678 :     const SprmReadInfo& rSprm = GetSprmReadInfo( nId );
    6186             : 
    6187       80678 :     if (rSprm.pReadFnc)
    6188       44712 :         (this->*rSprm.pReadFnc)( nId, 0, -1 );
    6189             : }
    6190             : 
    6191      103662 : short SwWW8ImplReader::ImportSprm(const sal_uInt8* pPos,sal_uInt16 nId)
    6192             : {
    6193      103662 :     if (!nId)
    6194       21308 :         nId = mpSprmParser->GetSprmId(pPos);
    6195             : 
    6196             :     OSL_ENSURE( nId != 0xff, "Sprm FF !!!!" );
    6197             : 
    6198      103662 :     const SprmReadInfo& rSprm = GetSprmReadInfo(nId);
    6199             : 
    6200      103662 :     sal_uInt16 nFixedLen = mpSprmParser->DistanceToData(nId);
    6201      103662 :     sal_uInt16 nL = mpSprmParser->GetSprmSize(nId, pPos);
    6202             : 
    6203      103662 :     if (rSprm.pReadFnc)
    6204       65678 :         (this->*rSprm.pReadFnc)(nId, pPos + nFixedLen, nL - nFixedLen);
    6205             : 
    6206      103662 :     return nL;
    6207         102 : }
    6208             : 
    6209             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10