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

Generated by: LCOV version 1.10