From koffice-devel Wed Nov 03 20:19:16 2004 From: Sven Langkamp Date: Wed, 03 Nov 2004 20:19:16 +0000 To: koffice-devel Subject: Re: New Junior Jobs (kofficecore and KWord/KPresenter) Message-Id: <200411032119.16731.longamp () reallygood ! de> X-MARC-Message: https://marc.info/?l=koffice-devel&m=109951330316921 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_E1TiBG/7HTbRMTX" --Boundary-00=_E1TiBG/7HTbRMTX Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Monday 01 November 2004 19:10, Nicolas Goutte wrote: > I have a list of new junior jobs to do. (Putting them in KDE Bugs would > take more time.) > > 1. Replacing ::unlink by QFile::remove > In koffice/lib/kofficecore/koDocument.cc line 1301, there is a call > to ::unlink this should be replaced to QFile::remove (of course then > calling QFile::encodeName is not needed anymore) > (See also if one of the #includes can be removed. I am not sure abou that.) > > 2. Use KoStoreDevice in KoDocument::savePreview > In koffice/lib/kofficecore/koDocument.cc line 1200, the thumbnail is saved > used QBuffer. It should use KoStoreDevice instead, like in SaveOasisPreview > (line 1181) Attached a patch. --Boundary-00=_E1TiBG/7HTbRMTX Content-Type: text/x-diff; charset="iso-8859-15"; name="patch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch.diff" Index: lib/kofficecore/koDocument.cc =================================================================== RCS file: /home/kde/koffice/lib/kofficecore/koDocument.cc,v retrieving revision 1.332 diff -u -r1.332 koDocument.cc --- lib/kofficecore/koDocument.cc 1 Nov 2004 18:51:07 -0000 1.332 +++ lib/kofficecore/koDocument.cc 3 Nov 2004 20:09:13 -0000 @@ -22,7 +22,6 @@ #include #include -#include #include @@ -1191,20 +1190,14 @@ { QPixmap pix = generatePreview(QSize(256, 256)); // Reducing to 8bpp reduces file sizes quite a lot. - QImageIO imageIO; - imageIO.setImage( pix.convertToImage().convertDepth(8, Qt::AvoidDither | Qt::DiffuseDither) ); - - // NOTE: we cannot use QDataStream, as it is not 1:1 - QByteArray imageData; - // ### TODO: perhaps use a KoStoreDevice instead - QBuffer buffer(imageData); - buffer.open(IO_WriteOnly); - imageIO.setIODevice(&buffer); - imageIO.setFormat("PNG"); - imageIO.write(); - buffer.close(); - - return store->write( imageData ) == (Q_LONG)imageData.size(); + const QImage preview ( pix.convertToImage().convertDepth( 8, Qt::AvoidDither | Qt::DiffuseDither) ); + KoStoreDevice io ( store ); + if ( !io.open( IO_WriteOnly ) ) + return false; + if ( ! preview.save( &io, "PNG" ) ) // ### TODO What is -9 in quality terms? + return false; + io.close(); + return true; } QPixmap KoDocument::generatePreview( const QSize& size ) @@ -1298,7 +1291,7 @@ return ret; } case KMessageBox::No : - unlink( QFile::encodeName( asf ) ); + QFile::remove( asf ); return false; default: // Cancel return false; @@ -1362,8 +1355,7 @@ autosaveOpened = true; break; case KMessageBox::No : - // ### TODO (JJ:) use QFile::remove instead of ::unlink - unlink( QFile::encodeName( asf ) ); + QFile::remove( asf ); break; default: // Cancel return false; @@ -1516,7 +1508,7 @@ // remove temp file - uncomment this to debug import filters if(!importedFile.isEmpty()) - unlink( QFile::encodeName(importedFile) ); + QFile::remove( importedFile ); } if ( ok && d->m_bSingleViewMode ) @@ -2214,10 +2206,10 @@ // Eliminate any auto-save file QString asf = autoSaveFile( m_file ); // the one in the current dir if ( QFile::exists( asf ) ) - unlink( QFile::encodeName( asf ) ); + QFile::remove( asf ); asf = autoSaveFile( QString::null ); // and the one in $HOME if ( QFile::exists( asf ) ) - unlink( QFile::encodeName( asf ) ); + QFile::remove( asf ); } void KoDocument::setBackupFile( bool _b ) --Boundary-00=_E1TiBG/7HTbRMTX Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@kde.org https://mail.kde.org/mailman/listinfo/koffice-devel --Boundary-00=_E1TiBG/7HTbRMTX--