Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Skipping footer/header and page numbering...
Skipping footer/header and page numbering... [message #58309] Fri, 15 April 2022 22:56
Tom1
Messages: 1086
Registered: March 2007
Senior Contributor
Hi Mirek,

Would it be possible to add a feature to skip footer/header and page numbering (with offset) in the beginning of a document?

The code needed follows:

RichText/HeaderFooter.cpp:
void RichText::PaintHeaderFooter(PageDraw& pw, const Rect& page, PageY py, const PaintInfo& pi_,
                                 int from_page, int to_page) const
{
	PaintInfo pi = pi_;
	pi.sell = pi.selh = 0;
	RichContext rc = Context(page, py);
	int last_page = -1;
	int pagecount = GetHeight(page).page + 1;
	int i = 0;
	while(last_page <= to_page) {
		while(last_page < rc.py.page) {
			last_page++;
			if(last_page >= from_page && (rc.header || rc.footer) && last_page >= pi_.header_footer_skip_pages) {
				if(rc.header_cy)
					GetHeaderFooterText(rc.header, last_page-pi_.header_footer_skip_pages, pagecount-pi_.header_footer_skip_pages).Paint(pw, PageY(last_page, page.top), page, pi);
				if(rc.footer_cy)
					GetHeaderFooterText(rc.footer, last_page-pi_.header_footer_skip_pages, pagecount-pi_.header_footer_skip_pages).Paint(pw, PageY(last_page, page.bottom - rc.footer_cy), page, pi);
			}
		}
		if(++i >= GetPartCount())
			break;
		RichContext begin;
		Advance(i, rc, begin);
	}
}

RichText/RichText.h:
struct PaintInfo {
	Zoom    zoom;
	int     sell, selh;
	int     tablesel;
	Rect    cells;
	PageY   top;
	PageY   bottom;
	Color   hyperlink;
	Color   indexentry;
	Color   textcolor; // not Null overrides text color, makes paper transparent, useful for QTFDisplay
	bool    indexentrybg;
	bool    usecache;
	bool    sizetracking;
	Color   showcodes;
	Bits  (*spellingchecker)(const RichPara& para);
	int     highlightpara;
	Color   highlight;
	bool    darktheme;
	void   *context;
	bool    showlabels;
	bool    shrink_oversized_objects;
	int	header_footer_skip_pages;                                 // << ADDED THIS!
	void  (*DrawSelection)(Draw& w, int x, int y, int cx, int cy);

	Color   ResolveInk(Color ink) const;
	Color   ResolvePaper(Color paper) const;

	PaintInfo();
};

RichText/ParaData.cpp:
PaintInfo::PaintInfo()
{
	sell = selh = 0;
	tablesel = 0;
	top = PageY(0, 0);
	bottom = PageY(INT_MAX, INT_MAX);
	hyperlink = SColorMark();
	usecache = false;
	sizetracking = false;
	showcodes = Null;
	spellingchecker = NULL;
	highlightpara = -1;
	highlight = Yellow();
	indexentry = LtGreen();
	indexentrybg = false;
	darktheme = false;
	context = NULL;
	showlabels = false;
	shrink_oversized_objects = false;
	header_footer_skip_pages = 0;          // << ADDED THIS
	textcolor = Null;
	DrawSelection = [] (Draw& w, int x, int y, int cx, int cy) {
		w.DrawRect(x, y, cx, cy, InvertColor);
	};
}


Unfortunately, this does not get saved within the document. That would require support added in QTF format.

As for GUI, I just added this as a menu option in a modified UWord. However, it would be most logical to include it in the Header/Footer dialog as a 'Pages to skip' entry field.

I'm not in any hurry with this, but it would be nice to have it included some time after 2022.1.

Best regards,

Tom
 
Read Message
Previous Topic: Page break does not work in Style
Goto Forum:
  


Current Time: Wed Jun 29 11:47:11 CEST 2022

Total time taken to generate the page: 0.01421 seconds