]> git.lyx.org Git - features.git/commitdiff
Reindent files with tab-stops (instead of 4 spaces). It is allowed to change
authorJürgen Vigna <jug@sad.it>
Mon, 2 Apr 2001 14:02:58 +0000 (14:02 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 2 Apr 2001 14:02:58 +0000 (14:02 +0000)
now the indent in files owned by myself to tabstops if I did miss some!
(but please set your tab-width to 4 ;)

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

po/POTFILES.in
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.C
src/insets/insetfoot.C
src/insets/insettext.C
src/insets/insettext.h
src/tabular.C
src/tabular.h

index d2d58428aacde6a913041eae134d61eae6b101d4..d5d6a47d63b731c1bf03be4610d8deeec52cdb59 100644 (file)
@@ -24,9 +24,9 @@ src/frontends/controllers/ControlInclude.C
 src/frontends/controllers/ControlPreamble.C
 src/frontends/controllers/ControlPrint.C
 src/frontends/controllers/ControlSearch.C
+src/frontends/controllers/ControlToc.C
 src/frontends/controllers/helper_funcs.C
 src/frontends/gnome/FormCitation.C
-src/frontends/gnome/FormCopyright.C
 src/frontends/gnome/FormError.C
 src/frontends/gnome/FormIndex.C
 src/frontends/gnome/FormPrint.C
index 74e8be1ab96e8e9f223b6783f70050370828aa11..a999b83d47ae137ffb0e4c4fe6c10a03e327f97a 100644 (file)
@@ -34,199 +34,198 @@ using std::max;
 InsetCollapsable::InsetCollapsable()
        : UpdatableInset()
 {
-    inset.setOwner(this);
-    collapsed = false;
-    label = "Label";
-    autocollapse = true;
-    inset.SetAutoBreakRows(true);
-    inset.SetDrawFrame(0, InsetText::ALWAYS);
-    inset.SetFrameColor(0, LColor::footnoteframe);
-    button_length = button_top_y = button_bottom_y = 0;
-    setInsetName("Collapsable");
-    widthCollapsed = oldWidth = 0;
-    need_update = FULL;
+       inset.setOwner(this);
+       collapsed = false;
+       label = "Label";
+       autocollapse = true;
+       inset.SetAutoBreakRows(true);
+       inset.SetDrawFrame(0, InsetText::ALWAYS);
+       inset.SetFrameColor(0, LColor::footnoteframe);
+       button_length = button_top_y = button_bottom_y = 0;
+       setInsetName("Collapsable");
+       widthCollapsed = oldWidth = 0;
+       need_update = FULL;
 }
 
 
 Inset * InsetCollapsable::Clone(Buffer const &) const
 {
-    InsetCollapsable * result = new InsetCollapsable();
-    result->inset.init(&inset);
-    result->inset.setOwner(result);
+       InsetCollapsable * result = new InsetCollapsable();
+       result->inset.init(&inset);
+       result->inset.setOwner(result);
 
-    result->collapsed = collapsed;
-    return result;
+       result->collapsed = collapsed;
+       return result;
 }
 
 
 bool InsetCollapsable::InsertInset(BufferView * bv, Inset * in)
 {
-    if (!InsertInsetAllowed(in)) {
-       lyxerr << "InsetCollapsable::InsertInset: "
-               "Unable to insert inset." << endl;
-       return false;
-    }
-    
-    return inset.InsertInset(bv, in);
+       if (!InsertInsetAllowed(in)) {
+               lyxerr << "InsetCollapsable::InsertInset: "
+                       "Unable to insert inset." << endl;
+               return false;
+       }
+       return inset.InsertInset(bv, in);
 }
 
 
 void InsetCollapsable::Write(Buffer const * buf, ostream & os) const
 {
-    os << "collapsed " << tostr(collapsed) << "\n";
-    inset.WriteParagraphData(buf, os);
+       os << "collapsed " << tostr(collapsed) << "\n";
+       inset.WriteParagraphData(buf, os);
 }
 
 
 
 void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
 {
-    if (lex.IsOK()) {
-       lex.next();
-        string const token = lex.GetString();
-       if (token == "collapsed") {
-           lex.next();
-           collapsed = lex.GetBool();
-       } else {
-               lyxerr << "InsetCollapsable::Read: Missing collapsed!"
-                      << endl;
+       if (lex.IsOK()) {
+               lex.next();
+               string const token = lex.GetString();
+               if (token == "collapsed") {
+                       lex.next();
+                       collapsed = lex.GetBool();
+               } else {
+                       lyxerr << "InsetCollapsable::Read: Missing collapsed!"
+                                  << endl;
+               }
        }
-    }
-    inset.Read(buf, lex);
+       inset.Read(buf, lex);
 }
 
 
 int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
 {
-    int width = 0;
-    int ascent = 0;
-    int descent = 0;
-    pain.buttonText(0, 0, label, labelfont, false, 
-                   width, ascent, descent);
-    return ascent;
+       int width = 0;
+       int ascent = 0;
+       int descent = 0;
+       pain.buttonText(0, 0, label, labelfont, false, 
+                                       width, ascent, descent);
+       return ascent;
 }
 
 
 int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
 {
-    int width = 0;
-    int ascent = 0;
-    int descent = 0;
-    pain.buttonText(0, 0, label, labelfont, false, 
-                   width, ascent, descent);
-    return descent;
+       int width = 0;
+       int ascent = 0;
+       int descent = 0;
+       pain.buttonText(0, 0, label, labelfont, false, 
+                                       width, ascent, descent);
+       return descent;
 }
 
 
 int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
 {
-    int width;
-    int ascent;
-    int descent;
-    pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label, labelfont, false,
-                   width, ascent, descent);
-    return width + (2*TEXT_TO_INSET_OFFSET);
+       int width;
+       int ascent;
+       int descent;
+       pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label, labelfont, false,
+                                       width, ascent, descent);
+       return width + (2*TEXT_TO_INSET_OFFSET);
 }
 
 
 int InsetCollapsable::ascent(BufferView * bv, LyXFont const & font) const
 {
-    return ascent_collapsed(bv->painter(), font);
+       return ascent_collapsed(bv->painter(), font);
 }
 
 
 int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
 {
-    if (collapsed) 
-       return descent_collapsed(bv->painter(), font);
+       if (collapsed) 
+               return descent_collapsed(bv->painter(), font);
 
-    return descent_collapsed(bv->painter(), font) + inset.descent(bv, font) +
-       inset.ascent(bv, font) + TEXT_TO_BOTTOM_OFFSET;
+       return descent_collapsed(bv->painter(), font) + inset.descent(bv, font) +
+               inset.ascent(bv, font) + TEXT_TO_BOTTOM_OFFSET;
 }
 
 
 int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
 {
-    if (collapsed) 
-       return widthCollapsed;
+       if (collapsed) 
+               return widthCollapsed;
 
-    return (inset.width(bv, font) > widthCollapsed) ?
-       inset.width(bv, font) : widthCollapsed;
+       return (inset.width(bv, font) > widthCollapsed) ?
+               inset.width(bv, font) : widthCollapsed;
 }
 
 
 void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &,
-                                     int baseline, float & x) const
+                                                                         int baseline, float & x) const
 {
-    int width = 0;
-    pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
-                   baseline, label, labelfont, true, width);
-    x += width + TEXT_TO_INSET_OFFSET;
+       int width = 0;
+       pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
+                                       baseline, label, labelfont, true, width);
+       x += width + TEXT_TO_INSET_OFFSET;
 }
 
 
 void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, 
-                           int baseline, float & x, bool cleared) const
+                                                       int baseline, float & x, bool cleared) const
 {
-    Painter & pain = bv->painter();
+       Painter & pain = bv->painter();
 
-    button_length = widthCollapsed;
-    button_top_y = -ascent(bv, f);
-    button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
+       button_length = widthCollapsed;
+       button_top_y = -ascent(bv, f);
+       button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
        descent_collapsed(pain, f);
-    if (collapsed) {
-       draw_collapsed(pain, f, baseline, x);
-       x += TEXT_TO_INSET_OFFSET;
-       return;
-    }
-
-    if (!cleared && ((inset.need_update == InsetText::FULL) ||
-                    (inset.need_update == InsetText::INIT) ||
-                    (top_x != int(x)) || (top_baseline != baseline))) {
-       int w =  owner() ? width(bv, f) : pain.paperWidth();
-       int h = ascent(bv, f) + descent(bv, f);
-       int tx = (needFullRow() && !owner()) ? 0 : int(x);
-       int ty = max(0, baseline - ascent(bv, f));
-       
-       if ((ty + h) > pain.paperHeight())
-           h = pain.paperHeight();
-       if ((top_x + w) > pain.paperWidth())
-           w = pain.paperWidth();
-       if (baseline < 0)
-           h += (baseline - ascent(bv, f));
-       pain.fillRectangle(tx, ty - 1, w, h + 2);
-       cleared = true;
-    }
-
-    top_x = int(x);
-    top_baseline = baseline;
-
-    float dummy = x;
-    int bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
-
-    draw_collapsed(pain, f, bl, dummy);
-    inset.draw(bv, f, 
-               bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
-               x, cleared);
-    need_update = NONE;
+       if (collapsed) {
+               draw_collapsed(pain, f, baseline, x);
+               x += TEXT_TO_INSET_OFFSET;
+               return;
+       }
+
+       if (!cleared && ((inset.need_update == InsetText::FULL) ||
+                                        (inset.need_update == InsetText::INIT) ||
+                                        (top_x != int(x)) || (top_baseline != baseline))) {
+               int w =  owner() ? width(bv, f) : pain.paperWidth();
+               int h = ascent(bv, f) + descent(bv, f);
+               int tx = (needFullRow() && !owner()) ? 0 : int(x);
+               int ty = max(0, baseline - ascent(bv, f));
+               
+               if ((ty + h) > pain.paperHeight())
+                       h = pain.paperHeight();
+               if ((top_x + w) > pain.paperWidth())
+                       w = pain.paperWidth();
+               if (baseline < 0)
+                       h += (baseline - ascent(bv, f));
+               pain.fillRectangle(tx, ty - 1, w, h + 2);
+               cleared = true;
+       }
+
+       top_x = int(x);
+       top_baseline = baseline;
+
+       float dummy = x;
+       int bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
+
+       draw_collapsed(pain, f, bl, dummy);
+       inset.draw(bv, f, 
+                          bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
+                          x, cleared);
+       need_update = NONE;
 }
 
 
 void InsetCollapsable::Edit(BufferView * bv, int xp, int yp, unsigned int button)
 {
-    UpdatableInset::Edit(bv, xp, yp, button);
-
-    if (collapsed && autocollapse) {
-       collapsed = false;
-       if (!bv->lockInset(this))
-           return;
-       bv->updateInset(this, false);
-       inset.Edit(bv, 0, 0, button);
-    } else if (!collapsed) {
-       if (!bv->lockInset(this))
-           return;
-       inset.Edit(bv, xp, yp+(top_baseline - inset.y()), button);
-    }
+       UpdatableInset::Edit(bv, xp, yp, button);
+
+       if (collapsed && autocollapse) {
+               collapsed = false;
+               if (!bv->lockInset(this))
+                       return;
+               bv->updateInset(this, false);
+               inset.Edit(bv, 0, 0, button);
+       } else if (!collapsed) {
+               if (!bv->lockInset(this))
+                       return;
+               inset.Edit(bv, xp, yp+(top_baseline - inset.y()), button);
+       }
 }
 
 
@@ -240,107 +239,107 @@ Inset::EDITABLE InsetCollapsable::Editable() const
 
 void InsetCollapsable::InsetUnlock(BufferView * bv)
 {
-    if (autocollapse) {
-       collapsed = true;
-    }
-    inset.InsetUnlock(bv);
-    bv->updateInset(this, false);
+       if (autocollapse) {
+               collapsed = true;
+       }
+       inset.InsetUnlock(bv);
+       bv->updateInset(this, false);
 }
 
 
 void InsetCollapsable::InsetButtonPress(BufferView * bv,int x,int y,int button)
 {
-    if (!collapsed && (y > button_bottom_y)) {
-       inset.InsetButtonPress(bv, x, y+(top_baseline - inset.y()), button);
-    }
+       if (!collapsed && (y > button_bottom_y)) {
+               inset.InsetButtonPress(bv, x, y+(top_baseline - inset.y()), button);
+       }
 }
 
 
 void InsetCollapsable::InsetButtonRelease(BufferView * bv,
                                          int x, int y, int button)
 {
-    if ((x >= 0)  && (x < button_length) &&
-       (y >= button_top_y) &&  (y <= button_bottom_y)) {
-       if (collapsed) {
-           collapsed = false;
-           inset.InsetButtonRelease(bv, 0, 0, button);
-           bv->updateInset(this, false);
-       } else {
-           collapsed = true;
-           bv->unlockInset(this);
-           bv->updateInset(this, false);
+       if ((x >= 0)  && (x < button_length) &&
+               (y >= button_top_y) &&  (y <= button_bottom_y)) {
+               if (collapsed) {
+                       collapsed = false;
+                       inset.InsetButtonRelease(bv, 0, 0, button);
+                       bv->updateInset(this, false);
+               } else {
+                       collapsed = true;
+                       bv->unlockInset(this);
+                       bv->updateInset(this, false);
+               }
+       } else if (!collapsed && (y > button_top_y)) {
+               inset.InsetButtonRelease(bv, x, y+(top_baseline-inset.y()), button);
        }
-    } else if (!collapsed && (y > button_top_y)) {
-       inset.InsetButtonRelease(bv, x, y+(top_baseline-inset.y()), button);
-    }
 }
 
 
 void InsetCollapsable::InsetMotionNotify(BufferView * bv,
                                         int x, int y, int state)
 {
-    if (x > button_bottom_y) {
-       inset.InsetMotionNotify(bv, x, y+(top_baseline - inset.y()), state);
-    }
+       if (x > button_bottom_y) {
+               inset.InsetMotionNotify(bv, x, y+(top_baseline - inset.y()), state);
+       }
 }
 
 
 void InsetCollapsable::InsetKeyPress(XKeyEvent * xke)
 {
-    inset.InsetKeyPress(xke);
+       inset.InsetKeyPress(xke);
 }
 
 
 int InsetCollapsable::Latex(Buffer const * buf, ostream & os,
-                           bool fragile, bool free_spc) const
+                               bool fragile, bool free_spc) const
 {
-    return inset.Latex(buf, os, fragile, free_spc);
+       return inset.Latex(buf, os, fragile, free_spc);
 }
 
 
 int InsetCollapsable::getMaxWidth(BufferView * bv,
                                  UpdatableInset const * inset) const
 {
-    int const w = UpdatableInset::getMaxWidth(bv, inset);
+       int const w = UpdatableInset::getMaxWidth(bv, inset);
 
-    if (w < 0) {
-       // What does a negative max width signify? (Lgb)
-       // Use the max width of the draw-area (Jug)
-       return w;
-    }
-    // should be at least 30 pixels !!!
-    return max(30, w - widthCollapsed);
+       if (w < 0) {
+               // What does a negative max width signify? (Lgb)
+               // Use the max width of the draw-area (Jug)
+               return w;
+       }
+       // should be at least 30 pixels !!!
+       return max(30, w - widthCollapsed);
 }
 
 
 void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
-                             bool reinit)
+                                 bool reinit)
 {
-    if (reinit) {
-       need_update = FULL;
-       if (owner())
-           owner()->update(bv, font, true);
-       return;
-    }
-    if (!widthCollapsed) {
-       widthCollapsed = width_collapsed(bv->painter(), font);
-       inset.resizeLyXText(bv);
-       need_update = FULL;
-       if (owner()) {
-               owner()->update(bv, font);
+       if (reinit) {
+               need_update = FULL;
+               if (owner())
+                       owner()->update(bv, font, true);
                return;
        }
-    }
-    if (oldWidth != width(bv, font)) {
-       oldWidth = width(bv, font);
-       inset.resizeLyXText(bv);
-       need_update = FULL;
-       if (owner()) {
-               owner()->update(bv, font);
-               return;
+       if (!widthCollapsed) {
+               widthCollapsed = width_collapsed(bv->painter(), font);
+               inset.resizeLyXText(bv);
+               need_update = FULL;
+               if (owner()) {
+                       owner()->update(bv, font);
+                       return;
+               }
        }
-    }
-    inset.update(bv, font);
+       if (oldWidth != width(bv, font)) {
+               oldWidth = width(bv, font);
+               inset.resizeLyXText(bv);
+               need_update = FULL;
+               if (owner()) {
+                       owner()->update(bv, font);
+                       return;
+               }
+       }
+       inset.update(bv, font);
 }
 
 
@@ -348,110 +347,110 @@ UpdatableInset::RESULT
 InsetCollapsable::LocalDispatch(BufferView * bv, kb_action action,
                                string const & arg)
 {
-    UpdatableInset::RESULT result = inset.LocalDispatch(bv, action, arg);
-    if (result == FINISHED)
-        bv->unlockInset(this);
-    return result;
+       UpdatableInset::RESULT result = inset.LocalDispatch(bv, action, arg);
+       if (result == FINISHED)
+               bv->unlockInset(this);
+       return result;
 }
 
 
 bool InsetCollapsable::LockInsetInInset(BufferView * bv, UpdatableInset * in)
 {
-    if (&inset == in)
-       return true;
-    return inset.LockInsetInInset(bv, in);
+       if (&inset == in)
+               return true;
+       return inset.LockInsetInInset(bv, in);
 }
 
 
 bool InsetCollapsable::UnlockInsetInInset(BufferView * bv, UpdatableInset * in,
                                          bool lr)
 {
-    if (&inset == in) {
-       bv->unlockInset(this);
-       return true;
-    }
-    return inset.UnlockInsetInInset(bv, in, lr);
+       if (&inset == in) {
+               bv->unlockInset(this);
+               return true;
+       }
+       return inset.UnlockInsetInInset(bv, in, lr);
 }
 
 
 bool InsetCollapsable::UpdateInsetInInset(BufferView * bv, Inset *in)
 {
-    if (&inset == in)
-       return true;
-    return inset.UpdateInsetInInset(bv, in);
+       if (&inset == in)
+               return true;
+       return inset.UpdateInsetInInset(bv, in);
 }
 
 
 unsigned int InsetCollapsable::InsetInInsetY()
 {
-    return inset.InsetInInsetY() - (top_baseline - inset.y());
+       return inset.InsetInInsetY() - (top_baseline - inset.y());
 }
 
 
 void InsetCollapsable::Validate(LaTeXFeatures & features) const
 {
-    inset.Validate(features);
+       inset.Validate(features);
 }
 
 
 void InsetCollapsable::GetCursorPos(BufferView * bv, int & x, int & y) const
 {
-    inset.GetCursorPos(bv, x , y);
+       inset.GetCursorPos(bv, x , y);
 }
 
 
 void InsetCollapsable::ToggleInsetCursor(BufferView * bv)
 {
-    inset.ToggleInsetCursor(bv);
+       inset.ToggleInsetCursor(bv);
 }
 
 
 UpdatableInset * InsetCollapsable::GetLockingInset()
 {
-    UpdatableInset * in = inset.GetLockingInset();
-    if (&inset == in)
-       return this;
-    return in;
+       UpdatableInset * in = inset.GetLockingInset();
+       if (&inset == in)
+               return this;
+       return in;
 }
 
 
 UpdatableInset * InsetCollapsable::GetFirstLockingInsetOfType(Inset::Code c)
 {
-    if (c == LyxCode())
-       return this;
-    return inset.GetFirstLockingInsetOfType(c);
+       if (c == LyxCode())
+               return this;
+       return inset.GetFirstLockingInsetOfType(c);
 }
 
 
 void InsetCollapsable::SetFont(BufferView * bv,
-                              LyXFont const & font, bool toggleall)
+                                                          LyXFont const & font, bool toggleall)
 {
-    inset.SetFont(bv, font, toggleall);
+       inset.SetFont(bv, font, toggleall);
 }
 
 
 bool InsetCollapsable::doClearArea() const
 {
-    return inset.doClearArea();
+       return inset.doClearArea();
 }
 
 
 LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
-                                      bool const recursive) const
+                                          bool const recursive) const
 {
-    return inset.getLyXText(bv, recursive);
+       return inset.getLyXText(bv, recursive);
 }
 
 
 void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
 {
-    inset.deleteLyXText(bv, recursive);
+       inset.deleteLyXText(bv, recursive);
 }
 
 
 void InsetCollapsable::resizeLyXText(BufferView * bv) const
 {
-    inset.resizeLyXText(bv);
-    LyXFont font(LyXFont::ALL_SANE);
-    oldWidth = width(bv, font);
+       inset.resizeLyXText(bv);
+       LyXFont font(LyXFont::ALL_SANE);
+       oldWidth = width(bv, font);
 }
index f418d6ad4ad06f6f1ca60425234829ce851a61ca..ce24297951cda918cee68cde4521ab805c575854 100644 (file)
@@ -33,146 +33,146 @@ class LyXText;
 */
 class InsetCollapsable : public UpdatableInset {
 public:
-    ///
-    enum UpdateCodes {
+       ///
+       enum UpdateCodes {
        NONE = 0,
        FULL
-    };
-    ///
-    static int const TEXT_TO_TOP_OFFSET = 2;
-    ///
-    static int const TEXT_TO_BOTTOM_OFFSET = 2;
-    ///
-    InsetCollapsable();
-    ///
-    Inset * Clone(Buffer const &) const;
-    ///
-    void Read(Buffer const *, LyXLex &);
-    ///
-    void Write(Buffer const *, std::ostream &) const;
-    ///
-    int ascent(BufferView *, LyXFont const &) const;
-    ///
-    int descent(BufferView *, LyXFont const &) const;
-    ///
-    int width(BufferView *, LyXFont const & f) const;
-    ///
-    void draw(BufferView *, const LyXFont &, int , float &, bool) const;
-    ///
-    void update(BufferView *, LyXFont const &, bool =false); 
-    ///
-    void Edit(BufferView *, int, int, unsigned int);
-    ///
-    EDITABLE Editable() const;
-    ///
-    bool InsertInset(BufferView *, Inset * inset);
-    ///
-    bool IsTextInset() const { return true; }
-    ///
-    bool doClearArea() const;
-    ///
-    void InsetUnlock(BufferView *);
-    ///
-    bool needFullRow() const { return !collapsed; }
-    ///
-    bool LockInsetInInset(BufferView *, UpdatableInset *);
-    ///
-    bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
-    ///
-    bool UpdateInsetInInset(BufferView *, Inset *);
-    ///
-    unsigned int InsetInInsetY();
-    ///
-    void InsetButtonRelease(BufferView *, int, int, int);
-    ///
-    void InsetButtonPress(BufferView *, int, int, int);
-    ///
-    void InsetMotionNotify(BufferView *, int, int, int);
-    ///
-    void InsetKeyPress(XKeyEvent *);
-    ///
-    UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
+       };
+       ///
+       static int const TEXT_TO_TOP_OFFSET = 2;
+       ///
+       static int const TEXT_TO_BOTTOM_OFFSET = 2;
+       ///
+       InsetCollapsable();
+       ///
+       Inset * Clone(Buffer const &) const;
+       ///
+       void Read(Buffer const *, LyXLex &);
+       ///
+       void Write(Buffer const *, std::ostream &) const;
+       ///
+       int ascent(BufferView *, LyXFont const &) const;
+       ///
+       int descent(BufferView *, LyXFont const &) const;
+       ///
+       int width(BufferView *, LyXFont const & f) const;
+       ///
+       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+       ///
+       void update(BufferView *, LyXFont const &, bool =false); 
+       ///
+       void Edit(BufferView *, int, int, unsigned int);
+       ///
+       EDITABLE Editable() const;
+       ///
+       bool InsertInset(BufferView *, Inset * inset);
+       ///
+       bool IsTextInset() const { return true; }
+       ///
+       bool doClearArea() const;
+       ///
+       void InsetUnlock(BufferView *);
+       ///
+       bool needFullRow() const { return !collapsed; }
+       ///
+       bool LockInsetInInset(BufferView *, UpdatableInset *);
+       ///
+       bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
+       ///
+       bool UpdateInsetInInset(BufferView *, Inset *);
+       ///
+       unsigned int InsetInInsetY();
+       ///
+       void InsetButtonRelease(BufferView *, int, int, int);
+       ///
+       void InsetButtonPress(BufferView *, int, int, int);
+       ///
+       void InsetMotionNotify(BufferView *, int, int, int);
+       ///
+       void InsetKeyPress(XKeyEvent *);
+       ///
+       UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
                                         string const &);
-    ///
-    int Latex(Buffer const *, std::ostream &,
-             bool fragile, bool free_spc) const;
-    ///
-    int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
-    ///
-    int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
-    ///
-    int DocBook(Buffer const *, std::ostream &) const { return 0; }
-    ///
-    void Validate(LaTeXFeatures & features) const;
-    ///
-    void GetCursorPos(BufferView *, int & x, int & y) const;
-    ///
-    void ToggleInsetCursor(BufferView *);
-    ///
-    UpdatableInset * GetLockingInset();
-    ///
-    UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
-    ///
-    void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
-    ///
-    void setLabel(string const & l) { label = l; }
-    ///
-    void setLabelFont(LyXFont & f) { labelfont = f; }
-    ///
-    void setAutoCollapse(bool f) { autocollapse = f; }
-    ///
-    int getMaxWidth(BufferView *, UpdatableInset const *) const;
-    ///
-    LyXText * getLyXText(BufferView const *, bool const recursive) const;
-    ///
-    void deleteLyXText(BufferView *, bool recursive=true) const;
-    ///
-    void resizeLyXText(BufferView *) const;
+       ///
+       int Latex(Buffer const *, std::ostream &,
+                 bool fragile, bool free_spc) const;
+       ///
+       int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
+       ///
+       int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
+       ///
+       int DocBook(Buffer const *, std::ostream &) const { return 0; }
+       ///
+       void Validate(LaTeXFeatures & features) const;
+       ///
+       void GetCursorPos(BufferView *, int & x, int & y) const;
+       ///
+       void ToggleInsetCursor(BufferView *);
+       ///
+       UpdatableInset * GetLockingInset();
+       ///
+       UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
+       ///
+       void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+       ///
+       void setLabel(string const & l) { label = l; }
+       ///
+       void setLabelFont(LyXFont & f) { labelfont = f; }
+       ///
+       void setAutoCollapse(bool f) { autocollapse = f; }
+       ///
+       int getMaxWidth(BufferView *, UpdatableInset const *) const;
+       ///
+       LyXText * getLyXText(BufferView const *, bool const recursive) const;
+       ///
+       void deleteLyXText(BufferView *, bool recursive=true) const;
+       ///
+       void resizeLyXText(BufferView *) const;
 
 protected:
-    ///
-    int ascent_collapsed(Painter &, LyXFont const &) const;
-    ///
-    int descent_collapsed(Painter &, LyXFont const &) const;
-    ///
-    int width_collapsed(Painter &, LyXFont const & f) const;
-    ///
-    void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
-    ///
-    int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
-    
-    ///
-    bool collapsed;
-    ///
-    LColor::color framecolor;
-    ///
-    LyXFont labelfont;
+       ///
+       int ascent_collapsed(Painter &, LyXFont const &) const;
+       ///
+       int descent_collapsed(Painter &, LyXFont const &) const;
+       ///
+       int width_collapsed(Painter &, LyXFont const & f) const;
+       ///
+       void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
+       ///
+       int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
+       
+       ///
+       bool collapsed;
+       ///
+       LColor::color framecolor;
+       ///
+       LyXFont labelfont;
 #ifdef NEW_INSETS
 public:
 #endif
-    ///
-    InsetText inset;
+       ///
+       InsetText inset;
 protected:
-    ///
-    mutable int button_length;
-    ///
-    mutable int button_top_y;
-    ///
-    mutable int button_bottom_y;
+       ///
+       mutable int button_length;
+       ///
+       mutable int button_top_y;
+       ///
+       mutable int button_bottom_y;
 
 private:
-    ///
-    string label;
-    ///
-    bool autocollapse;
-    ///
-    int widthCollapsed;
-    ///
-    mutable int oldWidth;
-    ///
-    mutable int topx;
-    mutable int topbaseline;
-    mutable UpdateCodes need_update;
+       ///
+       string label;
+       ///
+       bool autocollapse;
+       ///
+       int widthCollapsed;
+       ///
+       mutable int oldWidth;
+       ///
+       mutable int topx;
+       mutable int topbaseline;
+       mutable UpdateCodes need_update;
 };
 
 #endif
index d23eb7b1b2dc8c9f8a103fa624aa0d1eecb2120d..b725fbf19234f9fdb70971452f56ea275f6adf9e 100644 (file)
@@ -25,52 +25,52 @@ using std::ostream;
 
 InsetERT::InsetERT() : InsetCollapsable()
 {
-    setLabel(_("ERT"));
-    LyXFont font(LyXFont::ALL_SANE);
-    font.setLatex (LyXFont::ON);
-    labelfont = LyXFont(LyXFont::ALL_SANE);
-    labelfont.decSize();
-    labelfont.decSize();
-    labelfont.setColor(LColor::ert);
-    setAutoCollapse(false);
-    setInsetName("ERT");
+       setLabel(_("ERT"));
+       LyXFont font(LyXFont::ALL_SANE);
+       font.setLatex (LyXFont::ON);
+       labelfont = LyXFont(LyXFont::ALL_SANE);
+       labelfont.decSize();
+       labelfont.decSize();
+       labelfont.setColor(LColor::ert);
+       setAutoCollapse(false);
+       setInsetName("ERT");
 }
 
 
 void InsetERT::Write(Buffer const * buf, ostream & os) const 
 {
-    os << getInsetName() << "\n";
-    InsetCollapsable::Write(buf, os);
+       os << getInsetName() << "\n";
+       InsetCollapsable::Write(buf, os);
 }
 
 
 Inset * InsetERT::Clone(Buffer const &) const
 {
-    InsetERT * result = new InsetERT;
-    result->inset.init(&inset);
-
-    result->collapsed = collapsed;
-    return result;
+       InsetERT * result = new InsetERT;
+       result->inset.init(&inset);
+       
+       result->collapsed = collapsed;
+       return result;
 }
 
 
 string const InsetERT::EditMessage() const 
 {
-    return _("Opened ERT Inset");
+       return _("Opened ERT Inset");
 }
 
 
 void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
 {
-    WriteAlert(_("Impossible Operation!"),
-              _("Not permitted to change font-types inside ERT-insets!"),
-              _("Sorry."));
+       WriteAlert(_("Impossible Operation!"),
+                          _("Not permitted to change font-types inside ERT-insets!"),
+                          _("Sorry."));
 }
 
 
 void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
 {
-    InsetCollapsable::Edit(bv, x, y, button);
-    LyXFont font(LyXFont::ALL_SANE);
-    font.setLatex (LyXFont::ON);
+       InsetCollapsable::Edit(bv, x, y, button);
+       LyXFont font(LyXFont::ALL_SANE);
+       font.setLatex (LyXFont::ON);
 }
index 43f2e17fca06bd1b320d03ac0af93ee72f9e2f2c..9f65184713e2722bbc96dd367731234d9442b5a7 100644 (file)
@@ -29,44 +29,44 @@ using std::ostream;
 InsetFoot::InsetFoot()
        : InsetFootlike()
 {
-    setLabel(_("foot"));
-    setInsetName("Foot");
+       setLabel(_("foot"));
+       setInsetName("Foot");
 }
 
 
 Inset * InsetFoot::Clone(Buffer const &) const
 {
-    InsetFoot * result = new InsetFoot;
-    result->inset.init(&inset);
+       InsetFoot * result = new InsetFoot;
+       result->inset.init(&inset);
 
-    result->collapsed = collapsed;
-    return result;
+       result->collapsed = collapsed;
+       return result;
 }
 
 
 string const InsetFoot::EditMessage() const
 {
-    return _("Opened Footnote Inset");
+       return _("Opened Footnote Inset");
 }
 
 
 int InsetFoot::Latex(Buffer const * buf,
                     ostream & os, bool fragile, bool fp) const
 {
-    os << "\\footnote{%\n";
-    
-    int const i = inset.Latex(buf, os, fragile, fp);
-    os << "}%\n";
-    
-    return i + 2;
+       os << "\\footnote{%\n";
+       
+       int const i = inset.Latex(buf, os, fragile, fp);
+       os << "}%\n";
+       
+       return i + 2;
 }
 
 
 bool InsetFoot::InsertInsetAllowed(Inset * in) const
 {
-    if ((in->LyxCode() == Inset::FOOT_CODE) ||
-       (in->LyxCode() == Inset::MARGIN_CODE)) {
-       return false;
-    }
-    return true;
+       if ((in->LyxCode() == Inset::FOOT_CODE) ||
+               (in->LyxCode() == Inset::MARGIN_CODE)) {
+               return false;
+       }
+       return true;
 }
index 1fdad5dc02065a0836368eb1e76063e1339b052c..6ec23b24d5eb782a82224f1ab9f53a2cb95b721c 100644 (file)
@@ -60,326 +60,326 @@ extern int greek_kb_flag;
 
 InsetText::InsetText()
 {
-    par = new LyXParagraph();
-    init();
+       par = new LyXParagraph();
+       init();
 }
 
 
 InsetText::InsetText(InsetText const & ins)
        : UpdatableInset()
 {
-    par = 0;
-    init(&ins);
-    autoBreakRows = ins.autoBreakRows;
+       par = 0;
+       init(&ins);
+       autoBreakRows = ins.autoBreakRows;
 }
 
 
 InsetText & InsetText::operator=(InsetText const & it)
 {
-    init(&it);
-    autoBreakRows = it.autoBreakRows;
-    return * this;
+       init(&it);
+       autoBreakRows = it.autoBreakRows;
+       return * this;
 }
 
 
 void InsetText::init(InsetText const * ins)
 {
-    top_y = 0;
-    last_width = 0;
-    last_height = 0;
-    insetAscent = 0;
-    insetDescent = 0;
-    insetWidth = 0;
-    the_locking_inset = 0;
-    cursor_visible = false;
-    interline_space = 1;
-    no_selection = false;
-    need_update = INIT;
-    drawTextXOffset = 0;
-    drawTextYOffset = 0;
-    autoBreakRows = false;
-    drawFrame = NEVER;
-    xpos = 0.0;
-    if (ins) {
+       top_y = 0;
+       last_width = 0;
+       last_height = 0;
+       insetAscent = 0;
+       insetDescent = 0;
+       insetWidth = 0;
+       the_locking_inset = 0;
+       cursor_visible = false;
+       interline_space = 1;
+       no_selection = false;
+       need_update = INIT;
+       drawTextXOffset = 0;
+       drawTextYOffset = 0;
+       autoBreakRows = false;
+       drawFrame = NEVER;
+       xpos = 0.0;
+       if (ins) {
        SetParagraphData(ins->par);
        autoBreakRows = ins->autoBreakRows;
        drawFrame = ins->drawFrame;
-    }
-    par->SetInsetOwner(this);
-    frame_color = LColor::insetframe;
-    locked = false;
-    old_par = 0;
-    last_drawn_width = -1;
+       }
+       par->SetInsetOwner(this);
+       frame_color = LColor::insetframe;
+       locked = false;
+       old_par = 0;
+       last_drawn_width = -1;
 }
 
 
 InsetText::~InsetText()
 {
-    // delete all instances of LyXText before deleting the paragraps used
-    // by it.
-    for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
+       // delete all instances of LyXText before deleting the paragraps used
+       // by it.
+       for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
        delete (*cit).second;
        (*cit).second = 0;
-    }
+       }
 #ifndef NEW_INSETS
-    LyXParagraph * p = par->next_;
-    delete par;
-    while(p) {
+       LyXParagraph * p = par->next_;
+       delete par;
+       while(p) {
        par = p;
        p = p->next_;
        delete par;
-    }
+       }
 #else
-    LyXParagraph * p = par->next();
-    delete par;
-    while(p) {
+       LyXParagraph * p = par->next();
+       delete par;
+       while(p) {
        par = p;
        p = p->next();
        delete par;
-    }
+       }
 #endif
 }
 
 
 void InsetText::clear()
 {
-    // delete all instances of LyXText before deleting the paragraps used
-    // by it.
-    for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
-       delete (*cit).second;
-       (*cit).second = 0;
-    }
+       // delete all instances of LyXText before deleting the paragraps used
+       // by it.
+       for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
+               delete (*cit).second;
+               (*cit).second = 0;
+       }
 #ifndef NEW_INSETS
-    LyXParagraph * p = par->next_;
-    delete par;
-    while(p) {
-       par = p;
-       p = p->next_;
+       LyXParagraph * p = par->next_;
        delete par;
-    }
+       while(p) {
+               par = p;
+               p = p->next_;
+               delete par;
+       }
 #else
-    LyXParagraph * p = par->next();
-    delete par;
-    while(p) {
-       par = p;
-       p = p->next();
+       LyXParagraph * p = par->next();
        delete par;
-    }
+       while(p) {
+               par = p;
+               p = p->next();
+               delete par;
+       }
 #endif
-    par = new LyXParagraph();
+       par = new LyXParagraph();
 }
 
 
 Inset * InsetText::Clone(Buffer const &) const
 {
-    InsetText * t = new InsetText(*this);
-    return t;
+       InsetText * t = new InsetText(*this);
+       return t;
 }
 
 
 void InsetText::Write(Buffer const * buf, ostream & os) const
 {
-    os << "Text\n";
-    WriteParagraphData(buf, os);
+       os << "Text\n";
+       WriteParagraphData(buf, os);
 }
 
 
 void InsetText::WriteParagraphData(Buffer const * buf, ostream & os) const
 {
-    par->writeFile(buf, os, buf->params, 0, 0);
+       par->writeFile(buf, os, buf->params, 0, 0);
 }
 
 
 void InsetText::Read(Buffer const * buf, LyXLex & lex)
 {
-    string token;
-    int pos = 0;
-    LyXParagraph * return_par = 0;
-    char depth = 0; // signed or unsigned?
+       string token;
+       int pos = 0;
+       LyXParagraph * return_par = 0;
+       char depth = 0; // signed or unsigned?
 #ifndef NEW_INSETS
-    LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
-    LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
+       LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
+       LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
 #endif
-    LyXFont font(LyXFont::ALL_INHERIT);
+       LyXFont font(LyXFont::ALL_INHERIT);
 
-    // delete all instances of LyXText before deleting the paragraps used
-    // by it.
-    for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
-       delete (*cit).second;
-       (*cit).second = 0;
-    }
+       // delete all instances of LyXText before deleting the paragraps used
+       // by it.
+       for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
+               delete (*cit).second;
+               (*cit).second = 0;
+       }
 
 #ifndef NEW_INSETS
-    LyXParagraph * p = par->next_;
-    delete par;
-    while(p) {
-       par = p;
-       p = p->next_;
+       LyXParagraph * p = par->next_;
        delete par;
-    }
+       while(p) {
+               par = p;
+               p = p->next_;
+               delete par;
+       }
 #else
-    LyXParagraph * p = par->next();
-    delete par;
-    while(p) {
-       par = p;
-       p = p->next();
+       LyXParagraph * p = par->next();
        delete par;
-    }
+       while(p) {
+               par = p;
+               p = p->next();
+               delete par;
+       }
 #endif
-    par = new LyXParagraph;
-    while (lex.IsOK()) {
-        lex.nextToken();
-        token = lex.GetString();
-        if (token.empty())
-            continue;
-       if (token == "\\end_inset")
-           break;
-       if (const_cast<Buffer*>(buf)->
-           parseSingleLyXformat2Token(lex, par, return_par,token, pos, depth,
-                                      font
+       par = new LyXParagraph;
+       while (lex.IsOK()) {
+               lex.nextToken();
+               token = lex.GetString();
+               if (token.empty())
+                       continue;
+               if (token == "\\end_inset")
+                       break;
+               if (const_cast<Buffer*>(buf)->
+                       parseSingleLyXformat2Token(lex, par, return_par,token, pos, depth,
+                                                                          font
 #ifndef NEW_INSETS
-                                      , footnoteflag, footnotekind
+                                                                          , footnoteflag, footnotekind
 #endif
-                                      ))
-       {
-           // the_end read this should NEVER happen
-           lex.printError("\\the_end read in inset! Error in document!");
-           return;
-       }
-    }
-    if (!return_par)
-           return_par = par;
-    par = return_par;
-    while(return_par) {
-       return_par->SetInsetOwner(this);
+                                                                          ))
+               {
+                       // the_end read this should NEVER happen
+                       lex.printError("\\the_end read in inset! Error in document!");
+                       return;
+               }
+       }
+       if (!return_par)
+               return_par = par;
+       par = return_par;
+       while(return_par) {
+               return_par->SetInsetOwner(this);
 #ifndef NEW_INSETS
-       return_par = return_par->next_;
+               return_par = return_par->next_;
 #else
-       return_par = return_par->next();
+               return_par = return_par->next();
 #endif
-    }
-    
-    if (token != "\\end_inset") {
-        lex.printError("Missing \\end_inset at this point. "
-                       "Read: `$$Token'");
-    }
-    need_update = INIT;
+       }
+       
+       if (token != "\\end_inset") {
+               lex.printError("Missing \\end_inset at this point. "
+                                          "Read: `$$Token'");
+       }
+       need_update = INIT;
 }
 
 
 int InsetText::ascent(BufferView * bv, LyXFont const &) const
 {
-    int y_temp = 0;
-    Row * row = TEXT(bv)->GetRowNearY(y_temp);
-    insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
-    return insetAscent;
+       int y_temp = 0;
+       Row * row = TEXT(bv)->GetRowNearY(y_temp);
+       insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
+       return insetAscent;
 }
 
 
 int InsetText::descent(BufferView * bv, LyXFont const &) const
 {
-    int y_temp = 0;
-    Row * row = TEXT(bv)->GetRowNearY(y_temp);
-    insetDescent = TEXT(bv)->height - row->ascent_of_text() +
+       int y_temp = 0;
+       Row * row = TEXT(bv)->GetRowNearY(y_temp);
+       insetDescent = TEXT(bv)->height - row->ascent_of_text() +
        TEXT_TO_INSET_OFFSET;
-    return insetDescent;
+       return insetDescent;
 }
 
 
 int InsetText::width(BufferView * bv, LyXFont const &) const
 {
-    insetWidth = max(textWidth(bv),
-                    (int)TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET));
-    return insetWidth;
+       insetWidth = max(textWidth(bv),
+                        (int)TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET));
+       return insetWidth;
 }
 
 
 int InsetText::textWidth(BufferView * bv) const
 {
-    int const w = getMaxWidth(bv, this);
-    return w;
+       int const w = getMaxWidth(bv, this);
+       return w;
 }
 
 
 void InsetText::draw(BufferView * bv, LyXFont const & f,
-                    int baseline, float & x, bool cleared) const
+                        int baseline, float & x, bool cleared) const
 {
-    Painter & pain = bv->painter();
+       Painter & pain = bv->painter();
 
-    // no draw is necessary !!!
-    if ((drawFrame == LOCKED) && !locked && !par->size()) {
-       if (!cleared && (need_update & CLEAR_FRAME)) {
-           pain.rectangle(top_x + 1, baseline - insetAscent + 1,
-                          width(bv, f) - 1,
-                          insetAscent + insetDescent - 1,
-                          LColor::background);
+       // no draw is necessary !!!
+       if ((drawFrame == LOCKED) && !locked && !par->size()) {
+               if (!cleared && (need_update & CLEAR_FRAME)) {
+                       pain.rectangle(top_x + 1, baseline - insetAscent + 1,
+                                                  width(bv, f) - 1,
+                                                  insetAscent + insetDescent - 1,
+                                                  LColor::background);
+               }
+               top_x = int(x);
+               top_baseline = baseline;
+               x += width(bv, f);
+               need_update = NONE;
+               return;
        }
-       top_x = int(x);
-       top_baseline = baseline;
-       x += width(bv, f);
-       need_update = NONE;
-       return;
-    }
-
-    xpos = x;
-    UpdatableInset::draw(bv, f, baseline, x, cleared);
-
-    // update insetWidth and insetHeight with dummy calls
-    (void)ascent(bv, f);
-    (void)descent(bv, f);
-    (void)width(bv, f);
-
-    // if top_x differs we have a rule down and we don't have to clear anything
-    if (!cleared && (top_x == int(x)) &&
-       ((need_update==INIT)||(need_update==FULL)||(top_baseline!=baseline)||
-        (last_drawn_width!=insetWidth)))
-    {
-       int w =  insetWidth;
-       int h = insetAscent + insetDescent;
-       int ty = baseline - insetAscent;
+
+       xpos = x;
+       UpdatableInset::draw(bv, f, baseline, x, cleared);
+
+       // update insetWidth and insetHeight with dummy calls
+       (void)ascent(bv, f);
+       (void)descent(bv, f);
+       (void)width(bv, f);
+
+       // if top_x differs we have a rule down and we don't have to clear anything
+       if (!cleared && (top_x == int(x)) &&
+               ((need_update==INIT)||(need_update==FULL)||(top_baseline!=baseline) ||
+                (last_drawn_width!=insetWidth)))
+       {
+               int w =  insetWidth;
+               int h = insetAscent + insetDescent;
+               int ty = baseline - insetAscent;
        
-       if (ty < 0) {
-           h += ty;
-           ty = 0;
-       }
-       if ((ty + h) > pain.paperHeight())
-           h = pain.paperHeight();
-       if ((top_x + drawTextXOffset + w) > pain.paperWidth())
-           w = pain.paperWidth();
-       pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
-       cleared = true;
-       need_update = FULL;
-    }
-    if (!cleared && (need_update == NONE))
-       return;
+               if (ty < 0) {
+                       h += ty;
+                       ty = 0;
+               }
+               if ((ty + h) > pain.paperHeight())
+                       h = pain.paperHeight();
+               if ((top_x + drawTextXOffset + w) > pain.paperWidth())
+                       w = pain.paperWidth();
+               pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
+               cleared = true;
+               need_update = FULL;
+       }
+       if (!cleared && (need_update == NONE))
+               return;
+
+       if (top_x != int(x)) {
+               need_update = INIT;
+               top_x = int(x);
+               bv->text->status = LyXText::CHANGED_IN_DRAW;
+               return;
+       }
+       if (cleared || (last_drawn_width != insetWidth)) {
+               need_update |= FULL;
+               last_drawn_width = insetWidth;
+       }
 
-    if (top_x != int(x)) {
-       need_update = INIT;
-       top_x = int(x);
-       bv->text->status = LyXText::CHANGED_IN_DRAW;
-       return;
-    }
-    if (cleared || (last_drawn_width != insetWidth)) {
-       need_update |= FULL;
-       last_drawn_width = insetWidth;
-    }
-
-    top_baseline = baseline;
-    top_y = baseline - ascent(bv, f);
-    last_width = width(bv, f);
-    last_height = ascent(bv, f) + descent(bv, f);
-
-    if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
-       inset_x = cx(bv) - top_x + drawTextXOffset;
-       inset_y = cy(bv) + drawTextYOffset;
-    }
-    if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection) {
-       x += width(bv, f);
-       need_update = NONE;
-       return;
-    }
-    x += TEXT_TO_INSET_OFFSET;
-    {
+       top_baseline = baseline;
+       top_y = baseline - ascent(bv, f);
+       last_width = width(bv, f);
+       last_height = ascent(bv, f) + descent(bv, f);
+
+       if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
+       }
+       if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection) {
+               x += width(bv, f);
+               need_update = NONE;
+               return;
+       }
+       x += TEXT_TO_INSET_OFFSET;
+       {
        int y = 0;
        Row * row = TEXT(bv)->GetRowNearY(y);
        int y_offset = baseline - row->ascent_of_text();
@@ -387,1253 +387,1248 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        int first = 0;
        y = y_offset;
        while ((row != 0) && ((y+row->height()) <= 0)) {
-           y += row->height();
-           first += row->height();
-           row = row->next();
+               y += row->height();
+               first += row->height();
+               row = row->next();
        }
        if (y_offset < 0)
-           y_offset = y;
+               y_offset = y;
        TEXT(bv)->first = first;
        if (cleared) { // (need_update&FULL) || (need_update&INIT)
-           int yf = y_offset;
-           y = 0;
-           while ((row != 0) && (yf < ph)) {
-                   TEXT(bv)->GetVisibleRow(bv, y+y_offset, int(x), row,
-                                           y+first, cleared);
+               int yf = y_offset;
+               y = 0;
+               while ((row != 0) && (yf < ph)) {
+                       TEXT(bv)->GetVisibleRow(bv, y+y_offset, int(x), row,
+                                               y+first, cleared);
                y += row->height();
                yf += row->height();
                row = row->next();
-           }
+               }
        } else if (!locked) {
-           if (need_update & CURSOR) {
-               bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
-               TEXT(bv)->ClearSelection(bv);
-               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-           }
-           bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
+               if (need_update & CURSOR) {
+                       bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
+                       TEXT(bv)->ClearSelection(bv);
+                       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+               }
+               bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
        } else {
-           locked = false;
-           if (need_update & SELECTION)
-               bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x));
-           else if (need_update & CURSOR) {
-               bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
-               TEXT(bv)->ClearSelection(bv);
-               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-           }
-           bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
-           locked = true;
-       }
-    }
-    TEXT(bv)->refresh_y = 0;
-    TEXT(bv)->status = LyXText::UNCHANGED;
-    if ((need_update != CURSOR_PAR) &&
-       ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)))
-    {
-           pain.rectangle(top_x + 1, baseline - insetAscent + 1,
-                          width(bv, f) - 1, insetAscent + insetDescent - 1,
-                          frame_color);
-    } else if (need_update & CLEAR_FRAME) {
-           pain.rectangle(top_x + 1, baseline - insetAscent + 1,
-                          width(bv, f) - 1, insetAscent + insetDescent - 1,
-                          LColor::background);
-    }
-    x += width(bv, f) - TEXT_TO_INSET_OFFSET;
-    if (bv->text->status==LyXText::CHANGED_IN_DRAW) {
-       need_update = INIT;
-    } else if (need_update != INIT)
-       need_update = NONE;
+               locked = false;
+               if (need_update & SELECTION)
+                       bv->screen()->ToggleToggle(TEXT(bv), bv, y_offset, int(x));
+               else if (need_update & CURSOR) {
+                       bv->screen()->ToggleSelection(TEXT(bv), bv, true, y_offset,int(x));
+                       TEXT(bv)->ClearSelection(bv);
+                       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+               }
+               bv->screen()->Update(TEXT(bv), bv, y_offset, int(x));
+               locked = true;
+       }
+       }
+       TEXT(bv)->refresh_y = 0;
+       TEXT(bv)->status = LyXText::UNCHANGED;
+       if ((need_update != CURSOR_PAR) &&
+               ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)))
+       {
+               pain.rectangle(top_x + 1, baseline - insetAscent + 1,
+                                          width(bv, f) - 1, insetAscent + insetDescent - 1,
+                                          frame_color);
+       } else if (need_update & CLEAR_FRAME) {
+               pain.rectangle(top_x + 1, baseline - insetAscent + 1,
+                                          width(bv, f) - 1, insetAscent + insetDescent - 1,
+                                          LColor::background);
+       }
+       x += width(bv, f) - TEXT_TO_INSET_OFFSET;
+       if (bv->text->status==LyXText::CHANGED_IN_DRAW) {
+               need_update = INIT;
+       } else if (need_update != INIT)
+               need_update = NONE;
 }
 
 
 void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
 {
-    if (reinit) {  // && (need_update != CURSOR)) {
-       need_update = INIT;
-       resizeLyXText(bv);
-       if (owner())
-           owner()->update(bv, font, true);
-       return;
-    }
-    if (the_locking_inset) {
-       inset_x = cx(bv) - top_x + drawTextXOffset;
-       inset_y = cy(bv) + drawTextYOffset;
-       the_locking_inset->update(bv, font, reinit);
-    }
-    if (need_update == INIT) {
-       resizeLyXText(bv);
-       need_update = FULL;
-    }
-    int oldw = insetWidth;
+       if (reinit) {  // && (need_update != CURSOR)) {
+               need_update = INIT;
+               resizeLyXText(bv);
+               if (owner())
+                       owner()->update(bv, font, true);
+               return;
+       }
+       if (the_locking_inset) {
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
+               the_locking_inset->update(bv, font, reinit);
+       }
+       if (need_update == INIT) {
+               resizeLyXText(bv);
+               need_update = FULL;
+       }
+       int oldw = insetWidth;
 #if 1
-    insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
-    // max(textWidth(bv->painter()),
-    // static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
-    // (2 * TEXT_TO_INSET_OFFSET);
+       insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
+       // max(textWidth(bv->painter()),
+       // static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
+       // (2 * TEXT_TO_INSET_OFFSET);
 #else
-    insetWidth = textWidth(bv);
-    if (insetWidth < 0)
-           insetWidth = static_cast<int>(TEXT(bv)->width);
+       insetWidth = textWidth(bv);
+       if (insetWidth < 0)
+               insetWidth = static_cast<int>(TEXT(bv)->width);
 #endif
-    if (oldw != insetWidth) {
+       if (oldw != insetWidth) {
 //         printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
 //                textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
-       resizeLyXText(bv);
-       need_update = FULL;
-       update(bv, font, reinit);
-       return;
-    }
-    if ((need_update==CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
-       the_locking_inset)
-    {
-       TEXT(bv)->UpdateInset(bv, the_locking_inset);
-    }
-
-    if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
-       need_update = FULL;
+               resizeLyXText(bv);
+               need_update = FULL;
+               update(bv, font, reinit);
+               return;
+       }
+       if ((need_update==CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
+               the_locking_inset)
+       {
+               TEXT(bv)->UpdateInset(bv, the_locking_inset);
+       }
+       
+       if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
+               need_update = FULL;
 
-    int y_temp = 0;
-    Row * row = TEXT(bv)->GetRowNearY(y_temp);
-    insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
-    insetDescent = TEXT(bv)->height - row->ascent_of_text() +
-       TEXT_TO_INSET_OFFSET;
+       int y_temp = 0;
+       Row * row = TEXT(bv)->GetRowNearY(y_temp);
+       insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
+       insetDescent = TEXT(bv)->height - row->ascent_of_text() +
+               TEXT_TO_INSET_OFFSET;
 }
 
 void InsetText::SetUpdateStatus(BufferView * bv, int what)
 {
-    need_update |= what;
-    if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
-       need_update |= FULL;
-    else if (TEXT(bv)->status == LyXText::NEED_VERY_LITTLE_REFRESH)
-       need_update |= CURSOR_PAR;
+       need_update |= what;
+       if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
+               need_update |= FULL;
+       else if (TEXT(bv)->status == LyXText::NEED_VERY_LITTLE_REFRESH)
+               need_update |= CURSOR_PAR;
 
-    // this to not draw a selection when we redraw all of it!
-    if ((need_update & (INIT|FULL)) && (need_update & CURSOR))
-       TEXT(bv)->ClearSelection(bv);
+       // this to not draw a selection when we redraw all of it!
+       if ((need_update & (INIT|FULL)) && (need_update & CURSOR))
+               TEXT(bv)->ClearSelection(bv);
 }
 
 void InsetText::UpdateLocal(BufferView * bv, int what, bool mark_dirty)
 {
-    TEXT(bv)->FullRebreak(bv);
-    SetUpdateStatus(bv, what);
-    if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
-       TEXT(bv)->selection)
-           bv->updateInset(this, mark_dirty);
-    bv->owner()->showState();
-    if (old_par != cpar(bv)) {
-           bv->owner()->setLayout(cpar(bv)->GetLayout());
-           old_par = cpar(bv);
-    }
+       TEXT(bv)->FullRebreak(bv);
+       SetUpdateStatus(bv, what);
+       if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
+               TEXT(bv)->selection)
+               bv->updateInset(this, mark_dirty);
+       bv->owner()->showState();
+       if (old_par != cpar(bv)) {
+               bv->owner()->setLayout(cpar(bv)->GetLayout());
+               old_par = cpar(bv);
+       }
 }
 
 
 string const InsetText::EditMessage() const
 {
-    return _("Opened Text Inset");
+       return _("Opened Text Inset");
 }
 
 
 void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
 {
 //    par->SetInsetOwner(this);
-    UpdatableInset::Edit(bv, x, y, button);
-
-    if (!bv->lockInset(this)) {
-       lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
-       return;
-    }
-    locked = true;
-    the_locking_inset = 0;
-    inset_pos = inset_x = inset_y = 0;
-    inset_boundary = false;
-    inset_par = 0;
-    old_par = 0;
-    if (!checkAndActivateInset(bv, x, y, button))
-       TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
-                                          y+insetAscent);
-    TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-    bv->text->FinishUndo();
-    ShowInsetCursor(bv);
-    UpdateLocal(bv, FULL, false);
-
-    // If the inset is empty set the language of the current font to the
-    // language to the surronding text.
+       UpdatableInset::Edit(bv, x, y, button);
+
+       if (!bv->lockInset(this)) {
+               lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+               return;
+       }
+       locked = true;
+       the_locking_inset = 0;
+       inset_pos = inset_x = inset_y = 0;
+       inset_boundary = false;
+       inset_par = 0;
+       old_par = 0;
+       if (!checkAndActivateInset(bv, x, y, button))
+               TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+                                                                                  y+insetAscent);
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       bv->text->FinishUndo();
+       ShowInsetCursor(bv);
+       UpdateLocal(bv, FULL, false);
+
+       // If the inset is empty set the language of the current font to the
+       // language to the surronding text.
 #ifndef NEW_INSETS
-    if (par->Last() == 0 && !par->next_) {
+       if (par->Last() == 0 && !par->next_)
 #else
-    if (par->size() == 0 && !par->next()) {
+       if (par->size() == 0 && !par->next())
 #endif
-       LyXFont font(LyXFont::ALL_IGNORE);
-       font.setLanguage(bv->getParentLanguage(this));
-       SetFont(bv, font, false);
-    }
+       {
+               LyXFont font(LyXFont::ALL_IGNORE);
+               font.setLanguage(bv->getParentLanguage(this));
+               SetFont(bv, font, false);
+       }
 }
 
 
 void InsetText::InsetUnlock(BufferView * bv)
 {
-    if (the_locking_inset) {
-       the_locking_inset->InsetUnlock(bv);
-       the_locking_inset = 0;
-    }
-    HideInsetCursor(bv);
-    no_selection = false;
-    locked = false;
-    UpdateLocal(bv, CLEAR_FRAME|CURSOR, false);
-    if (owner())
-           bv->owner()->setLayout(owner()->getLyXText(bv)
-                                   ->cursor.par()->GetLayout());
-    else
-           bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
+       if (the_locking_inset) {
+               the_locking_inset->InsetUnlock(bv);
+               the_locking_inset = 0;
+       }
+       HideInsetCursor(bv);
+       no_selection = false;
+       locked = false;
+       UpdateLocal(bv, CLEAR_FRAME|CURSOR, false);
+       if (owner())
+               bv->owner()->setLayout(owner()->getLyXText(bv)
+                                                          ->cursor.par()->GetLayout());
+       else
+               bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
 }
 
 
 bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
 {
-    lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): ";
-    if (!inset)
-       return false;
-    if (inset == cpar(bv)->GetInset(cpos(bv))) {
-       lyxerr[Debug::INSETS] << "OK" << endl;
-       the_locking_inset = inset;
-       inset_x = cx(bv) - top_x + drawTextXOffset;
-       inset_y = cy(bv) + drawTextYOffset;
-       inset_pos = cpos(bv);
-       inset_par = cpar(bv);
-       inset_boundary = cboundary(bv);
+       lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): ";
+       if (!inset)
+               return false;
+       if (inset == cpar(bv)->GetInset(cpos(bv))) {
+               lyxerr[Debug::INSETS] << "OK" << endl;
+               the_locking_inset = inset;
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
+               inset_pos = cpos(bv);
+               inset_par = cpar(bv);
+               inset_boundary = cboundary(bv);
 #if 0
-       TEXT(bv)->ClearSelection(bv);
-       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       TEXT(bv)->UpdateInset(bv, the_locking_inset);
+               TEXT(bv)->ClearSelection(bv);
+               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+               TEXT(bv)->UpdateInset(bv, the_locking_inset);
 #else
-       UpdateLocal(bv, CURSOR, false);
+               UpdateLocal(bv, CURSOR, false);
 #endif
-       return true;
-    } else if (the_locking_inset && (the_locking_inset == inset)) {
-       if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
-           lyxerr[Debug::INSETS] << "OK" << endl;
-           inset_x = cx(bv) - top_x + drawTextXOffset;
-           inset_y = cy(bv) + drawTextYOffset;
-       } else {
-           lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
+               return true;
+       } else if (the_locking_inset && (the_locking_inset == inset)) {
+               if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
+                       lyxerr[Debug::INSETS] << "OK" << endl;
+                       inset_x = cx(bv) - top_x + drawTextXOffset;
+                       inset_y = cy(bv) + drawTextYOffset;
+               } else {
+                       lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
+               }
+       } else if (the_locking_inset) {
+               lyxerr[Debug::INSETS] << "MAYBE" << endl;
+               return the_locking_inset->LockInsetInInset(bv, inset);
        }
-    } else if (the_locking_inset) {
-       lyxerr[Debug::INSETS] << "MAYBE" << endl;
-       return the_locking_inset->LockInsetInInset(bv, inset);
-    }
-    lyxerr[Debug::INSETS] << "NOT OK" << endl;
-    return false;
+       lyxerr[Debug::INSETS] << "NOT OK" << endl;
+       return false;
 }
 
 
 bool InsetText::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
-                                  bool lr)
+                                                                  bool lr)
 {
-    if (!the_locking_inset)
-        return false;
-    if (the_locking_inset == inset) {
-        the_locking_inset->InsetUnlock(bv);
-       TEXT(bv)->UpdateInset(bv, inset);
-        the_locking_inset = 0;
-        if (lr)
-            moveRight(bv, false);
-       old_par = 0; // force layout setting
-       UpdateLocal(bv, CURSOR_PAR, false);
-        return true;
-    }
-    return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
+       if (!the_locking_inset)
+               return false;
+       if (the_locking_inset == inset) {
+               the_locking_inset->InsetUnlock(bv);
+               TEXT(bv)->UpdateInset(bv, inset);
+               the_locking_inset = 0;
+               if (lr)
+                       moveRight(bv, false);
+               old_par = 0; // force layout setting
+               UpdateLocal(bv, CURSOR_PAR, false);
+               return true;
+       }
+       return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
 }
 
 
 bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
 {
-    if (!the_locking_inset)
-        return false;
-    if (the_locking_inset != inset) {
-       TEXT(bv)->UpdateInset(bv, the_locking_inset);
-       SetUpdateStatus(bv, CURSOR_PAR);
-        return the_locking_inset->UpdateInsetInInset(bv, inset);
-    }
+       if (!the_locking_inset)
+               return false;
+       if (the_locking_inset != inset) {
+               TEXT(bv)->UpdateInset(bv, the_locking_inset);
+               SetUpdateStatus(bv, CURSOR_PAR);
+               return the_locking_inset->UpdateInsetInInset(bv, inset);
+       }
 //    UpdateLocal(bv, FULL, false);
-    if (TEXT(bv)->UpdateInset(bv, inset))
-       UpdateLocal(bv, CURSOR_PAR, false);
-    if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
-       inset_x = cx(bv) - top_x + drawTextXOffset;
-       inset_y = cy(bv) + drawTextYOffset;
-    }
-    return true;
+       if (TEXT(bv)->UpdateInset(bv, inset))
+               UpdateLocal(bv, CURSOR_PAR, false);
+       if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
+       }
+       return true;
 }
 
 
 void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
-    no_selection = true;
+       no_selection = true;
 
-    int tmp_x = x - drawTextXOffset;
-    int tmp_y = y + insetAscent - TEXT(bv)->first;
-    Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
+       int tmp_x = x - drawTextXOffset;
+       int tmp_y = y + insetAscent - TEXT(bv)->first;
+       Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
 
-    HideInsetCursor(bv);
-    if (the_locking_inset) {
-       if (the_locking_inset == inset) {
-           the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
-           no_selection = false;
-           return;
-       } else if (inset) {
-           // otherwise unlock the_locking_inset and lock the new inset
-           the_locking_inset->InsetUnlock(bv);
-           inset_x = cx(bv) - top_x + drawTextXOffset;
-           inset_y = cy(bv) + drawTextYOffset;
-           the_locking_inset = static_cast<UpdatableInset*>(inset);
-           inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
-           inset->Edit(bv, x - inset_x, y - inset_y, button);
-           if (the_locking_inset)
-               UpdateLocal(bv, CURSOR, false);
-           no_selection = false;
-           return;
-       }
-       // otherwise only unlock the_locking_inset
-       the_locking_inset->InsetUnlock(bv);
-       the_locking_inset = 0;
-    }
-    if (bv->theLockingInset()) {
-       if (inset && inset->Editable() == Inset::HIGHLY_EDITABLE) {
-           UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
-           inset_x = cx(bv) - top_x + drawTextXOffset;
-           inset_y = cy(bv) + drawTextYOffset;
-           inset_pos = cpos(bv);
-           inset_par = cpar(bv);
-           inset_boundary = cboundary(bv);
-           the_locking_inset = uinset;
-           uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
-           uinset->Edit(bv, x - inset_x, y - inset_y, 0);
-           if (the_locking_inset)
-               UpdateLocal(bv, CURSOR, false);
-           no_selection = false;
-           return;
+       HideInsetCursor(bv);
+       if (the_locking_inset) {
+               if (the_locking_inset == inset) {
+                       the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
+                       no_selection = false;
+                       return;
+               } else if (inset) {
+                       // otherwise unlock the_locking_inset and lock the new inset
+                       the_locking_inset->InsetUnlock(bv);
+                       inset_x = cx(bv) - top_x + drawTextXOffset;
+                       inset_y = cy(bv) + drawTextYOffset;
+                       the_locking_inset = static_cast<UpdatableInset*>(inset);
+                       inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
+                       inset->Edit(bv, x - inset_x, y - inset_y, button);
+                       if (the_locking_inset)
+                               UpdateLocal(bv, CURSOR, false);
+                       no_selection = false;
+                       return;
+               }
+               // otherwise only unlock the_locking_inset
+               the_locking_inset->InsetUnlock(bv);
+               the_locking_inset = 0;
        }
-    }
-    if (!inset && (button == 2)) {
-       bool paste_internally = false;
-       if ((button == 2) && TEXT(bv)->selection) {
-           LocalDispatch(bv, LFUN_COPY, "");
-           paste_internally = true;
+       if (bv->theLockingInset()) {
+               if (inset && inset->Editable() == Inset::HIGHLY_EDITABLE) {
+                       UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
+                       inset_x = cx(bv) - top_x + drawTextXOffset;
+                       inset_y = cy(bv) + drawTextYOffset;
+                       inset_pos = cpos(bv);
+                       inset_par = cpar(bv);
+                       inset_boundary = cboundary(bv);
+                       the_locking_inset = uinset;
+                       uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
+                       uinset->Edit(bv, x - inset_x, y - inset_y, 0);
+                       if (the_locking_inset)
+                               UpdateLocal(bv, CURSOR, false);
+                       no_selection = false;
+                       return;
+               }
        }
-       TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
-                                          y + insetAscent);
-       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR, false);
-       bv->owner()->setLayout(cpar(bv)->GetLayout());
-       old_par = cpar(bv);
-       // Insert primary selection with middle mouse
-       // if there is a local selection in the current buffer,
-       // insert this
-       if (button == 2) {
-           if (paste_internally)
-               LocalDispatch(bv, LFUN_PASTE, "");
-           else
-               LocalDispatch(bv, LFUN_PASTESELECTION, "paragraph");
+       if (!inset && (button == 2)) {
+               bool paste_internally = false;
+               if ((button == 2) && TEXT(bv)->selection) {
+                       LocalDispatch(bv, LFUN_COPY, "");
+                       paste_internally = true;
+               }
+               TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+                                                                                  y + insetAscent);
+               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+               UpdateLocal(bv, CURSOR, false);
+               bv->owner()->setLayout(cpar(bv)->GetLayout());
+               old_par = cpar(bv);
+               // Insert primary selection with middle mouse
+               // if there is a local selection in the current buffer,
+               // insert this
+               if (button == 2) {
+                       if (paste_internally)
+                               LocalDispatch(bv, LFUN_PASTE, "");
+                       else
+                               LocalDispatch(bv, LFUN_PASTESELECTION, "paragraph");
+               }
        }
-    }
-    ShowInsetCursor(bv);
-    no_selection = false;
+       ShowInsetCursor(bv);
+       no_selection = false;
 }
 
 
 void InsetText::InsetButtonRelease(BufferView * bv, int x, int y, int button)
 {
-    UpdatableInset * inset = 0;
+       UpdatableInset * inset = 0;
 
-    if (the_locking_inset) {
-           the_locking_inset->InsetButtonRelease(bv,
-                                                 x - inset_x, y - inset_y,
-                                                 button);
-    } else {
-       if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
-           inset = static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
-           if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
-               inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
-           } else {
-               inset_x = cx(bv) - top_x + drawTextXOffset;
-               inset_y = cy(bv) + drawTextYOffset;
-               inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
-               inset->Edit(bv, x - inset_x, y - inset_y, button);
-           }
-           UpdateLocal(bv, CURSOR_PAR, false);
+       if (the_locking_inset) {
+               the_locking_inset->InsetButtonRelease(bv,
+                                                                                         x - inset_x, y - inset_y,
+                                                                                         button);
+       } else {
+               if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
+                       inset = static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+                       if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
+                               inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
+                       } else {
+                               inset_x = cx(bv) - top_x + drawTextXOffset;
+                               inset_y = cy(bv) + drawTextYOffset;
+                               inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
+                               inset->Edit(bv, x - inset_x, y - inset_y, button);
+                       }
+                       UpdateLocal(bv, CURSOR_PAR, false);
+               }
        }
