29#include <kowmfpaint.h>
30#include "KoPictureKey.h"
31#include "KoPictureBase.h"
32#include "KoPictureWmf.h"
34KoPictureWmf::KoPictureWmf(
void) : m_clipart(KoPictureType::formatVersionTQPicture)
38KoPictureWmf::~KoPictureWmf(
void)
42KoPictureBase* KoPictureWmf::newCopy(
void)
const
44 return new KoPictureWmf(*
this);
47KoPictureType::Type KoPictureWmf::getType(
void)
const
49 return KoPictureType::TypeWmf;
52bool KoPictureWmf::isNull(
void)
const
54 return m_clipart.isNull();
57void KoPictureWmf::drawTQPicture(TQPicture& clipart, TQPainter& painter,
58 int x,
int y,
int width,
int height,
int sx,
int sy,
int sw,
int sh)
60 kdDebug(30003) <<
"Drawing KoPictureWmf " <<
this << endl;
61 kdDebug(30003) <<
" x=" << x <<
" y=" << y <<
" width=" << width <<
" height=" << height << endl;
62 kdDebug(30003) <<
" sx=" << sx <<
" sy=" << sy <<
" sw=" << sw <<
" sh=" << sh << endl;
65 TQRect br = clipart.boundingRect();
66 kdDebug(30003) <<
" Bounding rect. " << br << endl;
68 painter.translate(x,y);
69 if ( br.width() && br.height() )
70 painter.scale(
double(width)/
double(br.width()),
double(height)/
double(br.height()));
72 kdWarning(30003) <<
"Null bounding rectangle: " << br.width() <<
" x " << br.height() << endl;
73 painter.drawPicture(0,0,clipart);
77void KoPictureWmf::draw(TQPainter& painter,
int x,
int y,
int width,
int height,
int sx,
int sy,
int sw,
int sh,
bool )
79 drawTQPicture(m_clipart, painter, x, y, width, height, sx, sy, sw, sh);
82bool KoPictureWmf::loadData(
const TQByteArray& array,
const TQString& )
85 kdDebug(30003) <<
"Trying to load clipart... (Size:" << array.size() <<
")" << endl;
91 kdWarning(30003) <<
"Loading WMF has failed! (KoPictureWmf::load)" << endl;
96 wmf.
play(m_clipart,
true);
101bool KoPictureWmf::save(TQIODevice* io)
const
104 TQ_ULONG size=io->writeBlock(m_rawData);
105 return (size==m_rawData.size());
108TQSize KoPictureWmf::getOriginalSize(
void)
const
110 return m_originalSize;
113TQPixmap KoPictureWmf::generatePixmap(
const TQSize& size,
bool )
116 TQPixmap pixmap(size);
120 p.setBackgroundColor( TQt::white );
121 pixmap.fill( TQt::white );
123 if ( m_originalSize.width() && m_originalSize.height() )
124 p.scale( (
double)pixmap.width() / (
double)m_originalSize.width(), (
double)pixmap.height() / (
double)m_originalSize.height() );
125 p.drawPicture( m_clipart );
130TQString KoPictureWmf::getMimeType(
const TQString& )
const
132 return "image/x-wmf";
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...