]> git.lyx.org Git - features.git/commitdiff
Angus mathed (cleanup) and inset (bib) patch.
authorJürgen Vigna <jug@sad.it>
Tue, 3 Oct 2000 09:13:34 +0000 (09:13 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 3 Oct 2000 09:13:34 +0000 (09:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1074 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
ChangeLog
po/POTFILES.in
src/buffer.C
src/insets/figinset.C
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetinclude.C
src/lyxfunc.C
src/mathed/formula.C
src/mathed/math_cursor.C
src/mathed/math_inset.C
src/mathed/math_iter.C

index 86d34255c4a4b9901671fb13fcd614fbe75aabe3..23fc2ce91ad37aa5b90429805fa78b93f12fe392 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2000-10-02  Angus Leeming <a.leeming@ic.ac.uk>
+
+       * 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  <dekelts@tau.ac.il>
 
        * lib/configure.m4
index 78103e617bae81341532fa99eb40ba5a4a61d30d..7471c53912704412e4a560c3f16dfc4861da4882 100644 (file)
@@ -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
index 8a562f6accf1ed9e0d2b447493325e615d6455a8..116253f0b8da5d9b6b9c28a66f2f03d30186aa45 100644 (file)
@@ -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<pair<string,string> > const Buffer::getBibkeyList()
                        // Search for Bibtex or Include inset
                        if ((*it)->LyxCode() == Inset::BIBTEX_CODE) {
                                vector<pair<string,string> > tmp =
-                                       static_cast<InsetBibtex*>(*it)->getKeys();
+                                       static_cast<InsetBibtex*>(*it)->getKeys(this);
                                keys.insert(keys.end(), tmp.begin(), tmp.end());
                        } else if ((*it)->LyxCode() == Inset::INCLUDE_CODE) {
                                vector<pair<string,string> > const tmp =
index de3b0fc47ef3a666dae3321124f196646edc072f..b0bfa738fd080ee2e8cd7caa02b90709e8d1cd69 100644 (file)
@@ -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;
index 99bb4989ef4cfd545783704a01b90255b6e93f28..14cd00d6a022982ad7e9e0b5328e6a43f817d390 100644 (file)
@@ -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<pair<string, string> > const InsetBibtex::getKeys() const
+vector<pair<string, string> > 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<pair<string,string> > 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;
       
index a717f52d301f9101e2f05d58ed39656f04b8ea36..05f257bd3e70547acec08350de8f769f07b4aaf7 100644 (file)
@@ -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<std::pair<string,string> > const getKeys() const;
+       std::vector<std::pair<string,string> > const getKeys(Buffer const *) const;
         ///
         bool addDatabase(string const &);
         ///
@@ -109,9 +109,6 @@ public:
        };
 
 private:
-       ///
-       mutable Buffer * owner;
-
        ///
        Holder holder;
 };
index ca03b94f88f3fd7c4674deee1d396536bdbbf31f..087d9a2104696ae66b609ca8f9bf9e452dce8be2 100644 (file)
@@ -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()) {
index 4dd48ca90c6653b8f637da66eae55eca1cab6d0b..22369a0ac47dd71ce8401234ae19f37ae4fd9608 100644 (file)
@@ -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())
index 58230fa6276b1ad15676b73e18e439e055b77363..e1fe06392c465d603206197db5737640168e9256 100644 (file)
@@ -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);
 
index 7bdd91bdd638de7cd456f91b7743264e15e11733..32944de95b4b54c9fee768a2967c704edcbc5a43 100644 (file)
@@ -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)
index 3e77dc9f26383cd09e596350187d56fba19031cd..3b6d3765b536e7e91c311c9e7cc2e515e4aab7cd 100644 (file)
 #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) {
index 86d2ef94544bc0faa6e433a7c3e3c49a2c5dd276..a6ef6eaedf3240e6ac1ab707c2f8bb313abfd67c 100644 (file)
@@ -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;
 }