-    }
-    no_selection = false;
+       no_selection = false;
 }
 
 
 void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state)
 {
-    if (no_selection)
-       return;
-    if (the_locking_inset) {
-        the_locking_inset->InsetMotionNotify(bv, x - inset_x,
-                                            y - inset_y,state);
-        return;
-    }
-    HideInsetCursor(bv);
-    TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
-                                      y+insetAscent);
-    TEXT(bv)->SetSelection(bv);
-    if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() ||
-       TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos())
-       UpdateLocal(bv, SELECTION, false);
-    ShowInsetCursor(bv);
+       if (no_selection)
+               return;
+       if (the_locking_inset) {
+               the_locking_inset->InsetMotionNotify(bv, x - inset_x,
+                                                                                        y - inset_y,state);
+               return;
+       }
+       HideInsetCursor(bv);
+       TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+                                                                          y+insetAscent);
+       TEXT(bv)->SetSelection(bv);
+       if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() ||
+               TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos())
+               UpdateLocal(bv, SELECTION, false);
+       ShowInsetCursor(bv);
 }
 
 
 void InsetText::InsetKeyPress(XKeyEvent * xke)
 {
-    if (the_locking_inset) {
-        the_locking_inset->InsetKeyPress(xke);
-        return;
-    }
+       if (the_locking_inset) {
+               the_locking_inset->InsetKeyPress(xke);
+               return;
+       }
 }
 
 
 UpdatableInset::RESULT
 InsetText::LocalDispatch(BufferView * bv,
-                        kb_action action, string const & arg)
-{
-    no_selection = false;
-    UpdatableInset::RESULT
-        result= UpdatableInset::LocalDispatch(bv, action, arg);
-    if (result != UNDISPATCHED) {
-       return DISPATCHED;
-    }
-
-    result=DISPATCHED;
-    if ((action < 0) && arg.empty())
-        return FINISHED;
-
-    if (the_locking_inset) {
-        result = the_locking_inset->LocalDispatch(bv, action, arg);
-       if (result == DISPATCHED_NOUPDATE)
-           return result;
-       else if (result == DISPATCHED) {
-           UpdateLocal(bv, CURSOR_PAR, false);
-            return result;
-        } else if (result == FINISHED) {
-           bool dispatched = false;
-           switch (action) {
-           case LFUN_UNKNOWN_ACTION:
-           case LFUN_BREAKPARAGRAPH:
-           case LFUN_BREAKLINE:
-              moveRightIntern(bv, false, false);
-              break;
-           case LFUN_RIGHT:
-               if (!TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
-                   moveRightIntern(bv, false, false);
-               dispatched = true;
-               break;
-           case LFUN_LEFT:
-               if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
-                   moveRightIntern(bv, false, false);
-               dispatched = true;
-               break;
-           default:
-               break;
-           }
-           the_locking_inset = 0;
-           if (dispatched)
+                                                kb_action action, string const & arg)
+{
+       no_selection = false;
+       UpdatableInset::RESULT
+               result= UpdatableInset::LocalDispatch(bv, action, arg);
+       if (result != UNDISPATCHED) {
                return DISPATCHED;
        }
-    }
-    HideInsetCursor(bv);
-    switch (action) {
+
+       result=DISPATCHED;
+       if ((action < 0) && arg.empty())
+               return FINISHED;
+
+       if (the_locking_inset) {
+               result = the_locking_inset->LocalDispatch(bv, action, arg);
+               if (result == DISPATCHED_NOUPDATE)
+                       return result;
+               else if (result == DISPATCHED) {
+                       UpdateLocal(bv, CURSOR_PAR, false);
+                       return result;
+               } else if (result == FINISHED) {
+                       bool dispatched = false;
+                       switch (action) {
+                       case LFUN_UNKNOWN_ACTION:
+                       case LFUN_BREAKPARAGRAPH:
+                       case LFUN_BREAKLINE:
+                               moveRightIntern(bv, false, false);
+                               break;
+                       case LFUN_RIGHT:
+                               if (!TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+                                       moveRightIntern(bv, false, false);
+                               dispatched = true;
+                               break;
+                       case LFUN_LEFT:
+                               if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+                                       moveRightIntern(bv, false, false);
+                               dispatched = true;
+                               break;
+                       default:
+                               break;
+                       }
+                       the_locking_inset = 0;
+                       if (dispatched)
+                               return DISPATCHED;
+               }
+       }
+       HideInsetCursor(bv);
+       switch (action) {
        // Normal chars
-    case LFUN_UNKNOWN_ACTION:
-       if (bv->buffer()->isReadonly()) {
+       case LFUN_UNKNOWN_ACTION:
+               if (bv->buffer()->isReadonly()) {
 //         setErrorMessage(N_("Document is read only"));
-           break;
-       }
-       if (!arg.empty()) {
-           /* Automatically delete the currently selected
-            * text and replace it with what is being
-            * typed in now. Depends on lyxrc settings
-            * "auto_region_delete", which defaults to
-            * true (on). */
-
-           bv->text->SetUndo(bv->buffer(), Undo::INSERT,
+                       break;
+               }
+               if (!arg.empty()) {
+                       /* Automatically delete the currently selected
+                        * text and replace it with what is being
+                        * typed in now. Depends on lyxrc settings
+                        * "auto_region_delete", which defaults to
+                        * true (on). */
+
+                       bv->text->SetUndo(bv->buffer(), Undo::INSERT,
 #ifndef NEW_INSETS
-                             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-                             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-                             bv->text->cursor.par()->previous(),
-                             bv->text->cursor.par()->next()
+                                                         bv->text->cursor.par()->previous(),
+                                                         bv->text->cursor.par()->next()
 #endif
-                   );
-           bv->setState();
-           if (lyxrc.auto_region_delete) {
-               if (TEXT(bv)->selection){
-                   TEXT(bv)->CutSelection(bv, false);
-               }
-           }
-           TEXT(bv)->ClearSelection(bv);
-           for (string::size_type i = 0; i < arg.length(); ++i) {
-               if (greek_kb_flag) {
-                   if (!math_insert_greek(bv, arg[i])) {
-                       bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], TEXT(bv));
-                   } else if (!the_locking_inset) {
-                       (void)moveRight(bv, false);
-                   }
-               } else {
-                   bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], TEXT(bv));
+                                                         );
+                       bv->setState();
+                       if (lyxrc.auto_region_delete) {
+                               if (TEXT(bv)->selection){
+                                       TEXT(bv)->CutSelection(bv, false);
+                               }
+                       }
+                       TEXT(bv)->ClearSelection(bv);
+                       for (string::size_type i = 0; i < arg.length(); ++i) {
+                               if (greek_kb_flag) {
+                                       if (!math_insert_greek(bv, arg[i])) {
+                                               bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], TEXT(bv));
+                                       } else if (!the_locking_inset) {
+                                               (void)moveRight(bv, false);
+                                       }
+                               } else {
+                                       bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], TEXT(bv));
+                               }
+                       }
                }
-           }
-       }
-       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, true);
-       result=DISPATCHED_NOUPDATE;
-       break;
-        // --- Cursor Movements ---------------------------------------------
-    case LFUN_RIGHTSEL:
-       bv->text->FinishUndo();
-       moveRight(bv, false, true);
-       TEXT(bv)->SetSelection(bv);
-       UpdateLocal(bv, SELECTION, false);
-       break;
-    case LFUN_RIGHT:
-       result = moveRight(bv);
-       bv->text->FinishUndo();
-       UpdateLocal(bv, CURSOR, false);
-       break;
-    case LFUN_LEFTSEL:
-       bv->text->FinishUndo();
-       moveLeft(bv, false, true);
-       TEXT(bv)->SetSelection(bv);
-       UpdateLocal(bv, SELECTION, false);
-       break;
-    case LFUN_LEFT:
-       bv->text->FinishUndo();
-       result = moveLeft(bv);
-       UpdateLocal(bv, CURSOR, false);
-       break;
-    case LFUN_DOWNSEL:
-       bv->text->FinishUndo();
-       moveDown(bv);
-       TEXT(bv)->SetSelection(bv);
-       UpdateLocal(bv, SELECTION, false);
-       break;
-    case LFUN_DOWN:
-       bv->text->FinishUndo();
-       result = moveDown(bv);
-       UpdateLocal(bv, CURSOR, false);
-       break;
-    case LFUN_UPSEL:
-       bv->text->FinishUndo();
-       moveUp(bv);
-       TEXT(bv)->SetSelection(bv);
-       UpdateLocal(bv, SELECTION, false);
-       break;
-    case LFUN_UP:
-       bv->text->FinishUndo();
-       result = moveUp(bv);
-       UpdateLocal(bv, CURSOR, false);
-       break;
-    case LFUN_HOME:
-       bv->text->FinishUndo();
-       TEXT(bv)->CursorHome(bv);
-       UpdateLocal(bv, CURSOR, false);
-       break;
-    case LFUN_END:
-       TEXT(bv)->CursorEnd(bv);
-       UpdateLocal(bv, CURSOR, false);
-       break;
-    case LFUN_BACKSPACE:
-       bv->text->SetUndo(bv->buffer(), Undo::DELETE,
+               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+               UpdateLocal(bv, CURSOR_PAR, true);
+               result=DISPATCHED_NOUPDATE;
+               break;
+               // --- Cursor Movements ---------------------------------------------
+       case LFUN_RIGHTSEL:
+               bv->text->FinishUndo();
+               moveRight(bv, false, true);
+               TEXT(bv)->SetSelection(bv);
+               UpdateLocal(bv, SELECTION, false);
+               break;
+       case LFUN_RIGHT:
+               result = moveRight(bv);
+               bv->text->FinishUndo();
+               UpdateLocal(bv, CURSOR, false);
+               break;
+       case LFUN_LEFTSEL:
+               bv->text->FinishUndo();
+               moveLeft(bv, false, true);
+               TEXT(bv)->SetSelection(bv);
+               UpdateLocal(bv, SELECTION, false);
+               break;
+       case LFUN_LEFT:
+               bv->text->FinishUndo();
+               result = moveLeft(bv);
+               UpdateLocal(bv, CURSOR, false);
+               break;
+       case LFUN_DOWNSEL:
+               bv->text->FinishUndo();
+               moveDown(bv);
+               TEXT(bv)->SetSelection(bv);
+               UpdateLocal(bv, SELECTION, false);
+               break;
+       case LFUN_DOWN:
+               bv->text->FinishUndo();
+               result = moveDown(bv);
+               UpdateLocal(bv, CURSOR, false);
+               break;
+       case LFUN_UPSEL:
+               bv->text->FinishUndo();
+               moveUp(bv);
+               TEXT(bv)->SetSelection(bv);
+               UpdateLocal(bv, SELECTION, false);
+               break;
+       case LFUN_UP:
+               bv->text->FinishUndo();
+               result = moveUp(bv);
+               UpdateLocal(bv, CURSOR, false);
+               break;
+       case LFUN_HOME:
+               bv->text->FinishUndo();
+               TEXT(bv)->CursorHome(bv);
+               UpdateLocal(bv, CURSOR, false);
+               break;
+       case LFUN_END:
+               TEXT(bv)->CursorEnd(bv);
+               UpdateLocal(bv, CURSOR, false);
+               break;
+       case LFUN_BACKSPACE:
+               bv->text->SetUndo(bv->buffer(), Undo::DELETE,
 #ifndef NEW_INSETS
-         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-         bv->text->cursor.par()->previous(),
-         bv->text->cursor.par()->next()
+                                                 bv->text->cursor.par()->previous(),
+                                                 bv->text->cursor.par()->next()
 #endif
-               );
-       if (TEXT(bv)->selection)
-           TEXT(bv)->CutSelection(bv);
-       else
-           TEXT(bv)->Backspace(bv);
-       UpdateLocal(bv, CURSOR_PAR, true);
-       break;
-    case LFUN_DELETE:
-       bv->text->SetUndo(bv->buffer(), Undo::DELETE,
+                                                 );
+               if (TEXT(bv)->selection)
+                       TEXT(bv)->CutSelection(bv);
+               else
+                       TEXT(bv)->Backspace(bv);
+               UpdateLocal(bv, CURSOR_PAR, true);
+               break;
+       case LFUN_DELETE:
+               bv->text->SetUndo(bv->buffer(), Undo::DELETE,
 #ifndef NEW_INSETS
-         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-         bv->text->cursor.par()->previous(),
-         bv->text->cursor.par()->next()
+                                                 bv->text->cursor.par()->previous(),
+                                                 bv->text->cursor.par()->next()
 #endif
-               );
-       if (TEXT(bv)->selection)
-           TEXT(bv)->CutSelection(bv);
-       else
-           TEXT(bv)->Delete(bv);
-       UpdateLocal(bv, CURSOR_PAR, true);
-       break;
-    case LFUN_CUT:
-       bv->text->SetUndo(bv->buffer(), Undo::DELETE,
+                                                 );
+               if (TEXT(bv)->selection)
+                       TEXT(bv)->CutSelection(bv);
+               else
+                       TEXT(bv)->Delete(bv);
+               UpdateLocal(bv, CURSOR_PAR, true);
+               break;
+       case LFUN_CUT:
+               bv->text->SetUndo(bv->buffer(), Undo::DELETE,
 #ifndef NEW_INSETS
-         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-         bv->text->cursor.par()->previous(),
-         bv->text->cursor.par()->next()
+                                                 bv->text->cursor.par()->previous(),
+                                                 bv->text->cursor.par()->next()
 #endif
-               );
-       TEXT(bv)->CutSelection(bv);
-       UpdateLocal(bv, CURSOR_PAR, true);
-       break;
-    case LFUN_COPY:
-       bv->text->FinishUndo();
-       TEXT(bv)->CopySelection(bv);
-       UpdateLocal(bv, CURSOR_PAR, false);
-       break;
-    case LFUN_PASTESELECTION:
-    {
-       string clip(bv->workarea()->getClipboard());
+                                                 );
+               TEXT(bv)->CutSelection(bv);
+               UpdateLocal(bv, CURSOR_PAR, true);
+               break;
+       case LFUN_COPY:
+               bv->text->FinishUndo();
+               TEXT(bv)->CopySelection(bv);
+               UpdateLocal(bv, CURSOR_PAR, false);
+               break;
+       case LFUN_PASTESELECTION:
+       {
+               string clip(bv->workarea()->getClipboard());
        
-       if (clip.empty())
-           break;
-       if (arg == "paragraph") {
-               TEXT(bv)->InsertStringB(bv, clip);
-       } else {
-               TEXT(bv)->InsertStringA(bv, clip);
-       }
-       UpdateLocal(bv, CURSOR_PAR, true);
-       break;
-    }
-    case LFUN_PASTE:
-       if (!autoBreakRows) {
-           CutAndPaste cap;
-
-           if (cap.nrOfParagraphs() > 1) {
-               WriteAlert(_("Impossible operation"),
-                          _("Cannot include more than one paragraph!"),
-                          _("Sorry."));
+               if (clip.empty())
+                       break;
+               if (arg == "paragraph") {
+                       TEXT(bv)->InsertStringB(bv, clip);
+               } else {
+                       TEXT(bv)->InsertStringA(bv, clip);
+               }
+               UpdateLocal(bv, CURSOR_PAR, true);
                break;
-           }
        }
-       bv->text->SetUndo(bv->buffer(), Undo::INSERT,
+       case LFUN_PASTE:
+               if (!autoBreakRows) {
+                       CutAndPaste cap;
+
+                       if (cap.nrOfParagraphs() > 1) {
+                               WriteAlert(_("Impossible operation"),
+                                                  _("Cannot include more than one paragraph!"),
+                                                  _("Sorry."));
+                               break;
+                       }
+               }
+               bv->text->SetUndo(bv->buffer(), Undo::INSERT,
 #ifndef NEW_INSETS
-         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-         bv->text->cursor.par()->previous(),
-         bv->text->cursor.par()->next()
+                                                 bv->text->cursor.par()->previous(),
+                                                 bv->text->cursor.par()->next()
 #endif
-               );
-       TEXT(bv)->PasteSelection(bv);
-       UpdateLocal(bv, CURSOR_PAR, true);
-       break;
-    case LFUN_BREAKPARAGRAPH:
-       if (!autoBreakRows)
-           return DISPATCHED;
-       TEXT(bv)->BreakParagraph(bv, 0);
-       UpdateLocal(bv, FULL, true);
-       break;
-    case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
-       if (!autoBreakRows)
-           return DISPATCHED;
-       TEXT(bv)->BreakParagraph(bv, 1);
-       UpdateLocal(bv, FULL, true);
-       break;
-    case LFUN_BREAKLINE:
-       if (!autoBreakRows)
-           return DISPATCHED;
-       bv->text->SetUndo(bv->buffer(), Undo::INSERT,
+                                                 );
+               TEXT(bv)->PasteSelection(bv);
+               UpdateLocal(bv, CURSOR_PAR, true);
+               break;
+       case LFUN_BREAKPARAGRAPH:
+               if (!autoBreakRows)
+                       return DISPATCHED;
+               TEXT(bv)->BreakParagraph(bv, 0);
+               UpdateLocal(bv, FULL, true);
+               break;
+       case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
+               if (!autoBreakRows)
+                       return DISPATCHED;
+               TEXT(bv)->BreakParagraph(bv, 1);
+               UpdateLocal(bv, FULL, true);
+               break;
+       case LFUN_BREAKLINE:
+               if (!autoBreakRows)
+                       return DISPATCHED;
+               bv->text->SetUndo(bv->buffer(), Undo::INSERT,
 #ifndef NEW_INSETS
-           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-           bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-           bv->text->cursor.par()->previous(),
-           bv->text->cursor.par()->next()
+                                                 bv->text->cursor.par()->previous(),
+                                                 bv->text->cursor.par()->next()
 #endif
-               );
-       TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE);
-       UpdateLocal(bv, CURSOR_PAR, true);
-       break;
-    case LFUN_LAYOUT:
-       // do not set layouts on non breakable textinsets
-       if (autoBreakRows) {
-           LyXTextClass::size_type cur_layout = cpar(bv)->layout;
-      
-           // Derive layout number from given argument (string)
-           // and current buffer's textclass (number). */    
-           LyXTextClassList::ClassList::size_type tclass =
-               bv->buffer()->params.textclass;
-           std::pair <bool, LyXTextClass::size_type> layout = 
-               textclasslist.NumberOfLayout(tclass, arg);
-
-           // If the entry is obsolete, use the new one instead.
-           if (layout.first) {
-               string obs = textclasslist.Style(tclass,layout.second).
-                   obsoleted_by();
-               if (!obs.empty()) 
-                   layout = textclasslist.NumberOfLayout(tclass, obs);
-           }
-
-           // see if we found the layout number:
-           if (!layout.first) {
-               string msg = string(N_("Layout ")) + arg + N_(" not known");
-
-               bv->owner()->getMiniBuffer()->Set(msg);
-               break;
-           }
-
-           if (cur_layout != layout.second) {
-               cur_layout = layout.second;
-               TEXT(bv)->SetLayout(bv, layout.second);
-               bv->owner()->setLayout(cpar(bv)->GetLayout());
+                                                 );
+               TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE);
                UpdateLocal(bv, CURSOR_PAR, true);
-           }
-       } else {
-           // reset the layout box
-           bv->owner()->setLayout(cpar(bv)->GetLayout());
+               break;
+       case LFUN_LAYOUT:
+               // do not set layouts on non breakable textinsets
+               if (autoBreakRows) {
+                       LyXTextClass::size_type cur_layout = cpar(bv)->layout;
+         
+                       // Derive layout number from given argument (string)
+                       // and current buffer's textclass (number). */    
+                       LyXTextClassList::ClassList::size_type tclass =
+                               bv->buffer()->params.textclass;
+                       std::pair <bool, LyXTextClass::size_type> layout = 
+                               textclasslist.NumberOfLayout(tclass, arg);
+
+                       // If the entry is obsolete, use the new one instead.
+                       if (layout.first) {
+                               string obs = textclasslist.Style(tclass,layout.second).
+                                       obsoleted_by();
+                               if (!obs.empty()) 
+                                       layout = textclasslist.NumberOfLayout(tclass, obs);
+                       }
+
+                       // see if we found the layout number:
+                       if (!layout.first) {
+                               string msg = string(N_("Layout ")) + arg + N_(" not known");
+
+                               bv->owner()->getMiniBuffer()->Set(msg);
+                               break;
+                       }
+
+                       if (cur_layout != layout.second) {
+                               cur_layout = layout.second;
+                               TEXT(bv)->SetLayout(bv, layout.second);
+                               bv->owner()->setLayout(cpar(bv)->GetLayout());
+                               UpdateLocal(bv, CURSOR_PAR, true);
+                       }
+               } else {
+                       // reset the layout box
+                       bv->owner()->setLayout(cpar(bv)->GetLayout());
+               }
+               break;
+       case LFUN_PARAGRAPH_SPACING:
+               // This one is absolutely not working. When fiddling with this
+               // it also seems to me that the paragraphs inside the insettext
+               // inherit bufferparams/paragraphparams in a strange way. (Lgb)
+       {
+               LyXParagraph * par = TEXT(bv)->cursor.par();
+               Spacing::Space cur_spacing = par->params.spacing().getSpace();
+               float cur_value = 1.0;
+               if (cur_spacing == Spacing::Other) {
+                       cur_value = par->params.spacing().getValue();
+               }
+                               
+               std::istringstream istr(arg.c_str());
+               string tmp;
+               istr >> tmp;
+               Spacing::Space new_spacing = cur_spacing;
+               float new_value = cur_value;
+               if (tmp.empty()) {
+                       lyxerr << "Missing argument to `paragraph-spacing'"
+                                  << endl;
+               } else if (tmp == "single") {
+                       new_spacing = Spacing::Single;
+               } else if (tmp == "onehalf") {
+                       new_spacing = Spacing::Onehalf;
+               } else if (tmp == "double") {
+                       new_spacing = Spacing::Double;
+               } else if (tmp == "other") {
+                       new_spacing = Spacing::Other;
+                       float tmpval = 0.0;
+                       istr >> tmpval;
+                       lyxerr << "new_value = " << tmpval << endl;
+                       if (tmpval != 0.0)
+                               new_value = tmpval;
+               } else if (tmp == "default") {
+                       new_spacing = Spacing::Default;
+               } else {
+                       lyxerr << _("Unknown spacing argument: ")
+                                  << arg << endl;
+               }
+               if (cur_spacing != new_spacing || cur_value != new_value) {
+                       par->params.spacing(Spacing(new_spacing, new_value));
+                       //TEXT(bv)->RedoParagraph(owner->view());
+                       UpdateLocal(bv, CURSOR_PAR, true);
+                       //bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+               }
        }
        break;
-    case LFUN_PARAGRAPH_SPACING:
-           // This one is absolutely not working. When fiddling with this
-           // it also seems to me that the paragraphs inside the insettext
-           // inherit bufferparams/paragraphparams in a strange way. (Lgb)
-    {
-           LyXParagraph * par = TEXT(bv)->cursor.par();
-           Spacing::Space cur_spacing = par->params.spacing().getSpace();
-           float cur_value = 1.0;
-           if (cur_spacing == Spacing::Other) {
-                   cur_value = par->params.spacing().getValue();
-           }
-                       
-           std::istringstream istr(arg.c_str());
-           string tmp;
-           istr >> tmp;
-           Spacing::Space new_spacing = cur_spacing;
-           float new_value = cur_value;
-           if (tmp.empty()) {
-                   lyxerr << "Missing argument to `paragraph-spacing'"
-                          << endl;
-           } else if (tmp == "single") {
-                   new_spacing = Spacing::Single;
-           } else if (tmp == "onehalf") {
-                   new_spacing = Spacing::Onehalf;
-           } else if (tmp == "double") {
-                   new_spacing = Spacing::Double;
-           } else if (tmp == "other") {
-                   new_spacing = Spacing::Other;
-                   float tmpval = 0.0;
-                   istr >> tmpval;
-                   lyxerr << "new_value = " << tmpval << endl;
-                   if (tmpval != 0.0)
-                           new_value = tmpval;
-           } else if (tmp == "default") {
-                   new_spacing = Spacing::Default;
-           } else {
-                   lyxerr << _("Unknown spacing argument: ")
-                          << arg << endl;
-           }
-           if (cur_spacing != new_spacing || cur_value != new_value) {
-                   par->params.spacing(Spacing(new_spacing, new_value));
-                   //TEXT(bv)->RedoParagraph(owner->view());
-                   UpdateLocal(bv, CURSOR_PAR, true);
-                   //bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-           }
-    }
-    break;
        
-    default:
-       if (!bv->Dispatch(action, arg))
-           result = UNDISPATCHED;
-       break;
-    }
+       default:
+               if (!bv->Dispatch(action, arg))
+                       result = UNDISPATCHED;
+               break;
+       }
 
-    /// If the action has deleted all text in the inset, we need to change the
-    // language to the language to the surronding text.
+       /// If the action has deleted all text in the inset, we need to change the
+       // language to the language to the surronding text.
 #ifndef NEW_INSETS
-    if (par->Last() == 0 && !par->next_) {
+       if (par->Last() == 0 && !par->next_)
 #else
-    if (par->size() == 0 && !par->next()) {
+       if (par->size() == 0 && !par->next())
 #endif
-       LyXFont font(LyXFont::ALL_IGNORE);
-       font.setLanguage(bv->getParentLanguage(this));
-       SetFont(bv, font, false);
-    }
+       {
+               LyXFont font(LyXFont::ALL_IGNORE);
+               font.setLanguage(bv->getParentLanguage(this));
+               SetFont(bv, font, false);
+       }
 
-    if (result != FINISHED) {
-       ShowInsetCursor(bv);
-    } else
-        bv->unlockInset(this);
-    return result;
+       if (result != FINISHED) {
+               ShowInsetCursor(bv);
+       } else
+               bv->unlockInset(this);
+       return result;
 }
 
 
 int InsetText::Latex(Buffer const * buf, ostream & os, bool, bool) const
 {
-    TexRow texrow;
-    buf->latexParagraphs(os, par, 0, texrow);
-    return texrow.rows();
+       TexRow texrow;
+       buf->latexParagraphs(os, par, 0, texrow);
+       return texrow.rows();
 }
 
 
 int InsetText::Ascii(Buffer const * buf, ostream & os, int linelen) const
 {
-    LyXParagraph * p = par;
-    unsigned int lines = 0;
-    
-    string tmp;
-    while (p) {
-       tmp = buf->asciiParagraph(p, linelen);
-       lines += countChar(tmp, '\n');
-       os << tmp;
+       LyXParagraph * p = par;
+       unsigned int lines = 0;
+       
+       string tmp;
+       while (p) {
+               tmp = buf->asciiParagraph(p, linelen);
+               lines += countChar(tmp, '\n');
+               os << tmp;
 #ifndef NEW_INSETS
-       p = p->next();
+               p = p->next();
 #else
-       p = p->next();
+               p = p->next();
 #endif
-    }
-    return lines;
+       }
+       return lines;
 }
 
 
 int InsetText::DocBook(Buffer const * buf, ostream & os) const
 {
-    LyXParagraph * p = par;
-    unsigned int lines = 0;
-    int desc=0;
-    
-    string tmp;
-    while (p) {
-       buf->SimpleDocBookOnePar(os,tmp,p,desc,0);
+       LyXParagraph * p = par;
+       unsigned int lines = 0;
+       int desc=0;
+       
+       string tmp;
+       while (p) {
+               buf->SimpleDocBookOnePar(os,tmp,p,desc,0);
 #ifndef NEW_INSETS
-       p = p->next_;
+               p = p->next_;
 #else
-       p = p->next();
+               p = p->next();
 #endif
-    }
-    
-    return lines;
+       }
+       
+       return lines;
 }
 
 
 void InsetText::Validate(LaTeXFeatures & features) const
 {
-    LyXParagraph * p = par;
-    while(p) {
-       p->validate(features);
+       LyXParagraph * p = par;
+       while(p) {
+               p->validate(features);
 #ifndef NEW_INSETS
-       p = p->next_;
+               p = p->next_;
 #else
-       p = p->next();
+               p = p->next();
 #endif
-    }
+       }
 }
 
 
 int InsetText::BeginningOfMainBody(Buffer const * buf, LyXParagraph * p) const
 {
-    if (textclasslist.Style(buf->params.textclass,
-                           p->GetLayout()).labeltype != LABEL_MANUAL)
-       return 0;
-    else
-        return p->BeginningOfMainBody();
+       if (textclasslist.Style(buf->params.textclass,
+                                                       p->GetLayout()).labeltype != LABEL_MANUAL)
+               return 0;
+       else
+               return p->BeginningOfMainBody();
 }
 
 
 void InsetText::GetCursorPos(BufferView * bv,
-                            int & x, int & y) const
+                                                        int & x, int & y) const
 {
-    x = cx(bv);
-    y = cy(bv);
+       x = cx(bv);
+       y = cy(bv);
 }
 
 
 unsigned int InsetText::InsetInInsetY()
 {
-    if (!the_locking_inset)
-       return 0;
+       if (!the_locking_inset)
+               return 0;
 
-    return (inset_y + the_locking_inset->InsetInInsetY());
+       return (inset_y + the_locking_inset->InsetInInsetY());
 }
 
 
 void InsetText::ToggleInsetCursor(BufferView * bv)
 {
-    if (the_locking_inset) {
-        the_locking_inset->ToggleInsetCursor(bv);
-        return;
-    }
+       if (the_locking_inset) {
+               the_locking_inset->ToggleInsetCursor(bv);
+               return;
+       }
 
-    LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
+       LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
 
-    int asc = lyxfont::maxAscent(font);
-    int desc = lyxfont::maxDescent(font);
+       int asc = lyxfont::maxAscent(font);
+       int desc = lyxfont::maxDescent(font);
   
-    if (cursor_visible)
-        bv->hideLockedInsetCursor();
-    else
-        bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
-    cursor_visible = !cursor_visible;
+       if (cursor_visible)
+               bv->hideLockedInsetCursor();
+       else
+               bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+       cursor_visible = !cursor_visible;
 }
 
 
 void InsetText::ShowInsetCursor(BufferView * bv, bool show)
 {
-    if (the_locking_inset) {
-       the_locking_inset->ShowInsetCursor(bv);
-       return;
-    }
-    if (!cursor_visible) {
-       LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
+       if (the_locking_inset) {
+               the_locking_inset->ShowInsetCursor(bv);
+               return;
+       }
+       if (!cursor_visible) {
+               LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
        
-       int asc = lyxfont::maxAscent(font);
-       int desc = lyxfont::maxDescent(font);
+               int asc = lyxfont::maxAscent(font);
+               int desc = lyxfont::maxDescent(font);
 
-       bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
-       if (show)
-           bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
-       cursor_visible = true;
-    }
+               bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+               if (show)
+                       bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+               cursor_visible = true;
+       }
 }
 
 
 void InsetText::HideInsetCursor(BufferView * bv)
 {
-    if (cursor_visible) {
-        bv->hideLockedInsetCursor();
-       cursor_visible = false;
-    }
-    if (the_locking_inset)
-       the_locking_inset->HideInsetCursor(bv);
+       if (cursor_visible) {
+               bv->hideLockedInsetCursor();
+               cursor_visible = false;
+       }
+       if (the_locking_inset)
+               the_locking_inset->HideInsetCursor(bv);
 }
 
 
 UpdatableInset::RESULT
 InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
 {
-    if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
-       return moveLeftIntern(bv, false, activate_inset, selecting);
-    else
-       return moveRightIntern(bv, false, activate_inset, selecting);
+       if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+               return moveLeftIntern(bv, false, activate_inset, selecting);
+       else
+               return moveRightIntern(bv, false, activate_inset, selecting);
 }
 
 UpdatableInset::RESULT
 InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
 {
-    if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
-       return moveRightIntern(bv, true, activate_inset, selecting);
-    else
-       return moveLeftIntern(bv, true, activate_inset, selecting);
+       if (TEXT(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+               return moveRightIntern(bv, true, activate_inset, selecting);
+       else
+               return moveLeftIntern(bv, true, activate_inset, selecting);
 }
 
 
 UpdatableInset::RESULT
 InsetText::moveRightIntern(BufferView * bv, bool behind, 
-                          bool activate_inset, bool selecting)
+                                                  bool activate_inset, bool selecting)
 {
 #ifndef NEW_INSETS
-    if (!cpar(bv)->next_ && (cpos(bv) >= cpar(bv)->Last()))
+       if (!cpar(bv)->next_ && (cpos(bv) >= cpar(bv)->Last()))
 #else
-    if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
+       if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
 #endif
-       return FINISHED;
-    if (activate_inset && checkAndActivateInset(bv, behind))
-       return DISPATCHED;
-    TEXT(bv)->CursorRight(bv);
-    if (!selecting)
-           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-    return DISPATCHED_NOUPDATE;
+               return FINISHED;
+       if (activate_inset && checkAndActivateInset(bv, behind))
+               return DISPATCHED;
+       TEXT(bv)->CursorRight(bv);
+       if (!selecting)
+               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       return DISPATCHED_NOUPDATE;
 }
 
 
 UpdatableInset::RESULT
 InsetText::moveLeftIntern(BufferView * bv, bool behind,
-                         bool activate_inset, bool selecting)
+                                                 bool activate_inset, bool selecting)
 {
 #ifndef NEW_INSETS
-    if (!cpar(bv)->previous_ && (cpos(bv) <= 0))
+       if (!cpar(bv)->previous_ && (cpos(bv) <= 0))
 #else
-    if (!cpar(bv)->previous() && (cpos(bv) <= 0))
+       if (!cpar(bv)->previous() && (cpos(bv) <= 0))
 #endif
-       return FINISHED;
-    TEXT(bv)->CursorLeft(bv);
-    if (!selecting)
-           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-    if (activate_inset && checkAndActivateInset(bv, behind))
-       return DISPATCHED;
-    return DISPATCHED_NOUPDATE;
+               return FINISHED;
+       TEXT(bv)->CursorLeft(bv);
+       if (!selecting)
+               TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       if (activate_inset && checkAndActivateInset(bv, behind))
+               return DISPATCHED;
+       return DISPATCHED_NOUPDATE;
 }
 
 
 UpdatableInset::RESULT
 InsetText::moveUp(BufferView * bv)
 {
-    if (!crow(bv)->previous())
-       return FINISHED;
-    TEXT(bv)->CursorUp(bv);
-    return DISPATCHED_NOUPDATE;
+       if (!crow(bv)->previous())
+               return FINISHED;
+       TEXT(bv)->CursorUp(bv);
+       return DISPATCHED_NOUPDATE;
 }
 
 
 UpdatableInset::RESULT
 InsetText::moveDown(BufferView * bv)
 {
-    if (!crow(bv)->next())
-       return FINISHED;
-    TEXT(bv)->CursorDown(bv);
-    return DISPATCHED_NOUPDATE;
+       if (!crow(bv)->next())
+               return FINISHED;
+       TEXT(bv)->CursorDown(bv);
+       return DISPATCHED_NOUPDATE;
 }
 
 
 bool InsetText::InsertInset(BufferView * bv, Inset * inset)
 {
-    if (the_locking_inset) {
-       if (the_locking_inset->InsertInsetAllowed(inset))
-           return the_locking_inset->InsertInset(bv, inset);
-       return false;
-    }
-    bv->text->SetUndo(bv->buffer(), Undo::INSERT,
+       if (the_locking_inset) {
+               if (the_locking_inset->InsertInsetAllowed(inset))
+                       return the_locking_inset->InsertInset(bv, inset);
+               return false;
+       }
+       bv->text->SetUndo(bv->buffer(), Undo::INSERT,
 #ifndef NEW_INSETS
-             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-             bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-             bv->text->cursor.par()->previous(),
-             bv->text->cursor.par()->next()
+                                         bv->text->cursor.par()->previous(),
+                                         bv->text->cursor.par()->next()
 #endif
-           );
-    inset->setOwner(this);
-    HideInsetCursor(bv);
-    TEXT(bv)->InsertInset(bv, inset);
+                                         );
+       inset->setOwner(this);
+       HideInsetCursor(bv);
+       TEXT(bv)->InsertInset(bv, inset);
 #if 0
-    if ((cpar(bv)->GetChar(cpos(bv)) != LyXParagraph::META_INSET) ||
-       (cpar(bv)->GetInset(cpos(bv)) != inset))
-       TEXT(bv)->CursorLeft(bv);
+       if ((cpar(bv)->GetChar(cpos(bv)) != LyXParagraph::META_INSET) ||
+               (cpar(bv)->GetInset(cpos(bv)) != inset))
+               TEXT(bv)->CursorLeft(bv);
 #endif
-    bv->fitCursor(TEXT(bv));
-    UpdateLocal(bv, CURSOR_PAR|CURSOR, true);
-    ShowInsetCursor(bv);
-    return true;
+       bv->fitCursor(TEXT(bv));
+       UpdateLocal(bv, CURSOR_PAR|CURSOR, true);
+       ShowInsetCursor(bv);
+       return true;
 }
 
 
 UpdatableInset * InsetText::GetLockingInset()
 {
-    return the_locking_inset ? the_locking_inset->GetLockingInset() : this;
+       return the_locking_inset ? the_locking_inset->GetLockingInset() : this;
 }
 
 
 UpdatableInset * InsetText::GetFirstLockingInsetOfType(Inset::Code c)
 {
-    if (c == LyxCode())
-       return this;
-    if (the_locking_inset)
-       return the_locking_inset->GetFirstLockingInsetOfType(c);
-    return 0;
+       if (c == LyxCode())
+               return this;
+       if (the_locking_inset)
+               return the_locking_inset->GetFirstLockingInsetOfType(c);
+       return 0;
 }
 
 
 bool InsetText::ShowInsetDialog(BufferView * bv) const
 {
-    if (the_locking_inset)
-       return the_locking_inset->ShowInsetDialog(bv);
-    return false;
+       if (the_locking_inset)
+               return the_locking_inset->ShowInsetDialog(bv);
+       return false;
 }
 
 
 void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
 {
-    if (TEXT(bv)->selection) {
-       bv->text->SetUndo(bv->buffer(), Undo::EDIT,
+       if (TEXT(bv)->selection) {
+               bv->text->SetUndo(bv->buffer(), Undo::EDIT,
 #ifndef NEW_INSETS
-                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
-                         bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_,
+                                                 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_
 #else
-                         bv->text->cursor.par()->previous(),
-                         bv->text->cursor.par()->next()
+                                                 bv->text->cursor.par()->previous(),
+                                                 bv->text->cursor.par()->next()
 #endif
-           );
-    }
-    TEXT(bv)->SetFont(bv, font, toggleall);
-    bv->fitCursor(TEXT(bv));
-    UpdateLocal(bv, CURSOR_PAR, true);
+                                                 );
+       }
+       TEXT(bv)->SetFont(bv, font, toggleall);
+       bv->fitCursor(TEXT(bv));
+       UpdateLocal(bv, CURSOR_PAR, true);
 }
 
 
 bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
 {
-    if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
-       unsigned int x;
-       unsigned int y;
-       Inset * inset =
-           static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
-       if (!inset || inset->Editable() != Inset::HIGHLY_EDITABLE)
-           return false;
-       LyXFont const font =
-               TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
-       if (behind) {
-           x = inset->width(bv, font);
-           y = font.isRightToLeft() ? 0 : inset->descent(bv, font);
-       } else {
-           x = 0;
-           y = font.isRightToLeft() ? inset->descent(bv, font) : 0;
+       if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
+               unsigned int x;
+               unsigned int y;
+               Inset * inset =
+                       static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+               if (!inset || inset->Editable() != Inset::HIGHLY_EDITABLE)
+                       return false;
+               LyXFont const font =
+                       TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
+               if (behind) {
+                       x = inset->width(bv, font);
+                       y = font.isRightToLeft() ? 0 : inset->descent(bv, font);
+               } else {
+                       x = 0;
+                       y = font.isRightToLeft() ? inset->descent(bv, font) : 0;
+               }
+               //inset_x = cx(bv) - top_x + drawTextXOffset;
+               //inset_y = cy(bv) + drawTextYOffset;
+               inset->Edit(bv, x, y, 0);
+               if (!the_locking_inset)
+                       return false;
+               UpdateLocal(bv, CURSOR_PAR, false);
+               return true;
        }
-       //inset_x = cx(bv) - top_x + drawTextXOffset;
-       //inset_y = cy(bv) + drawTextYOffset;
-       inset->Edit(bv, x, y, 0);
-       if (!the_locking_inset)
-           return false;
-       UpdateLocal(bv, CURSOR_PAR, false);
-       return true;
-    }
-    return false;
+       return false;
 }
 
 
 bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
