From 627b8df878fa8979c1a52827b80ea5aed5e6e92c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 16 Jul 2005 12:02:31 +0000 Subject: [PATCH] remove unneeded function Paragraph::checkInsertChar, fix small bug in boundary handling git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10240 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/buffer.C | 1 - src/insets/ChangeLog | 2 +- src/language.C | 7 +++---- src/language.h | 46 ++++++++++++------------------------------- src/paragraph.C | 9 +-------- src/paragraph_funcs.C | 2 -- src/text.C | 32 +++++++++++++----------------- 7 files changed, 32 insertions(+), 67 deletions(-) diff --git a/src/buffer.C b/src/buffer.C index d6c34394d0..76e9de907a 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -498,7 +498,6 @@ void Buffer::insertStringAsLines(ParagraphList & pars, { LyXFont font = fn; - pars[pit].checkInsertChar(font); // insert the string, don't insert doublespace bool space_inserted = true; for (string::const_iterator cit = str.begin(); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c6da67c6d8..7c52241d38 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -6792,7 +6792,7 @@ 2001-07-27 Juergen Vigna - * inset.h: remove not used font variable in parameter. + * inset.h: remove unused font variable in parameter. removed checkInsertChar in UpdatableInset as it was equal to the one in Inset and so not needed. diff --git a/src/language.C b/src/language.C index c811aac9a9..d19ca03c5b 100644 --- a/src/language.C +++ b/src/language.C @@ -31,6 +31,7 @@ Language const * ignore_language = &ignore_lang; Language latex_lang("latex", "latex", "Latex", false, 0, "latex", ""); Language const * latex_language = &latex_lang; + void Languages::read(string const & filename) { // We need to set the encoding of latex_lang @@ -93,11 +94,9 @@ void Languages::read(string const & filename) english_language = default_language; } + Language const * Languages::getLanguage(string const & language) const { const_iterator it = languagelist.find(language); - if (it != languagelist.end()) - return &it->second; - else - return 0; + return it == languagelist.end() ? 0 : &it->second; } diff --git a/src/language.h b/src/language.h index b0eeff259d..5e75174820 100644 --- a/src/language.h +++ b/src/language.h @@ -25,42 +25,28 @@ class Encoding; class Language { public: /// - Language() : RightToLeft_(false) {} + Language() : rightToLeft_(false) {} /// Language(std::string const & l, std::string const & b, std::string const & d, bool rtl, Encoding const * e, std::string const & c, std::string const & o) - : lang_(l), babel_(b), display_(d), RightToLeft_(rtl), + : lang_(l), babel_(b), display_(d), rightToLeft_(rtl), encoding_(e), code_(c), latex_options_(o) {} /// - std::string const & lang() const { - return lang_; - } + std::string const & lang() const { return lang_; } /// - std::string const & babel() const { - return babel_; - } + std::string const & babel() const { return babel_; } /// - std::string const & display() const { - return display_; - } + std::string const & display() const { return display_; } /// - bool RightToLeft() const { - return RightToLeft_; - } + bool RightToLeft() const { return rightToLeft_; } /// - Encoding const * encoding() const { - return encoding_; - } + Encoding const * encoding() const { return encoding_; } /// - std::string const & code() const { - return code_; - } + std::string const & code() const { return code_; } /// - std::string const & latex_options() const { - return latex_options_; - } + std::string const & latex_options() const { return latex_options_; } private: /// std::string lang_; @@ -69,7 +55,7 @@ private: /// std::string display_; /// - bool RightToLeft_; + bool rightToLeft_; /// Encoding const * encoding_; /// @@ -92,17 +78,11 @@ public: /// Language const * getLanguage(std::string const & language) const; /// - size_type size() const { - return languagelist.size(); - } + size_type size() const { return languagelist.size(); } /// - const_iterator begin() const { - return languagelist.begin(); - } + const_iterator begin() const { return languagelist.begin(); } /// - const_iterator end() const { - return languagelist.end(); - } + const_iterator end() const { return languagelist.end(); } /// private: diff --git a/src/paragraph.C b/src/paragraph.C index 38d5763ec9..bf272458c4 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -260,18 +260,11 @@ int Paragraph::erase(pos_type start, pos_type end) void Paragraph::insert(pos_type start, string const & str, LyXFont const & font) { - int size = str.size(); - for (int i = 0 ; i < size ; ++i) + for (size_t i = 0, n = str.size(); i != n ; ++i) insertChar(start + i, str[i], font); } -bool Paragraph::checkInsertChar(LyXFont &) -{ - return true; -} - - void Paragraph::insertChar(pos_type pos, Paragraph::value_type c, Change change) { diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 2cb63eaa38..a43217cc05 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -83,8 +83,6 @@ bool moveItem(Paragraph & from, Paragraph & to, if (tmpinset) to.insertInset(j, tmpinset, tmpfont, change); } else { - if (!to.checkInsertChar(tmpfont)) - return false; to.insertChar(j, tmpchar, tmpfont, change); } return true; diff --git a/src/text.C b/src/text.C index 45ffe8dc6a..33df190840 100644 --- a/src/text.C +++ b/src/text.C @@ -424,14 +424,15 @@ int LyXText::singleWidth(Paragraph const & par, // The most common case is handled first (Asger) if (IsPrintable(c)) { - if (font.language()->RightToLeft()) { + Language const * language = font.language(); + if (language->RightToLeft()) { if ((lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 || lyxrc.font_norm_type == LyXRC::ISO_10646_1) - && font.language()->lang() == "arabic") { + && language->lang() == "arabic") { if (Encodings::IsComposeChar_arabic(c)) return 0; c = par.transformChar(c, pos); - } else if (font.language()->lang() == "hebrew" && + } else if (language->lang() == "hebrew" && Encodings::IsComposeChar_hebrew(c)) return 0; } @@ -2066,8 +2067,9 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const return 0; pos_type ppos = sl.pos(); - //// Correct position in front of big insets - if (ppos && boundary) + // Correct position in front of big insets + bool const boundary_correction = ppos != 0 && boundary; + if (boundary_correction) --ppos; Row const & row = par.getRow(ppos); @@ -2108,22 +2110,16 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const x -= singleWidth(par, body_pos - 1); } - if (hfillExpansion(par, row, pos)) { - x += singleWidth(par, pos); - if (pos >= body_pos) - x += m.hfill; - else - x += m.label_hfill; - } else if (par.isSeparator(pos)) { - x += singleWidth(par, pos); - if (pos >= body_pos) - x += m.separator; - } else - x += singleWidth(par, pos); + x += singleWidth(par, pos); + + if (hfillExpansion(par, row, pos)) + x += (pos >= body_pos) ? m.hfill : m.label_hfill; + else if (par.isSeparator(pos) && pos >= body_pos) + x += m.separator; } // see correction above - if (ppos && boundary) + if (boundary_correction) x += singleWidth(par, ppos); return int(x); -- 2.39.2