]> git.lyx.org Git - features.git/commitdiff
Various fixes and some "missing features" from Dekels Mail in insettext/
authorJürgen Vigna <jug@sad.it>
Thu, 28 Sep 2000 14:05:24 +0000 (14:05 +0000)
committerJürgen Vigna <jug@sad.it>
Thu, 28 Sep 2000 14:05:24 +0000 (14:05 +0000)
tabular fixe.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1052 a592a061-630c-0410-9148-cb99ea01b6c8

19 files changed:
ChangeLog
src/BufferView.C
src/BufferView.h
src/BufferView2.C
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/buffer.C
src/buffer.h
src/converter.C
src/frontends/xforms/FormTabular.C
src/insets/insetlabel.C
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/lyxfunc.C
src/tabular.C
src/tabular.h
src/text.C
src/text2.C

index eda8d9dc75ad9294f91660b56c4f504d26974619..f12e72d5b236019271b6fa89889f875b40047ba1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2000-09-28  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insettabular.C (update): fixed cursor setting when
+       the_locking_inset changed.
+       (draw): made this a bit cleaner.
+
+       * various files: added LyXText Parameter to fitCursor call.
+       
+       * src/BufferView.C (fitCursor): added LyXText parameter.
+
+       * src/insets/insettabular.C (draw): small draw fix.
+
+       * src/tabular.C: right setting of left/right celllines.
+
+       * src/tabular.[Ch]: fixed various types in funcions and structures. 
+       * src/insets/insettabular.C: ditto
+       * src/frontends/xforms/FormTabular.C: ditto
+
 2000-09-28  Allan Rae  <rae@lyx.org>
 
        * src/paragraph.C (TeXOnePar): fixed output of '\n'.  The problem was
index e244fb46b3605ecf6fb2eab451fe532f30a01f8d..88cbba5f8f7f927f7b276d664dd3f2ce37eedb85 100644 (file)
@@ -99,9 +99,9 @@ void BufferView::redraw()
 }
 
 
-void BufferView::fitCursor()
+void BufferView::fitCursor(LyXText * text)
 {
-       pimpl_->fitCursor();
+       pimpl_->fitCursor(text);
 }
 
 
index 444fcaed49f2cecaa15c1465f16040e318ac4cc0..d811704302efe3fe2ce18421d1690a1e6b318a36 100644 (file)
@@ -63,7 +63,7 @@ public:
        ///
        void redraw();
        ///
-       void fitCursor();
+       void fitCursor(LyXText *);
        ///
        void update();
        //
index fd8615a1341a1a12bc2ee9ae13d73deee4c51796..ab4e5ca3fc07de801cf786329a486270de18ab2f 100644 (file)
@@ -203,9 +203,8 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
        // if we are in a locking inset we should try to insert the
        // inset there otherwise this is a illegal function now
        if (the_locking_inset) {
-               if (the_locking_inset->InsertInsetAllowed(inset) &&
-                   the_locking_inset->InsertInset(this, inset))
-                       return true;
+               if (the_locking_inset->InsertInsetAllowed(inset))
+                   return the_locking_inset->InsertInset(this, inset);
                return false;
        }
 
@@ -252,19 +251,6 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
        }
        
        text->InsertInset(this, inset);
-#if 1
-       // if we enter a text-inset the cursor should be to the left side
-       // of it! This couldn't happen before as Undo was not handled inside
-       // inset now after the Undo LyX tries to call inset->Edit(...) again
-       // and cannot do this as the cursor is behind the inset and GetInset
-       // does not return the inset!
-       if (inset->IsTextInset()) {
-               if (text->cursor.par()->isRightToLeftPar(buffer()->params))
-                       text->CursorRight(this);
-               else
-                       text->CursorLeft(this);
-       }
-#endif
        update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
 
        text->UnFreezeUndo();
@@ -394,8 +380,7 @@ void BufferView::allFloats(char flag, char figmar)
 
        text->SetCursorIntern(this, cursor.par(), cursor.pos());
        redraw();
-       fitCursor();
-       //updateScrollbar();
+       fitCursor(text);
 }
 #endif
 
index 53fdc53cc00e35af4315a995fbfb3aa8c31b70e4..bc6b57134808bcf755615f1698ffb75e7ff920d8 100644 (file)
@@ -208,12 +208,13 @@ void BufferView::Pimpl::redraw()
 }
 
 
