From koffice-devel Mon Jul 16 16:43:40 2001 From: David Faure Date: Mon, 16 Jul 2001 16:43:40 +0000 To: koffice-devel Subject: Fwd: patches X-MARC-Message: https://marc.info/?l=koffice-devel&m=99530658912405 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------Boundary-00=_SSRK88ROM4PG5VBXUXX7" --------------Boundary-00=_SSRK88ROM4PG5VBXUXX7 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 8bit Anyone actually knowing about KIllu's code ? :) Hrm I mean, Kontour :) ---------- Forwarded Message ---------- Subject: patches Date: Mon, 16 Jul 2001 21:35:41 +0400 (MSD) From: rm To: david@mandrakesoft.com some patches: 2)fixes at options dialog for setting modified flag 3)fixes at GCanvas: duplicate and using QPixmap for containing picture I think it is some faster for redrawing but it is with non transparent background do you know how to to do transparent background? or better use QPicture? 4)set modified flag at KIlluView 5)fixes exporting to image use background color ------------------------------------------------------- -- David FAURE, david@mandrakesoft.com, faure@kde.org http://perso.mandrakesoft.com/~david/, http://www.konqueror.org/ KDE, Making The Future of Computing Available Today --------------Boundary-00=_SSRK88ROM4PG5VBXUXX7 Content-Type: text/plain; charset="koi8-r"; name="killu.2.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="killu.2.patch" diff -u killustrator/OptionDialog.cc ki/OptionDialog.cc --- killustrator/OptionDialog.cc Mon Jul 2 22:38:13 2001 +++ ki/OptionDialog.cc Wed Jul 11 15:26:35 2001 @@ -153,17 +153,12 @@ QBoxLayout *layout=new QHBoxLayout(parent, KDialogBase::marginHint(), KDialogBase::spacingHint()); QLabel* clabel = new QLabel(i18n("Background Color"), parent); bgbutton = new KColorButton(parent); - connect (bgbutton, SIGNAL(changed (const QColor&)), this, SLOT(colorChanged(const QColor&))); + connect (bgbutton, SIGNAL(changed (const QColor&)), this, SLOT(slotSetModified())); bgbutton->setColor(doc->activePage()->bgColor()); layout->addWidget(clabel); layout->addWidget(bgbutton); } -void OptionDialog::colorChanged(const QColor&) -{ - modified = true; -} - /*Grid*/ void OptionDialog::createGridWidget (QWidget* parent) @@ -183,6 +178,7 @@ hspinbox->setFormatString ("%-3.3f"); hspinbox->setEditable (true); hspinbox->setRange (0, 1000); + connect (hspinbox, SIGNAL(valueChanged (float)), this, SLOT(slotSetModified())); grid->addWidget(hspinbox, 0, 1); label = new QLabel(i18n("Vertically"), box); @@ -192,6 +188,7 @@ vspinbox->setFormatString ("%-3.3f"); vspinbox->setEditable (true); vspinbox->setRange (0, 1000); + connect (vspinbox, SIGNAL(valueChanged (float)), this, SLOT(slotSetModified())); grid->addWidget(vspinbox, 1, 1); hspinbox->setValue(doc->horizGridDistance()); @@ -199,15 +196,18 @@ gbutton = new QCheckBox(i18n("Snap To Grid"), parent); gbutton->setDown(doc->snapToGrid()); + connect (gbutton, SIGNAL(stateChanged (int)), this, SLOT(slotSetModified())); layout->addWidget(gbutton, 1, 0); sbutton = new QCheckBox(i18n("Show Grid"), parent); sbutton->setDown(doc->showGrid()); + connect (sbutton, SIGNAL(stateChanged (int)), this, SLOT(slotSetModified())); layout->addWidget(sbutton, 1, 1); cbutton = new KColorButton(parent); cbutton->setColor(doc->gridColor()); QLabel* clabel = new QLabel(i18n("Grid Color"), parent); + connect (cbutton, SIGNAL(changed (const QColor&)), this, SLOT(slotSetModified())); layout->addWidget(cbutton, 2, 1); layout->addWidget(clabel, 2, 0); } @@ -435,6 +435,11 @@ } /**/ +void OptionDialog::slotSetModified() +{ + modified = true; +} + void OptionDialog::slotApply() { /*Document settings*/ @@ -451,7 +456,10 @@ doc->setVertHelplines(vertLines); if(modified) + { doc->setModified(); + modified = false; + } doc->emitChanged(); } diff -u killustrator/OptionDialog.h ki/OptionDialog.h --- killustrator/OptionDialog.h Mon Jul 2 22:38:13 2001 +++ ki/OptionDialog.h Wed Jul 11 15:12:07 2001 @@ -56,7 +56,7 @@ void slotApply(); void slotOk(); - void colorChanged(const QColor&); + void slotSetModified(); void addHorizLine (); void updateHorizLine (); --------------Boundary-00=_SSRK88ROM4PG5VBXUXX7 Content-Type: text/plain; charset="koi8-r"; name="killu.3.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="killu.3.patch" diff -u killustrator/GClipart.cc ki/GClipart.cc --- killustrator/GClipart.cc Mon Jul 2 22:38:13 2001 +++ ki/GClipart.cc Mon Jul 16 14:00:37 2001 @@ -21,51 +21,59 @@ */ -#include +#include "GClipart.h" + #include #include -#include "GDocument.h" #include +#include + +#include "GDocument.h" GClipart::GClipart (GDocument *doc) :GObject(doc) { - - pic = 0L; + pix = 0L; } GClipart::GClipart (GDocument *doc, const QDomElement &element) : GObject (doc, element.namedItem("gobject").toElement()) { - url=element.attribute("src"); - QWinMetaFile wmf; - if (url.isLocalFile () && wmf.load (url.path ())) { - QRect r = wmf.bbox (); - width = (r.right () - r.left ()) * 72.0 / wmf.dpi (); - height = (r.bottom () - r.top ()) * 72.0 / wmf.dpi (); - pic = new QPicture (); - wmf.paint (pic); - } - else - // construct a malformed url - url = KURL (); - calcBoundingBox (); + url = element.attribute("src"); + QWinMetaFile wmf; + if(url.isLocalFile () && wmf.load (url.path ())) + { + QRect r = wmf.bbox (); + width = (r.right () - r.left ()) * 72.0 / wmf.dpi (); + height = (r.bottom () - r.top ()) * 72.0 / wmf.dpi (); + pix = new QPixmap(qRound(width),qRound(height)); + QPainter p(pix); + p.setBackgroundMode(TransparentMode); + p.eraseRect(0,0,qRound(width),qRound(height)); + wmf.paint (pix); + } + else + // construct a malformed url + url = KURL (); + calcBoundingBox (); } GClipart::GClipart (GDocument *doc, const QString &name) :GObject(doc) ,url (name) { - QWinMetaFile wmf; - wmf.load(name); - QRect r = wmf.bbox (); - - width = (r.right () - r.left ()) * 72.0 / wmf.dpi (); - height = (r.bottom () - r.top ()) * 72.0 / wmf.dpi (); - pic = new QPicture (); - wmf.paint (pic); - calcBoundingBox (); + QWinMetaFile wmf; + wmf.load(name); + QRect r = wmf.bbox (); + width = (r.right () - r.left ()) * 72.0 / wmf.dpi (); + height = (r.bottom () - r.top ()) * 72.0 / wmf.dpi (); + pix = new QPixmap(qRound(width),qRound(height)); + QPainter p(pix); + p.setBackgroundMode(TransparentMode); + p.eraseRect(0,0,qRound(width),qRound(height)); + wmf.paint (pix); + calcBoundingBox (); } GClipart::GClipart (const GClipart& obj) @@ -74,62 +82,60 @@ url = obj.url; width = obj.width; height = obj.height; + if (obj.pix) + pix = new QPixmap (*obj.pix); calcBoundingBox (); } -QString GClipart::typeName () const { +QString GClipart::typeName () const +{ return i18n("Clipart object"); } -void GClipart::draw (QPainter& p, bool /*withBasePoints*/, bool outline, bool) { +void GClipart::draw (QPainter& p, bool /*withBasePoints*/, bool outline, bool) +{ p.save (); - if (outline) { + p.setWorldMatrix (tmpMatrix, true); + if (outline) + { p.setPen (black); - p.drawRect (qRound (box.x ()), qRound (box.y ()), qRound (box.width ()), qRound (box.height ())); + p.drawRect (0, 0, qRound (width), qRound (height)); + int w5 = qRound (width / 5.0); + int h5 = qRound (height / 5.0); + p.drawLine (0, w5, w5, 0); + p.drawLine (qRound (width) - w5, qRound (height), qRound (width), qRound (height) - h5); } - else { - if (! url.isMalformed ()) { - p.setWorldMatrix (tmpMatrix, true); - QWMatrix mx = p.worldMatrix (); - QRect mr = mx.map (QRect (0, 0, qRound (width), qRound (height))); - QRect oldWin = p.window (); - QRect vPort = p.viewport (); - p.setViewport (mr); - p.setWorldMatrix (QWMatrix ()); - p.drawPicture (*pic); - p.setWindow (oldWin); - p.setViewport (vPort); - } - else { + else + { + if (pix != 0L) + p.drawPixmap (0, 0, *pix); + else + { p.setPen (gray); - p.fillRect (qRound (box.x ()), qRound (box.y ()), qRound (box.width ()), qRound (box.height ()), - gray); + p.fillRect (0, 0, qRound (width), qRound (height), gray); } } p.restore (); -} +} -void GClipart::calcBoundingBox () { +void GClipart::calcBoundingBox () +{ calcUntransformedBoundingBox (Coord (0, 0), Coord (width, 0), Coord (width, height), Coord (0, height)); } -GObject* GClipart::copy () { +GObject* GClipart::copy () +{ return new GClipart (*this); } -/*GObject* GClipart::create (GDocument *doc, const QDomElement &element) +QDomElement GClipart::writeToXml (QDomDocument &document) { - return new GClipart (doc, element); -}*/ - -QDomElement GClipart::writeToXml (QDomDocument &document) { - - // FIXME (Werner): Make this store internal/external depening on the user's wish - QDomElement element=document.createElement("clipart"); - element.setAttribute ("src", url.url ()); - element.appendChild(GObject::writeToXml(document)); - return element; + // FIXME (Werner): Make this store internal/external depening on the user's wish + QDomElement element=document.createElement("clipart"); + element.setAttribute ("src", url.url ()); + element.appendChild(GObject::writeToXml(document)); + return element; } #include diff -u killustrator/GClipart.h ki/GClipart.h --- killustrator/GClipart.h Mon Jul 2 22:38:13 2001 +++ ki/GClipart.h Mon Jul 16 13:56:35 2001 @@ -25,11 +25,11 @@ #ifndef GClipart_h_ #define GClipart_h_ -#include #include +#include class QWinMetaFile; -class QPicture; +class QPixmap; class QPainter; class GClipart : public GObject @@ -38,7 +38,6 @@ public: GClipart (GDocument* parent, const QString &name); GClipart (GDocument* parent, const QDomElement &element); - GClipart (GDocument* parent ); GClipart (const GClipart& obj); ~GClipart () {} @@ -49,7 +48,6 @@ virtual QString typeName () const; virtual GObject* copy (); - //virtual GObject* create (GDocument *doc, const QDomElement &element); virtual QDomElement writeToXml(QDomDocument &document); @@ -57,7 +55,7 @@ void calcBoundingBox (); private: - QPicture *pic; + QPixmap *pix; KURL url; float width, height; }; --------------Boundary-00=_SSRK88ROM4PG5VBXUXX7 Content-Type: text/plain; charset="koi8-r"; name="killu.4.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="killu.4.patch" diff -u killustrator/KIllustrator_view.cc ki/KIllustrator_view.cc --- killustrator/KIllustrator_view.cc Thu Jul 12 02:54:51 2001 +++ ki/KIllustrator_view.cc Mon Jul 16 14:14:11 2001 @@ -934,16 +934,20 @@ void KIllustratorView::slotShowGrid( bool b ) { if (b!=activeDocument()->showGrid()) - activeDocument()->showGrid( b ); + { + activeDocument()->showGrid( b ); + activeDocument()->setModified(); + } canvas->update(); } void KIllustratorView::slotShowHelplines( bool b ) { - if (b!=activeDocument()->showHelplines()) - { - activeDocument()->showHelplines( b ); - } + if (b!=activeDocument()->showHelplines()) + { + activeDocument()->showHelplines( b ); + activeDocument()->setModified(); + } canvas->update(); } @@ -958,14 +962,20 @@ void KIllustratorView::slotAlignToGrid( bool b ) { - if (b!=activeDocument()->snapToGrid()) - activeDocument()->snapToGrid( b ); + if (b!=activeDocument()->snapToGrid()) + { + activeDocument()->snapToGrid( b ); + activeDocument()->setModified(); + } } void KIllustratorView::slotAlignToHelplines( bool b ) { - if (b!=activeDocument()->alignToHelplines()) + if (b!=activeDocument()->alignToHelplines()) + { activeDocument()->alignToHelplines( b ); + activeDocument()->setModified(); + } } void KIllustratorView::slotTransformPosition() --------------Boundary-00=_SSRK88ROM4PG5VBXUXX7 Content-Type: text/plain; charset="koi8-r"; name="killu.5.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="killu.5.patch" diff -u killustrator/filter/ImageExport.cc ki/filter/ImageExport.cc --- killustrator/filter/ImageExport.cc Tue May 22 06:24:30 2001 +++ ki/filter/ImageExport.cc Mon Jul 16 21:52:59 2001 @@ -22,6 +22,8 @@ */ +#include "ImageExport.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -32,29 +34,33 @@ #include #include -#include "ImageExport.h" #include "GDocument.h" #include "GPage.h" #define RESOLUTION 72.0 -ImageExport::ImageExport () { +ImageExport::ImageExport () +{ // #ifdef HAVE_QIMGIO // qInitImageIO (); // #endif } -ImageExport::~ImageExport () { +ImageExport::~ImageExport () +{ } -bool ImageExport::setup (GDocument *, const char* fmt) { +bool ImageExport::setup (GDocument *, const char* fmt) +{ bool formatSupported = false; QStrList formats = QImageIO::outputFormats (); char* str = formats.first (); format = QString (); - while (str) { - if (strcasecmp (str, fmt) == 0) { + while (str) + { + if (strcasecmp (str, fmt) == 0) + { format = fmt; format = format.upper (); formatSupported = true; @@ -65,7 +71,8 @@ return formatSupported; } -bool ImageExport::exportToFile (GDocument* doc) { +bool ImageExport::exportToFile (GDocument* doc) +{ if (format.isNull ()) return false; @@ -78,10 +85,10 @@ if (buffer == 0L) return false; - buffer->fill (Qt::white); + buffer->fill (doc->activePage()->bgColor()); QPainter p; p.begin (buffer); - p.setBackgroundColor (Qt::white); + p.setBackgroundColor (doc->activePage()->bgColor()); p.eraseRect (0, 0, w, h); p.scale (RESOLUTION / 72.0, RESOLUTION / 72.0); @@ -90,27 +97,10 @@ p.end (); - // compute the bounding box - Rect box = doc->activePage()->boundingBoxForAllObjects (); - // and copy the affected area to the new pixmap - //the +1 fixes bug #20361, Alex - QPixmap *pixmap = new QPixmap (qRound (box.width ())+1, - qRound (box.height ())+1); - //kdDebug()<<"export: box.w=="<0) sx--; - if (sy>0) sy--; - bitBlt (pixmap, 0, 0, buffer, sx, sy, - qRound (box.width ())+1, qRound (box.height ())+1); - delete buffer; - // now create an image - QImage img = pixmap->convertToImage (); + QImage img = buffer->convertToImage (); img.setAlphaBuffer (true); - delete pixmap; + delete buffer; // and save the image in requested format return img.save(outputFileName (), format.latin1()); diff -u killustrator/filter/ImageExport.h ki/filter/ImageExport.h --- killustrator/filter/ImageExport.h Thu Jul 9 20:33:31 1998 +++ ki/filter/ImageExport.h Mon Jul 16 21:52:04 2001 @@ -30,7 +30,8 @@ /** * An export filter for image formats. */ -class ImageExport : public ExportFilter { +class ImageExport : public ExportFilter +{ public: ImageExport (); ~ImageExport (); --------------Boundary-00=_SSRK88ROM4PG5VBXUXX7-- _______________________________________________ Koffice-devel mailing list Koffice-devel@master.kde.org http://master.kde.org/mailman/listinfo/koffice-devel