LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - ww8par6.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1846 2286 80.8 %
Date: 2015-06-13 12:38:46 Functions: 140 144 97.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11