From fcc833018cf7670591bec9bd792f05b5a3f017ad Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 19 Nov 2001 15:34:11 +0000 Subject: [PATCH] latexfeatures path from Michael git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3041 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 117 +++++++------ src/LaTeXFeatures.C | 314 ++++++++++++++++------------------ src/LaTeXFeatures.h | 138 +++++---------- src/buffer.C | 33 ++-- src/insets/ChangeLog | 4 + src/insets/figinset.C | 5 +- src/insets/insetcite.C | 2 +- src/insets/insetexternal.C | 2 +- src/insets/insetfloat.C | 4 +- src/insets/insetgraphics.C | 4 +- src/insets/insetinclude.C | 4 +- src/insets/insetindex.C | 2 +- src/insets/insetquotes.C | 12 +- src/insets/insetref.C | 4 +- src/insets/insetspecialchar.C | 2 +- src/insets/inseturl.C | 2 +- src/mathed/ChangeLog | 5 + src/mathed/math_hullinset.C | 7 +- src/mathed/math_macro.C | 2 +- src/paragraph.C | 14 +- src/tabular.C | 8 +- 21 files changed, 318 insertions(+), 367 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 30bf984f45..525ba0e7c2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,21 +1,24 @@ -src/buffer.C -src/bufferlist.C src/BufferView2.C -src/bufferview_funcs.C src/BufferView_pimpl.C src/Chktex.C src/ColorHandler.C -src/converter.C src/CutAndPaste.C +src/FontLoader.C +src/LColor.C +src/LaTeX.C +src/LyXAction.C +src/LyXSendto.C +src/LyXView.C +src/MenuBackend.C +src/buffer.C +src/bufferlist.C +src/bufferview_funcs.C +src/converter.C src/debug.C src/exporter.C -src/ext_l10n.h -src/figure_form.C src/figureForm.C -src/FontLoader.C -src/frontends/controllers/biblio.C +src/figure_form.C src/frontends/controllers/ButtonController.h -src/frontends/controllers/character.C src/frontends/controllers/ControlAboutlyx.C src/frontends/controllers/ControlBibtex.C src/frontends/controllers/ControlCharacter.C @@ -29,6 +32,8 @@ src/frontends/controllers/ControlSpellchecker.C src/frontends/controllers/ControlTexinfo.C src/frontends/controllers/ControlThesaurus.C src/frontends/controllers/ControlVCLog.C +src/frontends/controllers/biblio.C +src/frontends/controllers/character.C src/frontends/controllers/helper_funcs.C src/frontends/gnome/FormCitation.C src/frontends/gnome/FormIndex.C @@ -37,7 +42,6 @@ src/frontends/gnome/FormRef.C src/frontends/gnome/FormToc.C src/frontends/gnome/Menubar_pimpl.C src/frontends/qt2/FileDialog.C -src/frontends/qt2/lengthcombo.C src/frontends/qt2/QAbout.C src/frontends/qt2/QBibitem.C src/frontends/qt2/QBibtex.C @@ -46,8 +50,8 @@ src/frontends/qt2/QCharacter.C src/frontends/qt2/QCitation.C src/frontends/qt2/QCitationDialog.C src/frontends/qt2/QDocument.C -src/frontends/qt2/QError.C src/frontends/qt2/QERT.C +src/frontends/qt2/QError.C src/frontends/qt2/QExternal.C src/frontends/qt2/QExternalDialog.C src/frontends/qt2/QGraphics.C @@ -69,86 +73,87 @@ src/frontends/qt2/QThesaurus.C src/frontends/qt2/QToc.C src/frontends/qt2/QURL.C src/frontends/qt2/QVCLog.C -src/frontends/xforms/combox.C +src/frontends/qt2/lengthcombo.C src/frontends/xforms/FileDialog.C -src/frontends/xforms/form_aboutlyx.C src/frontends/xforms/FormAboutlyx.C -src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibitem.C -src/frontends/xforms/form_bibtex.C src/frontends/xforms/FormBibtex.C -src/frontends/xforms/form_browser.C -src/frontends/xforms/form_character.C src/frontends/xforms/FormCharacter.C -src/frontends/xforms/form_citation.C src/frontends/xforms/FormCitation.C -src/frontends/xforms/form_document.C src/frontends/xforms/FormDocument.C -src/frontends/xforms/form_error.C -src/frontends/xforms/FormError.C -src/frontends/xforms/form_ert.C src/frontends/xforms/FormERT.C -src/frontends/xforms/form_external.C +src/frontends/xforms/FormError.C src/frontends/xforms/FormExternal.C -src/frontends/xforms/form_filedialog.C src/frontends/xforms/FormFiledialog.C -src/frontends/xforms/form_float.C src/frontends/xforms/FormFloat.C -src/frontends/xforms/form_graphics.C src/frontends/xforms/FormGraphics.C -src/frontends/xforms/form_include.C src/frontends/xforms/FormInclude.C -src/frontends/xforms/form_index.C src/frontends/xforms/FormIndex.C src/frontends/xforms/FormLog.C src/frontends/xforms/FormMathsBitmap.C -src/frontends/xforms/form_maths_deco.C src/frontends/xforms/FormMathsDeco.C -src/frontends/xforms/form_maths_delim.C src/frontends/xforms/FormMathsDelim.C -src/frontends/xforms/form_maths_matrix.C src/frontends/xforms/FormMathsMatrix.C -src/frontends/xforms/form_maths_panel.C src/frontends/xforms/FormMathsPanel.C -src/frontends/xforms/form_maths_space.C src/frontends/xforms/FormMathsSpace.C -src/frontends/xforms/form_minipage.C src/frontends/xforms/FormMinipage.C -src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormParagraph.C -src/frontends/xforms/form_preamble.C src/frontends/xforms/FormPreamble.C -src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPreferences.C -src/frontends/xforms/form_print.C src/frontends/xforms/FormPrint.C -src/frontends/xforms/form_ref.C src/frontends/xforms/FormRef.C -src/frontends/xforms/form_search.C src/frontends/xforms/FormSearch.C -src/frontends/xforms/form_spellchecker.C src/frontends/xforms/FormSpellchecker.C -src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabular.C -src/frontends/xforms/form_tabular_create.C src/frontends/xforms/FormTabularCreate.C -src/frontends/xforms/form_texinfo.C src/frontends/xforms/FormTexinfo.C -src/frontends/xforms/form_thesaurus.C src/frontends/xforms/FormThesaurus.C -src/frontends/xforms/form_toc.C src/frontends/xforms/FormToc.C -src/frontends/xforms/form_url.C src/frontends/xforms/FormUrl.C src/frontends/xforms/FormVCLog.C -src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C +src/frontends/xforms/combox.C +src/frontends/xforms/form_aboutlyx.C +src/frontends/xforms/form_bibitem.C +src/frontends/xforms/form_bibtex.C +src/frontends/xforms/form_browser.C +src/frontends/xforms/form_character.C +src/frontends/xforms/form_citation.C +src/frontends/xforms/form_document.C +src/frontends/xforms/form_error.C +src/frontends/xforms/form_ert.C +src/frontends/xforms/form_external.C +src/frontends/xforms/form_filedialog.C +src/frontends/xforms/form_float.C +src/frontends/xforms/form_graphics.C +src/frontends/xforms/form_include.C +src/frontends/xforms/form_index.C +src/frontends/xforms/form_maths_deco.C +src/frontends/xforms/form_maths_delim.C +src/frontends/xforms/form_maths_matrix.C +src/frontends/xforms/form_maths_panel.C +src/frontends/xforms/form_maths_space.C +src/frontends/xforms/form_minipage.C +src/frontends/xforms/form_paragraph.C +src/frontends/xforms/form_preamble.C +src/frontends/xforms/form_preferences.C +src/frontends/xforms/form_print.C +src/frontends/xforms/form_ref.C +src/frontends/xforms/form_search.C +src/frontends/xforms/form_spellchecker.C +src/frontends/xforms/form_tabular.C +src/frontends/xforms/form_tabular_create.C +src/frontends/xforms/form_texinfo.C +src/frontends/xforms/form_thesaurus.C +src/frontends/xforms/form_toc.C +src/frontends/xforms/form_url.C +src/frontends/xforms/input_validators.C src/frontends/xforms/xforms_helpers.C src/gettext.h src/importer.C src/insets/figinset.C -src/insets/insetbib.C src/insets/inset.C +src/insets/insetbib.C src/insets/insetcaption.C src/insets/inseterror.C src/insets/insetert.C @@ -173,25 +178,19 @@ src/insets/insettoc.C src/insets/inseturl.C src/kbsequence.C src/language.C -src/LaTeX.C src/layout.C -src/LColor.C -src/LyXAction.C src/lyx_cb.C +src/lyx_gui_misc.C +src/lyx_main.C src/lyxfind.C src/lyxfont.C src/lyxfunc.C -src/lyx_gui_misc.C -src/lyx_main.C src/lyxrc.C -src/LyXSendto.C src/lyxvc.C -src/LyXView.C -src/mathed/formulabase.C src/mathed/formula.C +src/mathed/formulabase.C src/mathed/formulamacro.C src/mathed/math_cursor.C -src/MenuBackend.C src/minibuffer.C src/paragraph.C src/print_form.C @@ -200,6 +199,6 @@ src/support/getUserName.C src/support/path.C src/support/path.h src/tabular.C -src/text2.C src/text.C +src/text2.C src/ext_l10n.h diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 15ae1996ff..f208c53590 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -25,113 +25,91 @@ #include "support/lstrings.h" #include "FloatList.h" #include "language.h" +#include "encoding.h" using std::endl; +using std::set; LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n) : layout(n, false), params(p) { - // packages - array = false; - color = false; - graphics = false; // INSET_GRAPHICS: remove this when InsetFig is thrown. - graphicx = false; - setspace = false; - makeidx = false; - verbatim = false; - longtable = false; - //algorithm = false; - rotating = false; - amssymb = false; - latexsym = false; - pifont = false; - subfigure = false; - floatflt = false; - url = false; - varioref = false; - prettyref = false; - chess = false; - natbib = false; - floats = false; - // commands - lyx = false; - lyxline = false; - noun = false; - lyxarrow = false; - - // quotes - quotesinglbase = false; - quotedblbase = false; - guilsinglleft = false; - guilsinglright = false; - guillemotleft = false; - guillemotright = false; - - // Math mode - amsstyle = false; - binom = false; - boldsymbol = false; - - // special features - ParagraphIndent = false; - NeedLyXFootnoteCode = false; - NeedLyXMinipageIndent = false; } void LaTeXFeatures::require(string const & name) { - if (name == "array") { - array = true; - } else if (name == "color") { - color = true; - } else if (name == "graphics") { - graphicx = true; - graphics = true;// INSET_GRAPHICS: remove this when InsetFig is thrown. - } else if (name == "setspace") { - setspace = true; - } else if (name == "makeidx") { - makeidx = true; - } else if (name == "verbatim") { - verbatim = true; - } else if (name == "longtable") { - longtable = true; - //} else if (name == "algorithm") { - //algorithm = true; - } else if (name == "rotating") { - rotating = true; - } else if (name == "amssymb") { - amssymb = true; - } else if (name == "latexsym") { - latexsym = true; - } else if (name == "pifont") { - pifont = true; - } else if (name == "subfigure") { - subfigure = true; - } else if (name == "floatflt") { - floatflt = true; - } else if (name == "url") { - url = true; - } else if (name == "varioref") { - varioref = true; - } else if (name == "prettyref") { - prettyref = true; - } else if (name == "chess") { - chess = true; - } else if (name == "amsstyle") { - amsstyle = true; - } else if (name == "boldsymbol") { - boldsymbol = true; - } else if (name == "binom") { - binom = true; - } else if (name == "natbib") { - natbib = true; - } else if (name == "float") { - floats = true; - } + // INSET_GRAPHICS: remove this when InsetFig is thrown. + if (name == "graphics") { + features.push_back("graphicx"); + features.push_back("graphics"); + } else + features.push_back(name); + } +void LaTeXFeatures::useLayout(std::vector::size_type const & idx) +{ + layout[idx] = true; +} + +bool LaTeXFeatures::isRequired(string const & name) const +{ + FeaturesList::const_iterator i = std::find(features.begin(), + features.end(), + name); + return i!= features.end(); +} + +void LaTeXFeatures::addExternalPreamble(string const & pream) +{ + externalPreambles += pream; +} + +void LaTeXFeatures::useFloat(string const & name) +{ + usedFloats.insert(name); +} + +void LaTeXFeatures::useLanguage(Language const * lang) +{ + UsedLanguages.insert(lang); +} + +void LaTeXFeatures::includeFile(string const & key, string const & name) +{ + IncludedFiles[key] = name; +} + +bool LaTeXFeatures::hasLanguages() +{ + return !UsedLanguages.empty(); +} + +string LaTeXFeatures::getLanguages() const +{ + + ostringstream languages; + + for (LanguageList::const_iterator cit = + UsedLanguages.begin(); + cit != UsedLanguages.end(); + ++cit) + languages << (*cit)->babel() << ','; + + return languages.str().c_str(); +} + +set LaTeXFeatures::getEncodingSet(string const & doc_encoding) +{ + set encodings; + for (LanguageList::const_iterator it = + UsedLanguages.begin(); + it != UsedLanguages.end(); ++it) + if ((*it)->encoding()->LatexName() != doc_encoding) + encodings.insert((*it)->encoding()->LatexName()); + return encodings; +} string const LaTeXFeatures::getPackages() const { @@ -139,12 +117,61 @@ string const LaTeXFeatures::getPackages() const LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); - // array-package - if (array) + + /** + * These are all the 'simple' includes. i.e + * packages which we just \usepackage{package} + **/ + +// array-package + if (isRequired("array")) packages << "\\usepackage{array}\n"; + // verbatim.sty + if (isRequired("verbatim")) + packages << "\\usepackage{verbatim}\n"; + + //longtable.sty + if (isRequired("longtable")) + packages << "\\usepackage{longtable}\n"; + + //rotating.sty + if (isRequired("rotating")) + packages << "\\usepackage{rotating}\n"; + + + // latexsym.sty + if (isRequired("latexsym")) + packages << "\\usepackage{latexsym}\n"; + + // pifont.sty + if (isRequired("pifont")) + packages << "\\usepackage{pifont}\n"; + + // subfigure.sty + if (isRequired("subfigure")) + packages << "\\usepackage{subfigure}\n"; + + // floatflt.sty + if (isRequired("floatflt")) + packages << "\\usepackage{floatflt}\n"; + + + // varioref.sty + if (isRequired("varioref")) + packages << "\\usepackage{varioref}\n"; + + // prettyref.sty + if (isRequired("prettyref")) + packages << "\\usepackage{prettyref}\n"; + + /** + * The rest of these packages are somewhat more complicated + * than those above. + **/ + // color.sty - if (color) { + if (isRequired("color")) { if (params.graphicsDriver == "default") packages << "\\usepackage{color}\n"; else @@ -154,14 +181,14 @@ string const LaTeXFeatures::getPackages() const } // makeidx.sty - if (makeidx) { + if (isRequired("makeidx")) { if (! tclass.provides(LyXTextClass::makeidx)) packages << "\\usepackage{makeidx}\n"; packages << "\\makeindex\n"; } // graphicx.sty - if (graphicx && params.graphicsDriver != "none") { + if (isRequired("graphicx") && params.graphicsDriver != "none") { if (params.graphicsDriver == "default") packages << "\\usepackage{graphicx}\n"; else @@ -172,7 +199,7 @@ string const LaTeXFeatures::getPackages() const // INSET_GRAPHICS: remove this when InsetFig is thrown. // graphics.sty - if (graphics && params.graphicsDriver != "none") { + if (isRequired("graphics") && params.graphicsDriver != "none") { if (params.graphicsDriver == "default") packages << "\\usepackage{graphics}\n"; else @@ -181,23 +208,19 @@ string const LaTeXFeatures::getPackages() const << "]{graphics}\n"; } - // verbatim.sty - if (verbatim) - packages << "\\usepackage{verbatim}\n"; - //if (algorithm) { // packages << "\\usepackage{algorithm}\n"; //} // lyxskak.sty --- newer chess support based on skak.sty - if (chess) { + if (isRequired("chess")) { packages << "\\usepackage[ps,mover]{lyxskak}\n"; } // setspace.sty if ((params.spacing.getSpace() != Spacing::Single && !params.spacing.isDefault()) - || setspace) { + || isRequired("setspace")) { packages << "\\usepackage{setspace}\n"; } switch (params.spacing.getSpace()) { @@ -218,47 +241,14 @@ string const LaTeXFeatures::getPackages() const break; } - //longtable.sty - if (longtable) - packages << "\\usepackage{longtable}\n"; - - //rotating.sty - if (rotating) - packages << "\\usepackage{rotating}\n"; - // amssymb.sty - if (amssymb || params.use_amsmath) + if (isRequired("amssymb") || params.use_amsmath) packages << "\\usepackage{amssymb}\n"; - - // latexsym.sty - if (latexsym) - packages << "\\usepackage{latexsym}\n"; - - // pifont.sty - if (pifont) - packages << "\\usepackage{pifont}\n"; - - // subfigure.sty - if (subfigure) - packages << "\\usepackage{subfigure}\n"; - - // floatflt.sty - if (floatflt) - packages << "\\usepackage{floatflt}\n"; - // url.sty - if (url && ! tclass.provides(LyXTextClass::url)) + if (isRequired("url") && ! tclass.provides(LyXTextClass::url)) packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n" " {\\newcommand{\\url}{\\texttt}}\n"; - // varioref.sty - if (varioref) - packages << "\\usepackage{varioref}\n"; - - // prettyref.sty - if (prettyref) - packages << "\\usepackage{prettyref}\n"; - // float.sty // We only need float.sty if we use non builtin floats, or if we // use the "H" modifier. This includes modified table and @@ -269,17 +259,17 @@ string const LaTeXFeatures::getPackages() const for (; beg != end; ++beg) { Floating const & fl = floatList.getType((*beg)); if (!fl.type().empty() && !fl.builtin()) { - const_cast(this)->floats = true; + const_cast(this)->require("floats"); break; } } } - if (floats) { + if (isRequired("floats")) { packages << "\\usepackage{float}\n"; } // natbib.sty - if (natbib) { + if (isRequired("natbib")) { packages << "\\usepackage["; if (params.use_numerical_citations) { packages << "numbers"; @@ -292,6 +282,7 @@ string const LaTeXFeatures::getPackages() const packages << externalPreambles; return packages.str().c_str(); + } @@ -300,46 +291,46 @@ string const LaTeXFeatures::getMacros() const ostringstream macros; // always include this - if (true || lyx) + if (true || isRequired("lyx")) macros << lyx_def << '\n'; - if (lyxline) + if (isRequired("lyxline")) macros << lyxline_def << '\n'; - if (noun) { + if (isRequired("noun")) { macros << noun_def << '\n'; } - if (lyxarrow) { + if (isRequired("lyxarrow")) { macros << lyxarrow_def << '\n'; } // quotes. - if (quotesinglbase) + if (isRequired("quotesinglbase")) macros << quotesinglbase_def << '\n'; - if (quotedblbase) + if (isRequired("quotedblbase")) macros << quotedblbase_def << '\n'; - if (guilsinglleft) + if (isRequired("guilsinglleft")) macros << guilsinglleft_def << '\n'; - if (guilsinglright) + if (isRequired("guilsinglright")) macros << guilsinglright_def << '\n'; - if (guillemotleft) + if (isRequired("guillemotleft")) macros << guillemotleft_def << '\n'; - if (guillemotright) + if (isRequired("guillemotright")) macros << guillemotright_def << '\n'; // Math mode - if (boldsymbol && !amsstyle) + if (isRequired("boldsymbol") && !isRequired("amsstyle")) macros << boldsymbol_def << '\n'; - if (binom && !amsstyle) + if (isRequired("binom") && !isRequired("amsstyle")) macros << binom_def << '\n'; // other - if (NeedLyXMinipageIndent) + if (isRequired("NeedLyXMinipageIndent")) macros << minipageindent_def; - if (ParagraphIndent) + if (isRequired("ParagraphIndent")) macros << paragraphindent_def; - if (NeedLyXFootnoteCode) + if (isRequired("NeedLyXFootnoteCode")) macros << floatingfootnote_def; // floats @@ -365,9 +356,9 @@ string const LaTeXFeatures::getTClassPreamble() const tcpreamble << tclass.preamble(); - for (unsigned int i = 0; i < tclass.numLayouts(); ++i) { + for (LyXTextClass::size_type i = 0; i < tclass.numLayouts(); ++i) { if (layout[i]) { - tcpreamble << tclass[i].preamble(); + tcpreamble << tclass[i].preamble(); } } @@ -380,7 +371,7 @@ string const LaTeXFeatures::getLyXSGMLEntities() const // Definition of entities used in the document that are LyX related. ostringstream entities; - if (lyxarrow) { + if (isRequired("lyxarrow")) { entities << "" << '\n'; } @@ -419,7 +410,6 @@ BufferParams const & LaTeXFeatures::bufferParams() const return params; } - void LaTeXFeatures::getFloatDefinitions(std::ostream & os) const { // Here we will output the code to create the needed float styles. diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index f08002369d..bf49291929 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -19,6 +19,7 @@ #include #include +#include #include "LString.h" #include "layout.h" @@ -26,13 +27,22 @@ class BufferParams; struct Language; -/** The packages and commands that a buffer needs. This struct - contains an entry for each of the latex packages and - commands that a buffer might need. This struct is supposed to be - extended as the need arises. Remember to update the validate function - in buffer.C and paragraph.C when you do so. +/** The packages and commands that a buffer needs. This class + contains a list. Each of the LaTeX packages that a buffer needs + should be added with void require(string const & name). + + i.e require("amssymb") + + To add support you should only need to require() the package name as + packages which don't have special requirements are handled automatically. + If your new package does need special consideration you'll need to alter + string const getPackages() const; + Remember to update the validate function in buffer.C and paragraph.C + when you do so. */ -struct LaTeXFeatures { +class LaTeXFeatures { + +public: /// LaTeXFeatures(BufferParams const &, LyXTextClass::size_type n) ; /// The packages needed by the document @@ -43,100 +53,48 @@ struct LaTeXFeatures { string const getTClassPreamble() const; /// The sgml definitions needed by the document (dobook/linuxdoc) string const getLyXSGMLEntities() const; - /// + /// The SGML Required to include the files added with includeFile(); string const getIncludedFiles(string const & fname) const; - /// + /// Include a file for use with the SGML entities + void includeFile(string const & key, string const & name); + /// The float definitions. void getFloatDefinitions(std::ostream & os) const; - - /// + /// Print requirements to lyxerr void showStruct() const; - + /// + void addExternalPreamble(string const &); /// Provide a string name-space to the requirements void require(string const & name); + /// Is the package required? + bool isRequired(string const & name) const; + /// + void useFloat(string const & name); + /// + void useLanguage(Language const *); + /// + bool hasLanguages(); + /// + string getLanguages() const; + /// + std::set getEncodingSet(string const & doc_encoding); + /// + /// + void useLayout(std::vector::size_type const & idx); + /// + BufferParams const & bufferParams() const; + /// - /// Static preamble bits from the external material insets +private: string externalPreambles; - /// - bool array; - /// - bool color; // color.sty - /// - bool graphicx; // graphicx.sty - /// - bool graphics; // graphics.sty - /// - bool setspace; // setspace.sty - /// - bool makeidx; // makeind.sty - /// - bool verbatim; // verbatim.sty - /// - bool longtable; // longtable.sty - /// - //bool algorithm; // algorithm.sty - /// - bool rotating; // rotating.sty - /// - bool amssymb; // amssymb.sty - /// - bool latexsym; // latexsym.sty - /// - bool pifont; // pifont.sty - /// - bool subfigure; // subfigure.sty - /// - bool floatflt; // floatflt.sty - /// - bool url; // url.sty - /// - bool varioref; // varioref.sty - /// - bool prettyref; // prettyref.sty - /// - bool chess; // skak.sty (new chess support) - /// - bool natbib; // natbib.sty - /// - bool floats; // float.sty - - /// - bool lyx; - /// - bool lyxline; - /// \noun - bool noun; - /// \lyxarrow - bool lyxarrow; - - /// - bool quotesinglbase; - /// - bool quotedblbase; - /// - bool guilsinglleft; - /// - bool guilsinglright; - /// - bool guillemotleft; - /// - bool guillemotright; - - /// - bool amsstyle; - /// - bool boldsymbol; - /// - bool binom; - std::vector layout; + /// Static preamble bits from the external material insets + + + typedef std::list FeaturesList; /// - bool ParagraphIndent; - /// - bool NeedLyXFootnoteCode; - /// - bool NeedLyXMinipageIndent; + FeaturesList features; /// typedef std::set LanguageList; /// @@ -150,8 +108,6 @@ struct LaTeXFeatures { /// FileMap IncludedFiles; /// - BufferParams const & bufferParams() const; -private: /// BufferParams const & params; }; diff --git a/src/buffer.C b/src/buffer.C index b0f732739d..38c0739b7d 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2057,16 +2057,13 @@ void Buffer::makeLaTeXFile(string const & fname, if (params.language->babel() == "hebrew" && default_language->babel() != "hebrew") // This seems necessary - features.UsedLanguages.insert(default_language); + features.useLanguage(default_language); if (lyxrc.language_use_babel || params.language->lang() != lyxrc.default_language || - !features.UsedLanguages.empty()) { + !features.hasLanguages()) { use_babel = true; - for (LaTeXFeatures::LanguageList::const_iterator cit = - features.UsedLanguages.begin(); - cit != features.UsedLanguages.end(); ++cit) - language_options << (*cit)->babel() << ','; + language_options << features.getLanguages(); language_options << params.language->babel(); if (lyxrc.language_global_options) options << language_options.str() << ','; @@ -2113,12 +2110,7 @@ void Buffer::makeLaTeXFile(string const & fname, // Create a list with all the input encodings used // in the document - set encodings; - for (LaTeXFeatures::LanguageList::const_iterator it = - features.UsedLanguages.begin(); - it != features.UsedLanguages.end(); ++it) - if ((*it)->encoding()->LatexName() != doc_encoding) - encodings.insert((*it)->encoding()->LatexName()); + set encodings = features.getEncodingSet(doc_encoding); ofs << "\\usepackage["; std::copy(encodings.begin(), encodings.end(), @@ -2234,12 +2226,13 @@ void Buffer::makeLaTeXFile(string const & fname, ofs << "}\n"; texrow.newline(); } - if (features.amsstyle - && !tclass.provides(LyXTextClass::amsmath)) { + + if (features.isRequired("amsstyle") + && !tclass.provides(LyXTextClass::amsmath)) { ofs << "\\usepackage{amsmath}\n"; texrow.newline(); } - + if (tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle) >= 0) { if (params.pagestyle == "fancy") { @@ -3388,8 +3381,8 @@ void Buffer::validate(LaTeXFeatures & features) const textclasslist.TextClass(params.textclass); // AMS Style is at document level - features.amsstyle = (params.use_amsmath || - tclass.provides(LyXTextClass::amsmath)); + if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath)) + features.require("amsstyle"); while (par) { // We don't use "lyxerr.debug" because of speed. (Asger) @@ -3418,12 +3411,12 @@ void Buffer::validate(LaTeXFeatures & features) const || c == 25 || c == 26 || c == 31) { - features.latexsym = true; + features.require("latexsym"); } } else if (font == 1) { - features.amssymb = true; + features.require("amssymb"); } else if ((font >= 2 && font <= 5)) { - features.pifont = true; + features.require("pifont"); } } } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 8fa1a101d3..cd232a9c4e 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2001-11-11 Michael A. Koziarski + + * various: updated to use the new LaTeXFeatures + 2001-11-14 José Matos * insetspecialchar.C (linuxdoc): diff --git a/src/insets/figinset.C b/src/insets/figinset.C index e2e8c52032..2c6352033f 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -1194,8 +1194,9 @@ int InsetFig::docbook(Buffer const *, ostream & os) const void InsetFig::validate(LaTeXFeatures & features) const { - features.graphics = true; - if (subfigure) features.subfigure = true; + features.require("graphics"); + if (subfigure) + features.require("subfigure"); } diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index a02f0ed4af..7772349b6a 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -106,5 +106,5 @@ int InsetCitation::latex(Buffer const * buffer, std::ostream & os, void InsetCitation::validate(LaTeXFeatures & features) const { if (features.bufferParams().use_natbib) - features.natbib = true; + features.require("natbib"); } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 1b44579265..735480991c 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -185,7 +185,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const features.require(cit->second.requirement); } if (!cit->second.preamble.empty()) { - features.externalPreambles += cit->second.preamble + "\n"; + features.addExternalPreamble(cit->second.preamble + "\n"); } } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 8b8babdc11..93ae48a21f 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -185,10 +185,10 @@ void InsetFloat::read(Buffer const * buf, LyXLex & lex) void InsetFloat::validate(LaTeXFeatures & features) const { if (contains(placement(), "H")) { - features.floats = true; + features.require("floats"); } - features.usedFloats.insert(floatType_); + features.useFloat(floatType_); InsetCollapsable::validate(features); } diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 264c83548f..dbc36183f4 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -784,10 +784,10 @@ void InsetGraphics::validate(LaTeXFeatures & features) const if (params.filename.empty()) return ; - features.graphicx = true; + features.require("graphicx"); if (params.subcaption) - features.subfigure = true; + features.require("subfigure"); } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 7ee6d2f988..018c63fd66 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -394,10 +394,10 @@ void InsetInclude::validate(LaTeXFeatures & features) const if (IsLyXFilename(getFileName())) writefile = ChangeExtension(writefile, ".sgml"); - features.IncludedFiles[include_label] = writefile; + features.includeFile(include_label, writefile); if (isVerbatim()) - features.verbatim = true; + features.require("verbatim"); // Here we must do the fun stuff... // Load the file in the include if it needs diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 825129f02c..02498e2be3 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -62,7 +62,7 @@ string const InsetPrintIndex::getScreenLabel(Buffer const *) const void InsetPrintIndex::validate(LaTeXFeatures & features) const { - features.makeidx = true; + features.require("makeidx"); } diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 437b1d747f..c0058ea412 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -343,16 +343,16 @@ void InsetQuotes::validate(LaTeXFeatures & features) const && lyxrc.fontenc != "T1") { if (times_ == SingleQ) switch (type) { - case ',': features.quotesinglbase = true; break; - case '<': features.guilsinglleft = true; break; - case '>': features.guilsinglright = true; break; + case ',': features.require("quotesinglbase"); break; + case '<': features.require("guilsinglleft"); break; + case '>': features.require("guilsinglright"); break; default: break; } else switch (type) { - case ',': features.quotedblbase = true; break; - case '<': features.guillemotleft = true; break; - case '>': features.guillemotright = true; break; + case ',': features.require("quotedblbase"); break; + case '<': features.require("guillemotleft"); break; + case '>': features.require("guillemotright"); break; default: break; } } diff --git a/src/insets/insetref.C b/src/insets/insetref.C index e9d2c8d69d..b35e77e7c7 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -101,9 +101,9 @@ int InsetRef::docbook(Buffer const *, ostream & os) const void InsetRef::validate(LaTeXFeatures & features) const { if (getCmdName() == "vref" || getCmdName() == "vpageref") - features.varioref = true; + features.require("varioref"); else if (getCmdName() == "prettyref") - features.prettyref = true; + features.require("prettyref"); } InsetRef::type_info InsetRef::types[] = { diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index 4e913c1c32..27eaa25f34 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -318,7 +318,7 @@ Inset * InsetSpecialChar::clone(Buffer const &, bool) const void InsetSpecialChar::validate(LaTeXFeatures & features) const { if (kind_ == MENU_SEPARATOR) { - features.lyxarrow = true; + features.require("lyxarrow"); } } diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 03531c8db8..0b95b22a27 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -91,5 +91,5 @@ int InsetUrl::DocBook(Buffer const *, ostream & os) const void InsetUrl::validate(LaTeXFeatures & features) const { - features.url = true; + features.require("url"); } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index dabc4ff5be..1e550b9644 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2001-11-11 Michael A. Koziarski + + * math_macro.C + * math_hullinset.C: Fixes to use the new LaTeXFeatures + correctly. 2001-11-07 André Pönitz diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 9ab4bf1223..17d74c1079 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -252,14 +252,17 @@ bool MathHullInset::numberedType() const void MathHullInset::validate(LaTeXFeatures & features) const { - features.amsstyle = ams(); + + if (ams()) + features.require("amsstyle"); + // Validation is necessary only if not using AMS math. // To be safe, we will always run mathedvalidate. //if (features.amsstyle) // return; - features.boldsymbol = true; + features.require("boldsymbol"); //features.binom = true; MathNestInset::validate(features); diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 984da2814d..8f413d47bd 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -189,7 +189,7 @@ bool MathMacro::idxRight(idx_type &, pos_type &) const void MathMacro::validate(LaTeXFeatures & features) const { if (name() == "binom") - features.binom = true; + features.require("binom"); //MathInset::validate(features); } diff --git a/src/paragraph.C b/src/paragraph.C index ece9443eb4..b9c8086dfd 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -329,12 +329,12 @@ void Paragraph::validate(LaTeXFeatures & features) const // check the params. if (params().lineTop() || params().lineBottom()) - features.lyxline = true; + features.require("lyxline"); if (!params().spacing().isDefault()) - features.setspace = true; + features.require("setspace"); // then the layouts - features.layout[getLayout()] = true; + features.useLayout(getLayout()); // then the fonts Language const * doc_language = bparams.language; @@ -345,7 +345,7 @@ void Paragraph::validate(LaTeXFeatures & features) const lyxerr[Debug::LATEX] << "font.noun: " << cit->font().noun() << endl; - features.noun = true; + features.require("noun"); lyxerr[Debug::LATEX] << "Noun enabled. Font: " << cit->font().stateText(0) << endl; @@ -360,7 +360,7 @@ void Paragraph::validate(LaTeXFeatures & features) const case LColor::note: break; default: - features.color = true; + features.require("color"); lyxerr[Debug::LATEX] << "Color enabled. Font: " << cit->font().stateText(0) << endl; @@ -374,7 +374,7 @@ void Paragraph::validate(LaTeXFeatures & features) const #endif language != latex_language) { - features.UsedLanguages.insert(language); + features.useLanguage(language); lyxerr[Debug::LATEX] << "Found language " << language->babel() << endl; } @@ -391,7 +391,7 @@ void Paragraph::validate(LaTeXFeatures & features) const cit->inset->validate(features); if (layout.needprotect && cit->inset->lyxCode() == Inset::FOOT_CODE) - features.NeedLyXFootnoteCode = true; + features.require("NeedLyXFootnoteCode"); } } } diff --git a/src/tabular.C b/src/tabular.C index 0c201c501a..58b9dbcd0c 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2620,12 +2620,12 @@ InsetText * LyXTabular::GetCellInset(int row, int column) const void LyXTabular::Validate(LaTeXFeatures & features) const { if (IsLongTabular()) - features.longtable = true; + features.require("longtable"); if (NeedRotating()) - features.rotating = true; - for (int cell = 0; !features.array && (cell < numberofcells); ++cell) { + features.require("rotating"); + for (int cell = 0; !features.isRequired("array") && (cell < numberofcells); ++cell) { if (GetVAlignment(cell) != LYX_VALIGN_TOP) - features.array = true; + features.require("array"); GetCellInset(cell)->validate(features); } }