]> git.lyx.org Git - lyx.git/blobdiff - lib/reLyX/RelyxTable.pm
The Box patch
[lyx.git] / lib / reLyX / RelyxTable.pm
index e52cd5f621bf1c909b47d82d403b45c327c36662..dc57aa6bec5908b9871e093083281d4d287cff79 100644 (file)
@@ -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);
@@ -283,65 +284,8 @@ sub parse_cols {
        }
     } # end sub done_reading
 
+# Subroutines to print out the table once it's created
     sub print_info {
-    # Subroutine to print out the table once it's created
-       &print_info_221(@_);
-    }
-
-    sub write_string {
-       my ($name, $s) = @_;
-       if (!$s) {
-           return '';
-       }
-       return ' ' . $name . '="' . $s . '"';
-    }
-
-    sub write_bool {
-       my ($name, $b) = @_;
-       if (!$b) {
-           return '';
-       }
-       write_string $name, "true";
-    }
-
-    sub write_int {
-       my ($name, $i) = @_;
-       if (!$i) {
-           return '';
-       }
-       write_string $name, $i;
-    }
-
-    sub print_info_221 {
-    # Subroutine to print out the table in \lyxformat 221
-       my $thistable = shift;
-        my $to_print = '';
-        # header line
-       $to_print .= "\n<lyxtabular" .
-           write_int("version", 3) .
-           write_int("rows", $thistable->numrows) .
-           write_int("columns", $thistable->numcols) .
-           ">\n";
-       # global longtable options
-       $to_print .= "<features" .
-          write_int ("rotate", 0) .
-          write_bool("islongtable", 0) .
-          write_int ("firstHeadTopDL", 0) .
-          write_int ("firstHeadBottomDL", 0) .
-          write_bool("firstHeadEmpty", 0) .
-          write_int ("headTopDL", 0) .
-          write_int ("headBottomDL", 0) .
-          write_int ("footTopDL", 0) .
-          write_int ("footBottomDL", 0) .
-          write_int ("lastFootTopDL", 0) .
-          write_int ("lastFootBottomDL", 0) .
-          write_bool("lastFootEmpty", 0) .
-          ">\n";
-           
-    }
-
-    sub print_info_215 {
-    # Subroutine to print out the table in \lyxformat 215
         # print the header information for this table
        my $thistable = shift;
         my $to_print = "";
@@ -433,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