From 197273f84066b66369dfd6b2972850223ccbc9f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Tue, 3 Oct 2000 09:13:34 +0000 Subject: [PATCH] Angus mathed (cleanup) and inset (bib) patch. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1074 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 22 +++++++++++++++++++ po/POTFILES.in | 13 +++++++++++ src/buffer.C | 4 ++-- src/insets/figinset.C | 7 ------ src/insets/insetbib.C | 45 +++++++++++---------------------------- src/insets/insetbib.h | 9 +++----- src/insets/insetinclude.C | 32 ++++++++++++++-------------- src/lyxfunc.C | 2 +- src/mathed/formula.C | 8 ------- src/mathed/math_cursor.C | 6 ------ src/mathed/math_inset.C | 8 ------- src/mathed/math_iter.C | 3 --- 12 files changed, 70 insertions(+), 89 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86d34255c4..23fc2ce91a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2000-10-02 Angus Leeming + + * src/mathed/formula.C (IsMacro): declared but not referenced; removed. + * src/mathed/math_cursor.C (IsAlpha): ditto. + * src/mathed/math_inset.C (strnew): ditto. + * src/mathed/math_iter.C: SizeFont declared but not referenced;removed. + (IMetrics): cxp set but never used; removed. + * src/insets/figinset.C (InitFigures): removed redundant for loop, now + that the variable in question has been removed also! + + + * src/insets/insetbib.[Ch]: remove need to store Buffer * owner by + using the Buffer * passed to Latex(), using the BufferView * passed to + bibitemMaxWidth() bibitemWidest() and by passing a Buffer* to getKeys() + + * src/insets/insetinclude.C: use the Buffer * passed to Latex(), + Linuxdoc() and DocBook() rather than the stored Buffer * master. + + * src/lyxfunc.C (Dispatch): used new InsetBibtex c-tor + * src/buffer.C (readInset): used new InsetBibtex c-tor + * (getBibkeyList): used new InsetBibtex::getKeys + 2000-10-01 Dekel Tsur * lib/configure.m4 diff --git a/po/POTFILES.in b/po/POTFILES.in index 78103e617b..7471c53912 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -64,6 +64,19 @@ src/frontends/xforms/FormPrint.C src/frontends/xforms/form_print.C src/frontends/xforms/FormRef.C src/frontends/xforms/form_ref.C +src/frontends/xforms/forms/form_citation.C +src/frontends/xforms/forms/form_copyright.C +src/frontends/xforms/forms/form_document.C +src/frontends/xforms/forms/form_error.C +src/frontends/xforms/forms/form_graphics.C +src/frontends/xforms/forms/form_index.C +src/frontends/xforms/forms/form_paragraph.C +src/frontends/xforms/forms/form_preferences.C +src/frontends/xforms/forms/form_print.C +src/frontends/xforms/forms/form_ref.C +src/frontends/xforms/forms/form_tabular.C +src/frontends/xforms/forms/form_toc.C +src/frontends/xforms/forms/form_url.C src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular.C src/frontends/xforms/FormToc.C diff --git a/src/buffer.C b/src/buffer.C index 8a562f6acc..116253f0b8 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -953,7 +953,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, lex.printError("Wrong place for bibitem"); inset = new InsetBibKey(inscmd); } else if (inscmd.getCmdName() == "BibTeX") { - inset = new InsetBibtex(inscmd, this); + inset = new InsetBibtex(inscmd); } else if (inscmd.getCmdName() == "index") { inset = new InsetIndex(inscmd); } else if (inscmd.getCmdName() == "include") { @@ -3583,7 +3583,7 @@ vector > const Buffer::getBibkeyList() // Search for Bibtex or Include inset if ((*it)->LyxCode() == Inset::BIBTEX_CODE) { vector > tmp = - static_cast(*it)->getKeys(); + static_cast(*it)->getKeys(this); keys.insert(keys.end(), tmp.begin(), tmp.end()); } else if ((*it)->LyxCode() == Inset::INCLUDE_CODE) { vector > const tmp = diff --git a/src/insets/figinset.C b/src/insets/figinset.C index de3b0fc47e..b0bfa738fd 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -381,13 +381,6 @@ void InitFigures() figures.clear(); bitmaps.clear(); - unsigned int k; - for (unsigned int i = 0; i < 256; ++i) { - k = 0; - for (unsigned int j = 0; j < 8; ++j) - if (i & (1 << (7-j))) k |= 1 << j; - } - // allocate color cube on pseudo-color display // first get visual gs_color = false; diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 99bb4989ef..14cd00d6a0 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -26,8 +26,6 @@ using std::endl; using std::vector; using std::pair; -extern BufferView * current_view; - FD_bibitem_form * bibitem_form = 0; FD_bibitem_form * create_form_bibitem_form(void); @@ -200,8 +198,8 @@ void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int) } -InsetBibtex::InsetBibtex(InsetCommandParams const & p, Buffer * o) - : InsetCommand(p), owner(o) +InsetBibtex::InsetBibtex(InsetCommandParams const & p) + : InsetCommand(p) {} @@ -220,16 +218,9 @@ string const InsetBibtex::getScreenLabel() const } -int InsetBibtex::Latex(Buffer const *, ostream & os, +int InsetBibtex::Latex(Buffer const * buffer, ostream & os, bool /*fragile*/, bool/*fs*/) const { - // this looks like an horrible hack and it is :) The problem - // is that owner is not initialized correctly when the bib - // inset is cut and pasted. Such hacks will not be needed - // later (JMarc) - if (!owner) { - owner = current_view->buffer(); - } // If we generate in a temp dir, we might need to give an // absolute path there. This is a bit complicated since we can // have a comma-separated list of bibliographies @@ -237,9 +228,9 @@ int InsetBibtex::Latex(Buffer const *, ostream & os, string db_in = getContents(); db_in = split(db_in, adb, ','); while(!adb.empty()) { - if (!owner->niceFile && - IsFileReadable(MakeAbsPath(adb, owner->filepath)+".bib")) - adb = MakeAbsPath(adb, owner->filepath); + if (!buffer->niceFile && + IsFileReadable(MakeAbsPath(adb, buffer->filepath)+".bib")) + adb = MakeAbsPath(adb, buffer->filepath); db_out += adb; db_out += ','; @@ -248,10 +239,10 @@ int InsetBibtex::Latex(Buffer const *, ostream & os, db_out = strip(db_out, ','); // Idem, but simpler string style; - if (!owner->niceFile - && IsFileReadable(MakeAbsPath(getOptions(), owner->filepath) + if (!buffer->niceFile + && IsFileReadable(MakeAbsPath(getOptions(), buffer->filepath) + ".bst")) - style = MakeAbsPath(getOptions(), owner->filepath); + style = MakeAbsPath(getOptions(), buffer->filepath); else style = getOptions(); @@ -262,19 +253,9 @@ int InsetBibtex::Latex(Buffer const *, ostream & os, // This method returns a comma separated list of Bibtex entries -vector > const InsetBibtex::getKeys() const +vector > const InsetBibtex::getKeys(Buffer const * buffer) const { - // This hack is copied from InsetBibtex::Latex. - // Is it still needed? Probably yes. - // Why is this needed here when it already is in Latex? - // Anyway we need a different way to get to the - // buffer the inset is in. (Lgb) - - //if (!owner) { - // owner = current_view->buffer(); - //} - - Path p(owner->filepath); + Path p(buffer->filepath); vector > keys; string tmp; @@ -383,7 +364,7 @@ int bibitemMaxWidth(BufferView * bv, LyXFont const & font) { int w = 0; // Does look like a hack? It is! (but will change at 0.13) - LyXParagraph * par = current_view->buffer()->paragraph; + LyXParagraph * par = bv->buffer()->paragraph; while (par) { if (par->bibkey) { @@ -401,7 +382,7 @@ string const bibitemWidest(BufferView * bv) { int w = 0; // Does look like a hack? It is! (but will change at 0.13) - LyXParagraph * par = current_view->buffer()->paragraph; + LyXParagraph * par = bv->buffer()->paragraph; InsetBibKey * bkey = 0; LyXFont font; diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index a717f52d30..05f257bd3e 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -78,11 +78,11 @@ private: class InsetBibtex : public InsetCommand { public: /// - InsetBibtex(InsetCommandParams const &, Buffer *); + InsetBibtex(InsetCommandParams const &); /// ~InsetBibtex(); /// - Inset * Clone() const { return new InsetBibtex(params(), owner); } + Inset * Clone() const { return new InsetBibtex(params()); } /// string const getScreenLabel() const; /// @@ -95,7 +95,7 @@ public: int Latex(Buffer const *, std::ostream &, bool fragile, bool freespace) const; /// - std::vector > const getKeys() const; + std::vector > const getKeys(Buffer const *) const; /// bool addDatabase(string const &); /// @@ -109,9 +109,6 @@ public: }; private: - /// - mutable Buffer * owner; - /// Holder holder; }; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index ca03b94f88..087d9a2104 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -353,7 +353,7 @@ bool InsetInclude::loadIfNeeded() const } -int InsetInclude::Latex(Buffer const *, ostream & os, +int InsetInclude::Latex(Buffer const * buffer, ostream & os, bool /*fragile*/, bool /*fs*/) const { string incfile(getContents()); @@ -365,37 +365,37 @@ int InsetInclude::Latex(Buffer const *, ostream & os, if (loadIfNeeded()) { Buffer * tmp = bufferlist.getBuffer(getFileName()); - if (tmp->params.textclass != master->params.textclass) { + if (tmp->params.textclass != buffer->params.textclass) { lyxerr << "ERROR: Cannot handle include file `" << MakeDisplayPath(getFileName()) << "' which has textclass `" << textclasslist.NameOfClass(tmp->params.textclass) << "' instead of `" - << textclasslist.NameOfClass(master->params.textclass) + << textclasslist.NameOfClass(buffer->params.textclass) << "'." << endl; return 0; } // write it to a file (so far the complete file) string writefile = ChangeExtension(getFileName(), ".tex"); - if (!master->tmppath.empty() - && !master->niceFile) { + if (!buffer->tmppath.empty() + && !buffer->niceFile) { incfile = subst(incfile, '/','@'); #ifdef __EMX__ incfile = subst(incfile, ':', '$'); #endif - writefile = AddName(master->tmppath, incfile); + writefile = AddName(buffer->tmppath, incfile); } else writefile = getFileName(); writefile = ChangeExtension(writefile, ".tex"); lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; lyxerr[Debug::LATEX] << "writefile:" << writefile << endl; - tmp->markDepClean(master->tmppath); + tmp->markDepClean(buffer->tmppath); tmp->makeLaTeXFile(writefile, OnlyPath(getMasterFilename()), - master->niceFile, true); + buffer->niceFile, true); } if (isVerb()) { @@ -421,7 +421,7 @@ int InsetInclude::Latex(Buffer const *, ostream & os, } -int InsetInclude::Linuxdoc(Buffer const *, ostream & os) const +int InsetInclude::Linuxdoc(Buffer const * buffer, ostream & os) const { string incfile(getContents()); @@ -434,9 +434,9 @@ int InsetInclude::Linuxdoc(Buffer const *, ostream & os) const // write it to a file (so far the complete file) string writefile = ChangeExtension(getFileName(), ".sgml"); - if (!master->tmppath.empty() && !master->niceFile) { + if (!buffer->tmppath.empty() && !buffer->niceFile) { incfile = subst(incfile, '/','@'); - writefile = AddName(master->tmppath, incfile); + writefile = AddName(buffer->tmppath, incfile); } else writefile = getFileName(); @@ -446,7 +446,7 @@ int InsetInclude::Linuxdoc(Buffer const *, ostream & os) const lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; lyxerr[Debug::LATEX] << "writefile:" << writefile << endl; - tmp->makeLinuxDocFile(writefile, master->niceFile, true); + tmp->makeLinuxDocFile(writefile, buffer->niceFile, true); } if (isVerb()) { @@ -458,7 +458,7 @@ int InsetInclude::Linuxdoc(Buffer const *, ostream & os) const } -int InsetInclude::DocBook(Buffer const *, ostream & os) const +int InsetInclude::DocBook(Buffer const * buffer, ostream & os) const { string incfile(getContents()); @@ -471,9 +471,9 @@ int InsetInclude::DocBook(Buffer const *, ostream & os) const // write it to a file (so far the complete file) string writefile = ChangeExtension(getFileName(), ".sgml"); - if (!master->tmppath.empty() && !master->niceFile) { + if (!buffer->tmppath.empty() && !buffer->niceFile) { incfile = subst(incfile, '/','@'); - writefile = AddName(master->tmppath, incfile); + writefile = AddName(buffer->tmppath, incfile); } else writefile = getFileName(); if(IsLyXFilename(getFileName())) @@ -482,7 +482,7 @@ int InsetInclude::DocBook(Buffer const *, ostream & os) const lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; lyxerr[Debug::LATEX] << "writefile:" << writefile << endl; - tmp->makeDocBookFile(writefile, master->niceFile, true); + tmp->makeDocBookFile(writefile, buffer->niceFile, true); } if (isVerb()) { diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 4dd48ca90c..22369a0ac4 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -2671,7 +2671,7 @@ string const LyXFunc::Dispatch(int ac, bibstyle = "plain"; InsetCommandParams p( "BibTeX", db, bibstyle ); - InsetBibtex * inset = new InsetBibtex(p, owner->buffer()); + InsetBibtex * inset = new InsetBibtex(p); if (owner->view()->insertInset(inset)) { if (argument.empty()) diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 58230fa627..e1fe06392c 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -70,14 +70,6 @@ int MathedInset::df_des; int MathedInset::df_width; -inline -bool IsMacro(short token, int id) -{ - return (token != LM_TK_FRAC && token != LM_TK_SQRT && - !((token == LM_TK_SYM || token == LM_TC_BSYM) && id < 255)); -} - - static void mathedValidate(LaTeXFeatures & features, MathParInset * par); diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 7bdd91bdd6..32944de95b 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -35,12 +35,6 @@ static LyxArrayBase * selarray = 0; using std::endl; -static inline -bool IsAlpha(char c) -{ - return ('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'); -} - // This was very smaller, I'll change it later static inline bool IsMacro(short tok, int id) diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 3e77dc9f26..3b6d3765b5 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -26,14 +26,6 @@ #include "symbol_def.h" -static inline -char * strnew(char const * s) -{ - char * s1 = new char[strlen(s)+1]; - return strcpy(s1, s); -} - - MathedInset::MathedInset(MathedInset * inset) { if (inset) { diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index 86d2ef9454..a6ef6eaedf 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -30,7 +30,6 @@ using std::endl; const int SizeInset = sizeof(char*) + 2; -const int SizeFont = 2; extern int mathed_char_width(short type, int style, byte c); extern int mathed_string_width(short type, int style, byte const* s, int ls); @@ -887,7 +886,6 @@ void MathedXIter::subMetrics(int a, int d) void MathedXIter::IMetrics(int pos2, int & width, int & ascent, int & descent) { byte cx; - byte cxp = 0; // *s; int x1; // ls; int asc = 0; int des = 0; @@ -948,7 +946,6 @@ void MathedXIter::IMetrics(int pos2, int & width, int & ascent, int & descent) break; } if (pos < pos2) Next(); - cxp = cx; } width = x - x1; } -- 2.39.2