-                                     int button)
-{
-    int dummyx, dummyy;
-
-    dummyx = x = x - drawTextXOffset;
-    dummyy = y + insetAscent;
-    Inset * inset = bv->checkInsetHit(TEXT(bv), dummyx, dummyy, button);
-
-    if (inset) {
-       if (x < 0)
-           x = insetWidth;
-       if (y < 0)
-           y = insetDescent;
-       inset_x = cx(bv) - top_x + drawTextXOffset;
-       inset_y = cy(bv) + drawTextYOffset;
-       inset->Edit(bv, x - inset_x, y - inset_y, button);
-       if (!the_locking_inset)
-           return false;
-       UpdateLocal(bv, CURSOR_PAR, false);
-       return true;
-    }
-    return false;
+                                                                         int button)
+{
+       int dummyx, dummyy;
+
+       dummyx = x = x - drawTextXOffset;
+       dummyy = y + insetAscent;
+       Inset * inset = bv->checkInsetHit(TEXT(bv), dummyx, dummyy, button);
+
+       if (inset) {
+               if (x < 0)
+                       x = insetWidth;
+               if (y < 0)
+                       y = insetDescent;
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
+               inset->Edit(bv, x - inset_x, y - inset_y, button);
+               if (!the_locking_inset)
+                       return false;
+               UpdateLocal(bv, CURSOR_PAR, false);
+               return true;
+       }
+       return false;
 }
 
 
 int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
 {
-    int w = UpdatableInset::getMaxWidth(bv, inset);
-    if (w < 0) {
-       return w;
-    }
-    if (owner()) {
-       w = w - top_x + owner()->x();
-       return w;
-    }
-    w -= (2 * TEXT_TO_INSET_OFFSET);
-    return w - top_x;
+       int w = UpdatableInset::getMaxWidth(bv, inset);
+       if (w < 0) {
+               return w;
+       }
+       if (owner()) {
+               w = w - top_x + owner()->x();
+               return w;
+       }
+       w -= (2 * TEXT_TO_INSET_OFFSET);
+       return w - top_x;
 //    return  w - (2*TEXT_TO_INSET_OFFSET);
 }
 
 
 void InsetText::SetParagraphData(LyXParagraph * p)
 {
-    // delete all instances of LyXText before deleting the paragraps used
-    // by it.
-    for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
-       delete (*cit).second;
-       (*cit).second = 0;
-    }
+       // delete all instances of LyXText before deleting the paragraps used
+       // by it.
+       for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
+               delete (*cit).second;
+               (*cit).second = 0;
+       }
 
 #ifndef NEW_INSETS
-    LyXParagraph * np;
-    if (par) {
-       np = par->next_;
-       delete par;
-       while (np) {
-           par = np;
-           np = np->next_;
-           delete par;
-       }
-    }
-    par = p->Clone();
-    par->SetInsetOwner(this);
-    np = par;
-    while (p->next_) {
-       p = p->next_;
-       np->next(p->Clone());
-       np->next_->previous(np);
-       np = np->next_;
-       np->SetInsetOwner(this);
-    }
+       LyXParagraph * np;
+       if (par) {
+               np = par->next_;
+               delete par;
+               while (np) {
+                       par = np;
+                       np = np->next_;
+                       delete par;
+               }
+       }
+       par = p->Clone();
+       par->SetInsetOwner(this);
+       np = par;
+       while (p->next_) {
+               p = p->next_;
+               np->next(p->Clone());
+               np->next_->previous(np);
+               np = np->next_;
+               np->SetInsetOwner(this);
+       }
 #else
-    LyXParagraph * np;
-    if (par) {
-       np = par->next();
-       delete par;
-       while(np) {
-           par = np;
-           np = np->next();
-           delete par;
-       }
-    }
-    par = p->Clone();
-    par->SetInsetOwner(this);
-    np = par;
-    while(p->next()) {
-       p = p->next();
-       np->next(p->Clone());
-       np->next()->previous(np);
-       np = np->next();
-       np->SetInsetOwner(this);
-    }
+       LyXParagraph * np;
+       if (par) {
+               np = par->next();
+               delete par;
+               while(np) {
+                       par = np;
+                       np = np->next();
+                       delete par;
+               }
+       }
+       par = p->Clone();
+       par->SetInsetOwner(this);
+       np = par;
+       while(p->next()) {
+               p = p->next();
+               np->next(p->Clone());
+               np->next()->previous(np);
+               np = np->next();
+               np->SetInsetOwner(this);
+       }
 #endif
-    need_update = INIT;
+       need_update = INIT;
 }
 
 
 void InsetText::SetText(string const & data)
 {
-    clear();
-    LyXFont font(LyXFont::ALL_SANE);
-    for(unsigned int i=0; i < data.length(); ++i)
-       par->InsertChar(i, data[i], font);
+       clear();
+       LyXFont font(LyXFont::ALL_SANE);
+       for(unsigned int i=0; i < data.length(); ++i)
+               par->InsertChar(i, data[i], font);
 }
 
 
 void InsetText::SetAutoBreakRows(bool flag)
 {
-    if (flag != autoBreakRows) {
-       autoBreakRows = flag;
-       need_update = FULL;
-       if (!flag)
-           removeNewlines();
-    }
+       if (flag != autoBreakRows) {
+               autoBreakRows = flag;
+               need_update = FULL;
+               if (!flag)
+                       removeNewlines();
+       }
 }
 
 
 void InsetText::SetDrawFrame(BufferView * bv, DrawFrame how)
 {
-    if (how != drawFrame) {
-       drawFrame = how;
-       if (bv)
-           UpdateLocal(bv, DRAW_FRAME, false);
-    }
+       if (how != drawFrame) {
+               drawFrame = how;
+               if (bv)
+                       UpdateLocal(bv, DRAW_FRAME, false);
+       }
 }
 
 
 void InsetText::SetFrameColor(BufferView * bv, LColor::color col)
 {
-    if (frame_color != col) {
-       frame_color = col;
-       if (bv)
-           UpdateLocal(bv, DRAW_FRAME, false);
-    }
-}
-
-#if 0
-LyXFont InsetText::GetDrawFont(BufferView * bv, LyXParagraph * p, int pos) const
-{
-    return TEXT(bv)->GetFont(bv->buffer(), p, pos);
+       if (frame_color != col) {
+               frame_color = col;
+               if (bv)
+                       UpdateLocal(bv, DRAW_FRAME, false);
+       }
 }
-#endif
 
 
 int InsetText::cx(BufferView * bv) const
@@ -1642,7 +1637,7 @@ int InsetText::cx(BufferView * bv) const
        int x = text->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
        if (the_locking_inset) {
                LyXFont font = text->GetFont(bv->buffer(),
-                                    text->cursor.par(), text->cursor.pos());
+                                                                        text->cursor.par(), text->cursor.pos());
                if (font.isVisibleRightToLeft())
                        x -= the_locking_inset->width(bv, font);
        }
@@ -1652,170 +1647,170 @@ int InsetText::cx(BufferView * bv) const
 
 int InsetText::cy(BufferView * bv) const
 {
-    LyXFont font;
-    return TEXT(bv)->cursor.y() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
+       LyXFont font;
+       return TEXT(bv)->cursor.y() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
 }
 
 
 LyXParagraph::size_type InsetText::cpos(BufferView * bv) const
 {
-    return TEXT(bv)->cursor.pos();
+       return TEXT(bv)->cursor.pos();
 }
 
 
 LyXParagraph * InsetText::cpar(BufferView * bv) const
 {
-    return TEXT(bv)->cursor.par();
+       return TEXT(bv)->cursor.par();
 }
 
 bool InsetText::cboundary(BufferView * bv) const
 {
-    return TEXT(bv)->cursor.boundary();
+       return TEXT(bv)->cursor.boundary();
 }
 
 
 Row * InsetText::crow(BufferView * bv) const
 {
-    return TEXT(bv)->cursor.row();
+       return TEXT(bv)->cursor.row();
 }
 
 
 LyXText * InsetText::getLyXText(BufferView const * lbv, bool const recursive) const
 {
-    // Super UGLY! (Lgb)
-    BufferView * bv = const_cast<BufferView *>(lbv);
+       // Super UGLY! (Lgb)
+       BufferView * bv = const_cast<BufferView *>(lbv);
        
-    if ((cache.find(bv) != cache.end()) && cache[bv]) {
-       if (recursive && the_locking_inset)
-           return the_locking_inset->getLyXText(bv);
-       return cache[bv];
-    }
-    LyXText * lt = new LyXText(const_cast<InsetText *>(this));
-    lt->init(bv);
-    cache[bv] = lt;
-    if (the_locking_inset) {
-       lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary);
-       if (recursive)
-          return the_locking_inset->getLyXText(bv);
-    }
-    return lt;
+       if ((cache.find(bv) != cache.end()) && cache[bv]) {
+               if (recursive && the_locking_inset)
+                       return the_locking_inset->getLyXText(bv);
+               return cache[bv];
+       }
+       LyXText * lt = new LyXText(const_cast<InsetText *>(this));
+       lt->init(bv);
+       cache[bv] = lt;
+       if (the_locking_inset) {
+               lt->SetCursor(bv, inset_par, inset_pos, true, inset_boundary);
+               if (recursive)
+                       return the_locking_inset->getLyXText(bv);
+       }
+       return lt;
 }
 
 
 void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
 {
-    if ((cache.find(bv) == cache.end()) || !cache[bv])
-       return;
-    delete cache[bv];
-    cache.erase(bv);
-    if (recursive) {
-       /// then remove all LyXText in text-insets
-       LyXParagraph * p = par;
+       if ((cache.find(bv) == cache.end()) || !cache[bv])
+               return;
+       delete cache[bv];
+       cache.erase(bv);
+       if (recursive) {
+               /// then remove all LyXText in text-insets
+               LyXParagraph * p = par;
 #ifndef NEW_INSETS
-       for (; p; p = p->next_) {
-           p->deleteInsetsLyXText(bv);
-       }
+               for (; p; p = p->next_) {
+                       p->deleteInsetsLyXText(bv);
+               }
 #else
-       for (; p; p = p->next()) {
-           p->deleteInsetsLyXText(bv);
-       }
+               for (; p; p = p->next()) {
+                       p->deleteInsetsLyXText(bv);
+               }
 #endif
-    }
+       }
 }
 
 
 void InsetText::resizeLyXText(BufferView * bv) const
 {
 #ifndef NEW_INSETS
-    if (!par->next_ && !par->size()) // resize not neccessary!
+       if (!par->next_ && !par->size()) // resize not neccessary!
 #else
-    if (!par->next() && !par->size()) // resize not neccessary!
+       if (!par->next() && !par->size()) // resize not neccessary!
 #endif
-       return;
-    if ((cache.find(bv) == cache.end()) || !cache[bv])
-       return;
-
-    LyXParagraph * lpar = 0;
-    LyXParagraph * selstartpar = 0;
-    LyXParagraph * selendpar = 0;
-    LyXParagraph::size_type pos = 0;
-    LyXParagraph::size_type selstartpos = 0;
-    LyXParagraph::size_type selendpos = 0;
-    bool boundary = false;
-    bool selstartboundary = false;
-    bool selendboundary = false;
-    int selection = 0;
-    int mark_set = 0;
+               return;
+       if ((cache.find(bv) == cache.end()) || !cache[bv])
+               return;
+
+       LyXParagraph * lpar = 0;
+       LyXParagraph * selstartpar = 0;
+       LyXParagraph * selendpar = 0;
+       LyXParagraph::size_type pos = 0;
+       LyXParagraph::size_type selstartpos = 0;
+       LyXParagraph::size_type selendpos = 0;
+       bool boundary = false;
+       bool selstartboundary = false;
+       bool selendboundary = false;
+       int selection = 0;
+       int mark_set = 0;
 
 //    ProhibitInput(bv);
 
-    if (locked) {
-       lpar = TEXT(bv)->cursor.par();
-       pos = TEXT(bv)->cursor.pos();
-       boundary = TEXT(bv)->cursor.boundary();
-       selstartpar = TEXT(bv)->sel_start_cursor.par();
-       selstartpos = TEXT(bv)->sel_start_cursor.pos();
-       selstartboundary = TEXT(bv)->sel_start_cursor.boundary();
-       selendpar = TEXT(bv)->sel_end_cursor.par();
-       selendpos = TEXT(bv)->sel_end_cursor.pos();
-       selendboundary = TEXT(bv)->sel_end_cursor.boundary();
-       selection = TEXT(bv)->selection;
-       mark_set = TEXT(bv)->mark_set;
-    }
-    deleteLyXText(bv, (the_locking_inset == 0));
-
-    if (lpar) {
-       TEXT(bv)->selection = true;
-       /* at this point just to avoid the Delete-Empty-Paragraph
-        * Mechanism when setting the cursor */
-       TEXT(bv)->mark_set = mark_set;
-       if (selection) {
-           TEXT(bv)->SetCursor(bv, selstartpar, selstartpos,true, 
-                               selstartboundary);
-           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-           TEXT(bv)->SetCursor(bv, selendpar, selendpos, true, selendboundary);
-           TEXT(bv)->SetSelection(bv);
-           TEXT(bv)->SetCursor(bv, lpar, pos);
-       } else {
-           TEXT(bv)->SetCursor(bv, lpar, pos, true, boundary);
-           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-           TEXT(bv)->selection = false;
-       }
-    }
-    if (bv->screen())
-           TEXT(bv)->first = bv->screen()->TopCursorVisible(TEXT(bv));
-    // this will scroll the screen such that the cursor becomes visible 
-    bv->updateScrollbar();
+       if (locked) {
+               lpar = TEXT(bv)->cursor.par();
+               pos = TEXT(bv)->cursor.pos();
+               boundary = TEXT(bv)->cursor.boundary();
+               selstartpar = TEXT(bv)->sel_start_cursor.par();
+               selstartpos = TEXT(bv)->sel_start_cursor.pos();
+               selstartboundary = TEXT(bv)->sel_start_cursor.boundary();
+               selendpar = TEXT(bv)->sel_end_cursor.par();
+               selendpos = TEXT(bv)->sel_end_cursor.pos();
+               selendboundary = TEXT(bv)->sel_end_cursor.boundary();
+               selection = TEXT(bv)->selection;
+               mark_set = TEXT(bv)->mark_set;
+       }
+       deleteLyXText(bv, (the_locking_inset == 0));
+
+       if (lpar) {
+               TEXT(bv)->selection = true;
+               /* at this point just to avoid the Delete-Empty-Paragraph
+                * Mechanism when setting the cursor */
+               TEXT(bv)->mark_set = mark_set;
+               if (selection) {
+                       TEXT(bv)->SetCursor(bv, selstartpar, selstartpos,true, 
+                                                               selstartboundary);
+                       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+                       TEXT(bv)->SetCursor(bv, selendpar, selendpos, true, selendboundary);
+                       TEXT(bv)->SetSelection(bv);
+                       TEXT(bv)->SetCursor(bv, lpar, pos);
+               } else {
+                       TEXT(bv)->SetCursor(bv, lpar, pos, true, boundary);
+                       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+                       TEXT(bv)->selection = false;
+               }
+       }
+       if (bv->screen())
+               TEXT(bv)->first = bv->screen()->TopCursorVisible(TEXT(bv));
+       // this will scroll the screen such that the cursor becomes visible 
+       bv->updateScrollbar();
 //    AllowInput(bv);
-    if (the_locking_inset) {
-       /// then resize all LyXText in text-insets
-       inset_x = cx(bv) - top_x + drawTextXOffset;
-       inset_y = cy(bv) + drawTextYOffset;
+       if (the_locking_inset) {
+               /// then resize all LyXText in text-insets
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
 #ifndef NEW_INSETS
-       for (LyXParagraph * p = par; p; p = p->next_) {
-           p->resizeInsetsLyXText(bv);
-       }
+               for (LyXParagraph * p = par; p; p = p->next_) {
+                       p->resizeInsetsLyXText(bv);
+               }
 #else
-       for (LyXParagraph * p = par; p; p = p->next()) {
-           p->resizeInsetsLyXText(bv);
-       }
+               for (LyXParagraph * p = par; p; p = p->next()) {
+                       p->resizeInsetsLyXText(bv);
+               }
 #endif
-    }
-    need_update = FULL;
+       }
+       need_update = FULL;
 }
 
 
 void InsetText::removeNewlines()
 {
 #ifndef NEW_INSETS
-    for (LyXParagraph * p = par; p; p = p->next_) {
-       for (int i = 0; i < p->Last(); ++i) {
+       for (LyXParagraph * p = par; p; p = p->next_) {
+               for (int i = 0; i < p->Last(); ++i) {
 #else
-    for (LyXParagraph * p = par; p; p = p->next()) {
-       for (int i = 0; i < p->size(); ++i) {
+       for (LyXParagraph * p = par; p; p = p->next()) {
+               for (int i = 0; i < p->size(); ++i) {
 #endif
-           if (p->GetChar(i) == LyXParagraph::META_NEWLINE)
-               p->Erase(i);
+                       if (p->GetChar(i) == LyXParagraph::META_NEWLINE)
+                               p->Erase(i);
+               }
        }
-    }
 }
index 934781980e08ae257cd59c6e58a0a5d9a024fd6e..205d5adcf5cef38d9b8afccf8a6f431333e0e7b3 100644 (file)
@@ -39,260 +39,260 @@ class LyXScreen;
  */
 class InsetText : public UpdatableInset {
 public:
-    ///
-    /// numbers need because of test if codeA < codeB
-    ///
-    enum UpdateCodes {
-       ///
-       NONE = 0,
-       ///
-       CURSOR = 1,
-       ///
-       CLEAR_FRAME = 2,
-       ///
-       DRAW_FRAME = 4,
-       ///
-       SELECTION = 8,
-       ///
-       CURSOR_PAR = 16,
-       ///
-       FULL = 32,
-       ///
-       INIT = 64
-    };
-    ///
-    enum DrawFrame {
-       ///
-       NEVER = 0,
-       ///
-       LOCKED,
-       ///
-       ALWAYS
-    };
-    ///
-    InsetText();
-    ///
-    explicit
-    InsetText(InsetText const &);
-    ///
-    ~InsetText();
-    ///
-    Inset * Clone(Buffer const &) const;
-    ///
-    InsetText & operator=(InsetText const & it);
-    ///
-    void clear();
-    ///
-    void Read(Buffer const *, LyXLex &);
-    ///
-    void Write(Buffer const *, std::ostream &) const;
-    ///
-    int ascent(BufferView *, LyXFont const &) const;
-    ///
-    int descent(BufferView *, LyXFont const &) const;
-    ///
-    int width(BufferView *, LyXFont const & f) const;
-    ///
-    int textWidth(BufferView *) const;
-    ///
-    void draw(BufferView *, LyXFont const &, int , float &, bool) const;
-    ///
-    void update(BufferView *, LyXFont const &, bool =false);
-    ///
-    void SetUpdateStatus(BufferView *, int what);
-    ///
-    string const EditMessage() const;
-    ///
-    void Edit(BufferView *, int, int, unsigned int);
-    ///
-    bool IsTextInset() const { return true; }
-    ///
-    bool doClearArea() const { return !locked; }
-    ///
-    void InsetUnlock(BufferView *);
-    ///
-    bool LockInsetInInset(BufferView *, UpdatableInset *);
-    ///
-    bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
-    ///
-    bool UpdateInsetInInset(BufferView *, Inset *);
-    ///
-    void InsetButtonRelease(BufferView *, int, int, int);
-    ///
-    void InsetButtonPress(BufferView *, int, int, int);
-    ///
-    void InsetMotionNotify(BufferView *, int, int, int);
-    ///
-    void InsetKeyPress(XKeyEvent *);
-    ///
-    UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action, string const &);
-    ///
-    int Latex(Buffer const *, std::ostream &,
-             bool fragile, bool free_spc) const;
-    ///
-    int Ascii(Buffer const *, std::ostream &, int linelen) const;
-    ///
-    int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
-    ///
-    int DocBook(Buffer const *, std::ostream &) const ;
-    ///
-    void Validate(LaTeXFeatures & features) const;
-    ///
-    Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
-    ///
-    void GetCursorPos(BufferView *, int & x, int & y) const;
-    ///
-    unsigned int InsetInInsetY();
-    ///
-    void ToggleInsetCursor(BufferView *);
-    ///
-    bool InsertInset(BufferView *, Inset *);
-    ///
-    UpdatableInset * GetLockingInset();
-    ///
-    UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
-    ///
-    void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
-    ///
-    int getMaxWidth(BufferView *, UpdatableInset const *) const;
-    ///
-    void init(InsetText const * ins = 0);
-    ///
-    void WriteParagraphData(Buffer const *, std::ostream &) const;
-    ///
-    void SetParagraphData(LyXParagraph *);
-    ///
-    void SetText(string const &);
-    ///
-    void SetAutoBreakRows(bool);
-    ///
-    void SetDrawFrame(BufferView *, DrawFrame);
-    ///
-    void SetFrameColor(BufferView *, LColor::color);
-    ///
-    LyXText * getLyXText(BufferView const *, bool const recursive=false) const;
-    ///
-    void deleteLyXText(BufferView *, bool recursive=true) const;
-    ///
-    void resizeLyXText(BufferView *) const;
-    ///
-    bool ShowInsetDialog(BufferView *) const;
-    ///
-    LyXParagraph * par;
-    ///
-    mutable int need_update;
+       ///
+       /// numbers need because of test if codeA < codeB
+       ///
+       enum UpdateCodes {
+               ///
+               NONE = 0,
+               ///
+               CURSOR = 1,
+               ///
+               CLEAR_FRAME = 2,
+               ///
+               DRAW_FRAME = 4,
+               ///
+               SELECTION = 8,
+               ///
+               CURSOR_PAR = 16,
+               ///
+               FULL = 32,
+               ///
+               INIT = 64
+       };
+       ///
+       enum DrawFrame {
+               ///
+               NEVER = 0,
+               ///
+               LOCKED,
+               ///
+               ALWAYS
+       };
+       ///
+       InsetText();
+       ///
+       explicit
+       InsetText(InsetText const &);
+       ///
+       ~InsetText();
+       ///
+       Inset * Clone(Buffer const &) const;
+       ///
+       InsetText & operator=(InsetText const & it);
+       ///
+       void clear();
+       ///
+       void Read(Buffer const *, LyXLex &);
+       ///
+       void Write(Buffer const *, std::ostream &) const;
+       ///
+       int ascent(BufferView *, LyXFont const &) const;
+       ///
+       int descent(BufferView *, LyXFont const &) const;
+       ///
+       int width(BufferView *, LyXFont const & f) const;
+       ///
+       int textWidth(BufferView *) const;
+       ///
+       void draw(BufferView *, LyXFont const &, int , float &, bool) const;
+       ///
+       void update(BufferView *, LyXFont const &, bool =false);
+       ///
+       void SetUpdateStatus(BufferView *, int what);
+       ///
+       string const EditMessage() const;
+       ///
+       void Edit(BufferView *, int, int, unsigned int);
+       ///
+       bool IsTextInset() const { return true; }
+       ///
+       bool doClearArea() const { return !locked; }
+       ///
+       void InsetUnlock(BufferView *);
+       ///
+       bool LockInsetInInset(BufferView *, UpdatableInset *);
+       ///
+       bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
+       ///
+       bool UpdateInsetInInset(BufferView *, Inset *);
+       ///
+       void InsetButtonRelease(BufferView *, int, int, int);
+       ///
+       void InsetButtonPress(BufferView *, int, int, int);
+       ///
+       void InsetMotionNotify(BufferView *, int, int, int);
+       ///
+       void InsetKeyPress(XKeyEvent *);
+       ///
+       UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action, string const &);
+       ///
+       int Latex(Buffer const *, std::ostream &,
+                         bool fragile, bool free_spc) const;
+       ///
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
+       ///
+       int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
+       ///
+       int DocBook(Buffer const *, std::ostream &) const ;
+       ///
+       void Validate(LaTeXFeatures & features) const;
+       ///
+       Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
+       ///
+       void GetCursorPos(BufferView *, int & x, int & y) const;
+       ///
+       unsigned int InsetInInsetY();
+       ///
+       void ToggleInsetCursor(BufferView *);
+       ///
+       bool InsertInset(BufferView *, Inset *);
+       ///
+       UpdatableInset * GetLockingInset();
+       ///
+       UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
+       ///
+       void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+       ///
+       int getMaxWidth(BufferView *, UpdatableInset const *) const;
+       ///
+       void init(InsetText const * ins = 0);
+       ///
+       void WriteParagraphData(Buffer const *, std::ostream &) const;
+       ///
+       void SetParagraphData(LyXParagraph *);
+       ///
+       void SetText(string const &);
+       ///
+       void SetAutoBreakRows(bool);
+       ///
+       void SetDrawFrame(BufferView *, DrawFrame);
+       ///
+       void SetFrameColor(BufferView *, LColor::color);
+       ///
+       LyXText * getLyXText(BufferView const *, bool const recursive=false) const;
+       ///
+       void deleteLyXText(BufferView *, bool recursive=true) const;
+       ///
+       void resizeLyXText(BufferView *) const;
+       ///
+       bool ShowInsetDialog(BufferView *) const;
+       ///
+       LyXParagraph * par;
+       ///
+       mutable int need_update;
 
 protected:
-    ///
-    void UpdateLocal(BufferView *, int what, bool mark_dirty);
-    ///
-    mutable int drawTextXOffset;
-    ///
-    mutable int drawTextYOffset;
-    ///
-    bool autoBreakRows;
-    ///
-    DrawFrame drawFrame;
-    ///
-    LColor::color frame_color;
+       ///
+       void UpdateLocal(BufferView *, int what, bool mark_dirty);
+       ///
+       mutable int drawTextXOffset;
+       ///
+       mutable int drawTextYOffset;
+       ///
+       bool autoBreakRows;
+       ///
+       DrawFrame drawFrame;
+       ///
+       LColor::color frame_color;
 
 private:
-    ///
-    typedef std::map<BufferView *, LyXText *> Cache;
-    ///
-    typedef Cache::value_type value_type;
-    ///
-    int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
-    ///
-    void ShowInsetCursor(BufferView *, bool show=true);
-    ///
-    void HideInsetCursor(BufferView *);
-    ///
-    UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true,
-                                    bool selecting = false);
-    ///
-    UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true,
-                                   bool selecting = false);
-    ///
-    UpdatableInset::RESULT moveRightIntern(BufferView *, bool behind,
-                                          bool activate_inset = true,
-                                          bool selecting = false);
-    ///
-    UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind, 
-                                         bool activate_inset = true,
-                                         bool selecting = false);
+       ///
+       typedef std::map<BufferView *, LyXText *> Cache;
+       ///
+       typedef Cache::value_type value_type;
+       ///
+       int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
+       ///
+       void ShowInsetCursor(BufferView *, bool show=true);
+       ///
+       void HideInsetCursor(BufferView *);
+       ///
+       UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true,
+                                                                        bool selecting = false);
+       ///
+       UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true,
+                                                                       bool selecting = false);
+       ///
+       UpdatableInset::RESULT moveRightIntern(BufferView *, bool behind,
+                                                                                  bool activate_inset = true,
+                                                                                  bool selecting = false);
+       ///
+       UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind, 
+                                                                                 bool activate_inset = true,
+                                                                                 bool selecting = false);
 
-    ///
-    UpdatableInset::RESULT moveUp(BufferView *);
-    ///
-    UpdatableInset::RESULT moveDown(BufferView *);
-    ///
-    void SetCharFont(Buffer const *, int pos, LyXFont const & font);
-    ///
-    string const getText(int);
-    ///
-    bool checkAndActivateInset(BufferView * bv, bool behind);
-    ///
-    bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
-                              int button = 0);
-    void removeNewlines();
+       ///
+       UpdatableInset::RESULT moveUp(BufferView *);
+       ///
+       UpdatableInset::RESULT moveDown(BufferView *);
+       ///
+       void SetCharFont(Buffer const *, int pos, LyXFont const & font);
+       ///
+       string const getText(int);
+       ///
+       bool checkAndActivateInset(BufferView * bv, bool behind);
+       ///
+       bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
+                                                          int button = 0);
+       void removeNewlines();
 
-    ///
-    int cx(BufferView *) const;
-    ///
-    int cy(BufferView *) const;
-    ///
-    LyXParagraph::size_type cpos(BufferView *) const;
-    ///
-    LyXParagraph * cpar(BufferView *) const;
-    ///
-    bool cboundary(BufferView *) const;
-    ///
-    Row * crow(BufferView *) const;
+       ///
+       int cx(BufferView *) const;
+       ///
+       int cy(BufferView *) const;
+       ///
+       LyXParagraph::size_type cpos(BufferView *) const;
+       ///
+       LyXParagraph * cpar(BufferView *) const;
+       ///
+       bool cboundary(BufferView *) const;
+       ///
+       Row * crow(BufferView *) const;
 
-    /// This instead of a macro
-    LyXText * TEXT(BufferView * bv) const {
-       return getLyXText(bv);
-    }
+       /// This instead of a macro
+       LyXText * TEXT(BufferView * bv) const {
+               return getLyXText(bv);
+       }
        
-    /* Private structures and variables */
-    ///
-    mutable bool locked;
-    ///
-    mutable int insetAscent;
-    ///
-    mutable int insetDescent;
-    ///
-    mutable int insetWidth;
-    ///
-    mutable int last_width;
-    ///
-    mutable int last_height;
-    ///
-    mutable int top_y;
-    ///
-    LyXParagraph * inset_par;
-    ///
-    LyXParagraph::size_type inset_pos;
-    ///
-    bool inset_boundary;
-    ///
-    mutable int inset_x;
-    ///
-    mutable int inset_y;
-    ///
-    int interline_space;
-    ///
-    bool no_selection;
-    ///
-    mutable float xpos;
-    ///
-    UpdatableInset * the_locking_inset;
-    ///
-    LyXParagraph * old_par;
-    /// The cache.
-    mutable Cache cache;
-    ///
-    mutable int last_drawn_width;
+       /* Private structures and variables */
+       ///
+       mutable bool locked;
+       ///
+       mutable int insetAscent;
+       ///
+       mutable int insetDescent;
+       ///
+       mutable int insetWidth;
+       ///
+       mutable int last_width;
+       ///
+       mutable int last_height;
+       ///
+       mutable int top_y;
+       ///
+       LyXParagraph * inset_par;
+       ///
+       LyXParagraph::size_type inset_pos;
+       ///
+       bool inset_boundary;
+       ///
+       mutable int inset_x;
+       ///
+       mutable int inset_y;
+       ///
+       int interline_space;
+       ///
+       bool no_selection;
+       ///
+       mutable float xpos;
+       ///
+       UpdatableInset * the_locking_inset;
+       ///
+       LyXParagraph * old_par;
+       /// The cache.
+       mutable Cache cache;
+       ///
+       mutable int last_drawn_width;
 };
 #endif
index ab3b4d8d1449a02d25752444cad19cd125c9355a..4e0ee4515b7770b4bcdd746a7aaa9c30d989f9ca 100644 (file)
@@ -42,7 +42,7 @@ using std::vector;
 
 namespace {
 
-int const WIDTH_OF_LINE = 5;
+       int const WIDTH_OF_LINE = 5;
 
 } // namespace
 
@@ -50,806 +50,806 @@ int const WIDTH_OF_LINE = 5;
 
 LyXTabular::cellstruct::cellstruct() 
 {
-    cellno = 0;
-    width_of_cell = 0;
-    multicolumn = LyXTabular::CELL_NORMAL;
-    alignment = LYX_ALIGN_CENTER;
-    valignment = LYX_VALIGN_TOP;
-    top_line = true;
-    bottom_line = false;
-    left_line = true;
-    right_line = false;
-    usebox = BOX_NONE;
-    rotate = false;
+       cellno = 0;
+       width_of_cell = 0;
+       multicolumn = LyXTabular::CELL_NORMAL;
+       alignment = LYX_ALIGN_CENTER;
+       valignment = LYX_VALIGN_TOP;
+       top_line = true;
+       bottom_line = false;
+       left_line = true;
+       right_line = false;
+       usebox = BOX_NONE;
+       rotate = false;
 }
 
 
 LyXTabular::rowstruct::rowstruct() 
 {
-    top_line = true;
-    bottom_line = false;
-    ascent_of_row = 0;
-    descent_of_row = 0;
-    newpage = false;
+       top_line = true;
+       bottom_line = false;
+       ascent_of_row = 0;
+       descent_of_row = 0;
+       newpage = false;
 }
 
 
 LyXTabular::columnstruct::columnstruct() 
 {
-    left_line = true;
-    right_line = false;
-    alignment = LYX_ALIGN_CENTER;
-    valignment = LYX_VALIGN_TOP;
-    width_of_column = 0;
+       left_line = true;
+       right_line = false;
+       alignment = LYX_ALIGN_CENTER;
+       valignment = LYX_VALIGN_TOP;
+       width_of_column = 0;
 }
 
 
 /* konstruktor */
 LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
 {
-    owner_ = inset;
-    Init(rows_arg, columns_arg);
+       owner_ = inset;
+       Init(rows_arg, columns_arg);
 }
 
 
 LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
 {
-    owner_ = inset;
-    Init(lt.rows_, lt.columns_);
+       owner_ = inset;
+       Init(lt.rows_, lt.columns_);
 #ifdef WITH_WARNINGS
 #warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
 #endif
-    operator=(lt);
+       operator=(lt);
 }
 
 
 LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
 {
-    owner_ = inset;
-    Read(buf, lex);
+       owner_ = inset;
+       Read(buf, lex);
 }
 
 
 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 {
-    // If this and lt is not of the same size we have a serious bug
-    // So then it is ok to throw an exception, or for now
-    // call abort()
-    Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
+       // If this and lt is not of the same size we have a serious bug
+       // So then it is ok to throw an exception, or for now
+       // call abort()
+       Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
 
-    cell_info = lt.cell_info;
-    row_info = lt.row_info;
-    column_info = lt.column_info;
+       cell_info = lt.cell_info;
+       row_info = lt.row_info;
+       column_info = lt.column_info;
 
-    // long tabular stuff
-    SetLongTabular(lt.is_long_tabular);
-    endhead = lt.endhead;
-    endfoot = lt.endfoot;
-    endfirsthead = lt.endfirsthead;
-    endlastfoot = lt.endlastfoot;
+       // long tabular stuff
+       SetLongTabular(lt.is_long_tabular);
+       endhead = lt.endhead;
+       endfoot = lt.endfoot;
+       endfirsthead = lt.endfirsthead;
+       endlastfoot = lt.endlastfoot;
 
-    rotate = lt.rotate;
+       rotate = lt.rotate;
 
-    Reinit();
-    
-    return *this;
+       Reinit();
+       
+       return *this;
 }
 
 
 LyXTabular * LyXTabular::Clone(InsetTabular * inset)
 {
-    LyXTabular * result = new LyXTabular(inset, *this);
-    // don't know if this is good but I need to Clone also
-    // the text-insets here, this is for the Undo-facility!
-    for (int i = 0; i < rows_; ++i) {
-       for (int j = 0; j < columns_; ++j) {
-           result->cell_info[i][j].inset = cell_info[i][j].inset;
-           result->cell_info[i][j].inset.setOwner(inset);
+       LyXTabular * result = new LyXTabular(inset, *this);
+       // don't know if this is good but I need to Clone also
+       // the text-insets here, this is for the Undo-facility!
+       for (int i = 0; i < rows_; ++i) {
+               for (int j = 0; j < columns_; ++j) {
+                       result->cell_info[i][j].inset = cell_info[i][j].inset;
+                       result->cell_info[i][j].inset.setOwner(inset);
+               }
        }
-    }
-    return result;
+       return result;
 }
 
 
 /* activates all lines and sets all widths to 0 */ 
 void LyXTabular::Init(int rows_arg, int columns_arg)
 {
-    rows_ = rows_arg;
-    columns_ = columns_arg;
-    row_info = row_vector(rows_, rowstruct());
-    column_info = column_vector(columns_, columnstruct());
-    cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct()));
-
-    int cellno = 0;
-    for (int i = 0; i < rows_; ++i) {
-        for (int j = 0; j < columns_; ++j) {
-           cell_info[i][j].inset.setOwner(owner_);
-           cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
-            cell_info[i][j].cellno = cellno++;
-        }
-       cell_info[i].back().right_line = true;
-    }
-    row_info.back().bottom_line = true;
-    row_info.front().bottom_line = true;
-
-    for (int i = 0; i < columns_; ++i) {
-        calculate_width_of_column(i);
-    }
-    column_info.back().right_line = true;
+       rows_ = rows_arg;
+       columns_ = columns_arg;
+       row_info = row_vector(rows_, rowstruct());
+       column_info = column_vector(columns_, columnstruct());
+       cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct()));
+
+       int cellno = 0;
+       for (int i = 0; i < rows_; ++i) {
+               for (int j = 0; j < columns_; ++j) {
+                       cell_info[i][j].inset.setOwner(owner_);
+                       cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
+                       cell_info[i][j].cellno = cellno++;
+               }
+               cell_info[i].back().right_line = true;
+       }
+       row_info.back().bottom_line = true;
+       row_info.front().bottom_line = true;
+
+       for (int i = 0; i < columns_; ++i) {
+               calculate_width_of_column(i);
+       }
+       column_info.back().right_line = true;
    
