bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / filter / ppt / pptatom.cxx
blob69d964a7dba77ac5f46d5beb37973bf9e0c630b9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <tools/stream.hxx>
21 #include "pptatom.hxx"
23 using namespace ppt;
25 Atom::Atom( const DffRecordHeader& rRecordHeader, SvStream& rStream )
26 : mrStream( rStream )
27 , maRecordHeader( rRecordHeader )
28 , mpFirstChild( 0 )
29 , mpNextAtom( 0 )
31 if( isContainer() )
33 if( seekToContent() )
35 DffRecordHeader aChildHeader;
37 Atom* pLastAtom = NULL;
39 // retrieve file size (to allow sanity checks)
40 const sal_Size nStreamPos = mrStream.Tell();
41 mrStream.Seek( STREAM_SEEK_TO_END );
42 const sal_Size nStreamSize = mrStream.Tell();
43 mrStream.Seek( nStreamPos );
45 while( (mrStream.GetError() == 0 )
46 && ( mrStream.Tell() < nStreamSize )
47 && ( mrStream.Tell() < maRecordHeader.GetRecEndFilePos() ) )
49 ReadDffRecordHeader( mrStream, aChildHeader );
51 if( mrStream.GetError() == 0 )
53 Atom* pAtom = new Atom( aChildHeader, mrStream );
55 if( pLastAtom )
56 pLastAtom->mpNextAtom = pAtom;
57 if( mpFirstChild == NULL )
58 mpFirstChild = pAtom;
60 pLastAtom = pAtom;
66 maRecordHeader.SeekToEndOfRecord( mrStream );
69 Atom::~Atom()
71 Atom* pChild = mpFirstChild;
72 while( pChild )
74 Atom* pNextChild = pChild->mpNextAtom;
75 delete pChild;
76 pChild = pNextChild;
80 /** imports this atom and its child atoms */
81 Atom* Atom::import( const DffRecordHeader& rRootRecordHeader, SvStream& rStCtrl )
83 Atom* pRootAtom = new Atom( rRootRecordHeader, rStCtrl );
85 if( rStCtrl.GetError() == 0 )
87 return pRootAtom;
89 else
91 delete pRootAtom;
92 return NULL;
96 /** returns the next child atom after pLast with nRecType or NULL */
97 const Atom* Atom::findNextChildAtom( sal_uInt16 nRecType, const Atom* pLast ) const
99 Atom* pChild = pLast != NULL ? pLast->mpNextAtom : mpFirstChild;
100 while( pChild && pChild->maRecordHeader.nRecType != nRecType )
102 pChild = pChild->mpNextAtom;
105 return pChild;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */