[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    kspread: zoom in embedded case
From:       Ariya Hidayat <ariya () kde ! org>
Date:       2003-11-16 11:38:04
[Download RAW message or body]

As described in bug #45505, embedded parts sometimes don't zoom 
correctly. Even if you embed a KSpread spreadsheet inside another 
KSpread spreadsheet, the zoom is ugly (using the painter scaling, ala 
KSpread 1.2). The patch fixes this problem.

There's still another big problem I'm investigasting: KSpread can't 
print embedded parts correctly. This is broken since long time, IIRC 
(after 1.2). KWord does that just fine. I spent hours to track it but 
still couldn't find the cause, so if somebody (David ? Werner ?) know 
better about embedded part printing, please give me some insight...

Best regards,

Ariya Hidayat
http://ariya.pandu.org

["embed.patch" (text/plain)]

--- kspread_canvas.cc.orig	2003-11-07 09:55:35.000000000 +0100
+++ kspread_canvas.cc	2003-11-16 12:17:02.000000000 +0100
@@ -3556,7 +3556,8 @@ void KSpreadCanvas::paintChildren( QPain
     {
       // #### todo: paint only if child is visible inside rect
       painter.save();
-      m_pDoc->paintChild( itChild.current(), painter, m_pView );
+      m_pDoc->paintChild( itChild.current(), painter, m_pView,
+        m_pDoc->zoom()/100.0,  m_pDoc->zoom()/100.0 );
       painter.restore();
     }
   }
--- kspread_doc.cc.orig	2003-09-09 20:03:24.000000000 +0200
+++ kspread_doc.cc	2003-11-16 12:18:54.000000000 +0100
@@ -789,8 +789,12 @@ void KSpreadDoc::paintContent( QPainter&
 {
   //  ElapsedTime et( "KSpreadDoc::paintContent1" );
     //kdDebug(36001) << "KSpreadDoc::paintContent m_zoom=" << m_zoom << " zoomX=" << \
zoomX << " zoomY=" << zoomY << " transparent=" << transparent << endl; +
+    // only one zoom is supported
+    double d_zoom = zoomX;
+
+    // save current zoom
     int oldZoom = m_zoom;
-    setZoomAndResolution( 100, QPaintDevice::x11AppDpiX(), \
QPaintDevice::x11AppDpiY() );  if ( m_zoomedResolutionX != zoomX || \
m_zoomedResolutionY != zoomY )  {
         setResolution( zoomX, zoomY );
@@ -798,6 +802,7 @@ void KSpreadDoc::paintContent( QPainter&
         newZoomAndResolution( false, forPrint );
     }
 
+    // use active sheet, or first sheet
     KSpreadSheet* table = 0L;
     if ( !m_activeTable )
         table = m_pMap->firstTable();
@@ -806,13 +811,22 @@ void KSpreadDoc::paintContent( QPainter&
     if ( !table )
         return;
 
+    // KSpread support zoom, therefore no need to scale with worldMatrix
+    QWMatrix matrix = painter.worldMatrix();
+    matrix.setMatrix( 1, 0, 0, 1, matrix.dx(), matrix.dy() );
+    QRect prect = rect;
+    prect.setWidth( prect.width() * painter.worldMatrix().m11() );
+    prect.setHeight( prect.height() * painter.worldMatrix().m22() );
+    setZoomAndResolution( d_zoom * 100, QPaintDevice::x11AppDpiX(), \
QPaintDevice::x11AppDpiY() ); +
+    // paint the content, now zoom is correctly set
     kdDebug(36001)<<"paintContent-------------------------------------\n";
     painter.save();
-
-    // painter.scale(zoomX, zoomY);
-    paintContent( painter, rect, transparent, table, false );
-
+    painter.setWorldMatrix( matrix );
+    paintContent( painter, prect, transparent, table, false );
     painter.restore();
+
+    // restore zoom
     m_zoom = oldZoom;
     setZoomAndResolution( oldZoom, QPaintDevice::x11AppDpiX(), \
QPaintDevice::x11AppDpiY() );  }



_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic