#include <fstream>
#include <iomanip>
+using lyx::support::FileName;
+
using std::endl;
using std::find;
using std::fill;
namespace {
-typedef pair<string, string> StrPair;
+typedef pair<string, FileName> SnippetPair;
// A list of alll snippets to be converted to previews
typedef list<string> PendingSnippets;
// Each item in the vector is a pair<snippet, image file name>.
-typedef vector<StrPair> BitmapFile;
+typedef vector<SnippetPair> BitmapFile;
string const unique_filename(string const & bufferpath)
if (from == to)
continue;
- lyx::Converter const * ptr = lyx::converters.getConverter(from, to);
+ lyx::Converter const * ptr = lyx::theConverters().getConverter(from, to);
if (ptr)
return ptr;
}
void setAscentFractions(vector<double> & ascent_fractions,
- string const & metrics_file)
+ FileName const & metrics_file)
{
// If all else fails, then the images will have equal ascents and
// descents.
vector<double>::iterator end = ascent_fractions.end();
fill(it, end, 0.5);
- ifstream in(metrics_file.c_str());
+ ifstream in(metrics_file.toFilesystemEncoding().c_str());
if (!in.good()) {
lyx::lyxerr[lyx::Debug::GRAPHICS]
<< "setAscentFractions(" << metrics_file << ")\n"
}
-class FindFirst : public std::unary_function<StrPair, bool> {
+class FindFirst : public std::unary_function<SnippetPair, bool> {
public:
FindFirst(string const & comp) : comp_(comp) {}
- bool operator()(StrPair const & sp) const
+ bool operator()(SnippetPair const & sp) const
{
return sp.first == comp_;
}
///
string command;
///
- string metrics_file;
+ FileName metrics_file;
///
BitmapFile snippets;
};
: to_format_(to_format), base_(filename_base), counter_(1)
{}
- StrPair const operator()(string const & snippet)
+ SnippetPair const operator()(string const & snippet)
{
ostringstream os;
os << base_ << counter_++ << '.' << to_format_;
string const file = os.str();
- return make_pair(snippet, file);
+ return make_pair(snippet, FileName(file));
}
private:
PendingSnippets const & pending,
string const & to_format)
: pid(0),
- metrics_file(filename_base + ".metrics"),
+ metrics_file(FileName(filename_base + ".metrics")),
snippets(pending.size())
{
PendingSnippets::const_iterator pit = pending.begin();
pending_.clear();
// Output the LaTeX file.
- string const latexfile = filename_base + ".tex";
+ FileName const latexfile(filename_base + ".tex");
// FIXME UNICODE
// This creates an utf8 encoded file, but the proper inputenc
// command is missing.
- odocfstream of(latexfile.c_str());
+ odocfstream of(latexfile.toFilesystemEncoding().c_str());
if (!of) {
lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()\n"
<< "Unable to create LaTeX file\n"
// The conversion command.
ostringstream cs;
cs << pconverter_->command << ' ' << pconverter_->to << ' '
- << support::quoteName(latexfile) << ' '
+ << support::quoteName(latexfile.toFilesystemEncoding()) << ' '
<< int(font_scaling_factor_) << ' '
- << theApp->hexName(LColor::preview) << ' '
- << theApp->hexName(LColor::background);
+ << theApp()->hexName(LColor::preview) << ' '
+ << theApp()->hexName(LColor::background);
string const command = support::libScriptSearch(cs.str());
int metrics_counter = 0;
for (; it != end; ++it, ++metrics_counter) {
string const & snip = it->first;
- string const & file = it->second;
+ FileName const & file = it->second;
double af = ascent_fractions[metrics_counter];
PreviewImagePtr ptr(new PreviewImage(parent_, snip, file, af));