LCOV - code coverage report
Current view: top level - libreoffice/lotuswordpro/source/filter/xfilter - xfcontentcontainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 85 34.1 %
Date: 2012-12-27 Functions: 8 16 50.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             :  * Container for content.It will destroy all children when destroy.
      59             :  ************************************************************************/
      60             : #include    "xfcontentcontainer.hxx"
      61             : #include    "xftextcontent.hxx"
      62             : 
      63         263 : XFContentContainer::XFContentContainer()
      64             : {
      65         263 : }
      66             : 
      67           0 : XFContentContainer::XFContentContainer(const XFContentContainer& other):XFContent(other)
      68             : {
      69           0 :     std::vector<IXFContent*>::const_iterator it;
      70             : 
      71           0 :     for( it = other.m_aContents.begin(); it != other.m_aContents.end(); ++it )
      72             :     {
      73           0 :         IXFContent *pContent = *it;
      74           0 :         if( pContent )
      75             :         {
      76           0 :             IXFContent *pClone = pContent->Clone();
      77           0 :             if( pClone )
      78           0 :                 Add(pClone);
      79             :         }
      80             :     }
      81           0 : }
      82             : 
      83           0 : XFContentContainer& XFContentContainer::operator=(const XFContentContainer& other)
      84             : {
      85           0 :     std::vector<IXFContent*>::const_iterator it;
      86             : 
      87           0 :     for( it = other.m_aContents.begin(); it != other.m_aContents.end(); ++it )
      88             :     {
      89           0 :         IXFContent *pContent = *it;
      90           0 :         if( pContent )
      91             :         {
      92           0 :             IXFContent *pClone = pContent->Clone();
      93           0 :             if( pClone )
      94           0 :                 Add(pClone);
      95             :         }
      96             :     }
      97           0 :     return *this;
      98             : }
      99             : 
     100         526 : XFContentContainer::~XFContentContainer()
     101             : {
     102         260 :     std::vector<IXFContent*>::iterator it;
     103             : 
     104         688 :     for( it = m_aContents.begin(); it != m_aContents.end(); ++it )
     105             :     {
     106         428 :         IXFContent *pContent = *it;
     107         428 :         delete pContent;
     108             :     }
     109         266 : }
     110             : 
     111         429 : void    XFContentContainer::Add(IXFContent *pContent)
     112             : {
     113         429 :     m_aContents.push_back(pContent);
     114         429 : }
     115             : 
     116           0 : void XFContentContainer::InsertAtBegin(IXFContent * pContent)
     117             : {
     118           0 :     m_aContents.insert(m_aContents.begin(), pContent);
     119           0 : }
     120           0 : void XFContentContainer::RemoveAt(sal_uInt32 nPos)
     121             : {
     122           0 :     m_aContents.erase(m_aContents.begin()+nPos);
     123           0 : }
     124           0 : void    XFContentContainer::Add(const rtl::OUString& text)
     125             : {
     126           0 :     XFTextContent *pTC = new XFTextContent();
     127           0 :     pTC->SetText(text);
     128           0 :     Add(pTC);
     129           0 : }
     130             : 
     131          18 : int     XFContentContainer::GetCount() const
     132             : {
     133          18 :     return m_aContents.size();
     134             : }
     135             : 
     136           0 : void    XFContentContainer::Reset()
     137             : {
     138           0 :     std::vector<IXFContent*>::iterator it;
     139             : 
     140           0 :     for( it = m_aContents.begin(); it != m_aContents.end(); ++it )
     141             :     {
     142           0 :         IXFContent *pContent = *it;
     143           0 :         if( pContent )
     144           0 :             delete pContent;
     145             :     }
     146           0 :     m_aContents.clear();
     147           0 : }
     148             : 
     149             : 
     150           0 : IXFContent* XFContentContainer::FindFirstContent(enumXFContent type)
     151             : {
     152           0 :     IXFContent *pRet = NULL;
     153           0 :     IXFContent  *pContent = NULL;
     154             : 
     155           0 :     for( int i=0; i<GetCount(); i++ )
     156             :     {
     157           0 :         pContent = GetContent(i);
     158           0 :         if( !pContent )
     159           0 :             continue;
     160             : 
     161           0 :         enumXFContent eType = pContent->GetContentType();
     162           0 :         if( eType == type )
     163           0 :             return pContent;
     164             :         else
     165             :         {
     166           0 :             XFContentContainer *pChildCont = static_cast<XFContentContainer*>(pContent);
     167           0 :             if( pChildCont )
     168             :             {
     169           0 :                 pRet = pChildCont->FindFirstContent(type);
     170           0 :                 if( pRet )
     171           0 :                     return pRet;
     172             :             }
     173             :         }
     174             :     }
     175           0 :     return pRet;
     176             : }
     177             : 
     178           0 : enumXFContent   XFContentContainer::GetContentType()
     179             : {
     180           0 :     return enumXFContentContainer;
     181             : }
     182             : 
     183         223 : void    XFContentContainer::ToXml(IXFStream *pStrm)
     184             : {
     185         223 :     std::vector<IXFContent*>::iterator it;
     186             : 
     187         631 :     for( it = m_aContents.begin(); it != m_aContents.end(); ++it )
     188             :     {
     189         408 :         IXFContent *pContent = *it;
     190         408 :         if( pContent )
     191         408 :             pContent->ToXml(pStrm);
     192             :     }
     193         223 : }
     194             : 
     195           1 : IXFContent* XFContentContainer::GetLastContent()
     196             : {
     197           1 :     sal_uInt32 index = m_aContents.size()-1;
     198           1 :     if(index >0)
     199             :     {
     200           1 :         return m_aContents[index];
     201             :     }
     202             : 
     203           0 :     return NULL;
     204             : }
     205             : 
     206           1 : void XFContentContainer::RemoveLastContent()
     207             : {
     208           1 :     sal_uInt32 index = m_aContents.size()-1;
     209           1 :     if(index >0)
     210             :     {
     211           1 :         m_aContents.erase(m_aContents.begin() + index);
     212             :     }
     213           1 : }
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10