copied_ptr.h
cow_ptr.h
debugstream.h
+ docstream.h
docstring.h
environment.h
filefilterlist.h
chdir.C
convert.C
copy.C
+ docstream.C
docstring.C
environment.C
filefilterlist.C
#include <boost/tuple/tuple.hpp>
+using lyx::docstring;
using lyx::pos_type;
using lyx::pit_type;
using lyx::textclass_type;
}
-std::vector<string> const availableSelections(Buffer const & buffer)
+std::vector<docstring> const availableSelections(Buffer const & buffer)
{
- vector<string> selList;
+ vector<docstring> selList;
CutStack::const_iterator cit = theCuts.begin();
CutStack::const_iterator end = theCuts.end();
// we do not use cit-> here because gcc 2.9x does not
// like it (JMarc)
ParagraphList const & pars = (*cit).first;
- string asciiSel;
+ docstring asciiSel;
ParagraphList::const_iterator pit = pars.begin();
ParagraphList::const_iterator pend = pars.end();
for (; pit != pend; ++pit) {
asciiSel += pit->asString(buffer, false);
if (asciiSel.size() > 25) {
- asciiSel.replace(22, string::npos, "...");
+ asciiSel.replace(22, docstring::npos,
+ lyx::from_ascii("..."));
break;
}
}
}
-std::string getSelection(Buffer const & buf, size_t sel_index)
+docstring getSelection(Buffer const & buf, size_t sel_index)
{
return sel_index < theCuts.size()
? theCuts[sel_index].first.back().asString(buf, false)
- : string();
+ : docstring();
}
#include "ParagraphList_fwd.h"
-#include "support/types.h"
+#include "support/docstring.h"
-#include <string>
#include <vector>
class Buffer;
namespace cap {
///
-std::vector<std::string> const availableSelections(Buffer const & buffer);
+std::vector<lyx::docstring> const availableSelections(Buffer const & buffer);
///
lyx::size_type numberOfSelections();
///
-std::string getSelection(Buffer const & buffer, size_t sel_index);
+lyx::docstring getSelection(Buffer const & buffer, size_t sel_index);
///
void cutSelection(LCursor & cur, bool doclear, bool realcut);
}
};
-string const limit_string_length(string const & str)
+docstring const limit_string_length(docstring const & str)
{
- string::size_type const max_item_length = 45;
+ docstring::size_type const max_item_length = 45;
if (str.size() > max_item_length)
return str.substr(0, max_item_length - 3) + "...";
int ii = 1;
for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
- docstring const label = convert<docstring>(ii) + lyx::from_ascii(". ")
+ docstring const label = convert<docstring>(ii) + ". "
+ makeDisplayPath((*lfit), 30)
+ char_type('|') + convert<docstring>(ii);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))));
for (; docit != end; ++docit, ++ii) {
docstring label = makeDisplayPath(*docit, 20);
if (ii < 10)
- label = convert<docstring>(ii) + lyx::from_ascii(". ") + label + char_type('|') + convert<docstring>(ii);
+ label = convert<docstring>(ii) + ". " + label + char_type('|') + convert<docstring>(ii);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, *docit)));
}
}
label = _("Plain Text as Lines");
else if ((*fit)->name() == "textparagraph")
label = _("Plain Text as Paragraphs");
- label += lyx::from_ascii("...");
+ label += "...";
break;
case MenuItem::ViewFormats:
case MenuItem::ExportFormats:
if (to - from <= max_number_of_items) {
for (lyx::toc::Toc::size_type i = from; i < to; ++i) {
docstring label(4 * max(0, toc_list[i].depth() - depth), char_type(' '));
- label += lyx::from_utf8(limit_string_length(toc_list[i].str()));
+ label += limit_string_length(toc_list[i].str());
if (toc_list[i].depth() == depth
&& shortcut_count < 9) {
if (label.find(convert<docstring>(shortcut_count + 1)) != docstring::npos)
++new_pos;
docstring label(4 * max(0, toc_list[pos].depth() - depth), ' ');
- label += lyx::from_utf8(limit_string_length(toc_list[pos].str()));
+ label += limit_string_length(toc_list[pos].str());
if (toc_list[pos].depth() == depth &&
shortcut_count < 9) {
if (label.find(convert<docstring>(shortcut_count + 1)) != docstring::npos)
label += char_type('|') + convert<docstring>(++shortcut_count);
- }
+ }
if (new_pos == pos + 1) {
tomenu.add(MenuItem(MenuItem::Command,
label, FuncRequest(toc_list[pos].action())));
lyx::toc::Toc::const_iterator ccit = cit->second.begin();
lyx::toc::Toc::const_iterator eend = cit->second.end();
for (; ccit != eend; ++ccit) {
- docstring const label = lyx::from_utf8(limit_string_length(ccit->str()));
+ docstring const label = limit_string_length(ccit->str());
menu->add(MenuItem(MenuItem::Command,
label,
FuncRequest(ccit->action())));
if (!buf)
return;
- vector<string> const sel =
+ vector<docstring> const sel =
lyx::cap::availableSelections(*buf);
- vector<string>::const_iterator cit = sel.begin();
- vector<string>::const_iterator end = sel.end();
+ vector<docstring>::const_iterator cit = sel.begin();
+ vector<docstring>::const_iterator end = sel.end();
for (unsigned int index = 0; cit != end; ++cit, ++index) {
- tomenu.add(MenuItem(MenuItem::Command, lyx::from_utf8(*cit),
+ tomenu.add(MenuItem(MenuItem::Command, *cit,
FuncRequest(LFUN_PASTE, convert<string>(index))));
}
}
for (int ii = 1; cit != end; ++cit, ++ii) {
docstring label = lyx::from_utf8(cit->getBranch());
if (ii < 10)
- label = convert<docstring>(ii) + lyx::from_ascii(". ") + label + char_type('|') + convert<docstring>(ii);
+ label = convert<docstring>(ii) + ". " + label + char_type('|') + convert<docstring>(ii);
tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
FuncRequest(LFUN_BRANCH_INSERT,
cit->getBranch())));
#include <iostream>
+using lyx::docstring;
+
using std::vector;
using std::max;
using std::ostream;
// TocBackend::Item implementation
TocBackend::Item::Item(ParConstIterator const & par_it, int d,
- std::string const & s)
+ docstring const & s)
: par_it_(par_it), depth_(d), str_(s)
{
/*
}
-std::string const & TocBackend::Item::str() const
+docstring const & TocBackend::Item::str() const
{
return str_;
}
-string const TocBackend::Item::asString() const
+docstring const TocBackend::Item::asString() const
{
- return string(4 * depth_, ' ') + str_;
+ return docstring(4 * depth_, ' ') + str_;
}
for (; pit != end; ++pit) {
// the string that goes to the toc (could be the optarg)
- string tocstring;
+ docstring tocstring;
// For each paragraph, traverse its insets and look for
// FLOAT_CODE or WRAP_CODE
break;
Paragraph const & par = *static_cast<InsetOptArg*>(it->inset)->paragraphs().begin();
if (!pit->getLabelstring().empty())
- tocstring = pit->getLabelstring()
- + ' ';
+ // FIXME UNICODE
+ tocstring = lyx::from_utf8(
+ pit->getLabelstring() + ' ');
tocstring += par.asString(*buffer_, false);
break;
}
}
-void TocBackend::asciiTocList(string const & type, ostream & os) const
+void TocBackend::asciiTocList(string const & type, lyx::odocstream & os) const
{
TocList::const_iterator cit = tocs_.find(type);
if (cit != tocs_.end()) {
Item(
ParConstIterator const & par_it = ParConstIterator(),
int d = -1,
- std::string const & s = std::string());
+ lyx::docstring const & s = lyx::docstring());
///
~Item() {}
///
///
int const depth() const;
///
- std::string const & str() const;
+ lyx::docstring const & str() const;
///
- std::string const asString() const;
+ lyx::docstring const asString() const;
/// set cursor in LyXView to this Item
void goTo(LyXView & lv_) const;
/// the action corresponding to the goTo above
int depth_;
/// Full item string
- std::string str_;
+ lyx::docstring str_;
};
///
/// Return the first Toc Item before the cursor
TocIterator const item(std::string const & type, ParConstIterator const &);
- void asciiTocList(std::string const & type, std::ostream & os) const;
+ void asciiTocList(std::string const & type, lyx::odocstream & os) const;
private:
///
size_t const endpos = selEnd().pos();
if (startpit == endpit)
- return lyx::from_utf8(pars[startpit].asString(buffer, startpos, endpos, label));
+ return pars[startpit].asString(buffer, startpos, endpos, label);
// First paragraph in selection
- string result = pars[startpit].
+ docstring result = pars[startpit].
asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
// The paragraphs in between (if any)
// Last paragraph in selection
result += pars[endpit].asString(buffer, 0, endpos, label);
- return lyx::from_utf8(result);
+ return result;
}
if (inMathed())
if (view()->buffer()) {
string const cur_title = buffer()->fileName();
if (!cur_title.empty()) {
- maximize_title += lyx::from_ascii(": ") + makeDisplayPath(cur_title, 30);
+ maximize_title += ": " + makeDisplayPath(cur_title, 30);
minimize_title = lyx::from_utf8(onlyFilename(cur_title));
if (!buffer()->isClean()) {
maximize_title += _(" (changed)");
for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
Gtk::ListStore::iterator row = tocstore_->append();
- (*row)[listCol_] = cit->asString();
+ (*row)[listCol_] = lyx::to_utf8(cit->asString());
(*row)[listColIndex_] = rowindex;
}
changing_views_ = false;
lyxerr[Debug::GUI]
<< "Table of contents\n"
- << "Added item " << iter->str()
+ << "Added item " << lyx::to_utf8(iter->str())
<< " at depth " << iter->depth()
<< ", previous sibling \""
<< (last ? fromqstr(last->text(0)) : "0")
}
-void QToc::select(string const & text)
+void QToc::select(string const & t)
{
+ // FIXME UNICODE
+ docstring const text = lyx::from_utf8(t);
toc::Toc::const_iterator iter = toclist.begin();
for (; iter != toclist.end(); ++iter) {
if (iter == toclist.end()) {
lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry: "
- << text << endl;
+ << t << endl;
return;
}
int depth_;
/// Store selected item's string
- std::string text_;
+ lyx::docstring text_;
/// Store ToC list type
std::string type_;
TocIterator const it = toc_models_[type_]->tocIterator(index);
lyxerr[Debug::GUI]
- << "QToc::goTo " << it->str()
+ << "QToc::goTo " << lyx::to_utf8(it->str())
<< endl;
it->goTo(kernel().lyxview());
lyxerr[Debug::GUI]
<< "Toc: at depth " << iter->depth()
- << ", added item " << iter->str()
+ << ", added item " << lyx::to_utf8(iter->str())
<< endl;
populate(iter, end, top_level_item);
int InsetBase::plaintext(Buffer const &,
- std::ostream &, OutputParams const &) const
+ lyx::odocstream &, OutputParams const &) const
{
return 0;
}
#ifndef INSETBASE_H
#define INSETBASE_H
-#include "support/docstring.h"
+#include "support/docstream.h"
#include <memory>
-#include <string>
#include <vector>
class Buffer;
/// describe content if cursor behind
virtual void infoize2(std::ostream &) const {}
- /// plain ascii output
- virtual int plaintext(Buffer const &, std::ostream & os,
+ /// plain text output in ucs4 encoding
+ virtual int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
/// docbook output
virtual int docbook(Buffer const &, std::ostream & os,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream &,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const { return 0; };
/** This enum indicates by which means the inset can be modified:
}
-string const InsetBibitem::getBibLabel() const
+docstring const InsetBibitem::getBibLabel() const
{
- return getOptions().empty() ? convert<string>(counter) : getOptions();
+ // FIXME UNICODE
+ return getOptions().empty() ?
+ convert<docstring>(counter) :
+ lyx::from_utf8(getOptions());
}
-string const InsetBibitem::getScreenLabel(Buffer const &) const
+docstring const InsetBibitem::getScreenLabel(Buffer const &) const
{
- return getContents() + " [" + getBibLabel() + ']';
+ // FIXME UNICODE
+ return lyx::from_utf8(getContents()) + " [" + getBibLabel() + ']';
}
-int InsetBibitem::plaintext(Buffer const &, ostream & os,
+
+int InsetBibitem::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << '[' << getCounter() << "] ";
// ale070405
-string const bibitemWidest(Buffer const & buffer)
+docstring const bibitemWidest(Buffer const & buffer)
{
int w = 0;
// Does look like a hack? It is! (but will change at 0.13)
for (; it != end; ++it) {
if (it->bibitem()) {
- string const label = it->bibitem()->getBibLabel();
- docstring const dlab(label.begin(), label.end());
+ docstring const label = it->bibitem()->getBibLabel();
int const wx =
- fm.width(dlab);
+ fm.width(label);
if (wx > w) {
w = wx;
bitem = it->bibitem();
if (bitem && !bitem->getBibLabel().empty())
return bitem->getBibLabel();
- return "99";
+ return lyx::from_ascii("99");
}
///
void read(Buffer const &, LyXLex & lex);
///
- virtual std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
///
int getCounter() const { return counter; }
///
- std::string const getBibLabel() const;
+ lyx::docstring const getBibLabel() const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
protected:
///
/// Return the widest label in the Bibliography.
-std::string const bibitemWidest(Buffer const &);
+lyx::docstring const bibitemWidest(Buffer const &);
#endif // INSET_BIBITEM_H
#include <fstream>
#include <sstream>
+using lyx::docstring;
using lyx::support::absolutePath;
using lyx::support::ascii_lowercase;
using lyx::support::changeExtension;
}
-string const InsetBibtex::getScreenLabel(Buffer const &) const
+docstring const InsetBibtex::getScreenLabel(Buffer const &) const
{
- // FIXME UNICODE
- return lyx::to_utf8(_("BibTeX Generated Bibliography"));
+ return _("BibTeX Generated Bibliography");
}
///
InsetBibtex(InsetCommandParams const &);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
}
-int InsetBox::plaintext(Buffer const & buf, std::ostream & os,
+int InsetBox::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
BoxType const btype = boxtranslator().find(params_.type);
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & runparams) const;
///
void validate(LaTeXFeatures &) const;
}
-int InsetBranch::plaintext(Buffer const & buf, std::ostream & os,
+int InsetBranch::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
return isBranchSelected(buf) ?
int docbook(Buffer const &, std::ostream &,
OutputParams const & runparams) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & runparams) const;
///
void validate(LaTeXFeatures &) const;
}
-int InsetCaption::plaintext(Buffer const & /*buf*/,ostream & /*os*/,
+int InsetCaption::plaintext(Buffer const & /*buf*/, lyx::odocstream & /*os*/,
OutputParams const & /*runparams*/) const
{
// FIXME: Implement me!
virtual int latex(Buffer const & buf, std::ostream & os,
OutputParams const &) const;
///
- int plaintext(Buffer const & buf, std::ostream & os,
+ int plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const;
///
int docbook(Buffer const & buf, std::ostream & os,
}
-int InsetCharStyle::plaintext(Buffer const & buf, ostream & os,
+int InsetCharStyle::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
return InsetText::plaintext(buf, os, runparams);
}
-int InsetCharStyle::textString(Buffer const & buf, ostream & os,
+int InsetCharStyle::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/exception.hpp>
+using lyx::docstring;
using lyx::support::ascii_lowercase;
using lyx::support::contains;
using lyx::support::getStringFromVector;
{}
-string const InsetCitation::generateLabel(Buffer const & buffer) const
+docstring const InsetCitation::generateLabel(Buffer const & buffer) const
{
string const before = getSecOptions();
string const after = getOptions();
label = getBasicLabel(getContents(), after);
}
- return label;
+ // FIXME UNICODE
+ return lyx::from_utf8(label);
}
-string const InsetCitation::getScreenLabel(Buffer const & buffer) const
+docstring const InsetCitation::getScreenLabel(Buffer const & buffer) const
{
biblio::CiteEngine const engine = biblio::getEngine(buffer);
if (cache.params == params() && cache.engine == engine)
string const before = getSecOptions();
string const after = getOptions();
- string const glabel = generateLabel(buffer);
+ docstring const glabel = generateLabel(buffer);
unsigned int const maxLabelChars = 45;
- string label = glabel;
+ docstring label = glabel;
if (label.size() > maxLabelChars) {
label.erase(maxLabelChars-3);
label += "...";
}
-int InsetCitation::plaintext(Buffer const & buffer, ostream & os, OutputParams const &) const
+int InsetCitation::plaintext(Buffer const & buffer, lyx::odocstream & os,
+ OutputParams const &) const
{
if (cache.params == params() &&
cache.engine == biblio::getEngine(buffer))
}
-int InsetCitation::textString(Buffer const & buf, ostream & os,
+int InsetCitation::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
///
InsetCitation(InsetCommandParams const &);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
InsetBase::Code lyxCode() const { return InsetBase::CITE_CODE; }
///
- int plaintext(Buffer const &, std::ostream &, OutputParams const &) const;
+ int plaintext(Buffer const &, lyx::odocstream &, OutputParams const &) const;
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
}
/// This function does the donkey work of creating the pretty label
- std::string const generateLabel(Buffer const &) const;
+ lyx::docstring const generateLabel(Buffer const &) const;
class Cache {
public:
///
InsetCommandParams params;
///
- std::string generated_label;
+ lyx::docstring generated_label;
///
- std::string screen_label;
+ lyx::docstring screen_label;
};
///
mutable Cache cache;
}
-int InsetCommand::plaintext(Buffer const &, ostream &,
+int InsetCommand::plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const
{
return 0;
virtual int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
virtual int docbook(Buffer const &, std::ostream &,
///
void setParams(InsetCommandParams const &);
/// This should provide the text for the button
- virtual std::string const getScreenLabel(Buffer const &) const = 0;
+ virtual lyx::docstring const getScreenLabel(Buffer const &) const = 0;
private:
///
}
-int InsetERT::plaintext(Buffer const &, ostream &,
+int InsetERT::plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & /*runparams*/) const
{
return 0;
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & runparams) const;
///
int docbook(Buffer const &, std::ostream &,
namespace external = lyx::external;
namespace graphics = lyx::graphics;
+using lyx::docstring;
using std::endl;
using std::string;
using std::auto_ptr;
}
-string const getScreenLabel(InsetExternalParams const & params,
+docstring const getScreenLabel(InsetExternalParams const & params,
Buffer const & buffer)
{
external::Template const * const ptr =
external::getTemplatePtr(params);
if (!ptr)
// FIXME UNICODE
- return lyx::to_utf8(support::bformat(_("External template %1$s is not installed"),
- lyx::from_utf8(params.templatename())));
- return external::doSubstitution(params, buffer, ptr->guiName, false);
+ return support::bformat((_("External template %1$s is not installed")),
+ lyx::from_utf8(params.templatename()));
+ // FIXME UNICODE
+ return lyx::from_utf8(external::doSubstitution(params, buffer,
+ ptr->guiName, false));
}
void add_preview_and_start_loading(RenderMonitoredPreview &,
}
-int InsetExternal::plaintext(Buffer const & buf, ostream & os,
+int InsetExternal::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
- return external::writeExternal(params_, "Ascii", buf, os,
+ std::ostringstream oss;
+ int const retval = external::writeExternal(params_, "Ascii", buf, oss,
*(runparams.exportdata), false,
runparams.inComment);
+ // FIXME UNICODE
+ os << lyx::from_utf8(oss.str());
+ return retval;
}
virtual int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- virtual int plaintext(Buffer const &, std::ostream &,
+ virtual int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
virtual int docbook(Buffer const &, std::ostream &,
for (; pit != end; ++pit) {
if (pit->layout()->labeltype == LABEL_SENSITIVE) {
string const type = params_.type;
- string const str =
- convert<string>(toclist[type].size() + 1)
+ docstring const str =
+ convert<docstring>(toclist[type].size() + 1)
+ ". " + pit->asString(buf, false);
- lyx::toc::TocItem const item(pit, 0 , str);
+ lyx::toc::TocItem const item(pit, 0, str);
toclist[type].push_back(item);
}
}
#include "support/lstrings.h"
+using lyx::docstring;
using lyx::support::bformat;
using std::endl;
}
-string const InsetFloatList::getScreenLabel(Buffer const & buf) const
+docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
{
FloatList const & floats = buf.params().getLyXTextClass().floats();
FloatList::const_iterator it = floats[getCmdName()];
if (it != floats.end())
- // FIXME UNICODE
- return lyx::to_utf8(buf.B_(it->second.listName()));
+ return buf.B_(it->second.listName());
else
- // FIXME UNICODE
- return lyx::to_utf8(_("ERROR: Nonexistent float type!"));
+ return _("ERROR: Nonexistent float type!");
}
}
-int InsetFloatList::plaintext(Buffer const & buffer, ostream & os, OutputParams const &) const
+int InsetFloatList::plaintext(Buffer const & buffer, lyx::odocstream & os,
+ OutputParams const &) const
{
os << getScreenLabel(buffer) << "\n\n";
///
InsetFloatList(std::string const & type);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const { return 0; }
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & runparams) const;
///
void validate(LaTeXFeatures & features) const;
}
-int InsetGraphics::plaintext(Buffer const &, ostream & os,
+int InsetGraphics::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
// No graphics in ascii output. Possible to use gifscii to convert
// 2. Read ascii output file and add it to the output stream.
// at least we send the filename
// FIXME UNICODE
- os << '<' << lyx::to_utf8(bformat(_("Graphics file: %1$s"),
- lyx::from_utf8(params().filename.absFilename()))) << ">\n";
+ // FIXME: We have no idea what the encoding of the filename is
+ os << '<' << bformat(_("Graphics file: %1$s"),
+ lyx::from_utf8(params().filename.absFilename()))
+ << ">\n";
return 0;
}
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
#include "support/std_ostream.h"
+using lyx::docstring;
+
using std::ostream;
}
-std::string const InsetHFill::getScreenLabel(Buffer const &) const
+docstring const InsetHFill::getScreenLabel(Buffer const &) const
{
- return getContents();
+ return lyx::from_ascii(getContents());
}
}
-int InsetHFill::plaintext(Buffer const &, ostream & os,
+int InsetHFill::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << '\t';
///
void metrics(MetricsInfo &, Dimension &) const;
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
InsetBase::Code lyxCode() const { return InsetBase::HFILL_CODE; }
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & runparams) const;
///
int docbook(Buffer const &, std::ostream &,
#include "insets/render_preview.h"
-#include "support/lyxalgo.h"
#include "support/filename.h"
#include "support/filetools.h"
#include "support/lstrings.h" // contains
+#include "support/lyxalgo.h"
#include "support/lyxlib.h"
#include "support/convert.h"
}
-string const InsetInclude::getScreenLabel(Buffer const &) const
+docstring const InsetInclude::getScreenLabel(Buffer const &) const
{
docstring temp;
break;
}
- temp += lyx::from_ascii(": ");
+ temp += ": ";
if (params_.getContents().empty())
- temp += lyx::from_ascii("???");
+ temp += "???";
else
+ // FIXME: We don't know the encoding of the filename
temp += lyx::from_ascii(onlyFilename(params_.getContents()));
- // FIXME UNICODE
- return lyx::to_utf8(temp);
+ return temp;
}
}
-int InsetInclude::plaintext(Buffer const & buffer, ostream & os,
+int InsetInclude::plaintext(Buffer const & buffer, lyx::odocstream & os,
OutputParams const &) const
{
if (isVerbatim(params_)) {
- string const str =
- getFileContents(includedFilename(buffer, params_));
+ // FIXME: We don't know the encoding of the file
+ docstring const str = lyx::from_utf8(
+ getFileContents(includedFilename(buffer, params_)));
os << str;
// Return how many newlines we issued.
return int(lyx::count(str.begin(), str.end(), '\n'));
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
/// set the parameters
void set(InsetCommandParams const & params, Buffer const &);
/// get the text displayed on the button
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
void write(std::ostream &) const;
///
#include "support/std_ostream.h"
+using lyx::docstring;
+
using std::string;
using std::ostream;
// {}
-string const InsetIndex::getScreenLabel(Buffer const &) const
+docstring const InsetIndex::getScreenLabel(Buffer const &) const
{
- // FIXME UNICODE
- return lyx::to_utf8(_("Idx"));
+ return _("Idx");
}
// {}
-string const InsetPrintIndex::getScreenLabel(Buffer const &) const
+docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
{
- // FIXME UNICODE
- return lyx::to_utf8(_("Index"));
+ return _("Index");
}
///
InsetIndex(InsetCommandParams const &);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
///
bool display() const { return true; }
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
private:
virtual std::auto_ptr<InsetBase> doClone() const {
return std::auto_ptr<InsetBase>(new InsetPrintIndex(params()));
#include "support/lyxalgo.h"
#include "support/std_ostream.h"
+using lyx::docstring;
using lyx::support::escape;
using std::string;
}
-string const InsetLabel::getScreenLabel(Buffer const &) const
+docstring const InsetLabel::getScreenLabel(Buffer const &) const
{
- return getContents();
+ // FIXME UNICODE
+ return lyx::from_utf8(getContents());
}
}
-int InsetLabel::plaintext(Buffer const &, ostream & os,
+int InsetLabel::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
- os << '<' << getContents() << '>';
+ // FIXME UNICODE
+ os << '<' << lyx::from_utf8(getContents()) << '>';
return 0;
}
///
InsetLabel(InsetCommandParams const &);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
}
-int InsetLatexAccent::plaintext(Buffer const &, ostream & os,
+int InsetLatexAccent::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
- os << contents;
+ os << lyx::from_ascii(contents);
return 0;
}
}
-int InsetLatexAccent::textString(Buffer const & buf, ostream & os,
+int InsetLatexAccent::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
bool directWrite() const;
}
-int InsetLine::plaintext(Buffer const &, ostream & os,
+int InsetLine::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << "-------------------------------------------";
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
int docbook(Buffer const &, std::ostream &,
}
-int InsetNewline::plaintext(Buffer const &, ostream & os,
+int InsetNewline::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << '\n';
virtual int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
- virtual int plaintext(Buffer const &, std::ostream &,
+ virtual int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
virtual int docbook(Buffer const &, std::ostream &,
}
-int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
+int InsetNote::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams_in) const
{
if (params_.type == InsetNoteParams::Note)
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
}
-int InsetOptArg::plaintext(Buffer const &, ostream &,
+int InsetOptArg::plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const
{
return 0;
OutputParams const &) const;
/// Standard plain text output -- short-circuited
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
/// Outputting the optional parameter of a LaTeX command
}
-int InsetPagebreak::plaintext(Buffer const &, ostream & os,
+int InsetPagebreak::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << '\n';
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
int docbook(Buffer const &, std::ostream &,
}
-int InsetQuotes::plaintext(Buffer const &, ostream & os,
+int InsetQuotes::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << '"';
}
-int InsetQuotes::textString(Buffer const & buf, ostream & os,
+int InsetQuotes::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
#include "support/lstrings.h"
+using lyx::docstring;
using lyx::support::escape;
using std::string;
}
-string const InsetRef::getScreenLabel(Buffer const &) const
+docstring const InsetRef::getScreenLabel(Buffer const &) const
{
- string temp;
+ docstring temp;
for (int i = 0; !types[i].latex_name.empty(); ++i) {
if (getCmdName() == types[i].latex_name) {
- // FIXME UNIOCDE
- temp = lyx::to_utf8(_(types[i].short_gui_name));
+ temp = _(types[i].short_gui_name);
break;
}
}
- temp += getContents();
+ // FIXME UNIOCDE
+ temp += lyx::from_utf8(getContents());
if (!isLatex && !getOptions().empty()) {
temp += "||";
- temp += getOptions();
+ // FIXME UNIOCDE
+ temp += lyx::from_utf8(getOptions());
}
return temp;
}
}
-int InsetRef::plaintext(Buffer const &, ostream & os,
+int InsetRef::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
- os << '[' << getContents() << ']';
+ // FIXME UNIOCDE
+ os << '[' << lyx::from_utf8(getContents()) << ']';
return 0;
}
}
-int InsetRef::textString(Buffer const & buf, ostream & os,
+int InsetRef::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
InsetRef(InsetCommandParams const &, Buffer const &);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
void validate(LaTeXFeatures & features) const;
}
-int InsetSpace::plaintext(Buffer const &, ostream & os,
+int InsetSpace::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
switch (kind_) {
}
-int InsetSpace::textString(Buffer const & buf, ostream & os,
+int InsetSpace::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
InsetBase::Code lyxCode() const { return InsetBase::SPACE_CODE; }
}
-int InsetSpecialChar::plaintext(Buffer const &, ostream & os,
+int InsetSpecialChar::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
switch (kind_) {
}
-int InsetSpecialChar::textString(Buffer const & buf, ostream & os,
+int InsetSpecialChar::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
InsetBase::Code lyxCode() const { return InsetBase::SPECIALCHAR_CODE; }
}
-int InsetTabular::plaintext(Buffer const & buf, ostream & os,
+int InsetTabular::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
int const dp = runparams.linelen ? runparams.depth : 0;
paste_tabular->setRightLine(paste_tabular->getLastCellInRow(0),
true, true);
- ostringstream os;
+ lyx::odocstringstream os;
OutputParams const runparams;
paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
- theClipboard().put(lyx::from_utf8(os.str()));
+ theClipboard().put(os.str());
// mark tabular stack dirty
// FIXME: this is a workaround for bug 1919. Should be removed for 1.5,
// when we (hopefully) have a one-for-all paste mechanism.
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
}
-int InsetText::plaintext(Buffer const & buf, ostream & os,
+int InsetText::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams) const
{
ParagraphList::const_iterator beg = paragraphs().begin();
ParagraphList::const_iterator end = paragraphs().end();
ParagraphList::const_iterator it = beg;
bool ref_printed = false;
- std::ostringstream oss;
+ lyx::odocstringstream oss;
for (; it != end; ++it)
asciiParagraph(buf, *it, oss, runparams, ref_printed);
- string const str = oss.str();
+ docstring const str = oss.str();
os << str;
// Return how many newlines we issued.
return int(lyx::count(str.begin(), str.end(), '\n'));
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
#include "support/std_ostream.h"
+using lyx::docstring;
+
using std::string;
using std::ostream;
}
-string const InsetTOC::getScreenLabel(Buffer const &) const
+docstring const InsetTOC::getScreenLabel(Buffer const &) const
{
- // FIXME UNICODE
if (getCmdName() == "tableofcontents")
- return lyx::to_utf8(_("Table of Contents"));
- return lyx::to_utf8(_("Unknown toc list"));
+ return _("Table of Contents");
+ return _("Unknown toc list");
}
}
-int InsetTOC::plaintext(Buffer const & buffer, ostream & os,
+int InsetTOC::plaintext(Buffer const & buffer, lyx::odocstream & os,
OutputParams const &) const
{
os << getScreenLabel(buffer) << "\n\n";
///
explicit InsetTOC(InsetCommandParams const &);
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
///
bool display() const { return true; }
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
#include "support/std_ostream.h"
+using lyx::docstring;
using lyx::support::subst;
using std::string;
{}
-string const InsetUrl::getScreenLabel(Buffer const &) const
+docstring const InsetUrl::getScreenLabel(Buffer const &) const
{
- string temp;
- // FIXME UNICODE
- if (getCmdName() == "url")
- temp = lyx::to_utf8(_("Url: "));
- else
- temp = lyx::to_utf8(_("HtmlUrl: "));
+ docstring const temp =
+ (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
string url;
url = url.substr(0, 10) + "..."
+ url.substr(url.length() - 17, url.length());
}
- return temp + url;
+ // FIXME UNICODE
+ return temp + lyx::from_utf8(url);
}
}
-int InsetUrl::plaintext(Buffer const &, ostream & os,
+int InsetUrl::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
+ // FIXME UNICODE
+ os << '[' << lyx::from_utf8(getContents());
if (getOptions().empty())
- os << '[' << getContents() << ']';
+ os << ']';
else
- os << '[' << getContents() << "||" << getOptions() << ']';
+ // FIXME UNICODE
+ os << "||" << lyx::from_utf8(getOptions()) << ']';
return 0;
}
}
-int InsetUrl::textString(Buffer const & buf, ostream & os,
+int InsetUrl::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
///
void validate(LaTeXFeatures &) const;
///
- std::string const getScreenLabel(Buffer const &) const;
+ lyx::docstring const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
private:
virtual std::auto_ptr<InsetBase> doClone() const {
}
-int InsetVSpace::plaintext(Buffer const &, ostream & os,
+int InsetVSpace::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
os << "\n\n";
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
for (; pit != end; ++pit) {
if (pit->layout()->labeltype == LABEL_SENSITIVE) {
string const type = params_.type;
- string const str =
- convert<string>(toclist[type].size() + 1)
+ docstring const str =
+ convert<docstring>(toclist[type].size() + 1)
+ ". " + pit->asString(buf, false);
- lyx::toc::TocItem const item(pit, 0 , str);
+ lyx::toc::TocItem const item(pit, 0, str);
toclist[type].push_back(item);
}
}
}
-void RenderButton::update(string const & text, bool editable)
+void RenderButton::update(docstring const & text, bool editable)
{
text_ = text;
editable_ = editable;
lyx::frontend::FontMetrics const & fm =
theFontMetrics(font);
- docstring dtext(text_.begin(), text_.end());
-
if (editable_)
- fm.buttonText(dtext, dim.wid, dim.asc, dim.des);
+ fm.buttonText(text_, dim.wid, dim.asc, dim.des);
else
- fm.rectText(dtext, dim.wid, dim.asc, dim.des);
+ fm.rectText(text_, dim.wid, dim.asc, dim.des);
dim.wid += 4;
}
font.setColor(LColor::command);
font.decSize();
- docstring dtext(text_.begin(), text_.end());
-
if (editable_) {
- pi.pain.buttonText(x + 2, y, dtext, font);
+ pi.pain.buttonText(x + 2, y, text_, font);
} else {
- pi.pain.rectText(x + 2, y, dtext, font,
+ pi.pain.rectText(x + 2, y, text_, font,
LColor::commandbg, LColor::commandframe);
}
}
#include "render_base.h"
#include "box.h"
-#include <string>
+#include "support/docstring.h"
class RenderButton : public RenderBase
virtual void draw(PainterInfo & pi, int x, int y) const;
/// Provide the text for the button
- void update(std::string const &, bool editable);
+ void update(lyx::docstring const &, bool editable);
/// The "sensitive area" box, i.e., the button area
Box box() const { return button_box_; }
private:
/// The stored data.
- std::string text_;
+ lyx::docstring text_;
bool editable_;
Box button_box_;
};
makeAbsPath(argument, owner->buffer()->filePath());
// FIXME Should use bformat
setMessage(_("Opening child document ") +
- makeDisplayPath(filename) + lyx::from_ascii("..."));
+ makeDisplayPath(filename) + "...");
view()->savePosition(0);
string const parentfilename = owner->buffer()->fileName();
if (theBufferList().exists(filename))
}
-int InsetFormulaMacro::plaintext(Buffer const &, ostream & os,
+int InsetFormulaMacro::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
WriteStream wi(os, false, true);
///
void write(Buffer const &, std::ostream & os) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int latex(Buffer const &, std::ostream & os,
#include <sstream>
+using lyx::docstring;
+
using std::string;
using std::auto_ptr;
using std::ostringstream;
}
-string const CommandInset::screenLabel() const
+docstring const CommandInset::screenLabel() const
{
- return name_;
+ return lyx::from_ascii(name_);
}
//
// void infoize(std::ostream & os) const;
///
- virtual std::string const screenLabel() const;
+ virtual lyx::docstring const screenLabel() const;
/// generate something that will be understood by the Dialogs.
std::string const createDialogStr(std::string const & name) const;
///
int n = 0;
is >> n;
InsetMathGrid grid(1, 1);
- mathed_parse_normal(grid, lyx::cap::getSelection(cur.buffer(), n));
+ // FIXME UNICODE
+ mathed_parse_normal(grid,
+ lyx::to_utf8(lyx::cap::getSelection(cur.buffer(), n)));
if (grid.nargs() == 1) {
// single cell/part of cell
recordUndo(cur);
}
-int InsetMathHull::plaintext(Buffer const &, ostream & os,
+int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
OutputParams const &) const
{
if (0 && display()) {
//metrics();
return tpain.textheight();
} else {
- WriteStream wi(os, false, true);
+ std::ostringstream oss;
+ WriteStream wi(oss, false, true);
wi << cell(0);
+ // FIXME UNICODE
+ os << lyx::from_utf8(oss.str());
return wi.line();
}
}
}
-int InsetMathHull::textString(Buffer const & buf, ostream & os,
+int InsetMathHull::textString(Buffer const & buf, lyx::odocstream & os,
OutputParams const & op) const
{
return plaintext(buf, os, op);
///
void read(Buffer const &, LyXLex & lex);
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
/// the string that is passed to the TOC
- virtual int textString(Buffer const &, std::ostream & os,
+ virtual int textString(Buffer const &, lyx::odocstream &,
OutputParams const &) const;
/// get notification when the cursor leaves this inset
#include <sstream>
+using lyx::docstring;
using lyx::cap::copySelection;
using lyx::cap::grabAndEraseSelection;
using lyx::cap::cutSelection;
size_t n = 0;
istringstream is(lyx::to_utf8(cmd.argument()));
is >> n;
- string const selection = lyx::cap::getSelection(cur.buffer(), n);
- cur.niceInsert(selection);
+ docstring const selection = lyx::cap::getSelection(cur.buffer(), n);
+ // FIXME UNICODE
+ cur.niceInsert(lyx::to_utf8(selection));
cur.clearSelection(); // bug 393
cur.bv().switchKeyMap();
finishUndo();
#include "outputparams.h"
#include "sgml.h"
+using lyx::docstring;
+
using std::string;
using std::auto_ptr;
using std::endl;
}
-string const RefInset::screenLabel() const
+docstring const RefInset::screenLabel() const
{
- string str;
+ docstring str;
for (int i = 0; !types[i].latex_name.empty(); ++i)
if (commandname() == types[i].latex_name) {
- // FIXME UNICODE
- str = lyx::to_utf8(_(types[i].short_gui_name));
+ str = _(types[i].short_gui_name);
break;
}
- str += asString(cell(0));
+ // FIXME UNICODE
+ str += lyx::from_utf8(asString(cell(0)));
//if (/* !isLatex && */ !cell(0).empty()) {
// str += "||";
}
-int RefInset::plaintext(std::ostream & os, OutputParams const &) const
+int RefInset::plaintext(lyx::odocstream & os, OutputParams const &) const
{
- os << '[' << asString(cell(0)) << ']';
+ // FIXME UNICODE
+ os << '[' << lyx::from_utf8(asString(cell(0))) << ']';
return 0;
}
///
void infoize(std::ostream & os) const;
///
- std::string const screenLabel() const;
+ lyx::docstring const screenLabel() const;
///
void validate(LaTeXFeatures & features) const;
///
virtual RefInset * asRefInset() { return this; }
- /// plain ascii output
- int plaintext(std::ostream & os, OutputParams const &) const;
+ /// plain text output in ucs4 encoding
+ int plaintext(lyx::odocstream &, OutputParams const &) const;
/// docbook output
int docbook(Buffer const & buf, std::ostream & os, OutputParams const &) const;
}
-void TextPainter::show(std::ostream & os, int offset) const
+void TextPainter::show(lyx::odocstream & os, int offset) const
{
os << '\n';
for (int j = 0; j <= ymax_; ++j) {
#define TEXTPAINTER_H
+#include "support/docstream.h"
+
#include <vector>
-#include <iosfwd>
class TextPainter {
public:
///
void draw(int x, int y, char c);
///
- void show(std::ostream & os, int offset = 0) const;
+ void show(lyx::odocstream & os, int offset = 0) const;
///
int textheight() const { return ymax_; }
///
#include "support/filetools.h"
-#include <fstream>
-
+using lyx::odocfstream;
using lyx::support::bformat;
using lyx::support::makeDisplayPath;
using std::ofstream;
using std::string;
-bool openFileWrite(ofstream & ofs, string const & fname)
+namespace {
+
+template<typename OFStream>
+bool doOpenFileWrite(OFStream & ofs, string const & fname)
{
ofs.open(fname.c_str());
if (!ofs) {
}
return true;
}
+
+}
+
+
+bool openFileWrite(ofstream & ofs, string const & fname)
+{
+ return doOpenFileWrite(ofs, fname);
+}
+
+
+bool openFileWrite(odocfstream & ofs, string const & fname)
+{
+ return doOpenFileWrite(ofs, fname);
+}
#ifndef OUTPUT_H
#define OUTPUT_H
-#include <iosfwd>
-#include <string>
+#include "support/docstream.h"
bool openFileWrite(std::ofstream & ofs, std::string const & fname);
+bool openFileWrite(lyx::odocfstream & ofs, std::string const & fname);
#endif
os << "{" << pit->params().labelWidthString() << "}\n";
} else if (style->labeltype == LABEL_BIBLIO) {
// ale970405
- os << "{" << bibitemWidest(buf) << "}\n";
+ // FIXME UNICODE
+ os << '{' << lyx::to_utf8(bibitemWidest(buf)) << "}\n";
} else
os << style->latexparam() << '\n';
texrow.newline();
#include "ParagraphParameters.h"
#include "support/lstrings.h"
-#include "support/unicode.h"
-
-#include <fstream>
using lyx::support::ascii_lowercase;
using lyx::support::compare_ascii_no_case;
using lyx::support::compare_no_case;
using lyx::support::contains;
+using lyx::docstring;
using lyx::pos_type;
using std::endl;
using std::ostream;
string const & fname,
OutputParams const & runparams)
{
- ofstream ofs;
+ lyx::odocfstream ofs;
if (!::openFileWrite(ofs, fname))
return;
writeFileAscii(buf, ofs, runparams);
}
-void writeFileAscii(Buffer const & buf, ostream & os,
+void writeFileAscii(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams)
{
bool ref_printed = false;
namespace {
-pair<int, string> const addDepth(int depth, int ldepth)
+pair<int, docstring> const addDepth(int depth, int ldepth)
{
int d = depth * 2;
if (ldepth > depth)
d += (ldepth - depth) * 2;
- return make_pair(d, string(d, ' '));
+ return make_pair(d, docstring(d, ' '));
}
}
void asciiParagraph(Buffer const & buf,
Paragraph const & par,
- ostream & os,
+ lyx::odocstream & os,
OutputParams const & runparams,
bool & ref_printed)
{
if (runparams.linelen > 0)
os << "\n\n";
- os << string(depth * 2, ' ');
+ os << docstring(depth * 2, ' ');
currlinelen += depth * 2;
//--
case 6: // Abstract
if (runparams.linelen > 0) {
- os << lyx::to_utf8(_("Abstract")) << "\n\n";
+ os << _("Abstract") << "\n\n";
currlinelen = 0;
} else {
- string const abst = lyx::to_utf8(_("Abstract: "));
+ docstring const abst = _("Abstract: ");
os << abst;
currlinelen += abst.length();
}
case 7: // Bibliography
if (!ref_printed) {
if (runparams.linelen > 0) {
- os << lyx::to_utf8(_("References")) << "\n\n";
+ os << _("References") << "\n\n";
currlinelen = 0;
} else {
- string const refs = lyx::to_utf8(_("References: "));
+ docstring const refs = _("References: ");
os << refs;
currlinelen += refs.length();
}
break;
default: {
- string const label = par.params().labelString();
+ // FIXME UNICODE
+ docstring const label =
+ lyx::from_utf8(par.params().labelString());
os << label << ' ';
currlinelen += label.length() + 1;
break;
}
if (!currlinelen) {
- pair<int, string> p = addDepth(depth, ltype_depth);
+ pair<int, docstring> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen += p.first;
}
// intelligent hopefully! (only in the case where we have a
// max runparams.linelength!) (Jug)
- string word;
+ docstring word;
for (pos_type i = 0; i < par.size(); ++i) {
lyx::char_type c = par.getUChar(buf.params(), i);
case ' ':
if (runparams.linelen > 0 &&
currlinelen + word.length() > runparams.linelen - 10) {
- os << "\n";
- pair<int, string> p = addDepth(depth, ltype_depth);
+ os << '\n';
+ pair<int, docstring> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
"writeAsciiFile: NULL char in structure." << endl;
break;
- default: {
- std::vector<char> const tmp = ucs4_to_utf8(c);
- word.append(tmp.begin(), tmp.end());
+ default:
+ word += c;
if (runparams.linelen > 0 &&
currlinelen + word.length() > runparams.linelen)
{
- os << "\n";
- pair<int, string> p = addDepth(depth, ltype_depth);
+ os << '\n';
+ pair<int, docstring> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
break;
}
- }
}
os << word;
}
#ifndef OUTPUT_PLAINTEXT_H
#define OUTPUT_PLAINTEXT_H
-#include <iosfwd>
-#include <string>
+#include "support/docstream.h"
class Buffer;
class OutputParams;
OutputParams const &);
///
-void writeFileAscii(Buffer const & buf, std::ostream &, OutputParams const &);
+void writeFileAscii(Buffer const & buf, lyx::odocstream &, OutputParams const &);
///
void asciiParagraph(Buffer const & buf,
Paragraph const & paragraphs,
- std::ostream & ofs,
+ lyx::odocstream & ofs,
OutputParams const &,
bool & ref_printed);
#include <stack>
#include <sstream>
+using lyx::docstring;
using lyx::pos_type;
using lyx::char_type;
// Convert the paragraph to a string.
// Used for building the table of contents
-string const Paragraph::asString(Buffer const & buffer, bool label) const
+docstring const Paragraph::asString(Buffer const & buffer, bool label) const
{
OutputParams runparams;
return asString(buffer, runparams, label);
}
-string const Paragraph::asString(Buffer const & buffer,
+docstring const Paragraph::asString(Buffer const & buffer,
OutputParams const & runparams,
bool label) const
{
return s;
#else
// This should really be done by the caller and not here.
- string ret = asString(buffer, runparams, 0, size(), label);
+ docstring ret = asString(buffer, runparams, 0, size(), label);
return subst(ret, '\n', ' ');
#endif
}
-string const Paragraph::asString(Buffer const & buffer,
+docstring const Paragraph::asString(Buffer const & buffer,
pos_type beg, pos_type end, bool label) const
{
}
-string const Paragraph::asString(Buffer const & buffer,
+docstring const Paragraph::asString(Buffer const & buffer,
OutputParams const & runparams,
pos_type beg, pos_type end, bool label) const
{
- ostringstream os;
+ lyx::odocstringstream os;
if (beg == 0 && label && !params().labelString().empty())
- os << params().labelString() << ' ';
+ // FIXME UNICODE
+ os << lyx::from_utf8(params().labelString()) << ' ';
for (pos_type i = beg; i < end; ++i) {
value_type const c = getUChar(buffer.params(), i);
+ // FIXME: isPrintable does not work for lyx::char_type
if (isPrintable(c))
- os << c;
+ os.put(c);
else if (c == META_INSET)
getInset(i)->textString(buffer, os, runparams);
}
bool isMultiLingual(BufferParams const &) const;
///
- std::string const asString(Buffer const &,
+ lyx::docstring const asString(Buffer const &,
OutputParams const & runparams,
bool label) const;
///
- std::string const asString(Buffer const &, bool label) const;
+ lyx::docstring const asString(Buffer const &, bool label) const;
///
- std::string const asString(Buffer const & buffer,
+ lyx::docstring const asString(Buffer const & buffer,
lyx::pos_type beg,
lyx::pos_type end,
bool label) const;
///
- std::string const asString(Buffer const &,
+ lyx::docstring const asString(Buffer const &,
OutputParams const & runparams,
lyx::pos_type beg,
lyx::pos_type end,
if (c != '\0')
os << c;
} else {
- owner_->getInset(i)->plaintext(buf, os, runparams);
+ lyx::odocstringstream oss;
+ owner_->getInset(i)->plaintext(buf, oss, runparams);
+ // FIXME UNICODE
+ os << lyx::to_utf8(oss.str());
}
return;
}
copied_ptr.h \
cow_ptr.h \
debugstream.h \
+ docstream.C \
+ docstream.h \
docstring.C \
docstring.h \
environment.h \
--- /dev/null
+/**
+ * \file docstream.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Georg Baum
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "docstream.h"
+
+#include <cerrno>
+#include <cstdio>
+#include <iconv.h>
+#include <locale>
+
+namespace {
+
+#ifdef WORDS_BIGENDIAN
+char const * ucs4_codeset = "UCS-4BE";
+#else
+char const * ucs4_codeset = "UCS-4LE";
+#endif
+char const * utf8_codeset = "UTF-8";
+
+// We use C IO throughout this file, because the facets might be used with
+// lyxerr in the future.
+
+
+class utf8_codecvt_facet_exception : public std::exception {
+public:
+ virtual ~utf8_codecvt_facet_exception() throw() {}
+ virtual const char* what() const throw()
+ {
+ return "iconv problem in utf8_codecvt_facet initialization";
+ }
+};
+
+
+/// codecvt facet for conversion of UCS4 (internal representation) to UTF8
+/// (external representation) or vice versa
+class utf8_codecvt_facet : public std::codecvt<lyx::char_type, char, std::mbstate_t>
+{
+ typedef std::codecvt<lyx::char_type, char, std::mbstate_t> base;
+public:
+ /// Constructor. You have to specify with \p inout whether you want
+ /// to use this facet only for input, only for output or for both.
+ explicit utf8_codecvt_facet(std::ios_base::openmode inout = std::ios_base::in | std::ios_base::out,
+ size_t refs = 0)
+ : base(refs)
+ {
+ if (inout & std::ios_base::in) {
+ in_cd_ = iconv_open(ucs4_codeset, utf8_codeset);
+ if (in_cd_ == (iconv_t)(-1)) {
+ fprintf(stderr, "Error %d returned from iconv_open(in_cd_): %s\n",
+ errno, strerror(errno));
+ fflush(stderr);
+ throw utf8_codecvt_facet_exception();
+ }
+ } else
+ in_cd_ = (iconv_t)(-1);
+ if (inout & std::ios_base::out) {
+ out_cd_ = iconv_open(utf8_codeset, ucs4_codeset);
+ if (out_cd_ == (iconv_t)(-1)) {
+ fprintf(stderr, "Error %d returned from iconv_open(out_cd_): %s\n",
+ errno, strerror(errno));
+ fflush(stderr);
+ throw utf8_codecvt_facet_exception();
+ }
+ } else
+ out_cd_ = (iconv_t)(-1);
+ }
+protected:
+ virtual ~utf8_codecvt_facet()
+ {
+ if (in_cd_ != (iconv_t)(-1))
+ if (iconv_close(in_cd_) == -1) {
+ fprintf(stderr, "Error %d returned from iconv_close(in_cd_): %s\n",
+ errno, strerror(errno));
+ fflush(stderr);
+ }
+ if (out_cd_ != (iconv_t)(-1))
+ if (iconv_close(out_cd_) == -1) {
+ fprintf(stderr, "Error %d returned from iconv_close(out_cd_): %s\n",
+ errno, strerror(errno));
+ fflush(stderr);
+ }
+ }
+ virtual result do_out(state_type &, intern_type const * from,
+ intern_type const * from_end, intern_type const *& from_next,
+ extern_type * to, extern_type * to_end,
+ extern_type *& to_next) const
+ {
+ size_t inbytesleft = (from_end - from) * sizeof(intern_type);
+ size_t outbytesleft = (to_end - to) * sizeof(extern_type);
+ from_next = from;
+ to_next = to;
+ return do_iconv(out_cd_, reinterpret_cast<char const **>(&from_next),
+ &inbytesleft, &to_next, &outbytesleft);
+ }
+ virtual result do_unshift(state_type &, extern_type * to,
+ extern_type *, extern_type *& to_next) const
+ {
+ // utf8 does not use shifting
+ to_next = to;
+ return base::noconv;
+ }
+ virtual result do_in(state_type &,
+ extern_type const * from, extern_type const * from_end,
+ extern_type const *& from_next,
+ intern_type * to, intern_type * to_end,
+ intern_type *& to_next) const
+ {
+ size_t inbytesleft = (from_end - from) * sizeof(extern_type);
+ size_t outbytesleft = (to_end - to) * sizeof(intern_type);
+ from_next = from;
+ to_next = to;
+ return do_iconv(in_cd_, &from_next, &inbytesleft,
+ reinterpret_cast<char **>(&to_next),
+ &outbytesleft);
+ }
+ virtual int do_encoding() const throw()
+ {
+ return 0;
+ }
+ virtual bool do_always_noconv() const throw()
+ {
+ return false;
+ }
+ virtual int do_length(state_type & /*state*/, extern_type const * from,
+ extern_type const * end, size_t max) const
+ {
+ // The docs are a bit unclear about this method.
+ // It seems that we should calculate the actual length of the
+ // converted sequence, but that would not make sense, since
+ // once could just do the conversion directly.
+ // Therefore we just return the number of unconverted
+ // characters, since that is the best guess we can do.
+#if 0
+ intern_type * to = new intern_type[max];
+ intern_type * to_end = to + max;
+ intern_type * to_next = to;
+ extern_type const * from_next = from;
+ do_in(state, from, end, from_next, to, to_end, to_next);
+ delete[] to;
+ return to_next - to;
+#else
+ size_t const length = end - from;
+ return std::min(length, max);
+#endif
+ }
+ virtual int do_max_length() const throw()
+ {
+ // UTF8 uses at most 6 bytes to represent one code point
+ return 6;
+ }
+private:
+ /// Do the actual conversion. The interface is equivalent to that of
+ /// iconv() (but const correct).
+ inline base::result do_iconv(iconv_t cd, char const ** from,
+ size_t * inbytesleft, char ** to, size_t * outbytesleft) const
+ {
+ char const * to_start = *to;
+ size_t converted = iconv(cd, const_cast<char ICONV_CONST **>(from),
+ inbytesleft, to, outbytesleft);
+ if (converted == (size_t)(-1)) {
+ switch(errno) {
+ case EINVAL:
+ case E2BIG:
+ return base::partial;
+ case EILSEQ:
+ default:
+ fprintf(stderr, "Error %d returned from iconv: %s\n",
+ errno, strerror(errno));
+ fflush(stderr);
+ return base::error;
+ }
+ }
+ if (*to == to_start)
+ return base::noconv;
+ return base::ok;
+ }
+ iconv_t in_cd_;
+ iconv_t out_cd_;
+};
+
+}
+
+
+namespace lyx {
+
+
+idocfstream::idocfstream() : base()
+{
+ std::locale global;
+ std::locale locale(global, new utf8_codecvt_facet(in));
+ imbue(locale);
+}
+
+
+idocfstream::idocfstream(const char* s, std::ios_base::openmode mode)
+ : base()
+{
+ // We must imbue the stream before openening the file
+ std::locale global;
+ std::locale locale(global, new utf8_codecvt_facet(in));
+ imbue(locale);
+ open(s, mode);
+}
+
+
+odocfstream::odocfstream() : base()
+{
+ std::locale global;
+ std::locale locale(global, new utf8_codecvt_facet(out));
+ imbue(locale);
+}
+
+
+odocfstream::odocfstream(const char* s, std::ios_base::openmode mode)
+ : base()
+{
+ // We must imbue the stream before openening the file
+ std::locale global;
+ std::locale locale(global, new utf8_codecvt_facet(out));
+ imbue(locale);
+ open(s, mode);
+}
+
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file docstream.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Georg Baum
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef LYX_DOCSTREAM_H
+#define LYX_DOCSTREAM_H
+
+#include "support/docstring.h"
+
+#include <fstream>
+#include <sstream>
+
+namespace lyx {
+
+/// Base class for UCS4 input streams
+typedef std::basic_istream<char_type> idocstream;
+
+/** Base class for UCS4 output streams.
+ If you want to output a single UCS4 character, use \code
+ os.put(c);
+ \endcode, not \code
+ os << c;
+ \endcode . The latter will not output the character, but the code point
+ as number. This is because we can't overload operator<< (our character
+ type is not a real type but a typedef). Narrow characters of type char
+ can be output as usual.
+ */
+typedef std::basic_ostream<char_type> odocstream;
+
+/// File stream for reading UTF8-encoded files with automatic conversion to
+/// UCS4.
+class idocfstream : public std::basic_ifstream<char_type> {
+ typedef std::basic_ifstream<char_type> base;
+public:
+ idocfstream();
+ explicit idocfstream(const char* s,
+ std::ios_base::openmode mode = std::ios_base::in);
+ ~idocfstream() {}
+};
+
+/// File stream for writing UTF8-encoded files with automatic conversion from
+/// UCS4.
+class odocfstream : public std::basic_ofstream<char_type> {
+ typedef std::basic_ofstream<char_type> base;
+public:
+ odocfstream();
+ explicit odocfstream(const char* s,
+ std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc);
+ ~odocfstream() {}
+};
+
+/// UCS4 input stringstream
+typedef std::basic_istringstream<char_type> idocstringstream;
+
+/// UCS4 output stringstream
+typedef std::basic_ostringstream<char_type> odocstringstream;
+
+}
+#endif
namespace {
- int ascii_tolower(int c) {
- if (c >= 'A' && c <= 'Z')
- return c - 'A' + 'a';
- return c;
- }
+
+int ascii_tolower(int c) {
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 'a';
+ return c;
}
-int compare_ascii_no_case(string const & s, string const & s2)
+template<typename String> inline
+int do_compare_ascii_no_case(String const & s, String const & s2)
{
- string::const_iterator p = s.begin();
- string::const_iterator p2 = s2.begin();
+ typename String::const_iterator p = s.begin();
+ typename String::const_iterator p2 = s2.begin();
while (p != s.end() && p2 != s2.end()) {
int const lc1 = ascii_tolower(*p);
return 1;
}
+}
+
+
+int compare_ascii_no_case(string const & s, string const & s2)
+{
+ return do_compare_ascii_no_case(s, s2);
+}
+
+
+int compare_ascii_no_case(docstring const & s, docstring const & s2)
+{
+ return do_compare_ascii_no_case(s, s2);
+}
+
int compare_no_case(string const & s, string const & s2, unsigned int len)
{
namespace {
+/// Substitute all \a oldchar with \a newchar
template<typename Ch> inline
std::basic_string<Ch> const subst_char(std::basic_string<Ch> const & a,
Ch oldchar, Ch newchar)
}
+/// substitutes all instances of \a oldstr with \a newstr
template<typename String> inline
String const subst_string(String const & a,
String const & oldstr, String const & newstr)
}
+namespace {
+
template<typename String, typename Char> inline
String const doSplit(String const & a, String & piece, Char delim)
{
return tmp;
}
+}
+
string const split(string const & a, string & piece, char delim)
{
///
int compare_ascii_no_case(std::string const & s, std::string const & s2);
+///
+int compare_ascii_no_case(docstring const & s, docstring const & s2);
+
///
int compare_no_case(std::string const & s, std::string const & s2, unsigned int len);
#include <sstream>
+using lyx::docstring;
using lyx::support::ltrim;
using lyx::support::prefixIs;
using lyx::support::rtrim;
}
-int LyXTabular::asciiTopHLine(ostream & os, row_type row,
+int LyXTabular::asciiTopHLine(lyx::odocstream & os, row_type row,
vector<unsigned int> const & clen) const
{
idx_type const fcell = getFirstCellInRow(row);
if (!tmp)
return 0;
- unsigned char ch;
+ lyx::char_type ch;
for (idx_type i = fcell; i < n; ++i) {
if (topLine(i)) {
if (leftLine(i))
while (column < columns_ - 1
&& isPartOfMultiColumn(row, ++column))
len += clen[column] + 4;
- os << string(len, ch);
+ os << docstring(len, ch);
if (topLine(i)) {
if (rightLine(i))
os << "-+";
}
-int LyXTabular::asciiBottomHLine(ostream & os, row_type row,
+int LyXTabular::asciiBottomHLine(lyx::odocstream & os, row_type row,
vector<unsigned int> const & clen) const
{
idx_type const fcell = getFirstCellInRow(row);
if (!tmp)
return 0;
- unsigned char ch;
+ lyx::char_type ch;
for (idx_type i = fcell; i < n; ++i) {
if (bottomLine(i)) {
if (leftLine(i))
while (column < columns_ -1
&& isPartOfMultiColumn(row, ++column))
len += clen[column] + 4;
- os << string(len, ch);
+ os << docstring(len, ch);
if (bottomLine(i)) {
if (rightLine(i))
os << "-+";
}
-int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
+int LyXTabular::asciiPrintCell(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams,
idx_type cell, row_type row, col_type column,
vector<unsigned int> const & clen,
bool onlydata) const
{
- ostringstream sstr;
+ lyx::odocstringstream sstr;
int const ret = getCellInset(cell)->plaintext(buf, sstr, runparams);
if (onlydata) {
break;
}
- os << string(len1, ' ') << sstr.str() << string(len2, ' ');
+ os << docstring(len1, ' ') << sstr.str()
+ << docstring(len2, ' ');
if (rightLine(cell))
os << " |";
}
-int LyXTabular::plaintext(Buffer const & buf, ostream & os,
+int LyXTabular::plaintext(Buffer const & buf, lyx::odocstream & os,
OutputParams const & runparams,
int const depth,
bool onlydata, unsigned char delim) const
idx_type cell = getCellNumber(i, j);
if (isMultiColumnReal(cell))
continue;
- ostringstream sstr;
+ lyx::odocstringstream sstr;
getCellInset(cell)->plaintext(buf, sstr, runparams);
if (clen[j] < sstr.str().length())
clen[j] = sstr.str().length();
idx_type cell = getCellNumber(i, j);
if (!isMultiColumnReal(cell) || isPartOfMultiColumn(i, j))
continue;
- ostringstream sstr;
+ lyx::odocstringstream sstr;
getCellInset(cell)->plaintext(buf, sstr, runparams);
int len = int(sstr.str().length());
idx_type const n = cells_in_multicolumn(cell);
idx_type cell = 0;
for (row_type i = 0; i < rows_; ++i) {
if (!onlydata && asciiTopHLine(os, i, clen))
- os << string(depth * 2, ' ');
+ os << docstring(depth * 2, ' ');
for (col_type j = 0; j < columns_; ++j) {
if (isPartOfMultiColumn(i, j))
continue;
}
os << endl;
if (!onlydata) {
- os << string(depth * 2, ' ');
+ os << docstring(depth * 2, ' ');
if (asciiBottomHLine(os, i, clen))
- os << string(depth * 2, ' ');
+ os << docstring(depth * 2, ' ');
}
}
return ret;
int docbook(Buffer const & buf, std::ostream & os,
OutputParams const &) const;
///
- int plaintext(Buffer const &, std::ostream &,
+ int plaintext(Buffer const &, lyx::odocstream &,
OutputParams const & runparams,
int const depth,
bool onlydata, unsigned char delim) const;
///
// helper function for ASCII returns number of newlines
///
- int asciiTopHLine(std::ostream &, row_type row,
+ int asciiTopHLine(lyx::odocstream &, row_type row,
std::vector<unsigned int> const &) const;
///
- int asciiBottomHLine(std::ostream &, row_type row,
+ int asciiBottomHLine(lyx::odocstream &, row_type row,
std::vector<unsigned int> const &) const;
///
- int asciiPrintCell(Buffer const &, std::ostream &,
+ int asciiPrintCell(Buffer const &, lyx::odocstream &,
OutputParams const &,
idx_type cell, row_type row, col_type column,
std::vector<unsigned int> const &,
if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
text.erase();
- string par_text = pars_[pit].asString(cur.buffer(), false);
+ // FIXME UNICODE
+ string par_text = lyx::to_utf8(pars_[pit].asString(cur.buffer(), false));
for (int i = 0; i < lyxrc.label_init_length; ++i) {
if (par_text.empty())
break;
}
-void asciiTocList(string const & type, Buffer const & buf, ostream & os)
+void asciiTocList(string const & type, Buffer const & buf, lyx::odocstream & os)
{
toc_backend_[&buf].asciiTocList(type, os);
}
std::string const & type);
///
-void asciiTocList(std::string const &, Buffer const &, std::ostream &);
+void asciiTocList(std::string const &, Buffer const &, lyx::odocstream &);
/** Given the cmdName of the TOC param, returns the type used
by ControlToc::getContents() */