LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfcellstyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 87 126 69.0 %
Date: 2012-08-25 Functions: 8 10 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 74 170 43.5 %

           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                 :            :  * Table cell style. Number format, string value, and so on...
      59                 :            :  ************************************************************************/
      60                 :            : #include    "xfcellstyle.hxx"
      61                 :            : #include    "xfborders.hxx"
      62                 :            : #include    "xffont.hxx"
      63                 :            : #include    "xfbgimage.hxx"
      64                 :            : 
      65                 :            : 
      66 [ +  - ][ +  - ]:        375 : XFCellStyle::XFCellStyle()
                 [ +  - ]
      67                 :            : {
      68                 :        375 :     m_eHoriAlign = enumXFAlignNone;
      69                 :        375 :     m_eVertAlign = enumXFAlignNone;
      70                 :        375 :     m_fTextIndent = 0;
      71                 :        375 :     m_pBorders = NULL;
      72                 :        375 :     m_pFont = NULL;
      73                 :        375 :     m_pBackImage = NULL;
      74                 :        375 :     m_bWrapText = sal_False;
      75                 :        375 : }
      76                 :            : 
      77         [ +  - ]:        375 : XFCellStyle::~XFCellStyle()
      78                 :            : {
      79         [ +  + ]:        375 :     if( m_pBorders )
      80                 :         95 :         delete m_pBorders;
      81         [ -  + ]:        750 : }
      82                 :            : 
      83                 :        375 : void XFCellStyle::SetPadding(double left, double right,double top, double bottom)
      84                 :            : {
      85         [ +  - ]:        375 :     if( left != -1 )
      86                 :        375 :         m_aPadding.SetLeft(left);
      87         [ +  - ]:        375 :     if( right != -1 )
      88                 :        375 :         m_aPadding.SetRight(right);
      89         [ +  - ]:        375 :     if( top != -1 )
      90                 :        375 :         m_aPadding.SetTop(top);
      91         [ +  - ]:        375 :     if( bottom != -1 )
      92                 :        375 :         m_aPadding.SetBottom( bottom );
      93                 :        375 : }
      94                 :            : 
      95                 :          0 : void    XFCellStyle::SetBackColor(XFColor& color)
      96                 :            : {
      97                 :          0 :     m_aBackColor = color;
      98                 :          0 : }
      99                 :            : 
     100                 :          0 : void    XFCellStyle::SetBackImage(XFBGImage *pImage)
     101                 :            : {
     102         [ #  # ]:          0 :     if( m_pBackImage )
     103         [ #  # ]:          0 :         delete m_pBackImage;
     104                 :          0 :     m_pBackImage = pImage;
     105                 :          0 : }
     106                 :            : 
     107                 :         95 : void    XFCellStyle::SetBorders(XFBorders *pBorders)
     108                 :            : {
     109         [ -  + ]:         95 :     if( m_pBorders )
     110                 :          0 :         delete m_pBorders;
     111                 :         95 :     m_pBorders = pBorders;
     112                 :         95 : }
     113                 :            : 
     114                 :       7435 : enumXFStyle XFCellStyle::GetStyleFamily()
     115                 :            : {
     116                 :       7435 :     return enumXFStyleTableCell;
     117                 :            : }
     118                 :            : 
     119                 :            : /**
     120                 :            :  *Affirm whether two XFCellStyle objects are equal.
     121                 :            :  */
     122                 :       1060 : sal_Bool    XFCellStyle::Equal(IXFStyle *pStyle)
     123                 :            : {
     124         [ -  + ]:       1060 :     if( this == pStyle )
     125                 :          0 :         return sal_True;
     126 [ +  - ][ -  + ]:       1060 :     if( !pStyle || pStyle->GetStyleFamily() != enumXFStyleTableCell )
                 [ -  + ]
     127                 :          0 :         return sal_False;
     128                 :            : 
     129                 :       1060 :     XFCellStyle *pOther = static_cast<XFCellStyle*>(pStyle);
     130         [ -  + ]:       1060 :     if( !pOther )
     131                 :          0 :         return sal_False;
     132                 :            : 
     133         [ +  + ]:       1060 :     if( m_strDataStyle != pOther->m_strDataStyle )
     134                 :        405 :         return sal_False;
     135                 :            : 
     136         [ -  + ]:        655 :     if( m_strParentStyleName != pOther->m_strParentStyleName )
     137                 :          0 :         return sal_False;
     138         [ -  + ]:        655 :     if( m_fTextIndent != pOther->m_fTextIndent )
     139                 :          0 :         return sal_False;
     140                 :            : 
     141                 :            :     //align:
     142         [ -  + ]:        655 :     if( m_eHoriAlign != pOther->m_eHoriAlign )
     143                 :          0 :         return sal_False;
     144         [ -  + ]:        655 :     if( m_eVertAlign != pOther->m_eVertAlign )
     145                 :          0 :         return sal_False;
     146                 :            : 
     147         [ -  + ]:        655 :     if( m_aBackColor != pOther->m_aBackColor )
     148                 :          0 :         return sal_False;
     149                 :            :     //shadow:
     150         [ -  + ]:        655 :     if( m_aShadow != pOther->m_aShadow )
     151                 :          0 :         return sal_False;
     152                 :            :     //margin:
     153         [ -  + ]:        655 :     if( m_aMargin != pOther->m_aMargin )
     154                 :          0 :         return sal_False;
     155                 :            :     //padding:
     156         [ +  + ]:        655 :     if( m_aPadding != pOther->m_aPadding )
     157                 :        240 :         return sal_False;
     158                 :            : 
     159                 :            :     //wrap:
     160         [ -  + ]:        415 :     if( m_bWrapText != pOther->m_bWrapText )
     161                 :          0 :         return sal_False;
     162                 :            : 
     163                 :            :     //font:
     164         [ -  + ]:        415 :     if( m_pFont )
     165                 :            :     {
     166         [ #  # ]:          0 :         if( !pOther->m_pFont )
     167                 :          0 :             return sal_False;
     168         [ #  # ]:          0 :         if(*m_pFont != *pOther->m_pFont )
     169                 :          0 :             return sal_False;
     170                 :            :     }
     171         [ -  + ]:        415 :     else if( pOther->m_pFont )
     172                 :          0 :         return sal_False;
     173                 :            : 
     174                 :            :     //border:
     175         [ +  + ]:        415 :     if( m_pBorders )
     176                 :            :     {
     177         [ -  + ]:        165 :         if( !pOther->m_pBorders )
     178                 :          0 :             return sal_False;
     179         [ +  + ]:        165 :         if( *m_pBorders != *pOther->m_pBorders )
     180                 :        150 :             return sal_False;
     181                 :            :     }
     182         [ +  + ]:        250 :     else if( pOther->m_pBorders )
     183                 :         40 :         return sal_False;
     184                 :            : 
     185                 :            :     //if there is backimage
     186         [ -  + ]:        225 :     if( m_pBackImage )
     187                 :            :     {
     188         [ #  # ]:          0 :         if( !pOther->m_pBackImage )
     189                 :          0 :             return sal_False;
     190         [ #  # ]:          0 :         if( !m_pBackImage->Equal(pOther) )
     191                 :          0 :             return sal_False;
     192                 :            :     }
     193                 :            :     else
     194                 :            :     {
     195         [ -  + ]:        225 :         if( pOther->m_pBackImage )
     196                 :          0 :             return sal_False;
     197                 :            :     }
     198                 :            : 
     199                 :       1060 :     return sal_True;
     200                 :            : }
     201                 :            : 
     202                 :        110 : void XFCellStyle::ToXml(IXFStream *pStrm)
     203                 :            : {
     204         [ +  - ]:        110 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     205         [ +  - ]:        110 :     rtl::OUString style = GetStyleName();
     206                 :            : 
     207         [ +  - ]:        110 :     pAttrList->Clear();
     208         [ +  - ]:        110 :     if( !style.isEmpty() )
     209 [ +  - ][ +  - ]:        110 :         pAttrList->AddAttribute(A2OUSTR("style:name"),GetStyleName());
     210 [ +  - ][ -  + ]:        110 :     if( !GetParentStyleName().isEmpty() )
     211 [ #  # ][ #  # ]:          0 :         pAttrList->AddAttribute(A2OUSTR("style:parent-style-name"),GetParentStyleName());
     212                 :            : 
     213         [ +  - ]:        110 :     pAttrList->AddAttribute(A2OUSTR("style:family"), A2OUSTR("table-cell"));
     214         [ -  + ]:        110 :     if( !m_strParentStyleName.isEmpty() )
     215         [ #  # ]:          0 :         pAttrList->AddAttribute(A2OUSTR("style:parent-style-name"),m_strParentStyleName);
     216         [ +  + ]:        110 :     if( !m_strDataStyle.isEmpty() )
     217         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("style:data-style-name"), m_strDataStyle );
     218                 :            : 
     219         [ +  - ]:        110 :     pStrm->StartElement(A2OUSTR("style:style"));
     220                 :            : 
     221                 :            :     //Paragraph properties:
     222         [ +  - ]:        110 :     pAttrList->Clear();
     223                 :            : 
     224                 :            :     //text indent:
     225         [ -  + ]:        110 :     if( m_fTextIndent>FLOAT_MIN )
     226                 :            :     {
     227 [ #  # ][ #  # ]:          0 :         pAttrList->AddAttribute(A2OUSTR("fo:text-indent"), DoubleToOUString(m_fTextIndent) + A2OUSTR("cm") );
     228                 :            :     }
     229                 :            :     //padding:
     230         [ +  - ]:        110 :     m_aPadding.ToXml(pStrm);
     231                 :            :     //margin:
     232         [ +  - ]:        110 :     m_aMargin.ToXml(pStrm);
     233                 :            : 
     234                 :            :     //text horizontal align:
     235         [ -  + ]:        110 :     if( m_eHoriAlign != enumXFAlignNone )
     236                 :            :     {
     237 [ #  # ][ #  # ]:          0 :         pAttrList->AddAttribute(A2OUSTR("fo:text-align"), GetAlignName(m_eHoriAlign) );
     238                 :            :     }
     239                 :            :     //text vertical align
     240         [ +  - ]:        110 :     if( m_eVertAlign != enumXFAlignNone )
     241 [ +  - ][ +  - ]:        110 :         pAttrList->AddAttribute( A2OUSTR("fo:vertical-align"), GetAlignName(m_eVertAlign) );
     242                 :            : 
     243                 :            :     //wrap text:
     244         [ -  + ]:        110 :     if( m_bWrapText )
     245         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("fo:wrap-option"), A2OUSTR("wrap") );
     246                 :            : 
     247                 :            :     //shadow:
     248         [ +  - ]:        110 :     m_aShadow.ToXml(pStrm);
     249                 :            :     //borders:
     250         [ +  + ]:        110 :     if( m_pBorders )
     251         [ +  - ]:         60 :         m_pBorders->ToXml(pStrm);
     252                 :            : 
     253                 :            :     //background color:
     254 [ -  + ][ #  # ]:        110 :     if( m_aBackColor.IsValid() && !m_pBackImage )
                 [ -  + ]
     255                 :            :     {
     256 [ #  # ][ #  # ]:          0 :         pAttrList->AddAttribute(A2OUSTR("fo:background-color"), m_aBackColor.ToString() );
     257                 :            :     }
     258                 :            :     //Font properties:
     259         [ -  + ]:        110 :     if( m_pFont )
     260         [ #  # ]:          0 :         m_pFont->ToXml(pStrm);
     261                 :            : 
     262         [ +  - ]:        110 :     pStrm->StartElement(A2OUSTR("style:properties"));
     263                 :            : 
     264         [ -  + ]:        110 :     if( m_pBackImage )
     265         [ #  # ]:          0 :         m_pBackImage->ToXml(pStrm);
     266                 :            : 
     267         [ +  - ]:        110 :     pStrm->EndElement(A2OUSTR("style:properties"));
     268                 :            : 
     269         [ +  - ]:        110 :     pStrm->EndElement(A2OUSTR("style:style"));
     270                 :        110 : }
     271                 :            : 
     272                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10