Remove "known_pagebreaks" from wxHtmlCell::AdjustPagebreak()
This parameter is not actually needed for any reasonable page breaking algorithm, as it shouldn't care about any previous page breaks except for the last one, which is already known as "*pagebreak - pageHeight" in this function. Removing it will allow to stop using wxArrayInt in the code using this method and switch to an std::vector<int> instead. This is not a backwards compatible change, but it seems that there is very little code actually overriding this function (none could be found in any open source repositories) and updating it should be as simple as removing the now unneeded argument.
This commit is contained in:
@@ -69,6 +69,9 @@ Changes in behaviour which may result in build errors
|
||||
- wxHtmlDCRenderer::Render() arguments have changed, simply omit the ones not
|
||||
existing in the function signature any more to update the code using it.
|
||||
|
||||
- wxHtmlCell::AdjustPagebreak() has lost its "known_pagebreaks" argument,
|
||||
update your code if you override this method (you shouldn't be calling it).
|
||||
|
||||
|
||||
3.1.2: (released 2018-??-??)
|
||||
----------------------------
|
||||
|
@@ -279,16 +279,20 @@ public:
|
||||
const wxPoint& pos,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
// This method used to adjust pagebreak position. The parameter is variable
|
||||
// that contains y-coordinate of page break (= horizontal line that should
|
||||
// not be crossed by words, images etc.). If this cell cannot be divided
|
||||
// into two pieces (each one on another page) then it moves the pagebreak
|
||||
// few pixels up.
|
||||
// This method is called when paginating HTML, e.g. when printing.
|
||||
//
|
||||
// On input, pagebreak contains y-coordinate of page break (i.e. the
|
||||
// horizontal line that should not be crossed by words, images etc.)
|
||||
// relative to the parent cell on entry and may be modified to request a
|
||||
// page break at a position before it if this cell cannot be divided into
|
||||
// two pieces (each one on its own page).
|
||||
//
|
||||
// Note that page break must still happen on the current page, i.e. the
|
||||
// returned value must be strictly greater than "*pagebreak - pageHeight"
|
||||
// and less or equal to "*pagebreak" for the value of pagebreak on input.
|
||||
//
|
||||
// Returned value : true if pagebreak was modified, false otherwise
|
||||
virtual bool AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const;
|
||||
virtual bool AdjustPagebreak(int *pagebreak, int pageHeight) const;
|
||||
|
||||
// Sets cell's behaviour on pagebreaks (see AdjustPagebreak). Default
|
||||
// is true - the cell can be split on two pages
|
||||
@@ -450,9 +454,7 @@ public:
|
||||
virtual void DrawInvisible(wxDC& dc, int x, int y,
|
||||
wxHtmlRenderingInfo& info) wxOVERRIDE;
|
||||
|
||||
virtual bool AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const wxOVERRIDE;
|
||||
virtual bool AdjustPagebreak(int *pagebreak, int pageHeight) const wxOVERRIDE;
|
||||
|
||||
// insert cell at the end of m_Cells list
|
||||
void InsertCell(wxHtmlCell *cell);
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
// Finds the next page break after the specified (vertical) position.
|
||||
// Returns wxNOT_FOUND if passed in position is the last page break.
|
||||
int FindNextPageBreak(const wxArrayInt& known_pagebreaks, int pos);
|
||||
int FindNextPageBreak(int pos);
|
||||
|
||||
// [x,y] is position of upper-left corner of printing rectangle (see SetSize)
|
||||
// from is y-coordinate of the very first visible cell
|
||||
|
@@ -187,28 +187,31 @@ public:
|
||||
wxHtmlCell();
|
||||
|
||||
/**
|
||||
This method is used to adjust pagebreak position.
|
||||
The first parameter is a variable that contains the y-coordinate of the page break
|
||||
(= horizontal line that should not be crossed by words, images etc.).
|
||||
If this cell cannot be divided into two pieces (each one on another page)
|
||||
then it either moves the pagebreak a few pixels up, if possible, or, if
|
||||
the cell cannot fit on the page at all, then the cell is forced to
|
||||
split unconditionally.
|
||||
This method is called when paginating HTML, e.g.\ when printing.
|
||||
|
||||
Returns @true if pagebreak was modified, @false otherwise.
|
||||
User code should never call this function, but may need to override it
|
||||
in custom HTML cell classes with any specific page breaking
|
||||
requirements.
|
||||
|
||||
On input, @a pagebreak contains y-coordinate of page break (i.e. the
|
||||
horizontal line that should not be crossed by words, images etc.)
|
||||
relative to the parent cell on entry and may be modified to request a
|
||||
page break at a position before it if this cell cannot be divided into
|
||||
two pieces (each one on its own page).
|
||||
|
||||
Note that page break must still happen on the current page, i.e. the
|
||||
returned value must be strictly greater than @code *pagebreak -
|
||||
pageHeight @endcode and less or equal to @c *pagebreak for the value of
|
||||
@a pagebreak on input.
|
||||
|
||||
@param pagebreak
|
||||
position in pixels of the pagebreak.
|
||||
|
||||
@param known_pagebreaks
|
||||
the list of the previous pagebreaks
|
||||
|
||||
@param pageHeight
|
||||
the height in pixels of the page drawable area
|
||||
|
||||
@return @true if pagebreak was modified, @false otherwise.
|
||||
*/
|
||||
virtual bool AdjustPagebreak(int* pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const;
|
||||
virtual bool AdjustPagebreak(int* pagebreak, int pageHeight) const;
|
||||
|
||||
/**
|
||||
Renders the cell.
|
||||
|
@@ -157,9 +157,7 @@ wxHtmlCell::GetMouseCursorAt(wxHtmlWindowInterface *window,
|
||||
|
||||
|
||||
bool
|
||||
wxHtmlCell::AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& WXUNUSED(known_pagebreaks),
|
||||
int pageHeight) const
|
||||
wxHtmlCell::AdjustPagebreak(int *pagebreak, int pageHeight) const
|
||||
{
|
||||
// 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.
|
||||
@@ -697,19 +695,17 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const
|
||||
|
||||
|
||||
bool
|
||||
wxHtmlContainerCell::AdjustPagebreak(int *pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const
|
||||
wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int pageHeight) const
|
||||
{
|
||||
if (!m_CanLiveOnPagebreak)
|
||||
return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, pageHeight);
|
||||
return wxHtmlCell::AdjustPagebreak(pagebreak, pageHeight);
|
||||
|
||||
bool rt = false;
|
||||
int pbrk = *pagebreak - m_PosY;
|
||||
|
||||
for ( wxHtmlCell *c = GetFirstChild(); c; c = c->GetNext() )
|
||||
{
|
||||
if (c->AdjustPagebreak(&pbrk, known_pagebreaks, pageHeight))
|
||||
if (c->AdjustPagebreak(&pbrk, pageHeight))
|
||||
rt = true;
|
||||
}
|
||||
if (rt)
|
||||
|
@@ -140,8 +140,7 @@ void wxHtmlDCRenderer::SetStandardFonts(int size,
|
||||
// else: SetHtmlText() not yet called, no need for relayout
|
||||
}
|
||||
|
||||
int wxHtmlDCRenderer::FindNextPageBreak(const wxArrayInt& known_pagebreaks,
|
||||
int pos)
|
||||
int wxHtmlDCRenderer::FindNextPageBreak(int pos)
|
||||
{
|
||||
// Stop looking for page breaks if the previous one was already at the end
|
||||
// of the last page.
|
||||
@@ -152,7 +151,7 @@ int wxHtmlDCRenderer::FindNextPageBreak(const wxArrayInt& known_pagebreaks,
|
||||
return wxNOT_FOUND;
|
||||
|
||||
int posNext = pos + m_Height;
|
||||
if ( m_Cells->AdjustPagebreak(&posNext, known_pagebreaks, m_Height) )
|
||||
if ( m_Cells->AdjustPagebreak(&posNext, m_Height) )
|
||||
{
|
||||
// Check that AdjustPagebreak() returns the page break at a strictly
|
||||
// greater position than that of the previous page, otherwise
|
||||
@@ -486,7 +485,7 @@ void wxHtmlPrintout::CountPages()
|
||||
for ( int pos = 0; pos != wxNOT_FOUND; )
|
||||
{
|
||||
m_PageBreaks.Add( pos);
|
||||
pos = m_Renderer.FindNextPageBreak(m_PageBreaks, pos);
|
||||
pos = m_Renderer.FindNextPageBreak(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -65,9 +65,7 @@ class wxHtmlPageBreakCell : public wxHtmlCell
|
||||
public:
|
||||
wxHtmlPageBreakCell() {}
|
||||
|
||||
bool AdjustPagebreak(int* pagebreak,
|
||||
const wxArrayInt& known_pagebreaks,
|
||||
int pageHeight) const wxOVERRIDE;
|
||||
bool AdjustPagebreak(int* pagebreak, int pageHeight) const wxOVERRIDE;
|
||||
|
||||
void Draw(wxDC& WXUNUSED(dc),
|
||||
int WXUNUSED(x), int WXUNUSED(y),
|
||||
@@ -79,9 +77,7 @@ private:
|
||||
};
|
||||
|
||||
bool
|
||||
wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak,
|
||||
const wxArrayInt& WXUNUSED(known_pagebreaks),
|
||||
int pageHeight) const
|
||||
wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak, int pageHeight) const
|
||||
{
|
||||
// Request a page break at the position of this cell if it's on the current
|
||||
// page. Note that it's important not to do it unconditionally or we could
|
||||
|
Reference in New Issue
Block a user