Bug 60147 - Kspread fails to redraw during and after 'Print Preview'
Summary: Kspread fails to redraw during and after 'Print Preview'
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Laurent Montel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-20 20:08 UTC by Philippe Rigault
Modified: 2003-11-18 21:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Rigault 2003-06-20 20:08:54 UTC
Version:            (using KDE KDE 3.1.2)
Installed from:    Compiled From Sources

Version affected: kspread 1.2.91 (also happens on 1.2.90)

When doing a 'Print Preview' from kspread, the following happens:
- Just after 'Print Preview' is selected (before the actual 'Print Preview' windows appears), an area on the top left of the spreadsheet (main window) is blanked out (improperly rendered cells: no text and cell separation lines)
- Then the 'Print Preview' window shows up. The blanked area is still there.
- Moving the 'Print Preview' above the spreadsheet creates even more blanked areas on the spread sheet.
- After closing the 'Print Preview' window, some blanked areas remain on the speadsheet.

PS: This is only for Print Preview. The 'Print' action works correctly (no blank areas at any time, everything redrawn properly)
Comment 1 Lukáš Tinkl 2003-06-25 12:47:50 UTC
Subject: koffice/kspread

CVS commit by lukas: 

fix 60147: Kspread fails to redraw during and after 'Print Preview'

CCMAIL: 60147-done@bugs.kde.org


  M +3 -1      kspread_view.cc   1.685


--- koffice/kspread/kspread_view.cc  #1.684:1.685
@@ -3998,4 +3998,6 @@ void KSpreadView::print( KPrinter &prt )
     //Restore original orientation
     print->setPaperOrientation( _orient );
+
+    m_pCanvas->repaint();
 }
 


Comment 2 Philippe Rigault 2003-08-27 19:54:48 UTC
I am reopening this bug because it is not properly fixed. 
 
The fix only addresses the repaint in the following cases: 
	- only upon closing the Print Preview 
	- and only if the spreadsheet is not empty. 
 
It does not address the following: 
 
1. Repaint upon creation of the 'Print Preview' window, and during the time the 
'Print Preview' window is up. This is more easily seen by moving the 'Print 
Preview' window above the spreadsheet (things get worse and worse). 
 
2. Empty spreadsheet. If one selects 'Print Preview' on an empty spreadsheet, 
an informational window 'Nothing to print' pops up, and selecting 'OK' (or 
closing it) reverts to the blank spreadsheet *incorrectly* rendered (missing a 
repaint). Several comments here: 
  - Why deny users the ability to print an empty page ? The popup 'Nothing to 
print' should only be a warning, anc clicking 'OK' should actually lead to 
'Print Preview' of that blank page. 
  - The repaint behaviour of the 'Nothing to print' window should be fixed the 
same way as the 'Print Preview', i.e proper repaint during the lifetime of the 
window and upon closing. 
 
Comment 3 Philippe Rigault 2003-10-01 02:13:43 UTC
Bug still there in 1.2.93.  
Comment 4 Philippe Rigault 2003-11-04 22:54:17 UTC
Bug still there in KDE 3.2 beta1

KDE 3.1.93
Koffice-1.2.94
GCC-3.3.2
Comment 5 Ariya Hidayat 2003-11-05 22:03:10 UTC
Subject: koffice/kspread

CVS commit by ariya: 

fix redraw problem with Print Preview

CCMAIL: 60147-done@bugs.kde.org


  M +10 -5     kspread_view.cc   1.697


--- koffice/kspread/kspread_view.cc  #1.696:1.697
@@ -3992,13 +3992,18 @@ void KSpreadView::print( KPrinter &prt )
     print->print( painter, &prt );
 
-    painter.end();
+    //Restore original orientation
+    print->setPaperOrientation( _orient );
 
     m_pDoc->setZoomAndResolution( oldZoom, QPaintDevice::x11AppDpiX(), QPaintDevice::x11AppDpiY() );
-    m_pDoc->newZoomAndResolution( false, false );
+    m_pDoc->newZoomAndResolution( true, false );
 
-    //Restore original orientation
-    print->setPaperOrientation( _orient );
+    // Repaint at correct zoom
+    m_pDoc->emitBeginOperation( false );
+    setZoom( oldZoom, false );
+    QRect r( m_pTable->visibleRect( m_pCanvas ) );
+    activeTable()->setRegionPaintDirty( r );
+    m_pDoc->emitEndOperation( r );
 
