[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Jul 30 06:57:55 CEST 2003


CVS commit by staikos: 

fix another crash found by regression tests, and implement printing images and
postscript from dcop.  Seems to have trouble with printing empty plots in
postscript, though printing empty plots to images works.  Could indicate a bug
in the printing code.


  M +2 -0      kst.h   1.18
  M +24 -7     kstiface_impl.cpp   1.8
  M +1 -0      kstview.cpp   1.23


--- kdeextragear-2/kst/kst/kst.h  #1.17:1.18
@@ -244,4 +244,6 @@ public slots:
   void registerDocChange();
 
+  KstView *viewObject() { return view; }
+
 private:
   /** the configuration object of the application */

--- kdeextragear-2/kst/kst/kstiface_impl.cpp  #1.7:1.8
@@ -26,4 +26,6 @@
 #include "kstcolorsequence.h"
 #include "kstvcurve.h"
+#include "kstview.h"
+#include <kprinter.h>
 #include <assert.h>
 
@@ -351,5 +353,5 @@ KstPlot *p = KST::plotList.FindKstPlot(n
   if (p) {
     KST::plotList.remove(p);
-    delete p;
+    //delete p; autodelets
     _doc->update();
     _doc->setModified();
@@ -435,13 +437,28 @@ return c->tagName();
 
 
-bool KstIfaceImpl::printImage(const QString& filename) {
-// FIXME
-return false;
+bool KstIfaceImpl::printImage(const QString& url) {
+  if (url.isEmpty()) {
+    return false;
+  }
+
+  KstView *view = _app->viewObject();
+  view->printToGraphicsFile(url, view->width(), view->height());
+return true; // FIXME: eventually return an error code
 }
 
 
-bool KstIfaceImpl::printPostScript(const QString& filename) {
-// FIXME
-return false;
+bool KstIfaceImpl::printPostScript(const QString& url) {
+  if (url.isEmpty()) {
+    return false;
+  }
+
+  KstView *view = _app->viewObject();
+  KPrinter printer;
+  printer.setPageSize(KPrinter::Letter);
+  printer.setOrientation(KPrinter::Landscape);
+  printer.setOutputToFile(true);
+  printer.setOutputFileName(url);
+  view->print(&printer);
+return true; // FIXME: eventually return an error code
 }
 

--- kdeextragear-2/kst/kst/kstview.cpp  #1.22:1.23
@@ -115,4 +115,5 @@ KstView::~KstView() {
 }
 
+// FIXME: make this return an error code!
 void KstView::printToGraphicsFile(const QString &filename, int in_w, int in_h) {
   float w, h, tlx, tly;




More information about the Kst mailing list