mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +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;
|
using std::set;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
using support::bformat;
|
using support::bformat;
|
||||||
using support::compare_no_case;
|
using support::compare_no_case;
|
||||||
using support::getVectorFromString;
|
using support::getVectorFromString;
|
||||||
using support::ltrim;
|
using support::ltrim;
|
||||||
using support::rtrim;
|
using support::rtrim;
|
||||||
|
|
||||||
////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// BibTeXInfo
|
// BibTeXInfo
|
||||||
//
|
//
|
||||||
////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BibTeXInfo::BibTeXInfo() : isBibTeX(true)
|
BibTeXInfo::BibTeXInfo()
|
||||||
|
: isBibTeX(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -75,33 +77,30 @@ docstring const & BibTeXInfo::getValueForField(string const & field) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
static docstring familyName(docstring const & name)
|
||||||
docstring const familyName(docstring const & name)
|
{
|
||||||
{
|
if (name.empty())
|
||||||
if (name.empty())
|
return docstring();
|
||||||
return docstring();
|
|
||||||
|
|
||||||
// Very simple parser
|
// Very simple parser
|
||||||
docstring fname = name;
|
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
|
|
||||||
|
|
||||||
|
// 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
|
docstring const BibTeXInfo::getAbbreviatedAuthor() const
|
||||||
@ -117,20 +116,22 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const
|
|||||||
return bibKey;
|
return bibKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
//OK, we've got some names. Let's format them.
|
// OK, we've got some names. Let's format them.
|
||||||
//Try to split the author list on " and "
|
// Try to split the author list on " and "
|
||||||
vector<docstring> const authors =
|
vector<docstring> const authors =
|
||||||
getVectorFromString(author, from_ascii(" and "));
|
getVectorFromString(author, from_ascii(" and "));
|
||||||
|
|
||||||
if (authors.size() == 2)
|
if (authors.size() == 2)
|
||||||
return bformat(_("%1$s and %2$s"),
|
return bformat(_("%1$s and %2$s"),
|
||||||
familyName(authors[0]), familyName(authors[1]));
|
familyName(authors[0]), familyName(authors[1]));
|
||||||
else if (authors.size() > 2)
|
|
||||||
|
if (authors.size() > 2)
|
||||||
return bformat(_("%1$s et al."), familyName(authors[0]));
|
return bformat(_("%1$s et al."), familyName(authors[0]));
|
||||||
else
|
|
||||||
return familyName(authors[0]);
|
return familyName(authors[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring const BibTeXInfo::getYear() const
|
docstring const BibTeXInfo::getYear() const
|
||||||
{
|
{
|
||||||
if (!isBibTeX)
|
if (!isBibTeX)
|
||||||
@ -150,11 +151,11 @@ docstring const BibTeXInfo::getInfo() const
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME
|
// FIXME
|
||||||
//This could be made alot better using the entryType
|
// This could be made a lot better using the entryType
|
||||||
//field to customize the output based upon entry type.
|
// 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");
|
docstring author = getValueForField("author");
|
||||||
if (author.empty())
|
if (author.empty())
|
||||||
author = getValueForField("editor");
|
author = getValueForField("editor");
|
||||||
@ -166,45 +167,47 @@ docstring const BibTeXInfo::getInfo() const
|
|||||||
docLoc = getValueForField("chapter");
|
docLoc = getValueForField("chapter");
|
||||||
if (!docLoc.empty())
|
if (!docLoc.empty())
|
||||||
docLoc = from_ascii("Ch. ") + docLoc;
|
docLoc = from_ascii("Ch. ") + docLoc;
|
||||||
} else
|
} else {
|
||||||
docLoc = from_ascii("pp. ") + docLoc;
|
docLoc = from_ascii("pp. ") + docLoc;
|
||||||
docstring media = getValueForField("journal");
|
}
|
||||||
|
|
||||||
|
docstring media = getValueForField("journal");
|
||||||
|
if (media.empty()) {
|
||||||
|
media = getValueForField("publisher");
|
||||||
if (media.empty()) {
|
if (media.empty()) {
|
||||||
media = getValueForField("publisher");
|
media = getValueForField("school");
|
||||||
if (media.empty()) {
|
if (media.empty())
|
||||||
media = getValueForField("school");
|
media = getValueForField("institution");
|
||||||
if (media.empty())
|
|
||||||
media = getValueForField("institution");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
docstring volume = getValueForField("volume");
|
}
|
||||||
|
docstring volume = getValueForField("volume");
|
||||||
odocstringstream result;
|
|
||||||
if (!author.empty())
|
odocstringstream result;
|
||||||
result << author << ", ";
|
if (!author.empty())
|
||||||
if (!title.empty())
|
result << author << ", ";
|
||||||
result << title;
|
if (!title.empty())
|
||||||
if (!media.empty())
|
result << title;
|
||||||
result << ", " << media;
|
if (!media.empty())
|
||||||
if (!year.empty())
|
result << ", " << media;
|
||||||
result << ", " << year;
|
if (!year.empty())
|
||||||
if (!docLoc.empty())
|
result << ", " << year;
|
||||||
result << ", " << docLoc;
|
if (!docLoc.empty())
|
||||||
|
result << ", " << docLoc;
|
||||||
docstring const result_str = rtrim(result.str());
|
|
||||||
if (!result_str.empty())
|
docstring const result_str = rtrim(result.str());
|
||||||
return 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
|
// BiblioInfo
|
||||||
//
|
//
|
||||||
////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// A functor for use with std::sort, leading to case insensitive sorting
|
// 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());
|
biblio::getCiteStyles(buf.params().getEngine());
|
||||||
|
|
||||||
vector<docstring> vec(styles.size());
|
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;
|
docstring str;
|
||||||
|
|
||||||
switch (styles[i]) {
|
switch (styles[i]) {
|
||||||
@ -430,11 +433,11 @@ void BiblioInfo::fillWithBibKeys(Buffer const * const buf)
|
|||||||
|
|
||||||
namespace biblio {
|
namespace biblio {
|
||||||
|
|
||||||
////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// CitationStyle
|
// CitationStyle
|
||||||
//
|
//
|
||||||
////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -539,7 +542,7 @@ vector<CiteStyle> const getCiteStyles(CiteEngine const engine)
|
|||||||
typedef vector<CiteStyle> cite_vec;
|
typedef vector<CiteStyle> cite_vec;
|
||||||
|
|
||||||
cite_vec styles(nStyles);
|
cite_vec styles(nStyles);
|
||||||
cite_vec::size_type i = 0;
|
size_t i = 0;
|
||||||
int j = start;
|
int j = start;
|
||||||
for (; i != styles.size(); ++i, ++j)
|
for (; i != styles.size(); ++i, ++j)
|
||||||
styles[i] = citeStyles[j];
|
styles[i] = citeStyles[j];
|
||||||
|
@ -157,7 +157,7 @@ namespace fs = boost::filesystem;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int const LYX_FORMAT = 299; //Uwe: Hyperlink types
|
int const LYX_FORMAT = 299; // Uwe: Hyperlink types
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
@ -1770,12 +1770,12 @@ bool Buffer::hasMacro(docstring const & name, Paragraph const & par) const
|
|||||||
{
|
{
|
||||||
Impl::PositionToMacroMap::iterator it;
|
Impl::PositionToMacroMap::iterator it;
|
||||||
it = pimpl_->macros[name].upper_bound(par.macrocontextPosition());
|
it = pimpl_->macros[name].upper_bound(par.macrocontextPosition());
|
||||||
if( it != pimpl_->macros[name].end() )
|
if (it != pimpl_->macros[name].end())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If there is a master buffer, query that
|
// If there is a master buffer, query that
|
||||||
const Buffer *master = masterBuffer();
|
const Buffer * master = masterBuffer();
|
||||||
if (master && master!=this)
|
if (master && master != this)
|
||||||
return master->hasMacro(name);
|
return master->hasMacro(name);
|
||||||
|
|
||||||
return MacroTable::globalMacros().has(name);
|
return MacroTable::globalMacros().has(name);
|
||||||
@ -1788,15 +1788,16 @@ bool Buffer::hasMacro(docstring const & name) const
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If there is a master buffer, query that
|
// If there is a master buffer, query that
|
||||||
const Buffer *master = masterBuffer();
|
const Buffer * master = masterBuffer();
|
||||||
if (master && master!=this)
|
if (master && master != this)
|
||||||
return master->hasMacro(name);
|
return master->hasMacro(name);
|
||||||
|
|
||||||
return MacroTable::globalMacros().has(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;
|
Impl::PositionToMacroMap::iterator it;
|
||||||
it = pimpl_->macros[name].upper_bound(par.macrocontextPosition());
|
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;
|
return it->second;
|
||||||
|
|
||||||
// If there is a master buffer, query that
|
// If there is a master buffer, query that
|
||||||
const Buffer *master = masterBuffer();
|
const Buffer * master = masterBuffer();
|
||||||
if (master && master!=this)
|
if (master && master != this)
|
||||||
return master->getMacro(name);
|
return master->getMacro(name);
|
||||||
|
|
||||||
return MacroTable::globalMacros().get(name);
|
return MacroTable::globalMacros().get(name);
|
||||||
@ -1820,8 +1821,8 @@ MacroData const & Buffer::getMacro(docstring const & name) const
|
|||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
// If there is a master buffer, query that
|
// If there is a master buffer, query that
|
||||||
const Buffer *master = masterBuffer();
|
const Buffer * master = masterBuffer();
|
||||||
if (master && master!=this)
|
if (master && master != this)
|
||||||
return master->getMacro(name);
|
return master->getMacro(name);
|
||||||
|
|
||||||
return MacroTable::globalMacros().get(name);
|
return MacroTable::globalMacros().get(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user