Codebase list mozc / 42db3de
Added std:: prefix for Mac and GUI tools BUG=#392 TEST=unittest REF_BUG=71969651 REF_CL=181934774 REF_TIME=2018-01-15T17:41:24+09:00 REF_TIME_RAW=1516005684 +0900 Hiroyuki Komatsu 6 years ago
30 changed file(s) with 125 addition(s) and 118 deletion(s). Raw diff Collapse all Expand all
2929
3030 MAJOR=2
3131 MINOR=23
32 BUILD=2789
32 BUILD=2790
3333 REVISION=102
3434 # This version represents the version of Mozc IME engine (converter, predictor,
3535 # etc.). This version info is included both in the Mozc server and in the Mozc
4949 POSListProvider::POSListProvider() = default;
5050 POSListProvider::~POSListProvider() = default;
5151
52 void POSListProvider::GetPOSList(vector<string> *pos_list) const {
52 void POSListProvider::GetPOSList(std::vector<string> *pos_list) const {
5353 SerializedStringArray array;
5454 CHECK(array.Init(LoadEmbeddedFile(kPosArray)));
5555 pos_list->resize(array.size());
3939 POSListProvider();
4040 ~POSListProvider() override;
4141
42 void GetPOSList(vector<string> *pos_list) const override;
42 void GetPOSList(std::vector<string> *pos_list) const override;
4343 };
4444
4545 } // namespace mozc
117117 QPainter painter(this);
118118 const QRect image_rect = product_image_->rect();
119119 // allow clipping on right / bottom borders
120 const QRect draw_rect(max(5, width() - image_rect.width() - 15),
121 max(0, color_frame->y() - image_rect.height()),
120 const QRect draw_rect(std::max(5, width() - image_rect.width() - 15),
121 std::max(0, color_frame->y() - image_rect.height()),
122122 image_rect.width(), image_rect.height());
123123 painter.drawImage(draw_rect, *product_image_.get());
124124 }
6969
7070 TranslationDataImpl();
7171 ~TranslationDataImpl() {
72 for (map<string, QTranslator *>::iterator it = translators_.begin();
72 for (std::map<string, QTranslator *>::iterator it = translators_.begin();
7373 it != translators_.end(); ++it) {
7474 delete it->second;
7575 }
7777 }
7878
7979 private:
80 map<string, QTranslator *> translators_;
80 std::map<string, QTranslator *> translators_;
8181 QTranslator default_translator_;
8282 QFont font_;
8383 #ifdef MOZC_SHOW_BUILD_NUMBER_ON_TITLE
117117 }
118118 QTranslator *translator = new QTranslator;
119119 CHECK(translator);
120 translators_.insert(make_pair(resource_name, translator));
120 translators_.insert(std::make_pair(resource_name, translator));
121121
122122 // Load ":/<resource_name>_<lang>.qm" from a qrc file.
123123 if (translator->load(QLocale::system(), resource_name, "_", ":/", ".qm")) {
102102 }
103103 }
104104 #else
105 InputFileStream is(lock_name.c_str(), ios::binary|ios::in);
105 InputFileStream is(lock_name.c_str(), std::ios::binary|std::ios::in);
106106 if (!is) {
107107 LOG(ERROR) << "cannot open: " << lock_name;
108108 return false;
179179 }
180180
181181 void HandWritingCanvas::listUpdated() {
182 vector<string> candidates;
182 std::vector<string> candidates;
183183 recognizer_thread_.GetCandidates(&candidates);
184184
185185 list_widget_->clear();
201201 strokes_.resize(strokes_.size() + 1);
202202 const float x = static_cast<float>(event->pos().x()) / width();
203203 const float y = static_cast<float>(event->pos().y()) / height();
204 strokes_.back().push_back(make_pair(x, y));
204 strokes_.back().push_back(std::make_pair(x, y));
205205 is_drawing_ = true;
206206 update();
207207 }
213213
214214 const float x = static_cast<float>(event->pos().x()) / width();
215215 const float y = static_cast<float>(event->pos().y()) / height();
216 strokes_.back().push_back(make_pair(x, y));
216 strokes_.back().push_back(std::make_pair(x, y));
217217 update();
218218 }
219219
5757 }
5858
5959 // Thread-safe copying of candidates.
60 void CopyCandidates(
61 const vector<string> &source, vector<string> *target, QMutex *mutex) {
60 void CopyCandidates(const std::vector<string> &source,
61 std::vector<string> *target,
62 QMutex *mutex) {
6263 DCHECK(target);
6364 DCHECK(mutex);
6465 QMutexLocker l(mutex);
9899 Clock::GetTimeOfDay(&strokes_sec_, &strokes_usec_);
99100 }
100101
101 void HandWritingThread::GetCandidates(vector<string> *candidates) {
102 void HandWritingThread::GetCandidates(std::vector<string> *candidates) {
102103 CopyCandidates(candidates_, candidates, &candidates_mutex_);
103104 }
104105
117118 return;
118119 }
119120
120 vector<string> candidates;
121 std::vector<string> candidates;
121122 status = handwriting::HandwritingManager::Recognize(strokes, &candidates);
122123 CopyCandidates(candidates, &candidates_, &candidates_mutex_);
123124 last_requested_sec_ = strokes_sec_;
5757 void SetStrokes(const handwriting::Strokes &strokes);
5858 // Copy internal candidates_ into the candidates. This will make
5959 // lock on candidates_ so thead-safe.
60 void GetCandidates(vector<string> *candidates);
60 void GetCandidates(std::vector<string> *candidates);
6161
6262 public slots:
6363 // This slot invokes the recognition and emit candidatesUpdated().
7070
7171 private:
7272 handwriting::Strokes strokes_;
73 vector<string> candidates_;
73 std::vector<string> candidates_;
7474
7575 uint64 strokes_sec_;
7676 uint32 strokes_usec_;
8989 CP932MapData key;
9090 key.ucs4 = ucs4;
9191 const CP932MapData *result =
92 lower_bound(kCP932MapData,
93 kCP932MapData + kCP932MapDataSize,
94 key,
95 UnicodeDataCompare<CP932MapData>());
92 std::lower_bound(kCP932MapData,
93 kCP932MapData + kCP932MapDataSize,
94 key,
95 UnicodeDataCompare<CP932MapData>());
9696 if (result == kCP932MapData + kCP932MapDataSize ||
9797 result->ucs4 != key.ucs4) {
9898 return 0;
108108 UnihanData key;
109109 key.ucs4 = ucs4;
110110 const UnihanData *result =
111 lower_bound(kUnihanData,
112 kUnihanData + kUnihanDataSize,
113 key,
114 UnicodeDataCompare<UnihanData>());
111 std::lower_bound(kUnihanData,
112 kUnihanData + kUnihanDataSize,
113 key,
114 UnicodeDataCompare<UnihanData>());
115115 if (result == kUnihanData + kUnihanDataSize ||
116116 result->ucs4 != ucs4) {
117117 return NULL;
129129 key.ucs4 = ucs4;
130130 key.description = NULL;
131131 const UnicodeData *result =
132 lower_bound(kUnicodeData,
133 kUnicodeData + kUnicodeDataSize,
134 key,
135 UnicodeDataCompare<UnicodeData>());
132 std::lower_bound(kUnicodeData,
133 kUnicodeData + kUnicodeDataSize,
134 key,
135 UnicodeDataCompare<UnicodeData>());
136136 if (result == kUnicodeData + kUnicodeDataSize ||
137137 result->ucs4 != ucs4) {
138138 return QString("");
588588 SET_CHECKBOX(dictionarySuggestCheckBox, use_dictionary_suggest);
589589 SET_CHECKBOX(realtimeConversionCheckBox, use_realtime_conversion);
590590
591 suggestionsSizeSpinBox->setValue
592 (max(1, min(9, static_cast<int>(config.suggestions_size()))));
591 suggestionsSizeSpinBox->setValue(
592 std::max(1, std::min(9, static_cast<int>(config.suggestions_size()))));
593593
594594 // tab5
595595 SetSendStatsCheckBox();
805805 void ConfigDialog::EditKeymap() {
806806 string current_keymap_table = "";
807807 const QString keymap_name = keymapSettingComboBox->currentText();
808 const map<QString, config::Config::SessionKeymap>::const_iterator itr =
808 const std::map<QString, config::Config::SessionKeymap>::const_iterator itr =
809809 keymapname_sessionkeymap_map_.find(keymap_name);
810810 if (itr != keymapname_sessionkeymap_map_.end()) {
811811 // Load from predefined mapping file.
812812 const char *keymap_file =
813813 keymap::KeyMapManager::GetKeyMapFileName(itr->second);
814 std::unique_ptr<istream> ifs(
814 std::unique_ptr<std::istream> ifs(
815815 ConfigFileStream::LegacyOpen(keymap_file));
816816 CHECK(ifs.get() != NULL); // should never happen
817 stringstream buffer;
817 std::stringstream buffer;
818818 buffer << ifs->rdbuf();
819819 current_keymap_table = buffer.str();
820820 } else {
108108 int initial_preedit_method_;
109109 bool initial_use_keyboard_to_change_preedit_method_;
110110 bool initial_use_mode_indicator_;
111 map<QString, config::Config::SessionKeymap> keymapname_sessionkeymap_map_;
111 std::map<QString, config::Config::SessionKeymap>
112 keymapname_sessionkeymap_map_;
112113 };
113114 } // namespace gui
114115 } // namespace mozc
3636
3737 #include <algorithm> // for unique
3838 #include <cctype>
39 #include <set>
4039 #include <sstream>
4140 #include <string>
4241 #include <vector>
139138 }
140139
141140 bool GenericTableEditorDialog::LoadFromString(const string &str) {
142 istringstream istr(str);
141 std::istringstream istr(str);
143142 return LoadFromStream(&istr);
144143 }
145144
146145 void GenericTableEditorDialog::DeleteSelectedItems() {
147 vector<int> rows;
146 std::vector<int> rows;
148147 QList<QTableWidgetItem *> selected =
149148 editorTableWidget->selectedItems();
150149
157156 rows.push_back(selected[i]->row());
158157 }
159158
160 vector<int>::iterator last = unique(rows.begin(), rows.end());
159 std::vector<int>::iterator last = unique(rows.begin(), rows.end());
161160 rows.erase(last, rows.end());
162161
163162 if (rows.empty()) {
360359 return kMaxEntrySize;
361360 }
362361
363 bool GenericTableEditorDialog::LoadFromStream(istream *is) {
362 bool GenericTableEditorDialog::LoadFromStream(std::istream *is) {
364363 return true;
365364 }
366365
7474
7575 // implements a method which loads
7676 // internal data from istream
77 virtual bool LoadFromStream(istream *is) = 0;
77 virtual bool LoadFromStream(std::istream *is) = 0;
7878
7979 // implements a method which called when
8080 // the current view is updated.
159159
160160 // Returns true if the key map entry is valid
161161 // invalid keymaps are not exported/imported.
162 bool IsValidEntry(const vector<string> &fields) {
162 bool IsValidEntry(const std::vector<string> &fields) {
163163 if (fields.size() < 3) {
164164 return false;
165165 }
174174
175175 // Returns true if the key map entry is configurable and
176176 // we want to show them.
177 bool IsVisibleEntry(const vector<string> &fields) {
177 bool IsVisibleEntry(const std::vector<string> &fields) {
178178 if (fields.size() < 3) {
179179 return false;
180180 }
191191 }
192192
193193 private:
194 set<uint32> invisible_modifiers_;
195 set<uint32> invisible_key_events_;
196 set<string> invisible_commands_;
194 std::set<uint32> invisible_modifiers_;
195 std::set<uint32> invisible_key_events_;
196 std::set<string> invisible_commands_;
197197 };
198198
199199 class KeyMapTableLoader {
200200 public:
201201 KeyMapTableLoader() {
202202 string line;
203 vector<string> fields;
204 set<string> status;
205 set<string> commands;
203 std::vector<string> fields;
204 std::set<string> status;
205 std::set<string> commands;
206206 KeyMapValidator *validator = mozc::Singleton<KeyMapValidator>::get();
207207
208208 // get all command names
209 set<string> command_names;
209 std::set<string> command_names;
210210 mozc::keymap::KeyMapManager manager;
211211 manager.GetAvailableCommandNameDirect(&command_names);
212212 manager.GetAvailableCommandNamePrecomposition(&command_names);
215215 manager.GetAvailableCommandNameZeroQuerySuggestion(&command_names);
216216 manager.GetAvailableCommandNameSuggestion(&command_names);
217217 manager.GetAvailableCommandNamePrediction(&command_names);
218 for (set<string>::const_iterator itr = command_names.begin();
218 for (std::set<string>::const_iterator itr = command_names.begin();
219219 itr != command_names.end(); ++itr) {
220220 if (validator->IsVisibleCommand(*itr)) {
221221 commands.insert(*itr);
226226 status_ << QString::fromUtf8(kKeyMapStatus[i]);
227227 }
228228
229 for (set<string>::const_iterator it = commands.begin();
229 for (std::set<string>::const_iterator it = commands.begin();
230230 it != commands.end(); ++it) {
231231 commands_ << QString::fromUtf8(it->c_str());
232232 }
322322
323323 KeyMapEditorDialog::~KeyMapEditorDialog() {}
324324
325 bool KeyMapEditorDialog::LoadFromStream(istream *is) {
325 bool KeyMapEditorDialog::LoadFromStream(std::istream *is) {
326326 if (is == NULL) {
327327 return false;
328328 }
332332 return false;
333333 }
334334
335 vector<string> fields;
335 std::vector<string> fields;
336336 int row = 0;
337337 mutable_table_widget()->setRowCount(0);
338338 mutable_table_widget()->verticalHeader()->hide();
407407 return false;
408408 }
409409
410 set<string> new_direct_mode_commands;
410 std::set<string> new_direct_mode_commands;
411411
412412 KeyMapValidator *validator = Singleton<KeyMapValidator>::get();
413413 string *keymap_table = mutable_table();
422422 const string &i18n_command =
423423 TableUtil::SafeGetItemText(mutable_table_widget(), i, 2).toStdString();
424424
425 const map<string, string>::const_iterator status_it =
425 const std::map<string, string>::const_iterator status_it =
426426 normalized_status_map_.find(i18n_status);
427427 if (status_it == normalized_status_map_.end()) {
428428 LOG(ERROR) << "Unsupported i18n status name: " << i18n_status;
430430 }
431431 const string &status = status_it->second;
432432
433 const map<string, string>::const_iterator command_it =
433 const std::map<string, string>::const_iterator command_it =
434434 normalized_command_map_.find(i18n_command);
435435 if (command_it == normalized_command_map_.end()) {
436436 LOG(ERROR) << "Unsupported i18n command name:" << i18n_command;
511511 import_index < arraysize(kKeyMaps)) {
512512 const char *keymap_file =
513513 keymap::KeyMapManager::GetKeyMapFileName(kKeyMaps[import_index]);
514 std::unique_ptr<istream> ifs(
514 std::unique_ptr<std::istream> ifs(
515515 ConfigFileStream::LegacyOpen(keymap_file));
516516 CHECK(ifs.get() != NULL); // should never happen
517517 CHECK(LoadFromStream(ifs.get()));
3131
3232 #include <QtWidgets/QWidget>
3333
34 #include <map>
3435 #include <memory>
3536 #include <set>
3637 #include <string>
6667 virtual string GetDefaultFilename() const {
6768 return "keymap.txt";
6869 }
69 virtual bool LoadFromStream(istream *is);
70 virtual bool LoadFromStream(std::istream *is);
7071 virtual bool Update();
7172
7273 private:
7374 string invisible_keymap_table_;
7475 // This is used for deciding whether the user has changed the settings that
7576 // are valid only for new applications.
76 set<string> direct_mode_commands_;
77 std::set<string> direct_mode_commands_;
7778 std::unique_ptr<QAction *[]> actions_;
7879 std::unique_ptr<QAction *[]> import_actions_;
7980 std::unique_ptr<ComboBoxDelegate> status_delegate_;
8081 std::unique_ptr<ComboBoxDelegate> commands_delegate_;
8182 std::unique_ptr<KeyBindingEditorDelegate> keybinding_delegate_;
8283
83 map<string, string> normalized_command_map_;
84 map<string, string> normalized_status_map_;
84 std::map<string, string> normalized_command_map_;
85 std::map<string, string> normalized_status_map_;
8586 };
8687
8788 } // namespace gui
8888 RomanTableEditorDialog::~RomanTableEditorDialog() {}
8989
9090 string RomanTableEditorDialog::GetDefaultRomanTable() {
91 std::unique_ptr<istream> ifs(ConfigFileStream::LegacyOpen(kRomanTableFile));
91 std::unique_ptr<std::istream> ifs(
92 ConfigFileStream::LegacyOpen(kRomanTableFile));
9293 CHECK(ifs.get() != NULL); // should never happen
9394 string line, result;
94 vector<string> fields;
95 std::vector<string> fields;
9596 while (getline(*ifs.get(), line)) {
9697 if (line.empty()) {
9798 continue;
115116 return result;
116117 }
117118
118 bool RomanTableEditorDialog::LoadFromStream(istream *is) {
119 bool RomanTableEditorDialog::LoadFromStream(std::istream *is) {
119120 CHECK(is);
120121 string line;
121 vector<string> fields;
122 std::vector<string> fields;
122123 mutable_table_widget()->setRowCount(0);
123124 mutable_table_widget()->verticalHeader()->hide();
124125
168169 }
169170
170171 bool RomanTableEditorDialog::LoadDefaultRomanTable() {
171 std::unique_ptr<istream> ifs(ConfigFileStream::LegacyOpen(kRomanTableFile));
172 std::unique_ptr<std::istream>
173 ifs(ConfigFileStream::LegacyOpen(kRomanTableFile));
172174 CHECK(ifs.get() != NULL); // should never happen
173175 CHECK(LoadFromStream(ifs.get()));
174176 return true;
6262 virtual string GetDefaultFilename() const {
6363 return "romantable.txt";
6464 }
65 virtual bool LoadFromStream(istream *is);
65 virtual bool LoadFromStream(std::istream *is);
6666 virtual bool Update();
6767
6868 private:
187187 ifs_(new InputFileStream(filename.c_str())),
188188 first_line_(true) {
189189 const std::streampos begin = ifs_->tellg();
190 ifs_->seekg(0, ios::end);
190 ifs_->seekg(0, std::ios::end);
191191 const size_t size = static_cast<size_t>(ifs_->tellg() - begin);
192 ifs_->seekg(0, ios::beg);
192 ifs_->seekg(0, std::ios::beg);
193193 progress_.reset(CreateProgressDialog(message, parent, size));
194194 }
195195
247247 void Reset() {
248248 // Clear state bit (eofbit, failbit, badbit).
249249 ifs_->clear();
250 ifs_->seekg(0, ios_base::beg);
250 ifs_->seekg(0, std::ios_base::beg);
251251 first_line_ = true;
252252 }
253253
391391 GetTableHeight(dic_content_));
392392
393393 // Get a list of POS and set a custom delagate that holds the list.
394 vector<string> tmp_pos_vec;
394 std::vector<string> tmp_pos_vec;
395395 pos_list_provider_->GetPOSList(&tmp_pos_vec);
396396 QStringList pos_list;
397397 for (size_t i = 0; i < tmp_pos_vec.size(); ++i) {
10281028 UpdateUIStatus();
10291029 }
10301030
1031 void DictionaryTool::GetSortedSelectedRows(vector<int> *rows) const {
1031 void DictionaryTool::GetSortedSelectedRows(std::vector<int> *rows) const {
10321032 DCHECK(rows);
10331033 rows->clear();
10341034
10411041 rows->push_back(items[i]->row());
10421042 }
10431043
1044 sort(rows->begin(), rows->end(), greater<int>());
1045 vector<int>::const_iterator end = unique(rows->begin(), rows->end());
1044 sort(rows->begin(), rows->end(), std::greater<int>());
1045 std::vector<int>::const_iterator end = unique(rows->begin(), rows->end());
10461046
10471047 rows->resize(end - rows->begin());
10481048 }
10601060 }
10611061
10621062 void DictionaryTool::DeleteWord() {
1063 vector<int> rows;
1063 std::vector<int> rows;
10641064 GetSortedSelectedRows(&rows);
10651065 if (rows.size() == 0) {
10661066 return;
11441144 target_dict_item->data(Qt::UserRole).toULongLong());
11451145 }
11461146
1147 vector<int> rows;
1147 std::vector<int> rows;
11481148 GetSortedSelectedRows(&rows);
11491149 if (rows.size() == 0) {
11501150 return;
12951295 }
12961296 }
12971297 }
1298 vector<pair<int, QAction *> > change_dictionary_actions;
1298 std::vector<std::pair<int, QAction *> > change_dictionary_actions;
12991299 // "Move to" is available only when we have 2 or more dictionaries.
13001300 if (dic_list_->count() > 1) {
13011301 QMenu *move_to = menu->addMenu(move_to_menu_text);
13111311 continue;
13121312 }
13131313 change_dictionary_actions.push_back(
1314 make_pair(i, move_to->addAction(item->text())));
1314 std::make_pair(i, move_to->addAction(item->text())));
13151315 }
13161316 }
13171317 }
13201320
13211321 menu->addSeparator();
13221322 QMenu *change_category_to = menu->addMenu(tr("Change category to"));
1323 vector<string> pos_list;
1323 std::vector<string> pos_list;
13241324 pos_list_provider_->GetPOSList(&pos_list);
1325 vector<QAction *> change_pos_actions(pos_list.size());
1325 std::vector<QAction *> change_pos_actions(pos_list.size());
13261326 for (size_t i = 0; i < pos_list.size(); ++i) {
13271327 change_pos_actions[i] = change_category_to->addAction(
13281328 QString::fromUtf8(pos_list[i].c_str()));
3636
3737 #include <memory>
3838 #include <string>
39 #include <vector>
3940
4041 #include "base/port.h"
4142 #include "gui/dictionary_tool/ui_dictionary_tool.h"
177178
178179 // Helper function for DeleteWord and MoveTo.
179180 // Fills selected word entry rows as a unique sorted sequence.
180 void GetSortedSelectedRows(vector<int> *rows) const;
181 void GetSortedSelectedRows(std::vector<int> *rows) const;
181182
182183 // Returns a pointer to the first selected dictionary.
183184 // Returns NULL if no dictionary is selected.
105105
106106 void FindDialog::Find(FindDialog::Direction direction) {
107107 const QString &query = QuerylineEdit->text();
108 const int start_row = max(0, table_->currentRow());
109 int start_column = min(1, max(0, table_->currentColumn()));
108 const int start_row = std::max(0, table_->currentRow());
109 int start_column = std::min(1, std::max(0, table_->currentColumn()));
110110 int matched_column = -1;
111111 int matched_row = -1;
112112
8989 }
9090 if (!mozc_flags::SetFlag(key, env)) {
9191 #ifndef IGNORE_INVALID_FLAG
92 cerr << "Unknown/Invalid flag " << key << endl;
92 std::cerr << "Unknown/Invalid flag " << key << std::endl;
9393 #endif
9494 }
9595 }
144144 #endif // !ENABLE_CLOUD_SYNC
145145
146146 // Initialize ComboBox
147 vector<string> pos_set;
147 std::vector<string> pos_set;
148148 pos_list_provider_->GetPOSList(&pos_set);
149149 CHECK(!pos_set.empty());
150150
3232 #include "ipc/ipc.h"
3333
3434 #include <map>
35 #include <vector>
3635
3736 #include <launch.h>
3837 #include <mach/mach.h>
134133 class DefaultServerMachPortManager : public MachPortManagerInterface {
135134 public:
136135 ~DefaultServerMachPortManager() {
137 for (map<string, mach_port_t>::const_iterator it = mach_ports_.begin();
136 for (std::map<string, mach_port_t>::const_iterator it = mach_ports_.begin();
138137 it != mach_ports_.end(); ++it) {
139138 mach_port_destroy(mach_task_self(), it->second);
140139 }
150149
151150 DLOG(INFO) << "\"" << port_name << "\"";
152151
153 map<string, mach_port_t>::const_iterator it = mach_ports_.find(port_name);
152 std::map<string, mach_port_t>::const_iterator it =
153 mach_ports_.find(port_name);
154154 if (it != mach_ports_.end()) {
155155 *port = it->second;
156156 return true;
169169 }
170170
171171 private:
172 map<string, mach_port_t> mach_ports_;
172 std::map<string, mach_port_t> mach_ports_;
173173 };
174174
175175 struct mach_ipc_send_message {
7474
7575 namespace {
7676 // set of bundle IDs of applications on which Mozc should not open urls.
77 const set<string> *gNoOpenLinkApps = nullptr;
77 const std::set<string> *gNoOpenLinkApps = nullptr;
7878 // The mapping from the CompositionMode enum to the actual id string
7979 // of composition modes.
80 const map<CompositionMode, NSString *> *gModeIdMap = nullptr;
81 const set<string> *gNoSelectedRangeApps = nullptr;
82 const set<string> *gNoDisplayModeSwitchApps = nullptr;
83 const set<string> *gNoSurroundingTextApps = nullptr;
80 const std::map<CompositionMode, NSString *> *gModeIdMap = nullptr;
81 const std::set<string> *gNoSelectedRangeApps = nullptr;
82 const std::set<string> *gNoDisplayModeSwitchApps = nullptr;
83 const std::set<string> *gNoSurroundingTextApps = nullptr;
8484
8585 // TODO(horo): This value should be get from system configuration.
8686 // DoubleClickInterval can be get from NSEvent (MacOSX ver >= 10.6)
143143 return mozc::commands::DIRECT;
144144 }
145145
146 bool IsBannedApplication(const set<string>* bundleIdSet,
146 bool IsBannedApplication(const std::set<string>* bundleIdSet,
147147 const string& bundleId) {
148148 return bundleIdSet == nullptr || bundleId.empty() ||
149149 bundleIdSet->find(bundleId) != bundleIdSet->end();
187187 return self;
188188 }
189189 keyCodeMap_ = [[KeyCodeMap alloc] init];
190 clientBundle_ = new(nothrow) string;
190 clientBundle_ = new(std::nothrow) string;
191191 replacementRange_ = NSMakeRange(NSNotFound, 0);
192192 originalString_ = [[NSMutableString alloc] init];
193193 composedString_ = [[NSMutableAttributedString alloc] init];
196196 checkInputMode_ = YES;
197197 suppressSuggestion_ = NO;
198198 yenSignCharacter_ = mozc::config::Config::YEN_SIGN;
199 candidateController_ = new(nothrow) mozc::renderer::RendererClient;
200 rendererCommand_ = new(nothrow)RendererCommand;
199 candidateController_ = new(std::nothrow) mozc::renderer::RendererClient;
200 rendererCommand_ = new(std::nothrow)RendererCommand;
201201 mozcClient_ = mozc::client::ClientFactory::NewClient();
202202 imkServer_ = reinterpret_cast<id<ServerCallback> >(server);
203203 imkClientForTest_ = nil;
257257 }
258258
259259 + (void)initializeConstants {
260 set<string> *noOpenlinkApps = new(nothrow) set<string>;
260 std::set<string> *noOpenlinkApps = new(std::nothrow) std::set<string>;
261261 if (noOpenlinkApps) {
262262 // should not open links during screensaver.
263263 noOpenlinkApps->insert("com.apple.securityagent");
264264 gNoOpenLinkApps = noOpenlinkApps;
265265 }
266266
267 map<CompositionMode, NSString *> *newMap =
268 new(nothrow) map<CompositionMode, NSString *>;
267 std::map<CompositionMode, NSString *> *newMap =
268 new(std::nothrow) std::map<CompositionMode, NSString *>;
269269 if (newMap) {
270270 (*newMap)[mozc::commands::DIRECT] = GetLabelForSuffix("Roman");
271271 (*newMap)[mozc::commands::HIRAGANA] = GetLabelForSuffix("base");
277277 gModeIdMap = newMap;
278278 }
279279
280 set<string> *noSelectedRangeApps = new(nothrow) set<string>;
280 std::set<string> *noSelectedRangeApps = new(std::nothrow) std::set<string>;
281281 if (noSelectedRangeApps) {
282282 // Do not call selectedRange: method for the following
283283 // applications because it could lead to application crash.
294294 // mode. When the first composition character is alphanumeric (such
295295 // like pressing Shift-A at first), that character is directly
296296 // inserted into application instead of composition starting "A".
297 set<string> *noDisplayModeSwitchApps = new(nothrow) set<string>;
297 std::set<string> *noDisplayModeSwitchApps =
298 new(std::nothrow) std::set<string>;
298299 if (noDisplayModeSwitchApps) {
299300 noDisplayModeSwitchApps->insert("com.microsoft.Word");
300301 gNoDisplayModeSwitchApps = noDisplayModeSwitchApps;
301302 }
302303
303 set<string> *noSurroundingTextApps = new(nothrow) set<string>;
304 std::set<string> *noSurroundingTextApps = new(std::nothrow) std::set<string>;
304305 if (noSurroundingTextApps) {
305306 // Disables the surrounding text feature for the following application
306307 // because calling attributedSubstringFromRange to it is very heavy.
479480 return;
480481 }
481482
482 map<CompositionMode, NSString *>::const_iterator it = gModeIdMap->find(mode_);
483 std::map<CompositionMode, NSString *>::const_iterator it =
484 gModeIdMap->find(mode_);
483485 if (it == gModeIdMap->end()) {
484486 LOG(ERROR) << "mode: " << mode_ << " is invalid";
485487 return;
167167 unsigned short keyCode = [event keyCode];
168168 unichar inputChar = [((nsModifiers == NSShiftKeyMask) ?
169169 inputString : inputStringRaw) characterAtIndex:0];
170 map<unsigned short, KeyEvent::SpecialKey>::const_iterator sp_iter =
170 std::map<unsigned short, KeyEvent::SpecialKey>::const_iterator sp_iter =
171171 kSpecialKeyMap->find(keyCode);
172172 if (sp_iter != kSpecialKeyMap->end()) {
173173 keyEvent->set_special_key(sp_iter->second);
174174 } else {
175 map<unichar, KeyEvent::SpecialKey>::const_iterator spc_iter =
175 std::map<unichar, KeyEvent::SpecialKey>::const_iterator spc_iter =
176176 kSpecialCharMap->find(inputChar);
177177 if (spc_iter != kSpecialCharMap->end()) {
178178 keyEvent->set_special_key(spc_iter->second);
184184
185185 // fill kana "key_string" if mode is kana.
186186 if (inputMode_ == KANA && !keyEvent->has_special_key()) {
187 map<unsigned short, const char *>::const_iterator kana_iter;
187 std::map<unsigned short, const char *>::const_iterator kana_iter;
188188 if (nsModifiers == NSShiftKeyMask && kKanaMapShift &&
189189 (kana_iter = kKanaMapShift->find(keyCode)) != kKanaMapShift->end()) {
190190 keyEvent->set_key_string(kana_iter->second);
6767 // than KeyCodeMap.mm
6868
6969 namespace {
70 static map<%(key_type)s, %(result_type)s> *k%(mapname)s = nullptr;
71 static map<%(key_type)s, %(result_type)s> *k%(mapname)sShift = nullptr;
70 static std::map<%(key_type)s, %(result_type)s> *k%(mapname)s = nullptr;
71 static std::map<%(key_type)s, %(result_type)s> *k%(mapname)sShift = nullptr;
7272 static once_t kOnceFor%(mapname)s = MOZC_ONCE_INIT;
7373 void Init%(mapname)s() {
7474 if (k%(mapname)s != nullptr || k%(mapname)sShift != nullptr) {
7575 return;
7676 }
77 k%(mapname)s = new(nothrow)map<%(key_type)s, %(result_type)s>;
77 k%(mapname)s = new(std::nothrow)std::map<%(key_type)s, %(result_type)s>;
7878 if (k%(mapname)s == nullptr) {
7979 return;
8080 }
81 k%(mapname)sShift = new(nothrow)map<%(key_type)s, %(result_type)s>;
81 k%(mapname)sShift = new(std::nothrow)std::map<%(key_type)s, %(result_type)s>;
8282 if (k%(mapname)sShift == nullptr) {
8383 delete k%(mapname)s;
8484 k%(mapname)s = nullptr;
186186 candidates.focused_index() - candidates.candidate(0).index();
187187 if (candidates.candidate_size() >= focused_row &&
188188 candidates.candidate(focused_row).has_information_id()) {
189 const uint32 delay = max(0u, candidates.usages().delay());
189 const uint32 delay = std::max(0u, candidates.usages().delay());
190190 infolist_window_->DelayShow(delay);
191191 } else {
192192 infolist_window_->DelayHide(kHideWindowDelay);
122122 CallOnce(&g_OnceForInitializeStyle, InitializeDefaultStyle);
123123 self = [super initWithFrame:frame];
124124 if (self) {
125 tableLayout_ = new(nothrow)TableLayout;
126 RendererStyle *style = new(nothrow)RendererStyle;
125 tableLayout_ = new(std::nothrow)TableLayout;
126 RendererStyle *style = new(std::nothrow)RendererStyle;
127127 if (style) {
128128 RendererStyleHandler::GetRendererStyle(style);
129129 }
6868 - (id)initWithFrame:(NSRect)frame {
6969 self = [super initWithFrame:frame];
7070 if (self) {
71 RendererStyle *style = new(nothrow)RendererStyle;
71 RendererStyle *style = new(std::nothrow)RendererStyle;
7272 if (style) {
7373 RendererStyleHandler::GetRendererStyle(style);
7474 }