-    calculate_width_of_tabular();
+       calculate_width_of_tabular();
 
-    rowofcell = vector<int>();
-    columnofcell = vector<int>();
-    set_row_column_number_info();
-    is_long_tabular = false;
-    rotate = false;
-    endhead = 0;
-    endfirsthead = 0;
-    endfoot = 0;
-    endlastfoot = 0;
+       rowofcell = vector<int>();
+       columnofcell = vector<int>();
+       set_row_column_number_info();
+       is_long_tabular = false;
+       rotate = false;
+       endhead = 0;
+       endfirsthead = 0;
+       endfoot = 0;
+       endlastfoot = 0;
 }
 
 
 void LyXTabular::AppendRow(int cell)
 {
-    ++rows_;
+       ++rows_;
    
-    int row = row_of_cell(cell);
+       int row = row_of_cell(cell);
 
-    row_vector::iterator rit = row_info.begin() + row;
-    row_info.insert(rit, rowstruct());
-    // now set the values of the row before
-    row_info[row] = row_info[row+1];
+       row_vector::iterator rit = row_info.begin() + row;
+       row_info.insert(rit, rowstruct());
+       // now set the values of the row before
+       row_info[row] = row_info[row+1];
 
 #if 0
-    cell_vvector::iterator cit = cell_info.begin() + row;
-    cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
+       cell_vvector::iterator cit = cell_info.begin() + row;
+       cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
 #else
-    cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
-                                                         cellstruct()));
+       cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
+                                                                                                                 cellstruct()));
 
-    for (int i = 0; i <= row; ++i) {
-       for (int j = 0; j < columns_; ++j) {
-           c_info[i][j] = cell_info[i][j];
+       for (int i = 0; i <= row; ++i) {
+               for (int j = 0; j < columns_; ++j) {
+                       c_info[i][j] = cell_info[i][j];
+               }
+       }
+       for (int i = row + 1; i < rows_; ++i) {
+               for (int j = 0; j < columns_; ++j) {
+                       c_info[i][j] = cell_info[i-1][j];
+               }
        }
-    }
-    for (int i = row + 1; i < rows_; ++i) {
+       cell_info = c_info;
+       ++row;
        for (int j = 0; j < columns_; ++j) {
-           c_info[i][j] = cell_info[i-1][j];
-       }
-    }
-    cell_info = c_info;
-    ++row;
-    for (int j = 0; j < columns_; ++j) {
-       cell_info[row][j].inset.clear();
-    }
+               cell_info[row][j].inset.clear();
+       }
 #endif
