Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <tools/stream.hxx>
30 : : #include "pptatom.hxx"
31 : :
32 : : using namespace ppt;
33 : :
34 : 0 : Atom::Atom( const DffRecordHeader& rRecordHeader, SvStream& rStream )
35 : : : mrStream( rStream )
36 : : , maRecordHeader( rRecordHeader )
37 : : , mpFirstChild( 0 )
38 : 0 : , mpNextAtom( 0 )
39 : : {
40 [ # # ]: 0 : if( isContainer() )
41 : : {
42 [ # # ]: 0 : if( seekToContent() )
43 : : {
44 : 0 : DffRecordHeader aChildHeader;
45 : :
46 : 0 : Atom* pLastAtom = NULL;
47 : :
48 : : // retrieve file size (to allow sanity checks)
49 : 0 : const sal_Size nStreamPos = mrStream.Tell();
50 [ # # ]: 0 : mrStream.Seek( STREAM_SEEK_TO_END );
51 : 0 : const sal_Size nStreamSize = mrStream.Tell();
52 [ # # ]: 0 : mrStream.Seek( nStreamPos );
53 : :
54 [ # # # # : 0 : while( (mrStream.GetError() == 0 )
# # ][ # # ]
55 : 0 : && ( mrStream.Tell() < nStreamSize )
56 : 0 : && ( mrStream.Tell() < maRecordHeader.GetRecEndFilePos() ) )
57 : : {
58 [ # # ]: 0 : mrStream >> aChildHeader;
59 : :
60 [ # # ]: 0 : if( mrStream.GetError() == 0 )
61 : : {
62 [ # # ][ # # ]: 0 : Atom* pAtom = new Atom( aChildHeader, mrStream );
63 : :
64 [ # # ]: 0 : if( pLastAtom )
65 : 0 : pLastAtom->mpNextAtom = pAtom;
66 [ # # ]: 0 : if( mpFirstChild == NULL )
67 : 0 : mpFirstChild = pAtom;
68 : :
69 : 0 : pLastAtom = pAtom;
70 : : }
71 : : }
72 : : }
73 : : }
74 : :
75 : 0 : maRecordHeader.SeekToEndOfRecord( mrStream );
76 : 0 : }
77 : :
78 : 0 : Atom::~Atom()
79 : : {
80 : 0 : Atom* pChild = mpFirstChild;
81 [ # # ]: 0 : while( pChild )
82 : : {
83 : 0 : Atom* pNextChild = pChild->mpNextAtom;
84 [ # # ]: 0 : delete pChild;
85 : 0 : pChild = pNextChild;
86 : : }
87 : 0 : }
88 : :
89 : : /** imports this atom and its child atoms */
90 : 0 : Atom* Atom::import( const DffRecordHeader& rRootRecordHeader, SvStream& rStCtrl )
91 : : {
92 [ # # ]: 0 : Atom* pRootAtom = new Atom( rRootRecordHeader, rStCtrl );
93 : :
94 [ # # ]: 0 : if( rStCtrl.GetError() == 0 )
95 : : {
96 : 0 : return pRootAtom;
97 : : }
98 : : else
99 : : {
100 [ # # ]: 0 : delete pRootAtom;
101 : 0 : return NULL;
102 : : }
103 : : }
104 : :
105 : : /** returns the next child atom after pLast with nRecType or NULL */
106 : 0 : const Atom* Atom::findNextChildAtom( sal_uInt16 nRecType, const Atom* pLast ) const
107 : : {
108 [ # # ]: 0 : Atom* pChild = pLast != NULL ? pLast->mpNextAtom : mpFirstChild;
109 [ # # ][ # # ]: 0 : while( pChild && pChild->maRecordHeader.nRecType != nRecType )
[ # # ]
110 : : {
111 : 0 : pChild = pChild->mpNextAtom;
112 : : }
113 : :
114 : 0 : return pChild;
115 : : }
116 : :
117 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|