This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C1C054.AD0B9D90 Content-Type: text/plain; charset="iso-8859-1" My continuing obsession with thumbnails has now created one for koffice files: http://www.babysimon.co.uk/kde/kofficepreview.png If you look carefully at the code you may see traces of the HTML preview and Philippe Fremy's KParts tutorial :) However, it's not quite as I would like it. I can't seem to control the scaling in a very meaningful way. What I would like to do is find out how wide the document "wants" to be, then scale for that (particularly important for KWord docs). But I can't mind a method that tells me this. Is there one? Also, when adjusting the zoom parameters which are passed to KoDocument::paintEverything, font sizes don't seem to change. I recall this used to be a problem but I don't know whether it's been fixed yet (ummm, I'm afraid I hardly use KOffice...). Also, it completely fails to work with KPresenter. I don't know why. The attached patch provides two .desktop files to switch it on and off - one for KOffice and one for MSOffice. I don't know if this is the best way to do it - should it be lots of little .desktops or one big one maybe? What else? Oh, to reply to the list admin's question, yes, it probably is quite slow. "Unfortunately" I developed it on my fast work machine. It might go faster if it "reused" the KoDocuments (like the HTML preview reuses KHTML), but it would probably need a QDict of them. Hmmm... Cheers, Simon <> <> <> <> <> ------_=_NextPart_000_01C1C054.AD0B9D90 Content-Type: application/octet-stream; name="koffice.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="koffice.diff" ? koffice.diff=0A= ? karbon/core/vtext.loT=0A= ? kword/serialletter/Makefile.in=0A= ? kword/serialletter/Makefile=0A= ? kword/serialletter/sql/Makefile.in=0A= ? kword/serialletter/sql/Makefile=0A= ? kword/serialletter/sql/qtsqldatasourceeditor.h=0A= ? kword/serialletter/sql/qtsqlopenwidget.h=0A= ? kword/serialletter/sql/kwqtsqlpower.h=0A= ? kword/serialletter/sql/serialletter_qtsql_base.kidl=0A= ? kword/serialletter/sql/serialletter_qtsql_base_skel.cc=0A= ? kword/serialletter/sql/qtsqldatasourceeditor.cc=0A= ? kword/serialletter/sql/qtsqlopenwidget.cc=0A= ? kword/serialletter/sql/serialletter_qtsql_power_plugin.kidl=0A= ? kword/serialletter/sql/serialletter_qtsql_power_plugin_skel.cc=0A= ? kword/serialletter/sql/kwqtsqlpower.cc=0A= ? tools/thumbnail/kofficecreator.cpp=0A= ? tools/thumbnail/kofficecreator.h=0A= ? tools/thumbnail/kofficethumbnail.desktop=0A= ? tools/thumbnail/msofficethumbnail.desktop=0A= Index: tools/thumbnail/Makefile.am=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /home/kde/koffice/tools/thumbnail/Makefile.am,v=0A= retrieving revision 1.2=0A= diff -u -3 -p -r1.2 Makefile.am=0A= --- tools/thumbnail/Makefile.am 2001/09/20 17:01:35 1.2=0A= +++ tools/thumbnail/Makefile.am 2002/02/28 12:18:36=0A= @@ -2,10 +2,15 @@ INCLUDES =3D $(KOFFICE_INCLUDES) $(all_inc=0A= LDFLAGS =3D $(all_libraries) $(KDE_RPATH)=0A= METASOURCES =3D AUTO=0A= =0A= -kde_module_LTLIBRARIES =3D clipartthumbnail.la=0A= +kde_module_LTLIBRARIES =3D clipartthumbnail.la kofficethumbnail.la=0A= =0A= clipartthumbnail_la_SOURCES =3D clipartcreator.cpp=0A= clipartthumbnail_la_LIBADD =3D $(LIB_KOFFICECORE) # for = KoClipartCollection=0A= clipartthumbnail_la_LDFLAGS =3D $(all_libraries) -module = $(KDE_PLUGIN)=0A= =0A= -kde_services_DATA =3D clipartthumbnail.desktop=0A= +kofficethumbnail_la_SOURCES =3D kofficecreator.cpp=0A= +kofficethumbnail_la_LIBADD =3D $(LIB_KOFFICECORE)=0A= +kofficethumbnail_la_LDFLAGS =3D $(all_libraries) -module = $(KDE_PLUGIN)=0A= +=0A= +kde_services_DATA =3D clipartthumbnail.desktop = kofficethumbnail.desktop msofficethumbnail.desktop=0A= +=0A= ------_=_NextPart_000_01C1C054.AD0B9D90 Content-Type: application/octet-stream; name="kofficecreator.cpp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kofficecreator.cpp" /* This file is part of the KDE libraries=0A= Copyright (C) 2000 Malte Starostik =0A= =0A= This library is free software; you can redistribute it and/or=0A= modify it under the terms of the GNU Library General Public=0A= License as published by the Free Software Foundation; either=0A= version 2 of the License, or (at your option) any later version.=0A= =0A= This library is distributed in the hope that it will be useful,=0A= but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the = GNU=0A= Library General Public License for more details.=0A= =0A= You should have received a copy of the GNU Library General Public = License=0A= along with this library; see the file COPYING.LIB. If not, write = to=0A= the Free Software Foundation, Inc., 59 Temple Place - Suite 330,=0A= Boston, MA 02111-1307, USA.=0A= */=0A= =0A= // $Id: htmlcreator.cpp,v 1.7 2001/12/29 17:22:21 mueller Exp $=0A= =0A= #include =0A= =0A= #include =0A= #include =0A= #include =0A= =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include "kofficecreator.h"=0A= =0A= extern "C"=0A= {=0A= ThumbCreator *new_creator()=0A= {=0A= return new KOfficeCreator;=0A= }=0A= };=0A= =0A= KOfficeCreator::KOfficeCreator()=0A= : m_doc(0)=0A= {=0A= }=0A= =0A= KOfficeCreator::~KOfficeCreator()=0A= {=0A= delete m_doc;=0A= }=0A= =0A= bool KOfficeCreator::create(const QString &path, int width, int height, = QImage &img)=0A= {=0A= KFileItem document ( KFileItem::Unknown, KFileItem::Unknown, = path);=0A= =0A= // Copied straight from the tutorial=0A= KTrader::OfferList offers =3D = KTrader::self()->query(document.mimetype(),=0A= "'KOfficePart' in = ServiceTypes");=0A= KLibFactory *factory =3D 0;=0A= KTrader::OfferList::Iterator it(offers.begin());=0A= for( ; it !=3D offers.end(); ++it) {=0A= KService::Ptr ptr =3D (*it);=0A= =0A= factory =3D KLibLoader::self()->factory( = ptr->library().latin1() );=0A= if (factory) {=0A= m_doc =3D static_cast(factory->create(0,=0A= ptr->name().latin1(), = "KParts::ReadOnlyPart"));=0A= break;=0A= }=0A= }=0A= =0A= if (!m_doc) return false;=0A= =0A= connect(m_doc, SIGNAL(completed()), SLOT(slotCompleted()));=0A= =0A= m_doc->openURL(path);=0A= m_completed =3D false;=0A= startTimer(5000);=0A= while (!m_completed)=0A= kapp->processOneEvent();=0A= killTimers();=0A= =0A= // render the page on a bigger pixmap and use smoothScale,=0A= // looks better than directly scaling with the QPainter (malte)=0A= QPixmap pix;=0A= if (width > 400 || height > 400)=0A= {=0A= if (height > width )=0A= pix.resize(height, height);=0A= else=0A= pix.resize(width, width);=0A= }=0A= else=0A= pix.resize(400, 400);=0A= // light-grey background, in case loadind the page failed=0A= pix.fill( QColor( 245, 245, 245 ) );=0A= =0A= int borderX =3D pix.width() / width,=0A= borderY =3D pix.height() / height;=0A= QRect rc(borderX, borderY, pix.width() - borderX * 2, pix.width() - = borderX * 2);=0A= =0A= QPainter p;=0A= p.begin(&pix);=0A= m_doc->paintEverything(p, rc);=0A= p.end();=0A= =0A= delete m_doc;=0A= m_doc =3D 0L;=0A= =0A= img =3D pix.convertToImage();=0A= return true;=0A= }=0A= =0A= void KOfficeCreator::timerEvent(QTimerEvent *)=0A= {=0A= m_doc->closeURL();=0A= m_completed =3D true;=0A= }=0A= =0A= void KOfficeCreator::slotCompleted()=0A= {=0A= m_completed =3D true;=0A= }=0A= =0A= ThumbCreator::Flags KOfficeCreator::flags() const=0A= {=0A= return (Flags)(DrawFrame | BlendIcon);=0A= }=0A= =0A= #include "kofficecreator.moc"=0A= =0A= ------_=_NextPart_000_01C1C054.AD0B9D90 Content-Type: application/octet-stream; name="kofficethumbnail.desktop" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kofficethumbnail.desktop" [Desktop Entry]=0A= Encoding=3DUTF-8=0A= Type=3DService=0A= Name=3DKOffice Files=0A= ServiceTypes=3DThumbCreator=0A= MimeTypes=3Dapplication/x-kword,application/x-kspread,application/x-kpre= senter=0A= X-KDE-Library=3Dkofficethumbnail=0A= CacheThumbnail=3Dtrue=0A= ------_=_NextPart_000_01C1C054.AD0B9D90 Content-Type: application/octet-stream; name="msofficethumbnail.desktop" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="msofficethumbnail.desktop" [Desktop Entry]=0A= Encoding=3DUTF-8=0A= Type=3DService=0A= Name=3DMicrosoft Office Files=0A= ServiceTypes=3DThumbCreator=0A= MimeTypes=3Dapplication/msword,application/msexcel=0A= X-KDE-Library=3Dkofficethumbnail=0A= CacheThumbnail=3Dtrue=0A= ------_=_NextPart_000_01C1C054.AD0B9D90 Content-Type: application/octet-stream; name="kofficecreator.h" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kofficecreator.h" /* This file is part of the KDE libraries=0A= Copyright (C) 2002 Simon MacMullen=0A= =0A= This library is free software; you can redistribute it and/or=0A= modify it under the terms of the GNU Library General Public=0A= License as published by the Free Software Foundation; either=0A= version 2 of the License, or (at your option) any later version.=0A= =0A= This library is distributed in the hope that it will be useful,=0A= but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the = GNU=0A= Library General Public License for more details.=0A= =0A= You should have received a copy of the GNU Library General Public = License=0A= along with this library; see the file COPYING.LIB. If not, write = to=0A= the Free Software Foundation, Inc., 59 Temple Place - Suite 330,=0A= Boston, MA 02111-1307, USA.=0A= */=0A= =0A= #ifndef _KWORDCREATOR_H_=0A= #define _KWORDCREATOR_H_ "$Id: htmlcreator.h,v 1.4 2001/10/01 20:32:50 = faure Exp $"=0A= =0A= #include =0A= #include =0A= #include "../../lib/kofficecore/koDocument.h"=0A= =0A= class KoDocument;=0A= =0A= class KOfficeCreator : public QObject, public ThumbCreator=0A= {=0A= Q_OBJECT=0A= public:=0A= KOfficeCreator();=0A= virtual ~KOfficeCreator();=0A= virtual bool create(const QString &path, int width, int height, = QImage &img);=0A= virtual Flags flags() const;=0A= =0A= protected:=0A= virtual void timerEvent(QTimerEvent *);=0A= =0A= private slots:=0A= void slotCompleted();=0A= =0A= private:=0A= KoDocument *m_doc;=0A= bool m_completed;=0A= };=0A= =0A= #endif=0A= ------_=_NextPart_000_01C1C054.AD0B9D90-- _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel