#include "Buffer.h"
#include "BufferParams.h"
#include "ColorSet.h"
+#include "Converter.h"
#include "Encoding.h"
#include "Floating.h"
#include "FloatList.h"
#include "LyXRC.h"
#include "TextClass.h"
+#include "insets/InsetLayout.h"
+
#include "support/debug.h"
#include "support/docstream.h"
#include "support/FileName.h"
}
+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();
bool LaTeXFeatures::isAvailable(string const & name)
{
+ string::size_type const i = name.find("->");
+ if (i != string::npos) {
+ string const from = name.substr(0,i);
+ string const to = name.substr(i+2);
+ LYXERR0("from=[" << from << "] to=[" << to << "]");
+ return theConverters().isReachable(from, to);
+ }
+
if (packages_.empty())
getAvailable();
string n = name;
if (mustProvide("pdfcolmk"))
colors << "\\usepackage{pdfcolmk}\n";
+ if (mustProvide("pagecolor")) {
+ // the \pagecolor command must be set after color is loaded and
+ // before pdfpages, therefore add the command here
+ // define the set color
+ colors << "\\definecolor{page_backgroundcolor}{rgb}{";
+ colors << outputLaTeXColor(params_.backgroundcolor) << "}\n";
+ // set the page color
+ colors << "\\pagecolor{page_backgroundcolor}\n";
+ }
+
return colors.str();
}
// [x]color and pdfcolmk are handled in getColorOptions() above
// makeidx.sty
- if (isRequired("makeidx")) {
- if (!tclass.provides("makeidx"))
+ if (isRequired("makeidx") || isRequired("splitidx")) {
+ if (!tclass.provides("makeidx") && !isRequired("splitidx"))
packages << "\\usepackage{makeidx}\n";
+ if (!tclass.provides("splitidx") && isRequired("splitidx"))
+ packages << "\\usepackage{splitidx}\n";
packages << "\\makeindex\n";
}
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();
+}
+
+
+docstring const LaTeXFeatures::getTClassHTMLPreamble() const
+{
+ DocumentClass const & tclass = params_.documentClass();
+ odocstringstream tcpreamble;
+
+ tcpreamble << tclass.htmlpreamble();
+
+ list<docstring>::const_iterator cit = usedLayouts_.begin();
+ list<docstring>::const_iterator end = usedLayouts_.end();
+ for (; cit != end; ++cit)
+ tcpreamble << tclass[*cit].htmlpreamble();
+
+ 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.htmlpreamble();
+ }
+
+ return tcpreamble.str();
+}
+
+
+docstring const LaTeXFeatures::getTClassHTMLStyles() const {
+ DocumentClass const & tclass = params_.documentClass();
+ odocstringstream tcpreamble;
+
+ list<docstring>::const_iterator cit = usedLayouts_.begin();
+ list<docstring>::const_iterator end = usedLayouts_.end();
+ for (; cit != end; ++cit)
+ tcpreamble << tclass[*cit].htmlstyle();
+
+ 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.htmlstyle();
+ }
+
return tcpreamble.str();
}