STORM-276 Insert braces around if/for/while loops

meow-7.2.2
Kitty Barnett 2012-06-11 13:39:45 +02:00
parent 20210455f5
commit 80b1a2c0a8
6 changed files with 96 additions and 0 deletions

View File

@ -599,7 +599,9 @@ std::string LLLineEditor::getMisspelledWord(U32 pos) const
for (std::list<std::pair<U32, U32> >::const_iterator it = mMisspellRanges.begin(); it != mMisspellRanges.end(); ++it)
{
if ( (it->first <= pos) && (it->second >= pos) )
{
return wstring_to_utf8str(mText.getWString().substr(it->first, it->second - it->first));
}
}
return LLStringUtil::null;
}
@ -609,7 +611,9 @@ bool LLLineEditor::isMisspelledWord(U32 pos) const
for (std::list<std::pair<U32, U32> >::const_iterator it = mMisspellRanges.begin(); it != mMisspellRanges.end(); ++it)
{
if ( (it->first <= pos) && (it->second >= pos) )
{
return true;
}
}
return false;
}
@ -1890,7 +1894,9 @@ void LLLineEditor::draw()
// Find the start of the first word
U32 word_start = 0, word_end = 0;
while ( (word_start < text.length()) && (!LLStringOps::isAlpha(text[word_start])) )
{
word_start++;
}
// Iterate over all words in the text block and check them one by one
mMisspellRanges.clear();
@ -1906,17 +1912,23 @@ void LLLineEditor::draw()
word_end++;
}
if (word_end > text.length())
{
break;
}
// Don't process words shorter than 3 characters
std::string word = wstring_to_utf8str(text.substr(word_start, word_end - word_start));
if ( (word.length() >= 3) && (!LLSpellChecker::instance().checkSpelling(word)) )
{
mMisspellRanges.push_back(std::pair<U32, U32>(start + word_start, start + word_end));
}
// Find the start of the next word
word_start = word_end + 1;
while ( (word_start < text.length()) && (!LLWStringUtil::isPartOfWord(text[word_start])) )
{
word_start++;
}
}
mSpellCheckStart = start;
@ -1928,19 +1940,27 @@ void LLLineEditor::draw()
{
// Skip over words that aren't (partially) visible
if ( ((it->first < start) && (it->second < start)) || (it->first > end) )
{
continue;
}
// Skip the current word if the user is still busy editing it
if ( (!mSpellCheckTimer.hasExpired()) && (it->first <= (U32)mCursorPos) && (it->second >= (U32)mCursorPos) )
{
continue;
}
S32 pxWidth = getRect().getWidth();
S32 pxStart = findPixelNearestPos(it->first - getCursor());
if (pxStart > pxWidth)
{
continue;
}
S32 pxEnd = findPixelNearestPos(it->second - getCursor());
if (pxEnd > pxWidth)
{
pxEnd = pxWidth;
}
S32 pxBottom = (S32)(text_bottom + mGLFont->getDescenderHeight());
@ -1949,7 +1969,9 @@ void LLLineEditor::draw()
{
gl_line_2d(pxStart, pxBottom, pxStart + 2, pxBottom - 2);
if (pxStart + 3 < pxEnd)
{
gl_line_2d(pxStart + 2, pxBottom - 3, pxStart + 4, pxBottom - 1);
}
pxStart += 4;
}
}
@ -2576,9 +2598,13 @@ void LLLineEditor::showContextMenu(S32 x, S32 y)
if (hasSelection())
{
if ( (mCursorPos < llmin(mSelectionStart, mSelectionEnd)) || (mCursorPos > llmax(mSelectionStart, mSelectionEnd)) )
{
deselect();
}
else
{
setCursor(llmax(mSelectionStart, mSelectionEnd));
}
}
bool use_spellcheck = getSpellCheck(), is_misspelled = false;

View File

@ -3909,9 +3909,13 @@ void LLContextMenu::show(S32 x, S32 y, LLView* spawning_view)
arrange();
if (spawning_view)
{
mSpawningViewHandle = spawning_view->getHandle();
}
else
{
mSpawningViewHandle.markDead();
}
LLView::setVisible(TRUE);
}

View File

