getInsetByCode<InsetRef>(cursor_,
InsetBase::REF_CODE);
if (inset) {
- label = lyx::from_utf8(inset->getContents());
+ label = inset->getParam("reference");
savePosition(0);
}
}
case LFUN_INDEX_INSERT: {
// Try and generate a valid index entry.
InsetCommandParams icp("index");
- string const contents = cmd.argument().empty() ?
- bv->getLyXText()->getStringToIndex(bv->cursor()) :
- lyx::to_utf8(cmd.argument());
- icp.setContents(contents);
+ icp["name"] = cmd.argument().empty() ?
+ lyx::from_utf8(bv->getLyXText()->getStringToIndex(bv->cursor())) :
+ cmd.argument();
return new InsetIndex(icp);
}
|| cmdName == "vref"
|| cmdName == "vpageref"
|| cmdName == "prettyref") {
- if (!inscmd.getOptions().empty()
- || !inscmd.getContents().empty()) {
+ if (!inscmd["name"].empty()
+ || !inscmd["reference"].empty()) {
inset.reset(new InsetRef(inscmd, buf));
}
} else if (cmdName == "tableofcontents") {
using std::ostream;
int InsetBibitem::key_counter = 0;
-string const key_prefix = "key-";
+docstring const key_prefix = lyx::from_ascii("key-");
InsetBibitem::InsetBibitem(InsetCommandParams const & p)
: InsetCommand(p, "bibitem"), counter(1)
{
- if (getContents().empty())
- setContents(key_prefix + convert<string>(++key_counter));
+ if (getParam("key").empty())
+ setParam("key", key_prefix + convert<docstring>(++key_counter));
}
cur.noUpdate();
break;
}
- if (p.getContents() != params().getContents())
- cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
- p.getContents(), InsetBase::CITE_CODE);
+ if (p["key"] != params()["key"])
+ // FIXME UNICODE
+ cur.bv().buffer()->changeRefsIfUnique(lyx::to_utf8(params()["key"]),
+ lyx::to_utf8(p["key"]), InsetBase::CITE_CODE);
setParams(p);
}
{
InsetCommand::read(buf, lex);
- if (prefixIs(getContents(), key_prefix)) {
- int const key = convert<int>(getContents().substr(key_prefix.length()));
+ if (prefixIs(getParam("key"), key_prefix)) {
+ int const key = convert<int>(getParam("key").substr(key_prefix.length()));
key_counter = max(key_counter, key);
}
}
docstring const InsetBibitem::getBibLabel() const
{
- // FIXME UNICODE
- return getOptions().empty() ?
- convert<docstring>(counter) :
- lyx::from_utf8(getOptions());
+ docstring const & label = getParam("label");
+ return label.empty() ? convert<docstring>(counter) : label;
}
docstring const InsetBibitem::getScreenLabel(Buffer const &) const
{
- // FIXME UNICODE
- return lyx::from_utf8(getContents()) + " [" + getBibLabel() + ']';
+ return getParam("key") + " [" + getBibLabel() + ']';
}
typedef boost::tokenizer<Separator> Tokenizer;
Separator const separator(",");
- Tokenizer const tokens(getContents(), separator);
+ Tokenizer const tokens(lyx::to_utf8(getParam("bibfiles")), separator);
Tokenizer::const_iterator const begin = tokens.begin();
Tokenizer::const_iterator const end = tokens.end();
dbs << ',';
dbs << latex_path(database);
}
- string const db_out = dbs.str();
+ // FIXME UNICODE
+ docstring const db_out = lyx::from_utf8(dbs.str());
// Post this warning only once.
static bool warned_about_spaces = false;
if (!warned_about_spaces &&
- runparams.nice && db_out.find(' ') != string::npos) {
+ runparams.nice && db_out.find(' ') != docstring::npos) {
warned_about_spaces = true;
- // FIXME UNICODE
Alert::warning(_("Export Warning!"),
_("There are spaces in the paths to your BibTeX databases.\n"
"BibTeX will be unable to find them."));
}
// Style-Options
- string style = getOptions(); // maybe empty! and with bibtotoc
+ string style = lyx::to_utf8(getParam("options")); // maybe empty! and with bibtotoc
string bibtotoc;
if (prefixIs(style, "bibtotoc")) {
bibtotoc = "bibtotoc";
}
if (!db_out.empty() && buffer.params().use_bibtopic){
- // FIXME UNICODE
- os << "\\begin{btSect}{" << lyx::from_utf8(db_out) << "}\n";
+ os << "\\begin{btSect}{" << db_out << "}\n";
docstring btprint = getParam("btprint");
if (btprint.empty())
// default
}
if (!db_out.empty() && !buffer.params().use_bibtopic){
- // FIXME UNICODE
- os << "\\bibliography{" << lyx::from_utf8(db_out) << "}\n";
+ os << "\\bibliography{" << db_out << "}\n";
nlines += 1;
}
vector<string> vec;
string tmp;
- string bibfiles = getContents();
+ // FIXME UNICODE
+ string bibfiles = lyx::to_utf8(getParam("bibfiles"));
bibfiles = split(bibfiles, tmp, ',');
while (!tmp.empty()) {
string file = findtexfile(changeExtension(tmp, "bib"), "bib");
bool InsetBibtex::addDatabase(string const & db)
{
- string contents(getContents());
- if (tokenPos(contents, ',', db) == -1) {
- if (!contents.empty())
- contents += ',';
- setContents(contents + db);
+ // FIXME UNICODE
+ string bibfiles(lyx::to_utf8(getParam("bibfiles")));
+ if (tokenPos(bibfiles, ',', db) == -1) {
+ if (!bibfiles.empty())
+ bibfiles += ',';
+ setParam("bibfiles", lyx::from_utf8(bibfiles + db));
return true;
}
return false;
bool InsetBibtex::delDatabase(string const & db)
{
- string contents(getContents());
- if (contains(contents, db)) {
- int const n = tokenPos(contents, ',', db);
+ // FIXME UNICODE
+ string bibfiles(lyx::to_utf8(getParam("bibfiles")));
+ if (contains(bibfiles, db)) {
+ int const n = tokenPos(bibfiles, ',', db);
string bd = db;
if (n > 0) {
// this is not the first database
string tmp = ',' + bd;
- setContents(subst(contents, tmp, ""));
+ setParam("bibfiles", lyx::from_utf8(subst(bibfiles, tmp, string())));
} else if (n == 0)
// this is the first (or only) database
- setContents(split(contents, bd, ','));
+ setParam("bibfiles", lyx::from_utf8(split(bibfiles, bd, ',')));
else
return false;
}
#include "insethfill.h"
+#include "gettext.h"
+
#include "support/std_ostream.h"
using lyx::docstring;
docstring const InsetHFill::getScreenLabel(Buffer const &) const
{
- return lyx::from_ascii(getContents());
+ return _("Horizontal Fill");
}
string const includedFilename(Buffer const & buffer,
InsetCommandParams const & params)
{
- return makeAbsPath(params.getContents(),
+ return makeAbsPath(lyx::to_utf8(params["filename"]),
onlyPath(parentFilename(buffer)));
}
temp += ": ";
- if (params_.getContents().empty())
+ if (params_["filename"].empty())
temp += "???";
else
// FIXME: We don't know the encoding of the filename
- temp += lyx::from_ascii(onlyFilename(params_.getContents()));
+ temp += lyx::from_ascii(onlyFilename(lyx::to_utf8(params_["filename"])));
return temp;
}
int InsetInclude::latex(Buffer const & buffer, odocstream & os,
OutputParams const & runparams) const
{
- string incfile(params_.getContents());
+ string incfile(lyx::to_utf8(params_["filename"]));
// Do nothing if no file name has been specified
if (incfile.empty())
int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
OutputParams const & runparams) const
{
- string incfile(params_.getContents());
+ string incfile(lyx::to_utf8(params_["filename"]));
// Do nothing if no file name has been specified
if (incfile.empty())
void InsetInclude::validate(LaTeXFeatures & features) const
{
- string incfile(params_.getContents());
+ string incfile(lyx::to_utf8(params_["filename"]));
string writefile;
Buffer const & buffer = features.buffer();
{
// FIXME UNICODE
os << "<indexterm><primary>"
- << lyx::from_ascii(sgml::escapeString(getContents()))
+ << lyx::from_ascii(sgml::escapeString(lyx::to_ascii(getParam("name"))))
<< "</primary></indexterm>";
return 0;
}
void InsetLabel::getLabelList(Buffer const &, std::vector<docstring> & list) const
{
- // FIXME UNICODE
- list.push_back(lyx::from_utf8(getContents()));
+ list.push_back(getParam("name"));
}
docstring const InsetLabel::getScreenLabel(Buffer const &) const
{
- // FIXME UNICODE
- return lyx::from_utf8(getContents());
+ return getParam("name");
}
cur.noUpdate();
break;
}
- if (p.getContents() != params().getContents())
- cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
- p.getContents(), InsetBase::REF_CODE);
+ if (p["name"] != params()["name"])
+ // FIXME UNICODE
+ cur.bv().buffer()->changeRefsIfUnique(lyx::to_utf8(params()["name"]),
+ lyx::to_utf8(p["name"]), InsetBase::REF_CODE);
setParams(p);
break;
}
int InsetLabel::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
- // FIXME UNICODE
- os << '<' << lyx::from_utf8(getContents()) << '>';
+ os << '<' << getParam("name") << '>';
return 0;
}
{
// FIXME UNICODE
os << "<!-- anchor id=\""
- << lyx::from_ascii(sgml::cleanID(buf, runparams, getContents()))
+ << lyx::from_ascii(sgml::cleanID(buf, runparams, lyx::to_ascii(getParam("name"))))
<< "\" -->";
return 0;
}
case LFUN_MOUSE_PRESS:
// Eventually trigger dialog with button 3 not 1
if (cmd.button() == mouse_button::button3)
- lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getContents()));
+ lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getParam("reference")));
else {
InsetCommandMailer("ref", *this).showDialog(&cur.bv());
cur.undispatched();
break;
}
}
- // FIXME UNICODE
- temp += lyx::from_utf8(getContents());
+ temp += getParam("reference");
- if (!isLatex && !getOptions().empty()) {
+ if (!isLatex && !getParam("name").empty()) {
temp += "||";
- // FIXME UNICODE
- temp += lyx::from_utf8(getOptions());
+ temp += getParam("name");
}
return temp;
}
int InsetRef::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
- // FIXME UNICODE
- os << '[' << lyx::from_utf8(getContents()) << ']';
+ os << '[' << getParam("reference") << ']';
return 0;
}
int InsetRef::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
- // FIXME UNICODE
- if (getOptions().empty() && runparams.flavor == OutputParams::XML) {
- os << "<xref linkend=\""
- << lyx::from_ascii(sgml::cleanID(buf, runparams, getContents()))
- << "\" />";
- } else if (getOptions().empty()) {
- os << "<xref linkend=\""
- << lyx::from_ascii(sgml::cleanID(buf, runparams, getContents()))
- << "\">";
+ docstring const & name = getParam("name");
+ if (name.empty()) {
+ if (runparams.flavor == OutputParams::XML) {
+ os << "<xref linkend=\""
+ << lyx::from_ascii(sgml::cleanID(buf, runparams, lyx::to_ascii(getParam("reference"))))
+ << "\" />";
+ } else {
+ os << "<xref linkend=\""
+ << lyx::from_ascii(sgml::cleanID(buf, runparams, lyx::to_ascii(getParam("reference"))))
+ << "\">";
+ }
} else {
- os << "<link linkend=\""
- << lyx::from_ascii(sgml::cleanID(buf, runparams, getContents()))
- << "\">"
- << lyx::from_ascii(getOptions())
- << "</link>";
+ os << "<link linkend=\""
+ << lyx::from_ascii(sgml::cleanID(buf, runparams, lyx::to_ascii(getParam("reference"))))
+ << "\">"
+ << getParam("name")
+ << "</link>";
}
return 0;
docstring const temp =
(getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
- string url;
+ docstring url;
- if (!getOptions().empty())
- url += getOptions();
+ if (!getParam("name").empty())
+ url += getParam("name");
else
- url += getContents();
+ url += getParam("target");
// elide if long
if (url.length() > 30) {
url = url.substr(0, 10) + "..."
+ url.substr(url.length() - 17, url.length());
}
- // FIXME UNICODE
- return temp + lyx::from_utf8(url);
+ return temp + url;
}
int InsetUrl::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
- // FIXME UNICODE
- os << '[' << lyx::from_utf8(getContents());
- if (getOptions().empty())
+ os << '[' << getParam("target");
+ if (getParam("name").empty())
os << ']';
else
- // FIXME UNICODE
- os << "||" << lyx::from_utf8(getOptions()) << ']';
+ os << "||" << getParam("name") << ']';
return 0;
}
int InsetUrl::docbook(Buffer const &, odocstream & os,
OutputParams const &) const
{
- // FIXME UNICODE
- os << "<ulink url=\""
- << lyx::from_ascii(subst(getContents(), "&", "&"))
- << "\">"
- << lyx::from_ascii(getOptions())
- << "</ulink>";
+ os << "<ulink url=\""
+ << subst(getParam("target"), lyx::from_ascii("&"), lyx::from_ascii("&"))
+ << "\">"
+ << getParam("name")
+ << "</ulink>";
return 0;
}
if (name == "label") {
InsetCommandParams p("label");
InsetCommandMailer::string2params(name, lyx::to_utf8(cmd.argument()), p);
- string str = p.getContents();
+ string str = lyx::to_utf8(p["name"]);
recordUndoInset(cur);
row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row();
str = lyx::support::trim(str);
}
+template<>
+int convert<int>(docstring const s)
+{
+ return strtol(lyx::to_ascii(s).c_str(), 0, 10);
+}
+
+
template<>
unsigned int convert<unsigned int>(string const s)
{
}
+bool prefixIs(docstring const & a, docstring const & pre)
+{
+ docstring::size_type const prelen = pre.length();
+ docstring::size_type const alen = a.length();
+
+ if (prelen > alen || a.empty())
+ return false;
+ else
+ return a.compare(0, prelen, pre) == 0;
+}
+
+
bool suffixIs(string const & a, char c)
{
if (a.empty()) return false;
/// Does the std::string start with this prefix?
bool prefixIs(std::string const &, std::string const &);
+bool prefixIs(lyx::docstring const &, lyx::docstring const &);
/// Does the string end with this char?
bool suffixIs(std::string const &, char);