bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / filter / ppt / pptatom.cxx
blob90e61e738ffb4ded30aea1d3ca6d9d7ad63ebb45
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( nullptr )
29 , mpNextAtom( nullptr )
31 if( isContainer() )
33 if( seekToContent() )
35 DffRecordHeader aChildHeader;
37 Atom* pLastAtom = nullptr;
39 // retrieve file size (to allow sanity checks)
40 sal_uInt64 const nStreamSize = mrStream.TellEnd();
42 while( (mrStream.GetError() == ERRCODE_NONE )
43 && ( mrStream.Tell() < nStreamSize )
44 && ( mrStream.Tell() < maRecordHeader.GetRecEndFilePos() ) )
46 ReadDffRecordHeader( mrStream, aChildHeader );
48 if( mrStream.GetError() == ERRCODE_NONE )
50 Atom* pAtom = new Atom( aChildHeader, mrStream );
52 if( pLastAtom )
53 pLastAtom->mpNextAtom = pAtom;
54 if( mpFirstChild == nullptr )
55 mpFirstChild = pAtom;
57 pLastAtom = pAtom;
63 maRecordHeader.SeekToEndOfRecord( mrStream );
66 Atom::~Atom()
68 Atom* pChild = mpFirstChild;
69 while( pChild )
71 Atom* pNextChild = pChild->mpNextAtom;
72 delete pChild;
73 pChild = pNextChild;
77 /** imports this atom and its child atoms */
78 Atom* Atom::import( const DffRecordHeader& rRootRecordHeader, SvStream& rStCtrl )
80 Atom* pRootAtom = new Atom( rRootRecordHeader, rStCtrl );
82 if( rStCtrl.GetError() == ERRCODE_NONE )
84 return pRootAtom;
86 else
88 delete pRootAtom;
89 return nullptr;
93 /** returns the next child atom after pLast with nRecType or NULL */
94 const Atom* Atom::findNextChildAtom( sal_uInt16 nRecType, const Atom* pLast ) const
96 Atom* pChild = pLast != nullptr ? pLast->mpNextAtom : mpFirstChild;
97 while( pChild && pChild->maRecordHeader.nRecType != nRecType )
99 pChild = pChild->mpNextAtom;
102 return pChild;
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */