#include "Buffer.h"
#include "buffer_funcs.h"
#include "BufferParams.h"
-#include "debug.h"
#include "ErrorList.h"
#include "Format.h"
-#include "gettext.h"
#include "Language.h"
#include "LaTeX.h"
#include "Mover.h"
#include "frontends/alert.h"
+#include "support/debug.h"
+#include "support/FileNameList.h"
#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/lyxlib.h"
#include "support/os.h"
#include "support/Package.h"
#include "support/Path.h"
#include "support/Systemcall.h"
-using std::find_if;
-using std::string;
-using std::vector;
-using std::distance;
-
+using namespace std;
+using namespace lyx::support;
namespace lyx {
-using support::addName;
-using support::bformat;
-using support::changeExtension;
-using support::compare_ascii_no_case;
-using support::contains;
-using support::dirList;
-using support::FileName;
-using support::getExtension;
-using support::libFileSearch;
-using support::libScriptSearch;
-using support::makeAbsPath;
-using support::makeRelPath;
-using support::onlyFilename;
-using support::onlyPath;
-using support::package;
-using support::prefixIs;
-using support::quoteName;
-using support::removeExtension;
-using support::split;
-using support::subst;
-using support::Systemcall;
-
namespace Alert = lyx::frontend::Alert;
string const token_base("$$b");
string const token_to("$$o");
string const token_path("$$p");
+string const token_orig_path("$$r");
string result;
if (bp.papersize != PAPER_CUSTOM) {
- string const paper_size = bp.paperSizeName();
- if (paper_size != "b5" && paper_size != "foolscap")
+ string const paper_size = bp.paperSizeName(BufferParams::DVIPDFM);
+ if (!paper_size.empty())
result = "-p "+ paper_size;
if (bp.orientation == ORIENTATION_LANDSCAPE)
formats.extension(from_format);
string const to_ext = formats.extension(to_format);
string const command =
- support::os::python() + ' ' +
+ os::python() + ' ' +
quoteName(libFileSearch("scripts", "convertDefault.py").toFilesystemEncoding()) +
' ' +
quoteName(from_ext + ':' + from_file.toFilesystemEncoding()) +
"I use convertDefault.py:\n\t" << command);
Systemcall one;
one.startscript(Systemcall::Wait, command);
- if (to_file.isFileReadable()) {
+ if (to_file.isReadableFile()) {
if (conversionflags & try_cache)
ConverterCache::get().add(orig_from,
to_format, to_file);
return true;
}
}
+
+ // only warn once per session and per file type
+ static std::map<string, string> warned;
+ if (warned.find(from_format) != warned.end() && warned.find(from_format)->second == to_format) {
+ return false;
+ }
+ warned.insert(make_pair(from_format, to_format));
+
Alert::error(_("Cannot convert file"),
bformat(_("No information for converting %1$s "
"format files to %2$s.\n"
string const path(onlyPath(from_file.absFilename()));
// Prevent the compiler from optimizing away p
FileName pp(path);
- support::PathChanger p(pp);
+ PathChanger p(pp);
// empty the error list before any new conversion takes place.
errorList.clear();
command = subst(command, token_from, quoteName(infile2));
command = subst(command, token_base, quoteName(from_base));
command = subst(command, token_to, quoteName(outfile2));
+ command = subst(command, token_path, quoteName(infile.onlyPath().absFilename()));
+ command = subst(command, token_orig_path, quoteName(orig_from.onlyPath().absFilename()));
command = libScriptSearch(command);
if (!conv.parselog.empty())
string const to_base = removeExtension(to.absFilename());
string const to_extension = getExtension(to.absFilename());
- vector<FileName> const files = dirList(FileName(path),
- getExtension(from.absFilename()));
- for (vector<FileName>::const_iterator it = files.begin();
+ support::FileNameList const files = FileName(path).dirList(getExtension(from.absFilename()));
+ for (support::FileNameList::const_iterator it = files.begin();
it != files.end(); ++it) {
string const from2 = it->absFilename();
string const file2 = onlyFilename(from2);
}
-std::vector<Format const *> const
-Converters::intToFormat(std::vector<int> const & input)
+vector<Format const *> const
+Converters::intToFormat(vector<int> const & input)
{
vector<Format const *> result(input.size());