X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2FreLyX%2FRelyxTable.pm;h=a77af824eb6adb6e73679f443157cb5a1e1e2458;hb=46ee486bdaf2a39538d9cabd2e7af722a4ede97d;hp=3bf797be59817d765b6b2651a7ae9cda28cfc779;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=features.git diff --git a/lib/reLyX/RelyxTable.pm b/lib/reLyX/RelyxTable.pm index 3bf797be59..a77af824eb 100644 --- a/lib/reLyX/RelyxTable.pm +++ b/lib/reLyX/RelyxTable.pm @@ -68,7 +68,7 @@ sub parse_cols { while (@group) { $tok = shift(@group); - # Each $tok will consist of /^[clr|]*[p*@]?$/ + # Each $tok will consist of /^[clr|]*[mp*@]?$/ # (Except first may have | and/or @ expressions before it) # p*@ will end the $tok since after it comes a group in braces # @ will be a TT::Token, everything else will be in TT::Text @@ -86,13 +86,14 @@ sub parse_cols { @new_cols = ($description =~ /[clr]\|*/g); push @cols, @new_cols; - # parse a p or * or @ if necessary + # parse a 'p', an 'm', a '*' or a '@' as necessary # use exact_print in case there's weird stuff in the @ descriptions $description = substr($description,-1); - if ($description eq 'p') { + # The m and p descriptors have identical form. + if ($description eq 'p' || $description eq 'm') { $tok = shift(@group); - my $pdes = $description . $tok->exact_print; # "p{foo}" - push @cols, $pdes; + my $des = $description . $tok->exact_print; # 'p{foo}' or 'm{foo}' + push @cols, $des; } elsif ($description eq '@') { $tok = shift(@group); @@ -175,7 +176,7 @@ sub parse_cols { push @RelyxTable::table_array, $thistable; - # Now that it's blessed, put the 0th row into the table + # Now that it's blessed, put the 0th row into the table $thistable->addrow; return $thistable; @@ -312,7 +313,7 @@ sub parse_cols { foreach $col (@{$thistable->{"columns"}}) { $to_print .= $col->print_info; } - + # Print cell info my $cell; foreach $row (@{$thistable->{"rows"}}) { @@ -368,7 +369,7 @@ package RelyxTable::Column; my $description = shift; my $col; - # Initially zero everything, since we set different + # Initially zero everything, since we set different # fields for @ and non-@ columns $col->{"alignment"} = "c"; # default $col->{"left_line"} = 0; @@ -376,25 +377,25 @@ package RelyxTable::Column; $col->{"pwidth"} = ""; $col->{"special"} = ""; - # Any special (@) column should be handled differently - if ($description =~ /\@/) { - # Just put the whole description in "special" field --- this - # corresponds the the "extra" field in LyX table popup - # Note that LyX ignores alignment, r/l lines for a special column - $col->{"special"} = $description; - print "\n'$description' column won't display WYSIWYG in LyX\n" - if $debug_on; - - # It's not a special @ column - } else { + # LyX does not know about '@' or 'm' column descriptors so, to + # ensure that the LaTeX -> LyX -> LaTeX cycle is invariant, + # these descriptors are placed in the 'special' field. + if ($description =~ /\@/ || $description =~ /^m/ ) { + $col->{"special"} = $description; + print "\n'$description' column won't display WYSIWYG in LyX\n" + if $debug_on; + } + # '@' columns really can't be displayed WYSIWYG in LyX, + # but we can get visual feedback on 'm' columns. + if (!($description =~ /\@/)) { # left line? $description =~ s/^\|*//; $col->{"left_line"} = length($&); # main column description - $description =~ s/^[clrp]//; - if ($& eq "p") { + $description =~ s/^[clrpm]//; + if ($& eq 'p' || $& eq 'm') { $description =~ s/^\{(.+)\}//; # eat the width $col->{"pwidth"} = $1; # width without braces # note: alignment is not applicable for 'p' columns @@ -423,7 +424,7 @@ package RelyxTable::Column; ); $to_print .= join(" ",@arr); $to_print .= "\n"; - + return $to_print; } } # end package RelyxTable::Column @@ -457,7 +458,13 @@ package RelyxTable::Row; $i++; # What if it was a multicolumn? - $i++ while ${$row->{"cells"}}[$i]->{"multicolumn"} eq "part"; + # $rcells holds a reference to the array of cells + my $rcells = \@{$row->{"cells"}}; + # Paranoia check that we're not attempting to access beyond the + # end of the array in case reLyX failed to parse the number of + # columns correctly. + $i++ while ($i < @{$rcells} && + ${$rcells}[$i]->{"multicolumn"} eq "part"); $row->{"curr_col"} = $i; } # end of sub nextcol @@ -512,7 +519,7 @@ package RelyxTable::Row; ); $to_print .= join(" ",@arr); $to_print .= "\n"; - + return $to_print; } # end sub print_info @@ -527,7 +534,7 @@ package RelyxTable::Cell; # alignment - alignment of this cell # top_line - does the cell have a line on the top? # bottom_line - does the cell have a line on the bottom? -# has_cont_row- +# has_cont_row- # rotate - rotate cell? # line_breaks - cell has line breaks in it (???) # special - does this multicol have a special description (@ commands?) @@ -588,7 +595,7 @@ package RelyxTable::Cell; ); $to_print .= join(" ",@arr); $to_print .= "\n"; - + return $to_print; } } # end package RelyxTable::Cell