Use UTF8 for LaTeX export.

Known problems:
- No space is output after a \hfill. I probably broke this with the
  InsetCommand patch. I'll have a look later.
- Although the encoding is now UTF8 the arguments of the inputenc package
  are still the old ones, so LaTeX will not run.
- Labels and references with non-ASCII characters are broken. This needs to
  be fixed in lyx::support::escape(), but this is a file format change.
- Something seems to be wrong with index entries, but this is probably also
  due to the InsetCommand changes.

Have fun!


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15378 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-10-19 16:51:30 +00:00
parent daae275cd1
commit 8b67659646
124 changed files with 698 additions and 525 deletions

View File

@ -94,6 +94,7 @@ namespace io = boost::iostreams;
using lyx::docstring;
using lyx::odocstream;
using lyx::pos_type;
using lyx::pit_type;
@ -824,7 +825,10 @@ void Buffer::makeLaTeXFile(string const & fname,
{
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
ofstream ofs;
// FIXME UNICODE
// This creates an utf8 encoded file, but the inputenc commands
// specify other encodings
lyx::odocfstream ofs;
if (!openFileWrite(ofs, fname))
return;
@ -837,7 +841,7 @@ void Buffer::makeLaTeXFile(string const & fname,
}
void Buffer::writeLaTeXSource(ostream & os,
void Buffer::writeLaTeXSource(odocstream & os,
string const & original_path,
OutputParams const & runparams_in,
bool const output_preamble, bool const output_body)
@ -883,11 +887,13 @@ void Buffer::writeLaTeXSource(ostream & os,
texrow().newline();
}
if (!original_path.empty()) {
string const inputpath = latex_path(original_path);
// FIXME UNICODE
// We don't know the encoding of inputpath
docstring const inputpath = lyx::from_utf8(latex_path(original_path));
os << "\\makeatletter\n"
<< "\\def\\input@path{{"
<< inputpath << "/}}\n"
<< "\\makeatother\n";
<< "\\def\\input@path{{"
<< inputpath << "/}}\n"
<< "\\makeatother\n";
texrow().newline();
texrow().newline();
texrow().newline();
@ -906,9 +912,11 @@ void Buffer::writeLaTeXSource(ostream & os,
lyxerr[Debug::INFO] << "preamble finished, now the body." << endl;
if (!lyxrc.language_auto_begin) {
os << subst(lyxrc.language_command_begin, "$$lang",
params().language->babel())
<< endl;
// FIXME UNICODE
os << lyx::from_utf8(subst(lyxrc.language_command_begin,
"$$lang",
params().language->babel()))
<< '\n';
texrow().newline();
}
@ -933,9 +941,10 @@ void Buffer::writeLaTeXSource(ostream & os,
texrow().newline();
if (!lyxrc.language_auto_end) {
os << subst(lyxrc.language_command_end, "$$lang",
params().language->babel())
<< endl;
os << lyx::from_utf8(subst(lyxrc.language_command_end,
"$$lang",
params().language->babel()))
<< '\n';
texrow().newline();
}
@ -1590,7 +1599,7 @@ void Buffer::changeRefsIfUnique(string const & from, string const & to, InsetBas
}
void Buffer::getSourceCode(ostream & os, lyx::pit_type par_begin, lyx::pit_type par_end, bool full_source)
void Buffer::getSourceCode(odocstream & os, lyx::pit_type par_begin, lyx::pit_type par_end, bool full_source)
{
OutputParams runparams;
runparams.nice = true;
@ -1603,8 +1612,12 @@ void Buffer::getSourceCode(ostream & os, lyx::pit_type par_begin, lyx::pit_type
os << "% Preview source code\n\n";
if (isLatex())
writeLaTeXSource(os, filePath(), runparams, true, true);
else
writeDocBookSource(os, fileName(), runparams, false);
else {
// FIXME UNICODE
ostringstream oss;
writeDocBookSource(oss, fileName(), runparams, false);
os << lyx::from_utf8(oss.str());
}
} else {
runparams.par_begin = par_begin;
runparams.par_end = par_end;
@ -1616,8 +1629,13 @@ void Buffer::getSourceCode(ostream & os, lyx::pit_type par_begin, lyx::pit_type
if (isLatex()) {
texrow().reset();
latexParagraphs(*this, paragraphs(), os, texrow(), runparams);
} else // DocBook
docbookParagraphs(paragraphs(), *this, os, runparams);
} else {
// DocBook
// FIXME UNICODE
ostringstream oss;
docbookParagraphs(paragraphs(), *this, oss, runparams);
os << lyx::from_utf8(oss.str());
}
}
}

View File

@ -146,7 +146,7 @@ public:
bool output_preamble = true,
bool output_body = true);
///
void writeLaTeXSource(std::ostream & os,
void writeLaTeXSource(lyx::odocstream & os,
std::string const & original_path,
OutputParams const &,
bool output_preamble = true,
@ -339,7 +339,7 @@ public:
void changeRefsIfUnique(std::string const & from, std::string const & to, InsetBase::Code code);
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
/// including preamble
void getSourceCode(std::ostream & os, lyx::pit_type par_begin, lyx::pit_type par_end, bool full_source);
void getSourceCode(lyx::odocstream & os, lyx::pit_type par_begin, lyx::pit_type par_end, bool full_source);
/// errorLists_ accessors.
//@{

View File

@ -49,6 +49,7 @@
namespace support = lyx::support;
using lyx::docstring;
using lyx::odocstream;
using lyx::support::bformat;
using lyx::support::rtrim;
using lyx::support::tokenPos;
@ -714,7 +715,7 @@ void BufferParams::writeFile(ostream & os) const
}
bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
TexRow & texrow) const
{
os << "\\documentclass";
@ -811,10 +812,11 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
string strOptions(clsoptions.str());
if (!strOptions.empty()) {
strOptions = rtrim(strOptions, ",");
os << '[' << strOptions << ']';
// FIXME UNICODE
os << '[' << lyx::from_utf8(strOptions) << ']';
}
os << '{' << tclass.latexname() << "}\n";
os << '{' << lyx::from_ascii(tclass.latexname()) << "}\n";
texrow.newline();
// end of \documentclass defs
@ -824,15 +826,15 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
fontsTypewriter, fontsSC, fontsOSF,
fontsSansScale, fontsTypewriterScale);
if (!fonts.empty()) {
os << fonts;
os << lyx::from_ascii(fonts);
texrow.newline();
}
if (fontsDefaultFamily != "default")
os << "\\renewcommand{\\familydefault}{\\"
<< fontsDefaultFamily << "}\n";
<< lyx::from_ascii(fontsDefaultFamily) << "}\n";
// this one is not per buffer
if (lyxrc.fontenc != "default") {
os << "\\usepackage[" << lyxrc.fontenc
os << "\\usepackage[" << lyx::from_ascii(lyxrc.fontenc)
<< "]{fontenc}\n";
texrow.newline();
}
@ -847,12 +849,14 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
features.getEncodingSet(doc_encoding);
os << "\\usepackage[";
std::copy(encodings.begin(), encodings.end(),
std::ostream_iterator<string>(os, ","));
os << doc_encoding << "]{inputenc}\n";
std::set<string>::const_iterator it = encodings.begin();
std::set<string>::const_iterator const end = encodings.end();
for (; it != end; ++it)
os << lyx::from_ascii(*it) << ',';
os << lyx::from_ascii(doc_encoding) << "]{inputenc}\n";
texrow.newline();
} else if (inputenc != "default") {
os << "\\usepackage[" << inputenc
os << "\\usepackage[" << lyx::from_ascii(inputenc)
<< "]{inputenc}\n";
texrow.newline();
}
@ -867,10 +871,10 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
case PAPER_CUSTOM:
if (!paperwidth.empty())
os << ",paperwidth="
<< paperwidth;
<< lyx::from_ascii(paperwidth);
if (!paperheight.empty())
os << ",paperheight="
<< paperheight;
<< lyx::from_ascii(paperheight);
break;
case PAPER_USLETTER:
os << ",letterpaper";
@ -931,19 +935,19 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
}
}
if (!topmargin.empty())
os << ",tmargin=" << topmargin;
os << ",tmargin=" << lyx::from_ascii(topmargin);
if (!bottommargin.empty())
os << ",bmargin=" << bottommargin;
os << ",bmargin=" << lyx::from_ascii(bottommargin);
if (!leftmargin.empty())
os << ",lmargin=" << leftmargin;
os << ",lmargin=" << lyx::from_ascii(leftmargin);
if (!rightmargin.empty())
os << ",rmargin=" << rightmargin;
os << ",rmargin=" << lyx::from_ascii(rightmargin);
if (!headheight.empty())
os << ",headheight=" << headheight;
os << ",headheight=" << lyx::from_ascii(headheight);
if (!headsep.empty())
os << ",headsep=" << headsep;
os << ",headsep=" << lyx::from_ascii(headsep);
if (!footskip.empty())
os << ",footskip=" << footskip;
os << ",footskip=" << lyx::from_ascii(footskip);
os << "}\n";
texrow.newline();
}
@ -954,7 +958,7 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
os << "\\usepackage{fancyhdr}\n";
texrow.newline();
}
os << "\\pagestyle{" << pagestyle << "}\n";
os << "\\pagestyle{" << lyx::from_ascii(pagestyle) << "}\n";
texrow.newline();
}
@ -987,7 +991,7 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
break;
case VSpace::LENGTH:
os << "\\setlength\\parskip{"
<< getDefSkip().length().asLatexString()
<< lyx::from_ascii(getDefSkip().length().asLatexString())
<< "}\n";
break;
default: // should never happen // Then delete it.
@ -1002,9 +1006,9 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
// If we use jurabib, we have to call babel here.
if (use_babel && features.isRequired("jurabib")) {
os << babelCall(language_options.str())
os << lyx::from_ascii(babelCall(language_options.str()))
<< '\n'
<< features.getBabelOptions();
<< lyx::from_ascii(features.getBabelOptions());
texrow.newline();
}
@ -1101,7 +1105,8 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
texrow.newline();
}
os << lyxpreamble;
// FIXME UNICODE
os << lyx::from_utf8(lyxpreamble);
return use_babel;
}

