From a02a2714dca81c8641013aaf22d01dc7a32cee60 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 10 Jan 2002 10:05:45 +0000 Subject: [PATCH] updates to latexfeatures stuff; allow empty \document_path git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3324 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 2 + src/ChangeLog | 23 ++++++ src/LaTeXFeatures.C | 108 ++++++++++--------------- src/buffer.C | 8 +- src/frontends/FileDialog.h | 19 +++-- src/frontends/xforms/ChangeLog | 11 +++ src/frontends/xforms/FormFiledialog.C | 42 +++++----- src/frontends/xforms/FormPreferences.C | 4 +- src/insets/ChangeLog | 4 + src/insets/insetfloat.C | 2 +- src/lyxrc.C | 4 +- src/mathed/ChangeLog | 5 ++ src/mathed/math_hullinset.C | 2 +- 13 files changed, 126 insertions(+), 108 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 70e9cdc541..20a05e23d2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -112,6 +112,8 @@ 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_maths_style.C +src/frontends/xforms/FormMathsStyle.C src/frontends/xforms/form_minipage.C src/frontends/xforms/FormMinipage.C src/frontends/xforms/form_paragraph.C diff --git a/src/ChangeLog b/src/ChangeLog index 36313b6f5d..c2146b4cbc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,26 @@ +2002-01-10 Jean-Marc Lasgouttes + + * lyxrc.C (getDescription): document that document_path and + template_path can be empty. + +2002-01-09 Jean-Marc Lasgouttes + + * LaTeXFeatures.C (getMacros): + * buffer.C (validate): rename feature "amsstyle" to "amsmath" + + * buffer.C (makeLaTeXFile): remove test for "amsstyle" from here. + + * LaTeXFeatures.C (useFloat): require "float" here instead of in + getPackages. + (getPackages): rename feature "floats" to "float". Use an array to + iterate over 'simple' features (i.e. just a \usepackage). Add + handling of "amsmath" (renamed from "amsstyle"). + +2001-12-29 Michael A. Koziarski + + * LaTeXFeatures.C (require): Prevent duplicate entries in the + features list. + 2002-01-08 Angus Leeming * FuncStatus.C: small compile fix for DEC cxx. Doesn't like diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 92462114bf..cb28134d43 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -41,6 +41,9 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, layout_type n) void LaTeXFeatures::require(string const & name) { + if (isRequired(name)) + return; + // INSET_GRAPHICS: remove this when InsetFig is thrown. if (name == "graphics") { features.push_back("graphicx"); @@ -74,6 +77,13 @@ void LaTeXFeatures::addExternalPreamble(string const & pream) void LaTeXFeatures::useFloat(string const & name) { usedFloats.insert(name); + // We only need float.sty if we use non builtin floats, or if we + // use the "H" modifier. This includes modified table and + // figure floats. (Lgb) + Floating const & fl = floatList.getType(name); + if (!fl.type().empty() && !fl.builtin()) { + require("float"); + } } @@ -120,6 +130,25 @@ set LaTeXFeatures::getEncodingSet(string const & doc_encoding) return encodings; } +namespace { + +char const * simplefeatures[] = { + "array", + "verbatim", + "longtable", + "rotating", + "latexsym", + "pifont", + "subfigure", + "floatflt", + "varioref", + "prettyref", + "float" +}; + +const int nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *); + +} string const LaTeXFeatures::getPackages() const { @@ -132,54 +161,23 @@ string const LaTeXFeatures::getPackages() const * 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"; - + for (int i = 0 ; i < nb_simplefeatures ; ++i) { + if (isRequired(simplefeatures[i])) + packages << "\\usepackage{" + << simplefeatures[i] + << "}\n"; + } + /** * The rest of these packages are somewhat more complicated * than those above. **/ + if (isRequired("amsmath") + && ! tclass.provides(LyXTextClass::amsmath)) { + packages << "\\usepackage{amsmath}\n"; + } + // color.sty if (isRequired("color")) { if (params.graphicsDriver == "default") @@ -260,24 +258,6 @@ string const LaTeXFeatures::getPackages() const " {\\newcommand{\\url}{\\texttt}}\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 - // figure floats. (Lgb) - if (!usedFloats.empty()) { - UsedFloats::const_iterator beg = usedFloats.begin(); - UsedFloats::const_iterator end = usedFloats.end(); - for (; beg != end; ++beg) { - Floating const & fl = floatList.getType((*beg)); - if (!fl.type().empty() && !fl.builtin()) { - const_cast(this)->require("floats"); - break; - } - } - } - if (isRequired("floats")) { - packages << "\\usepackage{float}\n"; - } - // natbib.sty if (isRequired("natbib")) { packages << "\\usepackage["; @@ -327,9 +307,9 @@ string const LaTeXFeatures::getMacros() const macros << guillemotright_def << '\n'; // Math mode - if (isRequired("boldsymbol") && !isRequired("amsstyle")) + if (isRequired("boldsymbol") && !isRequired("amsmath")) macros << boldsymbol_def << '\n'; - if (isRequired("binom") && !isRequired("amsstyle")) + if (isRequired("binom") && !isRequired("amsmath")) macros << binom_def << '\n'; // other @@ -467,7 +447,7 @@ void LaTeXFeatures::getFloatDefinitions(std::ostream & os) const << name << "}\n"; // What missing here is to code to minimalize the code - // outputted so that the same floatstyle will not be + // output so that the same floatstyle will not be // used several times, when the same style is still in // effect. (Lgb) } diff --git a/src/buffer.C b/src/buffer.C index 20bd850f45..e241f7373e 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2322,12 +2322,6 @@ void Buffer::makeLaTeXFile(string const & fname, texrow.newline(); } - 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") { @@ -3491,7 +3485,7 @@ void Buffer::validate(LaTeXFeatures & features) const // AMS Style is at document level if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath)) - features.require("amsstyle"); + features.require("amsmath"); while (par) { // We don't use "lyxerr.debug" because of speed. (Asger) diff --git a/src/frontends/FileDialog.h b/src/frontends/FileDialog.h index 02d7ae3b12..6b1533be7c 100644 --- a/src/frontends/FileDialog.h +++ b/src/frontends/FileDialog.h @@ -44,24 +44,27 @@ public: /** * Constructs a file dialog attached to LyXView \param lv, with - * title \param title. If param \a is \const LFUN_SELECT_FILE_SYNC + * title \param title. If \param a is \const LFUN_SELECT_FILE_SYNC * then a value will be returned immediately upon performing a Select(), * otherwise a callback Dispatch() will be invoked with the filename as * argument, of action \param a. * - * Up to two optional extra buttons are allowed for specifying addtional - * directories in the navigation. + * Up to two optional extra buttons are allowed for specifying + * additional directories in the navigation (an empty + * directory is interpreted as getcwd()) */ - FileDialog(LyXView * lv, string const & title, kb_action a = LFUN_SELECT_FILE_SYNC, - Button b1 = Button(string(), string()), - Button b2 = Button(string(), string())); + FileDialog(LyXView * lv, string const & title, + kb_action a = LFUN_SELECT_FILE_SYNC, + Button b1 = Button(string(), string()), + Button b2 = Button(string(), string())); ~FileDialog(); /** - * Choose a file for selection, starting in directory \param path, with the file - * selection \param mask. The \param mask string is of the form : + * Choose a file for selection, starting in directory \param + * path, with the file selection \param mask. The \param mask + * string is of the form : * * | * diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 2697bf5317..e8c54d6a1c 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2002-01-10 Jean-Marc Lasgouttes + + * FormPreferences.C (input): allow empty values for document_path + and template_path. + + * FormFiledialog.C (SetButton): + (FileDlgCB): do not disable directory buttons if they have an + empty path. + (SetDirectory): if the argument is an empty string, change to + cwd(). + 2002-01-09 Martin Vermeer * forms/form_maths_style.fd: diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index 3e67b753b4..53cbf5e042 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -375,15 +375,13 @@ void FileDialog::Private::Reread() // SetDirectory: sets dialog current directory void FileDialog::Private::SetDirectory(string const & Path) { + string tmp; - - if (!pszDirectory.empty()) { - string TempPath = ExpandPath(Path); // Expand ~/ - TempPath = MakeAbsPath(TempPath, pszDirectory); - tmp = MakeAbsPath(TempPath); - } else { - tmp = MakeAbsPath(Path); - } + + if (Path.empty()) + tmp = lyx::getcwd(); + else + tmp = MakeAbsPath(ExpandPath(Path), pszDirectory); // must check the directory exists DIR * pDirectory = ::opendir(tmp.c_str()); @@ -481,7 +479,7 @@ void FileDialog::Private::SetButton(int iIndex, string const & pszName, pTemp = &pszUserPath2; } else return; - if (!pszName.empty() && !pszPath.empty()) { + if (!pszName.empty()) { fl_set_object_label(pObject, pszName.c_str()); fl_show_object(pObject); *pTemp = pszPath; @@ -558,21 +556,17 @@ void FileDialog::Private::FileDlgCB(FL_OBJECT *, long lArgument) break; case 12: // user button 1 - if (!pCurrentDlg->pszUserPath1.empty()) { - pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1); - pCurrentDlg->SetMask(fl_get_input(pFileDlgForm - ->PatBox)); - pCurrentDlg->Reread(); - } + pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1); + pCurrentDlg->SetMask(fl_get_input(pFileDlgForm + ->PatBox)); + pCurrentDlg->Reread(); break; case 13: // user button 2 - if (!pCurrentDlg->pszUserPath2.empty()) { - pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2); - pCurrentDlg->SetMask(fl_get_input(pFileDlgForm - ->PatBox)); - pCurrentDlg->Reread(); - } + pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2); + pCurrentDlg->SetMask(fl_get_input(pFileDlgForm + ->PatBox)); + pCurrentDlg->Reread(); break; } @@ -716,8 +710,10 @@ void FileDialog::Private::Force(bool cancel) // Select: launches dialog and returns selected file -string const FileDialog::Private::Select(string const & title, string const & path, - string const & mask, string const & suggested) +string const FileDialog::Private::Select(string const & title, + string const & path, + string const & mask, + string const & suggested) { // handles new mask and path bool isOk = true; diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 083a47c27b..929a6efe38 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -2157,7 +2157,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (!ob || ob == dialog_->input_default_path) { string const name = fl_get_input(dialog_->input_default_path); - if (!RWInfo::WriteableDir(name)) { + if (!name.empty() && !RWInfo::WriteableDir(name)) { parent_.printWarning(RWInfo::ErrorMessage()); return false; } @@ -2165,7 +2165,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob) if (!ob || ob == dialog_->input_template_path) { string const name = fl_get_input(dialog_->input_template_path); - if (!RWInfo::ReadableDir(name)) { + if (!name.empty() && !RWInfo::ReadableDir(name)) { parent_.printWarning(RWInfo::ErrorMessage()); return false; } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index bef607c9f0..391812b3a6 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2002-01-09 Jean-Marc Lasgouttes + + * insetfloat.C (validate): require "float" instead of "floats". + 2002-01-08 Martin Vermeer * insettabular.C (getStatus): use FuncStatus diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 1d4c3614cb..e31523429f 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -185,7 +185,7 @@ void InsetFloat::read(Buffer const * buf, LyXLex & lex) void InsetFloat::validate(LaTeXFeatures & features) const { if (contains(placement(), "H")) { - features.require("floats"); + features.require("float"); } features.useFloat(floatType_); diff --git a/src/lyxrc.C b/src/lyxrc.C index 857c2d96f0..b7a5035676 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -1786,11 +1786,11 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_DOCUMENTPATH: - str = N_("The default path for your documents."); + str = N_("The default path for your documents. An empty value selects the directory LyX was started from."); break; case RC_TEMPLATEPATH: - str = N_("The path that LyX will set when offering to choose a template."); + str = N_("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from."); break; case RC_TEMPDIRPATH: diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index ee3cda7a21..e39c887e0a 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2002-01-09 Jean-Marc Lasgouttes + + * math_hullinset.C (validate): rename feature "amsstyle" to + "amsmath". + 2002-01-09 Martin Vermeer * math_support.C: modified to support a mathed pop-up for math diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index e2683fcf29..0e0db0d0d0 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -261,7 +261,7 @@ bool MathHullInset::numberedType() const void MathHullInset::validate(LaTeXFeatures & features) const { if (ams()) - features.require("amsstyle"); + features.require("amsmath"); // Validation is necessary only if not using AMS math. -- 2.39.2