-    Reinit();
+       Reinit();
 }
 
 
 void LyXTabular::DeleteRow(int row)
 {
-    // Why make it so hard? (Lgb)
-    //if (!(rows_ - 1))
-    //return;
-    if (rows_ == 1) return; // Not allowed to delete last row
+       // Why make it so hard? (Lgb)
+       //if (!(rows_ - 1))
+       //return;
+       if (rows_ == 1) return; // Not allowed to delete last row
        
-    row_info.erase(row_info.begin() + row); //&row_info[row]);
-    cell_info.erase(cell_info.begin() + row); //&cell_info[row]);
-    --rows_;
-    Reinit();
+       row_info.erase(row_info.begin() + row); //&row_info[row]);
+       cell_info.erase(cell_info.begin() + row); //&cell_info[row]);
+       --rows_;
+       Reinit();
 }
 
 
 void LyXTabular::AppendColumn(int cell)
 {
-    ++columns_;
+       ++columns_;
    
-    cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
-                                                         cellstruct()));
-    int const column = column_of_cell(cell);
-    column_vector::iterator cit = column_info.begin() + column + 1;
-    column_info.insert(cit, columnstruct());
-    // set the column values of the column before
-    column_info[column+1] = column_info[column];
-
-    for (int i = 0; i < rows_; ++i) {
-        for (int j = 0; j <= column; ++j) {
-            c_info[i][j] = cell_info[i][j];
-        }
-        for (int j = column + 1; j < columns_; ++j) {
-            c_info[i][j] = cell_info[i][j - 1];
-        }
-        // care about multicolumns
-        if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
-            cell_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
-        }
-        if ((column + 1) == columns_ ||
-            cell_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN) {
-            cell_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
-        }
-    }
-    cell_info = c_info;
-    //++column;
-    for (int i = 0; i < rows_; ++i) {
-       //cell_info[i][column].inset.clear();
-       cell_info[i][column + 1].inset.clear();
-    }
-    Reinit();
+       cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
+                                                                                                                 cellstruct()));
+       int const column = column_of_cell(cell);
+       column_vector::iterator cit = column_info.begin() + column + 1;
+       column_info.insert(cit, columnstruct());
+       // set the column values of the column before
+       column_info[column+1] = column_info[column];
+
+       for (int i = 0; i < rows_; ++i) {
+               for (int j = 0; j <= column; ++j) {
+                       c_info[i][j] = cell_info[i][j];
+               }
+               for (int j = column + 1; j < columns_; ++j) {
+                       c_info[i][j] = cell_info[i][j - 1];
+               }
+               // care about multicolumns
+               if (cell_info[i][column + 1].multicolumn==CELL_BEGIN_OF_MULTICOLUMN) {
+                       cell_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
+               }
+               if ((column + 1) == columns_ ||
+                       cell_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN) {
+                       cell_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
+               }
+       }
+       cell_info = c_info;
+       //++column;
+       for (int i = 0; i < rows_; ++i) {
+               //cell_info[i][column].inset.clear();
+               cell_info[i][column + 1].inset.clear();
+       }
+       Reinit();
 }
 
 
 void LyXTabular::DeleteColumn(int column)
 {
-    // Similar to DeleteRow
-    //if (!(columns_ - 1))
-    //return;
-    if (columns_ == 1) return; // Not allowed to delete last column
+       // Similar to DeleteRow
+       //if (!(columns_ - 1))
+       //return;
+       if (columns_ == 1) return; // Not allowed to delete last column
         
-    column_info.erase(column_info.begin() + column);
-    for (int i = 0; i < rows_; ++i) {
-       cell_info[i].erase(cell_info[i].begin() + column);
-    }
-    --columns_;
-    Reinit();
+       column_info.erase(column_info.begin() + column);
+       for (int i = 0; i < rows_; ++i) {
+               cell_info[i].erase(cell_info[i].begin() + column);
+       }
+       --columns_;
+       Reinit();
 }
 
 
 void LyXTabular::Reinit()
 {   
-    for (int i = 0; i < rows_; ++i) {
-       for (int j = 0; j < columns_; ++j) {
-           cell_info[i][j].width_of_cell = 0;
-           cell_info[i][j].inset.setOwner(owner_);
+       for (int i = 0; i < rows_; ++i) {
+               for (int j = 0; j < columns_; ++j) {
+                       cell_info[i][j].width_of_cell = 0;
+                       cell_info[i][j].inset.setOwner(owner_);
+               }
        }
-    }
   
-    for (int i = 0; i < columns_; ++i) {
-       calculate_width_of_column(i);
-    }
-    calculate_width_of_tabular();
+       for (int i = 0; i < columns_; ++i) {
+               calculate_width_of_column(i);
+       }
+       calculate_width_of_tabular();
 
-    set_row_column_number_info();
+       set_row_column_number_info();
 }
 
 
 void LyXTabular::set_row_column_number_info(bool oldformat)
 {
-    numberofcells = -1;
-    for (int row = 0; row < rows_; ++row) {
-       for (int column = 0; column<columns_; ++column) {
-           if (cell_info[row][column].multicolumn
-               != LyXTabular::CELL_PART_OF_MULTICOLUMN)
-               ++numberofcells;
-           cell_info[row][column].cellno = numberofcells;
-       }
-    }
-    ++numberofcells; // because this is one more than as we start from 0
-
-    rowofcell.resize(numberofcells);
-    columnofcell.resize(numberofcells);
-
-    for (int row = 0, column = 0, c = 0;
-        c < numberofcells && row < rows_ && column < columns_;) {
-       rowofcell[c] = row;
-       columnofcell[c] = column;
-       ++c;
-       do {
-           ++column;
-       } while (column < columns_ &&
-                cell_info[row][column].multicolumn
-                == LyXTabular::CELL_PART_OF_MULTICOLUMN);
-       if (column == columns_) {
-           column = 0;
-           ++row;
-       }
-    }
-
-    for (int row = 0; row < rows_; ++row) {
-       for (int 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());
-       }
-    }
+       numberofcells = -1;
+       for (int row = 0; row < rows_; ++row) {
+               for (int column = 0; column<columns_; ++column) {
+                       if (cell_info[row][column].multicolumn
+                               != LyXTabular::CELL_PART_OF_MULTICOLUMN)
+                               ++numberofcells;
+                       cell_info[row][column].cellno = numberofcells;
+               }
+       }
+       ++numberofcells; // because this is one more than as we start from 0
+
+       rowofcell.resize(numberofcells);
+       columnofcell.resize(numberofcells);
+
+       for (int row = 0, column = 0, c = 0;
+                c < numberofcells && row < rows_ && column < columns_;) {
+               rowofcell[c] = row;
+               columnofcell[c] = column;
+               ++c;
+               do {
+                       ++column;
+               } while (column < columns_ &&
+                                cell_info[row][column].multicolumn
+                                == LyXTabular::CELL_PART_OF_MULTICOLUMN);
+               if (column == columns_) {
+                       column = 0;
+                       ++row;
+               }
+       }
+
+       for (int row = 0; row < rows_; ++row) {
+               for (int 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());
+               }
+       }
 }
 
 
 int LyXTabular::GetNumberOfCells() const
 {
-    return numberofcells;
+       return numberofcells;
 }
 
 
 int LyXTabular::NumberOfCellsInRow(int cell) const
 {
-    int const row = row_of_cell(cell);
-    int result = 0;
-    for (int i = 0; i < columns_; ++i) {
-       if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
-           ++result;
-    }
-    return result;
+       int const row = row_of_cell(cell);
+       int result = 0;
+       for (int i = 0; i < columns_; ++i) {
+               if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
+                       ++result;
+       }
+       return result;
 }
 
 
 /* returns 1 if there is a topline, returns 0 if not */ 
 bool LyXTabular::TopLine(int cell, bool onlycolumn) const
 {
-    int const row = row_of_cell(cell);
-    
-    if (!onlycolumn && IsMultiColumn(cell))
-        return cellinfo_of_cell(cell)->top_line;
-    return row_info[row].top_line;
+       int const row = row_of_cell(cell);
+       
+       if (!onlycolumn && IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->top_line;
+       return row_info[row].top_line;
 }
 
 
 bool LyXTabular::BottomLine(int cell, bool onlycolumn) const
 {
-    // no bottom line underneath non-existent cells if you please
-    // Isn't that a programming error? Is so this should
-    // be an Assert instead. (Lgb)
-    if (cell >= numberofcells)
-       return false;
+       // no bottom line underneath non-existent cells if you please
+       // Isn't that a programming error? Is so this should
+       // be an Assert instead. (Lgb)
+       if (cell >= numberofcells)
+               return false;
 
-    if (!onlycolumn && IsMultiColumn(cell))
-        return cellinfo_of_cell(cell)->bottom_line;
-    return row_info[row_of_cell(cell)].bottom_line;
+       if (!onlycolumn && IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->bottom_line;
+       return row_info[row_of_cell(cell)].bottom_line;
 }
 
 
 bool LyXTabular::LeftLine(int cell, bool onlycolumn) const
 {
-    if (!onlycolumn && IsMultiColumn(cell))
-        return cellinfo_of_cell(cell)->left_line;
-    return column_info[column_of_cell(cell)].left_line;
+       if (!onlycolumn && IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->left_line;
+       return column_info[column_of_cell(cell)].left_line;
 }
 
 
 bool LyXTabular::RightLine(int cell, bool onlycolumn) const
 {
-    if (!onlycolumn && IsMultiColumn(cell))
-        return cellinfo_of_cell(cell)->right_line;
-    return column_info[right_column_of_cell(cell)].right_line;
+       if (!onlycolumn && IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->right_line;
+       return column_info[right_column_of_cell(cell)].right_line;
 }
 
 
 bool LyXTabular::TopAlreadyDrawed(int cell) const
 {
-    if (GetAdditionalHeight(cell))
+       if (GetAdditionalHeight(cell))
+               return false;
+       int row = row_of_cell(cell);
+       if (row > 0) {
+               int column = column_of_cell(cell);
+               --row;
+               while (column
+                          && cell_info[row][column].multicolumn
+                          == LyXTabular::CELL_PART_OF_MULTICOLUMN)
+                       --column;
+               if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
+                       return row_info[row].bottom_line;
+               else
+                       return cell_info[row][column].bottom_line;
+       }
        return false;
-    int row = row_of_cell(cell);
-    if (row > 0) {
-       int column = column_of_cell(cell);
-       --row;
-       while (column
-              && cell_info[row][column].multicolumn
-              == LyXTabular::CELL_PART_OF_MULTICOLUMN)
-           --column;
-       if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
-           return row_info[row].bottom_line;
-       else
-           return cell_info[row][column].bottom_line;
-    }
-    return false;
 }
 
 
 bool LyXTabular::LeftAlreadyDrawed(int cell) const
 {
-    int column = column_of_cell(cell);
-    if (column > 0) {
-       int row = row_of_cell(cell);
-       while (--column &&
-              (cell_info[row][column].multicolumn ==
-               LyXTabular::CELL_PART_OF_MULTICOLUMN));
-       if (GetAdditionalWidth(cell_info[row][column].cellno))
-           return false;
-       return column_info[column].right_line;
-    }
-    return false;
+       int column = column_of_cell(cell);
+       if (column > 0) {
+               int row = row_of_cell(cell);
+               while (--column &&
+                          (cell_info[row][column].multicolumn ==
+                               LyXTabular::CELL_PART_OF_MULTICOLUMN));
+               if (GetAdditionalWidth(cell_info[row][column].cellno))
+                       return false;
+               return column_info[column].right_line;
+       }
+       return false;
 }
 
 
 bool LyXTabular::IsLastRow(int cell) const
 {
-    return (row_of_cell(cell) == rows_ - 1);
+       return (row_of_cell(cell) == rows_ - 1);
 }
 
 
 int LyXTabular::GetAdditionalHeight(int cell) const
 {
-    int const row = row_of_cell(cell);
-    if (!row) return 0;
+       int const row = row_of_cell(cell);
+       if (!row) return 0;
 
-    bool top = true;
-    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) {
-       case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
-           bottom = cell_info[row - 1][column].bottom_line;
-           break;
-       case LyXTabular::CELL_NORMAL:
-           bottom = row_info[row - 1].bottom_line;
+       for (int column = 0; column < columns_ - 1 && bottom; ++column) {
+               switch (cell_info[row - 1][column].multicolumn) {
+               case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
+                       bottom = cell_info[row - 1][column].bottom_line;
+                       break;
+               case LyXTabular::CELL_NORMAL:
+                       bottom = row_info[row - 1].bottom_line;
+               }
        }
-    }
-    for (int column = 0; column < columns_ - 1 && top; ++column) {
-       switch (cell_info[row][column].multicolumn){
-       case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
-           top = cell_info[row][column].top_line;
-           break;
-       case LyXTabular::CELL_NORMAL:
-           top = row_info[row].top_line;
+       for (int column = 0; column < columns_ - 1 && top; ++column) {
+               switch (cell_info[row][column].multicolumn){
+               case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
+                       top = cell_info[row][column].top_line;
+                       break;
+               case LyXTabular::CELL_NORMAL:
+                       top = row_info[row].top_line;
+               }
        }
-    }
-    if (top && bottom)
-       return WIDTH_OF_LINE;
-    return 0;
+       if (top && bottom)
+               return WIDTH_OF_LINE;
+       return 0;
 }
 
 
 int LyXTabular::GetAdditionalWidth(int cell) const
 {
-    // internally already set in SetWidthOfCell
-    // used to get it back in text.C
-    int const col = right_column_of_cell(cell);
-    if (col < columns_ - 1 && column_info[col].right_line &&
-       column_info[col+1].left_line)
-       return WIDTH_OF_LINE;
-    else
-       return 0;
+       // internally already set in SetWidthOfCell
+       // used to get it back in text.C
+       int const col = right_column_of_cell(cell);
+       if (col < columns_ - 1 && column_info[col].right_line &&
+               column_info[col+1].left_line)
+               return WIDTH_OF_LINE;
+       else
+               return 0;
 }
 
 
 // returns the maximum over all rows 
 int LyXTabular::GetWidthOfColumn(int cell) const
 {
-    int const column1 = column_of_cell(cell);
-    int const column2 = right_column_of_cell(cell);
-    int result = 0;
-    for (int i = column1; i <= column2; ++i) {
-       result += column_info[i].width_of_column;
-    }
-    return result;
+       int const column1 = column_of_cell(cell);
+       int const column2 = right_column_of_cell(cell);
+       int result = 0;
+       for (int i = column1; i <= column2; ++i) {
+               result += column_info[i].width_of_column;
+       }
+       return result;
 }
 
 
 int LyXTabular::GetWidthOfTabular() const
 {
-    return width_of_tabular;
+       return width_of_tabular;
 }
 
 
 /* returns 1 if a complete update is necessary, otherwise 0 */ 
 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
 {
-    if (!IsMultiColumn(cell))
-        return false;
-    
-    int const row = row_of_cell(cell);
-    int const column1 = column_of_cell(cell);
-    int const column2 = right_column_of_cell(cell);
+       if (!IsMultiColumn(cell))
+               return false;
+       
+       int const row = row_of_cell(cell);
+       int const column1 = column_of_cell(cell);
+       int const column2 = right_column_of_cell(cell);
 
-    // first set columns to 0 so we can calculate the right width
-    for (int i = column1; i <= column2; ++i) {
-        cell_info[row][i].width_of_cell = 0;
-    }
-    // set the width to MAX_WIDTH until width > 0
-    int width = (new_width + 2 * WIDTH_OF_LINE);
+       // first set columns to 0 so we can calculate the right width
+       for (int i = column1; i <= column2; ++i) {
+               cell_info[row][i].width_of_cell = 0;
+       }
+       // set the width to MAX_WIDTH until width > 0
+       int width = (new_width + 2 * WIDTH_OF_LINE);
 
-    int i = column1;
-    for (; i < column2 && width > column_info[i].width_of_column; ++i) {
-        cell_info[row][i].width_of_cell = column_info[i].width_of_column;
-        width -= column_info[i].width_of_column;
-    }
-    if (width > 0) {
-        cell_info[row][i].width_of_cell = width;
-    }
-    return true;
+       int i = column1;
+       for (; i < column2 && width > column_info[i].width_of_column; ++i) {
+               cell_info[row][i].width_of_cell = column_info[i].width_of_column;
+               width -= column_info[i].width_of_column;
+       }
+       if (width > 0) {
+               cell_info[row][i].width_of_cell = width;
+       }
+       return true;
 }
 
 
 void LyXTabular::recalculateMulticolCells(int cell, int new_width)
 {
-    int const row = row_of_cell(cell);
-    int const column1 = column_of_cell(cell);
-    int const column2 = right_column_of_cell(cell);
+       int const row = row_of_cell(cell);
+       int const column1 = column_of_cell(cell);
+       int const column2 = right_column_of_cell(cell);
 
-    // first set columns to 0 so we can calculate the right width
-    int i = column1;
-    for (; i <= column2; ++i)
-        cell_info[row][i].width_of_cell = 0;
-    for (i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
-        ;
-    if (i < numberofcells)
-        recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
-    SetWidthOfMulticolCell(cell, new_width);
+       // first set columns to 0 so we can calculate the right width
+       int i = column1;
+       for (; i <= column2; ++i)
+               cell_info[row][i].width_of_cell = 0;
+       for (i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
+               ;
+       if (i < numberofcells)
+               recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
+       SetWidthOfMulticolCell(cell, new_width);
 }
 
 
 /* returns 1 if a complete update is necessary, otherwise 0 */ 
 bool LyXTabular::SetWidthOfCell(int cell, int new_width)
 {
-    int const row = row_of_cell(cell);
-    int const column1 = column_of_cell(cell);
-    bool tmp = false;
-    int width = 0;
+       int const row = row_of_cell(cell);
+       int const column1 = column_of_cell(cell);
+       bool tmp = false;
+       int width = 0;
 
-    if (GetWidthOfCell(cell) == (new_width+2*WIDTH_OF_LINE))
+       if (GetWidthOfCell(cell) == (new_width+2*WIDTH_OF_LINE))
+               return false;
+       if (IsMultiColumn(cell, true)) {
+               tmp = SetWidthOfMulticolCell(cell, new_width);
+       } else {
+               width = (new_width + 2*WIDTH_OF_LINE);
+               cell_info[row][column1].width_of_cell = width;
+               if (column_info[column1].right_line && (column1 < columns_-1) &&
+                       column_info[column1+1].left_line) // additional width
+                       cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
+               tmp = calculate_width_of_column_NMC(column1);
+       }
+       if (tmp) {
+               int i = 0;
+               for (; i<columns_; ++i)
+                       calculate_width_of_column_NMC(i);
+               for (i = 0; (i < numberofcells) && !IsMultiColumn(i); ++i)
+                       ;
+               if (i < numberofcells)
+                       recalculateMulticolCells(i, GetWidthOfCell(i)-(2 * WIDTH_OF_LINE));
+               for (i = 0; i < columns_; ++i)
+                       calculate_width_of_column(i);
+               calculate_width_of_tabular();
+               return true;
+       }
        return false;
-    if (IsMultiColumn(cell, true)) {
-        tmp = SetWidthOfMulticolCell(cell, new_width);
-    } else {
-       width = (new_width + 2*WIDTH_OF_LINE);
-        cell_info[row][column1].width_of_cell = width;
-        if (column_info[column1].right_line && (column1 < columns_-1) &&
-            column_info[column1+1].left_line) // additional width
-            cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
-        tmp = calculate_width_of_column_NMC(column1);
-    }
-    if (tmp) {
-        int i = 0;
-        for (; i<columns_; ++i)
-            calculate_width_of_column_NMC(i);
-        for (i = 0; (i < numberofcells) && !IsMultiColumn(i); ++i)
-            ;
-        if (i < numberofcells)
-            recalculateMulticolCells(i, GetWidthOfCell(i)-(2 * WIDTH_OF_LINE));
-        for (i = 0; i < columns_; ++i)
-            calculate_width_of_column(i);
-        calculate_width_of_tabular();
-        return true;
-    }
-    return false;
 }
 
 
 bool LyXTabular::SetAlignment(int cell, LyXAlignment align, bool onlycolumn)
 {
-    if (!IsMultiColumn(cell) || onlycolumn)
-        column_info[column_of_cell(cell)].alignment = align;
-    if (!onlycolumn)
-       cellinfo_of_cell(cell)->alignment = align;
-    return true;
+       if (!IsMultiColumn(cell) || onlycolumn)
+               column_info[column_of_cell(cell)].alignment = align;
+       if (!onlycolumn)
+               cellinfo_of_cell(cell)->alignment = align;
+       return true;
 }
 
 
 bool LyXTabular::SetVAlignment(int cell, VAlignment align, bool onlycolumn)
 {
-    if (!IsMultiColumn(cell) || onlycolumn)
-        column_info[column_of_cell(cell)].valignment = align;
-    if (!onlycolumn)
-       cellinfo_of_cell(cell)->valignment = align;
-    return true;
+       if (!IsMultiColumn(cell) || onlycolumn)
+               column_info[column_of_cell(cell)].valignment = align;
+       if (!onlycolumn)
+               cellinfo_of_cell(cell)->valignment = align;
+       return true;
 }
 
 
 bool LyXTabular::SetColumnPWidth(int cell, string const & width)
 {
-    bool flag = !width.empty();
-    int const j = column_of_cell(cell);
+       bool flag = !width.empty();
+       int const j = column_of_cell(cell);
 
-    column_info[j].p_width = width;
-    if (flag) // do this only if there is a width
-       SetAlignment(cell, LYX_ALIGN_LEFT);
-    for (int i = 0; i < rows_; ++i) {
-       int c = GetCellNumber(i, j);
-       flag = !GetPWidth(c).empty(); // because of multicolumns!
-       GetCellInset(c)->SetAutoBreakRows(flag);
-    }
-    return true;
+       column_info[j].p_width = width;
+       if (flag) // do this only if there is a width
+               SetAlignment(cell, LYX_ALIGN_LEFT);
+       for (int i = 0; i < rows_; ++i) {
+               int c = GetCellNumber(i, j);
+               flag = !GetPWidth(c).empty(); // because of multicolumns!
+               GetCellInset(c)->SetAutoBreakRows(flag);
+       }
+       return true;
 }
 
 
 bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
 {
-    bool const flag = !width.empty();
+       bool const flag = !width.empty();
 
-    cellinfo_of_cell(cell)->p_width = width;
-    if (IsMultiColumn(cell)) {
-       GetCellInset(cell)->SetAutoBreakRows(flag);
-       return true;
-    }
-    return false;
+       cellinfo_of_cell(cell)->p_width = width;
+       if (IsMultiColumn(cell)) {
+               GetCellInset(cell)->SetAutoBreakRows(flag);
+               return true;
+       }
+       return false;
 }
 
 
 bool LyXTabular::SetAlignSpecial(int cell, string const & special,
-                                LyXTabular::Feature what)
+                                                                LyXTabular::Feature what)
 {
-    if (what == SET_SPECIAL_MULTI)
-        cellinfo_of_cell(cell)->align_special = special;
-    else
-        column_info[column_of_cell(cell)].align_special = special;
-    return true;
+       if (what == SET_SPECIAL_MULTI)
+               cellinfo_of_cell(cell)->align_special = special;
+       else
+               column_info[column_of_cell(cell)].align_special = special;
+       return true;
 }
 
 
 bool LyXTabular::SetAllLines(int cell, bool line)
 {
-    SetTopLine(cell, line);
-    SetBottomLine(cell, line);
-    SetRightLine(cell, line);
-    SetLeftLine(cell, line);
-    return true;
+       SetTopLine(cell, line);
+       SetBottomLine(cell, line);
+       SetRightLine(cell, line);
+       SetLeftLine(cell, line);
+       return true;
 }
 
 
 bool LyXTabular::SetTopLine(int cell, bool line, bool onlycolumn)
 {
-    int const row = row_of_cell(cell);
+       int const row = row_of_cell(cell);
 
-    if (onlycolumn || !IsMultiColumn(cell))
-        row_info[row].top_line = line;
-    else
-        cellinfo_of_cell(cell)->top_line = line;
-    return true;
+       if (onlycolumn || !IsMultiColumn(cell))
+               row_info[row].top_line = line;
+       else
+               cellinfo_of_cell(cell)->top_line = line;
+       return true;
 }
 
 
 bool LyXTabular::SetBottomLine(int cell, bool line, bool onlycolumn)
 {
-    if (onlycolumn || !IsMultiColumn(cell))
-        row_info[row_of_cell(cell)].bottom_line = line;
-    else
-        cellinfo_of_cell(cell)->bottom_line = line;
-    return true;
+       if (onlycolumn || !IsMultiColumn(cell))
+               row_info[row_of_cell(cell)].bottom_line = line;
+       else
+               cellinfo_of_cell(cell)->bottom_line = line;
+       return true;
 }
 
 
 bool LyXTabular::SetLeftLine(int cell, bool line, bool onlycolumn)
 {
-    if (onlycolumn || !IsMultiColumn(cell))
-       column_info[column_of_cell(cell)].left_line = line;
-    else
-        cellinfo_of_cell(cell)->left_line = line;
-    return true;
+       if (onlycolumn || !IsMultiColumn(cell))
+               column_info[column_of_cell(cell)].left_line = line;
+       else
+               cellinfo_of_cell(cell)->left_line = line;
+       return true;
 }
 
 
 bool LyXTabular::SetRightLine(int cell, bool line, bool onlycolumn)
 {
-    if (onlycolumn || !IsMultiColumn(cell))
-       column_info[right_column_of_cell(cell)].right_line = line;
-    else
-        cellinfo_of_cell(cell)->right_line = line;
-    return true;
+       if (onlycolumn || !IsMultiColumn(cell))
+               column_info[right_column_of_cell(cell)].right_line = line;
+       else
+               cellinfo_of_cell(cell)->right_line = line;
+       return true;
 }
 
 
 LyXAlignment LyXTabular::GetAlignment(int cell, bool onlycolumn) const
 {
-    if (!onlycolumn && IsMultiColumn(cell))
-       return cellinfo_of_cell(cell)->alignment;
-    else
-       return column_info[column_of_cell(cell)].alignment;
+       if (!onlycolumn && IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->alignment;
+       else
+               return column_info[column_of_cell(cell)].alignment;
 }
 
 
 LyXTabular::VAlignment
 LyXTabular::GetVAlignment(int cell, bool onlycolumn) const
 {
-    if (!onlycolumn && IsMultiColumn(cell))
-       return cellinfo_of_cell(cell)->valignment;
-    else
-       return column_info[column_of_cell(cell)].valignment;
+       if (!onlycolumn && IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->valignment;
+       else
+               return column_info[column_of_cell(cell)].valignment;
 }
 
 
 string const LyXTabular::GetPWidth(int cell) const
 {
-    if (IsMultiColumn(cell))
-       return cellinfo_of_cell(cell)->p_width;
-    return column_info[column_of_cell(cell)].p_width;
+       if (IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->p_width;
+       return column_info[column_of_cell(cell)].p_width;
 }
 
 
 string const LyXTabular::GetColumnPWidth(int cell) const
 {
-    return column_info[column_of_cell(cell)].p_width;
+       return column_info[column_of_cell(cell)].p_width;
 }
 
 
 string const LyXTabular::GetMColumnPWidth(int cell) const
 {
-    if (IsMultiColumn(cell))
-       return cellinfo_of_cell(cell)->p_width;
-    return string();
+       if (IsMultiColumn(cell))
+               return cellinfo_of_cell(cell)->p_width;
+       return string();
 }
 
 
 string const LyXTabular::GetAlignSpecial(int cell, int what) const
 {
-    if (what == SET_SPECIAL_MULTI)
-        return cellinfo_of_cell(cell)->align_special;
-    return column_info[column_of_cell(cell)].align_special;
+       if (what == SET_SPECIAL_MULTI)
+               return cellinfo_of_cell(cell)->align_special;
+       return column_info[column_of_cell(cell)].align_special;
 }
 
 
 int LyXTabular::GetWidthOfCell(int cell) const
 {
-    int const row = row_of_cell(cell);
-    int const column1 = column_of_cell(cell);
-    int const column2 = right_column_of_cell(cell);
-    int result = 0;
-    for (int i = column1; i <= column2; ++i) {
-       result += cell_info[row][i].width_of_cell;
-    }
-    return result;
+       int const row = row_of_cell(cell);
+       int const column1 = column_of_cell(cell);
+       int const column2 = right_column_of_cell(cell);
+       int result = 0;
+       for (int i = column1; i <= column2; ++i) {
+               result += cell_info[row][i].width_of_cell;
+       }
+       return result;
 }
 
 
 int LyXTabular::GetBeginningOfTextInCell(int cell) const
 {
-    int x = 0;
+       int x = 0;
    
-    switch (GetAlignment(cell)){
-    case LYX_ALIGN_CENTER:
-       x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
-       break;
-    case LYX_ALIGN_RIGHT:
-       x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
-       // + GetAdditionalWidth(cell);
-       break;
-    default: /* LYX_ALIGN_LEFT: nothing :-) */ 
-       break;
-    }
-    
-    // the LaTeX Way :-(
-    x += WIDTH_OF_LINE;
-    return x;
+       switch (GetAlignment(cell)){
+       case LYX_ALIGN_CENTER:
+               x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
+               break;
+       case LYX_ALIGN_RIGHT:
+               x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
+               // + GetAdditionalWidth(cell);
+               break;
+       default: /* LYX_ALIGN_LEFT: nothing :-) */ 
+               break;
+       }
+       
+       // the LaTeX Way :-(
+       x += WIDTH_OF_LINE;
+       return x;
 }
 
 
 bool LyXTabular::IsFirstCellInRow(int cell) const
 {
-    return column_of_cell(cell) == 0;
+       return column_of_cell(cell) == 0;
 }
 
 
 int LyXTabular::GetFirstCellInRow(int row) const
 {
-    if (row > (rows_-1))
-       row = rows_ - 1;
-    return cell_info[row][0].cellno;
+       if (row > (rows_-1))
+               row = rows_ - 1;
+       return cell_info[row][0].cellno;
 }
 
 bool LyXTabular::IsLastCellInRow(int cell) const
 {
-    return (right_column_of_cell(cell) == (columns_ - 1));
+       return (right_column_of_cell(cell) == (columns_ - 1));
 }
 
 
 int LyXTabular::GetLastCellInRow(int row) const
 {
-    if (row > (rows_-1))
-       row = rows_ - 1;
-    return cell_info[row][columns_-1].cellno;
+       if (row > (rows_-1))
+               row = rows_ - 1;
+       return cell_info[row][columns_-1].cellno;
 }
 
 
 bool LyXTabular::calculate_width_of_column(int column)
 {
-    int const old_column_width = column_info[column].width_of_column;
-    int maximum = 0;
-    
-    for (int i = 0; i < rows_; ++i) {
-       maximum = max(cell_info[i][column].width_of_cell, maximum);
-    }
-    column_info[column].width_of_column = maximum;
-    return (column_info[column].width_of_column != old_column_width);
+       int const old_column_width = column_info[column].width_of_column;
+       int maximum = 0;
+       
+       for (int i = 0; i < rows_; ++i) {
+               maximum = max(cell_info[i][column].width_of_cell, maximum);
+       }
+       column_info[column].width_of_column = maximum;
+       return (column_info[column].width_of_column != old_column_width);
 }
 
 
@@ -859,56 +859,56 @@ bool LyXTabular::calculate_width_of_column(int column)
 //
 bool LyXTabular::calculate_width_of_column_NMC(int column)
 {
-    int const old_column_width = column_info[column].width_of_column;
-    int max = 0;
-    for (int i = 0; i < rows_; ++i) {
-        if (!IsMultiColumn(GetCellNumber(i, column), true) &&
-            (cell_info[i][column].width_of_cell > max)) {
-            max = cell_info[i][column].width_of_cell;
-        }
-    }
-    column_info[column].width_of_column = max;
-    return (column_info[column].width_of_column != old_column_width);
+       int const old_column_width = column_info[column].width_of_column;
+       int max = 0;
+       for (int i = 0; i < rows_; ++i) {
+               if (!IsMultiColumn(GetCellNumber(i, column), true) &&
+                       (cell_info[i][column].width_of_cell > max)) {
+                       max = cell_info[i][column].width_of_cell;
+               }
+       }
+       column_info[column].width_of_column = max;
+       return (column_info[column].width_of_column != old_column_width);
 }
 
 
 void LyXTabular::calculate_width_of_tabular()
 {
-    width_of_tabular = 0;
-    for (int i = 0; i < columns_; ++i) {
-       width_of_tabular += column_info[i].width_of_column;
-    }
+       width_of_tabular = 0;
+       for (int i = 0; i < columns_; ++i) {
+               width_of_tabular += column_info[i].width_of_column;
+       }
 }
 
 
 int LyXTabular::row_of_cell(int cell) const
 {
-    if (cell >= numberofcells)
-        return rows_ - 1;
-    else if (cell < 0)
-        return 0;
-    return rowofcell[cell];
+       if (cell >= numberofcells)
+               return rows_ - 1;
+       else if (cell < 0)
+               return 0;
+       return rowofcell[cell];
 }
 
 
 int LyXTabular::column_of_cell(int cell) const
 {
-    if (cell >= numberofcells)
-        return columns_ - 1;
-    else if (cell < 0)
-        return 0;
-    return columnofcell[cell];
+       if (cell >= numberofcells)
+               return columns_ - 1;
+       else if (cell < 0)
+               return 0;
+       return columnofcell[cell];
 }
 
 
 int LyXTabular::right_column_of_cell(int cell) const
 {
-    int const row = row_of_cell(cell);
-    int column = column_of_cell(cell);
-    while (column < (columns_ - 1) &&
-          cell_info[row][column + 1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
-       ++column;
-    return column;
+       int const row = row_of_cell(cell);
+       int column = column_of_cell(cell);
+       while (column < (columns_ - 1) &&
+                  cell_info[row][column + 1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
+               ++column;
+       return column;
 }
 
 
@@ -917,8 +917,8 @@ int LyXTabular::right_column_of_cell(int cell) const
 template<class T>
 string const write_attribute(string const & name, T const & t)
 {
-     string str = " " + name + "=\"" + tostr(t) + "\"";
-     return str;
+       string str = " " + name + "=\"" + tostr(t) + "\"";
+       return str;
 }
 
 template <>
@@ -931,22 +931,22 @@ string const write_attribute(string const & name, bool const & b)
 
 string const write_attribute(string const & name, int value)
 {
-    string str = " " + name + "=\"" + tostr(value) + "\"";
-    return str;
+       string str = " " + name + "=\"" + tostr(value) + "\"";
+       return str;
 }
 
 
 string const write_attribute(string const & name, string const & value)
 {
-    string str = " " + name + "=\"" + value + "\"";
-    return str;
+       string str = " " + name + "=\"" + value + "\"";
+       return str;
 }
 
 
 string const write_attribute(string const & name, bool value)
 {
-    string str = " " + name + "=\"" + tostr(static_cast<int>(value)) + "\"";
-    return str;
+       string str = " " + name + "=\"" + tostr(static_cast<int>(value)) + "\"";
+       return str;
 }
 #endif
 
@@ -955,23 +955,23 @@ template<>
 inline
 string const tostr(LyXAlignment const & num)
 {
-    switch(num) {
-    case LYX_ALIGN_NONE:
-       return "none";
-    case LYX_ALIGN_BLOCK:
-       return "block";
-    case LYX_ALIGN_LEFT:
-       return "left";
-    case LYX_ALIGN_CENTER:
-       return "center";
-    case LYX_ALIGN_RIGHT:
-       return "right";
-    case LYX_ALIGN_LAYOUT:
-       return "layout";
-    case LYX_ALIGN_SPECIAL:
-       return "special";
-    }
-    return string();
+       switch(num) {
+       case LYX_ALIGN_NONE:
+               return "none";
+       case LYX_ALIGN_BLOCK:
+               return "block";
+       case LYX_ALIGN_LEFT:
+               return "left";
+       case LYX_ALIGN_CENTER:
+               return "center";
+       case LYX_ALIGN_RIGHT:
+               return "right";
+       case LYX_ALIGN_LAYOUT:
+               return "layout";
+       case LYX_ALIGN_SPECIAL:
+               return "special";
+       }
+       return string();
 }
 
 
@@ -979,15 +979,15 @@ template<>
 inline
 string const tostr(LyXTabular::VAlignment const & num)
 {
-    switch(num) {
-    case LyXTabular::LYX_VALIGN_TOP:
-       return "top";
-    case LyXTabular::LYX_VALIGN_CENTER:
-       return "center";
-    case LyXTabular::LYX_VALIGN_BOTTOM:
-       return "bottom";
-    }
-    return string();
+       switch(num) {
+       case LyXTabular::LYX_VALIGN_TOP:
+               return "top";
+       case LyXTabular::LYX_VALIGN_CENTER:
+               return "center";
+       case LyXTabular::LYX_VALIGN_BOTTOM:
+               return "bottom";
+       }
+       return string();
 }
 
 
@@ -995,94 +995,75 @@ template<>
 inline
 string const tostr(LyXTabular::BoxType const & num)
 {
-    switch(num) {
-    case LyXTabular::BOX_NONE:
-       return "none";
-    case LyXTabular::BOX_PARBOX:
-       return "parbox";
-    case LyXTabular::BOX_MINIPAGE:
-       return "minipage";
-    }
-    return string();
+       switch(num) {
+       case LyXTabular::BOX_NONE:
+               return "none";
+       case LyXTabular::BOX_PARBOX:
+               return "parbox";
+       case LyXTabular::BOX_MINIPAGE:
+               return "minipage";
+       }
+       return string();
 }
 
 
 void LyXTabular::Write(Buffer const * buf, ostream & os) const
 {
-    // header line
-    os << "<lyxtabular"
-       << write_attribute("version", 2)
-       << write_attribute("rows", rows_)
-       << write_attribute("columns", columns_)
-       << ">\n";
-    // global longtable options
-    os << "<features"
-       << write_attribute("rotate", tostr(rotate))
-       << write_attribute("islongtable", tostr(is_long_tabular))
-       << write_attribute("endhead", endhead)
-       << write_attribute("endfirsthead", endfirsthead)
-       << write_attribute("endfoot", endfoot)
-       << write_attribute("endlastfoot", endlastfoot)
-       << ">\n";
-    for (int j = 0; j < columns_; ++j) {
-       os << "<column"
-          << write_attribute("alignment", tostr(column_info[j].alignment))
-          << write_attribute("valignment", tostr(column_info[j].valignment))
-          << write_attribute("leftline", tostr(column_info[j].left_line))
-          << write_attribute("rightline", tostr(column_info[j].right_line))
-          << write_attribute("width",
-                             VSpace(column_info[j].p_width)
-                             .asLyXCommand())
-          << write_attribute("special", column_info[j].align_special)
+       // header line
+       os << "<lyxtabular"
+          << write_attribute("version", 2)
+          << write_attribute("rows", rows_)
+          << write_attribute("columns", columns_)
           << ">\n";
-    }
-    for (int i = 0; i < rows_; ++i) {
-       os << "<row"
-          << write_attribute("topline", tostr(row_info[i].top_line))
-          << write_attribute("bottomline", tostr(row_info[i].bottom_line))
-          << write_attribute("newpage", tostr(row_info[i].newpage))
+       // global longtable options
+       os << "<features"
+          << write_attribute("rotate", tostr(rotate))
+          << write_attribute("islongtable", tostr(is_long_tabular))
+          << write_attribute("endhead", endhead)
+          << write_attribute("endfirsthead", endfirsthead)
+          << write_attribute("endfoot", endfoot)
+          << write_attribute("endlastfoot", endlastfoot)
           << ">\n";
        for (int j = 0; j < columns_; ++j) {
-#if 0
-           if (!i) {
                os << "<column"
                   << write_attribute("alignment", tostr(column_info[j].alignment))
                   << write_attribute("valignment", tostr(column_info[j].valignment))
                   << write_attribute("leftline", tostr(column_info[j].left_line))
                   << write_attribute("rightline", tostr(column_info[j].right_line))
                   << write_attribute("width",
-                                     VSpace(column_info[j].p_width)
-                                     .asLyXCommand())
+                                                         VSpace(column_info[j].p_width)
+                                                         .asLyXCommand())
                   << write_attribute("special", column_info[j].align_special)
                   << ">\n";
-           } else {
-               os << "<column>\n";
-           }
-#endif
-           os << "<cell"
-              << write_attribute("multicolumn", cell_info[i][j].multicolumn)
-              << write_attribute("alignment", tostr(cell_info[i][j].alignment))
-              << write_attribute("valignment", tostr(cell_info[i][j].valignment))
-              << write_attribute("topline", tostr(cell_info[i][j].top_line))
-              << write_attribute("bottomline", tostr(cell_info[i][j].bottom_line))
-              << write_attribute("leftline", tostr(cell_info[i][j].left_line))
-              << write_attribute("rightline", tostr(cell_info[i][j].right_line))
-              << write_attribute("rotate", tostr(cell_info[i][j].rotate))
-              << write_attribute("usebox", tostr(cell_info[i][j].usebox))
-              << write_attribute("width", cell_info[i][j].p_width)
-              << write_attribute("special", cell_info[i][j].align_special)
-              << ">\n";
-           os << "\\begin_inset ";
-           cell_info[i][j].inset.Write(buf, os);
-           os << "\n\\end_inset \n"
-              << "</cell>\n";
-#if 0
-              << "</column>\n";
-#endif
        }
-       os << "</row>\n";
-    }
-    os << "</lyxtabular>\n";
+       for (int i = 0; i < rows_; ++i) {
+               os << "<row"
+                  << write_attribute("topline", tostr(row_info[i].top_line))
+                  << write_attribute("bottomline", tostr(row_info[i].bottom_line))
+                  << write_attribute("newpage", tostr(row_info[i].newpage))
+                  << ">\n";
+               for (int j = 0; j < columns_; ++j) {
+                       os << "<cell"
+                          << write_attribute("multicolumn", cell_info[i][j].multicolumn)
+                          << write_attribute("alignment", tostr(cell_info[i][j].alignment))
+                          << write_attribute("valignment", tostr(cell_info[i][j].valignment))
+                          << write_attribute("topline", tostr(cell_info[i][j].top_line))
+                          << write_attribute("bottomline", tostr(cell_info[i][j].bottom_line))
+                          << write_attribute("leftline", tostr(cell_info[i][j].left_line))
+                          << write_attribute("rightline", tostr(cell_info[i][j].right_line))
+                          << write_attribute("rotate", tostr(cell_info[i][j].rotate))
+                          << write_attribute("usebox", tostr(cell_info[i][j].usebox))
+                          << write_attribute("width", cell_info[i][j].p_width)
+                          << write_attribute("special", cell_info[i][j].align_special)
+                          << ">\n";
+                       os << "\\begin_inset ";
+                       cell_info[i][j].inset.Write(buf, os);
+                       os << "\n\\end_inset \n"
+                          << "</cell>\n";
+               }
+               os << "</row>\n";
+       }
+       os << "</lyxtabular>\n";
 }
 
 
@@ -1093,144 +1074,144 @@ namespace {
 inline
 bool string2type(string const str, LyXAlignment & num)
 {
-    if (str == "none")
-       num = LYX_ALIGN_NONE;
-    else if (str == "block")
-       num = LYX_ALIGN_BLOCK;
-    else if (str == "left")
-       num = LYX_ALIGN_LEFT;
-    else if (str == "center")
-       num = LYX_ALIGN_CENTER;
-    else if (str == "right")
-       num = LYX_ALIGN_RIGHT;
-    else
-       return false;
-    return true;
+       if (str == "none")
+               num = LYX_ALIGN_NONE;
+       else if (str == "block")
+               num = LYX_ALIGN_BLOCK;
+       else if (str == "left")
+               num = LYX_ALIGN_LEFT;
+       else if (str == "center")
+               num = LYX_ALIGN_CENTER;
+       else if (str == "right")
+               num = LYX_ALIGN_RIGHT;
+       else
+               return false;
+       return true;
 }
 
 
 inline
 bool string2type(string const str, LyXTabular::VAlignment & num)
 {
-    if (str == "top")
-       num = LyXTabular::LYX_VALIGN_TOP;
-    else if (str == "center")
-       num = LyXTabular::LYX_VALIGN_CENTER;
-    else if (str == "bottom")
-       num = LyXTabular::LYX_VALIGN_BOTTOM;
-    else
-       return false;
-    return true;
+       if (str == "top")
+               num = LyXTabular::LYX_VALIGN_TOP;
+       else if (str == "center")
+               num = LyXTabular::LYX_VALIGN_CENTER;
+       else if (str == "bottom")
+               num = LyXTabular::LYX_VALIGN_BOTTOM;
+       else
+               return false;
+       return true;
 }
 
 
 inline
 bool string2type(string const str, LyXTabular::BoxType & num)
 {
-    if (str == "none")
-       num = LyXTabular::BOX_NONE;
-    else if (str == "parbox")
-       num = LyXTabular::BOX_PARBOX;
-    else if (str == "minipage")
-       num = LyXTabular::BOX_MINIPAGE;
-    else
-       return false;
-    return true;
+       if (str == "none")
+               num = LyXTabular::BOX_NONE;
+       else if (str == "parbox")
+               num = LyXTabular::BOX_PARBOX;
+       else if (str == "minipage")
+               num = LyXTabular::BOX_MINIPAGE;
+       else
+               return false;
+       return true;
 }
 
 
 inline
 bool string2type(string const str, bool & num)
 {
-    if (str == "true")
-       num = true;
-    else if (str == "false")
-       num = false;
-    else
-       return false;
-    return true;
+       if (str == "true")
+               num = true;
+       else if (str == "false")
+               num = false;
+       else
+               return false;
+       return true;
 }
 
 
 bool getTokenValue(string const & str, const char * token, string & ret)
 {
-    size_t token_length = strlen(token);
-    string::size_type pos = str.find(token);
-
-    if (pos == string::npos || pos+token_length+1 >= str.length()
-       || str[pos+token_length] != '=')
-       return false;
-    ret.erase();
-    pos += token_length + 1;
-    char ch = str[pos];
-    if ((ch != '"') && (ch != '\'')) { // only read till next space
-       ret += ch;
-       ch = ' ';
-    }
-    while((pos < str.length() - 1) && (str[++pos] != ch))
-       ret += str[pos];
+       size_t token_length = strlen(token);
+       string::size_type pos = str.find(token);
+
+       if (pos == string::npos || pos+token_length+1 >= str.length()
+               || str[pos+token_length] != '=')
+               return false;
+       ret.erase();
+       pos += token_length + 1;
+       char ch = str[pos];
+       if ((ch != '"') && (ch != '\'')) { // only read till next space
+               ret += ch;
+               ch = ' ';
+       }
+       while((pos < str.length() - 1) && (str[++pos] != ch))
+               ret += str[pos];
 
-    return true;
+       return true;
 }
 
 
 bool getTokenValue(string const & str, const char * token, int & num)
 {
-    string tmp;
-    if (!getTokenValue(str, token, tmp))
-       return false;
-    num = strToInt(tmp);
-    return true;
+       string tmp;
+       if (!getTokenValue(str, token, tmp))
+               return false;
+       num = strToInt(tmp);
+       return true;
 }
 
 
 bool getTokenValue(string const & str, const char * token, LyXAlignment & num)
 {
-    string tmp;
-    if (!getTokenValue(str, token, tmp))
-       return false;
-    return string2type(tmp, num);
+       string tmp;
+       if (!getTokenValue(str, token, tmp))
+               return false;
+       return string2type(tmp, num);
 }
 
 
 bool getTokenValue(string const & str, const char * token,
-                  LyXTabular::VAlignment & num)
+                                  LyXTabular::VAlignment & num)
 {
-    string tmp;
-    if (!getTokenValue(str, token, tmp))
-       return false;
-    return string2type(tmp, num);
+       string tmp;
+       if (!getTokenValue(str, token, tmp))
+               return false;
+       return string2type(tmp, num);
 }
 
 
 bool getTokenValue(string const & str, const char * token,
-                  LyXTabular::BoxType & num)
+                                  LyXTabular::BoxType & num)
 {
-    string tmp;
-    if (!getTokenValue(str, token, tmp))
-       return false;
-    return string2type(tmp, num);
+       string tmp;
+       if (!getTokenValue(str, token, tmp))
+               return false;
+       return string2type(tmp, num);
 }
 
 
 bool getTokenValue(string const & str, const char * token, bool & flag)
 {
-    string tmp;
-    if (!getTokenValue(str, token, tmp))
-       return false;
-    return string2type(tmp, flag);
+       string tmp;
+       if (!getTokenValue(str, token, tmp))
+               return false;
+       return string2type(tmp, flag);
 }    
 
 
 inline
 void l_getline(istream & is, string & str)
 {
-    str.erase();
-    while (str.empty()) {
-       getline(is, str);
-       if (!str.empty() && str[str.length() - 1] == '\r')
-           str.erase(str.length() - 1);
-    }
+       str.erase();
+       while (str.empty()) {
+               getline(is, str);
+               if (!str.empty() && str[str.length() - 1] == '\r')
+                       str.erase(str.length() - 1);
+       }
 }
 
 } // namespace anon
@@ -1243,7 +1224,7 @@ void LyXTabular::Read(Buffer const * buf, LyXLex & lex)
 
        l_getline(is, line);
        if (!prefixIs(line, "<lyxtabular ")
-           && !prefixIs(line, "<LyXTabular ")) {
+               && !prefixIs(line, "<LyXTabular ")) {
                OldFormatRead(lex, line);
                return;
        }
@@ -1259,1332 +1240,1333 @@ void LyXTabular::Read(Buffer const * buf, LyXLex & lex)
 
 
 void LyXTabular::ReadNew(Buffer const * buf, istream & is,
-                        LyXLex & lex, string const & l)
-{
-    string line(l);
-    int rows_arg;
-    if (!getTokenValue(line, "rows", rows_arg))
-       return;
-    int columns_arg;
-    if (!getTokenValue(line, "columns", columns_arg))
-       return;
-    Init(rows_arg, columns_arg);
-    l_getline(is, line);
-    if (!prefixIs(line, "<features")) {
-       lyxerr << "Wrong tabular format (expected <features ...> got" <<
-           line << ")" << endl;
-       return;
-    }
-    getTokenValue(line, "rotate", rotate);
-    getTokenValue(line, "islongtable", is_long_tabular);
-    getTokenValue(line, "endhead", endhead);
-    getTokenValue(line, "endfirsthead", endfirsthead);
-    getTokenValue(line, "endfoot", endfoot);
-    getTokenValue(line, "endlastfoot", endlastfoot);
-
-    for (int j = 0; j < columns_; ++j) {
-       l_getline(is,line);
-       if (!prefixIs(line,"<column")) {
-           lyxerr << "Wrong tabular format (expected <column ...> got" <<
-               line << ")" << endl;
-           return;
-       }
-       getTokenValue(line, "alignment", column_info[j].alignment);
-       getTokenValue(line, "valignment", column_info[j].valignment);
-       getTokenValue(line, "leftline", column_info[j].left_line);
-       getTokenValue(line, "rightline", column_info[j].right_line);
-       getTokenValue(line, "width", column_info[j].p_width);
-       getTokenValue(line, "special", column_info[j].align_special);
-    }
-
-    for (int i = 0; i < rows_; ++i) {
+                                                LyXLex & lex, string const & l)
+{
+       string line(l);
+       int rows_arg;
+       if (!getTokenValue(line, "rows", rows_arg))
+               return;
+       int columns_arg;
+       if (!getTokenValue(line, "columns", columns_arg))
+               return;
+       Init(rows_arg, columns_arg);
        l_getline(is, line);
-       if (!prefixIs(line, "<row")) {
-           lyxerr << "Wrong tabular format (expected <row ...> got" <<
-               line << ")" << endl;
-           return;
-       }
-       getTokenValue(line, "topline", row_info[i].top_line);
-       getTokenValue(line, "bottomline", row_info[i].bottom_line);
-       getTokenValue(line, "newpage", row_info[i].newpage);
-       for (int j = 0; j < columns_; ++j) {
-           l_getline(is, line);
-           if (!prefixIs(line, "<cell")) {
-               lyxerr << "Wrong tabular format (expected <cell ...> got" <<
-                   line << ")" << endl;
+       if (!prefixIs(line, "<features")) {
+               lyxerr << "Wrong tabular format (expected <features ...> got" <<
+                       line << ")" << endl;
                return;
-           }
-           getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
-           getTokenValue(line, "alignment", cell_info[i][j].alignment);
-           getTokenValue(line, "valignment", cell_info[i][j].valignment);
-           getTokenValue(line, "topline", cell_info[i][j].top_line);
-           getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
-           getTokenValue(line, "leftline", cell_info[i][j].left_line);
-           getTokenValue(line, "rightline", cell_info[i][j].right_line);
-           getTokenValue(line, "rotate", cell_info[i][j].rotate);
-           getTokenValue(line, "usebox", cell_info[i][j].usebox);
-           getTokenValue(line, "width", cell_info[i][j].p_width);
-           getTokenValue(line, "special", cell_info[i][j].align_special);
-           l_getline(is, line);
-           if (prefixIs(line, "\\begin_inset")) {
-               cell_info[i][j].inset.Read(buf, lex);
+       }
+       getTokenValue(line, "rotate", rotate);
+       getTokenValue(line, "islongtable", is_long_tabular);
+       getTokenValue(line, "endhead", endhead);
+       getTokenValue(line, "endfirsthead", endfirsthead);
+       getTokenValue(line, "endfoot", endfoot);
+       getTokenValue(line, "endlastfoot", endlastfoot);
+
+       for (int j = 0; j < columns_; ++j) {
+               l_getline(is,line);
+               if (!prefixIs(line,"<column")) {
+                       lyxerr << "Wrong tabular format (expected <column ...> got" <<
+                               line << ")" << endl;
+                       return;
+               }
+               getTokenValue(line, "alignment", column_info[j].alignment);
+               getTokenValue(line, "valignment", column_info[j].valignment);
+               getTokenValue(line, "leftline", column_info[j].left_line);
+               getTokenValue(line, "rightline", column_info[j].right_line);
+               getTokenValue(line, "width", column_info[j].p_width);
+               getTokenValue(line, "special", column_info[j].align_special);
+       }
+
+       for (int i = 0; i < rows_; ++i) {
                l_getline(is, line);
-           }
-           if (!prefixIs(line, "</cell>")) {
-               lyxerr << "Wrong tabular format (expected </cell> got" <<
-                   line << ")" << endl;
-               return;
-           }
+               if (!prefixIs(line, "<row")) {
+                       lyxerr << "Wrong tabular format (expected <row ...> got" <<
+                               line << ")" << endl;
+                       return;
+               }
+               getTokenValue(line, "topline", row_info[i].top_line);
+               getTokenValue(line, "bottomline", row_info[i].bottom_line);
+               getTokenValue(line, "newpage", row_info[i].newpage);
+               for (int j = 0; j < columns_; ++j) {
+                       l_getline(is, line);
+                       if (!prefixIs(line, "<cell")) {
+                               lyxerr << "Wrong tabular format (expected <cell ...> got" <<
+                                       line << ")" << endl;
+                               return;
+                       }
+                       getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
+                       getTokenValue(line, "alignment", cell_info[i][j].alignment);
+                       getTokenValue(line, "valignment", cell_info[i][j].valignment);
+                       getTokenValue(line, "topline", cell_info[i][j].top_line);
+                       getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
+                       getTokenValue(line, "leftline", cell_info[i][j].left_line);
+                       getTokenValue(line, "rightline", cell_info[i][j].right_line);
+                       getTokenValue(line, "rotate", cell_info[i][j].rotate);
+                       getTokenValue(line, "usebox", cell_info[i][j].usebox);
+                       getTokenValue(line, "width", cell_info[i][j].p_width);
+                       getTokenValue(line, "special", cell_info[i][j].align_special);
+                       l_getline(is, line);
+                       if (prefixIs(line, "\\begin_inset")) {
+                               cell_info[i][j].inset.Read(buf, lex);
+                               l_getline(is, line);
+                       }
+                       if (!prefixIs(line, "</cell>")) {
+                               lyxerr << "Wrong tabular format (expected </cell> got" <<
+                                       line << ")" << endl;
+                               return;
+                       }
+               }
+               l_getline(is, line);
+               if (!prefixIs(line, "</row>")) {
+                       lyxerr << "Wrong tabular format (expected </row> got" <<
+                               line << ")" << endl;
+                       return;
+               }
        }
-       l_getline(is, line);
-       if (!prefixIs(line, "</row>")) {
-           lyxerr << "Wrong tabular format (expected </row> got" <<
-               line << ")" << endl;
-           return;
+       while (!prefixIs(line, "</lyxtabular>")) {
+               l_getline(is, line);
        }
-    }
-    while (!prefixIs(line, "</lyxtabular>")) {
-       l_getline(is, line);
-    }
-    set_row_column_number_info();
+       set_row_column_number_info();
 }
 
 
 void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
 {
-    int version;
-    int i;
-    int j;
-    int rows_arg = 0;
-    int columns_arg = 0;
-    int is_long_tabular_arg = false;
-    int rotate_arg = false;
-    int a = -1;
-    int b = -1;
-    int c = -1;
-    int d = -1;
-    int e = 0;
-    int f = 0;
-    int g = 0;
+       int version;
+       int i;
+       int j;
+       int rows_arg = 0;
+       int columns_arg = 0;
+       int is_long_tabular_arg = false;
+       int rotate_arg = false;
+       int a = -1;
+       int b = -1;
+       int c = -1;
+       int d = -1;
+       int e = 0;
+       int f = 0;
+       int g = 0;
        
-    istream & is = lex.getStream();
-    string s(fl);
-    if (s.length() > 8)
-       version = lyx::atoi(s.substr(8, string::npos));
-    else
-       version = 1;
-
-    vector<int> cont_row_info;
-
-    if (version < 5) {
-       lyxerr << "Tabular format < 5 is not supported anymore\n"
-           "Get an older version of LyX (< 1.1.x) for conversion!"
-              << endl;
-       WriteAlert(_("Warning:"),
-                  _("Tabular format < 5 is not supported anymore\n"),
-                  _("Get an older version of LyX (< 1.1.x) for conversion!"));
-       if (version > 2) {
-           is >> rows_arg >> columns_arg >> is_long_tabular_arg
-              >> rotate_arg >> a >> b >> c >> d;
-       } else
-           is >> rows_arg >> columns_arg;
-       Init(rows_arg, columns_arg);
-       cont_row_info = vector<int>(rows_arg);
-       SetLongTabular(is_long_tabular_arg);
-       SetRotateTabular(rotate_arg);
-       string tmp;
-       for (i = 0; i < rows_; ++i) {
-           getline(is, tmp);
-           cont_row_info[i] = false;
-       }
-       for (i = 0; i < columns_; ++i) {
-           getline(is, tmp);
-       }
-       for (i = 0; i < rows_; ++i) {
-           for (j = 0; j < columns_; ++j) {
-               getline(is, tmp);
-           }
-       }
-    } else {
-       is >> rows_arg >> columns_arg >> is_long_tabular_arg
-          >> rotate_arg >> a >> b >> c >> d;
-       Init(rows_arg, columns_arg);
-       cont_row_info = vector<int>(rows_arg);
-       SetLongTabular(is_long_tabular_arg);
-       SetRotateTabular(rotate_arg);
-       endhead = a + 1;
-       endfirsthead = b + 1;
-       endfoot = c + 1;
-       endlastfoot = d + 1;
-       for (i = 0; i < rows_; ++i) {
-           a = b = c = d = e = f = g = 0;
-           is >> a >> b >> c >> d;
-           row_info[i].top_line = a;
-           row_info[i].bottom_line = b;
-           cont_row_info[i] = c;
-           row_info[i].newpage = d;
-       }
-       for (i = 0; i < columns_; ++i) {
-           string s1;
-           string s2;
-           is >> a >> b >> c;
+       istream & is = lex.getStream();
+       string s(fl);
+       if (s.length() > 8)
+               version = lyx::atoi(s.substr(8, string::npos));
+       else
+               version = 1;
+
+       vector<int> cont_row_info;
+
+       if (version < 5) {
+               lyxerr << "Tabular format < 5 is not supported anymore\n"
+                       "Get an older version of LyX (< 1.1.x) for conversion!"
+                          << endl;
+               WriteAlert(_("Warning:"),
+                                  _("Tabular format < 5 is not supported anymore\n"),
+                                  _("Get an older version of LyX (< 1.1.x) for conversion!"));
+               if (version > 2) {
+                       is >> rows_arg >> columns_arg >> is_long_tabular_arg
+                          >> rotate_arg >> a >> b >> c >> d;
+               } else
+                       is >> rows_arg >> columns_arg;
+               Init(rows_arg, columns_arg);
+               cont_row_info = vector<int>(rows_arg);
+               SetLongTabular(is_long_tabular_arg);
+               SetRotateTabular(rotate_arg);
+               string tmp;
+               for (i = 0; i < rows_; ++i) {
+                       getline(is, tmp);
+                       cont_row_info[i] = false;
+               }
+               for (i = 0; i < columns_; ++i) {
+                       getline(is, tmp);
+               }
+               for (i = 0; i < rows_; ++i) {
+                       for (j = 0; j < columns_; ++j) {
+                               getline(is, tmp);
+                       }
+               }
+       } else {
+               is >> rows_arg >> columns_arg >> is_long_tabular_arg
+                  >> rotate_arg >> a >> b >> c >> d;
+               Init(rows_arg, columns_arg);
+               cont_row_info = vector<int>(rows_arg);
+               SetLongTabular(is_long_tabular_arg);
+               SetRotateTabular(rotate_arg);
+               endhead = a + 1;
+               endfirsthead = b + 1;
+               endfoot = c + 1;
+               endlastfoot = d + 1;
+               for (i = 0; i < rows_; ++i) {
+                       a = b = c = d = e = f = g = 0;
+                       is >> a >> b >> c >> d;
+                       row_info[i].top_line = a;
+                       row_info[i].bottom_line = b;
+                       cont_row_info[i] = c;
+                       row_info[i].newpage = d;
+               }
+               for (i = 0; i < columns_; ++i) {
+                       string s1;
+                       string s2;
+                       is >> a >> b >> c;
 #if 1
-           char ch; // skip '"'
-           is >> ch;
+                       char ch; // skip '"'
+                       is >> ch;
 #else
-           // ignore is buggy but we will use it later (Lgb)
-           is.ignore(); // skip '"'
+                       // ignore is buggy but we will use it later (Lgb)
+                       is.ignore(); // skip '"'
 #endif    
-           getline(is, s1, '"');
+                       getline(is, s1, '"');
 #if 1
-           is >> ch; // skip '"'
+                       is >> ch; // skip '"'
 #else
-           // ignore is buggy but we will use it later (Lgb)
-           is.ignore(); // skip '"'
+                       // ignore is buggy but we will use it later (Lgb)
+                       is.ignore(); // skip '"'
 #endif
-           getline(is, s2, '"');
-           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;
-           column_info[i].align_special = s2;
-       }
-       for (i = 0; i < rows_; ++i) {
-           for (j = 0; j < columns_; ++j) {
-               string s1;
-               string s2;
-               is >> a >> b >> c >> d >> e >> f >> g;
+                       getline(is, s2, '"');
+                       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;
+                       column_info[i].align_special = s2;
+               }
+               for (i = 0; i < rows_; ++i) {
+                       for (j = 0; j < columns_; ++j) {
+                               string s1;
+                               string s2;
+                               is >> a >> b >> c >> d >> e >> f >> g;
 #if 1
-               char ch;
-               is >> ch; // skip '"'
+                               char ch;
+                               is >> ch; // skip '"'
 #else
-               // ignore is buggy but we will use it later (Lgb)
-               is.ignore(); // skip '"'
+                               // ignore is buggy but we will use it later (Lgb)
+                               is.ignore(); // skip '"'
 #endif
-               getline(is, s1, '"');
+                               getline(is, s1, '"');
 #if 1
-               is >> ch; // skip '"'
+                               is >> ch; // skip '"'
 #else
-               // ignore is buggy but we will use it later (Lgb)
-               is.ignore(); // skip '"'
+                               // ignore is buggy but we will use it later (Lgb)
+                               is.ignore(); // skip '"'
 #endif
-               getline(is, s2, '"');
-               cell_info[i][j].multicolumn = static_cast<char>(a);
-               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<BoxType>(g);
-               cell_info[i][j].align_special = s1;
-               cell_info[i][j].p_width = s2;
-           }
-       }
-    }
-    set_row_column_number_info(true);
-
-    LyXParagraph * par = new LyXParagraph;
-    LyXParagraph * return_par = 0;
+                               getline(is, s2, '"');
+                               cell_info[i][j].multicolumn = static_cast<char>(a);
+                               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<BoxType>(g);
+                               cell_info[i][j].align_special = s1;
+                               cell_info[i][j].p_width = s2;
+                       }
+               }
+       }
+       set_row_column_number_info(true);
+
+       LyXParagraph * par = new LyXParagraph;
+       LyXParagraph * return_par = 0;
 #ifndef NEW_INSETS
-    LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
-    LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
+       LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
+       LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
 #endif
-    string tmptok;
-    int pos = 0;
-    char depth = 0;
-    LyXFont font(LyXFont::ALL_INHERIT);
-    font.setLanguage(owner_->BufferOwner()->GetLanguage());
-
-    while (lex.IsOK()) {
-        lex.nextToken();
-        string const token = lex.GetString();
-        if (token.empty())
-            continue;
-       if (token == "\\layout"
-           || token == "\\end_float"
-           || token == "\\end_deeper") {
-           lex.pushToken(token);
-           break;
-       }
-       if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par,
-                                                             return_par,
-                                                             token, pos,
-                                                             depth, font
+       string tmptok;
+       int pos = 0;
+       char depth = 0;
+       LyXFont font(LyXFont::ALL_INHERIT);
+       font.setLanguage(owner_->BufferOwner()->GetLanguage());
+
+       while (lex.IsOK()) {
+               lex.nextToken();
+               string const token = lex.GetString();
+               if (token.empty())
+                       continue;
+               if (token == "\\layout"
+                       || token == "\\end_float"
+                       || token == "\\end_deeper") {
+                       lex.pushToken(token);
+                       break;
+               }
+               if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par,
+                                                                                                                         return_par,
+                                                                                                                         token, pos,
+                                                                                                                         depth, font
 #ifndef NEW_INSETS
-                                                             ,
-                                                             footnoteflag,
-                                                             footnotekind
+                                                                                                                         ,
+                                                                                                                         footnoteflag,
+                                                                                                                         footnotekind
 #endif
-               ))
-       {
-           // the_end read
-           lex.pushToken(token);
-           break;
-       }
-       if (return_par) {
-           lex.printError("New Paragraph allocated! This should not happen!");
-           lex.pushToken(token);
-           delete par;
-           par = return_par;
-           break;
-       }
-    }
-    // now we have the par we should fill the insets with this!
-    int cell = 0;
-    InsetText * inset = GetCellInset(cell);
-    int row;
+                                                                                                                         ))
+               {
+                       // the_end read
+                       lex.pushToken(token);
+                       break;
+               }
+               if (return_par) {
+                       lex.printError("New Paragraph allocated! This should not happen!");
+                       lex.pushToken(token);
+                       delete par;
+                       par = return_par;
+                       break;
+               }
+       }
+       // now we have the par we should fill the insets with this!
+       int cell = 0;
+       InsetText * inset = GetCellInset(cell);
+       int row;
 
 #ifndef NEW_INSETS
-    for (int i = 0; i < par->Last(); ++i) {
+       for (int i = 0; i < par->Last(); ++i)
 #else
-    for (int i = 0; i < par->size(); ++i) {
+       for (int i = 0; i < par->size(); ++i)
 #endif
-       if (par->IsNewline(i)) {
-           ++cell;
-           if (cell > GetNumberOfCells()) {
-               lyxerr << "Some error in reading old table format occured!" <<
-                   endl << "Terminating when reading cell[" << cell << "]!" <<
-                   endl;
-               delete par;
-               return;
-           }
-           row = row_of_cell(cell);
-           if (cont_row_info[row]) {
-               DeleteRow(row);
-               cont_row_info.erase(cont_row_info.begin() + row); //&cont_row_info[row]);
-               while(!IsFirstCellInRow(--cell));
-           } else {
-               inset = GetCellInset(cell);
-               continue;
-           }
-           inset = GetCellInset(cell);
-           row = row_of_cell(cell);
-           if (!cell_info[row_of_cell(cell)][column_of_cell(cell)].usebox)
-           {
-               // insert a space instead
-               par->Erase(i);
-               par->InsertChar(i, ' ');
-           }
-       }
-       par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
+       {
+               if (par->IsNewline(i)) {
+                       ++cell;
+                       if (cell > GetNumberOfCells()) {
+                               lyxerr << "Some error in reading old table format occured!" <<
+                                       endl << "Terminating when reading cell[" << cell << "]!" <<
+                                       endl;
+                               delete par;
+                               return;
+                       }
+                       row = row_of_cell(cell);
+                       if (cont_row_info[row]) {
+                               DeleteRow(row);
+                               cont_row_info.erase(cont_row_info.begin() + row); //&cont_row_info[row]);
+                               while(!IsFirstCellInRow(--cell));
+                       } else {
+                               inset = GetCellInset(cell);
+                               continue;
+                       }
+                       inset = GetCellInset(cell);
+                       row = row_of_cell(cell);
+                       if (!cell_info[row_of_cell(cell)][column_of_cell(cell)].usebox)
+                       {
+                               // insert a space instead
+                               par->Erase(i);
+                               par->InsertChar(i, ' ');
+                       }
+               }
+               par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
 #ifndef NEW_INSETS
-       inset->par->InsertFromMinibuffer(inset->par->Last());
+               inset->par->InsertFromMinibuffer(inset->par->Last());
 #else
-       inset->par->InsertFromMinibuffer(inset->par->size());
+               inset->par->InsertFromMinibuffer(inset->par->size());
 #endif
-    }
-    delete par;
-    Reinit();
+       }
+       delete par;
+       Reinit();
 }
 
 
 bool LyXTabular::IsMultiColumn(int cell, bool real) const
 {
-    return ((!real || (column_of_cell(cell) != right_column_of_cell(cell))) &&
-       (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL));
+       return ((!real || (column_of_cell(cell) != right_column_of_cell(cell))) &&
+                       (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL));
 }
 
 
 LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
 {
-    int const row = row_of_cell(cell);
-    int const column = column_of_cell(cell);
-    return  &cell_info[row][column];
+       int const row = row_of_cell(cell);
+       int const column = column_of_cell(cell);
+       return  &cell_info[row][column];
 }
 
 
 void LyXTabular::SetMultiColumn(int cell, int number)
 {
-    cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
-    cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
-    cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
-    cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
-    for (number--; number > 0; --number) {
-        cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
-    }
-    set_row_column_number_info();
+       cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
+       cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
+       cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
+       cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
+       for (number--; number > 0; --number) {
+               cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
+       }
+       set_row_column_number_info();
 }
 
 
 int LyXTabular::cells_in_multicolumn(int cell) const
 {
-    int const row = row_of_cell(cell);
-    int column = column_of_cell(cell);
-    int result = 1;
-    ++column;
-    while ((column < columns_) &&
-          cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN)
-    {
-        ++result;
-        ++column;
-    }
-    return result;
+       int const row = row_of_cell(cell);
+       int column = column_of_cell(cell);
+       int result = 1;
+       ++column;
+       while ((column < columns_) &&
+                  cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN)
+       {
+               ++result;
+               ++column;
+       }
+       return result;
 }
 
 
 int LyXTabular::UnsetMultiColumn(int cell)
 {
-    int const row = row_of_cell(cell);
-    int column = column_of_cell(cell);
-    
-    int result = 0;
-    
-    if (cell_info[row][column].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
-        cell_info[row][column].multicolumn = CELL_NORMAL;
-        ++column;
-        while ((column < columns_) &&
-               (cell_info[row][column].multicolumn ==CELL_PART_OF_MULTICOLUMN))
-       {
-            cell_info[row][column].multicolumn = CELL_NORMAL;
-            ++column;
-            ++result;
-        }
-    }
-    set_row_column_number_info();
-    return result;
+       int const row = row_of_cell(cell);
+       int column = column_of_cell(cell);
+       
+       int result = 0;
+       
+       if (cell_info[row][column].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
+               cell_info[row][column].multicolumn = CELL_NORMAL;
+               ++column;
+               while ((column < columns_) &&
+                          (cell_info[row][column].multicolumn ==CELL_PART_OF_MULTICOLUMN))
+               {
+                       cell_info[row][column].multicolumn = CELL_NORMAL;
+                       ++column;
+                       ++result;
+               }
+       }
+       set_row_column_number_info();
+       return result;
 }
 
 
 void LyXTabular::SetLongTabular(bool what)
 {
-    is_long_tabular = what;
+       is_long_tabular = what;
 }
 
 
 bool LyXTabular::IsLongTabular() const
 {
-    return is_long_tabular;
+       return is_long_tabular;
 }
 
 
 void LyXTabular::SetRotateTabular(bool flag)
 {
-    rotate = flag;
+       rotate = flag;
 }
 
 
 bool LyXTabular::GetRotateTabular() const
 {
-    return rotate;
+       return rotate;
 }
 
 
 void LyXTabular::SetRotateCell(int cell, bool flag)
 {
-    cellinfo_of_cell(cell)->rotate = flag;
+       cellinfo_of_cell(cell)->rotate = flag;
 }
 
 
 bool LyXTabular::GetRotateCell(int cell) const
 {
-    return cellinfo_of_cell(cell)->rotate;
+       return cellinfo_of_cell(cell)->rotate;
 }
 
 
 bool LyXTabular::NeedRotating() const
 {
-    if (rotate)
-        return true;
-    for (int i = 0; i < rows_; ++i) {
-        for (int j = 0; j < columns_; ++j) {
-            if (cell_info[i][j].rotate)
-                return true;
-        }
-    }
-    return false;
+       if (rotate)
+               return true;
+       for (int i = 0; i < rows_; ++i) {
+               for (int j = 0; j < columns_; ++j) {
+                       if (cell_info[i][j].rotate)
+                               return true;
+               }
+       }
+       return false;
 }
 
 
 bool LyXTabular::IsLastCell(int cell) const
 {
-    if ((cell + 1) < GetNumberOfCells())
-        return false;
-    return true;
+       if ((cell + 1) < GetNumberOfCells())
+               return false;
+       return true;
 }
 
 
 int LyXTabular::GetCellAbove(int cell) const
 {
-    if (row_of_cell(cell) > 0)
-        return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
-    return cell;
+       if (row_of_cell(cell) > 0)
+               return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
+       return cell;
 }
 
 
 int LyXTabular::GetCellBelow(int cell) const
 {
-    if (row_of_cell(cell) + 1 < rows_)
-        return cell_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno;
-    return cell;
+       if (row_of_cell(cell) + 1 < rows_)
+               return cell_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno;
+       return cell;
 }
 
 
 int LyXTabular::GetLastCellAbove(int cell) const
 {
-    if (row_of_cell(cell) <= 0)
-       return cell;
-    if (!IsMultiColumn(cell))
-       return GetCellAbove(cell);
-    return cell_info[row_of_cell(cell) - 1][right_column_of_cell(cell)].cellno;
+       if (row_of_cell(cell) <= 0)
+               return cell;
+       if (!IsMultiColumn(cell))
+               return GetCellAbove(cell);
+       return cell_info[row_of_cell(cell) - 1][right_column_of_cell(cell)].cellno;
 }
 
 
 int LyXTabular::GetLastCellBelow(int cell) const
 {
-    if (row_of_cell(cell) + 1 >= rows_)
-       return cell;
-    if (!IsMultiColumn(cell))
-       return GetCellBelow(cell);
-    return cell_info[row_of_cell(cell) + 1][right_column_of_cell(cell)].cellno;
+       if (row_of_cell(cell) + 1 >= rows_)
+               return cell;
+       if (!IsMultiColumn(cell))
+               return GetCellBelow(cell);
+       return cell_info[row_of_cell(cell) + 1][right_column_of_cell(cell)].cellno;
 }
 
 
 int LyXTabular::GetCellNumber(int row, int column) const
 {
-    if (column >= columns_)
-        column = columns_ - 1;
-    else if (column < 0)
-        column = 0;
-    if (row >= rows_)
-        row = rows_ - 1;
-    else if (row < 0)
-        row = 0;
-    
-    return cell_info[row][column].cellno;
+       if (column >= columns_)
+               column = columns_ - 1;
+       else if (column < 0)
+               column = 0;
+       if (row >= rows_)
+               row = rows_ - 1;
+       else if (row < 0)
+               row = 0;
+       
+       return cell_info[row][column].cellno;
 }
 
 
 void LyXTabular::SetUsebox(int cell, BoxType type)
 {
-    cellinfo_of_cell(cell)->usebox = type;
+       cellinfo_of_cell(cell)->usebox = type;
 }
 
 
 LyXTabular::BoxType LyXTabular::GetUsebox(int cell) const
 {
-    if (column_info[column_of_cell(cell)].p_width.empty() &&
-        !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
-        return BOX_NONE;
-    if (cellinfo_of_cell(cell)->usebox > 1)
-       return cellinfo_of_cell(cell)->usebox;
-    return UseParbox(cell);
+       if (column_info[column_of_cell(cell)].p_width.empty() &&
+               !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
+               return BOX_NONE;
+       if (cellinfo_of_cell(cell)->usebox > 1)
+               return cellinfo_of_cell(cell)->usebox;
+       return UseParbox(cell);
 }
 
 
 void LyXTabular::SetLTHead(int cell, bool first)
 {
-    int const row = row_of_cell(cell);
-    int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1);
+       int const row = row_of_cell(cell);
+       int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1);
 
-    if (first) {
-        if (endfirsthead == val)
-            endfirsthead = 0;
-        else
-            endfirsthead = val;
-    } else {
-        if (endhead == val)
-            endhead = 0;
-        else
-            endhead = val;
-    }
+       if (first) {
+               if (endfirsthead == val)
+                       endfirsthead = 0;
+               else
+                       endfirsthead = val;
+       } else {
+               if (endhead == val)
+                       endhead = 0;
+               else
+                       endhead = val;
+       }
 }
 
 
 bool LyXTabular::GetRowOfLTHead(int cell, int & row) const
 {
-    row = endhead;
-    if (abs(endhead) > rows_)
-        return false;
-    return (row_of_cell(cell) == abs(endhead) - 1);
+       row = endhead;
+       if (abs(endhead) > rows_)
+               return false;
+       return (row_of_cell(cell) == abs(endhead) - 1);
 }
 
 
 bool LyXTabular::GetRowOfLTFirstHead(int cell, int & row) const
 {
-    row = endfirsthead;
-    if (abs(endfirsthead) > rows_)
-        return false;
-    return (row_of_cell(cell) == abs(endfirsthead) - 1);
+       row = endfirsthead;
+       if (abs(endfirsthead) > rows_)
+               return false;
+       return (row_of_cell(cell) == abs(endfirsthead) - 1);
 }
 
 
 void LyXTabular::SetLTFoot(int cell, bool last)
 {
-    int const row = row_of_cell(cell);
-    int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1);
+       int const row = row_of_cell(cell);
+       int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1);
 
-    if (last) {
-        if (endlastfoot == val)
-            endlastfoot = 0;
-        else
-            endlastfoot = val;
-    } else {
-        if (endfoot == val)
-            endfoot = 0;
-        else
-            endfoot = val;
-    }
+       if (last) {
+               if (endlastfoot == val)
+                       endlastfoot = 0;
+               else
+                       endlastfoot = val;
+       } else {
+               if (endfoot == val)
+                       endfoot = 0;
+               else
+                       endfoot = val;
+       }
 }
 
 
 bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const
 {
-    row = endfoot;
-    if ((endfoot + 1) > rows_)
-        return false;
-    return (row_of_cell(cell) == abs(endfoot) - 1);
+       row = endfoot;
+       if ((endfoot + 1) > rows_)
+               return false;
+       return (row_of_cell(cell) == abs(endfoot) - 1);
 }
 
 
 bool LyXTabular::GetRowOfLTLastFoot(int cell, int & row) const
 {
-    row = endlastfoot;
-    if (abs(endlastfoot) > rows_)
-        return false;
-    return (row_of_cell(cell) == (abs(endlastfoot)-1));
+       row = endlastfoot;
+       if (abs(endlastfoot) > rows_)
+               return false;
+       return (row_of_cell(cell) == (abs(endlastfoot)-1));
 }
 
 
 void LyXTabular::SetLTNewPage(int cell, bool what)
 {
-    row_info[row_of_cell(cell)].newpage = what;
+       row_info[row_of_cell(cell)].newpage = what;
 }
 
 
 bool LyXTabular::GetLTNewPage(int cell) const
 {
-    return row_info[row_of_cell(cell)].newpage;
+       return row_info[row_of_cell(cell)].newpage;
 }
 
 
 bool LyXTabular::SetAscentOfRow(int row, int height)
 {
-    if ((row >= rows_) || (row_info[row].ascent_of_row == height))
-        return false;
-    row_info[row].ascent_of_row = height;
-    return true;
+       if ((row >= rows_) || (row_info[row].ascent_of_row == height))
+               return false;
+       row_info[row].ascent_of_row = height;
+       return true;
 }
 
 
 bool LyXTabular::SetDescentOfRow(int row, int height)
 {
-    if ((row >= rows_) || (row_info[row].descent_of_row == height))
-        return false;
-    row_info[row].descent_of_row = height;
-    return true;
+       if ((row >= rows_) || (row_info[row].descent_of_row == height))
+               return false;
+       row_info[row].descent_of_row = height;
+       return true;
 }
 
 
 int LyXTabular::GetAscentOfRow(int row) const
 {
-    if (row >= rows_)
-        return 0;
-    return row_info[row].ascent_of_row;
+       if (row >= rows_)
+               return 0;
+       return row_info[row].ascent_of_row;
 }
 
 
 int LyXTabular::GetDescentOfRow(int row) const
 {
-    if (row >= rows_)
-        return 0;
-    return row_info[row].descent_of_row;
+       if (row >= rows_)
+               return 0;
+       return row_info[row].descent_of_row;
 }
 
 
 int LyXTabular::GetHeightOfTabular() const
 {
-    int height = 0;
+       int height = 0;
 
-    for (int row = 0; row < rows_; ++row)
-        height += GetAscentOfRow(row) + GetDescentOfRow(row) +
-           GetAdditionalHeight(GetCellNumber(row, 0));
-    return height;
+       for (int row = 0; row < rows_; ++row)
+               height += GetAscentOfRow(row) + GetDescentOfRow(row) +
+                       GetAdditionalHeight(GetCellNumber(row, 0));
+       return height;
 }
 
 
 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
 {
-    if ((row >= rows_) || (column >= columns_))
-        return false;
-    return (cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN);
+       if ((row >= rows_) || (column >= columns_))
+               return false;
+       return (cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN);
 }
 
 
 int LyXTabular::TeXTopHLine(ostream & os, int row) const
 {
-    if ((row < 0) || (row >= rows_))
-       return 0;
+       if ((row < 0) || (row >= rows_))
+               return 0;
+
+       int const fcell = GetFirstCellInRow(row);
+       int const n = NumberOfCellsInRow(fcell) + fcell;
+       int tmp = 0;
 
-    int const fcell = GetFirstCellInRow(row);
-    int const n = NumberOfCellsInRow(fcell) + fcell;
-    int tmp = 0;
-
-    for (int i = fcell; i < n; ++i) {
-       if (TopLine(i))
-           ++tmp;
-    }
-    if (tmp == (n - fcell)){
-       os << "\\hline ";
-    } else if (tmp) {
        for (int i = fcell; i < n; ++i) {
-           if (TopLine(i)) {
-               os << "\\cline{"
-                  << column_of_cell(i) + 1
-                  << '-'
-                  << right_column_of_cell(i) + 1
-                  << "} ";
-           }
-       }
-    } else {
-       return 0;
-    }
-    os << "\n";
-    return 1;
+               if (TopLine(i))
+                       ++tmp;
+       }
+       if (tmp == (n - fcell)){
+               os << "\\hline ";
+       } else if (tmp) {
+               for (int i = fcell; i < n; ++i) {
+                       if (TopLine(i)) {
+                               os << "\\cline{"
+                                  << column_of_cell(i) + 1
+                                  << '-'
+                                  << right_column_of_cell(i) + 1
+                                  << "} ";
+                       }
+               }
+       } else {
+               return 0;
+       }
+       os << "\n";
+       return 1;
 }
 
 
 int LyXTabular::TeXBottomHLine(ostream & os, int row) const
 {
-    if ((row < 0) || (row >= rows_))
-       return 0;
+       if ((row < 0) || (row >= rows_))
+               return 0;
+
+       int const fcell = GetFirstCellInRow(row);
+       int const n = NumberOfCellsInRow(fcell) + fcell;
+       int tmp = 0;
 
-    int const fcell = GetFirstCellInRow(row);
-    int const n = NumberOfCellsInRow(fcell) + fcell;
-    int tmp = 0;
-
-    for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i))
-           ++tmp;
-    }
-    if (tmp == (n-fcell)){
-       os << "\\hline";
-    } else if (tmp) {
        for (int i = fcell; i < n; ++i) {
-           if (BottomLine(i)) {
-               os << "\\cline{"
-                  << column_of_cell(i) + 1
-                  << '-'
-                  << right_column_of_cell(i) + 1
-                  << "} ";
-           }
-       }
-    } else {
-       return 0;
-    }
-    os << "\n";
-    return 1;
+               if (BottomLine(i))
+                       ++tmp;
+       }
+       if (tmp == (n-fcell)){
+               os << "\\hline";
+       } else if (tmp) {
+               for (int i = fcell; i < n; ++i) {
+                       if (BottomLine(i)) {
+                               os << "\\cline{"
+                                  << column_of_cell(i) + 1
+                                  << '-'
+                                  << right_column_of_cell(i) + 1
+                                  << "} ";
+                       }
+               }
+       } else {
+               return 0;
+       }
+       os << "\n";
+       return 1;
 }
 
 
 int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
 {
-    int ret = 0;
+       int ret = 0;
 
-    if (GetRotateCell(cell)) {
-       os << "\\begin{sideways}\n";
-       ++ret;
-    }
-    if (IsMultiColumn(cell)) {
-       os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
-       if (!cellinfo_of_cell(cell)->align_special.empty()) {
-           os << cellinfo_of_cell(cell)->align_special << "}{";
-       } else {
-           if (LeftLine(cell))
-               os << '|';
-           if (!GetPWidth(cell).empty()) {
+       if (GetRotateCell(cell)) {
+               os << "\\begin{sideways}\n";
+               ++ret;
+       }
+       if (IsMultiColumn(cell)) {
+               os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
+               if (!cellinfo_of_cell(cell)->align_special.empty()) {
+                       os << cellinfo_of_cell(cell)->align_special << "}{";
+               } else {
+                       if (LeftLine(cell))
+                               os << '|';
+                       if (!GetPWidth(cell).empty()) {
+                               switch (GetVAlignment(cell)) {
+                               case LYX_VALIGN_TOP:
+                                       os << "p";
+                                       break;
+                               case LYX_VALIGN_CENTER:
+                                       os << "m";
+                                       break;
+                               case LYX_VALIGN_BOTTOM:
+                                       os << "b";
+                                       break;
+                               }
+                               os << "{" << GetPWidth(cell) << '}';
+                       } else {
+                               switch (GetAlignment(cell)) {
+                               case LYX_ALIGN_LEFT:
+                                       os << 'l';
+                                       break;
+                               case LYX_ALIGN_RIGHT:
+                                       os << 'r';
+                                       break;
+                               default:
+                                       os << 'c';
+                                       break;
+                               }
+                       }
+                       if (RightLine(cell))
+                               os << '|';
+                       if (((cell + 1) < numberofcells) && !IsFirstCellInRow(cell+1) &&
+                               LeftLine(cell+1))
+                               os << '|';
+                       os << "}{";
+               }
+       }
+       if (GetUsebox(cell) == BOX_PARBOX) {
+               os << "\\parbox[";
                switch (GetVAlignment(cell)) {
                case LYX_VALIGN_TOP:
-                   os << "p";
-                   break;
+                       os << "t";
+                       break;
                case LYX_VALIGN_CENTER:
-                   os << "m";
-                   break;
+                       os << "c";
+                       break;
                case LYX_VALIGN_BOTTOM:
-                   os << "b";
-                   break;
+                       os << "b";
+                       break;
                }
-               os << "{" << GetPWidth(cell) << '}';
-           } else {
-               switch (GetAlignment(cell)) {
-               case LYX_ALIGN_LEFT:
-                   os << 'l';
-                   break;
-               case LYX_ALIGN_RIGHT:
-                   os << 'r';
-                   break;
-               default:
-                   os << 'c';
-                   break;
+               os << "]{" << GetPWidth(cell) << "}{";
+       } else if (GetUsebox(cell) == BOX_MINIPAGE) {
+               os << "\\begin{minipage}[";
+               switch (GetVAlignment(cell)) {
+               case LYX_VALIGN_TOP:
+                       os << "t";
+                       break;
+               case LYX_VALIGN_CENTER:
+                       os << "m";
+                       break;
+               case LYX_VALIGN_BOTTOM:
+                       os << "b";
+                       break;
                }
-           }
-           if (RightLine(cell))
-               os << '|';
-           if (((cell + 1) < numberofcells) && !IsFirstCellInRow(cell+1) &&
-               LeftLine(cell+1))
-               os << '|';
-           os << "}{";
-       }
-    }
-    if (GetUsebox(cell) == BOX_PARBOX) {
-       os << "\\parbox[";
-       switch (GetVAlignment(cell)) {
-       case LYX_VALIGN_TOP:
-           os << "t";
-           break;
-       case LYX_VALIGN_CENTER:
-           os << "c";
-           break;
-       case LYX_VALIGN_BOTTOM:
-           os << "b";
-           break;
-       }
-       os << "]{" << GetPWidth(cell) << "}{";
-    } else if (GetUsebox(cell) == BOX_MINIPAGE) {
-       os << "\\begin{minipage}[";
-       switch (GetVAlignment(cell)) {
-       case LYX_VALIGN_TOP:
-           os << "t";
-           break;
-       case LYX_VALIGN_CENTER:
-           os << "m";
-           break;
-       case LYX_VALIGN_BOTTOM:
-           os << "b";
-           break;
-       }
-       os << "]{" << GetPWidth(cell) << "}\n";
-       ++ret;
-    }
-    return ret;
+               os << "]{" << GetPWidth(cell) << "}\n";
+               ++ret;
+       }
+       return ret;
 }
 
 
 int LyXTabular::TeXCellPostamble(ostream & os, int cell) const
 {
-    int ret = 0;
-
-    // usual cells
-    if (GetUsebox(cell) == BOX_PARBOX)
-       os << "}";
-    else if (GetUsebox(cell) == BOX_MINIPAGE) {
-       os << "%\n\\end{minipage}";
-       ret += 2;
-    }
-    if (IsMultiColumn(cell)){
-       os << '}';
-    }
-    if (GetRotateCell(cell)) {
-       os << "%\n\\end{sideways}";
-       ++ret;
-    }
-    return ret;
+       int ret = 0;
+
+       // usual cells
+       if (GetUsebox(cell) == BOX_PARBOX)
+               os << "}";
+       else if (GetUsebox(cell) == BOX_MINIPAGE) {
+               os << "%\n\\end{minipage}";
+               ret += 2;
+       }
+       if (IsMultiColumn(cell)){
+               os << '}';
+       }
+       if (GetRotateCell(cell)) {
+               os << "%\n\\end{sideways}";
+               ++ret;
+       }
+       return ret;
 }
 
 
 int LyXTabular::Latex(Buffer const * buf,
-                     ostream & os, bool fragile, bool fp) const
+                                         ostream & os, bool fragile, bool fp) const
 {
-    int ret = 0;
-    int cell = 0;
+       int ret = 0;
+       int cell = 0;
 
-    //+---------------------------------------------------------------------
-    //+                      first the opening preamble                    +
-    //+---------------------------------------------------------------------
+       //+---------------------------------------------------------------------
+       //+                      first the opening preamble                    +
+       //+---------------------------------------------------------------------
 
-    if (rotate) {
-       os << "\\begin{sideways}\n";
-       ++ret;
-    }
-    if (is_long_tabular)
-       os << "\\begin{longtable}{";
-    else
-       os << "\\begin{tabular}{";
-    for (int i = 0; i < columns_; ++i) {
-       if (column_info[i].left_line)
-           os << '|';
-       if (!column_info[i].align_special.empty()) {
-           os << column_info[i].align_special;
-       } else if (!column_info[i].p_width.empty()) {
-           switch (column_info[i].valignment) {
-           case LYX_VALIGN_TOP:
-               os << "p";
-               break;
-           case LYX_VALIGN_CENTER:
-               os << "m";
-               break;
-           case LYX_VALIGN_BOTTOM:
-               os << "b";
-               break;
-           }
-           os << "{"
-              << column_info[i].p_width
-              << '}';
-       } else {
-           switch (column_info[i].alignment) {
-           case LYX_ALIGN_LEFT:
-               os << 'l';
-               break;
-           case LYX_ALIGN_RIGHT:
-               os << 'r';
-               break;
-           default:
-               os << 'c';
-               break;
-           }
-       }
-       if (column_info[i].right_line)
-           os << '|';
-    }
-    os << "}\n";
-    ++ret;
-
-    //+---------------------------------------------------------------------
-    //+                      the single row and columns (cells)            +
-    //+---------------------------------------------------------------------
-
-    for (int i = 0; i < rows_; ++i) {
-       ret += TeXTopHLine(os, i);
-       int bret = ret;
-       if (IsLongTabular()) {
-           if ((endhead < 0) && (i == (abs(endhead)-1))) {
-               os << "\\endhead\n";
-               ++ret;
-           }
-           if ((endfirsthead < 0) && (i == (abs(endfirsthead)-1))) {
-               os << "\\endfirsthead\n";
+       if (rotate) {
+               os << "\\begin{sideways}\n";
                ++ret;
-           }
-           if ((endfoot < 0) && (i == (abs(endfoot)-1))) {
-               os << "\\endfoot\n";
-               ++ret;
-           }
-           if ((endlastfoot < 0) && (i == (abs(endlastfoot)-1))) {
-               os << "\\endlastfoot\n";
-               ++ret;
-           }
        }
-       if (ret > bret) {
-           ret += TeXBottomHLine(os, i-1);
-           ret += TeXTopHLine(os, i);
+       if (is_long_tabular)
+               os << "\\begin{longtable}{";
+       else
+               os << "\\begin{tabular}{";
+       for (int i = 0; i < columns_; ++i) {
+               if (column_info[i].left_line)
+                       os << '|';
+               if (!column_info[i].align_special.empty()) {
+                       os << column_info[i].align_special;
+               } else if (!column_info[i].p_width.empty()) {
+                       switch (column_info[i].valignment) {
+                       case LYX_VALIGN_TOP:
+                               os << "p";
+                               break;
+                       case LYX_VALIGN_CENTER:
+                               os << "m";
+                               break;
+                       case LYX_VALIGN_BOTTOM:
+                               os << "b";
+                               break;
+                       }
+                       os << "{"
+                          << column_info[i].p_width
+                          << '}';
+               } else {
+                       switch (column_info[i].alignment) {
+                       case LYX_ALIGN_LEFT:
+                               os << 'l';
+                               break;
+                       case LYX_ALIGN_RIGHT:
+                               os << 'r';
+                               break;
+                       default:
+                               os << 'c';
+                               break;
+                       }
+               }
+               if (column_info[i].right_line)
+                       os << '|';
        }
-       for (int j = 0; j < columns_; ++j) {
-           if (IsPartOfMultiColumn(i,j))
-               continue;
-           ret += TeXCellPreamble(os, cell);
-           InsetText * inset = GetCellInset(cell);
+       os << "}\n";
+       ++ret;
+
+       //+---------------------------------------------------------------------
+       //+                      the single row and columns (cells)            +
+       //+---------------------------------------------------------------------
+
+       for (int i = 0; i < rows_; ++i) {
+               ret += TeXTopHLine(os, i);
+               int bret = ret;
+               if (IsLongTabular()) {
+                       if ((endhead < 0) && (i == (abs(endhead)-1))) {
+                               os << "\\endhead\n";
+                               ++ret;
+                       }
+                       if ((endfirsthead < 0) && (i == (abs(endfirsthead)-1))) {
+                               os << "\\endfirsthead\n";
+                               ++ret;
+                       }
+                       if ((endfoot < 0) && (i == (abs(endfoot)-1))) {
+                               os << "\\endfoot\n";
+                               ++ret;
+                       }
+                       if ((endlastfoot < 0) && (i == (abs(endlastfoot)-1))) {
+                               os << "\\endlastfoot\n";
+                               ++ret;
+                       }
+               }
+               if (ret > bret) {
+                       ret += TeXBottomHLine(os, i-1);
+                       ret += TeXTopHLine(os, i);
+               }
+               for (int j = 0; j < columns_; ++j) {
+                       if (IsPartOfMultiColumn(i,j))
+                               continue;
+                       ret += TeXCellPreamble(os, cell);
+                       InsetText * inset = GetCellInset(cell);
 
-           bool rtl = inset->par->isRightToLeftPar(buf->params) &&
+                       bool rtl = inset->par->isRightToLeftPar(buf->params) &&
 #ifndef NEW_INSETS
-                   inset->par->Last() > 0 && GetPWidth(cell).empty();
+                               inset->par->Last() > 0 && GetPWidth(cell).empty();
 #else
-                   inset->par->size() > 0 && GetPWidth(cell).empty();
+                       inset->par->size() > 0 && GetPWidth(cell).empty();
 #endif
-           if (rtl)
-               os << "\\R{";
-           ret += inset->Latex(buf, os, fragile, fp);
-           if (rtl)
-               os << "}";
-
-           ret += TeXCellPostamble(os, cell);
-           if (!IsLastCellInRow(cell)) { // not last cell in row
-               os << "&\n";
-               ++ret;
-           }
-           ++cell;
-       }
-       os << "\\\\\n";
-       ret += TeXBottomHLine(os, i);
-       bret = ret;
-       if (IsLongTabular()) {
-           if ((endhead > 0) && (i == (endhead - 1))) {
-               os << "\\endhead\n";
-               ++ret;
-           }
-           if ((endfirsthead > 0) && (i == (endfirsthead - 1))) {
-               os << "\\endfirsthead\n";
-               ++ret;
-           }
-           if ((endfoot > 0) && (i == (endfoot - 1))) {
-               os << "\\endfoot\n";
-               ++ret;
-           }
-           if ((endlastfoot > 0) && (i == (endlastfoot - 1))) {
-               os << "\\endlastfoot\n";
-               ++ret;
-           }
+                       if (rtl)
+                               os << "\\R{";
+                       ret += inset->Latex(buf, os, fragile, fp);
+                       if (rtl)
+                               os << "}";
+
+                       ret += TeXCellPostamble(os, cell);
+                       if (!IsLastCellInRow(cell)) { // not last cell in row
+                               os << "&\n";
+                               ++ret;
+                       }
+                       ++cell;
+               }
+               os << "\\\\\n";
+               ret += TeXBottomHLine(os, i);
+               bret = ret;
+               if (IsLongTabular()) {
+                       if ((endhead > 0) && (i == (endhead - 1))) {
+                               os << "\\endhead\n";
+                               ++ret;
+                       }
+                       if ((endfirsthead > 0) && (i == (endfirsthead - 1))) {
+                               os << "\\endfirsthead\n";
+                               ++ret;
+                       }
+                       if ((endfoot > 0) && (i == (endfoot - 1))) {
+                               os << "\\endfoot\n";
+                               ++ret;
+                       }
+                       if ((endlastfoot > 0) && (i == (endlastfoot - 1))) {
+                               os << "\\endlastfoot\n";
+                               ++ret;
+                       }
 //         if (ret > bret)
 //             ret += TeXBottomHLine(os, i);
-           if (row_info[i].newpage) {
-               os << "\\newpage\n";
-               ++ret;
-           }
+                       if (row_info[i].newpage) {
+                               os << "\\newpage\n";
+                               ++ret;
+                       }
+               }
        }
-    }
 
-    //+---------------------------------------------------------------------
-    //+                      the closing of the tabular                    +
-    //+---------------------------------------------------------------------
+       //+---------------------------------------------------------------------
+       //+                      the closing of the tabular                    +
+       //+---------------------------------------------------------------------
 
-    if (is_long_tabular)
-       os << "\\end{longtable}";
-    else
-       os << "\\end{tabular}";
-    if (rotate) {
-       os << "\n\\end{sideways}";
-       ++ret;
-    }
+       if (is_long_tabular)
+               os << "\\end{longtable}";
+       else
+               os << "\\end{tabular}";
+       if (rotate) {
+               os << "\n\\end{sideways}";
+               ++ret;
+       }
 
-    return ret;
+       return ret;
 }
 
 
 int LyXTabular::DocBook(Buffer const * buf, ostream & os) const
 {
-    int ret = 0;
+       int ret = 0;
 
-    //+---------------------------------------------------------------------
-    //+                      first the opening preamble                    +
-    //+---------------------------------------------------------------------
+       //+---------------------------------------------------------------------
+       //+                      first the opening preamble                    +
+       //+---------------------------------------------------------------------
 
-    os << "<tgroup cols=\"" << columns_
-       << "\" colsep=\"1\" rowsep=\"1\">\n";
-    
-    for (int i = 0; i < columns_; ++i) {
-        os << "<colspec colname=\"col" << i << "\" align=\"";
-       switch (column_info[i].alignment) {
-       case LYX_ALIGN_LEFT:
-           os << "left";
-           break;
-       case LYX_ALIGN_RIGHT:
-           os << "right";
-           break;
-       default:
-           os << "center";
-           break;
+       os << "<tgroup cols=\"" << columns_
+          << "\" colsep=\"1\" rowsep=\"1\">\n";
+       
+       for (int i = 0; i < columns_; ++i) {
+               os << "<colspec colname=\"col" << i << "\" align=\"";
+               switch (column_info[i].alignment) {
+               case LYX_ALIGN_LEFT:
+                       os << "left";
+                       break;
+               case LYX_ALIGN_RIGHT:
+                       os << "right";
+                       break;
+               default:
+                       os << "center";
+                       break;
+               }
+               os << "\"/>\n";
+               ++ret;
        }
-       os << "\"/>\n";
-       ++ret;
-    }
 
-    //+---------------------------------------------------------------------
-    //+                      the single row and columns (cells)            +
-    //+---------------------------------------------------------------------
+       //+---------------------------------------------------------------------
+       //+                      the single row and columns (cells)            +
+       //+---------------------------------------------------------------------
 
-    int cell = 0;
-    os << "<tbody>\n";
-    for (int i = 0; i < rows_; ++i) {
-        os << "<row>\n";
-       for (int j = 0; j < columns_; ++j) {
-           if (IsPartOfMultiColumn(i, j))
-               continue;
-           
-           os << "<entry align=\"";
-           switch (GetAlignment(cell)) {
-           case LYX_ALIGN_LEFT:
-               os << "left";
-               break;
-           case LYX_ALIGN_RIGHT:
-               os << "right";
-               break;
-           default:
-               os << "center";
-               break;
-           }
-           
-           os << "\" valign=\"";
-           switch (GetVAlignment(cell)) {
-           case LYX_VALIGN_TOP:
-               os << "top";
-               break;
-           case LYX_VALIGN_BOTTOM:
-               os << "bottom";
-               break;
-           case LYX_VALIGN_CENTER:
-               os << "middle";
-           }
-           os << "\"";
-           
-           if (IsMultiColumn(cell)) {
-               os << " namest=\"col" << j << "\" ";
-               os << "nameend=\"col" << j + cells_in_multicolumn(cell) - 1<< "\"";
-           }
-           
-           os << ">";
-           ret += GetCellInset(cell)->DocBook(buf, os);
-           os << "</entry>";
-           ++cell;
-       }
-       os << "</row>\n";
-    }
-    os << "</tbody>\n";
-    //+---------------------------------------------------------------------
-    //+                      the closing of the tabular                    +
-    //+---------------------------------------------------------------------
-
-    os << "</tgroup>";
-    ++ret;
-
-    return ret;
+       int cell = 0;
+       os << "<tbody>\n";
+       for (int i = 0; i < rows_; ++i) {
+               os << "<row>\n";
+               for (int j = 0; j < columns_; ++j) {
+                       if (IsPartOfMultiColumn(i, j))
+                               continue;
+               
+                       os << "<entry align=\"";
+                       switch (GetAlignment(cell)) {
+                       case LYX_ALIGN_LEFT:
+                               os << "left";
+                               break;
+                       case LYX_ALIGN_RIGHT:
+                               os << "right";
+                               break;
+                       default:
+                               os << "center";
+                               break;
+                       }
+               
+                       os << "\" valign=\"";
+                       switch (GetVAlignment(cell)) {
+                       case LYX_VALIGN_TOP:
+                               os << "top";
+                               break;
+                       case LYX_VALIGN_BOTTOM:
+                               os << "bottom";
+                               break;
+                       case LYX_VALIGN_CENTER:
+                               os << "middle";
+                       }
+                       os << "\"";
+               
+                       if (IsMultiColumn(cell)) {
+                               os << " namest=\"col" << j << "\" ";
+                               os << "nameend=\"col" << j + cells_in_multicolumn(cell) - 1<< "\"";
+                       }
+               
+                       os << ">";
+                       ret += GetCellInset(cell)->DocBook(buf, os);
+                       os << "</entry>";
+                       ++cell;
+               }
+               os << "</row>\n";
+       }
+       os << "</tbody>\n";
+       //+---------------------------------------------------------------------
+       //+                      the closing of the tabular                    +
+       //+---------------------------------------------------------------------
+
+       os << "</tgroup>";
+       ++ret;
+
+       return ret;
 }
 
 
 namespace {
 
-inline
-void print_n_chars(ostream & os, unsigned char ch, int n)
-{
-       os << string(n, ch);
-}
+       inline
+       void print_n_chars(ostream & os, unsigned char ch, int n)
+       {
+               os << string(n, ch);
+       }
 
 } // namespace anon
 
 
 int LyXTabular::AsciiTopHLine(ostream & os, int row,
-                             vector<unsigned int> const & clen) const
+                                                         vector<unsigned int> const & clen) const
 {
-    int const fcell = GetFirstCellInRow(row);
-    int const n = NumberOfCellsInRow(fcell) + fcell;
-    int tmp = 0;
+       int const fcell = GetFirstCellInRow(row);
+       int const n = NumberOfCellsInRow(fcell) + fcell;
+       int tmp = 0;
 
-    for (int i = fcell; i < n; ++i) {
-       if (TopLine(i)) {
-           ++tmp;
-           break;
+       for (int i = fcell; i < n; ++i) {
+               if (TopLine(i)) {
+                       ++tmp;
+                       break;
+               }
        }
-    }
-    if (!tmp)
-       return 0;
+       if (!tmp)
+               return 0;
 
-    unsigned char ch;
-    for (int i = fcell; i < n; ++i) {
-       if (TopLine(i)) {
-           if (LeftLine(i))
-               os << "+-";
-           else
-               os << "--";
-           ch = '-';
-       } else {
-           os << "  ";
-           ch = ' ';
-       }
-       int column = column_of_cell(i);
-       int len = clen[column];
-       while(IsPartOfMultiColumn(row, ++column))
-           len += clen[column] + 4;
-       print_n_chars(os, ch, len);
-       if (TopLine(i)) {
-           if (RightLine(i))
-               os << "-+";
-           else
-               os << "--";
-       } else {
-           os << "  ";
+       unsigned char ch;
+       for (int i = fcell; i < n; ++i) {
+               if (TopLine(i)) {
+                       if (LeftLine(i))
+                               os << "+-";
+                       else
+                               os << "--";
+                       ch = '-';
+               } else {
+                       os << "  ";
+                       ch = ' ';
+               }
+               int column = column_of_cell(i);
+               int len = clen[column];
+               while(IsPartOfMultiColumn(row, ++column))
+                       len += clen[column] + 4;
+               print_n_chars(os, ch, len);
+               if (TopLine(i)) {
+                       if (RightLine(i))
+                               os << "-+";
+                       else
+                               os << "--";
+               } else {
+                       os << "  ";
+               }
        }
-    }
-    os << endl;
-    return 1;
+       os << endl;
+       return 1;
 }
 
 
 int LyXTabular::AsciiBottomHLine(ostream & os, int row,
-                                vector<unsigned int> const & clen) const
+                                                                vector<unsigned int> const & clen) const
 {
-    int const fcell = GetFirstCellInRow(row);
-    int const n = NumberOfCellsInRow(fcell) + fcell;
-    int tmp = 0;
+       int const fcell = GetFirstCellInRow(row);
+       int const n = NumberOfCellsInRow(fcell) + fcell;
+       int tmp = 0;
 
-    for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i)) {
-           ++tmp;
-           break;
+       for (int i = fcell; i < n; ++i) {
+               if (BottomLine(i)) {
+                       ++tmp;
+                       break;
+               }
        }
-    }
-    if (!tmp)
-       return 0;
+       if (!tmp)
+               return 0;
 
-    unsigned char ch;
-    for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i)) {
-           if (LeftLine(i))
-               os << "+-";
-           else
-               os << "--";
-           ch = '-';
-       } else {
-           os << "  ";
-           ch = ' ';
-       }
-       int column = column_of_cell(i);
-       int len = clen[column];
-       while(IsPartOfMultiColumn(row, ++column))
-           len += clen[column] + 4;
-       print_n_chars(os, ch, len);
-       if (BottomLine(i)) {
-           if (RightLine(i))
-               os << "-+";
-           else
-               os << "--";
-       } else {
-           os << "  ";
+       unsigned char ch;
+       for (int i = fcell; i < n; ++i) {
+               if (BottomLine(i)) {
+                       if (LeftLine(i))
+                               os << "+-";
+                       else
+                               os << "--";
+                       ch = '-';
+               } else {
+                       os << "  ";
+                       ch = ' ';
+               }
+               int column = column_of_cell(i);
+               int len = clen[column];
+               while(IsPartOfMultiColumn(row, ++column))
+                       len += clen[column] + 4;
+               print_n_chars(os, ch, len);
+               if (BottomLine(i)) {
+                       if (RightLine(i))
+                               os << "-+";
+                       else
+                               os << "--";
+               } else {
+                       os << "  ";
+               }
        }
-    }
-    os << endl;
-    return 1;
+       os << endl;
+       return 1;
 }
 
 
 int LyXTabular::AsciiPrintCell(Buffer const * buf, ostream & os,
-                              int cell, int row, int column,
-                              vector<unsigned int> const & clen) const
-{
-    ostringstream sstr;
-    int ret = GetCellInset(cell)->Ascii(buf, sstr, 0);
-
-    if (LeftLine(cell))
-       os << "| ";
-    else
-       os << "  ";
-
-    unsigned int len1 = sstr.str().length();
-    unsigned int len2 = clen[column];
-    while(IsPartOfMultiColumn(row, ++column))
-       len2 += clen[column] + 4;
-    len2 -= len1;
-
-    switch (GetAlignment(cell)) {
-    default:
-    case LYX_ALIGN_LEFT:
-       len1 = 0;
-       break;
-    case LYX_ALIGN_RIGHT:
-       len1 = len2;
-       len2 = 0;
-       break;
-    case LYX_ALIGN_CENTER:
-       len1 = len2 / 2;
+                                                          int cell, int row, int column,
+                                                          vector<unsigned int> const & clen) const
+{
+       ostringstream sstr;
+       int ret = GetCellInset(cell)->Ascii(buf, sstr, 0);
+
+       if (LeftLine(cell))
+               os << "| ";
+       else
+               os << "  ";
+
+       unsigned int len1 = sstr.str().length();
+       unsigned int len2 = clen[column];
+       while(IsPartOfMultiColumn(row, ++column))
+               len2 += clen[column] + 4;
        len2 -= len1;
-       break;
-    }
 
-    for (unsigned int i = 0; i < len1; ++i)
-       os << " ";
-    os << sstr.str();
-    for (unsigned int i = 0; i < len2; ++i)
-       os << " ";
-    if (RightLine(cell))
-       os << " |";
-    else
-       os << "  ";
+       switch (GetAlignment(cell)) {
+       default:
+       case LYX_ALIGN_LEFT:
+               len1 = 0;
+               break;
+       case LYX_ALIGN_RIGHT:
+               len1 = len2;
+               len2 = 0;
+               break;
+       case LYX_ALIGN_CENTER:
+               len1 = len2 / 2;
+               len2 -= len1;
+               break;
+       }
+
+       for (unsigned int i = 0; i < len1; ++i)
+               os << " ";
+       os << sstr.str();
+       for (unsigned int i = 0; i < len2; ++i)
+               os << " ";
+       if (RightLine(cell))
+               os << " |";
+       else
+               os << "  ";
 
-    return ret;
+       return ret;
 }
 
 
 int LyXTabular::Ascii(Buffer const * buf, ostream & os) const
 {
-    int ret = 0;
+       int ret = 0;
 
-    //+---------------------------------------------------------------------
-    //+           first calculate the width of the single columns          +
-    //+---------------------------------------------------------------------
-    vector<unsigned int> clen(columns_);
+       //+---------------------------------------------------------------------
+       //+           first calculate the width of the single columns          +
+       //+---------------------------------------------------------------------
+       vector<unsigned int> clen(columns_);
 
-    // first all non (real) multicolumn cells!
-    for (int j = 0; j < columns_; ++j) {
-       clen[j] = 0;
-       for (int i = 0; i < rows_; ++i) {
-           int cell = GetCellNumber(i, j);
-           if (IsMultiColumn(cell, true))
-               continue;
-           ostringstream sstr;
-           GetCellInset(cell)->Ascii(buf, sstr, 0);
-           if (clen[j] < sstr.str().length())
-               clen[j] = sstr.str().length();
-       }
-    }
-    // then all (real) multicolumn cells!
-    for (int j = 0; j < columns_; ++j) {
-       for (int i = 0; i < rows_; ++i) {
-           int cell = GetCellNumber(i, j);
-           if (!IsMultiColumn(cell, true) || IsPartOfMultiColumn(i, j))
-               continue;
-           ostringstream sstr;
-           GetCellInset(cell)->Ascii(buf, sstr, 0);
-           int len = int(sstr.str().length());
-           int const n = cells_in_multicolumn(cell);
-           for (int k = j; (len > 0) && (k < (j + n - 1)); ++k)
-               len -= clen[k];
-           if (len > int(clen[j + n - 1]))
-               clen[j + n - 1] = len;
-       }
-    }
-    int cell = 0;
-    for (int i = 0; i < rows_; ++i) {
-       AsciiTopHLine(os, i, clen);
+       // first all non (real) multicolumn cells!
        for (int j = 0; j < columns_; ++j) {
-           if (IsPartOfMultiColumn(i,j))
-               continue;
-           ret += AsciiPrintCell(buf, os, cell, i, j, clen);
-           ++cell;
+               clen[j] = 0;
+               for (int i = 0; i < rows_; ++i) {
+                       int cell = GetCellNumber(i, j);
+                       if (IsMultiColumn(cell, true))
+                               continue;
+                       ostringstream sstr;
+                       GetCellInset(cell)->Ascii(buf, sstr, 0);
+                       if (clen[j] < sstr.str().length())
+                               clen[j] = sstr.str().length();
+               }
        }
-       os << endl;
-       AsciiBottomHLine(os, i, clen);
-    }
-    return ret;
+       // then all (real) multicolumn cells!
+       for (int j = 0; j < columns_; ++j) {
+               for (int i = 0; i < rows_; ++i) {
+                       int cell = GetCellNumber(i, j);
+                       if (!IsMultiColumn(cell, true) || IsPartOfMultiColumn(i, j))
+                               continue;
+                       ostringstream sstr;
+                       GetCellInset(cell)->Ascii(buf, sstr, 0);
+                       int len = int(sstr.str().length());
+                       int const n = cells_in_multicolumn(cell);
+                       for (int k = j; (len > 0) && (k < (j + n - 1)); ++k)
+                               len -= clen[k];
+                       if (len > int(clen[j + n - 1]))
+                               clen[j + n - 1] = len;
+               }
+       }
+       int cell = 0;
+       for (int i = 0; i < rows_; ++i) {
+               AsciiTopHLine(os, i, clen);
+               for (int j = 0; j < columns_; ++j) {
+                       if (IsPartOfMultiColumn(i,j))
+                               continue;
+                       ret += AsciiPrintCell(buf, os, cell, i, j, clen);
+                       ++cell;
+               }
+               os << endl;
+               AsciiBottomHLine(os, i, clen);
+       }
+       return ret;
 }
 
 
 InsetText * LyXTabular::GetCellInset(int cell) const
 {
-    return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
+       return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
 }
 
 
 InsetText * LyXTabular::GetCellInset(int row, int column) const
 {
-    return GetCellInset(GetCellNumber(row, column));
+       return GetCellInset(GetCellNumber(row, column));
 }
 
 
 void LyXTabular::Validate(LaTeXFeatures & features) const
 {
-    if (IsLongTabular())
-        features.longtable = true;
-    if (NeedRotating())
-       features.rotating = true;
-    for (int cell = 0; !features.array && (cell < numberofcells); ++cell) {
-       if (GetVAlignment(cell) != LYX_VALIGN_TOP)
-           features.array = true;
-       GetCellInset(cell)->Validate(features);
-    }
+       if (IsLongTabular())
+               features.longtable = true;
+       if (NeedRotating())
+               features.rotating = true;
+       for (int cell = 0; !features.array && (cell < numberofcells); ++cell) {
+               if (GetVAlignment(cell) != LYX_VALIGN_TOP)
+                       features.array = true;
+               GetCellInset(cell)->Validate(features);
+       }
 }
 
 
 #ifndef NEW_INSETS
 LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
-    LyXParagraph * par = GetCellInset(cell)->par;
+       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 BOX_PARBOX;
+       for (; par; par = par->next_) {
+               for (int i = 0; i < par->Last(); ++i) {
+                       if (par->GetChar(i)     == LyXParagraph::META_NEWLINE)
+                               return BOX_PARBOX;
+               }
        }
-    }
-    return BOX_NONE;
+       return BOX_NONE;
 }
 #else
 LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
