output: Always use helper functions to access struct tab_table members.
[pspp-builds.git] / src / output / odt.c
index 7c87a37090ca62a44ae21a4ae27ed58ef64f98ce..8471b6b3fb7eb46bb16a536b748161eac7337902 100644 (file)
@@ -46,6 +46,8 @@
 
 struct odf_driver_options
 {
+  struct outp_driver *driver;
+  
   char *file_name;            /* Output file name. */
   bool debug;
 };
@@ -283,6 +285,7 @@ static bool
 handle_option (void *options_, const char *key, const struct string *val)
 {
   struct odf_driver_options *options = options_;
+  struct outp_driver *this = options->driver;
   int subcat;
   char *value = ds_cstr (val);
 
@@ -290,8 +293,8 @@ handle_option (void *options_, const char *key, const struct string *val)
     {
     case -1:
       error (0, 0,
-             _("unknown configuration parameter `%s' for ODF device "
-               "driver"), key);
+             _("unknown configuration parameter `%s' for %s device "
+               "driver"), key, this->class->name);
       break;
     case output_file_arg:
       free (options->file_name);
@@ -327,6 +330,7 @@ odt_open_driver (const char *name, int types, struct substring option_string)
 
   this->ext = x = xmalloc (sizeof *x);
 
+  x->opts.driver = this;
   x->opts.file_name = xstrdup ("pspp.pdt");
   x->opts.debug = false;
 
@@ -428,17 +432,17 @@ odt_close_driver (struct outp_driver *this)
 }
 
 static void
-odt_open_page (struct outp_driver *this)
+odt_open_page (struct outp_driver *this UNUSED)
 {
 }
 
 static void
-odt_close_page (struct outp_driver *this)
+odt_close_page (struct outp_driver *this UNUSED)
 {
 }
 
 static void
-odt_output_chart (struct outp_driver *this, const struct chart *chart)
+odt_output_chart (struct outp_driver *this UNUSED, const struct chart *chart UNUSED)
 {
  printf ("%s\n", __FUNCTION__);
 }
@@ -468,28 +472,28 @@ odt_submit (struct outp_driver *this, struct som_entity *e)
 
   /* Start column definitions */
   xmlTextWriterStartElement (x->content_wtr, _xml("table:table-column"));
-  xmlTextWriterWriteFormatAttribute (x->content_wtr, _xml("table:number-columns-repeated"), "%d", tab->nc);
+  xmlTextWriterWriteFormatAttribute (x->content_wtr, _xml("table:number-columns-repeated"), "%d", tab_nc (tab));
   xmlTextWriterEndElement (x->content_wtr);
 
 
   /* Deal with row headers */
-  if ( tab->t > 0)
+  if ( tab_t (tab) > 0)
     xmlTextWriterStartElement (x->content_wtr, _xml("table:table-header-rows"));
     
 
   /* Write all the rows */
-  for (r = 0 ; r < tab->nr; ++r)
+  for (r = 0 ; r < tab_nr (tab); ++r)
     {
       int spanned_columns = 0;
       /* Start row definition */
       xmlTextWriterStartElement (x->content_wtr, _xml("table:table-row"));
 
       /* Write all the columns */
-      for (c = 0 ; c < tab->nc ; ++c)
+      for (c = 0 ; c < tab_nc (tab) ; ++c)
        {
          char *s = NULL;
-         unsigned int opts = tab->ct[tab->nc * r + c];
-         struct substring ss = tab->cc[tab->nc * r + c];
+         unsigned int opts = tab->ct[tab_nc (tab) * r + c];
+         struct substring ss = tab->cc[tab_nc (tab) * r + c];
 
          if (opts & TAB_EMPTY)
            {
@@ -526,7 +530,7 @@ odt_submit (struct outp_driver *this, struct som_entity *e)
 
              xmlTextWriterStartElement (x->content_wtr, _xml("text:p"));
 
-             if ( r < tab->t || c < tab->l )
+             if ( r < tab_t (tab) || c < tab_l (tab) )
                xmlTextWriterWriteAttribute (x->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading"));
              else
                xmlTextWriterWriteAttribute (x->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents"));
@@ -549,7 +553,7 @@ odt_submit (struct outp_driver *this, struct som_entity *e)
   
       xmlTextWriterEndElement (x->content_wtr); /* row */
 
-      if ( tab->t > 0 && r == tab->t - 1)
+      if ( tab_t (tab) > 0 && r == tab_t (tab) - 1)
        xmlTextWriterEndElement (x->content_wtr); /* table-header-rows */
     }