mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Commiting my changes till now. Mainly (only?) changes to make text-insets and
tabular insets work. After all the complaints about the tabular-save format I redid it completely, have a look ;) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@711 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4bca0762af
commit
570e57d5b9
34
ChangeLog
34
ChangeLog
@ -1,3 +1,37 @@
|
||||
2000-05-04 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* src/insets/insettext.C: Prepared all for inserting of multiple
|
||||
paragraphs. Still display stuff to do (alignment and other things),
|
||||
but I would like to use LyXText to do this when we cleaned out the
|
||||
table-support stuff.
|
||||
|
||||
* src/insets/insettabular.C: Changed lot of stuff and added lots
|
||||
of functionality still a lot to do.
|
||||
|
||||
* src/tabular.C: Various functions changed name and moved to be
|
||||
const functions. Added new Read and Write functions and changed
|
||||
lots of things so it works good with tabular-insets (also removed
|
||||
some stuff which is not needed anymore * hacks *).
|
||||
|
||||
* src/lyxcursor.h: added operators == and != which just look if
|
||||
par and pos are (not) equal.
|
||||
|
||||
* src/buffer.C (latexParagraphs): inserted this function to latex
|
||||
all paragraphs form par to endpar as then I can use this too for
|
||||
text-insets.
|
||||
|
||||
* src/text2.C (SetLayout): Changed this to use a cursor this is needed
|
||||
so that I can call this to from text insets with their own cursor.
|
||||
|
||||
* src/buffer.C (makeLaTeXFile): added the output of one \n after the
|
||||
output off all paragraphs (because of the fix below)!
|
||||
|
||||
* src/paragraph.C (TeXOnePar): removed output of \n when we are in
|
||||
the very last paragraph (this could be also the last paragraph of an
|
||||
inset!)
|
||||
|
||||
* src/texrow.h: added rows() call which returns the count-variable.
|
||||
|
||||
2000-05-03 Jose Abilio Oliveira Matos <jamatos@novalis.fc.up.pt>
|
||||
|
||||
* lib/lyxrc.example: fix examples for exporting SGML to HTML.
|
||||
|
96
src/buffer.C
96
src/buffer.C
@ -71,6 +71,7 @@
|
||||
#include "insets/insetert.h"
|
||||
#include "insets/insetgraphics.h"
|
||||
#include "insets/insetfoot.h"
|
||||
#include "insets/insettabular.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path.h"
|
||||
#include "LaTeX.h"
|
||||
@ -822,6 +823,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
par->InsertInset(pos, inset);
|
||||
par->SetFont(pos, font);
|
||||
++pos;
|
||||
} else if (tmptok == "Tabular") {
|
||||
Inset * inset = new InsetTabular(this);
|
||||
inset->Read(lex);
|
||||
par->InsertChar(pos, LyXParagraph::META_INSET);
|
||||
par->InsertInset(pos, inset);
|
||||
par->SetFont(pos, font);
|
||||
++pos;
|
||||
} else if (tmptok == "Text") {
|
||||
Inset * inset = new InsetText(this);
|
||||
inset->Read(lex);
|
||||
@ -2025,6 +2033,52 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
latexParagraphs(ofs, paragraph, 0, texrow);
|
||||
|
||||
// add this just in case after all the paragraphs
|
||||
ofs << endl;
|
||||
texrow.newline();
|
||||
|
||||
if (!lyxrc.language_auto_end && params.language != "default") {
|
||||
ofs << subst(lyxrc.language_command_end, "$$lang",
|
||||
params.language)
|
||||
<< endl;
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (!only_body) {
|
||||
ofs << "\\end{document}\n";
|
||||
texrow.newline();
|
||||
|
||||
lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
|
||||
} else {
|
||||
lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Just to be sure. (Asger)
|
||||
texrow.newline();
|
||||
|
||||
// tex_code_break_column's value is used to decide
|
||||
// if we are in batchmode or not (within mathed_write()
|
||||
// in math_write.C) so we must set it to a non-zero
|
||||
// value when we leave otherwise we save incorrect .lyx files.
|
||||
tex_code_break_column = lyxrc.ascii_linelen;
|
||||
|
||||
ofs.close();
|
||||
if (ofs.fail()) {
|
||||
lyxerr << "File was not closed properly." << endl;
|
||||
}
|
||||
|
||||
lyxerr.debug() << "Finished making latex file." << endl;
|
||||
}
|
||||
|
||||
//
|
||||
// LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end
|
||||
//
|
||||
void Buffer::latexParagraphs(ostream & ofs, LyXParagraph *par,
|
||||
LyXParagraph *endpar, TexRow & texrow)
|
||||
{
|
||||
bool was_title = false;
|
||||
bool already_title = false;
|
||||
#ifdef HAVE_SSTREAM
|
||||
@ -2035,10 +2089,8 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
TexRow ft_texrow;
|
||||
int ftcount = 0;
|
||||
|
||||
LyXParagraph * par = paragraph;
|
||||
|
||||
// if only_body
|
||||
while (par) {
|
||||
while (par != endpar) {
|
||||
#ifndef HAVE_SSTREAM
|
||||
ostrstream ftnote;
|
||||
if (tmpholder) {
|
||||
@ -2048,7 +2100,7 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
}
|
||||
#endif
|
||||
if (par->IsDummy())
|
||||
lyxerr[Debug::LATEX] << "Error in MakeLateXFile."
|
||||
lyxerr[Debug::LATEX] << "Error in latexParagraphs."
|
||||
<< endl;
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(params.textclass,
|
||||
@ -2056,7 +2108,7 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
|
||||
if (layout.intitle) {
|
||||
if (already_title) {
|
||||
lyxerr <<"Error in MakeLatexFile: You"
|
||||
lyxerr <<"Error in latexParagraphs: You"
|
||||
" should not mix title layouts"
|
||||
" with normal ones." << endl;
|
||||
} else
|
||||
@ -2114,42 +2166,8 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
ofs << "\\maketitle\n";
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (!lyxrc.language_auto_end && params.language != "default") {
|
||||
ofs << subst(lyxrc.language_command_end, "$$lang",
|
||||
params.language)
|
||||
<< endl;
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (!only_body) {
|
||||
ofs << "\\end{document}\n";
|
||||
texrow.newline();
|
||||
|
||||
lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
|
||||
} else {
|
||||
lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Just to be sure. (Asger)
|
||||
texrow.newline();
|
||||
|
||||
// tex_code_break_column's value is used to decide
|
||||
// if we are in batchmode or not (within mathed_write()
|
||||
// in math_write.C) so we must set it to a non-zero
|
||||
// value when we leave otherwise we save incorrect .lyx files.
|
||||
tex_code_break_column = lyxrc.ascii_linelen;
|
||||
|
||||
ofs.close();
|
||||
if (ofs.fail()) {
|
||||
lyxerr << "File was not closed properly." << endl;
|
||||
}
|
||||
|
||||
lyxerr.debug() << "Finished making latex file." << endl;
|
||||
}
|
||||
|
||||
|
||||
bool Buffer::isLatex() const
|
||||
{
|
||||
return textclasslist.TextClass(params.textclass).outputType() == LATEX;
|
||||
|
@ -153,6 +153,12 @@ public:
|
||||
void makeLaTeXFile(string const & filename,
|
||||
string const & original_path,
|
||||
bool nice, bool only_body = false);
|
||||
//
|
||||
// LaTeX all paragraphs from par to endpar,
|
||||
// if endpar == 0 then to the end
|
||||
//
|
||||
void latexParagraphs(ostream & os, LyXParagraph *par,
|
||||
LyXParagraph *endpar, TexRow & texrow);
|
||||
|
||||
///
|
||||
int runLaTeX();
|
||||
|
@ -54,15 +54,12 @@ char const * InsetFoot::EditMessage() const
|
||||
|
||||
int InsetFoot::Latex(ostream & os, bool fragile, bool fp) const
|
||||
{
|
||||
if (fragile)
|
||||
os << "\\footnote{"; // was footnotemark but that won't work
|
||||
else
|
||||
os << "\\footnote{";
|
||||
os << "\\footnote{%" << endl;
|
||||
|
||||
int i = InsetText::Latex(os, fragile, fp);
|
||||
os << "}";
|
||||
os << "}%" << endl;
|
||||
|
||||
return i;
|
||||
return i + 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Painter.h"
|
||||
#include "font.h"
|
||||
#include "lyxtext.h"
|
||||
#include "insets/insettext.h"
|
||||
|
||||
const int ADD_TO_HEIGHT = 2;
|
||||
@ -51,7 +52,7 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
|
||||
buffer = buf;
|
||||
cursor_visible = false;
|
||||
cursor.x_fix = -1;
|
||||
sel_pos_start = sel_pos_end = 0;
|
||||
actcell = cursor.pos = sel_pos_start = sel_pos_end = 0;
|
||||
no_selection = false;
|
||||
init = true;
|
||||
}
|
||||
@ -64,7 +65,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
|
||||
buffer = buf;
|
||||
cursor_visible = false;
|
||||
cursor.x_fix = -1;
|
||||
sel_pos_start = sel_pos_end = 0;
|
||||
actcell = cursor.pos = sel_pos_start = sel_pos_end = 0;
|
||||
no_selection = false;
|
||||
init = true;
|
||||
}
|
||||
@ -72,7 +73,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
|
||||
|
||||
InsetTabular::~InsetTabular()
|
||||
{
|
||||
delete tabular;
|
||||
delete tabular;
|
||||
}
|
||||
|
||||
|
||||
@ -85,18 +86,31 @@ Inset * InsetTabular::Clone() const
|
||||
|
||||
void InsetTabular::Write(ostream & os) const
|
||||
{
|
||||
os << "\\begin_inset Tabular\n";
|
||||
tabular->Write(os,false);
|
||||
os << "\\end_inset\n";
|
||||
os << " Tabular" << endl;
|
||||
tabular->Write(os);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::Read(LyXLex & lex)
|
||||
{
|
||||
delete tabular;
|
||||
// bool old_format = (lex.GetString() == "\\LyXTable");
|
||||
string token;
|
||||
|
||||
// bool old_format = (lex.GetString() == "\\LyXTabular");
|
||||
if (tabular)
|
||||
delete tabular;
|
||||
tabular = new LyXTabular(lex, buffer);
|
||||
|
||||
lex.nextToken();
|
||||
token = lex.GetString();
|
||||
while (lex.IsOK() && (token != "\\end_inset")) {
|
||||
lex.nextToken();
|
||||
token = lex.GetString();
|
||||
}
|
||||
if (token != "\\end_inset") {
|
||||
lex.printError("Missing \\end_inset at this point. "
|
||||
"Read: `$$Token'");
|
||||
}
|
||||
tabular->SetLongTabular(true);
|
||||
init = true;
|
||||
}
|
||||
|
||||
@ -107,7 +121,7 @@ int InsetTabular::ascent(Painter & pain, LyXFont const & font) const
|
||||
calculate_width_of_cells(pain, font);
|
||||
init = false;
|
||||
}
|
||||
return tabular->AscentOfRow(0);
|
||||
return tabular->GetAscentOfRow(0);
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +131,7 @@ int InsetTabular::descent(Painter & pain, LyXFont const & font) const
|
||||
calculate_width_of_cells(pain, font);
|
||||
init = false;
|
||||
}
|
||||
return tabular->HeightOfTabular() - tabular->AscentOfRow(0);
|
||||
return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0);
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +141,7 @@ int InsetTabular::width(Painter & pain, LyXFont const & font) const
|
||||
calculate_width_of_cells(pain, font);
|
||||
init = false;
|
||||
}
|
||||
return tabular->WidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
|
||||
return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
@ -136,28 +150,64 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
|
||||
{
|
||||
int i, j, cell=0;
|
||||
int nx;
|
||||
float cx;
|
||||
|
||||
UpdatableInset::draw(pain,font,baseline,x);
|
||||
if (top_x != int(x)) {
|
||||
int ox = top_x;
|
||||
if ((top_x != int(x)) || (top_baseline != baseline)) {
|
||||
top_x = int(x);
|
||||
setPos(pain, cursor.x - ox - 2, cursor.y);
|
||||
top_baseline = baseline;
|
||||
resetPos(pain);
|
||||
}
|
||||
top_baseline = baseline;
|
||||
calculate_width_of_cells(pain, font);
|
||||
for(i=0;i<tabular->rows();++i) {
|
||||
nx = int(x);
|
||||
for(j=0;j<tabular->columns();++j) {
|
||||
cx = nx + tabular->GetBeginningOfTextInCell(cell);
|
||||
tabular->GetCellInset(cell)->draw(pain, font, baseline, cx);
|
||||
DrawCellLines(pain, nx, baseline, i, cell);
|
||||
nx += tabular->WidthOfColumn(cell);
|
||||
nx += tabular->GetWidthOfColumn(cell);
|
||||
++cell;
|
||||
}
|
||||
baseline += tabular->DescentOfRow(i) + tabular->AscentOfRow(i+1)
|
||||
+ tabular->AdditionalHeight(cell+1);
|
||||
baseline += tabular->GetDescentOfRow(i) + tabular->GetAscentOfRow(i+1)
|
||||
+ tabular->GetAdditionalHeight(cell+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
|
||||
int row, int cell) const
|
||||
{
|
||||
int x2 = x + tabular->GetWidthOfColumn(cell);
|
||||
bool on_off;
|
||||
|
||||
if (!tabular->TopAlreadyDrawed(cell)) {
|
||||
on_off = !tabular->TopLine(cell);
|
||||
pain.line(x, baseline - tabular->GetAscentOfRow(row),
|
||||
x2, baseline - tabular->GetAscentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
}
|
||||
on_off = !tabular->BottomLine(cell);
|
||||
pain.line(x,baseline + tabular->GetDescentOfRow(row),
|
||||
x2, baseline + tabular->GetDescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
if (!tabular->LeftAlreadyDrawed(cell)) {
|
||||
on_off = !tabular->LeftLine(cell);
|
||||
pain.line(x, baseline - tabular->GetAscentOfRow(row),
|
||||
x, baseline + tabular->GetDescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
}
|
||||
on_off = !tabular->RightLine(cell);
|
||||
pain.line(x2 - tabular->GetAdditionalWidth(cell),
|
||||
baseline - tabular->GetAscentOfRow(row),
|
||||
x2 - tabular->GetAdditionalWidth(cell),
|
||||
baseline + tabular->GetDescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
}
|
||||
|
||||
|
||||
char const * InsetTabular::EditMessage() const
|
||||
{
|
||||
return _("Opened Tabular Inset");
|
||||
@ -176,7 +226,10 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
|
||||
sel_pos_start = sel_pos_end = inset_pos = inset_x = inset_y = 0;
|
||||
setPos(bv->painter(), x, y);
|
||||
sel_pos_start = sel_pos_end = cursor.pos;
|
||||
// bv->text->FinishUndo();
|
||||
bv->text->FinishUndo();
|
||||
if (InsetHit(bv, x, y)) {
|
||||
ActivateCellInset(bv, x, y, button);
|
||||
}
|
||||
UpdateLocal(bv, true);
|
||||
// bv->getOwner()->getPopups().updateFormTabular();
|
||||
}
|
||||
@ -184,10 +237,11 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
|
||||
|
||||
void InsetTabular::InsetUnlock(BufferView * bv)
|
||||
{
|
||||
if (the_locking_inset)
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->InsetUnlock(bv);
|
||||
the_locking_inset = 0;
|
||||
}
|
||||
HideInsetCursor(bv);
|
||||
the_locking_inset = 0;
|
||||
if (hasCharSelection()) {
|
||||
sel_pos_start = sel_pos_end = cursor.pos;
|
||||
UpdateLocal(bv, false);
|
||||
@ -196,35 +250,57 @@ void InsetTabular::InsetUnlock(BufferView * bv)
|
||||
no_selection = false;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::LockInsetInInset(UpdatableInset *)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
|
||||
bool lr)
|
||||
{
|
||||
if (!the_locking_inset)
|
||||
return false;
|
||||
if (the_locking_inset == inset) {
|
||||
the_locking_inset->InsetUnlock(bv);
|
||||
the_locking_inset = 0;
|
||||
if (lr)
|
||||
moveRight(bv);
|
||||
return true;
|
||||
}
|
||||
return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::UpdateLocal(BufferView * bv, bool flag)
|
||||
{
|
||||
// resetPos();
|
||||
if (flag)
|
||||
calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
|
||||
bv->updateInset(this, flag);
|
||||
}
|
||||
|
||||
bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
|
||||
{
|
||||
lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" <<inset<< "): ";
|
||||
if (!inset)
|
||||
return false;
|
||||
if (inset == tabular->GetCellInset(actcell)) {
|
||||
lyxerr[Debug::INSETS] << "OK" << endl;
|
||||
the_locking_inset = tabular->GetCellInset(actcell);
|
||||
resetPos(bv->painter());
|
||||
inset_x = cursor.x - top_x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
inset_y = cursor.y;
|
||||
inset_pos = cursor.pos;
|
||||
return true;
|
||||
} else if (the_locking_inset && (the_locking_inset == inset)) {
|
||||
if (cursor.pos == inset_pos) {
|
||||
lyxerr[Debug::INSETS] << "OK" << endl;
|
||||
resetPos(bv->painter());
|
||||
inset_x = cursor.x - top_x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
inset_y = cursor.y;
|
||||
} else {
|
||||
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
|
||||
}
|
||||
} else if (the_locking_inset) {
|
||||
lyxerr[Debug::INSETS] << "MAYBE" << endl;
|
||||
return the_locking_inset->LockInsetInInset(bv, inset);
|
||||
}
|
||||
lyxerr[Debug::INSETS] << "NOT OK" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
|
||||
bool lr)
|
||||
{
|
||||
if (!the_locking_inset)
|
||||
return false;
|
||||
if (the_locking_inset == inset) {
|
||||
the_locking_inset->InsetUnlock(bv);
|
||||
the_locking_inset = 0;
|
||||
if (lr)
|
||||
moveRight(bv, false);
|
||||
return true;
|
||||
}
|
||||
return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
|
||||
}
|
||||
|
||||
bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
|
||||
{
|
||||
@ -237,35 +313,53 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
|
||||
}
|
||||
|
||||
|
||||
int InsetTabular::InsetInInsetY()
|
||||
{
|
||||
if (!the_locking_inset)
|
||||
return 0;
|
||||
|
||||
return (inset_y + the_locking_inset->InsetInInsetY());
|
||||
}
|
||||
|
||||
void InsetTabular::InsetButtonRelease(BufferView * bv,
|
||||
int x, int y, int button)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->InsetButtonRelease(bv, x-inset_x,y-inset_y,button);
|
||||
the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
|
||||
return;
|
||||
}
|
||||
no_selection = false;
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int)
|
||||
void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
||||
{
|
||||
if (hasCharSelection()) {
|
||||
sel_pos_start = sel_pos_end = 0;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
no_selection = false;
|
||||
if (the_locking_inset) {
|
||||
// otherwise only unlock the_locking_inset
|
||||
|
||||
int oldcell = actcell;
|
||||
|
||||
setPos(bv->painter(), x, y);
|
||||
|
||||
bool inset_hit = InsetHit(bv, x, y);
|
||||
|
||||
if ((oldcell == actcell) && the_locking_inset && inset_hit) {
|
||||
the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
|
||||
return;
|
||||
} else if (the_locking_inset) {
|
||||
the_locking_inset->InsetUnlock(bv);
|
||||
}
|
||||
#if 0
|
||||
int oldcell = actcell;
|
||||
#endif
|
||||
setPos(bv->painter(),x,y);
|
||||
the_locking_inset = 0;
|
||||
sel_pos_start = sel_pos_end = cursor.pos;
|
||||
sel_cell_start = sel_cell_end = actcell;
|
||||
if (inset_hit && bv->the_locking_inset) {
|
||||
ActivateCellInset(bv, x, y, button);
|
||||
the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (button == 3)
|
||||
bview->getOwner()->getPopups().showFormTabular();
|
||||
@ -319,7 +413,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
|
||||
if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
|
||||
|| (result == DISPATCHED_NOUPDATE)) {
|
||||
|
||||
resetPos(bv);
|
||||
resetPos(bv->painter());
|
||||
return result;
|
||||
}
|
||||
result=DISPATCHED;
|
||||
@ -335,15 +429,15 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
|
||||
if (result == DISPATCHED_NOUPDATE)
|
||||
return result;
|
||||
else if (result == DISPATCHED) {
|
||||
setWidthOfCell(cursor.pos,actcell,actrow);
|
||||
bool upd = SetCellDimensions(bv->painter(), actcell, actrow);
|
||||
the_locking_inset->ToggleInsetCursor(bv);
|
||||
UpdateLocal(bv, false);
|
||||
UpdateLocal(bv, upd);
|
||||
the_locking_inset->ToggleInsetCursor(bv);
|
||||
return result;
|
||||
} else if (result == FINISHED) {
|
||||
if ((action == LFUN_RIGHT) || (action == -1)) {
|
||||
cursor.pos = inset_pos + 1;
|
||||
resetPos(bv);
|
||||
resetPos(bv->painter());
|
||||
}
|
||||
the_locking_inset=0;
|
||||
result = DISPATCHED;
|
||||
@ -358,7 +452,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
|
||||
break;
|
||||
// --- Cursor Movements ---------------------------------------------
|
||||
case LFUN_RIGHTSEL:
|
||||
moveRight(bv);
|
||||
moveRight(bv, false);
|
||||
sel_pos_end = cursor.pos;
|
||||
UpdateLocal(bv, false);
|
||||
break;
|
||||
@ -371,12 +465,12 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
|
||||
sel_pos_start = sel_pos_end = cursor.pos;
|
||||
break;
|
||||
case LFUN_LEFTSEL:
|
||||
moveLeft();
|
||||
moveLeft(bv, false);
|
||||
sel_pos_end = cursor.pos;
|
||||
UpdateLocal(bv, false);
|
||||
break;
|
||||
case LFUN_LEFT:
|
||||
result= moveLeft();
|
||||
result = moveLeft(bv);
|
||||
if (hasCharSelection()) {
|
||||
sel_pos_start = sel_pos_end = cursor.pos;
|
||||
UpdateLocal(bv, false);
|
||||
@ -476,63 +570,28 @@ void InsetTabular::Validate(LaTeXFeatures & features) const
|
||||
void InsetTabular::calculate_width_of_cells(Painter & pain,
|
||||
LyXFont const & font) const
|
||||
{
|
||||
int cell = -1;
|
||||
int maxAsc, maxDesc;
|
||||
InsetText * inset;
|
||||
int cell = -1;
|
||||
int maxAsc, maxDesc;
|
||||
InsetText * inset;
|
||||
|
||||
for(int i = 0; i < tabular->rows(); ++i) {
|
||||
maxAsc = maxDesc = 0;
|
||||
for(int j= 0; j < tabular->columns(); ++j) {
|
||||
if (tabular->IsPartOfMultiColumn(i,j))
|
||||
continue;
|
||||
++cell;
|
||||
inset = tabular->GetCellInset(cell);
|
||||
maxAsc = max(maxAsc, inset->ascent(pain, font));
|
||||
maxDesc = max(maxDesc, inset->descent(pain, font));
|
||||
tabular->SetWidthOfCell(cell,
|
||||
inset->width(pain, font));
|
||||
}
|
||||
tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
|
||||
tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
|
||||
for(int i = 0; i < tabular->rows(); ++i) {
|
||||
maxAsc = maxDesc = 0;
|
||||
for(int j= 0; j < tabular->columns(); ++j) {
|
||||
if (tabular->IsPartOfMultiColumn(i,j))
|
||||
continue;
|
||||
++cell;
|
||||
inset = tabular->GetCellInset(cell);
|
||||
maxAsc = max(maxAsc, inset->ascent(pain, font));
|
||||
maxDesc = max(maxDesc, inset->descent(pain, font));
|
||||
tabular->SetWidthOfCell(cell, inset->width(pain, font));
|
||||
}
|
||||
tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
|
||||
tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
|
||||
int row, int cell) const
|
||||
{
|
||||
// Juergen, have you thought about drawing the on-off lines in a
|
||||
// different color (gray of some kind), especially since those
|
||||
// lines will not be there on the hardcopy anyway. (Lgb)
|
||||
int x2 = x + tabular->WidthOfColumn(cell);
|
||||
bool on_off = !tabular->TopLine(cell);
|
||||
|
||||
if (!tabular->TopAlreadyDrawed(cell))
|
||||
pain.line(x, baseline - tabular->AscentOfRow(row),
|
||||
x2, baseline - tabular->AscentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
on_off = !tabular->BottomLine(cell);
|
||||
pain.line(x,baseline + tabular->DescentOfRow(row),
|
||||
x2, baseline + tabular->DescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
on_off = !tabular->LeftLine(cell);
|
||||
pain.line(x, baseline - tabular->AscentOfRow(row),
|
||||
x, baseline + tabular->DescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
on_off = !tabular->RightLine(cell);
|
||||
pain.line(x2 - tabular->AdditionalWidth(cell),
|
||||
baseline - tabular->AscentOfRow(row),
|
||||
x2 - tabular->AdditionalWidth(cell),
|
||||
baseline + tabular->DescentOfRow(row),
|
||||
on_off ? LColor::tabularonoffline:LColor::tabularline,
|
||||
on_off ? Painter::line_onoffdash:Painter::line_solid);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::GetCursorPos(int & x, int & y)
|
||||
void InsetTabular::GetCursorPos(int & x, int & y) const
|
||||
{
|
||||
x = cursor.x-top_x;
|
||||
y = cursor.y;
|
||||
@ -580,80 +639,120 @@ void InsetTabular::HideInsetCursor(BufferView * bv)
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::setPos(Painter &, int x, int y) const
|
||||
void InsetTabular::setPos(Painter & pain, int x, int y) const
|
||||
{
|
||||
cursor.y = cursor.pos = actcell = actrow = actcol = 0;
|
||||
int ly = tabular->DescentOfRow(actrow);
|
||||
int ly = tabular->GetDescentOfRow(actrow);
|
||||
|
||||
// first search the right row
|
||||
while((ly < y) && (actrow < tabular->rows())) {
|
||||
cursor.y += tabular->DescentOfRow(actrow) +
|
||||
tabular->AscentOfRow(actrow+1) +
|
||||
tabular->AdditionalHeight(tabular->GetCellNumber(actcol,actrow+1));
|
||||
cursor.y += tabular->GetDescentOfRow(actrow) +
|
||||
tabular->GetAscentOfRow(actrow+1) +
|
||||
tabular->GetAdditionalHeight(tabular->GetCellNumber(actcol,actrow+1));
|
||||
++actrow;
|
||||
ly = cursor.y + tabular->DescentOfRow(actrow);
|
||||
ly = cursor.y + tabular->GetDescentOfRow(actrow);
|
||||
}
|
||||
actcell = tabular->GetCellNumber(actcol, actrow);
|
||||
|
||||
// now search the right column
|
||||
int lx = tabular->GetWidthOfCell(actcell);
|
||||
for(;
|
||||
!tabular->IsLastCellInRow(actcell) && (lx < x);
|
||||
++actcell,lx += tabular->GetWidthOfCell(actcell)) {}
|
||||
cursor.x = lx - tabular->GetWidthOfCell(actcell) + top_x + 2;
|
||||
int lx = tabular->GetWidthOfColumn(actcell) -
|
||||
tabular->GetAdditionalWidth(actcell);
|
||||
for(; !tabular->IsLastCellInRow(actcell) && (lx < x);
|
||||
++actcell,lx += tabular->GetWidthOfColumn(actcell) +
|
||||
tabular->GetAdditionalWidth(actcell-1));
|
||||
cursor.pos = ((actcell+1) * 2) - 1;
|
||||
resetPos(pain);
|
||||
if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
|
||||
cursor.x = lx + top_x - 2;
|
||||
} else {
|
||||
--cursor.pos;
|
||||
cursor.x = lx - tabular->GetWidthOfColumn(actcell) + top_x + 2;
|
||||
}
|
||||
resetPos(pain);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::resetPos(BufferView * bv)
|
||||
void InsetTabular::resetPos(Painter & pain) const
|
||||
{
|
||||
actrow = cursor.y = actcol = 0;
|
||||
|
||||
int cell = 0;
|
||||
for(; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
|
||||
if (tabular->IsLastCellInRow(cell)) {
|
||||
cursor.y += tabular->DescentOfRow(actrow) +
|
||||
tabular->AscentOfRow(actrow+1) +
|
||||
tabular->AdditionalHeight(cell+1);
|
||||
cursor.y += tabular->GetDescentOfRow(actrow) +
|
||||
tabular->GetAscentOfRow(actrow+1) +
|
||||
tabular->GetAdditionalHeight(cell+1);
|
||||
++actrow;
|
||||
}
|
||||
}
|
||||
for(cell=actcell;!tabular->IsFirstCellInRow(cell);--cell)
|
||||
;
|
||||
int lx = tabular->GetWidthOfCell(actcell);
|
||||
int lx = tabular->GetWidthOfColumn(actcell);
|
||||
for(; (cell < actcell); ++cell) {
|
||||
lx += tabular->GetWidthOfCell(actcell);
|
||||
lx += tabular->GetWidthOfColumn(cell);
|
||||
++actcol;
|
||||
}
|
||||
cursor.x = lx - tabular->GetWidthOfCell(actcell) + top_x + 2;
|
||||
cursor.x = lx - tabular->GetWidthOfColumn(actcell) + top_x + 2;
|
||||
if (cursor.pos % 2) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
cursor.x += tabular->GetCellInset(actcell)->width(bv->painter(),font);
|
||||
cursor.x += tabular->GetCellInset(actcell)->width(pain,font) +
|
||||
tabular->GetBeginningOfTextInCell(actcell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::setWidthOfCell(int, int, int)
|
||||
bool InsetTabular::SetCellDimensions(Painter & pain, int cell, int row)
|
||||
{
|
||||
InsetText * inset = tabular->GetCellInset(cell);
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int asc = inset->ascent(pain, font) + ADD_TO_HEIGHT;
|
||||
int desc = inset->descent(pain, font) + ADD_TO_HEIGHT;
|
||||
int maxAsc = tabular->GetAscentOfRow(row);
|
||||
int maxDesc = tabular->GetDescentOfRow(row);
|
||||
bool ret = tabular->SetWidthOfCell(cell, inset->width(pain, font));
|
||||
|
||||
if (maxAsc < asc) {
|
||||
ret = true;
|
||||
tabular->SetAscentOfRow(row, asc);
|
||||
}
|
||||
if (maxDesc < desc) {
|
||||
ret = true;
|
||||
tabular->SetDescentOfRow(row, desc);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv)
|
||||
UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
|
||||
{
|
||||
if (cursor.pos % 2) { // behind the inset
|
||||
++actcell;
|
||||
if (actcell >= tabular->GetNumberOfCells())
|
||||
return FINISHED;
|
||||
++cursor.pos;
|
||||
} else if (lock) {
|
||||
if (ActivateCellInset(bv))
|
||||
return DISPATCHED;
|
||||
} else { // before the inset
|
||||
++cursor.pos;
|
||||
}
|
||||
resetPos(bv);
|
||||
resetPos(bv->painter());
|
||||
return DISPATCHED_NOUPDATE;
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::moveLeft()
|
||||
UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
|
||||
{
|
||||
if (!cursor.pos)
|
||||
return FINISHED;
|
||||
--cursor.pos;
|
||||
if (cursor.pos % 2) { // behind the inset
|
||||
--actcell;
|
||||
} else if (lock) { // behind the inset
|
||||
if (ActivateCellInset(bv, -1, -1))
|
||||
return DISPATCHED;
|
||||
}
|
||||
resetPos(bv->painter());
|
||||
return DISPATCHED_NOUPDATE;
|
||||
}
|
||||
|
||||
@ -688,7 +787,7 @@ bool InsetTabular::Delete()
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::SetFont(LyXFont const &)
|
||||
void InsetTabular::SetFont(BufferView *, LyXFont const &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1036,3 +1135,44 @@ void InsetTabular::TabularFeatures(int, string)
|
||||
void InsetTabular::RemoveTabularRow()
|
||||
{
|
||||
}
|
||||
|
||||
bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button)
|
||||
{
|
||||
// the cursor.pos has to be before the inset so if it isn't now just
|
||||
// reset the curor pos first!
|
||||
if (cursor.pos % 2) { // behind the inset
|
||||
--cursor.pos;
|
||||
resetPos(bv->painter());
|
||||
}
|
||||
UpdatableInset * inset =
|
||||
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
if (x < 0)
|
||||
x = inset->width(bv->painter(), font) + top_x;
|
||||
if (y < 0)
|
||||
y = inset->descent(bv->painter(), font);
|
||||
inset_x = cursor.x - top_x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
inset_y = cursor.y;
|
||||
inset->Edit(bv, x-inset_x, y-inset_y, button);
|
||||
if (!the_locking_inset)
|
||||
return false;
|
||||
UpdateLocal(bv, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
|
||||
{
|
||||
InsetText * inset = tabular->GetCellInset(actcell);
|
||||
int x1 = x + top_x;
|
||||
|
||||
if (cursor.pos % 2) { // behind the inset
|
||||
return (((x+top_x) < cursor.x) &&
|
||||
((x+top_x) > (cursor.x - inset->width(bv->painter(),
|
||||
LyXFont(LyXFont::ALL_SANE)))));
|
||||
} else {
|
||||
int x2 = cursor.x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
return ((x1 > x2) &&
|
||||
(x1 < (x2 + inset->width(bv->painter(),
|
||||
LyXFont(LyXFont::ALL_SANE)))));
|
||||
}
|
||||
}
|
||||
|
@ -88,14 +88,16 @@ public:
|
||||
///
|
||||
void InsetUnlock(BufferView *);
|
||||
///
|
||||
bool LockInsetInInset(UpdatableInset *);
|
||||
void UpdateLocal(BufferView *, bool flag = true);
|
||||
///
|
||||
bool LockInsetInInset(BufferView *, UpdatableInset *);
|
||||
///
|
||||
bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr=false);
|
||||
///
|
||||
void UpdateLocal(BufferView *, bool flag = true);
|
||||
///
|
||||
bool UpdateInsetInInset(BufferView *, Inset *);
|
||||
///
|
||||
int InsetInInsetY();
|
||||
///
|
||||
bool display() const { return tabular->IsLongTabular(); }
|
||||
///
|
||||
void InsetButtonRelease(BufferView *, int, int, int);
|
||||
@ -120,7 +122,7 @@ public:
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::TABULAR_CODE; }
|
||||
///
|
||||
void GetCursorPos(int & x, int & y);
|
||||
void GetCursorPos(int & x, int & y) const;
|
||||
///
|
||||
void ToggleInsetCursor(BufferView *);
|
||||
///
|
||||
@ -128,7 +130,7 @@ public:
|
||||
///
|
||||
int GetActCell() { return actcell; }
|
||||
///
|
||||
void SetFont(LyXFont const &);
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
///
|
||||
/// Public structures and variables
|
||||
///
|
||||
@ -145,27 +147,32 @@ private:
|
||||
///
|
||||
void setPos(Painter &, int x, int y) const;
|
||||
///
|
||||
void setWidthOfCell(int pos, int cell, int row);
|
||||
bool SetCellDimensions(Painter & pain, int cell, int row);
|
||||
///
|
||||
UpdatableInset::RESULT moveRight(BufferView *);
|
||||
UpdatableInset::RESULT moveLeft();
|
||||
UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
|
||||
UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
|
||||
UpdatableInset::RESULT moveUp();
|
||||
UpdatableInset::RESULT moveDown();
|
||||
bool moveNextCell();
|
||||
bool movePrevCell();
|
||||
bool Delete();
|
||||
///
|
||||
void resetPos(BufferView *);
|
||||
void resetPos(Painter &) const;
|
||||
///
|
||||
void RemoveTabularRow();
|
||||
///
|
||||
bool hasCharSelection() const {return (sel_pos_start != sel_pos_end);}
|
||||
bool hasCellSelection() const {return hasCharSelection() &&
|
||||
(sel_cell_start != sel_cell_end);}
|
||||
///
|
||||
bool ActivateCellInset(BufferView *, int x=0, int y=0, int button=0);
|
||||
///
|
||||
bool InsetHit(BufferView * bv, int x, int y) const;
|
||||
|
||||
///
|
||||
/// Private structures and variables
|
||||
///
|
||||
UpdatableInset
|
||||
InsetText
|
||||
* the_locking_inset;
|
||||
Buffer
|
||||
* buffer;
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include "lyxcursor.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "font.h"
|
||||
#include "minibuffer.h"
|
||||
#include "toolbar.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::ifstream;
|
||||
@ -61,6 +63,7 @@ using std::min;
|
||||
using std::max;
|
||||
|
||||
extern unsigned char getCurrentTextClass(Buffer *);
|
||||
extern LyXTextClass::size_type current_layout;
|
||||
|
||||
|
||||
InsetText::InsetText(Buffer * buf)
|
||||
@ -84,7 +87,6 @@ void InsetText::init(Buffer * buf, InsetText const * ins)
|
||||
buffer = buf;
|
||||
cursor_visible = false;
|
||||
cursor.x_fix = -1;
|
||||
selection_start = selection_end = 0;
|
||||
interline_space = 1;
|
||||
no_selection = false;
|
||||
init_inset = true;
|
||||
@ -93,14 +95,13 @@ void InsetText::init(Buffer * buf, InsetText const * ins)
|
||||
autoBreakRows = false;
|
||||
xpos = 0.0;
|
||||
if (ins) {
|
||||
if (par)
|
||||
delete par;
|
||||
par = ins->par->Clone();
|
||||
SetParagraphData(ins->par);
|
||||
autoBreakRows = ins->autoBreakRows;
|
||||
}
|
||||
par->SetInsetOwner(this);
|
||||
cursor.par = par;
|
||||
cursor.pos = 0;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
|
||||
|
||||
@ -241,12 +242,12 @@ void InsetText::drawRowSelection(Painter & pain, int startpos, int endpos,
|
||||
return;
|
||||
|
||||
int s_start, s_end;
|
||||
if (selection_start > selection_end) {
|
||||
s_start = selection_end;
|
||||
s_end = selection_start;
|
||||
if (selection_start_cursor.pos > selection_end_cursor.pos) {
|
||||
s_start = selection_end_cursor.pos;
|
||||
s_end = selection_start_cursor.pos;
|
||||
} else {
|
||||
s_start = selection_start;
|
||||
s_end = selection_end;
|
||||
s_start = selection_start_cursor.pos;
|
||||
s_end = selection_end_cursor.pos;
|
||||
}
|
||||
if ((s_start > endpos) || (s_end < startpos))
|
||||
return;
|
||||
@ -351,11 +352,10 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
|
||||
return;
|
||||
}
|
||||
the_locking_inset = 0;
|
||||
selection_start = selection_end = inset_pos = inset_x = inset_y = 0;
|
||||
// no_selection = true;
|
||||
inset_pos = inset_x = inset_y = 0;
|
||||
setPos(bv->painter(), x, y);
|
||||
checkAndActivateInset(bv, x, y, button);
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
current_font = real_current_font = GetFont(par, cursor.pos);
|
||||
bv->text->FinishUndo();
|
||||
UpdateLocal(bv, true);
|
||||
@ -368,10 +368,11 @@ void InsetText::InsetUnlock(BufferView * bv)
|
||||
the_locking_inset->InsetUnlock(bv);
|
||||
the_locking_inset = 0;
|
||||
}
|
||||
HideInsetCursor(bv);
|
||||
lyxerr[Debug::INSETS] << "InsetText::InsetUnlock(" << this <<
|
||||
")" << endl;
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
no_selection = false;
|
||||
@ -445,7 +446,7 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
|
||||
void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
||||
{
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
no_selection = false;
|
||||
@ -486,7 +487,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
||||
UpdateLocal(bv, true);
|
||||
}
|
||||
}
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
|
||||
|
||||
@ -521,11 +522,11 @@ void InsetText::InsetMotionNotify(BufferView * bv, int x, int y, int state)
|
||||
return;
|
||||
}
|
||||
if (!no_selection) {
|
||||
int old = selection_end;
|
||||
LyXCursor old = selection_end_cursor;
|
||||
HideInsetCursor(bv);
|
||||
setPos(bv->painter(), x, y);
|
||||
selection_end = cursor.pos;
|
||||
if (old != selection_end)
|
||||
selection_end_cursor = cursor;
|
||||
if (old != selection_end_cursor)
|
||||
UpdateLocal(bv, false);
|
||||
ShowInsetCursor(bv);
|
||||
}
|
||||
@ -593,82 +594,82 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
|
||||
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
|
||||
cutSelection();
|
||||
cursor.pos = selection_start;
|
||||
cursor = selection_start_cursor;
|
||||
par->InsertChar(cursor.pos,arg[0]);
|
||||
SetCharFont(cursor.pos,current_font);
|
||||
++cursor.pos;
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, true);
|
||||
break;
|
||||
// --- Cursor Movements ---------------------------------------------
|
||||
case LFUN_RIGHTSEL:
|
||||
bv->text->FinishUndo();
|
||||
moveRight(bv, false);
|
||||
selection_end = cursor.pos;
|
||||
selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
break;
|
||||
case LFUN_RIGHT:
|
||||
bv->text->FinishUndo();
|
||||
result = moveRight(bv);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
break;
|
||||
case LFUN_LEFTSEL:
|
||||
bv->text->FinishUndo();
|
||||
moveLeft(bv, false);
|
||||
selection_end = cursor.pos;
|
||||
selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
break;
|
||||
case LFUN_LEFT:
|
||||
bv->text->FinishUndo();
|
||||
result= moveLeft(bv);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
break;
|
||||
case LFUN_DOWNSEL:
|
||||
bv->text->FinishUndo();
|
||||
moveDown(bv);
|
||||
selection_end = cursor.pos;
|
||||
selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
break;
|
||||
case LFUN_DOWN:
|
||||
bv->text->FinishUndo();
|
||||
result = moveDown(bv);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
break;
|
||||
case LFUN_UPSEL:
|
||||
bv->text->FinishUndo();
|
||||
moveUp(bv);
|
||||
selection_end = cursor.pos;
|
||||
selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
break;
|
||||
case LFUN_UP:
|
||||
bv->text->FinishUndo();
|
||||
result = moveUp(bv);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
break;
|
||||
case LFUN_BACKSPACE:
|
||||
if (!cursor.pos) { // || par->IsNewline(cursor.pos-1)) {
|
||||
if (!cursor.pos) {
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
break;
|
||||
@ -681,17 +682,17 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
|
||||
bool ret = true;
|
||||
if (hasSelection()) {
|
||||
LyXParagraph::size_type i = selection_start;
|
||||
for (; i < selection_end; ++i) {
|
||||
par->Erase(selection_start);
|
||||
LyXParagraph::size_type i = selection_start_cursor.pos;
|
||||
for (; i < selection_end_cursor.pos; ++i) {
|
||||
par->Erase(selection_start_cursor.pos);
|
||||
}
|
||||
} else
|
||||
ret = Delete();
|
||||
if (ret) { // we need update
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, true);
|
||||
} else if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
}
|
||||
@ -704,10 +705,10 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
|
||||
if (cutSelection()) {
|
||||
// we need update
|
||||
cursor.pos = selection_end = selection_start;
|
||||
cursor = selection_end_cursor = selection_start_cursor;
|
||||
UpdateLocal(bv, true);
|
||||
} else if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
resetPos(bv->painter());
|
||||
@ -716,10 +717,10 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
bv->text->FinishUndo();
|
||||
if (copySelection()) {
|
||||
// we need update
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, true);
|
||||
} else if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
}
|
||||
break;
|
||||
@ -729,7 +730,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
|
||||
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
|
||||
if (pasteSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, true);
|
||||
}
|
||||
}
|
||||
@ -741,10 +742,10 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
cursor.x -= SingleWidth(bv->painter(), par, cursor.pos);
|
||||
cursor.x -= SingleWidth(bv->painter(), par, cursor.pos);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
resetPos(bv->painter());
|
||||
break;
|
||||
@ -757,10 +758,10 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
for(; cursor.pos < checkpos; ++cursor.pos)
|
||||
cursor.x += SingleWidth(bv->painter(), par, cursor.pos);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
UpdateLocal(bv, false);
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
}
|
||||
resetPos(bv->painter());
|
||||
@ -782,9 +783,42 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
SetCharFont(cursor.pos,current_font);
|
||||
UpdateLocal(bv, true);
|
||||
++cursor.pos;
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
resetPos(bv->painter());
|
||||
break;
|
||||
case LFUN_LAYOUT:
|
||||
{
|
||||
// Derive layout number from given argument (string)
|
||||
// and current buffer's textclass (number). */
|
||||
LyXTextClassList::ClassList::size_type tclass =
|
||||
buffer->params.textclass;
|
||||
pair <bool, LyXTextClass::size_type> layout =
|
||||
textclasslist.NumberOfLayout(tclass, arg);
|
||||
|
||||
// If the entry is obsolete, use the new one instead.
|
||||
if (layout.first) {
|
||||
string obs = textclasslist.Style(tclass,layout.second).
|
||||
obsoleted_by();
|
||||
if (!obs.empty())
|
||||
layout = textclasslist.NumberOfLayout(tclass, obs);
|
||||
}
|
||||
|
||||
// see if we found the layout number:
|
||||
if (!layout.first) {
|
||||
string msg = string(N_("Layout ")) + arg + N_(" not known");
|
||||
|
||||
bv->owner()->getMiniBuffer()->Set(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
if (current_layout != layout.second) {
|
||||
bv->text->SetLayout(cursor, selection_start_cursor,
|
||||
selection_end_cursor, layout.second);
|
||||
bv->owner()->getToolbar()->combox->select(cursor.par->GetLayout()+1);
|
||||
UpdateLocal(bv, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = UNDISPATCHED;
|
||||
break;
|
||||
@ -799,9 +833,9 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
|
||||
int InsetText::Latex(ostream & os, bool /*fragile*/, bool /*fp*/) const
|
||||
{
|
||||
TexRow texrow;
|
||||
int ret = par->SimpleTeXOnePar(os, texrow);
|
||||
return ret;
|
||||
TexRow texrow;
|
||||
buffer->latexParagraphs(os, par, 0, texrow);
|
||||
return texrow.rows();
|
||||
}
|
||||
|
||||
|
||||
@ -1048,6 +1082,8 @@ void InsetText::setPos(Painter & pain, int x, int y) const
|
||||
|
||||
void InsetText::resetPos(Painter & pain) const
|
||||
{
|
||||
cursor.par = par;
|
||||
|
||||
if (!rows.size())
|
||||
return;
|
||||
|
||||
@ -1149,9 +1185,9 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
|
||||
par->InsertChar(cursor.pos, LyXParagraph::META_INSET);
|
||||
par->InsertInset(cursor.pos, inset);
|
||||
if (hasSelection()) {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
} else {
|
||||
selection_start = selection_end = cursor.pos;
|
||||
selection_start_cursor = selection_end_cursor = cursor;
|
||||
}
|
||||
UpdateLocal(bv, true);
|
||||
static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
|
||||
@ -1189,12 +1225,12 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
}
|
||||
|
||||
int s_start, s_end;
|
||||
if (selection_start > selection_end) {
|
||||
s_start = selection_end;
|
||||
s_end = selection_start;
|
||||
if (selection_start_cursor.pos > selection_end_cursor.pos) {
|
||||
s_start = selection_end_cursor.pos;
|
||||
s_end = selection_start_cursor.pos;
|
||||
} else {
|
||||
s_start = selection_start;
|
||||
s_end = selection_end;
|
||||
s_start = selection_start_cursor.pos;
|
||||
s_end = selection_end_cursor.pos;
|
||||
}
|
||||
LyXFont newfont;
|
||||
while(s_start < s_end) {
|
||||
@ -1427,6 +1463,7 @@ void InsetText::UpdateLocal(BufferView * bv, bool flag)
|
||||
bv->updateInset(this, flag);
|
||||
if (flag)
|
||||
resetPos(bv->painter());
|
||||
bv->owner()->getToolbar()->combox->select(cursor.par->GetLayout()+1);
|
||||
}
|
||||
|
||||
|
||||
@ -1439,12 +1476,12 @@ bool InsetText::cutSelection()
|
||||
|
||||
LyXParagraph * endpar = par;
|
||||
int start, end;
|
||||
if (selection_start > selection_end) {
|
||||
start = selection_end;
|
||||
end = selection_start;
|
||||
if (selection_start_cursor.pos > selection_end_cursor.pos) {
|
||||
start = selection_end_cursor.pos;
|
||||
end = selection_start_cursor.pos;
|
||||
} else {
|
||||
start = selection_start;
|
||||
end = selection_end;
|
||||
start = selection_start_cursor.pos;
|
||||
end = selection_end_cursor.pos;
|
||||
}
|
||||
|
||||
return cap.cutSelection(par, &endpar, start, end,buffer->params.textclass);
|
||||
@ -1459,12 +1496,12 @@ bool InsetText::copySelection()
|
||||
CutAndPaste cap;
|
||||
|
||||
int start, end;
|
||||
if (selection_start > selection_end) {
|
||||
start = selection_end;
|
||||
end = selection_start;
|
||||
if (selection_start_cursor.pos > selection_end_cursor.pos) {
|
||||
start = selection_end_cursor.pos;
|
||||
end = selection_start_cursor.pos;
|
||||
} else {
|
||||
start = selection_start;
|
||||
end = selection_end;
|
||||
start = selection_start_cursor.pos;
|
||||
end = selection_end_cursor.pos;
|
||||
}
|
||||
return cap.copySelection(par, par, start, end, buffer->params.textclass);
|
||||
}
|
||||
@ -1516,3 +1553,12 @@ int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset,
|
||||
{
|
||||
return getMaxWidth(pain, inset) - x;
|
||||
}
|
||||
|
||||
void InsetText::SetParagraphData(LyXParagraph *p)
|
||||
{
|
||||
if (par)
|
||||
delete par;
|
||||
par = p->Clone();
|
||||
par->SetInsetOwner(this);
|
||||
init_inset = true;
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ class Buffer;
|
||||
*/
|
||||
class InsetText : public UpdatableInset {
|
||||
public:
|
||||
///
|
||||
enum { TEXT_TO_INSET_OFFSET = 1 };
|
||||
///
|
||||
explicit
|
||||
enum { TEXT_TO_INSET_OFFSET = 1 };
|
||||
///
|
||||
explicit
|
||||
InsetText(Buffer *);
|
||||
///
|
||||
InsetText(InsetText const &, Buffer *);
|
||||
@ -107,6 +107,8 @@ public:
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
///
|
||||
void init(Buffer *, InsetText const * ins = 0);
|
||||
///
|
||||
void SetParagraphData(LyXParagraph *);
|
||||
|
||||
LyXParagraph * par;
|
||||
|
||||
@ -178,7 +180,8 @@ private:
|
||||
bool copySelection();
|
||||
bool pasteSelection();
|
||||
///
|
||||
bool hasSelection() const { return selection_start != selection_end; }
|
||||
bool hasSelection() const
|
||||
{ return (selection_start_cursor != selection_end_cursor); }
|
||||
///
|
||||
void SetCharFont(int pos, LyXFont const & font);
|
||||
///
|
||||
@ -197,9 +200,9 @@ private:
|
||||
///
|
||||
int interline_space;
|
||||
///
|
||||
int selection_start;
|
||||
LyXCursor selection_start_cursor;
|
||||
///
|
||||
int selection_end;
|
||||
LyXCursor selection_end_cursor;
|
||||
///
|
||||
mutable LyXCursor cursor;
|
||||
///
|
||||
@ -241,9 +244,7 @@ private:
|
||||
inset_x = it.inset_x;
|
||||
inset_y = it.inset_y;
|
||||
interline_space = it.interline_space;
|
||||
selection_start = it.selection_start;
|
||||
selection_end = it.selection_end;
|
||||
cursor = it.cursor;
|
||||
selection_start_cursor = selection_end_cursor = cursor = it.cursor;
|
||||
actrow = it.actrow;
|
||||
no_selection = it.no_selection;
|
||||
the_locking_inset = it.the_locking_inset; // suspect
|
||||
|
@ -177,8 +177,6 @@ public:
|
||||
return 0;
|
||||
}
|
||||
///
|
||||
virtual void init(BufferView *) {}
|
||||
///
|
||||
virtual bool InsertInsetAllowed(Inset *) const { return false; }
|
||||
///
|
||||
virtual void setInsetName(const char * s) { name = s; }
|
||||
|
@ -31,6 +31,11 @@ struct LyXCursor {
|
||||
unsigned long y;
|
||||
///
|
||||
Row * row;
|
||||
///
|
||||
inline bool operator==(const LyXCursor &a) const
|
||||
{ return (a.par == par) && (a.pos == pos); }
|
||||
inline bool operator!=(const LyXCursor &a) const
|
||||
{ return (a.par != par) || (a.pos != pos); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -88,6 +88,10 @@ public:
|
||||
/** set layout over selection and make a total rebreak of
|
||||
those paragraphs
|
||||
*/
|
||||
LyXParagraph * SetLayout(LyXCursor & actual_cursor,
|
||||
LyXCursor & selection_start,
|
||||
LyXCursor & selection_end,
|
||||
LyXTextClass::size_type layout);
|
||||
void SetLayout(LyXTextClass::size_type layout);
|
||||
|
||||
/// used in setlayout
|
||||
|
@ -2126,7 +2126,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
|
||||
|| par->pextra_type != pextra_type))
|
||||
break;
|
||||
default:
|
||||
if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE
|
||||
// we don't need it for the last paragraph!!!
|
||||
if (next && !(footnoteflag != LyXParagraph::NO_FOOTNOTE
|
||||
&& footnotekind != LyXParagraph::FOOTNOTE
|
||||
&& footnotekind != LyXParagraph::MARGIN
|
||||
&& (table
|
||||
@ -2168,7 +2169,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
|
||||
// we don't need it for the last paragraph!!!
|
||||
if (next && !(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
|
||||
par->footnoteflag == LyXParagraph::NO_FOOTNOTE)) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
|
@ -1403,8 +1403,7 @@ int LyXTable::TexEndOfCell(ostream & os, int cell)
|
||||
}
|
||||
}
|
||||
if (nvcell < numberofcells && Linebreaks(nvcell)) {
|
||||
// !column_info[column_of_cell(nvcell)].p_width.empty()) {
|
||||
os << "\\parbox{"
|
||||
os << "\\parbox[t]{"
|
||||
<< GetPWidth(nvcell)
|
||||
<< "}{\\smallskip{}";
|
||||
}
|
||||
|
1122
src/tabular.C
1122
src/tabular.C
File diff suppressed because it is too large
Load Diff
108
src/tabular.h
108
src/tabular.h
@ -68,50 +68,52 @@ public:
|
||||
};
|
||||
/* konstruktor */
|
||||
///
|
||||
LyXTabular(int columns_arg, int rows_arg, Buffer *buf = 0);
|
||||
LyXTabular(int columns_arg, int rows_arg, Buffer *buf);
|
||||
///
|
||||
///
|
||||
LyXTabular(LyXTabular const &, Buffer *buf = 0);
|
||||
LyXTabular(LyXTabular const &, Buffer *buf);
|
||||
///
|
||||
explicit
|
||||
LyXTabular(LyXLex & lex, Buffer *buf = 0);
|
||||
LyXTabular(LyXLex & lex, Buffer *buf);
|
||||
///
|
||||
~LyXTabular();
|
||||
///
|
||||
LyXTabular & operator=(LyXTabular const &);
|
||||
///
|
||||
LyXTabular * Clone();
|
||||
LyXTabular * Clone(Buffer * buf);
|
||||
|
||||
/// Returns true if there is a topline, returns false if not
|
||||
bool TopLine(int cell);
|
||||
bool TopLine(int cell) const;
|
||||
/// Returns true if there is a topline, returns false if not
|
||||
bool BottomLine(int cell);
|
||||
bool BottomLine(int cell) const;
|
||||
/// Returns true if there is a topline, returns false if not
|
||||
bool LeftLine(int cell);
|
||||
bool LeftLine(int cell) const;
|
||||
/// Returns true if there is a topline, returns false if not
|
||||
bool RightLine(int cell);
|
||||
bool RightLine(int cell) const;
|
||||
|
||||
///
|
||||
bool TopAlreadyDrawed(int cell);
|
||||
bool TopAlreadyDrawed(int cell) const;
|
||||
///
|
||||
bool VeryLastRow(int cell);
|
||||
bool LeftAlreadyDrawed(int cell) const;
|
||||
///
|
||||
bool IsLastRow(int cell) const;
|
||||
|
||||
///
|
||||
int AdditionalHeight(int cell);
|
||||
int GetAdditionalHeight(int cell) const;
|
||||
///
|
||||
int AdditionalWidth(int cell);
|
||||
int GetAdditionalWidth(int cell) const;
|
||||
|
||||
/* returns the maximum over all rows */
|
||||
///
|
||||
int WidthOfColumn(int cell);
|
||||
int GetWidthOfColumn(int cell) const;
|
||||
///
|
||||
int WidthOfTabular();
|
||||
int GetWidthOfTabular() const;
|
||||
///
|
||||
int AscentOfRow(int row);
|
||||
int GetAscentOfRow(int row) const;
|
||||
///
|
||||
int DescentOfRow(int row);
|
||||
int GetDescentOfRow(int row) const;
|
||||
///
|
||||
int HeightOfTabular();
|
||||
int GetHeightOfTabular() const;
|
||||
///
|
||||
void SetAscentOfRow(int row, int height);
|
||||
///
|
||||
@ -135,15 +137,15 @@ public:
|
||||
///
|
||||
bool SetAlignSpecial(int cell, string special, int what);
|
||||
///
|
||||
char GetAlignment(int cell); // add approp. signedness
|
||||
char GetAlignment(int cell) const; // add approp. signedness
|
||||
///
|
||||
string GetPWidth(int cell);
|
||||
string GetPWidth(int cell) const;
|
||||
///
|
||||
string GetAlignSpecial(int cell, int what);
|
||||
string GetAlignSpecial(int cell, int what) const;
|
||||
///
|
||||
int GetWidthOfCell(int cell);
|
||||
int GetWidthOfCell(int cell) const;
|
||||
///
|
||||
int GetBeginningOfTextInCell(int cell);
|
||||
int GetBeginningOfTextInCell(int cell) const;
|
||||
///
|
||||
void AppendRow(int cell);
|
||||
///
|
||||
@ -153,49 +155,51 @@ public:
|
||||
///
|
||||
void DeleteColumn(int cell);
|
||||
///
|
||||
bool IsFirstCellInRow(int cell);
|
||||
bool IsFirstCellInRow(int cell) const;
|
||||
///
|
||||
bool IsLastCellInRow(int cell);
|
||||
bool IsLastCellInRow(int cell) const;
|
||||
///
|
||||
int GetNumberOfCells();
|
||||
int GetNumberOfCells() const;
|
||||
///
|
||||
int AppendCellAfterCell(int append_cell, int question_cell);
|
||||
///
|
||||
int DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell);
|
||||
///
|
||||
int NumberOfCellsInRow(int cell);
|
||||
int NumberOfCellsInRow(int cell) const;
|
||||
///
|
||||
void Reinit();
|
||||
///
|
||||
void Init(int columns_arg, int rows_arg);
|
||||
///
|
||||
void Write(std::ostream &, bool old_format=true);
|
||||
void Write(std::ostream &) const;
|
||||
///
|
||||
void Read(std::istream &);
|
||||
void Read(LyXLex &);
|
||||
///
|
||||
int Latex(std::ostream &);
|
||||
void OldFormatRead(std::istream &, string);
|
||||
///
|
||||
int Latex(std::ostream &) const;
|
||||
|
||||
// cell <0 will tex the preamble
|
||||
// returns the number of printed newlines
|
||||
///
|
||||
int TexEndOfCell(std::ostream &, int cell);
|
||||
int TexEndOfCell(std::ostream &, int cell) const;
|
||||
///
|
||||
int DocBookEndOfCell(std::ostream &, int cell, int & depth);
|
||||
int DocBookEndOfCell(std::ostream &, int cell, int & depth) const;
|
||||
#if 0
|
||||
///
|
||||
int RoffEndOfCell(std::ostream &, int cell);
|
||||
#endif
|
||||
///
|
||||
char const * getDocBookAlign(int cell, bool isColumn = false);
|
||||
char const * GetDocBookAlign(int cell, bool isColumn = false) const;
|
||||
|
||||
///
|
||||
bool IsMultiColumn(int cell);
|
||||
bool IsMultiColumn(int cell) const;
|
||||
///
|
||||
void SetMultiColumn(int cell, int number);
|
||||
///
|
||||
int UnsetMultiColumn(int cell); // returns number of new cells
|
||||
///
|
||||
bool IsPartOfMultiColumn(int row, int column);
|
||||
bool IsPartOfMultiColumn(int row, int column) const;
|
||||
///
|
||||
int row_of_cell(int cell) const;
|
||||
///
|
||||
@ -203,47 +207,45 @@ public:
|
||||
///
|
||||
void SetLongTabular(int what);
|
||||
///
|
||||
bool IsLongTabular();
|
||||
bool IsLongTabular() const;
|
||||
///
|
||||
void SetRotateTabular(int what);
|
||||
///
|
||||
bool RotateTabular();
|
||||
bool GetRotateTabular() const;
|
||||
///
|
||||
void SetRotateCell(int cell, int what);
|
||||
///
|
||||
bool RotateCell(int cell);
|
||||
bool GetRotateCell(int cell) const;
|
||||
///
|
||||
bool NeedRotating();
|
||||
bool NeedRotating() const;
|
||||
///
|
||||
bool ShouldBeVeryLastCell(int cell);
|
||||
bool IsLastCell(int cell) const;
|
||||
///
|
||||
bool IsLastRow(int cell);
|
||||
int GetCellAbove(int cell) const;
|
||||
///
|
||||
int GetCellAbove(int cell);
|
||||
///
|
||||
int GetCellNumber(int column, int row);
|
||||
int GetCellNumber(int column, int row) const;
|
||||
///
|
||||
void SetLinebreaks(int cell, bool what);
|
||||
///
|
||||
bool Linebreaks(int cell);
|
||||
bool GetLinebreaks(int cell) const;
|
||||
///
|
||||
/// Long Tabular Options
|
||||
///
|
||||
void SetLTHead(int cell, bool first);
|
||||
///
|
||||
bool RowOfLTHead(int cell);
|
||||
bool GetRowOfLTHead(int cell) const;
|
||||
///
|
||||
bool RowOfLTFirstHead(int cell);
|
||||
bool GetRowOfLTFirstHead(int cell) const;
|
||||
///
|
||||
void SetLTFoot(int cell, bool last);
|
||||
///
|
||||
bool RowOfLTFoot(int cell);
|
||||
bool GetRowOfLTFoot(int cell) const;
|
||||
///
|
||||
bool RowOfLTLastFoot(int cell);
|
||||
bool GetRowOfLTLastFoot(int cell) const;
|
||||
///
|
||||
void SetLTNewPage(int cell, bool what);
|
||||
///
|
||||
bool LTNewPage(int cell);
|
||||
bool GetLTNewPage(int cell) const;
|
||||
///
|
||||
InsetText * GetCellInset(int cell) const;
|
||||
///
|
||||
@ -255,7 +257,7 @@ private: //////////////////////////////////////////////////////////////////
|
||||
///
|
||||
struct cellstruct {
|
||||
///
|
||||
cellstruct(Buffer * buf = 0);
|
||||
cellstruct(Buffer * buf);
|
||||
///
|
||||
~cellstruct();
|
||||
///
|
||||
@ -355,16 +357,16 @@ private: //////////////////////////////////////////////////////////////////
|
||||
void calculate_width_of_tabular();
|
||||
|
||||
///
|
||||
int right_column_of_cell(int cell);
|
||||
int right_column_of_cell(int cell) const;
|
||||
|
||||
///
|
||||
cellstruct * cellinfo_of_cell(int cell);
|
||||
cellstruct * cellinfo_of_cell(int cell) const;
|
||||
|
||||
///
|
||||
void delete_column(int column);
|
||||
|
||||
///
|
||||
int cells_in_multicolumn(int cell);
|
||||
int cells_in_multicolumn(int cell) const;
|
||||
///
|
||||
int is_long_tabular;
|
||||
///
|
||||
|
@ -45,6 +45,9 @@ public:
|
||||
/// Appends another TexRow
|
||||
TexRow & operator+= (TexRow const &);
|
||||
|
||||
/// Returns the number of rows in this texrow
|
||||
int rows() { return count; }
|
||||
|
||||
private:
|
||||
/// Linked list of items
|
||||
struct RowItem {
|
||||
|
85
src/text2.C
85
src/text2.C
@ -474,12 +474,78 @@ void LyXText::MakeFontEntriesLayoutSpecific(LyXParagraph * par)
|
||||
}
|
||||
}
|
||||
|
||||
LyXParagraph * LyXText::SetLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
||||
LyXCursor & send_cur,
|
||||
LyXTextClass::size_type layout)
|
||||
{
|
||||
LyXParagraph * endpar = send_cur.par->LastPhysicalPar()->Next();
|
||||
LyXParagraph * undoendpar = endpar;
|
||||
|
||||
if (endpar && endpar->GetDepth()) {
|
||||
while (endpar && endpar->GetDepth()) {
|
||||
endpar = endpar->LastPhysicalPar()->Next();
|
||||
undoendpar = endpar;
|
||||
}
|
||||
} else if (endpar) {
|
||||
endpar = endpar->Next(); // because of parindents etc.
|
||||
}
|
||||
|
||||
SetUndo(Undo::EDIT,
|
||||
sstart_cur.par->ParFromPos(sstart_cur.pos)->previous,
|
||||
undoendpar);
|
||||
|
||||
/* ok we have a selection. This is always between sstart_cur
|
||||
* and sel_end cursor */
|
||||
cur = sstart_cur;
|
||||
|
||||
LyXLayout const & lyxlayout =
|
||||
textclasslist.Style(buffer->params.textclass, layout);
|
||||
|
||||
while (cur.par != send_cur.par) {
|
||||
if (cur.par->footnoteflag == sstart_cur.par->footnoteflag) {
|
||||
cur.par->SetLayout(layout);
|
||||
MakeFontEntriesLayoutSpecific(cur.par);
|
||||
LyXParagraph* fppar = cur.par->FirstPhysicalPar();
|
||||
fppar->added_space_top = lyxlayout.fill_top ?
|
||||
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
|
||||
fppar->added_space_bottom = lyxlayout.fill_bottom ?
|
||||
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
|
||||
if (lyxlayout.margintype == MARGIN_MANUAL)
|
||||
cur.par->SetLabelWidthString(lyxlayout.labelstring());
|
||||
if (lyxlayout.labeltype != LABEL_BIBLIO
|
||||
&& fppar->bibkey) {
|
||||
delete fppar->bibkey;
|
||||
fppar->bibkey = 0;
|
||||
}
|
||||
}
|
||||
cur.par = cur.par->Next();
|
||||
}
|
||||
if (cur.par->footnoteflag == sstart_cur.par->footnoteflag) {
|
||||
cur.par->SetLayout(layout);
|
||||
MakeFontEntriesLayoutSpecific(cur.par);
|
||||
LyXParagraph* fppar = cur.par->FirstPhysicalPar();
|
||||
fppar->added_space_top = lyxlayout.fill_top ?
|
||||
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
|
||||
fppar->added_space_bottom = lyxlayout.fill_bottom ?
|
||||
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
|
||||
if (lyxlayout.margintype == MARGIN_MANUAL)
|
||||
cur.par->SetLabelWidthString(lyxlayout.labelstring());
|
||||
if (lyxlayout.labeltype != LABEL_BIBLIO
|
||||
&& fppar->bibkey) {
|
||||
delete fppar->bibkey;
|
||||
fppar->bibkey = 0;
|
||||
}
|
||||
}
|
||||
return endpar;
|
||||
}
|
||||
|
||||
// set layout over selection and make a total rebreak of those paragraphs
|
||||
void LyXText::SetLayout(LyXTextClass::size_type layout)
|
||||
{
|
||||
LyXCursor tmpcursor;
|
||||
LyXCursor
|
||||
tmpcursor = cursor; /* store the current cursor */
|
||||
|
||||
#ifdef USE_OLD_SET_LAYOUT
|
||||
// if there is no selection just set the layout
|
||||
// of the current paragraph */
|
||||
if (!selection) {
|
||||
@ -504,8 +570,6 @@ void LyXText::SetLayout(LyXTextClass::size_type layout)
|
||||
sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->previous,
|
||||
undoendpar);
|
||||
|
||||
tmpcursor = cursor; /* store the current cursor */
|
||||
|
||||
/* ok we have a selection. This is always between sel_start_cursor
|
||||
* and sel_end cursor */
|
||||
cursor = sel_start_cursor;
|
||||
@ -550,7 +614,16 @@ void LyXText::SetLayout(LyXTextClass::size_type layout)
|
||||
fppar->bibkey = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
// if there is no selection just set the layout
|
||||
// of the current paragraph */
|
||||
if (!selection) {
|
||||
sel_start_cursor = cursor; // dummy selection
|
||||
sel_end_cursor = cursor;
|
||||
}
|
||||
LyXParagraph *
|
||||
endpar = SetLayout(cursor, sel_start_cursor, sel_end_cursor, layout);
|
||||
#endif
|
||||
RedoParagraphs(sel_start_cursor, endpar);
|
||||
|
||||
// we have to reset the selection, because the
|
||||
@ -2210,7 +2283,7 @@ void LyXText::CopySelection()
|
||||
DeleteSimpleCutBuffer();
|
||||
|
||||
// set the textclass
|
||||
simple_cut_buffer_textclass = buffer->params->textclass;
|
||||
simple_cut_buffer_textclass = buffer->params.textclass;
|
||||
|
||||
// copy behind a space if there is one
|
||||
while (sel_start_cursor.par->Last() > sel_start_cursor.pos
|
||||
@ -2457,7 +2530,7 @@ void LyXText::PasteSelection()
|
||||
|
||||
// make sure there is no class difference
|
||||
cap.SwitchLayoutsBetweenClasses(simple_cut_buffer_textclass,
|
||||
buffer->params->textclass,
|
||||
buffer->params.textclass,
|
||||
simple_cut_buffer);
|
||||
|
||||
// make the simple_cut_buffer exactly the same layout than
|
||||
|
Loading…
Reference in New Issue
Block a user