LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfframe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 88 65.9 %
Date: 2012-08-25 Functions: 9 12 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 86 33.7 %

           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 whose anchor is not page.
      59                 :            :  ************************************************************************/
      60                 :            : #include    "xfframe.hxx"
      61                 :            : #include    "xfparagraph.hxx"
      62                 :            : #define     ZINDEX_MAX 0x7fffffff
      63                 :            : #define     ZINDEX_MIN 0
      64                 :         95 : XFFrame::XFFrame()
      65                 :            : {
      66                 :         95 :     m_isTextBox = sal_False;
      67                 :         95 :     m_eAnchor = enumXFAnchorPara;
      68                 :         95 :     m_nAnchorPage = 0;
      69                 :         95 :     m_nZIndex = ZINDEX_MIN;
      70                 :            :     //give it a default name:
      71         [ +  - ]:         95 :     m_strName = XFGlobal::GenFrameName();
      72                 :         95 :     m_fMinHeight = 0;
      73                 :         95 :     m_fMaxHeight = 0;
      74                 :         95 :     m_nFlag = 0;
      75                 :         95 :     m_eType = enumXFFrameTextbox;
      76                 :         95 : }
      77                 :          0 : XFFrame::XFFrame(sal_Bool isTextBox):m_isTextBox(isTextBox)
      78                 :            : {
      79                 :          0 :     m_eAnchor = enumXFAnchorPara;
      80                 :          0 :     m_nAnchorPage = 0;
      81                 :          0 :     m_nZIndex = ZINDEX_MIN;
      82                 :            :     //give it a default name:
      83         [ #  # ]:          0 :     m_strName = XFGlobal::GenFrameName();
      84                 :          0 :     m_fMinHeight = 0;
      85                 :          0 :     m_fMaxHeight = 0;
      86                 :          0 :     m_nFlag = 0;
      87                 :          0 :     m_eType = enumXFFrameTextbox;
      88                 :          0 : }
      89                 :            : 
      90                 :         85 : XFFrame::~XFFrame()
      91                 :            : {
      92         [ -  + ]:         85 : }
      93                 :            : 
      94                 :         20 : void    XFFrame::Add(IXFContent *pContent)
      95                 :            : {
      96                 :         20 :     XFContentContainer::Add(pContent);
      97         [ +  - ]:         20 :     if( pContent->GetContentType() == enumXFContentFrame )
      98                 :            :     {
      99                 :         20 :         XFFrame *pFrame = (XFFrame*)pContent;
     100         [ +  - ]:         20 :         if( pFrame )
     101                 :            :         {
     102                 :         20 :             pFrame->SetZIndex(pFrame->m_nZIndex + 1);
     103                 :            :         }
     104                 :            :     }
     105                 :            : 
     106                 :         20 : }
     107                 :            : 
     108                 :         20 : void    XFFrame::SetZIndex(sal_uInt32 zIndex)
     109                 :            : {
     110         [ -  + ]:         20 :     if( zIndex == m_nZIndex )
     111                 :         20 :         return;
     112                 :         20 :     m_nZIndex = zIndex;
     113                 :         20 :     AdjustZIndex();
     114                 :            : }
     115                 :            : 
     116                 :          0 : enumXFFrameType XFFrame::GetFrameType()
     117                 :            : {
     118                 :          0 :     return m_eType;
     119                 :            : }
     120                 :            : 
     121                 :         20 : enumXFContent   XFFrame::GetContentType()
     122                 :            : {
     123                 :         20 :     return enumXFContentFrame;
     124                 :            : }
     125                 :            : 
     126                 :         65 : void    XFFrame::ToXml(IXFStream *pStrm)
     127                 :            : {
     128                 :         65 :     StartFrame(pStrm);
     129                 :            : 
     130                 :         65 :     XFContentContainer::ToXml(pStrm);
     131                 :            : 
     132                 :         65 :     EndFrame(pStrm);
     133                 :         65 : }
     134                 :            : 
     135                 :         65 : void    XFFrame::StartFrame(IXFStream *pStrm)
     136                 :            : {
     137                 :         65 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     138                 :            : 
     139         [ +  - ]:         65 :     if( !GetStyleName().isEmpty() )
     140         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("draw:style-name"), GetStyleName() );
     141                 :            : 
     142                 :            :     assert(!m_strName.isEmpty());    //name should not be null.
     143 [ +  - ][ +  - ]:         65 :     if( !m_strName.isEmpty() && m_isTextBox == sal_False)
                 [ +  - ]
     144         [ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("draw:name"), m_strName );
     145                 :            :     //anchor type:
     146   [ +  -  +  -  :         65 :     switch( m_eAnchor )
                   -  - ]
     147                 :            :     {
     148                 :            :     case enumXFAnchorPara:
     149         [ +  - ]:         45 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("paragraph") );
     150                 :         45 :         break;
     151                 :            :     case enumXFAnchorPage:
     152         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("page") );
     153         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-page-number"), Int32ToOUString(m_nAnchorPage) );
     154                 :          0 :         break;
     155                 :            :     case enumXFAnchorChar:
     156         [ +  - ]:         20 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("char") );
     157                 :         20 :         break;
     158                 :            :     case enumXFAnchorAsChar:
     159         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("as-char") );
     160                 :          0 :         break;
     161                 :            :     case enumXFAnchorFrame:
     162         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("frame") );
     163                 :          0 :         break;
     164                 :            :     default:
     165                 :          0 :         break;
     166                 :            :     }
     167 [ +  - ][ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("svg:x"), DoubleToOUString(m_aRect.GetX()) + A2OUSTR("cm") );
     168 [ +  - ][ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("svg:y"), DoubleToOUString(m_aRect.GetY()) + A2OUSTR("cm") );
     169 [ +  - ][ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("svg:width"), DoubleToOUString(m_aRect.GetWidth()) + A2OUSTR("cm") );
     170         [ -  + ]:         65 :     if( m_nFlag& XFFRAME_FLAG_MINHEIGHT )
     171                 :            :     {
     172 [ #  # ][ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("fo:min-height"), DoubleToOUString(m_fMinHeight) + A2OUSTR("cm") );
     173         [ #  # ]:          0 :         if( m_nFlag&XFFRAME_FLAG_MAXHEIGHT )
     174 [ #  # ][ #  # ]:          0 :             pAttrList->AddAttribute( A2OUSTR("fo:max-height"), DoubleToOUString(m_fMaxHeight) + A2OUSTR("cm") );
     175                 :            :     }
     176                 :            :     else
     177 [ +  - ][ +  - ]:         65 :         pAttrList->AddAttribute( A2OUSTR("svg:height"), DoubleToOUString(m_aRect.GetHeight()) + A2OUSTR("cm") );
     178                 :            : 
     179         [ +  - ]:         65 :     pAttrList->AddAttribute( A2OUSTR("draw:z-index"), Int32ToOUString(m_nZIndex) );
     180                 :            : 
     181         [ -  + ]:         65 :     if( !m_strNextLink.isEmpty() )
     182         [ #  # ]:          0 :         pAttrList->AddAttribute( A2OUSTR("draw:chain-next-name"), m_strNextLink );
     183                 :            : 
     184         [ +  - ]:         65 :     pStrm->StartElement( A2OUSTR("draw:text-box") );
     185                 :         65 : }
     186                 :            : 
     187                 :         65 : void    XFFrame::EndFrame(IXFStream *pStrm)
     188                 :            : {
     189         [ +  - ]:         65 :     pStrm->EndElement( A2OUSTR("draw:text-box") );
     190                 :         65 : }
     191                 :            : 
     192                 :         20 : void    XFFrame::AdjustZIndex()
     193                 :            : {
     194         [ -  + ]:         20 :     for( int i=0; i<GetCount(); i++ )
     195                 :            :     {
     196                 :          0 :         IXFContent *pContent = GetContent(i);
     197         [ #  # ]:          0 :         if( pContent )
     198                 :            :         {
     199         [ #  # ]:          0 :             if( pContent->GetContentType() == enumXFContentFrame )
     200                 :            :             {
     201                 :          0 :                 XFFrame *pFrame = (XFFrame*)pContent;
     202                 :          0 :                 pFrame->m_nZIndex = m_nZIndex + 1;
     203                 :          0 :                 pFrame->AdjustZIndex();
     204                 :            :             }
     205                 :            :         }
     206                 :            :     }
     207                 :         20 : }
     208                 :            : 
     209                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10