Remove redundant wxHtmlDCRenderer::m_NumPages

The actual number of pages is given by the number of elements in
m_PageBreaks vector after CountPages() is shown and is unknown until
then, so m_NumPages is completely unnecessary and can be just removed.
This commit is contained in:
Vadim Zeitlin
2018-05-25 01:35:34 +02:00
parent bf9712978a
commit adfde70054
2 changed files with 3 additions and 7 deletions

View File

@@ -184,11 +184,10 @@ private:
wxString TranslateHeader(const wxString& instr, int page); wxString TranslateHeader(const wxString& instr, int page);
// substitute @PAGENUM@ and @PAGESCNT@ by real values // substitute @PAGENUM@ and @PAGESCNT@ by real values
void CountPages(); void CountPages();
// counts pages and fills m_NumPages and m_PageBreaks // fills m_PageBreaks, which indirectly gives the number of pages
private: private:
int m_NumPages;
wxVector<int> m_PageBreaks; wxVector<int> m_PageBreaks;
wxString m_Document, m_BasePath; wxString m_Document, m_BasePath;

View File

@@ -199,7 +199,6 @@ wxVector<wxHtmlFilter*> wxHtmlPrintout::m_Filters;
wxHtmlPrintout::wxHtmlPrintout(const wxString& title) : wxPrintout(title) wxHtmlPrintout::wxHtmlPrintout(const wxString& title) : wxPrintout(title)
{ {
m_NumPages = INT_MAX;
m_BasePathIsDir = true; m_BasePathIsDir = true;
m_HeaderHeight = m_FooterHeight = 0; m_HeaderHeight = m_FooterHeight = 0;
SetMargins(); // to default values SetMargins(); // to default values
@@ -391,8 +390,8 @@ bool wxHtmlPrintout::OnPrintPage(int page)
void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
{ {
*minPage = 1; *minPage = 1;
if ( m_NumPages >= (signed)m_PageBreaks.size()-1) if ( m_PageBreaks.empty() )
*maxPage = m_NumPages; *maxPage = INT_MAX;
else else
*maxPage = (signed)m_PageBreaks.size()-1; *maxPage = (signed)m_PageBreaks.size()-1;
*selPageFrom = 1; *selPageFrom = 1;
@@ -479,8 +478,6 @@ void wxHtmlPrintout::CountPages()
{ {
wxBusyCursor wait; wxBusyCursor wait;
m_NumPages = 0;
m_PageBreaks.clear(); m_PageBreaks.clear();
for ( int pos = 0; pos != wxNOT_FOUND; ) for ( int pos = 0; pos != wxNOT_FOUND; )