presentation.cpp
1/* libppt - library to read PowerPoint presentation
2 Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA
18*/
19
20#include "presentation.h"
21#include "slide.h"
22#include "powerpoint.h"
23
24#include <vector>
25
26using namespace Libppt;
27
28class Presentation::Private
29{
30public:
31 Slide* masterSlide;
32 std::vector<Slide*> slides;
33};
34
35Presentation::Presentation()
36{
37 d = new Private;
38 d->masterSlide = 0;
39}
40
41Presentation::~Presentation()
42{
43 clear();
44 delete d;
45}
46
47void Presentation::clear()
48{
49 // FIXME use iterator
50 for( unsigned i=0; i<slideCount(); i++ )
51 delete slide( i );
52 d->slides.clear();
53 delete d->masterSlide;
54 d->masterSlide = 0;
55}
56
57bool Presentation::load( const char* filename )
58{
59 PPTReader* reader = new PPTReader;
60 bool result = reader->load( this, filename );
61 delete reader;
62 return result;
63}
64
65void Presentation::appendSlide( Slide* slide )
66{
67 d->slides.push_back( slide );
68}
69
70unsigned Presentation::slideCount() const
71{
72 return d->slides.size();
73}
74
75Slide* Presentation::slide( unsigned index )
76{
77 if( index >= slideCount() ) return (Slide*)0;
78 return d->slides[index];
79}
80
81
82Slide* Presentation::masterSlide()
83{
84 return d->masterSlide;
85}
86
87void Presentation::setMasterSlide( Slide* masterSlide )
88{
89 delete d->masterSlide;
90 d->masterSlide = masterSlide;
91}