use NEW_TABULAR�to controll all insettabler usage and code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@912 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-07-21 18:47:54 +00:00
parent f23a147fe1
commit 69c9c901ac
13 changed files with 294 additions and 157 deletions

View File

@ -1,5 +1,25 @@
2000-07-21 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/toolbar.h: include commandtags.h instead of lyxfunc.h,
forward decl of LyXView.
* src/toolbar.C (toolbarItem): moved from toolbar.h
(toolbarItem::clean): ditto
(toolbarItem::~toolbarItem): ditto
(toolbarItem::operator): ditto
* src/text2.C (SetLayout): commetn out USE_OLD_SETUP_LAYOUT stuff
* src/paragraph.h: control the NEW_TABULAR define from here
* src/buffer.C: remove define USE_PARSE_FUNCTION, change
USE_TABULAR_INSETS to NEW_TABULAR
* src/ToolbarDefaults.C: add include "lyxlex.h"
* files using the old table/tabular: use NEW_TABULAR to control
compilation of old tabular stuff.
* src/paragraph.C (SimpleTeXOnePar): NEW_INSETS: move some #ifdef
to correct place.

View File

@ -17,7 +17,6 @@
#include "layout.h"
#include "insets/lyxinset.h"
// Prototypes
extern FD_form_table_options * fd_form_table_options;
extern FD_form_table_extra * fd_form_table_extra;
@ -42,7 +41,8 @@ bool UpdateLayoutTable(int flag)
bool update = true;
if (!current_view->available())
update = false;
#ifndef NEW_TABULAR
if (update && current_view->text->cursor.par()->table) {
char buf[12];
string pwidth, special;
@ -212,7 +212,9 @@ bool UpdateLayoutTable(int flag)
table->RotateTable());
fl_set_focus_object(fd_form_table_options->form_table_options,
fd_form_table_options->button_table_delete);
} else if (fd_form_table_options->form_table_options->visible) {
} else
#endif
if (fd_form_table_options->form_table_options->visible) {
fl_set_focus_object(fd_form_table_options->form_table_options,
fd_form_table_options->button_table_delete);
fl_hide_form(fd_form_table_options->form_table_options);
@ -257,6 +259,7 @@ void MenuLayoutTable(int flag)
void TableOptionsCB(FL_OBJECT * ob, long)
{
#ifndef NEW_TABULAR
LyXTable * table = 0;
int s, num = 0;
string special, str;
@ -438,6 +441,7 @@ void TableOptionsCB(FL_OBJECT * ob, long)
} else
UpdateLayoutTable(true);
return;
#endif
}
@ -459,6 +463,7 @@ void TableSpeCloseCB(FL_OBJECT *, long)
void SetPWidthCB(FL_OBJECT * ob, long)
{
#ifndef NEW_TABULAR
fl_set_object_label(fd_form_table_options->text_warning, "");
Confirmed = false;
if (ob == fd_form_table_options->input_column_width) {
@ -480,4 +485,5 @@ void SetPWidthCB(FL_OBJECT * ob, long)
}
MenuLayoutTable(0); // update for alignment
}
#endif
}

View File

@ -4,6 +4,7 @@
#include "LyXAction.h"
#include "toolbar.h"
#include "debug.h"
#include "lyxlex.h"
using std::endl;

View File

