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
This commit is contained in:
André Pönitz 2005-07-16 12:02:31 +00:00
parent 316b56e2bc
commit 627b8df878
7 changed files with 32 additions and 67 deletions

View File

@ -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();

View File

@ -6792,7 +6792,7 @@
2001-07-27 Juergen Vigna <jug@sad.it>
* 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.

View File

@ -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;
}

View File

@ -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:

View File

@ -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)
{

View File

@ -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;

View File

@ -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);