View File

@ -86,7 +86,7 @@ public:
* the BufferParams and a LyXRC variable).
* This returned value can then be passed to the insets...
*/
bool writeLaTeX(std::ostream &, LaTeXFeatures &, TexRow &) const;
bool writeLaTeX(lyx::odocstream &, LaTeXFeatures &, TexRow &) const;
///
void useClassDefaults();

View File

@ -17,6 +17,8 @@
#include <boost/assert.hpp>
using lyx::docstring;
using lyx::odocstream;
using lyx::pos_type;
using std::endl;
@ -450,17 +452,17 @@ void Changes::check() const
}
int Changes::latexMarkChange(std::ostream & os,
int Changes::latexMarkChange(odocstream & os,
Change::Type const old, Change::Type const change,
bool const & output)
{
if (!output || old == change)
return 0;
string const start("\\changestart{}");
string const end("\\changeend{}");
string const son("\\overstrikeon{}");
string const soff("\\overstrikeoff{}");
static docstring const start(lyx::from_ascii("\\changestart{}"));
static docstring const end(lyx::from_ascii("\\changeend{}"));
static docstring const son(lyx::from_ascii("\\overstrikeon{}"));
static docstring const soff(lyx::from_ascii("\\overstrikeoff{}"));
int column = 0;

View File

@ -14,11 +14,10 @@
#ifndef CHANGES_H
#define CHANGES_H
#include "support/types.h"
#include "support/docstream.h"
#include "support/lyxtime.h"
#include <vector>
#include <iosfwd>
class Change {
@ -84,7 +83,7 @@ public:
/// output latex to mark a transition between two changetypes
/// returns length of text outputted
static int latexMarkChange(std::ostream & os, Change::Type old,
static int latexMarkChange(lyx::odocstream & os, Change::Type old,
Change::Type change, bool const & output);
/// output .lyx file format for transitions between changes

View File

@ -970,9 +970,10 @@ void LCursor::normalize()
lyxerr << "this should not really happen - 2: "
<< pos() << ' ' << lastpos() << " in idx: " << idx()
<< " in atom: '";
WriteStream wi(lyxerr, false, true);
lyx::odocstringstream os;
WriteStream wi(os, false, true);
inset().asInsetMath()->write(wi);
lyxerr << endl;
lyxerr << lyx::to_utf8(os.str()) << endl;
pos() = lastpos();
}
}

View File

@ -21,7 +21,6 @@
#include <sstream>
using std::string;
using std::ostringstream;
namespace lyx {
namespace frontend {
@ -36,7 +35,7 @@ bool ControlViewSource::initialiseParams(string const & /*source*/)
return true;
}
string const ControlViewSource::updateContent(bool fullSource)
docstring const ControlViewSource::updateContent(bool fullSource)
{
// get the *top* level paragraphs that contain the cursor,
// or the selected text
@ -53,7 +52,7 @@ string const ControlViewSource::updateContent(bool fullSource)
}
if (par_begin > par_end)
std::swap(par_begin, par_end);
ostringstream ostr;
lyx::odocstringstream ostr;
view->buffer()->getSourceCode(ostr, par_begin, par_end + 1, fullSource);
return ostr.str();
}

View File

@ -42,7 +42,7 @@ public:
/** get the source code of selected paragraphs, or the whole document
\param fullSource get full source code
*/
std::string const updateContent(bool fullSource);
lyx::docstring const updateContent(bool fullSource);
};
} // namespace frontend

View File

