Exemplo n.º 1
0
void HelpDialog::setText (QString text) {
  /* Try real hard to get a monospaced font. */
  QFont font ("monospace");

  if (!font_is_monospaced (font)) {
#if QT_VERSION >= 0x040700
    font.setStyleHint (QFont::Monospace);
#else
    font.setStyleHint (QFont::TypeWriter);
#endif
  }

  if (!font_is_monospaced (font)) {
    font.setFamily ("Courier New");
  }

  if (!font_is_monospaced (font)) {
    font.setFamily ("Courier");
  }

  /* If the font is not monospaced by now, there's not much else we can do... */
  font.setPointSize (10);

  plainTextEdit->setFont (font);

  plainTextEdit->setTabStopWidth (30);
  plainTextEdit->setWordWrapMode (QTextOption::NoWrap);
  plainTextEdit->setPlainText (text);
}
Exemplo n.º 2
0
/*
 * write every sheet of the workbook to a roff file
 *
 * FIXME: Should roff quote sheet name (and everything else)
 */
void
roff_file_save (GOFileSaver const *fs, GOIOContext *io_context,
                WorkbookView const *wb_view, GsfOutput *output)
{
	GSList *sheets, *ptr;
	GnmCell *cell;
	int row, col, fontsize, v_size;
	Workbook *wb = wb_view_get_workbook (wb_view);

	g_return_if_fail (wb != NULL);

	gsf_output_printf (output, ".\\\" TROFF file\n");
	gsf_output_printf (output, ".fo ''%%''\n");
	sheets = workbook_sheets (wb);
	for (ptr = sheets ; ptr != NULL ; ptr = ptr->next) {
		Sheet *sheet = ptr->data;
		GnmRange r = sheet_get_extent (sheet, FALSE, TRUE);

		gsf_output_printf (output, "%s\n\n", sheet->name_unquoted);
		gsf_output_printf (output, ".TS H\n");
		gsf_output_printf (output, "allbox;\n");

		for (row = r.start.row; row <= r.end.row; row++) {
			ColRowInfo const * ri;
			ri = sheet_row_get_info (sheet, row);
			if (ri->needs_respan)
				row_calc_spans ((ColRowInfo *) ri, row, sheet);

			if (row > r.start.row)
				gsf_output_printf (output, ".T&\n");
			/* define alignments, bold etc. per cell */
			v_size = DEFSIZE;
			for (col = r.start.col; col <= r.end.col; col++) {
				cell = sheet_cell_get (sheet, col, row);
				if (col > r.start.col)
					gsf_output_printf (output, " ");
				if (!cell) {
					gsf_output_printf (output, "l");
				} else {
					GnmStyle const *style = gnm_cell_get_style (cell);
					if (!style)
						break;
					if (gnm_style_get_align_h (style) & GNM_HALIGN_RIGHT)
						gsf_output_printf (output, "r");
					else if (gnm_style_get_align_h (style) == GNM_HALIGN_CENTER ||
						 /* FIXME : center across selection is different */
						 gnm_style_get_align_h (style) == GNM_HALIGN_CENTER_ACROSS_SELECTION ||
						 gnm_style_get_align_h (style) == GNM_HALIGN_DISTRIBUTED)
						gsf_output_printf (output, "c");
					else
						gsf_output_printf (output, "l");
					if (font_is_monospaced (style)) {
						if (gnm_style_get_font_bold (style) &&
						    gnm_style_get_font_italic (style))
							gsf_output_printf (output, "fCBI");
						else if (gnm_style_get_font_bold (style))
							gsf_output_printf (output, "fCB");
						else if (gnm_style_get_font_italic (style))
							gsf_output_printf (output, "fCI");
						else
							gsf_output_printf (output, "fCR");
					} else if (font_is_helvetica (style)) {
						if (gnm_style_get_font_bold (style) &&
						    gnm_style_get_font_italic (style))
							gsf_output_printf (output, "fHBI");
						else if (gnm_style_get_font_bold (style))
							gsf_output_printf (output, "fHB");
						else if (gnm_style_get_font_italic (style))
							gsf_output_printf (output, "fHI");
						else
							gsf_output_printf (output, "fHR");
					} else {
						/* default is times */
						if (gnm_style_get_font_bold (style) &&
						    gnm_style_get_font_italic (style))
							gsf_output_printf (output, "fTBI");
						else if (gnm_style_get_font_bold (style))
							gsf_output_printf (output, "fTB");
						else if (gnm_style_get_font_italic (style))
							gsf_output_printf (output, "fTI");
					}
					fontsize = gnm_style_get_font_size (style);
					if (fontsize) {
						gsf_output_printf (output, "p%d", fontsize);
						v_size = v_size > fontsize ? v_size :
							fontsize;
					}
				}
			}
			gsf_output_printf (output, ".\n");
			gsf_output_printf (output, ".vs %.2fp\n", 2.5 + v_size);
			for (col = r.start.col; col <= r.end.col;  col++) {
				if (col > r.start.col)
					gsf_output_printf (output, "\t");
				cell = sheet_cell_get (sheet, col, row);
				if (!cell) {	/* empty cell */
					gsf_output_printf (output, " ");
				} else {
					roff_fprintf (output, cell);
				}
			}
			gsf_output_printf (output, "\n");
			if (row == r.start.row)
				gsf_output_printf (output, ".TH\n");
		}
		gsf_output_printf (output, ".TE\n\n");
	}
	g_slist_free (sheets);
}
Exemplo n.º 3
0
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, "\",");
}
Exemplo n.º 4
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>");
		}
	}
}