1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pptatom.cpp,v $
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 ************************************************************************/
32 #include <tools/stream.hxx>
36 #include "pptatom.hxx"
41 Atom::Atom( const DffRecordHeader
& rRecordHeader
, SvStream
& rStream
)
43 , maRecordHeader( rRecordHeader
)
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
);
64 pLastAtom
->mpNextAtom
= pAtom
;
65 if( mpFirstChild
== NULL
)
74 maRecordHeader
.SeekToEndOfRecord( mrStream
);
79 Atom
* pChild
= mpFirstChild
;
82 Atom
* pNextChild
= pChild
->mpNextAtom
;
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 )
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
;
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
);