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
This commit is contained in:
Jean-Marc Lasgouttes 2002-01-10 10:05:45 +00:00
parent 76d05a79f2
commit a02a2714dc
13 changed files with 126 additions and 108 deletions

View File

@ -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

View File

@ -1,3 +1,26 @@
2002-01-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* lyxrc.C (getDescription): document that document_path and
template_path can be empty.
2002-01-09 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* 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 <michael@koziarski.org>
* LaTeXFeatures.C (require): Prevent duplicate entries in the
features list.
2002-01-08 Angus Leeming <a.leeming@ic.ac.uk>
* FuncStatus.C: small compile fix for DEC cxx. Doesn't like

View File

@ -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<string> 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<LaTeXFeatures *>(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)
}

View File

@ -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)

View File

@ -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 :
*
* <regular expression to match> | <description>
*

View File

@ -1,3 +1,14 @@
2002-01-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* 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 <martin.vermeer@hut.fi>
* forms/form_maths_style.fd:

View File

@ -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;

View File

@ -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;
}

View File

@ -1,3 +1,7 @@
2002-01-09 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insetfloat.C (validate): require "float" instead of "floats".
2002-01-08 Martin Vermeer <martin.vermeer@hut.fi>
* insettabular.C (getStatus): use FuncStatus

View File

@ -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_);

View File

@ -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:

View File

@ -1,3 +1,8 @@
2002-01-09 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* math_hullinset.C (validate): rename feature "amsstyle" to
"amsmath".
2002-01-09 Martin Vermeer <martin.vermeer@hut.fi>
* math_support.C: modified to support a mathed pop-up for math

View File

@ -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.