-bool BufferView::Pimpl::fitCursor()
+bool BufferView::Pimpl::fitCursor(LyXText * text)
 {
        Assert(screen_); // it is a programming error to call fitCursor
        // without a valid screen.
-       bool ret = screen_->FitCursor(bv_->text);
-       if (ret) updateScrollbar();
+       bool ret = screen_->FitCursor(text);
+       if (ret)
+           updateScrollbar();
        return ret;
 }
 
@@ -541,7 +542,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
       
                bv_->text->SetSelection();
                screen_->ToggleToggle(bv_->text);
-               fitCursor();
+               fitCursor(bv_->text);
                screen_->ShowCursor(bv_->text);
        }
        return;
@@ -634,7 +635,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
        bv_->text->cursor.x_fix(bv_->text->cursor.x());
        
        owner_->updateLayoutChoice();
-       if (fitCursor()) {
+       if (fitCursor(bv_->text)) {
                selection_possible = false;
        }
        
@@ -976,7 +977,7 @@ void BufferView::Pimpl::workAreaExpose()
                        // fitCursor() ensures we don't jump back
                        // to the start of the document on vertical
                        // resize
-                       fitCursor();
+                       fitCursor(bv_->text);
 
                        // The main window size has changed, repaint most stuff
                        redraw();
@@ -1052,7 +1053,7 @@ void BufferView::Pimpl::update(BufferView::UpdateCodes f)
        update();
 
        if ((f & FITCUR)) {
-               fitCursor();
+               fitCursor(bv_->text);
        }
 
        if ((f & CHANGE)) {
index 46e9e3df182b8b70692e039ecc7b5e4a91d8ba25..858e809af38a029bc985f634468527eaee9aadce 100644 (file)
@@ -36,7 +36,7 @@ struct BufferView::Pimpl : public Object {
        ///
        void redraw();
        /// Return true if the cursor was fitted.
-       bool fitCursor();
+       bool fitCursor(LyXText *);
        ///
        void redoCurrentBuffer();
        ///
index 845b038737360bb43b787a3590d0859504f9e98c..ae13856bad164c32de4ff17e484649ce9f854b78 100644 (file)
@@ -3386,7 +3386,7 @@ int Buffer::runLiterate()
        // error insets after we ran LaTeX this must be run:
         if (removedErrorInsets || (res & Literate::ERRORS)){
                 users->redraw();
-                users->fitCursor();
+                users->fitCursor(users->text);
                 //users->updateScrollbar();
         }
         AllowInput(users);
@@ -3457,7 +3457,7 @@ int Buffer::buildProgram()
        // must be run:
        if (removedErrorInsets || (res & Literate::ERRORS)){
                users->redraw();
-               users->fitCursor();
+               users->fitCursor(users->text);
                //users->updateScrollbar();
        }
        AllowInput(users);
@@ -3509,8 +3509,7 @@ int Buffer::runChktex()
        // error insets after we ran chktex, this must be run:
        if (removedErrorInsets || res){
                users->redraw();
-               users->fitCursor();
-               //users->updateScrollbar();
+               users->fitCursor(users->text);
        }
        AllowInput(users);
 
index ad3249b57959c7ed310d042e87de3c2d969a62bb..39d57306bd5a44966d315526f9bb3cdd9f27652c 100644 (file)
@@ -106,7 +106,7 @@ public:
        ///
        void redraw() {
                users->redraw(); 
-               users->fitCursor(); 
+               users->fitCursor(users->text); 
                //users->updateScrollbar();
        }
 
index cc4bb3a453d930be951ce7dfe77dc069f1590ed5..81bf1cdba093be7ebfa8e481e5f0f4dea519448b 100644 (file)
@@ -462,8 +462,7 @@ bool Converter::runLaTeX(Buffer * buffer, string const & command)
        // error insets after we ran LaTeX this must be run:
         if (a || (result & LaTeX::ERRORS)){
                 bv->redraw();
-                bv->fitCursor();
-                //bv->updateScrollbar();
+                bv->fitCursor(bv->text);
         }
 
        // check return value from latex.run().
index a77761beb8c7758ec0ce487cbf0bceecc0831545..2e05c2ad85b58c8ceefe7e218ba15aac62abb63c 100644 (file)
@@ -490,8 +490,9 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long)
         * tabular = inset_->tabular;
     int
         cell,
-        s,
-        num = 0;
+        s;
+    LyXTabular::Feature
+        num = LyXTabular::LAST_ACTION;
     string
         special,
         str;
index df69302a406af73db7f9b02395138e5ec533674a..72376e442799d187d9bd33e806d268403534e55f 100644 (file)
@@ -57,8 +57,7 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int)
                        bv->text->RedoParagraph(bv);
                        if (flag) {
                                bv->redraw();
-                               bv->fitCursor();
-                               //bv->updateScrollbar();
+                               bv->fitCursor(getLyXText(bv));
                        } else
                                bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                }
