mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
more unicode filenames
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16173 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
534095ce9e
commit
9eab5fa88a
12
src/buffer.C
12
src/buffer.C
@ -829,7 +829,7 @@ bool Buffer::do_writeFile(ostream & ofs) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Buffer::makeLaTeXFile(string const & fname,
|
bool Buffer::makeLaTeXFile(FileName const & fname,
|
||||||
string const & original_path,
|
string const & original_path,
|
||||||
OutputParams const & runparams,
|
OutputParams const & runparams,
|
||||||
bool output_preamble, bool output_body)
|
bool output_preamble, bool output_body)
|
||||||
@ -1025,7 +1025,7 @@ bool Buffer::isDocBook() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Buffer::makeDocBookFile(string const & fname,
|
void Buffer::makeDocBookFile(FileName const & fname,
|
||||||
OutputParams const & runparams,
|
OutputParams const & runparams,
|
||||||
bool const body_only)
|
bool const body_only)
|
||||||
{
|
{
|
||||||
@ -1036,7 +1036,7 @@ void Buffer::makeDocBookFile(string const & fname,
|
|||||||
if (!openFileWrite(ofs, fname))
|
if (!openFileWrite(ofs, fname))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
writeDocBookSource(ofs, fname, runparams, body_only);
|
writeDocBookSource(ofs, fname.absFilename(), runparams, body_only);
|
||||||
|
|
||||||
ofs.close();
|
ofs.close();
|
||||||
if (ofs.fail())
|
if (ofs.fail())
|
||||||
@ -1124,7 +1124,7 @@ int Buffer::runChktex()
|
|||||||
busy(true);
|
busy(true);
|
||||||
|
|
||||||
// get LaTeX-Filename
|
// get LaTeX-Filename
|
||||||
string const name = getLatexName();
|
string const name = getLatexName(false);
|
||||||
string const path = temppath();
|
string const path = temppath();
|
||||||
string const org_path = filePath();
|
string const org_path = filePath();
|
||||||
|
|
||||||
@ -1135,10 +1135,10 @@ int Buffer::runChktex()
|
|||||||
OutputParams runparams;
|
OutputParams runparams;
|
||||||
runparams.flavor = OutputParams::LATEX;
|
runparams.flavor = OutputParams::LATEX;
|
||||||
runparams.nice = false;
|
runparams.nice = false;
|
||||||
makeLaTeXFile(name, org_path, runparams);
|
makeLaTeXFile(FileName(name), org_path, runparams);
|
||||||
|
|
||||||
TeXErrors terr;
|
TeXErrors terr;
|
||||||
Chktex chktex(lyxrc.chktex_command, name, filePath());
|
Chktex chktex(lyxrc.chktex_command, onlyFilename(name), filePath());
|
||||||
int const res = chktex.run(terr); // run chktex
|
int const res = chktex.run(terr); // run chktex
|
||||||
|
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
bool writeFile(support::FileName const &) const;
|
bool writeFile(support::FileName const &) const;
|
||||||
|
|
||||||
/// Just a wrapper for the method below, first creating the ofstream.
|
/// Just a wrapper for the method below, first creating the ofstream.
|
||||||
bool makeLaTeXFile(std::string const & filename,
|
bool makeLaTeXFile(support::FileName const & filename,
|
||||||
std::string const & original_path,
|
std::string const & original_path,
|
||||||
OutputParams const &,
|
OutputParams const &,
|
||||||
bool output_preamble = true,
|
bool output_preamble = true,
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
bool output_preamble = true,
|
bool output_preamble = true,
|
||||||
bool output_body = true);
|
bool output_body = true);
|
||||||
///
|
///
|
||||||
void makeDocBookFile(std::string const & filename,
|
void makeDocBookFile(support::FileName const & filename,
|
||||||
OutputParams const & runparams_in,
|
OutputParams const & runparams_in,
|
||||||
bool only_body = false);
|
bool only_body = false);
|
||||||
///
|
///
|
||||||
|
@ -319,7 +319,7 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir,
|
|||||||
string writefile = mastertmpdir;
|
string writefile = mastertmpdir;
|
||||||
writefile += '/';
|
writefile += '/';
|
||||||
writefile += (*it)->getLatexName();
|
writefile += (*it)->getLatexName();
|
||||||
(*it)->makeLaTeXFile(writefile, mastertmpdir,
|
(*it)->makeLaTeXFile(FileName(writefile), mastertmpdir,
|
||||||
runparams, false);
|
runparams, false);
|
||||||
(*it)->markDepClean(mastertmpdir);
|
(*it)->markDepClean(mastertmpdir);
|
||||||
}
|
}
|
||||||
|
@ -192,19 +192,19 @@ bool Exporter::Export(Buffer * buffer, string const & format,
|
|||||||
|
|
||||||
// Ascii backend
|
// Ascii backend
|
||||||
if (backend_format == "text")
|
if (backend_format == "text")
|
||||||
writeFileAscii(*buffer, filename, runparams);
|
writeFileAscii(*buffer, FileName(filename), runparams);
|
||||||
// no backend
|
// no backend
|
||||||
else if (backend_format == "lyx")
|
else if (backend_format == "lyx")
|
||||||
buffer->writeFile(FileName(filename));
|
buffer->writeFile(FileName(filename));
|
||||||
// Docbook backend
|
// Docbook backend
|
||||||
else if (buffer->isDocBook()) {
|
else if (buffer->isDocBook()) {
|
||||||
runparams.nice = !put_in_tempdir;
|
runparams.nice = !put_in_tempdir;
|
||||||
buffer->makeDocBookFile(filename, runparams);
|
buffer->makeDocBookFile(FileName(filename), runparams);
|
||||||
}
|
}
|
||||||
// LaTeX backend
|
// LaTeX backend
|
||||||
else if (backend_format == format) {
|
else if (backend_format == format) {
|
||||||
runparams.nice = true;
|
runparams.nice = true;
|
||||||
if (!buffer->makeLaTeXFile(filename, string(), runparams))
|
if (!buffer->makeLaTeXFile(FileName(filename), string(), runparams))
|
||||||
return false;
|
return false;
|
||||||
} else if (!lyxrc.tex_allows_spaces
|
} else if (!lyxrc.tex_allows_spaces
|
||||||
&& contains(buffer->filePath(), ' ')) {
|
&& contains(buffer->filePath(), ' ')) {
|
||||||
@ -213,7 +213,7 @@ bool Exporter::Export(Buffer * buffer, string const & format,
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
runparams.nice = false;
|
runparams.nice = false;
|
||||||
if (!buffer->makeLaTeXFile(filename, buffer->filePath(), runparams))
|
if (!buffer->makeLaTeXFile(FileName(filename), buffer->filePath(), runparams))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,12 +568,12 @@ void PreviewLoader::Impl::startLoading()
|
|||||||
pending_.clear();
|
pending_.clear();
|
||||||
|
|
||||||
// Output the LaTeX file.
|
// Output the LaTeX file.
|
||||||
string const latexfile = filename_base + ".tex";
|
FileName const latexfile(filename_base + ".tex");
|
||||||
|
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
// This creates an utf8 encoded file, but the proper inputenc
|
// This creates an utf8 encoded file, but the proper inputenc
|
||||||
// command is missing.
|
// command is missing.
|
||||||
odocfstream of(latexfile.c_str());
|
odocfstream of(latexfile.toFilesystemEncoding().c_str());
|
||||||
if (!of) {
|
if (!of) {
|
||||||
lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()\n"
|
lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()\n"
|
||||||
<< "Unable to create LaTeX file\n"
|
<< "Unable to create LaTeX file\n"
|
||||||
@ -590,7 +590,7 @@ void PreviewLoader::Impl::startLoading()
|
|||||||
// The conversion command.
|
// The conversion command.
|
||||||
ostringstream cs;
|
ostringstream cs;
|
||||||
cs << pconverter_->command << ' ' << pconverter_->to << ' '
|
cs << pconverter_->command << ' ' << pconverter_->to << ' '
|
||||||
<< support::quoteName(latexfile) << ' '
|
<< support::quoteName(latexfile.toFilesystemEncoding()) << ' '
|
||||||
<< int(font_scaling_factor_) << ' '
|
<< int(font_scaling_factor_) << ' '
|
||||||
<< theApp()->hexName(LColor::preview) << ' '
|
<< theApp()->hexName(LColor::preview) << ' '
|
||||||
<< theApp()->hexName(LColor::background);
|
<< theApp()->hexName(LColor::background);
|
||||||
|
@ -428,7 +428,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
|
|||||||
// argument. Should we set it to string(), or should makeLaTeXFile
|
// argument. Should we set it to string(), or should makeLaTeXFile
|
||||||
// make use of it somehow? (JMarc 20031002)
|
// make use of it somehow? (JMarc 20031002)
|
||||||
#endif
|
#endif
|
||||||
tmp->makeLaTeXFile(writefile.absFilename(),
|
tmp->makeLaTeXFile(writefile,
|
||||||
onlyPath(masterFilename(buffer)),
|
onlyPath(masterFilename(buffer)),
|
||||||
runparams, false);
|
runparams, false);
|
||||||
} else {
|
} else {
|
||||||
@ -535,7 +535,7 @@ int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
|
|||||||
lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
|
lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
|
||||||
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
||||||
|
|
||||||
tmp->makeDocBookFile(writefile.absFilename(), runparams, true);
|
tmp->makeDocBookFile(writefile, runparams, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
runparams.exportdata->addExternalFile("docbook", writefile,
|
runparams.exportdata->addExternalFile("docbook", writefile,
|
||||||
|
11
src/output.C
11
src/output.C
@ -22,6 +22,7 @@
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
using support::bformat;
|
using support::bformat;
|
||||||
|
using support::FileName;
|
||||||
using support::makeDisplayPath;
|
using support::makeDisplayPath;
|
||||||
|
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
@ -30,11 +31,11 @@ using std::string;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template<typename OFStream>
|
template<typename OFStream>
|
||||||
bool doOpenFileWrite(OFStream & ofs, string const & fname)
|
bool doOpenFileWrite(OFStream & ofs, FileName const & fname)
|
||||||
{
|
{
|
||||||
ofs.open(fname.c_str());
|
ofs.open(fname.toFilesystemEncoding().c_str());
|
||||||
if (!ofs) {
|
if (!ofs) {
|
||||||
docstring const file = makeDisplayPath(fname, 50);
|
docstring const file = makeDisplayPath(fname.absFilename(), 50);
|
||||||
docstring text = bformat(_("Could not open the specified "
|
docstring text = bformat(_("Could not open the specified "
|
||||||
"document\n%1$s."), file);
|
"document\n%1$s."), file);
|
||||||
frontend::Alert::error(_("Could not open file"), text);
|
frontend::Alert::error(_("Could not open file"), text);
|
||||||
@ -46,13 +47,13 @@ bool doOpenFileWrite(OFStream & ofs, string const & fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool openFileWrite(ofstream & ofs, string const & fname)
|
bool openFileWrite(ofstream & ofs, FileName const & fname)
|
||||||
{
|
{
|
||||||
return doOpenFileWrite(ofs, fname);
|
return doOpenFileWrite(ofs, fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool openFileWrite(odocfstream & ofs, string const & fname)
|
bool openFileWrite(odocfstream & ofs, FileName const & fname)
|
||||||
{
|
{
|
||||||
return doOpenFileWrite(ofs, fname);
|
return doOpenFileWrite(ofs, fname);
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
bool openFileWrite(std::ofstream & ofs, std::string const & fname);
|
namespace support { class FileName; }
|
||||||
bool openFileWrite(odocfstream & ofs, std::string const & fname);
|
|
||||||
|
bool openFileWrite(std::ofstream & ofs, support::FileName const & fname);
|
||||||
|
bool openFileWrite(odocfstream & ofs, support::FileName const & fname);
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "ParagraphList.h"
|
#include "ParagraphList.h"
|
||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
|
|
||||||
|
#include "support/filename.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ using support::ascii_lowercase;
|
|||||||
using support::compare_ascii_no_case;
|
using support::compare_ascii_no_case;
|
||||||
using support::compare_no_case;
|
using support::compare_no_case;
|
||||||
using support::contains;
|
using support::contains;
|
||||||
|
using support::FileName;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
@ -38,7 +40,7 @@ using std::pair;
|
|||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
void writeFileAscii(Buffer const & buf, string const & fname,
|
void writeFileAscii(Buffer const & buf, FileName const & fname,
|
||||||
OutputParams const & runparams)
|
OutputParams const & runparams)
|
||||||
{
|
{
|
||||||
odocfstream ofs;
|
odocfstream ofs;
|
||||||
|
@ -17,13 +17,15 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace support { class FileName; }
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class OutputParams;
|
class OutputParams;
|
||||||
class Paragraph;
|
class Paragraph;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
void writeFileAscii(Buffer const & buf, std::string const &,
|
void writeFileAscii(Buffer const & buf, support::FileName const &,
|
||||||
OutputParams const &);
|
OutputParams const &);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -456,17 +456,16 @@ void tex2lyx(std::istream &is, std::ostream &os)
|
|||||||
|
|
||||||
|
|
||||||
/// convert TeX from \p infilename to LyX and write it to \p os
|
/// convert TeX from \p infilename to LyX and write it to \p os
|
||||||
bool tex2lyx(string const &infilename, std::ostream &os)
|
bool tex2lyx(FileName const & infilename, std::ostream &os)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(lyx::support::absolutePath(infilename));
|
ifstream is(infilename.toFilesystemEncoding().c_str());
|
||||||
ifstream is(infilename.c_str());
|
|
||||||
if (!is.good()) {
|
if (!is.good()) {
|
||||||
cerr << "Could not open input file \"" << infilename
|
cerr << "Could not open input file \"" << infilename
|
||||||
<< "\" for reading." << endl;
|
<< "\" for reading." << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string const oldParentFilePath = parentFilePath;
|
string const oldParentFilePath = parentFilePath;
|
||||||
parentFilePath = onlyPath(infilename);
|
parentFilePath = onlyPath(infilename.absFilename());
|
||||||
tex2lyx(is, os);
|
tex2lyx(is, os);
|
||||||
parentFilePath = oldParentFilePath;
|
parentFilePath = oldParentFilePath;
|
||||||
return true;
|
return true;
|
||||||
@ -499,7 +498,7 @@ bool tex2lyx(string const &infilename, FileName const &outfilename)
|
|||||||
cerr << "Input file: " << infilename << "\n";
|
cerr << "Input file: " << infilename << "\n";
|
||||||
cerr << "Output file: " << outfilename << "\n";
|
cerr << "Output file: " << outfilename << "\n";
|
||||||
#endif
|
#endif
|
||||||
return tex2lyx(infilename, os);
|
return tex2lyx(FileName(infilename), os);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
@ -546,7 +545,7 @@ int main(int argc, char * argv[])
|
|||||||
parentFilePath = masterFilePath;
|
parentFilePath = masterFilePath;
|
||||||
|
|
||||||
if (outfilename == "-") {
|
if (outfilename == "-") {
|
||||||
if (tex2lyx(infilename, cout))
|
if (tex2lyx(FileName(infilename), cout))
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
else
|
else
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user