Jean-Marc Lasgouttes wrote:

>>>>>>"Michael" == Michael A Koziarski <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Michael> This is the last patch I'll be able to contribute till late
>Michael> next week some time. Hopefully there's nothing that can
>Michael> prevent it being applied.
>
>A few comments/ideas (although I think this patch is definitely good).
>
>1/ You could have a simple helper function
>
>void handleFeature(std::ostream os, string const &name) const
>{
>  if(isRequired(name))
>        os << "\usepackage{" << name << "\}\n";
>}
>
If we install a packagemanager we need something like
 
void LaTeXFeatures::require(string const & name,
                            string const & options = "[]{}")

where options get the packageoptions (in []) and additional
stuff (in {}). than we have

bool LaTeXFeatures::isRequired(string const & name) const {
    UsedPackages::const_iterator cit = usedPackages.find(name);
    return cit != usedPackages.end();
}

string const LaTeXFeatures::getPackages() const {
    ostringstream packages;
    LyXTextClass const & tclass =
        textclasslist.TextClass(params.textclass);
    UsedPackages::const_iterator cit = usedPackages.begin();
    for (; cit != usedPackages.end(); ++cit) {
        string const name = cit->first;
        string options = lyx::token(cit->second,'{',0);
        string addStuff = lyx::token(lyx::split(cit->second,'{'), '}',0);

        // at first all the special stuff which needs more than an
        // easy \usepackage{}
        if ((name == "color") && (params.graphicsDriver != "default"))
            options = "["+ params.graphicsDriver+"]";
        else if ((name == "graphicx") &&
                (params.graphicsDriver != "none") &&
[...]
        } else if ((name == "url") && !tclass.provides(LyXTextClass::url))
            addStuff = "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
                            "                      
{\\newcommand{\\url}{\\texttt}}";
        else if (name == "html")
            addStuff = "\\latex{\\renewcommand{\\htmladdnormallink}[2]{"
                        "#1 (\\url{#2})}}";
[...]
        packages << "\\usepackage" << options << '{' << name << "}\n";
        if (!addStuff.empty())
            packages << addStuff << '\n';   
    }
[...]

in the preferences we can save optional lists where the user can
save his individuell order of loading packages. for example:

first = url, html
last = hyperref, babel


Herbert



Reply via email to