-    m_pCanvas->repaint();
+    painter.end();
 }
 


Comment 6 Philippe Rigault 2003-11-10 20:57:03 UTC
Reopening again. Nearly done :-)

Thanks for the patch, it works fine now in most cases:
  - for non-empty spreadsheets (during and after the preview)
  - for empty spreadsheets after the preview

However, if one activates PrintPreview on an empty spreadsheet,  it still looks ugly during the time the popup menus 'Nothing to print' and 'Printing Status' are up. Moving the popups around makes things worse. 

Any comments on point 2 of comment#2 (denying the user the printing of a blank page) ?
Comment 7 Ariya Hidayat 2003-11-18 20:48:59 UTC
Halo Phillippe,

I hope the patch (and the explanation) as in http://lists.kde.org/?l=koffice-devel&m=106875747926025&w=2 will fix the issue with "nothing to print" warning. I will commit it soon.
Feel free to reopen if another thing is still missing :-)

Best regards,

Ariya

Comment 8 Ariya Hidayat 2003-11-18 21:04:52 UTC
Subject: koffice/kspread

CVS commit by ariya: 

better handling of "nothing to print" warning
(also fix the redraw problem, again)

CCMAIL: 60147-done@bugs.kde.org


  M +29 -33    kspread_sheetprint.cc   1.9
  M +4 -1      kspread_sheetprint.h   1.5
  M +11 -1     kspread_view.cc   1.699


--- koffice/kspread/kspread_sheetprint.h  #1.4:1.5
@@ -38,5 +38,8 @@ public:
     ~KSpreadSheetPrint();
 
-    void print( QPainter &painter, KPrinter *_printer );
+    /**
+     * @return false if nothing to print.
+     */
+    bool print( QPainter &painter, KPrinter *_printer );
 
     /**

--- koffice/kspread/kspread_sheetprint.cc  #1.8:1.9
@@ -179,5 +179,5 @@ bool KSpreadSheetPrint::pageNeedsPrintin
 }
 
-void KSpreadSheetPrint::print( QPainter &painter, KPrinter *_printer )
+bool KSpreadSheetPrint::print( QPainter &painter, KPrinter *_printer )
 {
     kdDebug(36001)<<"PRINTING ...."<<endl;
@@ -249,17 +249,10 @@ void KSpreadSheetPrint::print( QPainter 
     if ( page_list.count() == 0 )
     {
-        KMessageBox::information( 0, i18n("Nothing to print.") );
-        if ( !m_bPrintGrid )
-        {
-            // Restore the grid pen
-            m_pDoc->setDefaultGridPen( gridPen );
-        }
-        m_pSheet->setShowGrid( oldShowGrid );
-
-        //abort printing
-        _printer->abort();
-
-        return;
+        // nothing to print
+        painter.setPen( QPen( Qt::black, 1 ) );
+        painter.drawPoint( 1, 1 );
     }
+    else
+    {
 
     int pageNo = 1;
@@ -290,4 +283,5 @@ void KSpreadSheetPrint::print( QPainter 
             _printer->newPage();
     }
+    }
 
     if ( !m_bPrintGrid )
@@ -297,4 +291,6 @@ void KSpreadSheetPrint::print( QPainter 
     }
     m_pSheet->setShowGrid( oldShowGrid );
+
+    return ( page_list.count() > 0 );
 }
 

--- koffice/kspread/kspread_view.cc  #1.698:1.699
@@ -3989,5 +3989,5 @@ void KSpreadView::print( KPrinter &prt )
     }
 
-    print->print( painter, &prt );
+    bool result = print->print( painter, &prt );
 
     //Restore original orientation
@@ -4001,4 +4001,14 @@ void KSpreadView::print( KPrinter &prt )
     setZoom( oldZoom, false );
     m_pDoc->emitEndOperation();
+
+    // Nothing to print
+    if( !result )
+    {
+      if( !prt.previewOnly() )
+      {
+        KMessageBox::information( 0, i18n("Nothing to print.") );
+        prt.abort();
+      }
+    }
 
     painter.end();