From 50a25e9a76d753f5229b4fca1076e242a99af467 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 30 May 2002 03:37:24 +0000 Subject: [PATCH] srcdoc fixes + a little tidy or two git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4288 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 17 +++++++ src/LaTeX.C | 2 +- src/importer.C | 13 ----- src/importer.h | 20 +++----- src/lyx_sty.C | 23 ++++----- src/lyx_sty.h | 35 ++++---------- src/lyxlex.C | 27 ++++++----- src/lyxrow.h | 1 + src/lyxtext.h | 11 +++-- src/paragraph.C | 1 + src/paragraph.h | 2 +- src/texrow.C | 123 +++++++++++++++++++++++++----------------------- src/texrow.h | 77 +++++++++++++++--------------- src/text.C | 4 -- src/trans_mgr.h | 8 ++-- 15 files changed, 174 insertions(+), 190 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index d9557742e1..86ae7a25b1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2002-05-30 John Levon + + * LaTeX.C: + * importer.h: + * importer.C: + * lyx_sty.h: + * lyx_sty.C: + * lyxlex.C: + * lyxrow.h: + * lyxtext.h: + * paragraph.h: + * paragraph.C: + * texrow.h: + * texrow.C: + * text.C: + * trans_mgr.h: srcdocs, and some minor cleanups + 2002-05-29 Jean-Marc Lasgouttes * paragraph_pimpl.C (isTextAt): rewrite to be much faster (do not diff --git a/src/LaTeX.C b/src/LaTeX.C index daa1dfb1f9..55cf334851 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -376,7 +376,7 @@ bool LaTeX::runMakeIndex(string const & f) // It should be possible to set the switches for makeindex // sorting style and such. It would also be very convenient // to be able to make style files from within LyX. This has - // to come for a later time. (0.13 perhaps?) + // to come for a later time. string tmp = "makeindex -c -q "; tmp += f; Systemcall one; diff --git a/src/importer.C b/src/importer.C index 59b943a07d..a0610964ef 100644 --- a/src/importer.C +++ b/src/importer.C @@ -87,19 +87,6 @@ bool Importer::Import(LyXView * lv, string const & filename, } -#if 0 -bool Importer::IsImportable(string const & format) -{ - vector loaders = Loaders(); - for (vector::const_iterator it = loaders.begin(); - it != loaders.end(); ++it) - if (converters.IsReachable(format, *it)) - return true; - return false; -} -#endif - - vector const Importer::GetImportableFormats() { vector loaders = Loaders(); diff --git a/src/importer.h b/src/importer.h index 8bcfd08140..0cd3e67fbd 100644 --- a/src/importer.h +++ b/src/importer.h @@ -1,13 +1,11 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file importer.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author unknown + */ #ifndef IMPORTER_H #define IMPORTER_H @@ -28,11 +26,7 @@ public: static bool Import(LyXView * lv, string const & filename, string const & format); -#if 0 - /// - static - bool IsImportable(string const & format); -#endif + /// static std::vector const GetImportableFormats(); diff --git a/src/lyx_sty.C b/src/lyx_sty.C index 21a72df3f4..7450237ae2 100644 --- a/src/lyx_sty.C +++ b/src/lyx_sty.C @@ -1,26 +1,19 @@ -/* This file is part of - * ====================================================== +/** + * \file lyx_sty.C + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author Lars Gullik Bjornes + */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "lyx_sty.h" //\NeedsTeXFormat{LaTeX2e} //\ProvidesPackage{lyx}[1996/01/11 LLE v0.2 (LyX LaTeX Extensions)] //\message{LyX LaTeX Extensions (LLE v0.2) of 11-Jan-1996.} -// include this always string const lyx_def = "\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}"; @@ -37,8 +30,6 @@ string const lyxarrow_def = // for quotes without babel. This does not give perfect results, but // anybody serious about non-english quotes should use babel (JMarc). - - string const quotedblbase_def = "\\ProvideTextCommandDefault{\\quotedblbase}{%\n" " \\raisebox{-1.4ex}[1ex][.5ex]{\\textquotedblright}%\n" @@ -81,6 +72,8 @@ string const paragraphleftindent_def = " \\begin{list}{}{%\n" " \\setlength\\topsep{0pt}%\n" " \\addtolength{\\leftmargin}{#1}\n" +// ho hum, yet more things commented out with no hint as to why they +// weren't just removed // "%% \\addtolength{\\leftmargin}{#1\\textwidth}\n" // "%% \\setlength{\\textwidth}{#2\\textwidth}\n" // "%% \\setlength\\listparindent\\parindent%\n" diff --git a/src/lyx_sty.h b/src/lyx_sty.h index 52d247bda7..9ac39db2c5 100644 --- a/src/lyx_sty.h +++ b/src/lyx_sty.h @@ -1,37 +1,22 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file lyx_sty.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. + * A number of LaTeX command definitions for various + * things. The name of this file is a holdover from the + * days of yore. * - * ====================================================== */ + * \author Lars Gullik Bjornes + */ #ifndef LYX_STY_H #define LYX_STY_H -#ifdef __GNUG__ -#pragma interface -#endif - #include "LString.h" -// This seems to be fixed now (JMarc) -//#ifdef WITH_WARNINGS -//#warning README!! -//#endif -// I suddenly began to get segfaults in guilsinglleft_def and had no clue -// on why this happened, then I tried a rewrite and added lyx_sty.C. Now -// the segfault has moved to bibcombox... It seems that we(or gcc) have a -// problem with static (non-pointer) objects , if someone knows why please -// tell me. I am using gcc 2.7.2.1 (Linux) and when IĀ get this segfault it -// always has to do with a static object of some kind... I tried to rewrite -// the objects causing the segfault, but the segfault then just moves to -// another object. I'll let some others have a look now... (Lgb) - -// include this always /// extern string const lyx_def; /// @@ -65,4 +50,4 @@ extern string const binom_def; /// extern string const mathcircumflex_def; -#endif +#endif // LYX_STY_H diff --git a/src/lyxlex.C b/src/lyxlex.C index 118162bdc1..04c4b23c7e 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -236,21 +236,22 @@ void LyXLex::pushToken(string const & pt) int LyXLex::findToken(char const * str[]) { + if (!next()) { + pimpl_->printError("file ended while scanning string token"); + return -1; + } + int i = 0; - - if (next()) { - if (compare(pimpl_->buff, "default")) { - while (str[i][0] && compare(str[i], pimpl_->buff)) { - ++i; - } - if (!str[i][0]) { - pimpl_->printError("Unknown argument `$$Token'"); - i = -1; - } + + if (compare(pimpl_->buff, "default")) { + while (str[i][0] && compare(str[i], pimpl_->buff)) { + ++i; + } + if (!str[i][0]) { + pimpl_->printError("Unknown argument `$$Token'"); + i = -1; } - } else { - pimpl_->printError("file ended while scanning string token"); - i = -1; } + return i; } diff --git a/src/lyxrow.h b/src/lyxrow.h index f427b7a8a4..7339c88959 100644 --- a/src/lyxrow.h +++ b/src/lyxrow.h @@ -25,6 +25,7 @@ class Row { public: /// Row(); + /// void par(Paragraph * p); /// diff --git a/src/lyxtext.h b/src/lyxtext.h index f5fd74c611..bd27342e77 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -666,11 +666,12 @@ private: /// lyx::pos_type beginningOfMainBody(Buffer const *, Paragraph const * par) const; - /** Returns the left beginning of the text. - This information cannot be taken from the layouts-objekt, because - in LaTeX the beginning of the text fits in some cases - (for example sections) exactly the label-width. - */ + /** + * Returns the left beginning of the text. + * This information cannot be taken from the layout object, because + * in LaTeX the beginning of the text fits in some cases + * (for example sections) exactly the label-width. + */ int leftMargin(BufferView *, Row const * row) const; /// int rightMargin(Buffer const *, Row const * row) const; diff --git a/src/paragraph.C b/src/paragraph.C index 6a8c93fc2b..301e7c9187 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1704,6 +1704,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, } if (moving_arg) os << "\\protect "; + os << "\\\\\n"; } texrow.newline(); diff --git a/src/paragraph.h b/src/paragraph.h index ecc95e4fab..cfe648b4c3 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -261,7 +261,7 @@ public: value_type getUChar(BufferParams const &, lyx::pos_type pos) const; /// The position must already exist. void setChar(lyx::pos_type pos, value_type c); - /// + /// pos <= size() (there is a dummy font change at the end of each par) void setFont(lyx::pos_type pos, LyXFont const & font); /// Returns the height of the highest font in range LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos, diff --git a/src/texrow.C b/src/texrow.C index 84d9c7ce00..2e3bd01fc2 100644 --- a/src/texrow.C +++ b/src/texrow.C @@ -1,12 +1,10 @@ -/* This file is part of - * ====================================================== +/** + * \file texrow.C + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author Matthias Ettrich + */ #include @@ -21,9 +19,57 @@ #include "debug.h" using std::find_if; +using std::for_each; using std::endl; -// Delete linked list +namespace { + +/// function object returning true when row number is found +class same_rownumber { +public: + same_rownumber(int row) : row_(row) {} + bool operator()(TexRow::RowList::value_type const & vt) const { + return vt.rownumber() == row_; + } + +private: + int row_; +}; + + +/// increment the pos value of the argument if the par id +/// is the same, and the pos parameter is larger +class increase_pos { +public: + increase_pos(int id, int pos) + : id_(id), pos_(pos) {} + + void operator()(TexRow::RowList::value_type & vt) const { + if (vt.id() != id_ || vt.pos() >= pos_) + return; + vt.pos(vt.pos() + 1); + + lyxerr[Debug::INFO] + << "TeXRow::increasePos: ideally this " + "should never happen..." << endl; + + // FIXME: When verified to work this clause should be deleted. + if (id_ == vt.id() && pos_ == vt.pos()) { + lyxerr[Debug::INFO] + << "TexRow::increasePos: this should happen " + "maximum one time for each run of " + "increasePos!" << endl; + } + } + +private: + int id_; + int pos_; +}; + +} // namespace anon + + void TexRow::reset() { rowlist.clear(); @@ -33,7 +79,6 @@ void TexRow::reset() } -// Defines paragraph and position for the beginning of this row void TexRow::start(Paragraph * par, int pos) { lastpar = par; @@ -41,39 +86,20 @@ void TexRow::start(Paragraph * par, int pos) } -// Insert node when line is completed void TexRow::newline() { - RowItem tmp; - tmp.pos(lastpos); - if (lastpar) - tmp.id(lastpar->id()); - else - tmp.id(-1); - tmp.rownumber(++count); + int const id = lastpar ? lastpar->id() : -1; + RowList::value_type tmp(id, lastpos, ++count); rowlist.push_back(tmp); } -class same_rownumber { -public: - same_rownumber(TexRow::RowList::value_type const & v):vt(v) {} - bool operator()(TexRow::RowList::value_type const & vt1) const { - return vt.rownumber() == vt1.rownumber(); - } -private: - TexRow::RowList::value_type const & vt; -}; - - - bool TexRow::getIdFromRow(int row, int & id, int & pos) const { - RowList::value_type vt; - vt.rownumber(row); RowList::const_iterator cit = - find_if(rowlist.begin(), rowlist.end(), same_rownumber(vt)); - + find_if(rowlist.begin(), rowlist.end(), + same_rownumber(row)); + if (cit != rowlist.end()) { id = cit->id(); pos = cit->pos(); @@ -85,36 +111,15 @@ bool TexRow::getIdFromRow(int row, int & id, int & pos) const } -// should perhaps have a better name... -// Increase the pos of all rows with the -// same id (and where the pos is larger) -// to avoid putting errorinsets at the -// same pos. -void TexRow::increasePos(int id, int pos) const +void TexRow::increasePos(int id, int pos) { - RowList::iterator kit = rowlist.begin(); + RowList::iterator it = rowlist.begin(); RowList::iterator end = rowlist.end(); - for (; kit != end; ++kit) { - if (id == kit->id() - && pos < kit->pos()) { - kit->pos(kit->pos() + 1); - lyxerr[Debug::INFO] - << "TeXRow::increasePos: ideally this " - "should never happen..." << endl; - } - // When verified to work this clause should be deleted. - if (id == kit->id() - && pos == kit->pos()) { - lyxerr[Debug::INFO] - << "TexRow::increasePos: this should happen " - "maximum one time for each run of " - "increasePos!" << endl; - } - } + for_each(it, end, increase_pos(id, pos)); } -TexRow & TexRow::operator+= (TexRow const & tr) +TexRow & TexRow::operator+=(TexRow const & tr) { rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end()); return *this; diff --git a/src/texrow.h b/src/texrow.h index 700bcd67df..d35c7a57a9 100644 --- a/src/texrow.h +++ b/src/texrow.h @@ -1,13 +1,12 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file texrow.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team - * - * ====================================================== */ + * \author Matthias Ettrich + */ + #ifndef TEXROW_H #define TEXROW_H @@ -20,7 +19,7 @@ class Paragraph; -// Controls correspondance between paragraphs and the generated LaTeX file +/// Represents the correspondence between paragraphs and the generated LaTeX file class TexRow { public: /// @@ -35,65 +34,69 @@ public: /// Insert node when line is completed void newline(); - /// Returns paragraph id and position from a row number + /** + * getIdFromRow - find pid and position for a given row + * @param row row number to find + * @param id set to id if found + * @param pos set to paragraph position if found + * @return true if found, false otherwise + * + * If the row could not be found, pos is set to zero and + * id is set to -1 + */ bool getIdFromRow(int row, int & id, int & pos) const; - /// Appends another TexRow TexRow & operator+= (TexRow const &); - /// Returns the number of rows in this texrow + /// Returns the number of rows contained int rows() const { return count; } - /// Linked list of items + /// an individual id/pos <=> row mapping class RowItem { public: - /// - RowItem() : id_(-1), pos_(-1), rownumber_(0) {} - /// - void id(int i) { - id_ = i; - } - /// + RowItem(int id, int pos, int row) + : id_(id), pos_(pos), rownumber_(row) + {} + + /// paragraph id int id() const { return id_; } - /// + + /// set paragraph position void pos(int p) { pos_ = p; } - /// + + /// paragraph position int pos() const { return pos_; } - /// - void rownumber(int r) { - rownumber_ = r; - } - /// + + /// row number int rownumber() const { return rownumber_; } private: - /// int id_; - /// int pos_; - /// int rownumber_; }; /// typedef std::list RowList; - /// - void increasePos(int id, int pos) const; + /// increment position of all other RowItems + /// with same par id, to avoid placing error insets + /// at the same position + void increasePos(int id, int pos); private: - /// + /// number of lines unsigned int count; - /// - mutable RowList rowlist; + /// container of id/pos <=> row mapping + RowList rowlist; /// Last paragraph Paragraph * lastpar; /// Last position int lastpos; - }; -#endif + +#endif // TEXROW_H diff --git a/src/text.C b/src/text.C index 602abcc7ae..214207ca0a 100644 --- a/src/text.C +++ b/src/text.C @@ -697,10 +697,6 @@ bool LyXText::draw(DrawRowParams & p, pos_type & vpos) } -// Returns the left beginning of the text. -// This information cannot be taken from the layouts-objekt, because in -// LaTeX the beginning of the text fits in some cases (for example sections) -// exactly the label-width. int LyXText::leftMargin(BufferView * bview, Row const * row) const { Inset * ins; diff --git a/src/trans_mgr.h b/src/trans_mgr.h index 4507f48272..2620dde25d 100644 --- a/src/trans_mgr.h +++ b/src/trans_mgr.h @@ -1,6 +1,6 @@ // -*- C++ -*- -#ifndef Trans_Manager_h -#define Trans_Manager_h +#ifndef TRANS_MANAGER_H +#define TRANS_MANAGER_H #ifdef __GNUG__ #pragma interface @@ -14,7 +14,7 @@ class LyXText; class Trans; -/// Translation State +/// Translation state class TransState { public: /// @@ -187,4 +187,4 @@ string const TransManager::deadkey(char c, KmodInfo t) return trans_fsm_.currentState->deadkey(c, t); } -#endif +#endif // TRANS_MANAGER_H -- 2.39.2