summaryrefslogtreecommitdiffstats
path: root/filters/kpresenter/powerpoint/libppt/objects.h
blob: 823e2a75997561c217b0f188899b183e1f61f1ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* libppt - library to read PowerPoint presentation
   Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA
*/

#ifndef LIBPPT_OBJECTS
#define LIBPPT_OBJECTS

#include "ustring.h"
#include <string>


namespace Libppt
{

class Color
{
public:
  unsigned red, green, blue;
  Color(){ red = green = blue = 0; }
  Color( unsigned r, unsigned g, unsigned b )
    { red = r; green = g; blue = b; }
  Color( const Color& c )
    { red = c.red; green = c.green; blue = c.blue; }
  Color& operator=( const Color& c )
    { red = c.red; green = c.green; blue = c.blue; return *this; }
};

class Object
{
public:
  Object();
  virtual ~Object();

  int id() const;
  void setId( int id );

  virtual bool isText() const { return false; }
  virtual bool isPicture() const { return false; }
  virtual bool isGroup() const { return false; }
  virtual bool isDrawing() const { return false; }

  // all is in mm

  double top() const;
  double left() const;
  double width() const;
  double height() const;
  void setTop( double top );
  void setLeft( double left );
  void setWidth( double width );
  void setHeight( double height );

  bool isBackground() const;
  void setBackground( bool bg );
  

  bool hasProperty( std::string name );

  void setProperty( std::string name, int value );
  void setProperty( std::string name, double value );
  void setProperty( std::string name, std::string value );
  void setProperty( std::string name, bool value );  
  void setProperty( std::string name, Color value );
  void setProperty( std::string name, const char* value )
    { setProperty( name, std::string(value) ); }

  int getIntProperty( std::string name );
  double getDoubleProperty( std::string name );
  bool getBoolProperty( std::string name );
  std::string getStrProperty( std::string name );
  Color getColorProperty(std::string name); 

private:
  // no copy or assign
  Object( const Object& );
  Object& operator=( const Object& );
  
  class Private;
  Private* d;
};

class TextObject: public Object
{
public:

  enum { 
    Title       = 0, 
    Body        = 1, 
    Notes       = 2, 
    NotUsed     = 3,
    Other       = 4,  // text in a shape
    CenterBody  = 5,  // subtitle in title slide
    CenterTitle = 6,  // title in title slide
    HalfBody    = 7,  // body in two-column slide
    QuarterBody = 8   // body in four-body slide
  };

  TextObject();
  virtual ~TextObject();
  virtual bool isText() const { return true; }
  unsigned type() const;
  void setType( unsigned type );
  const char* typeAsString() const;
  UString text(unsigned index) const;
  void setText( const UString& text );
  unsigned listSize() const;
  bool bulletFlag(unsigned index) const;
  void setBulletFlag( bool flag ) ;
  void convertFrom( Object* object );

private:
  // no copy or assign
  TextObject( const TextObject& );
  TextObject& operator=( const TextObject& );
  
  class Private;
  Private* d;
};

class GroupObject: public Object
{
public:
  GroupObject();
  virtual ~GroupObject();
  virtual bool isGroup() const { return true; }
  unsigned objectCount() const;
  Object* object( unsigned index );
  void addObject( Object* object );
  void takeObject( Object* object );

private:
  // no copy or assign
  GroupObject( const GroupObject& );
  GroupObject& operator=( const GroupObject& );
  
  class Private;
  Private* d;

};

class DrawObject: public Object
{
public:

  enum {
    None = 0,
    Rectangle,
    RoundRectangle,
    Circle,
    Ellipse,
    Diamond,
    RightArrow,
    LeftArrow,
    UpArrow,
    DownArrow, 
    IsoscelesTriangle,
    RightTriangle,
    Parallelogram,
    Trapezoid,
    Hexagon,
    Octagon,
    Line,
    Smiley,
    Heart,
    FreeLine
  };

  DrawObject();
  virtual ~DrawObject();
  virtual bool isDrawing() const { return true; }
   
  unsigned shape() const;
  void setShape( unsigned s );

  bool isVerFlip() const;
  void setVerFlip( bool vFlip );
  bool isHorFlip() const;
  void setHorFlip( bool hFlip );  

private:
  // no copy or assign
  DrawObject( const DrawObject& );
  DrawObject& operator=( const DrawObject& );
  
  class Private;
  Private* d;
};

}

#endif /* LIBPPT_OBJECTS */