merge the formfield patch from ooo-build
[ooovba.git] / sd / source / filter / ppt / pptatom.cpp
blobd5198980ef7866b02dfb5b689518b6b060b5001e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pptatom.cpp,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _STREAM_HXX
32 #include <tools/stream.hxx>
33 #endif
35 #ifndef _PPTATOM_HXX_
36 #include "pptatom.hxx"
37 #endif
39 using namespace ppt;
41 Atom::Atom( const DffRecordHeader& rRecordHeader, SvStream& rStream )
42 : mrStream( rStream )
43 , maRecordHeader( rRecordHeader )
44 , mpFirstChild( 0 )
45 , mpNextAtom( 0 )
47 if( isContainer() )
49 if( seekToContent() )
51 DffRecordHeader aChildHeader;
53 Atom* pLastAtom = NULL;
55 while( (mrStream.GetError() == 0 ) && ( mrStream.Tell() < maRecordHeader.GetRecEndFilePos() ) )
57 mrStream >> aChildHeader;
59 if( mrStream.GetError() == 0 )
61 Atom* pAtom = new Atom( aChildHeader, mrStream );
63 if( pLastAtom )
64 pLastAtom->mpNextAtom = pAtom;
65 if( mpFirstChild == NULL )
66 mpFirstChild = pAtom;
68 pLastAtom = pAtom;
74 maRecordHeader.SeekToEndOfRecord( mrStream );
77 Atom::~Atom()
79 Atom* pChild = mpFirstChild;
80 while( pChild )
82 Atom* pNextChild = pChild->mpNextAtom;
83 delete pChild;
84 pChild = pNextChild;
88 /** imports this atom and its child atoms */
89 Atom* Atom::import( const DffRecordHeader& rRootRecordHeader, SvStream& rStCtrl )
91 Atom* pRootAtom = new Atom( rRootRecordHeader, rStCtrl );
93 if( rStCtrl.GetError() == 0 )
95 return pRootAtom;
97 else
99 delete pRootAtom;
100 return NULL;
104 /** returns the next child atom after pLast with nRecType or NULL */
105 const Atom* Atom::findNextChildAtom( sal_uInt16 nRecType, const Atom* pLast ) const
107 Atom* pChild = pLast != NULL ? pLast->mpNextAtom : mpFirstChild;
108 while( pChild && pChild->maRecordHeader.nRecType != nRecType )
110 pChild = pChild->mpNextAtom;
113 return pChild;
116 /** returns the next child atom after pLast with nRecType and nRecInstance or NULL */
117 const Atom* Atom::findNextChildAtom( sal_uInt16 nRecType, sal_uInt16 nRecInstance, const Atom* pLast ) const
119 const Atom* pChild = pLast != NULL ? pLast->mpNextAtom : mpFirstChild;
120 while( pChild && (pChild->maRecordHeader.nRecType != nRecType) && (pChild->maRecordHeader.nRecInstance != nRecInstance) )
122 pChild = findNextChildAtom( pChild );
125 return pChild;