On Sat, Mar 12, 2005 at 07:17:25PM +0100, Juergen Spitzmueller wrote:
> Martin Vermeer wrote:
> > Patch attached. Seems to work for me, at least for for various character
> > attributes, and for rows/columns/sub-rectangles of the table.
> 
> Yes, works fine here too. The only irritating thing (and annoying, if you 
> want 
> to do several operations on a selection) is that only the last cell is 
> selected afterwards.
> I think we should restore the selection at the end, if we really need to 
> select every single cell in the loop.

Done, verbosely :-(
 
> > Please test. There are still easy ways to crash tables, but
> > I think this is an improvement. One crash you can get by painting
> > several cells and then typing C-l for ERT. This could be easily
> > eliminated by a separate switch case. Any others?
> 
> Basically all collapsables. The attached patch (against insettabular.C _with_ 
> your patch attached) disables them when multiple cells are selected. This 
> seems the right thing to do for me (and better than the 1.3 solution: insert 
> the inset into the last selected cell).

I added this too (with small mods). See attached patch. This works and seems 
pretty final, so I will later commit this if no-one else objects.

> Jürgen

There is BTW still a problem with collapsable insets inside *single* table 
cells:
the method which works outside tables: select a range of chars and type C-l -> 
the
characters will be included in the new ERT, fails here. Instead, what happens 
is that the 
*whole* cell content is replaced by an ERT, which contains "junk" (i.e., the 
content of the
last ERT inserted outside the table.)

- Martin


Index: insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.454
diff -u -r1.454 insettabular.C
--- insettabular.C      8 Feb 2005 13:18:04 -0000       1.454
+++ insettabular.C      12 Mar 2005 21:15:16 -0000
@@ -724,6 +724,43 @@
                cell(cur.idx())->dispatch(cur, cmd);
                break;
 
+        case LFUN_EMPH:
+        case LFUN_BOLD:
+        case LFUN_ROMAN:
+        case LFUN_NOUN:
+        case LFUN_ITAL:
+        case LFUN_FRAK:
+        case LFUN_CODE:
+        case LFUN_SANS:
+               if (tablemode(cur)) {
+                       row_type rs, re;
+                       col_type cs, ce;
+                       getSelection(cur, rs, re, cs, ce);
+                       for (row_type i = rs; i <= re; ++i)
+                               for (col_type j = cs; j <= ce; ++j) {
+                                       // cursor follows cell:
+                                       cur.idx() = tabular.getCellNumber(i, j);
+                                       // select this cell only:
+                                       cur.pos() = 0;
+                                       cur.resetAnchor();
+                                       cur.pos() = cur.top().lastpos();
+                                       cur.setCursor(cur);
+                                       cur.setSelection();
+                                       cell(cur.idx())->dispatch(cur, cmd);
+                               }
+                       // Restore original selection
+                       cur.idx() = tabular.getCellNumber(rs, cs);
+                       cur.pos() = 0;
+                       cur.resetAnchor();
+                       cur.idx() = tabular.getCellNumber(re, ce);
+                       cur.pos() = cur.top().lastpos();
+                       cur.setCursor(cur);
+                       cur.setSelection();
+                       break;
+               } else {
+                       cell(cur.idx())->dispatch(cur, cmd);
+                       break;
+               }
        default:
                // we try to handle this event in the insets dispatch function.
                cell(cur.idx())->dispatch(cur, cmd);
@@ -907,6 +944,24 @@
                        break;
                }
                return true;
+       }
+
+       // disable these with multiple cells selected
+       case LFUN_INSERT_CHARSTYLE:
+       case LFUN_INSET_FLOAT:
+       case LFUN_INSET_WIDE_FLOAT:
+       case LFUN_INSET_FOOTNOTE:
+       case LFUN_INSET_MARGINAL:
+       case LFUN_INSERT_NOTE:
+       case LFUN_INSET_OPTARG:
+       case LFUN_INSERT_BOX:
+       case LFUN_INSERT_BRANCH:
+       case LFUN_INSET_WRAP:
+       case LFUN_INSET_ERT: {
+               if (tablemode(cur)) {
+                       status.enabled(false);
+                       return true;
+               }
        }
 
        default:
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1115
diff -u -r1.1115 ChangeLog
--- ChangeLog   28 Feb 2005 13:14:48 -0000      1.1115
+++ ChangeLog   12 Mar 2005 21:15:17 -0000
@@ -1,3 +1,10 @@
+2005-03-12  Martin Vermeer  <[EMAIL PROTECTED]>
+
+       * insettabular.C: make applying character attributes 
+       possible for multiple cells in tables. Disable collapsable
+       insets for multiple-cell selection in table (Jïrgen S.)
+       Bug reported by Helge Hafting.
+
 2005-02-25  Andreas Vox  <[EMAIL PROTECTED]>
 
        * insetmarginal.[hC] (docbook): new method, render as <note>

Attachment: pgpNOrvuAcnKY.pgp
Description: PGP signature

Reply via email to