Buffer::ReadStatus Buffer::readFile(FileName const & fn)
{
- FileName fname(fn);
Lexer lex;
- if (!lex.setFile(fname)) {
+ if (!lex.setFile(fn)) {
Alert::error(_("File Not Found"),
bformat(_("Unable to open file `%1$s'."),
from_utf8(fn.absFileName())));
break;
case LFUN_BUFFER_EXPORT: {
- docstring const arg = cmd.argument();
+ docstring const & arg = cmd.argument();
if (arg == "custom") {
enable = true;
break;
|| cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
BranchList const & branchList = master ? masterBuffer()->params().branchlist()
: params().branchlist();
- docstring const branchName = cmd.argument();
+ docstring const & branchName = cmd.argument();
flag.setEnabled(!branchName.empty() && branchList.find(branchName));
break;
}
Buffer * buf = master ? const_cast<Buffer *>(masterBuffer())
: this;
- docstring const branch_name = func.argument();
+ docstring const & branch_name = func.argument();
// the case without a branch name is handled elsewhere
if (branch_name.empty()) {
dispatched = false;
}
case LFUN_BRANCH_ADD: {
- docstring branchnames = func.argument();
+ docstring const & branchnames = func.argument();
if (branchnames.empty()) {
dispatched = false;
break;
break;
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
case LFUN_FILE_INSERT_PLAINTEXT: {
- docstring const fname = cmd.argument();
+ docstring const & fname = cmd.argument();
if (!FileName::isAbsolute(to_utf8(fname))) {
flag.message(_("Absolute filename expected."));
return false;
DocPair()
{}
- DocPair(DocIterator o_, DocIterator n_)
+ DocPair(DocIterator const & o_, DocIterator const & n_)
: o(o_), n(n_)
{}
} else if (regex_match(token, sub, biberError)) {
retval |= BIBTEX_ERROR;
string errstr = N_("Biber error: ") + sub.str(2);
- string msg = token;
terr.insertError(0,
from_local8bit(errstr),
- from_local8bit(msg));
+ from_local8bit(token));
}
prevtoken = token;
}
} else if (prefixIs(token, "ERROR: ")) {
retval |= BIBTEX_ERROR;
string errstr = N_("Xindy error: ") + token.substr(6);
- string msg = token;
terr.insertError(0,
from_local8bit(errstr),
- from_local8bit(msg));
+ from_local8bit(token));
}
}
return retval;
// We check whether the used rm font supports an encoding our language supports
LaTeXFont const & lf =
theLaTeXFonts().getLaTeXFont(from_ascii(params.fontsRoman()));
- vector<string> const lfe = lf.fontencs();
+ vector<string> const & lfe = lf.fontencs();
for (auto & fe : fontenc_) {
// ASCII means: support all T* encodings plus OT1
if (fe == "ASCII") {
}
-bool isValidTagType(std::string type)
+bool isValidTagType(std::string const & type)
{
return !(type.empty() || (type != "block" && type != "paragraph" && type != "inline"));
}
}
-void ParagraphParameters::read(string str, bool merge)
+void ParagraphParameters::read(string const & str, bool merge)
{
istringstream is(str);
Lexer lex;
void leftIndent(Length const &);
/// read the parameters from a string
- void read (std::string str, bool merge = true);
+ void read (std::string const & str, bool merge = true);
/// read the parameters from a lex
void read(Lexer & lex, bool merge = true);
case LFUN_NEWLINE_INSERT: {
InsetNewlineParams inp;
- docstring arg = cmd.argument();
+ docstring const & arg = cmd.argument();
if (arg == "linebreak")
inp.kind = InsetNewlineParams::LINEBREAK;
else
{
vector<CitationStyle> const styles = citeStyles(type);
vector<string> cmds;
+ cmds.reserve(styles.size());
for (auto const & cs : styles)
cmds.push_back(cs.name);
MyThes * mythes = nullptr;
docstring const lang_code = from_ascii(wl.lang()->code());
- docstring const t = wl.word();
+ docstring const & t = wl.word();
if (!d->addThesaurus(lang_code))
return meanings;
// remove silly item
if (support::prefixIs(meaning, '-'))
meaning = support::ltrim(meaning, "- ");
+ ret.reserve(pm->count);
for (int j = 0; j < pm->count; j++) {
ret.push_back(from_iconv_encoding(string(pm->psyns[j]), encoding));
}
}
case LFUN_INDEX_INSERT: {
- docstring arg = cmd.argument();
+ docstring const & arg = cmd.argument();
return new InsetIndex(buf, InsetIndexParams(arg));
}
}
case INDEX_CODE: {
- docstring arg = cmd.argument();
+ docstring const & arg = cmd.argument();
return new InsetIndex(buf, InsetIndexParams(arg));
}
static QStringList toolbar_uifiles;
-GuiApplication::ReturnValues GuiApplication::readUIFile(FileName ui_path)
+GuiApplication::ReturnValues GuiApplication::readUIFile(FileName const & ui_path)
{
enum {
ui_menuset = 1,
FormatMismatch
};
///
- ReturnValues readUIFile(support::FileName);
+ ReturnValues readUIFile(support::FileName const & ui_path);
///
void setGuiLanguage();
///
void GuiCitation::filterByEntryType(BiblioInfo const & bi,
- vector<docstring> & keyVector, docstring entry_type)
+ vector<docstring> & keyVector, docstring const & entry_type)
{
if (entry_type.empty())
return;
vector<docstring> GuiCitation::searchKeys(BiblioInfo const & bi,
vector<docstring> const & keys_to_search, bool only_keys,
- docstring const & search_expression, docstring field,
+ docstring const & search_expression, docstring const & field,
bool case_sensitive, bool regex)
{
vector<docstring> foundKeys;
///
void filterByEntryType(BiblioInfo const & bi,
- std::vector<docstring> & keyVector, docstring entryType);
+ std::vector<docstring> & keyVector, docstring const & entryType);
/// Search a given string within the passed keys.
/// \return the vector of matched keys.
std::vector<docstring> const & keys_to_search, //< Keys to search.
bool only_keys, //< whether to search only the keys
docstring const & search_expression, //< Search expression (regex possible)
- docstring field, //< field to search, empty for all fields
+ docstring const & field, //< field to search, empty for all fields
bool case_sensitive = false, //< set to true is the search should be case sensitive
bool regex = false //< \set to true if \c search_expression is a regex
); //
* Since we are going to write a HTML file for external converters we need
* to ensure that it is a well formed HTML file, including all the mentioned tags.
*/
-QString tidyHtml(QString input)
+QString tidyHtml(QString const & input)
{
// Misuse QTextDocument to cleanup the HTML.
// As a side effect, all visual markup like <tt> is converted to CSS,
}
-void GuiCompare::setStatusMessage(QString msg)
+void GuiCompare::setStatusMessage(QString const & msg)
{
statusBar->showMessage(msg);
}
///
void progressMax(int) const;
///
- void setStatusMessage(QString);
+ void setStatusMessage(QString const &);
private:
///
}
/// \return the math unicode symbol associated to a TeX name.
-MathSymbol const & mathSymbol(string tex_name)
+MathSymbol const & mathSymbol(string const & tex_name)
{
map<string, MathSymbol>::const_iterator it =
math_symbols_.find(tex_name);
QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
QListWidgetItem * lwi = new QListWidgetItem(symbol);
lyxfont.setFamily(ms.fontfamily);
- QFont font = frontend::getFont(lyxfont);
+ QFont const & font = frontend::getFont(lyxfont);
lwi->setFont(font);
setDelimiterName(lwi, delim);
lwi->setToolTip(toqstr(delim));
<< toqstr(system);
for (int i = 0; i < dirs.size(); ++i) {
- QString const dir = dirs.at(i);
+ QString const & dir = dirs.at(i);
QDirIterator it(dir, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString fn = QFileInfo(it.next()).fileName();
namespace {
-QString const guiString(QString in)
+QString const guiString(QString const & in)
{
// recode specially encoded chars in file names (URL encoding and underbar)
return QString::fromUtf8(QByteArray::fromPercentEncoding(in.toUtf8())).replace('_', ' ');
<< toqstr(system);
for (int i = 0; i < dirs.size(); ++i) {
- QString const dir = dirs.at(i);
+ QString const & dir = dirs.at(i);
QDirIterator it(dir, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString fn(QFile(it.next()).fileName());
fillRectangle(x, y, w, h, Color_graphicsbg);
- QImage const image = qlimage.image();
+ QImage const & image = qlimage.image();
QRectF const drect = QRectF(x, y, w, h);
QRectF const srect = QRectF(0, 0, image.width(), image.height());
// Bilinear filtering is needed on a rare occasion for instant previews when
}
-bool PrefColors::setColor(int const row, QColor const new_color,
- QString const old_color)
+bool PrefColors::setColor(int const row, QColor const & new_color,
+ QString const & old_color)
{
if (new_color.isValid() && new_color.name() != old_color) {
newcolors_[size_t(row)] = new_color.name();
}
-bool PrefColors::isDefaultColor(int const row, QString const color)
+bool PrefColors::isDefaultColor(int const row, QString const & color)
{
return color == getDefaultColorByRow(row).name();
}
void resetAllColor();
void changeSysColor();
void changeLyxObjectsSelection();
- bool setColor(int const row, QColor const new_color,
- QString const old_color);
- bool isDefaultColor(int const row, QString const color);
+ bool setColor(int const row, QColor const & new_color,
+ QString const & old_color);
+ bool isDefaultColor(int const row, QString const & color);
void setDisabledResets();
private:
if (groupCB->isChecked()) {
QList<QTreeWidgetItem *> refsCats;
for (int i = 0; i < refsCategories.size(); ++i) {
- QString const cat = refsCategories.at(i);
+ QString const & cat = refsCategories.at(i);
QTreeWidgetItem * item = new QTreeWidgetItem(refsTW);
item->setText(0, cat);
for (int j = 0; j < refsStrings.size(); ++j) {
- QString const ref = refsStrings.at(j);
+ QString const & ref = refsStrings.at(j);
if ((ref.startsWith(cat + QString(":")))
|| (cat == qt_("<No prefix>")
&& (!ref.mid(1).contains(":") || ref.left(1).contains(":")))) {
<< toqstr(system);
for (int i = 0; i < dirs.size(); ++i) {
- QString const dir = dirs.at(i);
+ QString const & dir = dirs.at(i);
QDirIterator it(dir, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString fn = QFileInfo(it.next()).fileName();
}
-void GuiWorkAreaContainer::dispatch(FuncRequest f) const
+void GuiWorkAreaContainer::dispatch(FuncRequest const & f) const
{
lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
wa_->bufferView().buffer().absFileName()));
Q_OBJECT
// non-null
GuiWorkArea * const wa_;
- void dispatch(FuncRequest f) const;
+ void dispatch(FuncRequest const & f) const;
private Q_SLOTS:
void updateDisplay();
void expandFloatInsert(Buffer const * buf);
void expandFlexInsert(Buffer const * buf, InsetLayout::InsetLyXType type);
void expandTocSubmenu(std::string const & type, Toc const & toc_list);
- void expandToc2(Toc const & toc_list, size_t from, size_t to, int depth, string toc_type);
+ void expandToc2(Toc const & toc_list, size_t from, size_t to, int depth, const string &toc_type);
void expandToc(Buffer const * buf);
void expandPasteRecent(Buffer const * buf);
void expandToolbars();
void MenuDefinition::expandToc2(Toc const & toc_list,
size_t from, size_t to, int depth,
- string toc_type)
+ string const & toc_type)
{
int shortcut_count = 0;
{
fr.setViewOrigin(&gui_view_);
- DispatchResult dr=dispatch(fr);
+ DispatchResult const & dr = dispatch(fr);
if (dr.error())
gui_view_.message(dr.message());
}
vector<pair<docstring, string>> const dbs =
buffer().prepareBibFilePaths(runparams, getBibFiles(), false);
vector<docstring> db_out;
- for (pair<docstring, string> const & db : dbs)
+ db_out.reserve(dbs.size());
+ for (pair<docstring, string> const & db : dbs)
db_out.push_back(db.first);
// Style options
if (style == "default")
void InsetCommand::changeCmdName(string const & new_name)
{
- string const old_name = getCmdName();
+ string const & old_name = getCmdName();
if (old_name == new_name)
return;
void InsetRef::validate(LaTeXFeatures & features) const
{
- string const cmd = getCmdName();
+ string const & cmd = getCmdName();
if (cmd == "vref" || cmd == "vpageref")
features.require("varioref");
else if (cmd == "formatted") {
row_type const row2 = tabular.cellRow(enidx);
for (col_type col = col1; col <= col2; col++)
for (row_type row = row1; row <= row2; row++)
- for (auto par : tabular.cellInset(row, col)->paragraphs())
+ for (auto const & par : tabular.cellInset(row, col)->paragraphs())
retval.push_back(par);
return retval;
}
{
Paragraph const & par = paragraphs()[pit];
TocBuilder & b = backend.builder(par.layout().tocType());
- docstring const label = par.labelString();
+ docstring const & label = par.labelString();
b.pushItem(dit, label + (label.empty() ? "" : " "), output_active);
return text().lastInSequence(pit);
}
}
-docstring InsetText::toolTipText(docstring prefix, size_t const len) const
+docstring InsetText::toolTipText(docstring const & prefix, size_t const len) const
{
OutputParams rp(&buffer().params().encoding());
rp.for_tooltip = true;
/// of that sort. (Note: unnecessary internal copies have been removed
/// since the previous note. The efficiency would have to be assessed
/// again by profiling.)
- docstring toolTipText(docstring prefix = empty_docstring(),
+ docstring toolTipText(docstring const & prefix = empty_docstring(),
size_t len = 400) const;
///
// FIXME XHTML
// We need to do something about alignment here.
-void InsetMathGrid::htmlize(HtmlStream & os, string attrib) const
+void InsetMathGrid::htmlize(HtmlStream & os, string const & attrib) const
{
bool const havetable = nrows() > 1 || ncols() > 1;
if (!havetable) {
///
void htmlize(HtmlStream &) const override;
///
- void htmlize(HtmlStream &, std::string attrib) const;
+ void htmlize(HtmlStream &, std::string const & attrib) const;
///
void validate(LaTeXFeatures & features) const override;
///
int const a = dim.ascent();
int const d = dim.descent();
int const t = pi.base.solidLineThickness();
- Dimension const dimn = nucleus.dimension(*pi.base.bv);
+ Dimension const & dimn = nucleus.dimension(*pi.base.bv);
// the width of the left part of the root
int const wl = dim.width() - dimn.width();
// the "exponent"
if (root) {
Changer script = pi.base.font.changeStyle(SCRIPTSCRIPT_STYLE);
- Dimension const dimr = root->dimension(*pi.base.bv);
+ Dimension const & dimr = root->dimension(*pi.base.bv);
int const root_offset = wl - 3 * w / 8 - dimr.width();
root->draw(pi, x + root_offset, y + (d - a)/2);
}
bool const prot = nextToken().character() == '*';
if (prot)
getToken();
- docstring const name = t.cs();
+ docstring const & name = t.cs();
docstring const arg = parse_verbatim_item();
Length length;
if (prot && arg == "\\fill")
void setSecondStream(std::ostream * os)
{ second_enabled_ = (second_stream_ = os); }
/// Is the second stream is enabled?
- bool secondEnabled() { return second_enabled_; }
+ bool secondEnabled() const { return second_enabled_; }
/// Sets the debug level
void setLevel(Debug::Type t) { dt_ = t; }
}
-odocstream & operator<<(odocstream & os, SetEnc e)
+odocstream & operator<<(odocstream & os, SetEnc const & e)
{
if (has_facet<iconv_codecvt_facet>(os.rdbuf()->getloc())) {
// This stream must be a file stream, since we never imbue
}
-idocstream & operator<<(idocstream & is, SetEnc e)
+idocstream & operator<<(idocstream & is, SetEnc const & e)
{
if (has_facet<iconv_codecvt_facet>(is.rdbuf()->getloc())) {
// This stream must be a file stream, since we never imbue
os << setEncoding("ISO-8859-1");
\endcode
*/
-odocstream & operator<<(odocstream & os, SetEnc e);
-idocstream & operator<<(idocstream & os, SetEnc e);
+odocstream & operator<<(odocstream & os, SetEnc const & e);
+idocstream & operator<<(idocstream & os, SetEnc const & e);
} // namespace lyx
}
-FileName const tempFileName(FileName tempdir, string const & mask, bool const dir)
+FileName const tempFileName(FileName const & tempdir, string const & mask, bool const dir)
{
return tempFileName(TempFile(tempdir, mask).name(), dir);
}
*/
FileName const tempFileName(FileName, bool const dir = false);
/// Get temporary file name with custom path
-FileName const tempFileName(FileName, std::string const &, bool const dir = false);
+FileName const tempFileName(FileName const &, std::string const &, bool const dir = false);
/// Get temporary file name with default path
FileName const tempFileName(std::string const &, bool const dir = false);
}
-void iparserdocstream::putback(docstring s)
+void iparserdocstream::putback(docstring const & s)
{
s_ = s + s_;
}
// add to the list of characters to read before actually reading
// the stream
- void putback(docstring s);
+ void putback(const docstring &s);
/// Like std::istream::get()
iparserdocstream & get(char_type &c);
if (layout) {
found_style = true;
dpre = layout->preamble();
- std::set<std::string> lreqs = layout->required();
+ std::set<std::string> const & lreqs = layout->required();
if (!lreqs.empty())
cmd_reqs.insert(lreqs.begin(), lreqs.end());
} else if (insetlayout) {
namespace {
-void output_arguments(ostream &, Parser &, bool, bool, string, Context &,
+void output_arguments(ostream &, Parser &, bool, bool, const string &, Context &,
Layout::LaTeXArgMap const &);
}
/// If we have ambiguous quotation marks, make a smart guess
/// based on main quote style
-string guessQuoteStyle(string in, bool const opening)
+string guessQuoteStyle(string const & in, bool const opening)
{
string res = in;
if (prefixIs(in, "qr")) {// straight quote
}
-string const fromPolyglossiaEnvironment(string const s)
+string const fromPolyglossiaEnvironment(string const & s)
{
// Since \arabic is taken by the LaTeX kernel,
// the Arabic polyglossia environment is upcased
}
-string uncapitalize(string const s)
+string uncapitalize(string const & s)
{
docstring in = from_ascii(s);
char_type t = lowercase(s[0]);
}
-bool isCapitalized(string const s)
+bool isCapitalized(string const & s)
{
docstring in = from_ascii(s);
char_type t = uppercase(s[0]);
/// try to convert \p s to a valid InsetCommand argument
/// without trying to recode macros.
-string convert_literate_command_inset_arg(string s)
+string convert_literate_command_inset_arg(string const & s)
{
// LyX cannot handle newlines in a latex command
return subst(s, "\n", " ");
}
-void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, string const prefix,
+void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, string const & prefix,
Context & context, Layout::LaTeXArgMap const & latexargs)
{
if (context.layout->latextype != LATEX_ITEM_ENVIRONMENT || !prefix.empty()) {
}
-void copy_file(FileName const & src, string dstname)
+void copy_file(FileName const & src, string const & dstname)
{
if (!copyFiles())
return;