Reformat 7.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/***************************************************/
/* File   : Reformat.h                             */
17 18 19
/*                                                 */
/* Purpose: Functions to handle page reformatting. */
/*                                                 */
20
/* Author : A.D.Hodgkinson                         */
21 22 23 24 25 26 27 28 29 30 31 32
/*                                                 */
/* History: 03-Dec-96: Created.                    */
/*          16-Apr-97: First merge with T.Cheal's  */
/*                     table code...               */
/*          22-May-97: Amazingly, *still* trying   */
/*                     to get this to work.        */
/*          18-Jun-97: Hpmh; works, but very slow. */
/*                     Will need to rewrite at     */
/*                     some stage; for the moment, */
/*                     moved a few bits over to    */
/*                     Tables.c as they fitted in  */
/*                     better over there.          */
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/***************************************************/

#include "HTMLLib.h" /* From the HTML library; the definitions below rely on this */

/* Line break position definitions */

#define LINEBREAK    (P | BR | LI)      /* Tags that force linebreaks at the  */
                                        /* point where they are encountered   */

#define LINEBREAKSW  (PRE | BLOCKQUOTE) /* Tags that force linebreaks when    */
                                        /* they are encountered in the source */
                                        /* whilst the effect is turned on     */

#define LINEBREAKON  (DT | ADDRESS)     /* Tags that force a line break at    */
                                        /* the point when they turn on        */

#define LINEBREAKOFF (H_MASK | ADDRESS) /* Tags that force a line break at    */
                                        /* the point when they turn off       */

/* Other tag classification masks */

Kevin Bracey's avatar
Kevin Bracey committed
54
#define VISUALDATA   (HR | IMG | INPUT) /* Does the tag contain displayable data, despite */
55 56 57 58 59 60
                                        /* having no text inside it? If the tag's style   */
                                        /* word contains the bit(s) defined here, it is   */
                                        /* deemed to contain such data.                   */

/* Formatting definitions */

61 62 63
#define Reformat_AsWideAsPossible_OS           0x8000000  /* OS unit 'very very wide' value */
#define Reformat_AsWideAsPossible_MP           0x40000000 /* Millipoint 'very wide' value   */
#define Reformat_UnrealisticallyHighLineNumber 0x40000000 /* For the deferred reformatter */
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

/* Reformatter flags */

#define Reformatter_KeepGoingToEnd  (1u<<1) /* Tell reformatter to keep going until it runs out of data, regardless of how long it takes */
#define Reformatter_ReturnMinimum   (1u<<2) /* Tell reformatter to return the minimum width that the stream could have fitted in         */
#define Reformatter_FindingWidest   (1u<<3) /* Tell reformatter we're trying to find the greatest width the page could occupy            */
#define Reformatter_FindingSmallest (1u<<4) /* Tell reformatter we're trying to find the smallest width the page could occupy            */
#define Reformatter_FromStreamStart (1u<<5) /* Tell reformatter to ignore last_token fields in browser_data and use streambase instead   */
#define Reformatter_Virtual         (1u<<6) /* Tell reformatter not to actually allocate lines/chunks (for finding widths of things)     */

/* The CENTRED macro returns 1 when passed an HStream pointer if that HStream */
/* has the Style flag saying it is centred, or if the general alignment field */
/* says that the tag should be centred; else it returns 0.                    */

#define CENTRED(x)   (((x->style & CENTER) || ((x->type & TYPE_ALIGN_MASK) == TYPE_CENTRE)) != 0)

/* Local structures */

typedef struct reformat_width_data
{
84 85 86 87 88 89
  browser_data  * b;
  reformat_cell * d;
  HStream       * tp;     /* Pointer to the token this structure represents           */
  char          * data;   /* Pointer to the token's data                              */
  int             offset; /* The offset into the data to start at                     */
  int             maxwid; /* The width to try and fit the token into                  */
90
                         /*                                                          */
91 92
  int             bytes;  /* (Returned) The number of bytes that will (might) fit     */
  int             width;  /* (Returned) The actual width of the given number of bytes */
93 94 95 96 97

} reformat_width_data;

/* Function prototypes */

98 99
int                   reformat_formatting           (browser_data * b);
_kernel_oserror     * reformat_stop                 (browser_data * b);
100

101
int                   reformat_newline              (HStream * current, HStream * last, int offset);
102

103 104 105 106
_kernel_oserror     * reformat_shift_vertically     (browser_data * b, int start, int end, int y_shift);
_kernel_oserror     * reformat_format_from          (browser_data * b, int lastline, int immediate, int image);
int                   reformat_format_timer         (int eventcode, WimpPollBlock * b, IdBlock * idb, browser_data * handle);
void                  reformat_stop_pending         (browser_data * b);
107

108 109 110 111 112 113
_kernel_oserror     * reformat_get_image_size       (browser_data * b, HStream * tp, BBox * box);
_kernel_oserror     * reformat_get_object_size      (browser_data * b, HStream * tp, BBox * box);
void                  reformat_get_placeholder_size (browser_data * b, HStream * tp, const char * text, BBox * box);
int                   reformat_bullet_width         (int bullet);
int                   reformat_bullet_height        (int bullet);
int                   reformat_y_offset             (browser_data * b);
114

115 116 117
_kernel_oserror     * reformat_check_extent         (browser_data * b);
int                   reformat_return_extent        (browser_data * b, reformat_cell * cell);
_kernel_oserror     * reformat_set_extent           (browser_data * b, int y_extent);
118

119 120 121
void                  reformat_reformatter          (browser_data * b);
int                   reformat_format_cell          (int toplevel, browser_data * b, HStream * streambase, table_stream * table, reformat_cell * cellarray, int ColWidth, int Row, int Column);
void                  reformat_find_cell_limits     (int toplevel, browser_data * b, HStream * streambase, table_stream * table, reformat_cell * cellarray, int Row, int Column, int * retmin, int * retmax);
122

123
void                  reformat_change_text          (browser_data * b, HStream * tp);