1
/* This file is part of the KDE project
2
Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
3
Copyright (C) 2002, 2003, 2004 Nicolas GOUTTE <goutte@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
20
#ifndef __koPictureShared_h__
21
#define __koPictureShared_h__
25
#include <qiodevice.h>
28
#include "KoPictureKey.h"
40
* KoPictureShared is the class that contains the shared part for KoPicture
42
* @warning As with all QShared objects, the sharing is neither automatic nor transparent!
44
class KoPictureShared : public QShared
48
* Default constructor.
50
KoPictureShared(void);
55
~KoPictureShared(void);
58
* @brief Copy constructor
60
* This makes a deep copy. Do not use if you want to share!
62
KoPictureShared(const KoPictureShared &other);
65
* @brief Assignment operator
67
* This makes a deep copy. Do not use if you want to share!
69
KoPictureShared& operator=(const KoPictureShared& other);
71
KoPictureType::Type getType(void) const;
74
* Returns true if the picture is null.
76
bool isNull(void) const;
79
* @brief Draw the image in a painter.
81
* The parameter @p fastMode allows the picture to be re-sized and drawn quicker if possible
83
* The parameters @p width, @p height define the desired size for the picture
85
* The other parameters are very similar to QPainter::drawPixmap :
86
* (@p x, @p y) define the position in the painter,
87
* (@p sx, @p sy) specify the top-left point in pixmap that is to be drawn. The default is (0, 0).
88
* (@p sw, @p sh) specify the size of the pixmap that is to be drawn. The default, (-1, -1), means all the way to the bottom
89
* right of the pixmap.
91
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);
94
* Create a dragobject containing this picture.
95
* @param dragSource must be 0 when copying to the clipboard
96
* @return 0L if the picture is null!
98
QDragObject* dragObject( QWidget *dragSource = 0L, const char *name = 0L );
100
bool load(QIODevice* io, const QString& extension);
101
bool loadFromBase64( const QCString& str );
104
* Save picture into a QIODevice
105
* @param io QIODevice used for saving
107
bool save(QIODevice* io) const;
110
* OASIS FlatXML support:
111
* Save picture as base64-encoded data into an XML writer.
113
bool saveAsBase64( KoXmlWriter& writer ) const;
115
void setExtension(const QString& extension);
117
QString getExtension(void) const;
119
QSize getOriginalSize(void) const;
122
* Clear and set the mode of this KoPictureShared
124
* @param newMode file extension (like "png") giving the wanted mode
126
void clearAndSetMode(const QString& newMode);
129
* Reset the KoPictureShared (but not the key!)
136
* @param fileName the name of the file to load
138
bool loadFromFile(const QString& fileName);
141
* Load a potentially broken XPM file (for KPresenter)
143
bool loadXpm(QIODevice* io);
147
* Returns a QPixmap from an image
149
* @param size the wanted size for the QPixmap
151
QPixmap generatePixmap(const QSize& size, bool smoothScale = false);
153
QString getMimeType(void) const;
158
* (always in slow mode)
160
* @param size the wanted size for the QImage
162
QImage generateImage(const QSize& size);
164
bool hasAlphaBuffer() const;
165
void setAlphaBuffer(bool enable);
166
QImage createAlphaMask(int conversion_flags = 0) const;
171
* It is used to avoid using too much memory
172
* especially if the application somehow caches the KoPicture too.
174
void clearCache(void);
176
QString uniquePictureId() const;
177
void assignPictureId( uint _id);
183
* \note In %KOffice 1.1, a .wmf file was a QPicture file
185
bool loadWmf(QIODevice* io);
189
* Loads a temporary file, probably from a downloaded file
191
bool loadTmp(QIODevice* io);
193
/// Find type of image, create base accordingly, and load data
194
bool identifyAndLoad( QByteArray data );
198
* Loads a compressed file
200
* @warning risk of endless recurision, be careful when it is called from @see load
202
* @param io QIODevice of the compressed file/strea,
203
* @param mimeType mimetype of the (de-)compressor
204
* @param extension extension of the uncompressed file
206
bool loadCompressed( QIODevice* io, const QString& mimeType, const QString& extension );
209
KoPictureBase* m_base;
214
#endif /* __koPictureShared_h__ */