-    LyXParagraph * par = GetCellInset(cell)->par;
+       LyXParagraph * par = GetCellInset(cell)->par;
 
-    for (; par; par = par->next()) {
-       for (int i = 0; i < par->size(); ++i) {
-           if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
-               return BOX_PARBOX;
+       for (; par; par = par->next()) {
+               for (int i = 0; i < par->size(); ++i) {
+                       if (par->GetChar(i)     == LyXParagraph::META_NEWLINE)
+                               return BOX_PARBOX;
+               }
        }
-    }
-    return BOX_NONE;
+       return BOX_NONE;
 }
 #endif
index b95a38d280da5834ac5624209ae968f7702327f3..5af58996edc2a3c3448dfc4e3faa8276a46924dc 100644 (file)
@@ -32,485 +32,485 @@ class Buffer;
 ///
 class LyXTabular  {
 public:
-    ///
-    enum Feature {
        ///
-       APPEND_ROW = 0,
+       enum Feature {
+               ///
+               APPEND_ROW = 0,
+               ///
+               APPEND_COLUMN,
+               ///
+               DELETE_ROW,
+               ///
+               DELETE_COLUMN,
+               ///
+               TOGGLE_LINE_TOP,
+               ///
+               TOGGLE_LINE_BOTTOM,
+               ///
+               TOGGLE_LINE_LEFT,
+               ///
+               TOGGLE_LINE_RIGHT,
+               ///
+               ALIGN_LEFT,
+               ///
+               ALIGN_RIGHT,
+               ///
+               ALIGN_CENTER,
+               ///
+               VALIGN_TOP,
+               ///
+               VALIGN_BOTTOM,
+               ///
+               VALIGN_CENTER,
+               ///
+               M_TOGGLE_LINE_TOP,
+               ///
+               M_TOGGLE_LINE_BOTTOM,
+               ///
+               M_TOGGLE_LINE_LEFT,
+               ///
+               M_TOGGLE_LINE_RIGHT,
+               ///
+               M_ALIGN_LEFT,
+               ///
+               M_ALIGN_RIGHT,
+               ///
+               M_ALIGN_CENTER,
+               ///
+               M_VALIGN_TOP,
+               ///
+               M_VALIGN_BOTTOM,
+               ///
+               M_VALIGN_CENTER,
+               ///
+               MULTICOLUMN,
+               ///
+               SET_ALL_LINES,
+               ///
+               UNSET_ALL_LINES,
+               ///
+               SET_LONGTABULAR,
+               ///
+               UNSET_LONGTABULAR,
+               ///
+               SET_PWIDTH,
+               ///
+               SET_MPWIDTH,
+               ///
+               SET_ROTATE_TABULAR,
+               ///
+               UNSET_ROTATE_TABULAR,
+               ///
+               SET_ROTATE_CELL,
+               ///
+               UNSET_ROTATE_CELL,
+               ///
+               SET_USEBOX,
+               ///
+               SET_LTHEAD,
+               ///
+               SET_LTFIRSTHEAD,
+               ///
+               SET_LTFOOT,
+               ///
+               SET_LTLASTFOOT,
+               ///
+               SET_LTNEWPAGE,
+               ///
+               SET_SPECIAL_COLUMN,
+               ///
+               SET_SPECIAL_MULTI,
+               ///
+               LAST_ACTION
+       };
+       ///
+       enum {
+               ///
+               CELL_NORMAL = 0,
+               ///
+               CELL_BEGIN_OF_MULTICOLUMN,
+               ///
+               CELL_PART_OF_MULTICOLUMN
+       };
+
        ///
-       APPEND_COLUMN,
+       enum VAlignment {
+               ///
+               LYX_VALIGN_TOP = 0,
+               ///
+               LYX_VALIGN_BOTTOM = 1,
+               ///
+               LYX_VALIGN_CENTER = 2
+       };
+
+       enum BoxType {
+               ///
+               BOX_NONE = 0,
+               ///
+               BOX_PARBOX = 1,
+               ///
+               BOX_MINIPAGE = 2
+       };
+
+       /* konstruktor */
        ///
-       DELETE_ROW,
+       LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
        ///
-       DELETE_COLUMN,
+       LyXTabular(InsetTabular *, LyXTabular const &);
        ///
-       TOGGLE_LINE_TOP,
+       explicit
+       LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
        ///
-       TOGGLE_LINE_BOTTOM,
+       LyXTabular & operator=(LyXTabular const &);
        ///
-       TOGGLE_LINE_LEFT,
+       LyXTabular * Clone(InsetTabular *);
+       
+       /// Returns true if there is a topline, returns false if not
+       bool TopLine(int cell, bool onlycolumn = false) const;
+       /// Returns true if there is a topline, returns false if not
+       bool BottomLine(int cell, bool onlycolumn = false) const;
+       /// Returns true if there is a topline, returns false if not
+       bool LeftLine(int cell, bool onlycolumn = false) const;
+       /// Returns true if there is a topline, returns false if not
+       bool RightLine(int cell, bool onlycolumn = false) const;
+       
        ///
-       TOGGLE_LINE_RIGHT,
+       bool TopAlreadyDrawed(int cell) const;
        ///
-       ALIGN_LEFT,
+       bool LeftAlreadyDrawed(int cell) const;
        ///
-       ALIGN_RIGHT,
+       bool IsLastRow(int cell) const;
+       
        ///
-       ALIGN_CENTER,
+       int GetAdditionalHeight(int cell) const;
        ///
-       VALIGN_TOP,
+       int GetAdditionalWidth(int cell) const;
+       
+       /* returns the maximum over all rows */
        ///
-       VALIGN_BOTTOM,
+       int GetWidthOfColumn(int cell) const;
        ///
-       VALIGN_CENTER,
+       int GetWidthOfTabular() const;
        ///
-       M_TOGGLE_LINE_TOP,
+       int GetAscentOfRow(int row) const;
        ///
-       M_TOGGLE_LINE_BOTTOM,
+       int GetDescentOfRow(int row) const;
        ///
-       M_TOGGLE_LINE_LEFT,
+       int GetHeightOfTabular() const;
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetAscentOfRow(int row, int height);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetDescentOfRow(int row, int height);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetWidthOfCell(int cell, int new_width);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetAllLines(int cell, bool line);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetTopLine(int cell, bool line, bool onlycolumn=false);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetBottomLine(int cell, bool line, bool onlycolumn=false);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetLeftLine(int cell, bool line, bool onlycolumn=false);
+       /// 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, LyXAlignment align, bool onlycolumn = false);
+       /// Returns true if a complete update is necessary, otherwise false
+       bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false);
        ///
-       M_TOGGLE_LINE_RIGHT,
+       bool SetColumnPWidth(int cell, string const & width);
        ///
-       M_ALIGN_LEFT,
+       bool SetMColumnPWidth(int cell, string const & width);
        ///
-       M_ALIGN_RIGHT,
+       bool SetAlignSpecial(int cell, string const & special, Feature what);
        ///
-       M_ALIGN_CENTER,
+       LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const;
        ///
-       M_VALIGN_TOP,
+       VAlignment GetVAlignment(int cell, bool onlycolumn = false) const;
        ///
-       M_VALIGN_BOTTOM,
+       string const GetPWidth(int cell) const;
        ///
-       M_VALIGN_CENTER,
+       string const GetColumnPWidth(int cell) const;
        ///
-       MULTICOLUMN,
+       string const GetMColumnPWidth(int cell) const;
        ///
-       SET_ALL_LINES,
+       string const GetAlignSpecial(int cell, int what) const;
        ///
-       UNSET_ALL_LINES,
+       int GetWidthOfCell(int cell) const;
        ///
-       SET_LONGTABULAR,
+       int GetBeginningOfTextInCell(int cell) const;
        ///
-       UNSET_LONGTABULAR,
+       void AppendRow(int cell);
        ///
-       SET_PWIDTH,
+       void DeleteRow(int row);
        ///
-       SET_MPWIDTH,
+       void AppendColumn(int cell);
        ///
-       SET_ROTATE_TABULAR,
+       void DeleteColumn(int column);
        ///
-       UNSET_ROTATE_TABULAR,
+       bool IsFirstCellInRow(int cell) const;
        ///
-       SET_ROTATE_CELL,
+       int GetFirstCellInRow(int row) const;
        ///
-       UNSET_ROTATE_CELL,
+       bool IsLastCellInRow(int cell) const;
        ///
-       SET_USEBOX,
+       int GetLastCellInRow(int row) const;
        ///
-       SET_LTHEAD,
+       int GetNumberOfCells() const;
        ///
-       SET_LTFIRSTHEAD,
+       int NumberOfCellsInRow(int cell) const;
        ///
-       SET_LTFOOT,
+       void Write(Buffer const *, std::ostream &) const;
        ///
-       SET_LTLASTFOOT,
+       void Read(Buffer const *, LyXLex &);
        ///
-       SET_LTNEWPAGE,
+       void OldFormatRead(LyXLex &, string const &);
+       //
+       // helper function for Latex returns number of newlines
        ///
-       SET_SPECIAL_COLUMN,
+       int TeXTopHLine(std::ostream &, int row) const;
        ///
-       SET_SPECIAL_MULTI,
+       int TeXBottomHLine(std::ostream &, int row) const;
        ///
-       LAST_ACTION
-    };
-    ///
-    enum {
+       int TeXCellPreamble(std::ostream &, int cell) const;
        ///
-       CELL_NORMAL = 0,
+       int TeXCellPostamble(std::ostream &, int cell) const;
        ///
-       CELL_BEGIN_OF_MULTICOLUMN,
+       int Latex(Buffer const *, std::ostream &, bool, bool) const;
        ///
-       CELL_PART_OF_MULTICOLUMN
-    };
-
-    ///
-    enum VAlignment {
+       int DocBook(Buffer const * buf, std::ostream & os) const;
        ///
-       LYX_VALIGN_TOP = 0,
+       // helper function for Latex returns number of newlines
        ///
-       LYX_VALIGN_BOTTOM = 1,
+       int AsciiTopHLine(std::ostream &, int row,
+                                         std::vector<unsigned int> const &) const;
        ///
-       LYX_VALIGN_CENTER = 2
-    };
-
-    enum BoxType {
+       int AsciiBottomHLine(std::ostream &, int row,
+                                                std::vector<unsigned int> const &) const;
        ///
-       BOX_NONE = 0,
+       int AsciiPrintCell(Buffer const *, std::ostream &, int cell, int row,
+                                          int column, std::vector<unsigned int> const &) const;
        ///
-       BOX_PARBOX = 1,
+       int Ascii(Buffer const *, std::ostream &) const;
        ///
-       BOX_MINIPAGE = 2
-    };
-
-    /* konstruktor */
-    ///
-    LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
-    ///
-    LyXTabular(InsetTabular *, LyXTabular const &);
-    ///
-    explicit
-    LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
-    ///
-    LyXTabular & operator=(LyXTabular const &);
-    ///
-    LyXTabular * Clone(InsetTabular *);
-    
-    /// Returns true if there is a topline, returns false if not
-    bool TopLine(int cell, bool onlycolumn = false) const;
-    /// Returns true if there is a topline, returns false if not
-    bool BottomLine(int cell, bool onlycolumn = false) const;
-    /// Returns true if there is a topline, returns false if not
-    bool LeftLine(int cell, bool onlycolumn = false) const;
-    /// Returns true if there is a topline, returns false if not
-    bool RightLine(int cell, bool onlycolumn = false) const;
-    
-    ///
-    bool TopAlreadyDrawed(int cell) const;
-    ///
-    bool LeftAlreadyDrawed(int cell) const;
-    ///
-    bool IsLastRow(int cell) const;
-    
-    ///
-    int GetAdditionalHeight(int cell) const;
-    ///
-    int GetAdditionalWidth(int cell) const;
-    
-    /* returns the maximum over all rows */
-    ///
-    int GetWidthOfColumn(int cell) const;
-    ///
-    int GetWidthOfTabular() const;
-    ///
-    int GetAscentOfRow(int row) const;
-    ///
-    int GetDescentOfRow(int row) const;
-    ///
-    int GetHeightOfTabular() const;
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetAscentOfRow(int row, int height);
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetDescentOfRow(int row, int height);
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetWidthOfCell(int cell, int new_width);
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetAllLines(int cell, bool line);
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetTopLine(int cell, bool line, bool onlycolumn=false);
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetBottomLine(int cell, bool line, bool onlycolumn=false);
-    /// Returns true if a complete update is necessary, otherwise false
-    bool SetLeftLine(int cell, bool line, bool onlycolumn=false);
-    /// 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, LyXAlignment align, bool onlycolumn = false);
-    /// Returns true if a complete update is necessary, otherwise 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, Feature what);
-    ///
-    LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const;
-    ///
-    VAlignment GetVAlignment(int cell, bool onlycolumn = false) const;
-    ///
-    string const GetPWidth(int cell) const;
-    ///
-    string const GetColumnPWidth(int cell) const;
-    ///
-    string const GetMColumnPWidth(int cell) const;
-    ///
-    string const GetAlignSpecial(int cell, int what) const;
-    ///
-    int GetWidthOfCell(int cell) const;
-    ///
-    int GetBeginningOfTextInCell(int cell) const;
-    ///
-    void AppendRow(int cell);
-    ///
-    void DeleteRow(int row);
-    ///
-    void AppendColumn(int cell);
-    ///
-    void DeleteColumn(int column);
-    ///
-    bool IsFirstCellInRow(int cell) const;
-    ///
-    int GetFirstCellInRow(int row) const;
-    ///
-    bool IsLastCellInRow(int cell) const;
-    ///
-    int GetLastCellInRow(int row) const;
-    ///
-    int GetNumberOfCells() const;
-    ///
-    int NumberOfCellsInRow(int cell) const;
-    ///
-    void Write(Buffer const *, std::ostream &) const;
-    ///
-    void Read(Buffer const *, LyXLex &);
-    ///
-    void OldFormatRead(LyXLex &, string const &);
-    //
-    // helper function for Latex returns number of newlines
-    ///
-    int TeXTopHLine(std::ostream &, int row) const;
-    ///
-    int TeXBottomHLine(std::ostream &, int row) const;
-    ///
-    int TeXCellPreamble(std::ostream &, int cell) const;
-    ///
-    int TeXCellPostamble(std::ostream &, int cell) const;
-    ///
-    int Latex(Buffer const *, std::ostream &, bool, bool) const;
-    ///
-    int DocBook(Buffer const * buf, std::ostream & os) const;
-    ///
-    // helper function for Latex returns number of newlines
-    ///
-    int AsciiTopHLine(std::ostream &, int row,
-                     std::vector<unsigned int> const &) const;
-    ///
-    int AsciiBottomHLine(std::ostream &, int row,
-                        std::vector<unsigned int> const &) const;
-    ///
-    int AsciiPrintCell(Buffer const *, std::ostream &, int cell, int row,
-                      int column, std::vector<unsigned int> const &) const;
-    ///
-    int Ascii(Buffer const *, std::ostream &) const;
-    ///
-    bool IsMultiColumn(int cell, bool real = false) const;
-    ///
-    void SetMultiColumn(int cell, int number);
-    ///
-    int UnsetMultiColumn(int cell); // returns number of new cells
-    ///
-    bool IsPartOfMultiColumn(int row, int column) const;
-    ///
-    int row_of_cell(int cell) const;
-    ///
-    int column_of_cell(int cell) const;
-    ///
-    int right_column_of_cell(int cell) const;
-    ///
-    void SetLongTabular(bool);
-    ///
-    bool IsLongTabular() const;
-    ///
-    void SetRotateTabular(bool);
-    ///
-    bool GetRotateTabular() const;
-    ///
-    void SetRotateCell(int cell, bool);
-    ///
-    bool GetRotateCell(int cell) const;
-    ///
-    bool NeedRotating() const;
-    ///
-    bool IsLastCell(int cell) const;
-    ///
-    int GetCellAbove(int cell) const;
-    ///
-    int GetCellBelow(int cell) const;
-    ///
-    int GetLastCellAbove(int cell) const;
-    ///
-    int GetLastCellBelow(int cell) const;
-    ///
-    int GetCellNumber(int row, int column) const;
-    ///
-    void SetUsebox(int cell, BoxType);
-    ///
-    BoxType GetUsebox(int cell) const;
-    //
-    // Long Tabular Options
-    ///
-    void SetLTHead(int cell, bool first);
-    ///
-    bool GetRowOfLTHead(int cell, int & row) const;
-    ///
-    bool GetRowOfLTFirstHead(int cell, int & row) const;
-    ///
-    void SetLTFoot(int cell, bool last);
-    ///
-    bool GetRowOfLTFoot(int cell, int & row) const;
-    ///
-    bool GetRowOfLTLastFoot(int cell, int & row) const;
-    ///
-    void SetLTNewPage(int cell, bool what);
-    ///
-    bool GetLTNewPage(int cell) const;
-    ///
-    InsetText * GetCellInset(int cell) const;
-    ///
-    InsetText * GetCellInset(int row, int column) const;
-    ///
-    int rows() const { return rows_; }
-    ///
-    int columns() const { return columns_;}
-    ///
-    InsetTabular * owner() const { return owner_; }
-    ///
-    void Validate(LaTeXFeatures &) const;
-
-private: //////////////////////////////////////////////////////////////////
-    ///
-    struct cellstruct {
+       bool IsMultiColumn(int cell, bool real = false) const;
        ///
-        cellstruct();
+       void SetMultiColumn(int cell, int number);
        ///
-       int cellno;
+       int UnsetMultiColumn(int cell); // returns number of new cells
        ///
-       int width_of_cell;
+       bool IsPartOfMultiColumn(int row, int column) const;
        ///
-       int multicolumn;
+       int row_of_cell(int cell) const;
        ///
-       LyXAlignment alignment;
+       int column_of_cell(int cell) const;
        ///
-       VAlignment valignment;
+       int right_column_of_cell(int cell) const;
        ///
-       bool top_line;
+       void SetLongTabular(bool);
        ///
-       bool bottom_line;
+       bool IsLongTabular() const;
        ///
-       bool left_line;
+       void SetRotateTabular(bool);
        ///
-       bool right_line;
+       bool GetRotateTabular() const;
        ///
-       BoxType usebox;
+       void SetRotateCell(int cell, bool);
        ///
-       bool rotate;
+       bool GetRotateCell(int cell) const;
        ///
-       string align_special;
+       bool NeedRotating() const;
        ///
-       string p_width; // this is only set for multicolumn!!!
+       bool IsLastCell(int cell) const;
        ///
-       InsetText inset;
-    };
-    ///
-    typedef std::vector<cellstruct> cell_vector;
-    ///
-    typedef std::vector<cell_vector> cell_vvector;
-
-    ///
-    struct rowstruct {
+       int GetCellAbove(int cell) const;
        ///
-        rowstruct();
+       int GetCellBelow(int cell) const;
        ///
-       bool top_line;
+       int GetLastCellAbove(int cell) const;
        ///
-       bool bottom_line;
+       int GetLastCellBelow(int cell) const;
        ///
-        int ascent_of_row;
+       int GetCellNumber(int row, int column) const;
        ///
-        int descent_of_row;
-       /// This are for longtabulars only
-       bool newpage;
-    };
-    ///
-    typedef std::vector<rowstruct> row_vector;
-
-    ///
-    struct columnstruct {
+       void SetUsebox(int cell, BoxType);
+       ///
+       BoxType GetUsebox(int cell) const;
+       //
+       // Long Tabular Options
        ///
-        columnstruct();
+       void SetLTHead(int cell, bool first);
        ///
-       LyXAlignment alignment;
+       bool GetRowOfLTHead(int cell, int & row) const;
        ///
-       VAlignment valignment;
+       bool GetRowOfLTFirstHead(int cell, int & row) const;
        ///
-       bool left_line;
+       void SetLTFoot(int cell, bool last);
        ///
-       bool right_line;
+       bool GetRowOfLTFoot(int cell, int & row) const;
        ///
-       int  width_of_column;
+       bool GetRowOfLTLastFoot(int cell, int & row) const;
+       ///
+       void SetLTNewPage(int cell, bool what);
+       ///
+       bool GetLTNewPage(int cell) const;
+       ///
+       InsetText * GetCellInset(int cell) const;
+       ///
+       InsetText * GetCellInset(int row, int column) const;
+       ///
+       int rows() const { return rows_; }
+       ///
+       int columns() const { return columns_;}
+       ///
+       InsetTabular * owner() const { return owner_; }
+       ///
+       void Validate(LaTeXFeatures &) const;
+
+private: //////////////////////////////////////////////////////////////////
+       ///
+       struct cellstruct {
+               ///
+               cellstruct();
+               ///
+               int cellno;
+               ///
+               int width_of_cell;
+               ///
+               int multicolumn;
+               ///
+               LyXAlignment alignment;
+               ///
+               VAlignment valignment;
+               ///
+               bool top_line;
+               ///
+               bool bottom_line;
+               ///
+               bool left_line;
+               ///
+               bool right_line;
+               ///
+               BoxType usebox;
+               ///
+               bool rotate;
+               ///
+               string align_special;
+               ///
+               string p_width; // this is only set for multicolumn!!!
+               ///
+               InsetText inset;
+       };
+       ///
+       typedef std::vector<cellstruct> cell_vector;
+       ///
+       typedef std::vector<cell_vector> cell_vvector;
+
        ///
-       string p_width;
+       struct rowstruct {
+               ///
+               rowstruct();
+               ///
+               bool top_line;
+               ///
+               bool bottom_line;
+               ///
+               int ascent_of_row;
+               ///
+               int descent_of_row;
+               /// This are for longtabulars only
+               bool newpage;
+       };
+       ///
+       typedef std::vector<rowstruct> row_vector;
+
        ///
-       string align_special;
-    };
-    ///
-    typedef std::vector<columnstruct> column_vector;
+       struct columnstruct {
+               ///
+               columnstruct();
+               ///
+               LyXAlignment alignment;
+               ///
+               VAlignment valignment;
+               ///
+               bool left_line;
+               ///
+               bool right_line;
+               ///
+               int  width_of_column;
+               ///
+               string p_width;
+               ///
+               string align_special;
+       };
+       ///
+       typedef std::vector<columnstruct> column_vector;
 
