LCOV - code coverage report
Current view: top level - sw/source/filter/ww1 - w1sprm.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 305 0.0 %
Date: 2014-04-11 Functions: 0 42 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : #include <tools/solar.h>
      22             : #include <editeng/paperinf.hxx>
      23             : #include <editeng/lrspitem.hxx>
      24             : #include <editeng/adjustitem.hxx>
      25             : #include <editeng/spltitem.hxx>
      26             : #include <editeng/keepitem.hxx>
      27             : #include <editeng/boxitem.hxx>
      28             : #include <editeng/shaditem.hxx>
      29             : #include <editeng/ulspitem.hxx>
      30             : #include <editeng/lspcitem.hxx>
      31             : #include <editeng/tstpitem.hxx>
      32             : #include <fmtclds.hxx>
      33             : #include <fmtfsize.hxx>
      34             : #include <pam.hxx>
      35             : #include <ndtxt.hxx>
      36             : #include <charatr.hxx>
      37             : #include <frmatr.hxx>
      38             : #include <doc.hxx>
      39             : #include <fltini.hxx>
      40             : #include <docufld.hxx>
      41             : #include <pagedesc.hxx>
      42             : #include <flddat.hxx>
      43             : #include <reffld.hxx>
      44             : #include <expfld.hxx>
      45             : #include <w1par.hxx>
      46             : #include <mdiexp.hxx>
      47             : #include <swerror.h>
      48             : #include <statstr.hrc>
      49             : 
      50             : using ::editeng::SvxBorderLine;
      51             : using namespace ::com::sun::star;
      52             : 
      53           0 : void Ww1Sprm::Stop( Ww1Shell& rOut, Ww1Manager& rMan)
      54             : {
      55           0 :     if(IsUsed())
      56           0 :         for(short i=Count()-1;i>=0;i--){    // backwards
      57             :             sal_uInt8 nId;
      58             :             sal_uInt16 nSize;
      59             :             sal_uInt8* pSprm;
      60           0 :             Fill(i, nId, nSize, pSprm);
      61           0 :             GetTab(nId).Stop(rOut, nId, pSprm, nSize, rMan);
      62             :         }
      63           0 : }
      64             : 
      65           0 : void Ww1Sprm::Start(
      66             :     Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 i)
      67             : {
      68             :     sal_uInt8 nId;
      69             :     sal_uInt16 nSize;
      70             :     sal_uInt8* pSprm;
      71           0 :     Fill(i, nId, nSize, pSprm);
      72           0 :     GetTab(nId).Start(rOut, nId, pSprm, nSize, rMan);
      73           0 : }
      74             : 
      75           0 : void Ww1Sprm::Start(
      76             :     Ww1Shell& rOut, Ww1Manager& rMan)
      77             : {
      78           0 :     if(IsUsed())
      79           0 :         for(sal_uInt16 i=0;i<Count();i++)
      80           0 :             Start(rOut, rMan, i);
      81           0 : }
      82             : 
      83           0 : void Ww1SingleSprm::Start(
      84             :     Ww1Shell&, sal_uInt8 /*nId*/, sal_uInt8*, sal_uInt16, Ww1Manager&)
      85             : {
      86           0 : }
      87             : 
      88           0 : void Ww1SingleSprm::Stop(
      89             :     Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&)
      90             : {
      91             : // OSL_ENSURE(FALSE, "Unknown Sprm");
      92           0 : }
      93             : 
      94             : // STOP
      95             : // The following defines are used for implementing the SingleSprm
      96             : // classes' Stop() members, because they normally merely put
      97             : // EndItem(s) into the shell.
      98             : #define STOP1(Class, Code) \
      99             :     void Class::Stop( \
     100             :      Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) { \
     101             :         rOut.EndItem(Code); }
     102             : #define STOP2(Class, Code1, Code2) \
     103             :     void Class::Stop( \
     104             :      Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) { \
     105             :         rOut.EndItem(Code1).EndItem(Code2); }
     106             : 
     107             : // SingleSprmXxxxx
     108             : // This starts the evaluation of the actual sprms. Each sprmtyp has
     109             : // its own class implementing the virtual methods start and stop. The
     110             : // classes are referenced from the sprm table, a static member of
     111             : // Ww1Sprm. When an sprm is encountered in the document, the virtual
     112             : // methods will be called at the formatting boundaries.
     113           0 : void Ww1SingleSprmPDxaLeft::Start(
     114             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     115             : {
     116           0 :     SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
     117           0 :     short nPara = SVBT16ToShort(pSprm);
     118           0 :     if(nPara < 0)
     119           0 :         nPara = 0;
     120           0 :     if(aLR.GetTxtFirstLineOfst() < -nPara)
     121           0 :         aLR.SetTxtFirstLineOfst(-nPara); // otherwise SetTxtLeft() refuses to work
     122           0 :     aLR.SetTxtLeft(nPara);
     123           0 :     rOut << aLR;
     124           0 : }
     125             : 
     126           0 : void Ww1SingleSprmPDxaRight::Start(
     127             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     128             : {
     129           0 :     SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
     130           0 :     short nPara = SVBT16ToShort(pSprm);
     131           0 :     if(nPara < 0)
     132           0 :         nPara = 0;
     133           0 :     aLR.SetRight(nPara);
     134           0 :     rOut << aLR;
     135           0 : }
     136             : 
     137           0 : void Ww1SingleSprmPDxaLeft1::Start(
     138             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     139             : {
     140           0 :     SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
     141           0 :     short nPara = SVBT16ToShort(pSprm);
     142           0 :     if(-nPara >(short)aLR.GetTxtLeft())
     143           0 :         nPara = -(short)aLR.GetTxtLeft();
     144           0 :     aLR.SetTxtFirstLineOfst(nPara);
     145           0 :     rOut << aLR;
     146           0 : }
     147             : 
     148           0 : STOP1(Ww1SingleSprmPDxa, RES_LR_SPACE)
     149             : 
     150           0 : void Ww1SingleSprmPJc::Start(
     151             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     152             : {
     153             :     static SvxAdjust const aAdj[] = {
     154             :         SVX_ADJUST_LEFT,
     155             :         SVX_ADJUST_CENTER,
     156             :         SVX_ADJUST_RIGHT,
     157             :         SVX_ADJUST_BLOCK };
     158           0 :     sal_uInt8 nPara = *pSprm;
     159           0 :     nPara %=SAL_N_ELEMENTS(aAdj);
     160           0 :     rOut << SvxAdjustItem(aAdj[nPara], RES_PARATR_ADJUST);
     161           0 : }
     162             : 
     163           0 : STOP1(Ww1SingleSprmPJc, RES_PARATR_ADJUST)
     164             : 
     165           0 : void Ww1SingleSprmPFKeep::Start(
     166             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     167             : {
     168           0 :     rOut << SvxFmtSplitItem((*pSprm & 1) == 0, RES_PARATR_SPLIT);
     169           0 : }
     170             : 
     171           0 : STOP1(Ww1SingleSprmPFKeep, RES_PARATR_SPLIT)
     172             : 
     173           0 : void Ww1SingleSprmPFKeepFollow::Start(
     174             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     175             : {
     176           0 :     rOut << SvxFmtKeepItem((*pSprm & 1) != 0, RES_KEEP);
     177           0 : }
     178             : 
     179           0 : STOP1(Ww1SingleSprmPFKeepFollow, RES_KEEP)
     180             : 
     181           0 : void Ww1SingleSprmPPageBreakBefore::Start(
     182             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
     183             : {
     184           0 :     rOut << SvxFmtBreakItem(*pSprm & 1?
     185           0 :      SVX_BREAK_PAGE_BEFORE:SVX_BREAK_NONE, RES_BREAK );
     186           0 : }
     187             : 
     188           0 : STOP1(Ww1SingleSprmPPageBreakBefore, RES_BREAK)
     189             : 
     190           0 : SvxBorderLine* Ww1SingleSprmPBrc::SetBorder(SvxBorderLine* pLine, W1_BRC10* pBrc)
     191             : {
     192             :     sal_uInt16 nCode;
     193           0 :     ::editeng::SvxBorderStyle eStyle = table::BorderLineStyle::SOLID;
     194           0 :     if(pBrc->dxpLine2WidthGet() == 0)
     195             :     {
     196           0 :         switch(pBrc->dxpLine1WidthGet())
     197             :         {
     198             :         default: OSL_FAIL("unknown linewidth");
     199           0 :         case 0: return 0;                           // no line
     200           0 :         case 1: nCode = DEF_LINE_WIDTH_0; break;
     201           0 :         case 2: nCode = DEF_LINE_WIDTH_1; break;
     202           0 :         case 3: nCode = DEF_LINE_WIDTH_2; break;
     203           0 :         case 4: nCode = DEF_LINE_WIDTH_3; break;
     204           0 :         case 5: nCode = DEF_LINE_WIDTH_4; break;
     205             :         case 6:
     206           0 :                 nCode = DEF_LINE_WIDTH_5;
     207           0 :                 eStyle = table::BorderLineStyle::DOTTED;
     208           0 :                 break;
     209             :         case 7:
     210           0 :                 nCode = DEF_LINE_WIDTH_5;
     211           0 :                 eStyle = table::BorderLineStyle::DASHED;
     212           0 :                 break;
     213             :         }
     214           0 :         pLine->SetWidth( nCode );
     215           0 :         pLine->SetBorderLineStyle( eStyle );
     216             :     }
     217             :     else
     218             :     {
     219           0 :         if ( pBrc->dxpLine1WidthGet() == 1 && pBrc->dxpLine2WidthGet() == 1 )
     220             :         {
     221           0 :             pLine->SetBorderLineStyle( table::BorderLineStyle::DOUBLE );
     222           0 :             pLine->SetWidth( DEF_LINE_WIDTH_0 );
     223             :         }
     224             :         else
     225             :             OSL_ENSURE(false, "unknown linewidth");
     226             :     }
     227           0 :     return pLine;
     228             : }
     229             : 
     230           0 : void Ww1SingleSprmPBrc::Start(
     231             :     Ww1Shell& rOut, sal_uInt8,
     232             :     W1_BRC10* pBrc,
     233             :     sal_uInt16
     234             : #if OSL_DEBUG_LEVEL > 0
     235             :     nSize
     236             : #endif
     237             :     ,
     238             :     Ww1Manager& /*rMan*/,
     239             :     SvxBoxItem& aBox)
     240             : {
     241             : #if OSL_DEBUG_LEVEL > 0
     242             :     OSL_ENSURE(sizeof(W1_BRC10) == nSize, "sizemissmatch");
     243             : #endif
     244           0 :     if(pBrc->dxpSpaceGet())
     245           0 :         aBox.SetDistance(10 + 20 * pBrc->dxpSpaceGet());
     246             :             //??? Why 10+... ????
     247             : 
     248           0 :     if( rOut.IsInFly() )
     249           0 :         rOut.SetFlyFrmAttr( aBox );
     250             :     else
     251           0 :         rOut << aBox;
     252             : 
     253           0 :     if(pBrc->fShadowGet())
     254             :     {
     255           0 :         Color aBlack(COL_BLACK); // black...
     256             :         SvxShadowItem aS(RES_SHADOW,(const Color*)&aBlack, 32,
     257           0 :                          SVX_SHADOW_BOTTOMRIGHT); // 1.6 tw wide
     258           0 :         if( rOut.IsInFly() )
     259           0 :             rOut.SetFlyFrmAttr( aS );
     260             :         else
     261           0 :             rOut << aS;
     262             :     }
     263           0 : }
     264             : 
     265           0 : STOP2(Ww1SingleSprmPBrc, RES_BOX, RES_SHADOW)
     266             : 
     267             : static sal_uInt16 nBrcTrans[BRC_ANZ] =
     268             :      { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
     269             : 
     270           0 : void Ww1SingleSprmPBrc10::Start(
     271             :     Ww1Shell& rOut, sal_uInt8 nId, sal_uInt8* pSprm, sal_uInt16 nSize, Ww1Manager& rMan)
     272             : {
     273             : 
     274           0 :     W1_BRC10* pBrc =(W1_BRC10*)pSprm;
     275           0 :     const SfxPoolItem &rItem = ( ( rOut.IsInFly() ) ?
     276           0 :                      rOut.GetFlyFrmAttr(RES_BOX) :rOut.GetAttr(RES_BOX));
     277           0 :     const SvxBoxItem &rBoxItem = (const SvxBoxItem&)rItem;
     278           0 :     SvxBoxItem aBox( rBoxItem );
     279           0 :     SvxBorderLine aLine;
     280           0 :     aBox.SetLine(SetBorder(&aLine, pBrc), nBrcTrans[nLine] );
     281           0 :     Ww1SingleSprmPBrc::Start(rOut, nId, pBrc, nSize, rMan, aBox);
     282           0 : }
     283             : 
     284           0 : STOP1(Ww1SingleSprmParaSpace, RES_UL_SPACE)
     285             : 
     286           0 : void Ww1SingleSprmPDyaBefore::Start(
     287             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     288             : {
     289           0 :     short nPara = SVBT16ToShort(pSprm);
     290           0 :     if(nPara < 0)
     291           0 :         nPara = -nPara;
     292           0 :     SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE));
     293           0 :     aUL.SetUpper(nPara);
     294           0 :     rOut << aUL;
     295           0 : }
     296             : 
     297           0 : void Ww1SingleSprmPDyaAfter::Start(
     298             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     299             : {
     300           0 :     short nPara = SVBT16ToShort(pSprm);
     301           0 :     if(nPara < 0)
     302           0 :         nPara = -nPara;
     303           0 :     SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE));
     304           0 :     aUL.SetLower(nPara);
     305           0 :     rOut << aUL;
     306           0 : }
     307             : 
     308           0 : STOP1(Ww1SingleSprmPDyaLine, RES_PARATR_LINESPACING)
     309             : 
     310           0 : void Ww1SingleSprmPDyaLine::Start(
     311             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     312             : {
     313           0 :     short nSpace = SVBT16ToShort(pSprm);
     314           0 :     if(nSpace < 0)
     315           0 :         nSpace = -nSpace;
     316           0 :     SvxLineSpacingItem aLSpc( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING );
     317             :     {// MultilineSpace(proportional)
     318           0 :         long n = nSpace * 100 / 240;    // W1: 240 = 100%, SW: 100 = 100%
     319           0 :         if(n>200)
     320           0 :             n = 200; // SW_UI-Maximum
     321           0 :         aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     322           0 :         aLSpc.SetPropLineSpace((sal_uInt8)n);
     323             :     }
     324           0 :     rOut << aLSpc;
     325           0 : }
     326             : 
     327           0 : void Ww1SingleSprmPChgTabsPapx::Start(
     328             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     329             : {
     330             : 
     331           0 :     short nLeftPMgn = 0;    // Coordinates approximately equal ??
     332             : 
     333             :     short i;
     334           0 :     sal_uInt8 nDel = pSprm[1];
     335           0 :     sal_uInt8* pDel = pSprm + 2;                        // Del - Array
     336           0 :     sal_uInt8 nIns = pSprm[nDel*2+2];
     337           0 :     sal_uInt8* pIns = pSprm + 2*nDel + 3;           // Ins - Array
     338           0 :     W1_TBD* pTyp = (W1_TBD*)(pSprm + 2*nDel + 2*nIns + 3);// Typ - Array
     339             : 
     340           0 :     SvxTabStopItem aAttr( (SvxTabStopItem&)rOut.GetNodeOrStyAttr( RES_PARATR_TABSTOP ));
     341             : 
     342           0 :     SvxTabStop aTabStop;
     343             : 
     344           0 :     for( i=0; i<nDel; i++ ){
     345           0 :         sal_uInt16 nPos = aAttr.GetPos( SVBT16ToShort( pDel + i*2 ) - nLeftPMgn );
     346           0 :         if( nPos != SVX_TAB_NOTFOUND )
     347           0 :             aAttr.Remove( nPos, 1 );
     348             :     }
     349             : 
     350           0 :     for( i=0; i<nIns; i++ ){
     351           0 :         short nPos = SVBT16ToShort( pIns + i*2 ) - nLeftPMgn;
     352           0 :         if( nPos < 0 )
     353           0 :             continue;
     354           0 :         aTabStop.GetTabPos() = nPos;
     355           0 :         switch( pTyp[i].jcGet() ){
     356           0 :         case 0: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break;
     357           0 :         case 1: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; break;
     358           0 :         case 2: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; break;
     359           0 :         case 3: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL; break;
     360           0 :         case 4: continue;                   // ignore Bar
     361             :         }
     362             : 
     363           0 :         switch( pTyp[i].tlcGet() ){
     364           0 :         case 0: aTabStop.GetFill() = ' '; break;
     365           0 :         case 1: aTabStop.GetFill() = '.'; break;
     366           0 :         case 2: aTabStop.GetFill() = '-'; break;
     367             :         case 3:
     368           0 :         case 4: aTabStop.GetFill() = '_'; break;
     369             :         }
     370             : 
     371           0 :         sal_uInt16 nPos2 = aAttr.GetPos( nPos );
     372           0 :         if( nPos2 != SVX_TAB_NOTFOUND )
     373           0 :             aAttr.Remove( nPos2, 1 );       // otherwise Insert() refuses to work
     374             : 
     375           0 :         aAttr.Insert( aTabStop );
     376             :     }
     377           0 :     rOut << aAttr;
     378           0 : }
     379             : 
     380           0 : STOP1(Ww1SingleSprmPChgTabsPapx, RES_PARATR_TABSTOP)
     381             : 
     382           0 : void Ww1SingleSprmSGprfIhdt::Start(
     383             :     Ww1Shell& /*rOut*/, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan)
     384             : {
     385           0 :     rMan.GetSep().SetGrpfIhdt(*pSprm);
     386           0 : }
     387             : 
     388           0 : void Ww1SingleSprmSColumns::Start(
     389             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     390             : {
     391           0 :     short nColSpace = 708; // default 1,25 cm
     392           0 :     short nNettoWidth = -1; //~ mdt: dxaLeft/Right missing...
     393           0 :     short nCols = SVBT16ToShort(pSprm);
     394           0 :     nCols++;
     395           0 :     if (nCols < 2)
     396           0 :         return;
     397           0 :     SwFmtCol aCol;
     398           0 :     aCol.Init(nCols, nColSpace, nNettoWidth);
     399           0 :     rOut.GetPageDesc().GetMaster().SetFmtAttr(aCol);
     400             : }
     401             : 
     402           0 : void Ww1SingleSprmPTtp::Start(
     403             :     Ww1Shell& /*rOut*/, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager& rMan)
     404             : {
     405           0 :     rMan.SetInTtp( true );      // Special case: will be reset at
     406             :                                 // InTable::Stop instead of InTtp::Stop,
     407             :                                 // because evaluation happens in InTable
     408           0 : }
     409             : 
     410           0 : void Ww1SingleSprmPTtp::Stop(
     411             :     Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager& rMan)
     412             : {
     413           0 :     if (rOut.IsInTable() && rMan.HasInTable())
     414           0 :         rOut.NextTableRow();
     415           0 : }
     416             : 
     417           0 : void Ww1SingleSprmPFInTable::Start(
     418             :     Ww1Shell& /*rOut*/, sal_uInt8, sal_uInt8*, sal_uInt16,
     419             :     Ww1Manager& /*rMan*/)
     420             : {
     421           0 : }
     422             : 
     423           0 : void Ww1SingleSprmPFInTable::Stop(
     424             :     Ww1Shell&
     425             : #if OSL_DEBUG_LEVEL > 0
     426             :     rOut
     427             : #endif
     428             :     ,
     429             :     sal_uInt8, sal_uInt8*, sal_uInt16,
     430             :     Ww1Manager& /*rMan*/)
     431             : {
     432             : #if OSL_DEBUG_LEVEL > 0
     433             :     OSL_ENSURE(rOut.IsInTable(), "");
     434             : #endif
     435           0 : }
     436             : 
     437           0 : void Ww1SingleSprmTDxaGapHalf::Start(
     438             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     439             : {
     440           0 :     short nSpace = SVBT16ToShort(pSprm);
     441           0 :     rOut.SetCellSpace(nSpace);
     442           0 : }
     443             : 
     444           0 : void Ww1SingleSprmTDefTable10::Start(
     445             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 nSize, Ww1Manager& /*rMan*/)
     446             : {
     447             :     sal_uInt16 i;
     448           0 :     sal_uInt8 *p = pSprm + 2;   // skip length word
     449           0 :     sal_uInt8 nCount = *p;
     450           0 :     p++;
     451           0 :     nSize -= 3;
     452             : // Still missing:
     453             : // - GapHalf
     454             : // - potential thinning of cell borders
     455             : 
     456           0 :     if( nCount < 1 || nCount > 32 || nSize < ( nCount + 1 ) * 2  )
     457           0 :         return;
     458             : 
     459             : // Let's read the cell positions for starters
     460           0 :     short nPos = SVBT16ToShort( p );    // signed, can be negative !!!
     461             : 
     462             :     {
     463           0 :         short nWholeWidth = SVBT16ToShort( p + 2 * nCount ) - nPos;
     464           0 :         rOut.SetTableWidth( (sal_uInt16)nWholeWidth );  // set table width
     465             : 
     466             : // Set table position
     467           0 :         long nMidTab = nPos + nWholeWidth / 2;      // table center
     468           0 :         const SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
     469           0 :         const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
     470           0 :         long nRight = rFmt.GetFrmSize().GetWidth()
     471           0 :                       - rLR.GetLeft() - rLR.GetRight();
     472             : 
     473           0 :         sal_Int16 eOri = text::HoriOrientation::LEFT;
     474           0 :         if( nPos > MINLAY ){                        // positioned by twiddling
     475           0 :             if ( nMidTab <= nRight / 3 )            // 1/3rd of page
     476           0 :                 eOri = text::HoriOrientation::LEFT;
     477           0 :             else if ( nMidTab <= 2 * nRight / 3 )   // 2/3rd of page
     478           0 :                 eOri = text::HoriOrientation::CENTER;
     479             :             else
     480           0 :                 eOri = text::HoriOrientation::RIGHT;
     481             :         }
     482           0 :         rOut.SetTableOrient( eOri );
     483             :     }
     484             : 
     485           0 :     sal_uInt8* pEndPos = p+2;
     486           0 :     sal_uInt8* pTc0 = ( nSize >= nCount * 10 ) ? pEndPos + 2 * nCount : 0;
     487           0 :     sal_uInt16 nCellsDeleted = 0;       // for merged cells
     488             : 
     489           0 :     for( i = 0; i < nCount; i++ ){
     490             : // Collect info
     491           0 :         W1_TC* pTc = (W1_TC*)pTc0;
     492           0 :         sal_Bool bMerged = (pTc) ? pTc->fMergedGet() : sal_False;
     493             : 
     494             : // set cell widths
     495           0 :         sal_uInt16 nPos1 = SVBT16ToShort( pEndPos );
     496           0 :         if( !bMerged )
     497           0 :             rOut.SetCellWidth( nPos1 - nPos, i - nCellsDeleted );
     498             :                                         // set cell width
     499             :                                         // Interaction with GapHalf still missing
     500             :                                         // ( GapHalf is being ignored for now )
     501           0 :         pEndPos+=2;
     502           0 :         nPos = nPos1;
     503             : 
     504           0 :         if( pTc0 ){                     // are there actually TCs ?
     505           0 :             W1_TC* pTc2 = (W1_TC*)pTc0;
     506           0 :             sal_Bool bMerged2 = pTc2->fMergedGet();
     507           0 :             if( !bMerged2 ){
     508             : // and now the borders
     509           0 :                 SvxBoxItem aBox( (SvxBoxItem&)rOut.GetCellAttr( RES_BOX ));
     510           0 :                 SvxBorderLine aLine;
     511           0 :                 W1_BRC10* pBrc = pTc2->rgbrcGet();
     512           0 :                 for( sal_uInt16 j=0; j<4; j++ ){
     513           0 :                     aBox.SetLine(Ww1SingleSprmPBrc::SetBorder(&aLine, pBrc),
     514           0 :                                  nBrcTrans[j]);
     515           0 :                     pBrc++;
     516             :                 }
     517           0 :                 rOut.SetCellBorder( aBox, i - nCellsDeleted );
     518             :             }else{
     519             : // remove merged cells
     520           0 :                 rOut.DeleteCell( i - nCellsDeleted );
     521           0 :                 nCellsDeleted++;
     522             :             }
     523           0 :             pTc0+=sizeof(W1_TC);    // 10
     524             :         }
     525             :     }
     526             : }
     527             : 
     528           0 : void Ww1SingleSprmTDyaRowHeight::Start(
     529             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     530             : {
     531           0 :     short nSpace = SVBT16ToShort(pSprm);
     532           0 :     rOut.SetCellHeight(nSpace);
     533           0 : }
     534             : 
     535             : // I don't need Fastsave attributes as dummies
     536             : 
     537           0 : void Ww1SingleSprmPpc::Start(
     538             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan)
     539             : {
     540           0 :     sal_uInt8 nPpc = *pSprm;
     541             : 
     542           0 :     if (rOut.IsInTable())                       // PMW does not know Flys in tables
     543           0 :         return;
     544             : 
     545             :     RndStdIds eAnchor;          // binding
     546             : 
     547           0 :     switch ( ( nPpc & 0x30 ) >> 4 )     // Y binding determines Sw binding
     548             :     {
     549             :         case 0:
     550           0 :             eAnchor = FLY_AT_PARA;      // Vert Margin
     551           0 :             break;
     552             :         default:
     553           0 :             eAnchor = FLY_AT_PAGE;      // Vert Page or unknown
     554           0 :             break;                          // 2=Vert. Paragraph, 3=Use Default
     555             :     }
     556             : 
     557           0 :     if( !rOut.IsInFly() && rMan.IsInStyle() ){
     558           0 :         rOut.BeginFly( eAnchor );           // start StyleFly
     559             :     }else{
     560           0 :         rOut.SetFlyAnchor( eAnchor );       // set anchor
     561             :     }
     562             : }
     563             : 
     564           0 : void Ww1SingleSprmPDxaAbs::Start(
     565             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan)
     566             : {
     567           0 :     short nXPos = SVBT16ToShort(pSprm);
     568             : 
     569           0 :     if( rMan.IsInStyle() && !rOut.IsInFly() ){
     570           0 :         rOut.BeginFly();                    // Fly ohne PPc-Attribut
     571             :     }
     572             : 
     573           0 :     sal_Int16 eHRel = text::RelOrientation::FRAME;
     574           0 :     sal_Int16 eHAlign = text::HoriOrientation::NONE;
     575             : 
     576           0 :     switch( nXPos ){                        // Special x positions ?
     577             :     case 0:
     578           0 :     case -12: eHAlign = text::HoriOrientation::NONE; nXPos = 0; break;   // Cheat: inside -> left
     579             :                             // actually text::HoriOrientation::LEFT, but then
     580             :                             // an outer margin moves the Fly
     581           0 :     case -4:  eHAlign = text::HoriOrientation::CENTER; nXPos = 0; break;
     582             :     case -8:                                           // right
     583           0 :     case -16: eHAlign = text::HoriOrientation::RIGHT; nXPos = 0; break;  // Cheat: outside -> right
     584             : 
     585             :     }
     586           0 :     rOut.SetFlyXPos( nXPos, eHRel, eHAlign );
     587           0 : }
     588             : 
     589           0 : void Ww1SingleSprmPDyaAbs::Start(
     590             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     591             : {
     592           0 :     short nYPos = SVBT16ToShort(pSprm);
     593           0 :     sal_Int16 eVRel = text::RelOrientation::FRAME;
     594           0 :     sal_Int16 eVAlign = text::VertOrientation::NONE;
     595             : 
     596           0 :     switch( nYPos ){                            // special y positions ?
     597           0 :     case -4:  eVAlign = text::VertOrientation::TOP; nYPos = 0; break;
     598           0 :     case -8:  eVAlign = text::VertOrientation::CENTER; nYPos = 0; break;
     599           0 :     case -12: eVAlign = text::VertOrientation::BOTTOM; nYPos = 0; break;
     600             : 
     601             :     }
     602           0 :     rOut.SetFlyYPos( nYPos, eVRel, eVAlign );
     603           0 : }
     604             : 
     605           0 : void Ww1SingleSprmPDxaWidth::Start(
     606             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     607             : {
     608           0 :     short nDxaWidth = SVBT16ToShort(pSprm);
     609           0 :     rOut.SetFlyFrmAttr( SwFmtFrmSize( ATT_VAR_SIZE, nDxaWidth, MINFLY ) );
     610           0 : }
     611             : 
     612           0 : void Ww1SingleSprmPFromText::Start(
     613             :     Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
     614             : {
     615           0 :     if( rOut.IsInFly() ){   // Appears outside of Fly as well, but then it
     616             :                             // obviously has no meaning. It definitely does
     617             :                             // not implicitly start a new Fly
     618           0 :         short nFromText = SVBT16ToShort(pSprm);
     619             : 
     620           0 :         SvxLRSpaceItem aLR( RES_LR_SPACE );
     621           0 :         aLR.SetTxtLeft( nFromText );
     622           0 :         aLR.SetRight( nFromText );
     623           0 :         rOut.SetFlyFrmAttr( aLR );
     624             : 
     625           0 :         rOut.SetFlyFrmAttr( SvxULSpaceItem( nFromText, nFromText, RES_UL_SPACE ) );
     626             :     }
     627           0 : }
     628             : 
     629             : #undef STOP1
     630             : #undef STOP2
     631             : 
     632             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10