[Uml-devel] KDE/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Mon Dec 11 22:59:16 UTC 2006


SVN commit 612609 by okellogg:

merge r610682:611560 from branches/KDE/3.5

 M  +3 -0      ChangeLog  
 M  +1 -1      umbrello/umldoc.cpp  
 M  +24 -17    umbrello/umlview.cpp  


--- trunk/KDE/kdesdk/umbrello/ChangeLog #612608:612609
@@ -9,7 +9,10 @@
   http://www.geeksoc.org/~jr/umbrello/uml-devel/9862.html
 * Note widget is now always drawn on TOP of all widgets
   http://www.geeksoc.org/~jr/umbrello/uml-devel/9863.html
+* Optimized printer margins
+  http://www.geeksoc.org/~jr/umbrello/uml-devel/9895.html
 * Bugs/wishes from http://bugs.kde.org:
+* Umbrello saves too much copies at xmi (135606)
 * Artifacts of a component diagram are wrongly placed in Deployment View folder (137564)
 * Incorrect export to SQL (138139)
 
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #612608:612609
@@ -841,7 +841,7 @@
     if (s != NULL) {
         return s;
     }
-    s = new UMLStereotype(name);
+    s = new UMLStereotype(name, STR2ID(name));
     addStereotype(s);
     //emit modified();
     return s;
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #612608:612609
@@ -27,6 +27,7 @@
 #include <qcolor.h>
 #include <qmatrix.h>
 #include <qregexp.h>
+#include <q3paintdevicemetrics.h>
 //Added by qt3to4:
 #include <QTextStream>
 #include <QHideEvent>
@@ -223,33 +224,39 @@
 void UMLView::print(KPrinter *pPrinter, QPainter & pPainter) {
     int height, width;
     //get the size of the page
+    pPrinter->setFullPage( true );
+    Q3PaintDeviceMetrics metrics(pPrinter);
     QFontMetrics fm = pPainter.fontMetrics(); // use the painter font metrics, not the screen fm!
     int fontHeight  = fm.lineSpacing();
-    int marginX = pPrinter->margins().width();
-    int marginY = pPrinter->margins().height();
+    uint left, right, top, bottom;
+    // fetch printer margins individual for all four page sides, as at least top and bottom are not the same
+    pPrinter->margins ( &top, &left, &bottom, &right );
+    // give a little extra space at each side
+    left += 2;
+    right += 2;
+    top += 2;
+    bottom += 2;
 
     if(pPrinter->orientation() == KPrinter::Landscape) {
         // we are printing in LANDSCAPE --> swap marginX and marginY
-        // this is needed, as KPrinter reports width margin strictly as printer
-        // default orientation margin - and not depend on LANDSCAPE/PORTRAIT
-        int temp = marginX;
-        marginX = marginY;
-        marginY = temp;
+        uint right_old = right;
+        // the DiagramRight side is printed at PrintersTop
+        right = top;
+        // the DiagramTop side is printed at PrintersLeft
+        top = left;
+        // the DiagramLeft side is printed at PrintersBottom
+        left = bottom;
+        // the DiagramBottom side is printed at PrintersRight
+        bottom = right_old;
     }
 
     // The printer will probably use a different font with different font metrics,
     // force the widgets to update accordingly on paint
     forceUpdateWidgetFontMetrics(&pPainter);
 
-    //double margin at bottom of page as it doesn't print down there
-    //on my printer, so play safe as default.
-    if(pPrinter->orientation() == KPrinter::Portrait) {
-        width = pPrinter->width() - marginX * 2;
-        height = pPrinter->height() - fontHeight - 4 - marginY * 3;
-    } else {
-        width = pPrinter->width() - marginX * 2;
-        height = pPrinter->height() - fontHeight - 4 - marginY * 2;
-    }
+    width = metrics.width() - left - right;
+    height = metrics.height() - top - bottom;
+
     //get the smallest rect holding the diagram
     QRect rect = getDiagramRect();
     //now draw to printer
@@ -346,7 +353,7 @@
     // set viewport - the physical mapping
     // --> Qt's QPainter will map all drawed elements from diagram area ( window )
     //     to printer area ( viewport )
-    pPainter.setViewport( marginX, marginY, width, height );
+    pPainter.setViewport( left, top, width, height );
 
     // get Diagram
     getDiagram(QRect(rect.x(), rect.y(), windowWidth, diagramHeight), pPainter);




More information about the umbrello-devel mailing list