* Copyright 1995 Matthias Ettrich
* Copyright 1995-1999 The LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
#include <cctype>
#include FORMS_H_LOCATION
+
#ifdef __GNUG__
#pragma implementation "lyxtext.h"
-#pragma implementation "undo.h"
#endif
#include "LString.h"
#include "lyxtext.h"
#include "gettext.h"
-extern MiniBuffer *minibuffer;
+using std::copy;
+
+extern MiniBuffer * minibuffer;
// Constructor
-LyXText::LyXText(int pw, Buffer *p)
+LyXText::LyXText(int pw, Buffer * p)
{
firstrow = 0;
lastrow = 0;
parameters = &p->params;
params = p;
number_of_rows = 0;
- refresh_y= 0;
+ refresh_y = 0;
status = LyXText::UNCHANGED;
- LyXParagraph *par = p->paragraph;
+ LyXParagraph * par = p->paragraph;
current_font = GetFont(par, 0);
height = 0;
LyXText::~LyXText()
{
// Delete all rows, this does not touch the paragraphs!
- Row *tmprow = firstrow;
+ Row * tmprow = firstrow;
while (firstrow) {
tmprow = firstrow->next;
delete firstrow;
// smaller. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
-LyXFont LyXText::GetFont(LyXParagraph* par, int pos)
+LyXFont LyXText::GetFont(LyXParagraph * par,
+ LyXParagraph::size_type pos)
{
- LyXLayout *layout =
- lyxstyle.Style(parameters->textclass, par->GetLayout());
+ LyXLayout const & layout =
+ textclasslist.Style(parameters->textclass, par->GetLayout());
char par_depth = par->GetDepth();
// We specialize the 95% common case:
if (par->footnoteflag == LyXParagraph::NO_FOOTNOTE && !par_depth) {
if (pos >= 0){
// 95% goes here
- if (layout->labeltype == LABEL_MANUAL
+ if (layout.labeltype == LABEL_MANUAL
&& pos < BeginningOfMainBody(par)) {
// 1% goes here
return par->GetFontSettings(pos).
- realize(layout->reslabelfont);
+ realize(layout.reslabelfont);
} else
return par->GetFontSettings(pos).
- realize(layout->resfont);
+ realize(layout.resfont);
} else {
// 5% goes here.
// process layoutfont for pos == -1 and labelfont for pos < -1
if (pos == -1)
- return layout->resfont;
+ return layout.resfont;
else
- return layout->reslabelfont;
+ return layout.reslabelfont;
}
}
// 95% goes here
if (pos < BeginningOfMainBody(par)) {
// 1% goes here
- layoutfont = layout->labelfont;
+ layoutfont = layout.labelfont;
} else {
// 99% goes here
- layoutfont = layout->font;
+ layoutfont = layout.font;
}
tmpfont = par->GetFontSettings(pos);
tmpfont.realize(layoutfont);
- } else{
+ } else {
// 5% goes here.
// process layoutfont for pos == -1 and labelfont for pos < -1
if (pos == -1)
- tmpfont = layout->font;
+ tmpfont = layout.font;
else
- tmpfont = layout->labelfont;
+ tmpfont = layout.labelfont;
}
// Resolve against environment font information
- //if (par->GetDepth()){ // already in while condition
- while (par && par_depth && !tmpfont.resolved()) {
- par = par->DepthHook(par_depth - 1);
- if (par) {
- tmpfont.realize(lyxstyle.
- Style(parameters->textclass,
- par->GetLayout())->font);
- par_depth = par->GetDepth();
- }
+ while (par && par_depth && !tmpfont.resolved()) {
+ par = par->DepthHook(par_depth - 1);
+ if (par) {
+ tmpfont.realize(textclasslist.
+ Style(parameters->textclass,
+ par->GetLayout()).font);
+ par_depth = par->GetDepth();
}
- //}
+ }
- tmpfont.realize(lyxstyle.TextClass(parameters->textclass)->defaultfont);
+ tmpfont.realize(textclasslist.TextClass(parameters->textclass).defaultfont());
// Cosmetic improvement: If this is an open footnote, make the font
// smaller.
}
-void LyXText::SetCharFont(LyXParagraph *par, int pos, LyXFont font)
+void LyXText::SetCharFont(LyXParagraph * par,
+ LyXParagraph::size_type pos,
+ LyXFont font)
{
/* let the insets convert their font */
- if (par->GetChar(pos) == LYX_META_INSET) {
+ if (par->GetChar(pos) == LyXParagraph::META_INSET) {
if (par->GetInset(pos))
font = par->GetInset(pos)->ConvertFont(font);
}
- LyXLayout *layout = lyxstyle.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(parameters->textclass,
par->GetLayout());
// Get concrete layout font to reduce against
LyXFont layoutfont;
if (pos < BeginningOfMainBody(par))
- layoutfont = layout->labelfont;
+ layoutfont = layout.labelfont;
else
- layoutfont = layout->font;
+ layoutfont = layout.font;
// Realize against environment font information
if (par->GetDepth()){
while (!layoutfont.resolved() && tp && tp->GetDepth()) {
tp = tp->DepthHook(tp->GetDepth()-1);
if (tp)
- layoutfont.realize(lyxstyle.
+ layoutfont.realize(textclasslist.
Style(parameters->textclass,
- tp->GetLayout())->font);
+ tp->GetLayout()).font);
}
}
- layoutfont.realize(lyxstyle.TextClass(parameters->textclass)->defaultfont);
+ layoutfont.realize(textclasslist.TextClass(parameters->textclass).defaultfont());
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
/* inserts a new row behind the specified row, increments
* the touched counters */
-void LyXText::InsertRow(Row *row, LyXParagraph *par, int pos)
+void LyXText::InsertRow(Row * row, LyXParagraph * par,
+ LyXParagraph::size_type pos)
{
- Row *tmprow = new Row;
+ Row * tmprow = new Row;
if (!row) {
tmprow->previous = 0;
tmprow->next = firstrow;
/* removes the row and reset the touched counters */
-void LyXText::RemoveRow(Row *row)
+void LyXText::RemoveRow(Row * row)
{
/* this must not happen before the currentrow for clear reasons.
so the trick is just to set the current row onto the previous
height -= row->height; /* the text becomes smaller */
delete row;
- number_of_rows--; /* one row less */
+ --number_of_rows; /* one row less */
}
+
/* remove all following rows of the paragraph of the specified row. */
-void LyXText::RemoveParagraph(Row *row)
+void LyXText::RemoveParagraph(Row * row)
{
- LyXParagraph *tmppar;
- Row *tmprow;
+ Row * tmprow;
- tmppar = row->par;
+ LyXParagraph * tmppar = row->par;
row = row->next;
while (row && row->par == tmppar) {
/* insert the specified paragraph behind the specified row */
-void LyXText::InsertParagraph(LyXParagraph *par, Row *row)
+void LyXText::InsertParagraph(LyXParagraph * par, Row * row)
{
InsertRow(row, par, 0); /* insert a new row, starting
* at postition 0 */
void LyXText::ToggleFootnote()
{
- LyXParagraph *par;
-
- par = cursor.par->ParFromPos(cursor.pos);
+ LyXParagraph * par = cursor.par->ParFromPos(cursor.pos);
if (par->next && par->next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){
OpenFootnote();
minibuffer->Set(_("Opened float"));
void LyXText::OpenStuff()
{
if (cursor.pos == 0 && cursor.par->bibkey){
- cursor.par->bibkey->Edit(0,0);
+ cursor.par->bibkey->Edit(0, 0);
}
else if (cursor.pos < cursor.par->Last()
- && cursor.par->GetChar(cursor.pos) == LYX_META_INSET
+ && cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
&& cursor.par->GetInset(cursor.pos)->Editable()) {
minibuffer->Set(cursor.par->GetInset(cursor.pos)->EditMessage());
if (cursor.par->GetInset(cursor.pos)->Editable() != 2)
SetCursorParUndo();
- cursor.par->GetInset(cursor.pos)->Edit(0,0);
+ cursor.par->GetInset(cursor.pos)->Edit(0, 0);
}
else {
ToggleFootnote();
void LyXText::CloseFootnote()
{
- LyXParagraph *par, *endpar,*tmppar;
- Row *row;
+ LyXParagraph * endpar, * tmppar;
+ Row * row;
- par = cursor.par->ParFromPos(cursor.pos);
+ LyXParagraph * par = cursor.par->ParFromPos(cursor.pos);
/* if the cursor is not in an open footnote, or
* there is no open footnote in this paragraph, just return. */
/* ok, move the cursor right before the footnote */
/* just a little faster than using CursorRight() */
- for (cursor.pos=0; cursor.par->ParFromPos(cursor.pos)!=par; cursor.pos++);
+ for (cursor.pos = 0; cursor.par->ParFromPos(cursor.pos)!= par; cursor.pos++);
/* now the cursor is at the beginning of the physical par */
- SetCursor(cursor.par, cursor.pos + cursor.par->ParFromPos(cursor.pos)->last);
+ SetCursor(cursor.par,
+ cursor.pos +
+ cursor.par->ParFromPos(cursor.pos)->text.size());
}
else {
/* we are in a footnote, so let us move at the beginning */
- /* while (cursor.par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
- cursor.par = cursor.par->Previous();
-
- SetCursor(cursor.par, cursor.par->Last()); */
/* this is just faster than using just CursorLeft() */
tmppar = cursor.par;
tmppar->CloseFootnote(cursor.pos);
- /* set the dimensions of the cursor row */
- /* row->fill = Fill(row, paperwidth);
- SetHeightOfRow(row); */
-
while (tmppar != endpar) {
RemoveRow(row->next);
if (row->next)
/* used in setlayout */
// Asger is not sure we want to do this...
-void LyXText::MakeFontEntriesLayoutSpecific(LyXParagraph *par)
+void LyXText::MakeFontEntriesLayoutSpecific(LyXParagraph * par)
{
LyXFont layoutfont, tmpfont;
- int pos;
-
- LyXLayout* layout = lyxstyle.Style(parameters->textclass, par->GetLayout());
-
- for (pos = 0; pos < par->Last(); pos++) {
+ LyXLayout const & layout = textclasslist.Style(parameters->textclass, par->GetLayout());
+
+ for (LyXParagraph::size_type pos = 0;
+ pos < par->Last(); ++pos) {
if (pos < BeginningOfMainBody(par))
- layoutfont = layout->labelfont;
+ layoutfont = layout.labelfont;
else
- layoutfont = layout->font;
+ layoutfont = layout.font;
tmpfont = par->GetFontSettings(pos);
tmpfont.reduce(layoutfont);
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->depth = 0;
endpar = endpar->LastPhysicalPar()->Next();
undoendpar = endpar;
}
* and sel_end cursor */
cursor = sel_start_cursor;
- LyXLayout * lyxlayout = lyxstyle.Style(parameters->textclass, layout);
+ LyXLayout const & lyxlayout = textclasslist.Style(parameters->textclass, layout);
while (cursor.par != sel_end_cursor.par) {
if (cursor.par->footnoteflag ==
cursor.par->SetLayout(layout);
MakeFontEntriesLayoutSpecific(cursor.par);
LyXParagraph* fppar = cursor.par->FirstPhysicalPar();
- fppar->added_space_top = lyxlayout->fill_top ?
+ fppar->added_space_top = lyxlayout.fill_top ?
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- fppar->added_space_bottom = lyxlayout->fill_bottom ?
+ 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
+ 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->SetLayout(layout);
MakeFontEntriesLayoutSpecific(cursor.par);
LyXParagraph* fppar = cursor.par->FirstPhysicalPar();
- fppar->added_space_top = lyxlayout->fill_top ?
+ fppar->added_space_top = lyxlayout.fill_top ?
VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
- fppar->added_space_bottom = lyxlayout->fill_bottom ?
+ 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
+ if (lyxlayout.margintype == MARGIN_MANUAL)
+ cursor.par->SetLabelWidthString(lyxlayout.labelstring());
+ if (lyxlayout.labeltype != LABEL_BIBLIO
&& fppar->bibkey) {
delete fppar->bibkey;
fppar->bibkey = 0;
}
// We end at the next paragraph with depth 0
- 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()) {
// NOTE: you can't change the depth of a bibliography entry
if (cursor.par->footnoteflag ==
sel_start_cursor.par->footnoteflag
- && lyxstyle.Style(parameters->textclass,
+ && textclasslist.Style(parameters->textclass,
cursor.par->GetLayout()
- )->labeltype != LABEL_BIBLIO) {
+ ).labeltype != LABEL_BIBLIO) {
LyXParagraph * prev = cursor.par->FirstPhysicalPar()->Previous();
if (prev
&& (prev->GetDepth() - cursor.par->GetDepth() > 0
|| (prev->GetDepth() == cursor.par->GetDepth()
- && lyxstyle.Style(parameters->textclass,
- prev->GetLayout())->isEnvironment()))) {
+ && textclasslist.Style(parameters->textclass,
+ prev->GetLayout()).isEnvironment()))) {
cursor.par->FirstPhysicalPar()->depth++;
anything_changed = true;
}
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()) {
layoutfont = GetFont(cursor.par, -2);
else
layoutfont = GetFont(cursor.par, -1);
-
// Update current font
- real_current_font.update(font,toggleall);
+ real_current_font.update(font, toggleall);
// Reduce to implicit settings
current_font = real_current_font;
== sel_start_cursor.par->footnoteflag) { /* an open footnote
* should behave
* like a closed */
- LyXFont newfont = GetFont(cursor.par,cursor.pos);
- newfont.update(font,toggleall);
+ LyXFont newfont = GetFont(cursor.par, cursor.pos);
+ newfont.update(font, toggleall);
SetCharFont(cursor.par, cursor.pos, newfont);
cursor.pos++;
} else {
void LyXText::RedoHeightOfParagraph(LyXCursor cursor)
{
- Row *tmprow;
- LyXParagraph *first_phys_par;
- long y;
-
- tmprow = cursor.row;
-
- y = cursor.y - tmprow->baseline;
+ Row * tmprow = cursor.row;
+ long y = cursor.y - tmprow->baseline;
+
SetHeightOfRow(tmprow);
- first_phys_par = tmprow->par->FirstPhysicalPar();
+ LyXParagraph * first_phys_par = tmprow->par->FirstPhysicalPar();
/* find the first row of the paragraph */
if (first_phys_par != tmprow->par)
while (tmprow->previous && tmprow->previous->par != first_phys_par) {
void LyXText::RedoDrawingOfParagraph(LyXCursor cursor)
{
- Row *tmprow;
- LyXParagraph *first_phys_par;
- long y;
+ Row * tmprow = cursor.row;
- tmprow = cursor.row;
-
- y = cursor.y - tmprow->baseline;
+ long y = cursor.y - tmprow->baseline;
SetHeightOfRow(tmprow);
- first_phys_par = tmprow->par->FirstPhysicalPar();
+ LyXParagraph * first_phys_par = tmprow->par->FirstPhysicalPar();
/* find the first row of the paragraph */
if (first_phys_par != tmprow->par)
while (tmprow->previous && tmprow->previous->par != first_phys_par) {
/* deletes and inserts again all paragaphs between the cursor
* and the specified par
* This function is needed after SetLayout and SetFont etc. */
-void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph *endpar)
+void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph * endpar)
{
- Row *tmprow, *tmprow2;
- LyXParagraph *tmppar, *first_phys_par;
- long y;
+ Row * tmprow2;
+ LyXParagraph * tmppar, * first_phys_par;
- tmprow = cursor.row;
+ Row * tmprow = cursor.row;
- y = cursor.y - tmprow->baseline;
+ long y = cursor.y - tmprow->baseline;
if (!tmprow->previous){
first_phys_par = FirstParagraph(); // a trick/hack for UNDO
if (tmprow && tmprow->next)
SetHeightOfRow(tmprow->next);
-
- /* restore the correct refresh row */
-/* if (refresh_row)
- refresh_row = refresh_row->next;
- else
- refresh_row = firstrow;*/
}
/* returns a pointer to the row near the specified y-coordinate
* (relative to the whole text). y is set to the real beginning
* of this row */
-Row* LyXText::GetRowNearY(long& y)
+Row * LyXText::GetRowNearY(long & y)
{
- Row* tmprow;
+ Row * tmprow;
long tmpy;
if (currentrow){
tmpy = 0;
}
- if (tmpy<=y)
+ if (tmpy<= y)
while (tmprow->next && tmpy + tmprow->height <= y) {
tmpy += tmprow->height;
tmprow = tmprow->next;
int implicitSelection = SelectWordWhenUnderCursor();
// Set font
- SetFont(font,toggleall);
+ SetFont(font, toggleall);
//minibuffer->Set(_("Font style changed"));
/* Implicit selections are cleared afterwards and cursor is set to the
}
-int LyXText::BeginningOfMainBody(LyXParagraph *par)
+LyXParagraph::size_type LyXText::BeginningOfMainBody(LyXParagraph * par) const
{
- if (lyxstyle.Style(parameters->textclass, par->GetLayout())->labeltype != LABEL_MANUAL)
+ if (textclasslist.Style(parameters->textclass, par->GetLayout()).labeltype != LABEL_MANUAL)
return 0;
else
return par->BeginningOfMainBody();
* in the selection, otherwise just the environment you are in */
void LyXText::MeltFootnoteEnvironment()
{
- LyXParagraph *tmppar, *firsttmppar;
+ LyXParagraph * tmppar, * firsttmppar;
ClearSelection();
firsttmppar = cursor.par->ParFromPos(cursor.pos);
tmppar = firsttmppar;
/* tmppar is now the paragraph right before the footnote */
-
- char first_footnote_par_is_not_empty = tmppar->next->last;
+
+ char first_footnote_par_is_not_empty = tmppar->next->text.size();
while (tmppar->next && tmppar->next->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
tmppar = tmppar->next; /* I use next instead of Next(),
tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE;
/* remember the captions and empty paragraphs */
- if ((lyxstyle.Style(parameters->textclass,
- tmppar->GetLayout())->labeltype == LABEL_SENSITIVE)
+ if ((textclasslist.Style(parameters->textclass,
+ tmppar->GetLayout()).labeltype == LABEL_SENSITIVE)
|| !tmppar->Last())
tmppar->SetLayout(0);
}
* (only if the previous par and the footnotepar are not empty!) */
if ((!firsttmppar->next->GetLayout() && !firsttmppar->next->table)
|| firsttmppar->HasSameLayout(firsttmppar->next)) {
- if (firsttmppar->last
- && !firsttmppar->IsSeparator(firsttmppar->last - 1)
+ if (firsttmppar->text.size()
+ && !firsttmppar->IsSeparator(firsttmppar->text.size() - 1)
&& first_footnote_par_is_not_empty) {
firsttmppar->next->InsertChar(0, ' ');
}
SetCursor(cursor.par, cursor.pos);
/* sometimes it can happen, that there is a counter change */
- Row *row = cursor.row;
+ Row * row = cursor.row;
while (row->next && row->par != tmppar && row->next->par != tmppar)
row = row->next;
UpdateCounters(row);
void LyXText::SetParagraph(bool line_top, bool line_bottom,
bool pagebreak_top, bool pagebreak_bottom,
VSpace space_top, VSpace space_bottom,
- char align,
+ LyXAlignment align,
string labelwidthstring,
bool noindent)
{
- LyXCursor tmpcursor;
- tmpcursor = cursor;
- LyXParagraph *tmppar;
+ LyXCursor tmpcursor = cursor;
if (!selection) {
sel_start_cursor = cursor;
sel_end_cursor = cursor;
}
// make sure that the depth behind the selection are restored, too
- 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()) {
undoendpar);
- tmppar = sel_end_cursor.par;
- while (tmppar != sel_start_cursor.par->FirstPhysicalPar()->Previous())
- {
- SetCursor(tmppar->FirstPhysicalPar(), 0);
- status = LyXText::NEED_MORE_REFRESH;
- refresh_row = cursor.row;
- refresh_y = cursor.y - cursor.row->baseline;
- if (cursor.par->footnoteflag ==
- sel_start_cursor.par->footnoteflag) {
- cursor.par->line_top = line_top;
- cursor.par->line_bottom = line_bottom;
- cursor.par->pagebreak_top = pagebreak_top;
- cursor.par->pagebreak_bottom = pagebreak_bottom;
- cursor.par->added_space_top = space_top;
- cursor.par->added_space_bottom = space_bottom;
- /* does the layout allow the new alignment? */
- if (align == LYX_ALIGN_LAYOUT)
- align = lyxstyle.Style(parameters->textclass, cursor.par->GetLayout())->align;
- if (align & lyxstyle.Style(parameters->textclass, cursor.par->GetLayout())->alignpossible) {
- if (align == lyxstyle.Style(parameters->textclass, cursor.par->GetLayout())->align)
- cursor.par->align = LYX_ALIGN_LAYOUT;
- else
- cursor.par->align = align;
- }
- cursor.par->SetLabelWidthString(labelwidthstring);
- cursor.par->noindent = noindent;
+ LyXParagraph * tmppar = sel_end_cursor.par;
+ while (tmppar != sel_start_cursor.par->FirstPhysicalPar()->Previous()){
+ SetCursor(tmppar->FirstPhysicalPar(), 0);
+ status = LyXText::NEED_MORE_REFRESH;
+ refresh_row = cursor.row;
+ refresh_y = cursor.y - cursor.row->baseline;
+ if (cursor.par->footnoteflag ==
+ sel_start_cursor.par->footnoteflag) {
+ cursor.par->line_top = line_top;
+ cursor.par->line_bottom = line_bottom;
+ cursor.par->pagebreak_top = pagebreak_top;
+ cursor.par->pagebreak_bottom = pagebreak_bottom;
+ cursor.par->added_space_top = space_top;
+ cursor.par->added_space_bottom = space_bottom;
+ /* does the layout allow the new alignment? */
+ if (align == LYX_ALIGN_LAYOUT)
+ align = textclasslist
+ .Style(parameters->textclass,
+ cursor.par->GetLayout()).align;
+ if (align & textclasslist
+ .Style(parameters->textclass,
+ cursor.par->GetLayout()).alignpossible) {
+ if (align == textclasslist
+ .Style(parameters->textclass,
+ cursor.par->GetLayout()).align)
+ cursor.par->align = LYX_ALIGN_LAYOUT;
+ else
+ cursor.par->align = align;
}
-
- /*
- tmprow = cursor.row;
- while (tmprow->next && tmprow->next->par->previous != cursor.par->LastPhysicalPar())
- tmprow = tmprow->next;
- SetHeightOfRow(tmprow);
- SetHeightOfRow(cursor.row); */
- tmppar = cursor.par->FirstPhysicalPar()->Previous();
+ cursor.par->SetLabelWidthString(labelwidthstring);
+ cursor.par->noindent = noindent;
}
+
+ tmppar = cursor.par->FirstPhysicalPar()->Previous();
+ }
RedoParagraphs(sel_start_cursor, endpar);
void LyXText::SetParagraphExtraOpt(int type,
- const char *width,
- const char *widthp,
+ char const * width,
+ char const * widthp,
int alignment, bool hfill,
bool start_minipage)
{
- LyXCursor tmpcursor;
- tmpcursor = cursor;
- LyXParagraph *tmppar;
+ LyXCursor tmpcursor = cursor;
+ LyXParagraph * tmppar;
if (!selection) {
sel_start_cursor = cursor;
sel_end_cursor = cursor;
}
// make sure that the depth behind the selection are restored, too
- 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()) {
refresh_y = cursor.y - cursor.row->baseline;
if (cursor.par->footnoteflag ==
sel_start_cursor.par->footnoteflag) {
- if (type == PEXTRA_NONE) {
- if (cursor.par->pextra_type != PEXTRA_NONE) {
+ if (type == LyXParagraph::PEXTRA_NONE) {
+ if (cursor.par->pextra_type != LyXParagraph::PEXTRA_NONE) {
cursor.par->UnsetPExtraType();
- cursor.par->pextra_type=PEXTRA_NONE;
+ cursor.par->pextra_type = LyXParagraph::PEXTRA_NONE;
}
} else {
- cursor.par->SetPExtraType(type,width,widthp);
+ cursor.par->SetPExtraType(type, width, widthp);
cursor.par->pextra_hfill = hfill;
cursor.par->pextra_start_minipage = start_minipage;
cursor.par->pextra_alignment = alignment;
}
-static char* alphaCounter(int n){
+static char const * alphaCounter(int n){
static char result[2];
result[1] = 0;
if (n == 0)
return "";
else {
- result[0] = 64+n;
+ result[0] = 64 + n;
if (n > 26)
return "??";
}
/* set the counter of a paragraph. This includes the labels */
-void LyXText::SetCounter(LyXParagraph *par)
+void LyXText::SetCounter(LyXParagraph * par)
{
int i;
/* this is only relevant for the beginning of paragraph */
par = par->FirstPhysicalPar();
- LyXLayout* layout = lyxstyle.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(parameters->textclass,
par->GetLayout());
- LyXTextClass *textclass = lyxstyle.TextClass(parameters->textclass);
+ LyXTextClass const & textclass = textclasslist.TextClass(parameters->textclass);
/* copy the prev-counters to this one, unless this is the start of a
footnote or of a bibliography or the very first paragraph */
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
- && !(lyxstyle.Style(parameters->textclass,
+ && !(textclasslist.Style(parameters->textclass,
par->Previous()->GetLayout()
- )->labeltype != LABEL_BIBLIO
- && layout->labeltype == LABEL_BIBLIO)) {
- for (i=0; i<10; i++) {
+ ).labeltype != LABEL_BIBLIO
+ && layout.labeltype == LABEL_BIBLIO)) {
+ for (i = 0; i<10; i++) {
par->setCounter(i, par->Previous()->GetFirstCounter(i));
}
par->appendix = par->Previous()->FirstPhysicalPar()->appendix;
if (!par->appendix && par->start_of_appendix){
par->appendix = true;
- for (i=0; i<10; i++) {
+ for (i = 0; i<10; i++) {
par->setCounter(i, 0);
}
}
par->itemdepth = par->Previous()->FirstPhysicalPar()->itemdepth;
}
else {
- for (i=0; i<10; i++) {
+ for (i = 0; i<10; i++) {
par->setCounter(i, 0);
}
par->appendix = par->start_of_appendix;
&& par->Previous()
&& par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
&& (par->PreviousBeforeFootnote()
- && lyxstyle.Style(parameters->textclass,
+ && textclasslist.Style(parameters->textclass,
par->PreviousBeforeFootnote()->GetLayout()
- )->labeltype >= LABEL_COUNTER_ENUMI)) {
+ ).labeltype >= LABEL_COUNTER_ENUMI)) {
// Any itemize or enumerate environment in a marginnote
// that is embedded in an itemize or enumerate
// paragraph is seen by LaTeX as being at a deeper
*/
if (par->Previous()
&& par->Previous()->GetDepth() < par->GetDepth()
- && lyxstyle.Style(parameters->textclass,
+ && textclasslist.Style(parameters->textclass,
par->Previous()->GetLayout()
- )->labeltype == LABEL_COUNTER_ENUMI
+ ).labeltype == LABEL_COUNTER_ENUMI
&& par->enumdepth < 3
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
- && layout->labeltype != LABEL_BIBLIO) {
+ && layout.labeltype != LABEL_BIBLIO) {
par->enumdepth++;
}
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
- && layout->labeltype != LABEL_BIBLIO) {
+ && layout.labeltype != LABEL_BIBLIO) {
par->enumdepth = par->DepthHook(par->GetDepth())->enumdepth;
par->setCounter(6 + par->enumdepth,
par->DepthHook(par->GetDepth())->getCounter(6 + par->enumdepth));
/* reset the counters.
* A depth change is like a breaking layout
*/
- for (i=6 + par->enumdepth + 1; i<10;i++)
+ for (i = 6 + par->enumdepth + 1; i<10;i++)
par->setCounter(i, 0);
}
if (!par->labelstring.empty()) {
- par->labelstring.erase();
+ par->labelstring.clear();
}
- if (layout->margintype == MARGIN_MANUAL) {
+ if (layout.margintype == MARGIN_MANUAL) {
if (par->labelwidthstring.empty()) {
- par->SetLabelWidthString(layout->labelstring);
+ par->SetLabelWidthString(layout.labelstring());
}
}
else {
}
/* is it a layout that has an automatic label ? */
- if (layout->labeltype >= LABEL_FIRST_COUNTER) {
+ if (layout.labeltype >= LABEL_FIRST_COUNTER) {
- i = layout->labeltype - LABEL_FIRST_COUNTER;
- if (i>=0 && i<=parameters->secnumdepth) {
+ i = layout.labeltype - LABEL_FIRST_COUNTER;
+ if (i >= 0 && i<= parameters->secnumdepth) {
par->incCounter(i); // increment the counter
char * s = new char[50];
// Is there a label? Useful for Chapter layout
if (!par->appendix){
- if (!layout->labelstring.empty())
- par->labelstring = layout->labelstring;
+ if (!layout.labelstring().empty())
+ par->labelstring = layout.labelstring();
else
- par->labelstring.erase();
+ par->labelstring.clear();
}
else {
- if (!layout->labelstring_appendix.empty())
- par->labelstring = layout->labelstring_appendix;
+ if (!layout.labelstring_appendix().empty())
+ par->labelstring = layout.labelstring_appendix();
else
- par->labelstring.erase();
+ par->labelstring.clear();
}
if (!par->appendix){
switch (2 * LABEL_FIRST_COUNTER -
- textclass->maxcounter + i) {
+ textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
sprintf(s, "%d",
par->getCounter(i));
}
}
else {
- switch (2 * LABEL_FIRST_COUNTER - textclass->maxcounter+ i) {
+ switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
sprintf(s, "%s",
alphaCounter(par->getCounter(i)));
/* reset the following counters */
par->setCounter(i, 0);
}
- } else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
+ } else if (layout.labeltype < LABEL_COUNTER_ENUMI) {
for (i++; i<10; i++) {
/* reset the following counters */
par->setCounter(i, 0);
}
- } else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
+ } else if (layout.labeltype == LABEL_COUNTER_ENUMI) {
par->incCounter(i + par->enumdepth);
char * s = new char[25];
int number = par->getCounter(i + par->enumdepth);
par->setCounter(i, 0); /* reset the following counters */
}
- } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
+ } else if (layout.labeltype == LABEL_BIBLIO) {// ale970302
i = LABEL_COUNTER_ENUMI - LABEL_FIRST_COUNTER + par->enumdepth;
par->incCounter(i);
int number = par->getCounter(i);
if (!par->bibkey)
par->bibkey = new InsetBibKey();
par->bibkey->setCounter(number);
- par->labelstring = layout->labelstring;
+ par->labelstring = layout.labelstring();
// In biblio should't be following counters but...
}
else {
- string s = layout->labelstring;
+ string s = layout.labelstring();
/* the caption hack: */
- if (layout->labeltype == LABEL_SENSITIVE) {
+ if (layout.labeltype == LABEL_SENSITIVE) {
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& (par->footnotekind == LyXParagraph::FIG
|| par->footnotekind == LyXParagraph::WIDE_FIG))
/* reset the enumeration counter. They are always resetted
* when there is any other layout between */
- for (i=6 + par->enumdepth; i<10;i++)
+ for (i = 6 + par->enumdepth; i<10;i++)
par->setCounter(i, 0);
}
}
/* Updates all counters BEHIND the row. Changed paragraphs
* with a dynamic left margin will be rebroken. */
-void LyXText::UpdateCounters(Row *row)
+void LyXText::UpdateCounters(Row * row)
{
- LyXParagraph *par;
+ LyXParagraph * par;
if (!row) {
row = firstrow;
par = row->par;
/* now check for the headline layouts. remember that they
* have a dynamic left margin */
if (!par->IsDummy()
- && ( lyxstyle.Style(parameters->textclass, par->layout)->margintype == MARGIN_DYNAMIC
- || lyxstyle.Style(parameters->textclass, par->layout)->labeltype == LABEL_SENSITIVE)
+ && ( textclasslist.Style(parameters->textclass, par->layout).margintype == MARGIN_DYNAMIC
+ || textclasslist.Style(parameters->textclass, par->layout).labeltype == LABEL_SENSITIVE)
){
/* Rebreak the paragraph */
SetUndo(Undo::INSERT,
cursor.par->ParFromPos(cursor.pos)->previous,
cursor.par->ParFromPos(cursor.pos)->next);
- cursor.par->InsertChar(cursor.pos, LYX_META_INSET);
+ cursor.par->InsertChar(cursor.pos, LyXParagraph::META_INSET);
cursor.par->InsertInset(cursor.pos, inset);
- InsertChar(LYX_META_INSET); /* just to rebreak and refresh correctly.
+ InsertChar(LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a
* second time */
}
/* this is for the simple cut and paste mechanism */
-static LyXParagraph *simple_cut_buffer = 0;
+static LyXParagraph * simple_cut_buffer = 0;
static char simple_cut_buffer_textclass = 0;
void DeleteSimpleCutBuffer()
/* OK, we have a selection. This is always between sel_start_cursor
* and sel_end cursor */
- LyXParagraph *tmppar;
- int i;
+ LyXParagraph * tmppar;
/* Check whether there are half footnotes in the selection */
if (sel_start_cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
/* table stuff -- end*/
// make sure that the depth behind the selection are restored, too
- 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()) {
This is not implemented yet.
*/
- char space_wrapped =
+ bool space_wrapped =
sel_end_cursor.par->IsLineSeparator(sel_end_cursor.pos);
if (sel_end_cursor.pos > 0
&& sel_end_cursor.par->IsLineSeparator(sel_end_cursor.pos - 1)) {
sel_end_cursor.pos--; /* please break before a space at
* the end */
- space_wrapped = True;
+ space_wrapped = true;
}
// cut behind a space if there is one
if (sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)
== sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
/* only within one paragraph */
- simple_cut_buffer = new LyXParagraph();
- for (i=sel_start_cursor.pos; i< sel_end_cursor.pos; i++){
+ simple_cut_buffer = new LyXParagraph;
+ LyXParagraph::size_type i =
+ sel_start_cursor.pos;
+ for (; i< sel_end_cursor.pos; i++){
/* table stuff -- begin*/
if (sel_start_cursor.par->table
&& sel_start_cursor.par->IsNewline(sel_start_cursor.pos)){
void LyXText::CopySelection()
{
- int i=0;
-
+ LyXParagraph::size_type i = 0;
/* this doesnt make sense, if there is no selection */
if (!selection) {
return;
/* ok we have a selection. This is always between sel_start_cursor
* and sel_end cursor */
- LyXParagraph *tmppar;
+ LyXParagraph * tmppar;
/* check wether there are half footnotes in the selection */
if (sel_start_cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
if (sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)
== sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
/* only within one paragraph */
- simple_cut_buffer = new LyXParagraph();
- for (i=sel_start_cursor.pos; i< sel_end_cursor.pos; i++){
+ simple_cut_buffer = new LyXParagraph;
+ for (i = sel_start_cursor.pos; i < sel_end_cursor.pos; ++i){
sel_start_cursor.par->CopyIntoMinibuffer(i);
simple_cut_buffer->InsertFromMinibuffer(i - sel_start_cursor.pos);
}
tmppar = tmppar->next;
tmppar2->next = tmppar->Clone();
tmppar2->next->previous = tmppar2;
- tmppar2=tmppar2->next;
+ tmppar2 = tmppar2->next;
}
tmppar2->next = 0;
}
/* the simple_cut_buffer paragraph is too big */
- int tmpi2;
-
- tmpi2 = sel_start_cursor.par->PositionInParFromPos(sel_start_cursor.pos);
+ LyXParagraph::size_type tmpi2 =
+ sel_start_cursor.par->PositionInParFromPos(sel_start_cursor.pos);
for (;tmpi2;tmpi2--)
simple_cut_buffer->Erase(0);
/* now tmppar 2 is too big, delete all after sel_end_cursor.pos */
tmpi2 = sel_end_cursor.par->PositionInParFromPos(sel_end_cursor.pos);
- while (tmppar2->last > tmpi2) {
- tmppar2->Erase(tmppar2->last-1);
+ while (tmppar2->size() > tmpi2) {
+ tmppar2->Erase(tmppar2->text.size() - 1);
}
-
}
}
if (!simple_cut_buffer)
return;
- LyXParagraph *tmppar;
- LyXParagraph *endpar;
+ LyXParagraph * tmppar;
+ LyXParagraph * endpar;
LyXCursor tmpcursor;
/* table stuff -- begin*/
bool table_too_small = false;
if (tmpcursor.par->table) {
- while (simple_cut_buffer->last && !table_too_small){
+ while (simple_cut_buffer->text.size()
+ && !table_too_small) {
if (simple_cut_buffer->IsNewline(0)){
while(tmpcursor.pos < tmpcursor.par->Last() && !tmpcursor.par->IsNewline(tmpcursor.pos))
tmpcursor.pos++;
}
} else {
/* table stuff -- end*/
- while (simple_cut_buffer->last){
+ while (simple_cut_buffer->text.size()){
simple_cut_buffer->CutIntoMinibuffer(0);
simple_cut_buffer->Erase(0);
tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos);
/* make a copy of the simple cut_buffer */
tmppar = simple_cut_buffer;
- LyXParagraph *simple_cut_clone = tmppar->Clone();
- LyXParagraph *tmppar2 = simple_cut_clone;
+ LyXParagraph * simple_cut_clone = tmppar->Clone();
+ LyXParagraph * tmppar2 = simple_cut_clone;
if (cursor.par->footnoteflag){
tmppar->footnoteflag = cursor.par->footnoteflag;
tmppar->footnotekind = cursor.par->footnotekind;
tmppar = tmppar->next;
tmppar2->next = tmppar->Clone();
tmppar2->next->previous = tmppar2;
- tmppar2=tmppar2->next;
+ tmppar2 = tmppar2->next;
if (cursor.par->footnoteflag){
tmppar->footnoteflag = cursor.par->footnoteflag;
tmppar->footnotekind = cursor.par->footnotekind;
/* find the end of the buffer */
LyXParagraph *lastbuffer = simple_cut_buffer;
while (lastbuffer->Next())
- lastbuffer=lastbuffer->Next();
+ lastbuffer = lastbuffer->Next();
/* find the physical end of the buffer */
lastbuffer = simple_cut_buffer;
while (lastbuffer->Next())
- lastbuffer=lastbuffer->Next();
+ lastbuffer = lastbuffer->Next();
/* please break behind a space, if there is one. The space
* should be copied too */
if ((!cursor.par->Last()
|| cursor.par->IsLineSeparator(cursor.pos - 1)
|| cursor.par->IsNewline(cursor.pos - 1))
- && simple_cut_buffer->last
+ && simple_cut_buffer->text.size()
&& simple_cut_buffer->IsLineSeparator(0))
simple_cut_buffer->Erase(0);
/* returns a pointer to the very first LyXParagraph */
-LyXParagraph* LyXText::FirstParagraph()
+LyXParagraph * LyXText::FirstParagraph()
{
return params->paragraph;
}
/* returns true if the specified string is at the specified position */
-bool LyXText::IsStringInText(LyXParagraph *par, int pos, char const* string)
+bool LyXText::IsStringInText(LyXParagraph * par,
+ LyXParagraph::size_type pos,
+ char const * str)
{
if (par) {
int i = 0;
- while (pos+i < par->Last() && string[i] &&
- string[i]==par->GetChar(pos+i))
- {
- i++;
+ while (pos + i < par->Last() && str[i] &&
+ str[i] == par->GetChar(pos + i)) {
+ ++i;
}
-
- if (!string[i])
+ if (!str[i])
return true;
}
return false;
/* sets the selection over the number of characters of string, no check!! */
-void LyXText::SetSelectionOverString(char const* string)
+void LyXText::SetSelectionOverString(char const * string)
{
sel_cursor = cursor;
- int i;
- for (i=0; string[i]; i++)
+ for (int i = 0; string[i]; ++i)
CursorRight();
SetSelection();
}
/* simple replacing. The font of the first selected character is used */
-void LyXText::ReplaceSelectionWithString(char const* string)
+void LyXText::ReplaceSelectionWithString(char const * str)
{
SetCursorParUndo();
FreezeUndo();
}
// Get font setting before we cut
- int pos = sel_end_cursor.pos;
+ LyXParagraph::size_type pos = sel_end_cursor.pos;
LyXFont font = sel_start_cursor.par->GetFontSettings(sel_start_cursor.pos);
// Insert the new string
- for (int i=0; string[i];i++) {
- sel_end_cursor.par->InsertChar(pos, string[i]);
+ for (int i = 0; str[i]; ++i) {
+ sel_end_cursor.par->InsertChar(pos, str[i]);
sel_end_cursor.par->SetFont(pos, font);
- pos++;
+ ++pos;
}
// Cut the selection
/* if the string can be found: return true and set the cursor to
* the new position */
-bool LyXText::SearchForward(char const* string)
+bool LyXText::SearchForward(char const * str)
{
- LyXParagraph *par = cursor.par;
- int pos = cursor.pos;
-
- while (par && !IsStringInText(par,pos,string)) {
- if (pos<par->Last()-1)
- pos++;
+ LyXParagraph * par = cursor.par;
+ LyXParagraph::size_type pos = cursor.pos;
+ while (par && !IsStringInText(par, pos, str)) {
+ if (pos < par->Last() - 1)
+ ++pos;
else {
pos = 0;
par = par->Next();
}
}
if (par) {
- SetCursor(par,pos);
+ SetCursor(par, pos);
return true;
}
else
}
-bool LyXText::SearchBackward(char const* string)
+bool LyXText::SearchBackward(char const * string)
{
- LyXParagraph *par = cursor.par;
+ LyXParagraph * par = cursor.par;
int pos = cursor.pos;
do {
pos = par->Last()-1;
} while (par && pos<0);
}
- } while (par && !IsStringInText(par,pos,string));
+ } while (par && !IsStringInText(par, pos, string));
if (par) {
- SetCursor(par,pos);
+ SetCursor(par, pos);
return true;
}
else
}
+void LyXText::InsertStringA(LyXParagraph::TextContainer const & text)
+{
+ char * str = new char[text.size() + 1];
+ copy(text.begin(), text.end(), str);
+ str[text.size()] = '\0';
+ InsertStringA(str);
+ delete [] str;
+}
+
+
/* needed to insert the selection */
-void LyXText::InsertStringA(char* string)
+void LyXText::InsertStringA(char const * s)
{
- LyXParagraph *par = cursor.par;
- int pos = cursor.pos;
- int a = 0;
+ string str(s);
+ LyXParagraph * par = cursor.par;
+ LyXParagraph::size_type pos = cursor.pos;
+ LyXParagraph::size_type a = 0;
int cell = 0;
- LyXParagraph *endpar = cursor.par->Next();
+ LyXParagraph * endpar = cursor.par->Next();
SetCursorParUndo();
- char flag = lyxstyle.Style(parameters->textclass,
- cursor.par->GetLayout())->isEnvironment();
+ char flag = textclasslist.Style(parameters->textclass,
+ cursor.par->GetLayout()).isEnvironment();
/* only to be sure, should not be neccessary */
ClearSelection();
/* insert the string, don't insert doublespace */
- int i=0;
- int i2 = 0;
-
- for (i2=i;string[i2]&&string[i2]!='\n';i2++);
- par->Enlarge(pos, i2 - i);
- while (string[i]) {
- if (string[i]!='\n') {
- if (string[i]==' ' && (string[i+1]!=' ')
- && pos && par->GetChar(pos-1)!=' ') {
+ string::size_type i = 0;
+ while (i < str.length()) {
+ if (str[i] != '\n') {
+ if (str[i] == ' '
+ && i+1<str.length() && str[i+1]!= ' '
+ && pos && par->GetChar(pos-1)!= ' ') {
par->InsertChar(pos,' ');
pos++;
}
else if (par->table) {
- if (string[i] == '\t') {
- while((pos < par->last) &&
- (par->GetChar(pos) != LYX_META_NEWLINE))
- pos++;
- if (pos < par->last)
- pos++;
+ if (str[i] == '\t') {
+ while((pos < par->size()) &&
+ (par->GetChar(pos) != LyXParagraph::META_NEWLINE))
+ ++pos;
+ if (pos < par->size())
+ ++pos;
else // no more fields to fill skip the rest
break;
- } else if ((string[i] != 13) &&
- (((unsigned char) string[i] & 127) >= ' ')) {
- par->InsertChar(pos,string[i]);
+ } else if ((str[i] != 13) &&
+ ((str[i] & 127) >= ' ')) {
+ par->InsertChar(pos, str[i]);
pos++;
}
}
- else if (string[i]==' ') {
- par->InsertChar(pos,LYX_META_PROTECTED_SEPARATOR);
+ else if (str[i] == ' ') {
+ par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR);
pos++;
}
- else if (string[i]=='\t') {
- for (a=pos; a<(pos/8+1)*8 ; a++) {
- par->InsertChar(a,LYX_META_PROTECTED_SEPARATOR);
+ else if (str[i] == '\t') {
+ for (a = pos; a < (pos/8 + 1) * 8 ; ++a) {
+ par->InsertChar(a, LyXParagraph::META_PROTECTED_SEPARATOR);
}
pos = a;
}
- else if (string[i]!=13 &&
+ else if (str[i]!= 13 &&
// Ignore unprintables
- ((unsigned char) string[i] & 127) >= ' ') {
- par->InsertChar(pos,string[i]);
+ (str[i] & 127) >= ' ') {
+ par->InsertChar(pos, str[i]);
pos++;
}
} else {
if (par->table) {
- if (!string[i+1]) {
+ if (i+1>=str.length()) {
pos++;
break;
}
- while((pos < par->last) &&
- (par->GetChar(pos) != LYX_META_NEWLINE))
+ while((pos < par->size()) &&
+ (par->GetChar(pos) != LyXParagraph::META_NEWLINE))
pos++;
pos++;
- cell=NumberOfCell(par,pos);
- while((pos < par->last) &&
+ cell = NumberOfCell(par, pos);
+ while((pos < par->size()) &&
!(par->table->IsFirstCell(cell))) {
- while((pos < par->last) &&
- (par->GetChar(pos) != LYX_META_NEWLINE))
- pos++;
- pos++;
- cell=NumberOfCell(par,pos);
+ while((pos < par->size()) &&
+ (par->GetChar(pos) != LyXParagraph::META_NEWLINE))
+ ++pos;
+ ++pos;
+ cell = NumberOfCell(par, pos);
}
- if (pos >= par->last)
+ if (pos >= par->size())
// no more fields to fill skip the rest
break;
} else {
- if (!par->last) {
- par->InsertChar(pos,LYX_META_PROTECTED_SEPARATOR);
+ if (!par->text.size()) {
+ par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR);
pos++;
}
par->BreakParagraph(pos, flag);
par = par->Next();
pos = 0;
}
- for (i2=i;string[i2]&&string[i2]!='\n';i2++);
- par->Enlarge(pos, i2 - i);
}
i++;
}
- RedoParagraphs(cursor,endpar);
+ RedoParagraphs(cursor, endpar);
SetCursor(cursor.par, cursor.pos);
sel_cursor = cursor;
SetCursor(par, pos);
SetSelection();
}
+
+void LyXText::InsertStringB(LyXParagraph::TextContainer const & text)
+{
+ char * str = new char[text.size() + 1];
+ copy(text.begin(), text.end(), str);
+ str[text.size()] = '\0';
+ InsertStringB(str);
+ delete [] str;
+}
+
+
/* turns double-CR to single CR, others where converted into one blank and 13s
* that are ignored .Double spaces are also converted into one. Spaces at
* the beginning of a paragraph are forbidden. tabs are converted into one
* space. then InsertStringA is called */
-void LyXText::InsertStringB(char* string)
-{
- LyXParagraph *par = cursor.par;
- int i=1;
- while (string[i]) {
- if (string[i]=='\t' && !par->table)
- string[i] = ' ';
- if (string[i]==' ' && string[i+1]==' ')
- string[i] = 13;
- if (string[i]=='\n' && string[i+1] && !par->table){
- if (string[i+1]!='\n') {
- if (string[i-1]!=' ')
- string[i]=' ';
+void LyXText::InsertStringB(char const * s)
+{
+ string str(s);
+ LyXParagraph * par = cursor.par;
+ string::size_type i = 1;
+ while (i < str.length()) {
+ if (str[i] == '\t' && !par->table)
+ 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 + 1] != '\n') {
+ if (str[i - 1] != ' ')
+ str[i] = ' ';
else
- string[i]= 13;
+ str[i] = 13;
}
- while (string[i+1] && (string[i+1]==' '
- || string[i+1]=='\t'
- || string[i+1]=='\n'
- || string[i+1]==13)) {
- string[i+1]=13;
- i++;
+ while (i+1 < str.length()
+ && (str[i + 1] == ' '
+ || str[i + 1] == '\t'
+ || str[i + 1] == '\n'
+ || str[i + 1] == 13)) {
+ str[i + 1] = 13;
+ ++i;
}
}
- i++;
+ ++i;
}
- InsertStringA(string);
+ InsertStringA(str.c_str());
}
bool LyXText::GotoNextError()
{
- LyXCursor res=cursor;
+ LyXCursor res = cursor;
do {
- if (res.pos < res.par->Last()-1) {
+ if (res.pos < res.par->Last() - 1) {
res.pos++;
}
else {
- res.par=res.par->Next();
+ res.par = res.par->Next();
res.pos = 0;
}
} while (res.par &&
- !(res.par->GetChar(res.pos)==LYX_META_INSET
+ !(res.par->GetChar(res.pos) == LyXParagraph::META_INSET
&& res.par->GetInset(res.pos)->AutoDelete()));
if (res.par) {
bool LyXText::GotoNextNote()
{
- LyXCursor res=cursor;
+ LyXCursor res = cursor;
do {
if (res.pos < res.par->Last()-1) {
res.pos++;
}
else {
- res.par=res.par->Next();
+ res.par = res.par->Next();
res.pos = 0;
}
} while (res.par &&
- !(res.par->GetChar(res.pos)==LYX_META_INSET
- && res.par->GetInset(res.pos)->LyxCode()==Inset::IGNORE_CODE));
+ !(res.par->GetChar(res.pos) == LyXParagraph::META_INSET
+ && res.par->GetInset(res.pos)->LyxCode() == Inset::IGNORE_CODE));
if (res.par) {
SetCursor(res.par, res.pos);
int LyXText::SwitchLayoutsBetweenClasses(char class1, char class2,
- LyXParagraph *par)
+ LyXParagraph * par)
{
- InsetError * new_inset = 0;
int ret = 0;
if (!par || class1 == class2)
return ret;
par = par->FirstPhysicalPar();
while (par) {
- string name = lyxstyle.NameOfLayout(class1, par->layout);
- int lay = lyxstyle.NumberOfLayout(class2, name);
- if (lay == -1) // layout not found
- // use default layout "Stadard" (0)
+ string name = textclasslist.NameOfLayout(class1, par->layout);
+ int lay = 0;
+ pair<bool, LyXTextClass::LayoutList::size_type> pp =
+ textclasslist.NumberOfLayout(class2, name);
+ if (pp.first) {
+ lay = pp.second;
+ } else { // layout not found
+ // use default layout "Standard" (0)
lay = 0;
+ }
par->layout = lay;
- if (name != lyxstyle.NameOfLayout(class2, par->layout)) {
+ if (name != textclasslist.NameOfLayout(class2, par->layout)) {
ret++;
- string s= "Layout had to be changed from\n"
- + name + " to " + lyxstyle.NameOfLayout(class2, par->layout)
+ string s = "Layout had to be changed from\n"
+ + name + " to " + textclasslist.NameOfLayout(class2, par->layout)
+ "\nbecause of class conversion from\n"
- + lyxstyle.NameOfClass(class1) + " to "
- + lyxstyle.NameOfClass(class2);
- new_inset = new InsetError(s);
- par->InsertChar(0, LYX_META_INSET);
+ + textclasslist.NameOfClass(class1) + " to "
+ + textclasslist.NameOfClass(class2);
+ InsetError * new_inset = new InsetError(s);
+ par->InsertChar(0, LyXParagraph::META_INSET);
par->InsertInset(0, new_inset);
}
}
-void LyXText::CheckParagraph(LyXParagraph* par, int pos)
+void LyXText::CheckParagraph(LyXParagraph * par,
+ LyXParagraph::size_type pos)
{
LyXCursor tmpcursor;
/* table stuff -- end*/
long y = 0;
- int z;
-
- Row* row = GetRow(par, pos, y);
+ LyXParagraph::size_type z;
+ Row * row = GetRow(par, pos, y);
/* is there a break one row above */
if (row->previous && row->previous->par == row->par) {
}
int tmpheight = row->height;
- int tmplast = RowLast(row);
+ LyXParagraph::size_type tmplast = RowLast(row);
refresh_y = y;
refresh_row = row;
status = LyXText::NEED_MORE_REFRESH;
/* check the special right address boxes */
- if (lyxstyle.Style(parameters->textclass, par->GetLayout())->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+ if (textclasslist.Style(parameters->textclass, par->GetLayout()).margintype == MARGIN_RIGHT_ADDRESS_BOX) {
tmpcursor.par = par;
tmpcursor.row = row;
tmpcursor.y = y;
/* returns 0 if inset wasn't found */
-int LyXText::UpdateInset(Inset* inset)
+int LyXText::UpdateInset(Inset * inset)
{
- int pos;
- LyXParagraph *par;
-
/* first check the current paragraph */
- pos = cursor.par->GetPositionOfInset(inset);
+ int pos = cursor.par->GetPositionOfInset(inset);
if (pos != -1){
CheckParagraph(cursor.par, pos);
return 1;
/* check every paragraph */
- par = FirstParagraph();
+ LyXParagraph * par = FirstParagraph();
do {
/* make sure the paragraph is open */
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
}
-void LyXText::SetCursor(LyXParagraph *par, int pos)
+void LyXText::SetCursor(LyXParagraph * par,
+ LyXParagraph::size_type pos)
{
LyXCursor old_cursor = cursor;
SetCursorIntern(par, pos);
}
-void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
+void LyXText::SetCursorIntern(LyXParagraph * par, LyXParagraph::size_type pos)
{
long y;
- Row *row;
+ Row * row;
int left_margin;
- LyXParagraph *tmppar;
+ LyXParagraph * tmppar;
/* correct the cursor position if impossible */
if (pos > par->Last()){
pos = par->PositionInParFromPos(pos);
par = tmppar;
}
- if (par->IsDummy() && par->previous &&
+ if (par->IsDummy() && par->previous &&
par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
- while (par->previous &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){
+ while (par->previous &&
+ ((par->previous->IsDummy() && par->previous->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) ||
+ (par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))) {
par = par->previous ;
+ if (par->IsDummy() &&
+ par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+ pos += par->text.size() + 1;
}
if (par->previous) {
par = par->previous;
}
- pos += par->last + 1;
+ pos += par->text.size() + 1;
}
cursor.par = par;
float fill_separator, fill_hfill, fill_label_hfill;
left_margin = LabelEnd(row);
PrepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill);
- int main_body = BeginningOfMainBody(row->par);
-
+ LyXParagraph::size_type main_body =
+ BeginningOfMainBody(row->par);
/* table stuff -- begin*/
if (row->par->table) {
int cell = NumberOfCell(row->par, row->pos);
if (pos && pos == main_body
&& !row->par->IsLineSeparator(pos - 1)) {
x += GetFont(row->par, -2).stringWidth(
- lyxstyle.Style(parameters->textclass, row->par->GetLayout())->labelsep);
+ textclasslist.Style(parameters->textclass, row->par->GetLayout()).labelsep);
if (x < left_margin)
x = left_margin;
}
if (pos + 1 == main_body
&& row->par->IsLineSeparator(pos)) {
x += GetFont(row->par, -2).stringWidth(
- lyxstyle.Style(parameters->textclass, row->par->GetLayout())->labelsep);
+ textclasslist.Style(parameters->textclass, row->par->GetLayout()).labelsep);
if (row->par->IsLineSeparator(pos))
- x-= SingleWidth(row->par, pos);
+ x -= SingleWidth(row->par, pos);
if (x < left_margin)
x = left_margin;
}
void LyXText::SetCursorFromCoordinates(int x, long y)
{
- Row *row;
- int column;
-
- LyXCursor old_cursor;
-
- old_cursor = cursor;
+ LyXCursor old_cursor = cursor;
/* get the row first */
- row = GetRowNearY(y);
+ Row * row = GetRowNearY(y);
cursor.par = row->par;
- column = GetColumnNearX(row, x);
+ int column = GetColumnNearX(row, x);
cursor.pos = row->pos + column;
cursor.x = x;
cursor.y = y + row->baseline;
if (cursor.par->Next()) {
SetCursor(cursor.par->Next(), 0);
} else {
- SetCursor(cursor.par,cursor.par->Last());
+ SetCursor(cursor.par, cursor.par->Last());
}
}
return;
// Paragraph should not be deleted if empty
- if ((lyxstyle.Style(parameters->textclass,
- old_cursor.par->GetLayout()))->keepempty)
+ if ((textclasslist.Style(parameters->textclass,
+ old_cursor.par->GetLayout())).keepempty)
return;
LyXCursor tmpcursor;
|| (old_cursor.par->Last() == 1
&& (old_cursor.par->IsLineSeparator(0))))
&& old_cursor.par->FirstPhysicalPar()
- == old_cursor.par->LastPhysicalPar()
- //&& (
- // impossible to insert your own \caption with
- // this set. made it impossible to use the
- // optional argument...
- // also empty pars in fig or tab never was removed(?)(Lgb)
- //lyxstyle.Style(parameters->textclass,
-// old_cursor.par->GetLayout())->labeltype!=LABEL_SENSITIVE ||
- // (old_cursor.par->footnoteflag == LyXParagraph::NO_FOOTNOTE
- //|| (old_cursor.par->footnotekind != LyXParagraph::FIG
- // && old_cursor.par->footnotekind != LyXParagraph::TAB)))
- ) {
+ == old_cursor.par->LastPhysicalPar()) {
/* ok, we will delete anything */
}
-LyXParagraph* LyXText::GetParFromID(int id)
+LyXParagraph * LyXText::GetParFromID(int id)
{
- LyXParagraph* result = FirstParagraph();
- while (result && result->GetID() != id)
+ LyXParagraph * result = FirstParagraph();
+ while (result && result->id() != id)
result = result->next;
return result;
}
// undo functions
bool LyXText::TextUndo()
{ // returns false if no undo possible
- Undo *undo = params->undostack.Pop();
+ Undo * undo = params->undostack.pop();
if (undo){
FinishUndo();
if (!undo_frozen)
- params->redostack.Push(CreateUndo(undo->kind,
+ params->redostack.push(CreateUndo(undo->kind,
GetParFromID(undo->number_of_before_par),
GetParFromID(undo->number_of_behind_par)));
}
bool LyXText::TextRedo()
{ // returns false if no redo possible
- Undo *undo = params->redostack.Pop();
+ Undo * undo = params->redostack.pop();
if (undo){
FinishUndo();
if (!undo_frozen)
- params->undostack.Push(CreateUndo(undo->kind,
+ params->undostack.push(CreateUndo(undo->kind,
GetParFromID(undo->number_of_before_par),
GetParFromID(undo->number_of_behind_par)));
}
}
-bool LyXText::TextHandleUndo(Undo* undo){ // returns false if no undo possible
+bool LyXText::TextHandleUndo(Undo * undo){ // returns false if no undo possible
bool result = false;
if (undo){
- LyXParagraph* before = GetParFromID(undo->number_of_before_par);
- LyXParagraph* behind = GetParFromID(undo->number_of_behind_par);
- LyXParagraph* tmppar;
- LyXParagraph* tmppar2;
- LyXParagraph* tmppar3;
- LyXParagraph* tmppar4;
- LyXParagraph* endpar;
- LyXParagraph* tmppar5;
+ LyXParagraph * before = GetParFromID(undo->number_of_before_par);
+ LyXParagraph * behind = GetParFromID(undo->number_of_behind_par);
+ LyXParagraph * tmppar;
+ LyXParagraph * tmppar2;
+ LyXParagraph * tmppar3;
+ LyXParagraph * tmppar4;
+ LyXParagraph * endpar;
+ LyXParagraph * tmppar5;
- /*
- if (before){
- before->text[before->last] = 0;
- printf("before: %s\n", before->text);
- }
- if (behind){
- behind->text[behind->last] = 0;
- printf("behind: %s\n", behind->text);
- }
- */
-
// if there's no before take the beginning of the document for redoing
if (!before)
SetCursorIntern(FirstParagraph(), 0);
// is stored in the undo. So restore the text informations.
if (undo->kind == Undo::EDIT){
tmppar2->text = tmppar->text;
- tmppar->text = 0;
+ tmppar->text.clear();
+ //tmppar->text.erase(tmppar->text.begin(),
+ // tmppar->text.end());
tmppar2 = tmppar2->next;
}
if ( currentrow && currentrow->par == tmppar )
// check wether before points to a closed float and open it if necessary
if (before && before->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE
&& before->next && before->next->footnoteflag != LyXParagraph::NO_FOOTNOTE){
- tmppar4 =before;
+ tmppar4 = before;
while (tmppar4->previous &&
tmppar4->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
tmppar4 = tmppar4->previous;
}
-void LyXText::SetUndo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *behind)
+void LyXText::SetUndo(Undo::undo_kind kind, LyXParagraph * before,
+ LyXParagraph * behind)
{
if (!undo_frozen)
- params->undostack.Push(CreateUndo(kind, before, behind));
- params->redostack.Clear();
+ params->undostack.push(CreateUndo(kind, before, behind));
+ params->redostack.clear();
}
-void LyXText::SetRedo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *behind)
+void LyXText::SetRedo(Undo::undo_kind kind, LyXParagraph * before,
+ LyXParagraph * behind)
{
- params->redostack.Push(CreateUndo(kind, before, behind));
+ params->redostack.push(CreateUndo(kind, before, behind));
}
-Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before,
- LyXParagraph *behind)
+Undo * LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph * before,
+ LyXParagraph * behind)
{
int before_number = -1;
int behind_number = -1;
if (before)
- before_number = before->GetID();
+ before_number = before->id();
if (behind)
- behind_number = behind->GetID();
+ behind_number = behind->id();
// Undo::EDIT and Undo::FINISH are
// always finished. (no overlapping there)
// overlapping only with insert and delete inside one paragraph:
if (!undo_finished && kind != Undo::EDIT &&
kind != Undo::FINISH){
// check wether storing is needed
- if (params->undostack.Top() &&
- params->undostack.Top()->kind == kind &&
- params->undostack.Top()->number_of_before_par == before_number &&
- params->undostack.Top()->number_of_behind_par == behind_number ){
+ if (!params->undostack.empty() &&
+ params->undostack.top()->kind == kind &&
+ params->undostack.top()->number_of_before_par == before_number &&
+ params->undostack.top()->number_of_behind_par == behind_number ){
// no undo needed
return 0;
}
}
// create a new Undo
- LyXParagraph* undopar;
- LyXParagraph* tmppar;
- LyXParagraph *tmppar2;
+ LyXParagraph * undopar;
+ LyXParagraph * tmppar;
+ LyXParagraph * tmppar2;
- LyXParagraph* start = 0;
- LyXParagraph* end = 0;
+ LyXParagraph * start = 0;
+ LyXParagraph * end = 0;
if (before)
start = before->next;
if (start && end && start != end->next && (before != behind || (!before && !behind))) {
tmppar = start;
tmppar2 = tmppar->Clone();
- tmppar2->SetID(tmppar->GetID());
+ tmppar2->id(tmppar->id());
// a memory optimization: Just store the layout information when only edit
if (kind == Undo::EDIT){
- if (tmppar2->text)
- delete[] tmppar2->text;
- tmppar2->text = 0;
+ tmppar2->text.clear();
+ //tmppar2->text.erase(tmppar2->text.begin(),
+ // tmppar2->text.end());
}
undopar = tmppar2;
while (tmppar != end && tmppar->next) {
tmppar = tmppar->next;
tmppar2->next = tmppar->Clone();
- tmppar2->next->SetID(tmppar->GetID());
+ tmppar2->next->id(tmppar->id());
// a memory optimization: Just store the layout information when only edit
if (kind == Undo::EDIT){
- if (tmppar2->next->text)
- delete[] tmppar2->next->text;
- tmppar2->next->text = 0;
+ tmppar2->next->text.clear();
+ //tmppar2->next->text.erase(tmppar2->next->text.begin(), tmppar2->next->text.end());
}
tmppar2->next->previous = tmppar2;
- tmppar2=tmppar2->next;
+ tmppar2 = tmppar2->next;
}
tmppar2->next = 0;
}
else
undopar = 0; // nothing to replace (undo of delete maybe)
- int cursor_par = cursor.par->ParFromPos(cursor.pos)->GetID();
+ int cursor_par = cursor.par->ParFromPos(cursor.pos)->id();
int cursor_pos = cursor.par->PositionInParFromPos(cursor.pos);
- Undo* undo = new Undo(kind,
+ Undo * undo = new Undo(kind,
before_number, behind_number,
cursor_par, cursor_pos,
undopar);
cursor.par->ParFromPos(cursor.pos)->next);
}
-void LyXText::RemoveTableRow(LyXCursor *cursor)
+void LyXText::RemoveTableRow(LyXCursor * cursor)
{
int
cell_act,
return;
}
-bool LyXText::IsEmptyTableRow(LyXCursor *old_cursor)
+
+bool LyXText::IsEmptyTableRow(LyXCursor * old_cursor) const
{
if (!old_cursor->par->table)
return false;
#ifdef I_DONT_KNOW_IF_I_SHOULD_DO_THIS
- int
- pos = old_cursor->pos,
- cell = NumberOfCell(old_cursor->par, pos);
+ int pos = old_cursor->pos;
+ int cell = NumberOfCell(old_cursor->par, pos);
// search first charater of this table row
while (pos && !old_cursor->par->table->IsFirstCell(cell)) {
}
-bool LyXText::IsEmptyTableCell()
+bool LyXText::IsEmptyTableCell() const
{
- int pos = cursor.pos - 1;
-
- while ((pos>=0) && (pos < cursor.par->Last()) &&
- !cursor.par->IsNewline(pos))
- pos--;
- return cursor.par->IsNewline(pos+1);
+ LyXParagraph::size_type pos = cursor.pos - 1;
+ while (pos >= 0 && pos < cursor.par->Last()
+ && !cursor.par->IsNewline(pos))
+ --pos;
+ return cursor.par->IsNewline(pos + 1);
}
+
void LyXText::toggleAppendix(){
- LyXParagraph* par = cursor.par->FirstPhysicalPar();
+ LyXParagraph * par = cursor.par->FirstPhysicalPar();
bool start = !par->start_of_appendix;
/* ensure that we have only one start_of_appendix in this document */
- LyXParagraph* tmp = FirstParagraph();
- for (;tmp;tmp=tmp->next)
+ LyXParagraph * tmp = FirstParagraph();
+ for (;tmp;tmp = tmp->next)
tmp->start_of_appendix = 0;
par->start_of_appendix = start;