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

Generated by: LCOV version 1.11