2 /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2007, 2009
3 Free Software Foundation, Inc.
4 Written by James Clark (jjc@jclark.com)
6 This file is part of groff.
8 groff is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 class limit_box : public box {
30 limit_box(box *, box *, box *);
32 int compute_metrics(int);
38 box *make_limit_box(box *pp, box *qq, box *rr)
40 return new limit_box(pp, qq, rr);
43 limit_box::limit_box(box *pp, box *qq, box *rr)
44 : p(pp), from(qq), to(rr)
46 spacing_type = p->spacing_type;
49 limit_box::~limit_box()
56 int limit_box::compute_metrics(int style)
58 printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
59 if (!(style <= SCRIPT_STYLE && one_size_reduction_flag))
61 printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
65 res = from->compute_metrics(cramped_style(script_style(style)));
70 int r = to->compute_metrics(script_style(style));
72 error("multiple marks and lineups");
78 printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
79 int r = p->compute_metrics(style);
80 p->compute_subscript_kern();
82 error("multiple marks and lineups");
87 printf(".nr " LEFT_WIDTH_FORMAT " "
88 "0\\n[" WIDTH_FORMAT "]",
91 printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
94 printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
97 printf(".nr " WIDTH_FORMAT " "
98 "0\\n[" WIDTH_FORMAT "]",
101 printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
104 printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
106 printf("/2+\\n[" LEFT_WIDTH_FORMAT "]\n", uid);
107 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]", uid, p->uid);
109 printf(">?\\n[" WIDTH_FORMAT "]", to->uid);
111 printf(">?\\n[" WIDTH_FORMAT "]", from->uid);
114 printf(".nr " MARK_REG " +(\\n[" LEFT_WIDTH_FORMAT "]"
115 "-(\\n[" WIDTH_FORMAT "]/2))\n",
118 printf(".nr " SUP_RAISE_FORMAT " %dM+\\n[" DEPTH_FORMAT
119 "]>?%dM+\\n[" HEIGHT_FORMAT "]\n",
120 uid, big_op_spacing1, to->uid, big_op_spacing3, p->uid);
121 printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
122 HEIGHT_FORMAT "]+%dM\n",
123 uid, uid, to->uid, big_op_spacing5);
126 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
128 printf(".nr " SUB_LOWER_FORMAT " %dM+\\n[" HEIGHT_FORMAT
129 "]>?%dM+\\n[" DEPTH_FORMAT "]\n",
130 uid, big_op_spacing2, from->uid, big_op_spacing4, p->uid);
131 printf(".nr " DEPTH_FORMAT " \\n[" SUB_LOWER_FORMAT "]+\\n["
132 DEPTH_FORMAT "]+%dM\n",
133 uid, uid, from->uid, big_op_spacing5);
136 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
140 void limit_box::output()
142 if (output_format == troff) {
143 printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
145 printf("\\Z" DELIMITER_CHAR);
146 printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
147 printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
148 "+(-\\n[" WIDTH_FORMAT "]u+\\n[" SUB_KERN_FORMAT "]u/2u)'",
149 uid, to->uid, p->uid);
151 printf(DELIMITER_CHAR);
154 printf("\\Z" DELIMITER_CHAR);
155 printf("\\v'\\n[" SUB_LOWER_FORMAT "]u'", uid);
156 printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
157 "+(-\\n[" SUB_KERN_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u)'",
158 uid, p->uid, from->uid);
160 printf(DELIMITER_CHAR);
162 printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
163 printf("\\Z" DELIMITER_CHAR);
164 printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
165 "-(\\n[" WIDTH_FORMAT "]u/2u)'",
168 printf(DELIMITER_CHAR);
169 printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
171 else if (output_format == mathml) {
172 if (from != 0 && to != 0) {
173 printf("<munderover>");
177 printf("</munderover>");
179 else if (from != 0) {
194 void limit_box::debug_print()
196 fprintf(stderr, "{ ");
198 fprintf(stderr, " }");
200 fprintf(stderr, " from { ");
202 fprintf(stderr, " }");
205 fprintf(stderr, " to { ");
207 fprintf(stderr, " }");
211 void limit_box::check_tabs(int level)
214 to->check_tabs(level + 1);
216 from->check_tabs(level + 1);
217 p->check_tabs(level + 1);