X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Frender.c;h=642881e08aabe872580a8428dad647da1cc10b25;hb=9be3ebc378cac9467044f7240b1c42ab1bfe01c2;hp=d282a8fce68797e0430fc7a95cf86a5c1dbe35dd;hpb=8dd405d0900f29f69e54726a79045c119146de89;p=pspp diff --git a/src/output/render.c b/src/output/render.c index d282a8fce6..642881e08a 100644 --- a/src/output/render.c +++ b/src/output/render.c @@ -33,6 +33,9 @@ #include "gl/minmax.h" #include "gl/xalloc.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* This file uses TABLE_HORZ and TABLE_VERT enough to warrant abbreviating. */ #define H TABLE_HORZ #define V TABLE_VERT @@ -927,13 +930,13 @@ render_page_unref (struct render_page *page) /* Returns the size of PAGE along AXIS. (This might be larger than the page size specified in the parameters passed to render_page_create(). Use a render_break to break up a render_page into page-sized chunks.) */ -int +static int render_page_get_size (const struct render_page *page, enum table_axis axis) { return page->cp[axis][page->n[axis] * 2 + 1]; } -int +static int render_page_get_best_breakpoint (const struct render_page *page, int height) { int y; @@ -966,6 +969,23 @@ is_rule (int z) return !(z & 1); } +bool +render_direction_rtl (void) +{ + /* TRANSLATORS: Do not translate this string. If the script of your language + reads from right to left (eg Persian, Arabic, Hebrew etc), then replace + this string with "output-direction-rtl". Otherwise either leave it + untranslated or copy it verbatim. */ + const char *dir = _("output-direction-ltr"); + if ( 0 == strcmp ("output-direction-rtl", dir)) + return true; + + if ( 0 != strcmp ("output-direction-ltr", dir)) + fprintf (stderr, "This localisation has been incorrectly translated. Complain to the translator.\n"); + + return false; +} + static void render_rule (const struct render_page *page, const int ofs[TABLE_N_AXES], const int d[TABLE_N_AXES]) @@ -1009,6 +1029,12 @@ render_rule (const struct render_page *page, const int ofs[TABLE_N_AXES], bb[H][0] = ofs[H] + page->cp[H][d[H]]; bb[H][1] = ofs[H] + page->cp[H][d[H] + 1]; + if (render_direction_rtl ()) + { + int temp = bb[H][0]; + bb[H][0] = render_page_get_size (page, H) - bb[H][1]; + bb[H][1] = render_page_get_size (page, H) - temp; + } bb[V][0] = ofs[V] + page->cp[V][d[V]]; bb[V][1] = ofs[V] + page->cp[V][d[V] + 1]; page->params->draw_line (page->params->aux, bb, styles); @@ -1025,6 +1051,12 @@ render_cell (const struct render_page *page, const int ofs[TABLE_N_AXES], bb[H][0] = clip[H][0] = ofs[H] + page->cp[H][cell->d[H][0] * 2 + 1]; bb[H][1] = clip[H][1] = ofs[H] + page->cp[H][cell->d[H][1] * 2]; + if (render_direction_rtl ()) + { + int temp = bb[H][0]; + bb[H][0] = clip[H][0] = render_page_get_size (page, H) - bb[H][1]; + bb[H][1] = clip[H][1] = render_page_get_size (page, H) - temp; + } bb[V][0] = clip[V][0] = ofs[V] + page->cp[V][cell->d[V][0] * 2 + 1]; bb[V][1] = clip[V][1] = ofs[V] + page->cp[V][cell->d[V][1] * 2]; @@ -1085,7 +1117,7 @@ render_page_draw_cells (const struct render_page *page, /* Renders PAGE, by calling the 'draw_line' and 'draw_cell' functions from the render_params provided to render_page_create(). */ -void +static void render_page_draw (const struct render_page *page, int ofs[TABLE_N_AXES]) { int bb[TABLE_N_AXES][2]; @@ -1151,7 +1183,7 @@ get_clip_max_extent (int x1, const int cp[], int n) /* Renders the cells of PAGE that intersect (X,Y)-(X+W,Y+H), by calling the 'draw_line' and 'draw_cell' functions from the render_params provided to render_page_create(). */ -void +static void render_page_draw_region (const struct render_page *page, int ofs[TABLE_N_AXES], int clip[TABLE_N_AXES][2]) { @@ -1164,7 +1196,7 @@ render_page_draw_region (const struct render_page *page, render_page_draw_cells (page, ofs, bb); } - + /* Breaking up tables to fit on a page. */ /* An iterator for breaking render_pages into smaller chunks. */