Example #1
0
static void
ssindex_hlink (IndexerState *state, GnmHLink const *lnk)
{
	gchar const *str;

	str = gnm_hlink_get_target (lnk);
	if (str)
		gsf_xml_out_simple_element (state->output, "data", str);

	str = gnm_hlink_get_tip (lnk);
	if (str)
		gsf_xml_out_simple_element (state->output, "data", str);
}
Example #2
0
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>");
		}
	}
}
Example #3
0
int gnumeric_sheet_get_cell(GnumericSheetPtr sheet, int x, int y,
			    GSheetCellPtr cell) {
  gsheetcell_zero(cell);
  GnmValue const *value = sheet_cell_get_value((Sheet*)sheet,x,y);
  if (value==NULL) return 0;
  if (value->type == VALUE_EMPTY) return 0;

  GnmCell const *gcell = sheet_cell_get((Sheet*)sheet,x,y);
  if (gcell) {
    if (gnm_cell_has_expr (gcell)) {
      if (gcell->base.texpr->expr) {
	const GnmExpr *expr = gcell->base.texpr->expr;
	if (expr) {
	  if (expr->oper==GNM_EXPR_OP_FUNCALL) {
	    if (expr->func.func) {
	      const char *name = expr->func.func->name;
	      if (name) {
		if (strcasecmp(name,"hyperlink")==0) {
		  // Hyperlink. Take url part.
		  char *url = NULL;
		  char *txt = NULL;
		  if (expr->func.argc==2) {
		    const GnmExpr *expr0 = expr->func.argv[0];
		    if (expr0) {
		      if (expr0->oper == GNM_EXPR_OP_CONSTANT) {
			url = value_get_as_string(expr0->constant.value);
		      }
		    }
		    const GnmExpr *expr1 = expr->func.argv[1];
		    if (expr1) {
		      if (expr1->oper == GNM_EXPR_OP_CONSTANT) {
			txt = value_get_as_string(expr1->constant.value);
		      }
		    }
		  }
		  if (url&&txt) {
		    if (strcasecmp(url,txt)==0) {
		      cell->all = url;
		      cell->url = g_strdup(url);
		      cell->txt = g_strdup(url);
		      cell->is_url = 1;
		      return 0;
		    }
		    cell->all = g_strconcat("[",url,"|",txt,"]",NULL);
		    cell->url = url;
		    cell->txt = txt;
		    cell->is_url = 1;
		    return 0;
		  } else {
		    if (url) g_free(url);
		    if (txt) g_free(txt);
		  }
		}
	      }
	    }
	  }
	}
      }
      //return gnm_cell_get_entered_text(cell);
    }
  }

  GnmStyle const *style = sheet_style_get((Sheet*)sheet,x,y);
  GnmHLink* hlink = gnm_style_get_hlink (style);
  const guchar* hlink_target = NULL;
  if (hlink && IS_GNM_HLINK_URL (hlink)) {
    hlink_target = gnm_hlink_get_target (hlink);
    if (hlink_target) {
      //char *str = value_get_as_string(value);
      //if (!str) return str;
      //const char *str2 = " ";
      //char *result = g_strconcat(str,str2,hlink_target);
      //g_free(str);
      //return result;
      cell->is_url = 1;
      cell->all = g_strdup(hlink_target);
      cell->url = g_strdup(hlink_target);
      cell->txt = g_strdup(hlink_target);
      return 0;
    }
  }

  cell->all = value_get_as_string(value);
  return 0;
}