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:
André Pönitz 2003-07-21 11:01:29 +00:00
parent e3fcc05ff6
commit d6ed22a813
10 changed files with 526 additions and 779 deletions

View File

@ -3,6 +3,14 @@
* rowpainter.C: remove unused variables * 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> 2003-07-18 André Pönitz <poenitz@gmx.net>
* lyxtext.h: * lyxtext.h:

View File

@ -220,8 +220,6 @@ lyx_SOURCES = \
sgml.h \ sgml.h \
tabular.C \ tabular.C \
tabular.h \ tabular.h \
tabular_funcs.C \
tabular_funcs.h \
tex-accent.C \ tex-accent.C \
tex-accent.h \ tex-accent.h \
tex-strings.C \ tex-strings.C \

View File

@ -20,8 +20,8 @@ class Author {
public: public:
Author() {} Author() {}
Author(string n, string e) Author(string const & name, string const & email)
: name_(n), email_(e) {} : name_(name), email_(email) {}
string const name() const { string const name() const {
return name_; return name_;

View File

@ -320,7 +320,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
drawCellSelection(pi.pain, nx, y, i, j, cell); 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); drawCellLines(pi.pain, nx, y, i, cell);
nx += tabular.getWidthOfColumn(cell); nx += tabular.getWidthOfColumn(cell);
++cell; ++cell;
@ -457,16 +457,16 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
if (!inset) if (!inset)
return false; return false;
oldcell = -1; oldcell = -1;
if (inset == tabular.getCellInset(actcell)) { if (inset == &tabular.getCellInset(actcell)) {
lyxerr[Debug::INSETTEXT] << "OK" << endl; lyxerr[Debug::INSETTEXT] << "OK" << endl;
the_locking_inset = tabular.getCellInset(actcell); the_locking_inset = &tabular.getCellInset(actcell);
resetPos(bv); resetPos(bv);
return true; return true;
} else if (!the_locking_inset) { } else if (!the_locking_inset) {
int const n = tabular.getNumberOfCells(); int const n = tabular.getNumberOfCells();
int const id = inset->id(); int const id = inset->id();
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
InsetText * in = tabular.getCellInset(i); InsetText * in = &tabular.getCellInset(i);
if (inset == in) { if (inset == in) {
actcell = i; actcell = i;
the_locking_inset = in; the_locking_inset = in;
@ -633,9 +633,7 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd)
} }
if (inset_hit && bv->theLockingInset()) { if (inset_hit && bv->theLockingInset()) {
if (!bv->lockInset(static_cast<UpdatableInset*> if (!bv->lockInset(&tabular.getCellInset(actcell))) {
(tabular.getCellInset(actcell))))
{
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
return; 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?) // change so I'll try this to have a boost, but who knows ;) (Jug?)
// This is _really_ important (André) // This is _really_ important (André)
if (need_update != INIT && if (need_update != INIT &&
the_locking_inset == tabular.getCellInset(actcell)) { the_locking_inset == &tabular.getCellInset(actcell)) {
int maxAsc = 0; int maxAsc = 0;
int maxDesc = 0; int maxDesc = 0;
for (int j = 0; j < tabular.columns(); ++j) { for (int j = 0; j < tabular.columns(); ++j) {
@ -1238,7 +1236,7 @@ void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
MetricsInfo m = mi; MetricsInfo m = mi;
m.base.textwidth = m.base.textwidth =
tabular.column_info[j].p_width.inPixels(mi.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); maxAsc = max(dim.asc, maxAsc);
maxDesc = max(dim.des, maxDesc); maxDesc = max(dim.des, maxDesc);
} }
@ -1262,7 +1260,7 @@ void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
MetricsInfo m = mi; MetricsInfo m = mi;
m.base.textwidth = m.base.textwidth =
tabular.column_info[j].p_width.inPixels(mi.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); maxAsc = max(maxAsc, dim.asc);
maxDesc = max(maxDesc, dim.des); maxDesc = max(maxDesc, dim.des);
changed = tabular.setWidthOfCell(cell, dim.wid) || changed; changed = tabular.setWidthOfCell(cell, dim.wid) || changed;
@ -1543,7 +1541,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
++actcell; ++actcell;
} }
if (lock) { if (lock) {
bool rtl = tabular.getCellInset(actcell)->paragraphs.begin()-> bool rtl = tabular.getCellInset(actcell).paragraphs.begin()->
isRightToLeftPar(bv->buffer()->params); isRightToLeftPar(bv->buffer()->params);
activateCellInset(bv, 0, 0, mouse_button::none, !rtl); activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
} }
@ -1572,7 +1570,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
--actcell; --actcell;
} }
if (lock) { if (lock) {
bool rtl = tabular.getCellInset(actcell)->paragraphs.begin()-> bool rtl = tabular.getCellInset(actcell).paragraphs.begin()->
isRightToLeftPar(bv->buffer()->params); isRightToLeftPar(bv->buffer()->params);
activateCellInset(bv, 0, 0, mouse_button::none, !rtl); 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_start;
int sel_col_end; int sel_col_end;
getSelection(sel_row_start, sel_row_end, sel_col_start, 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 i = sel_row_start; i <= sel_row_end; ++i)
for(int j = sel_col_start; j <= sel_col_end; ++j) { for(int j = sel_col_start; j <= sel_col_end; ++j)
tabular.getCellInset(i, j)->setFont(bv, font, tall, true); tabular.getCellInset(i, j).setFont(bv, font, tall, true);
}
}
if (!frozen) if (!frozen)
unFreezeUndo(); unFreezeUndo();
if (selectall) if (selectall)
@ -1731,11 +1728,8 @@ void InsetTabular::tabularFeatures(BufferView * bv,
// until later (see InsetText::do_resize) // until later (see InsetText::do_resize)
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
int cell; for (int i = 0; i < tabular.rows(); ++i)
for (int i = 0; i < tabular.rows(); ++i) { tabular.getCellInset(i, column).resizeLyXText(bv);
cell = tabular.getCellNumber(i,column);
tabular.getCellInset(cell)->resizeLyXText(bv);
}
updateLocal(bv, INIT); updateLocal(bv, INIT);
} }
@ -1760,10 +1754,9 @@ void InsetTabular::tabularFeatures(BufferView * bv,
// until later (see InsetText::do_resize) // until later (see InsetText::do_resize)
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
for (int i = 0; i < tabular.rows(); ++i) { for (int i = 0; i < tabular.rows(); ++i)
tabular.getCellInset(tabular.getCellNumber(i, column))-> tabular.getCellInset(i, column).resizeLyXText(bv);
resizeLyXText(bv);
}
updateLocal(bv, INIT); updateLocal(bv, INIT);
} }
} }
@ -2030,16 +2023,15 @@ void InsetTabular::tabularFeatures(BufferView * bv,
bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, bool InsetTabular::activateCellInset(BufferView * bv, int x, int y,
mouse_button::state button, bool behind) mouse_button::state button, bool behind)
{ {
UpdatableInset * inset = UpdatableInset & inset = tabular.getCellInset(actcell);
static_cast<UpdatableInset*>(tabular.getCellInset(actcell));
if (behind) { if (behind) {
#warning metrics? #warning metrics?
x = inset->x() + inset->width(); x = inset.x() + inset.width();
y = inset->descent(); y = inset.descent();
} }
//inset_x = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell); //inset_x = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell);
//inset_y = cursory_; //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) if (!the_locking_inset)
return false; return false;
updateLocal(bv, CELL); updateLocal(bv, CELL);
@ -2071,13 +2063,10 @@ void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
void InsetTabular::resizeLyXText(BufferView * bv, bool force) const void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
{ {
if (force) { if (force)
for(int i = 0; i < tabular.rows(); ++i) { for(int i = 0; i < tabular.rows(); ++i)
for(int j = 0; j < tabular.columns(); ++j) { for(int j = 0; j < tabular.columns(); ++j)
tabular.getCellInset(i, j)->resizeLyXText(bv, true); tabular.getCellInset(i, j).resizeLyXText(bv, true);
}
}
}
need_update = FULL; need_update = FULL;
} }
@ -2102,10 +2091,10 @@ bool InsetTabular::showInsetDialog(BufferView * bv) const
void InsetTabular::openLayoutDialog(BufferView * bv) const void InsetTabular::openLayoutDialog(BufferView * bv) const
{ {
if (the_locking_inset) { if (the_locking_inset) {
InsetTabular * i = static_cast<InsetTabular *> InsetTabular * inset = static_cast<InsetTabular *>
(the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)); (the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE));
if (i) { if (inset) {
i->openLayoutDialog(bv); inset->openLayoutDialog(bv);
return; return;
} }
} }
@ -2326,10 +2315,10 @@ bool InsetTabular::pasteSelection(BufferView * bv)
return false; return false;
for (int r1 = 0, r2 = actrow; for (int r1 = 0, r2 = actrow;
(r1 < paste_tabular->rows()) && (r2 < tabular.rows()); r1 < paste_tabular->rows() && r2 < tabular.rows();
++r1, ++r2) { ++r1, ++r2) {
for (int c1 = 0, c2 = actcol; for (int c1 = 0, c2 = actcol;
(c1 < paste_tabular->columns()) && (c2 < tabular.columns()); c1 < paste_tabular->columns() && c2 < tabular.columns();
++c1, ++c2) { ++c1, ++c2) {
if (paste_tabular->isPartOfMultiColumn(r1, c1) && if (paste_tabular->isPartOfMultiColumn(r1, c1) &&
tabular.isPartOfMultiColumn(r2, c2)) tabular.isPartOfMultiColumn(r2, c2))
@ -2342,12 +2331,11 @@ bool InsetTabular::pasteSelection(BufferView * bv)
--c1; --c1;
continue; continue;
} }
int const n1 = paste_tabular->getCellNumber(r1, c1); InsetText & inset = tabular.getCellInset(r2, c2);
int const n2 = tabular.getCellNumber(r2, c2); inset = paste_tabular->getCellInset(r1, c1);
*(tabular.getCellInset(n2)) = *(paste_tabular->getCellInset(n1)); inset.setOwner(this);
tabular.getCellInset(n2)->setOwner(this); inset.deleteLyXText(bv);
tabular.getCellInset(n2)->deleteLyXText(bv); inset.markNew();
tabular.getCellInset(n2)->markNew();
} }
} }
return true; return true;
@ -2375,11 +2363,9 @@ bool InsetTabular::cutSelection(BufferParams const & bp)
if (sel_cell_start > sel_cell_end) { if (sel_cell_start > sel_cell_end) {
swap(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 i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j) { for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular.getCellInset(tabular.getCellNumber(i, j))->clear(bp.tracking_changes); tabular.getCellInset(tabular.getCellNumber(i, j)).clear(bp.tracking_changes);
}
}
return true; return true;
} }
@ -2434,7 +2420,7 @@ void InsetTabular::getSelection(int & srow, int & erow,
ParagraphList * InsetTabular::getParagraphs(int i) const ParagraphList * InsetTabular::getParagraphs(int i) const
{ {
return (i < tabular.getNumberOfCells()) return (i < tabular.getNumberOfCells())
? tabular.getCellInset(i)->getParagraphs(0) ? tabular.getCellInset(i).getParagraphs(0)
: 0; : 0;
} }
@ -2454,7 +2440,7 @@ Inset * InsetTabular::getInsetFromID(int id_arg) const
for (int i = 0; i < tabular.rows(); ++i) { for (int i = 0; i < tabular.rows(); ++i) {
for (int j = 0; j < tabular.columns(); ++j) { 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) if (inset)
return 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 // otherwise we have to lock the next inset and ask for it's selecttion
tabular.getCellInset(actcell) tabular.getCellInset(actcell)
->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); .localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
WordLangTuple word(selectNextWordInt(bv, value)); WordLangTuple word(selectNextWordInt(bv, value));
nodraw(false); nodraw(false);
if (!word.word().empty()) 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 // otherwise we have to lock the next inset and ask for it's selecttion
++actcell; ++actcell;
tabular.getCellInset(actcell) tabular.getCellInset(actcell)
->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); .localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return selectNextWordInt(bv, value); return selectNextWordInt(bv, value);
} }
@ -2530,7 +2516,7 @@ void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
void InsetTabular::markErased() void InsetTabular::markErased()
{ {
for (int cell = 0; cell < tabular.getNumberOfCells(); ++cell) 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; return false;
++actcell; ++actcell;
} }
InsetText * inset = tabular.getCellInset(actcell); InsetText & inset = tabular.getCellInset(actcell);
if (inset->nextChange(bv, length)) { if (inset.nextChange(bv, length)) {
updateLocal(bv, FULL); updateLocal(bv, FULL);
return true; return true;
} }
while (!tabular.isLastCell(actcell)) { while (!tabular.isLastCell(actcell)) {
++actcell; ++actcell;
inset = tabular.getCellInset(actcell); InsetText & inset = tabular.getCellInset(actcell);
if (inset->nextChange(bv, length)) { if (inset.nextChange(bv, length)) {
updateLocal(bv, FULL); updateLocal(bv, FULL);
return true; return true;
} }
@ -2575,15 +2561,15 @@ bool InsetTabular::searchForward(BufferView * bv, string const & str,
return false; return false;
cell = actcell + 1; cell = actcell + 1;
} }
InsetText * inset = tabular.getCellInset(cell); InsetText & inset = tabular.getCellInset(cell);
if (inset->searchForward(bv, str, cs, mw)) { if (inset.searchForward(bv, str, cs, mw)) {
updateLocal(bv, FULL); updateLocal(bv, FULL);
return true; return true;
} }
while (!tabular.isLastCell(cell)) { while (!tabular.isLastCell(cell)) {
++cell; ++cell;
inset = tabular.getCellInset(cell); InsetText & inset = tabular.getCellInset(cell);
if (inset->searchForward(bv, str, cs, mw)) { if (inset.searchForward(bv, str, cs, mw)) {
updateLocal(bv, FULL); updateLocal(bv, FULL);
return true; return true;
} }
@ -2606,8 +2592,8 @@ bool InsetTabular::searchBackward(BufferView * bv, string const & str,
while (cell) { while (cell) {
--cell; --cell;
InsetText * inset = tabular.getCellInset(cell); InsetText & inset = tabular.getCellInset(cell);
if (inset->searchBackward(bv, str, cs, mw)) { if (inset.searchBackward(bv, str, cs, mw)) {
updateLocal(bv, CELL); updateLocal(bv, CELL);
return true; return true;
} }
@ -2704,10 +2690,10 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
case '\t': case '\t':
// we can only set this if we are not too far right // we can only set this if we are not too far right
if (cols < columns) { if (cols < columns) {
InsetText * ti = loctab->getCellInset(cell); InsetText & inset = loctab->getCellInset(cell);
LyXFont const font = ti->getLyXText(bv)-> LyXFont const font = inset.getLyXText(bv)->
getFont(bv->buffer(), ti->paragraphs.begin(), 0); getFont(bv->buffer(), inset.paragraphs.begin(), 0);
ti->setText(buf.substr(op, p - op), font); inset.setText(buf.substr(op, p - op), font);
++cols; ++cols;
++cell; ++cell;
} }
@ -2715,10 +2701,10 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
case '\n': case '\n':
// we can only set this if we are not too far right // we can only set this if we are not too far right
if (cols < columns) { if (cols < columns) {
InsetText * ti = loctab->getCellInset(cell); InsetText & inset = tabular.getCellInset(cell);
LyXFont const font = ti->getLyXText(bv)-> LyXFont const font = inset.getLyXText(bv)->
getFont(bv->buffer(), ti->paragraphs.begin(), 0); getFont(bv->buffer(), inset.paragraphs.begin(), 0);
ti->setText(buf.substr(op, p - op), font); inset.setText(buf.substr(op, p - op), font);
} }
cols = ocol; cols = ocol;
++row; ++row;
@ -2731,10 +2717,10 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
} }
// check for the last cell if there is no trailing '\n' // check for the last cell if there is no trailing '\n'
if (cell < cells && op < len) { if (cell < cells && op < len) {
InsetText * ti = loctab->getCellInset(cell); InsetText & inset = loctab->getCellInset(cell);
LyXFont const font = ti->getLyXText(bv)-> LyXFont const font = inset.getLyXText(bv)->
getFont(bv->buffer(), ti->paragraphs.begin(), 0); getFont(bv->buffer(), inset.paragraphs.begin(), 0);
ti->setText(buf.substr(op, len - op), font); inset.setText(buf.substr(op, len - op), font);
} }
return true; return true;
@ -2745,11 +2731,9 @@ void InsetTabular::addPreview(PreviewLoader & loader) const
{ {
int const rows = tabular.rows(); int const rows = tabular.rows();
int const columns = tabular.columns(); int const columns = tabular.columns();
for (int i = 0; i < rows; ++i) { for (int i = 0; i < rows; ++i)
for (int j = 0; j < columns; ++j) { for (int j = 0; j < columns; ++j)
tabular.getCellInset(i,j)->addPreview(loader); tabular.getCellInset(i, j).addPreview(loader);
}
}
} }

View File

@ -814,7 +814,8 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
BufferView * bv = cmd.view(); BufferView * bv = cmd.view();
setViewCache(bv); setViewCache(bv);
if (cmd.action == LFUN_INSET_EDIT) { switch (cmd.action) {
case LFUN_INSET_EDIT: {
UpdatableInset::localDispatch(cmd); UpdatableInset::localDispatch(cmd);
if (!bv->lockInset(this)) { if (!bv->lockInset(this)) {
@ -878,16 +879,17 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
return DISPATCHED; return DISPATCHED;
} }
switch (cmd.action) {
case LFUN_MOUSE_PRESS: case LFUN_MOUSE_PRESS:
lfunMousePress(cmd); lfunMousePress(cmd);
return DISPATCHED; return DISPATCHED;
case LFUN_MOUSE_MOTION: case LFUN_MOUSE_MOTION:
lfunMouseMotion(cmd); lfunMouseMotion(cmd);
return DISPATCHED; return DISPATCHED;
case LFUN_MOUSE_RELEASE: case LFUN_MOUSE_RELEASE:
return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED; return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
default: default:
break; break;
} }

File diff suppressed because it is too large Load Diff

View File

@ -12,21 +12,14 @@
#ifndef TABULAR_H #ifndef TABULAR_H
#define TABULAR_H #define TABULAR_H
#include "layout.h"
#include "LString.h"
#include "lyxlength.h" #include "lyxlength.h"
#include "insets/insettext.h" #include "insets/insettext.h"
#include <iosfwd> #include <iosfwd>
#include <vector> #include <vector>
class InsetTabular; class InsetTabular;
class BufferParams;
class LaTeXFeatures;
class LatexRunParams; class LatexRunParams;
class Buffer;
class LyXLex;
/* The features the text class offers for tables */ /* The features the text class offers for tables */
@ -183,8 +176,6 @@ public:
/// ///
explicit explicit
LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex); LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
///
LyXTabular * clone(BufferParams const &, InsetTabular *);
/// Returns true if there is a topline, returns false if not /// Returns true if there is a topline, returns false if not
bool topLine(int cell, bool onlycolumn = false) const; bool topLine(int cell, bool onlycolumn = false) const;
@ -224,28 +215,28 @@ public:
bool setDescentOfRow(int row, int height); bool setDescentOfRow(int row, int height);
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool setWidthOfCell(int cell, int new_width); bool setWidthOfCell(int cell, int new_width);
/// Returns true if a complete update is necessary, otherwise false ///
bool setAllLines(int cell, bool line); void setAllLines(int cell, bool line);
/// Returns true if a complete update is necessary, otherwise false ///
bool setTopLine(int cell, bool line, bool onlycolumn = false); void 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); void 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); void 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); void 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 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 onlycolumn = false);
/// ///
bool setColumnPWidth(int cell, LyXLength const & width); void setVAlignment(int cell, VAlignment align,
bool onlycolumn = false);
///
void setColumnPWidth(int cell, LyXLength const & width);
/// ///
bool setMColumnPWidth(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; LyXAlignment getAlignment(int cell, bool onlycolumn = false) const;
/// ///
@ -369,9 +360,9 @@ public:
/// ///
// end longtable support // 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 /// Search for \param inset in the tabular, with the
/// additional hint that it could be at \param maybe_cell /// additional hint that it could be at \param maybe_cell
int getCellFromInset(Inset const * inset, int maybe_cell = -1) const; int getCellFromInset(Inset const * inset, int maybe_cell = -1) const;
@ -423,7 +414,7 @@ public:
/// ///
InsetText inset; InsetText inset;
}; };
cellstruct * cellinfo_of_cell(int cell) const; cellstruct & cellinfo_of_cell(int cell) const;
/// ///
typedef std::vector<cellstruct> cell_vector; typedef std::vector<cellstruct> cell_vector;
/// ///
@ -520,15 +511,13 @@ public:
/// ///
void Reinit(bool reset_widths = true); void Reinit(bool reset_widths = true);
/// ///
LyXTabular & operator=(LyXTabular const &);
///
void set_row_column_number_info(bool oldformat = false); void set_row_column_number_info(bool oldformat = false);
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool setWidthOfMulticolCell(int cell, int new_width); bool setWidthOfMulticolCell(int cell, int new_width);
/// ///
void recalculateMulticolumnsOfColumn(int column); void recalculateMulticolumnsOfColumn(int column);
/// Returns true if change /// 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 bool calculate_width_of_column_NMC(int column); // no multi cells
/// ///

View File

@ -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);
}
}

View File

@ -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

View File

@ -1769,7 +1769,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
bool left_side = false; bool left_side = false;
pos_type body_pos = rit_par->beginningOfBody(); pos_type body_pos = rit_par->beginningOfBody();
float last_tmpx = tmpx; int last_tmpx = tmpx;
if (body_pos > 0 && if (body_pos > 0 &&
(body_pos - 1 > last || (body_pos - 1 > last ||
@ -1778,7 +1778,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
// check for empty row // check for empty row
if (!rit_par->size()) { if (!rit_par->size()) {
x = int(tmpx); x = tmpx;
return 0; return 0;
} }
@ -1865,8 +1865,7 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
void LyXText::setCursorFromCoordinates(int x, int y) void LyXText::setCursorFromCoordinates(int x, int y)
{ {
LyXCursor old_cursor = cursor; //LyXCursor old_cursor = cursor;
setCursorFromCoordinates(cursor, x, y); setCursorFromCoordinates(cursor, x, y);
setCurrentFont(); setCurrentFont();
#warning DEPM disabled, otherwise crash when entering new table #warning DEPM disabled, otherwise crash when entering new table