LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfframestyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 76 116 65.5 %
Date: 2012-08-25 Functions: 6 9 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 49 138 35.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                 :            :  * Frame style include position,size,rotation and so on.
      59                 :            :  ************************************************************************/
      60                 :            : #include    "xfframestyle.hxx"
      61                 :            : #include    "xfcolumns.hxx"
      62                 :            : #include    "xfborders.hxx"
      63                 :            : #include    "xfshadow.hxx"
      64                 :            : #include    "xfbgimage.hxx"
      65                 :            : 
      66 [ +  - ][ +  - ]:        155 : XFFrameStyle::XFFrameStyle()
      67                 :            : {
      68                 :        155 :     m_eWrap = enumXFWrapNone;
      69                 :        155 :     m_nWrapLines = 0;   //not limited.
      70                 :        155 :     m_pBorders = NULL;
      71                 :        155 :     m_pColumns = NULL;
      72                 :        155 :     m_pShadow = NULL;
      73                 :        155 :     m_pBGImage = NULL;
      74                 :            : 
      75                 :        155 :     m_bProtectContent = sal_False;
      76                 :        155 :     m_bProtectSize = sal_False;
      77                 :        155 :     m_bProtectPos = sal_False;
      78                 :        155 :     m_bEditable = sal_False;
      79                 :        155 :     m_bPrintable = sal_True;
      80                 :        155 :     m_bBackground = sal_False;
      81                 :        155 :     m_nTransparency = 0;
      82                 :            : 
      83                 :        155 :     m_eTextDir = enumXFTextDirNone;
      84                 :        155 :     m_eXPos = enumXFFrameXPosCenter;
      85                 :        155 :     m_eXRel = enumXFFrameXRelParaContent;
      86                 :        155 :     m_eYPos = enumXFFrameYPosTop;
      87                 :        155 :     m_eYRel = enumXFFrameYRelPage;
      88                 :        155 : }
      89                 :            : 
      90                 :        155 : XFFrameStyle::~XFFrameStyle()
      91                 :            : {
      92         [ +  + ]:        155 :     if( m_pBorders )
      93                 :         80 :         delete m_pBorders;
      94         [ -  + ]:        155 :     if( m_pColumns )
      95 [ #  # ][ #  # ]:          0 :         delete m_pColumns;
      96         [ -  + ]:        155 :     if( m_pShadow )
      97 [ #  # ][ #  # ]:          0 :         delete m_pShadow;
      98         [ -  + ]:        155 :     if( m_pBGImage )
      99 [ #  # ][ #  # ]:          0 :         delete m_pBGImage;
     100         [ -  + ]:        280 : }
     101                 :            : 
     102                 :         80 : void    XFFrameStyle::SetBorders(XFBorders *pBorders)
     103                 :            : {
     104         [ -  + ]:         80 :     if( m_pBorders )
     105                 :          0 :         delete m_pBorders;
     106                 :         80 :     m_pBorders = pBorders;
     107                 :         80 : }
     108                 :            : 
     109                 :          0 : void    XFFrameStyle::SetColumns(XFColumns *pColumns)
     110                 :            : {
     111         [ #  # ]:          0 :     if( m_pColumns )
     112         [ #  # ]:          0 :         delete m_pColumns;
     113                 :          0 :     m_pColumns = pColumns;
     114                 :          0 : }
     115                 :            : 
     116                 :          0 : void    XFFrameStyle::SetShadow(XFShadow *pShadow)
     117                 :            : {
     118         [ #  # ]:          0 :     if( m_pShadow )
     119         [ #  # ]:          0 :         delete m_pShadow;
     120                 :          0 :     m_pShadow = pShadow;
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : void    XFFrameStyle::SetBackImage(XFBGImage *image)
     124                 :            : {
     125         [ #  # ]:          0 :     if( m_pBGImage )
     126         [ #  # ]:          0 :         delete m_pBGImage;
     127                 :          0 :     m_pBGImage = image;
     128                 :          0 : }
     129                 :            : 
     130                 :       2325 : enumXFStyle XFFrameStyle::GetStyleFamily()
     131                 :            : {
     132                 :       2325 :     return enumXFStyleGraphics;
     133                 :            : }
     134                 :            : 
     135                 :         65 : void    XFFrameStyle::ToXml(IXFStream *pStrm)
     136                 :            : {
     137                 :         65 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     138                 :            : 
     139                 :         65 :     pAttrList->Clear();
     140         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("style:name"), GetStyleName() );
     141         [ -  + ]:         65 :     if( GetParentStyleName().getLength() > 0 )
     142         [ #  # ]:          0 :         pAttrList->AddAttribute(A2OUSTR("style:parent-style-name"),GetParentStyleName());
     143         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("style:family"), A2OUSTR("graphics") );
     144                 :            :     //parent style name ignore now.
     145         [ +  - ]:         65 :     pStrm->StartElement( A2OUSTR("style:style") );
     146                 :            : 
     147                 :         65 :     m_aMargins.ToXml(pStrm);
     148                 :            : 
     149                 :         65 :     pAttrList->Clear();
     150                 :            : 
     151                 :            :     /*if( m_eWrap == enumXFWrapBackground )
     152                 :            :     {
     153                 :            :         pAttrList->AddAttribute( A2OUSTR("style:run-through"), A2OUSTR("background") );
     154                 :            :     }
     155                 :            :     else
     156                 :            :     {*/
     157         [ -  + ]:         65 :     if( m_bBackground)
     158         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("style:run-through"), A2OUSTR("background") );
     159                 :            :     else
     160         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("style:run-through"), A2OUSTR("foreground") );
     161                 :            : 
     162         [ +  + ]:         65 :     if( m_eWrap == enumXFWrapNone )
     163         [ +  - ]:         40 :         pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("none") );
     164         [ -  + ]:         25 :     else if( m_eWrap == enumXFWrapLeft )
     165         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("left") );
     166         [ +  + ]:         25 :     else if( m_eWrap == enumXFWrapRight )
     167         [ +  - ]:         20 :         pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("right") );
     168         [ -  + ]:          5 :     else if( m_eWrap == enumXFWrapParallel )
     169         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("parallel") );
     170         [ +  - ]:          5 :     else if( m_eWrap == enumXFWrapRunThrough )
     171         [ +  - ]:          5 :         pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("run-through") );
     172         [ #  # ]:          0 :     else if( m_eWrap == enumXFWrapBest )
     173         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("dynamic") );
     174                 :            :     //}
     175                 :            :     //background
     176         [ +  - ]:         65 :     if( m_aBackColor.IsValid() )
     177                 :            :     {
     178         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("fo:background-color"), m_aBackColor.ToString() );
     179 [ +  - ][ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("style:background-transparency"), Int16ToOUString(m_nTransparency) + A2OUSTR("%"));
     180                 :            :     }
     181                 :            : 
     182                 :            :     //pad
     183                 :         65 :     m_aPad.ToXml(pStrm);
     184                 :            :     //margin:
     185                 :         65 :     m_aMargins.ToXml(pStrm);
     186                 :            :     //border
     187         [ +  + ]:         65 :     if( m_pBorders )
     188                 :         40 :         m_pBorders->ToXml(pStrm);
     189                 :            :     else
     190         [ +  - ]:         25 :         pAttrList->AddAttribute( A2OUSTR("fo:border"), A2OUSTR("none") );
     191                 :            :     //shadow
     192         [ -  + ]:         65 :     if( m_pShadow )
     193                 :          0 :         m_pShadow->ToXml(pStrm);
     194                 :            :     //print
     195         [ +  - ]:         65 :     if( m_bPrintable )
     196         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("style:print-content"), A2OUSTR("true") );
     197                 :            :     //text directory
     198         [ +  - ]:         65 :     if( m_eTextDir != enumXFTextDirNone )
     199         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("style:writing-mode"), GetTextDirName(m_eTextDir) );
     200                 :            :     //protect:
     201 [ +  - ][ +  - ]:         65 :     if( m_bProtectContent || m_bProtectSize || m_bProtectPos )
                 [ -  + ]
     202                 :            :     {
     203                 :          0 :         rtl::OUString protect;
     204         [ #  # ]:          0 :         if( m_bProtectContent )
     205                 :          0 :             protect += A2OUSTR("content");
     206         [ #  # ]:          0 :         if( m_bProtectSize )
     207                 :            :         {
     208         [ #  # ]:          0 :             if( protect.getLength()>0 )
     209                 :          0 :                 protect += A2OUSTR(" ");
     210                 :          0 :             protect += A2OUSTR("size");
     211                 :            :         }
     212         [ #  # ]:          0 :         if( m_bProtectPos )
     213                 :            :         {
     214         [ #  # ]:          0 :             if( protect.getLength()>0 )
     215                 :          0 :                 protect += A2OUSTR(" ");
     216                 :          0 :             protect += A2OUSTR("position");
     217                 :            :         }
     218         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("style:protect"), protect );
     219                 :            :     }
     220                 :            :     //vertical pos and horizon pos:
     221         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("style:vertical-pos"), GetFrameYPos(m_eYPos) );
     222         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("style:vertical-rel"), GetFrameYRel(m_eYRel) );
     223         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("style:horizontal-pos"), GetFrameXPos(m_eXPos) );
     224         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("style:horizontal-rel"), GetFrameXRel(m_eXRel) );
     225                 :            : 
     226                 :            :     //
     227         [ +  - ]:         65 :     pStrm->StartElement( A2OUSTR("style:properties") );
     228         [ -  + ]:         65 :     if( m_pColumns )
     229                 :          0 :         m_pColumns->ToXml(pStrm);
     230         [ -  + ]:         65 :     if( m_pBGImage )
     231                 :          0 :         m_pBGImage->ToXml(pStrm);
     232         [ +  - ]:         65 :     pStrm->EndElement( A2OUSTR("style:properties") );
     233                 :            : 
     234         [ +  - ]:         65 :     pStrm->EndElement( A2OUSTR("style:style") );
     235                 :         65 : }
     236                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10