Esempio n. 1
0
static void
cb_index_styles (GnmStyle *style, IndexerState *state)
{
	if (gnm_style_is_element_set (style, MSTYLE_HLINK)) {
		GnmHLink const *lnk = gnm_style_get_hlink (style);
		if (lnk != NULL)
			ssindex_hlink (state, lnk);
	}

	if (gnm_style_is_element_set (style, MSTYLE_VALIDATION)) {
		GnmValidation const *valid = gnm_style_get_validation (style);
		if (valid)
			ssindex_validation (state, valid);
	}

	/* Input Msg? */
}
static guint16
calc_indent (PangoContext *context, const GnmStyle *mstyle)
{
	int indent = 0;
	if (gnm_style_is_element_set (mstyle, MSTYLE_INDENT)) {
		int n = gnm_style_get_indent (mstyle);
		if (n) {
			GnmFont *style_font = gnm_style_get_font (mstyle, context);
			indent = PANGO_PIXELS (n * style_font->go.metrics->avg_digit_width);
		}
	}
	return MIN (indent, 65535);
}
Esempio n. 3
0
/**
 * gnm_style_required_spanflags:
 * @style: the style
 *
 * What changes are required after applying the supplied style.
 **/
GnmSpanCalcFlags
gnm_style_required_spanflags (GnmStyle const *style)
{
	GnmSpanCalcFlags res = GNM_SPANCALC_SIMPLE;

	if (gnm_style_is_element_set (style, MSTYLE_CONDITIONS))
		/* Note that style->cond_styles may not be set yet */
		/* More importantly, even if the conditions are empty we */
		/* have to rerender everything since we do not know what changed. */
		res |= GNM_SPANCALC_RE_RENDER | GNM_SPANCALC_RESIZE | GNM_SPANCALC_ROW_HEIGHT;
	else {
		gboolean const row_height =
			gnm_style_is_element_set (style, MSTYLE_FONT_SIZE) ||
			gnm_style_is_element_set (style, MSTYLE_WRAP_TEXT) ||
			gnm_style_is_element_set (style, MSTYLE_ROTATION) ||
			gnm_style_is_element_set (style, MSTYLE_FONT_SCRIPT);
		gboolean const size_change = row_height ||
			gnm_style_is_element_set (style, MSTYLE_FONT_NAME) ||
			gnm_style_is_element_set (style, MSTYLE_FONT_BOLD) ||
			gnm_style_is_element_set (style, MSTYLE_FONT_ITALIC);
		gboolean const format_change =
			gnm_style_is_element_set (style, MSTYLE_FORMAT) ||
			gnm_style_is_element_set (style, MSTYLE_INDENT) ||
			gnm_style_is_element_set (style, MSTYLE_ALIGN_H) ||
			gnm_style_is_element_set (style, MSTYLE_ALIGN_V) ||
			gnm_style_is_element_set (style, MSTYLE_FONT_STRIKETHROUGH) ||
			gnm_style_is_element_set (style, MSTYLE_FONT_UNDERLINE) ||
			gnm_style_is_element_set (style, MSTYLE_FONT_COLOR);

		if (row_height)
			res |= GNM_SPANCALC_ROW_HEIGHT;
		if (format_change || size_change)
			res |= GNM_SPANCALC_RE_RENDER | GNM_SPANCALC_RESIZE;
	}
	return res;
}
Esempio n. 4
0
static void
write_cell (GsfOutput *output, Sheet *sheet, gint row, gint col, html_version_t version, gboolean is_merge)
{
	GnmCell *cell;
	GnmStyle const *style;
	guint r, g, b;

	style = sheet_style_get (sheet, col, row);
	if (style != NULL && version != HTML32 && version != HTML40 &&
	    gnm_style_get_pattern (style) != 0 &&
	    gnm_style_is_element_set (style, MSTYLE_COLOR_BACK)) {
		html_get_back_color (style, &r, &g, &b);
		gsf_output_printf (output, " bgcolor=\"#%02X%02X%02X\"", r, g, b);
	}

	cell = sheet_cell_get (sheet, col, row);
	if (cell != NULL) {

		switch (gnm_style_get_align_v (style)) {
		case GNM_VALIGN_TOP:
			gsf_output_puts (output, " valign=\"top\" ");
			break;
		case GNM_VALIGN_BOTTOM:
			gsf_output_puts (output, " valign=\"bottom\" ");
			break;
		case GNM_VALIGN_DISTRIBUTED:
		case GNM_VALIGN_CENTER:
			gsf_output_puts (output, " valign=\"center\" ");
			break;
		case GNM_VALIGN_JUSTIFY:
			gsf_output_puts (output, " valign=\"baseline\" ");
			break;
		default:
			break;
		}
		switch (gnm_style_default_halign (style, cell)) {
		case GNM_HALIGN_RIGHT:
			gsf_output_puts (output, " align=\"right\" ");
			break;
		case GNM_HALIGN_DISTRIBUTED:
		case GNM_HALIGN_CENTER:
		case GNM_HALIGN_CENTER_ACROSS_SELECTION:
			gsf_output_puts (output, " align=\"center\" ");
			break;
		case GNM_HALIGN_LEFT:
			gsf_output_puts (output, " align=\"left\" ");
			break;
		case GNM_HALIGN_JUSTIFY:
			gsf_output_puts (output, " align=\"justify\" ");
			break;
		default:
			break;
		}

	}
	if (version == HTML40 || version == HTML40F  || version ==XHTML) {
		if (style != NULL) {
			gsf_output_printf (output, " style=\"");
			if (gnm_style_get_pattern (style) != 0 &&
			    gnm_style_is_element_set (style, MSTYLE_COLOR_BACK)) {
				html_get_back_color (style, &r, &g, &b);
				gsf_output_printf (output, "background:#%02X%02X%02X;", r, g, b);
			}
			if (cell != NULL) {
				gint size = (int) (gnm_style_get_font_size (style) + 0.5);
				gsf_output_printf (output, " font-size:%ipt;", size);
				html_get_text_color (cell, style, &r, &g, &b);
				if (r > 0 || g > 0 || b > 0)
					gsf_output_printf (output, " color:#%02X%02X%02X;", r, g, b);
				if (gnm_style_get_contents_hidden (style))
					gsf_output_puts (output, " visibility:hidden;");
			}
			if (is_merge)
				html_write_border_style_40_for_merged_cell (output, style, sheet, row, col);
			else
				html_write_border_style_40 (output, style);
			gsf_output_printf (output, "\"");
		}
	}
	gsf_output_printf (output, ">");
	html_write_cell_content (output, cell, style, version);
	gsf_output_puts (output, "</td>\n");
}