static void pwcsv_print_encoded (GsfOutput *output, char const *str) { gunichar c; gchar *encoded; if (str == NULL) return; gsf_output_puts (output, "\""); for (; *str != '\0' ; str = g_utf8_next_char (str)) { switch (*str) { case '"': gsf_output_puts (output, "\"\""); break; default: c = g_utf8_get_char (str); if (((c >= 0x20) && (c < 0x80)) || (c == '\n') || (c == '\r') || (c == '\t')) { gsf_output_write (output, 1, (guint8 *)str); } else { c = g_utf8_get_char (str); encoded = g_ucs4_to_utf8(&c, 1, NULL, NULL, NULL); gsf_output_puts (output, encoded); g_free(encoded); } break; } } gsf_output_puts (output, "\","); }
/* * write_row: * * @output: the stream * @sheet: the gnumeric sheet * @row: the row number * */ static void write_row (GsfOutput *output, Sheet *sheet, gint row, GnmRange *range) { char const *text = NULL; char *formatted_string = NULL; GnmCell *cell; GnmStyle const *style; GODateConventions const *date_conv = sheet->workbook ? workbook_date_conv (sheet->workbook) : NULL; gint col; for (col = range->start.col; col <= range->end.col; col++) { GnmRange const *merge_range; GnmCellPos pos; pos.col = col; pos.row = row; merge_range = gnm_sheet_merge_contains_pos (sheet, &pos); if (merge_range != NULL) { /* If cell is inside a merged region, we use the corner cell of the merged region: */ cell = sheet_cell_get (sheet, merge_range->start.col, merge_range->start.row); } else { cell = sheet_cell_get (sheet, col, row); } if (cell != NULL && cell->value) { text = value_peek_string (cell->value); pwcsv_print_encoded (output, text); style = sheet_style_get (sheet, col, row); GOFormat const *format = gnm_style_get_format (style); // set col_width to 16-something. This works around gnumeric quirk // where, in wider cells, it formats 9,3 as 9,300000000000001 formatted_string = format_value (format, cell->value, 16, date_conv); pwcsv_print_encoded (output, formatted_string); html_write_cell_content (output, cell, style, formatted_string); g_free (formatted_string); /* Without this, we're accumulating lots of heap memory on big spreadsheets. */ gnm_cell_unrender(cell); } else { gsf_output_puts (output, ",,,"); } } gsf_output_puts (output, "\n"); }
static void sylk_write_sheet (SylkWriter *state) { GnmRange extent; /* collect style and font info */ extent = sheet_get_extent (state->sheet, FALSE, TRUE); sheet_style_foreach (state->sheet, (GFunc)cb_sylk_collect_styles, state); sheet_cell_foreach (state->sheet, (GHFunc)cb_sylk_collect_cell_styles, state); /* * 1) formats P;P..... * 2.1) ?? fonts P;F.... * 2.2) indexed fonts P;E.... * 3) global formats F; */ /* Global Formatting */ /* F;P0;DG0G10;SM0;Z;M280;N3 10 */ /* Bounds */ gsf_output_printf (state->output, "B;Y%d;X%d;D0 0 %d %d\r\n", extent.end.row + 1, extent.end.col + 1, extent.end.row, extent.end.col); /* Global options */ gsf_output_printf (state->output, "O;%c%d %f", (state->wb->iteration.enabled ? 'A' : 'G'), state->wb->iteration.max_number, state->wb->iteration.tolerance); if (!state->sheet->convs->r1c1_addresses) gsf_output_puts (state->output, ";L"); if (!state->wb->recalc_auto) gsf_output_puts (state->output, ";M"); gsf_output_printf (state->output, ";V%d", workbook_date_conv (state->wb)->use_1904 ? 4 : 0); if (state->sheet->hide_zero) gsf_output_puts (state->output, ";Z"); gsf_output_write (state->output, 2, "\r\n"); /* dump content */ state->cur_row = -1; sheet_foreach_cell_in_range (state->sheet, CELL_ITER_IGNORE_BLANK, extent.start.col, extent.start.row, extent.end.col, extent.end.row, (CellIterFunc) cb_sylk_write_cell, state); }
/* * write_sheet: * * @output: the stream * @sheet: the gnumeric sheet * * set up a table and call write_row for each row */ static void write_sheet (GsfOutput *output, Sheet *sheet, html_version_t version, GOFileSaveScope save_scope) { GnmRange total_range; gint row; switch (version) { case HTML40: case HTML40F: case XHTML: gsf_output_puts (output, "<p></p><table cellspacing=\"0\" cellpadding=\"3\">\n"); break; default: gsf_output_puts (output, "<p><table border=\"1\">\n"); break; } if (save_scope != GO_FILE_SAVE_RANGE) { gsf_output_puts (output, "<caption>"); html_print_encoded (output, sheet->name_unquoted); gsf_output_puts (output, "</caption>\n"); } total_range = sheet_get_extent (sheet, TRUE, TRUE); for (row = total_range.start.row; row <= total_range.end.row; row++) { gsf_output_puts (output, "<tr>\n"); write_row (output, sheet, row, &total_range, version); gsf_output_puts (output, "</tr>\n"); } gsf_output_puts (output, "</table>\n"); }
/* * write_sheet: * * @output: the stream * @sheet: the gnumeric sheet * * set up a table and call write_row for each row */ static void write_sheet (GsfOutput *output, Sheet *sheet, GOFileSaveScope save_scope) { GnmRange total_range; gint row; total_range = sheet_get_extent (sheet, FALSE, TRUE); for (row = total_range.start.row; row <= total_range.end.row; row++) { write_row (output, sheet, row, &total_range); } gsf_output_puts (output, "---\n"); }
/* * html_print_encoded: * * @output: the stream * @str: the string * * print the string to output encoded all special chars * */ static void html_print_encoded (GsfOutput *output, char const *str) { gunichar c; gchar *encoded; if (str == NULL) return; for (; *str != '\0' ; str = g_utf8_next_char (str)) { switch (*str) { case '"': gsf_output_puts (output, "\"\""); break; case '<': gsf_output_puts (output, "<"); break; case '>': gsf_output_puts (output, ">"); break; case '&': gsf_output_puts (output, "&"); break; case '\n': gsf_output_puts (output, "<br />\n"); break; case '\r': gsf_output_puts (output, "<br />\r"); if( *(str+1) == '\n' ) { gsf_output_puts (output, "\n"); str++; } break; default: c = g_utf8_get_char (str); if (((c >= 0x20) && (c < 0x80)) || (c == '\n') || (c == '\r') || (c == '\t')) { gsf_output_write (output, 1, (guint8 *)str); } else { c = g_utf8_get_char (str); encoded = g_ucs4_to_utf8(&c, 1, NULL, NULL, NULL); gsf_output_puts (output, encoded); g_free(encoded); } break; } } }
void sylk_file_save (GOFileSaver const *fs, GOIOContext *io_context, gconstpointer wb_view, GsfOutput *output) { GnmLocale *locale; SylkWriter state; state.wb = wb_view_get_workbook (wb_view); state.sheet = wb_view_cur_sheet (wb_view); state.output = output; state.convs = sylk_conventions_new (); if (NULL == state.sheet) { go_io_error_string (io_context, _("Cannot get default sheet.")); return; } locale = gnm_push_C_locale (); gsf_output_puts (output, "ID;PGnumeric;N;E\r\n"); sylk_write_sheet (&state); gsf_output_puts (output, "E\r\n"); gnm_pop_C_locale (locale); gnm_conventions_unref (state.convs); }
/* * write_row: * * @output: the stream * @sheet: the gnumeric sheet * @row: the row number * * Set up a TD node for each cell in the given row, witht eh appropriate * colspan and rowspan. * Call write_cell for each cell. */ static void write_row (GsfOutput *output, Sheet *sheet, gint row, GnmRange *range, html_version_t version) { gint col; ColRowInfo const *ri = sheet_row_get_info (sheet, row); if (ri->needs_respan) row_calc_spans ((ColRowInfo *) ri, row, sheet); for (col = range->start.col; col <= range->end.col; col++) { CellSpanInfo const *the_span; GnmRange const *merge_range; GnmCellPos pos; pos.col = col; pos.row = row; /* Is this a span */ the_span = row_span_get (ri, col); if (the_span != NULL) { gsf_output_printf (output, "<td colspan=\"%i\" ", the_span->right - col + 1); write_cell (output, sheet, row, the_span->cell->pos.col, version, FALSE); col = the_span->right; continue; } /* is this covered by a merge */ merge_range = gnm_sheet_merge_contains_pos (sheet, &pos); if (merge_range != NULL) { if (merge_range->start.col != col || merge_range->start.row != row) continue; gsf_output_printf (output, "<td colspan=\"%i\" rowspan=\"%i\" ", merge_range->end.col - merge_range->start.col + 1, merge_range->end.row - merge_range->start.row + 1); write_cell (output, sheet, row, col, version, TRUE); col = merge_range->end.col; continue; } gsf_output_puts (output, "<td "); write_cell (output, sheet, row, col, version, FALSE); } }
/* * html_print_encoded: * * @output: the stream * @str: the string * * print the string to output encoded all special chars * */ static void html_print_encoded (GsfOutput *output, char const *str) { gunichar c; if (str == NULL) return; for (; *str != '\0' ; str = g_utf8_next_char (str)) { switch (*str) { case '<': gsf_output_puts (output, "<"); break; case '>': gsf_output_puts (output, ">"); break; case '&': gsf_output_puts (output, "&"); break; case '\"': gsf_output_puts (output, """); break; case '\n': gsf_output_puts (output, "<br>\n"); break; case '\r': gsf_output_puts (output, "<br>\r"); if( *(str+1) == '\n' ) { gsf_output_puts (output, "\n"); str++; } break; default: c = g_utf8_get_char (str); if (((c >= 0x20) && (c < 0x80)) || (c == '\n') || (c == '\r') || (c == '\t')) gsf_output_write (output, 1, str); else gsf_output_printf (output, "&#%u;", c); break; } } }
static void html_new_markup (GsfOutput *output, const PangoAttrList *markup, char const *text, html_version_t version) { int handled = 0; PangoAttrIterator * iter; int from, to; int len = strlen (text); GString *closure = g_string_new (""); iter = pango_attr_list_get_iterator ((PangoAttrList *) markup); do { GSList *list, *l; g_string_erase (closure, 0, -1); pango_attr_iterator_range (iter, &from, &to); from = (from > len) ? len : from; /* Since "from" can be really big! */ to = (to > len) ? len : to; /* Since "to" can be really big! */ if (from > handled) cb_html_add_chars (output, text + handled, from - handled); list = pango_attr_iterator_get_attrs (iter); for (l = list; l != NULL; l = l->next) { char const *result = cb_html_attrs_as_string (output, l->data, version); if (result != NULL) g_string_prepend (closure, result); } g_slist_free (list); if (to > from) cb_html_add_chars (output, text + from, to - from); gsf_output_puts (output, closure->str); handled = to; } while (pango_attr_iterator_next (iter)); g_string_free (closure, TRUE); pango_attr_iterator_destroy (iter); return; }
/* * Write _current_ sheet of the workbook to a DIF format file */ void dif_file_save (GOFileSaver const *fs, GOIOContext *io_context, WorkbookView const *wbv, GsfOutput *out) { GnmLocale *locale; Sheet *sheet; GnmRange r; gint row, col; gboolean ok = TRUE; sheet = wb_view_cur_sheet (wbv); if (sheet == NULL) { go_io_error_string (io_context, _("Cannot get default sheet.")); return; } r = sheet_get_extent (sheet, FALSE, TRUE); /* Write out the standard headers */ gsf_output_puts (out, "TABLE\n" "0,1\n" "\"GNUMERIC\"\n"); gsf_output_printf (out, "VECTORS\n" "0,%d\n" "\"\"\n", r.end.col+1); gsf_output_printf (out, "TUPLES\n" "0,%d\n" "\"\"\n", r.end.row+1); gsf_output_puts (out, "DATA\n" "0,0\n" "\"\"\n"); locale = gnm_push_C_locale (); /* Process all cells */ for (row = r.start.row; ok && row <= r.end.row; row++) { gsf_output_puts (out, "-1,0\n" "BOT\n"); for (col = r.start.col; col <= r.end.col; col++) { GnmCell *cell = sheet_cell_get (sheet, col, row); if (gnm_cell_is_empty (cell)) { gsf_output_puts(out, "1,0\n" "\"\"\n"); } else if (VALUE_IS_BOOLEAN (cell->value)) { if (value_get_as_checked_bool (cell->value)) gsf_output_puts(out, "0,1\n" "TRUE\n"); else gsf_output_puts(out, "0,0\n" "FALSE\n"); } else if (VALUE_IS_ERROR (cell->value)) { if (value_error_classify (cell->value) == GNM_ERROR_NA) gsf_output_puts(out, "0,0\n" "NA\n"); else gsf_output_puts(out, "0,0\n" "ERROR\n"); } else if (VALUE_IS_FLOAT (cell->value)) gsf_output_printf (out, "0,%" GNM_FORMAT_g "\n" "V\n", value_get_as_float (cell->value)); else { gchar *str = gnm_cell_get_rendered_text (cell); ok = gsf_output_printf (out, "1,0\n" "\"%s\"\n", str); g_free (str); } } } gsf_output_puts (out, "-1,0\n" "EOD\n"); gnm_pop_C_locale (locale); if (!ok) go_io_error_string (io_context, _("Error while saving DIF file.")); }
static void html_write_cell_content (GsfOutput *output, GnmCell *cell, GnmStyle const *style, char *formatted_string) { gsf_output_puts (output, "\""); if (style != NULL) { if (gnm_style_get_font_italic (style)) gsf_output_puts (output, "<i>"); if (gnm_style_get_font_bold (style)) gsf_output_puts (output, "<b>"); if (gnm_style_get_font_uline (style) != UNDERLINE_NONE) gsf_output_puts (output, "<u>"); if (font_is_monospaced (style)) gsf_output_puts (output, "<tt>"); if (gnm_style_get_font_strike (style)) gsf_output_puts (output, "<strike>"); switch (gnm_style_get_font_script (style)) { case GO_FONT_SCRIPT_SUB: gsf_output_puts (output, "<sub>"); break; case GO_FONT_SCRIPT_SUPER: gsf_output_puts (output, "<sup>"); break; default: break; } } if (cell != NULL) { const PangoAttrList * markup = NULL; if ((cell->value->type == VALUE_STRING) && (VALUE_FMT (cell->value) != NULL) && go_format_is_markup (VALUE_FMT (cell->value))) markup = go_format_get_markup (VALUE_FMT (cell->value)); if (markup != NULL) { GString *str = g_string_new (""); value_get_as_gstring (cell->value, str, NULL); html_new_markup (output, markup, str->str); g_string_free (str, TRUE); } else { html_print_encoded (output, formatted_string); } } if (style != NULL) { if (gnm_style_get_font_strike (style)) gsf_output_puts (output, "</strike>"); switch (gnm_style_get_font_script (style)) { case GO_FONT_SCRIPT_SUB: gsf_output_puts (output, "</sub>"); break; case GO_FONT_SCRIPT_SUPER: gsf_output_puts (output, "</sup>"); break; default: break; } if (font_is_monospaced (style)) gsf_output_puts (output, "</tt>"); if (gnm_style_get_font_uline (style) != UNDERLINE_NONE) gsf_output_puts (output, "</u>"); if (gnm_style_get_font_bold (style)) gsf_output_puts (output, "</b>"); if (gnm_style_get_font_italic (style)) gsf_output_puts (output, "</i>"); } gsf_output_puts (output, "\","); }
static char const * cb_html_attrs_as_string (GsfOutput *output, PangoAttribute *a) { /* PangoColor const *c; */ char const *closure = NULL; switch (a->klass->type) { case PANGO_ATTR_FAMILY : break; /* ignored */ case PANGO_ATTR_SIZE : break; /* ignored */ case PANGO_ATTR_RISE: if (((PangoAttrInt *)a)->value > 5) { gsf_output_puts (output, "<sup>"); closure = "</sup>"; } else if (((PangoAttrInt *)a)->value < -5) { gsf_output_puts (output, "<sub>"); closure = "</sub>"; } break; case PANGO_ATTR_STYLE : if (((PangoAttrInt *)a)->value == PANGO_STYLE_ITALIC) { gsf_output_puts (output, "<i>"); closure = "</i>"; } break; case PANGO_ATTR_WEIGHT : if (((PangoAttrInt *)a)->value > 600){ gsf_output_puts (output, "<b>"); closure = "</b>"; } break; case PANGO_ATTR_STRIKETHROUGH : if (((PangoAttrInt *)a)->value == 1) { gsf_output_puts (output, "<strike>"); closure = "</strike>"; } break; case PANGO_ATTR_UNDERLINE : if (((PangoAttrInt *)a)->value != PANGO_UNDERLINE_NONE) { gsf_output_puts (output, "<u>"); closure = "</u>"; } break; case PANGO_ATTR_FOREGROUND : /* c = &((PangoAttrColor *)a)->color; */ /* g_string_append_printf (accum, "[color=%02xx%02xx%02x", */ /* ((c->red & 0xff00) >> 8), */ /* ((c->green & 0xff00) >> 8), */ /* ((c->blue & 0xff00) >> 8)); */ break;/* ignored */ default : if (a->klass->type == go_pango_attr_subscript_get_attr_type ()) { if (((GOPangoAttrSubscript *)a)->val) { gsf_output_puts (output, "<sub>"); closure = "</sub>"; } } else if (a->klass->type == go_pango_attr_superscript_get_attr_type ()) { if (((GOPangoAttrSuperscript *)a)->val) { gsf_output_puts (output, "<sup>"); closure = "</sup>"; } } break; /* ignored */ } return closure; }
/* * html_file_save: * * write the html file (version of html according to version argument) */ static void html_file_save (GOFileSaver const *fs, GOIOContext *io_context, WorkbookView const *wb_view, GsfOutput *output, html_version_t version) { Workbook *wb = wb_view_get_workbook (wb_view); GOFileSaveScope save_scope; GPtrArray *sel; unsigned ui; g_return_if_fail (fs != NULL); g_return_if_fail (wb != NULL); g_return_if_fail (output != NULL); switch (version) { case HTML32: gsf_output_puts (output, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n" "<html>\n" "<head>\n\t<title>Tables</title>\n" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" "<meta name=\"generator\" content=\"Gnumeric " GNM_VERSION_FULL " via " G_PLUGIN_FOR_HTML "\">\n" "<style><!--\n" "tt {\n" "\tfont-family: courier;\n" "}\n" "td {\n" "\tfont-family: helvetica, sans-serif;\n" "}\n" "caption {\n" "\tfont-family: helvetica, sans-serif;\n" "\tfont-size: 14pt;\n" "\ttext-align: left;\n" "}\n" "--></style>\n" "</head>\n<body>\n"); break; case HTML40: gsf_output_puts (output, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n" "\t\t\"http://www.w3.org/TR/html4/strict.dtd\">\n" "<html>\n" "<head>\n\t<title>Tables</title>\n" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" "<meta name=\"generator\" content=\"Gnumeric " GNM_VERSION_FULL " via " G_PLUGIN_FOR_HTML "\">\n" "<style type=\"text/css\">\n" "tt {\n" "\tfont-family: courier;\n" "}\n" "td {\n" "\tfont-family: helvetica, sans-serif;\n" "}\n" "caption {\n" "\tfont-family: helvetica, sans-serif;\n" "\tfont-size: 14pt;\n" "\ttext-align: left;\n" "}\n" "</style>\n" "</head>\n<body>\n"); break; case XHTML : gsf_output_puts (output, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" "\t\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" "<head>\n\t<title>Tables</title>\n" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" "<meta name=\"generator\" content=\"Gnumeric " GNM_VERSION_FULL " via " G_PLUGIN_FOR_HTML "\" />\n" "<style type=\"text/css\">\n" "tt {\n" "\tfont-family: courier;\n" "}\n" "td {\n" "\tfont-family: helvetica, sans-serif;\n" "}\n" "caption {\n" "\tfont-family: helvetica, sans-serif;\n" "\tfont-size: 14pt;\n" "\ttext-align: left;\n" "}\n" "</style>\n" "</head>\n<body>\n"); break; default: break; } save_scope = go_file_saver_get_save_scope (fs); sel = gnm_file_saver_get_sheets (fs, wb_view, TRUE); for (ui = 0; ui < sel->len; ui++) { Sheet *sheet = g_ptr_array_index (sel, ui); write_sheet (output, sheet, version, save_scope); } g_ptr_array_unref (sel); if (version == HTML32 || version == HTML40 || version == XHTML) gsf_output_puts (output, "</body>\n</html>\n"); }
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"); }
static void html_write_cell_content (GsfOutput *output, GnmCell *cell, GnmStyle const *style, html_version_t version) { guint r = 0; guint g = 0; guint b = 0; char *rendered_string; gboolean hidden = gnm_style_get_contents_hidden (style); GnmHLink* hlink = gnm_style_get_hlink (style); const guchar* hlink_target = NULL; if (hlink && GNM_IS_HLINK_URL (hlink)) { hlink_target = gnm_hlink_get_target (hlink); } if (version == HTML32 && hidden) gsf_output_puts (output, "<!-- 'HIDDEN DATA' -->"); else { if (style != NULL) { if (gnm_style_get_font_italic (style)) gsf_output_puts (output, "<i>"); if (gnm_style_get_font_bold (style)) gsf_output_puts (output, "<b>"); if (gnm_style_get_font_uline (style) != UNDERLINE_NONE) gsf_output_puts (output, "<u>"); if (font_is_monospaced (style)) gsf_output_puts (output, "<tt>"); if (gnm_style_get_font_strike (style)) { if (version == HTML32) gsf_output_puts (output, "<strike>"); else gsf_output_puts (output, "<span style=\"text-decoration: line-through;\">"); } switch (gnm_style_get_font_script (style)) { case GO_FONT_SCRIPT_SUB: gsf_output_puts (output, "<sub>"); break; case GO_FONT_SCRIPT_SUPER: gsf_output_puts (output, "<sup>"); break; default: break; } } if (hlink_target) gsf_output_printf (output, "<a href=\"%s\">", hlink_target); if (cell != NULL) { const PangoAttrList * markup = NULL; if (style != NULL && version != HTML40) { html_get_text_color (cell, style, &r, &g, &b); if (r > 0 || g > 0 || b > 0) gsf_output_printf (output, "<font color=\"#%02X%02X%02X\">", r, g, b); } if (VALUE_IS_STRING (cell->value) && (VALUE_FMT (cell->value) != NULL) && go_format_is_markup (VALUE_FMT (cell->value))) markup = go_format_get_markup (VALUE_FMT (cell->value)); if (markup != NULL) { GString *str = g_string_new (""); value_get_as_gstring (cell->value, str, NULL); html_new_markup (output, markup, str->str, version); g_string_free (str, TRUE); } else { rendered_string = gnm_cell_get_rendered_text (cell); html_print_encoded (output, rendered_string); g_free (rendered_string); } } if (r > 0 || g > 0 || b > 0) gsf_output_puts (output, "</font>"); if (hlink_target) gsf_output_puts (output, "</a>"); if (style != NULL) { if (gnm_style_get_font_strike (style)) { if (version == HTML32) gsf_output_puts (output, "</strike>"); else gsf_output_puts (output, "</span>"); } switch (gnm_style_get_font_script (style)) { case GO_FONT_SCRIPT_SUB: gsf_output_puts (output, "</sub>"); break; case GO_FONT_SCRIPT_SUPER: gsf_output_puts (output, "</sup>"); break; default: break; } if (font_is_monospaced (style)) gsf_output_puts (output, "</tt>"); if (gnm_style_get_font_uline (style) != UNDERLINE_NONE) gsf_output_puts (output, "</u>"); if (gnm_style_get_font_bold (style)) gsf_output_puts (output, "</b>"); if (gnm_style_get_font_italic (style)) gsf_output_puts (output, "</i>"); } } }