filters

graphicshandler.cpp

00001 /* This file is part of the KOffice project
00002    Copyright (C) 2003 Werner Trobin <trobin@kde.org>
00003    Copyright (C) 2003 David Faure <faure@kde.org>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "graphicshandler.h"
00021 #include "document.h"
00022 
00023 #include <wv2/olestream.h>
00024 
00025 #include <KoStoreDevice.h>
00026 #include <KoSize.h>
00027 #include <kdebug.h>
00028 
00029 using namespace wvWare;
00030 
00031 KWordPictureHandler::KWordPictureHandler( Document* doc ) : QObject(), m_doc(doc)
00032 {
00033 }
00034 
00035 #ifdef IMAGE_IMPORT
00036 
00037 void KWordPictureHandler::bitmapData( OLEImageReader& reader, SharedPtr<const Word97::PICF> /*picf*/ )
00038 {
00039     kdDebug(30513) << "Bitmap data found ->>>>>>>>>>>>>>>>>>>>>>>>>>>>> size=" << reader.size() << endl;
00040 
00041 }
00042 
00043 void KWordPictureHandler::wmfData( OLEImageReader& reader, SharedPtr<const Word97::PICF> picf )
00044 {
00045     kdDebug(30513) << "wmf data found ->>>>>>>>>>>>>>>>>>>>>>>>>>>>> size=" << reader.size() << endl;
00046 
00047     // We have two things to do here
00048     // 1 - Create the frameset and its frame
00049     // 2 - Store the picture in the store
00050     // We combine those two things into one call to the document
00051     KoSize size( (double)picf->dxaGoal / 20.0, (double)picf->dyaGoal / 20.0 );
00052     kdDebug(30513) << "size=" << size << endl;
00053     KoStoreDevice* dev = m_doc->createPictureFrameSet( size );
00054     Q_ASSERT(dev);
00055     if ( !dev )
00056         return; // ouch
00057 
00058 #define IMG_BUF_SIZE 2048
00059     wvWare::U8 buf[IMG_BUF_SIZE];
00060     Q_LONG len = reader.size();
00061     while ( len > 0 )  {
00062         size_t n = reader.read( buf, QMIN( len, IMG_BUF_SIZE ) );
00063         Q_LONG n1 = dev->writeBlock( (const char*)buf, n );
00064         Q_ASSERT( (size_t)n1 == n );
00065         if ( (size_t)n1 != n )
00066             return; // ouch
00067         len -= n;
00068     }
00069     Q_ASSERT( len == 0 );
00070     dev->close();
00071 }
00072 
00073 void KWordPictureHandler::tiffData( const UString& /*name*/, SharedPtr<const Word97::PICF> /*picf*/ )
00074 {
00075 }
00076 
00077 #endif // IMAGE_IMPORT
00078 
00079 #include "graphicshandler.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys