move Buffer::nice to LaTeXFeatures

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8364 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-01-21 17:52:07 +00:00
parent ccc5d55764
commit 85fa1d41ba
8 changed files with 37 additions and 57 deletions

View File

@ -1,3 +1,7 @@
2004-01-19 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LaTeXFeatures.h: add nice_ and nice() const
* buffer.[Ch]: remove niceFile(), use LaTeXFeatures::nice() instead
2004-01-20 André Pönitz <poenitz@gmx.net>

View File

@ -42,8 +42,8 @@ using std::ostringstream;
using std::set;
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p)
: buffer_(b), params_(p)
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool n)
: buffer_(b), params_(p), nice_(n)
{}

View File

@ -39,7 +39,7 @@ struct Language;
class LaTeXFeatures {
public:
///
LaTeXFeatures(Buffer const &, BufferParams const &);
LaTeXFeatures(Buffer const &, BufferParams const &, bool);
/// The packages needed by the document
std::string const getPackages() const;
/// The macros definitions needed by the document
@ -82,6 +82,8 @@ public:
BufferParams const & bufferParams() const;
/// the return value is dependent upon both LyXRC and LaTeXFeatures.
bool useBabel() const;
///
bool nice() const { return nice_; };
private:
std::list<std::string> usedLayouts_;
@ -108,6 +110,10 @@ private:
Buffer const & buffer_;
///
BufferParams const & params_;
/** If we are writing a nice LaTeX file or not.
* Only needed by InsetInclude::validate().
*/
bool nice_;
};
#endif

View File

@ -148,7 +148,6 @@ struct Buffer::Impl
BufferParams params;
LyXVC lyxvc;
string temppath;
bool nicefile;
TexRow texrow;
/// need to regenerate .tex ?
@ -186,8 +185,7 @@ struct Buffer::Impl
Buffer::Impl::Impl(Buffer & parent, string const & file, bool readonly_)
: nicefile(true),
lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
: lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
filename(file), filepath(OnlyPath(file)), file_fully_loaded(false),
text(0, 0)
{
@ -294,18 +292,6 @@ string const & Buffer::temppath() const
}
bool & Buffer::niceFile()
{
return pimpl_->nicefile;
}
bool Buffer::niceFile() const
{
return pimpl_->nicefile;
}
TexRow & Buffer::texrow()
{
return pimpl_->texrow;
@ -848,11 +834,10 @@ void Buffer::makeLaTeXFile(ostream & os,
bool output_preamble, bool output_body)
{
OutputParams runparams = runparams_in;
niceFile() = runparams.nice; // this will be used by Insetincludes.
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
LaTeXFeatures features(*this, params());
LaTeXFeatures features(*this, params(), runparams.nice);
validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
@ -944,9 +929,6 @@ void Buffer::makeLaTeXFile(ostream & os,
lyxerr[Debug::INFO] << "Finished making LaTeX file." << endl;
lyxerr[Debug::INFO] << "Row count was " << texrow().rows() - 1
<< '.' << endl;
// we want this to be true outside previews (for insetexternal)
niceFile() = true;
}
@ -991,10 +973,7 @@ void Buffer::makeLinuxDocFile(string const & fname,
if (!openFileWrite(ofs, fname))
return;
niceFile() = runparams.nice; // this will be used by included files.
LaTeXFeatures features(*this, params());
LaTeXFeatures features(*this, params(), runparams.nice);
validate(features);
texrow().reset();
@ -1040,9 +1019,6 @@ void Buffer::makeLinuxDocFile(string const & fname,
ofs.close();
// How to check for successful close
// we want this to be true outside previews (for insetexternal)
niceFile() = true;
}
@ -1054,9 +1030,7 @@ void Buffer::makeDocBookFile(string const & fname,
if (!openFileWrite(ofs, fname))
return;
niceFile() = runparams.nice; // this will be used by Insetincludes.
LaTeXFeatures features(*this, params());
LaTeXFeatures features(*this, params(), runparams.nice);
validate(features);
texrow().reset();
@ -1101,9 +1075,6 @@ void Buffer::makeDocBookFile(string const & fname,
ofs.close();
// How to check for successful close
// we want this to be true outside previews (for insetexternal)
niceFile() = true;
}

View File

@ -275,12 +275,6 @@ public:
/// Where to put temporary files.
std::string const & temppath() const;
/** If we are writing a nice LaTeX file or not.
While writing as LaTeX, tells whether we are
doing a 'nice' LaTeX file */
bool & niceFile();
bool niceFile() const;
/// Used when typesetting to place errorboxes.
TexRow & texrow();
TexRow const & texrow() const;

View File

@ -1,3 +1,9 @@
2004-01-19 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* insetgraphics.C, insetinclude.C: use runparams.nice instead of
buffer->niceFile()
* insetinclude.C (validate): use feautures.nice() instead of
buffer->niceFile()
2004-01-20 André Pönitz <poenitz@gmx.net>

View File

@ -633,9 +633,9 @@ int InsetGraphics::plaintext(Buffer const &, ostream & os,
int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os,
OutputParams const &) const
OutputParams const & runparams) const
{
string const file_name = buf.niceFile() ?
string const file_name = runparams.nice ?
params().filename.relFilename(buf.filePath()):
params().filename.absFilename();

View File

@ -389,7 +389,7 @@ int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os,
// write it to a file (so far the complete file)
string writefile = ChangeExtension(included_file, ".sgml");
if (!buffer.temppath().empty() && !buffer.niceFile()) {
if (!buffer.temppath().empty() && !runparams.nice) {
incfile = subst(incfile, '/','@');
writefile = AddName(buffer.temppath(), incfile);
} else
@ -402,7 +402,6 @@ int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os,
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
OutputParams runp = runparams;
runp.nice = buffer.niceFile();
tmp->makeLinuxDocFile(writefile, runp, true);
}
@ -433,7 +432,7 @@ int InsetInclude::docbook(Buffer const & buffer, ostream & os,
// write it to a file (so far the complete file)
string writefile = ChangeExtension(included_file, ".sgml");
if (!buffer.temppath().empty() && !buffer.niceFile()) {
if (!buffer.temppath().empty() && !runparams.nice) {
incfile = subst(incfile, '/','@');
writefile = AddName(buffer.temppath(), incfile);
} else
@ -445,7 +444,6 @@ int InsetInclude::docbook(Buffer const & buffer, ostream & os,
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
OutputParams runp = runparams;
runp.nice = buffer.niceFile();
tmp->makeDocBookFile(writefile, runp, true);
}
@ -469,17 +467,20 @@ void InsetInclude::validate(LaTeXFeatures & features) const
string const included_file = includedFilename(buffer, params_);
if (!buffer.temppath().empty() &&
!buffer.niceFile() &&
!isVerbatim(params_)) {
if (IsLyXFilename(included_file))
writefile = ChangeExtension(writefile, ".sgml");
else if (!buffer.temppath().empty() &&
!features.nice() &&
!isVerbatim(params_)) {
incfile = subst(incfile, '/','@');
#ifdef __EMX__
// FIXME: It seems that the following is necessary (see latex() above)
// incfile = subst(incfile, ':', '$');
#endif
writefile = AddName(buffer.temppath(), incfile);
} else
writefile = included_file;
if (IsLyXFilename(included_file))
writefile = ChangeExtension(writefile, ".sgml");
features.includeFile(include_label, writefile);
if (isVerbatim(params_))
@ -491,10 +492,8 @@ void InsetInclude::validate(LaTeXFeatures & features) const
if (loadIfNeeded(buffer, params_)) {
// a file got loaded
Buffer * const tmp = bufferlist.getBuffer(included_file);
if (tmp) {
tmp->niceFile() = buffer.niceFile();
if (tmp)
tmp->validate(features);
}
}
}