Fixes for tabular-clipboard-paste and tabular-scroll.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1301 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-01-04 12:06:29 +00:00
parent 1e6f221aa5
commit 451f6bb767
3 changed files with 57 additions and 16 deletions

View File

@ -1,3 +1,15 @@
2001-01-04 Juergen Vigna <jug@sad.it>
* src/insets/insettabular.C (resetPos): an extra scroll, but we
really should redo all this scrolling code!
* src/text.C (GetVisibleRow): check that y/h values are good otherwise
change them.
* src/insets/insettabular.C (LocalDispatch): fixes to PASTESELECTION.
(pasteSelection): pay attention to multicolumn cells.
(calculate_dimensions_of_cells): forgot to reset maxAsc/Desc.
2001-01-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 2001-01-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/mathed/math_panel.C (deco_cb): check the decoration index is * src/mathed/math_panel.C (deco_cb): check the decoration index is

View File

@ -970,36 +970,40 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
if (clip.empty()) if (clip.empty())
break; break;
if (clip.find('\t') != string::npos) { if (clip.find('\t') != string::npos) {
int cols = 0; int cols = 1;
int rows = 0; int rows = 1;
int maxCols = 0; int maxCols = 1;
unsigned int len = clip.length();
string::size_type p = 0; string::size_type p = 0;
while((p < clip.length()) && while((p < len) &&
(p = clip.find_first_of("\t\n", p)) != string::npos) ((p = clip.find_first_of("\t\n", p)) != string::npos))
{ {
switch(clip[p]) { switch(clip[p]) {
case '\t': case '\t':
++cols; ++cols;
break; break;
case '\n': case '\n':
++rows; if ((p+1) < len)
maxCols = max(cols+1, maxCols); ++rows;
cols = 0; maxCols = max(cols, maxCols);
cols = 1;
break; break;
} }
++p; ++p;
} }
maxCols = max(cols, maxCols);
delete paste_tabular; delete paste_tabular;
paste_tabular = new LyXTabular(this, rows+1, maxCols); paste_tabular = new LyXTabular(this, rows, maxCols);
string::size_type op = 0; string::size_type op = 0;
int cell = 0; int cell = 0;
unsigned int len = clip.length();
int cells = paste_tabular->GetNumberOfCells(); int cells = paste_tabular->GetNumberOfCells();
p = cols = 0; p = cols = 0;
while((cell < cells) && (p < len) && while((cell < cells) && (p < len) &&
(p = clip.find_first_of("\t\n", p)) != string::npos) (p = clip.find_first_of("\t\n", p)) != string::npos)
{ {
if (p >= len)
break;
switch(clip[p]) { switch(clip[p]) {
case '\t': case '\t':
paste_tabular->GetCellInset(cell)->SetText(clip.substr(op, p-op)); paste_tabular->GetCellInset(cell)->SetText(clip.substr(op, p-op));
@ -1013,12 +1017,12 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
cols = 0; cols = 0;
break; break;
} }
op = p + 1;
++p; ++p;
op = p;
} }
// 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-1) < len)) if ((cell < cells) && (op < len))
paste_tabular->GetCellInset(cell)->SetText(clip.substr(op, p-op)); paste_tabular->GetCellInset(cell)->SetText(clip.substr(op, len-op));
} else { } else {
// so that the clipboard is used and it goes on to default // so that the clipboard is used and it goes on to default
// and executes LFUN_PASTESELECTION in insettext! // and executes LFUN_PASTESELECTION in insettext!
@ -1131,6 +1135,8 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
return changed; return changed;
} }
for (int i = 0; i < tabular->rows(); ++i) { for (int i = 0; i < tabular->rows(); ++i) {
maxAsc = 0;
maxDesc = 0;
for (int j= 0; j < tabular->columns(); ++j) { for (int j= 0; j < tabular->columns(); ++j) {
if (tabular->IsPartOfMultiColumn(i,j)) if (tabular->IsPartOfMultiColumn(i,j))
continue; continue;
@ -1283,6 +1289,7 @@ void InsetTabular::resetPos(BufferView * bv) const
} }
static int const offset = ADD_TO_TABULAR_WIDTH + 2; static int const offset = ADD_TO_TABULAR_WIDTH + 2;
int new_x = getCellXPos(actcell); int new_x = getCellXPos(actcell);
int old_x = cursor.x();
new_x += offset; new_x += offset;
cursor.x(new_x); cursor.x(new_x);
// cursor.x(getCellXPos(actcell) + offset); // cursor.x(getCellXPos(actcell) + offset);
@ -1299,6 +1306,9 @@ void InsetTabular::resetPos(BufferView * bv) const
LyXFont font(LyXFont::ALL_SANE); LyXFont font(LyXFont::ALL_SANE);
cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) + cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
tabular->GetBeginningOfTextInCell(actcell)); tabular->GetBeginningOfTextInCell(actcell));
} else if (scroll() && (top_x > 20) &&
((top_x+tabular->GetWidthOfTabular()) > (bv->workWidth()-20))) {
scroll(bv, old_x - cursor.x());
} }
if ((!the_locking_inset || if ((!the_locking_inset ||
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) && !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
@ -2138,6 +2148,17 @@ bool InsetTabular::pasteSelection(BufferView * bv)
(c1 < paste_tabular->columns()) && (c2 < tabular->columns()); (c1 < paste_tabular->columns()) && (c2 < tabular->columns());
++c1, ++c2) ++c1, ++c2)
{ {
if (paste_tabular->IsPartOfMultiColumn(r1,c1) &&
tabular->IsPartOfMultiColumn(r2,c2))
continue;
if (paste_tabular->IsPartOfMultiColumn(r1,c1)) {
--c2;
continue;
}
if (tabular->IsPartOfMultiColumn(r2,c2)) {
--c1;
continue;
}
int n1 = paste_tabular->GetCellNumber(r1, c1); int n1 = paste_tabular->GetCellNumber(r1, c1);
int n2 = tabular->GetCellNumber(r2, c2); int n2 = tabular->GetCellNumber(r2, c2);
*(tabular->GetCellInset(n2)) = *(paste_tabular->GetCellInset(n1)); *(tabular->GetCellInset(n2)) = *(paste_tabular->GetCellInset(n1));

View File

@ -3079,10 +3079,18 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
} else if (clear_area) { } else if (clear_area) {
#ifdef WITH_WARNINGS #ifdef WITH_WARNINGS
#warning Should be fixed with a lyxinset::clear_width(bv, font) function! (Jug) #warning Should be fixed with a lyxinset::clear_width(bv, font) function! (Jug)
#warning Should we not fix this in the Painter, please have a look Lars! (Jug)
#endif #endif
int const w = (inset_owner ? int w = (inset_owner ? inset_owner->width(bview, font)-2 : ww);
inset_owner->width(bview, font)-2 : ww); int h = row_ptr->height();
pain.fillRectangle(x_offset, y_offset, w, row_ptr->height()); int x = x_offset;
int y = y_offset;
if (y < 0) {
h += y;
y = 0;
}
pain.fillRectangle(x, y, w, h);
} else if (inset != 0) { } else if (inset != 0) {
int h = row_ptr->baseline() - inset->ascent(bview, font); int h = row_ptr->baseline() - inset->ascent(bview, font);
if (h > 0) { if (h > 0) {