Following rev 21967: final touch to odocfstream:

- odocfstream: properly fix plaintext output by getting rid of ctor with std::string argument as this can be mixed up with std::ofstream(std::string) ctor where the argument is a file. UTF8 is now the default encoding.
- PreviewLoader::Impl::startLoading(): catch another potential iconv exception.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22332 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-29 18:04:43 +00:00
parent 31496b4a16
commit 58729e1117
5 changed files with 9 additions and 10 deletions

View File

@ -1209,7 +1209,6 @@ void Buffer::makeDocBookFile(FileName const & fname,
{
LYXERR(Debug::LATEX, "makeDocBookFile...");
//ofstream ofs;
odocfstream ofs;
if (!openFileWrite(ofs, fname))
return;

View File

@ -554,7 +554,14 @@ void PreviewLoader::Impl::startLoading()
// we use the encoding of the buffer
Encoding const & enc = buffer_.params().encoding();
odocfstream of(enc.iconvName());
odocfstream of;
try { of.reset(enc.iconvName()); }
catch (iconv_codecvt_facet_exception & e) {
LYXERR0("Caught iconv exception: " << e.what()
<< "\nUnable to create LaTeX file: " << latexfile);
return;
}
TexRow texrow;
OutputParams runparams(&enc);
LaTeXFeatures features(buffer_, buffer_.params(), runparams);

View File

@ -35,7 +35,6 @@ void writePlaintextFile(Buffer const & buf, FileName const & fname,
OutputParams const & runparams)
{
odocfstream ofs;
ofs << setEncoding("UTF-8");
if (!openFileWrite(ofs, fname))
return;
writePlaintextFile(buf, ofs, runparams);

View File

@ -298,12 +298,7 @@ idocfstream::idocfstream(const char* s, ios_base::openmode mode,
odocfstream::odocfstream(): base()
{
}
odocfstream::odocfstream(string const & encoding) : base()
{
setEncoding(*this, encoding, out);
setEncoding(*this, "UTF-8", out);
}

View File

@ -58,7 +58,6 @@ class odocfstream : public std::basic_ofstream<char_type> {
typedef std::basic_ofstream<char_type> base;
public:
odocfstream();
odocfstream(std::string const & encoding);
explicit odocfstream(const char* s,
std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc,
std::string const & encoding = "UTF-8");