Fix infinite loop in wxHtmlEasyPrinting page break code.
The code didn't handle cells higher than the page height correctly and entered an infinite loop when trying to adjust page breaks in their presence, e.g. when trying to print a very tall image. Closes #13935. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -220,11 +220,16 @@ wxCursor wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface *window) const
|
||||
}
|
||||
|
||||
|
||||
bool wxHtmlCell::AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& WXUNUSED(known_pagebreaks)) const
|
||||
bool
|
||||
wxHtmlCell::AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& WXUNUSED(known_pagebreaks),
|
||||
int pageHeight) const
|
||||
{
|
||||
if ((!m_CanLiveOnPagebreak) &&
|
||||
m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak)
|
||||
// Notice that we always break the cells bigger than the page height here
|
||||
// as otherwise we wouldn't be able to break them at all.
|
||||
if ( m_Height <= pageHeight &&
|
||||
(!m_CanLiveOnPagebreak &&
|
||||
m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) )
|
||||
{
|
||||
*pagebreak = m_PosY;
|
||||
return true;
|
||||
@@ -774,11 +779,13 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const
|
||||
}
|
||||
|
||||
|
||||
bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& known_pagebreaks) const
|
||||
bool
|
||||
wxHtmlContainerCell::AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const
|
||||
{
|
||||
if (!m_CanLiveOnPagebreak)
|
||||
return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks);
|
||||
return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, pageHeight);
|
||||
|
||||
wxHtmlCell *c = GetFirstChild();
|
||||
bool rt = false;
|
||||
@@ -786,7 +793,7 @@ bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak,
|
||||
|
||||
while (c)
|
||||
{
|
||||
if (c->AdjustPagebreak(&pbrk, known_pagebreaks))
|
||||
if (c->AdjustPagebreak(&pbrk, known_pagebreaks, pageHeight))
|
||||
rt = true;
|
||||
c = c->GetNext();
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ int wxHtmlDCRenderer::Render(int x, int y,
|
||||
int pbreak, hght;
|
||||
|
||||
pbreak = (int)(from + m_Height);
|
||||
while (m_Cells->AdjustPagebreak(&pbreak, known_pagebreaks)) {}
|
||||
while (m_Cells->AdjustPagebreak(&pbreak, known_pagebreaks, m_Height)) {}
|
||||
hght = pbreak - from;
|
||||
if(to < hght)
|
||||
hght = to;
|
||||
|
||||
@@ -71,7 +71,8 @@ public:
|
||||
wxHtmlPageBreakCell() {}
|
||||
|
||||
bool AdjustPagebreak(int* pagebreak,
|
||||
const wxArrayInt& known_pagebreaks) const;
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const;
|
||||
|
||||
void Draw(wxDC& WXUNUSED(dc),
|
||||
int WXUNUSED(x), int WXUNUSED(y),
|
||||
@@ -82,7 +83,10 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxHtmlPageBreakCell);
|
||||
};
|
||||
|
||||
bool wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak, const wxArrayInt& known_pagebreaks) const
|
||||
bool
|
||||
wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int WXUNUSED(pageHeight)) const
|
||||
{
|
||||
// When we are counting pages, 'known_pagebreaks' is non-NULL.
|
||||
// That's the only time we change 'pagebreak'. Otherwise, pages
|
||||
|
||||
Reference in New Issue
Block a user