filters

graphicshandler.cpp
1/* This file is part of the KOffice project
2 Copyright (C) 2003 Werner Trobin <trobin@kde.org>
3 Copyright (C) 2003 David Faure <faure@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#undef signals // Collides with GTK symbols
21#include <wv2/olestream.h>
22
23#include "graphicshandler.h"
24#include "document.h"
25
26#include <KoStoreDevice.h>
27#include <KoSize.h>
28#include <kdebug.h>
29
30using namespace wvWare;
31
32KWordPictureHandler::KWordPictureHandler( Document* doc ) : TQObject(), m_doc(doc)
33{
34}
35
36#ifdef IMAGE_IMPORT
37
38void KWordPictureHandler::bitmapData( OLEImageReader& reader, SharedPtr<const Word97::PICF> /*picf*/ )
39{
40 kdDebug(30513) << "Bitmap data found ->>>>>>>>>>>>>>>>>>>>>>>>>>>>> size=" << reader.size() << endl;
41
42}
43
44void KWordPictureHandler::wmfData( OLEImageReader& reader, SharedPtr<const Word97::PICF> picf )
45{
46 kdDebug(30513) << "wmf data found ->>>>>>>>>>>>>>>>>>>>>>>>>>>>> size=" << reader.size() << endl;
47
48 // We have two things to do here
49 // 1 - Create the frameset and its frame
50 // 2 - Store the picture in the store
51 // We combine those two things into one call to the document
52 KoSize size( (double)picf->dxaGoal / 20.0, (double)picf->dyaGoal / 20.0 );
53 kdDebug(30513) << "size=" << size << endl;
54 KoStoreDevice* dev = m_doc->createPictureFrameSet( size );
55 Q_ASSERT(dev);
56 if ( !dev )
57 return; // ouch
58
59#define IMG_BUF_SIZE 2048
60 wvWare::U8 buf[IMG_BUF_SIZE];
61 TQ_LONG len = reader.size();
62 while ( len > 0 ) {
63 size_t n = reader.read( buf, TQMIN( len, IMG_BUF_SIZE ) );
64 TQ_LONG n1 = dev->writeBlock( (const char*)buf, n );
65 Q_ASSERT( (size_t)n1 == n );
66 if ( (size_t)n1 != n )
67 return; // ouch
68 len -= n;
69 }
70 Q_ASSERT( len == 0 );
71 dev->close();
72}
73
74void KWordPictureHandler::tiffData( const UString& /*name*/, SharedPtr<const Word97::PICF> /*picf*/ )
75{
76}
77
78#endif // IMAGE_IMPORT
79
80#include "graphicshandler.moc"
This class hold a whole document with its headers, footers, footnotes, endnotes, content,...