handle relayout of shack elements

This commit is contained in:
spence 1998-05-12 23:04:58 +00:00
parent 6b461310f7
commit 569779ab6c
2 changed files with 141 additions and 5 deletions

View File

@ -109,8 +109,8 @@ lo_FormatBuiltinObject (MWContext *context, lo_DocState* state,
void
lo_FillInBuiltinGeometry(lo_DocState *state,
LO_BuiltinStruct *builtin,
Bool relayout)
LO_BuiltinStruct *builtin,
Bool relayout)
{
int32 doc_width;
@ -404,7 +404,7 @@ lo_FormatBuiltinInternal (MWContext *context, lo_DocState *state, PA_Tag *tag,
builtin->border_horiz_space = FEUNITS_X(builtin->border_horiz_space,
context);
/* embed_list for reflection? XXX */
/* builtin_list for reflection? XXX */
lo_FinishBuiltin (context, state, builtin);
}
@ -414,7 +414,6 @@ lo_FinishBuiltin (MWContext *context, lo_DocState *state, LO_BuiltinStruct *buil
{
int32 baseline_inc;
int32 line_inc;
int32 embed_height, embed_width;
#ifdef DEBUG_SPENCE
printf ("lo_FinishBuiltin\n");
@ -478,3 +477,103 @@ lo_UpdateStateAfterBuiltinLayout (lo_DocState *state, LO_BuiltinStruct *builtin,
y = builtin->y + builtin->y_offset + builtin->border_width;
}
void
lo_LayoutInflowBuiltin(MWContext *context,
lo_DocState *state,
LO_BuiltinStruct *builtin,
Bool inRelayout,
int32 *line_inc,
int32 *baseline_inc)
{
int32 builtin_width, builtin_height;
Bool line_break;
PA_Block buff;
char *str;
LO_TextStruct tmp_text;
LO_TextInfo text_info;
lo_TopState *top_state;
top_state = state->top_state;
/*
* All this work is to get the text_info filled in for the current
* font in the font stack. Yuck, there must be a better way.
*/
memset (&tmp_text, 0, sizeof (tmp_text));
buff = PA_ALLOC(1);
if (buff == NULL)
{
top_state->out_of_memory = TRUE;
return;
}
PA_LOCK(str, char *, buff);
str[0] = ' ';
PA_UNLOCK(buff);
tmp_text.text = buff;
tmp_text.text_len = 1;
tmp_text.text_attr =
state->font_stack->text_attr;
FE_GetTextInfo(context, &tmp_text, &text_info);
PA_FREE(buff);
builtin_width = builtin->width + (2 * builtin->border_width) +
(2 * builtin->border_horiz_space);
builtin_height = builtin->height + (2 * builtin->border_width) +
(2 * builtin->border_vert_space);
/*
* Will this builtin make the line too wide.
*/
if ((state->x + builtin_width) > state->right_margin)
{
line_break = TRUE;
}
else
{
line_break = FALSE;
}
/*
* if we are at the beginning of the line. There is
* no point in breaking, we are just too wide.
* Also don't break in unwrapped preformatted text.
* Also can't break inside a NOBR section.
*/
if ((state->at_begin_line != FALSE)||
(state->preformatted == PRE_TEXT_YES)||
(state->breakable == FALSE))
{
line_break = FALSE;
}
/*
* break on the builtin if we have
* a break.
*/
if (line_break != FALSE)
{
/*
* We need to make the elements sequential, linefeed
* before builtin.
*/
top_state->element_id = builtin->ele_id;
if (!inRelayout)
{
lo_SoftLineBreak(context, state, TRUE);
}
else
{
lo_rl_AddSoftBreakAndFlushLine(context, state);
}
builtin->x = state->x;
builtin->y = state->y;
builtin->ele_id = NEXT_ELEMENT;
}
lo_CalcAlignOffsets(state, &text_info, (intn)builtin->alignment,
builtin_width, builtin_height,
&builtin->x_offset, &builtin->y_offset, line_inc, baseline_inc);
}

View File

@ -82,6 +82,9 @@ static LO_Element * lo_rl_FitFormEle( lo_RelayoutState *relay_state, LO_Element
static LO_Element * lo_rl_FitTable( lo_RelayoutState *relay_state, LO_Element *lo_ele );
static LO_Element * lo_rl_FitCell( lo_RelayoutState *relay_state, LO_Element *lo_ele );
static LO_Element * lo_rl_FitEmbed( lo_RelayoutState *relay_state, LO_Element *lo_ele );
#ifdef SHACK
static LO_Element * lo_rl_FitBuiltin( lo_RelayoutState *relay_state, LO_Element *lo_ele );
#endif /* SHACK */
static LO_Element * lo_rl_FitJava( lo_RelayoutState *relay_state, LO_Element *lo_ele );
static LO_Element * lo_rl_FitObject( lo_RelayoutState *relay_state, LO_Element *lo_ele );
static LO_Element * lo_rl_FitParagraph( lo_RelayoutState *relay_state, LO_Element *lo_ele );
@ -129,7 +132,10 @@ static lo_FitFunction lo_rl_FitFunctionTable[] = {
lo_rl_FitHeading, /* LO_HEADING */
lo_rl_FitSpan, /* LO_SPAN */
lo_rl_FitDiv, /* LO_DIV */
lo_rl_FitSpacer /* LO_SPACER */
#ifdef SHACK
lo_rl_FitBuiltin, /* LO_BUILTIN */
#endif /* SHACK */
lo_rl_FitSpacer /* LO_SPACER */
};
@ -1158,6 +1164,23 @@ lo_rl_FitEmbed( lo_RelayoutState *relay_state, LO_Element *lo_ele )
return next;
}
#ifdef SHACK
static LO_Element *
lo_rl_FitBuiltin( lo_RelayoutState *relay_state, LO_Element *lo_ele )
{
int32 line_inc, baseline_inc;
LO_Element *next = lo_tv_GetNextLayoutElement(relay_state->doc_state, lo_ele, FALSE);
LO_BuiltinStruct *builtin = (LO_BuiltinStruct*)lo_ele;
lo_FillInBuiltinGeometry(relay_state->doc_state, builtin, TRUE);
lo_LayoutInflowBuiltin(relay_state->context, relay_state->doc_state, builtin, TRUE, &line_inc, &baseline_inc);
lo_AppendToLineList(relay_state->context, relay_state->doc_state, lo_ele, baseline_inc);
lo_UpdateStateAfterBuiltinLayout(relay_state->doc_state, builtin, line_inc, baseline_inc);
return next;
}
#endif /* SHACK */
static LO_Element *
lo_rl_FitJava( lo_RelayoutState *relay_state, LO_Element *lo_ele )
{
@ -1407,6 +1430,20 @@ lo_rl_FitFloat( lo_RelayoutState *relay_state, LO_Element *lo_ele )
layer = embed->layer;
}
#ifdef SHACK
else if (lo_ele->lo_float.float_ele->lo_any.type == LO_BUILTIN) {
LO_BuiltinStruct *builtin = (LO_BuiltinStruct *)lo_ele->lo_float.float_ele;
lo_LayoutFloatEmbed( relay_state->context, relay_state->doc_state,
(LO_EmbedStruct *)builtin, FALSE );
/* Determine the new position of the layer. */
x = builtin->x + builtin->x_offset + builtin->border_width;
y = builtin->y + builtin->y_offset + builtin->border_width;
layer = builtin->layer;
}
#endif /* SHACK */
else if (lo_ele->lo_float.float_ele->lo_any.type == LO_TABLE) {
LO_TableStruct *table_ele = (LO_TableStruct *)lo_ele->lo_float.float_ele;
lo_DocState *state = relay_state->doc_state;