From: John Darrington Date: Wed, 24 Aug 2011 07:29:49 +0000 (+0200) Subject: Improve paste to Openoffice.org &c X-Git-Tag: v0.7.9~152 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a0c099b7e531a7e30e5734b62f6befe10d9108a;p=pspp-builds.git Improve paste to Openoffice.org &c Added "css" and "borders" options to the html driver, and set these options to false when generating clipboard data. This produces better looking results when cut & pasting to OOo --- diff --git a/doc/invoking.texi b/doc/invoking.texi index b37d5956..95662f80 100644 --- a/doc/invoking.texi +++ b/doc/invoking.texi @@ -194,6 +194,9 @@ check} and similar scripts. @node PDF PostScript and SVG Output Options @section PDF, PostScript, and SVG Output Options +@cindex PDF +@cindex Postscript +@cindex SVG To produce output in PDF, PostScript, and SVG formats, specify @option{-o @var{file}} on the PSPP command line, optionally followed @@ -335,7 +338,7 @@ you might pass the output. Default: @code{none}. @node HTML Output Options @section HTML Output Options - +@cindex HTML To produce output in HTML format, specify @option{-o @var{file}} on the PSPP command line, optionally followed by any of the options shown in the table below to customize the output format. @@ -348,6 +351,16 @@ given on @option{-o} does not end in @file{.html}. @item -O charts=@{@var{template}.png|none@} Sets the name used for chart files. @xref{Plain Text Output Options}, for details. + +@item -O borders=@var{boolean} +Decorate the tables with borders. If set to false, the tables produced +will have no borders. The default value is true. + +@item -O css=@var{boolean} +Use cascading style sheets. Cascading style sheets give an improved appearance +and can be used to produce pages which fit a certain web site's style. +The default value is true. + @end table @node OpenDocument Output Options diff --git a/src/output/html.c b/src/output/html.c index 45c9a1ef..77d4195f 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -55,6 +55,9 @@ struct html_driver char *command_name; FILE *file; size_t chart_cnt; + + bool css; + bool borders; }; static const struct output_driver_class html_driver_class; @@ -91,6 +94,8 @@ html_create (const char *file_name, enum settings_output_devices device_type, d = &html->driver; output_driver_init (&html->driver, &html_driver_class, file_name, device_type); + html->css = parse_boolean (opt (d, o, "css", "true")); + html->borders = parse_boolean (opt (d, o, "borders", "true")); html->file_name = xstrdup (file_name); html->chart_file_name = parse_chart_file_name (opt (d, o, "charts", @@ -111,62 +116,66 @@ html_create (const char *file_name, enum settings_output_devices device_type, fputs ("\n", html->file); print_title_tag (html->file, "TITLE", _("PSPP Output")); fprintf (html->file, "\n", version); - fputs ("\n", - html->file); fputs ("\n", html->file); - fputs ("\n", - html->file); + + if ( html->css) + { + fputs ("\n", + html->file); + fputs ("\n", + html->file); + } fputs ("\n", html->file); fputs ("file); fputs (" LINK=\"#1f00ff\" ALINK=\"#ff0000\" VLINK=\"#9900dd\">\n", html->file); @@ -406,33 +415,36 @@ html_output_table (struct html_driver *html, struct table_item *item) if (rowspan > 1) fprintf (html->file, " ROWSPAN=\"%d\"", rowspan); - /* Cell borders. */ - n_borders = 0; + if (html->borders) + { + /* Cell borders. */ + n_borders = 0; - top = table_get_rule (t, TABLE_VERT, x, y); - if (top > TAL_GAP) - put_border (html->file, n_borders++, top, "top"); - - if (y == table_nr (t) - 1) - { - bottom = table_get_rule (t, TABLE_VERT, x, y + 1); - if (bottom > TAL_GAP) - put_border (html->file, n_borders++, bottom, "bottom"); - } - - left = table_get_rule (t, TABLE_HORZ, x, y); - if (left > TAL_GAP) - put_border (html->file, n_borders++, left, "left"); - - if (x == table_nc (t) - 1) - { - right = table_get_rule (t, TABLE_HORZ, x + 1, y); - if (right > TAL_GAP) - put_border (html->file, n_borders++, right, "right"); - } - - if (n_borders > 0) - fputs ("\"", html->file); + top = table_get_rule (t, TABLE_VERT, x, y); + if (top > TAL_GAP) + put_border (html->file, n_borders++, top, "top"); + + if (y == table_nr (t) - 1) + { + bottom = table_get_rule (t, TABLE_VERT, x, y + 1); + if (bottom > TAL_GAP) + put_border (html->file, n_borders++, bottom, "bottom"); + } + + left = table_get_rule (t, TABLE_HORZ, x, y); + if (left > TAL_GAP) + put_border (html->file, n_borders++, left, "left"); + + if (x == table_nc (t) - 1) + { + right = table_get_rule (t, TABLE_HORZ, x + 1, y); + if (right > TAL_GAP) + put_border (html->file, n_borders++, right, "right"); + } + + if (n_borders > 0) + fputs ("\"", html->file); + } putc ('>', html->file); diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index a29fcc6c..3b865cbd 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -855,6 +855,8 @@ clipboard_get_cb (GtkClipboard *clipboard, case SELECT_FMT_HTML: string_map_insert (&options, "format", "html"); + string_map_insert (&options, "borders", "false"); + string_map_insert (&options, "css", "false"); break; case SELECT_FMT_ODT: