/[groff]/groff/src/devices/grohtml/html-table.cpp
ViewVC logotype

Diff of /groff/src/devices/grohtml/html-table.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by wl, Tue Nov 23 09:20:48 2004 UTC revision 1.4 by wl, Wed Feb 16 14:07:24 2005 UTC
# Line 1  Line 1 
1  // -*- C++ -*-  // -*- C++ -*-
2  /* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.  /* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3   *   *
4   *  Gaius Mulley (gaius@glam.ac.uk) wrote html-table.cpp   *  Gaius Mulley (gaius@glam.ac.uk) wrote html-table.cpp
5   *   *
# Line 32  Foundation, 59 Temple Place - Suite 330, Line 32  Foundation, 59 Temple Place - Suite 330,
32  #include "html-table.h"  #include "html-table.h"
33  #include "ctype.h"  #include "ctype.h"
34  #include "html.h"  #include "html.h"
35    #include "html-text.h"
36    
37  #if !defined(TRUE)  #if !defined(TRUE)
38  #   define TRUE  (1==1)  #   define TRUE  (1==1)
# Line 238  void tabs::dump_tabs (void) Line 239  void tabs::dump_tabs (void)
239   */   */
240    
241  html_table::html_table (simple_output *op, int linelen)  html_table::html_table (simple_output *op, int linelen)
242    : columns(NULL), out(op), linelength(linelen), last_col(NULL), start_space(FALSE)    : out(op), columns(NULL), linelength(linelen), last_col(NULL), start_space(FALSE)
243  {  {
244    tab_stops = new tabs();    tab_stops = new tabs();
245  }  }
# Line 335  void html_table::emit_table_header (int Line 336  void html_table::emit_table_header (int
336      out->nl();      out->nl();
337      out->nl();      out->nl();
338    
 #if 0  
     if (space)  
       out->put_string("<p>");  
 #endif  
   
     start_space = space;  
339      out->put_string("<table width=\"100%\"")      out->put_string("<table width=\"100%\"")
340        .put_string(" border=0 rules=\"none\" frame=\"void\"\n")        .put_string(" border=0 rules=\"none\" frame=\"void\"\n")
341        .put_string("       cellspacing=\"0\" cellpadding=\"0\"")        .put_string("       cellspacing=\"0\" cellpadding=\"0\"");
342        .put_string(start_space ? " style=\"margin-top: 8px; margin-bottom: 8px\"" : "")      out->put_string(">")
       .put_string(">")  
343        .nl();        .nl();
344      out->put_string("<tr valign=\"top\" align=\"left\">").nl();      out->put_string("<tr valign=\"top\" align=\"left\"");
345        if (space) {
346          out->put_string(" style=\"margin-top: ");
347          out->put_string(STYLE_VERTICAL_SPACE);
348          out->put_string("\"");
349        }
350        out->put_string(">").nl();
351    }    }
352  }  }
353    
# Line 365  int html_table::get_right (cols *c) Line 365  int html_table::get_right (cols *c)
365  }  }
366    
367  /*  /*
368     *  set_space - assigns start_space. Used to determine the
369     *              vertical alignment when generating the next table row.
370     */
371    
372    void html_table::set_space (int space)
373    {
374      start_space = space;
375    }
376    
377    /*
378   *  emit_col - moves onto column, n.   *  emit_col - moves onto column, n.
379   */   */
380    
# Line 478  void html_table::finish_row (void) Line 488  void html_table::finish_row (void)
488  void html_table::emit_new_row (void)  void html_table::emit_new_row (void)
489  {  {
490    finish_row();    finish_row();
491    out->put_string("<tr valign=\"top\" align=\"left\">").nl();  
492      out->put_string("<tr valign=\"top\" align=\"left\"");
493      if (start_space) {
494        out->put_string(" style=\"margin-top: ");
495        out->put_string(STYLE_VERTICAL_SPACE);
496        out->put_string("\"");
497      }
498      out->put_string(">").nl();
499      start_space = FALSE;
500    last_col = NULL;    last_col = NULL;
501  }  }
502    
# Line 486  void html_table::emit_finish_table (void Line 504  void html_table::emit_finish_table (void
504  {  {
505    finish_row();    finish_row();
506    out->put_string("</table>");    out->put_string("</table>");
 #if 0  
   if (start_space)  
     out->put_string("</p>");  
 #endif  
507  }  }
508    
509  /*  /*
# Line 718  html_indent::html_indent (simple_output Line 732  html_indent::html_indent (simple_output
732    in = ind;    in = ind;
733    pg = pageoffset;    pg = pageoffset;
734    ll = linelength;    ll = linelength;
   is_used = FALSE;  
735  }  }
736    
737  html_indent::~html_indent (void)  html_indent::~html_indent (void)
# Line 729  html_indent::~html_indent (void) Line 742  html_indent::~html_indent (void)
742    
743  void html_indent::begin (int space)  void html_indent::begin (int space)
744  {  {
745    if (! is_used) {    if (in + pg == 0) {
746      table->emit_table_header(space);      if (space) {
747      table->emit_col(1);        table->out->put_string(" style=\"margin-top: ");
748      is_used = TRUE;        table->out->put_string(STYLE_VERTICAL_SPACE);
749          table->out->put_string("\"");
750        }
751      }
752      else {
753        //
754        // we use exactly the same mechanism for calculating
755        // indentation as html_table::emit_col
756        //
757        table->out->put_string(" style=\"margin-left:")
758          .put_number(((in + pg) * 100 + ll/2) / ll -
759                      (ll/2)/ll)
760          .put_string("%;");
761    
762        if (space) {
763          table->out->put_string(" margin-top: ");
764          table->out->put_string(STYLE_VERTICAL_SPACE);
765        }
766        table->out->put_string("\"");
767    }    }
768  }  }
769    
770  void html_indent::end (void)  void html_indent::end (void)
771  {  {
   if (is_used)  
     table->emit_finish_table();  
   is_used = FALSE;  
772  }  }
773    
774  /*  /*

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26