00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KoPictureBase.h"
00022
00023 #include <KoXmlWriter.h>
00024
00025 #include <kdebug.h>
00026 #include <kconfig.h>
00027 #include <kglobal.h>
00028
00029 #include <kcodecs.h>
00030 #include <QPainter>
00031 #include <q3picture.h>
00032 #include <QPixmap>
00033 #include <q3dragobject.h>
00034
00035 #include <QBuffer>
00036 static int s_useSlowResizeMode = -1;
00037
00038 KoPictureBase::KoPictureBase(void)
00039 {
00040
00041 if ( s_useSlowResizeMode == -1 )
00042 {
00043 KConfigGroup group( KGlobal::config(), "KOfficeImage" );
00044 s_useSlowResizeMode = group.readEntry( "HighResolution", 1 );
00045 kDebug(30003) << "HighResolution = " << s_useSlowResizeMode << endl;
00046 }
00047 }
00048
00049 KoPictureBase::~KoPictureBase(void)
00050 {
00051 }
00052
00053 KoPictureBase* KoPictureBase::newCopy(void) const
00054 {
00055 return new KoPictureBase(*this);
00056 }
00057
00058 KoPictureType::Type KoPictureBase::getType(void) const
00059 {
00060 return KoPictureType::TypeUnknown;
00061 }
00062
00063 bool KoPictureBase::isNull(void) const
00064 {
00065 return true;
00066 }
00067
00068 void KoPictureBase::draw(QPainter& painter, int x, int y, int width, int height, int, int, int, int, bool )
00069 {
00070
00071 kWarning(30003) << "Drawing light red rectangle! (KoPictureBase::draw)" << endl;
00072 painter.save();
00073 painter.setBrush(QColor(128,0,0));
00074 painter.drawRect(x,y,width,height);
00075 painter.restore();
00076 }
00077
00078 bool KoPictureBase::load(QIODevice* io, const QString& extension)
00079 {
00080 return loadData(io->readAll(), extension);
00081 }
00082
00083 bool KoPictureBase::loadData(const QByteArray&, const QString&)
00084 {
00085
00086 return false;
00087 }
00088
00089 bool KoPictureBase::save(QIODevice*) const
00090 {
00091
00092 return false;
00093 }
00094
00095 bool KoPictureBase::saveAsBase64( KoXmlWriter& writer ) const
00096 {
00097 QBuffer buffer;
00098 buffer.open(QIODevice::ReadWrite);
00099 if ( !save( &buffer ) )
00100 return false;
00101 QByteArray encoded = KCodecs::base64Encode( buffer.buffer() );
00102 writer.addTextNode( encoded );
00103 return true;
00104 }
00105
00106 QSize KoPictureBase::getOriginalSize(void) const
00107 {
00108 return QSize(0,0);
00109 }
00110
00111 QPixmap KoPictureBase::generatePixmap(const QSize&, bool )
00112 {
00113 return QPixmap();
00114 }
00115
00116 QString KoPictureBase::getMimeType(const QString&) const
00117 {
00118 return QString(NULL_MIME_TYPE);
00119 }
00120
00121 bool KoPictureBase::isSlowResizeModeAllowed(void) const
00122 {
00123 return s_useSlowResizeMode != 0;
00124 }
00125
00126 Q3DragObject* KoPictureBase::dragObject( QWidget * dragSource, const char * name )
00127 {
00128 QImage image (generateImage(getOriginalSize()));
00129 if (image.isNull())
00130 return 0L;
00131 else
00132 return new Q3ImageDrag( image, dragSource, name );
00133 }
00134
00135 QImage KoPictureBase::generateImage(const QSize& size)
00136 {
00137 return generatePixmap(size,true).toImage();
00138 }
00139
00140 void KoPictureBase::clearCache(void)
00141 {
00142
00143 }