-    ///
-    void ReadNew(Buffer const * buf, std::istream & is,
-            LyXLex & lex, string const & l);
-    ///
-    void ReadOld(Buffer const * buf, std::istream & is,
-            LyXLex & lex, string const & l);
-    ///
-    int rows_;
-    ///
-    int columns_;
-    ///
-    int numberofcells;
-    ///
-    std::vector<int> rowofcell;
-    ///
-    std::vector<int> columnofcell;
-    ///
-    row_vector row_info;
-    ///
-    column_vector column_info;
-    ///
-    mutable cell_vvector cell_info;
-    ///
-    int width_of_tabular;
-    ///
-    bool rotate;
-    //
-    // for long tabulars
-    ///
-    bool is_long_tabular;
-    /// row of endhead
-    int endhead;
-    /// row of endfirsthead
-    int endfirsthead;
-    /// row of endfoot
-    int endfoot;
-    /// row of endlastfoot
-    int endlastfoot;
-    ///
-    InsetTabular * owner_;
+       ///
+       void ReadNew(Buffer const * buf, std::istream & is,
+                                LyXLex & lex, string const & l);
+       ///
+       void ReadOld(Buffer const * buf, std::istream & is,
+                                LyXLex & lex, string const & l);
+       ///
+       int rows_;
+       ///
+       int columns_;
+       ///
+       int numberofcells;
+       ///
+       std::vector<int> rowofcell;
+       ///
+       std::vector<int> columnofcell;
+       ///
+       row_vector row_info;
+       ///
+       column_vector column_info;
+       ///
+       mutable cell_vvector cell_info;
+       ///
+       int width_of_tabular;
+       ///
+       bool rotate;
+       //
+       // for long tabulars
+       ///
+       bool is_long_tabular;
+       /// row of endhead
+       int endhead;
+       /// row of endfirsthead
+       int endfirsthead;
+       /// row of endfoot
+       int endfoot;
+       /// row of endlastfoot
+       int endlastfoot;
+       ///
+       InsetTabular * owner_;
    
-    ///
-    void Init(int columns_arg, int rows_arg);
-    ///
-    void Reinit();
-    ///
-    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);
-    ///
-    void recalculateMulticolCells(int cell, int new_width);
-    /// Returns true if change
-    bool calculate_width_of_column(int column);
-    ///
-    bool calculate_width_of_column_NMC(int column); // no multi cells
-    ///
-    void calculate_width_of_tabular();
-    ///
-    cellstruct * cellinfo_of_cell(int cell) const;
-    ///
-    void delete_column(int column);
-    ///
-    int cells_in_multicolumn(int cell) const;
-    ///
-    BoxType UseParbox(int cell) const;
+       ///
+       void Init(int columns_arg, int rows_arg);
+       ///
+       void Reinit();
+       ///
+       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);
+       ///
+       void recalculateMulticolCells(int cell, int new_width);
+       /// Returns true if change
+       bool calculate_width_of_column(int column);
+       ///
+       bool calculate_width_of_column_NMC(int column); // no multi cells
+       ///
+       void calculate_width_of_tabular();
+       ///
+       cellstruct * cellinfo_of_cell(int cell) const;
+       ///
+       void delete_column(int column);
+       ///
+       int cells_in_multicolumn(int cell) const;
+       ///
+       BoxType UseParbox(int cell) const;
 };
 
 #endif