LCOV - code coverage report
Current view: top level - libreoffice/lotuswordpro/source/filter/xfilter - xfframe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 88 65.9 %
Date: 2012-12-27 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 = sal_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(sal_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          17 : XFFrame::~XFFrame()
      90             : {
      91          17 : }
      92             : 
      93           4 : void    XFFrame::Add(IXFContent *pContent)
      94             : {
      95           4 :     XFContentContainer::Add(pContent);
      96           4 :     if( pContent->GetContentType() == enumXFContentFrame )
      97             :     {
      98           4 :         XFFrame *pFrame = (XFFrame*)pContent;
      99           4 :         if( pFrame )
     100             :         {
     101           4 :             pFrame->SetZIndex(pFrame->m_nZIndex + 1);
     102             :         }
     103             :     }
     104             : 
     105           4 : }
     106             : 
     107           4 : void    XFFrame::SetZIndex(sal_uInt32 zIndex)
     108             : {
     109           4 :     if( zIndex == m_nZIndex )
     110           4 :         return;
     111           4 :     m_nZIndex = zIndex;
     112           4 :     AdjustZIndex();
     113             : }
     114             : 
     115           0 : enumXFFrameType XFFrame::GetFrameType()
     116             : {
     117           0 :     return m_eType;
     118             : }
     119             : 
     120           4 : enumXFContent   XFFrame::GetContentType()
     121             : {
     122           4 :     return enumXFContentFrame;
     123             : }
     124             : 
     125          13 : void    XFFrame::ToXml(IXFStream *pStrm)
     126             : {
     127          13 :     StartFrame(pStrm);
     128             : 
     129          13 :     XFContentContainer::ToXml(pStrm);
     130             : 
     131          13 :     EndFrame(pStrm);
     132          13 : }
     133             : 
     134          13 : void    XFFrame::StartFrame(IXFStream *pStrm)
     135             : {
     136          13 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     137             : 
     138          13 :     if( !GetStyleName().isEmpty() )
     139          13 :         pAttrList->AddAttribute( A2OUSTR("draw:style-name"), GetStyleName() );
     140             : 
     141             :     assert(!m_strName.isEmpty());    //name should not be null.
     142          13 :     if( !m_strName.isEmpty() && m_isTextBox == sal_False)
     143          13 :         pAttrList->AddAttribute( A2OUSTR("draw:name"), m_strName );
     144             :     //anchor type:
     145          13 :     switch( m_eAnchor )
     146             :     {
     147             :     case enumXFAnchorPara:
     148           9 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("paragraph") );
     149           9 :         break;
     150             :     case enumXFAnchorPage:
     151           0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("page") );
     152           0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-page-number"), Int32ToOUString(m_nAnchorPage) );
     153           0 :         break;
     154             :     case enumXFAnchorChar:
     155           4 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("char") );
     156           4 :         break;
     157             :     case enumXFAnchorAsChar:
     158           0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("as-char") );
     159           0 :         break;
     160             :     case enumXFAnchorFrame:
     161           0 :         pAttrList->AddAttribute( A2OUSTR("text:anchor-type"), A2OUSTR("frame") );
     162           0 :         break;
     163             :     default:
     164           0 :         break;
     165             :     }
     166          13 :     pAttrList->AddAttribute( A2OUSTR("svg:x"), DoubleToOUString(m_aRect.GetX()) + A2OUSTR("cm") );
     167          13 :     pAttrList->AddAttribute( A2OUSTR("svg:y"), DoubleToOUString(m_aRect.GetY()) + A2OUSTR("cm") );
     168          13 :     pAttrList->AddAttribute( A2OUSTR("svg:width"), DoubleToOUString(m_aRect.GetWidth()) + A2OUSTR("cm") );
     169          13 :     if( m_nFlag& XFFRAME_FLAG_MINHEIGHT )
     170             :     {
     171           0 :         pAttrList->AddAttribute( A2OUSTR("fo:min-height"), DoubleToOUString(m_fMinHeight) + A2OUSTR("cm") );
     172           0 :         if( m_nFlag&XFFRAME_FLAG_MAXHEIGHT )
     173           0 :             pAttrList->AddAttribute( A2OUSTR("fo:max-height"), DoubleToOUString(m_fMaxHeight) + A2OUSTR("cm") );
     174             :     }
     175             :     else
     176          13 :         pAttrList->AddAttribute( A2OUSTR("svg:height"), DoubleToOUString(m_aRect.GetHeight()) + A2OUSTR("cm") );
     177             : 
     178          13 :     pAttrList->AddAttribute( A2OUSTR("draw:z-index"), Int32ToOUString(m_nZIndex) );
     179             : 
     180          13 :     if( !m_strNextLink.isEmpty() )
     181           0 :         pAttrList->AddAttribute( A2OUSTR("draw:chain-next-name"), m_strNextLink );
     182             : 
     183          13 :     pStrm->StartElement( A2OUSTR("draw:text-box") );
     184          13 : }
     185             : 
     186          13 : void    XFFrame::EndFrame(IXFStream *pStrm)
     187             : {
     188          13 :     pStrm->EndElement( A2OUSTR("draw:text-box") );
     189          13 : }
     190             : 
     191           4 : void    XFFrame::AdjustZIndex()
     192             : {
     193           4 :     for( int i=0; i<GetCount(); i++ )
     194             :     {
     195           0 :         IXFContent *pContent = GetContent(i);
     196           0 :         if( pContent )
     197             :         {
     198           0 :             if( pContent->GetContentType() == enumXFContentFrame )
     199             :             {
     200           0 :                 XFFrame *pFrame = (XFFrame*)pContent;
     201           0 :                 pFrame->m_nZIndex = m_nZIndex + 1;
     202           0 :                 pFrame->AdjustZIndex();
     203             :             }
     204             :         }
     205             :     }
     206           4 : }
     207             : 
     208             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10