@ -235,8 +235,6 @@ void Buffer::fileName(string const & newfile)
// if par = 0 normal behavior
// else insert behavior
// Returns false if "\the_end" is not read for formats >= 2.13. (Asger)
#define USE_PARSE_FUNCTION 1
//#define USE_TABULAR_INSETS 1
bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
{
string tmptok;
@ -1027,7 +1025,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
par->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
++pos;
} else if (token == "\\LyXTable") {
#ifdef USE_TABULAR_INSETS
#ifdef NEW_TABULAR
Inset * inset = new InsetTabular(this);
inset->Read(this, lex);
par->InsertInset(pos, inset, font);
@ -1291,9 +1289,18 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
char c, footnoteflag = 0, depth = 0;
string tmp;
LyXParagraph::size_type i;
int j, h, ltype = 0, ltype_depth = 0,
* clen = 0, actcell = 0, actpos = 0, cell = 0, cells = 0,
currlinelen = 0;
int j;
int ltype = 0;
int ltype_depth = 0;
int * actcell = 0;
int actpos = 0;
#ifndef NEW_TABULAR
int h;
int * clen = 0;
int cell = 0;
int cells = 0;
#endif
int currlinelen = 0;
long fpos = 0;
bool ref_printed = false;

View File

@ -2629,7 +2629,8 @@ void TableApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
#ifndef NEW_TABULAR
// check for tables in tables
if (current_view->text->cursor.par()->table){
WriteAlert(_("Impossible Operation!"),
@ -2637,7 +2638,7 @@ void TableApplyCB(FL_OBJECT *, long)
_("Sorry."));
return;
}
#endif
current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
@ -2693,10 +2694,10 @@ void TableApplyCB(FL_OBJECT *, long)
0);
}
#endif
#ifndef NEW_TABULAR
current_view->text->cursor.par()->table =
new LyXTable(xsize, ysize);
#endif
Language const * lang =
current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT, lang);
@ -2766,7 +2767,10 @@ void FigureApplyCB(FL_OBJECT *, long)
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
if (fl_get_button(fd_form_figure->radio_inline)
|| current_view->text->cursor.par()->table) {
#ifndef NEW_TABULAR
|| current_view->text->cursor.par()->table
#endif
) {
InsetFig * new_inset = new InsetFig(100, 20, buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));

View File

@ -404,9 +404,11 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
case LFUN_RUNCHKTEX:
disable = lyxrc.chktex_command == "none";
break;
#ifndef NEW_TABULAR
case LFUN_LAYOUT_TABLE:
disable = ! owner->view()->text->cursor.par()->table;
break;
#endif
default:
break;
}

View File