@ -75,13 +75,17 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str
{
suggestions.clear();
if ( (!mHunspell) || (word.length() < 3) )
{
return 0;
}
char** suggestion_list; int suggestion_cnt = 0;
if ( (suggestion_cnt = mHunspell->suggest(&suggestion_list, word.c_str())) != 0 )
{
for (int suggestion_index = 0; suggestion_index < suggestion_cnt; suggestion_index++)
{
suggestions.push_back(suggestion_list[suggestion_index]);
}
mHunspell->free_list(&suggestion_list, suggestion_cnt);
}
return suggestions.size();
@ -94,7 +98,9 @@ const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language)
{
const LLSD& dict_entry = *it;
if (dict_language == dict_entry["language"].asString())
{
return dict_entry;
}
}
return LLSD();
}
@ -104,7 +110,9 @@ void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
{
const std::string dict_language = dict_info["language"].asString();
if (dict_language.empty())
{
return;
}
for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
{
@ -131,7 +139,9 @@ void LLSpellChecker::refreshDictionaryMap()
{
llifstream app_file(app_path + "dictionaries.xml", std::ios::binary);
if ( (!app_file.is_open()) || (0 == LLSDSerialize::fromXMLDocument(sDictMap, app_file)) || (0 == sDictMap.size()) )
{
return;
}
}
// Load user installed dictionary information
@ -141,7 +151,9 @@ void LLSpellChecker::refreshDictionaryMap()
LLSD custom_dict_map;
LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file);
for (LLSD::array_const_iterator it = custom_dict_map.beginArray(); it != custom_dict_map.endArray(); ++it)
{
setDictionaryData(*it);
}
custom_file.close();
}
@ -197,7 +209,9 @@ void LLSpellChecker::addToDictFile(const std::string& dict_path, const std::stri
{
// Skip over the first line since that's just a line count
if (0 != line_num)
{
word_list.push_back(word);
}
line_num++;
}
}
@ -215,7 +229,9 @@ void LLSpellChecker::addToDictFile(const std::string& dict_path, const std::stri
{
file_out << word_list.size() << std::endl;
for (std::vector<std::string>::const_iterator itWord = word_list.begin(); itWord != word_list.end(); ++itWord)
{
file_out << *itWord << std::endl;
}
file_out.close();
}
}
@ -249,13 +265,19 @@ void LLSpellChecker::setSecondaryDictionaries(dict_list_t dict_list)
{
const LLSD dict_entry = getDictionaryData(*it_added);
if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) )
{
continue;
}
const std::string strFileDic = dict_entry["name"].asString() + ".dic";
if (gDirUtilp->fileExists(user_path + strFileDic))
{
mHunspell->add_dic((user_path + strFileDic).c_str());
}
else if (gDirUtilp->fileExists(app_path + strFileDic))
{
mHunspell->add_dic((app_path + strFileDic).c_str());
}
}
mDictSecondary = dict_list;
sSettingsChangeSignal();
@ -287,11 +309,17 @@ void LLSpellChecker::initHunspell(const std::string& dict_name)
const std::string filename_aff = dict_entry["name"].asString() + ".aff";
const std::string filename_dic = dict_entry["name"].asString() + ".dic";
if ( (gDirUtilp->fileExists(user_path + filename_aff)) && (gDirUtilp->fileExists(user_path + filename_dic)) )
{
mHunspell = new Hunspell((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());
}
else if ( (gDirUtilp->fileExists(app_path + filename_aff)) && (gDirUtilp->fileExists(app_path + filename_dic)) )
{
mHunspell = new Hunspell((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());
}
if (!mHunspell)
{
return;
}
mDictName = dict_name;
mDictFile = dict_entry["name"].asString();
@ -325,13 +353,19 @@ void LLSpellChecker::initHunspell(const std::string& dict_name)
{
const LLSD dict_entry = getDictionaryData(*it);
if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) )
{
continue;
}
const std::string filename_dic = dict_entry["name"].asString() + ".dic";
if (gDirUtilp->fileExists(user_path + filename_dic))
{
mHunspell->add_dic((user_path + filename_dic).c_str());
}
else if (gDirUtilp->fileExists(app_path + filename_dic))
{
mHunspell->add_dic((app_path + filename_dic).c_str());
}
}
}
@ -382,5 +416,7 @@ void LLSpellChecker::setUseSpellCheck(const std::string& dict_name)
void LLSpellChecker::initClass()
{
if (sDictMap.isUndefined())
{
refreshDictionaryMap();
}
}

View File

