mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Rationalize the handling of InsetLayout's preamble and requries. That is,
bring it into line with the handing of Layout's preamble and requires. This will make information about used InsetLayout's avaiable elsewhere. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29914 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d3ff1d16e3
commit
658457b847
@ -29,6 +29,8 @@
|
||||
#include "LyXRC.h"
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "insets/InsetLayout.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/FileName.h"
|
||||
@ -357,6 +359,26 @@ void LaTeXFeatures::useLayout(docstring const & layoutname)
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::useInsetLayout(InsetLayout const & lay)
|
||||
{
|
||||
docstring const & lname = lay.name();
|
||||
DocumentClass const & tclass = params_.documentClass();
|
||||
if (!tclass.hasInsetLayout(lname)) {
|
||||
lyxerr << "LaTeXFeatures::useInsetLayout: layout `"
|
||||
<< to_utf8(lname) << "' does not exist in this class"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
// Is this layout already in usedInsetLayouts?
|
||||
if (find(usedInsetLayouts_.begin(), usedInsetLayouts_.end(), lname)
|
||||
!= usedInsetLayouts_.end())
|
||||
return;
|
||||
|
||||
require(lay.requires());
|
||||
usedInsetLayouts_.push_back(lname);
|
||||
}
|
||||
|
||||
|
||||
bool LaTeXFeatures::isRequired(string const & name) const
|
||||
{
|
||||
return features_.find(name) != features_.end();
|
||||
@ -895,6 +917,16 @@ docstring const LaTeXFeatures::getTClassPreamble() const
|
||||
for (; cit != end; ++cit)
|
||||
tcpreamble << tclass[*cit].preamble();
|
||||
|
||||
cit = usedInsetLayouts_.begin();
|
||||
end = usedInsetLayouts_.end();
|
||||
TextClass::InsetLayouts const & ils = tclass.insetLayouts();
|
||||
for (; cit != end; ++cit) {
|
||||
TextClass::InsetLayouts::const_iterator it = ils.find(*cit);
|
||||
if (it == ils.end())
|
||||
continue;
|
||||
tcpreamble << it->second.preamble();
|
||||
}
|
||||
|
||||
return tcpreamble.str();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace lyx {
|
||||
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
class InsetLayout;
|
||||
class Language;
|
||||
|
||||
/** The packages and commands that a buffer needs. This class
|
||||
@ -98,6 +99,8 @@ public:
|
||||
///
|
||||
void useLayout(docstring const & lyt);
|
||||
///
|
||||
void useInsetLayout(InsetLayout const & lay);
|
||||
///
|
||||
Buffer const & buffer() const;
|
||||
///
|
||||
void setBuffer(Buffer const &);
|
||||
@ -113,8 +116,10 @@ public:
|
||||
OutputParams const & runparams() const { return runparams_; }
|
||||
|
||||
private:
|
||||
///
|
||||
std::list<docstring> usedLayouts_;
|
||||
|
||||
///
|
||||
std::list<docstring> usedInsetLayouts_;
|
||||
/// The features that are needed by the document
|
||||
typedef std::set<std::string> Features;
|
||||
///
|
||||
|
@ -873,10 +873,7 @@ int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) c
|
||||
|
||||
void InsetCollapsable::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
string const preamble = getLayout().preamble();
|
||||
if (!preamble.empty())
|
||||
features.addPreambleSnippet(preamble);
|
||||
features.require(getLayout().requires());
|
||||
features.useInsetLayout(getLayout());
|
||||
InsetText::validate(features);
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
bgcolor_ = lcolor.getFromLyXName(tmp);
|
||||
break;
|
||||
case IL_PREAMBLE:
|
||||
preamble_ = lex.getLongString("EndPreamble");
|
||||
preamble_ = from_utf8(lex.getLongString("EndPreamble"));
|
||||
break;
|
||||
case IL_REQUIRES: {
|
||||
lex.eatLine();
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
///
|
||||
ColorCode bgcolor() const { return bgcolor_; };
|
||||
///
|
||||
std::string preamble() const { return preamble_; };
|
||||
docstring preamble() const { return preamble_; };
|
||||
///
|
||||
std::set<std::string> requires() const { return requires_; };
|
||||
///
|
||||
@ -124,7 +124,7 @@ private:
|
||||
///
|
||||
ColorCode bgcolor_;
|
||||
///
|
||||
std::string preamble_;
|
||||
docstring preamble_;
|
||||
///
|
||||
std::set<std::string> requires_;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user