@ -43,6 +43,8 @@
namespace support = lyx::support;
using lyx::odocstream;
using std::endl;
using std::find;
using std::fill;
@ -54,8 +56,6 @@ using boost::bind;
using std::ifstream;
using std::list;
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::pair;
using std::vector;
@ -149,9 +149,9 @@ private:
/// Called by the Forkedcall process that generated the bitmap files.
void finishedGenerating(pid_t, int);
///
void dumpPreamble(ostream &) const;
void dumpPreamble(odocstream &) const;
///
void dumpData(ostream &, BitmapFile const &) const;
void dumpData(odocstream &, BitmapFile const &) const;
/** cache_ allows easy retrieval of already-generated images
* using the LaTeX snippet as the identifier.
@ -481,7 +481,10 @@ void PreviewLoader::Impl::startLoading()
// Output the LaTeX file.
string const latexfile = filename_base + ".tex";
ofstream of(latexfile.c_str());
// FIXME UNICODE
// This creates an utf8 encoded file, but the proper inputenc
// command is missing.
lyx::odocfstream of(latexfile.c_str());
if (!of) {
lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()\n"
<< "Unable to create LaTeX file\n"
@ -582,7 +585,7 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
}
void PreviewLoader::Impl::dumpPreamble(ostream & os) const
void PreviewLoader::Impl::dumpPreamble(odocstream & os) const
{
// Why on earth is Buffer::makeLaTeXFile a non-const method?
Buffer & tmp = const_cast<Buffer &>(buffer_);
@ -596,7 +599,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
// FIXME! This is a HACK! The proper fix is to control the 'true'
// passed to WriteStream below:
// int InsetFormula::latex(Buffer const &, ostream & os,
// int InsetFormula::latex(Buffer const &, odocstream & os,
// OutputParams const & runparams) const
// {
// WriteStream wi(os, runparams.moving_arg, true);
@ -629,7 +632,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
}
void PreviewLoader::Impl::dumpData(ostream & os,
void PreviewLoader::Impl::dumpData(odocstream & os,
BitmapFile const & vec) const
{
if (vec.empty())
@ -639,8 +642,9 @@ void PreviewLoader::Impl::dumpData(ostream & os,
BitmapFile::const_iterator end = vec.end();
for (; it != end; ++it) {
// FIXME UNICODE
os << "\\begin{preview}\n"
<< it->first
<< lyx::from_utf8(it->first)
<< "\n\\end{preview}\n\n";
}
}

View File

@ -32,13 +32,10 @@
#include "support/package.h"
#include "support/path.h"
#include "support/std_ostream.h"
namespace support = lyx::support;
using std::endl;
using std::ostream;
using std::string;
using std::vector;
@ -334,7 +331,7 @@ string const substituteOptions(InsetExternalParams const & params,
int writeExternal(InsetExternalParams const & params,
string const & format,
Buffer const & buffer, ostream & os,
Buffer const & buffer, lyx::odocstream & os,
ExportData & exportdata,
bool external_in_tmpdir,
bool external_in_comment)
@ -362,7 +359,8 @@ int writeExternal(InsetExternalParams const & params,
use_latex_path, external_in_tmpdir);
str = substituteCommands(params, str, format);
str = substituteOptions(params, str, format);
os << str;
// FIXME UNICODE
os << lyx::from_utf8(str);
return int(lyx::count(str.begin(), str.end(),'\n'));
}

View File

@ -13,8 +13,7 @@
#ifndef EXTERNALSUPPORT_H
#define EXTERNALSUPPORT_H
#include <iosfwd>
#include <string>
#include "support/docstream.h"
class Buffer;
class ExportData;
@ -63,7 +62,7 @@ std::string const doSubstitution(InsetExternalParams const & params,
int writeExternal(InsetExternalParams const &,
std::string const & format,
Buffer const &,
std::ostream &,
lyx::odocstream &,
ExportData &,
bool external_in_tmpdir,
bool external_in_comment);

View File

@ -34,6 +34,9 @@
#include <typeinfo>
using lyx::odocstream;
namespace {
class InsetName {
@ -221,7 +224,7 @@ bool InsetBase::idxUpDown(LCursor &, bool) const
int InsetBase::plaintext(Buffer const &,
lyx::odocstream &, OutputParams const &) const
odocstream &, OutputParams const &) const
{
return 0;
}

View File

@ -356,7 +356,7 @@ public:
/// read inset in .lyx format
virtual void read(Buffer const &, LyXLex &) {}
/// returns the number of rows (\n's) of generated tex code.
virtual int latex(Buffer const &, std::ostream &,
virtual int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const { return 0; }
/// returns true to override begin and end inset in file
virtual bool directWrite() const;

View File

@ -26,6 +26,7 @@
#include "support/convert.h"
using lyx::docstring;
using lyx::odocstream;
using lyx::support::prefixIs;
using std::max;
@ -109,7 +110,7 @@ docstring const InsetBibitem::getScreenLabel(Buffer const &) const
}
int InsetBibitem::plaintext(Buffer const &, lyx::odocstream & os,
int InsetBibitem::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '[' << getCounter() << "] ";

View File

@ -37,6 +37,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::support::absolutePath;
using lyx::support::ascii_lowercase;
using lyx::support::changeExtension;
@ -126,7 +127,7 @@ string normalize_name(Buffer const & buffer, OutputParams const & runparams,
}
int InsetBibtex::latex(Buffer const & buffer, ostream & os,
int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
OutputParams const & runparams) const
{
// the sequence of the commands:
@ -234,8 +235,9 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
<< endl;
}
}
// FIXME UNICODE
os << "\\bibliographystyle{"
<< latex_path(normalize_name(buffer, runparams, base, ".bst"))
<< lyx::from_utf8(latex_path(normalize_name(buffer, runparams, base, ".bst")))
<< "}\n";
nlines += 1;
}
@ -244,18 +246,18 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
static bool warned_about_bst_spaces = false;
if (!warned_about_bst_spaces && runparams.nice && contains(style, ' ')) {
warned_about_bst_spaces = true;
// FIXME UNICODE
Alert::warning(_("Export Warning!"),
_("There are spaces in the path to your BibTeX style file.\n"
"BibTeX will be unable to find it."));
}
if (!db_out.empty() && buffer.params().use_bibtopic){
os << "\\begin{btSect}{" << db_out << "}\n";
string btprint = getSecOptions();
// FIXME UNICODE
os << "\\begin{btSect}{" << lyx::from_utf8(db_out) << "}\n";
docstring btprint = getParam("btprint");
if (btprint.empty())
// default
btprint = "btPrintCited";
btprint = lyx::from_ascii("btPrintCited");
os << "\\" << btprint << "\n"
<< "\\end{btSect}\n";
nlines += 3;
@ -287,7 +289,8 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
}
if (!db_out.empty() && !buffer.params().use_bibtopic){
os << "\\bibliography{" << db_out << "}\n";
// FIXME UNICODE
os << "\\bibliography{" << lyx::from_utf8(db_out) << "}\n";
nlines += 1;
}

View File

@ -31,7 +31,7 @@ public:
///
bool display() const { return true; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
void fillWithBibKeys(Buffer const & buffer,

View File

@ -31,6 +31,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::auto_ptr;
using std::string;
@ -245,7 +246,7 @@ bool InsetBox::getStatus(LCursor & cur, FuncRequest const & cmd,
}
int InsetBox::latex(Buffer const & buf, ostream & os,
int InsetBox::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
BoxType btype = boxtranslator().find(params_.type);
@ -292,11 +293,14 @@ int InsetBox::latex(Buffer const & buf, ostream & os,
if (!params_.inner_box) {
os << "{\\makebox";
// Special widths, see usrguide §3.5
// FIXME UNICODE
if (params_.special != "none") {
os << "[" << params_.width.value()
<< "\\" << params_.special << "]";
<< '\\' << lyx::from_utf8(params_.special)
<< ']';
} else
os << "[" << width_string << "]";
os << '[' << lyx::from_ascii(width_string)
<< ']';
if (params_.hor_pos != 'c')
os << "[" << params_.hor_pos << "]";
}
@ -325,16 +329,21 @@ int InsetBox::latex(Buffer const & buf, ostream & os,
os << "[" << params_.pos << "]";
if (params_.height_special == "none") {
os << "[" << params_.height.asLatexString() << "]";
// FIXME UNICODE
os << '[' << lyx::from_ascii(params_.height.asLatexString())
<< ']';
} else {
// Special heights
// FIXME UNICODE
os << "[" << params_.height.value()
<< "\\" << params_.height_special << "]";
<< '\\' << lyx::from_utf8(params_.height_special)
<< ']';
}
if (params_.inner_pos != params_.pos)
os << "[" << params_.inner_pos << "]";
os << "{" << width_string << "}";
// FIXME UNICODE
os << '{' << lyx::from_ascii(width_string) << '}';
if (params_.use_parbox)
os << "{";
@ -381,7 +390,7 @@ int InsetBox::docbook(Buffer const & buf, std::ostream & os,
}
int InsetBox::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetBox::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
BoxType const btype = boxtranslator().find(params_.type);

View File

@ -82,7 +82,7 @@ public:
///
bool noFontChange() const { return true; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -27,6 +27,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -220,7 +221,7 @@ bool InsetBranch::isBranchSelected(Buffer const & buffer) const
}
int InsetBranch::latex(Buffer const & buf, ostream & os,
int InsetBranch::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return isBranchSelected(buf) ?
@ -236,7 +237,7 @@ int InsetBranch::docbook(Buffer const & buf, std::ostream & os,
}
int InsetBranch::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetBranch::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return isBranchSelected(buf) ?

View File

@ -53,7 +53,7 @@ public:
///
bool showInsetDialog(BufferView *) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -35,13 +35,13 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::support::bformat;
using std::auto_ptr;
using std::endl;
using std::string;
using std::ostream;
using std::ostringstream;
InsetCaption::InsetCaption(BufferParams const & bp)
@ -176,7 +176,7 @@ InsetBase * InsetCaption::editXY(LCursor & cur, int x, int y)
}
int InsetCaption::latex(Buffer const & buf, ostream & os,
int InsetCaption::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
// This is a bit too simplistic to take advantage of
@ -184,14 +184,14 @@ int InsetCaption::latex(Buffer const & buf, ostream & os,
// This code is currently only able to handle the simple
// \caption{...}, later we will make it take advantage
// of the one of the caption packages. (Lgb)
ostringstream ost;
lyx::odocstringstream ost;
int const l = InsetText::latex(buf, ost, runparams);
os << "\\caption{" << ost.str() << "}\n";
return l + 1;
}
int InsetCaption::plaintext(Buffer const & /*buf*/, lyx::odocstream & /*os*/,
int InsetCaption::plaintext(Buffer const & /*buf*/, odocstream & /*os*/,
OutputParams const & /*runparams*/) const
{
// FIXME: Implement me!

View File

@ -48,7 +48,7 @@ public:
///
virtual InsetBase * editXY(LCursor & cur, int x, int y);
///
virtual int latex(Buffer const & buf, std::ostream & os,
virtual int latex(Buffer const & buf, lyx::odocstream & os,
OutputParams const &) const;
///
int plaintext(Buffer const & buf, lyx::odocstream & os,

View File

@ -39,6 +39,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -282,14 +283,15 @@ bool InsetCharStyle::getStatus(LCursor & cur, FuncRequest const & cmd,
}
int InsetCharStyle::latex(Buffer const & buf, ostream & os,
int InsetCharStyle::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
if (!undefined()) {
os << "\\" << params_.latexname;
// FIXME UNICODE
os << '\\' << lyx::from_utf8(params_.latexname);
if (!params_.latexparam.empty())
os << params_.latexparam;
os << "{";
os << lyx::from_utf8(params_.latexparam);
os << '{';
}
int i = InsetText::latex(buf, os, runparams);
if (!undefined())
@ -322,14 +324,14 @@ int InsetCharStyle::docbook(Buffer const & buf, ostream & os,
}
int InsetCharStyle::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return InsetText::plaintext(buf, os, runparams);
}
int InsetCharStyle::textString(Buffer const & buf, lyx::odocstream & os,
int InsetCharStyle::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -73,7 +73,7 @@ public:
///
bool forceDefaultParagraphs(idx_type) const { return true; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -31,6 +31,7 @@
#include <boost/filesystem/exception.hpp>
using lyx::docstring;
using lyx::odocstream;
using lyx::support::ascii_lowercase;
using lyx::support::contains;
using lyx::support::getStringFromVector;
@ -357,7 +358,7 @@ docstring const InsetCitation::getScreenLabel(Buffer const & buffer) const
}
int InsetCitation::plaintext(Buffer const & buffer, lyx::odocstream & os,
int InsetCitation::plaintext(Buffer const & buffer, odocstream & os,
OutputParams const &) const
{
if (cache.params == params() &&
@ -398,7 +399,7 @@ int InsetCitation::docbook(Buffer const &, ostream & os, OutputParams const &) c
}
int InsetCitation::textString(Buffer const & buf, lyx::odocstream & os,
int InsetCitation::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
@ -409,23 +410,25 @@ int InsetCitation::textString(Buffer const & buf, lyx::odocstream & os,
// the \cite command is valid. Eg, the user has natbib enabled, inputs some
// citations and then changes his mind, turning natbib support off. The output
// should revert to \cite[]{}
int InsetCitation::latex(Buffer const & buffer, ostream & os,
int InsetCitation::latex(Buffer const & buffer, odocstream & os,
OutputParams const &) const
{
biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
string const cite_str =
biblio::asValidLatexCommand(getCmdName(), cite_engine);
// FIXME UNICODE
docstring const cite_str = lyx::from_utf8(
biblio::asValidLatexCommand(getCmdName(), cite_engine));
os << "\\" << cite_str;
string const before = getSecOptions();
string const after = getOptions();
docstring const & before = getParam("before");
docstring const & after = getParam("after");
if (!before.empty() && cite_engine != biblio::ENGINE_BASIC)
os << '[' << before << "][" << after << ']';
else if (!after.empty())
os << '[' << after << ']';
os << '{' << cleanupWhitespace(getContents()) << '}';
// FIXME UNICODE
os << '{' << lyx::from_utf8(cleanupWhitespace(getContents())) << '}';
return 0;
}

View File

@ -33,7 +33,7 @@ public:
///
int plaintext(Buffer const &, lyx::odocstream &, OutputParams const &) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -23,6 +23,8 @@
#include <sstream>
using lyx::odocstream;
using std::string;
using std::istringstream;
using std::ostream;
@ -70,7 +72,7 @@ void InsetCommand::setParams(InsetCommandParams const & p)
}
int InsetCommand::latex(Buffer const &, ostream & os,
int InsetCommand::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << getCommand();
@ -78,7 +80,7 @@ int InsetCommand::latex(Buffer const &, ostream & os,
}
int InsetCommand::plaintext(Buffer const &, lyx::odocstream &,
int InsetCommand::plaintext(Buffer const &, odocstream &,
OutputParams const &) const
{
return 0;

View File

@ -48,7 +48,7 @@ public:
/// FIXME remove
void scanCommand(std::string const & c) { p_.scanCommand(c); };
///
virtual int latex(Buffer const &, std::ostream &,
virtual int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,
@ -95,7 +95,7 @@ protected:
///
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
///
std::string const getCommand() const { return p_.getCommand(); }
lyx::docstring const getCommand() const { return p_.getCommand(); }
///
std::string const & getCmdName() const { return p_.getCmdName(); }
///

View File

@ -228,7 +228,7 @@ void InsetCommandParams::scanCommand(string const & cmd)
if (lyxerr.debugging(Debug::PARSER))
lyxerr << "Command <" << cmd
<< "> == <" << getCommand()
<< "> == <" << lyx::to_utf8(getCommand())
<< "> == <" << getCmdName()
<< '|' << getContents()
<< '|' << getOptions()
@ -284,7 +284,7 @@ void InsetCommandParams::write(ostream & os) const
}
string const InsetCommandParams::getCommand() const
docstring const InsetCommandParams::getCommand() const
{
docstring s = '\\' + lyx::from_ascii(name_);
for (size_t i = 0; i < info_->n; ++i) {
@ -306,7 +306,7 @@ string const InsetCommandParams::getCommand() const
} else
s += '{' + params_[i] + '}';
}
return lyx::to_utf8(s);
return s;
}

View File

@ -34,7 +34,7 @@ public:
///
void write(std::ostream &) const;
/// Build the complete LaTeX command
std::string const getCommand() const;
lyx::docstring const getCommand() const;
/// Return the command name
std::string const & getCmdName() const { return name_; }
/// FIXME remove

View File

@ -18,10 +18,9 @@
#include "output_latex.h"
#include "texrow.h"
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -69,14 +68,16 @@ docstring const InsetEnvironment::editMessage() const
}
int InsetEnvironment::latex(Buffer const & buf, ostream & os,
int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << layout_->latexheader;
// FIXME UNICODE
os << lyx::from_utf8(layout_->latexheader);
TexRow texrow;
latexParagraphs(buf, paragraphs(), os, texrow, runparams,
layout_->latexparagraph);
os << layout_->latexfooter;
// FIXME UNICODE
os << lyx::from_utf8(layout_->latexfooter);
return texrow.rows();
}

View File

@ -27,7 +27,7 @@ public:
///
InsetBase::Code lyxCode() const { return InsetBase::ENVIRONMENT_CODE; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
virtual lyx::docstring const editMessage() const;

View File

@ -36,6 +36,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::pos_type;
using lyx::support::token;
@ -143,7 +144,7 @@ docstring const InsetERT::editMessage() const
}
int InsetERT::latex(Buffer const &, ostream & os,
int InsetERT::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
ParagraphList::const_iterator par = paragraphs().begin();
@ -157,7 +158,7 @@ int InsetERT::latex(Buffer const &, ostream & os,
if (par->isDeleted(i))
continue;
os << par->getChar(i);
os.put(par->getChar(i));
}
++par;
if (par != end) {
@ -170,7 +171,7 @@ int InsetERT::latex(Buffer const &, ostream & os,
}
int InsetERT::plaintext(Buffer const &, lyx::odocstream &,
int InsetERT::plaintext(Buffer const &, odocstream &,
OutputParams const & /*runparams*/) const
{
return 0;
@ -187,7 +188,7 @@ int InsetERT::docbook(Buffer const &, ostream & os,
while (par != end) {
pos_type siz = par->size();
for (pos_type i = 0; i < siz; ++i)
os << par->getChar(i);
os.put(par->getChar(i));
++par;
if (par != end) {
os << "\n";

View File

@ -49,7 +49,7 @@ public:
///
bool insetAllowed(InsetBase::Code code) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -49,6 +49,8 @@ namespace external = lyx::external;
namespace graphics = lyx::graphics;
using lyx::docstring;
using lyx::odocstream;
using std::endl;
using std::string;
using std::auto_ptr;
@ -676,12 +678,13 @@ void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
}
int InsetExternal::latex(Buffer const & buf, ostream & os,
int InsetExternal::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
if (params_.draft) {
// FIXME UNICODE
os << "\\fbox{\\ttfamily{}"
<< params_.filename.outputFilename(buf.filePath())
<< lyx::from_utf8(params_.filename.outputFilename(buf.filePath()))
<< "}\n";
return 1;
}
@ -717,25 +720,25 @@ int InsetExternal::latex(Buffer const & buf, ostream & os,
}
int InsetExternal::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetExternal::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
std::ostringstream oss;
int const retval = external::writeExternal(params_, "Ascii", buf, oss,
return external::writeExternal(params_, "Ascii", buf, os,
*(runparams.exportdata), false,
runparams.inComment);
// FIXME UNICODE
os << lyx::from_utf8(oss.str());
return retval;
}
int InsetExternal::docbook(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
return external::writeExternal(params_, "DocBook", buf, os,
lyx::odocstringstream oss;
int const retval = external::writeExternal(params_, "DocBook", buf, oss,
*(runparams.exportdata), false,
runparams.inComment);
// FIXME UNICODE
os << lyx::to_utf8(oss.str());
return retval;
}
@ -802,9 +805,9 @@ bool preview_wanted(InsetExternalParams const & params)
}
string const latex_string(InsetExternal const & inset, Buffer const & buffer)
docstring const latex_string(InsetExternal const & inset, Buffer const & buffer)
{
ostringstream os;
lyx::odocstringstream os;
OutputParams runparams;
runparams.flavor = OutputParams::LATEX;
inset.latex(buffer, os, runparams);
@ -822,7 +825,7 @@ void add_preview_and_start_loading(RenderMonitoredPreview & renderer,
if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
preview_wanted(params)) {
renderer.setAbsFile(params.filename.absFilename());
string const snippet = latex_string(inset, buffer);
docstring const snippet = latex_string(inset, buffer);
renderer.addPreview(snippet, buffer);
renderer.startLoading(buffer);
}
@ -839,7 +842,7 @@ void InsetExternal::addPreview(graphics::PreviewLoader & ploader) const
if (preview_wanted(params())) {
ptr->setAbsFile(params_.filename.absFilename());
string const snippet = latex_string(*this, ploader.buffer());
docstring const snippet = latex_string(*this, ploader.buffer());
ptr->addPreview(snippet, ploader);
}
}

View File

@ -123,7 +123,7 @@ public:
virtual void read(Buffer const &, LyXLex & lex);
/// \returns the number of rows (\n's) of generated code.
virtual int latex(Buffer const &, std::ostream &,
virtual int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
virtual int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -37,6 +37,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::support::contains;
using std::endl;
@ -279,7 +280,7 @@ docstring const InsetFloat::editMessage() const
}
int InsetFloat::latex(Buffer const & buf, ostream & os,
int InsetFloat::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
FloatList const & floats = buf.params().getLyXTextClass().floats();
@ -310,11 +311,11 @@ int InsetFloat::latex(Buffer const & buf, ostream & os,
// The \n is used to force \begin{<floatname>} to appear in a new line.
// The % is needed to prevent two consecutive \n chars in the case
// when the current output line is empty.
os << "%\n\\begin{" << tmptype << '}';
os << "%\n\\begin{" << lyx::from_ascii(tmptype) << '}';
// We only output placement if different from the def_placement.
// sidewaysfloats always use their own page
if (!placement.empty() && !params_.sideways) {
os << '[' << placement << ']';
os << '[' << lyx::from_ascii(placement) << ']';
}
os << '\n';
@ -322,7 +323,7 @@ int InsetFloat::latex(Buffer const & buf, ostream & os,
// The \n is used to force \end{<floatname>} to appear in a new line.
// In this case, we do not case if the current output line is empty.
os << "\n\\end{" << tmptype << "}\n";
os << "\n\\end{" << lyx::from_ascii(tmptype) << "}\n";
return i + 4;
}

View File

@ -54,7 +54,7 @@ public:
///
InsetBase::Code lyxCode() const { return InsetBase::FLOAT_CODE; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -28,6 +28,7 @@
#include "support/lstrings.h"
using lyx::docstring;
using lyx::odocstream;
using lyx::support::bformat;
using std::endl;
@ -79,7 +80,7 @@ void InsetFloatList::read(Buffer const & buf, LyXLex & lex)
}
int InsetFloatList::latex(Buffer const & buf, ostream & os,
int InsetFloatList::latex(Buffer const & buf, odocstream & os,
OutputParams const &) const
{
FloatList const & floats = buf.params().getLyXTextClass().floats();
@ -98,20 +99,20 @@ int InsetFloatList::latex(Buffer const & buf, ostream & os,
}
} else {
// FIXME UNICODE
os << "\\listof{" << getCmdName() << "}{"
<< lyx::to_utf8(buf.B_(cit->second.listName())) << "}\n";
os << "\\listof{" << lyx::from_ascii(getCmdName()) << "}{"
<< buf.B_(cit->second.listName()) << "}\n";
}
} else {
// FIXME UNICODE
os << "%%\\listof{" << getCmdName() << "}{"
<< lyx::to_utf8(bformat(_("List of %1$s"), lyx::from_utf8(cit->second.name())))
os << "%%\\listof{" << lyx::from_ascii(getCmdName()) << "}{"
<< bformat(_("List of %1$s"), lyx::from_utf8(cit->second.name()))
<< "}\n";
}
return 1;
}
int InsetFloatList::plaintext(Buffer const & buffer, lyx::odocstream & os,
int InsetFloatList::plaintext(Buffer const & buffer, odocstream & os,
OutputParams const &) const
{
os << getScreenLabel(buffer) << "\n\n";

View File

@ -36,7 +36,7 @@ public:
///
void read(Buffer const &, LyXLex &);
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -24,6 +24,7 @@
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -58,7 +59,7 @@ docstring const InsetFoot::editMessage() const
}
int InsetFoot::latex(Buffer const & buf, ostream & os,
int InsetFoot::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams_in) const
{
OutputParams runparams = runparams_in;

View File

@ -25,7 +25,7 @@ public:
///
InsetBase::Code lyxCode() const { return InsetBase::FOOT_CODE; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -87,6 +87,8 @@ TODO
#include <sstream>
using lyx::odocstream;
namespace support = lyx::support;
using lyx::support::absolutePath;
@ -735,7 +737,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
}
int InsetGraphics::latex(Buffer const & buf, ostream & os,
int InsetGraphics::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
// If there is no file specified or not existing,
@ -795,7 +797,8 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
// (when there are several versions in different formats)
latex_str += prepareFile(buf, runparams);
latex_str += '}' + after;
os << latex_str;
// FIXME UNICODE
os << lyx::from_utf8(latex_str);
lyxerr[Debug::GRAPHICS] << "InsetGraphics::latex outputting:\n"
<< latex_str << endl;
@ -804,7 +807,7 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
}
int InsetGraphics::plaintext(Buffer const &, lyx::odocstream & os,
int InsetGraphics::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
// No graphics in ascii output. Possible to use gifscii to convert

View File

@ -43,7 +43,7 @@ public:
#fragile == true# means, that the inset should take care about
fragile commands by adding a #\protect# before.
*/
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -15,6 +15,7 @@
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using std::ostream;
@ -45,7 +46,7 @@ docstring const InsetHFill::getScreenLabel(Buffer const &) const
}
int InsetHFill::latex(Buffer const &, ostream & os,
int InsetHFill::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << getCommand();
@ -53,7 +54,7 @@ int InsetHFill::latex(Buffer const &, ostream & os,
}
int InsetHFill::plaintext(Buffer const &, lyx::odocstream & os,
int InsetHFill::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\t';

View File

@ -26,7 +26,7 @@ public:
///
InsetBase::Code lyxCode() const { return InsetBase::HFILL_CODE; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -54,6 +54,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::support::addName;
using lyx::support::absolutePath;
using lyx::support::bformat;
@ -258,7 +259,7 @@ void InsetInclude::write(Buffer const &, ostream & os) const
void InsetInclude::write(ostream & os) const
{
os << "Include " << params_.getCommand() << '\n'
os << "Include " << lyx::to_utf8(params_.getCommand()) << '\n'
<< "preview " << convert<string>(params_.preview()) << '\n';
}
@ -350,7 +351,7 @@ bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
} // namespace anon
int InsetInclude::latex(Buffer const & buffer, ostream & os,
int InsetInclude::latex(Buffer const & buffer, odocstream & os,
OutputParams const & runparams) const
{
string incfile(params_.getContents());
@ -435,7 +436,9 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
"latex" : "pdflatex";
if (isVerbatim(params_)) {
incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{' << incfile << '}';
// FIXME UNICODE
os << '\\' << lyx::from_ascii(params_.getCmdName()) << '{'
<< lyx::from_utf8(incfile) << '}';
} else if (type(params_) == INPUT) {
runparams.exportdata->addExternalFile(tex_format, writefile,
exportfile);
@ -443,13 +446,15 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
// \input wants file with extension (default is .tex)
if (!isLyXFilename(included_file)) {
incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{' << incfile << '}';
// FIXME UNICODE
os << '\\' << lyx::from_ascii(params_.getCmdName())
<< '{' << lyx::from_utf8(incfile) << '}';
} else {
incfile = changeExtension(incfile, ".tex");
incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{'
<< incfile
<< '}';
// FIXME UNICODE
os << '\\' << lyx::from_ascii(params_.getCmdName())
<< '{' << lyx::from_utf8(incfile) << '}';
}
} else {
runparams.exportdata->addExternalFile(tex_format, writefile,
@ -459,16 +464,16 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
// file really have .tex
incfile = changeExtension(incfile, string());
incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{'
<< incfile
<< '}';
// FIXME UNICODE
os << '\\' << lyx::from_ascii(params_.getCmdName()) << '{'
<< lyx::from_utf8(incfile) << '}';
}
return 0;
}
int InsetInclude::plaintext(Buffer const & buffer, lyx::odocstream & os,
int InsetInclude::plaintext(Buffer const & buffer, odocstream & os,
OutputParams const &) const
{
if (isVerbatim(params_)) {
@ -708,9 +713,9 @@ bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
}
string const latex_string(InsetInclude const & inset, Buffer const & buffer)
docstring const latex_string(InsetInclude const & inset, Buffer const & buffer)
{
ostringstream os;
lyx::odocstringstream os;
OutputParams runparams;
runparams.flavor = OutputParams::LATEX;
inset.latex(buffer, os, runparams);
@ -726,7 +731,7 @@ void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
preview_wanted(params, buffer)) {
renderer.setAbsFile(includedFilename(buffer, params));
string const snippet = latex_string(inset, buffer);
docstring const snippet = latex_string(inset, buffer);
renderer.addPreview(snippet, buffer);
}
}
@ -739,7 +744,7 @@ void InsetInclude::addPreview(lyx::graphics::PreviewLoader & ploader) const
Buffer const & buffer = ploader.buffer();
if (preview_wanted(params(), buffer)) {
preview_->setAbsFile(includedFilename(buffer, params()));
string const snippet = latex_string(*this, buffer);
docstring const snippet = latex_string(*this, buffer);
preview_->addPreview(snippet, ploader);
}
}

View File

@ -75,7 +75,7 @@ public:
///
void read(Buffer const &, LyXLex &);
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -27,6 +27,7 @@
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using lyx::support::escape;
using std::string;
@ -84,7 +85,7 @@ void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
}
int InsetLabel::latex(Buffer const &, ostream & os,
int InsetLabel::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << escape(getCommand());
@ -92,7 +93,7 @@ int InsetLabel::latex(Buffer const &, ostream & os,
}
int InsetLabel::plaintext(Buffer const &, lyx::odocstream & os,
int InsetLabel::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
// FIXME UNICODE

View File

@ -27,7 +27,7 @@ public:
/// Appends \c list with this label
void getLabelList(Buffer const &, std::vector<lyx::docstring> & list) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -26,6 +26,7 @@
using lyx::char_type;
using lyx::docstring;
using lyx::odocstream;
using lyx::support::contains;
using lyx::support::trim;
@ -571,15 +572,15 @@ void InsetLatexAccent::read(Buffer const &, LyXLex & lex)
}
int InsetLatexAccent::latex(Buffer const &, ostream & os,
int InsetLatexAccent::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << contents;
os << lyx::from_ascii(contents);
return 0;
}
int InsetLatexAccent::plaintext(Buffer const &, lyx::odocstream & os,
int InsetLatexAccent::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << lyx::from_ascii(contents);
@ -595,7 +596,7 @@ int InsetLatexAccent::docbook(Buffer const &, ostream & os,
}
int InsetLatexAccent::textString(Buffer const & buf, lyx::odocstream & os,
int InsetLatexAccent::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -43,7 +43,7 @@ public:
///
void read(Buffer const &, LyXLex & lex);
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -21,6 +21,7 @@
#include "frontends/Painter.h"
using lyx::odocstream;
using lyx::frontend::Painter;
using std::endl;
@ -55,15 +56,16 @@ void InsetLine::draw(PainterInfo & pi, int x, int y) const
}
int InsetLine::latex(Buffer const &, ostream & os,
int InsetLine::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
os << "\\lyxline{\\" << runparams.local_font->latexSize() << '}';
os << "\\lyxline{\\"
<< lyx::from_ascii(runparams.local_font->latexSize()) << '}';
return 0;
}
int InsetLine::plaintext(Buffer const &, lyx::odocstream & os,
int InsetLine::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << "-------------------------------------------";

View File

@ -26,7 +26,7 @@ public:
void draw(PainterInfo & pi, int x, int y) const;
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -19,6 +19,7 @@
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -53,7 +54,7 @@ docstring const InsetMarginal::editMessage() const
}
int InsetMarginal::latex(Buffer const & buf, ostream & os,
int InsetMarginal::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << "%\n\\marginpar{";

View File

@ -26,7 +26,7 @@ public:
///
InsetBase::Code lyxCode() const { return InsetBase::MARGIN_CODE; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -22,6 +22,8 @@
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
using lyx::odocstream;
using std::endl;
using std::ostream;
@ -49,7 +51,7 @@ void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
}
int InsetNewline::latex(Buffer const &, ostream &,
int InsetNewline::latex(Buffer const &, odocstream &,
OutputParams const &) const
{
lyxerr << "Eek, calling InsetNewline::latex !" << endl;
@ -57,7 +59,7 @@ int InsetNewline::latex(Buffer const &, ostream &,
}
int InsetNewline::plaintext(Buffer const &, lyx::odocstream & os,
int InsetNewline::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\n';

View File

@ -26,7 +26,7 @@ public:
virtual void draw(PainterInfo & pi, int x, int y) const;
virtual int latex(Buffer const &, std::ostream &,
virtual int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
virtual int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -35,6 +35,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -250,7 +251,7 @@ bool InsetNote::getStatus(LCursor & cur, FuncRequest const & cmd,
}
int InsetNote::latex(Buffer const & buf, ostream & os,
int InsetNote::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams_in) const
{
if (params_.type == InsetNoteParams::Note)
@ -270,10 +271,10 @@ int InsetNote::latex(Buffer const & buf, ostream & os,
else if (params_.type == InsetNoteParams::Shaded)
type = "shaded";
ostringstream ss;
ss << "%\n\\begin{" << type << "}\n";
lyx::odocstringstream ss;
ss << "%\n\\begin{" << lyx::from_ascii(type) << "}\n";
InsetText::latex(buf, ss, runparams);
ss << "\n\\end{" << type << "}\n";
ss << "\n\\end{" << lyx::from_ascii(type) << "}\n";
// the space after the comment in 'a[comment] b' will be eaten by the
// comment environment since the space before b is ignored with the
// following latex output:
@ -288,10 +289,10 @@ int InsetNote::latex(Buffer const & buf, ostream & os,
if (params_.type == InsetNoteParams::Comment)
ss << "{}";
string const str = ss.str();
docstring const str = ss.str();
os << str;
// Return how many newlines we issued.
return int(lyx::count(str.begin(), str.end(),'\n'));
return int(lyx::count(str.begin(), str.end(), '\n'));
}
@ -322,7 +323,7 @@ int InsetNote::docbook(Buffer const & buf, std::ostream & os,
}
int InsetNote::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetNote::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams_in) const
{
if (params_.type == InsetNoteParams::Note)

View File

@ -57,7 +57,7 @@ public:
/// show the note dialog
bool showInsetDialog(BufferView * bv) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -20,6 +20,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -66,7 +67,7 @@ void InsetOptArg::write(Buffer const & buf, ostream & os) const
}
int InsetOptArg::latex(Buffer const &, ostream &,
int InsetOptArg::latex(Buffer const &, odocstream &,
OutputParams const &) const
{
return 0;
@ -79,20 +80,20 @@ int InsetOptArg::docbook(Buffer const &, ostream &,
}
int InsetOptArg::plaintext(Buffer const &, lyx::odocstream &,
int InsetOptArg::plaintext(Buffer const &, odocstream &,
OutputParams const &) const
{
return 0;
}
int InsetOptArg::latexOptional(Buffer const & buf, ostream & os,
int InsetOptArg::latexOptional(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
ostringstream ss;
lyx::odocstringstream ss;
int ret = InsetText::latex(buf, ss, runparams);
string str = ss.str();
if (str.find(']') != string::npos)
docstring str = ss.str();
if (str.find(']') != docstring::npos)
str = '{' + str + '}';
os << '[' << str << ']';
return ret;

View File

@ -30,7 +30,7 @@ public:
virtual lyx::docstring const editMessage() const;
/// Standard LaTeX output -- short-circuited
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
/// Standard DocBook output -- short-circuited
int docbook(Buffer const &, std::ostream &,
@ -41,7 +41,7 @@ public:
OutputParams const &) const;
/// Outputting the optional parameter of a LaTeX command
int latexOptional(Buffer const &, std::ostream &,
int latexOptional(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
/// Write out tothe .lyx file
void write(Buffer const & buf, std::ostream & os) const;

View File

@ -22,6 +22,7 @@
#include "frontends/Painter.h"
using lyx::docstring;
using lyx::odocstream;
using lyx::frontend::Painter;
using std::endl;
@ -75,7 +76,7 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
}
int InsetPagebreak::latex(Buffer const &, ostream & os,
int InsetPagebreak::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << "\\newpage{}";
@ -83,7 +84,7 @@ int InsetPagebreak::latex(Buffer const &, ostream & os,
}
int InsetPagebreak::plaintext(Buffer const &, lyx::odocstream & os,
int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\n';

View File

@ -26,7 +26,7 @@ public:
void draw(PainterInfo & pi, int x, int y) const;
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -31,6 +31,7 @@
using lyx::docstring;
using lyx::odocstream;
using lyx::support::prefixIs;
using std::endl;
@ -268,7 +269,7 @@ void InsetQuotes::read(Buffer const &, LyXLex & lex)
}
int InsetQuotes::latex(Buffer const &, ostream & os,
int InsetQuotes::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
const int quoteind = quote_index[side_][language_];
@ -296,12 +297,12 @@ int InsetQuotes::latex(Buffer const &, ostream & os,
if (prefixIs(qstr, "`"))
qstr.insert(0, "{}");
os << qstr;
os << lyx::from_ascii(qstr);
return 0;
}
int InsetQuotes::plaintext(Buffer const &, lyx::odocstream & os,
int InsetQuotes::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '"';
@ -327,7 +328,7 @@ int InsetQuotes::docbook(Buffer const &, ostream & os,
}
int InsetQuotes::textString(Buffer const & buf, lyx::odocstream & os,
int InsetQuotes::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -84,7 +84,7 @@ public:
///
void read(Buffer const &, LyXLex & lex);
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -25,6 +25,7 @@
using lyx::docstring;
using lyx::odocstream;
using lyx::support::escape;
using std::string;
@ -84,7 +85,7 @@ docstring const InsetRef::getScreenLabel(Buffer const &) const
}
int InsetRef::latex(Buffer const &, ostream & os,
int InsetRef::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
// Don't output p_["name"], this is only used in docbook
@ -95,7 +96,7 @@ int InsetRef::latex(Buffer const &, ostream & os,
}
int InsetRef::plaintext(Buffer const &, lyx::odocstream & os,
int InsetRef::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
// FIXME UNICODE
@ -120,7 +121,7 @@ int InsetRef::docbook(Buffer const & buf, ostream & os,
}
int InsetRef::textString(Buffer const & buf, lyx::odocstream & os,
int InsetRef::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -44,7 +44,7 @@ public:
///
bool display() const { return false; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -25,6 +25,8 @@
#include "frontends/Painter.h"
using lyx::odocstream;
using std::string;
using std::max;
using std::auto_ptr;
@ -162,7 +164,7 @@ void InsetSpace::read(Buffer const &, LyXLex & lex)
}
int InsetSpace::latex(Buffer const &, ostream & os,
int InsetSpace::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
switch (kind_) {
@ -195,7 +197,7 @@ int InsetSpace::latex(Buffer const &, ostream & os,
}
int InsetSpace::plaintext(Buffer const &, lyx::odocstream & os,
int InsetSpace::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
switch (kind_) {
@ -235,7 +237,7 @@ int InsetSpace::docbook(Buffer const &, ostream & os,
}
int InsetSpace::textString(Buffer const & buf, lyx::odocstream & os,
int InsetSpace::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -61,7 +61,7 @@ public:
/// Will not be used when lyxf3
void read(Buffer const &, LyXLex & lex);
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -24,6 +24,7 @@
#include "frontends/Painter.h"
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::auto_ptr;
@ -164,7 +165,7 @@ void InsetSpecialChar::read(Buffer const &, LyXLex & lex)
}
int InsetSpecialChar::latex(Buffer const &, ostream & os,
int InsetSpecialChar::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
switch (kind_) {
@ -188,7 +189,7 @@ int InsetSpecialChar::latex(Buffer const &, ostream & os,
}
int InsetSpecialChar::plaintext(Buffer const &, lyx::odocstream & os,
int InsetSpecialChar::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
switch (kind_) {
@ -230,7 +231,7 @@ int InsetSpecialChar::docbook(Buffer const &, ostream & os,
}
int InsetSpecialChar::textString(Buffer const & buf, lyx::odocstream & os,
int InsetSpecialChar::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -53,7 +53,7 @@ public:
/// Will not be used when lyxf3
void read(Buffer const &, LyXLex & lex);
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -47,6 +47,7 @@
#include <limits>
using lyx::docstring;
using lyx::odocstream;
using lyx::Point;
using lyx::cap::dirtyTabularStack;
@ -1054,14 +1055,14 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
}
int InsetTabular::latex(Buffer const & buf, ostream & os,
int InsetTabular::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return tabular.latex(buf, os, runparams);
}
int InsetTabular::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetTabular::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
int const dp = runparams.linelen ? runparams.depth : 0;

View File

@ -84,7 +84,7 @@ public:
///
bool display() const { return tabular.isLongTabular(); }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -53,6 +53,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::pos_type;
using lyx::graphics::PreviewLoader;
@ -260,7 +261,7 @@ bool InsetText::getStatus(LCursor & cur, FuncRequest const & cmd,
}
int InsetText::latex(Buffer const & buf, ostream & os,
int InsetText::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
TexRow texrow;
@ -269,7 +270,7 @@ int InsetText::latex(Buffer const & buf, ostream & os,
}
int InsetText::plaintext(Buffer const & buf, lyx::odocstream & os,
int InsetText::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
ParagraphList::const_iterator beg = paragraphs().begin();

View File

@ -61,7 +61,7 @@ public:
///
InsetText const * asTextInset() const { return this; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -87,7 +87,7 @@ string const InsetTheorem::editMessage() const
}
int InsetTheorem::latex(Buffer const * buf, ostream & os,
int InsetTheorem::latex(Buffer const * buf, odocstream & os,
OutputParams const & runparams) const
{
os << "\\begin{theorem}%\n";

View File

@ -31,7 +31,7 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
virtual lyx::docstring const editMessage() const;

View File

@ -21,6 +21,7 @@
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::ostream;
@ -54,7 +55,7 @@ InsetBase::Code InsetTOC::lyxCode() const
}
int InsetTOC::plaintext(Buffer const & buffer, lyx::odocstream & os,
int InsetTOC::plaintext(Buffer const & buffer, odocstream & os,
OutputParams const &) const
{
os << getScreenLabel(buffer) << "\n\n";

View File

@ -23,6 +23,7 @@
#include "support/std_ostream.h"
using lyx::docstring;
using lyx::odocstream;
using lyx::support::subst;
using std::string;
@ -56,19 +57,20 @@ docstring const InsetUrl::getScreenLabel(Buffer const &) const
}
int InsetUrl::latex(Buffer const &, ostream & os,
int InsetUrl::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
if (!getOptions().empty())
os << getOptions() + ' ';
docstring const & name = getParam("name");
if (!name.empty())
os << name + ' ';
if (runparams.moving_arg)
os << "\\protect";
os << "\\url{" << getContents() << '}';
os << "\\url{" << getParam("target") << '}';
return 0;
}
int InsetUrl::plaintext(Buffer const &, lyx::odocstream & os,
int InsetUrl::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
// FIXME UNICODE
@ -91,7 +93,7 @@ int InsetUrl::docbook(Buffer const &, ostream & os,
}
int InsetUrl::textString(Buffer const & buf, lyx::odocstream & os,
int InsetUrl::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -35,7 +35,7 @@ public:
///
bool display() const { return false; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -29,6 +29,7 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::istringstream;
using std::ostream;
@ -202,15 +203,15 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
}
int InsetVSpace::latex(Buffer const & buf, ostream & os,
int InsetVSpace::latex(Buffer const & buf, odocstream & os,
OutputParams const &) const
{
os << space_.asLatexCommand(buf.params()) << '\n';
os << lyx::from_ascii(space_.asLatexCommand(buf.params())) << '\n';
return 1;
}
int InsetVSpace::plaintext(Buffer const &, lyx::odocstream & os,
int InsetVSpace::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << "\n\n";

View File

@ -30,7 +30,7 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, lyx::odocstream &,

View File

@ -32,9 +32,8 @@
#include "support/convert.h"
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using std::string;
using std::endl;
@ -180,15 +179,15 @@ docstring const InsetWrap::editMessage() const
}
int InsetWrap::latex(Buffer const & buf, ostream & os,
int InsetWrap::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << "\\begin{floating" << params_.type << '}';
os << "\\begin{floating" << lyx::from_ascii(params_.type) << '}';
if (!params_.placement.empty())
os << '[' << params_.placement << ']';
os << '{' << params_.width.asLatexString() << "}%\n";
os << '[' << lyx::from_ascii(params_.placement) << ']';
os << '{' << lyx::from_ascii(params_.width.asLatexString()) << "}%\n";
int const i = InsetText::latex(buf, os, runparams);
os << "\\end{floating" << params_.type << "}%\n";
os << "\\end{floating" << lyx::from_ascii(params_.type) << "}%\n";
return i + 2;
}

View File

@ -50,7 +50,7 @@ public:
///
InsetBase::Code lyxCode() const { return InsetBase::WRAP_CODE; }
///
int latex(Buffer const &, std::ostream &,
int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -184,7 +184,7 @@ void RenderPreview::startLoading(Buffer const & buffer) const
}
void RenderPreview::addPreview(string const & latex_snippet,
void RenderPreview::addPreview(docstring const & latex_snippet,
Buffer const & buffer)
{
if (status() == LyXRC::PREVIEW_OFF)
@ -195,13 +195,15 @@ void RenderPreview::addPreview(string const & latex_snippet,
}
void RenderPreview::addPreview(string const & latex_snippet,
void RenderPreview::addPreview(docstring const & latex_snippet,
graphics::PreviewLoader & ploader)
{
if (status() == LyXRC::PREVIEW_OFF)
return;
snippet_ = support::trim(latex_snippet);
// FIXME UNICODE
// We have to make sure that we call latex with the right encoding
snippet_ = support::trim(lyx::to_utf8(latex_snippet));
if (snippet_.empty())
return;

View File

@ -19,6 +19,7 @@
#include "render_base.h"
#include "support/FileMonitor.h"
#include "support/docstring.h"
#include <boost/signal.hpp>
#include <boost/signals/trackable.hpp>
@ -56,12 +57,12 @@ public:
/** Find the PreviewLoader and add a LaTeX snippet to it.
* Do not start the loading process.
*/
void addPreview(std::string const & latex_snippet, Buffer const &);
void addPreview(lyx::docstring const & latex_snippet, Buffer const &);
/** Add a LaTeX snippet to the PreviewLoader.
* Do not start the loading process.
*/
void addPreview(std::string const & latex_snippet,
void addPreview(lyx::docstring const & latex_snippet,
lyx::graphics::PreviewLoader & ploader);
/// Begin the loading process.

View File

@ -26,8 +26,7 @@
#include "support/lstrings.h"
#include <sstream>
using lyx::odocstream;
using lyx::support::ascii_lowercase;
using lyx::support::bformat;
using lyx::support::rtrim;
@ -743,7 +742,7 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont,
/// Writes the head of the LaTeX needed to impose this font
// Returns number of chars written.
int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
int LyXFont::latexWriteStartChanges(odocstream & os, LyXFont const & base,
LyXFont const & prev) const
{
int count = 0;
@ -763,7 +762,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
string const tmp =
subst(lyxrc.language_command_local,
"$$lang", language()->babel());
os << tmp;
os << lyx::from_ascii(tmp);
count += tmp.length();
}
}
@ -800,7 +799,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
}
if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
os << "\\textcolor{"
<< lcolor.getLaTeXName(f.color())
<< lyx::from_ascii(lcolor.getLaTeXName(f.color()))
<< "}{";
count += lcolor.getLaTeXName(f.color()).length() + 13;
env = true; //We have opened a new environment
@ -839,7 +838,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
int LyXFont::latexWriteEndChanges(odocstream & os, LyXFont const & base,
LyXFont const & next) const
{
int count = 0;

View File

@ -16,9 +16,8 @@
#define LYXFONT_H
#include "LColor.h"
#include "support/docstream.h"
#include <iosfwd>
#include <string>
class LyXLex;
class BufferParams;
@ -295,14 +294,14 @@ public:
to this font. Returns number of chars written. Base is the
font state active now.
*/
int latexWriteStartChanges(std::ostream &, LyXFont const & base,
int latexWriteStartChanges(lyx::odocstream &, LyXFont const & base,
LyXFont const & prev) const;
/** Writes the tail of the LaTeX needed to change to this font.
Returns number of chars written. Base is the font state we want
to achieve.
*/
int latexWriteEndChanges(std::ostream &, LyXFont const & base,
int latexWriteEndChanges(lyx::odocstream &, LyXFont const & base,
LyXFont const & next) const;
/// Build GUI description of font state

View File

@ -31,6 +31,7 @@
#include <sstream>
using lyx::odocstream;
using lyx::support::bformat;
using std::string;
@ -75,7 +76,7 @@ void InsetFormulaMacro::write(Buffer const &, ostream & os) const
}
int InsetFormulaMacro::latex(Buffer const &, ostream & os,
int InsetFormulaMacro::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
//lyxerr << "InsetFormulaMacro::latex" << endl;
@ -85,7 +86,7 @@ int InsetFormulaMacro::latex(Buffer const &, ostream & os,
}
int InsetFormulaMacro::plaintext(Buffer const &, lyx::odocstream & os,
int InsetFormulaMacro::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
WriteStream wi(os, false, true);

View File

@ -44,7 +44,7 @@ public:
int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int latex(Buffer const &, std::ostream & os,
int latex(Buffer const &, lyx::odocstream & os,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,

View File

@ -20,8 +20,9 @@
#include <boost/current_function.hpp>
using lyx::odocstream;
using std::string;
using std::ostream;
using std::endl;
@ -44,8 +45,10 @@ MathArray const & InsetMath::cell(idx_type) const
void InsetMath::dump() const
{
lyxerr << "---------------------------------------------" << endl;
WriteStream wi(lyxerr, false, true);
lyx::odocstringstream os;
WriteStream wi(os, false, true);
write(wi);
lyxerr << lyx::to_utf8(os.str());
lyxerr << "\n---------------------------------------------" << endl;
}
@ -131,7 +134,16 @@ string InsetMath::name() const
}
ostream & operator<<(ostream & os, MathAtom const & at)
std::ostream & operator<<(std::ostream & os, MathAtom const & at)
{
lyx::odocstringstream oss;
WriteStream wi(oss, false, false);
at->write(wi);
return os << lyx::to_utf8(oss.str());
}
odocstream & operator<<(odocstream & os, MathAtom const & at)
{
WriteStream wi(os, false, false);
at->write(wi);

View File

@ -17,8 +17,6 @@
#include "insets/insetbase.h"
#include <string>
enum HullType {
hullNone,
hullSimple,
@ -198,7 +196,10 @@ public:
virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
};
///
std::ostream & operator<<(std::ostream &, MathAtom const &);
///
lyx::odocstream & operator<<(lyx::odocstream &, MathAtom const &);
// initialize math
void initMath();

View File

@ -22,7 +22,6 @@ using lyx::docstring;
using std::string;
using std::auto_ptr;
using std::ostringstream;
CommandInset::CommandInset(string const & name)
@ -80,10 +79,10 @@ docstring const CommandInset::screenLabel() const
string const CommandInset::createDialogStr(string const & name) const
{
ostringstream os;
os << name << " LatexCommand ";
lyx::odocstringstream os;
os << lyx::from_ascii(name) << " LatexCommand ";
WriteStream ws(os);
write(ws);
ws << "\n\\end_inset\n\n";
return os.str();
return lyx::to_utf8(os.str());
}

View File

@ -44,7 +44,6 @@ using std::string;
using std::auto_ptr;
using std::istream;
using std::istringstream;
using std::ostringstream;
using std::vector;
@ -60,12 +59,12 @@ public:
///
virtual string const inset2string(Buffer const &) const
{
ostringstream data;
lyx::odocstringstream data;
//data << name() << " active_cell " << inset.getActCell() << '\n';
data << name() << " active_cell " << 0 << '\n';
data << lyx::from_utf8(name()) << " active_cell " << 0 << '\n';
WriteStream ws(data);
inset_.write(ws);
return data.str();
return lyx::to_utf8(data.str());
}
protected:

View File

@ -61,6 +61,8 @@
#include <sstream>
using lyx::docstring;
using lyx::odocstream;
using lyx::odocstringstream;
using lyx::cap::grabAndEraseSelection;
using lyx::support::bformat;
using lyx::support::subst;
@ -360,7 +362,7 @@ void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
if (display()) {
InsetMathGrid::metricsT(mi, dim);
} else {
ostringstream os;
odocstringstream os;
WriteStream wi(os, false, true);
write(wi);
dim.wid = os.str().size();
@ -375,7 +377,7 @@ void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
if (display()) {
InsetMathGrid::drawT(pain, x, y);
} else {
ostringstream os;
odocstringstream os;
WriteStream wi(os, false, true);
write(wi);
pain.draw(x, y, os.str().c_str());
@ -385,9 +387,9 @@ void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
namespace {
string const latex_string(InsetMathHull const & inset)
docstring const latex_string(InsetMathHull const & inset)
{
ostringstream ls;
odocstringstream ls;
WriteStream wi(ls, false, false);
inset.write(wi);
return ls.str();
@ -399,7 +401,7 @@ string const latex_string(InsetMathHull const & inset)
void InsetMathHull::addPreview(lyx::graphics::PreviewLoader & ploader) const
{
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
string const snippet = latex_string(*this);
docstring const snippet = latex_string(*this);
preview_->addPreview(snippet, ploader);
}
}
@ -409,7 +411,7 @@ bool InsetMathHull::notifyCursorLeaves(LCursor & cur)
{
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
Buffer const & buffer = cur.buffer();
string const snippet = latex_string(*this);
docstring const snippet = latex_string(*this);
preview_->addPreview(snippet, buffer);
preview_->startLoading(buffer);
}
@ -951,12 +953,13 @@ void InsetMathHull::check() const
void InsetMathHull::doExtern(LCursor & cur, FuncRequest & func)
{
string lang;
string extra;
istringstream iss(lyx::to_utf8(func.argument()));
iss >> lang >> extra;
docstring dlang;
docstring extra;
lyx::idocstringstream iss(func.argument());
iss >> dlang >> extra;
if (extra.empty())
extra = "noextra";
extra = lyx::from_ascii("noextra");
string const lang = lyx::to_ascii(dlang);
#ifdef WITH_WARNINGS
#warning temporarily disabled
@ -1412,9 +1415,11 @@ bool InsetMathHull::searchForward(BufferView * bv, string const & str,
void InsetMathHull::write(Buffer const &, std::ostream & os) const
{
WriteStream wi(os, false, false);
os << "Formula ";
odocstringstream oss;
WriteStream wi(oss, false, false);
oss << "Formula ";
write(wi);
os << lyx::to_utf8(oss.str());
}
@ -1426,7 +1431,7 @@ void InsetMathHull::read(Buffer const &, LyXLex & lex)
}
int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
int InsetMathHull::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
if (0 && display()) {
@ -1440,11 +1445,8 @@ int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
//metrics();
return tpain.textheight();
} else {
std::ostringstream oss;
WriteStream wi(oss, false, true);
WriteStream wi(os, false, true);
wi << cell(0);
// FIXME UNICODE
os << lyx::from_utf8(oss.str());
return wi.line();
}
}
@ -1453,7 +1455,8 @@ int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
int InsetMathHull::docbook(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
MathMLStream ms(os);
odocstringstream oss;
MathMLStream ms(oss);
int res = 0;
string name;
if (getType() == hullSimple)
@ -1466,7 +1469,7 @@ int InsetMathHull::docbook(Buffer const & buf, ostream & os,
bname += " id=\"" + sgml::cleanID(buf, runparams, label(0)) + "\"";
ms << MTag(bname.c_str());
ostringstream ls;
odocstringstream ls;
if (runparams.flavor == OutputParams::XML) {
ms << MTag("alt role=\"tex\" ");
// Workaround for db2latex: db2latex always includes equations with
@ -1474,7 +1477,7 @@ int InsetMathHull::docbook(Buffer const & buf, ostream & os,
// so we strip LyX' math environment
WriteStream wi(ls, false, false);
InsetMathGrid::write(wi);
ms << subst(subst(ls.str(), "&", "&amp;"), "<", "&lt;");
ms << subst(subst(lyx::to_utf8(ls.str()), "&", "&amp;"), "<", "&lt;");
ms << ETag("alt");
ms << MTag("math");
InsetMathGrid::mathmlize(ms);
@ -1482,7 +1485,7 @@ int InsetMathHull::docbook(Buffer const & buf, ostream & os,
} else {
ms << MTag("alt role=\"tex\"");
res = latex(buf, ls, runparams);
ms << subst(subst(ls.str(), "&", "&amp;"), "<", "&lt;");
ms << subst(subst(lyx::to_utf8(ls.str()), "&", "&amp;"), "<", "&lt;");
ms << ETag("alt");
}
@ -1498,11 +1501,12 @@ int InsetMathHull::docbook(Buffer const & buf, ostream & os,
ms << "\">";
ms << ETag(name.c_str());
os << lyx::to_utf8(oss.str());
return ms.line() + res;
}
int InsetMathHull::textString(Buffer const & buf, lyx::odocstream & os,
int InsetMathHull::textString(Buffer const & buf, odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);

View File

@ -79,7 +79,7 @@ void InsetMathMBox::write(WriteStream & ws) const
}
int InsetMathMBox::latex(Buffer const & buf, std::ostream & os,
int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << "\\mbox{\n";

View File

@ -36,7 +36,7 @@ public:
///
void write(WriteStream & os) const;
///
int latex(Buffer const &, std::ostream & os,
int latex(Buffer const &, lyx::odocstream & os,
OutputParams const & runparams) const;
///
LyXText * getText(int) const;

View File

@ -62,6 +62,7 @@
using lyx::CoordCache;
using lyx::docstring;
using lyx::odocstream;
using lyx::Point;
using lyx::cap::copySelection;
@ -208,13 +209,15 @@ bool InsetMathNest::idxLast(LCursor & cur) const
void InsetMathNest::dump() const
{
WriteStream os(lyxerr);
lyx::odocstringstream oss;
WriteStream os(oss);
os << "---------------------------------------------\n";
write(os);
os << "\n";
for (idx_type i = 0, n = nargs(); i != n; ++i)
os << cell(i) << "\n";
os << "---------------------------------------------\n";
lyxerr << lyx::to_utf8(oss.str());
}
@ -348,7 +351,7 @@ void InsetMathNest::normalize(NormalStream & os) const
}
int InsetMathNest::latex(Buffer const &, std::ostream & os,
int InsetMathNest::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
WriteStream wi(os, runparams.moving_arg, true);

Some files were not shown because too many files have changed in this diff Show More