@ -582,7 +582,9 @@ void LLTextBase::drawText()
// Find the start of the first word
U32 word_start = seg_start, word_end = -1;
while ( (word_start < wstrText.length()) && (!LLStringOps::isAlpha(wstrText[word_start])) )
{
word_start++;
}
// Iterate over all words in the text block and check them one by one
while (word_start < seg_end)
@ -597,7 +599,9 @@ void LLTextBase::drawText()
word_end++;
}
if (word_end > seg_end)
{
break;
}
// Don't process words shorter than 3 characters
std::string word = wstring_to_utf8str(wstrText.substr(word_start, word_end - word_start));
@ -609,7 +613,9 @@ void LLTextBase::drawText()
// Find the start of the next word
word_start = word_end + 1;
while ( (word_start < seg_end) && (!LLWStringUtil::isPartOfWord(wstrText[word_start])) )
{
word_start++;
}
}
}
@ -695,12 +701,16 @@ void LLTextBase::drawText()
{
gl_line_2d(squiggle_start, squiggle_bottom, squiggle_start + 2, squiggle_bottom - 2);
if (squiggle_start + 3 < squiggle_end)
{
gl_line_2d(squiggle_start + 2, squiggle_bottom - 3, squiggle_start + 4, squiggle_bottom - 1);
}
squiggle_start += 4;
}
if (misspell_it->second > seg_end)
{
break;
}
++misspell_it;
}
@ -1297,7 +1307,9 @@ std::string LLTextBase::getMisspelledWord(U32 pos) const
for (std::list<std::pair<U32, U32> >::const_iterator it = mMisspellRanges.begin(); it != mMisspellRanges.end(); ++it)
{
if ( (it->first <= pos) && (it->second >= pos) )
{
return wstring_to_utf8str(getWText().substr(it->first, it->second - it->first));
}
}
return LLStringUtil::null;
}
@ -1307,7 +1319,9 @@ bool LLTextBase::isMisspelledWord(U32 pos) const
for (std::list<std::pair<U32, U32> >::const_iterator it = mMisspellRanges.begin(); it != mMisspellRanges.end(); ++it)
{
if ( (it->first <= pos) && (it->second >= pos) )
{
return true;
}
}
return false;
}

View File

@ -1960,9 +1960,13 @@ void LLTextEditor::showContextMenu(S32 x, S32 y)
if (hasSelection())
{
if ( (mCursorPos < llmin(mSelectionStart, mSelectionEnd)) || (mCursorPos > llmax(mSelectionStart, mSelectionEnd)) )
{
deselect();
}
else
{
setCursorPos(llmax(mSelectionStart, mSelectionEnd));
}
}
bool use_spellcheck = getSpellCheck(), is_misspelled = false;

View File

@ -101,7 +101,9 @@ void LLFloaterSpellCheckerSettings::onBtnOK()
LLScrollListCtrl* list_ctrl = findChild<LLScrollListCtrl>("spellcheck_active_list");
std::vector<LLScrollListItem*> list_items = list_ctrl->getAllData();
for (std::vector<LLScrollListItem*>::const_iterator item_it = list_items.begin(); item_it != list_items.end(); ++item_it)
{
list_dict.push_back((*item_it)->getColumn(0)->getValue().asString());
}
}
gSavedSettings.setString("SpellCheckDictionary", boost::join(list_dict, ","));
@ -128,7 +130,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
LLComboBox* dict_combo = findChild<LLComboBox>("spellcheck_main_combo");
std::string dict_cur = dict_combo->getSelectedItemLabel();
if ((dict_cur.empty() || from_settings) && (LLSpellChecker::getUseSpellCheck()))
{
dict_cur = LLSpellChecker::instance().getActiveDictionary();
}
dict_combo->clearRows();
dict_combo->setEnabled(enabled);
@ -139,10 +143,14 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
{
const LLSD& dict = *dict_it;
if ( (dict["installed"].asBoolean()) && (dict["is_primary"].asBoolean()) && (dict.has("language")) )
{
dict_combo->add(dict["language"].asString());
}
}
if (!dict_combo->selectByValue(dict_cur))
{
dict_combo->clear();
}
}
// Populate the available and active dictionary list
@ -153,7 +161,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
if ( ((!avail_ctrl->getItemCount()) && (!active_ctrl->getItemCount())) || (from_settings) )
{
if (LLSpellChecker::getUseSpellCheck())
{
active_list = LLSpellChecker::instance().getSecondaryDictionaries();
}
}
else
{
@ -162,7 +172,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
{
std::string dict = (*item_it)->getColumn(0)->getValue().asString();
if (dict_cur != dict)
{
active_list.push_back(dict);
}
}
}