26#include <tdeio/netaccess.h>
28#include "KoPictureKey.h"
29#include "KoPictureBase.h"
30#include "KoPictureShared.h"
33uint KoPicture::uniqueValue = 0;
38 m_uniqueName =
"Pictures"+ TQString::number(uniqueValue++);
46TQString KoPicture::uniqueName()
const
57void KoPicture::assignPictureId( uint _id)
60 m_sharedData->assignPictureId(_id);
63TQString KoPicture::uniquePictureId()
const
66 return m_sharedData->uniquePictureId();
74 if (other.m_sharedData)
75 other.linkSharedData();
78 m_sharedData=other.m_sharedData;
84void KoPicture::unlinkSharedData(
void)
86 if (m_sharedData && m_sharedData->deref())
92void KoPicture::linkSharedData(
void)
const
98void KoPicture::createSharedData(
void)
102 m_sharedData=
new KoPictureShared();
107KoPictureType::Type KoPicture::getType(
void)
const
110 return m_sharedData->getType();
111 return KoPictureType::TypeUnknown;
128 return m_sharedData->isNull();
132void KoPicture::draw(TQPainter& painter,
int x,
int y,
int width,
int height,
int sx,
int sy,
int sw,
int sh,
bool fastMode)
135 m_sharedData->draw(painter, x, y, width, height, sx, sy, sw, sh, fastMode);
139 kdWarning(30003) <<
"Drawing white rectangle! (KoPicture::draw)" << endl;
141 painter.setBrush(TQColor(255, 255, 255));
142 painter.drawRect(x,y,width,height);
149 kdDebug(30003) <<
"KoPicture::loadXpm" << endl;
152 kdError(30003) <<
"No TQIODevice!" << endl;
156 return m_sharedData->loadXpm(io);
164 return m_sharedData->save(io);
171 return m_sharedData->saveAsBase64( writer );
183 m_sharedData->clearAndSetMode(newMode);
189 return m_sharedData->getExtension();
196 return m_sharedData->getMimeType();
197 return TQString(NULL_MIME_TYPE);
200bool KoPicture::load(TQIODevice* io,
const TQString& extension)
202 kdDebug(30003) <<
"KoPicture::load(TQIODevice*, const TQString&) " << extension << endl;
205 return m_sharedData->load(io,extension);
210 kdDebug(30003) <<
"KoPicture::loadFromFile " << fileName << endl;
212 return m_sharedData->loadFromFile(fileName);
218 return m_sharedData->loadFromBase64( str );
224 return m_sharedData->getOriginalSize();
231 return m_sharedData->generatePixmap(size, smoothScale);
239 TQString tmpFileName;
240 if ( TDEIO::NetAccess::download(url, tmpFileName, window) )
246 TDEIO::NetAccess::removeTempFile( tmpFileName );
255 return m_sharedData->dragObject( dragSource, name );
262 return m_sharedData->generateImage( size );
269 return m_sharedData->hasAlphaBuffer();
276 m_sharedData->setAlphaBuffer(enable);
282 return m_sharedData->createAlphaMask(conversion_flags);
289 m_sharedData->clearCache();
KoPictureKey is the structure describing a picture in a unique way.
void setKeyFromFile(const TQString &filename)
Sets the key according to filename, including modification time.
KoPicture is a container class for various types of pictures supported by KOffice.
~KoPicture(void)
Destructor.
TQString getExtension(void) const
bool setKeyAndDownloadPicture(const KURL &url, TQWidget *window)
Download and set the key for a possibly remote file.
bool saveAsBase64(KoXmlWriter &writer) const
OASIS FlatXML support: Save picture as base64-encoded data into an XML writer.
bool loadFromBase64(const TQCString &str)
Load the picture from base64-encoded data.
void clear(void)
Reset the KoPicture (but not the key!)
TQString getMimeType(void) const
void setKey(const KoPictureKey &key)
Set the key structure describing the picture in a unique way.
bool loadFromFile(const TQString &fileName)
Load the picture from a file named fileName.
void clearAndSetMode(const TQString &newMode)
Clear and set the mode of this KoPicture.
bool isNull(void) const
Returns true if the picture is null.
TQSize getOriginalSize(void) const
void clearCache(void)
Clear any cache.
bool save(TQIODevice *io) const
Save picture into a TQIODevice.
void draw(TQPainter &painter, int x, int y, int width, int height, int sx=0, int sy=0, int sw=-1, int sh=-1, bool fastMode=false)
Draw the picture in a painter.
bool loadXpm(TQIODevice *io)
Load a potentially broken XPM file (for old files of KPresenter)
TQPixmap generatePixmap(const TQSize &size, bool smoothScale=false)
KoPictureKey getKey(void) const
Retrieve the key structure describing the picture in a unique way.
KoPicture & operator=(const KoPicture &other)
Assignment operator.
void setAlphaBuffer(bool enable)
Respect the image alpha buffer.
bool hasAlphaBuffer() const
TQDragObject * dragObject(TQWidget *dragSource=0L, const char *name=0L)
Create a dragobject containing this picture.
TQImage generateImage(const TQSize &size)
Generate a TQImage (always in slow mode)
TQImage createAlphaMask(int conversion_flags=0) const
Creates an alpha mask for the picture (first you have to call setAlphaBuffer).
KoPicture(void)
Default constructor.
A class for writing out XML (to any TQIODevice), with a special attention on performance.