28#include <tdeversion.h>
29#if ! KDE_IS_VERSION( 3,1,90 )
30#include <kdebugclasses.h>
33#include <kowmfpaint.h>
34#include "KoPictureKey.h"
35#include "KoPictureBase.h"
36#include "KoPictureWmf.h"
38KoPictureWmf::KoPictureWmf(
void) : m_clipart(KoPictureType::formatVersionTQPicture)
42KoPictureWmf::~KoPictureWmf(
void)
46KoPictureBase* KoPictureWmf::newCopy(
void)
const
48 return new KoPictureWmf(*
this);
51KoPictureType::Type KoPictureWmf::getType(
void)
const
53 return KoPictureType::TypeWmf;
56bool KoPictureWmf::isNull(
void)
const
58 return m_clipart.isNull();
61void KoPictureWmf::drawTQPicture(TQPicture& clipart, TQPainter& painter,
62 int x,
int y,
int width,
int height,
int sx,
int sy,
int sw,
int sh)
64 kdDebug(30003) <<
"Drawing KoPictureWmf " <<
this << endl;
65 kdDebug(30003) <<
" x=" << x <<
" y=" << y <<
" width=" << width <<
" height=" << height << endl;
66 kdDebug(30003) <<
" sx=" << sx <<
" sy=" << sy <<
" sw=" << sw <<
" sh=" << sh << endl;
69 TQRect br = clipart.boundingRect();
70 kdDebug(30003) <<
" Bounding rect. " << br << endl;
72 painter.translate(x,y);
73 if ( br.width() && br.height() )
74 painter.scale(
double(width)/
double(br.width()),
double(height)/
double(br.height()));
76 kdWarning(30003) <<
"Null bounding rectangle: " << br.width() <<
" x " << br.height() << endl;
77 painter.drawPicture(0,0,clipart);
81void KoPictureWmf::draw(TQPainter& painter,
int x,
int y,
int width,
int height,
int sx,
int sy,
int sw,
int sh,
bool )
83 drawTQPicture(m_clipart, painter, x, y, width, height, sx, sy, sw, sh);
86bool KoPictureWmf::loadData(
const TQByteArray& array,
const TQString& )
89 kdDebug(30003) <<
"Trying to load clipart... (Size:" << array.size() <<
")" << endl;
95 kdWarning(30003) <<
"Loading WMF has failed! (KoPictureWmf::load)" << endl;
100 wmf.
play(m_clipart,
true);
105bool KoPictureWmf::save(TQIODevice* io)
const
108 TQ_ULONG size=io->writeBlock(m_rawData);
109 return (size==m_rawData.size());
112TQSize KoPictureWmf::getOriginalSize(
void)
const
114 return m_originalSize;
117TQPixmap KoPictureWmf::generatePixmap(
const TQSize& size,
bool )
120 TQPixmap pixmap(size);
124 p.setBackgroundColor( TQt::white );
125 pixmap.fill( TQt::white );
127 if ( m_originalSize.width() && m_originalSize.height() )
128 p.scale( (
double)pixmap.width() / (
double)m_originalSize.width(), (
double)pixmap.height() / (
double)m_originalSize.height() );
129 p.drawPicture( m_clipart );
134TQString KoPictureWmf::getMimeType(
const TQString& )
const
136 return "image/x-wmf";
KoWmfPaint inherits the abstract class KoWmfRead and redirects WMF actions onto a TQPaintDevice.
bool play(TQPaintDevice &target, bool relativeCoord=false)
play WMF file on a TQPaintDevice.
virtual bool load(const TQString &fileName)
Load WMF file.
virtual TQRect boundingRect(void) const
Returns the bounding rectangle Standard Meta File : return the bounding box from setWindowOrg and set...