Beispiel #1
0
static fz_html_flow *split_flow(fz_context *ctx, fz_pool *pool, fz_html_flow *flow, size_t offset)
{
    fz_html_flow *new_flow;
    char *text;
    size_t len;

    if (offset == 0)
        return flow;
    new_flow = fz_pool_alloc(ctx, pool, sizeof *flow);
    *new_flow = *flow;
    new_flow->next = flow->next;
    flow->next = new_flow;

    text = flow->content.text;
    while (*text && offset)
    {
        int rune;
        text += fz_chartorune(&rune, text);
        offset--;
    }
    len = strlen(text);
    new_flow->content.text = fz_pool_alloc(ctx, pool, len+1);
    strcpy(new_flow->content.text, text);
    *text = 0;
    return new_flow;
}
Beispiel #2
0
static void add_flow_word(fz_context *ctx, fz_pool *pool, fz_html *top, fz_css_style *style, const char *a, const char *b)
{
    fz_html_flow *flow = add_flow(ctx, pool, top, style, FLOW_WORD);
    flow->content.text = fz_pool_alloc(ctx, pool, b - a + 1);
    memcpy(flow->content.text, a, b - a);
    flow->content.text[b - a] = 0;
}
Beispiel #3
0
static fz_html_flow *add_flow(fz_context *ctx, fz_pool *pool, fz_html *top, fz_css_style *style, int type)
{
	fz_html_flow *flow = fz_pool_alloc(ctx, pool, sizeof *flow);
	flow->type = type;
	flow->style = style;
	*top->flow_tail = flow;
	top->flow_tail = &flow->next;
	return flow;
}
Beispiel #4
0
static fz_html *new_box(fz_context *ctx, fz_pool *pool)
{
    fz_html *box = fz_pool_alloc(ctx, pool, sizeof *box);
    init_box(ctx, box);
    return box;
}