objects.h
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#ifndef LIBPPT_OBJECTS
21#define LIBPPT_OBJECTS
22
23#include "ustring.h"
24#include <string>
25
26
27namespace Libppt
28{
29
30class Color
31{
32public:
33 unsigned red, green, blue;
34 Color(){ red = green = blue = 0; }
35 Color( unsigned r, unsigned g, unsigned b )
36 { red = r; green = g; blue = b; }
37 Color( const Color& c )
38 { red = c.red; green = c.green; blue = c.blue; }
39 Color& operator=( const Color& c )
40 { red = c.red; green = c.green; blue = c.blue; return *this; }
41};
42
43class Object
44{
45public:
46 Object();
47 virtual ~Object();
48
49 int id() const;
50 void setId( int id );
51
52 virtual bool isText() const { return false; }
53 virtual bool isPicture() const { return false; }
54 virtual bool isGroup() const { return false; }
55 virtual bool isDrawing() const { return false; }
56
57 // all is in mm
58
59 double top() const;
60 double left() const;
61 double width() const;
62 double height() const;
63 void setTop( double top );
64 void setLeft( double left );
65 void setWidth( double width );
66 void setHeight( double height );
67
68 bool isBackground() const;
69 void setBackground( bool bg );
70
71
72 bool hasProperty( std::string name );
73
74 void setProperty( std::string name, int value );
75 void setProperty( std::string name, double value );
76 void setProperty( std::string name, std::string value );
77 void setProperty( std::string name, bool value );
78 void setProperty( std::string name, Color value );
79 void setProperty( std::string name, const char* value )
80 { setProperty( name, std::string(value) ); }
81
82 int getIntProperty( std::string name );
83 double getDoubleProperty( std::string name );
84 bool getBoolProperty( std::string name );
85 std::string getStrProperty( std::string name );
86 Color getColorProperty(std::string name);
87
88private:
89 // no copy or assign
90 Object( const Object& );
91 Object& operator=( const Object& );
92
93 class Private;
94 Private* d;
95};
96
97class TextObject: public Object
98{
99public:
100
101 enum {
102 Title = 0,
103 Body = 1,
104 Notes = 2,
105 NotUsed = 3,
106 Other = 4, // text in a shape
107 CenterBody = 5, // subtitle in title slide
108 CenterTitle = 6, // title in title slide
109 HalfBody = 7, // body in two-column slide
110 QuarterBody = 8 // body in four-body slide
111 };
112
113 TextObject();
114 virtual ~TextObject();
115 virtual bool isText() const { return true; }
116 unsigned type() const;
117 void setType( unsigned type );
118 const char* typeAsString() const;
119 UString text(unsigned index) const;
120 void setText( const UString& text );
121 unsigned listSize() const;
122 bool bulletFlag(unsigned index) const;
123 void setBulletFlag( bool flag ) ;
124 void convertFrom( Object* object );
125
126private:
127 // no copy or assign
128 TextObject( const TextObject& );
129 TextObject& operator=( const TextObject& );
130
131 class Private;
132 Private* d;
133};
134
135class GroupObject: public Object
136{
137public:
138 GroupObject();
139 virtual ~GroupObject();
140 virtual bool isGroup() const { return true; }
141 unsigned objectCount() const;
142 Object* object( unsigned index );
143 void addObject( Object* object );
144 void takeObject( Object* object );
145
146private:
147 // no copy or assign
148 GroupObject( const GroupObject& );
149 GroupObject& operator=( const GroupObject& );
150
151 class Private;
152 Private* d;
153
154};
155
156class DrawObject: public Object
157{
158public:
159
160 enum {
161 None = 0,
162 Rectangle,
163 RoundRectangle,
164 Circle,
165 Ellipse,
166 Diamond,
167 RightArrow,
168 LeftArrow,
169 UpArrow,
170 DownArrow,
171 IsoscelesTriangle,
172 RightTriangle,
173 Parallelogram,
174 Trapezoid,
175 Hexagon,
176 Octagon,
177 Line,
178 Smiley,
179 Heart,
180 FreeLine
181 };
182
183 DrawObject();
184 virtual ~DrawObject();
185 virtual bool isDrawing() const { return true; }
186
187 unsigned shape() const;
188 void setShape( unsigned s );
189
190 bool isVerFlip() const;
191 void setVerFlip( bool vFlip );
192 bool isHorFlip() const;
193 void setHorFlip( bool hFlip );
194
195private:
196 // no copy or assign
197 DrawObject( const DrawObject& );
198 DrawObject& operator=( const DrawObject& );
199
200 class Private;
201 Private* d;
202};
203
204}
205
206#endif /* LIBPPT_OBJECTS */
The body is a frameset.
Definition body.h:38