LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpparastyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 277 379 73.1 %
Date: 2012-08-25 Functions: 21 21 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 197 441 44.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *  The Contents of this file are made available subject to the terms of
       5                 :            :  *  either of the following licenses
       6                 :            :  *
       7                 :            :  *         - GNU Lesser General Public License Version 2.1
       8                 :            :  *         - Sun Industry Standards Source License Version 1.1
       9                 :            :  *
      10                 :            :  *  Sun Microsystems Inc., October, 2000
      11                 :            :  *
      12                 :            :  *  GNU Lesser General Public License Version 2.1
      13                 :            :  *  =============================================
      14                 :            :  *  Copyright 2000 by Sun Microsystems, Inc.
      15                 :            :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16                 :            :  *
      17                 :            :  *  This library is free software; you can redistribute it and/or
      18                 :            :  *  modify it under the terms of the GNU Lesser General Public
      19                 :            :  *  License version 2.1, as published by the Free Software Foundation.
      20                 :            :  *
      21                 :            :  *  This library is distributed in the hope that it will be useful,
      22                 :            :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23                 :            :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24                 :            :  *  Lesser General Public License for more details.
      25                 :            :  *
      26                 :            :  *  You should have received a copy of the GNU Lesser General Public
      27                 :            :  *  License along with this library; if not, write to the Free Software
      28                 :            :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29                 :            :  *  MA  02111-1307  USA
      30                 :            :  *
      31                 :            :  *
      32                 :            :  *  Sun Industry Standards Source License Version 1.1
      33                 :            :  *  =================================================
      34                 :            :  *  The contents of this file are subject to the Sun Industry Standards
      35                 :            :  *  Source License Version 1.1 (the "License"); You may not use this file
      36                 :            :  *  except in compliance with the License. You may obtain a copy of the
      37                 :            :  *  License at http://www.openoffice.org/license.html.
      38                 :            :  *
      39                 :            :  *  Software provided under this License is provided on an "AS IS" basis,
      40                 :            :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41                 :            :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42                 :            :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43                 :            :  *  See the License for the specific provisions governing your rights and
      44                 :            :  *  obligations concerning the Software.
      45                 :            :  *
      46                 :            :  *  The Initial Developer of the Original Code is: IBM Corporation
      47                 :            :  *
      48                 :            :  *  Copyright: 2008 by IBM Corporation
      49                 :            :  *
      50                 :            :  *  All Rights Reserved.
      51                 :            :  *
      52                 :            :  *  Contributor(s): _______________________________________
      53                 :            :  *
      54                 :            :  *
      55                 :            :  ************************************************************************/
      56                 :            : /*************************************************************************
      57                 :            :  * @file
      58                 :            :  *  For LWP filter architecture prototype
      59                 :            :  ************************************************************************/
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  Jan 2005           Created
      63                 :            :  ************************************************************************/
      64                 :            : 
      65                 :            : #include <boost/scoped_ptr.hpp>
      66                 :            : 
      67                 :            : #include "lwpparastyle.hxx"
      68                 :            : #include "lwpfilehdr.hxx"
      69                 :            : #include "lwpoverride.hxx"
      70                 :            : #include "lwpparaborderoverride.hxx"
      71                 :            : #include "lwpbreaksoverride.hxx"
      72                 :            : #include "lwpnumberingoverride.hxx"
      73                 :            : #include "lwptaboverride.hxx"
      74                 :            : #include "lwpbackgroundoverride.hxx"
      75                 :            : #include "xfilter/xfdefs.hxx"
      76                 :            : #include "xfilter/xfparastyle.hxx"
      77                 :            : #include "xfilter/xfborders.hxx"
      78                 :            : #include "lwpfont.hxx"
      79                 :            : #include "lwpfoundry.hxx"
      80                 :            : #include "lwppiece.hxx"
      81                 :            : #include "lwpshadow.hxx"
      82                 :            : #include "lwpborderstuff.hxx"
      83                 :            : #include "lwpmargins.hxx"
      84                 :            : #include "lwptabrack.hxx"
      85                 :            : 
      86                 :            : #include "lwpsilverbullet.hxx"
      87                 :            : 
      88                 :            : 
      89                 :        204 : LwpParaStyle::LwpParaStyle(LwpObjectHeader& objHdr, LwpSvStream* pStrm) :
      90                 :        204 : LwpTextStyle(objHdr, pStrm), m_pKinsokuOptsOverride(new LwpKinsokuOptsOverride),
      91 [ +  - ][ +  - ]:        408 : m_pBulletOverride(new LwpBulletOverride)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ +  -  +  - ]
                 [ +  - ]
      92                 :            : {
      93                 :        204 : }
      94                 :            : 
      95                 :        204 : LwpParaStyle::~LwpParaStyle()
      96                 :            : {
      97         [ +  - ]:        204 :     if (m_pKinsokuOptsOverride)
      98                 :            :     {
      99 [ +  - ][ +  - ]:        204 :         delete m_pKinsokuOptsOverride;
     100                 :            :     }
     101                 :            : 
     102         [ +  - ]:        204 :     if (m_pBulletOverride)
     103                 :            :     {
     104 [ +  - ][ +  - ]:        204 :         delete m_pBulletOverride;
     105                 :            :     }
     106         [ -  + ]:        408 : }
     107                 :            : 
     108                 :        204 : void LwpParaStyle::Read()
     109                 :            : {
     110                 :        204 :     LwpTextStyle::Read();
     111                 :            : 
     112         [ -  + ]:        204 :     if (LwpFileHeader::m_nFileRevision < 0x000B)
     113                 :            :     {
     114                 :            :         // read many overrides
     115                 :          0 :         LwpAlignmentOverride    aAlignOverride;
     116         [ #  # ]:          0 :         aAlignOverride.Read(m_pObjStrm);
     117                 :            : 
     118         [ #  # ]:          0 :         LwpSpacingOverride  aSpacingOverride;
     119         [ #  # ]:          0 :         aSpacingOverride.Read(m_pObjStrm);
     120                 :            : 
     121                 :          0 :         LwpIndentOverride       aIndentOverride;
     122         [ #  # ]:          0 :         aIndentOverride.Read(m_pObjStrm);
     123                 :            : 
     124         [ #  # ]:          0 :         LwpParaBorderOverride   aPBOverride;
     125         [ #  # ]:          0 :         aPBOverride.Read(m_pObjStrm);
     126                 :            : 
     127         [ #  # ]:          0 :         LwpBreaksOverride   aBreaksOverride;
     128         [ #  # ]:          0 :         aBreaksOverride.Read(m_pObjStrm);
     129                 :            : 
     130         [ #  # ]:          0 :         LwpNumberingOverride    aNumberingOverride;
     131         [ #  # ]:          0 :         aNumberingOverride.Read(m_pObjStrm);
     132                 :            : 
     133         [ #  # ]:          0 :         LwpTabOverride      aTabOverride;
     134 [ #  # ][ #  # ]:          0 :         aTabOverride.Read(m_pObjStrm);
         [ #  # ][ #  # ]
     135                 :            : 
     136                 :            :     }
     137                 :            :     else
     138                 :            :     {
     139                 :        204 :         m_AlignmentStyle.ReadIndexed(m_pObjStrm);
     140                 :        204 :         m_SpacingStyle.ReadIndexed(m_pObjStrm);
     141                 :        204 :         m_IndentStyle.ReadIndexed(m_pObjStrm);
     142                 :        204 :         m_BorderStyle.ReadIndexed(m_pObjStrm);
     143                 :        204 :         m_BreaksStyle.ReadIndexed(m_pObjStrm);
     144                 :        204 :         m_NumberingStyle.ReadIndexed(m_pObjStrm);
     145                 :        204 :         m_TabStyle.ReadIndexed(m_pObjStrm);
     146                 :            : 
     147                 :        204 :         m_pKinsokuOptsOverride->Read(m_pObjStrm);
     148                 :        204 :         m_pBulletOverride->Read(m_pObjStrm);
     149                 :            : 
     150         [ +  + ]:        204 :         if (m_pObjStrm->CheckExtra())
     151                 :            :         {
     152                 :        156 :             m_BackgroundStyle.ReadIndexed(m_pObjStrm);
     153                 :        156 :             m_pObjStrm->SkipExtra();
     154                 :            :         }
     155                 :            : 
     156                 :            : 
     157                 :            :     }
     158                 :        204 : }
     159                 :            : 
     160                 :        204 : void LwpParaStyle::Apply(XFParaStyle *pParaStyle)
     161                 :            : {
     162                 :            :     assert(pParaStyle);
     163         [ -  + ]:        204 :     if (!pParaStyle)
     164                 :        204 :         return;
     165                 :            : 
     166                 :        204 :     LwpVirtualPiece *pPiece = NULL;
     167                 :            :     //alignment:
     168         [ +  + ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_AlignmentStyle.obj());
     169         [ +  + ]:        204 :     if( pPiece )
     170                 :            :     {
     171         [ -  + ]:         60 :         LwpAlignmentOverride *pAlign = dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
     172         [ +  - ]:         60 :         if( pAlign )
     173                 :         60 :                 ApplyAlignment(pParaStyle,pAlign);
     174                 :            :     }
     175                 :            : 
     176                 :            :     //don't known top and bottom indent now.
     177         [ +  + ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_IndentStyle.obj());
     178         [ +  + ]:        204 :     if( pPiece )
     179                 :            :     {
     180         [ -  + ]:        147 :         LwpIndentOverride   *pIndent = dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
     181         [ +  - ]:        147 :         if( pIndent )
     182                 :            :         {
     183         [ +  + ]:        147 :             if (!m_pBulletOverride->IsInValid())//Add by ,for remove bullet indent in named bullet style
     184                 :            :             {
     185         [ +  - ]:        123 :                 boost::scoped_ptr<LwpIndentOverride> pNewIndent(pIndent->clone());
     186                 :        123 :                 pNewIndent->SetMFirst(0);
     187                 :        123 :                 pNewIndent->SetMRest(0);
     188 [ +  - ][ +  - ]:        123 :                 ApplyIndent(NULL, pParaStyle, pNewIndent.get());
     189                 :            :             }
     190                 :            :             else
     191                 :         24 :                 ApplyIndent(NULL,pParaStyle,pIndent);
     192                 :            :         }
     193                 :            :     }
     194                 :            :     //shadow & borders.
     195         [ +  + ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_BorderStyle.obj());
     196         [ +  + ]:        204 :     if( pPiece )
     197                 :            :     {
     198         [ -  + ]:         12 :         LwpParaBorderOverride *pBorder = dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
     199         [ +  - ]:         12 :         if( pBorder )
     200                 :            :         {
     201                 :         12 :             this->ApplyParaBorder(pParaStyle, pBorder);
     202                 :            :         }
     203                 :            :     }
     204                 :            : 
     205         [ +  + ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_SpacingStyle.obj());
     206         [ +  + ]:        204 :     if (pPiece)
     207                 :            :     {
     208         [ -  + ]:         81 :         LwpSpacingOverride *pSpacing = dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
     209         [ +  - ]:         81 :         if( pSpacing)
     210                 :         81 :             ApplySpacing(NULL,pParaStyle,pSpacing);
     211                 :            :     }
     212                 :            : 
     213                 :            :     //paragraph background.
     214         [ +  - ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_BackgroundStyle.obj());
     215         [ -  + ]:        204 :     if( pPiece )
     216                 :            :     {
     217         [ #  # ]:          0 :         LwpBackgroundOverride *pBack = dynamic_cast<LwpBackgroundOverride*>(pPiece->GetOverride());
     218         [ #  # ]:          0 :         if( pBack )
     219                 :            :         {
     220                 :          0 :             LwpColor color = pBack->GetBackColor();
     221         [ #  # ]:          0 :             XFColor aXFColor( color.To24Color() );
     222         [ #  # ]:          0 :             pParaStyle->SetBackColor( aXFColor );
     223                 :            :         }
     224                 :            :     }
     225                 :            : 
     226                 :            : 
     227                 :            :     //add tab style
     228         [ +  - ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_TabStyle.obj());
     229         [ -  + ]:        204 :     if( pPiece  )
     230                 :            :     {
     231         [ #  # ]:          0 :         LwpTabOverride *pTab = dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
     232         [ #  # ]:          0 :         if(pTab)
     233                 :            :         {
     234                 :          0 :             ApplyTab(pParaStyle,pTab);
     235                 :            :         }
     236                 :            :     }
     237         [ +  + ]:        204 :     pPiece = dynamic_cast<LwpVirtualPiece*>(m_BreaksStyle.obj());
     238         [ +  + ]:        204 :     if( pPiece  )
     239                 :            :     {
     240         [ -  + ]:         81 :         LwpBreaksOverride *pBreak = dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
     241         [ +  - ]:         81 :         if(pBreak)
     242                 :            :         {
     243                 :         81 :             ApplyBreaks(pParaStyle,pBreak);
     244                 :            :         }
     245                 :            :     }
     246                 :            : 
     247                 :            : }
     248                 :            : 
     249                 :       1056 : void LwpParaStyle::ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType, XFBorders* pXFBorders)
     250                 :            : {
     251                 :       1056 :     enumXFBorder eXFBorderSide = enumXFBorderNone;
     252   [ +  +  +  +  :       1056 :     switch (eType)
                      - ]
     253                 :            :     {
     254                 :            :     case LwpBorderStuff::LEFT:
     255                 :        264 :         eXFBorderSide = enumXFBorderLeft;
     256                 :        264 :         break;
     257                 :            :     case LwpBorderStuff::RIGHT:
     258                 :        264 :         eXFBorderSide = enumXFBorderRight;
     259                 :        264 :         break;
     260                 :            :     case LwpBorderStuff::TOP:
     261                 :        264 :         eXFBorderSide = enumXFBorderTop;
     262                 :        264 :         break;
     263                 :            :     case LwpBorderStuff::BOTTOM:
     264                 :        264 :         eXFBorderSide = enumXFBorderBottom;
     265                 :        264 :         break;
     266                 :            :     default:
     267                 :          0 :         break;
     268                 :            :     }
     269                 :            : 
     270         [ +  - ]:       1056 :     LwpColor    aColor = pBorderStuff->GetSideColor(eType);
     271         [ +  - ]:       1056 :     float       fWidth = pBorderStuff->GetSideWidth(eType);
     272         [ +  - ]:       1056 :     sal_uInt16  nType = pBorderStuff->GetSideType(eType);
     273                 :            : 
     274   [ +  -  -  - ]:       1056 :     switch (nType)
     275                 :            :     {
     276                 :            :     default://fall through!
     277                 :            :     case 0x14: //single fall through!
     278                 :            :     case 0x17: //treble
     279         [ +  - ]:       1056 :         pXFBorders->SetWidth(eXFBorderSide, fWidth);
     280                 :       1056 :         break;
     281                 :            :     case 0x15: //double , fall through!
     282                 :            :     case 0x16: //thick double
     283         [ #  # ]:          0 :         pXFBorders->SetDoubleLine(eXFBorderSide, sal_True, sal_False);
     284         [ #  # ]:          0 :         pXFBorders->SetWidthOutter(eXFBorderSide, static_cast<float>(fWidth*0.333));
     285         [ #  # ]:          0 :         pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.334));
     286         [ #  # ]:          0 :         pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.333));
     287                 :            : //      pXFBorders->SetWidth(eXFBorderSide, fWidth);
     288                 :          0 :         break;
     289                 :            :     case 0x18: //thick-thin
     290         [ #  # ]:          0 :         pXFBorders->SetDoubleLine(eXFBorderSide, sal_True, sal_False);
     291         [ #  # ]:          0 :         pXFBorders->SetWidthOutter(eXFBorderSide, static_cast<float>(fWidth*0.5));
     292         [ #  # ]:          0 :         pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.25));
     293         [ #  # ]:          0 :         pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.25));
     294                 :          0 :         break;
     295                 :            :     case 0x19: //thin-thick
     296         [ #  # ]:          0 :         pXFBorders->SetDoubleLine(eXFBorderSide, sal_True, sal_False);
     297         [ #  # ]:          0 :         pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.7));
     298         [ #  # ]:          0 :         pXFBorders->SetWidthOutter(eXFBorderSide, static_cast<float>(fWidth*0.15));
     299         [ #  # ]:          0 :         pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.15));
     300                 :          0 :         break;
     301                 :            :     }
     302                 :            : 
     303         [ +  - ]:       1056 :     if (aColor.IsValidColor())
     304                 :            :     {
     305         [ +  - ]:       1056 :         XFColor aXFColor(aColor.To24Color());
     306         [ +  - ]:       1056 :         pXFBorders->SetColor(eXFBorderSide, aXFColor );
     307                 :       1056 :     }
     308                 :       1056 : }
     309                 :            : 
     310                 :         18 : void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder)
     311                 :            : {
     312                 :            :     //convert LwpShadow:
     313                 :         18 :     LwpShadow *pShadow = pBorder->GetShadow();
     314         [ +  - ]:         18 :     if( pShadow )
     315                 :            :     {
     316                 :         18 :         LwpColor color = pShadow->GetColor();
     317                 :         18 :         float   offsetX = pShadow->GetOffsetX();
     318                 :         18 :         float   offsetY = pShadow->GetOffsetY();
     319                 :            : 
     320 [ +  - ][ +  - ]:         18 :         if( offsetX && offsetY && color.IsValidColor() )
         [ +  + ][ +  + ]
     321                 :            :         {
     322         [ +  - ]:          3 :             XFColor aXFColor(color.To24Color());
     323                 :          3 :             sal_Bool left = sal_False;
     324                 :          3 :             sal_Bool top = sal_False;
     325         [ -  + ]:          3 :             if( offsetX < 0 )
     326                 :          0 :                 left = sal_True;
     327         [ -  + ]:          3 :             if( offsetY < 0 )
     328                 :          0 :                 top = sal_True;
     329         [ -  + ]:          3 :             if( left )
     330                 :            :             {
     331         [ #  # ]:          0 :                 if( top )
     332         [ #  # ]:          0 :                     pParaStyle->SetShadow(enumXFShadowLeftTop,-offsetX,aXFColor);
     333                 :            :                 else
     334         [ #  # ]:          0 :                     pParaStyle->SetShadow(enumXFShadowLeftBottom,-offsetX,aXFColor);
     335                 :            :             }
     336                 :            :             else
     337                 :            :             {
     338         [ -  + ]:          3 :                 if( top )
     339         [ #  # ]:          0 :                     pParaStyle->SetShadow(enumXFShadowRightTop,offsetX,aXFColor);
     340                 :            :                 else
     341         [ +  - ]:          3 :                     pParaStyle->SetShadow(enumXFShadowRightBottom,offsetX,aXFColor);
     342                 :            :             }
     343                 :         18 :         }
     344                 :            :     }
     345                 :            : 
     346                 :            :     //convert to XFBorders obejct:
     347                 :         18 :     LwpBorderStuff  *pBorderStuff = pBorder->GetBorderStuff();
     348 [ +  + ][ +  + ]:         18 :     if( pBorderStuff && pBorderStuff->GetSide() != 0 )
                 [ +  - ]
     349                 :            :     {
     350 [ +  - ][ +  - ]:          6 :         XFBorders   *pXFBorders = new XFBorders();
     351         [ +  - ]:          6 :         pParaStyle->SetBorders(pXFBorders);
     352                 :            : 
     353                 :          6 :         LwpMargins* pMargins = pBorder->GetMargins();
     354                 :            : 
     355                 :            :         // apply 4 borders respectively
     356                 :            :         LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
     357                 :          6 :             LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
     358                 :            :         float pMarginValue[4];
     359                 :            : 
     360         [ +  + ]:         30 :         for (sal_uInt8 nC = 0; nC < 4; nC++)
     361                 :            :         {
     362 [ +  - ][ +  - ]:         24 :             if (pBorderStuff->HasSide(pType[nC]))
     363                 :            :             {
     364         [ +  - ]:         24 :                 this->ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
     365                 :            : 
     366                 :            :                 //get border spacing to text content
     367         [ +  - ]:         24 :                 if (pMargins)
     368                 :            :                 {
     369                 :         24 :                     pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
     370                 :            :                 }
     371                 :            :             }
     372                 :            : 
     373                 :            :         }
     374                 :            : 
     375                 :            :         //apply border spacing to text content
     376                 :          6 :         pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
     377                 :            : 
     378                 :            :     }
     379                 :         18 : }
     380                 :            : 
     381                 :         81 : void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, LwpBreaksOverride* pBreaks)
     382                 :            : {
     383         [ +  + ]:         81 :     if (pBreaks->IsKeepWithNext())
     384                 :            :     {
     385                 :         12 :         pParaStyle->SetBreaks(enumXFBreakKeepWithNext);
     386                 :            :     }
     387         [ -  + ]:         81 :     if (pBreaks->IsPageBreakBefore())
     388                 :            :     {
     389                 :          0 :         pParaStyle->SetBreaks(enumXFBreakBefPage);
     390                 :            :     }
     391         [ -  + ]:         81 :     if (pBreaks->IsPageBreakAfter())
     392                 :            :     {
     393                 :          0 :         pParaStyle->SetBreaks(enumXFBreakAftPage);
     394                 :            :     }
     395         [ -  + ]:         81 :     if (pBreaks->IsColumnBreakBefore())
     396                 :            :     {
     397                 :          0 :         pParaStyle->SetBreaks(enumXFBreakBefColumn);
     398                 :            :     }
     399         [ -  + ]:         81 :     if (pBreaks->IsColumnBreakAfter())
     400                 :            :     {
     401                 :          0 :         pParaStyle->SetBreaks(enumXFBreakAftColumn);
     402                 :            :     }
     403                 :         81 : }
     404                 :            : 
     405                 :         72 : void LwpParaStyle::ApplyAlignment(XFParaStyle* pParaStyle, LwpAlignmentOverride* pAlign)
     406                 :            : {
     407                 :         72 :     enumXFAlignType alignType = enumXFAlignStart;
     408                 :            :     LwpAlignmentOverride::AlignType type;
     409                 :            : 
     410                 :         72 :     type = pAlign->GetAlignType();
     411                 :         72 :     pParaStyle->SetNumberRight(sal_False);//to identify its align attribute
     412   [ +  +  +  -  :         72 :     switch(type)
                -  +  - ]
     413                 :            :     {
     414                 :            :     case LwpAlignmentOverride::ALIGN_LEFT:
     415                 :         12 :         alignType = enumXFAlignStart;
     416                 :         12 :         break;
     417                 :            :     case LwpAlignmentOverride::ALIGN_RIGHT:
     418                 :          6 :         alignType = enumXFAlignEnd;
     419                 :          6 :         break;
     420                 :            :     case LwpAlignmentOverride::ALIGN_CENTER:
     421                 :         42 :         alignType = enumXFAlignCenter;
     422                 :         42 :         break;
     423                 :            :     case LwpAlignmentOverride::ALIGN_NUMERICLEFT://if non-number in table,ALIGN_NUMERICLEFT/RIGHT are useless
     424                 :          0 :         alignType = enumXFAlignStart;            //note by  1/28
     425                 :          0 :         break;
     426                 :            :     case LwpAlignmentOverride::ALIGN_JUSTIFY:
     427                 :            :     case LwpAlignmentOverride::ALIGN_JUSTIFYALL:
     428                 :          0 :         alignType = enumXFAlignJustify;
     429                 :          0 :         break;
     430                 :            :     case LwpAlignmentOverride::ALIGN_NUMERICRIGHT:
     431                 :         12 :         pParaStyle->SetNumberRight(sal_True);//to identify its align attribute
     432                 :         12 :         alignType = enumXFAlignEnd;
     433                 :         12 :         break;
     434                 :            :     default:
     435                 :          0 :         break;
     436                 :            :     }
     437                 :         72 :     pParaStyle->SetAlignType(alignType);
     438                 :         72 : }
     439                 :            : 
     440                 :        537 : void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, LwpIndentOverride* pIndent)
     441                 :            : {
     442                 :            :     LwpPara* pParentPara;
     443         [ +  + ]:        537 :     if (pPara)
     444         [ +  - ]:        390 :         pParentPara = pPara->GetParent();
     445                 :            :     else
     446                 :        147 :         pParentPara = NULL;
     447                 :            : 
     448                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     449         [ +  - ]:        537 :     std::auto_ptr<LwpIndentOverride> pTotalIndent(new LwpIndentOverride);
     450                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     451 [ +  + ][ -  + ]:        537 :     if (pIndent->IsUseRelative() && pParentPara)
         [ -  + ][ +  - ]
     452                 :            :     {
     453                 :          0 :         LwpIndentOverride* pParentIndent = pParentPara->GetIndent();
     454         [ #  # ]:          0 :         if (!pParentIndent)
     455                 :            :             return;
     456         [ #  # ]:          0 :         pTotalIndent.reset(pIndent->clone());
     457                 :            : 
     458                 :            :         //add by ,for bullet only
     459         [ #  # ]:          0 :         if (pPara)
     460                 :            :         {
     461         [ #  # ]:          0 :             if (pPara->GetBulletFlag())
     462                 :            :             {
     463                 :          0 :                 pTotalIndent->SetMAll(pParentIndent->GetMAll() + pTotalIndent->GetMAll());
     464                 :          0 :                 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
     465                 :            :                 pParaStyle->SetMargins(LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(
     466         [ #  # ]:          0 :                     pTotalIndent->GetMAll())), pTotalIndent->GetRight());
     467         [ #  # ]:          0 :                 pPara->SetIndent(pTotalIndent.release());
     468                 :            :                 return;
     469                 :            :             }
     470                 :            :         }
     471                 :            :         //end add
     472         [ #  # ]:          0 :         sal_uInt16 relative = pParentIndent->GetRelative();
     473                 :            : 
     474                 :          0 :         sal_Int32 Amount = pParentIndent->GetMAll();
     475                 :            : 
     476         [ #  # ]:          0 :         if (relative == LwpIndentOverride::RELATIVE_FIRST)
     477                 :          0 :             Amount += pParentIndent->GetMFirst();
     478         [ #  # ]:          0 :         else if (relative == LwpIndentOverride::RELATIVE_REST)
     479                 :          0 :             Amount += pParentIndent->GetMRest();
     480                 :          0 :         pTotalIndent->SetMAll(Amount + pTotalIndent->GetMAll());
     481                 :          0 :         pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
     482                 :            : 
     483         [ #  # ]:          0 :         pParaStyle->SetIndent(pTotalIndent->GetFirst());
     484         [ #  # ]:          0 :         pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
     485         [ #  # ]:          0 :         pPara->SetIndent(pTotalIndent.release());
     486                 :            : 
     487                 :            :     }
     488                 :            :     else
     489                 :            :     {
     490         [ +  - ]:        537 :         pTotalIndent.reset(pIndent->clone());
     491                 :            :         //add by
     492         [ +  + ]:        537 :         if (pPara)
     493                 :            :         {
     494         [ +  + ]:        390 :             if (pPara->GetBulletFlag())
     495                 :            :             {
     496                 :            : //              pParaStyle->SetIndent(LwpTools::ConvertFromUnits(pIndent->GetMAll()));
     497                 :            :                 pParaStyle->SetMargins(LwpTools::ConvertToMetric(
     498         [ +  - ]:         12 :                     LwpTools::ConvertFromUnits(pIndent->GetMAll())), pIndent->GetRight());
     499         [ +  - ]:         12 :                 pPara->SetIndent(pTotalIndent.release());
     500                 :            :                 return;
     501                 :            :             }
     502                 :            :         }
     503                 :            :         //end add
     504                 :            : 
     505         [ +  - ]:        525 :         pParaStyle->SetIndent(pIndent->GetFirst());
     506         [ +  - ]:        525 :         pParaStyle->SetMargins(pIndent->GetLeft(), pIndent->GetRight());
     507         [ +  + ]:        525 :         if (pPara)
     508                 :            :         {
     509         [ +  - ]:        525 :             pPara->SetIndent(pTotalIndent.release());
     510                 :            :         }
     511 [ +  - ][ +  + ]:        537 :     }
     512                 :            : }
     513                 :            : 
     514                 :        417 : void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing)
     515                 :            : {
     516                 :        417 :     LwpSpacingCommonOverride* spacing = pSpacing->GetSpacing();
     517                 :        417 :     LwpSpacingCommonOverride* abovepara = pSpacing->GetAboveSpacing();
     518                 :        417 :     LwpSpacingCommonOverride* belowpara = pSpacing->GetBelowSpacing();
     519                 :            : 
     520                 :        417 :     LwpSpacingCommonOverride::SpacingType type = spacing->GetType();
     521                 :        417 :     sal_Int32 amount = spacing->GetAmount();
     522                 :        417 :     sal_Int32 multiple = spacing->GetMultiple();
     523                 :            :     enumLHType xftype;
     524                 :            :     double height;
     525                 :            : 
     526   [ +  -  -  +  :        417 :     switch(type)
                      - ]
     527                 :            :     {
     528                 :            :     case LwpSpacingCommonOverride::SPACING_DYNAMIC:
     529                 :            :     {
     530                 :        351 :     xftype = enumLHPercent;
     531                 :        351 :     height = double(multiple)/65536L*100;
     532         [ +  - ]:        351 :     pParaStyle->SetLineHeight(xftype,height);
     533                 :            :     }
     534                 :        351 :         break;
     535                 :            :     case LwpSpacingCommonOverride::SPACING_LEADING:
     536                 :            :     {
     537                 :          0 :     xftype = enumLHSpace;
     538                 :          0 :     height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(amount));
     539         [ #  # ]:          0 :     pParaStyle->SetLineHeight(xftype,height);
     540                 :            :     }
     541                 :          0 :         break;
     542                 :            :     case LwpSpacingCommonOverride::SPACING_CUSTOM:
     543                 :            :     {
     544                 :          0 :     xftype = enumLHHeight;
     545                 :          0 :     height =  LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
     546         [ #  # ]:          0 :         pParaStyle->SetLineHeight(xftype,height);
     547                 :            :     }
     548                 :          0 :         break;
     549                 :            :     case LwpSpacingCommonOverride::SPACING_NONE:
     550                 :         66 :         break;
     551                 :            :     }
     552                 :            : 
     553                 :            : //TO DO: Above Line need to be processed!!!!!!! what it means??????  1-26
     554                 :            : 
     555                 :        417 :     type = abovepara->GetType();
     556                 :        417 :     amount = abovepara->GetAmount();
     557                 :        417 :     multiple = abovepara->GetMultiple();
     558                 :        417 :     double above_val =-1;
     559   [ +  -  +  +  :        417 :     switch(type)
                      - ]
     560                 :            :     {
     561                 :            :     case LwpSpacingCommonOverride::SPACING_DYNAMIC:
     562                 :            : //        above_val = LINE_HEIGHT*float(multiple)/65536L*100; //TO DO:  1-26
     563                 :         36 :         break;
     564                 :            :     case LwpSpacingCommonOverride::SPACING_LEADING:
     565                 :          0 :         break;
     566                 :            :     case LwpSpacingCommonOverride::SPACING_CUSTOM:
     567                 :        312 :         above_val =  LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
     568                 :        312 :         break;
     569                 :            :     case LwpSpacingCommonOverride::SPACING_NONE:
     570                 :         69 :         break;
     571                 :            :     }
     572                 :            : 
     573                 :        417 :     type = belowpara->GetType();
     574                 :        417 :     amount = belowpara->GetAmount();
     575                 :        417 :     multiple = belowpara->GetMultiple();
     576                 :        417 :     double below_val=-1;
     577   [ +  -  +  +  :        417 :     switch(type)
                      - ]
     578                 :            :     {
     579                 :            :     case LwpSpacingCommonOverride::SPACING_DYNAMIC:
     580                 :            : //        below_val = LINE_HEIGHT*float(multiple)/65536L*100;//TO DO:  1-26
     581                 :         12 :         break;
     582                 :            :     case LwpSpacingCommonOverride::SPACING_LEADING:
     583                 :          0 :         break;
     584                 :            :     case LwpSpacingCommonOverride::SPACING_CUSTOM:
     585                 :        312 :         below_val =  LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
     586                 :        312 :         break;
     587                 :            :     case LwpSpacingCommonOverride::SPACING_NONE:
     588                 :         93 :         break;
     589                 :            :     }
     590                 :            : 
     591         [ +  + ]:        417 :     if (pPara)
     592                 :            :     {
     593         [ +  + ]:        336 :         if (below_val != -1)
     594                 :        291 :             pPara->SetBelowSpacing(below_val);
     595 [ +  - ][ -  + ]:        336 :         LwpPara* pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj());
     596 [ +  - ][ +  + ]:        336 :         if (pPrePara && above_val != -1)
     597                 :            :         {
     598                 :        291 :             above_val += pPrePara->GetBelowSpacing();
     599                 :            : 
     600                 :            :         }
     601                 :            : 
     602                 :            :     }
     603         [ +  - ]:        417 :     pParaStyle->SetMargins(-1,-1,above_val,below_val);
     604                 :        417 : }
     605                 :            : /**************************************************************************
     606                 :            :  * @short:
     607                 :            :  * @descr:
     608                 :            :  * @param:
     609                 :            :  * @param:
     610                 :            :  * @return:
     611                 :            : **************************************************************************/
     612                 :         75 : void LwpParaStyle::ApplyTab(XFParaStyle *pParaStyle, LwpTabOverride *pTabOverRide)
     613                 :            : {
     614                 :         75 :     LwpObjectID* pTabRackID = pTabOverRide->GetTabRackID();
     615         [ +  + ]:         75 :     if(pTabRackID->IsNull())
     616                 :            :     {
     617                 :            :         //assert(false);
     618                 :         60 :         return;
     619                 :            :     }
     620                 :            : 
     621         [ -  + ]:         15 :     LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(pTabRackID->obj());
     622         [ -  + ]:         15 :     if(!pTabRack)
     623                 :            :     {
     624                 :            :         //assert(false);
     625                 :          0 :         return;
     626                 :            :     }
     627                 :            : 
     628                 :         15 :     pParaStyle->ClearTabStyles();
     629                 :            :     //Get margin left value
     630                 :         15 :     double dMarginLeft = pParaStyle->GetMargins().GetLeft();
     631                 :            : 
     632                 :         15 :     sal_uInt16 nNumTabs = pTabRack->GetNumTabs();
     633         [ +  + ]:        105 :     for(sal_uInt16 nIndex=0; nIndex<nNumTabs; nIndex++)
     634                 :            :     {
     635                 :            :         //get tab type
     636                 :         30 :         LwpTab* pTab = pTabRack->Lookup(nIndex);
     637         [ -  + ]:         30 :         if(!pTab)
     638                 :          0 :             return;
     639                 :            : 
     640                 :         30 :         enumXFTab eType = enumXFTabNone;
     641                 :         30 :         LwpTab::TabType type = pTab->GetTabType();
     642   [ -  +  +  -  :         30 :         switch(type)
                      - ]
     643                 :            :         {
     644                 :            :         case LwpTab::TT_LEFT:
     645                 :          0 :             eType = enumXFTabLeft;
     646                 :          0 :             break;
     647                 :            :         case LwpTab::TT_CENTER:
     648                 :         15 :             eType = enumXFTabCenter;
     649                 :         15 :             break;
     650                 :            :         case LwpTab::TT_RIGHT:
     651                 :         15 :             eType = enumXFTabRight;
     652                 :         15 :             break;
     653                 :            :         case LwpTab::TT_NUMERIC:
     654                 :          0 :             eType = enumXFTabChar;
     655                 :          0 :             break;
     656                 :            :         }
     657                 :            : 
     658                 :            :         //get position
     659                 :         30 :         sal_uInt32 nPos = pTab->GetPosition();
     660                 :            :         //different feature between SODC and lwp, the tab length must minus the margin left of para.
     661                 :         30 :         double fLen = LwpTools::ConvertFromUnitsToMetric(nPos) - dMarginLeft;
     662                 :            : 
     663                 :            :         //get leader type
     664                 :         30 :         sal_Unicode cLeader = 0x00;
     665                 :         30 :         LwpTab::LeaderType leader= pTab->GetLeaderType();
     666   [ +  -  -  -  :         30 :         switch(leader)
                      - ]
     667                 :            :         {
     668                 :            :         case LwpTab::TL_NONE:
     669                 :         30 :             cLeader = 0x20;     //space
     670                 :         30 :             break;
     671                 :            :         case LwpTab::TL_HYPHEN: //'-'
     672                 :          0 :             cLeader = 0xAD;
     673                 :          0 :             break;
     674                 :            :         case LwpTab::TL_DOT:    //'.'
     675                 :          0 :             cLeader = 0x2E;
     676                 :          0 :             break;
     677                 :            :         case LwpTab::TL_LINE:   //'_'
     678                 :          0 :             cLeader = 0x5F;
     679                 :          0 :             break;
     680                 :            :         }
     681                 :            : 
     682                 :         30 :         sal_Unicode cAlignChar = static_cast<sal_Unicode>(pTab->GetAlignChar());
     683                 :            : 
     684                 :         30 :         pParaStyle->AddTabStyle(eType,fLen,cLeader,cAlignChar);
     685                 :            :     }
     686                 :            : 
     687                 :            : }
     688                 :            : 
     689                 :            : 
     690                 :        204 : void LwpParaStyle::RegisterStyle()
     691                 :            : {
     692 [ +  - ][ +  - ]:        204 :     XFParaStyle* pStyle = new XFParaStyle();
     693                 :            : 
     694                 :            :     //Set name
     695                 :        204 :     OUString styleName = GetName()->str();
     696         [ +  - ]:        204 :     pStyle->SetStyleName(styleName);
     697                 :            : 
     698                 :            :     //Create font
     699                 :        204 :     LwpFontManager* pFontMgr = m_pFoundry->GetFontManger();
     700         [ +  - ]:        204 :     XFFont* pFont = pFontMgr->CreateFont(m_nFinalFontID);
     701         [ +  - ]:        204 :     pStyle->SetFont(pFont);
     702                 :            : 
     703                 :            :     //Set other paragraph properties...
     704                 :            : 
     705         [ +  - ]:        204 :     Apply(pStyle);
     706                 :            :     //Add style
     707                 :        204 :     LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
     708         [ +  - ]:        204 :     pStyleMgr->AddStyle(*GetObjectID(), pStyle);
     709                 :        204 : }
     710                 :            : 
     711                 :         24 : LwpAlignmentOverride* LwpParaStyle::GetAlignment()
     712                 :            : {
     713         [ -  + ]:         24 :     if (m_AlignmentStyle.obj() == NULL)
     714                 :          0 :         return NULL;
     715                 :            : 
     716         [ -  + ]:         24 :     LwpAlignmentPiece *pPiece = dynamic_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj());
     717         [ +  - ]:         24 :     if (pPiece)
     718         [ +  - ]:         24 :         return dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
     719                 :         24 :     return NULL;
     720                 :            : }
     721                 :            : 
     722                 :       1866 : LwpIndentOverride* LwpParaStyle::GetIndent()
     723                 :            : {
     724         [ +  + ]:       1866 :     if (m_IndentStyle.obj() == NULL)
     725                 :        183 :         return NULL;
     726                 :            : 
     727         [ -  + ]:       1683 :     LwpIndentPiece *pPiece = dynamic_cast<LwpIndentPiece*>(m_IndentStyle.obj());
     728         [ +  - ]:       1683 :     if (pPiece)
     729         [ +  - ]:       1683 :         return dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
     730                 :       1866 :     return NULL;
     731                 :            : }
     732                 :            : 
     733                 :        672 : LwpSpacingOverride* LwpParaStyle::GetSpacing()
     734                 :            : {
     735         [ -  + ]:        672 :     if (m_SpacingStyle.obj() == NULL)
     736                 :          0 :         return NULL;
     737                 :            : 
     738         [ -  + ]:        672 :     LwpSpacingPiece *pPiece = dynamic_cast<LwpSpacingPiece*>(m_SpacingStyle.obj());
     739         [ +  - ]:        672 :     if (pPiece)
     740         [ +  - ]:        672 :         return dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
     741                 :        672 :     return NULL;
     742                 :            : }
     743                 :            : 
     744                 :          6 : LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const
     745                 :            : {
     746         [ -  + ]:          6 :     if(m_BorderStyle.IsNull())
     747                 :          0 :         return NULL;
     748                 :            : 
     749         [ -  + ]:          6 :     LwpParaBorderPiece *pPiece = dynamic_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE));
     750         [ +  - ]:          6 :     if (pPiece)
     751         [ +  - ]:          6 :         return dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
     752                 :          6 :     return NULL;
     753                 :            : }
     754                 :            : 
     755                 :        381 : LwpBreaksOverride* LwpParaStyle::GetBreaks() const
     756                 :            : {
     757         [ -  + ]:        381 :     if(m_BreaksStyle.IsNull())
     758                 :          0 :         return NULL;
     759                 :            : 
     760         [ -  + ]:        381 :     LwpBreaksPiece *pPiece = dynamic_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE));
     761         [ +  - ]:        381 :     if (pPiece)
     762         [ +  - ]:        381 :         return dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
     763                 :        381 :     return NULL;
     764                 :            : }
     765                 :            : 
     766                 :        786 : LwpBulletOverride* LwpParaStyle::GetBulletOverride() const
     767                 :            : {
     768                 :        786 :     return m_pBulletOverride;
     769                 :            : }
     770                 :            : 
     771                 :        786 : LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const
     772                 :            : {
     773         [ +  + ]:        786 :     if(m_NumberingStyle.IsNull())
     774                 :        111 :         return NULL;
     775                 :            : 
     776         [ -  + ]:        675 :     LwpNumberingPiece *pPiece = dynamic_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE));
     777         [ +  - ]:        675 :     if (pPiece)
     778         [ +  - ]:        675 :         return dynamic_cast<LwpNumberingOverride*>(pPiece->GetOverride());
     779                 :        786 :     return NULL;
     780                 :            : }
     781                 :            : 
     782                 :            : 
     783                 :            : /**************************************************************************
     784                 :            :  * @short:
     785                 :            :  * @descr:
     786                 :            :  * @param:
     787                 :            :  * @param:
     788                 :            :  * @return:
     789                 :            : **************************************************************************/
     790                 :         75 : LwpTabOverride* LwpParaStyle::GetTabOverride() const
     791                 :            : {
     792         [ +  - ]:         75 :     if(m_TabStyle.obj() == NULL)
     793                 :         75 :         return NULL;
     794         [ #  # ]:          0 :     LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabStyle.obj());
     795         [ #  # ]:          0 :     if (pPiece)
     796         [ #  # ]:          0 :         return dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
     797                 :         75 :     return NULL;
     798                 :            : }
     799                 :            : 
     800                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10