summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-05-12 12:59:07 -0400
committerOz Linden <oz@lindenlab.com>2012-05-12 12:59:07 -0400
commit0d11c70e8e68ea2c33cdf01b56b6f2f81ed46f1e (patch)
treeda5527658213b0446016a0a0ae88e3b4ba0c49dd
parent0f5d636a1a45500fc49cc713e6f93160c4fafe0b (diff)
STORM-1738: fix class name and other coding standards issues
-rw-r--r--indra/newview/llautoreplace.cpp107
-rw-r--r--indra/newview/llautoreplace.h18
-rw-r--r--indra/newview/llfloaterautoreplacesettings.cpp26
-rw-r--r--indra/newview/llimfloater.cpp2
-rw-r--r--indra/newview/llnearbychatbar.cpp2
5 files changed, 90 insertions, 65 deletions
diff --git a/indra/newview/llautoreplace.cpp b/indra/newview/llautoreplace.cpp
index fa46f53e96..10005aee9f 100644
--- a/indra/newview/llautoreplace.cpp
+++ b/indra/newview/llautoreplace.cpp
@@ -30,20 +30,20 @@
#include "llviewercontrol.h"
#include "llnotificationsutil.h"
-AutoReplace* AutoReplace::sInstance;
+LLAutoReplace* LLAutoReplace::sInstance;
-AutoReplace::AutoReplace()
+LLAutoReplace::LLAutoReplace()
{
sInstance = this;
sInstance->loadFromDisk();
}
-AutoReplace::~AutoReplace()
+LLAutoReplace::~LLAutoReplace()
{
sInstance = NULL;
}
-void AutoReplace::autoreplaceCallback(LLUIString& inputText, S32& cursorPos)
+void LLAutoReplace::autoreplaceCallback(LLUIString& inputText, S32& cursorPos)
{
static LLCachedControl<bool> perform_autoreplace(gSavedSettings, "AutoReplace");
if(perform_autoreplace)
@@ -52,16 +52,22 @@ void AutoReplace::autoreplaceCallback(LLUIString& inputText, S32& cursorPos)
S32 wordEnd = cursorPos-1;
if(wordEnd < 1)
+ {
return;
-
+ }
+
LLWString text = inputText.getWString();
if(text.size()<1)
+ {
return;
-
+ }
+
if(LLWStringUtil::isPartOfWord(text[wordEnd]))
+ {
return;//we only check on word breaks
-
+ }
+
wordEnd--;
if(LLWStringUtil::isPartOfWord(text[wordEnd]))
@@ -80,11 +86,11 @@ void AutoReplace::autoreplaceCallback(LLUIString& inputText, S32& cursorPos)
std::string strLastWord = std::string(text.begin(), text.end());
std::string lastTypedWord = strLastWord.substr(wordStart, wordEnd-wordStart);
- std::string replaceedWord(replaceWord(lastTypedWord));
+ std::string replacedWord(replaceWord(lastTypedWord));
- if(replaceedWord != lastTypedWord)
+ if(replacedWord != lastTypedWord)
{
- LLWString strNew = utf8str_to_wstring(replaceedWord);
+ LLWString strNew = utf8str_to_wstring(replacedWord);
LLWString strOld = utf8str_to_wstring(lastTypedWord);
int nDiff = strNew.size() - strOld.size();
@@ -97,20 +103,21 @@ void AutoReplace::autoreplaceCallback(LLUIString& inputText, S32& cursorPos)
}
}
-AutoReplace* AutoReplace::getInstance()
+LLAutoReplace* LLAutoReplace::getInstance()
{
- if(sInstance)return sInstance;
- else
+ if(!sInstance)
{
- sInstance = new AutoReplace();
- return sInstance;
+ sInstance = new LLAutoReplace();
}
+ return sInstance;
}
-void AutoReplace::save()
+
+void LLAutoReplace::save()
{
saveToDisk(mAutoReplaces);
}
-std::string AutoReplace::getFileName()
+
+std::string LLAutoReplace::getFileName()
{
std::string path=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
@@ -120,7 +127,8 @@ std::string AutoReplace::getFileName()
}
return path;
}
-std::string AutoReplace::getDefaultFileName()
+
+std::string LLAutoReplace::getDefaultFileName()
{
std::string path=gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "");
@@ -130,7 +138,8 @@ std::string AutoReplace::getDefaultFileName()
}
return path;
}
-LLSD AutoReplace::exportList(std::string listName)
+
+LLSD LLAutoReplace::exportList(std::string listName)
{
LLSD toReturn;
if(mAutoReplaces.has(listName))
@@ -141,12 +150,12 @@ LLSD AutoReplace::exportList(std::string listName)
}
return toReturn;
}
-BOOL AutoReplace::addReplacementList(LLSD newList)
+
+BOOL LLAutoReplace::addReplacementList(LLSD newList)
{
if(newList.has("listName"))
{
std::string name = newList["listName"];
- //if(!mAutoReplaces.has(name)){
LLSD newPart;
newPart["data"]=newList["data"];
newPart["enabled"]=TRUE;
@@ -155,11 +164,11 @@ BOOL AutoReplace::addReplacementList(LLSD newList)
mAutoReplaces[name]=newPart;
return TRUE;
-
}
return FALSE;
}
-BOOL AutoReplace::removeReplacementList(std::string listName)
+
+BOOL LLAutoReplace::removeReplacementList(std::string listName)
{
if(mAutoReplaces.has(listName))
{
@@ -168,7 +177,8 @@ BOOL AutoReplace::removeReplacementList(std::string listName)
}
return FALSE;
}
-BOOL AutoReplace::setListEnabled(std::string listName, BOOL enabled)
+
+BOOL LLAutoReplace::setListEnabled(std::string listName, BOOL enabled)
{
if(mAutoReplaces.has(listName))
{
@@ -178,7 +188,8 @@ BOOL AutoReplace::setListEnabled(std::string listName, BOOL enabled)
return FALSE;
}
-BOOL AutoReplace::setListPriority(std::string listName, int priority)
+
+BOOL LLAutoReplace::setListPriority(std::string listName, int priority)
{
if(mAutoReplaces.has(listName))
{
@@ -187,11 +198,13 @@ BOOL AutoReplace::setListPriority(std::string listName, int priority)
}
return FALSE;
}
-LLSD AutoReplace::getAutoReplaces()
+
+LLSD LLAutoReplace::getAutoReplaces()
{
return mAutoReplaces;
}
-void AutoReplace::loadFromDisk()
+
+void LLAutoReplace::loadFromDisk()
{
std::string filename=getFileName();
if (filename.empty())
@@ -214,8 +227,11 @@ void AutoReplace::loadFromDisk()
}
file.close();
saveToDisk(blankllsd);
- }else
- saveToDisk(getExampleLLSD());
+ }
+ else
+ {
+ saveToDisk(getExampleLLSD());
+ }
}
else
{
@@ -228,7 +244,8 @@ void AutoReplace::loadFromDisk()
file.close();
}
}
-void AutoReplace::saveToDisk(LLSD newSettings)
+
+void LLAutoReplace::saveToDisk(LLSD newSettings)
{
mAutoReplaces=newSettings;
std::string filename=getFileName();
@@ -237,7 +254,8 @@ void AutoReplace::saveToDisk(LLSD newSettings)
LLSDSerialize::toPrettyXML(mAutoReplaces, file);
file.close();
}
-void AutoReplace::runTest()
+
+void LLAutoReplace::runTest()
{
std::string startS("He just abandonned all his abilties");
std::string endS = replaceWords(startS);
@@ -245,7 +263,8 @@ void AutoReplace::runTest()
}
-BOOL AutoReplace::saveListToDisk(std::string listName, std::string fileName)
+
+BOOL LLAutoReplace::saveListToDisk(std::string listName, std::string fileName)
{
if(mAutoReplaces.has(listName))
{
@@ -257,7 +276,8 @@ BOOL AutoReplace::saveListToDisk(std::string listName, std::string fileName)
}
return FALSE;
}
-LLSD AutoReplace::getAutoReplaceEntries(std::string listName)
+
+LLSD LLAutoReplace::getAutoReplaceEntries(std::string listName)
{
LLSD toReturn;
if(mAutoReplaces.has(listName))
@@ -266,7 +286,8 @@ LLSD AutoReplace::getAutoReplaceEntries(std::string listName)
}
return toReturn;
}
-std::string AutoReplace::replaceWord(std::string currentWord)
+
+std::string LLAutoReplace::replaceWord(std::string currentWord)
{
static LLCachedControl<bool> perform_autoreplace(gSavedSettings, "AutoReplace");
if(!(perform_autoreplace))return currentWord;
@@ -293,11 +314,15 @@ std::string AutoReplace::replaceWord(std::string currentWord)
}
return currentWord;
}
-std::string AutoReplace::replaceWords(std::string words)
+
+std::string LLAutoReplace::replaceWords(std::string words)
{
static LLCachedControl<bool> perform_autoreplace(gSavedSettings, "AutoReplace");
- if(!(perform_autoreplace))return words;
-
+ if(!(perform_autoreplace))
+ {
+ return words;
+ }
+
boost_tokenizer tokens(words, boost::char_separator<char>(" "));
for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter)
{
@@ -320,7 +345,8 @@ std::string AutoReplace::replaceWords(std::string words)
}
return words;
}
-BOOL AutoReplace::addEntryToList(std::string wrong, std::string right, std::string listName)
+
+BOOL LLAutoReplace::addEntryToList(std::string wrong, std::string right, std::string listName)
{
// *HACK: Make sure the "Custom" list exists, because the design of this
// system prevents us from updating it by changing the original file...
@@ -339,7 +365,8 @@ BOOL AutoReplace::addEntryToList(std::string wrong, std::string right, std::stri
return FALSE;
}
-BOOL AutoReplace::removeEntryFromList(std::string wrong, std::string listName)
+
+BOOL LLAutoReplace::removeEntryFromList(std::string wrong, std::string listName)
{
if(mAutoReplaces.has(listName))
{
@@ -352,7 +379,7 @@ BOOL AutoReplace::removeEntryFromList(std::string wrong, std::string listName)
return FALSE;
}
-LLSD AutoReplace::getExampleLLSD()
+LLSD LLAutoReplace::getExampleLLSD()
{
LLSD toReturn;
diff --git a/indra/newview/llautoreplace.h b/indra/newview/llautoreplace.h
index 6c531d0040..27533c4ef1 100644
--- a/indra/newview/llautoreplace.h
+++ b/indra/newview/llautoreplace.h
@@ -17,19 +17,19 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AUTO_REPLACE
-#define AUTO_REPLACE
+#ifndef LLAUTOREPLACE_H
+#define LLAUTOREPLACE_H
#include "lllineeditor.h"
-class AutoReplace : public LLSingleton<AutoReplace>
+class LLAutoReplace : public LLSingleton<LLAutoReplace>
{
- AutoReplace();
- ~AutoReplace();
- static AutoReplace* sInstance;
+ LLAutoReplace();
+ ~LLAutoReplace();
+ static LLAutoReplace* sInstance;
public:
void autoreplaceCallback(LLUIString& inputText, S32& cursorPos);
- static AutoReplace* getInstance();
+ static LLAutoReplace* getInstance();
BOOL addReplacementList(LLSD newList);
BOOL removeReplacementList(std::string listName);
BOOL setListEnabled(std::string listName, BOOL enabled);
@@ -48,7 +48,7 @@ public:
void loadFromDisk();
private:
- friend class LLSingleton<AutoReplace>;
+ friend class LLSingleton<LLAutoReplace>;
void saveToDisk(LLSD newSettings);
LLSD getExampleLLSD();
std::string getFileName();
@@ -58,6 +58,4 @@ private:
};
-
-
#endif
diff --git a/indra/newview/llfloaterautoreplacesettings.cpp b/indra/newview/llfloaterautoreplacesettings.cpp
index 3dfcfba936..1a52e5d493 100644
--- a/indra/newview/llfloaterautoreplacesettings.cpp
+++ b/indra/newview/llfloaterautoreplacesettings.cpp
@@ -130,7 +130,7 @@ void LLFloaterAutoReplaceSettings::updateItemsList()
updateListControlsEnabled(TRUE);
std::string listName= namesList->getFirstSelected()->getColumn(0)->getValue().asString();
- LLSD listData = AutoReplace::getInstance()->getAutoReplaceEntries(listName);
+ LLSD listData = LLAutoReplace::getInstance()->getAutoReplaceEntries(listName);
childSetValue("ac_list_enabled",listData["enabled"].asBoolean());
childSetValue("ac_text_name",listName);
childSetValue("ac_priority",listData["priority"]);
@@ -166,7 +166,7 @@ void LLFloaterAutoReplaceSettings::updateNamesList()
updateItemsList();
return;
}
- LLSD autoReplaces = AutoReplace::getInstance()->getAutoReplaces();
+ LLSD autoReplaces = LLAutoReplace::getInstance()->getAutoReplaces();
LLSD::map_const_iterator loc_it = autoReplaces.beginMap();
LLSD::map_const_iterator loc_end = autoReplaces.endMap();
for ( ; loc_it != loc_end; ++loc_it)
@@ -230,7 +230,7 @@ void LLFloaterAutoReplaceSettings::updateEnabledStuff()
childSetEnabled("ac_list_entry", autoreplace);
updateListControlsEnabled(autoreplace);
updateNamesList();
- AutoReplace::getInstance()->save();
+ LLAutoReplace::getInstance()->save();
}
void LLFloaterAutoReplaceSettings::setData(void * data)
@@ -255,12 +255,12 @@ void LLFloaterAutoReplaceSettings::onEntrySettingChange(LLUICtrl* caller, void*
if ( self )
{
std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString();
- AutoReplace::getInstance()->setListEnabled(listName,self->childGetValue("ac_list_enabled").asBoolean());
- AutoReplace::getInstance()->setListPriority(listName,self->childGetValue("ac_priority").asInteger());
+ LLAutoReplace::getInstance()->setListEnabled(listName,self->childGetValue("ac_list_enabled").asBoolean());
+ LLAutoReplace::getInstance()->setListPriority(listName,self->childGetValue("ac_priority").asInteger());
//sInstance->updateEnabledStuff();
self->updateItemsList();
- AutoReplace::getInstance()->save();
+ LLAutoReplace::getInstance()->save();
}
}
}
@@ -277,9 +277,9 @@ void LLFloaterAutoReplaceSettings::deleteEntry(void* data)
if((self->entryList->getAllSelected().size())>0)
{
std::string wrong= self->entryList->getFirstSelected()->getColumn(0)->getValue().asString();
- AutoReplace::getInstance()->removeEntryFromList(wrong,listName);
+ LLAutoReplace::getInstance()->removeEntryFromList(wrong,listName);
self->updateItemsList();
- AutoReplace::getInstance()->save();
+ LLAutoReplace::getInstance()->save();
}
}
}
@@ -301,7 +301,7 @@ void LLFloaterAutoReplaceSettings::loadList(void* data)
}
file.close();
gSavedSettings.setBOOL("AutoReplace",true);
- AutoReplace::getInstance()->addReplacementList(blankllsd);
+ LLAutoReplace::getInstance()->addReplacementList(blankllsd);
if ( data )
{
LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )data;
@@ -319,7 +319,7 @@ void LLFloaterAutoReplaceSettings::removeList(void* data)
if ( self )
{
std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString();
- AutoReplace::getInstance()->removeReplacementList(listName);
+ LLAutoReplace::getInstance()->removeReplacementList(listName);
self->updateEnabledStuff();
}
@@ -339,7 +339,7 @@ void LLFloaterAutoReplaceSettings::exportList(void *data)
{
llofstream file;
file.open(picker.getFirstFile().c_str());
- LLSDSerialize::toPrettyXML(AutoReplace::getInstance()->exportList(listName), file);
+ LLSDSerialize::toPrettyXML(LLAutoReplace::getInstance()->exportList(listName), file);
file.close();
}
}
@@ -357,9 +357,9 @@ void LLFloaterAutoReplaceSettings::addEntry(void* data)
std::string right = self->mNewText->getText();
if(wrong != "" && right != "")
{
- AutoReplace::getInstance()->addEntryToList(wrong, right, listName);
+ LLAutoReplace::getInstance()->addEntryToList(wrong, right, listName);
self->updateItemsList();
- AutoReplace::getInstance()->save();
+ LLAutoReplace::getInstance()->save();
}
}
}
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 670db3773e..63eedcdfea 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -256,7 +256,7 @@ BOOL LLIMFloater::postBuild()
// enable line history support for instant message bar
mInputEditor->setEnableLineHistory(TRUE);
// *TODO Establish LineEditor with autoreplace callback
- mInputEditor->setAutoreplaceCallback(boost::bind(&AutoReplace::autoreplaceCallback, AutoReplace::getInstance(), _1, _2));
+ mInputEditor->setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2));
LLFontGL* font = LLViewerChat::getChatFont();
mInputEditor->setFont(font);
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index a3aeadbfb8..2a1d3b9fc5 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -88,7 +88,7 @@ BOOL LLNearbyChatBar::postBuild()
{
mChatBox = getChild<LLLineEditor>("chat_box");
- mChatBox->setAutoreplaceCallback(boost::bind(&AutoReplace::autoreplaceCallback, AutoReplace::getInstance(), _1, _2));
+ mChatBox->setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2));
mChatBox->setCommitCallback(boost::bind(&LLNearbyChatBar::onChatBoxCommit, this));
mChatBox->setKeystrokeCallback(&onChatBoxKeystroke, this);
mChatBox->setFocusLostCallback(boost::bind(&onChatBoxFocusLost, _1, this));