public:
constexpr static const char *activityType = DerivedType::activityType;
- ClipboardActivity() : UIActivity(activityType) {}
+ ClipboardActivity() : UIActivity(activityType), atspi(Singleton<UniversalSwitch>::instance().getAtspi()) {}
protected:
- bool getAtspiInterfaces()
+ void getAtspiInterfaces()
{
+ ASSERT(atspi, "Atspi should exist");
+
if (!uiElement) {
ERROR("Process invoked with incorrect UIElement");
- markAsCompleted();
- return false;
- }
-
- atspi = Singleton<UniversalSwitch>::instance().getAtspi();
- if (!atspi) {
- markAsCompleted();
- return false;
+ return;
}
atspiText = atspi->getTextInterface(uiElement->getObject());
- if (!atspiText) {
- markAsCompleted();
- return false;
- }
-
atspiEditableText = atspi->getEditableTextInterface(uiElement->getObject());
- if (!atspiEditableText) {
- markAsCompleted();
- return false;
- }
-
- return true;
}
std::shared_ptr<Atspi> atspi;
void process() override
{
- if (!getAtspiInterfaces())
- return;
+ getAtspiInterfaces();
auto range = atspi->getTextSelection(atspiText);
if (range)
void process() override
{
- if (!getAtspiInterfaces())
- return;
+ getAtspiInterfaces();
auto range = atspi->getTextSelection(atspiText);
if (range)
void process() override
{
- if (!getAtspiInterfaces())
- return;
+ getAtspiInterfaces();
auto caretOffset = atspi->getTextCaretOffset(atspiText);
if (caretOffset)
markAsCompleted();
}
};
+
+class SelectAllActivity : public ClipboardActivity<SelectAllActivity>
+{
+public:
+ constexpr static const char *activityType = "SELECT_ALL";
+
+ void process() override
+ {
+ getAtspiInterfaces();
+
+ auto offsetEnd = atspi->countTextCharacters(atspiText);
+ if (offsetEnd) {
+ auto range = TextRange {0, *offsetEnd};
+ atspi->setTextSelection(atspiText, range);
+ }
+
+ markAsCompleted();
+ }
+};
defaultImg);
auto selectAll = std::make_shared<MenuItemImplementation>(
std::vector<std::string> {"IDS_SELECT_ALL"},
- defaultImg);
+ defaultImg,
+ "SELECT_ALL");
auto previous = std::make_shared<VconfIntTypeMenuItem>(
std::vector<std::string> { "IDS_PREVIOUS_CHARACTER", "IDS_PREVIOUS_WORD", "IDS_PREVIOUS_LINE", "IDS_PREVIOUS_PARAGRAPH"},
defaultImg,