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

Generated by: LCOV version 1.10