@ -37,6 +37,10 @@ class BufferView;
// up. (Lgb)
//#define NEW_INSETS 1
// I dare you to try this one too. It is ortogonal with NEW_INSETS so you
// can try both or just one of them.
//#define NEW_TABULAR 1
/// A LyXParagraph holds all text, attributes and insets in a text paragraph
class LyXParagraph {
public:
@ -329,11 +333,12 @@ public:
///
LyXParagraph * previous;
#ifndef NEW_TABULAR
/* table stuff -- begin*/
///
LyXTable * table;
/* table stuff -- end*/
#endif
///
InsetBibKey * bibkey; // ale970302
@ -534,6 +539,7 @@ public:
void UnsetPExtraType(BufferParams const &);
///
bool linuxDocConvertChar(char c, string & sgml_string);
#ifndef NEW_TABULAR
///
void DocBookContTableRows(Buffer const *,
std::ostream &, string & extra,
@ -543,6 +549,7 @@ public:
void SimpleDocBookOneTablePar(Buffer const *,
std::ostream &, string & extra,
int & desc_on, int depth);
#endif
private:
///
struct InsetTable {
@ -623,6 +630,7 @@ private:
int & foot_count,
bool parent_is_rtl);
#endif
#ifndef NEW_TABULAR
///
bool SimpleTeXOneTablePar(Buffer const *, BufferParams const &,
std::ostream &, TexRow & texrow);
@ -631,6 +639,7 @@ private:
std::ostream &, size_type i,
int current_cell_number,
int & column, TexRow & texrow);
#endif
///
void SimpleTeXBlanks(std::ostream &, TexRow & texrow,
size_type const i,

View File

@ -909,6 +909,7 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
// Table submenu
int SubEditTable = fl_newpup(FL_ObjWin(ob));
#ifndef NEW_TABULAR
if (men->currentView()->available() &&
men->currentView()->text->cursor.par()->table &&
!tmpbuffer->isReadonly()){
@ -1005,7 +1006,9 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
// xgettext:no-c-format
fl_addtopup(SubEditTable, _("|Delete Table%x43"));
fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
} else if (men->currentView()->the_locking_inset &&
} else
#endif
if (men->currentView()->the_locking_inset &&
(men->currentView()->the_locking_inset->LyxCode() ==
Inset::TABULAR_CODE) &&
!tmpbuffer->isReadonly()) {
@ -1250,11 +1253,14 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
static_cast<InsetTabular *>
(men->currentView()->the_locking_inset);
inset->TabularFeatures(men->currentView(), choice - 32);
} else {
}
#ifndef NEW_TABULAR
else {
men->currentView()->text->
TableFeatures(men->currentView(), choice - 32);
men->currentView()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
#endif
}
break;
// version control sub-menu
@ -1632,11 +1638,12 @@ void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
if (font.latex() == LyXFont::ON)
fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
// Grey out unavailable entries
#ifndef NEW_TABULAR
if (!men->currentView()->text->cursor.par()->table)
fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
#endif
if (tmpbuffer->isReadonly()) {
fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);

View File

@ -397,8 +397,10 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
(*cit).inset->Validate(features);
}
#ifndef NEW_TABULAR
if (table && table->IsLongTable())
features.longtable = true;
#endif
if (pextra_type == PEXTRA_INDENT)
features.LyXParagraphIndent = true;
if (pextra_type == PEXTRA_FLOATFLT)
@ -411,8 +413,10 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
if (params.paragraph_separation == BufferParams::PARSEP_INDENT
&& pextra_type == LyXParagraph::PEXTRA_MINIPAGE)
features.NeedLyXMinipageIndent = true;
#ifndef NEW_TABULAR
if (table && table->NeedRotating())
features.rotating = true;
#endif
#ifndef NEW_INSETS
if (footnoteflag != NO_FOOTNOTE && footnotekind == ALGORITHM)
features.algorithm = true;
@ -1572,7 +1576,12 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
#ifndef NEW_INSETS
!IsDummy() &&
#endif
!table){
#ifndef NEW_TABULAR
!table
#else
true
#endif
){
while (Last()
&& (IsNewline(0) || IsLineSeparator(0))){
Erase(0);
@ -2388,15 +2397,17 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
default:
// we don't need it for the last paragraph!!!
if (next
&& !(
#ifndef NEW_INSETS
footnoteflag != LyXParagraph::NO_FOOTNOTE
&& !( footnoteflag != LyXParagraph::NO_FOOTNOTE
&& footnotekind != LyXParagraph::FOOTNOTE
&& footnotekind != LyXParagraph::MARGIN &&
&& footnotekind != LyXParagraph::MARGIN)
#endif
(table
#ifndef NEW_TABULAR
&& !(table
|| (par
&& par->table)))) {
&& par->table))
#endif
) {
// don't insert this if we would be adding it
// before or after a table in a float. This
// little trick is needed in order to allow
@ -2682,6 +2693,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
}
#ifndef NEW_TABULAR
// This one spits out the text of a table paragraph
bool LyXParagraph::SimpleTeXOneTablePar(Buffer const * buf,
BufferParams const & bparams,
@ -2866,8 +2878,10 @@ bool LyXParagraph::SimpleTeXOneTablePar(Buffer const * buf,
lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
return return_value;
}
#endif
#ifndef NEW_TABULAR
// This one spits out the text off ContRows in tables
bool LyXParagraph::TeXContTableRows(Buffer const * buf,
BufferParams const & bparams,
@ -2978,6 +2992,7 @@ bool LyXParagraph::TeXContTableRows(Buffer const * buf,
lyxerr[Debug::LATEX] << "TeXContTableRows...done " << this << endl;
return return_value;
}
#endif
bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
@ -3044,6 +3059,7 @@ bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
}
#ifndef NEW_TABULAR
void LyXParagraph::SimpleDocBookOneTablePar(Buffer const * buffer,
ostream & os, string & extra,
int & desc_on, int depth)
@ -3228,8 +3244,10 @@ void LyXParagraph::SimpleDocBookOneTablePar(Buffer const * buffer,
lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar...done "
<< this << endl;
}
#endif
#ifndef NEW_TABULAR
void LyXParagraph::DocBookContTableRows(Buffer const * buffer,
ostream & os, string & extra,
int & desc_on,
@ -3378,6 +3396,7 @@ void LyXParagraph::DocBookContTableRows(Buffer const * buffer,
}
lyxerr[Debug::LATEX] << "DocBookContTableRows...done " << this << endl;
}
#endif
void LyXParagraph::SimpleTeXBlanks(ostream & os, TexRow & texrow,
@ -3894,7 +3913,9 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
if (par && par->depth > depth) {
if (textclasslist.Style(bparams.textclass,
par->layout).isParagraph()
#ifndef NEW_TABULAR
&& !par->table
#endif
// Thinko!
// How to handle this? (Lgb)
//&& !suffixIs(os, "\n\n")
@ -4509,14 +4530,17 @@ LyXParagraph::getParLanguage(BufferParams const & bparams) const
#endif
else if (previous)
return previous->getParLanguage(bparams);
else
//else
return bparams.language_info;
}
bool LyXParagraph::isRightToLeftPar(BufferParams const & bparams) const
{
return lyxrc.rtl_support && !table
return lyxrc.rtl_support
#ifndef NEW_TABULAR
&& !table
#endif
&& getParLanguage(bparams)->RightToLeft();
}
@ -4598,9 +4622,9 @@ string LyXParagraph::String(Buffer const * buffer,
LyXParagraph::size_type end)
{
string s;
#ifndef NEW_TABULAR
int actcell = 0;
int cell = 1;
#ifndef NEW_TABULAR
if (table)
for (LyXParagraph::size_type i = 0; i < beg; ++i)
if (IsNewline(i)) {
@ -4633,7 +4657,9 @@ string LyXParagraph::String(Buffer const * buffer,
ost << '\0';
#endif
s += ost.str();
} else if (table && IsNewlineChar(c)) {
}
#ifndef NEW_TABULAR
else if (table && IsNewlineChar(c)) {
if (cell >= table->NumberOfCellsInRow(actcell)) {
s += '\n';
cell = 1;
@ -4643,6 +4669,7 @@ string LyXParagraph::String(Buffer const * buffer,
}
++actcell;
}
#endif
}
return s;

View File

@ -260,8 +260,11 @@ void LyXText::ComputeBidiTables(Buffer const * buf, Row * row) const
LyXParagraph::size_type pos =
(is_space && lpos + 1 <= bidi_end &&
!row->par()->IsLineSeparator(lpos + 1) &&
(!row->par()->table
|| !row->par()->IsNewline(lpos + 1)) )
(
#ifndef NEW_TABULAR
!row->par()->table ||
#endif
!row->par()->IsNewline(lpos + 1)) )
? lpos + 1 : lpos;
LyXFont font = row->par()->GetFontSettings(buf->params, pos);
bool new_rtl = font.isVisibleRightToLeft();
@ -342,14 +345,20 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
if (!lyxrc.rtl_support)
return false; // This is just for speedup
if (!bidi_InRange(pos - 1) ||
(par->table && par->IsNewline(pos-1)) )
if (!bidi_InRange(pos - 1)
#ifndef NEW_TABULAR
|| (par->table && par->IsNewline(pos-1))
#endif
)
return false;
bool rtl = bidi_level(pos - 1) % 2;
bool rtl2 = rtl;
if (pos == par->Last() ||
(par->table && par->IsNewline(pos)))
if (pos == par->Last()
#ifndef NEW_TABULAR
|| (par->table && par->IsNewline(pos))
#endif
)
rtl2 = par->isRightToLeftPar(buf->params);
else if (bidi_InRange(pos))
rtl2 = bidi_level(pos) % 2;
@ -366,8 +375,11 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
bool rtl = font.isVisibleRightToLeft();
bool rtl2 = rtl;
if (pos == par->Last() ||
(par->table && par->IsNewline(pos)))
if (pos == par->Last()
#ifndef NEW_TABULAR
|| (par->table && par->IsNewline(pos))
#endif
)
rtl2 = par->isRightToLeftPar(buf->params);
else if (bidi_InRange(pos))
rtl2 = bidi_level(pos) % 2;
@ -1921,7 +1933,11 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout)
SetHeightOfRow(bview, cursor.row());
while (!cursor.par()->Next()->table && cursor.par()->Next()->Last()
while (
#ifndef NEW_TABULAR
!cursor.par()->Next()->table &&
#endif
cursor.par()->Next()->Last()
&& cursor.par()->Next()->IsNewline(0))
cursor.par()->Next()->Erase(0);
@ -3962,8 +3978,8 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
} else if (sel_start_cursor.row() == row_ptr ||
sel_end_cursor.row() == row_ptr) {
float tmpx = x;
int cell = 0;
#ifndef NEW_TABULAR
int cell = 0;
if (row_ptr->par()->table) {
cell = NumberOfCell(row_ptr->par(), row_ptr->pos());
tmpx += row_ptr->par()->table->GetBeginningOfTextInCell(cell);
@ -4888,9 +4904,12 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x,
(!rtl && vc == last + 1 && x > tmpx + 5) ))
c = last + 1;
#endif
else if (vc == row->pos() ||
(row->par()->table
&& vc <= last && row->par()->IsNewline(vc-1)) ) {
else if (vc == row->pos()
#ifndef NEW_TABULAR
|| (row->par()->table
&& vc <= last && row->par()->IsNewline(vc-1))
#endif
) {
c = vis2log(vc);
if (bidi_level(c) % 2 == 1)
++c;
@ -4903,8 +4922,12 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x,
}
}
if (!row->par()->table && row->pos() <= last && c > last
&& row->par()->IsNewline(last)) {
if (
#ifndef NEW_TABULAR
!row->par()->table &&
#endif
row->pos() <= last && c > last
&& row->par()->IsNewline(last)) {
if (bidi_level(last) % 2 == 0)
tmpx -= SingleWidth(bview, row->par(), last);
else

View File

@ -44,12 +44,11 @@
#include "lyxrc.h"
#include "FloatList.h"
//#define USE_OLD_CUT_AND_PASTE 1
using std::copy;
using std::endl;
using std::pair;
LyXText::LyXText(BufferView * bv)
{
bv_owner = bv;
@ -627,83 +626,82 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview,
// set layout over selection and make a total rebreak of those paragraphs
void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)
{
LyXCursor
tmpcursor = cursor; /* store the current cursor */
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) {
sel_start_cursor = cursor; // dummy selection
sel_end_cursor = cursor;
}
// #ifdef USE_OLD_SET_LAYOUT
// // 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 = sel_end_cursor.par()->LastPhysicalPar()->Next();
LyXParagraph * undoendpar = endpar;
// LyXParagraph * endpar = sel_end_cursor.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.
}
// 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,
sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous,
undoendpar);
// SetUndo(Undo::EDIT,
// sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous,
// undoendpar);
/* ok we have a selection. This is always between sel_start_cursor
* and sel_end cursor */
cursor = sel_start_cursor;
// /* ok we have a selection. This is always between sel_start_cursor
// * and sel_end cursor */
// cursor = sel_start_cursor;
LyXLayout const & lyxlayout =
textclasslist.Style(bview->buffer()->params.textclass, layout);
// LyXLayout const & lyxlayout =
// textclasslist.Style(bview->buffer()->params.textclass, layout);
while (cursor.par() != sel_end_cursor.par()) {
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
cursor.par()->SetLayout(layout);
MakeFontEntriesLayoutSpecific(cursor.par());
LyXParagraph* fppar = cursor.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)
cursor.par()->SetLabelWidthString(lyxlayout.labelstring());
if (lyxlayout.labeltype != LABEL_BIBLIO
&& fppar->bibkey) {
delete fppar->bibkey;
fppar->bibkey = 0;
}
}
cursor.par() = cursor.par()->Next();
}
if (cursor.par()->footnoteflag ==
sel_start_cursor.par()->footnoteflag) {
cursor.par()->SetLayout(layout);
MakeFontEntriesLayoutSpecific(cursor.par());
#ifndef NEW_INSETS
LyXParagraph* fppar = cursor.par()->FirstPhysicalPar();
#else
LyXParagraph* fppar = cursor.par();
#endif
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)
cursor.par()->SetLabelWidthString(lyxlayout.labelstring());
if (lyxlayout.labeltype != LABEL_BIBLIO
&& fppar->bibkey) {
delete fppar->bibkey;
fppar->bibkey = 0;
}
}
#else
// while (cursor.par() != sel_end_cursor.par()) {
// if (cursor.par()->footnoteflag ==
// sel_start_cursor.par()->footnoteflag) {
// cursor.par()->SetLayout(layout);
// MakeFontEntriesLayoutSpecific(cursor.par());
// LyXParagraph* fppar = cursor.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)
// cursor.par()->SetLabelWidthString(lyxlayout.labelstring());
// if (lyxlayout.labeltype != LABEL_BIBLIO
// && fppar->bibkey) {
// delete fppar->bibkey;
// fppar->bibkey = 0;
// }
// }
// cursor.par() = cursor.par()->Next();
// }
// if (cursor.par()->footnoteflag ==
// sel_start_cursor.par()->footnoteflag) {
// cursor.par()->SetLayout(layout);
// MakeFontEntriesLayoutSpecific(cursor.par());
// #ifndef NEW_INSETS
// LyXParagraph* fppar = cursor.par()->FirstPhysicalPar();
// #else
// LyXParagraph* fppar = cursor.par();
// #endif
// 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)
// cursor.par()->SetLabelWidthString(lyxlayout.labelstring());
// if (lyxlayout.labeltype != LABEL_BIBLIO
// && fppar->bibkey) {
// delete fppar->bibkey;
// fppar->bibkey = 0;
// }
// }
// #else
// if there is no selection just set the layout
// of the current paragraph */
if (!selection) {
@ -713,11 +711,11 @@ void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)
LyXParagraph *
endpar = SetLayout(bview, cursor, sel_start_cursor,
sel_end_cursor, layout);
#endif
//#endif
RedoParagraphs(bview, sel_start_cursor, endpar);
// we have to reset the selection, because the
// geometry could have changed */
// geometry could have changed
SetCursor(bview, sel_start_cursor.par(),
sel_start_cursor.pos(), false);
sel_cursor = cursor;
@ -2554,7 +2552,6 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
LyXParagraph * par = cursor.par();
LyXParagraph::size_type pos = cursor.pos();
LyXParagraph::size_type a = 0;
int cell = 0;
LyXParagraph * endpar = cursor.par()->Next();
SetCursorParUndo(bview->buffer());
@ -2574,7 +2571,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
&& pos && par->GetChar(pos - 1)!= ' ') {
par->InsertChar(pos, ' ', current_font);
++pos;
#ifndef NEW_TABLAR
#ifndef NEW_TABULAR
} else if (par->table) {
if (str[i] == '\t') {
while((pos < par->size()) &&
@ -2631,7 +2628,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
(par->GetChar(pos) != LyXParagraph::META_NEWLINE))
++pos;
++pos;
cell = NumberOfCell(par, pos);
int cell = NumberOfCell(par, pos);
while((pos < par->size()) &&
!(par->table->IsFirstCell(cell))) {
@ -2683,14 +2680,24 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
void LyXText::InsertStringB(BufferView * bview, string const & s)
{
string str(s);
#ifndef NEW_TABULAR
LyXParagraph * par = cursor.par();
#endif
string::size_type i = 1;
while (i < str.length()) {
if (str[i] == '\t' && !par->table)
if (str[i] == '\t'
#ifndef NEW_TABULAR
&& !par->table
#endif
)
str[i] = ' ';
if (str[i] == ' ' && i + 1 < str.length() && str[i + 1] == ' ')
str[i] = 13;
if (str[i] == '\n' && i + 1 < str.length() && !par->table){
if (str[i] == '\n' && i + 1 < str.length()
#ifndef NEW_TABULAR
&& !par->table
#endif
){
if (str[i + 1] != '\n') {
if (str[i - 1] != ' ')
str[i] = ' ';
@ -2950,8 +2957,11 @@ void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par,
cursor_vpos = (row->par()->isRightToLeftPar(bview->buffer()->params))
? row->pos() : last + 1;
else if (pos > row->pos() &&
(pos > last || boundary ||
(row->par()->table && row->par()->IsNewline(pos))))
(pos > last || boundary
#ifndef NEW_TABULAR
|| (row->par()->table && row->par()->IsNewline(pos))
#endif
))
/// Place cursor after char at (logical) position pos - 1
cursor_vpos = (bidi_level(pos - 1) % 2 == 0)
? log2vis(pos - 1) + 1 : log2vis(pos - 1);
@ -3040,8 +3050,11 @@ void LyXText::SetCurrentFont(BufferView * bview) const
--pos;
if (pos > 0) {
if (pos == cursor.par()->Last() ||
(cursor.par()->table && cursor.par()->IsNewline(pos)))
if (pos == cursor.par()->Last()
#ifndef NEW_TABULAR
|| (cursor.par()->table && cursor.par()->IsNewline(pos))
#endif
)
--pos;
else if (cursor.par()->IsSeparator(pos)) {
if (pos > cursor.row()->pos() &&
@ -3155,7 +3168,11 @@ void LyXText::CursorRight(BufferView * bview, bool internal) const
void LyXText::CursorRightIntern(BufferView * bview, bool internal) const
{
if (!internal && cursor.boundary() &&
(!cursor.par()->table || !cursor.par()->IsNewline(cursor.pos())))
(
#ifndef NEW_TABULAR
!cursor.par()->table ||
#endif
!cursor.par()->IsNewline(cursor.pos())))
SetCursor(bview, cursor.par(), cursor.pos(), true, false);
else if (cursor.pos() < cursor.par()->Last()) {
SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false);

View File

@ -41,6 +41,40 @@ extern char const ** get_pixmap_from_symbol(char const * arg, int, int);
extern LyXAction lyxaction;
Toolbar::toolbarItem::toolbarItem()
{
action = LFUN_NOACTION;
icon = 0;
}
void Toolbar::toolbarItem::clean()
{
if (icon) {
fl_delete_object(icon);
fl_free_object(icon);
icon = 0;
}
}
Toolbar::toolbarItem::~toolbarItem()
{
clean();
}
Toolbar::toolbarItem &
Toolbar::toolbarItem::operator=(Toolbar::toolbarItem const & ti)
{
// do we have to check icon and IsBitmap too?
action = ti.action;
icon = 0; // locally we need to get the icon anew
return *this;
}
Toolbar::Toolbar(LyXView * o, int x, int y)
: owner(o), sxpos(x), sypos(y)
{

View File

@ -20,9 +20,11 @@
#include <vector>
#include FORMS_H_LOCATION
#include "lyxfunc.h"
#include "commandtags.h"
#include "combox.h"
class LyXView;
/** The LyX toolbar class
This class {\em is} the LyX toolbar, and is not likely to be enhanced
further until we begin the move to Qt. We will probably have to make our
@ -92,30 +94,13 @@ private:
///
FL_OBJECT * icon;
///
toolbarItem() {
action = LFUN_NOACTION;
icon = 0;
}
toolbarItem();
///
void clean() {
if (icon) {
fl_delete_object(icon);
fl_free_object(icon);
icon = 0;
}
}
void clean();
///
~toolbarItem() {
clean();
}
toolbarItem & operator=(const toolbarItem & ti) {
// do we have to check icon and IsBitmap too?
action = ti.action;
icon = 0; // locally we need to get the icon anew
return *this;
}
~toolbarItem();
///
toolbarItem & operator=(toolbarItem const & ti);
};
/// typedef to simplify things
@ -152,12 +137,7 @@ private:
/** more...
*/
void reset();// {
// toollist = 0;
// cleaned = false;
//
// lightReset();
// }
void reset();
/** more...
*/