mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
cosmetics as hinted by uncrustify
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21450 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cd95a4bae8
commit
5216137bdb
@ -37,19 +37,21 @@ using std::endl;
|
||||
using std::set;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::bformat;
|
||||
using support::compare_no_case;
|
||||
using support::getVectorFromString;
|
||||
using support::ltrim;
|
||||
using support::rtrim;
|
||||
|
||||
////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BibTeXInfo
|
||||
//
|
||||
////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
BibTeXInfo::BibTeXInfo() : isBibTeX(true)
|
||||
BibTeXInfo::BibTeXInfo()
|
||||
: isBibTeX(true)
|
||||
{}
|
||||
|
||||
|
||||
@ -75,33 +77,30 @@ docstring const & BibTeXInfo::getValueForField(string const & field) const
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
docstring const familyName(docstring const & name)
|
||||
{
|
||||
if (name.empty())
|
||||
return docstring();
|
||||
static docstring familyName(docstring const & name)
|
||||
{
|
||||
if (name.empty())
|
||||
return docstring();
|
||||
|
||||
// Very simple parser
|
||||
docstring fname = name;
|
||||
|
||||
// possible authorname combinations are:
|
||||
// "Surname, FirstName"
|
||||
// "Surname, F."
|
||||
// "FirstName Surname"
|
||||
// "F. Surname"
|
||||
docstring::size_type idx = fname.find(',');
|
||||
if (idx != docstring::npos)
|
||||
return ltrim(fname.substr(0, idx));
|
||||
idx = fname.rfind('.');
|
||||
if (idx != docstring::npos && idx + 1 < fname.size())
|
||||
fname = ltrim(fname.substr(idx + 1));
|
||||
// test if we have a LaTeX Space in front
|
||||
if (fname[0] == '\\')
|
||||
return fname.substr(2);
|
||||
return rtrim(fname);
|
||||
}
|
||||
} // namespace anon
|
||||
// Very simple parser
|
||||
docstring fname = name;
|
||||
|
||||
// possible authorname combinations are:
|
||||
// "Surname, FirstName"
|
||||
// "Surname, F."
|
||||
// "FirstName Surname"
|
||||
// "F. Surname"
|
||||
docstring::size_type idx = fname.find(',');
|
||||
if (idx != docstring::npos)
|
||||
return ltrim(fname.substr(0, idx));
|
||||
idx = fname.rfind('.');
|
||||
if (idx != docstring::npos && idx + 1 < fname.size())
|
||||
fname = ltrim(fname.substr(idx + 1));
|
||||
// test if we have a LaTeX Space in front
|
||||
if (fname[0] == '\\')
|
||||
return fname.substr(2);
|
||||
return rtrim(fname);
|
||||
}
|
||||
|
||||
|
||||
docstring const BibTeXInfo::getAbbreviatedAuthor() const
|
||||
@ -117,20 +116,22 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const
|
||||
return bibKey;
|
||||
}
|
||||
|
||||
//OK, we've got some names. Let's format them.
|
||||
//Try to split the author list on " and "
|
||||
// OK, we've got some names. Let's format them.
|
||||
// Try to split the author list on " and "
|
||||
vector<docstring> const authors =
|
||||
getVectorFromString(author, from_ascii(" and "));
|
||||
|
||||
if (authors.size() == 2)
|
||||
return bformat(_("%1$s and %2$s"),
|
||||
familyName(authors[0]), familyName(authors[1]));
|
||||
else if (authors.size() > 2)
|
||||
|
||||
if (authors.size() > 2)
|
||||
return bformat(_("%1$s et al."), familyName(authors[0]));
|
||||
else
|
||||
return familyName(authors[0]);
|
||||
|
||||
return familyName(authors[0]);
|
||||
}
|
||||
|
||||
|
||||
docstring const BibTeXInfo::getYear() const
|
||||
{
|
||||
if (!isBibTeX)
|
||||
@ -150,11 +151,11 @@ docstring const BibTeXInfo::getInfo() const
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//FIXME
|
||||
//This could be made alot better using the entryType
|
||||
//field to customize the output based upon entry type.
|
||||
// FIXME
|
||||
// This could be made a lot better using the entryType
|
||||
// field to customize the output based upon entry type.
|
||||
|
||||
//Search for all possible "required" fields
|
||||
// Search for all possible "required" fields
|
||||
docstring author = getValueForField("author");
|
||||
if (author.empty())
|
||||
author = getValueForField("editor");
|
||||
@ -166,45 +167,47 @@ docstring const BibTeXInfo::getInfo() const
|
||||
docLoc = getValueForField("chapter");
|
||||
if (!docLoc.empty())
|
||||
docLoc = from_ascii("Ch. ") + docLoc;
|
||||
} else
|
||||
} else {
|
||||
docLoc = from_ascii("pp. ") + docLoc;
|
||||
docstring media = getValueForField("journal");
|
||||
}
|
||||
|
||||
docstring media = getValueForField("journal");
|
||||
if (media.empty()) {
|
||||
media = getValueForField("publisher");
|
||||
if (media.empty()) {
|
||||
media = getValueForField("publisher");
|
||||
if (media.empty()) {
|
||||
media = getValueForField("school");
|
||||
if (media.empty())
|
||||
media = getValueForField("institution");
|
||||
}
|
||||
media = getValueForField("school");
|
||||
if (media.empty())
|
||||
media = getValueForField("institution");
|
||||
}
|
||||
docstring volume = getValueForField("volume");
|
||||
}
|
||||
docstring volume = getValueForField("volume");
|
||||
|
||||
odocstringstream result;
|
||||
if (!author.empty())
|
||||
result << author << ", ";
|
||||
if (!title.empty())
|
||||
result << title;
|
||||
if (!media.empty())
|
||||
result << ", " << media;
|
||||
if (!year.empty())
|
||||
result << ", " << year;
|
||||
if (!docLoc.empty())
|
||||
result << ", " << docLoc;
|
||||
odocstringstream result;
|
||||
if (!author.empty())
|
||||
result << author << ", ";
|
||||
if (!title.empty())
|
||||
result << title;
|
||||
if (!media.empty())
|
||||
result << ", " << media;
|
||||
if (!year.empty())
|
||||
result << ", " << year;
|
||||
if (!docLoc.empty())
|
||||
result << ", " << docLoc;
|
||||
|
||||
docstring const result_str = rtrim(result.str());
|
||||
if (!result_str.empty())
|
||||
return result_str;
|
||||
docstring const result_str = rtrim(result.str());
|
||||
if (!result_str.empty())
|
||||
return result_str;
|
||||
|
||||
// This should never happen (or at least be very unusual!)
|
||||
return docstring();
|
||||
// This should never happen (or at least be very unusual!)
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BiblioInfo
|
||||
//
|
||||
////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace {
|
||||
// A functor for use with std::sort, leading to case insensitive sorting
|
||||
@ -309,7 +312,7 @@ vector<docstring> const BiblioInfo::getNumericalStrings(
|
||||
biblio::getCiteStyles(buf.params().getEngine());
|
||||
|
||||
vector<docstring> vec(styles.size());
|
||||
for (vector<docstring>::size_type i = 0; i != vec.size(); ++i) {
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
docstring str;
|
||||
|
||||
switch (styles[i]) {
|
||||
@ -430,11 +433,11 @@ void BiblioInfo::fillWithBibKeys(Buffer const * const buf)
|
||||
|
||||
namespace biblio {
|
||||
|
||||
////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CitationStyle
|
||||
//
|
||||
////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace {
|
||||
|
||||
@ -539,7 +542,7 @@ vector<CiteStyle> const getCiteStyles(CiteEngine const engine)
|
||||
typedef vector<CiteStyle> cite_vec;
|
||||
|
||||
cite_vec styles(nStyles);
|
||||
cite_vec::size_type i = 0;
|
||||
size_t i = 0;
|
||||
int j = start;
|
||||
for (; i != styles.size(); ++i, ++j)
|
||||
styles[i] = citeStyles[j];
|
||||
|
@ -157,7 +157,7 @@ namespace fs = boost::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 299; //Uwe: Hyperlink types
|
||||
int const LYX_FORMAT = 299; // Uwe: Hyperlink types
|
||||
|
||||
} // namespace anon
|
||||
|
||||
@ -1770,12 +1770,12 @@ bool Buffer::hasMacro(docstring const & name, Paragraph const & par) const
|
||||
{
|
||||
Impl::PositionToMacroMap::iterator it;
|
||||
it = pimpl_->macros[name].upper_bound(par.macrocontextPosition());
|
||||
if( it != pimpl_->macros[name].end() )
|
||||
if (it != pimpl_->macros[name].end())
|
||||
return true;
|
||||
|
||||
// If there is a master buffer, query that
|
||||
const Buffer *master = masterBuffer();
|
||||
if (master && master!=this)
|
||||
const Buffer * master = masterBuffer();
|
||||
if (master && master != this)
|
||||
return master->hasMacro(name);
|
||||
|
||||
return MacroTable::globalMacros().has(name);
|
||||
@ -1788,15 +1788,16 @@ bool Buffer::hasMacro(docstring const & name) const
|
||||
return true;
|
||||
|
||||
// If there is a master buffer, query that
|
||||
const Buffer *master = masterBuffer();
|
||||
if (master && master!=this)
|
||||
const Buffer * master = masterBuffer();
|
||||
if (master && master != this)
|
||||
return master->hasMacro(name);
|
||||
|
||||
return MacroTable::globalMacros().has(name);
|
||||
}
|
||||
|
||||
|
||||
MacroData const & Buffer::getMacro(docstring const & name, Paragraph const & par) const
|
||||
MacroData const & Buffer::getMacro(docstring const & name,
|
||||
Paragraph const & par) const
|
||||
{
|
||||
Impl::PositionToMacroMap::iterator it;
|
||||
it = pimpl_->macros[name].upper_bound(par.macrocontextPosition());
|
||||
@ -1804,8 +1805,8 @@ MacroData const & Buffer::getMacro(docstring const & name, Paragraph const & par
|
||||
return it->second;
|
||||
|
||||
// If there is a master buffer, query that
|
||||
const Buffer *master = masterBuffer();
|
||||
if (master && master!=this)
|
||||
const Buffer * master = masterBuffer();
|
||||
if (master && master != this)
|
||||
return master->getMacro(name);
|
||||
|
||||
return MacroTable::globalMacros().get(name);
|
||||
@ -1820,8 +1821,8 @@ MacroData const & Buffer::getMacro(docstring const & name) const
|
||||
return it->second;
|
||||
|
||||
// If there is a master buffer, query that
|
||||
const Buffer *master = masterBuffer();
|
||||
if (master && master!=this)
|
||||
const Buffer * master = masterBuffer();
|
||||
if (master && master != this)
|
||||
return master->getMacro(name);
|
||||
|
||||
return MacroTable::globalMacros().get(name);
|
||||
|
Loading…
Reference in New Issue
Block a user