00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __koPictureShared_h__
00021 #define __koPictureShared_h__
00022
00023 #include <q3shared.h>
00024 #include <QString>
00025 #include <QIODevice>
00026 #include <QPixmap>
00027
00028 #include "KoPictureKey.h"
00029
00030 class KoXmlWriter;
00031 class QPainter;
00032 class QSize;
00033
00034 class KUrl;
00035
00036 class KoPictureBase;
00037
00044 class KoPictureShared : public Q3Shared
00045 {
00046 public:
00050 KoPictureShared(void);
00051
00055 ~KoPictureShared(void);
00056
00062 KoPictureShared(const KoPictureShared &other);
00063
00069 KoPictureShared& operator=(const KoPictureShared& other);
00070
00071 KoPictureType::Type getType(void) const;
00072
00076 bool isNull(void) const;
00077
00091 void draw(QPainter& painter, int x, int y, int width, int height, int sx = 0, int sy = 0, int sw = -1, int sh = -1, bool fastMode = false);
00092
00098 Q3DragObject* dragObject( QWidget *dragSource = 0L, const char *name = 0L );
00099
00100 bool load(QIODevice* io, const QString& extension);
00101 bool loadFromBase64( const QByteArray& str );
00102
00107 bool save(QIODevice* io) const;
00108
00113 bool saveAsBase64( KoXmlWriter& writer ) const;
00114
00115 void setExtension(const QString& extension);
00116
00117 QString getExtension(void) const;
00118
00119 QSize getOriginalSize(void) const;
00120
00126 void clearAndSetMode(const QString& newMode);
00127
00131 void clear(void);
00132
00138 bool loadFromFile(const QString& fileName);
00139
00143 bool loadXpm(QIODevice* io);
00144
00151 QPixmap generatePixmap(const QSize& size, bool smoothScale = false);
00152
00153 QString getMimeType(void) const;
00154
00162 QImage generateImage(const QSize& size);
00163
00164 bool hasAlphaBuffer() const;
00165 void setAlphaBuffer(bool enable);
00166 QImage createAlphaMask(Qt::ImageConversionFlags flags = Qt::AutoColor) const;
00167
00174 void clearCache(void);
00175
00176 QString uniquePictureId() const;
00177 void assignPictureId( uint _id);
00178
00179 protected:
00185 bool loadWmf(QIODevice* io);
00186
00191 bool loadTmp(QIODevice* io);
00192
00194 bool identifyAndLoad( QByteArray data );
00195
00206 bool loadCompressed( QIODevice* io, const QString& mimeType, const QString& extension );
00207
00208 protected:
00209 KoPictureBase* m_base;
00210 QString m_extension;
00211 uint m_pictureId;
00212 };
00213
00214 #endif