Commit c3204ab0 authored by Andrew Hodgkinson's avatar Andrew Hodgkinson
Browse files

Header and footer support working a lot better than in the previous release....

Header and footer support working a lot better than in the previous release. Could do with some code tidying, but little else to do.

Fixed a typo in JavaScript.c that stopped debug builds compiling,
and updated Trace.c to know about all current HStream flags bits.
parent db21237d
......@@ -52,3 +52,5 @@ ahodgkin_208_i2 Intermediate 2.08 build. Printing headers and
footers just completed. Image system still in
need of serious overhaul, misc. other incomplete
features (25-Feb-2000).
ahodgkin_208_i3 Intermediate 2.08 build. Printing headers and
footers now work... (01-Mar-2000).
......@@ -12,7 +12,7 @@
#
# HomePage - The URL that the browser defaults to on loading.
HomePage:http://www.acorn.co.uk/
HomePage:about:
# Page colours
# ============
......@@ -494,15 +494,15 @@ SaveImageHistory:once
# at the top of the document.
# PrintDateFormat - Format in which dates are output, using same scheme as
# the Sys$DateFormat variable and !Alarm (the format you
# give is run through SWI OS_ConvertDateAndTime). Remember
# to use two '%'s wherever you want one in Sys$DateFormat as
# this is going to be parsed by MessageTrans first.
# give is run through SWI OS_ConvertDateAndTime), replacing
# any '%' with '!'.
PrintCopies:1
PrintStart:start
PrintEnd:end
PrintReform:yes
PrintOrient:portrait
PrintOrient:upright
PrintBack:tables
PrintBlack:bg
PrintPlain:yes
......@@ -523,7 +523,7 @@ PrintHFItalic:yes
PrintHFScale:80
PrintFacingPages:no
PrintDateFormat:%%24:%%mi:%%se %%dy-%%m3-%%ce%%yr
PrintDateFormat:!24:!mi:!se !dy-!m3-!ce!yr
# Toolbar controls
# ================
......
......@@ -2151,9 +2151,9 @@ _kernel_oserror * javascript_window_open(browser_data * b, int must_find, int re
sprintf(erb.errmess,
"Unknown action type %d in javascript_handle_post_exec_actions",
exec->type);
this->type);
show_error_ret(&erb)
show_error_ret(&erb);
}
break;
......
......@@ -1067,16 +1067,17 @@ static void load_choices(void)
if (!strcmp(lookup_choice("PrintHFBold:no", 0, 0), "yes")) choices.print_hf_bold = 1;
if (!strcmp(lookup_choice("PrintHFItalic:yes", 0, 0), "yes")) choices.print_hf_italic = 1;
choices.print_date_format = utils_strdup(lookup_choice("PrintDateFormat:%%24:%%mi:%%se %%dy-%%m3-%%ce%%yr", 0, 0));
choices.print_date_format = utils_strdup(lookup_choice("PrintDateFormat:!24:!mi:!se !dy-!m3-!ce!yr", 0, 0));
if (choices.print_date_format == NULL) show_error(make_no_memory_error(32));
if (!strcmp(lookup_choice("PrintReform:yes", 0, 0), "yes")) choices.print_reform = 1;
/* Backwards compatible unusual dual-meaning. Upright is a synonym of portrait, */
/* and sideways of landscape. The browser always *saves* portrait or landscape. */
/* and sideways of landscape. The browser always *saves* upright or sideways. */
if (!strcmp(lookup_choice("PrintOrient:upright", 0, 0), "upright")) choices.print_orient = Choices_PrintOrient_Upright;
else choices.print_orient = Choices_PrintOrient_Sideways;
if (!strcmp(lookup_choice("PrintOrient:upright", 0, 0), "upright")) choices.print_orient = Choices_PrintOrient_Upright;
else if (!strcmp(lookup_choice("PrintOrient:upright", 0, 0), "portrait")) choices.print_orient = Choices_PrintOrient_Upright;
else choices.print_orient = Choices_PrintOrient_Sideways;
if (!strcmp(lookup_choice("PrintBack:tables", 0, 0), "always")) choices.print_back = Choices_PrintBack_Always;
else if (!strcmp(lookup_choice("PrintBack:tables", 0, 0), "none")) choices.print_back = Choices_PrintBack_None;
......
......@@ -1327,6 +1327,7 @@ static _kernel_oserror * print_page(browser_data * b, int copies, int from, int
if (e) goto out2;
if (choices.print_headers_from > 0)
{
BBox head;
BBox hpof;
......@@ -1365,6 +1366,7 @@ static _kernel_oserror * print_page(browser_data * b, int copies, int from, int
if (e) goto out2;
}
if (choices.print_footers_from > 0)
{
BBox foot;
BBox fpof;
......@@ -1561,13 +1563,16 @@ static _kernel_oserror * print_page(browser_data * b, int copies, int from, int
/* End_Visible; if 'bottom' is zero as well, there's */
/* nothing more to print. */
if (end == End_Visible && !bottom) break;
if (end == End_Visible && !bottom)
{
break;
}
/* If xscroll is 0, redraw_draw must not have found any */
/* lines that fell off the bottom of the page - so */
/* there cannot be any more pages. */
if (!redraw.xscroll) break;
if (redraw.xscroll == 0) break;
/* Otherwise, close the outer while loop - which */
/* may mean we loop for another page. */
......@@ -2427,9 +2432,12 @@ static void print_header_and_footer_sizes(browser_data * b, unsigned int pages,
{
char buffer[Limits_Message]; /* Slightly arbitrary choice */
int ok;
int top, bot;
if (!header || !footer) return;
*header = *footer = 0;
/* Set bit 0 of ok for a header, and bit 1 for a footer */
ok = 0;
......@@ -2471,23 +2479,10 @@ static void print_header_and_footer_sizes(browser_data * b, unsigned int pages,
}
}
/* If we've got a header / footer, work out the height */
if (reformat_text_line_height(b, NULL, &top, &bot)) return;
if (ok != 0)
{
int top, bot;
if (reformat_text_line_height(b, NULL, &top, &bot))
{
*header = *footer = 0;
return;
}
if ((ok & 1) != 0) *header = ((top + bot) * PrintHeaderAndFooterHeightMultiplier * choices.print_hf_scale) / 1000;
if ((ok & 2) != 0) *footer = ((top + bot) * PrintHeaderAndFooterHeightMultiplier * choices.print_hf_scale) / 1000;
}
else *header = *footer = 0;
if ((ok & 1) != 0) *header = ((top + bot) * PrintHeaderAndFooterHeightMultiplier * choices.print_hf_scale) / 1000;
if ((ok & 2) != 0) *footer = ((top + bot) * PrintHeaderAndFooterHeightMultiplier * choices.print_hf_scale) / 1000;
return;
}
......@@ -3042,6 +3037,17 @@ static void print_fake_redraw(browser_data * b, WimpRedrawWindowBlock * r)
}
}
/* ...with "line fits on *exactly*" adjustment. */
else if (
d->ldata[l].y == page_bottom &&
l + 1 < d->nlines
)
{
r->xscroll = d->ldata[l + 1].y + d->ldata[l + 1].h;
return;
}
/* Second, look ahead to keep heading lines and DT / DD lines together */
if (
......@@ -3054,14 +3060,18 @@ static void print_fake_redraw(browser_data * b, WimpRedrawWindowBlock * r)
HStream * t2 = d->cdata[d->ldata[l + 1].chunks].t;
if (
t1->tagno != TAG_TABLE &&
reformat_istext(t1) &&
(
(
((t1->style & H_MASK) != 0) &&
((t2->style & H_MASK) == 0)
(
(t2->style & H_MASK) == 0 ||
!reformat_istext(t2)
)
)
||
(
reformat_istext(t2) &&
((t1->style & DT) != 0) &&
((t2->style & DD) != 0)
)
......@@ -3085,28 +3095,29 @@ static void print_fake_redraw(browser_data * b, WimpRedrawWindowBlock * r)
int h1;
int h2;
if (t2->tagno != TAG_TABLE)
if (reformat_istext(t2))
{
/* The previous line might not be useful (e.g. two H2s in a row */
/* would have a dummy tag in between occuping a zero height */
/* line of its own). So we need to scan backwards to get a */
/* useful token. */
while (
t1->tagno != TAG_TABLE &&
!t1->text &&
scan >= 0 &&
--scan
t1 != NULL &&
(
reformat_istext(t1) &&
t1->text == NULL
)
&& --scan >= 0
)
t1 = d->cdata[d->ldata[scan].chunks].t;
if (t1->tagno == TAG_TABLE) h1 = 0;
else h1 = redraw_header(t1->style);
h1 = reformat_istext(t1) ? redraw_header(t1->style) : 0;
h2 = redraw_header(t2->style);
if (
(
t1->tagno == TAG_TABLE ||
t1->text
)
&& d->ldata[scan].y < wbox.ymax
&& d->ldata[scan].y + d->ldata[scan].h <= wbox.ymax
d->ldata[scan].y < wbox.ymax &&
d->ldata[scan].y + d->ldata[scan].h <= wbox.ymax
&&
(
h1 > choices.print_page_break_hx ||
......
......@@ -140,9 +140,10 @@ static void redraw_read_section(browser_data * b, HStream * t2)
free(b->inferred_section), b->inferred_section = NULL;
while (
t2 != NULL &&
t2->tagno != TAG_TABLE &&
redraw_header(t2->style) == h2
t2 != NULL &&
reformat_istext(t2) &&
redraw_header(t2->style) == h2 &&
t2->tagno != TAG_BR
)
{
if (t2->text != NULL && *t2->text != '\0')
......@@ -1637,7 +1638,13 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* Possibly store inferred section */
if ((t1->style & H_MASK) != 0 && choices.print_page_break_hx != 0) redraw_read_section(b, t1);
if (
choices.print_page_break_hx > 0 &&
reformat_istext(t1) &&
redraw_header(t1->style) > 0 &&
redraw_header(t1->style) <= choices.print_page_break_hx
)
redraw_read_section(b, t1);
return NULL;
}
......@@ -1647,6 +1654,30 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* right... */
}
/* The unusual one-off case where the line exactly fits on the page */
else if (
osyorg + d->ldata[l].y == page_bottom &&
l + 1 < d->nlines
)
{
HStream * t1 = d->cdata[d->ldata[l + 1].chunks].t;
r->xscroll = osyorg + d->ldata[l + 1].y + d->ldata[l + 1].h;
/* Possibly store inferred section */
if (
choices.print_page_break_hx > 0 &&
reformat_istext(t1) &&
redraw_header(t1->style) > 0 &&
redraw_header(t1->style) <= choices.print_page_break_hx
)
redraw_read_section(b, t1);
return NULL;
}
/* Trying to get clever now. Here we look one line ahead, and see if */
/* this line would fall off the page. If so, then should we allow it */
/* to get seperated from the current line, or should we put *both* */
......@@ -1667,14 +1698,18 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* then don't split up the two lines. */
if (
t1->tagno != TAG_TABLE &&
reformat_istext(t1) &&
(
(
((t1->style & H_MASK) != 0) &&
((t2->style & H_MASK) == 0)
(
(t2->style & H_MASK) == 0 ||
!reformat_istext(t2)
)
)
||
(
reformat_istext(t2) &&
((t1->style & DT) != 0) &&
((t2->style & DD) != 0)
)
......@@ -1683,9 +1718,16 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
{
r->xscroll = osyorg + d->ldata[l].y + d->ldata[l].h;
/* Possibly store inferred section */
/* Possibly store inferred section */
if ((t1->style & H_MASK) != 0 && choices.print_page_break_hx != 0) redraw_read_section(b, t1);
if (
choices.print_page_break_hx > 0 &&
reformat_istext(t1) &&
redraw_header(t1->style) > 0 &&
redraw_header(t1->style) <= choices.print_page_break_hx
)
redraw_read_section(b, t1);
return NULL;
}
......@@ -1704,7 +1746,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
int h1;
int h2;
if (t2->tagno != TAG_TABLE)
if (reformat_istext(t2))
{
/* The previous line might not be useful (e.g. two H2s in a row */
/* would have a dummy tag in between occuping a zero height */
......@@ -1712,25 +1754,21 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* useful token. */
while (
t1->tagno != TAG_TABLE &&
!t1->text &&
scan >= 0 &&
--scan
t1 != NULL &&
(
reformat_istext(t1) &&
t1->text == NULL
)
&& --scan >= 0
)
t1 = d->cdata[d->ldata[scan].chunks].t;
if (t1->tagno == TAG_TABLE) h1 = 0;
else h1 = redraw_header(t1->style);
h1 = reformat_istext(t1) ? redraw_header(t1->style) : 0;
h2 = redraw_header(t2->style);
if (
(
t1->tagno == TAG_TABLE ||
t1->text
)
&& osyorg + d->ldata[scan].y < wbox.ymax
&& osyorg + d->ldata[scan].y + d->ldata[scan].h <= wbox.ymax
osyorg + d->ldata[scan].y < wbox.ymax &&
osyorg + d->ldata[scan].y + d->ldata[scan].h <= wbox.ymax
&&
(
h1 > choices.print_page_break_hx ||
......@@ -3067,13 +3105,14 @@ do_image: /* (This code is also used for form INPUT TYPE=IMAGE tags; see above)
/* code is run. */
}
#ifdef ANTI_TWITTER
if (!printing && toplevel) anti_twitter(r);
#endif
if (!printing && toplevel)
{
#ifdef ANTI_TWITTER
anti_twitter(r);
#endif
if (!printing && toplevel) wimp_get_rectangle(r,&more);
wimp_get_rectangle(r,&more);
}
else more = 0;
}
while (more);
......
......@@ -73,7 +73,6 @@
/* Static function prototypes */
static int reformat_istext (HStream * tp);
static int reformat_useless_token (HStream * tp);
static int reformat_newline_check (HStream * current, HStream * last, int offset);
static int reformat_datasize (HStream * p);
......@@ -182,7 +181,8 @@ _kernel_oserror * reformat_stop(browser_data * b)
/* reformat_istext() */
/* */
/* Returns 1 if an HStream structure represents */
/* neither a horizontal rule nor an image. */
/* a text item - e.g. not an image, HR, object, */
/* table... */
/* */
/* Parameters: Pointer to the HStream structure. */
/* */
......@@ -190,7 +190,7 @@ _kernel_oserror * reformat_stop(browser_data * b)
/* else 0. */
/*************************************************/
static int reformat_istext(HStream * tp)
int reformat_istext(HStream * tp)
{
return (
((tp->style) & (IMG | HR)) == 0 &&
......
......@@ -696,9 +696,15 @@ tdtbs_fo_err: /* If there's an error whilst writing to the file */
TrOut(file, depth, (file, "\t\tHFlags_IgnoreObject\n"));
}
if (token->flags & HFlags_MarksParaSpace)
{
TrOut(file, depth, (file, "\t\tHFlags_MarksParaSpace\n"));
}
mask = HFlags_DealtWithToken |
HFlags_LinkVisited |
HFlags_IgnoreObject;
HFlags_IgnoreObject |
HFlags_MarksParaSpace;
if (token->flags & ~mask)
{
......@@ -932,8 +938,20 @@ tdtbs_fo_err: /* If there's an error whilst writing to the file */
TrOut(file, depth, (file, "\t\tHFlags_LinkVisited\n"));
}
if (table->flags & HFlags_IgnoreObject)
{
TrOut(file, depth, (file, "\t\tHFlags_IgnoreObject\n"));
}
if (table->flags & HFlags_MarksParaSpace)
{
TrOut(file, depth, (file, "\t\tHFlags_MarksParaSpace\n"));
}
mask = HFlags_DealtWithToken |
HFlags_LinkVisited;
HFlags_LinkVisited |
HFlags_IgnoreObject |
HFlags_MarksParaSpace;
if (table->flags & ~mask)
{
......
......@@ -98,6 +98,7 @@ typedef struct reformat_width_data
int reformat_formatting (browser_data * b);
_kernel_oserror * reformat_stop (browser_data * b);
int reformat_istext (HStream * tp);
int reformat_newline (HStream * current, HStream * last, int offset);
_kernel_oserror * reformat_shift_vertically (browser_data * b, int start, int end, int y_shift);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment