summaryrefslogtreecommitdiffstats
path: root/filters/kword/msword/graphicshandler.cpp
blob: 234a71e927e2790267c19285ac8f29cf5bc2f1cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* This file is part of the KOffice project
   Copyright (C) 2003 Werner Trobin <trobin@kde.org>
   Copyright (C) 2003 David Faure <faure@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License version 2 as published by the Free Software Foundation.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#undef signals // Collides with GTK symbols
#include <wv2/olestream.h>

#include "graphicshandler.h"
#include "document.h"

#include <KoStoreDevice.h>
#include <KoSize.h>
#include <kdebug.h>

using namespace wvWare;

KWordPictureHandler::KWordPictureHandler( Document* doc ) : TQObject(), m_doc(doc)
{
}

#ifdef IMAGE_IMPORT

void KWordPictureHandler::bitmapData( OLEImageReader& reader, SharedPtr<const Word97::PICF> /*picf*/ )
{
    kdDebug(30513) << "Bitmap data found ->>>>>>>>>>>>>>>>>>>>>>>>>>>>> size=" << reader.size() << endl;

}

void KWordPictureHandler::wmfData( OLEImageReader& reader, SharedPtr<const Word97::PICF> picf )
{
    kdDebug(30513) << "wmf data found ->>>>>>>>>>>>>>>>>>>>>>>>>>>>> size=" << reader.size() << endl;

    // We have two things to do here
    // 1 - Create the frameset and its frame
    // 2 - Store the picture in the store
    // We combine those two things into one call to the document
    KoSize size( (double)picf->dxaGoal / 20.0, (double)picf->dyaGoal / 20.0 );
    kdDebug(30513) << "size=" << size << endl;
    KoStoreDevice* dev = m_doc->createPictureFrameSet( size );
    Q_ASSERT(dev);
    if ( !dev )
        return; // ouch

#define IMG_BUF_SIZE 2048
    wvWare::U8 buf[IMG_BUF_SIZE];
    TQ_LONG len = reader.size();
    while ( len > 0 )  {
        size_t n = reader.read( buf, TQMIN( len, IMG_BUF_SIZE ) );
        TQ_LONG n1 = dev->writeBlock( (const char*)buf, n );
        Q_ASSERT( (size_t)n1 == n );
        if ( (size_t)n1 != n )
            return; // ouch
        len -= n;
    }
    Q_ASSERT( len == 0 );
    dev->close();
}

void KWordPictureHandler::tiffData( const UString& /*name*/, SharedPtr<const Word97::PICF> /*picf*/ )
{
}

#endif // IMAGE_IMPORT

#include "graphicshandler.moc"