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

Generated by: LCOV version 1.11