#include "LyXView.h"
#include "insets/insettext.h"
#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
#include "debug.h"
#include "WorkArea.h"
#include "gettext.h"
clearSelection();
need_update = INIT;
in_update = false;
+ in_reset_pos = false;
}
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;
sel_cell_start = sel_cell_end = 0;
need_update = INIT;
in_update = false;
+ in_reset_pos = false;
}
}
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);
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;
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;
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;
}
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;
}
}
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 &&
// reset need_update setted in above function!
need_update = NONE;
result = the_locking_inset->localDispatch(bv, action, arg);
- if ((result == UNDISPATCHED) || (result == FINISHED)) {
+ if ((result == UNDISPATCHED) || (result >= FINISHED)) {
unlockInsetInInset(bv, the_locking_inset);
nodraw(false);
the_locking_inset = 0;
}
break;
}
- if (result!=FINISHED) {
+ if (result < FINISHED) {
if (!the_locking_inset) {
showInsetCursor(bv);
}
}
-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
+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 << "<informaltable>\n";
+ ret++;
+ }
+ ret+= tabular->DocBook(buf,os);
+ if (!master) {
+ os << "</informaltable>\n";
+ ret++;
+ }
+ return ret;
}
continue;
++cell;
inset = tabular->GetCellInset(cell);
- if (!reinit)
+ if (!reinit && !tabular->GetPWidth(cell).empty())
inset->update(bv, font, false);
maxAsc = max(maxAsc, inset->ascent(bv, font));
maxDesc = max(maxDesc, inset->descent(bv, font));
void InsetTabular::resetPos(BufferView * bv) const
{
- if (!locked)
+ 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;
bv->owner()->getDialogs()->updateTabular(inset);
oldcell = actcell;
}
+ in_reset_pos = false;
}
bool moved = isRightToLeft(bv)
? movePrevCell(bv) : moveNextCell(bv);
if (!moved)
- return FINISHED;
+ return FINISHED_RIGHT;
if (lock && activateCellInset(bv))
return DISPATCHED;
}
int const ocell = actcell;
actcell = tabular->GetCellAbove(actcell);
if (actcell == ocell) // we moved out of the inset
- return FINISHED;
+ return FINISHED_UP;
resetPos(bv);
if (lock) {
int x = 0;
int const ocell = actcell;
actcell = tabular->GetCellBelow(actcell);
if (actcell == ocell) // we moved out of the inset
- return FINISHED;
+ return FINISHED_DOWN;
resetPos(bv);
if (lock) {
int x = 0;
}
-bool InsetTabular::deletable()
+bool InsetTabular::deletable() const
{
return true;
}
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:
{
for(int i = sel_row_start; i <= sel_row_end; ++i) {
tabular->DeleteRow(sel_row_start);
}
- if ((sel_row_start) > tabular->rows())
+ if (sel_row_start >= tabular->rows())
--sel_row_start;
actcell = tabular->GetCellNumber(sel_row_start, column);
clearSelection();
for(int i = sel_col_start; i <= sel_col_end; ++i) {
tabular->DeleteColumn(sel_col_start);
}
- if ((sel_col_start+1) > tabular->columns())
+ if (sel_col_start >= tabular->columns())
--sel_col_start;
actcell = tabular->GetCellNumber(row, sel_col_start);
clearSelection();
case LyXTabular::MULTICOLUMN:
{
if (sel_row_start != sel_row_end) {
- WriteAlert(_("Impossible Operation!"),
+ Alert::alert(_("Impossible Operation!"),
_("Multicolumns can only be horizontally."),
_("Sorry."));
return;
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:
{
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;
}
}
int sel_row_start;
int sel_row_end;
int dummy;
+ LyXTabular::ltType dummyltt;
bool flag = true;
if (hasSelection()) {
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;
}
+Paragraph * InsetTabular::getFirstParagraph(int i) const
+{
+ return (i < tabular->GetNumberOfCells())
+ ? tabular->GetCellInset(i)->getFirstParagraph(0)
+ : 0;
+}
+
+
LyXCursor const & InsetTabular::cursor(BufferView * bv) const
{
if (the_locking_inset)
}
-string const InsetTabular::selectNextWord(BufferView * bv, float & value) const
+string const InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
{
if (the_locking_inset) {
- string const str(the_locking_inset->selectNextWord(bv, value));
+ string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
if (!str.empty())
return str;
if (tabular->IsLastCell(actcell)) {
// when entering this function the inset should be ALWAYS locked!
lyx::Assert(the_locking_inset);
- string const str(the_locking_inset->selectNextWord(bv, value));
+ string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
if (!str.empty())
return str;
// otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
- inset->edit(bv, 0, 0, 0);
+ inset->edit(bv);
return selectNextWordInt(bv, value);
}