filters

objects.h

00001 /* libppt - library to read PowerPoint presentation
00002    Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008    
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA
00018 */
00019 
00020 #ifndef LIBPPT_OBJECTS
00021 #define LIBPPT_OBJECTS
00022 
00023 #include "ustring.h"
00024 #include <string>
00025 
00026 
00027 namespace Libppt
00028 {
00029 
00030 class Color
00031 {
00032 public:
00033   unsigned red, green, blue;
00034   Color(){ red = green = blue = 0; }
00035   Color( unsigned r, unsigned g, unsigned b )
00036     { red = r; green = g; blue = b; }
00037   Color( const Color& c )
00038     { red = c.red; green = c.green; blue = c.blue; }
00039   Color& operator=( const Color& c )
00040     { red = c.red; green = c.green; blue = c.blue; return *this; }
00041 };
00042 
00043 class Object
00044 {
00045 public:
00046   Object();
00047   virtual ~Object();
00048 
00049   int id() const;
00050   void setId( int id );
00051 
00052   virtual bool isText() const { return false; }
00053   virtual bool isPicture() const { return false; }
00054   virtual bool isGroup() const { return false; }
00055   virtual bool isDrawing() const { return false; }
00056 
00057   // all is in mm
00058 
00059   double top() const;
00060   double left() const;
00061   double width() const;
00062   double height() const;
00063   void setTop( double top );
00064   void setLeft( double left );
00065   void setWidth( double width );
00066   void setHeight( double height );
00067 
00068   bool isBackground() const;
00069   void setBackground( bool bg );
00070   
00071 
00072   bool hasProperty( std::string name );
00073 
00074   void setProperty( std::string name, int value );
00075   void setProperty( std::string name, double value );
00076   void setProperty( std::string name, std::string value );
00077   void setProperty( std::string name, bool value );  
00078   void setProperty( std::string name, Color value );
00079   void setProperty( std::string name, const char* value )
00080     { setProperty( name, std::string(value) ); }
00081 
00082   int getIntProperty( std::string name );
00083   double getDoubleProperty( std::string name );
00084   bool getBoolProperty( std::string name );
00085   std::string getStrProperty( std::string name );
00086   Color getColorProperty(std::string name); 
00087 
00088 private:
00089   // no copy or assign
00090   Object( const Object& );
00091   Object& operator=( const Object& );
00092   
00093   class Private;
00094   Private* d;
00095 };
00096 
00097 class TextObject: public Object
00098 {
00099 public:
00100 
00101   enum { 
00102     Title       = 0, 
00103     Body        = 1, 
00104     Notes       = 2, 
00105     NotUsed     = 3,
00106     Other       = 4,  // text in a shape
00107     CenterBody  = 5,  // subtitle in title slide
00108     CenterTitle = 6,  // title in title slide
00109     HalfBody    = 7,  // body in two-column slide
00110     QuarterBody = 8   // body in four-body slide
00111   };
00112 
00113   TextObject();
00114   virtual ~TextObject();
00115   virtual bool isText() const { return true; }
00116   unsigned type() const;
00117   void setType( unsigned type );
00118   const char* typeAsString() const;
00119   UString text(unsigned index) const;
00120   void setText( const UString& text );
00121   unsigned listSize() const;
00122   bool bulletFlag(unsigned index) const;
00123   void setBulletFlag( bool flag ) ;
00124   void convertFrom( Object* object );
00125 
00126 private:
00127   // no copy or assign
00128   TextObject( const TextObject& );
00129   TextObject& operator=( const TextObject& );
00130   
00131   class Private;
00132   Private* d;
00133 };
00134 
00135 class GroupObject: public Object
00136 {
00137 public:
00138   GroupObject();
00139   virtual ~GroupObject();
00140   virtual bool isGroup() const { return true; }
00141   unsigned objectCount() const;
00142   Object* object( unsigned index );
00143   void addObject( Object* object );
00144   void takeObject( Object* object );
00145 
00146 private:
00147   // no copy or assign
00148   GroupObject( const GroupObject& );
00149   GroupObject& operator=( const GroupObject& );
00150   
00151   class Private;
00152   Private* d;
00153 
00154 };
00155 
00156 class DrawObject: public Object
00157 {
00158 public:
00159 
00160   enum {
00161     None = 0,
00162     Rectangle,
00163     RoundRectangle,
00164     Circle,
00165     Ellipse,
00166     Diamond,
00167     RightArrow,
00168     LeftArrow,
00169     UpArrow,
00170     DownArrow, 
00171     IsoscelesTriangle,
00172     RightTriangle,
00173     Parallelogram,
00174     Trapezoid,
00175     Hexagon,
00176     Octagon,
00177     Line,
00178     Smiley,
00179     Heart,
00180     FreeLine
00181   };
00182 
00183   DrawObject();
00184   virtual ~DrawObject();
00185   virtual bool isDrawing() const { return true; }
00186    
00187   unsigned shape() const;
00188   void setShape( unsigned s );
00189 
00190   bool isVerFlip() const;
00191   void setVerFlip( bool vFlip );
00192   bool isHorFlip() const;
00193   void setHorFlip( bool hFlip );  
00194 
00195 private:
00196   // no copy or assign
00197   DrawObject( const DrawObject& );
00198   DrawObject& operator=( const DrawObject& );
00199   
00200   class Private;
00201   Private* d;
00202 };
00203 
00204 }
00205 
00206 #endif /* LIBPPT_OBJECTS */
KDE Home | KDE Accessibility Home | Description of Access Keys