lib Library API Documentation

koPictureBase.cc

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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, 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 <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; // unset
00036 
00037 KoPictureBase::KoPictureBase(void)
00038 {
00039     // Slow mode can be very slow, especially at high zoom levels -> configurable
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;    // A KoPictureBase is always null.
00065 }
00066 
00067 void KoPictureBase::draw(QPainter& painter, int x, int y, int width, int height, int, int, int, int, bool /*fastMode*/)
00068 {
00069     // Draw a light red box (easier DEBUG)
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     // Nothing to load!
00085     return false;
00086 }
00087 
00088 bool KoPictureBase::save(QIODevice*) const
00089 {
00090     // Nothing to save!
00091     return false;
00092 }
00093 
00094 bool KoPictureBase::saveAsKOffice1Dot1(QIODevice* io, const QString&) const
00095 {
00096     // The default is the normla save
00097     return save(io);
00098 }
00099 
00100 bool KoPictureBase::saveAsBase64( KoXmlWriter& writer ) const
00101 {
00102     QBuffer buffer;
00103     buffer.open(IO_ReadWrite);
00104     if ( !save( &buffer ) )
00105         return false;
00106     QCString encoded = KCodecs::base64Encode( buffer.buffer() );
00107     writer.addTextNode( encoded );
00108     return true;
00109 }
00110 
00111 QSize KoPictureBase::getOriginalSize(void) const
00112 {
00113     return QSize(0,0);
00114 }
00115 
00116 QPixmap KoPictureBase::generatePixmap(const QSize&, bool /*smoothScale*/)
00117 {
00118     return QPixmap();
00119 }
00120 
00121 bool KoPictureBase::isClipartAsKOffice1Dot1(void) const
00122 {
00123     return false;
00124 }
00125 
00126 QString KoPictureBase::getMimeType(const QString&) const
00127 {
00128     return QString(NULL_MIME_TYPE);
00129 }
00130 
00131 bool KoPictureBase::isSlowResizeModeAllowed(void) const
00132 {
00133     return s_useSlowResizeMode != 0;
00134 }
00135 
00136 QDragObject* KoPictureBase::dragObject( QWidget * dragSource, const char * name )
00137 {
00138     QImage image (generateImage(getOriginalSize()));
00139     if (image.isNull())
00140         return 0L;
00141     else
00142         return new QImageDrag( image, dragSource, name );
00143 }
00144 
00145 QImage KoPictureBase::generateImage(const QSize& size)
00146 {
00147     return generatePixmap(size,true).convertToImage();
00148 }
00149 
00150 void KoPictureBase::clearCache(void)
00151 {
00152     // Nothign to do!
00153 }
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:04 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003