LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpborderstuff.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 92 91.3 %
Date: 2012-08-25 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 41 73.2 %

           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                 :            : * Border stuff of Wordpro.
      59                 :            : ************************************************************************/
      60                 :            : #include    "lwpborderstuff.hxx"
      61                 :            : #include    "lwpstyledef.hxx"
      62                 :            : #include    "lwpfilehdr.hxx"
      63                 :            : #include    "lwptools.hxx"
      64                 :            : 
      65                 :        294 : LwpBorderStuff::LwpBorderStuff()
      66                 :            : {
      67                 :        294 :     m_nSides = 0;
      68                 :        294 :     m_nValid = 0;
      69                 :            : 
      70                 :        294 :     m_nBoderGroupIDLeft = 0;
      71                 :        294 :     m_nBoderGroupIDRight = 0;
      72                 :        294 :     m_nBoderGroupIDTop = 0;
      73                 :        294 :     m_nBoderGroupIDBottom = 0;
      74                 :            : 
      75                 :        294 :     m_nGroupIndent = 0;
      76                 :            : 
      77                 :        294 :     m_nWidthLeft = 0;
      78                 :        294 :     m_nWidthTop = 0;
      79                 :        294 :     m_nWidthRight = 0;
      80                 :        294 :     m_nWidthBottom = 0;
      81                 :        294 : }
      82                 :            : 
      83                 :         72 : void    LwpBorderStuff::Read(LwpObjectStream *pStrm)
      84                 :            : {
      85                 :         72 :     m_nSides = pStrm->QuickReaduInt16();
      86         [ +  + ]:         72 :     if( m_nSides&LEFT )
      87                 :            :     {
      88                 :         24 :         m_nBoderGroupIDLeft = pStrm->QuickReaduInt16();
      89                 :         24 :         m_nWidthLeft = pStrm->QuickReadInt32();
      90                 :         24 :         m_aColorLeft.Read(pStrm);
      91                 :            : 
      92         [ -  + ]:         24 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
      93                 :            :         {
      94                 :          0 :             pStrm->SeekRel(8);
      95                 :            :         }
      96                 :            :     }
      97                 :            : 
      98         [ +  + ]:         72 :     if( m_nSides&RIGHT )
      99                 :            :     {
     100                 :         24 :         m_nBoderGroupIDRight = pStrm->QuickReaduInt16();
     101                 :         24 :         m_nWidthRight = pStrm->QuickReadInt32();
     102                 :         24 :         m_aColorRight.Read(pStrm);
     103                 :            : 
     104         [ -  + ]:         24 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
     105                 :            :         {
     106                 :          0 :             pStrm->SeekRel(8);
     107                 :            :         }
     108                 :            :     }
     109                 :            : 
     110         [ +  + ]:         72 :     if( m_nSides&TOP )
     111                 :            :     {
     112                 :         48 :         m_nBoderGroupIDTop = pStrm->QuickReaduInt16();
     113                 :         48 :         m_nWidthTop = pStrm->QuickReadInt32();
     114                 :         48 :         m_aColorTop.Read(pStrm);
     115                 :            : 
     116         [ -  + ]:         48 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
     117                 :            :         {
     118                 :          0 :             pStrm->SeekRel(8);
     119                 :            :         }
     120                 :            :     }
     121                 :            : 
     122         [ +  + ]:         72 :     if( m_nSides&BOTTOM )
     123                 :            :     {
     124                 :         24 :         m_nBoderGroupIDBottom = pStrm->QuickReaduInt16();
     125                 :         24 :         m_nWidthBottom = pStrm->QuickReadInt32();
     126                 :         24 :         m_aColorBottom.Read(pStrm);
     127                 :            : 
     128         [ -  + ]:         24 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
     129                 :            :         {
     130                 :          0 :             pStrm->SeekRel(8);
     131                 :            :         }
     132                 :            :     }
     133                 :            : 
     134                 :         72 :     m_nGroupIndent = pStrm->QuickReadInt32();
     135                 :         72 :     m_nValid = pStrm->QuickReaduInt16();
     136                 :         72 :     pStrm->SkipExtra();
     137                 :            : 
     138         [ +  + ]:         72 :     if( LwpFileHeader::m_nFileRevision < 0x0010 )
     139                 :            :     {
     140         [ -  + ]:         18 :         if( m_nBoderGroupIDLeft&EXTERNAL_ID )
     141                 :            :         {
     142                 :          0 :             m_nBoderGroupIDLeft = BGRP_SOLID;
     143                 :            :         }
     144         [ -  + ]:         18 :         if( m_nBoderGroupIDRight&EXTERNAL_ID )
     145                 :            :         {
     146                 :          0 :             m_nBoderGroupIDRight = BGRP_SOLID;
     147                 :            :         }
     148         [ -  + ]:         18 :         if( m_nBoderGroupIDTop&EXTERNAL_ID )
     149                 :            :         {
     150                 :          0 :             m_nBoderGroupIDTop = BGRP_SOLID;
     151                 :            :         }
     152         [ -  + ]:         18 :         if( m_nBoderGroupIDBottom&EXTERNAL_ID )
     153                 :            :         {
     154                 :          0 :             m_nBoderGroupIDBottom = BGRP_SOLID;
     155                 :            :         }
     156                 :            :     }
     157                 :         72 : }
     158                 :            : 
     159                 :       1056 : sal_Bool    LwpBorderStuff::HasSide(sal_uInt16 side)
     160                 :            : {
     161                 :       1056 :     return m_nSides&side;
     162                 :            : }
     163                 :            : 
     164                 :       1056 : sal_uInt16  LwpBorderStuff::GetSideType(sal_uInt16 side)
     165                 :            : {
     166   [ +  +  +  +  :       1056 :     switch(side)
                      - ]
     167                 :            :     {
     168                 :            :     case LEFT:
     169                 :        264 :         return m_nBoderGroupIDLeft;
     170                 :            :         break;
     171                 :            :     case RIGHT:
     172                 :        264 :         return m_nBoderGroupIDRight;
     173                 :            :         break;
     174                 :            :     case TOP:
     175                 :        264 :         return m_nBoderGroupIDTop;
     176                 :            :         break;
     177                 :            :     case BOTTOM:
     178                 :        264 :         return m_nBoderGroupIDBottom;
     179                 :            :         break;
     180                 :            :     }
     181                 :            :     // FIXME: this is needed to avoid warning: control reaches end of non-void function
     182                 :            :     //        a better solution would be to enum value for the parameter side
     183                 :       1056 :     return 0;
     184                 :            : }
     185                 :            : 
     186                 :       1080 : LwpColor    LwpBorderStuff::GetSideColor(sal_uInt16 side)
     187                 :            : {
     188   [ +  +  +  +  :       1080 :     switch(side)
                      - ]
     189                 :            :     {
     190                 :            :     case LEFT:
     191                 :        264 :         return m_aColorLeft;
     192                 :            :         break;
     193                 :            :     case RIGHT:
     194                 :        264 :         return m_aColorRight;
     195                 :            :         break;
     196                 :            :     case TOP:
     197                 :        288 :         return m_aColorTop;
     198                 :            :         break;
     199                 :            :     case BOTTOM:
     200                 :        264 :         return m_aColorBottom;
     201                 :            :         break;
     202                 :            :     }
     203                 :            :     // FIXME: this is needed to avoid warning: control reaches end of non-void function
     204                 :            :     //        a better solution would be to enum value for the parameter side
     205                 :       1080 :     return LwpColor();
     206                 :            : }
     207                 :            : 
     208                 :       1080 : float   LwpBorderStuff::GetSideWidth(sal_uInt16 side)
     209                 :            : {
     210   [ +  +  +  +  :       1080 :     switch(side)
                      - ]
     211                 :            :     {
     212                 :            :     case LEFT:
     213                 :        264 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthLeft));
     214                 :            :         break;
     215                 :            :     case RIGHT:
     216                 :        264 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthRight));
     217                 :            :         break;
     218                 :            :     case TOP:
     219                 :        288 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthTop));
     220                 :            :         break;
     221                 :            :     case BOTTOM:
     222                 :        264 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthBottom));
     223                 :            :         break;
     224                 :            :     }
     225                 :            :     // FIXME: this is needed to avoid warning: control reaches end of non-void function
     226                 :            :     //        a better solution would be to enum value for the parameter side
     227                 :       1080 :     return 0;
     228                 :            : }
     229                 :            : 
     230                 :         12 : LwpBorderStuff& LwpBorderStuff::operator = (const LwpBorderStuff& rOther)
     231                 :            : {
     232                 :         12 :     m_nSides = rOther.m_nSides;
     233                 :         12 :     m_nValid = rOther.m_nValid;
     234                 :            : 
     235                 :         12 :     m_nBoderGroupIDLeft = rOther.m_nBoderGroupIDLeft;
     236                 :         12 :     m_nBoderGroupIDRight = rOther.m_nBoderGroupIDRight;
     237                 :         12 :     m_nBoderGroupIDTop = rOther.m_nBoderGroupIDTop;
     238                 :         12 :     m_nBoderGroupIDBottom = rOther.m_nBoderGroupIDBottom;
     239                 :            : 
     240                 :         12 :     m_nGroupIndent = rOther.m_nGroupIndent;
     241                 :            : 
     242                 :         12 :     m_nWidthLeft = rOther.m_nWidthLeft;
     243                 :         12 :     m_nWidthTop = rOther.m_nWidthTop;
     244                 :         12 :     m_nWidthRight = rOther.m_nWidthRight;
     245                 :         12 :     m_nWidthBottom = rOther.m_nWidthBottom;
     246                 :            : 
     247                 :         12 :     m_aColorLeft = rOther.m_aColorLeft;
     248                 :         12 :     m_aColorRight = rOther.m_aColorRight;
     249                 :         12 :     m_aColorTop = rOther.m_aColorTop;
     250                 :         12 :     m_aColorBottom = rOther.m_aColorBottom;
     251                 :            : 
     252                 :         12 :     return *this;
     253                 :            : }
     254                 :            : 
     255                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10