lib
KoPictureBase.cpp00001
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 <kmdcodec.h>
00030 #include <qpainter.h>
00031 #include <qpicture.h>
00032 #include <qpixmap.h>
00033 #include <qdragobject.h>
00034
00035 static int s_useSlowResizeMode = -1;
00036
00037 KoPictureBase::KoPictureBase(void)
00038 {
00039
00040 if ( s_useSlowResizeMode == -1 )
00041 {
00042 KConfigGroup group( KGlobal::config(), "KOfficeImage" );
00043 s_useSlowResizeMode = group.readNumEntry( "HighResolution", 1 );
00044 kdDebug(30003) << "HighResolution = " << s_useSlowResizeMode << endl;
00045 }
00046 }
00047
00048 KoPictureBase::~KoPictureBase(void)
00049 {
00050 }
00051
00052 KoPictureBase* KoPictureBase::newCopy(void) const
00053 {
00054 return new KoPictureBase(*this);
00055 }
00056
00057 KoPictureType::Type KoPictureBase::getType(void) const
00058 {
00059 return KoPictureType::TypeUnknown;
00060 }
00061
00062 bool KoPictureBase::isNull(void) const
00063 {
00064 return true;
00065 }
00066
00067 void KoPictureBase::draw(QPainter& painter, int x, int y, int width, int height, int, int, int, int, bool )
00068 {
00069
00070 kdWarning(30003) << "Drawing light red rectangle! (KoPictureBase::draw)" << endl;
00071 painter.save();
00072 painter.setBrush(QColor(128,0,0));
00073 painter.drawRect(x,y,width,height);
00074 painter.restore();
00075 }
00076
00077 bool KoPictureBase::load(QIODevice* io, const QString& extension)
00078 {
00079 return loadData(io->readAll(), extension);
00080 }
00081
00082 bool KoPictureBase::loadData(const QByteArray&, const QString&)
00083 {
00084
00085 return false;
00086 }
00087
00088 bool KoPictureBase::save(QIODevice*) const
00089 {
00090
00091 return false;
00092 }
00093
00094 bool KoPictureBase::saveAsBase64( KoXmlWriter& writer ) const
00095 {
00096 QBuffer buffer;
00097 buffer.open(IO_ReadWrite);
00098 if ( !save( &buffer ) )
00099 return false;
00100 QCString encoded = KCodecs::base64Encode( buffer.buffer() );
00101 writer.addTextNode( encoded );
00102 return true;
00103 }
00104
00105 QSize KoPictureBase::getOriginalSize(void) const
00106 {
00107 return QSize(0,0);
00108 }
00109
00110 QPixmap KoPictureBase::generatePixmap(const QSize&, bool )
00111 {
00112 return QPixmap();
00113 }
00114
00115 QString KoPictureBase::getMimeType(const QString&) const
00116 {
00117 return QString(NULL_MIME_TYPE);
00118 }
00119
00120 bool KoPictureBase::isSlowResizeModeAllowed(void) const
00121 {
00122 return s_useSlowResizeMode != 0;
00123 }
00124
00125 QDragObject* KoPictureBase::dragObject( QWidget * dragSource, const char * name )
00126 {
00127 QImage image (generateImage(getOriginalSize()));
00128 if (image.isNull())
00129 return 0L;
00130 else
00131 return new QImageDrag( image, dragSource, name );
00132 }
00133
00134 QImage KoPictureBase::generateImage(const QSize& size)
00135 {
00136 return generatePixmap(size,true).convertToImage();
00137 }
00138
00139 void KoPictureBase::clearCache(void)
00140 {
00141
00142 }
|