index edb29a69d4f575ed6edfc8d08d31f25e680c77c2..a1a160c1ea6338195687b210ac173a63a974081e 100644 (file)
@@ -53,7 +53,7 @@ using std::swap;
 
     
 struct tabular_features {
-    int action;
+    LyXTabular::Feature action;
     string feature;
 };
 
@@ -85,7 +85,6 @@ static tabular_features tabularFeatures[] =
     { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
     { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
     { LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
-    { LyXTabular::DELETE_TABULAR, "delete-tabular" },
     { LyXTabular::MULTICOLUMN, "multicolumn" },
     { LyXTabular::SET_ALL_LINES, "set-all-lines" },
     { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
@@ -255,45 +254,18 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
        return;
     bool dodraw;
     x += ADD_TO_TABULAR_WIDTH;
-    if (cleared || (need_update == FULL) || (need_update == CELL)) {
+    if (cleared) {
        for(i = 0; i < tabular->rows(); ++i) {
            nx = int(x);
            dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) &&
-                   (baseline - tabular->GetAscentOfRow(i)) < pain.paperHeight();
+                   (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight();
            for(j = 0; j < tabular->columns(); ++j) {
                if (tabular->IsPartOfMultiColumn(i, j))
                    continue;
                cx = nx + tabular->GetBeginningOfTextInCell(cell);
-               if (hasSelection())
-                   DrawCellSelection(pain, nx, baseline, i, j, cell);
-               if (dodraw && !cleared && locked && the_locking_inset) {
-                   if (the_locking_inset == tabular->GetCellInset(cell)) {
-                       LyXText::text_status st = bv->text->status;
-                       do {
-                           bv->text->status = st;
-                           if (need_update == CELL) {
-                               // clear before the inset
-                               pain.fillRectangle(
-                                   nx + 1,
-                                   baseline - tabular->GetAscentOfRow(i) + 1,
-                                   int(cx - nx - 1),
-                                   tabular->GetAscentOfRow(i) +
-                                   tabular->GetDescentOfRow(i) - 1);
-                               // clear behind the inset
-                               pain.fillRectangle(
-                                   int(cx + the_locking_inset->width(bv,font) + 1),
-                                   baseline - tabular->GetAscentOfRow(i) + 1,
-                                   tabular->GetWidthOfColumn(cell) -
-                                   tabular->GetBeginningOfTextInCell(cell) -
-                                   the_locking_inset->width(bv,font) - 1,
-                                   tabular->GetAscentOfRow(i) +
-                                   tabular->GetDescentOfRow(i) - 1);
-                           }
-                           tabular->GetCellInset(cell)->draw(
-                               bv, font, baseline, cx, false);
-                       } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
-                   }
-               } else if (dodraw) {
+               if (dodraw) {
+                   if (hasSelection())
+                       DrawCellSelection(pain, nx, baseline, i, j, cell);
                    tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
                                                      cleared);
                    DrawCellLines(pain, nx, baseline, i, cell);
@@ -303,7 +275,47 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
            }
            baseline += tabular->GetDescentOfRow(i) +
                tabular->GetAscentOfRow(i + 1) +
-               tabular->GetAdditionalHeight(cell + 1);
+               tabular->GetAdditionalHeight(cell);
+       }
+    } else if (need_update == CELL) {
+       nx = int(x);
+       for(i = 0; (cell < actcell) && (i < tabular->rows()); ++i) {
+           nx = int(x);
+           for(j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
+               if (tabular->IsPartOfMultiColumn(i, j))
+                   continue;
+               nx += tabular->GetWidthOfColumn(cell);
+               ++cell;
+           }
+           baseline += tabular->GetDescentOfRow(i) +
+               tabular->GetAscentOfRow(i + 1) +
+               tabular->GetAdditionalHeight(cell);
+       }
+       if (the_locking_inset == tabular->GetCellInset(cell)) {
+           cx = nx + tabular->GetBeginningOfTextInCell(cell);
+           LyXText::text_status st = bv->text->status;
+           do {
+               bv->text->status = st;
+               if (need_update == CELL) {
+                    // clear before the inset
+                   pain.fillRectangle(
+                       nx + 1,
+                       baseline - tabular->GetAscentOfRow(i) + 1,
+                       int(cx - nx - 1),
+                       tabular->GetAscentOfRow(i) +
+                       tabular->GetDescentOfRow(i) - 1);
+                   // clear behind the inset
+                   pain.fillRectangle(
+                       int(cx + the_locking_inset->width(bv,font) + 1),
+                       baseline - tabular->GetAscentOfRow(i) + 1,
+                       tabular->GetWidthOfColumn(cell) -
+                       tabular->GetBeginningOfTextInCell(cell) -
+                       the_locking_inset->width(bv,font) - 1,
+                       tabular->GetAscentOfRow(i) +
+                       tabular->GetDescentOfRow(i) - 1);
+               }
+               tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
+           } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
        }
     }
     x -= ADD_TO_TABULAR_WIDTH;
@@ -384,8 +396,12 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
            owner()->update(bv, font, true);
        return;
     }
-    if (the_locking_inset)
+    if (the_locking_inset) {
        the_locking_inset->update(bv, font, reinit);
+       resetPos(bv);
+       inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
+       inset_y = cursor.y();
+    }
     switch(need_update) {
     case INIT:
     case FULL:
@@ -815,22 +831,12 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        if (hs)
            UpdateLocal(bv, SELECTION, false);
        break;
-#if 0
-    case LFUN_LAYOUT_TABLE:
-    {
-       dialogs_ = bv->owner()->getDialogs();
-        dialogs_->showTabular(this);
-    }
-    break;
-#else
-#warning Jürgen, have a look. Is this correct? (Lgb)
     case LFUN_LAYOUT_TABULAR:
     {
        dialogs_ = bv->owner()->getDialogs();
         dialogs_->showTabular(this);
     }
     break;
-#endif
     case LFUN_TABULAR_FEATURE:
        if (!TabularFeatures(bv, arg))
            result = UNDISPATCHED;
@@ -1197,7 +1203,7 @@ void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
 
 bool InsetTabular::TabularFeatures(BufferView * bv, string const & what)
 {
-    int action = LyXTabular::LAST_ACTION;
+    LyXTabular::Feature action = LyXTabular::LAST_ACTION;
 
     int i = 0;
     for(; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
@@ -1220,7 +1226,8 @@ bool InsetTabular::TabularFeatures(BufferView * bv, string const & what)
 }
 
 
-void InsetTabular::TabularFeatures(BufferView * bv, int feature,
+void InsetTabular::TabularFeatures(BufferView * bv,
+                                  LyXTabular::Feature feature,
                                   string const & value)
 {
     int i;
@@ -1231,6 +1238,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
     int sel_row_end;
     int setLines = 0;
     LyXAlignment setAlign = LYX_ALIGN_LEFT;
+    LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
     int lineSet;
     bool what;
 
@@ -1249,15 +1257,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
           break;
       case LyXTabular::M_VALIGN_TOP:
       case LyXTabular::VALIGN_TOP:
-          setAlign=LyXTabular::LYX_VALIGN_TOP;
+          setVAlign=LyXTabular::LYX_VALIGN_TOP;
           break;
       case LyXTabular::M_VALIGN_BOTTOM:
       case LyXTabular::VALIGN_BOTTOM:
-          setAlign=LyXTabular::LYX_VALIGN_BOTTOM;
+          setVAlign=LyXTabular::LYX_VALIGN_BOTTOM;
           break;
       case LyXTabular::M_VALIGN_CENTER:
       case LyXTabular::VALIGN_CENTER:
-          setAlign=LyXTabular::LYX_VALIGN_CENTER;
+          setVAlign=LyXTabular::LYX_VALIGN_CENTER;
           break;
       default:
           break;
@@ -1422,8 +1430,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
     case LyXTabular::VALIGN_CENTER:
        for(i = sel_row_start; i <= sel_row_end; ++i)
            for(j = sel_col_start; j <= sel_col_end; ++j)
-               tabular->SetVAlignment(tabular->GetCellNumber(i, j), setAlign,
-                                      flag);
+               tabular->SetVAlignment(tabular->GetCellNumber(i, j),
+                                      setVAlign, flag);
        if (hasSelection())
            UpdateLocal(bv, INIT, true);
        else
@@ -1527,6 +1535,9 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
        what = !tabular->GetLTNewPage(actcell);
        tabular->SetLTNewPage(actcell, what);
        break;
+    // dummy stuff just to avoid warnings
+    case LyXTabular::LAST_ACTION:
+       break;
     }
 }
 
index 6b4701e3cd95a9feef66ec872aebefbaf4140fc0..6b2513efc55a7e377da8e90ef8f47f1966394f51 100644 (file)
@@ -152,7 +152,7 @@ public:
     ///
     bool TabularFeatures(BufferView * bv, string const & what);
     ///
-    void TabularFeatures(BufferView * bv, int feature,
+    void TabularFeatures(BufferView * bv, LyXTabular::Feature feature,
                         string const & val = string());
     ///
     int GetActCell() const { return actcell; }
index 298f11edd38fee7c57bec3114a97b18247c79d4c..89ce5d7e38b6c915ebd9a6bb5dc0d36f71c18ec5 100644 (file)
@@ -1190,10 +1190,13 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
        UpdatableInset * i = static_cast<UpdatableInset *>(inset);
        i->setOwner(static_cast<UpdatableInset *>(this));
     }
+    HideInsetCursor(bv);
     TEXT(bv)->InsertInset(bv, inset);
     TEXT(bv)->selection = 0;
+    bv->fitCursor(TEXT(bv));
     UpdateLocal(bv, CURSOR_PAR, true);
     static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
+    ShowInsetCursor(bv);
     return true;
 }
 
index abda8b84dd46b20279170baecd893418c1716679..00195488d487d3644f3010ed371b06cd9d194689 100644 (file)
@@ -1081,8 +1081,7 @@ string const LyXFunc::Dispatch(int ac,
        case LFUN_REMOVEERRORS:
                if (owner->view()->removeAutoInsets()) {
                        owner->view()->redraw();
-                       owner->view()->fitCursor();
-                       //owner->view()->updateScrollbar();
+                       owner->view()->fitCursor(owner->view()->text);
                }
                break;
                
@@ -1565,13 +1564,17 @@ string const LyXFunc::Dispatch(int ac,
                bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params);
                if(!txt->mark_set) owner->view()->beforeChange();
                owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
+               LyXCursor cur = txt->cursor;
                if (!is_rtl)
                        txt->CursorLeft(owner->view(), false);
-               if (txt->cursor.pos() < txt->cursor.par()->Last()
-                   && txt->cursor.par()->GetChar(txt->cursor.pos())
-                   == LyXParagraph::META_INSET
-                   && txt->cursor.par()->GetInset(txt->cursor.pos())
-                   && txt->cursor.par()->GetInset(txt->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE) {
+               if ((cur != txt->cursor) && // only if really moved!
+                   txt->cursor.pos() < txt->cursor.par()->Last() &&
+                   (txt->cursor.par()->GetChar(txt->cursor.pos()) ==
+                    LyXParagraph::META_INSET) &&
+                   txt->cursor.par()->GetInset(txt->cursor.pos()) &&
+                   (txt->cursor.par()->GetInset(txt->cursor.pos())->Editable()
+                    == Inset::HIGHLY_EDITABLE))
+               {
                        Inset * tmpinset = txt->cursor.par()->GetInset(txt->cursor.pos());
                        setMessage(tmpinset->EditMessage());
                        LyXFont font = txt->GetFont(owner->view()->buffer(),
index 25697c118f6cee99018706591de3423f4c2f3bb5..268bf4e8c2ad59462ebf3ee861d2965a4ca70bed 100644 (file)
@@ -53,9 +53,9 @@ LyXTabular::cellstruct::cellstruct()
     multicolumn = LyXTabular::CELL_NORMAL;
     alignment = LYX_ALIGN_CENTER;
     valignment = LYX_VALIGN_TOP;
-    top_line = false;
+    top_line = true;
     bottom_line = false;
-    left_line = false;
+    left_line = true;
     right_line = false;
     usebox = BOX_NONE;
     rotate = false;
@@ -172,6 +172,7 @@ void LyXTabular::Init(int rows_arg, int columns_arg)
            cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
             cell_info[i][j].cellno = cellno++;
         }
+       cell_info[i][columns_-1].right_line = true;
     }
     //row_info[i - 1].bottom_line = true;
     //row_info[0].bottom_line = true;
@@ -318,7 +319,7 @@ void LyXTabular::Reinit()
 }
 
 
-void LyXTabular::set_row_column_number_info()
+void LyXTabular::set_row_column_number_info(bool oldformat)
 {
     int c = 0;
     int column = 0;
@@ -359,6 +360,14 @@ void LyXTabular::set_row_column_number_info()
        for (column = 0; column<columns_; ++column) {
            if (IsPartOfMultiColumn(row,column))
                continue;
+           // now set the right line of multicolumns right for oldformat read
+           if (oldformat &&
+               cell_info[row][column].multicolumn==CELL_BEGIN_OF_MULTICOLUMN)
+           {
+               int cn=cells_in_multicolumn(cell_info[row][column].cellno);
+               cell_info[row][column].right_line =
+                   cell_info[row][column+cn-1].right_line;
+           }
            cell_info[row][column].inset.SetAutoBreakRows(
                !GetPWidth(GetCellNumber(row, column)).empty());
        }
@@ -473,9 +482,8 @@ int LyXTabular::GetAdditionalHeight(int cell) const
     int const row = row_of_cell(cell);
     if (!row) return 0;
 
-#warning Jürgen, should the types change? (Lgb)
-    int top = 1; // bool top = true; ??
-    int bottom = 1; // bool bottom = true; ??
+    bool top = true;
+    bool bottom = true;
 
     for (int column = 0; column < columns_ - 1 && bottom; ++column) {
        switch (cell_info[row - 1][column].multicolumn) {
@@ -621,7 +629,6 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width)
 
 bool LyXTabular::SetAlignment(int cell, LyXAlignment align, bool onlycolumn)
 {
-#warning Please fix align type. (Lgb)
     if (!IsMultiColumn(cell) || onlycolumn)
         column_info[column_of_cell(cell)].alignment = align;
     if (!onlycolumn)
@@ -630,9 +637,8 @@ bool LyXTabular::SetAlignment(int cell, LyXAlignment align, bool onlycolumn)
 }
 
 
-bool LyXTabular::SetVAlignment(int cell, char align, bool onlycolumn)
+bool LyXTabular::SetVAlignment(int cell, VAlignment align, bool onlycolumn)
 {
-#warning Please fix align type. (Lgb)
     if (!IsMultiColumn(cell) || onlycolumn)
         column_info[column_of_cell(cell)].valignment = align;
     if (!onlycolumn)
@@ -671,9 +677,9 @@ bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
 }
 
 
-bool LyXTabular::SetAlignSpecial(int cell, string const & special, int what)
+bool LyXTabular::SetAlignSpecial(int cell, string const & special,
+                                LyXTabular::Feature what)
 {
-#warning Fix the "what" type. (Lgb)
     if (what == SET_SPECIAL_MULTI)
         cellinfo_of_cell(cell)->align_special = special;
     else
@@ -734,9 +740,8 @@ bool LyXTabular::SetRightLine(int cell, bool line, bool onlycolumn)
 }
 
 
-char LyXTabular::GetAlignment(int cell, bool onlycolumn) const
+LyXAlignment LyXTabular::GetAlignment(int cell, bool onlycolumn) const
 {
-#warning Fix return type. (Lgb)
     if (!onlycolumn && IsMultiColumn(cell))
        return cellinfo_of_cell(cell)->alignment;
     else
@@ -744,9 +749,8 @@ char LyXTabular::GetAlignment(int cell, bool onlycolumn) const
 }
 
 
-char LyXTabular::GetVAlignment(int cell, bool onlycolumn) const
+LyXTabular::VAlignment LyXTabular::GetVAlignment(int cell, bool onlycolumn) const
 {
-#warning Fix return type. (Lgb)
     if (!onlycolumn && IsMultiColumn(cell))
        return cellinfo_of_cell(cell)->valignment;
     else
@@ -1048,6 +1052,38 @@ bool getTokenValue(string const str, const char * token, int & num)
 }
 
 
+static
+bool getTokenValue(string const str, const char * token, LyXAlignment & num)
+{
+    int tmp;
+    bool ret = getTokenValue(str, token, tmp);
+    num = static_cast<LyXAlignment>(tmp);
+    return ret;
+}
+
+
+static
+bool getTokenValue(string const str, const char * token,
+                  LyXTabular::VAlignment & num)
+{
+    int tmp;
+    bool ret = getTokenValue(str, token, tmp);
+    num = static_cast<LyXTabular::VAlignment>(tmp);
+    return ret;
+}
+
+
+static
+bool getTokenValue(string const str, const char * token,
+                  LyXTabular::BoxType & num)
+{
+    int tmp;
+    bool ret = getTokenValue(str, token, tmp);
+    num = static_cast<LyXTabular::BoxType>(tmp);
+    return ret;
+}
+
+
 static
 bool getTokenValue(string const str, const char * token, bool & flag)
 {
@@ -1272,7 +1308,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
            getline(is, s1, '"');
            is >> ch; // skip '"'
            getline(is, s2, '"');
-           column_info[i].alignment = static_cast<char>(a);
+           column_info[i].alignment = static_cast<LyXAlignment>(a);
            column_info[i].left_line = b;
            column_info[i].right_line = c;
            column_info[i].p_width = s1;
@@ -1289,17 +1325,19 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                is >> ch; // skip '"'
                getline(is, s2, '"');
                cell_info[i][j].multicolumn = static_cast<char>(a);
-               cell_info[i][j].alignment = static_cast<char>(b);
+               cell_info[i][j].alignment = static_cast<LyXAlignment>(b);
                cell_info[i][j].top_line = static_cast<char>(c);
                cell_info[i][j].bottom_line = static_cast<char>(d);
+               cell_info[i][j].left_line = column_info[j].left_line;
+               cell_info[i][j].right_line = column_info[j].right_line;
                cell_info[i][j].rotate = static_cast<bool>(f);
-               cell_info[i][j].usebox = static_cast<bool>(g);
+               cell_info[i][j].usebox = static_cast<BoxType>(g);
                cell_info[i][j].align_special = s1;
                cell_info[i][j].p_width = s2;
            }
        }
     }
-    set_row_column_number_info();
+    set_row_column_number_info(true);
 
     LyXParagraph * par = new LyXParagraph;
     LyXParagraph * return_par = 0;
@@ -1615,9 +1653,8 @@ int LyXTabular::UnsetMultiColumn(int cell)
 }
 
 
-void LyXTabular::SetLongTabular(int what)
+void LyXTabular::SetLongTabular(bool what)
 {
-#warning Should what be bool? (Lgb)
     is_long_tabular = what;
 }
 
@@ -1731,9 +1768,8 @@ void LyXTabular::SetUsebox(int cell, BoxType type)
 }
 
 
-int LyXTabular::GetUsebox(int cell) const
+LyXTabular::BoxType LyXTabular::GetUsebox(int cell) const
 {
-#warning should the return type change? (Lgb)
     if (column_info[column_of_cell(cell)].p_width.empty() &&
         !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
         return BOX_NONE;
@@ -1884,7 +1920,6 @@ bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
 
 int LyXTabular::TeXTopHLine(ostream & os, int row) const
 {
-#warning should this return a bool? (Lgb)
     int const fcell = GetFirstCellInRow(row);
     int const n = NumberOfCellsInRow(fcell) + fcell;
     int tmp = 0;
@@ -1916,7 +1951,6 @@ int LyXTabular::TeXTopHLine(ostream & os, int row) const
 
 int LyXTabular::TeXBottomHLine(ostream & os, int row) const
 {
-#warning should this return a bool? (Lgb)
     int const fcell = GetFirstCellInRow(row);
     int const n = NumberOfCellsInRow(fcell) + fcell;
     int tmp = 0;
@@ -2217,15 +2251,15 @@ void LyXTabular::Validate(LaTeXFeatures & features) const
 }
 
 
-bool LyXTabular::UseParbox(int cell) const
+LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
     LyXParagraph * par = GetCellInset(cell)->par;
 
     for(; par; par = par->next) {
        for(int i = 0; i < par->Last(); ++i) {
            if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
-               return true;
+               return BOX_PARBOX;
        }
     }
-    return false;
+    return BOX_NONE;
 }
index 3035110f6243cb4608c49cc7442e429f6667b373..53f5474f3894c9e1f129817fc00fc4435056e6bf 100644 (file)
@@ -33,7 +33,7 @@ class Buffer;
 class LyXTabular  {
 public:
     ///
-    enum {
+    enum Feature {
        ///
        APPEND_ROW = 0,
        ///
@@ -83,8 +83,6 @@ public:
        ///
        M_VALIGN_CENTER,
        ///
-       DELETE_TABULAR,
-       ///
        MULTICOLUMN,
        ///
        SET_ALL_LINES,
@@ -218,19 +216,19 @@ public:
     /// Returns true if a complete update is necessary, otherwise false
     bool SetRightLine(int cell, bool line, bool onlycolumn=false);
     /// Returns true if a complete update is necessary, otherwise false
-    bool SetAlignment(int cell, char align, bool onlycolumn = false);
+    bool SetAlignment(int cell, LyXAlignment align, bool onlycolumn = false);
     /// Returns true if a complete update is necessary, otherwise false
-    bool SetVAlignment(int cell, char align, bool onlycolumn = false);
+    bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false);
     ///
     bool SetColumnPWidth(int cell, string const & width);
     ///
     bool SetMColumnPWidth(int cell, string const & width);
     ///
-    bool SetAlignSpecial(int cell, string const & special, int what);
+    bool SetAlignSpecial(int cell, string const & special, Feature what);
     ///
-    char GetAlignment(int cell, bool onlycolumn = false) const;
+    LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const;
     ///
-    char GetVAlignment(int cell, bool onlycolumn = false) const;
+    VAlignment GetVAlignment(int cell, bool onlycolumn = false) const;
     ///
     string const GetPWidth(int cell) const;
     ///
@@ -305,7 +303,7 @@ public:
     ///
     int right_column_of_cell(int cell) const;
     ///
-    void SetLongTabular(int what);
+    void SetLongTabular(bool);
     ///
     bool IsLongTabular() const;
     ///
@@ -333,7 +331,7 @@ public:
     ///
     void SetUsebox(int cell, BoxType);
     ///
-    int GetUsebox(int cell) const;
+    BoxType GetUsebox(int cell) const;
     //
     // Long Tabular Options
     ///
@@ -375,9 +373,9 @@ private: //////////////////////////////////////////////////////////////////
        ///
        int multicolumn;
        ///
-       int alignment;
+       LyXAlignment alignment;
        ///
-       int valignment;
+       VAlignment valignment;
        ///
        bool top_line;
        ///
@@ -387,7 +385,7 @@ private: //////////////////////////////////////////////////////////////////
        ///
        bool right_line;
        ///
-       int usebox;
+       BoxType usebox;
        ///
        bool rotate;
        ///
@@ -425,9 +423,9 @@ private: //////////////////////////////////////////////////////////////////
        ///
         columnstruct();
        ///
-       int alignment;
+       LyXAlignment alignment;
        ///
-       int valignment;
+       VAlignment valignment;
        ///
        bool left_line;
        ///
@@ -482,7 +480,7 @@ private: //////////////////////////////////////////////////////////////////
     ///
     void Reinit();
     ///
-    void set_row_column_number_info();
+    void set_row_column_number_info(bool oldformat=false);
     /// Returns true if a complete update is necessary, otherwise false
     bool SetWidthOfMulticolCell(int cell, int new_width);
     ///
@@ -500,7 +498,7 @@ private: //////////////////////////////////////////////////////////////////
     ///
     int cells_in_multicolumn(int cell) const;
     ///
-    bool UseParbox(int cell) const;
+    BoxType UseParbox(int cell) const;
 };
 
 #endif
index e9ef5677e6cb37ca4f54771df4950527289a4bc1..aa793d5d10878ea3aa1cb812821d39d1164193c7 100644 (file)
@@ -3402,7 +3402,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                                  GetFont(bview->buffer(),
                                                          row_ptr->par(), 0));
                        int w = (inset_owner ? inset_owner->width(bview, font) : ww);
-                       int xp = (inset_owner ? x : 0);
+                       int xp = static_cast<int>(inset_owner ? x : 0);
                        pain.line(xp, y_offset + y_top,
                                  w, y_offset + y_top,
                                  LColor::topline,
@@ -3583,7 +3583,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                        y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
                                                                 par, par->Last() - 1));
                        int w = (inset_owner ? inset_owner->width(bview, font) : ww);
-                       int xp = (inset_owner ? x : 0);
+                       int xp = static_cast<int>(inset_owner ? x : 0);
                        pain.line(xp, y_offset + y_bottom,
                                  w, y_offset + y_bottom,
                                  LColor::topline, Painter::line_solid,
index e9a3a85fca54d258109cab9f2b27a7da582b65c7..24f1f000dcde2dc4acddc485b4b01c52c1a37282 100644 (file)
@@ -2140,6 +2140,19 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset)
        InsertChar(bview, LyXParagraph::META_INSET);  /* just to rebreak and refresh correctly.
                                      * The character will not be inserted a
                                      * second time */
+#if 1
+       // if we enter a text-inset the cursor should be to the left side
+       // of it! This couldn't happen before as Undo was not handled inside
+       // inset now after the Undo LyX tries to call inset->Edit(...) again
+       // and cannot do this as the cursor is behind the inset and GetInset
+       // does not return the inset!
+       if (inset->IsTextInset()) {
+               if (cursor.par()->isRightToLeftPar(bview->buffer()->params))
+                       CursorRight(bview);
+               else
+                       CursorLeft(bview);
+       }
+#endif
 }