LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpborderstuff.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 81 92 88.0 %
Date: 2014-11-03 Functions: 7 7 100.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             :  *
       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         196 : LwpBorderStuff::LwpBorderStuff()
      66             : {
      67         196 :     m_nSides = 0;
      68         196 :     m_nValid = 0;
      69             : 
      70         196 :     m_nBoderGroupIDLeft = 0;
      71         196 :     m_nBoderGroupIDRight = 0;
      72         196 :     m_nBoderGroupIDTop = 0;
      73         196 :     m_nBoderGroupIDBottom = 0;
      74             : 
      75         196 :     m_nGroupIndent = 0;
      76             : 
      77         196 :     m_nWidthLeft = 0;
      78         196 :     m_nWidthTop = 0;
      79         196 :     m_nWidthRight = 0;
      80         196 :     m_nWidthBottom = 0;
      81         196 : }
      82             : 
      83          48 : void    LwpBorderStuff::Read(LwpObjectStream *pStrm)
      84             : {
      85          48 :     m_nSides = pStrm->QuickReaduInt16();
      86          48 :     if( m_nSides&LEFT )
      87             :     {
      88          16 :         m_nBoderGroupIDLeft = pStrm->QuickReaduInt16();
      89          16 :         m_nWidthLeft = pStrm->QuickReadInt32();
      90          16 :         m_aColorLeft.Read(pStrm);
      91             : 
      92          16 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
      93             :         {
      94           0 :             pStrm->SeekRel(8);
      95             :         }
      96             :     }
      97             : 
      98          48 :     if( m_nSides&RIGHT )
      99             :     {
     100          16 :         m_nBoderGroupIDRight = pStrm->QuickReaduInt16();
     101          16 :         m_nWidthRight = pStrm->QuickReadInt32();
     102          16 :         m_aColorRight.Read(pStrm);
     103             : 
     104          16 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
     105             :         {
     106           0 :             pStrm->SeekRel(8);
     107             :         }
     108             :     }
     109             : 
     110          48 :     if( m_nSides&TOP )
     111             :     {
     112          32 :         m_nBoderGroupIDTop = pStrm->QuickReaduInt16();
     113          32 :         m_nWidthTop = pStrm->QuickReadInt32();
     114          32 :         m_aColorTop.Read(pStrm);
     115             : 
     116          32 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
     117             :         {
     118           0 :             pStrm->SeekRel(8);
     119             :         }
     120             :     }
     121             : 
     122          48 :     if( m_nSides&BOTTOM )
     123             :     {
     124          16 :         m_nBoderGroupIDBottom = pStrm->QuickReaduInt16();
     125          16 :         m_nWidthBottom = pStrm->QuickReadInt32();
     126          16 :         m_aColorBottom.Read(pStrm);
     127             : 
     128          16 :         if( LwpFileHeader::m_nFileRevision < 0x000b )
     129             :         {
     130           0 :             pStrm->SeekRel(8);
     131             :         }
     132             :     }
     133             : 
     134          48 :     m_nGroupIndent = pStrm->QuickReadInt32();
     135          48 :     m_nValid = pStrm->QuickReaduInt16();
     136          48 :     pStrm->SkipExtra();
     137             : 
     138          48 :     if( LwpFileHeader::m_nFileRevision < 0x0010 )
     139             :     {
     140          12 :         if( m_nBoderGroupIDLeft&EXTERNAL_ID )
     141             :         {
     142           0 :             m_nBoderGroupIDLeft = BGRP_SOLID;
     143             :         }
     144          12 :         if( m_nBoderGroupIDRight&EXTERNAL_ID )
     145             :         {
     146           0 :             m_nBoderGroupIDRight = BGRP_SOLID;
     147             :         }
     148          12 :         if( m_nBoderGroupIDTop&EXTERNAL_ID )
     149             :         {
     150           0 :             m_nBoderGroupIDTop = BGRP_SOLID;
     151             :         }
     152          12 :         if( m_nBoderGroupIDBottom&EXTERNAL_ID )
     153             :         {
     154           0 :             m_nBoderGroupIDBottom = BGRP_SOLID;
     155             :         }
     156             :     }
     157          48 : }
     158             : 
     159         680 : bool    LwpBorderStuff::HasSide(sal_uInt16 side)
     160             : {
     161         680 :     return (m_nSides & side) != 0;
     162             : }
     163             : 
     164         680 : sal_uInt16  LwpBorderStuff::GetSideType(sal_uInt16 side)
     165             : {
     166         680 :     switch(side)
     167             :     {
     168             :     case LEFT:
     169         170 :         return m_nBoderGroupIDLeft;
     170             :     case RIGHT:
     171         170 :         return m_nBoderGroupIDRight;
     172             :     case TOP:
     173         170 :         return m_nBoderGroupIDTop;
     174             :     case BOTTOM:
     175         170 :         return m_nBoderGroupIDBottom;
     176             :     }
     177             :     // FIXME: this is needed to avoid warning: control reaches end of non-void function
     178             :     //        a better solution would be to enum value for the parameter side
     179           0 :     return 0;
     180             : }
     181             : 
     182         696 : LwpColor    LwpBorderStuff::GetSideColor(sal_uInt16 side)
     183             : {
     184         696 :     switch(side)
     185             :     {
     186             :     case LEFT:
     187         170 :         return m_aColorLeft;
     188             :     case RIGHT:
     189         170 :         return m_aColorRight;
     190             :     case TOP:
     191         186 :         return m_aColorTop;
     192             :     case BOTTOM:
     193         170 :         return m_aColorBottom;
     194             :     }
     195             :     // FIXME: this is needed to avoid warning: control reaches end of non-void function
     196             :     //        a better solution would be to enum value for the parameter side
     197           0 :     return LwpColor();
     198             : }
     199             : 
     200         696 : float   LwpBorderStuff::GetSideWidth(sal_uInt16 side)
     201             : {
     202         696 :     switch(side)
     203             :     {
     204             :     case LEFT:
     205         170 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthLeft));
     206             :     case RIGHT:
     207         170 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthRight));
     208             :     case TOP:
     209         186 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthTop));
     210             :     case BOTTOM:
     211         170 :         return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthBottom));
     212             :     }
     213             :     // FIXME: this is needed to avoid warning: control reaches end of non-void function
     214             :     //        a better solution would be to enum value for the parameter side
     215           0 :     return 0;
     216             : }
     217             : 
     218           8 : LwpBorderStuff& LwpBorderStuff::operator = (const LwpBorderStuff& rOther)
     219             : {
     220           8 :     m_nSides = rOther.m_nSides;
     221           8 :     m_nValid = rOther.m_nValid;
     222             : 
     223           8 :     m_nBoderGroupIDLeft = rOther.m_nBoderGroupIDLeft;
     224           8 :     m_nBoderGroupIDRight = rOther.m_nBoderGroupIDRight;
     225           8 :     m_nBoderGroupIDTop = rOther.m_nBoderGroupIDTop;
     226           8 :     m_nBoderGroupIDBottom = rOther.m_nBoderGroupIDBottom;
     227             : 
     228           8 :     m_nGroupIndent = rOther.m_nGroupIndent;
     229             : 
     230           8 :     m_nWidthLeft = rOther.m_nWidthLeft;
     231           8 :     m_nWidthTop = rOther.m_nWidthTop;
     232           8 :     m_nWidthRight = rOther.m_nWidthRight;
     233           8 :     m_nWidthBottom = rOther.m_nWidthBottom;
     234             : 
     235           8 :     m_aColorLeft = rOther.m_aColorLeft;
     236           8 :     m_aColorRight = rOther.m_aColorRight;
     237           8 :     m_aColorTop = rOther.m_aColorTop;
     238           8 :     m_aColorBottom = rOther.m_aColorBottom;
     239             : 
     240           8 :     return *this;
     241             : }
     242             : 
     243             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10