mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
rowpainter.C: remove unused variables
tabular_funcs.C: tabular_funcs.h: move to tabular.C Makefile.am: adjust tabular.[Ch]: basic optical cleaning author.h: pass references, not values git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7329 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e3fcc05ff6
commit
d6ed22a813
@ -3,6 +3,14 @@
|
||||
|
||||
* rowpainter.C: remove unused variables
|
||||
|
||||
* tabular_funcs.C:
|
||||
* tabular_funcs.h: move to tabular.C
|
||||
* Makefile.am: adjust
|
||||
|
||||
* tabular.[Ch]: basic optical cleaning
|
||||
|
||||
* author.h: pass references, not values
|
||||
|
||||
2003-07-18 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* lyxtext.h:
|
||||
|
@ -220,8 +220,6 @@ lyx_SOURCES = \
|
||||
sgml.h \
|
||||
tabular.C \
|
||||
tabular.h \
|
||||
tabular_funcs.C \
|
||||
tabular_funcs.h \
|
||||
tex-accent.C \
|
||||
tex-accent.h \
|
||||
tex-strings.C \
|
||||
|
@ -20,8 +20,8 @@ class Author {
|
||||
public:
|
||||
Author() {}
|
||||
|
||||
Author(string n, string e)
|
||||
: name_(n), email_(e) {}
|
||||
Author(string const & name, string const & email)
|
||||
: name_(name), email_(email) {}
|
||||
|
||||
string const name() const {
|
||||
return name_;
|
||||
|
@ -320,7 +320,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
drawCellSelection(pi.pain, nx, y, i, j, cell);
|
||||
}
|
||||
|
||||
tabular.getCellInset(cell)->draw(pi, cx, y);
|
||||
tabular.getCellInset(cell).draw(pi, cx, y);
|
||||
drawCellLines(pi.pain, nx, y, i, cell);
|
||||
nx += tabular.getWidthOfColumn(cell);
|
||||
++cell;
|
||||
@ -457,16 +457,16 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
|
||||
if (!inset)
|
||||
return false;
|
||||
oldcell = -1;
|
||||
if (inset == tabular.getCellInset(actcell)) {
|
||||
if (inset == &tabular.getCellInset(actcell)) {
|
||||
lyxerr[Debug::INSETTEXT] << "OK" << endl;
|
||||
the_locking_inset = tabular.getCellInset(actcell);
|
||||
the_locking_inset = &tabular.getCellInset(actcell);
|
||||
resetPos(bv);
|
||||
return true;
|
||||
} else if (!the_locking_inset) {
|
||||
int const n = tabular.getNumberOfCells();
|
||||
int const id = inset->id();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
InsetText * in = tabular.getCellInset(i);
|
||||
InsetText * in = &tabular.getCellInset(i);
|
||||
if (inset == in) {
|
||||
actcell = i;
|
||||
the_locking_inset = in;
|
||||
@ -633,9 +633,7 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
if (inset_hit && bv->theLockingInset()) {
|
||||
if (!bv->lockInset(static_cast<UpdatableInset*>
|
||||
(tabular.getCellInset(actcell))))
|
||||
{
|
||||
if (!bv->lockInset(&tabular.getCellInset(actcell))) {
|
||||
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
||||
return;
|
||||
}
|
||||
@ -1230,7 +1228,7 @@ void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
|
||||
// change so I'll try this to have a boost, but who knows ;) (Jug?)
|
||||
// This is _really_ important (André)
|
||||
if (need_update != INIT &&
|
||||
the_locking_inset == tabular.getCellInset(actcell)) {
|
||||
the_locking_inset == &tabular.getCellInset(actcell)) {
|
||||
int maxAsc = 0;
|
||||
int maxDesc = 0;
|
||||
for (int j = 0; j < tabular.columns(); ++j) {
|
||||
@ -1238,7 +1236,7 @@ void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
|
||||
MetricsInfo m = mi;
|
||||
m.base.textwidth =
|
||||
tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
|
||||
tabular.getCellInset(actrow, j)->metrics(m, dim);
|
||||
tabular.getCellInset(actrow, j).metrics(m, dim);
|
||||
maxAsc = max(dim.asc, maxAsc);
|
||||
maxDesc = max(dim.des, maxDesc);
|
||||
}
|
||||
@ -1262,7 +1260,7 @@ void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
|
||||
MetricsInfo m = mi;
|
||||
m.base.textwidth =
|
||||
tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
|
||||
tabular.getCellInset(cell)->metrics(m, dim);
|
||||
tabular.getCellInset(cell).metrics(m, dim);
|
||||
maxAsc = max(maxAsc, dim.asc);
|
||||
maxDesc = max(maxDesc, dim.des);
|
||||
changed = tabular.setWidthOfCell(cell, dim.wid) || changed;
|
||||
@ -1543,7 +1541,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
|
||||
++actcell;
|
||||
}
|
||||
if (lock) {
|
||||
bool rtl = tabular.getCellInset(actcell)->paragraphs.begin()->
|
||||
bool rtl = tabular.getCellInset(actcell).paragraphs.begin()->
|
||||
isRightToLeftPar(bv->buffer()->params);
|
||||
activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
|
||||
}
|
||||
@ -1572,7 +1570,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
|
||||
--actcell;
|
||||
}
|
||||
if (lock) {
|
||||
bool rtl = tabular.getCellInset(actcell)->paragraphs.begin()->
|
||||
bool rtl = tabular.getCellInset(actcell).paragraphs.begin()->
|
||||
isRightToLeftPar(bv->buffer()->params);
|
||||
activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
|
||||
}
|
||||
@ -1598,11 +1596,10 @@ void InsetTabular::setFont(BufferView * bv, LyXFont const & font, bool tall,
|
||||
int sel_col_start;
|
||||
int sel_col_end;
|
||||
getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
|
||||
for(int i = sel_row_start; i <= sel_row_end; ++i) {
|
||||
for(int j = sel_col_start; j <= sel_col_end; ++j) {
|
||||
tabular.getCellInset(i, j)->setFont(bv, font, tall, true);
|
||||
}
|
||||
}
|
||||
for(int i = sel_row_start; i <= sel_row_end; ++i)
|
||||
for(int j = sel_col_start; j <= sel_col_end; ++j)
|
||||
tabular.getCellInset(i, j).setFont(bv, font, tall, true);
|
||||
|
||||
if (!frozen)
|
||||
unFreezeUndo();
|
||||
if (selectall)
|
||||
@ -1731,11 +1728,8 @@ void InsetTabular::tabularFeatures(BufferView * bv,
|
||||
// until later (see InsetText::do_resize)
|
||||
unlockInsetInInset(bv, the_locking_inset);
|
||||
|
||||
int cell;
|
||||
for (int i = 0; i < tabular.rows(); ++i) {
|
||||
cell = tabular.getCellNumber(i,column);
|
||||
tabular.getCellInset(cell)->resizeLyXText(bv);
|
||||
}
|
||||
for (int i = 0; i < tabular.rows(); ++i)
|
||||
tabular.getCellInset(i, column).resizeLyXText(bv);
|
||||
updateLocal(bv, INIT);
|
||||
}
|
||||
|
||||
@ -1760,10 +1754,9 @@ void InsetTabular::tabularFeatures(BufferView * bv,
|
||||
// until later (see InsetText::do_resize)
|
||||
unlockInsetInInset(bv, the_locking_inset);
|
||||
|
||||
for (int i = 0; i < tabular.rows(); ++i) {
|
||||
tabular.getCellInset(tabular.getCellNumber(i, column))->
|
||||
resizeLyXText(bv);
|
||||
}
|
||||
for (int i = 0; i < tabular.rows(); ++i)
|
||||
tabular.getCellInset(i, column).resizeLyXText(bv);
|
||||
|
||||
updateLocal(bv, INIT);
|
||||
}
|
||||
}
|
||||
@ -2030,16 +2023,15 @@ void InsetTabular::tabularFeatures(BufferView * bv,
|
||||
bool InsetTabular::activateCellInset(BufferView * bv, int x, int y,
|
||||
mouse_button::state button, bool behind)
|
||||
{
|
||||
UpdatableInset * inset =
|
||||
static_cast<UpdatableInset*>(tabular.getCellInset(actcell));
|
||||
UpdatableInset & inset = tabular.getCellInset(actcell);
|
||||
if (behind) {
|
||||
#warning metrics?
|
||||
x = inset->x() + inset->width();
|
||||
y = inset->descent();
|
||||
x = inset.x() + inset.width();
|
||||
y = inset.descent();
|
||||
}
|
||||
//inset_x = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell);
|
||||
//inset_y = cursory_;
|
||||
inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button));
|
||||
inset.localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button));
|
||||
if (!the_locking_inset)
|
||||
return false;
|
||||
updateLocal(bv, CELL);
|
||||
@ -2071,13 +2063,10 @@ void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
|
||||
|
||||
void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
|
||||
{
|
||||
if (force) {
|
||||
for(int i = 0; i < tabular.rows(); ++i) {
|
||||
for(int j = 0; j < tabular.columns(); ++j) {
|
||||
tabular.getCellInset(i, j)->resizeLyXText(bv, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (force)
|
||||
for(int i = 0; i < tabular.rows(); ++i)
|
||||
for(int j = 0; j < tabular.columns(); ++j)
|
||||
tabular.getCellInset(i, j).resizeLyXText(bv, true);
|
||||
need_update = FULL;
|
||||
}
|
||||
|
||||
@ -2102,10 +2091,10 @@ bool InsetTabular::showInsetDialog(BufferView * bv) const
|
||||
void InsetTabular::openLayoutDialog(BufferView * bv) const
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
InsetTabular * i = static_cast<InsetTabular *>
|
||||
InsetTabular * inset = static_cast<InsetTabular *>
|
||||
(the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE));
|
||||
if (i) {
|
||||
i->openLayoutDialog(bv);
|
||||
if (inset) {
|
||||
inset->openLayoutDialog(bv);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2326,28 +2315,27 @@ bool InsetTabular::pasteSelection(BufferView * bv)
|
||||
return false;
|
||||
|
||||
for (int r1 = 0, r2 = actrow;
|
||||
(r1 < paste_tabular->rows()) && (r2 < tabular.rows());
|
||||
r1 < paste_tabular->rows() && r2 < tabular.rows();
|
||||
++r1, ++r2) {
|
||||
for(int c1 = 0, c2 = actcol;
|
||||
(c1 < paste_tabular->columns()) && (c2 < tabular.columns());
|
||||
for (int c1 = 0, c2 = actcol;
|
||||
c1 < paste_tabular->columns() && c2 < tabular.columns();
|
||||
++c1, ++c2) {
|
||||
if (paste_tabular->isPartOfMultiColumn(r1,c1) &&
|
||||
tabular.isPartOfMultiColumn(r2,c2))
|
||||
if (paste_tabular->isPartOfMultiColumn(r1, c1) &&
|
||||
tabular.isPartOfMultiColumn(r2, c2))
|
||||
continue;
|
||||
if (paste_tabular->isPartOfMultiColumn(r1,c1)) {
|
||||
if (paste_tabular->isPartOfMultiColumn(r1, c1)) {
|
||||
--c2;
|
||||
continue;
|
||||
}
|
||||
if (tabular.isPartOfMultiColumn(r2,c2)) {
|
||||
if (tabular.isPartOfMultiColumn(r2, c2)) {
|
||||
--c1;
|
||||
continue;
|
||||
}
|
||||
int const n1 = paste_tabular->getCellNumber(r1, c1);
|
||||
int const n2 = tabular.getCellNumber(r2, c2);
|
||||
*(tabular.getCellInset(n2)) = *(paste_tabular->getCellInset(n1));
|
||||
tabular.getCellInset(n2)->setOwner(this);
|
||||
tabular.getCellInset(n2)->deleteLyXText(bv);
|
||||
tabular.getCellInset(n2)->markNew();
|
||||
InsetText & inset = tabular.getCellInset(r2, c2);
|
||||
inset = paste_tabular->getCellInset(r1, c1);
|
||||
inset.setOwner(this);
|
||||
inset.deleteLyXText(bv);
|
||||
inset.markNew();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -2375,11 +2363,9 @@ bool InsetTabular::cutSelection(BufferParams const & bp)
|
||||
if (sel_cell_start > sel_cell_end) {
|
||||
swap(sel_cell_start, sel_cell_end);
|
||||
}
|
||||
for (int i = sel_row_start; i <= sel_row_end; ++i) {
|
||||
for (int j = sel_col_start; j <= sel_col_end; ++j) {
|
||||
tabular.getCellInset(tabular.getCellNumber(i, j))->clear(bp.tracking_changes);
|
||||
}
|
||||
}
|
||||
for (int i = sel_row_start; i <= sel_row_end; ++i)
|
||||
for (int j = sel_col_start; j <= sel_col_end; ++j)
|
||||
tabular.getCellInset(tabular.getCellNumber(i, j)).clear(bp.tracking_changes);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2434,7 +2420,7 @@ void InsetTabular::getSelection(int & srow, int & erow,
|
||||
ParagraphList * InsetTabular::getParagraphs(int i) const
|
||||
{
|
||||
return (i < tabular.getNumberOfCells())
|
||||
? tabular.getCellInset(i)->getParagraphs(0)
|
||||
? tabular.getCellInset(i).getParagraphs(0)
|
||||
: 0;
|
||||
}
|
||||
|
||||
@ -2454,7 +2440,7 @@ Inset * InsetTabular::getInsetFromID(int id_arg) const
|
||||
|
||||
for (int i = 0; i < tabular.rows(); ++i) {
|
||||
for (int j = 0; j < tabular.columns(); ++j) {
|
||||
Inset * inset = tabular.getCellInset(i, j)->getInsetFromID(id_arg);
|
||||
Inset * inset = tabular.getCellInset(i, j).getInsetFromID(id_arg);
|
||||
if (inset)
|
||||
return inset;
|
||||
}
|
||||
@ -2482,7 +2468,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
|
||||
}
|
||||
// otherwise we have to lock the next inset and ask for it's selecttion
|
||||
tabular.getCellInset(actcell)
|
||||
->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
|
||||
.localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
|
||||
WordLangTuple word(selectNextWordInt(bv, value));
|
||||
nodraw(false);
|
||||
if (!word.word().empty())
|
||||
@ -2508,7 +2494,7 @@ WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) co
|
||||
// otherwise we have to lock the next inset and ask for it's selecttion
|
||||
++actcell;
|
||||
tabular.getCellInset(actcell)
|
||||
->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
|
||||
.localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
|
||||
return selectNextWordInt(bv, value);
|
||||
}
|
||||
|
||||
@ -2530,7 +2516,7 @@ void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
|
||||
void InsetTabular::markErased()
|
||||
{
|
||||
for (int cell = 0; cell < tabular.getNumberOfCells(); ++cell)
|
||||
tabular.getCellInset(cell)->markErased();
|
||||
tabular.getCellInset(cell).markErased();
|
||||
}
|
||||
|
||||
|
||||
@ -2545,15 +2531,15 @@ bool InsetTabular::nextChange(BufferView * bv, lyx::pos_type & length)
|
||||
return false;
|
||||
++actcell;
|
||||
}
|
||||
InsetText * inset = tabular.getCellInset(actcell);
|
||||
if (inset->nextChange(bv, length)) {
|
||||
InsetText & inset = tabular.getCellInset(actcell);
|
||||
if (inset.nextChange(bv, length)) {
|
||||
updateLocal(bv, FULL);
|
||||
return true;
|
||||
}
|
||||
while (!tabular.isLastCell(actcell)) {
|
||||
++actcell;
|
||||
inset = tabular.getCellInset(actcell);
|
||||
if (inset->nextChange(bv, length)) {
|
||||
InsetText & inset = tabular.getCellInset(actcell);
|
||||
if (inset.nextChange(bv, length)) {
|
||||
updateLocal(bv, FULL);
|
||||
return true;
|
||||
}
|
||||
@ -2575,15 +2561,15 @@ bool InsetTabular::searchForward(BufferView * bv, string const & str,
|
||||
return false;
|
||||
cell = actcell + 1;
|
||||
}
|
||||
InsetText * inset = tabular.getCellInset(cell);
|
||||
if (inset->searchForward(bv, str, cs, mw)) {
|
||||
InsetText & inset = tabular.getCellInset(cell);
|
||||
if (inset.searchForward(bv, str, cs, mw)) {
|
||||
updateLocal(bv, FULL);
|
||||
return true;
|
||||
}
|
||||
while (!tabular.isLastCell(cell)) {
|
||||
++cell;
|
||||
inset = tabular.getCellInset(cell);
|
||||
if (inset->searchForward(bv, str, cs, mw)) {
|
||||
InsetText & inset = tabular.getCellInset(cell);
|
||||
if (inset.searchForward(bv, str, cs, mw)) {
|
||||
updateLocal(bv, FULL);
|
||||
return true;
|
||||
}
|
||||
@ -2606,8 +2592,8 @@ bool InsetTabular::searchBackward(BufferView * bv, string const & str,
|
||||
|
||||
while (cell) {
|
||||
--cell;
|
||||
InsetText * inset = tabular.getCellInset(cell);
|
||||
if (inset->searchBackward(bv, str, cs, mw)) {
|
||||
InsetText & inset = tabular.getCellInset(cell);
|
||||
if (inset.searchBackward(bv, str, cs, mw)) {
|
||||
updateLocal(bv, CELL);
|
||||
return true;
|
||||
}
|
||||
@ -2704,10 +2690,10 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
|
||||
case '\t':
|
||||
// we can only set this if we are not too far right
|
||||
if (cols < columns) {
|
||||
InsetText * ti = loctab->getCellInset(cell);
|
||||
LyXFont const font = ti->getLyXText(bv)->
|
||||
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
|
||||
ti->setText(buf.substr(op, p - op), font);
|
||||
InsetText & inset = loctab->getCellInset(cell);
|
||||
LyXFont const font = inset.getLyXText(bv)->
|
||||
getFont(bv->buffer(), inset.paragraphs.begin(), 0);
|
||||
inset.setText(buf.substr(op, p - op), font);
|
||||
++cols;
|
||||
++cell;
|
||||
}
|
||||
@ -2715,10 +2701,10 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
|
||||
case '\n':
|
||||
// we can only set this if we are not too far right
|
||||
if (cols < columns) {
|
||||
InsetText * ti = loctab->getCellInset(cell);
|
||||
LyXFont const font = ti->getLyXText(bv)->
|
||||
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
|
||||
ti->setText(buf.substr(op, p - op), font);
|
||||
InsetText & inset = tabular.getCellInset(cell);
|
||||
LyXFont const font = inset.getLyXText(bv)->
|
||||
getFont(bv->buffer(), inset.paragraphs.begin(), 0);
|
||||
inset.setText(buf.substr(op, p - op), font);
|
||||
}
|
||||
cols = ocol;
|
||||
++row;
|
||||
@ -2731,10 +2717,10 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
|
||||
}
|
||||
// check for the last cell if there is no trailing '\n'
|
||||
if (cell < cells && op < len) {
|
||||
InsetText * ti = loctab->getCellInset(cell);
|
||||
LyXFont const font = ti->getLyXText(bv)->
|
||||
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
|
||||
ti->setText(buf.substr(op, len - op), font);
|
||||
InsetText & inset = loctab->getCellInset(cell);
|
||||
LyXFont const font = inset.getLyXText(bv)->
|
||||
getFont(bv->buffer(), inset.paragraphs.begin(), 0);
|
||||
inset.setText(buf.substr(op, len - op), font);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -2745,11 +2731,9 @@ void InsetTabular::addPreview(PreviewLoader & loader) const
|
||||
{
|
||||
int const rows = tabular.rows();
|
||||
int const columns = tabular.columns();
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < columns; ++j) {
|
||||
tabular.getCellInset(i,j)->addPreview(loader);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < rows; ++i)
|
||||
for (int j = 0; j < columns; ++j)
|
||||
tabular.getCellInset(i, j).addPreview(loader);
|
||||
}
|
||||
|
||||
|
||||
|
@ -814,7 +814,8 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
BufferView * bv = cmd.view();
|
||||
setViewCache(bv);
|
||||
|
||||
if (cmd.action == LFUN_INSET_EDIT) {
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_EDIT: {
|
||||
UpdatableInset::localDispatch(cmd);
|
||||
|
||||
if (!bv->lockInset(this)) {
|
||||
@ -878,18 +879,19 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
|
||||
default:
|
||||
break;
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bool was_empty = (paragraphs.begin()->empty() &&
|
||||
|
711
src/tabular.C
711
src/tabular.C
File diff suppressed because it is too large
Load Diff
@ -12,21 +12,14 @@
|
||||
#ifndef TABULAR_H
|
||||
#define TABULAR_H
|
||||
|
||||
#include "layout.h"
|
||||
#include "LString.h"
|
||||
#include "lyxlength.h"
|
||||
|
||||
#include "insets/insettext.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
class InsetTabular;
|
||||
class BufferParams;
|
||||
class LaTeXFeatures;
|
||||
class LatexRunParams;
|
||||
class Buffer;
|
||||
class LyXLex;
|
||||
|
||||
/* The features the text class offers for tables */
|
||||
|
||||
@ -183,8 +176,6 @@ public:
|
||||
///
|
||||
explicit
|
||||
LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
|
||||
///
|
||||
LyXTabular * clone(BufferParams const &, InsetTabular *);
|
||||
|
||||
/// Returns true if there is a topline, returns false if not
|
||||
bool topLine(int cell, bool onlycolumn = false) const;
|
||||
@ -224,28 +215,28 @@ public:
|
||||
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,
|
||||
///
|
||||
void setAllLines(int cell, bool line);
|
||||
///
|
||||
void setTopLine(int cell, bool line, bool onlycolumn = false);
|
||||
///
|
||||
void setBottomLine(int cell, bool line, bool onlycolumn = false);
|
||||
///
|
||||
void setLeftLine(int cell, bool line, bool onlycolumn = false);
|
||||
///
|
||||
void setRightLine(int cell, bool line, bool onlycolumn = false);
|
||||
///
|
||||
void setAlignment(int cell, LyXAlignment align,
|
||||
bool onlycolumn = false);
|
||||
/// Returns true if a complete update is necessary, otherwise false
|
||||
bool setVAlignment(int cell, VAlignment align,
|
||||
///
|
||||
void setVAlignment(int cell, VAlignment align,
|
||||
bool onlycolumn = false);
|
||||
///
|
||||
bool setColumnPWidth(int cell, LyXLength const & width);
|
||||
void setColumnPWidth(int cell, LyXLength const & width);
|
||||
///
|
||||
bool setMColumnPWidth(int cell, LyXLength const & width);
|
||||
///
|
||||
bool setAlignSpecial(int cell, string const & special, Feature what);
|
||||
void setAlignSpecial(int cell, string const & special, Feature what);
|
||||
///
|
||||
LyXAlignment getAlignment(int cell, bool onlycolumn = false) const;
|
||||
///
|
||||
@ -369,9 +360,9 @@ public:
|
||||
///
|
||||
// end longtable support
|
||||
///
|
||||
InsetText * getCellInset(int cell) const;
|
||||
InsetText & getCellInset(int cell) const;
|
||||
///
|
||||
InsetText * getCellInset(int row, int column) const;
|
||||
InsetText & getCellInset(int row, int column) const;
|
||||
/// Search for \param inset in the tabular, with the
|
||||
/// additional hint that it could be at \param maybe_cell
|
||||
int getCellFromInset(Inset const * inset, int maybe_cell = -1) const;
|
||||
@ -423,7 +414,7 @@ public:
|
||||
///
|
||||
InsetText inset;
|
||||
};
|
||||
cellstruct * cellinfo_of_cell(int cell) const;
|
||||
cellstruct & cellinfo_of_cell(int cell) const;
|
||||
///
|
||||
typedef std::vector<cellstruct> cell_vector;
|
||||
///
|
||||
@ -520,15 +511,13 @@ public:
|
||||
///
|
||||
void Reinit(bool reset_widths = true);
|
||||
///
|
||||
LyXTabular & operator=(LyXTabular const &);
|
||||
///
|
||||
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 recalculateMulticolumnsOfColumn(int column);
|
||||
/// Returns true if change
|
||||
bool calculate_width_of_column(int column);
|
||||
void calculate_width_of_column(int column);
|
||||
///
|
||||
bool calculate_width_of_column_NMC(int column); // no multi cells
|
||||
///
|
||||
|
@ -1,267 +0,0 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
*
|
||||
* @author: Jürgen Vigna
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "tabular_funcs.h"
|
||||
|
||||
#include "support/LIstream.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using namespace lyx::support;
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::strlen;
|
||||
#endif
|
||||
|
||||
using std::istream;
|
||||
using std::getline;
|
||||
|
||||
// Perfect case for a template... (Lgb)
|
||||
// or perhaps not...
|
||||
|
||||
template <>
|
||||
string const write_attribute(string const & name, bool const & b)
|
||||
{
|
||||
// we write only true attribute values so we remove a bit of the
|
||||
// file format bloat for tabulars.
|
||||
if (!b)
|
||||
return string();
|
||||
|
||||
return write_attribute(name, tostr(b));
|
||||
}
|
||||
|
||||
template <>
|
||||
string const write_attribute(string const & name, int const & i)
|
||||
{
|
||||
// we write only true attribute values so we remove a bit of the
|
||||
// file format bloat for tabulars.
|
||||
if (!i)
|
||||
return string();
|
||||
|
||||
return write_attribute(name, tostr(i));
|
||||
}
|
||||
|
||||
template <>
|
||||
string const write_attribute(string const & name, LyXLength const & value)
|
||||
{
|
||||
// we write only the value if we really have one same reson as above.
|
||||
if (value.zero())
|
||||
return string();
|
||||
|
||||
return write_attribute(name, value.asString());
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// I would have liked a fromstr template a lot better. (Lgb)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool string2type(string const str, bool & num)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ret.erase();
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool getTokenValue(string const & str, const char * token, int & num)
|
||||
{
|
||||
string tmp;
|
||||
num = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
bool getTokenValue(string const & str, const char * token,
|
||||
LyXTabular::VAlignment & 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)
|
||||
{
|
||||
string tmp;
|
||||
if (!getTokenValue(str, token, tmp))
|
||||
return false;
|
||||
return string2type(tmp, num);
|
||||
}
|
||||
|
||||
|
||||
bool getTokenValue(string const & str, const char * token, bool & flag)
|
||||
{
|
||||
// set the flag always to false as this should be the default for bools
|
||||
// not in the file-format.
|
||||
flag = false;
|
||||
string tmp;
|
||||
if (!getTokenValue(str, token, tmp))
|
||||
return false;
|
||||
return string2type(tmp, flag);
|
||||
}
|
||||
|
||||
|
||||
bool getTokenValue(string const & str, const char * token, LyXLength & len)
|
||||
{
|
||||
// set the lenght to be zero() as default as this it should be if not
|
||||
// in the file format.
|
||||
len = LyXLength();
|
||||
string tmp;
|
||||
if (!getTokenValue(str, token, tmp))
|
||||
return false;
|
||||
return isValidLength(tmp, &len);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
*
|
||||
* @author: Jürgen Vigna
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
|
||||
#ifndef TABULAR_FUNCS_H
|
||||
#define TABULAR_FUNCS_H
|
||||
|
||||
#include "tabular.h"
|
||||
#include "support/tostr.h"
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
// Perfect case for a template... (Lgb)
|
||||
// or perhaps not...
|
||||
template<class T>
|
||||
string const write_attribute(string const & name, T const & t)
|
||||
{
|
||||
if (tostr(t).empty())
|
||||
return string();
|
||||
|
||||
string str = " " + name + "=\"" + tostr(t) + "\"";
|
||||
return str;
|
||||
}
|
||||
template<>
|
||||
string const write_attribute(string const & name, bool const & b);
|
||||
template<>
|
||||
string const write_attribute(string const & name, int const & b);
|
||||
template<>
|
||||
string const write_attribute(string const & name, LyXLength const & value);
|
||||
string const tostr(LyXAlignment const & num);
|
||||
string const tostr(LyXTabular::VAlignment const & num);
|
||||
string const tostr(LyXTabular::BoxType const & num);
|
||||
|
||||
// I would have liked a fromstr template a lot better. (Lgb)
|
||||
bool string2type(string const str, LyXAlignment & num);
|
||||
bool string2type(string const str, LyXTabular::VAlignment & num);
|
||||
bool string2type(string const str, LyXTabular::BoxType & num);
|
||||
bool string2type(string const str, bool & num);
|
||||
bool getTokenValue(string const & str, char const * token, string &ret);
|
||||
bool getTokenValue(string const & str, char const * token, int & num);
|
||||
bool getTokenValue(string const & str, char const * token,
|
||||
LyXAlignment & num);
|
||||
bool getTokenValue(string const & str, char const * token,
|
||||
LyXTabular::VAlignment & num);
|
||||
bool getTokenValue(string const & str, char const * token,
|
||||
LyXTabular::BoxType & num);
|
||||
bool getTokenValue(string const & str, char const * token, bool & flag);
|
||||
bool getTokenValue(string const & str, char const * token,
|
||||
LyXLength & len);
|
||||
void l_getline(std::istream & is, string & str);
|
||||
|
||||
#endif
|
@ -1769,7 +1769,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
bool left_side = false;
|
||||
|
||||
pos_type body_pos = rit_par->beginningOfBody();
|
||||
float last_tmpx = tmpx;
|
||||
int last_tmpx = tmpx;
|
||||
|
||||
if (body_pos > 0 &&
|
||||
(body_pos - 1 > last ||
|
||||
@ -1778,7 +1778,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
|
||||
// check for empty row
|
||||
if (!rit_par->size()) {
|
||||
x = int(tmpx);
|
||||
x = tmpx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1802,7 +1802,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
} else if (rit_par->isSeparator(c)) {
|
||||
tmpx += singleWidth(rit_par, c);
|
||||
if (c >= body_pos)
|
||||
tmpx+= fill_separator;
|
||||
tmpx += fill_separator;
|
||||
} else {
|
||||
tmpx += singleWidth(rit_par, c);
|
||||
}
|
||||
@ -1865,8 +1865,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
|
||||
|
||||
void LyXText::setCursorFromCoordinates(int x, int y)
|
||||
{
|
||||
LyXCursor old_cursor = cursor;
|
||||
|
||||
//LyXCursor old_cursor = cursor;
|
||||
setCursorFromCoordinates(cursor, x, y);
|
||||
setCurrentFont();
|
||||
#warning DEPM disabled, otherwise crash when entering new table
|
||||
|
Loading…
Reference in New Issue
Block a user