]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed #14429: Printing a large table in wxRichTextCtrl fails
authorJulian Smart <julian@anthemion.co.uk>
Thu, 21 Jun 2012 20:12:44 +0000 (20:12 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 21 Jun 2012 20:12:44 +0000 (20:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextprint.cpp

index 55c0dbf8cfb6485eb9924dfa6b16ad7f6b0f259b..a3c8d1152298264c61bf0db0f4814c5c16b77e3e 100644 (file)
@@ -97,26 +97,30 @@ void wxRichTextPrintout::OnPreparePrinting()
 
                     if (((lineY + line->GetSize().y) > rect.GetBottom()) || hasHardPageBreak)
                     {
-                        // New page starting at this line
-                        int newY = rect.y;
-
-                        // We increase the offset by the difference between new and old positions
-
-                        int increaseOffsetBy = lineY - newY;
-                        yOffset += increaseOffsetBy;
-
-                        if (!lastLine)
-                            lastLine = line;
-
-                        m_pageBreaksStart.Add(lastStartPos);
-                        m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd());
-                        m_pageYOffsets.Add(yOffset);
+                        // Only if we're not at the start of the document, and
+                        // even then, only if either it's a hard break or if the object
+                        // can fit in a whole page (otherwise there's no point in making
+                        // the rest of this page blank).
+                        if (lastLine && (hasHardPageBreak || (line->GetSize().y <= rect.GetHeight())))
+                        {
+                            // New page starting at this line
+                            int newY = rect.y;
+                            
+                            // We increase the offset by the difference between new and old positions
+                            
+                            int increaseOffsetBy = lineY - newY;
+                            yOffset += increaseOffsetBy;
+                            
+                            m_pageBreaksStart.Add(lastStartPos);
+                            m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd());
+                            m_pageYOffsets.Add(yOffset);
+                            
+                            lastStartPos = line->GetAbsoluteRange().GetStart();
+                            m_numPages ++;
+                        }
 
-                        lastStartPos = line->GetAbsoluteRange().GetStart();
                         lastLine = line;
 
-                        m_numPages ++;
-
                         // Now create page breaks for the rest of the line, if it's larger than the page height
                         int contentLeft = line->GetSize().y - rect.GetHeight();
                         while (contentLeft >= 0)
@@ -127,6 +131,8 @@ void wxRichTextPrintout::OnPreparePrinting()
                             m_pageBreaksStart.Add(lastStartPos);
                             m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd());
                             m_pageYOffsets.Add(yOffset);
+
+                            m_numPages ++;
                         }
                     }