X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftext2.C;h=6515b58c7aef9fdf121a4a9ebebbf47c00046c52;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=1cbb53bd3a901abe0d950f3cf1b40f6a24dd0f1d;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/text2.C b/src/text2.C index 1cbb53bd3a..6515b58c7a 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1,16 +1,16 @@ /* This file is part of -* ====================================================== -* -* LyX, The Document Processor -* -* Copyright (C) 1995 Matthias Ettrich -* Copyright (C) 1995-1998 The LyX Team. -* -*======================================================*/ + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 The LyX Team. + * + * ======================================================*/ #include -#include +#include #include FORMS_H_LOCATION #ifdef __GNUG__ @@ -23,7 +23,7 @@ #include "insets/inseterror.h" #include "layout.h" #include "LyXView.h" -#include "textutils.h" +#include "support/textutils.h" #include "lyx_cb.h" #include "undo.h" #include "minibuffer.h" @@ -33,20 +33,14 @@ #include "lyxtext.h" #include "gettext.h" -// $Id: text2.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $ - -#if !defined(lint) && !defined(WITH_WARNINGS) -static char vcid[] = "$Id: text2.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $"; -#endif /* lint */ - extern MiniBuffer *minibuffer; // Constructor LyXText::LyXText(int pw, Buffer *p) { - firstrow = NULL; - lastrow = NULL; - currentrow = NULL; + firstrow = 0; + lastrow = 0; + currentrow = 0; currentrow_y = 0; paperwidth = pw; parameters = &p->params; @@ -74,7 +68,7 @@ LyXText::LyXText(int pw, Buffer *p) mark_set = false; /* no rebreak necessary */ - need_break_row = NULL; + need_break_row = 0; undo_finished = true; undo_frozen = false; @@ -233,7 +227,7 @@ void LyXText::InsertRow(Row *row, LyXParagraph *par, int pos) { Row *tmprow = new Row; if (!row) { - tmprow->previous = NULL; + tmprow->previous = 0; tmprow->next = firstrow; firstrow = tmprow; } @@ -424,7 +418,7 @@ void LyXText::CloseFootnote() if (row->next) tmppar = row->next->par; else - tmppar = NULL; + tmppar = 0; } AppendParagraph(cursor.row); @@ -860,18 +854,18 @@ void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph *endpar) if (tmprow->next) tmppar = tmprow->next->par; else - tmppar = NULL; + tmppar = 0; while (tmppar != endpar) { RemoveRow(tmprow->next); if (tmprow->next) tmppar = tmprow->next->par; else - tmppar = NULL; + tmppar = 0; } /* remove the first one */ tmprow2 = tmprow; /* this is because tmprow->previous - * can be NULL */ + * can be 0 */ tmprow = tmprow->previous; RemoveRow(tmprow2); @@ -916,7 +910,7 @@ int LyXText::FullRebreak() { if (need_break_row) { BreakAgain(need_break_row); - need_break_row = NULL; + need_break_row = 0; return 1; } return 0; @@ -1208,7 +1202,7 @@ void LyXText::SetParagraph(bool line_top, bool line_bottom, bool pagebreak_top, bool pagebreak_bottom, VSpace space_top, VSpace space_bottom, char align, - LString labelwidthstring, + string labelwidthstring, bool noindent) { LyXCursor tmpcursor; @@ -1469,7 +1463,7 @@ void LyXText::SetCounter(LyXParagraph *par) } if (!par->labelstring.empty()) { - par->labelstring.clean(); + par->labelstring.clear(); } if (layout->margintype == MARGIN_MANUAL) { @@ -1478,7 +1472,7 @@ void LyXText::SetCounter(LyXParagraph *par) } } else { - par->SetLabelWidthString(LString()); + par->SetLabelWidthString(string()); } /* is it a layout that has an automatic label ? */ @@ -1495,13 +1489,13 @@ void LyXText::SetCounter(LyXParagraph *par) if (!layout->labelstring.empty()) par->labelstring = layout->labelstring; else - par->labelstring.clean(); + par->labelstring.clear(); } else { if (!layout->labelstring_appendix.empty()) par->labelstring = layout->labelstring_appendix; else - par->labelstring.clean(); + par->labelstring.clear(); } if (!par->appendix){ @@ -1664,7 +1658,7 @@ void LyXText::SetCounter(LyXParagraph *par) // In biblio should't be following counters but... } else { - LString s = layout->labelstring; + string s = layout->labelstring; /* the caption hack: */ @@ -1766,7 +1760,7 @@ void LyXText::InsertInset(Inset *inset) /* this is for the simple cut and paste mechanism */ -static LyXParagraph *simple_cut_buffer = NULL; +static LyXParagraph *simple_cut_buffer = 0; static char simple_cut_buffer_textclass = 0; void DeleteSimpleCutBuffer() @@ -1780,7 +1774,7 @@ void DeleteSimpleCutBuffer() simple_cut_buffer = simple_cut_buffer->next; delete tmppar; } - simple_cut_buffer = NULL; + simple_cut_buffer = 0; } @@ -1957,8 +1951,8 @@ This is not implemented yet. /*store the selection */ simple_cut_buffer = sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->next; - simple_cut_buffer->previous = NULL; - sel_end_cursor.par->previous->next = NULL; + simple_cut_buffer->previous = 0; + sel_end_cursor.par->previous->next = 0; /* cut the selection */ sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->next @@ -2083,7 +2077,7 @@ void LyXText::CopySelection() tmppar2->next->previous = tmppar2; tmppar2=tmppar2->next; } - tmppar2->next = NULL; + tmppar2->next = 0; /* care about footnotes */ if (simple_cut_buffer->footnoteflag) { @@ -2649,13 +2643,13 @@ bool LyXText::GotoNextNote() int LyXText::SwitchLayoutsBetweenClasses(char class1, char class2, LyXParagraph *par) { - InsetError * new_inset = NULL; + InsetError * new_inset = 0; int ret = 0; if (!par || class1 == class2) return ret; par = par->FirstPhysicalPar(); while (par) { - LString name = lyxstyle.NameOfLayout(class1, par->layout); + string name = lyxstyle.NameOfLayout(class1, par->layout); int lay = lyxstyle.NumberOfLayout(class2, name); if (lay == -1) // layout not found // use default layout "Stadard" (0) @@ -2664,7 +2658,7 @@ int LyXText::SwitchLayoutsBetweenClasses(char class1, char class2, if (name != lyxstyle.NameOfLayout(class2, par->layout)) { ret++; - LString s= "Layout had to be changed from\n" + string s= "Layout had to be changed from\n" + name + " to " + lyxstyle.NameOfLayout(class2, par->layout) + "\nbecause of class conversion from\n" + lyxstyle.NameOfClass(class1) + " to " @@ -2813,11 +2807,15 @@ void LyXText::SetCursorIntern(LyXParagraph *par, int pos) 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->last + 1; } if (par->previous) { par = par->previous; @@ -3283,7 +3281,7 @@ bool LyXText::TextHandleUndo(Undo* undo){ // returns false if no undo possible // replace the paragraphs with the undo informations tmppar3 = undo->par; - undo->par = NULL; // otherwise the undo destructor would delete the paragraph + undo->par = 0; // otherwise the undo destructor would delete the paragraph tmppar4 = tmppar3; if (tmppar4){ while (tmppar4->next) @@ -3304,7 +3302,7 @@ bool LyXText::TextHandleUndo(Undo* undo){ // returns false if no undo possible // is stored in the undo. So restore the text informations. if (undo->kind == Undo::EDIT){ tmppar2->text = tmppar->text; - tmppar->text = NULL; + tmppar->text = 0; tmppar2 = tmppar2->next; } if ( currentrow && currentrow->par == tmppar ) @@ -3439,7 +3437,7 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before, params->undostack.Top()->number_of_before_par == before_number && params->undostack.Top()->number_of_behind_par == behind_number ){ // no undo needed - return NULL; + return 0; } } // create a new Undo @@ -3447,8 +3445,8 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph* tmppar; LyXParagraph *tmppar2; - LyXParagraph* start = NULL; - LyXParagraph* end = NULL; + LyXParagraph* start = 0; + LyXParagraph* end = 0; if (before) start = before->next; @@ -3471,7 +3469,7 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before, if (kind == Undo::EDIT){ if (tmppar2->text) delete[] tmppar2->text; - tmppar2->text = NULL; + tmppar2->text = 0; } undopar = tmppar2; @@ -3484,15 +3482,15 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before, if (kind == Undo::EDIT){ if (tmppar2->next->text) delete[] tmppar2->next->text; - tmppar2->next->text = NULL; + tmppar2->next->text = 0; } tmppar2->next->previous = tmppar2; tmppar2=tmppar2->next; } - tmppar2->next = NULL; + tmppar2->next = 0; } else - undopar = NULL; // nothing to replace (undo of delete maybe) + undopar = 0; // nothing to replace (undo of delete maybe) int cursor_par = cursor.par->ParFromPos(cursor.pos)->GetID(); int cursor_pos = cursor.par->PositionInParFromPos(cursor.pos);