summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwl <wl>2008-10-18 04:43:34 +0000
committerwl <wl>2008-10-18 04:43:34 +0000
commitebdc085f5c04d8b1fe9b29e8e6ee85711dda19d7 (patch)
treedddd55f4e9cd5bec604b35d440f2150c9e615d52
parent9727ced342d4f21aef0c2ba4fe9722c5ee33a1e1 (diff)
downloadgroff-ebdc085f5c04d8b1fe9b29e8e6ee85711dda19d7.tar.gz
* src/preproc/tbl/table.cpp (table::compute_available_block_width):
New function. (table::compute_widths): Replace some code with new function (shifted to a more appropriate place). * src/preproc/tbl/table.h: Updated.
-rw-r--r--ChangeLog8
-rw-r--r--src/preproc/tbl/table.cpp48
-rw-r--r--src/preproc/tbl/table.h3
3 files changed, 40 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 05b9ce38..2b4ceed9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-17 Werner LEMBERG <wl@gnu.org>
+
+ * src/preproc/tbl/table.cpp (table::compute_available_block_width):
+ New function.
+ (table::compute_widths): Replace some code with new function
+ (shifted to a more appropriate place).
+ * src/preproc/tbl/table.h: Updated.
+
2008-10-16 Werner LEMBERG <wl@gnu.org>
* tmac/doc-common (doc-operating-system-*), tmac/groff_mdoc.man: Add
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 9cee7ea0..7631f127 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -737,7 +737,7 @@ void block_entry::do_divert(int alphabetic, int ncols, const string *mw,
void block_entry::do_width()
{
- for (int i=start_col; i <= end_col; i++)
+ for (int i = start_col; i <= end_col; i++)
parent->blockflag[i] = (char)1;
}
@@ -1962,8 +1962,6 @@ void compute_span_width(int start_col, int end_col)
span_left_numeric_width_reg(start_col, end_col),
span_right_numeric_width_reg(start_col, end_col),
span_alphabetic_width_reg(start_col, end_col));
- printfs(".nr " AVAILABLE_REG " -\\n[%1]\n",
- span_width_reg(start_col, end_col));
}
// Increase the widths of columns so that the width of any spanning entry
@@ -2056,9 +2054,24 @@ void table::build_span_list()
}
}
+// Compute remaining length for block columns.
+
+void table::compute_available_block_width()
+{
+ printfs(".nr " COLCOUNT_REG " %1\n", as_string(count_block_columns()));
+ prints(".nr " AVAILABLE_REG " \\n[.l]-\\n[.i]");
+ for (int i = 0; i < ncolumns; i++)
+ printfs("-\\n[%1]", span_width_reg(i, i));
+ prints("\n");
+ prints(".if \\n[" AVAILABLE_REG "]<0 \\{"
+ ".tm warning: page \\n%: table wider than line width\n"
+ ".nr " AVAILABLE_REG " 0\n"
+ ".\\}\n");
+}
+
void table::compute_separation_factor()
{
- if (flags & (ALLBOX|BOX|DOUBLEBOX))
+ if (flags & (ALLBOX | BOX | DOUBLEBOX))
left_separation = right_separation = 1;
else {
for (int i = 0; i < nrows; i++) {
@@ -2152,6 +2165,7 @@ void table::compute_widths()
build_span_list();
int i;
horizontal_span *p;
+ // These values get refined later.
prints(".nr " SEPARATION_FACTOR_REG " 1n\n");
for (i = 0; i < ncolumns; i++) {
init_span_reg(i, i);
@@ -2160,29 +2174,26 @@ void table::compute_widths()
}
for (p = span_list; p; p = p->next)
init_span_reg(p->start_col, p->end_col);
+ // Compute all field widths except for blocks.
table_entry *q;
for (q = entry_list; q; q = q->next)
if (!q->mod->zero_width)
q->do_width();
+ // Compute all span widths, not handling blocks yet.
for (i = 0; i < ncolumns; i++)
compute_span_width(i, i);
for (p = span_list; p; p = p->next)
compute_span_width(p->start_col, p->end_col);
- printfs(".nr " COLCOUNT_REG " %1\n", as_string(count_block_columns()));
- prints(".nr " AVAILABLE_REG " \\n[.l]-\\n[.i]");
- for (i = 0; i < ncolumns; i++)
- printfs("-\\n[%1]", span_width_reg(i, i));
- prints("\n");
- prints(".if \\n[" AVAILABLE_REG "]<0 \\{"
- ".tm warning: page \\n%: table wider than line width\n"
- ".nr " AVAILABLE_REG " 0\n"
- ".\\}\n");
+ // Making columns equal normally increases the width of some columns.
make_columns_equal();
// Note that divide_span keeps equal width columns equal.
+ // This function might increase the width of some columns, too.
for (p = span_list; p; p = p->next)
divide_span(p->start_col, p->end_col);
for (p = span_list; p; p = p->next)
sum_columns(p->start_col, p->end_col);
+ // Now handle blocks.
+ compute_available_block_width();
int had_spanning_block = 0;
int had_equal_block = 0;
for (q = entry_list; q; q = q->next)
@@ -2194,6 +2205,7 @@ void table::compute_widths()
if (equal[i])
had_equal_block = 1;
}
+ // Second pass.
if (had_equal_block)
make_columns_equal();
if (had_spanning_block)
@@ -2463,7 +2475,7 @@ void table::build_vrule_list()
}
}
}
- if (flags & (BOX|ALLBOX|DOUBLEBOX)) {
+ if (flags & (BOX | ALLBOX | DOUBLEBOX)) {
add_vertical_rule(0, nrows - 1, 0, 0);
add_vertical_rule(0, nrows - 1, ncolumns, 0);
}
@@ -2507,7 +2519,7 @@ void table::define_bottom_macro()
".if !\\n[" SUPPRESS_BOTTOM_REG "] \\{"
"." REPEATED_VPT_MACRO " 0\n"
".mk " SAVED_VERTICAL_POS_REG "\n");
- if (flags & (BOX|ALLBOX|DOUBLEBOX)) {
+ if (flags & (BOX | ALLBOX | DOUBLEBOX)) {
prints(".if \\n[T.]&\\n[" NEED_BOTTOM_RULE_REG "] \\{");
print_single_hline(0);
prints(".\\}\n");
@@ -2737,7 +2749,7 @@ void table::do_row(int r)
void table::do_top()
{
prints(".fc \002\003\n");
- if (!(flags & NOKEEP) && (flags & (BOX|DOUBLEBOX|ALLBOX)))
+ if (!(flags & NOKEEP) && (flags & (BOX | DOUBLEBOX | ALLBOX)))
prints("." TABLE_KEEP_MACRO_NAME "\n");
if (flags & DOUBLEBOX) {
prints(".ls 1\n"
@@ -2757,7 +2769,7 @@ void table::do_top()
prints(".ls\n"
".vs\n");
}
- else if (flags & (ALLBOX|BOX)) {
+ else if (flags & (ALLBOX | BOX)) {
print_single_hline(0);
}
//printfs(".mk %1\n", row_top_reg(0));
@@ -2775,7 +2787,7 @@ void table::do_bottom()
prints(".nr " NEED_BOTTOM_RULE_REG " 1\n"
".nr T. 1\n"
".T#\n");
- if (!(flags & NOKEEP) && (flags & (BOX|DOUBLEBOX|ALLBOX)))
+ if (!(flags & NOKEEP) && (flags & (BOX | DOUBLEBOX | ALLBOX)))
prints("." TABLE_RELEASE_MACRO_NAME "\n");
if (flags & DOUBLEBOX)
prints(".sp " DOUBLE_LINE_SEP "\n");
diff --git a/src/preproc/tbl/table.h b/src/preproc/tbl/table.h
index 0d9d4179..4989a4d8 100644
--- a/src/preproc/tbl/table.h
+++ b/src/preproc/tbl/table.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2007
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2007, 2008
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -104,6 +104,7 @@ class table {
int right_separation;
int allocated_rows;
void build_span_list();
+ void compute_available_block_width();
void do_hspan(int r, int c);
void do_vspan(int r, int c);
void allocate(int r);