| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_TEXT_H_ | 5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_TEXT_H_ |
| 6 #define CHROMEOS_DBUS_IBUS_IBUS_TEXT_H_ | 6 #define CHROMEOS_DBUS_IBUS_IBUS_TEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 // Pops a IBusText from |reader|. | 81 // Pops a IBusText from |reader|. |
| 82 // Returns false if an error occures. | 82 // Returns false if an error occures. |
| 83 bool CHROMEOS_EXPORT PopIBusText(dbus::MessageReader* reader, | 83 bool CHROMEOS_EXPORT PopIBusText(dbus::MessageReader* reader, |
| 84 IBusText* ibus_text); | 84 IBusText* ibus_text); |
| 85 // Pops a IBusText from |reader| and stores it's text field into text. Use | 85 // Pops a IBusText from |reader| and stores it's text field into text. Use |
| 86 // PopIBusText instead in the case of using any attribute entries in IBusText. | 86 // PopIBusText instead in the case of using any attribute entries in IBusText. |
| 87 // Returns true on success. | 87 // Returns true on success. |
| 88 bool CHROMEOS_EXPORT PopStringFromIBusText(dbus::MessageReader* reader, | 88 bool CHROMEOS_EXPORT PopStringFromIBusText(dbus::MessageReader* reader, |
| 89 std::string* text); | 89 std::string* text); |
| 90 // Appends a IBusText to |writer|. | 90 // Appends a IBusText to |writer|. Annotation and description field is not |
| 91 // filled with AppendIBusText. |
| 92 // TODO(nona): Support annotation/description appending if necessary. |
| 91 void CHROMEOS_EXPORT AppendIBusText(const IBusText& ibus_text, | 93 void CHROMEOS_EXPORT AppendIBusText(const IBusText& ibus_text, |
| 92 dbus::MessageWriter* writer); | 94 dbus::MessageWriter* writer); |
| 93 | 95 |
| 94 // Appends a string to |writer| as IBusText without any attributes. Use | 96 // Appends a string to |writer| as IBusText without any attributes. Use |
| 95 // AppendIBusText instead in the case of using any attribute entries. | 97 // AppendIBusText instead in the case of using any attribute entries. |
| 98 // TODO(nona): Support annotation/description appending if necessary. |
| 96 void CHROMEOS_EXPORT AppendStringAsIBusText(const std::string& text, | 99 void CHROMEOS_EXPORT AppendStringAsIBusText(const std::string& text, |
| 97 dbus::MessageWriter* writer); | 100 dbus::MessageWriter* writer); |
| 98 | 101 |
| 99 // Handles IBusText object which is used in dbus communication with ibus-daemon. | 102 // Handles IBusText object which is used in dbus communication with ibus-daemon. |
| 100 // The IBusAttribute has four uint32 variables and the IBusAttributes represents | 103 // The IBusAttribute has four uint32 variables and the IBusAttributes represents |
| 101 // three type of decoration based on it's values. | 104 // three type of decoration based on it's values. |
| 102 // 1. Underline decoration (corresponds to UnderlineAttribute structure) | 105 // 1. Underline decoration (corresponds to UnderlineAttribute structure) |
| 103 // 1st value: indicates underline attribute. | 106 // 1st value: indicates underline attribute. |
| 104 // 2nd value: type of decoration. Chrome only support single and double | 107 // 2nd value: type of decoration. Chrome only support single and double |
| 105 // underline and error line. | 108 // underline and error line. |
| 106 // 3rd value: the start index of this attribute in multibyte. | 109 // 3rd value: the start index of this attribute in multibyte. |
| 107 // 4th value: the end index of this attribute in multibyte. | 110 // 4th value: the end index of this attribute in multibyte. |
| 108 // | 111 // |
| 109 // 2. Background decoration (corresponds to SelectionAttribute structure) | 112 // 2. Background decoration (corresponds to SelectionAttribute structure) |
| 110 // NOTE: Background decoration is treated as selection in Chrome. | 113 // NOTE: Background decoration is treated as selection in Chrome. |
| 111 // 1st value: indicates background attribute. | 114 // 1st value: indicates background attribute. |
| 112 // 2nd value: Represents color but not supported in Chrome. | 115 // 2nd value: Represents color but not supported in Chrome. |
| 113 // 3rd value: the start index of this attribute in multibyte. | 116 // 3rd value: the start index of this attribute in multibyte. |
| 114 // 4th value: the end index of this attribute in multibyte. | 117 // 4th value: the end index of this attribute in multibyte. |
| 115 // | 118 // |
| 116 // 3. Forward decoration | 119 // 3. Forward decoration |
| 117 // Not supported in Chrome. | 120 // Not supported in Chrome. |
| 118 // TODO(nona): Support attachment for mozc infolist feature(crosbug.com/30653). | |
| 119 class CHROMEOS_EXPORT IBusText { | 121 class CHROMEOS_EXPORT IBusText { |
| 120 public: | 122 public: |
| 121 enum IBusTextUnderlineType { | 123 enum IBusTextUnderlineType { |
| 122 IBUS_TEXT_UNDERLINE_SINGLE = 1, | 124 IBUS_TEXT_UNDERLINE_SINGLE = 1, |
| 123 IBUS_TEXT_UNDERLINE_DOUBLE = 2, | 125 IBUS_TEXT_UNDERLINE_DOUBLE = 2, |
| 124 IBUS_TEXT_UNDERLINE_ERROR = 4, | 126 IBUS_TEXT_UNDERLINE_ERROR = 4, |
| 125 }; | 127 }; |
| 126 | 128 |
| 127 struct UnderlineAttribute { | 129 struct UnderlineAttribute { |
| 128 IBusTextUnderlineType type; | 130 IBusTextUnderlineType type; |
| 129 uint32 start_index; // The inclusive start index. | 131 uint32 start_index; // The inclusive start index. |
| 130 uint32 end_index; // The exclusive end index. | 132 uint32 end_index; // The exclusive end index. |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 struct SelectionAttribute { | 135 struct SelectionAttribute { |
| 134 uint32 start_index; // The inclusive start index. | 136 uint32 start_index; // The inclusive start index. |
| 135 uint32 end_index; // The exclusive end index. | 137 uint32 end_index; // The exclusive end index. |
| 136 }; | 138 }; |
| 137 | 139 |
| 138 // Accessors | 140 // Accessors |
| 139 IBusText(); | 141 IBusText(); |
| 140 virtual ~IBusText(); | 142 virtual ~IBusText(); |
| 141 | 143 |
| 142 std::string text() const; | 144 const std::string& text() const { return text_; } |
| 143 void set_text(const std::string& text); | 145 void set_text(const std::string& text) { text_ = text; } |
| 144 | 146 |
| 145 const std::vector<UnderlineAttribute>& underline_attributes() const; | 147 const std::string& annotation() const { return annotation_; } |
| 146 std::vector<UnderlineAttribute>* mutable_underline_attributes(); | 148 void set_annotation(const std::string& annotation) { |
| 149 annotation_ = annotation; |
| 150 } |
| 147 | 151 |
| 148 const std::vector<SelectionAttribute>& selection_attributes() const; | 152 const std::string& description() const { return description_; } |
| 149 std::vector<SelectionAttribute>* mutable_selection_attributes(); | 153 void set_description(const std::string& description) { |
| 154 description_ = description; |
| 155 } |
| 156 |
| 157 const std::vector<UnderlineAttribute>& underline_attributes() const { |
| 158 return underline_attributes_; |
| 159 } |
| 160 |
| 161 std::vector<UnderlineAttribute>* mutable_underline_attributes() { |
| 162 return &underline_attributes_; |
| 163 } |
| 164 |
| 165 const std::vector<SelectionAttribute>& selection_attributes() const { |
| 166 return selection_attributes_; |
| 167 } |
| 168 std::vector<SelectionAttribute>* mutable_selection_attributes() { |
| 169 return &selection_attributes_; |
| 170 } |
| 150 | 171 |
| 151 private: | 172 private: |
| 152 std::string text_; | 173 std::string text_; |
| 174 std::string annotation_; |
| 175 std::string description_; |
| 153 std::vector<UnderlineAttribute> underline_attributes_; | 176 std::vector<UnderlineAttribute> underline_attributes_; |
| 154 std::vector<SelectionAttribute> selection_attributes_; | 177 std::vector<SelectionAttribute> selection_attributes_; |
| 155 | 178 |
| 156 DISALLOW_COPY_AND_ASSIGN(IBusText); | 179 DISALLOW_COPY_AND_ASSIGN(IBusText); |
| 157 }; | 180 }; |
| 158 | 181 |
| 159 } // namespace ibus | 182 } // namespace ibus |
| 160 } // namespace chromeos | 183 } // namespace chromeos |
| 161 | 184 |
| 162 #endif // CHROMEOS_DBUS_IBUS_IBUS_TEXT_H_ | 185 #endif // CHROMEOS_DBUS_IBUS_IBUS_TEXT_H_ |
| OLD | NEW |