Fixed #14429: Printing a large table in wxRichTextCtrl fails

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2012-06-21 20:12:44 +00:00
parent a8a15de623
commit b5a1cc93f3

View File

@@ -96,6 +96,12 @@ void wxRichTextPrintout::OnPreparePrinting()
// an explicit page break // an explicit page break
if (((lineY + line->GetSize().y) > rect.GetBottom()) || hasHardPageBreak) if (((lineY + line->GetSize().y) > rect.GetBottom()) || hasHardPageBreak)
{
// 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 // New page starting at this line
int newY = rect.y; int newY = rect.y;
@@ -105,17 +111,15 @@ void wxRichTextPrintout::OnPreparePrinting()
int increaseOffsetBy = lineY - newY; int increaseOffsetBy = lineY - newY;
yOffset += increaseOffsetBy; yOffset += increaseOffsetBy;
if (!lastLine)
lastLine = line;
m_pageBreaksStart.Add(lastStartPos); m_pageBreaksStart.Add(lastStartPos);
m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd()); m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd());
m_pageYOffsets.Add(yOffset); m_pageYOffsets.Add(yOffset);
lastStartPos = line->GetAbsoluteRange().GetStart(); lastStartPos = line->GetAbsoluteRange().GetStart();
lastLine = line;
m_numPages ++; m_numPages ++;
}
lastLine = line;
// Now create page breaks for the rest of the line, if it's larger than the page height // 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(); int contentLeft = line->GetSize().y - rect.GetHeight();
@@ -127,6 +131,8 @@ void wxRichTextPrintout::OnPreparePrinting()
m_pageBreaksStart.Add(lastStartPos); m_pageBreaksStart.Add(lastStartPos);
m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd()); m_pageBreaksEnd.Add(lastLine->GetAbsoluteRange().GetEnd());
m_pageYOffsets.Add(yOffset); m_pageYOffsets.Add(yOffset);
m_numPages ++;
} }
} }