]> git.lyx.org Git - features.git/commitdiff
do not define macro \LyX if we do not need it; small things
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 20 Jul 2002 16:42:15 +0000 (16:42 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 20 Jul 2002 16:42:15 +0000 (16:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4724 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/LaTeXFeatures.C
src/graphics/ChangeLog
src/graphics/PreviewLoader.C
src/paragraph.C
src/paragraph_pimpl.C
src/paragraph_pimpl.h
src/version.C.in

index 68cbe3c5bfb927426d7aee75b0601aaaab1849eb..88a4cf7a931f65d9a75a3e8e98f1a69d836d9742 100644 (file)
@@ -1,5 +1,13 @@
 2002-07-20  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * version.C.in: update lyx_docversion
+
+       * LaTeXFeatures.C (getMacros): only define \LyX when needed
+
+       * paragraph.C (validate): remove from here...
+       * paragraph_pimpl.C (validate): ... and move here
+       (isTextAt): make it const
+
        * buffer.C (getLists): ws cleanup
 
 2002-07-20  Dekel Tsur  <dekelts@tau.ac.il>
index 1648699972e604698eb7d0d38095d02a781ce94c..4f22c9fcd46a6c588580f8eeb33196524d58af88 100644 (file)
@@ -265,8 +265,7 @@ string const LaTeXFeatures::getMacros() const
 {
        ostringstream macros;
 
-       // always include this
-       if (true || isRequired("lyx"))
+       if (isRequired("LyX"))
                macros << lyx_def << '\n';
 
        if (isRequired("lyxline"))
index 9f59ce1112c214e033eae68e6686ea1d66450039..8918c67806f918f1070f79c9b23825c894d81b1d 100644 (file)
@@ -1,5 +1,8 @@
 2002-07-20  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * PreviewLoader.C (startLoading): pass an interger as resolution
+       to the lyxpreview converter
+
        * GraphicsParams.C: include <cstdlib>
 
 2002-07-19  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
index ccdbaaca82d93404974bad51d45592cde280bc8f..eb28055954bff55763beafe8c8335ca558ebd9d7 100644 (file)
@@ -465,7 +465,7 @@ void PreviewLoader::Impl::startLoading()
        // The conversion command.
        ostringstream cs;
        cs << pconverter_->command << " " << latexfile << " "
-          << font_scaling_factor_;
+          << int(font_scaling_factor_);
 
        string const command = LibScriptSearch(cs.str().c_str());
 
index 97405c5e9421c23753a5fece4d9da068c975a67b..9c397dee98eee560c1e42f4a0d7e3ca43e54f6a8 100644 (file)
@@ -23,7 +23,6 @@
 #include "buffer.h"
 #include "bufferparams.h"
 #include "debug.h"
-#include "LaTeXFeatures.h"
 #include "texrow.h"
 #include "BufferView.h"
 #include "encoding.h"
@@ -332,78 +331,7 @@ void Paragraph::writeFile(Buffer const * buf, ostream & os,
 
 void Paragraph::validate(LaTeXFeatures & features) const
 {
-       BufferParams const & bparams = features.bufferParams();
-
-       // check the params.
-       if (params().lineTop() || params().lineBottom())
-               features.require("lyxline");
-       if (!params().spacing().isDefault())
-               features.require("setspace");
-
-       // then the layouts
-       features.useLayout(layout()->name());
-
-       // then the fonts
-       Language const * doc_language = bparams.language;
-
-       Pimpl::FontList::const_iterator fcit = pimpl_->fontlist.begin();
-       Pimpl::FontList::const_iterator fend = pimpl_->fontlist.end();
-       for (; fcit != fend; ++fcit) {
-               if (fcit->font().noun() == LyXFont::ON) {
-                       lyxerr[Debug::LATEX] << "font.noun: "
-                                            << fcit->font().noun()
-                                            << endl;
-                       features.require("noun");
-                       lyxerr[Debug::LATEX] << "Noun enabled. Font: "
-                                            << fcit->font().stateText(0)
-                                            << endl;
-               }
-               switch (fcit->font().color()) {
-               case LColor::none:
-               case LColor::inherit:
-               case LColor::ignore:
-                       // probably we should put here all interface colors used for
-                       // font displaying! For now I just add this ones I know of (Jug)
-               case LColor::latex:
-               case LColor::note:
-                       break;
-               default:
-                       features.require("color");
-                       lyxerr[Debug::LATEX] << "Color enabled. Font: "
-                                            << fcit->font().stateText(0)
-                                            << endl;
-               }
-
-               Language const * language = fcit->font().language();
-               if (language->babel() != doc_language->babel() &&
-                   language != ignore_language &&
-#ifdef INHERIT_LANGUAGE
-                   language != inherit_language &&
-#endif
-                   language != latex_language)
-               {
-                       features.useLanguage(language);
-                       lyxerr[Debug::LATEX] << "Found language "
-                                            << language->babel() << endl;
-               }
-       }
-
-       if (!params().leftIndent().zero())
-               features.require("ParagraphLeftIndent");
-
-       // then the insets
-       LyXLayout_ptr const & lout = layout();
-
-       InsetList::const_iterator icit = insetlist.begin();
-       InsetList::const_iterator iend = insetlist.end();
-       for (; icit != iend; ++icit) {
-               if (icit->inset) {
-                       icit->inset->validate(features);
-                       if (lout->needprotect &&
-                           icit->inset->lyxCode() == Inset::FOOT_CODE)
-                               features.require("NeedLyXFootnoteCode");
-               }
-       }
+       pimpl_->validate(features, *layout());
 }
 
 
index 76355805cc46f70a9c7abbb985811379a204081a..0126b79e2ea3cb67a4e35dea46cce48bb7c43dc2 100644 (file)
@@ -15,6 +15,7 @@
 #endif
 
 #include "paragraph_pimpl.h"
+#include "LaTeXFeatures.h"
 #include "texrow.h"
 #include "language.h"
 #include "bufferparams.h"
@@ -41,14 +42,20 @@ unsigned int Paragraph::Pimpl::paragraph_id = 0;
 
 namespace {
 
-string special_phrases[][2] = {
-       { "LyX", "\\LyX{}" },
-       { "TeX", "\\TeX{}" },
-       { "LaTeX2e", "\\LaTeXe{}" },
-       { "LaTeX", "\\LaTeX{}" },
-       };
-
-size_t phrases_nr = sizeof(special_phrases)/sizeof(special_phrases[0]);
+struct special_phrase {
+       string phrase;
+       string macro;
+       bool builtin;
+};
+       
+special_phrase special_phrases[] = {
+       { "LyX", "\\LyX{}", false },
+       { "TeX", "\\TeX{}", true },
+       { "LaTeX2e", "\\LaTeXe{}", true },
+       { "LaTeX", "\\LaTeX{}", true },
+};
+
+size_t phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
 
 } // namespace anon
 
@@ -275,7 +282,7 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
 }
 
 
-bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos)
+bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos) const
 {
        pos_type const len = str.length();
 
@@ -511,17 +518,19 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
 
                        // LyX, LaTeX etc.
 
-                       // FIXME: if we have "LaTeX" with a font change in the middle (before
-                       // the 'T', then the "TeX" part is still special cased. Really we
-                       // should only operate this on "words" for some definition of word
+                       // FIXME: if we have "LaTeX" with a font
+                       // change in the middle (before the 'T', then
+                       // the "TeX" part is still special cased.
+                       // Really we should only operate this on
+                       // "words" for some definition of word
 
                        size_t pnr = 0;
 
                        for (; pnr < phrases_nr; ++pnr) {
-                               if (isTextAt(special_phrases[pnr][0], i)) {
-                                       os << special_phrases[pnr][1];
-                                       i += special_phrases[pnr][0].length() - 1;
-                                       column += special_phrases[pnr][1].length() - 1;
+                               if (isTextAt(special_phrases[pnr].phrase, i)) {
+                                       os << special_phrases[pnr].macro;
+                                       i += special_phrases[pnr].phrase.length() - 1;
+                                       column += special_phrases[pnr].macro.length() - 1;
                                        break;
                                }
                        }
@@ -558,6 +567,93 @@ Paragraph * Paragraph::Pimpl::TeXDeeper(Buffer const * buf,
 }
 
 
+void Paragraph::Pimpl::validate(LaTeXFeatures & features,
+                               LyXLayout const & layout) const
+{
+       BufferParams const & bparams = features.bufferParams();
+
+       // check the params.
+       if (params.lineTop() || params.lineBottom())
+               features.require("lyxline");
+       if (!params.spacing().isDefault())
+               features.require("setspace");
+
+       // then the layouts
+       features.useLayout(layout.name());
+
+       // then the fonts
+       Language const * doc_language = bparams.language;
+
+       FontList::const_iterator fcit = fontlist.begin();
+       FontList::const_iterator fend = fontlist.end();
+       for (; fcit != fend; ++fcit) {
+               if (fcit->font().noun() == LyXFont::ON) {
+                       lyxerr[Debug::LATEX] << "font.noun: "
+                                            << fcit->font().noun()
+                                            << endl;
+                       features.require("noun");
+                       lyxerr[Debug::LATEX] << "Noun enabled. Font: "
+                                            << fcit->font().stateText(0)
+                                            << endl;
+               }
+               switch (fcit->font().color()) {
+               case LColor::none:
+               case LColor::inherit:
+               case LColor::ignore:
+                       // probably we should put here all interface colors used for
+                       // font displaying! For now I just add this ones I know of (Jug)
+               case LColor::latex:
+               case LColor::note:
+                       break;
+               default:
+                       features.require("color");
+                       lyxerr[Debug::LATEX] << "Color enabled. Font: "
+                                            << fcit->font().stateText(0)
+                                            << endl;
+               }
+
+               Language const * language = fcit->font().language();
+               if (language->babel() != doc_language->babel() &&
+                   language != ignore_language &&
+#ifdef INHERIT_LANGUAGE
+                   language != inherit_language &&
+#endif
+                   language != latex_language)
+               {
+                       features.useLanguage(language);
+                       lyxerr[Debug::LATEX] << "Found language "
+                                            << language->babel() << endl;
+               }
+       }
+
+       if (!params.leftIndent().zero())
+               features.require("ParagraphLeftIndent");
+
+       // then the insets
+       InsetList::const_iterator icit = owner_->insetlist.begin();
+       InsetList::const_iterator iend = owner_->insetlist.end();
+       for (; icit != iend; ++icit) {
+               if (icit->inset) {
+                       icit->inset->validate(features);
+                       if (layout.needprotect &&
+                           icit->inset->lyxCode() == Inset::FOOT_CODE)
+                               features.require("NeedLyXFootnoteCode");
+               }
+       }
+
+       // then the contents
+       for (pos_type i = 0; i < size() ; ++i) {
+               for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
+                       if (!special_phrases[pnr].builtin
+                           && isTextAt(special_phrases[pnr].phrase, i)) {
+                               features.require(special_phrases[pnr].phrase);
+                               break;
+                       }
+               }
+       }               
+}
+
+
 Paragraph * Paragraph::Pimpl::getParFromID(int id) const
 {
        InsetList::const_iterator cit = owner_->insetlist.begin();
index efbbd7046f66952e139a073d85a907a9213e770b..014bcdaea3595cc9040b079fec6168476829aa12 100644 (file)
@@ -141,6 +141,11 @@ struct Paragraph::Pimpl {
                                   LyXLayout const & style,
                                   lyx::pos_type & i,
                                   int & column, value_type const c);
+
+       ///
+       void validate(LaTeXFeatures & features,
+                     LyXLayout const & layout) const;
+
        ///
        Paragraph * getParFromID(int id) const;
        ///
@@ -151,7 +156,7 @@ struct Paragraph::Pimpl {
        ParagraphParameters params;
 private:
        /// match a string against a particular point in the paragraph
-       bool isTextAt(string const & str, lyx::pos_type pos);
+       bool isTextAt(string const & str, lyx::pos_type pos) const;
 
        /// Who owns us?
        Paragraph * owner_;
index 0a7b360e4d8cf804e7f8b695afb1921a5dd1e5e3..b95682d156d239d7cac2d94fb3bdbcb852e48af2 100644 (file)
@@ -16,7 +16,7 @@ char const * lyx_version = "@VERSION@";
 char const * lyx_release_date = "Fri, May 3, 2002";
 
 /// This version string is intended to be used in files created by LyX
-char const * lyx_docversion = "LyX 1.2";
+char const * lyx_docversion = "LyX 1.3";
 
 /// This is the version information shown by 'lyx -version'
 char const * lyx_version_info = "@VERSION_INFO@";