Correct URL in documentation.
[pspp] / src / output / render.c
index b3eb6c93d459251668a8eefc4fafbef42076b92b..11830a3e8e4125addea848732be02f9fb65fe89a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011, 2013, 2014, 2016 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -140,7 +140,7 @@ struct render_page
   };
 
 static struct render_page *render_page_create (const struct render_params *,
-                                               const struct table *);
+                                               struct table *);
 
 struct render_page *render_page_ref (const struct render_page *page_);
 static void render_page_unref (struct render_page *);
@@ -684,11 +684,9 @@ set_join_crossings (struct render_page *page, enum table_axis axis,
    size is PARAMS->size, but the caller is responsible for actually breaking it
    up to fit on such a device, using the render_break abstraction.  */
 static struct render_page *
-render_page_create (const struct render_params *params,
-                    const struct table *table_)
+render_page_create (const struct render_params *params, struct table *table)
 {
   struct render_page *page;
-  struct table *table;
   enum { MIN, MAX };
   struct render_row *columns[2];
   struct render_row *rows;
@@ -701,7 +699,6 @@ render_page_create (const struct render_params *params,
   int i;
   enum table_axis axis;
 
-  table = table_ref (table_);
   nc = table_nc (table);
   nr = table_nr (table);
 
@@ -916,7 +913,7 @@ render_page_unref (struct render_page *page)
       hmap_destroy (&page->overflows);
 
       table_unref (page->table);
-      
+
       for (i = 0; i < TABLE_N_AXES; ++i)
        {
          free (page->join_crossing[i]);
@@ -972,9 +969,9 @@ is_rule (int z)
 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 
+  /* 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))
@@ -1032,8 +1029,8 @@ render_rule (const struct render_page *page, const int ofs[TABLE_N_AXES],
       if (render_direction_rtl ())
        {
          int temp = bb[H][0];
-         bb[H][0] = page->params->size[H] - bb[H][1];
-         bb[H][1] = page->params->size[H] - temp;
+         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];
@@ -1054,8 +1051,8 @@ render_cell (const struct render_page *page, const int ofs[TABLE_N_AXES],
   if (render_direction_rtl ())
     {
       int temp = bb[H][0];
-      bb[H][0] = clip[H][0] = page->params->size[H] - bb[H][1];
-      bb[H][1] = clip[H][1] = page->params->size[H] - temp;
+      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];
@@ -1216,12 +1213,13 @@ static struct render_page *render_page_select (const struct render_page *,
                                                int z0, int p0,
                                                int z1, int p1);
 
-/* Initializes render_break B for breaking PAGE along AXIS. */
+/* Initializes render_break B for breaking PAGE along AXIS.
+   Takes ownership of PAGE. */
 static void
-render_break_init (struct render_break *b, const struct render_page *page,
+render_break_init (struct render_break *b, struct render_page *page,
                    enum table_axis axis)
 {
-  b->page = render_page_ref (page);
+  b->page = page;
   b->axis = axis;
   b->z = page->h[axis][0];
   b->pixel = 0;
@@ -1462,7 +1460,8 @@ render_pager_add_table (struct render_pager *p, struct table *table)
 static void
 render_pager_start_page (struct render_pager *p)
 {
-  render_break_init (&p->x_break, p->pages[p->cur_page++], H);
+  render_break_init (&p->x_break, render_page_ref (p->pages[p->cur_page++]),
+                     H);
   render_break_init_empty (&p->y_break);
 }