X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsettabular.C;h=703c29742d7df88381a4166160ea3fd6acfcd7c0;hb=c130d5dbfd3f4d4a2721c9be786b7fa45b806aca;hp=5fbe7fdeea75f4f5b4ee60fe49df82d42a65c2e0;hpb=a2ef5d11b305ea76ecd8eea2a95e2d3d47ca6670;p=features.git diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 5fbe7fdeea..703c29742d 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -34,6 +34,7 @@ #include "LyXView.h" #include "insets/insettext.h" #include "frontends/Dialogs.h" +#include "frontends/Alert.h" #include "debug.h" #include "WorkArea.h" #include "gettext.h" @@ -139,6 +140,7 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns) clearSelection(); need_update = INIT; in_update = false; + in_reset_pos = false; } @@ -146,7 +148,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf, bool same_id) : UpdatableInset(tab, same_id), buffer(&buf) { - tabular.reset(new LyXTabular(this, *(tab.tabular))); + tabular.reset(new LyXTabular(this, *(tab.tabular), same_id)); the_locking_inset = 0; locked = no_selection = false; oldcell = -1; @@ -154,6 +156,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf, sel_cell_start = sel_cell_end = 0; need_update = INIT; in_update = false; + in_reset_pos = false; } @@ -352,7 +355,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, } i = tabular->row_of_cell(cell); if (the_locking_inset != tabular->GetCellInset(cell)) { - lyxerr[Debug::INSETS] << "ERROR this shouldn't happen\n"; + lyxerr[Debug::INSETTEXT] << "ERROR this shouldn't happen\n"; return; } float dx = nx + tabular->GetBeginningOfTextInCell(cell); @@ -523,7 +526,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button) UpdatableInset::edit(bv, x, y, button); if (!bv->lockInset(this)) { - lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl; + lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl; return; } locked = true; @@ -544,7 +547,7 @@ void InsetTabular::edit(BufferView * bv, bool front) UpdatableInset::edit(bv, front); if (!bv->lockInset(this)) { - lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl; + lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl; return; } locked = true; @@ -599,24 +602,24 @@ void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what, bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset) { - lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" + lyxerr[Debug::INSETTEXT] << "InsetTabular::LockInsetInInset(" << inset << "): "; if (!inset) return false; oldcell = -1; if (inset == tabular->GetCellInset(actcell)) { - lyxerr[Debug::INSETS] << "OK" << endl; + lyxerr[Debug::INSETTEXT] << "OK" << endl; the_locking_inset = tabular->GetCellInset(actcell); resetPos(bv); return true; } else if (the_locking_inset && (the_locking_inset == inset)) { - lyxerr[Debug::INSETS] << "OK" << endl; + lyxerr[Debug::INSETTEXT] << "OK" << endl; resetPos(bv); } else if (the_locking_inset) { - lyxerr[Debug::INSETS] << "MAYBE" << endl; + lyxerr[Debug::INSETTEXT] << "MAYBE" << endl; return the_locking_inset->lockInsetInInset(bv, inset); } - lyxerr[Debug::INSETS] << "NOT OK" << endl; + lyxerr[Debug::INSETTEXT] << "NOT OK" << endl; return false; } @@ -878,6 +881,12 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action, updateLocal(bv, CELL, false); the_locking_inset->toggleInsetCursor(bv); return result; + } else if (result == FINISHED_UP) { + action = LFUN_UP; + } else if (result == FINISHED_DOWN) { + action = LFUN_DOWN; + } else if (result == FINISHED_RIGHT) { + action = LFUN_RIGHT; } } @@ -1028,7 +1037,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action, int cols = 1; int rows = 1; int maxCols = 1; - unsigned int len = clip.length(); + string::size_type len = clip.length(); string::size_type p = 0; while(p < len && @@ -1145,15 +1154,33 @@ int InsetTabular::ascii(Buffer const * buf, ostream & os, int) const } -int InsetTabular::linuxdoc(Buffer const *, ostream &) const +int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const { - return 0; + return tabular->Ascii(buf,os); } int InsetTabular::docbook(Buffer const * buf, ostream & os) const { - return tabular->DocBook(buf,os); + int ret = 0; + Inset * master; + + // if the table is inside a float it doesn't need the informaltable + // wrapper. Search for it. + for(master = owner(); + master && master->lyxCode() != Inset::FLOAT_CODE; + master = master->owner()); + + if (!master) { + os << "\n"; + ret++; + } + ret+= tabular->DocBook(buf,os); + if (!master) { + os << "\n"; + ret++; + } + return ret; } @@ -1325,6 +1352,12 @@ void InsetTabular::resetPos(BufferView * bv) const { if (!locked || nodraw()) return; +#warning This should be fixed in the right manner (20011128 Jug) + // fast hack to fix infinite repaintings! + if (in_reset_pos) + return; + in_reset_pos = true; + actcol = tabular->column_of_cell(actcell); int cell = 0; @@ -1388,6 +1421,7 @@ void InsetTabular::resetPos(BufferView * bv) const bv->owner()->getDialogs()->updateTabular(inset); oldcell = actcell; } + in_reset_pos = false; } @@ -1523,7 +1557,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock) } -bool InsetTabular::deletable() +bool InsetTabular::deletable() const { return true; } @@ -1638,10 +1672,11 @@ void InsetTabular::tabularFeatures(BufferView * bv, bv->text->cursor.par(), bv->text->cursor.par()->next()); - int row = tabular->row_of_cell(actcell); + LyXTabular::ltType ltt; + int row = ltt.row = tabular->row_of_cell(actcell); int column = tabular->column_of_cell(actcell); bool flag = true; - + switch (feature) { case LyXTabular::SET_PWIDTH: { @@ -1800,7 +1835,7 @@ void InsetTabular::tabularFeatures(BufferView * bv, case LyXTabular::MULTICOLUMN: { if (sel_row_start != sel_row_end) { - WriteAlert(_("Impossible Operation!"), + Alert::alert(_("Impossible Operation!"), _("Multicolumns can only be horizontally."), _("Sorry.")); return; @@ -1882,17 +1917,25 @@ void InsetTabular::tabularFeatures(BufferView * bv, tabular->GetCellNumber(i, j), val); break; } + case LyXTabular::UNSET_LTFIRSTHEAD: + ltt.row = 0; case LyXTabular::SET_LTFIRSTHEAD: - tabular->SetLTHead(actcell, true); + tabular->SetLTHead(ltt, true); break; + case LyXTabular::UNSET_LTHEAD: + ltt.row = 0; case LyXTabular::SET_LTHEAD: - tabular->SetLTHead(actcell, false); + tabular->SetLTHead(ltt, false); break; + case LyXTabular::UNSET_LTFOOT: + ltt.row = 0; case LyXTabular::SET_LTFOOT: - tabular->SetLTFoot(actcell, false); + tabular->SetLTFoot(ltt, false); break; + case LyXTabular::UNSET_LTLASTFOOT: + ltt.row = 0; case LyXTabular::SET_LTLASTFOOT: - tabular->SetLTFoot(actcell, true); + tabular->SetLTFoot(ltt, true); break; case LyXTabular::SET_LTNEWPAGE: { @@ -1964,7 +2007,7 @@ int InsetTabular::getMaxWidth(BufferView * bv, cell = actcell; if (tabular->GetCellInset(cell) != inset) { - lyxerr << "Actcell not equal to actual cell!\n"; + lyxerr[Debug::INSETTEXT] << "Actcell not equal to actual cell!\n"; cell = -1; } } @@ -2084,6 +2127,7 @@ func_status::value_type InsetTabular::getStatus(string const & what) const int sel_row_start; int sel_row_end; int dummy; + LyXTabular::ltType dummyltt; bool flag = true; if (hasSelection()) { @@ -2238,25 +2282,25 @@ func_status::value_type InsetTabular::getStatus(string const & what) const status |= func_status::ToggleOff; break; case LyXTabular::SET_LTFIRSTHEAD: - if (tabular->GetRowOfLTHead(actcell, dummy)) + if (tabular->GetRowOfLTHead(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; break; case LyXTabular::SET_LTHEAD: - if (tabular->GetRowOfLTHead(actcell, dummy)) + if (tabular->GetRowOfLTHead(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; break; case LyXTabular::SET_LTFOOT: - if (tabular->GetRowOfLTFoot(actcell, dummy)) + if (tabular->GetRowOfLTFoot(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; break; case LyXTabular::SET_LTLASTFOOT: - if (tabular->GetRowOfLTFoot(actcell, dummy)) + if (tabular->GetRowOfLTFoot(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff;