3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
19 #include "support/lassert.h"
20 #include "support/convert.h"
21 #include "support/lstrings.h"
32 // filled in preamble.cpp
33 map
<char, int> special_columns
;
40 ColInfo() : align('n'), valign('n'), rightlines(0), leftlines(0) {}
43 /// vertical alignment
47 /// special column alignment
49 /// number of lines on the right
51 /// number of lines on the left
56 /// row type for longtables
63 /// part of head on first page
67 /// part of foot on last page
74 RowInfo() : topline(false), bottomline(false), type(LT_NORMAL
),
76 /// horizontal line above
78 /// horizontal line below
80 /// These are for longtabulars only
81 /// row type (head, foot, firsthead etc.)
91 /// A multicolumn cell. The number of columns is <tt>1 + number
92 /// of CELL_PART_OF_MULTICOLUMN cells</tt> that follow directly
93 CELL_BEGIN_OF_MULTICOLUMN
,
94 /// This is a dummy cell (part of a multicolumn cell)
95 CELL_PART_OF_MULTICOLUMN
101 CellInfo() : multi(CELL_NORMAL
), align('n'), valign('n'),
102 leftlines(0), rightlines(0), topline(false),
103 bottomline(false), rotate(false) {}
110 /// vertical cell alignment
112 /// number of lines on the left
114 /// number of lines on the right
116 /// do we have a line above?
118 /// do we have a line below?
120 /// is the cell rotated?
122 /// width for multicolumn cells
124 /// special formatting for multicolumn cells
129 /// translate a horizontal alignment (as stored in ColInfo and CellInfo) to LyX
130 inline char const * verbose_align(char c
)
145 /// translate a vertical alignment (as stored in ColInfo and CellInfo) to LyX
146 inline char const * verbose_valign(char c
)
148 // The default value for no special alignment is "top".
161 // stripped down from tabluar.C. We use it currently only for bools and
163 string
const write_attribute(string
const & name
, bool const & b
)
165 // we write only true attribute values so we remove a bit of the
166 // file format bloat for tabulars.
167 return b
? ' ' + name
+ "=\"true\"" : string();
171 string
const write_attribute(string
const & name
, string
const & s
)
173 return s
.empty() ? string() : ' ' + name
+ "=\"" + s
+ '"';
177 /*! rather brutish way to code table structure in a string:
182 \multicolumn{2}{c}{4} & 5 //
188 gets "translated" to:
191 HLINE 1 TAB 2 TAB 3 HLINE HLINE LINE
192 \hline HLINE \multicolumn{2}{c}{4} TAB 5 HLINE HLINE LINE
193 HLINE 6 TAB 7 HLINE HLINE LINE
194 HLINE 8 HLINE \endhead HLINE LINE
198 char const TAB
= '\001';
199 char const LINE
= '\002';
200 char const HLINE
= '\004';
204 * Move the information in leftlines, rightlines, align and valign to the
205 * special field. This is necessary if the special field is not empty,
206 * because LyX ignores leftlines, rightlines, align and valign in this case.
208 void ci2special(ColInfo
& ci
)
210 if (ci
.width
.empty() && ci
.align
== 'n')
211 // The alignment setting is already in special, since
212 // handle_colalign() never stores ci with these settings
213 // and ensures that leftlines == 0 and rightlines == 0 in
217 if (!ci
.width
.empty()) {
220 ci
.special
+= ">{\\raggedright}";
223 ci
.special
+= ">{\\raggedleft}";
226 ci
.special
+= ">{\\centering}";
229 if (ci
.valign
== 'n')
232 ci
.special
+= ci
.valign
;
233 ci
.special
+= '{' + ci
.width
+ '}';
236 ci
.special
+= ci
.align
;
238 for (int i
= 0; i
< ci
.leftlines
; ++i
)
239 ci
.special
.insert(0, "|");
240 for (int i
= 0; i
< ci
.rightlines
; ++i
)
250 * Handle column specifications for tabulars and multicolumns.
251 * The next token of the parser \p p must be an opening brace, and we read
252 * everything until the matching closing brace.
253 * The resulting column specifications are filled into \p colinfo. This is
254 * in an intermediate form. fix_colalign() makes it suitable for LyX output.
256 void handle_colalign(Parser
& p
, vector
<ColInfo
> & colinfo
,
257 ColInfo
const & start
)
259 if (p
.get_token().cat() != catBegin
)
260 cerr
<< "Wrong syntax for table column alignment.\n"
261 "Expected '{', got '" << p
.curr_token().asInput()
264 ColInfo next
= start
;
265 for (Token t
= p
.get_token(); p
.good() && t
.cat() != catEnd
;
268 cerr
<< "t: " << t
<< " c: '" << t
.character() << "'\n";
271 // We cannot handle comments here
272 if (t
.cat() == catComment
) {
273 if (t
.cs().empty()) {
277 cerr
<< "Ignoring comment: " << t
.asInput();
281 switch (t
.character()) {
285 // new column, horizontal aligned
286 next
.align
= t
.character();
287 if (!next
.special
.empty())
289 colinfo
.push_back(next
);
295 // new column, vertical aligned box
296 next
.valign
= t
.character();
297 next
.width
= p
.verbatim_item();
298 if (!next
.special
.empty())
300 colinfo
.push_back(next
);
305 if (colinfo
.empty()) {
306 if (next
.special
.empty())
310 } else if (colinfo
.back().special
.empty())
311 ++colinfo
.back().rightlines
;
312 else if (next
.special
.empty())
315 colinfo
.back().special
+= '|';
318 // text before the next column
319 string
const s
= trim(p
.verbatim_item());
320 if (next
.special
.empty() &&
322 // Maybe this can be converted to a
323 // horizontal alignment setting for
324 // fixed width columns
325 if (s
== "\\raggedleft")
327 else if (s
== "\\raggedright")
329 else if (s
== "\\centering")
332 next
.special
= ">{" + s
+ '}';
334 next
.special
+= ">{" + s
+ '}';
338 // text after the last column
339 string
const s
= trim(p
.verbatim_item());
341 // This is not possible in LaTeX.
342 cerr
<< "Ignoring separator '<{"
343 << s
<< "}'." << endl
;
345 ColInfo
& ci
= colinfo
.back();
347 ci
.special
+= "<{" + s
+ '}';
352 // *{n}{arg} means 'n' columns of type 'arg'
353 string
const num
= p
.verbatim_item();
354 string
const arg
= p
.verbatim_item();
355 size_t const n
= convert
<unsigned int>(num
);
356 if (!arg
.empty() && n
> 0) {
358 for (size_t i
= 0; i
< n
; ++i
)
362 handle_colalign(p2
, colinfo
, next
);
365 cerr
<< "Ignoring column specification"
366 " '*{" << num
<< "}{"
367 << arg
<< "}'." << endl
;
372 // text instead of the column spacing
374 // text in addition to the column spacing
375 next
.special
+= t
.character();
376 next
.special
+= '{' + p
.verbatim_item() + '}';
379 // try user defined column types
380 if (special_columns
.find(t
.character()) !=
381 special_columns
.end()) {
383 next
.special
+= t
.character();
385 special_columns
[t
.character()];
386 for (int i
= 0; i
< nargs
; ++i
)
387 next
.special
+= '{' +
390 colinfo
.push_back(next
);
393 cerr
<< "Ignoring column specification"
394 " '" << t
<< "'." << endl
;
399 // Maybe we have some column separators that need to be added to the
402 if (!next
.special
.empty()) {
403 ColInfo
& ci
= colinfo
.back();
405 ci
.special
+= next
.special
;
406 next
.special
.erase();
412 * Move the left and right lines and alignment settings of the column \p ci
413 * to the special field if necessary.
415 void fix_colalign(ColInfo
& ci
)
417 if (ci
.leftlines
> 1 || ci
.rightlines
> 1)
423 * LyX can't handle more than one vertical line at the left or right side
425 * This function moves the left and right lines and alignment settings of all
426 * columns in \p colinfo to the special field if necessary.
428 void fix_colalign(vector
<ColInfo
> & colinfo
)
430 // Try to move extra leftlines to the previous column.
431 // We do this only if both special fields are empty, otherwise we
432 // can't tell wether the result will be the same.
433 for (size_t col
= 0; col
< colinfo
.size(); ++col
) {
434 if (colinfo
[col
].leftlines
> 1 &&
435 colinfo
[col
].special
.empty() && col
> 0 &&
436 colinfo
[col
- 1].rightlines
== 0 &&
437 colinfo
[col
- 1].special
.empty()) {
438 ++colinfo
[col
- 1].rightlines
;
439 --colinfo
[col
].leftlines
;
442 // Try to move extra rightlines to the next column
443 for (size_t col
= 0; col
< colinfo
.size(); ++col
) {
444 if (colinfo
[col
].rightlines
> 1 &&
445 colinfo
[col
].special
.empty() &&
446 col
< colinfo
.size() - 1 &&
447 colinfo
[col
+ 1].leftlines
== 0 &&
448 colinfo
[col
+ 1].special
.empty()) {
449 ++colinfo
[col
+ 1].leftlines
;
450 --colinfo
[col
].rightlines
;
453 // Move the lines and alignment settings to the special field if
455 for (size_t col
= 0; col
< colinfo
.size(); ++col
)
456 fix_colalign(colinfo
[col
]);
461 * Parse hlines and similar stuff.
462 * \returns wether the token \p t was parsed
464 bool parse_hlines(Parser
& p
, Token
const & t
, string
& hlines
,
465 bool is_long_tabular
)
467 LASSERT(t
.cat() == catEscape
, return false);
469 if (t
.cs() == "hline")
472 else if (t
.cs() == "cline")
473 hlines
+= "\\cline{" + p
.verbatim_item() + '}';
475 else if (is_long_tabular
&& t
.cs() == "newpage")
476 hlines
+= "\\newpage";
485 /// Position in a row
487 /// At the very beginning, before the first token
489 /// After the first token and before any column token
491 /// After the first column token. Comments and whitespace are only
492 /// treated as tokens in this position
494 /// After the first non-column token at the end
500 * Parse table structure.
501 * We parse tables in a two-pass process: This function extracts the table
502 * structure (rows, columns, hlines etc.), but does not change the cell
503 * content. The cell content is parsed in a second step in handle_tabular().
505 void parse_table(Parser
& p
, ostream
& os
, bool is_long_tabular
,
506 RowPosition
& pos
, unsigned flags
)
508 // table structure commands such as \hline
511 // comments that occur at places where we can't handle them
515 Token
const & t
= p
.get_token();
518 cerr
<< "t: " << t
<< " flags: " << flags
<< "\n";
521 // comments and whitespace in hlines
524 case IN_HLINES_START
:
526 if (t
.cat() == catComment
) {
531 // We can't handle comments here,
532 // store them for later use
533 comments
+= t
.asInput();
535 } else if (t
.cat() == catSpace
||
536 t
.cat() == catNewline
) {
537 // whitespace is irrelevant here, we
538 // need to recognize hline stuff
547 // We need to handle structure stuff first in order to
548 // determine wether we need to output a HLINE separator
549 // before the row or not.
550 if (t
.cat() == catEscape
) {
551 if (parse_hlines(p
, t
, hlines
, is_long_tabular
)) {
554 pos
= IN_HLINES_START
;
559 case IN_HLINES_START
:
566 else if (t
.cs() == "tabularnewline" ||
570 cerr
<< "Warning: Converting TeX "
571 "'\\cr' to LaTeX '\\\\'."
573 // stuff before the line break
574 os
<< comments
<< HLINE
<< hlines
<< HLINE
576 //cerr << "hlines: " << hlines << endl;
583 else if (is_long_tabular
&&
584 (t
.cs() == "endhead" ||
585 t
.cs() == "endfirsthead" ||
586 t
.cs() == "endfoot" ||
587 t
.cs() == "endlastfoot")) {
588 hlines
+= t
.asInput();
592 // these commands are implicit line
594 os
<< comments
<< HLINE
<< hlines
601 pos
= IN_HLINES_START
;
603 case IN_HLINES_START
:
611 // We need a HLINE separator if we either have no hline
612 // stuff at all and are just starting a row or if we just
613 // got the first non-hline token.
616 // no hline tokens exist, first token at row start
617 case IN_HLINES_START
:
618 // hline tokens exist, first non-hline token at row
620 os
<< hlines
<< HLINE
<< comments
;
626 // Oops, there is still cell content after hline
627 // stuff. This does not work in LaTeX, so we ignore
629 cerr
<< "Ignoring '" << hlines
<< "' in a cell"
640 // If we come here we have normal cell content
644 if (t
.cat() == catMath
) {
645 // we are inside some text mode thingy, so opening new math is allowed
646 Token
const & n
= p
.get_token();
647 if (n
.cat() == catMath
) {
648 // TeX's $$...$$ syntax for displayed math
650 // This does only work because parse_math outputs TeX
651 parse_math(p
, os
, FLAG_SIMPLE
, MATH_MODE
);
653 p
.get_token(); // skip the second '$' token
655 // simple $...$ stuff
658 // This does only work because parse_math outputs TeX
659 parse_math(p
, os
, FLAG_SIMPLE
, MATH_MODE
);
664 else if (t
.cat() == catSpace
|| t
.cat() == catNewline
)
667 else if (t
.cat() == catLetter
||
668 t
.cat() == catSuper
||
670 t
.cat() == catOther
||
671 t
.cat() == catActive
||
672 t
.cat() == catParameter
)
675 else if (t
.cat() == catBegin
) {
677 parse_table(p
, os
, is_long_tabular
, pos
,
682 else if (t
.cat() == catEnd
) {
683 if (flags
& FLAG_BRACE_LAST
)
685 cerr
<< "unexpected '}'\n";
688 else if (t
.cat() == catAlign
) {
693 else if (t
.cat() == catComment
)
696 else if (t
.cs() == "(") {
698 // This does only work because parse_math outputs TeX
699 parse_math(p
, os
, FLAG_SIMPLE2
, MATH_MODE
);
703 else if (t
.cs() == "[") {
705 // This does only work because parse_math outputs TeX
706 parse_math(p
, os
, FLAG_EQUATION
, MATH_MODE
);
710 else if (t
.cs() == "begin") {
711 string
const name
= p
.getArg('{', '}');
712 active_environments
.push_back(name
);
713 os
<< "\\begin{" << name
<< '}';
714 // treat the nested environment as a block, don't
715 // parse &, \\ etc, because they don't belong to our
716 // table if they appear.
717 os
<< p
.verbatimEnvironment(name
);
718 os
<< "\\end{" << name
<< '}';
719 active_environments
.pop_back();
722 else if (t
.cs() == "end") {
723 if (flags
& FLAG_END
) {
724 // eat environment name
725 string
const name
= p
.getArg('{', '}');
726 if (name
!= active_environment())
727 p
.error("\\end{" + name
+ "} does not match \\begin{"
728 + active_environment() + "}");
731 p
.error("found 'end' unexpectedly");
738 // We can have comments if the last line is incomplete
741 // We can have hline stuff if the last line is incomplete
742 if (!hlines
.empty()) {
743 // this does not work in LaTeX, so we ignore it
744 cerr
<< "Ignoring '" << hlines
<< "' at end of tabular"
750 void handle_hline_above(RowInfo
& ri
, vector
<CellInfo
> & ci
)
753 for (size_t col
= 0; col
< ci
.size(); ++col
)
754 ci
[col
].topline
= true;
758 void handle_hline_below(RowInfo
& ri
, vector
<CellInfo
> & ci
)
760 ri
.bottomline
= true;
761 for (size_t col
= 0; col
< ci
.size(); ++col
)
762 ci
[col
].bottomline
= true;
766 } // anonymous namespace
769 void handle_tabular(Parser
& p
, ostream
& os
, bool is_long_tabular
,
772 string posopts
= p
.getOpt();
773 if (!posopts
.empty()) {
774 // FIXME: Convert this to ERT
776 cerr
<< "horizontal longtable";
778 cerr
<< "vertical tabular";
779 cerr
<< " positioning '" << posopts
<< "' ignored\n";
782 vector
<ColInfo
> colinfo
;
784 // handle column formatting
785 handle_colalign(p
, colinfo
, ColInfo());
786 fix_colalign(colinfo
);
788 // first scan of cells
789 // use table mode to keep it minimal-invasive
790 // not exactly what's TeX doing...
791 vector
<string
> lines
;
793 RowPosition rowpos
= ROW_START
;
794 parse_table(p
, ss
, is_long_tabular
, rowpos
, FLAG_END
);
795 split(ss
.str(), lines
, LINE
);
797 vector
< vector
<CellInfo
> > cellinfo(lines
.size());
798 vector
<RowInfo
> rowinfo(lines
.size());
801 //cerr << "// split into rows\n";
802 for (size_t row
= 0; row
< rowinfo
.size(); ++row
) {
805 cellinfo
[row
].resize(colinfo
.size());
808 vector
<string
> dummy
;
809 //cerr << "\n########### LINE: " << lines[row] << "########\n";
810 split(lines
[row
], dummy
, HLINE
);
812 // handle horizontal line fragments
813 // we do only expect this for a last line without '\\'
814 if (dummy
.size() != 3) {
815 if ((dummy
.size() != 1 && dummy
.size() != 2) ||
816 row
!= rowinfo
.size() - 1)
817 cerr
<< "unexpected dummy size: " << dummy
.size()
818 << " content: " << lines
[row
] << "\n";
821 lines
[row
] = dummy
[1];
823 //cerr << "line: " << row << " above 0: " << dummy[0] << "\n";
824 //cerr << "line: " << row << " below 2: " << dummy[2] << "\n";
825 //cerr << "line: " << row << " cells 1: " << dummy[1] << "\n";
827 for (int i
= 0; i
<= 2; i
+= 2) {
828 //cerr << " reading from line string '" << dummy[i] << "'\n";
831 Token t
= p1
.get_token();
832 //cerr << "read token: " << t << "\n";
833 if (t
.cs() == "hline") {
835 if (rowinfo
[row
].topline
) {
836 if (row
> 0) // extra bottomline above
837 handle_hline_below(rowinfo
[row
- 1], cellinfo
[row
- 1]);
839 cerr
<< "dropping extra hline\n";
840 //cerr << "below row: " << row-1 << endl;
842 handle_hline_above(rowinfo
[row
], cellinfo
[row
]);
843 //cerr << "above row: " << row << endl;
846 //cerr << "below row: " << row << endl;
847 handle_hline_below(rowinfo
[row
], cellinfo
[row
]);
849 } else if (t
.cs() == "cline") {
850 string arg
= p1
.verbatim_item();
851 //cerr << "read cline arg: '" << arg << "'\n";
855 size_t from
= convert
<unsigned int>(t
[0]);
857 cerr
<< "Could not parse "
858 "cline start column."
861 // 1 based index -> 0 based
863 if (from
>= colinfo
.size()) {
864 cerr
<< "cline starts at non "
866 << (from
+ 1) << endl
;
867 from
= colinfo
.size() - 1;
869 size_t to
= convert
<unsigned int>(t
[1]);
871 cerr
<< "Could not parse "
875 // 1 based index -> 0 based
877 if (to
>= colinfo
.size()) {
878 cerr
<< "cline ends at non "
881 to
= colinfo
.size() - 1;
883 for (size_t col
= from
; col
<= to
; ++col
) {
884 //cerr << "row: " << row << " col: " << col << " i: " << i << endl;
886 rowinfo
[row
].topline
= true;
887 cellinfo
[row
][col
].topline
= true;
889 rowinfo
[row
].bottomline
= true;
890 cellinfo
[row
][col
].bottomline
= true;
893 } else if (t
.cs() == "endhead") {
895 rowinfo
[row
].type
= LT_HEAD
;
896 for (int r
= row
- 1; r
>= 0; --r
) {
897 if (rowinfo
[r
].type
!= LT_NORMAL
)
899 rowinfo
[r
].type
= LT_HEAD
;
901 } else if (t
.cs() == "endfirsthead") {
903 rowinfo
[row
].type
= LT_FIRSTHEAD
;
904 for (int r
= row
- 1; r
>= 0; --r
) {
905 if (rowinfo
[r
].type
!= LT_NORMAL
)
907 rowinfo
[r
].type
= LT_FIRSTHEAD
;
909 } else if (t
.cs() == "endfoot") {
911 rowinfo
[row
].type
= LT_FOOT
;
912 for (int r
= row
- 1; r
>= 0; --r
) {
913 if (rowinfo
[r
].type
!= LT_NORMAL
)
915 rowinfo
[r
].type
= LT_FOOT
;
917 } else if (t
.cs() == "endlastfoot") {
919 rowinfo
[row
].type
= LT_LASTFOOT
;
920 for (int r
= row
- 1; r
>= 0; --r
) {
921 if (rowinfo
[r
].type
!= LT_NORMAL
)
923 rowinfo
[r
].type
= LT_LASTFOOT
;
925 } else if (t
.cs() == "newpage") {
928 rowinfo
[row
- 1].newpage
= true;
930 // This does not work in LaTeX
936 rowinfo
[row
].newpage
= true;
938 cerr
<< "unexpected line token: " << t
<< endl
;
944 vector
<string
> cells
;
945 split(lines
[row
], cells
, TAB
);
946 for (size_t col
= 0, cell
= 0; cell
< cells
.size();
948 //cerr << "cell content: '" << cells[cell] << "'\n";
949 if (col
>= colinfo
.size()) {
950 // This does not work in LaTeX
951 cerr
<< "Ignoring extra cell '"
952 << cells
[cell
] << "'." << endl
;
955 Parser
p(cells
[cell
]);
957 //cells[cell] << "'\n";
958 if (p
.next_token().cs() == "multicolumn") {
961 size_t const ncells
=
962 convert
<unsigned int>(p
.verbatim_item());
964 // special cell properties alignment
966 handle_colalign(p
, t
, ColInfo());
967 ColInfo
& ci
= t
.front();
969 // The logic of LyX for multicolumn vertical
970 // lines is too complicated to reproduce it
971 // here (see LyXTabular::TeXCellPreamble()).
972 // Therefore we simply put everything in the
976 cellinfo
[row
][col
].multi
= CELL_BEGIN_OF_MULTICOLUMN
;
977 cellinfo
[row
][col
].align
= ci
.align
;
978 cellinfo
[row
][col
].special
= ci
.special
;
979 cellinfo
[row
][col
].leftlines
= ci
.leftlines
;
980 cellinfo
[row
][col
].rightlines
= ci
.rightlines
;
982 parse_text_in_inset(p
, os
, FLAG_ITEM
, false, context
);
983 if (!cellinfo
[row
][col
].content
.empty()) {
984 // This may or may not work in LaTeX,
985 // but it does not work in LyX.
986 // FIXME: Handle it correctly!
987 cerr
<< "Moving cell content '"
989 << "' into a multicolumn cell. "
990 "This will probably not work."
993 cellinfo
[row
][col
].content
+= os
.str();
995 // add dummy cells for multicol
996 for (size_t i
= 0; i
< ncells
- 1 && col
< colinfo
.size(); ++i
) {
998 cellinfo
[row
][col
].multi
= CELL_PART_OF_MULTICOLUMN
;
999 cellinfo
[row
][col
].align
= 'c';
1003 cellinfo
[row
][col
].leftlines
= colinfo
[col
].leftlines
;
1004 cellinfo
[row
][col
].rightlines
= colinfo
[col
].rightlines
;
1005 cellinfo
[row
][col
].align
= colinfo
[col
].align
;
1007 parse_text_in_inset(p
, os
, FLAG_CELL
, false, context
);
1008 cellinfo
[row
][col
].content
+= os
.str();
1012 //cerr << "// handle almost empty last row what we have\n";
1013 // handle almost empty last row
1014 if (row
&& lines
[row
].empty() && row
+ 1 == rowinfo
.size()) {
1015 //cerr << "remove empty last line\n";
1016 if (rowinfo
[row
].topline
)
1017 rowinfo
[row
- 1].bottomline
= true;
1018 for (size_t col
= 0; col
< colinfo
.size(); ++col
)
1019 if (cellinfo
[row
][col
].topline
)
1020 cellinfo
[row
- 1][col
].bottomline
= true;
1025 // Now we have the table structure and content in rowinfo, colinfo
1027 // Unfortunately LyX has some limitations that we need to work around.
1029 // Convert cells with special content to multicolumn cells
1030 // (LyX ignores the special field for non-multicolumn cells).
1031 for (size_t row
= 0; row
< rowinfo
.size(); ++row
) {
1032 for (size_t col
= 0; col
< cellinfo
[row
].size(); ++col
) {
1033 if (cellinfo
[row
][col
].multi
== CELL_NORMAL
&&
1034 !cellinfo
[row
][col
].special
.empty())
1035 cellinfo
[row
][col
].multi
= CELL_BEGIN_OF_MULTICOLUMN
;
1039 //cerr << "// output what we have\n";
1040 // output what we have
1041 os
<< "\n<lyxtabular version=\"3\" rows=\"" << rowinfo
.size()
1042 << "\" columns=\"" << colinfo
.size() << "\">\n";
1044 << write_attribute("rotate", false)
1045 << write_attribute("islongtable", is_long_tabular
)
1048 //cerr << "// after header\n";
1049 for (size_t col
= 0; col
< colinfo
.size(); ++col
) {
1050 os
<< "<column alignment=\""
1051 << verbose_align(colinfo
[col
].align
) << "\""
1053 << verbose_valign(colinfo
[col
].valign
) << "\""
1054 << write_attribute("leftline", colinfo
[col
].leftlines
> 0)
1055 << write_attribute("rightline", colinfo
[col
].rightlines
> 0)
1056 << write_attribute("width", translate_len(colinfo
[col
].width
))
1057 << write_attribute("special", colinfo
[col
].special
)
1060 //cerr << "// after cols\n";
1062 for (size_t row
= 0; row
< rowinfo
.size(); ++row
) {
1064 << write_attribute("topline", rowinfo
[row
].topline
)
1065 << write_attribute("bottomline", rowinfo
[row
].bottomline
)
1066 << write_attribute("endhead",
1067 rowinfo
[row
].type
== LT_HEAD
)
1068 << write_attribute("endfirsthead",
1069 rowinfo
[row
].type
== LT_FIRSTHEAD
)
1070 << write_attribute("endfoot",
1071 rowinfo
[row
].type
== LT_FOOT
)
1072 << write_attribute("endlastfoot",
1073 rowinfo
[row
].type
== LT_LASTFOOT
)
1074 << write_attribute("newpage", rowinfo
[row
].newpage
)
1076 for (size_t col
= 0; col
< colinfo
.size(); ++col
) {
1077 CellInfo
const & cell
= cellinfo
[row
][col
];
1079 if (cell
.multi
!= CELL_NORMAL
)
1080 os
<< " multicolumn=\"" << cell
.multi
<< "\"";
1081 os
<< " alignment=\"" << verbose_align(cell
.align
)
1083 << " valignment=\"" << verbose_valign(cell
.valign
)
1085 << write_attribute("topline", cell
.topline
)
1086 << write_attribute("bottomline", cell
.bottomline
)
1087 << write_attribute("leftline", cell
.leftlines
> 0)
1088 << write_attribute("rightline", cell
.rightlines
> 0)
1089 << write_attribute("rotate", cell
.rotate
);
1090 //cerr << "\nrow: " << row << " col: " << col;
1092 // cerr << " topline=\"true\"";
1093 //if (cell.bottomline)
1094 // cerr << " bottomline=\"true\"";
1095 os
<< " usebox=\"none\""
1096 << write_attribute("width", translate_len(cell
.width
));
1097 if (cell
.multi
!= CELL_NORMAL
)
1098 os
<< write_attribute("special", cell
.special
);
1100 << "\n\\begin_inset Text\n"
1102 << "\n\\end_inset\n"
1108 os
<< "</lyxtabular>\n";