[Uml-devel] branches/work/soc-umbrello

Gopala Krishna A krishna.ggk at gmail.com
Tue Jul 8 19:21:58 UTC 2008


SVN commit 829643 by gopala:

Merged revisions 821827 via svnmerge from 
svn+ssh://svn.kde.org/home/kde/trunk/KDE/kdesdk/umbrello

........
  r821827 | gopala | 2008-06-18 21:24:54 +0530 (Wed, 18 Jun 2008) | 4 lines
  
  Fixed svg exporting of the diagram.
  Had to use QSvgGenerator as the paint device rather than the QPicture.
........


 _M            . (directory)  
 M  +15 -16    umbrello/umlviewimageexportermodel.cpp  


** branches/work/soc-umbrello #property svnmerge-integrated
   - /trunk/KDE/kdesdk/umbrello:1-814855,815154,815906,815954,816854,816861,817524,817552,819993,820008
   + /trunk/KDE/kdesdk/umbrello:1-814855,815154,815906,815954,816854,816861,817524,817552,819993,820008,821827
--- branches/work/soc-umbrello/umbrello/umlviewimageexportermodel.cpp #829642:829643
@@ -25,6 +25,7 @@
 #include <QtGui/QPrinter>
 #include <QtCore/QDir>
 #include <QtCore/QRegExp>
+#include <QtSvg/QSvgGenerator>
 
 // kde include files
 #include <kdebug.h>
@@ -327,30 +328,28 @@
     return true;
 }
 
-bool UMLViewImageExporterModel::exportViewToSvg(UMLView* view, const QString &fileName) const {
+bool UMLViewImageExporterModel::exportViewToSvg(UMLView* view, const QString &fileName) const
+{
     bool exportSuccessful;
+    QRectF rect = view->umlScene()->getDiagramRect();
 
-    QPicture* diagram = new QPicture();
+    QSvgGenerator generator;
+    generator.setFileName(fileName);
+    generator.setSize(rect.toRect().size());
+    QPainter painter(&generator);
 
-    // do not call printer.setup(); because we want no user
-    // interaction here
-    QPainter* painter = new QPainter();
-    painter->begin( diagram );
-
     // make sure the widget sizes will be according to the
     // actually used printer font, important for getDiagramRect()
     // and the actual painting
-    view->umlScene()->forceUpdateWidgetFontMetrics(painter);
+    view->umlScene()->forceUpdateWidgetFontMetrics(&painter);
 
-    QRectF rect = view->umlScene()->getDiagramRect();
-    painter->translate(-rect.x(),-rect.y());
-    view->umlScene()->getDiagram(rect,*painter);
-    painter->end();
-    exportSuccessful = diagram->save(fileName);
+    painter.translate(-rect.x(),-rect.y());
+    view->umlScene()->getDiagram(rect, painter);
+    painter.end();
 
-    // delete painter and printer before we try to open and fix the file
-    delete painter;
-    delete diagram;
+    //FIXME: Determine the status of svg generation.
+    exportSuccessful = true;
+
     // next painting will most probably be to a different device (i.e. the screen)
     view->umlScene()->forceUpdateWidgetFontMetrics(0);
 




More information about the umbrello-devel mailing list