F:/KPlato/koffice/libs/kofficecore/KoPictureBase.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
00003    Copyright (C) 2002, 2003 Nicolas GOUTTE <goutte@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
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 //Added by qt3to4:
00035 #include <QBuffer>
00036 static int s_useSlowResizeMode = -1; // unset
00037 
00038 KoPictureBase::KoPictureBase(void)
00039 {
00040     // Slow mode can be very slow, especially at high zoom levels -> configurable
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;    // A KoPictureBase is always null.
00066 }
00067 
00068 void KoPictureBase::draw(QPainter& painter, int x, int y, int width, int height, int, int, int, int, bool /*fastMode*/)
00069 {
00070     // Draw a light red box (easier DEBUG)
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     // Nothing to load!
00086     return false;
00087 }
00088 
00089 bool KoPictureBase::save(QIODevice*) const
00090 {
00091     // Nothing to save!
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 /*smoothScale*/)
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     // Nothign to do!
00143 }

Généré le Wed Nov 22 23:41:03 2006 pour KPlato par  doxygen 1.5.1-p1