LCOV - code coverage report
Current view: top level - sd/source/filter/ppt - pptatom.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 40 42 95.2 %
Date: 2014-11-03 Functions: 6 6 100.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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/stream.hxx>
      21             : #include "pptatom.hxx"
      22             : 
      23             : using namespace ppt;
      24             : 
      25       10214 : Atom::Atom( const DffRecordHeader& rRecordHeader, SvStream& rStream )
      26             : : mrStream( rStream )
      27             : , maRecordHeader( rRecordHeader )
      28             : , mpFirstChild( 0 )
      29       10214 : , mpNextAtom( 0 )
      30             : {
      31       10214 :     if( isContainer() )
      32             :     {
      33        3832 :         if( seekToContent() )
      34             :         {
      35        3832 :             DffRecordHeader aChildHeader;
      36             : 
      37        3832 :             Atom* pLastAtom = NULL;
      38             : 
      39             :             // retrieve file size (to allow sanity checks)
      40        3832 :             const sal_Size nStreamPos = mrStream.Tell();
      41        3832 :             mrStream.Seek( STREAM_SEEK_TO_END );
      42        3832 :             const sal_Size nStreamSize = mrStream.Tell();
      43        3832 :             mrStream.Seek( nStreamPos );
      44             : 
      45       31772 :             while( (mrStream.GetError() == 0 )
      46       13970 :                 && ( mrStream.Tell() < nStreamSize )
      47       27940 :                 && ( mrStream.Tell() < maRecordHeader.GetRecEndFilePos() ) )
      48             :             {
      49       10138 :                 ReadDffRecordHeader( mrStream, aChildHeader );
      50             : 
      51       10138 :                 if( mrStream.GetError() == 0 )
      52             :                 {
      53       10138 :                     Atom* pAtom = new Atom( aChildHeader, mrStream );
      54             : 
      55       10138 :                     if( pLastAtom )
      56        6726 :                         pLastAtom->mpNextAtom = pAtom;
      57       10138 :                     if( mpFirstChild == NULL )
      58        3412 :                         mpFirstChild = pAtom;
      59             : 
      60       10138 :                     pLastAtom = pAtom;
      61             :                 }
      62             :             }
      63             :         }
      64             :     }
      65             : 
      66       10214 :     maRecordHeader.SeekToEndOfRecord( mrStream );
      67       10214 : }
      68             : 
      69       10214 : Atom::~Atom()
      70             : {
      71       10214 :     Atom* pChild = mpFirstChild;
      72       30566 :     while( pChild )
      73             :     {
      74       10138 :         Atom* pNextChild = pChild->mpNextAtom;
      75       10138 :         delete pChild;
      76       10138 :         pChild = pNextChild;
      77             :     }
      78       10214 : }
      79             : 
      80             : /** imports this atom and its child atoms */
      81          76 : Atom* Atom::import( const DffRecordHeader& rRootRecordHeader, SvStream& rStCtrl )
      82             : {
      83          76 :     Atom* pRootAtom = new Atom( rRootRecordHeader, rStCtrl );
      84             : 
      85          76 :     if( rStCtrl.GetError() == 0 )
      86             :     {
      87          76 :         return pRootAtom;
      88             :     }
      89             :     else
      90             :     {
      91           0 :         delete pRootAtom;
      92           0 :         return NULL;
      93             :     }
      94             : }
      95             : 
      96             : /** returns the next child atom after pLast with nRecType or NULL */
      97        7086 : const Atom* Atom::findNextChildAtom( sal_uInt16 nRecType, const Atom* pLast ) const
      98             : {
      99        7086 :     Atom* pChild = pLast != NULL ? pLast->mpNextAtom : mpFirstChild;
     100       29092 :     while( pChild && pChild->maRecordHeader.nRecType != nRecType )
     101             :     {
     102       14920 :         pChild = pChild->mpNextAtom;
     103             :     }
     104             : 
     105        7086 :     return pChild;
     106          24 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10