static void set_layout(GnmStyle * style,const psiconv_sheet_cell_layout psi_layout) { GnmColor *color; set_format(style,psi_layout->numberformat); gnm_style_set_font_size(style,psi_layout->character->font_size); gnm_style_set_font_italic(style,psi_layout->character->italic?TRUE:FALSE); gnm_style_set_font_bold(style,psi_layout->character->bold?TRUE:FALSE); gnm_style_set_font_uline(style, psi_layout->character->underline?TRUE:FALSE); gnm_style_set_font_strike(style, psi_layout->character->strikethrough?TRUE:FALSE); gnm_style_set_font_name(style, (const char *) psi_layout->character->font->name); color = get_color(psi_layout->character->color); if (color) gnm_style_set_font_color (style, color); /* TODO: Character level layouts: super_sub */ /* TODO: Paragraph level layouts: all */ /* TODO: Background color: add transparant if white */ #if 0 color = get_color(psi_layout->paragraph->back_color); if (color) { gnm_style_set_back_color(style, color); gnm_style_set_pattern_color(style, color); /* TODO: Replace 24 with some symbol */ gnm_style_set_pattern(style,1); } #endif }
static void html_read_row (htmlNodePtr cur, htmlDocPtr doc, GnmHtmlTableCtxt *tc) { htmlNodePtr ptr; int col = -1; for (ptr = cur->children; ptr != NULL ; ptr = ptr->next) { if (xmlStrEqual (ptr->name, CC2XML ("td")) || xmlStrEqual (ptr->name, CC2XML ("th"))) { GString *buf; xmlBufferPtr a_buf; xmlAttrPtr props; int colspan = 1; int rowspan = 1; GnmCellPos pos; GnmStyle *mstyle; GSList *hrefs = NULL; GnmHLink *lnk = NULL; /* Check whether we need to skip merges from above */ pos.row = tc->row; pos.col = col + 1; while (gnm_sheet_merge_contains_pos (tc->sheet, &pos)) { col++; pos.col++; } /* Do we span across multiple rows or cols? */ props = ptr->properties; while (props) { if (xmlStrEqual (props->name, CC2XML ("colspan")) && props->children) colspan = atoi (CXML2C (props->children->content)); if (xmlStrEqual (props->name, CC2XML ("rowspan")) && props->children) rowspan = atoi (CXML2C (props->children->content)); props = props->next; } if (colspan < 1) colspan = 1; if (rowspan < 1) rowspan = 1; /* Let's figure out the content of the cell */ buf = g_string_new (NULL); a_buf = xmlBufferCreate (); mstyle = gnm_style_new_default (); if (xmlStrEqual (ptr->name, CC2XML ("th"))) gnm_style_set_font_bold (mstyle, TRUE); html_read_content (ptr, buf, mstyle, a_buf, &hrefs, TRUE, doc, tc); if (g_slist_length (hrefs) >= 1 && buf->len > 0) { /* One hyperlink, and text to make it * visible */ char *url; xmlBufferPtr h_buf = xmlBufferCreate (); hrefs = g_slist_reverse (hrefs); htmlNodeDump ( h_buf, doc, (htmlNodePtr)hrefs->data); url = g_strndup ( CXML2C (h_buf->content), h_buf->use); if (strncmp (url, "mailto:", strlen ("mailto:")) == 0) lnk = gnm_hlink_new ( gnm_hlink_email_get_type (), tc->sheet); else lnk = gnm_hlink_new ( gnm_hlink_url_get_type (), tc->sheet); gnm_hlink_set_target (lnk, url); gnm_style_set_hlink (mstyle, lnk); gnm_style_set_font_uline (mstyle, UNDERLINE_SINGLE); gnm_style_set_font_color (mstyle, gnm_color_new_go (GO_COLOR_BLUE)); g_free (url); xmlBufferFree (h_buf); } if (g_slist_length (hrefs) > 1 || buf->len <= 0) { /* Multiple links, * or no text to give hyperlink style, * so put them in a comment */ GSList *l; for (l = hrefs; l != NULL; l = l->next) { htmlNodeDump (a_buf, doc, (htmlNodePtr)l->data); xmlBufferAdd (a_buf, CC2XML ("\n"), -1); } } g_slist_free (hrefs); if (buf->len > 0) { GnmCell *cell = sheet_cell_fetch (tc->sheet, col + 1, tc->row); sheet_style_set_pos (tc->sheet, col + 1, tc->row, mstyle); gnm_cell_set_text (cell, buf->str); } else gnm_style_unref (mstyle); if (a_buf->use > 0) { char *name; name = g_strndup (CXML2C (a_buf->content), a_buf->use); cell_set_comment (tc->sheet, &pos, NULL, name, NULL); g_free (name); } g_string_free (buf, TRUE); xmlBufferFree (a_buf); /* If necessary create the merge */ if (colspan > 1 || rowspan > 1) { GnmRange range; GnmRange *r = ⦥ range_init (r, col + 1, tc->row, col + colspan, tc->row + rowspan - 1); gnm_sheet_merge_add (tc->sheet, r, FALSE, NULL); } col += colspan; } } }