using lyx::docstring;
+using lyx::odocstream;
using lyx::pos_type;
using lyx::pit_type;
{
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;
}
-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)
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();
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();
}
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();
}
}
-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;
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;
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());
+ }
}
}
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,
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.
//@{
namespace support = lyx::support;
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::bformat;
using lyx::support::rtrim;
using lyx::support::tokenPos;
}
-bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
+bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
TexRow & texrow) const
{
os << "\\documentclass";
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
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();
}
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();
}
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";
}
}
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();
}
os << "\\usepackage{fancyhdr}\n";
texrow.newline();
}
- os << "\\pagestyle{" << pagestyle << "}\n";
+ os << "\\pagestyle{" << lyx::from_ascii(pagestyle) << "}\n";
texrow.newline();
}
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.
// 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();
}
texrow.newline();
}
- os << lyxpreamble;
+ // FIXME UNICODE
+ os << lyx::from_utf8(lyxpreamble);
return use_babel;
}
* 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();
#include <boost/assert.hpp>
+using lyx::docstring;
+using lyx::odocstream;
using lyx::pos_type;
using std::endl;
}
-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;
#ifndef CHANGES_H
#define CHANGES_H
-#include "support/types.h"
+#include "support/docstream.h"
#include "support/lyxtime.h"
#include <vector>
-#include <iosfwd>
class Change {
/// 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
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();
}
}
#include <sstream>
using std::string;
-using std::ostringstream;
namespace lyx {
namespace frontend {
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
}
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();
}
/** 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
namespace support = lyx::support;
+using lyx::odocstream;
+
using std::endl;
using std::find;
using std::fill;
using std::ifstream;
using std::list;
using std::map;
-using std::ofstream;
-using std::ostream;
using std::ostringstream;
using std::pair;
using std::vector;
/// 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.
// 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"
}
-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_);
// 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);
}
-void PreviewLoader::Impl::dumpData(ostream & os,
+void PreviewLoader::Impl::dumpData(odocstream & os,
BitmapFile const & vec) const
{
if (vec.empty())
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";
}
}
#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;
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)
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'));
}
#ifndef EXTERNALSUPPORT_H
#define EXTERNALSUPPORT_H
-#include <iosfwd>
-#include <string>
+#include "support/docstream.h"
class Buffer;
class ExportData;
int writeExternal(InsetExternalParams const &,
std::string const & format,
Buffer const &,
- std::ostream &,
+ lyx::odocstream &,
ExportData &,
bool external_in_tmpdir,
bool external_in_comment);
#include <typeinfo>
+using lyx::odocstream;
+
+
namespace {
class InsetName {
int InsetBase::plaintext(Buffer const &,
- lyx::odocstream &, OutputParams const &) const
+ odocstream &, OutputParams const &) const
{
return 0;
}
/// 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;
#include "support/convert.h"
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::prefixIs;
using std::max;
}
-int InsetBibitem::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetBibitem::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '[' << getCounter() << "] ";
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::absolutePath;
using lyx::support::ascii_lowercase;
using lyx::support::changeExtension;
}
-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:
<< 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;
}
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;
}
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;
}
///
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,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using std::auto_ptr;
using std::string;
}
-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);
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 << "]";
}
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 << "{";
}
-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);
///
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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-int InsetBranch::latex(Buffer const & buf, ostream & os,
+int InsetBranch::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return isBranchSelected(buf) ?
}
-int InsetBranch::plaintext(Buffer const & buf, lyx::odocstream & os,
+int InsetBranch::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return isBranchSelected(buf) ?
///
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 &,
#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)
}
-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
// 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!
///
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,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-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())
}
-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);
///
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 &,
#include <boost/filesystem/exception.hpp>
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::ascii_lowercase;
using lyx::support::contains;
using lyx::support::getStringFromVector;
}
-int InsetCitation::plaintext(Buffer const & buffer, lyx::odocstream & os,
+int InsetCitation::plaintext(Buffer const & buffer, odocstream & os,
OutputParams const &) const
{
if (cache.params == params() &&
}
-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);
// 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;
}
///
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 &,
#include <sstream>
+using lyx::odocstream;
+
using std::string;
using std::istringstream;
using std::ostream;
}
-int InsetCommand::latex(Buffer const &, ostream & os,
+int InsetCommand::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << getCommand();
}
-int InsetCommand::plaintext(Buffer const &, lyx::odocstream &,
+int InsetCommand::plaintext(Buffer const &, odocstream &,
OutputParams const &) const
{
return 0;
/// 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 &,
///
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(); }
///
if (lyxerr.debugging(Debug::PARSER))
lyxerr << "Command <" << cmd
- << "> == <" << getCommand()
+ << "> == <" << lyx::to_utf8(getCommand())
<< "> == <" << getCmdName()
<< '|' << getContents()
<< '|' << getOptions()
}
-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) {
} else
s += '{' + params_[i] + '}';
}
- return lyx::to_utf8(s);
+ return s;
}
///
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
#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;
}
-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();
}
///
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;
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::pos_type;
using lyx::support::token;
}
-int InsetERT::latex(Buffer const &, ostream & os,
+int InsetERT::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
ParagraphList::const_iterator par = paragraphs().begin();
if (par->isDeleted(i))
continue;
- os << par->getChar(i);
+ os.put(par->getChar(i));
}
++par;
if (par != end) {
}
-int InsetERT::plaintext(Buffer const &, lyx::odocstream &,
+int InsetERT::plaintext(Buffer const &, odocstream &,
OutputParams const & /*runparams*/) const
{
return 0;
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";
///
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 &,
namespace graphics = lyx::graphics;
using lyx::docstring;
+using lyx::odocstream;
+
using std::endl;
using std::string;
using std::auto_ptr;
}
-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;
}
}
-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;
}
}
-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);
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);
}
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);
}
}
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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::contains;
using std::endl;
}
-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();
// 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';
// 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;
}
///
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 &,
#include "support/lstrings.h"
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::bformat;
using std::endl;
}
-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();
}
} 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";
///
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 &,
#include "support/std_ostream.h"
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-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;
///
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 &,
#include <sstream>
+using lyx::odocstream;
+
namespace support = lyx::support;
using lyx::support::absolutePath;
}
-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,
// (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;
}
-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
#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 &,
#include "support/std_ostream.h"
using lyx::docstring;
+using lyx::odocstream;
using std::ostream;
}
-int InsetHFill::latex(Buffer const &, ostream & os,
+int InsetHFill::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << getCommand();
}
-int InsetHFill::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetHFill::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\t';
///
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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::addName;
using lyx::support::absolutePath;
using lyx::support::bformat;
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';
}
} // 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());
"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);
// \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,
// 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_)) {
}
-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);
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);
}
}
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);
}
}
///
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 &,
#include "support/std_ostream.h"
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::escape;
using std::string;
}
-int InsetLabel::latex(Buffer const &, ostream & os,
+int InsetLabel::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << escape(getCommand());
}
-int InsetLabel::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetLabel::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
// FIXME UNICODE
/// 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 &,
using lyx::char_type;
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::contains;
using lyx::support::trim;
}
-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);
}
-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);
///
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 &,
#include "frontends/Painter.h"
+using lyx::odocstream;
using lyx::frontend::Painter;
using std::endl;
}
-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 << "-------------------------------------------";
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 &,
#include "support/std_ostream.h"
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-int InsetMarginal::latex(Buffer const & buf, ostream & os,
+int InsetMarginal::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << "%\n\\marginpar{";
///
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 &,
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
+using lyx::odocstream;
+
using std::endl;
using std::ostream;
}
-int InsetNewline::latex(Buffer const &, ostream &,
+int InsetNewline::latex(Buffer const &, odocstream &,
OutputParams const &) const
{
lyxerr << "Eek, calling InsetNewline::latex !" << endl;
}
-int InsetNewline::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetNewline::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\n';
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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-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)
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:
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'));
}
}
-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)
/// 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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-int InsetOptArg::latex(Buffer const &, ostream &,
+int InsetOptArg::latex(Buffer const &, odocstream &,
OutputParams const &) const
{
return 0;
}
-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;
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 &,
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;
#include "frontends/Painter.h"
using lyx::docstring;
+using lyx::odocstream;
using lyx::frontend::Painter;
using std::endl;
}
-int InsetPagebreak::latex(Buffer const &, ostream & os,
+int InsetPagebreak::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << "\\newpage{}";
}
-int InsetPagebreak::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\n';
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 &,
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::prefixIs;
using std::endl;
}
-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_];
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 << '"';
}
-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);
///
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 &,
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::escape;
using std::string;
}
-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
}
-int InsetRef::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetRef::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
// FIXME UNICODE
}
-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);
///
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 &,
#include "frontends/Painter.h"
+using lyx::odocstream;
+
using std::string;
using std::max;
using std::auto_ptr;
}
-int InsetSpace::latex(Buffer const &, ostream & os,
+int InsetSpace::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
switch (kind_) {
}
-int InsetSpace::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetSpace::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
switch (kind_) {
}
-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);
/// 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 &,
#include "frontends/Painter.h"
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::auto_ptr;
}
-int InsetSpecialChar::latex(Buffer const &, ostream & os,
+int InsetSpecialChar::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
switch (kind_) {
}
-int InsetSpecialChar::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetSpecialChar::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
switch (kind_) {
}
-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);
/// 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 &,
#include <limits>
using lyx::docstring;
+using lyx::odocstream;
using lyx::Point;
using lyx::cap::dirtyTabularStack;
}
-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;
///
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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::pos_type;
using lyx::graphics::PreviewLoader;
}
-int InsetText::latex(Buffer const & buf, ostream & os,
+int InsetText::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
TexRow texrow;
}
-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();
///
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 &,
}
-int InsetTheorem::latex(Buffer const * buf, ostream & os,
+int InsetTheorem::latex(Buffer const * buf, odocstream & os,
OutputParams const & runparams) const
{
os << "\\begin{theorem}%\n";
///
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;
#include "support/std_ostream.h"
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::ostream;
}
-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";
#include "support/std_ostream.h"
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::subst;
using std::string;
}
-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
}
-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);
///
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 &,
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using std::istringstream;
using std::ostream;
}
-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";
///
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 &,
#include "support/convert.h"
-#include <sstream>
-
using lyx::docstring;
+using lyx::odocstream;
using std::string;
using std::endl;
}
-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;
}
///
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 &,
}
-void RenderPreview::addPreview(string const & latex_snippet,
+void RenderPreview::addPreview(docstring const & latex_snippet,
Buffer const & buffer)
{
if (status() == LyXRC::PREVIEW_OFF)
}
-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;
#include "render_base.h"
#include "support/FileMonitor.h"
+#include "support/docstring.h"
#include <boost/signal.hpp>
#include <boost/signals/trackable.hpp>
/** 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.
#include "support/lstrings.h"
-#include <sstream>
-
+using lyx::odocstream;
using lyx::support::ascii_lowercase;
using lyx::support::bformat;
using lyx::support::rtrim;
/// 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;
string const tmp =
subst(lyxrc.language_command_local,
"$$lang", language()->babel());
- os << tmp;
+ os << lyx::from_ascii(tmp);
count += tmp.length();
}
}
}
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
/// 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;
#define LYXFONT_H
#include "LColor.h"
+#include "support/docstream.h"
-#include <iosfwd>
-#include <string>
class LyXLex;
class BufferParams;
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
#include <sstream>
+using lyx::odocstream;
using lyx::support::bformat;
using std::string;
}
-int InsetFormulaMacro::latex(Buffer const &, ostream & os,
+int InsetFormulaMacro::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
//lyxerr << "InsetFormulaMacro::latex" << endl;
}
-int InsetFormulaMacro::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetFormulaMacro::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
WriteStream wi(os, false, true);
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 &,
#include <boost/current_function.hpp>
+using lyx::odocstream;
+
using std::string;
-using std::ostream;
using std::endl;
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;
}
}
-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);
#include "insets/insetbase.h"
-#include <string>
-
enum HullType {
hullNone,
hullSimple,
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();
using std::string;
using std::auto_ptr;
-using std::ostringstream;
CommandInset::CommandInset(string const & name)
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());
}
using std::auto_ptr;
using std::istream;
using std::istringstream;
-using std::ostringstream;
using std::vector;
///
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:
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
+using lyx::odocstringstream;
using lyx::cap::grabAndEraseSelection;
using lyx::support::bformat;
using lyx::support::subst;
if (display()) {
InsetMathGrid::metricsT(mi, dim);
} else {
- ostringstream os;
+ odocstringstream os;
WriteStream wi(os, false, true);
write(wi);
dim.wid = os.str().size();
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());
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();
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);
}
}
{
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);
}
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
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());
}
}
-int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
+int InsetMathHull::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
if (0 && display()) {
//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();
}
}
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)
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
// so we strip LyX' math environment
WriteStream wi(ls, false, false);
InsetMathGrid::write(wi);
- ms << subst(subst(ls.str(), "&", "&"), "<", "<");
+ ms << subst(subst(lyx::to_utf8(ls.str()), "&", "&"), "<", "<");
ms << ETag("alt");
ms << MTag("math");
InsetMathGrid::mathmlize(ms);
} else {
ms << MTag("alt role=\"tex\"");
res = latex(buf, ls, runparams);
- ms << subst(subst(ls.str(), "&", "&"), "<", "<");
+ ms << subst(subst(lyx::to_utf8(ls.str()), "&", "&"), "<", "<");
ms << ETag("alt");
}
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);
}
-int InsetMathMBox::latex(Buffer const & buf, std::ostream & os,
+int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << "\\mbox{\n";
///
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;
using lyx::CoordCache;
using lyx::docstring;
+using lyx::odocstream;
using lyx::Point;
using lyx::cap::copySelection;
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());
}
}
-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);
/// writes [, name(), and args in []
void normalize(NormalStream & os) const;
///
- int latex(Buffer const &, std::ostream & os,
+ int latex(Buffer const &, lyx::odocstream & os,
OutputParams const & runparams) const;
protected:
#include <boost/assert.hpp>
+using lyx::odocstream;
+
using std::abs;
using std::endl;
using std::min;
void MathArray::dump2() const
{
- NormalStream ns(lyxerr);
+ lyx::odocstringstream os;
+ NormalStream ns(os);
for (const_iterator it = begin(); it != end(); ++it)
ns << *it << ' ';
+ lyxerr << lyx::to_utf8(os.str());
}
void MathArray::dump() const
{
- NormalStream ns(lyxerr);
+ lyx::odocstringstream os;
+ NormalStream ns(os);
for (const_iterator it = begin(); it != end(); ++it)
ns << '<' << *it << '>';
+ lyxerr << lyx::to_utf8(os.str());
}
{
return bv.coordCache().getArrays().y(this);
}
+
+
+std::ostream & operator<<(std::ostream & os, MathArray const & ar)
+{
+ lyx::odocstringstream oss;
+ NormalStream ns(oss);
+ ns << ar;
+ return os << lyx::to_utf8(oss.str());
+}
+
+
+odocstream & operator<<(odocstream & os, MathArray const & ar)
+{
+ NormalStream ns(os);
+ ns << ar;
+ return os;
+}
#ifndef MATH_DATA_H
#define MATH_DATA_H
-#include <iosfwd>
#include <vector>
#include "MathAtom.h"
#include "dimension.h"
+#include "support/docstream.h"
+
class BufferView;
class LaTeXFeatures;
class ReplaceData;
///
std::ostream & operator<<(std::ostream & os, MathArray const & ar);
+///
+lyx::odocstream & operator<<(lyx::odocstream & os, MathArray const & ar);
#endif
#include <algorithm>
#include <sstream>
+using lyx::docstring;
+using lyx::odocstream;
+using lyx::odocstringstream;
using lyx::support::cmd_ret;
using lyx::support::getVectorFromString;
using lyx::support::libFileSearch;
using std::auto_ptr;
using std::istringstream;
using std::ostream;
-using std::ostringstream;
using std::swap;
using std::vector;
-ostream & operator<<(ostream & os, MathArray const & ar)
-{
- NormalStream ns(os);
- ns << ar;
- return os;
-}
-
-
// define a function for tests
typedef bool TestItemFunc(MathAtom const &);
return string::npos;
}
- MathArray pipeThroughMaxima(string const &, MathArray const & ar)
+ MathArray pipeThroughMaxima(docstring const &, MathArray const & ar)
{
- ostringstream os;
+ lyx::odocstringstream os;
MaximaStream ms(os);
ms << ar;
- string expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string expr = lyx::to_utf8(os.str());
string const header = "simpsum:true;";
string out;
}
- MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
+ MathArray pipeThroughMaple(docstring const & extra, MathArray const & ar)
{
string header = "readlib(latex):\n";
// " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
string trailer = "quit;";
- ostringstream os;
+ lyx::odocstringstream os;
MapleStream ms(os);
ms << ar;
- string expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string expr = lyx::to_utf8(os.str());
lyxerr << "ar: '" << ar << "'\n"
- << "ms: '" << os.str() << "'" << endl;
+ << "ms: '" << expr << "'" << endl;
for (int i = 0; i < 100; ++i) { // at most 100 attempts
// try to fix missing '*' the hard way by using mint
expr.insert(pos, 1, '*');
}
- string full = "latex(" + extra + '(' + expr + "));";
+ // FIXME UNICODE Is utf8 encoding correct?
+ string full = "latex(" + lyx::to_utf8(extra) + '(' + expr + "));";
string out = captureOutput("maple -q", header + full + trailer);
// change \_ into _
}
- MathArray pipeThroughOctave(string const &, MathArray const & ar)
+ MathArray pipeThroughOctave(docstring const &, MathArray const & ar)
{
- ostringstream os;
+ lyx::odocstringstream os;
OctaveStream vs(os);
vs << ar;
- string expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string expr = lyx::to_utf8(os.str());
string out;
lyxerr << "pipe: ar: '" << ar << "'\n"
}
- MathArray pipeThroughMathematica(string const &, MathArray const & ar)
+ MathArray pipeThroughMathematica(docstring const &, MathArray const & ar)
{
- ostringstream os;
+ lyx::odocstringstream os;
MathematicaStream ms(os);
ms << ar;
- string const expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string const expr = lyx::to_utf8(os.str());
string out;
lyxerr << "expr: '" << expr << "'" << endl;
}
-MathArray pipeThroughExtern(string const & lang, string const & extra,
+MathArray pipeThroughExtern(string const & lang, docstring const & extra,
MathArray const & ar)
{
if (lang == "octave")
return pipeThroughMathematica(extra, ar);
// create normalized expression
- ostringstream os;
+ lyx::odocstringstream os;
NormalStream ns(os);
os << '[' << extra << ' ';
ns << ar;
os << ']';
- string data = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string data = lyx::to_utf8(os.str());
// search external script
string file = libFileSearch("mathed", "extern_" + lang);
#ifndef MATH_EXTERN_H
#define MATH_EXTERN_H
-#include <string>
+#include "support/docstring.h"
class NormalStream;
bool extractNumber(MathArray const & ar, int & i);
bool extractNumber(MathArray const & ar, double & i);
-MathArray pipeThroughExtern(std::string const & lang, std::string const & extra,
+MathArray pipeThroughExtern(std::string const & lang, lyx::docstring const & extra,
MathArray const & ar);
#endif
using std::strlen;
-using std::ostream;
+using lyx::odocstream;
namespace {
}
-WriteStream::WriteStream(ostream & os, bool fragile, bool latex)
+WriteStream::WriteStream(odocstream & os, bool fragile, bool latex)
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex),
pendingspace_(false), line_(0)
{}
-WriteStream::WriteStream(ostream & os)
+WriteStream::WriteStream(odocstream & os)
: os_(os), fragile_(false), firstitem_(false), latex_(false),
pendingspace_(false), line_(0)
{}
//////////////////////////////////////////////////////////////////////
-MathMLStream::MathMLStream(ostream & os)
+MathMLStream::MathMLStream(odocstream & os)
: os_(os), tab_(0), line_(0), lastchar_(0)
{}
#include "metricsinfo.h"
-#include <iosfwd>
+#include "support/docstream.h"
class MathArray;
class InsetMath;
class WriteStream {
public:
///
- WriteStream(std::ostream & os, bool fragile, bool latex);
+ WriteStream(lyx::odocstream & os, bool fragile, bool latex);
///
- explicit WriteStream(std::ostream & os);
+ explicit WriteStream(lyx::odocstream & os);
///
~WriteStream();
///
///
bool latex() const { return latex_; }
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
///
bool & firstitem() { return firstitem_; }
///
bool pendingSpace() const { return pendingspace_; }
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
/// do we have to write \\protect sometimes
bool fragile_;
/// are we at the beginning of an MathArray?
class MathMLStream {
public:
///
- explicit MathMLStream(std::ostream & os);
+ explicit MathMLStream(lyx::odocstream & os);
///
void cr();
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
///
int line() const { return line_; }
///
friend MathMLStream & operator<<(MathMLStream &, char const *);
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
///
int tab_;
///
class NormalStream {
public:
///
- explicit NormalStream(std::ostream & os) : os_(os) {}
+ explicit NormalStream(lyx::odocstream & os) : os_(os) {}
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
};
///
class MapleStream {
public:
///
- explicit MapleStream(std::ostream & os) : os_(os) {}
+ explicit MapleStream(lyx::odocstream & os) : os_(os) {}
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
};
class MaximaStream {
public:
///
- explicit MaximaStream(std::ostream & os) : os_(os) {}
+ explicit MaximaStream(lyx::odocstream & os) : os_(os) {}
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
};
class MathematicaStream {
public:
///
- explicit MathematicaStream(std::ostream & os) : os_(os) {}
+ explicit MathematicaStream(lyx::odocstream & os) : os_(os) {}
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
};
class OctaveStream {
public:
///
- explicit OctaveStream(std::ostream & os) : os_(os) {}
+ explicit OctaveStream(lyx::odocstream & os) : os_(os) {}
///
- std::ostream & os() { return os_; }
+ lyx::odocstream & os() { return os_; }
private:
///
- std::ostream & os_;
+ lyx::odocstream & os_;
};
///
void MathMacroTemplate::write(Buffer const &, std::ostream & os) const
{
- WriteStream wi(os, false, false);
- os << "FormulaMacro\n";
+ lyx::odocstringstream oss;
+ WriteStream wi(oss, false, false);
+ oss << "FormulaMacro\n";
write(wi);
+ os << lyx::to_utf8(oss.str());
}
#include "MathStream.h"
#include "MathMLStream.h"
-#include "support/std_ostream.h"
using std::string;
NormalStream & operator<<(NormalStream & ns, string const & s)
{
- ns.os() << s;
+ // FIXME UNICODE
+ ns.os() << lyx::from_utf8(s);
return ns;
}
MapleStream & operator<<(MapleStream & ms, string const & s)
{
- ms.os() << s;
+ // FIXME UNICODE
+ ms.os() << lyx::from_utf8(s);
return ms;
}
MaximaStream & operator<<(MaximaStream & ms, string const & s)
{
- ms.os() << s;
+ // FIXME UNICODE
+ ms.os() << lyx::from_utf8(s);
return ms;
}
MathematicaStream & operator<<(MathematicaStream & ms, string const & s)
{
- ms.os() << s;
+ // FIXME UNICODE
+ ms.os() << lyx::from_utf8(s);
return ms;
}
MathMLStream & operator<<(MathMLStream & ms, string const & s)
{
- ms.os() << s;
+ // FIXME UNICODE
+ ms.os() << lyx::from_utf8(s);
return ms;
}
OctaveStream & operator<<(OctaveStream & os, string const & s)
{
- os.os() << s;
+ // FIXME UNICODE
+ os.os() << lyx::from_utf8(s);
return os;
}
string asString(MathArray const & ar)
{
- std::ostringstream os;
+ lyx::odocstringstream os;
WriteStream ws(os);
ws << ar;
- return os.str();
+ // FIXME UNICODE
+ return lyx::to_utf8(os.str());
}
string asString(InsetMath const & inset)
{
- std::ostringstream os;
+ lyx::odocstringstream os;
WriteStream ws(os);
inset.write(ws);
- return os.str();
+ // FIXME UNICODE
+ return lyx::to_utf8(os.str());
}
string asString(MathAtom const & at)
{
- std::ostringstream os;
+ lyx::odocstringstream os;
WriteStream ws(os);
at->write(ws);
- return os.str();
+ // FIXME UNICODE
+ return lyx::to_utf8(os.str());
}
#include "support/std_ostream.h"
+using lyx::char_type;
+
+
TextPainter::TextPainter(int xmax, int ymax)
: xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
{}
-char & TextPainter::at(int x, int y)
+char_type & TextPainter::at(int x, int y)
{
return data_[y * xmax_ + x];
}
-char TextPainter::at(int x, int y) const
+char_type TextPainter::at(int x, int y) const
{
return data_[y * xmax_ + x];
}
-void TextPainter::draw(int x, int y, char const * str)
+void TextPainter::draw(int x, int y, char_type const * str)
{
//cerr << "drawing string '" << str << "' at " << x << ',' << y << endl;
for (int i = 0; *str && x + i < xmax_; ++i, ++str)
}
-void TextPainter::horizontalLine(int x, int y, int n, char c)
+void TextPainter::horizontalLine(int x, int y, int n, char_type c)
{
for (int i = 0; i < n && i + x < xmax_; ++i)
at(x + i, y) = c;
}
-void TextPainter::verticalLine(int x, int y, int n, char c)
+void TextPainter::verticalLine(int x, int y, int n, char_type c)
{
for (int i = 0; i < n && i + y < ymax_; ++i)
at(x, y + i) = c;
}
-void TextPainter::draw(int x, int y, char c)
+void TextPainter::draw(int x, int y, char_type c)
{
//cerr << "drawing char '" << c << "' at " << x << ',' << y << endl;
at(x, y) = c;
///
TextPainter(int xmax, int ymax);
///
- void draw(int x, int y, char const * str);
+ void draw(int x, int y, lyx::char_type const * str);
///
- void draw(int x, int y, char c);
+ void draw(int x, int y, lyx::char_type c);
///
void show(lyx::odocstream & os, int offset = 0) const;
///
int textheight() const { return ymax_; }
///
- void horizontalLine(int x, int y, int len, char c = '-');
+ void horizontalLine(int x, int y, int len, lyx::char_type c = '-');
///
- void verticalLine(int x, int y, int len, char c = '|');
+ void verticalLine(int x, int y, int len, lyx::char_type c = '|');
private:
///
- typedef std::vector<char> data_type;
+ typedef std::vector<lyx::char_type> data_type;
///
- char at(int x, int y) const;
+ lyx::char_type at(int x, int y) const;
///
- char & at(int x, int y);
+ lyx::char_type & at(int x, int y);
/// xsize of the painter area
int xmax_;
using lyx::support::subst;
using std::endl;
-using std::ostream;
+using lyx::odocstream;
using std::string;
TeXEnvironment(Buffer const & buf,
ParagraphList const & paragraphs,
ParagraphList::const_iterator pit,
- ostream & os, TexRow & texrow,
+ odocstream & os, TexRow & texrow,
OutputParams const & runparams);
ParagraphList::const_iterator
TeXOnePar(Buffer const & buf,
ParagraphList const & paragraphs,
ParagraphList::const_iterator pit,
- ostream & os, TexRow & texrow,
+ odocstream & os, TexRow & texrow,
OutputParams const & runparams,
string const & everypar = string());
TeXDeeper(Buffer const & buf,
ParagraphList const & paragraphs,
ParagraphList::const_iterator pit,
- ostream & os, TexRow & texrow,
+ odocstream & os, TexRow & texrow,
OutputParams const & runparams)
{
lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
- ostream & os, OutputParams const & runparams, int number);
+ odocstream & os, OutputParams const & runparams, int number);
ParagraphList::const_iterator
TeXEnvironment(Buffer const & buf,
ParagraphList const & paragraphs,
ParagraphList::const_iterator pit,
- ostream & os, TexRow & texrow,
+ odocstream & os, TexRow & texrow,
OutputParams const & runparams)
{
lyxerr[Debug::LATEX] << "TeXEnvironment... " << &*pit << endl;
if (!lyxrc.language_command_end.empty() &&
previous_language->babel() != doc_language->babel()) {
- os << subst(lyxrc.language_command_end, "$$lang",
- previous_language->babel())
+ os << lyx::from_ascii(subst(
+ lyxrc.language_command_end,
+ "$$lang",
+ previous_language->babel()))
<< endl;
texrow.newline();
}
if (lyxrc.language_command_end.empty() ||
language->babel() != doc_language->babel()) {
- os << subst(lyxrc.language_command_begin, "$$lang",
- language->babel())
+ os << lyx::from_ascii(subst(
+ lyxrc.language_command_begin,
+ "$$lang",
+ language->babel()))
<< endl;
texrow.newline();
}
bool leftindent_open = false;
if (!pit->params().leftIndent().zero()) {
- os << "\\begin{LyXParagraphLeftIndent}{" <<
- pit->params().leftIndent().asLatexString() << "}\n";
+ os << "\\begin{LyXParagraphLeftIndent}{"
+ << lyx::from_ascii(pit->params().leftIndent().asLatexString())
+ << "}\n";
texrow.newline();
leftindent_open = true;
}
if (style->isEnvironment()) {
- os << "\\begin{" << style->latexname() << '}';
+ os << "\\begin{" << lyx::from_ascii(style->latexname()) << '}';
if (style->optionalargs > 0) {
int ret = latexOptArgInsets(buf, *pit, os, runparams,
style->optionalargs);
}
}
if (style->latextype == LATEX_LIST_ENVIRONMENT) {
- os << "{" << pit->params().labelWidthString() << "}\n";
+ // FIXME UNICODE
+ os << '{'
+ << lyx::from_utf8(pit->params().labelWidthString())
+ << "}\n";
} else if (style->labeltype == LABEL_BIBLIO) {
// ale970405
- // FIXME UNICODE
- os << '{' << lyx::to_utf8(bibitemWidest(buf)) << "}\n";
+ os << '{' << bibitemWidest(buf) << "}\n";
} else
- os << style->latexparam() << '\n';
+ os << lyx::from_ascii(style->latexparam()) << '\n';
texrow.newline();
}
ParagraphList::const_iterator par = pit;
&& par->params().leftIndent() == pit->params().leftIndent());
if (style->isEnvironment()) {
- os << "\\end{" << style->latexname() << "}\n";
+ os << "\\end{" << lyx::from_ascii(style->latexname()) << "}\n";
texrow.newline();
}
int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
- ostream & os, OutputParams const & runparams, int number)
+ odocstream & os, OutputParams const & runparams, int number)
{
int lines = 0;
TeXOnePar(Buffer const & buf,
ParagraphList const & paragraphs,
ParagraphList::const_iterator pit,
- ostream & os, TexRow & texrow,
+ odocstream & os, TexRow & texrow,
OutputParams const & runparams_in,
string const & everypar)
{
if (!lyxrc.language_command_end.empty() &&
previous_language->babel() != doc_language->babel())
{
- os << subst(lyxrc.language_command_end, "$$lang",
- previous_language->babel())
+ os << lyx::from_ascii(subst(lyxrc.language_command_end,
+ "$$lang",
+ previous_language->babel()))
<< endl;
texrow.newline();
}
if (lyxrc.language_command_end.empty() ||
language->babel() != doc_language->babel())
{
- os << subst(lyxrc.language_command_begin, "$$lang",
- language->babel())
+ os << lyx::from_ascii(subst(
+ lyxrc.language_command_begin,
+ "$$lang",
+ language->babel()))
<< endl;
texrow.newline();
}
if (bparams.inputenc == "auto" &&
language->encoding() != previous_language->encoding()) {
os << "\\inputencoding{"
- << language->encoding()->latexName()
+ << lyx::from_ascii(language->encoding()->latexName())
<< "}\n";
texrow.newline();
}
&& (pit == paragraphs.begin()
|| !boost::prior(pit)->hasSameLayout(*pit)))
{
- os << pit->params().spacing().writeEnvirBegin() << '\n';
+ os << lyx::from_ascii(pit->params().spacing().writeEnvirBegin())
+ << '\n';
texrow.newline();
}
switch (style->latextype) {
case LATEX_COMMAND:
- os << '\\' << style->latexname();
+ os << '\\' << lyx::from_ascii(style->latexname());
// Separate handling of optional argument inset.
if (style->optionalargs > 0) {
}
}
else
- os << style->latexparam();
+ os << lyx::from_ascii(style->latexparam());
break;
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
break;
}
- os << everypar;
+ // FIXME UNICODE
+ os << lyx::from_utf8(everypar);
bool need_par = pit->simpleTeXOnePar(buf, bparams,
outerFont(std::distance(paragraphs.begin(), pit), paragraphs),
os, texrow, runparams);
&& !is_command) {
if (!need_par)
os << '{';
- os << "\\" << font.latexSize() << " \\par}";
+ os << "\\" << lyx::from_ascii(font.latexSize()) << " \\par}";
} else if (need_par) {
os << "\\par}";
} else if (is_command)
&& (boost::next(pit) == paragraphs.end()
|| !boost::next(pit)->hasSameLayout(*pit)))
{
- os << pit->params().spacing().writeEnvirEnd() << '\n';
+ os << lyx::from_ascii(pit->params().spacing().writeEnvirEnd())
+ << '\n';
texrow.newline();
}
}
// float.
if (lyxrc.language_command_end.empty())
- os << subst(lyxrc.language_command_begin,
- "$$lang",
- doc_language->babel())
+ os << lyx::from_ascii(subst(
+ lyxrc.language_command_begin,
+ "$$lang",
+ doc_language->babel()))
<< endl;
else
- os << subst(lyxrc.language_command_end,
- "$$lang",
- language->babel())
+ os << lyx::from_ascii(subst(
+ lyxrc.language_command_end,
+ "$$lang",
+ language->babel()))
<< endl;
texrow.newline();
}
// LaTeX all paragraphs
void latexParagraphs(Buffer const & buf,
ParagraphList const & paragraphs,
- ostream & os,
+ odocstream & os,
TexRow & texrow,
OutputParams const & runparams,
string const & everypar)
was_title = true;
if (tclass.titletype() == TITLE_ENVIRONMENT) {
os << "\\begin{"
- << tclass.titlename()
+ << lyx::from_ascii(tclass.titlename())
<< "}\n";
texrow.newline();
}
}
} else if (was_title && !already_title) {
if (tclass.titletype() == TITLE_ENVIRONMENT) {
- os << "\\end{" << tclass.titlename()
+ os << "\\end{" << lyx::from_ascii(tclass.titlename())
<< "}\n";
}
else {
- os << "\\" << tclass.titlename()
+ os << "\\" << lyx::from_ascii(tclass.titlename())
<< "\n";
}
texrow.newline();
// It might be that we only have a title in this document
if (was_title && !already_title) {
if (tclass.titletype() == TITLE_ENVIRONMENT) {
- os << "\\end{" << tclass.titlename()
+ os << "\\end{" << lyx::from_ascii(tclass.titlename())
<< "}\n";
}
else {
- os << "\\" << tclass.titlename()
+ os << "\\" << lyx::from_ascii(tclass.titlename())
<< "\n";
}
texrow.newline();
#include "ParagraphList_fwd.h"
-#include <string>
+#include "support/docstream.h"
class Buffer;
class OutputParams;
void latexParagraphs(Buffer const & buf,
ParagraphList const & paragraphs,
- std::ostream & ofs,
+ lyx::odocstream & ofs,
TexRow & texrow,
OutputParams const &,
std::string const & everypar = std::string());
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::pos_type;
using lyx::char_type;
// This could go to ParagraphParameters if we want to
int Paragraph::startTeXParParams(BufferParams const & bparams,
- ostream & os, bool moving_arg) const
+ odocstream & os, bool moving_arg) const
{
int column = 0;
output = corrected_env("\\begin", "flushleft", ownerCode());
else
output = corrected_env("\\begin", "flushright", ownerCode());
- os << output;
+ os << lyx::from_ascii(output);
column += output.size();
break;
} case LYX_ALIGN_RIGHT: {
output = corrected_env("\\begin", "flushright", ownerCode());
else
output = corrected_env("\\begin", "flushleft", ownerCode());
- os << output;
+ os << lyx::from_ascii(output);
column += output.size();
break;
} case LYX_ALIGN_CENTER: {
string output;
output = corrected_env("\\begin", "center", ownerCode());
- os << output;
+ os << lyx::from_ascii(output);
column += output.size();
break;
}
// This could go to ParagraphParameters if we want to
int Paragraph::endTeXParParams(BufferParams const & bparams,
- ostream & os, bool moving_arg) const
+ odocstream & os, bool moving_arg) const
{
int column = 0;
output = corrected_env("\\par\\end", "flushleft", ownerCode());
else
output = corrected_env("\\par\\end", "flushright", ownerCode());
- os << output;
+ os << lyx::from_ascii(output);
column += output.size();
break;
} case LYX_ALIGN_RIGHT: {
output = corrected_env("\\par\\end", "flushright", ownerCode());
else
output = corrected_env("\\par\\end", "flushleft", ownerCode());
- os << output;
+ os << lyx::from_ascii(output);
column += output.size();
break;
} case LYX_ALIGN_CENTER: {
string output;
output = corrected_env("\\par\\end", "center", ownerCode());
- os << output;
+ os << lyx::from_ascii(output);
column += output.size();
break;
}
bool Paragraph::simpleTeXOnePar(Buffer const & buf,
BufferParams const & bparams,
LyXFont const & outerfont,
- ostream & os, TexRow & texrow,
+ odocstream & os, TexRow & texrow,
OutputParams const & runparams) const
{
lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
break;
bool ws;
string str;
+ // FIXME UNICODE
+ // sgml::escapeChar takes a char, not lyx::char_type
boost::tie(ws, str) = sgml::escapeChar(c);
os << str;
value_type c = getChar(i);
bool ws;
string str;
+ // FIXME UNICODE
+ // sgml::escapeChar takes a char, not lyx::char_type
boost::tie(ws, str) = sgml::escapeChar(c);
if (style->pass_thru)
#include "insets/insetbase.h" // only for InsetBase::Code
-#include "support/types.h"
-
-#include <string>
class Buffer;
class BufferParams;
void validate(LaTeXFeatures &) const;
///
- int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
+ int startTeXParParams(BufferParams const &, lyx::odocstream &, bool) const;
///
- int endTeXParParams(BufferParams const &, std::ostream &, bool) const;
+ int endTeXParParams(BufferParams const &, lyx::odocstream &, bool) const;
///
bool simpleTeXOnePar(Buffer const &, BufferParams const &,
- LyXFont const & outerfont, std::ostream &,
+ LyXFont const & outerfont, lyx::odocstream &,
TexRow & texrow, OutputParams const &) const;
/// Can we drop the standard paragraph wrapper?
#include <boost/next_prior.hpp>
+using lyx::docstring;
+using lyx::odocstream;
using lyx::pos_type;
using std::endl;
using std::upper_bound;
using std::lower_bound;
using std::string;
-using std::ostream;
// Initialization of the counter for the paragraph id's,
struct special_phrase {
string phrase;
- string macro;
+ docstring macro;
bool builtin;
};
-special_phrase special_phrases[] = {
- { "LyX", "\\LyX{}", false },
- { "TeX", "\\TeX{}", true },
- { "LaTeX2e", "\\LaTeXe{}", true },
- { "LaTeX", "\\LaTeX{}", true },
+special_phrase const special_phrases[] = {
+ { "LyX", lyx::from_ascii("\\LyX{}"), false },
+ { "TeX", lyx::from_ascii("\\TeX{}"), true },
+ { "LaTeX2e", lyx::from_ascii("\\LaTeXe{}"), true },
+ { "LaTeX", lyx::from_ascii("\\LaTeX{}"), true },
};
size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
}
-void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
+void Paragraph::Pimpl::simpleTeXBlanks(odocstream & os, TexRow & texrow,
pos_type const i,
unsigned int & column,
LyXFont const & font,
void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
BufferParams const & bparams,
- ostream & os,
+ odocstream & os,
TexRow & texrow,
OutputParams const & runparams,
LyXFont & font,
if (style.pass_thru) {
if (c != Paragraph::META_INSET) {
if (c != '\0')
- os << c;
- } else {
- lyx::odocstringstream oss;
- owner_->getInset(i)->plaintext(buf, oss, runparams);
- // FIXME UNICODE
- os << lyx::to_utf8(oss.str());
- }
+ os.put(c);
+ } else
+ owner_->getInset(i)->plaintext(buf, os, runparams);
return;
}
}
bool close = false;
- ostream::pos_type const len = os.tellp();
+ odocstream::pos_type const len = os.tellp();
if ((inset->lyxCode() == InsetBase::GRAPHICS_CODE
|| inset->lyxCode() == InsetBase::MATH_CODE
FontList fontlist;
///
- void simpleTeXBlanks(std::ostream &, TexRow & texrow,
+ void simpleTeXBlanks(lyx::odocstream &, TexRow & texrow,
lyx::pos_type const i,
unsigned int & column,
LyXFont const & font,
LyXLayout const & style);
///
void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
- std::ostream &, TexRow & texrow,
+ lyx::odocstream &, TexRow & texrow,
OutputParams const &,
LyXFont & font, LyXFont & running_font,
LyXFont & basefont,
if (isPrintableNonspace(c)) {
int const width2 =
text_.singleWidth(par_, i, c, text_.getFont(par_, i));
+ // FIXME UNICODE
+ // This does not work anymore, and non-ascii
+ // characters in source files are forbidden
+ // anyway.
// dalet / resh
dx = (c == 'ø' || c == 'ã')
? width2 - width
// This function escapes 8-bit characters and other problematic
// characters that cause problems in latex labels.
-string const escape(string const & lab)
+docstring const escape(docstring const & lab)
{
- char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
+ lyx::char_type hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
- string enc;
- for (string::size_type i = 0; i < lab.length(); ++i) {
- unsigned char c= lab[i];
+ docstring enc;
+ for (docstring::size_type i = 0; i < lab.length(); ++i) {
+ lyx::char_type c= lab[i];
+ // FIXME We must change the following algorithm for UCS4
+ // chars, but that will be a file format change.
if (c >= 128 || c == '=' || c == '%') {
enc += '=';
enc += hexdigit[c>>4];
std::string const rsplit(std::string const & a, std::string & piece, char delim);
/// Escapes non ASCII chars
-std::string const escape(std::string const & lab);
+lyx::docstring const escape(lyx::docstring const & lab);
/// gives a vector of stringparts which have the delimiter delim
std::vector<std::string> const getVectorFromString(std::string const & str,
char ICONV_CONST * inbuf = const_cast<char ICONV_CONST *>(reinterpret_cast<char const *>(buf));
size_t inbytesleft = buflen * sizeof(InType);
- size_t const outsize = 1000;
+ size_t const outsize = 10000;
static char out[outsize];
char * outbuf = out;
size_t outbytesleft = outsize;
#include <sstream>
using lyx::docstring;
+using lyx::odocstream;
using lyx::support::ltrim;
using lyx::support::prefixIs;
using lyx::support::rtrim;
}
-int LyXTabular::TeXTopHLine(ostream & os, row_type row) const
+int LyXTabular::TeXTopHLine(odocstream & os, row_type row) const
{
// FIXME: assert or return 0 as in TeXBottomHLine()?
BOOST_ASSERT(row != npos);
}
-int LyXTabular::TeXBottomHLine(ostream & os, row_type row) const
+int LyXTabular::TeXBottomHLine(odocstream & os, row_type row) const
{
// FIXME: return 0 or assert as in TeXTopHLine()?
if (row == npos || row >= rows_)
}
-int LyXTabular::TeXCellPreamble(ostream & os, idx_type cell) const
+int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const
{
int ret = 0;
if (isMultiColumn(cell)) {
os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
if (!cellinfo_of_cell(cell).align_special.empty()) {
- os << cellinfo_of_cell(cell).align_special << "}{";
+ os << lyx::from_ascii(cellinfo_of_cell(cell).align_special)
+ << "}{";
} else {
if (leftLine(cell) &&
(isFirstCellInRow(cell) ||
break;
}
os << '{'
- << getPWidth(cell).asLatexString()
+ << lyx::from_ascii(getPWidth(cell).asLatexString())
<< '}';
} else {
switch (getAlignment(cell)) {
os << 'b';
break;
}
- os << "]{" << getPWidth(cell).asLatexString() << "}{";
+ os << "]{" << lyx::from_ascii(getPWidth(cell).asLatexString())
+ << "}{";
} else if (getUsebox(cell) == BOX_MINIPAGE) {
os << "\\begin{minipage}[";
switch (getVAlignment(cell)) {
os << 'b';
break;
}
- os << "]{" << getPWidth(cell).asLatexString() << "}\n";
+ os << "]{" << lyx::from_ascii(getPWidth(cell).asLatexString())
+ << "}\n";
++ret;
}
return ret;
}
-int LyXTabular::TeXCellPostamble(ostream & os, idx_type cell) const
+int LyXTabular::TeXCellPostamble(odocstream & os, idx_type cell) const
{
int ret = 0;
}
-int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const & buf,
+int LyXTabular::TeXLongtableHeaderFooter(odocstream & os, Buffer const & buf,
OutputParams const & runparams) const
{
if (!is_long_tabular)
}
-int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
+int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf,
OutputParams const & runparams) const
{
idx_type cell = getCellNumber(i, 0);
} else if(!row_info[i].top_space.zero()) {
if (use_booktabs)
os << "\\addlinespace["
- << row_info[i].top_space.asLatexString() << "]\n";
+ << lyx::from_ascii(row_info[i].top_space.asLatexString())
+ << "]\n";
else {
os << "\\noalign{\\vskip"
- << row_info[i].top_space.asLatexString() << "}\n";
+ << lyx::from_ascii(row_info[i].top_space.asLatexString())
+ << "}\n";
}
++ret;
}
} else if (!row_info[i].bottom_space.zero()) {
if (use_booktabs)
os << "\\addlinespace";
- os << '[' << row_info[i].bottom_space.asLatexString() << ']';
+ os << '['
+ << lyx::from_ascii(row_info[i].bottom_space.asLatexString())
+ << ']';
}
os << '\n';
++ret;
} else if (!row_info[i].interline_space.zero()) {
if (use_booktabs)
os << "\\addlinespace["
- << row_info[i].interline_space.asLatexString()
+ << lyx::from_ascii(row_info[i].interline_space.asLatexString())
<< "]\n";
else
os << "\\noalign{\\vskip"
- << row_info[i].interline_space.asLatexString()
+ << lyx::from_ascii(row_info[i].interline_space.asLatexString())
<< "}\n";
++ret;
}
}
-int LyXTabular::latex(Buffer const & buf, ostream & os,
+int LyXTabular::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
int ret = 0;
os << "\\begin{tabular}{";
for (col_type i = 0; i < columns_; ++i) {
if (!column_info[i].align_special.empty()) {
- os << column_info[i].align_special;
+ os << lyx::from_ascii(column_info[i].align_special);
} else {
if (!use_booktabs && column_info[i].left_line)
os << '|';
break;
}
os << '{'
- << column_info[i].p_width.asLatexString()
+ << lyx::from_ascii(column_info[i].p_width.asLatexString())
<< '}';
} else {
switch (column_info[i].alignment) {
///
void read(Buffer const &, LyXLex &);
///
- int latex(Buffer const &, std::ostream &,
+ int latex(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
//
int docbook(Buffer const & buf, std::ostream & os,
///
// helper function for Latex returns number of newlines
///
- int TeXTopHLine(std::ostream &, row_type row) const;
+ int TeXTopHLine(lyx::odocstream &, row_type row) const;
///
- int TeXBottomHLine(std::ostream &, row_type row) const;
+ int TeXBottomHLine(lyx::odocstream &, row_type row) const;
///
- int TeXCellPreamble(std::ostream &, idx_type cell) const;
+ int TeXCellPreamble(lyx::odocstream &, idx_type cell) const;
///
- int TeXCellPostamble(std::ostream &, idx_type cell) const;
+ int TeXCellPostamble(lyx::odocstream &, idx_type cell) const;
///
- int TeXLongtableHeaderFooter(std::ostream &, Buffer const & buf,
+ int TeXLongtableHeaderFooter(lyx::odocstream &, Buffer const & buf,
OutputParams const &) const;
///
bool isValidRow(row_type const row) const;
///
- int TeXRow(std::ostream &, row_type const row, Buffer const & buf,
+ int TeXRow(lyx::odocstream &, row_type const row, Buffer const & buf,
OutputParams const &) const;
///
// helper function for ASCII returns number of newlines