From 6b2232a29c682d8e62d1d2b963bb1a70bee4330b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sat, 27 Oct 2012 15:45:27 +0200 Subject: [PATCH] src/*.cpp: reformatting to increase consistency --- src/AppleSpellChecker.cpp | 6 +- src/AspellChecker.cpp | 32 ++-- src/Author.cpp | 13 +- src/BiblioInfo.cpp | 233 ++++++++++++++-------------- src/Bidi.cpp | 1 + src/BranchList.cpp | 5 +- src/Buffer.cpp | 16 +- src/BufferList.cpp | 2 + src/BufferParams.cpp | 5 +- src/BufferView.cpp | 1 + src/Changes.cpp | 2 + src/Chktex.cpp | 3 +- src/CmdDef.cpp | 2 +- src/Color.cpp | 1 + src/Compare.cpp | 28 +++- src/ConverterCache.cpp | 6 +- src/CoordCache.cpp | 1 + src/Counters.cpp | 2 +- src/Cursor.cpp | 314 ++++++++++++++++++++++---------------- src/CutAndPaste.cpp | 1 + src/DepTable.cpp | 6 +- src/DocIterator.cpp | 1 + src/EnchantChecker.cpp | 12 +- src/Encoding.cpp | 3 +- src/FontInfo.cpp | 192 +++++++++++------------ src/Format.cpp | 15 +- src/FuncStatus.cpp | 3 +- src/HSpace.cpp | 1 + src/HunspellChecker.cpp | 34 ++--- src/IndicesList.cpp | 8 +- src/LaTeXFeatures.cpp | 2 + src/Layout.cpp | 19 ++- src/LayoutFile.cpp | 11 +- src/LyX.cpp | 10 +- src/ModuleList.cpp | 10 +- src/Paragraph.cpp | 32 ++-- src/ParagraphMetrics.cpp | 3 +- src/PersonalWordList.cpp | 1 + src/Server.cpp | 8 +- src/ServerSocket.cpp | 1 - src/Session.cpp | 1 - src/Text.cpp | 1 + src/TextClass.cpp | 92 +++++------ src/Thesaurus.cpp | 9 +- src/VCBackend.cpp | 1 + src/VSpace.cpp | 1 + src/WordList.cpp | 3 +- src/factory.cpp | 15 +- src/lengthcommon.cpp | 2 + src/lyxfind.cpp | 25 ++- src/output_docbook.cpp | 49 +++--- src/output_latex.cpp | 6 +- src/output_plaintext.cpp | 1 + src/output_xhtml.cpp | 17 ++- src/rowpainter.cpp | 2 + 55 files changed, 719 insertions(+), 552 deletions(-) diff --git a/src/AppleSpellChecker.cpp b/src/AppleSpellChecker.cpp index cb80a60bd1..189ada71cf 100644 --- a/src/AppleSpellChecker.cpp +++ b/src/AppleSpellChecker.cpp @@ -55,9 +55,9 @@ AppleSpellChecker::Private::~Private() } -AppleSpellChecker::AppleSpellChecker(): d(new Private) -{ -} +AppleSpellChecker::AppleSpellChecker() + : d(new Private) +{} AppleSpellChecker::~AppleSpellChecker() diff --git a/src/AspellChecker.cpp b/src/AspellChecker.cpp index a03dc65759..5829612270 100644 --- a/src/AspellChecker.cpp +++ b/src/AspellChecker.cpp @@ -53,7 +53,8 @@ typedef map LangPersonalWordList; struct AspellChecker::Private { - Private() {} + Private() + {} ~Private(); @@ -91,27 +92,38 @@ struct AspellChecker::Private /// the location below system/user directory /// there the rws files lookup will happen - const string dictDirectory(void) { return "dicts"; } + const string dictDirectory(void) + { + return "dicts"; + } /// there the dat+cmap files lookup will happen - const string dataDirectory(void) { return "data"; } + const string dataDirectory(void) + { + return "data"; + } /// os package directory constants /// macports on Mac OS X or /// aspell rpms on Linux - const string osPackageBase(void) { + const string osPackageBase(void) + { #ifdef USE_MACOSX_PACKAGING return "/opt/local"; #else return "/usr"; #endif } - const string osPackageDictDirectory(void) { + const string osPackageDictDirectory(void) + { #ifdef USE_MACOSX_PACKAGING return "/share/aspell"; #else return "/lib/aspell-0.60"; #endif } - const string osPackageDataDirectory(void) { return "/lib/aspell-0.60"; } + const string osPackageDataDirectory(void) + { + return "/lib/aspell-0.60"; + } }; @@ -404,9 +416,9 @@ bool AspellChecker::Private::learned(WordLangTuple const & word) } -AspellChecker::AspellChecker(): d(new Private) -{ -} +AspellChecker::AspellChecker() + : d(new Private) +{} AspellChecker::~AspellChecker() @@ -483,12 +495,14 @@ void AspellChecker::suggest(WordLangTuple const & wl, delete_aspell_string_enumeration(els); } + void AspellChecker::remove(WordLangTuple const & word) { d->remove(word); advanceChangeNumber(); } + bool AspellChecker::hasDictionary(Language const * lang) const { bool have = false; diff --git a/src/Author.cpp b/src/Author.cpp index 12f7137a5f..f4658e6126 100644 --- a/src/Author.cpp +++ b/src/Author.cpp @@ -57,6 +57,7 @@ ostream & operator<<(ostream & os, Author const & a) return os; } + istream & operator>>(istream & is, Author & a) { string s; @@ -69,15 +70,15 @@ istream & operator>>(istream & is, Author & a) } -bool author_smaller(Author const & lhs, Author const & rhs) { +bool author_smaller(Author const & lhs, Author const & rhs) +{ return lhs.bufferId() < rhs.bufferId(); } AuthorList::AuthorList() : last_id_(0) -{ -} +{} int AuthorList::record(Author const & a) @@ -133,12 +134,14 @@ AuthorList::Authors::const_iterator AuthorList::end() const } -void AuthorList::sort() { +void AuthorList::sort() +{ std::sort(authors_.begin(), authors_.end(), author_smaller); } -ostream & operator<<(ostream & os, AuthorList const & a) { +ostream & operator<<(ostream & os, AuthorList const & a) +{ // Copy the authorlist, because we don't want to sort the original AuthorList sorted = a; sorted.sort(); diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 93094f8bfa..7142f7b7e7 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -89,6 +89,7 @@ docstring familyName(docstring const & name) return retval; } + // converts a string containing LaTeX commands into unicode // for display. docstring convertLaTeXCommands(docstring const & str) @@ -288,115 +289,117 @@ docstring const BibTeXInfo::getXRef() const namespace { - string parseOptions(string const & format, string & optkey, - string & ifpart, string & elsepart); - - // Calls parseOptions to deal with an embedded option, such as: - // {%number%[[, no.~%number%]]} - // which must appear at the start of format. ifelsepart gets the - // whole of the option, and we return what's left after the option. - // we return format if there is an error. - string parseEmbeddedOption(string const & format, string & ifelsepart) - { - LASSERT(format[0] == '{' && format[1] == '%', return format); - string optkey; - string ifpart; - string elsepart; - string const rest = parseOptions(format, optkey, ifpart, elsepart); - if (format == rest) { // parse error - LYXERR0("ERROR! Couldn't parse `" << format <<"'."); - return format; - } - LASSERT(rest.size() <= format.size(), /* */); - ifelsepart = format.substr(0, format.size() - rest.size()); - return rest; + +string parseOptions(string const & format, string & optkey, + string & ifpart, string & elsepart); + +// Calls parseOptions to deal with an embedded option, such as: +// {%number%[[, no.~%number%]]} +// which must appear at the start of format. ifelsepart gets the +// whole of the option, and we return what's left after the option. +// we return format if there is an error. +string parseEmbeddedOption(string const & format, string & ifelsepart) +{ + LASSERT(format[0] == '{' && format[1] == '%', return format); + string optkey; + string ifpart; + string elsepart; + string const rest = parseOptions(format, optkey, ifpart, elsepart); + if (format == rest) { // parse error + LYXERR0("ERROR! Couldn't parse `" << format <<"'."); + return format; } + LASSERT(rest.size() <= format.size(), /* */); + ifelsepart = format.substr(0, format.size() - rest.size()); + return rest; +} - // Gets a "clause" from a format string, where the clause is - // delimited by '[[' and ']]'. Returns what is left after the - // clause is removed, and returns format if there is an error. - string getClause(string const & format, string & clause) - { - string fmt = format; - // remove '[[' - fmt = fmt.substr(2); - // we'll remove characters from the front of fmt as we - // deal with them - while (!fmt.empty()) { - if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') { - // that's the end - fmt = fmt.substr(2); - break; +// Gets a "clause" from a format string, where the clause is +// delimited by '[[' and ']]'. Returns what is left after the +// clause is removed, and returns format if there is an error. +string getClause(string const & format, string & clause) +{ + string fmt = format; + // remove '[[' + fmt = fmt.substr(2); + // we'll remove characters from the front of fmt as we + // deal with them + while (!fmt.empty()) { + if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') { + // that's the end + fmt = fmt.substr(2); + break; + } + // check for an embedded option + if (fmt[0] == '{' && fmt.size() > 1 && fmt[1] == '%') { + string part; + string const rest = parseEmbeddedOption(fmt, part); + if (fmt == rest) { + LYXERR0("ERROR! Couldn't parse embedded option in `" << format <<"'."); + return format; } - // check for an embedded option - if (fmt[0] == '{' && fmt.size() > 1 && fmt[1] == '%') { - string part; - string const rest = parseEmbeddedOption(fmt, part); - if (fmt == rest) { - LYXERR0("ERROR! Couldn't parse embedded option in `" << format <<"'."); - return format; - } - clause += part; - fmt = rest; - } else { // it's just a normal character + clause += part; + fmt = rest; + } else { // it's just a normal character clause += fmt[0]; fmt = fmt.substr(1); - } } - return fmt; } + return fmt; +} - // parse an options string, which must appear at the start of the - // format parameter. puts the parsed bits in optkey, ifpart, and - // elsepart and returns what's left after the option is removed. - // if there's an error, it returns format itself. - string parseOptions(string const & format, string & optkey, - string & ifpart, string & elsepart) - { - LASSERT(format[0] == '{' && format[1] == '%', return format); - // strip '{%' - string fmt = format.substr(2); - size_t pos = fmt.find('%'); // end of key - if (pos == string::npos) { - LYXERR0("Error parsing `" << format <<"'. Can't find end of key."); - return format; - } - optkey = fmt.substr(0,pos); - fmt = fmt.substr(pos + 1); - // [[format]] should be next - if (fmt[0] != '[' || fmt[1] != '[') { - LYXERR0("Error parsing `" << format <<"'. Can't find '[[' after key."); - return format; - } +// parse an options string, which must appear at the start of the +// format parameter. puts the parsed bits in optkey, ifpart, and +// elsepart and returns what's left after the option is removed. +// if there's an error, it returns format itself. +string parseOptions(string const & format, string & optkey, + string & ifpart, string & elsepart) +{ + LASSERT(format[0] == '{' && format[1] == '%', return format); + // strip '{%' + string fmt = format.substr(2); + size_t pos = fmt.find('%'); // end of key + if (pos == string::npos) { + LYXERR0("Error parsing `" << format <<"'. Can't find end of key."); + return format; + } + optkey = fmt.substr(0,pos); + fmt = fmt.substr(pos + 1); + // [[format]] should be next + if (fmt[0] != '[' || fmt[1] != '[') { + LYXERR0("Error parsing `" << format <<"'. Can't find '[[' after key."); + return format; + } - string curfmt = fmt; - fmt = getClause(curfmt, ifpart); - if (fmt == curfmt) { - LYXERR0("Error parsing `" << format <<"'. Couldn't get if clause."); - return format; - } + string curfmt = fmt; + fmt = getClause(curfmt, ifpart); + if (fmt == curfmt) { + LYXERR0("Error parsing `" << format <<"'. Couldn't get if clause."); + return format; + } - if (fmt[0] == '}') // we're done, no else clause - return fmt.substr(1); + if (fmt[0] == '}') // we're done, no else clause + return fmt.substr(1); - // else part should follow - if (fmt[0] != '[' || fmt[1] != '[') { - LYXERR0("Error parsing `" << format <<"'. Can't find else clause."); - return format; - } + // else part should follow + if (fmt[0] != '[' || fmt[1] != '[') { + LYXERR0("Error parsing `" << format <<"'. Can't find else clause."); + return format; + } - curfmt = fmt; - fmt = getClause(curfmt, elsepart); - // we should be done - if (fmt == curfmt || fmt[0] != '}') { - LYXERR0("Error parsing `" << format <<"'. Can't find end of option."); - return format; - } - return fmt.substr(1); + curfmt = fmt; + fmt = getClause(curfmt, elsepart); + // we should be done + if (fmt == curfmt || fmt[0] != '}') { + LYXERR0("Error parsing `" << format <<"'. Can't find end of option."); + return format; + } + return fmt.substr(1); } + } // anon namespace @@ -650,14 +653,16 @@ docstring BibTeXInfo::getValueForKey(string const & key, ////////////////////////////////////////////////////////////////////// namespace { + // A functor for use with sort, leading to case insensitive sorting - class compareNoCase: public binary_function - { - public: - bool operator()(docstring const & s1, docstring const & s2) const { - return compare_no_case(s1, s2) < 0; - } - }; +class compareNoCase: public binary_function +{ +public: + bool operator()(docstring const & s1, docstring const & s2) const { + return compare_no_case(s1, s2) < 0; + } +}; + } // namespace anon @@ -827,19 +832,21 @@ void BiblioInfo::mergeBiblioInfo(BiblioInfo const & info) namespace { - // used in xhtml to sort a list of BibTeXInfo objects - bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs) - { - docstring const lauth = lhs->getAbbreviatedAuthor(); - docstring const rauth = rhs->getAbbreviatedAuthor(); - docstring const lyear = lhs->getYear(); - docstring const ryear = rhs->getYear(); - docstring const ltitl = lhs->operator[]("title"); - docstring const rtitl = rhs->operator[]("title"); - return (lauth < rauth) - || (lauth == rauth && lyear < ryear) - || (lauth == rauth && lyear == ryear && ltitl < rtitl); - } + +// used in xhtml to sort a list of BibTeXInfo objects +bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs) +{ + docstring const lauth = lhs->getAbbreviatedAuthor(); + docstring const rauth = rhs->getAbbreviatedAuthor(); + docstring const lyear = lhs->getYear(); + docstring const ryear = rhs->getYear(); + docstring const ltitl = lhs->operator[]("title"); + docstring const rtitl = rhs->operator[]("title"); + return (lauth < rauth) + || (lauth == rauth && lyear < ryear) + || (lauth == rauth && lyear == ryear && ltitl < rtitl); +} + } diff --git a/src/Bidi.cpp b/src/Bidi.cpp index b9d1222931..a85f3eaddd 100644 --- a/src/Bidi.cpp +++ b/src/Bidi.cpp @@ -46,6 +46,7 @@ bool Bidi::inRange(pos_type pos) const return start_ == -1 || (start_ <= pos && pos <= end_); } + bool Bidi::same_direction() const { return same_direction_; diff --git a/src/BranchList.cpp b/src/BranchList.cpp index 7cb23ef5b4..4624f19f4d 100644 --- a/src/BranchList.cpp +++ b/src/BranchList.cpp @@ -30,7 +30,9 @@ namespace { class BranchNamesEqual : public std::unary_function { public: - BranchNamesEqual(docstring const & name) : name_(name) {} + BranchNamesEqual(docstring const & name) + : name_(name) + {} bool operator()(Branch const & branch) const { @@ -39,6 +41,7 @@ public: private: docstring name_; }; + } diff --git a/src/Buffer.cpp b/src/Buffer.cpp index a045deadc9..c5de4c8169 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -282,7 +282,8 @@ public: /// This is here to force the test to be done whenever parent_buffer /// is accessed. - Buffer const * parent() const { + Buffer const * parent() const + { // ignore_parent temporarily "orphans" a buffer // (e.g. if a child is compiled standalone) if (ignore_parent) @@ -299,7 +300,8 @@ public: } /// - void setParent(Buffer const * pb) { + void setParent(Buffer const * pb) + { if (parent_buffer == pb) // nothing to do return; @@ -324,10 +326,14 @@ public: /// \p from initial position /// \p to points to the end position void updateStatistics(DocIterator & from, DocIterator & to, - bool skipNoOutput = true); + bool skipNoOutput = true); /// statistics accessor functions - int wordCount() const { return word_count_; } - int charCount(bool with_blanks) const { + int wordCount() const + { + return word_count_; + } + int charCount(bool with_blanks) const + { return char_count_ + (with_blanks ? blank_count_ : 0); } diff --git a/src/BufferList.cpp b/src/BufferList.cpp index f756384bf4..2348ac6103 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -265,11 +265,13 @@ bool BufferList::exists(FileName const & fname) const namespace { + struct equivalent_to : public binary_function { bool operator()(FileName const & x, FileName const & y) const { return equivalent(x, y); } }; + } diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index e3dcb87986..403a2cbbe1 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2127,9 +2127,12 @@ bool BufferParams::isExportable(string const & format) const namespace { -bool formatSorter(Format const * lhs, Format const * rhs) { + +bool formatSorter(Format const * lhs, Format const * rhs) +{ return _(lhs->prettyname()) < _(rhs->prettyname()); } + } diff --git a/src/BufferView.cpp b/src/BufferView.cpp index bb5ed50387..31c95cf764 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -105,6 +105,7 @@ T * getInsetByCode(Cursor const & cur, InsetCode code) return 0; } + /// Note that comparing contents can only be used for InsetCommand bool findNextInset(DocIterator & dit, vector const & codes, docstring const & contents) diff --git a/src/Changes.cpp b/src/Changes.cpp index ea7c5c998e..766b698a3a 100644 --- a/src/Changes.cpp +++ b/src/Changes.cpp @@ -340,6 +340,7 @@ void Changes::merge() namespace { + docstring getLaTeXMarkup(docstring const & macro, docstring const & author, docstring const & chgTime, OutputParams const & runparams) @@ -379,6 +380,7 @@ docstring getLaTeXMarkup(docstring const & macro, docstring const & author, return ods.str(); } + } //namespace anon diff --git a/src/Chktex.cpp b/src/Chktex.cpp index 8ca70d80be..02271e308c 100644 --- a/src/Chktex.cpp +++ b/src/Chktex.cpp @@ -31,8 +31,7 @@ namespace lyx { Chktex::Chktex(string const & chktex, string const & f, string const & p) : cmd(chktex), file(f), path(p) -{ -} +{} int Chktex::run(TeXErrors &terr) diff --git a/src/CmdDef.cpp b/src/CmdDef.cpp index 1a9f42f480..779ac8270a 100644 --- a/src/CmdDef.cpp +++ b/src/CmdDef.cpp @@ -152,7 +152,7 @@ void CmdDef::release(string const & name) CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name, - string const & def) + string const & def) { string const name2 = trim(name); diff --git a/src/Color.cpp b/src/Color.cpp index 290c50a0b2..609c742e73 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -85,6 +85,7 @@ RGBColor rgbFromHexName(string const & x11hexname) return c; } + string const outputLaTeXColor(RGBColor const & color) { // this routine returns a LaTeX readable color string in the form diff --git a/src/Compare.cpp b/src/Compare.cpp index cd54e43bb4..5831f22111 100644 --- a/src/Compare.cpp +++ b/src/Compare.cpp @@ -97,13 +97,15 @@ size_t DocRange::length() const class DocPair { public: - DocPair() {} + DocPair() + {} DocPair(DocIterator o_, DocIterator n_) : o(o_), n(n_) {} - bool operator!=(DocPair const & rhs) { + bool operator!=(DocPair const & rhs) + { // this might not be intuitive but correct for our purpose return o != rhs.o && n != rhs.n; } @@ -146,10 +148,16 @@ public: {} /// Returns the from pair - DocPair from() const { return DocPair(o.from, n.from); } + DocPair from() const + { + return DocPair(o.from, n.from); + } /// Returns the to pair - DocPair to() const { return DocPair(o.to, n.to); } + DocPair to() const + { + return DocPair(o.to, n.to); + } DocRange o; DocRange n; @@ -181,7 +189,8 @@ static DocRangePair stepIntoInset(DocPair const & inset_location) template class compl_vector { public: - compl_vector() {} + compl_vector() + {} void reset(T const & def) { @@ -223,7 +232,8 @@ public: {} /// - ~Impl() {} + ~Impl() + {} // Algorithm to find the shortest edit string. This algorithm // only needs a linear amount of memory (linear with the sum @@ -235,7 +245,8 @@ public: bool abort_; /// - QString status() { + QString status() + { QString status; status += toqstr("recursion level:") + " " + QString::number(recursion_level_) + " " + toqstr("differences:") + " " + QString::number(D_); @@ -444,7 +455,8 @@ static bool equal(Inset const * i_o, Inset const * i_n) } -static bool equal(DocIterator & o, DocIterator & n) { +static bool equal(DocIterator & o, DocIterator & n) +{ // Explicitly check for this, so we won't call // Paragraph::getChar for the last pos. bool const o_lastpos = o.pos() == o.lastpos(); diff --git a/src/ConverterCache.cpp b/src/ConverterCache.cpp index 76721835e6..61df9d062d 100644 --- a/src/ConverterCache.cpp +++ b/src/ConverterCache.cpp @@ -54,7 +54,8 @@ static FileName cache_dir; class CacheItem { public: - CacheItem() {} + CacheItem() + {} CacheItem(FileName const & orig_from, string const & to_format, time_t t, unsigned long c) : timestamp(t), checksum(c) @@ -67,7 +68,8 @@ public: << ' ' << to_format << ' ' << cache_name << ' ' << long(timestamp) << ' ' << checksum << '.'); } - ~CacheItem() {} + ~CacheItem() + {} FileName cache_name; time_t timestamp; unsigned long checksum; diff --git a/src/CoordCache.cpp b/src/CoordCache.cpp index 4c9e880092..6926dab322 100644 --- a/src/CoordCache.cpp +++ b/src/CoordCache.cpp @@ -32,6 +32,7 @@ Point::Point(int x, int y) LASSERT(y < 1000000, /**/); } + // just a helper to be able to set a breakpoint void lyxbreaker(void const * data, const char * hint, int size) { diff --git a/src/Counters.cpp b/src/Counters.cpp index 1349c3dcbe..21331e8e18 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -109,6 +109,7 @@ bool Counter::read(Lexer & lex) return getout; } + void Counter::set(int v) { value_ = v; @@ -363,7 +364,6 @@ char hebrewCounter(int const n) } - // On the special cases, see http://mathworld.wolfram.com/RomanNumerals.html // and for a list of roman numerals up to and including 3999, see // http://www.research.att.com/~njas/sequences/a006968.txt. (Thanks to Joost diff --git a/src/Cursor.cpp b/src/Cursor.cpp index e38ca5ec13..8afbdf3cb4 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -214,9 +214,10 @@ bool bruteFind3(Cursor & cur, int x, int y, bool up) for ( ; it != et; it.forwardPos()) { // avoid invalid nesting when selecting if (bv.cursorStatus(it) == CUR_INSIDE - && (!cur.selection() || positionable(it, cur.realAnchor()))) { - // If this function is ever used again, check whether this - // is the same as "bv.getPos(it, false)" with boundary = false. + && (!cur.selection() || positionable(it, cur.realAnchor()))) { + // If this function is ever used again, check + // whether this is the same as "bv.getPos(it, + // false)" with boundary = false. Point p = bv.getPos(it); int xo = p.x_; int yo = p.y_; @@ -638,8 +639,9 @@ bool Cursor::posVisRight(bool skip_inset) new_cur.boundary(false); if (!skip_inset && text()->checkAndActivateInsetVisual(new_cur, right_pos >= pos(), false)) { - // we actually move the cursor at the end of this function, for now - // we just keep track of the new position in new_cur... + // we actually move the cursor at the end of this + // function, for now we just keep track of the new + // position in new_cur... LYXERR(Debug::RTL, "entering inset at: " << new_cur.pos()); } @@ -652,8 +654,9 @@ bool Cursor::posVisRight(bool skip_inset) return false; } - // we actually move the cursor at the end of this function, for now - // just keep track of the new position in new_cur... + // we actually move the cursor at the end of this + // function, for now just keep track of the new + // position in new_cur... LYXERR(Debug::RTL, "right edge, moving: " << int(new_cur.pit()) << "," << int(new_cur.pos()) << "," << (new_cur.boundary() ? 1 : 0)); @@ -661,28 +664,33 @@ bool Cursor::posVisRight(bool skip_inset) // normal movement to the right else { new_cur = *this; - // Recall, if the cursor is at position 'x', that means *before* - // the character at position 'x'. In RTL, "before" means "to the - // right of", in LTR, "to the left of". So currently our situation - // is this: the position to our right is 'right_pos' (i.e., we're - // currently to the left of 'right_pos'). In order to move to the - // right, it depends whether or not the character at 'right_pos' is RTL. + // Recall, if the cursor is at position 'x', that + // means *before* the character at position 'x'. In + // RTL, "before" means "to the right of", in LTR, "to + // the left of". So currently our situation is this: + // the position to our right is 'right_pos' (i.e., + // we're currently to the left of 'right_pos'). In + // order to move to the right, it depends whether or + // not the character at 'right_pos' is RTL. new_pos_is_RTL = paragraph().getFontSettings( buffer()->params(), right_pos).isVisibleRightToLeft(); - // If the character at 'right_pos' *is* LTR, then in order to move to - // the right of it, we need to be *after* 'right_pos', i.e., move to - // position 'right_pos' + 1. + // If the character at 'right_pos' *is* LTR, then in + // order to move to the right of it, we need to be + // *after* 'right_pos', i.e., move to position + // 'right_pos' + 1. if (!new_pos_is_RTL) { new_cur.pos() = right_pos + 1; // set the boundary to true in two situations: if ( - // 1. if new_pos is now lastpos, and we're in an RTL paragraph - // (this means that we're moving right to the end of an LTR chunk + // 1. if new_pos is now lastpos, and we're in + // an RTL paragraph (this means that we're + // moving right to the end of an LTR chunk // which is at the end of an RTL paragraph); (new_cur.pos() == lastpos() && paragraph().isRTL(buffer()->params())) - // 2. if the position *after* right_pos is RTL (we want to be - // *after* right_pos, not before right_pos + 1!) + // 2. if the position *after* right_pos is RTL + // (we want to be *after* right_pos, not + // before right_pos + 1!) || paragraph().getFontSettings(buffer()->params(), new_cur.pos()).isVisibleRightToLeft() ) @@ -690,9 +698,9 @@ bool Cursor::posVisRight(bool skip_inset) else // set the boundary to false new_cur.boundary(false); } - // Otherwise (if the character at position 'right_pos' is RTL), then - // moving to the right of it is as easy as setting the new position - // to 'right_pos'. + // Otherwise (if the character at position 'right_pos' + // is RTL), then moving to the right of it is as easy + // as setting the new position to 'right_pos'. else { new_cur.pos() = right_pos; new_cur.boundary(false); @@ -731,8 +739,9 @@ bool Cursor::posVisLeft(bool skip_inset) new_cur.boundary(false); if (!skip_inset && text()->checkAndActivateInsetVisual(new_cur, left_pos >= pos(), true)) { - // we actually move the cursor at the end of this function, for now - // we just keep track of the new position in new_cur... + // we actually move the cursor at the end of this + // function, for now we just keep track of the new + // position in new_cur... LYXERR(Debug::RTL, "entering inset at: " << new_cur.pos()); } @@ -745,8 +754,9 @@ bool Cursor::posVisLeft(bool skip_inset) return false; } - // we actually move the cursor at the end of this function, for now - // just keep track of the new position in new_cur... + // we actually move the cursor at the end of this + // function, for now just keep track of the new + // position in new_cur... LYXERR(Debug::RTL, "left edge, moving: " << int(new_cur.pit()) << "," << int(new_cur.pos()) << "," << (new_cur.boundary() ? 1 : 0)); @@ -754,28 +764,33 @@ bool Cursor::posVisLeft(bool skip_inset) // normal movement to the left else { new_cur = *this; - // Recall, if the cursor is at position 'x', that means *before* - // the character at position 'x'. In RTL, "before" means "to the - // right of", in LTR, "to the left of". So currently our situation - // is this: the position to our left is 'left_pos' (i.e., we're - // currently to the right of 'left_pos'). In order to move to the - // left, it depends whether or not the character at 'left_pos' is RTL. + // Recall, if the cursor is at position 'x', that + // means *before* the character at position 'x'. In + // RTL, "before" means "to the right of", in LTR, "to + // the left of". So currently our situation is this: + // the position to our left is 'left_pos' (i.e., we're + // currently to the right of 'left_pos'). In order to + // move to the left, it depends whether or not the + // character at 'left_pos' is RTL. new_pos_is_RTL = paragraph().getFontSettings( buffer()->params(), left_pos).isVisibleRightToLeft(); - // If the character at 'left_pos' *is* RTL, then in order to move to - // the left of it, we need to be *after* 'left_pos', i.e., move to - // position 'left_pos' + 1. + // If the character at 'left_pos' *is* RTL, then in + // order to move to the left of it, we need to be + // *after* 'left_pos', i.e., move to position + // 'left_pos' + 1. if (new_pos_is_RTL) { new_cur.pos() = left_pos + 1; // set the boundary to true in two situations: if ( - // 1. if new_pos is now lastpos and we're in an LTR paragraph - // (this means that we're moving left to the end of an RTL chunk + // 1. if new_pos is now lastpos and we're in + // an LTR paragraph (this means that we're + // moving left to the end of an RTL chunk // which is at the end of an LTR paragraph); (new_cur.pos() == lastpos() && !paragraph().isRTL(buffer()->params())) - // 2. if the position *after* left_pos is not RTL (we want to be - // *after* left_pos, not before left_pos + 1!) + // 2. if the position *after* left_pos is not + // RTL (we want to be *after* left_pos, not + // before left_pos + 1!) || !paragraph().getFontSettings(buffer()->params(), new_cur.pos()).isVisibleRightToLeft() ) @@ -783,9 +798,9 @@ bool Cursor::posVisLeft(bool skip_inset) else // set the boundary to false new_cur.boundary(false); } - // Otherwise (if the character at position 'left_pos' is LTR), then - // moving to the left of it is as easy as setting the new position - // to 'left_pos'. + // Otherwise (if the character at position 'left_pos' + // is LTR), then moving to the left of it is as easy + // as setting the new position to 'left_pos'. else { new_cur.pos() = left_pos; new_cur.boundary(false); @@ -818,14 +833,16 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) LYXERR(Debug::RTL, "bidi: " << row.pos() << "--" << row.endpos()); - // The cursor is painted *before* the character at pos(), or, if 'boundary' - // is true, *after* the character at (pos() - 1). So we already have one - // known position around the cursor: + // The cursor is painted *before* the character at pos(), or, + // if 'boundary' is true, *after* the character at (pos() - + // 1). So we already have one known position around the + // cursor: pos_type const known_pos = boundary() && pos() > 0 ? pos() - 1 : pos(); - // edge case: if we're at the end of the paragraph, things are a little - // different (because lastpos is a position which does not really "exist" - // --- there's no character there yet). + // edge case: if we're at the end of the paragraph, things are + // a little different (because lastpos is a position which + // does not really "exist" --- there's no character there + // yet). if (known_pos == lastpos()) { if (par.isRTL(buf.params())) { left_pos = -1; @@ -838,28 +855,31 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) return; } - // Whether 'known_pos' is to the left or to the right of the cursor depends - // on whether it is an RTL or LTR character... + // Whether 'known_pos' is to the left or to the right of the + // cursor depends on whether it is an RTL or LTR character... bool const cur_is_RTL = par.getFontSettings(buf.params(), known_pos).isVisibleRightToLeft(); // ... in the following manner: - // For an RTL character, "before" means "to the right" and "after" means - // "to the left"; and for LTR, it's the reverse. So, 'known_pos' is to the - // right of the cursor if (RTL && boundary) or (!RTL && !boundary): + // For an RTL character, "before" + // means "to the right" and "after" means "to the left"; and + // for LTR, it's the reverse. So, 'known_pos' is to the right + // of the cursor if (RTL && boundary) or (!RTL && !boundary): bool const known_pos_on_right = cur_is_RTL == boundary(); - // So we now know one of the positions surrounding the cursor. Let's - // determine the other one: + // So we now know one of the positions surrounding the cursor. + // Let's determine the other one: if (known_pos_on_right) { right_pos = known_pos; // *visual* position of 'left_pos': pos_type v_left_pos = bidi.log2vis(right_pos) - 1; - // If the position we just identified as 'left_pos' is a "skipped - // separator" (a separator which is at the logical end of a row, - // except for the last row in a paragraph; such separators are not - // painted, so they "are not really there"; note that in bidi text, - // such a separator could appear visually in the middle of a row), - // set 'left_pos' to the *next* position to the left. + // If the position we just identified as 'left_pos' is + // a "skipped separator" (a separator which is at the + // logical end of a row, except for the last row in a + // paragraph; such separators are not painted, so they + // "are not really there"; note that in bidi text, + // such a separator could appear visually in the + // middle of a row), set 'left_pos' to the *next* + // position to the left. if (bidi.inRange(v_left_pos) && bidi.vis2log(v_left_pos) + 1 == row.endpos() && row.endpos() < lastpos() @@ -871,8 +891,9 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) left_pos = -1; else left_pos = bidi.vis2log(v_left_pos); - // If the position we identified as 'right_pos' is a "skipped - // separator", set 'right_pos' to the *next* position to the right. + // If the position we identified as 'right_pos' is a + // "skipped separator", set 'right_pos' to the *next* + // position to the right. if (right_pos + 1 == row.endpos() && row.endpos() < lastpos() && par.isSeparator(right_pos)) { pos_type const v_right_pos = bidi.log2vis(right_pos) + 1; @@ -886,8 +907,9 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) left_pos = known_pos; // *visual* position of 'right_pos' pos_type v_right_pos = bidi.log2vis(left_pos) + 1; - // If the position we just identified as 'right_pos' is a "skipped - // separator", set 'right_pos' to the *next* position to the right. + // If the position we just identified as 'right_pos' + // is a "skipped separator", set 'right_pos' to the + // *next* position to the right. if (bidi.inRange(v_right_pos) && bidi.vis2log(v_right_pos) + 1 == row.endpos() && row.endpos() < lastpos() @@ -899,8 +921,9 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos) right_pos = -1; else right_pos = bidi.vis2log(v_right_pos); - // If the position we identified as 'left_pos' is a "skipped - // separator", set 'left_pos' to the *next* position to the left. + // If the position we identified as 'left_pos' is a + // "skipped separator", set 'left_pos' to the *next* + // position to the left. if (left_pos + 1 == row.endpos() && row.endpos() < lastpos() && par.isSeparator(left_pos)) { pos_type const v_left_pos = bidi.log2vis(left_pos) - 1; @@ -921,16 +944,16 @@ bool Cursor::posVisToNewRow(bool movingLeft) Row const & row = textRow(); bool par_is_LTR = !par.isRTL(buf.params()); - // Inside a table, determining whether to move to the next or previous row - // should be done based on the table's direction. + // Inside a table, determining whether to move to the next or + // previous row should be done based on the table's direction. int s = depth() - 1; if (s >= 1 && (*this)[s].inset().asInsetTabular()) { par_is_LTR = !(*this)[s].inset().asInsetTabular()->isRightToLeft(*this); LYXERR(Debug::RTL, "Inside table! par_is_LTR=" << (par_is_LTR ? 1 : 0)); } - // if moving left in an LTR paragraph or moving right in an RTL one, - // move to previous row + // if moving left in an LTR paragraph or moving right in an + // RTL one, move to previous row if (par_is_LTR == movingLeft) { if (row.pos() == 0) { // we're at first row in paragraph if (pit() == 0) // no previous paragraph! don't move @@ -944,8 +967,8 @@ bool Cursor::posVisToNewRow(bool movingLeft) boundary(false); } } - // if moving left in an RTL paragraph or moving right in an LTR one, - // move to next row + // if moving left in an RTL paragraph or moving right in an + // LTR one, move to next row else { if (row.endpos() == lastpos()) { // we're at last row in paragraph if (pit() == lastpit()) // last paragraph! don't move @@ -987,30 +1010,43 @@ void Cursor::posVisToRowExtremity(bool left) else { pos() = bidi.vis2log(row.pos()); - // Moving to the leftmost position in the row, the cursor should - // normally be placed to the *left* of the leftmost position. - // A very common exception, though, is if the leftmost character - // also happens to be the separator at the (logical) end of the row - // --- in this case, the separator is positioned beyond the left - // margin, and we don't want to move the cursor there (moving to - // the left of the separator is equivalent to moving to the next - // line). So, in this case we actually want to place the cursor - // to the *right* of the leftmost position (the separator). - // Another exception is if we're moving to the logically last - // position in the row, which is *not* a separator: this means - // that the entire row has no separators (if there were any, the - // row would have been broken there); and therefore in this case - // we also move to the *right* of the last position (this indicates - // to the user that there is no space after this position, and is - // consistent with the behavior in the middle of a row --- moving - // right or left moves to the next/previous character; if we were - // to move to the *left* of this position, that would simulate - // a separator which is not really there!). - // Finally, there is an exception to the previous exception: if - // this non-separator-but-last-position-in-row is an inset, then - // we *do* want to stay to the left of it anyway: this is the + // Moving to the leftmost position in the row, + // the cursor should normally be placed to the + // *left* of the leftmost position. A very + // common exception, though, is if the + // leftmost character also happens to be the + // separator at the (logical) end of the row + // --- in this case, the separator is + // positioned beyond the left margin, and we + // don't want to move the cursor there (moving + // to the left of the separator is equivalent + // to moving to the next line). So, in this + // case we actually want to place the cursor + // to the *right* of the leftmost position + // (the separator). Another exception is if + // we're moving to the logically last position + // in the row, which is *not* a separator: + // this means that the entire row has no + // separators (if there were any, the row + // would have been broken there); and + // therefore in this case we also move to the + // *right* of the last position (this + // indicates to the user that there is no + // space after this position, and is + // consistent with the behavior in the middle + // of a row --- moving right or left moves to + // the next/previous character; if we were to + // move to the *left* of this position, that + // would simulate a separator which is not + // really there!). Finally, there is an + // exception to the previous exception: if + // this non-separator-but-last-position-in-row + // is an inset, then we *do* want to stay to + // the left of it anyway: this is the // "boundary" which we simulate at insets. - // Another exception is when row.endpos() is 0. + + // Another exception is when row.endpos() is + // 0. // do we want to be to the right of pos? // as explained above, if at last pos in row, stay to the right @@ -1036,30 +1072,41 @@ void Cursor::posVisToRowExtremity(bool left) else { pos() = row.endpos() > 0 ? bidi.vis2log(row.endpos() - 1) : 0; - // Moving to the rightmost position in the row, the cursor should - // normally be placed to the *right* of the rightmost position. - // A very common exception, though, is if the rightmost character - // also happens to be the separator at the (logical) end of the row - // --- in this case, the separator is positioned beyond the right - // margin, and we don't want to move the cursor there (moving to - // the right of the separator is equivalent to moving to the next - // line). So, in this case we actually want to place the cursor - // to the *left* of the rightmost position (the separator). - // Another exception is if we're moving to the logically last - // position in the row, which is *not* a separator: this means - // that the entire row has no separators (if there were any, the - // row would have been broken there); and therefore in this case - // we also move to the *left* of the last position (this indicates - // to the user that there is no space after this position, and is - // consistent with the behavior in the middle of a row --- moving - // right or left moves to the next/previous character; if we were - // to move to the *right* of this position, that would simulate - // a separator which is not really there!). - // Finally, there is an exception to the previous exception: if - // this non-separator-but-last-position-in-row is an inset, then - // we *do* want to stay to the right of it anyway: this is the - // "boundary" which we simulate at insets. - // Another exception is when row.endpos() is 0. + // Moving to the rightmost position in the + // row, the cursor should normally be placed + // to the *right* of the rightmost position. A + // very common exception, though, is if the + // rightmost character also happens to be the + // separator at the (logical) end of the row + // --- in this case, the separator is + // positioned beyond the right margin, and we + // don't want to move the cursor there (moving + // to the right of the separator is equivalent + // to moving to the next line). So, in this + // case we actually want to place the cursor + // to the *left* of the rightmost position + // (the separator). Another exception is if + // we're moving to the logically last position + // in the row, which is *not* a separator: + // this means that the entire row has no + // separators (if there were any, the row + // would have been broken there); and + // therefore in this case we also move to the + // *left* of the last position (this indicates + // to the user that there is no space after + // this position, and is consistent with the + // behavior in the middle of a row --- moving + // right or left moves to the next/previous + // character; if we were to move to the + // *right* of this position, that would + // simulate a separator which is not really + // there!). Finally, there is an exception to + // the previous exception: if this + // non-separator-but-last-position-in-row is + // an inset, then we *do* want to stay to the + // right of it anyway: this is the "boundary" + // which we simulate at insets. Another + // exception is when row.endpos() is 0. // do we want to be to the left of pos? // as explained above, if at last pos in row, stay to the left, @@ -1915,6 +1962,7 @@ bool Cursor::atFirstOrLastRow(bool up) return false; } + bool Cursor::upDownInText(bool up, bool & updateNeeded) { LASSERT(text(), /**/); @@ -1932,14 +1980,16 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) setTargetX(xo); else if (xo - textTargetOffset() != x_target() && depth() == beforeDispatchCursor_.depth()) { - // In text mode inside the line (not left or right) possibly set a new target_x, - // but only if we are somewhere else than the previous target-offset. + // In text mode inside the line (not left or right) + // possibly set a new target_x, but only if we are + // somewhere else than the previous target-offset. - // We want to keep the x-target on subsequent up/down movements - // that cross beyond the end of short lines. Thus a special - // handling when the cursor is at the end of line: Use the new - // x-target only if the old one was before the end of line - // or the old one was after the beginning of the line + // We want to keep the x-target on subsequent up/down + // movements that cross beyond the end of short lines. + // Thus a special handling when the cursor is at the + // end of line: Use the new x-target only if the old + // one was before the end of line or the old one was + // after the beginning of the line bool inRTL = isWithinRtlParagraph(*this); bool left; bool right; @@ -2128,6 +2178,7 @@ void Cursor::errorMessage(docstring const & msg) const namespace { + docstring parbreak(Cursor const * cur) { odocstringstream os; @@ -2138,6 +2189,7 @@ docstring parbreak(Cursor const * cur) os << '\n'; return os.str(); } + } @@ -2267,9 +2319,9 @@ void Cursor::noScreenUpdate() const Font Cursor::getFont() const { - // The logic here should more or less match to the Cursor::setCurrentFont - // logic, i.e. the cursor height should give a hint what will happen - // if a character is entered. + // The logic here should more or less match to the + // Cursor::setCurrentFont logic, i.e. the cursor height should + // give a hint what will happen if a character is entered. // HACK. far from being perfect... diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 9a336a194a..6534475885 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -848,6 +848,7 @@ void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext) putClipboard(theCuts[0].first, theCuts[0].second, plaintext); } + namespace { void copySelectionToStack(Cursor const & cur, CutStack & cutstack) diff --git a/src/DepTable.cpp b/src/DepTable.cpp index fdbbd46a06..835130717f 100644 --- a/src/DepTable.cpp +++ b/src/DepTable.cpp @@ -108,7 +108,8 @@ bool DepTable::sumchange() const DepList::const_iterator cit = deplist.begin(); DepList::const_iterator end = deplist.end(); for (; cit != end; ++cit) { - if (cit->second.changed()) return true; + if (cit->second.changed()) + return true; } return false; } @@ -144,9 +145,8 @@ bool DepTable::ext_exist(string const & ext) const DepList::const_iterator cit = deplist.begin(); DepList::const_iterator end = deplist.end(); for (; cit != end; ++cit) { - if (suffixIs(cit->first.absFileName(), ext)) { + if (suffixIs(cit->first.absFileName(), ext)) return true; - } } return false; } diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp index 420c782c37..35b23a98b7 100644 --- a/src/DocIterator.cpp +++ b/src/DocIterator.cpp @@ -42,6 +42,7 @@ DocIterator::DocIterator() : boundary_(false), inset_(0), buffer_(0) {} + // We could be able to get rid of this if only every BufferView were // associated to a buffer on construction. DocIterator::DocIterator(Buffer * buf) diff --git a/src/EnchantChecker.cpp b/src/EnchantChecker.cpp index 61127108a4..77c9e309ed 100644 --- a/src/EnchantChecker.cpp +++ b/src/EnchantChecker.cpp @@ -40,7 +40,8 @@ typedef map Spellers; struct EnchantChecker::Private { - Private() {} + Private() + {} ~Private(); @@ -60,9 +61,8 @@ EnchantChecker::Private::~Private() Spellers::iterator it = spellers_.begin(); Spellers::iterator end = spellers_.end(); - for (; it != end; ++it) { + for (; it != end; ++it) delete it->second.speller; - } } @@ -97,9 +97,9 @@ enchant::Dict * EnchantChecker::Private::speller(string const & lang) } -EnchantChecker::EnchantChecker(): d(new Private) -{ -} +EnchantChecker::EnchantChecker() + : d(new Private) +{} EnchantChecker::~EnchantChecker() diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 3325301a7c..298fc6a0ae 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -852,8 +852,7 @@ Encoding const * Encodings::fromLaTeXName(string const & n) const Encodings::Encodings() -{ -} +{} void Encodings::read(FileName const & encfile, FileName const & symbolsfile) diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp index 27b6a51ba3..d7494707d2 100644 --- a/src/FontInfo.cpp +++ b/src/FontInfo.cpp @@ -101,6 +101,7 @@ FontInfo::FontInfo() *this = sane_font; } + /// Decreases font size_ by one FontInfo & FontInfo::decSize() { @@ -346,115 +347,116 @@ Color FontInfo::realColor() const namespace { - void appendSep(string & s1, string const & s2) { - if (s2.empty()) - return; - s1 += s1.empty() ? "" : "\n"; - s1 += s2; - } +void appendSep(string & s1, string const & s2) +{ + if (s2.empty()) + return; + s1 += s1.empty() ? "" : "\n"; + s1 += s2; +} - string makeCSSTag(string const & key, string const & val) - { - return key + ": " + val + ";"; - } +string makeCSSTag(string const & key, string const & val) +{ + return key + ": " + val + ";"; +} - string getFamilyCSS(FontFamily const & f) - { - switch (f) { - case ROMAN_FAMILY: - return "serif"; - case SANS_FAMILY: - return "sans-serif"; - case TYPEWRITER_FAMILY: - return "monospace"; - case SYMBOL_FAMILY: - case CMR_FAMILY: - case CMSY_FAMILY: - case CMM_FAMILY: - case CMEX_FAMILY: - case MSA_FAMILY: - case MSB_FAMILY: - case EUFRAK_FAMILY: - case RSFS_FAMILY: - case WASY_FAMILY: - case ESINT_FAMILY: - case INHERIT_FAMILY: - case IGNORE_FAMILY: - break; - } - return ""; +string getFamilyCSS(FontFamily const & f) +{ + switch (f) { + case ROMAN_FAMILY: + return "serif"; + case SANS_FAMILY: + return "sans-serif"; + case TYPEWRITER_FAMILY: + return "monospace"; + case SYMBOL_FAMILY: + case CMR_FAMILY: + case CMSY_FAMILY: + case CMM_FAMILY: + case CMEX_FAMILY: + case MSA_FAMILY: + case MSB_FAMILY: + case EUFRAK_FAMILY: + case RSFS_FAMILY: + case WASY_FAMILY: + case ESINT_FAMILY: + case INHERIT_FAMILY: + case IGNORE_FAMILY: + break; } + return ""; +} - string getSeriesCSS(FontSeries const & s) - { - switch (s) { - case MEDIUM_SERIES: - return "normal"; - case BOLD_SERIES: - return "bold"; - case INHERIT_SERIES: - case IGNORE_SERIES: - break; - } - return ""; +string getSeriesCSS(FontSeries const & s) +{ + switch (s) { + case MEDIUM_SERIES: + return "normal"; + case BOLD_SERIES: + return "bold"; + case INHERIT_SERIES: + case IGNORE_SERIES: + break; } + return ""; +} - string getShapeCSS(FontShape const & s) - { - string fs = "normal"; - string fv = "normal"; - switch (s) { - case UP_SHAPE: break; - case ITALIC_SHAPE: fs = "italic"; break; - case SLANTED_SHAPE: fs = "oblique"; break; - case SMALLCAPS_SHAPE: fv = "small-caps"; break; - case IGNORE_SHAPE: - case INHERIT_SHAPE: - fs = ""; fv = ""; break; - } - string retval; - if (!fs.empty()) - appendSep(retval, makeCSSTag("font-style", fs)); - if (!fv.empty()) - appendSep(retval, makeCSSTag("font-variant", fv)); - return retval; +string getShapeCSS(FontShape const & s) +{ + string fs = "normal"; + string fv = "normal"; + switch (s) { + case UP_SHAPE: break; + case ITALIC_SHAPE: fs = "italic"; break; + case SLANTED_SHAPE: fs = "oblique"; break; + case SMALLCAPS_SHAPE: fv = "small-caps"; break; + case IGNORE_SHAPE: + case INHERIT_SHAPE: + fs = ""; fv = ""; break; } + string retval; + if (!fs.empty()) + appendSep(retval, makeCSSTag("font-style", fs)); + if (!fv.empty()) + appendSep(retval, makeCSSTag("font-variant", fv)); + return retval; +} - string getSizeCSS(FontSize const & s) - { - switch (s) { - case FONT_SIZE_TINY: - return "xx-small"; - case FONT_SIZE_SCRIPT: - return "x-small"; - case FONT_SIZE_FOOTNOTE: - case FONT_SIZE_SMALL: - return "small"; - case FONT_SIZE_NORMAL: - return "medium"; - case FONT_SIZE_LARGE: - return "large"; - case FONT_SIZE_LARGER: - case FONT_SIZE_LARGEST: - return "x-large"; - case FONT_SIZE_HUGE: - case FONT_SIZE_HUGER: - return "xx-large"; - case FONT_SIZE_INCREASE: - return "larger"; - case FONT_SIZE_DECREASE: - return "smaller"; - case FONT_SIZE_IGNORE: - case FONT_SIZE_INHERIT: - break; - } - return ""; +string getSizeCSS(FontSize const & s) +{ + switch (s) { + case FONT_SIZE_TINY: + return "xx-small"; + case FONT_SIZE_SCRIPT: + return "x-small"; + case FONT_SIZE_FOOTNOTE: + case FONT_SIZE_SMALL: + return "small"; + case FONT_SIZE_NORMAL: + return "medium"; + case FONT_SIZE_LARGE: + return "large"; + case FONT_SIZE_LARGER: + case FONT_SIZE_LARGEST: + return "x-large"; + case FONT_SIZE_HUGE: + case FONT_SIZE_HUGER: + return "xx-large"; + case FONT_SIZE_INCREASE: + return "larger"; + case FONT_SIZE_DECREASE: + return "smaller"; + case FONT_SIZE_IGNORE: + case FONT_SIZE_INHERIT: + break; } + return ""; +} } // namespace anonymous diff --git a/src/Format.cpp b/src/Format.cpp index 71699d64ad..7e634b48be 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -59,7 +59,8 @@ string const token_socket_format("$$a"); class FormatNamesEqual : public unary_function { public: FormatNamesEqual(string const & name) - : name_(name) {} + : name_(name) + {} bool operator()(Format const & f) const { return f.name() == name_; @@ -72,7 +73,8 @@ private: class FormatExtensionsEqual : public unary_function { public: FormatExtensionsEqual(string const & extension) - : extension_(extension) {} + : extension_(extension) + {} bool operator()(Format const & f) const { return f.hasExtension(extension_); @@ -85,7 +87,8 @@ private: class FormatMimeEqual : public unary_function { public: FormatMimeEqual(string const & mime) - : mime_(mime) {} + : mime_(mime) + {} bool operator()(Format const & f) const { // The test for empty mime strings is needed since we allow @@ -100,7 +103,8 @@ private: class FormatPrettyNameEqual : public unary_function { public: FormatPrettyNameEqual(string const & prettyname) - : prettyname_(prettyname) {} + : prettyname_(prettyname) + {} bool operator()(Format const & f) const { return f.prettyname() == prettyname_; @@ -763,8 +767,10 @@ string const Formats::extensions(string const & name) const namespace { + typedef Translator FlavorTranslator; + FlavorTranslator initFlavorTranslator() { FlavorTranslator f(OutputParams::LATEX, "latex"); @@ -784,6 +790,7 @@ FlavorTranslator const & flavorTranslator() static FlavorTranslator translator = initFlavorTranslator(); return translator; } + } diff --git a/src/FuncStatus.cpp b/src/FuncStatus.cpp index 576376a4ee..9b936869ac 100644 --- a/src/FuncStatus.cpp +++ b/src/FuncStatus.cpp @@ -17,8 +17,7 @@ namespace lyx { FuncStatus::FuncStatus() : v_(OK) -{ -} +{} void FuncStatus::clear() diff --git a/src/HSpace.cpp b/src/HSpace.cpp index 5a2b16695f..b29b4d50fc 100644 --- a/src/HSpace.cpp +++ b/src/HSpace.cpp @@ -142,6 +142,7 @@ string HSpace::asHTMLLength() const return result; } + int HSpace::inPixels(BufferView const & bv) const { switch (kind_) { diff --git a/src/HunspellChecker.cpp b/src/HunspellChecker.cpp index a2d2c95e05..31b629671e 100644 --- a/src/HunspellChecker.cpp +++ b/src/HunspellChecker.cpp @@ -56,7 +56,7 @@ struct HunspellChecker::Private ~Private(); void cleanCache(); - void setUserPath(std::string path); + void setUserPath(std::string const & path); const string dictPath(int selector); bool haveLanguageFiles(string const & hpath); bool haveDictionary(Language const * lang, string & hpath); @@ -107,7 +107,7 @@ HunspellChecker::Private::~Private() } -void HunspellChecker::Private::setUserPath(std::string path) +void HunspellChecker::Private::setUserPath(std::string const & path) { if (user_path_ != lyxrc.hunspelldir_path) { cleanCache(); @@ -167,9 +167,8 @@ const string HunspellChecker::Private::dictPath(int selector) bool HunspellChecker::Private::haveDictionary(Language const * lang, string & hpath) { - if (hpath.empty()) { + if (hpath.empty()) return false; - } LYXERR(Debug::FILES, "check hunspell path: " << hpath << " for language " << (lang ? lang->lang() : "NULL" )); @@ -183,9 +182,8 @@ bool HunspellChecker::Private::haveDictionary(Language const * lang, string & hp } // another try with code, '_' replaced by '-' h_path = addName(hpath, subst(lang->code(), '_', '-')); - if (!haveLanguageFiles(h_path)) { + if (!haveLanguageFiles(h_path)) return false; - } LYXERR(Debug::FILES, " found " << h_path); hpath = h_path; return true; @@ -197,7 +195,7 @@ bool HunspellChecker::Private::haveDictionary(Language const * lang) bool result = false; setUserPath(lyxrc.hunspelldir_path); - for ( int p = 0; !result && p < maxLookupSelector(); p++ ) { + for (int p = 0; !result && p < maxLookupSelector(); ++p) { string lpath = dictPath(p); result = haveDictionary(lang, lpath); } @@ -213,9 +211,8 @@ Hunspell * HunspellChecker::Private::speller(Language const * lang) { setUserPath(lyxrc.hunspelldir_path); Spellers::iterator it = spellers_.find(lang->lang()); - if (it != spellers_.end()) { + if (it != spellers_.end()) return it->second; - } return addSpeller(lang); } @@ -239,11 +236,11 @@ Hunspell * HunspellChecker::Private::addSpeller(Language const * lang,string & p Hunspell * HunspellChecker::Private::addSpeller(Language const * lang) { Hunspell * h = 0; - for ( int p = 0; p < maxLookupSelector() && 0 == h; p++ ) { + for (int p = 0; p < maxLookupSelector() && 0 == h; ++p) { string lpath = dictPath(p); h = addSpeller(lang, lpath); } - if (0 != h) { + if (h) { string const encoding = h->get_dic_encoding(); PersonalWordList * pd = new PersonalWordList(lang->lang()); pd->load(); @@ -265,9 +262,8 @@ int HunspellChecker::Private::numDictionaries() const Spellers::const_iterator it = spellers_.begin(); Spellers::const_iterator et = spellers_.end(); - for (; it != et; ++it) { + for (; it != et; ++it) result += it->second != 0; - } return result; } @@ -276,9 +272,9 @@ bool HunspellChecker::Private::isIgnored(WordLangTuple const & wl) const { IgnoreList::const_iterator it = ignored_.begin(); for (; it != ignored_.end(); ++it) { - if ((*it).lang()->code() != wl.lang()->code()) + if (it->lang()->code() != wl.lang()->code()) continue; - if ((*it).word() == wl.word()) + if (it->word() == wl.word()) return true; } return false; @@ -324,9 +320,9 @@ bool HunspellChecker::Private::learned(WordLangTuple const & wl) } -HunspellChecker::HunspellChecker(): d(new Private) -{ -} +HunspellChecker::HunspellChecker() + : d(new Private) +{} HunspellChecker::~HunspellChecker() @@ -436,7 +432,7 @@ bool HunspellChecker::hasDictionary(Language const * lang) const { if (!lang) return false; - return (d->haveDictionary(lang)); + return d->haveDictionary(lang); } diff --git a/src/IndicesList.cpp b/src/IndicesList.cpp index 9f22373f3a..26881549a1 100644 --- a/src/IndicesList.cpp +++ b/src/IndicesList.cpp @@ -30,7 +30,9 @@ namespace { class IndexNamesEqual : public std::unary_function { public: - IndexNamesEqual(docstring const & name) : name_(name) {} + IndexNamesEqual(docstring const & name) + : name_(name) + {} bool operator()(Index const & index) const { @@ -44,7 +46,9 @@ private: class IndexHasShortcut : public std::unary_function { public: - IndexHasShortcut(docstring const & shortcut) : shortc_(shortcut) {} + IndexHasShortcut(docstring const & shortcut) + : shortc_(shortcut) + {} bool operator()(Index const & index) const { diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 94cdb637d0..bbc76d1852 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -501,6 +501,7 @@ bool LaTeXFeatures::isProvided(string const & name) const nomath); } + bool LaTeXFeatures::mustProvide(string const & name) const { return isRequired(name) && !isProvided(name); @@ -1280,6 +1281,7 @@ docstring const LaTeXFeatures::getTClassHTMLStyles() const namespace { + docstring const getFloatI18nPreamble(docstring const & type, docstring const & name, Language const * lang, Encoding const & enc, bool const polyglossia) diff --git a/src/Layout.cpp b/src/Layout.cpp index 48726d0702..97594b706e 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -911,7 +911,8 @@ string const & Layout::htmllabelattr() const } -docstring Layout::htmlstyle() const { +docstring Layout::htmlstyle() const +{ if (!htmlstyle_.empty() && !htmlforcecss_) return htmlstyle_; if (htmldefaultstyle_.empty()) @@ -951,15 +952,19 @@ string Layout::defaultCSSClass() const namespace { - string makeMarginValue(char const * side, double d) { - ostringstream os; - os << "margin-" << side << ": " << d << "ex;\n"; - return os.str(); - } + +string makeMarginValue(char const * side, double d) +{ + ostringstream os; + os << "margin-" << side << ": " << d << "ex;\n"; + return os.str(); +} + } -void Layout::makeDefaultCSS() const { +void Layout::makeDefaultCSS() const +{ // this never needs to be redone, since reloading layouts will // wipe out what we did before. if (!htmldefaultstyle_.empty()) diff --git a/src/LayoutFile.cpp b/src/LayoutFile.cpp index 4337956170..5f2f0d3db8 100644 --- a/src/LayoutFile.cpp +++ b/src/LayoutFile.cpp @@ -182,7 +182,8 @@ std::vector LayoutFileList::classList() const } -void LayoutFileList::reset(LayoutFileIndex const & classname) { +void LayoutFileList::reset(LayoutFileIndex const & classname) +{ LASSERT(haveClass(classname), /**/); LayoutFile * tc = classmap_[classname]; LayoutFile * tmpl = @@ -216,6 +217,7 @@ string layoutpost = } + LayoutFileIndex LayoutFileList::addEmptyClass(string const & textclass) { FileName const tempLayout = FileName::tempName("basic_layout"); @@ -257,8 +259,8 @@ LayoutFileIndex LayoutFileList::addEmptyClass(string const & textclass) } -LayoutFileIndex - LayoutFileList::addLocalLayout(string const & textclass, string const & path) +LayoutFileIndex LayoutFileList::addLocalLayout( + string const & textclass, string const & path) { // FIXME There is a bug here: 4593 // @@ -321,7 +323,8 @@ LayoutFileIndex return textclass; } } - // If .layout is not in local directory, or an invalid layout is found, return null + // If .layout is not in local directory, or an invalid layout + // is found, return null return string(); } diff --git a/src/LyX.cpp b/src/LyX.cpp index 2962207241..8c9fdbcb02 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -138,11 +138,10 @@ void reconfigureUserLyXDir() } // namespace anon /// The main application class private implementation. -struct LyX::Impl -{ - Impl() : latexfonts_(0), spell_checker_(0), apple_spell_checker_(0), aspell_checker_(0), enchant_checker_(0), hunspell_checker_(0) - { - } +struct LyX::Impl { + Impl() + : latexfonts_(0), spell_checker_(0), apple_spell_checker_(0), aspell_checker_(0), enchant_checker_(0), hunspell_checker_(0) + {} ~Impl() { @@ -205,6 +204,7 @@ struct LyX::Impl SpellChecker * hunspell_checker_; }; + /// frontend::Application * theApp() { diff --git a/src/ModuleList.cpp b/src/ModuleList.cpp index f5d5dd54b4..6b693b16e6 100644 --- a/src/ModuleList.cpp +++ b/src/ModuleList.cpp @@ -46,7 +46,8 @@ LyXModule::LyXModule(string const & n, string const & i, } -vector LyXModule::prerequisites() const { +vector LyXModule::prerequisites() const +{ #ifdef TEX2LYX return vector(); #else @@ -57,7 +58,8 @@ vector LyXModule::prerequisites() const { } -bool LyXModule::isAvailable() const { +bool LyXModule::isAvailable() const +{ #ifdef TEX2LYX return true; #else @@ -115,8 +117,7 @@ bool LyXModule::areCompatible(string const & mod1, string const & mod2) // used when sorting the module list. -class ModuleSorter -{ +class ModuleSorter { public: int operator()(LyXModule const & lm1, LyXModule const & lm2) const { @@ -265,6 +266,7 @@ LyXModule const * ModuleList::operator[](string const & str) const return 0; } + LyXModule * ModuleList::operator[](string const & str) { LyXModuleList::iterator it = modlist_.begin(); diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 5a68047850..223d2eb53e 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -69,8 +69,10 @@ using namespace lyx::support; namespace lyx { namespace { + /// Inset identifier (above 0x10ffff, for ucs-4) char_type const META_INSET = 0x200001; + } @@ -129,7 +131,8 @@ private: class SpellCheckerState { public: - SpellCheckerState() { + SpellCheckerState() + { needs_refresh_ = true; current_change_number_ = 0; } @@ -209,20 +212,24 @@ public: return empty_; } - bool needsRefresh() const { + bool needsRefresh() const + { return needs_refresh_; } - SpellChecker::ChangeNumber currentChangeNumber() const { + SpellChecker::ChangeNumber currentChangeNumber() const + { return current_change_number_; } - void refreshRange(pos_type & first, pos_type & last) const { + void refreshRange(pos_type & first, pos_type & last) const + { first = refresh_.first; last = refresh_.last; } - void needsRefresh(pos_type pos) { + void needsRefresh(pos_type pos) + { if (needs_refresh_ && pos != -1) { if (pos < refresh_.first) refresh_.first = pos; @@ -237,13 +244,13 @@ public: needs_refresh_ = pos != -1; } - void needsCompleteRefresh(SpellChecker::ChangeNumber change_number) { + void needsCompleteRefresh(SpellChecker::ChangeNumber change_number) + { needs_refresh_ = true; refresh_.first = 0; refresh_.last = -1; current_change_number_ = change_number; } - private: typedef vector Ranges; typedef Ranges::const_iterator RangesIterator; @@ -384,9 +391,10 @@ public: Language * getSpellLanguage(pos_type const from) const; Language * locateSpellRange(pos_type & from, pos_type & to, - SkipPositions & skips) const; + SkipPositions & skips) const; - bool hasSpellerChange() const { + bool hasSpellerChange() const + { SpellChecker::ChangeNumber speller_change_number = 0; if (theSpellChecker()) speller_change_number = theSpellChecker()->changeNumber(); @@ -405,14 +413,16 @@ public: speller_state_.setRange(fp, state); } - void requestSpellCheck(pos_type pos) { + void requestSpellCheck(pos_type pos) + { if (pos == -1) speller_state_.needsCompleteRefresh(speller_state_.currentChangeNumber()); else speller_state_.needsRefresh(pos); } - void readySpellCheck() { + void readySpellCheck() + { speller_state_.needsRefresh(-1); } diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp index 85e57683df..e6541fdb0b 100644 --- a/src/ParagraphMetrics.cpp +++ b/src/ParagraphMetrics.cpp @@ -257,9 +257,8 @@ bool ParagraphMetrics::hfillExpansion(Row const & row, pos_type pos) const } // expand at the beginning of a row only if it is the first row of a paragraph - if (pos == row.pos()) { + if (pos == row.pos()) return pos == 0; - } // do not expand in some labels if (par_->layout().margintype != MARGIN_MANUAL && pos < par_->beginOfBody()) diff --git a/src/PersonalWordList.cpp b/src/PersonalWordList.cpp index 75dcda6aa7..665eb331b5 100644 --- a/src/PersonalWordList.cpp +++ b/src/PersonalWordList.cpp @@ -92,6 +92,7 @@ void PersonalWordList::save() LYXERR(Debug::FILES, "count of saved items: " << words_.size()); } + bool PersonalWordList::equalwords(docstring const & w1, docstring const & w2) const { return w1 == w2; diff --git a/src/Server.cpp b/src/Server.cpp index 1e673e6f87..1de758a5f4 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -695,6 +695,7 @@ string const LyXComm::pipeName(DWORD index) const LyXComm::LyXComm(string const &, Server *, ClientCallbackfct) {} + void LyXComm::openConnection() {} @@ -716,6 +717,7 @@ void LyXComm::endPipe(int & fd, string const & filename, bool write) void LyXComm::emergencyCleanup() {} + void LyXComm::read_ready() {} @@ -726,7 +728,6 @@ void LyXComm::send(string const & msg) #else // defined (HAVE_MKFIFO) - LyXComm::LyXComm(string const & pip, Server * cli, ClientCallbackfct ccb) : pipename_(pip), client_(cli), clientcb_(ccb) { @@ -915,7 +916,6 @@ void LyXComm::read_ready() int status; // the single = is intended here. while ((status = ::read(infd_, charbuf, charbuf_size - 1))) { - if (status > 0) { charbuf[status] = '\0'; // turn it into a c string read_buffer_ += rtrim(charbuf, "\r"); @@ -966,7 +966,8 @@ void LyXComm::send(string const & msg) LYXERR(Debug::LYXSERVER, "LyXComm: Sending '" << msg << '\''); - if (pipename_.empty()) return; + if (pipename_.empty()) + return; if (!ready_) { LYXERR0("LyXComm: Pipes are closed. Could not send " << msg); @@ -1068,7 +1069,6 @@ Server::~Server() int compare(char const * a, char const * b, unsigned int len) { - using namespace std; return strncmp(a, b, len); } diff --git a/src/ServerSocket.cpp b/src/ServerSocket.cpp index 4c34212cb5..3d73a67ed6 100644 --- a/src/ServerSocket.cpp +++ b/src/ServerSocket.cpp @@ -41,7 +41,6 @@ using namespace std; using namespace lyx::support; - namespace lyx { // Address is the unix address for the socket. diff --git a/src/Session.cpp b/src/Session.cpp index aff0628fbf..6cdf1f7248 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -40,7 +40,6 @@ string const sec_lastcommands = "[last commands]"; namespace lyx { - LastFilesSection::LastFilesSection(unsigned int num) : default_num_last_files(4), absolute_max_last_files(100) diff --git a/src/Text.cpp b/src/Text.cpp index c61e9e1bb1..390b69d714 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1812,6 +1812,7 @@ bool Text::read(Lexer & lex, return res; } + // Returns the current font and depth as a message. docstring Text::currentState(Cursor const & cur) const { diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 93eae96b9c..55b90c6cfe 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -222,50 +222,50 @@ enum TextClassTags { namespace { - LexerKeyword textClassTags[] = { - { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE }, - { "addtohtmlstyles", TC_ADDTOHTMLSTYLES }, - { "addtopreamble", TC_ADDTOPREAMBLE }, - { "citeengine", TC_CITEENGINE }, - { "citeenginetype", TC_CITEENGINETYPE }, - { "citeformat", TC_CITEFORMAT }, - { "classoptions", TC_CLASSOPTIONS }, - { "columns", TC_COLUMNS }, - { "counter", TC_COUNTER }, - { "defaultbiblio", TC_DEFAULTBIBLIO }, - { "defaultfont", TC_DEFAULTFONT }, - { "defaultmodule", TC_DEFAULTMODULE }, - { "defaultstyle", TC_DEFAULTSTYLE }, - { "excludesmodule", TC_EXCLUDESMODULE }, - { "float", TC_FLOAT }, - { "format", TC_FORMAT }, - { "fullauthorlist", TC_FULLAUTHORLIST }, - { "htmlpreamble", TC_HTMLPREAMBLE }, - { "htmlstyles", TC_HTMLSTYLES }, - { "htmltocsection", TC_HTMLTOCSECTION }, - { "ifcounter", TC_IFCOUNTER }, - { "ifstyle", TC_IFSTYLE }, - { "input", TC_INPUT }, - { "insetlayout", TC_INSETLAYOUT }, - { "leftmargin", TC_LEFTMARGIN }, - { "nocounter", TC_NOCOUNTER }, - { "nofloat", TC_NOFLOAT }, - { "nostyle", TC_NOSTYLE }, - { "outputformat", TC_OUTPUTFORMAT }, - { "outputtype", TC_OUTPUTTYPE }, - { "pagestyle", TC_PAGESTYLE }, - { "preamble", TC_PREAMBLE }, - { "provides", TC_PROVIDES }, - { "providesmodule", TC_PROVIDESMODULE }, - { "requires", TC_REQUIRES }, - { "rightmargin", TC_RIGHTMARGIN }, - { "secnumdepth", TC_SECNUMDEPTH }, - { "sides", TC_SIDES }, - { "style", TC_STYLE }, - { "titlelatexname", TC_TITLELATEXNAME }, - { "titlelatextype", TC_TITLELATEXTYPE }, - { "tocdepth", TC_TOCDEPTH } - }; +LexerKeyword textClassTags[] = { + { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE }, + { "addtohtmlstyles", TC_ADDTOHTMLSTYLES }, + { "addtopreamble", TC_ADDTOPREAMBLE }, + { "citeengine", TC_CITEENGINE }, + { "citeenginetype", TC_CITEENGINETYPE }, + { "citeformat", TC_CITEFORMAT }, + { "classoptions", TC_CLASSOPTIONS }, + { "columns", TC_COLUMNS }, + { "counter", TC_COUNTER }, + { "defaultbiblio", TC_DEFAULTBIBLIO }, + { "defaultfont", TC_DEFAULTFONT }, + { "defaultmodule", TC_DEFAULTMODULE }, + { "defaultstyle", TC_DEFAULTSTYLE }, + { "excludesmodule", TC_EXCLUDESMODULE }, + { "float", TC_FLOAT }, + { "format", TC_FORMAT }, + { "fullauthorlist", TC_FULLAUTHORLIST }, + { "htmlpreamble", TC_HTMLPREAMBLE }, + { "htmlstyles", TC_HTMLSTYLES }, + { "htmltocsection", TC_HTMLTOCSECTION }, + { "ifcounter", TC_IFCOUNTER }, + { "ifstyle", TC_IFSTYLE }, + { "input", TC_INPUT }, + { "insetlayout", TC_INSETLAYOUT }, + { "leftmargin", TC_LEFTMARGIN }, + { "nocounter", TC_NOCOUNTER }, + { "nofloat", TC_NOFLOAT }, + { "nostyle", TC_NOSTYLE }, + { "outputformat", TC_OUTPUTFORMAT }, + { "outputtype", TC_OUTPUTTYPE }, + { "pagestyle", TC_PAGESTYLE }, + { "preamble", TC_PREAMBLE }, + { "provides", TC_PROVIDES }, + { "providesmodule", TC_PROVIDESMODULE }, + { "requires", TC_REQUIRES }, + { "rightmargin", TC_RIGHTMARGIN }, + { "secnumdepth", TC_SECNUMDEPTH }, + { "sides", TC_SIDES }, + { "style", TC_STYLE }, + { "titlelatexname", TC_TITLELATEXNAME }, + { "titlelatextype", TC_TITLELATEXTYPE }, + { "tocdepth", TC_TOCDEPTH } +}; } //namespace anon @@ -1237,6 +1237,7 @@ string const & TextClass::prerequisites(string const & sep) const return prerequisites_; } + bool TextClass::hasLayout(docstring const & n) const { docstring const name = n.empty() ? defaultLayoutName() : n; @@ -1531,9 +1532,8 @@ Layout const & DocumentClass::getTOCLayout() const Layout const & DocumentClass::htmlTOCLayout() const { - if (html_toc_section_.empty()) { + if (html_toc_section_.empty()) html_toc_section_ = getTOCLayout().name(); - } return operator[](html_toc_section_); } diff --git a/src/Thesaurus.cpp b/src/Thesaurus.cpp index f8e8448979..b4655ac27f 100644 --- a/src/Thesaurus.cpp +++ b/src/Thesaurus.cpp @@ -128,9 +128,8 @@ pair Thesaurus::Private::getThesaurus(string const & path, docstr break; } } - if (idx.empty()) { + if (idx.empty()) return make_pair(string(), string()); - } for (support::FileNameList::const_iterator it = data_files.begin(); it != data_files.end(); ++it) { if (contains(it->onlyFileName(), basename)) { data = it->absFileName(); @@ -150,9 +149,8 @@ pair Thesaurus::Private::getThesaurus(docstring const & lang) if (thesaurusAvailable(lang)) return make_pair(string(), string()); - if (!thes_path.empty()) { + if (!thes_path.empty()) result = getThesaurus(thes_path, lang); - } if (result.first.empty() || result.second.empty()) { string const sys_path = external_path(addName(lyx::support::package().system_support().absFileName(),dataDirectory())) ; result = getThesaurus(sys_path, lang); @@ -271,7 +269,8 @@ Thesaurus::Meanings Thesaurus::lookup(WordLangTuple const & wl) } -Thesaurus::Thesaurus() : d(new Thesaurus::Private) +Thesaurus::Thesaurus() + : d(new Thesaurus::Private) { } diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 719c3c2a1f..bd468d86a7 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -98,6 +98,7 @@ bool VCS::makeRCSRevision(string const &version, string &revis) const return true; } + bool VCS::checkparentdirs(FileName const & file, std::string const & pathname) { FileName dirname = file.onlyPath(); diff --git a/src/VSpace.cpp b/src/VSpace.cpp index 72315072d6..944d016ce3 100644 --- a/src/VSpace.cpp +++ b/src/VSpace.cpp @@ -200,6 +200,7 @@ string VSpace::asHTMLLength() const return result; } + int VSpace::inPixels(BufferView const & bv) const { // Height of a normal line in pixels (zoom factor considered) diff --git a/src/WordList.cpp b/src/WordList.cpp index 5dcbc14234..96b7c35ea7 100644 --- a/src/WordList.cpp +++ b/src/WordList.cpp @@ -42,7 +42,8 @@ WordList * theWordList(Language const & lang) } -void WordList::cleanupWordLists() { +void WordList::cleanupWordLists() +{ map::const_iterator it = theGlobalWordList.begin(); for (; it != theGlobalWordList.end(); ++it) delete it->second; diff --git a/src/factory.cpp b/src/factory.cpp index 858e53f138..e25a263049 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -564,12 +564,15 @@ Inset * readInset(Lexer & lex, Buffer * buf) } inset->setBuffer(*buf); } else { - // FIXME This branch should be made to use inset codes as the preceding - // branch does. Unfortunately, that will take some doing. It requires - // converting the representation of the insets in LyX files so that they - // use the inset names listed in Inset.cpp. Then, as above, the inset names - // can be translated to inset codes using insetCode(). And the insets' - // write() routines should use insetName() rather than hardcoding it. + // FIXME This branch should be made to use inset codes + // as the preceding branch does. Unfortunately, that + // will take some doing. It requires converting the + // representation of the insets in LyX files so that + // they use the inset names listed in Inset.cpp. Then, + // as above, the inset names can be translated to + // inset codes using insetCode(). And the insets' + // write() routines should use insetName() rather than + // hardcoding it. if (tmptok == "Quotes") { inset.reset(new InsetQuotes(buf)); } else if (tmptok == "External") { diff --git a/src/lengthcommon.cpp b/src/lengthcommon.cpp index a226a7e2e7..217c22b604 100644 --- a/src/lengthcommon.cpp +++ b/src/lengthcommon.cpp @@ -47,6 +47,7 @@ char const * const unit_name_gui[] = { N_("Column Width %"), N_("Page Width %"), N_("Line Width %"), N_("Text Height %"), N_("Page Height %"), "" }; + Length::UNIT unitFromString(string const & data) { int i = 0; @@ -208,6 +209,7 @@ LaTeXLength table[] = { } // namespace anon + const char * stringFromUnit(int unit) { if (unit < 0 || unit > num_units) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 74b045c4bb..73700cb4fc 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -623,6 +623,7 @@ string escape_for_regex(string s, bool match_latex) return s; } + /// Wrapper for lyx::regex_replace with simpler interface bool regex_replace(string const & s, string & t, string const & searchstr, string const & replacestr) @@ -637,6 +638,7 @@ bool regex_replace(string const & s, string & t, string const & searchstr, return rv; } + /** Checks if supplied string segment is well-formed from the standpoint of matching open-closed braces. ** ** Verify that closed braces exactly match open braces. This avoids that, for example, @@ -678,6 +680,7 @@ bool braces_match(string::const_iterator const & beg, return true; } + /** The class performing a match between a position in the document and the FindAdvOptions. **/ class MatchStringAdv { @@ -762,7 +765,8 @@ static docstring buffer_to_latex(Buffer & buffer) } -static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions const & opt) { +static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions const & opt) +{ docstring str; if (!opt.ignoreformat) { str = buffer_to_latex(buffer); @@ -787,7 +791,8 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co /// Return separation pos between the leading material and the rest -static size_t identifyLeading(string const & s) { +static size_t identifyLeading(string const & s) +{ string t = s; // @TODO Support \item[text] while (regex_replace(t, t, "^\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)\\*?\\{", "") @@ -801,7 +806,8 @@ static size_t identifyLeading(string const & s) { // Remove trailing closure of math, macros and environments, so to catch parts of them. -static int identifyClosing(string & t) { +static int identifyClosing(string & t) +{ int open_braces = 0; do { LYXERR(Debug::FIND, "identifyClosing(): t now is '" << t << "'"); @@ -1211,7 +1217,8 @@ int findMostBackwards(DocIterator & cur, MatchStringAdv const & match) /// Finds backwards -int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) { +int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) +{ if (! cur) return 0; // Backup of original position @@ -1290,7 +1297,8 @@ namespace { /** Check if 'len' letters following cursor are all non-lowercase */ -static bool allNonLowercase(DocIterator const & cur, int len) { +static bool allNonLowercase(DocIterator const & cur, int len) +{ pos_type end_pos = cur.pos() + len; for (pos_type pos = cur.pos(); pos != end_pos; ++pos) if (isLowerCase(cur.paragraph().getChar(pos))) @@ -1300,7 +1308,8 @@ static bool allNonLowercase(DocIterator const & cur, int len) { /** Check if first letter is upper case and second one is lower case */ -static bool firstUppercase(DocIterator const & cur) { +static bool firstUppercase(DocIterator const & cur) +{ char_type ch1, ch2; if (cur.pos() >= cur.lastpos() - 1) { LYXERR(Debug::FIND, "No upper-case at cur: " << cur); @@ -1321,13 +1330,15 @@ static bool firstUppercase(DocIterator const & cur) { ** ** \fixme What to do with possible further paragraphs in replace buffer ? **/ -static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case) { +static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case) +{ ParagraphList::iterator pit = buffer.paragraphs().begin(); pos_type right = pos_type(1); pit->changeCase(buffer.params(), pos_type(0), right, first_case); right = pit->size() + 1; pit->changeCase(buffer.params(), right, right, others_case); } + } // anon namespace /// diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 432b2e7109..f8a36d3e43 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -42,7 +42,7 @@ namespace { ParagraphList::const_iterator searchParagraph( ParagraphList::const_iterator p, - ParagraphList::const_iterator const & pend) + ParagraphList::const_iterator const & pend) { for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p) ; @@ -52,8 +52,8 @@ ParagraphList::const_iterator searchParagraph( ParagraphList::const_iterator searchCommand( - ParagraphList::const_iterator p, - ParagraphList::const_iterator const & pend) + ParagraphList::const_iterator p, + ParagraphList::const_iterator const & pend) { Layout const & bstyle = p->layout(); @@ -68,8 +68,8 @@ ParagraphList::const_iterator searchCommand( ParagraphList::const_iterator searchEnvironment( - ParagraphList::const_iterator p, - ParagraphList::const_iterator const & pend) + ParagraphList::const_iterator p, + ParagraphList::const_iterator const & pend) { Layout const & bstyle = p->layout(); size_t const depth = p->params().depth(); @@ -95,12 +95,13 @@ ParagraphList::const_iterator searchEnvironment( } -ParagraphList::const_iterator makeParagraph(Buffer const & buf, - odocstream & os, - OutputParams const & runparams, - Text const & text, - ParagraphList::const_iterator const & pbegin, - ParagraphList::const_iterator const & pend) +ParagraphList::const_iterator makeParagraph( + Buffer const & buf, + odocstream & os, + OutputParams const & runparams, + Text const & text, + ParagraphList::const_iterator const & pbegin, + ParagraphList::const_iterator const & pend) { ParagraphList const & paragraphs = text.paragraphs(); for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) { @@ -123,12 +124,13 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf, } -ParagraphList::const_iterator makeEnvironment(Buffer const & buf, - odocstream & os, - OutputParams const & runparams, - Text const & text, - ParagraphList::const_iterator const & pbegin, - ParagraphList::const_iterator const & pend) +ParagraphList::const_iterator makeEnvironment( + Buffer const & buf, + odocstream & os, + OutputParams const & runparams, + Text const & text, + ParagraphList::const_iterator const & pbegin, + ParagraphList::const_iterator const & pend) { ParagraphList const & paragraphs = text.paragraphs(); ParagraphList::const_iterator par = pbegin; @@ -244,12 +246,13 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf, } -ParagraphList::const_iterator makeCommand(Buffer const & buf, - odocstream & os, - OutputParams const & runparams, - Text const & text, - ParagraphList::const_iterator const & pbegin, - ParagraphList::const_iterator const & pend) +ParagraphList::const_iterator makeCommand( + Buffer const & buf, + odocstream & os, + OutputParams const & runparams, + Text const & text, + ParagraphList::const_iterator const & pbegin, + ParagraphList::const_iterator const & pend) { ParagraphList const & paragraphs = text.paragraphs(); ParagraphList::const_iterator par = pbegin; diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 92913afb4e..585ef8a3ec 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -45,9 +45,9 @@ namespace lyx { namespace { enum OpenEncoding { - none, - inputenc, - CJK + none, + inputenc, + CJK }; static int open_encoding_ = none; diff --git a/src/output_plaintext.cpp b/src/output_plaintext.cpp index d58c44a796..f0a383df4c 100644 --- a/src/output_plaintext.cpp +++ b/src/output_plaintext.cpp @@ -71,6 +71,7 @@ static pair addDepth(int depth, int ldepth) return make_pair(d, docstring(d, ' ')); } + void writePlaintextParagraph(Buffer const & buf, Paragraph const & par, odocstream & os, diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 336f5a88db..50ba0f4b0b 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -71,7 +71,8 @@ docstring escapeChar(char_type c, XHTMLStream::EscapeSettings e) // escape what needs escaping -docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e) { +docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e) +{ odocstringstream d; docstring::const_iterator it = str.begin(); docstring::const_iterator en = str.end(); @@ -109,7 +110,8 @@ string escapeChar(char c, XHTMLStream::EscapeSettings e) // escape what needs escaping -string htmlize(string const & str, XHTMLStream::EscapeSettings e) { +string htmlize(string const & str, XHTMLStream::EscapeSettings e) +{ ostringstream d; string::const_iterator it = str.begin(); string::const_iterator en = str.end(); @@ -915,10 +917,10 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf, void makeCommand(Buffer const & buf, - XHTMLStream & xs, - OutputParams const & runparams, - Text const & text, - ParagraphList::const_iterator const & pbegin) + XHTMLStream & xs, + OutputParams const & runparams, + Text const & text, + ParagraphList::const_iterator const & pbegin) { Layout const & style = pbegin->layout(); if (!style.counter.empty()) @@ -1020,7 +1022,8 @@ void xhtmlParagraphs(Text const & text, } -string alignmentToCSS(LyXAlignment align) { +string alignmentToCSS(LyXAlignment align) +{ switch (align) { case LYX_ALIGN_BLOCK: // we are NOT going to use text-align: justify!! diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index 0a902b7ef2..5810fd66e5 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -54,6 +54,7 @@ namespace lyx { using frontend::Painter; using frontend::FontMetrics; + RowPainter::RowPainter(PainterInfo & pi, Text const & text, pit_type pit, Row const & row, Bidi & bidi, int x, int y) : pi_(pi), text_(text), @@ -693,6 +694,7 @@ void RowPainter::paintTopLevelLabel() pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font); } + /** Check if the current paragraph is the last paragraph in a proof environment */ static int getEndLabel(pit_type p, Text const & text) -- 2.39.5