Remove Qt4 Mac accessibility backend files.
[profile/ivi/qtbase.git] / src / gui / accessible / qaccessible2.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtGui module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qaccessible2.h"
43 #include <QtGui/QGuiApplication>
44 #include "qclipboard.h"
45 #include "qtextboundaryfinder.h"
46
47 #ifndef QT_NO_ACCESSIBILITY
48
49 QT_BEGIN_NAMESPACE
50
51 /*!
52     \namespace QAccessible2
53     \ingroup accessibility
54
55     \brief The QAccessible2 namespace defines constants relating to
56     IAccessible2-based interfaces
57
58     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
59 */
60
61 /*!
62     \class QAccessibleTextInterface
63
64     \ingroup accessibility
65
66     \brief The QAccessibleTextInterface class implements support for text handling.
67
68     This interface corresponds to the IAccessibleText interface.
69     It should be implemented for widgets that display more text than a plain label.
70     Labels should be represented by only \l QAccessibleInterface
71     and return their text as name (\l QAccessibleInterface::text() with \l QAccessible::Name as type).
72     The QAccessibleTextInterface is typically for text that a screen reader
73     might want to read line by line, and for widgets that support text selection and input.
74     This interface is, for example, implemented for QLineEdit.
75
76     Editable text objects should also implement \l QAccessibleEditableTextInterface.
77     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
78 */
79
80 /*!
81     \fn QAccessibleTextInterface::~QAccessibleTextInterface()
82     Destructor.
83 */
84
85 /*!
86     \fn void QAccessibleTextInterface::addSelection(int startOffset, int endOffset)
87     Select the text from \a startOffset to \a endOffset.
88     The \a startOffset is the first character that will be selected.
89     The \a endOffset is the first character that will not be selected.
90
91     When the object supports multiple selections (e.g. in a word processor),
92     this adds a new selection, otherwise it replaces the previous selection.
93
94     The selection will be \a endOffset - \a startOffset characters long.
95 */
96
97 /*!
98     \fn QString QAccessibleTextInterface::attributes(int offset, int *startOffset, int *endOffset) const
99 */
100
101 /*!
102     \fn int QAccessibleTextInterface::cursorPosition() const
103
104     Returns the current cursor position.
105 */
106
107 /*!
108     \fn QRect QAccessibleTextInterface::characterRect(int offset, QAccessible2::CoordinateType coordType) const
109 */
110
111 /*!
112     \fn int QAccessibleTextInterface::selectionCount() const
113
114     Returns the number of selections in this text.
115 */
116
117 /*!
118     \fn int QAccessibleTextInterface::offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const
119 */
120
121 /*!
122     \fn void QAccessibleTextInterface::selection(int selectionIndex, int *startOffset, int *endOffset) const
123 */
124
125 /*!
126     \fn QString QAccessibleTextInterface::text(int startOffset, int endOffset) const
127
128     Returns the text from \a startOffset to \a endOffset.
129     The \a startOffset is the first character that will be returned.
130     The \a endOffset is the first character that will not be returned.
131 */
132
133 /*!
134     \fn QString QAccessibleTextInterface::textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
135                       int *startOffset, int *endOffset) const
136 */
137
138 /*!
139     \fn QString QAccessibleTextInterface::textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
140                     int *startOffset, int *endOffset) const
141 */
142
143 /*!
144     \fn QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
145                  int *startOffset, int *endOffset) const
146 */
147
148 /*!
149     \fn void QAccessibleTextInterface::removeSelection(int selectionIndex)
150
151     Clears the selection with \a index selectionIndex.
152 */
153
154 /*!
155     \fn void QAccessibleTextInterface::setCursorPosition(int position)
156
157     Moves the cursor to \a position.
158 */
159
160 /*!
161     \fn void QAccessibleTextInterface::setSelection(int selectionIndex, int startOffset, int endOffset)
162
163     Set the selection \a selectionIndex to the range from \a startOffset to \a endOffset.
164
165     \sa addSelection(), removeSelection()
166 */
167
168 /*!
169     \fn int QAccessibleTextInterface::characterCount() const
170
171     Returns the lenght of the text (total size including spaces).
172 */
173
174 /*!
175     \fn void QAccessibleTextInterface::scrollToSubstring(int startIndex, int endIndex)
176
177     Ensures that the text between \a startIndex and \a endIndex is visible.
178 */
179
180 /*!
181     \class QAccessibleEditableTextInterface
182     \ingroup accessibility
183
184     \brief The QAccessibleEditableTextInterface class implements support for objects with editable text.
185
186     When implementing this interface you will almost certainly also want to implement \l QAccessibleTextInterface.
187
188     Since this interface can be implemented by means of the normal \l QAccessibleTextInterface,
189     \l QAccessibleSimpleEditableTextInterface provides a convenience implementation of this interface.
190     Consider inheriting \l QAccessibleSimpleEditableTextInterface instead.
191
192     \sa QAccessibleInterface
193
194     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
195 */
196
197 /*!
198     \fn QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface()
199
200
201 */
202
203 /*!
204     \fn void QAccessibleEditableTextInterface::copyText(int startOffset, int endOffset) const
205
206     Copies the text from \a startOffset to \a endOffset to the system clip board.
207     The \a startOffset is the first character that will be copied.
208     The \a endOffset is the first character that will not be copied.
209 */
210
211 /*!
212     \fn void QAccessibleEditableTextInterface::deleteText(int startOffset, int endOffset)
213
214     Deletes the text from \a startOffset to \a endOffset.
215 */
216
217 /*!
218     \fn void QAccessibleEditableTextInterface::insertText(int offset, const QString &text)
219
220     Inserts \a text at position \a offset.
221 */
222
223 /*!
224     \fn void QAccessibleEditableTextInterface::cutText(int startOffset, int endOffset)
225
226     Removes the text from \a startOffset to \a endOffset and puts it in the system clip board.
227 */
228
229 /*!
230     \fn void QAccessibleEditableTextInterface::pasteText(int offset)
231
232     Pastes text from the system clip board at the position \a offset.
233 */
234
235 /*!
236     \fn void QAccessibleEditableTextInterface::replaceText(int startOffset, int endOffset, const QString &text)
237
238     Removes the text from \a startOffset to \a endOffset and instead inserts \a text.
239 */
240
241 /*!
242     \fn void QAccessibleEditableTextInterface::setAttributes(int startOffset, int endOffset, const QString &attributes)
243
244     \sa QAccessibleTextInterface::attributes()
245 */
246
247 /*!
248     \class QAccessibleSimpleEditableTextInterface
249     \ingroup accessibility
250
251     \brief The QAccessibleSimpleEditableTextInterface class is a convenience class for
252     text-based widgets. It can be inherited instead of \l QAccessibleEditableTextInterface.
253
254     \sa QAccessibleInterface, QAccessibleEditableTextInterface
255
256     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
257 */
258
259 /*!
260     \class QAccessibleValueInterface
261     \ingroup accessibility
262
263     \brief The QAccessibleValueInterface class implements support for objects that manipulate a value.
264
265     This interface should be implemented by accessible objects that represent a value.
266     Examples are spinner, slider, dial and scroll bar.
267
268     Instead of forcing the user to deal with the individual parts of the widgets, this interface
269     gives an easier approach to the kind of widget it represents.
270
271     Usually this interface is implemented by classes that also implement \l QAccessibleInterface.
272
273     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
274 */
275
276 /*!
277     \fn QAccessibleValueInterface::~QAccessibleValueInterface()
278     Destructor.
279 */
280
281 /*!
282     \fn QVariant QAccessibleValueInterface::currentValue() const
283
284     Returns the current value of the widget. This is usually a double or int.
285     \sa setCurrentValue()
286 */
287
288 /*!
289     \fn void QAccessibleValueInterface::setCurrentValue(const QVariant &value)
290
291     Sets the \a value. If the desired \a value is out of the range of permissible values,
292     this call will be ignored.
293
294     \sa currentValue(), minimumValue(), maximumValue()
295 */
296
297 /*!
298     \fn QVariant QAccessibleValueInterface::maximumValue() const
299
300     Returns the maximum value this object accepts.
301     \sa minimumValue(), currentValue()
302 */
303
304 /*!
305     \fn QVariant QAccessibleValueInterface::minimumValue() const
306
307     Returns the minimum value this object accepts.
308     \sa maximumValue(), currentValue()
309 */
310
311 /*!
312     \class QAccessibleImageInterface
313     \ingroup accessibility
314     \internal
315     \preliminary
316
317     \brief The QAccessibleImageInterface class implements support for
318     the IAccessibleImage interface.
319
320     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
321 */
322
323 /*!
324     \class QAccessibleTableCellInterface
325     \ingroup accessibility
326
327     \brief The QAccessibleTableCellInterface class implements support for
328     the IAccessibleTable2 Cell interface.
329
330     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
331 */
332
333 /*!
334     \class QAccessibleTableInterface
335     \ingroup accessibility
336
337     \brief The QAccessibleTableInterface class implements support for
338     the IAccessibleTable2 interface.
339
340     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
341 */
342
343
344 /*!
345     \class QAccessibleActionInterface
346     \ingroup accessibility
347
348     \brief The QAccessibleActionInterface class implements support for
349     invocable actions in the interface.
350
351     Accessible objects should implement the action interface if they support user interaction.
352     Usually this interface is implemented by classes that also implement \l QAccessibleInterface.
353
354     The supported actions should use the predefined actions offered in this class unless they do not
355     fit a predefined action. In that case a custom action can be added.
356
357     When subclassing QAccessibleActionInterface you need to provide a list of actionNames which
358     is the primary means to discover the available actions. Action names are never localized.
359     In order to present actions to the user there are two functions that need to return localized versions
360     of the name and give a description of the action. For the predefined action names use
361     \l QAccessibleActionInterface::localizedActionName() and \l QAccessibleActionInterface::localizedActionDescription()
362     to return their localized counterparts.
363
364     In general you should use one of the predefined action names, unless describing an action that does not fit these:
365     \table
366     \header \o Action name         \o Description
367     \row    \o \l checkAction()    \o checks the item (checkbox, radio button, ...)
368     \row    \o \l decreaseAction() \o decrease the value of the accessible (e.g. spinbox)
369     \row    \o \l increaseAction() \o increase the value of the accessible (e.g. spinbox)
370     \row    \o \l pressAction()    \o press or click or activate the accessible (should correspont to clicking the object with the mouse)
371     \row    \o \l setFocusAction() \o set the focus to this accessible
372     \row    \o \l showMenuAction() \o show a context menu, corresponds to right-clicks
373     \row    \o \l uncheckAction()  \o uncheck the item (checkbox, radio button, ...)
374     \endtable
375
376     In order to invoke the action, \l doAction() is called with an action name.
377
378     Most widgets will simply implement \l pressAction(). This is what happens when the widget is activated by
379     being clicked, space pressed or similar.
380
381     \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
382 */
383
384 /*!
385     \fn QStringList QAccessibleActionInterface::actionNames() const
386
387     Returns the list of actions supported by this accessible object.
388     The actions returned should be in preferred order,
389     i.e. the action that the user most likely wants to trigger should be returned first,
390     while the least likely action should be returned last.
391
392     The list does only contain actions that can be invoked.
393     It won't return disabled actions, or actions associated with disabled UI controls.
394
395     The list can be empty.
396
397     Note that this list is not localized. For a localized representation re-implement \l localizedActionName()
398     and \l localizedActionDescription()
399
400     \sa doAction(), localizedActionName(), localizedActionDescription()
401 */
402
403 /*!
404     \fn QString QAccessibleActionInterface::localizedActionName(const QString &actionName) const
405
406     Returns a localized action name of \a actionName.
407
408     For custom actions this function has to be re-implemented.
409     When using one of the default names, you can call this function in QAccessibleActionInterface
410     to get the localized string.
411
412     \sa actionNames(), localizedActionDescription()
413 */
414
415 /*!
416     \fn QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
417
418     Returns a localized action description of the action \a actionName.
419
420     When using one of the default names, you can call this function in QAccessibleActionInterface
421     to get the localized string.
422
423     \sa actionNames(), localizedActionName()
424 */
425
426 /*!
427     \fn void QAccessibleActionInterface::doAction(const QString &actionName)
428
429     Invokes the action specified by \a actionName.
430     Note that \a actionName is the non-localized name as returned by \l actionNames()
431     This function is usually implemented by calling the same functions
432     that other user interaction, such as clicking the object, would trigger.
433
434     \sa actionNames()
435 */
436
437 /*!
438     \fn QStringList QAccessibleActionInterface::keyBindingsForAction(const QString &actionName) const
439
440     Returns a list of the keyboard shortcuts available for invoking the action named \a actionName.
441
442     This is important to let users learn alternative ways of using the application by emphasizing the keyboard.
443
444     \sa actionNames()
445 */
446
447
448 struct QAccessibleActionStrings
449 {
450     QAccessibleActionStrings() :
451         pressAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Press"))),
452         increaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Increase"))),
453         decreaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Decrease"))),
454         showMenuAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "ShowMenu"))),
455         setFocusAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "SetFocus"))),
456         checkAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Check"))),
457         uncheckAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Uncheck"))) {}
458
459     const QString pressAction;
460     const QString increaseAction;
461     const QString decreaseAction;
462     const QString showMenuAction;
463     const QString setFocusAction;
464     const QString checkAction;
465     const QString uncheckAction;
466 };
467
468 Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings)
469
470 QString QAccessibleActionInterface::localizedActionName(const QString &actionName) const
471 {
472     return QAccessibleActionInterface::tr(qPrintable(actionName));
473 }
474
475 QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
476 {
477     const QAccessibleActionStrings *strings = accessibleActionStrings();
478     if (actionName == strings->pressAction)
479         return tr("Triggers the action");
480     else if (actionName == strings->increaseAction)
481         return tr("Increase the value");
482     else if (actionName == strings->decreaseAction)
483         return tr("Decrease the value");
484     else if (actionName == strings->showMenuAction)
485         return tr("Shows the menu");
486     else if (actionName == strings->setFocusAction)
487         return tr("Sets the focus");
488     else if (actionName == strings->checkAction)
489         return tr("Checks the checkbox");
490     else if (actionName == strings->uncheckAction)
491         return tr("Unchecks the checkbox");
492
493     return QString();
494 }
495
496 /*!
497     Returns the name of the press default action.
498     \sa actionNames(), localizedActionName()
499   */
500 const QString &QAccessibleActionInterface::pressAction()
501 {
502     return accessibleActionStrings()->pressAction;
503 }
504
505 /*!
506     Returns the name of the increase default action.
507     \sa actionNames(), localizedActionName()
508   */
509 const QString &QAccessibleActionInterface::increaseAction()
510 {
511     return accessibleActionStrings()->increaseAction;
512 }
513
514 /*!
515     Returns the name of the decrease default action.
516     \sa actionNames(), localizedActionName()
517   */
518 const QString &QAccessibleActionInterface::decreaseAction()
519 {
520     return accessibleActionStrings()->decreaseAction;
521 }
522
523 /*!
524     Returns the name of the show menu default action.
525     \sa actionNames(), localizedActionName()
526   */
527 const QString &QAccessibleActionInterface::showMenuAction()
528 {
529     return accessibleActionStrings()->showMenuAction;
530 }
531
532 /*!
533     Returns the name of the set focus default action.
534     \sa actionNames(), localizedActionName()
535   */
536 const QString &QAccessibleActionInterface::setFocusAction()
537 {
538     return accessibleActionStrings()->setFocusAction;
539 }
540
541 /*!
542     Returns the name of the check default action.
543     \sa actionNames(), localizedActionName()
544   */
545 const QString &QAccessibleActionInterface::checkAction()
546 {
547     return accessibleActionStrings()->checkAction;
548 }
549
550 /*!
551     Returns the name of the uncheck default action.
552     \sa actionNames(), localizedActionName()
553   */
554 const QString &QAccessibleActionInterface::uncheckAction()
555 {
556     return accessibleActionStrings()->uncheckAction;
557 }
558
559 /*!
560   \internal
561 */
562 QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
563         int *startOffset, int *endOffset, const QString& text)
564 {
565     QTextBoundaryFinder::BoundaryType type;
566     switch (boundaryType) {
567     case QAccessible2::CharBoundary:
568         type = QTextBoundaryFinder::Grapheme;
569         break;
570     case QAccessible2::WordBoundary:
571         type = QTextBoundaryFinder::Word;
572         break;
573     case QAccessible2::SentenceBoundary:
574         type = QTextBoundaryFinder::Sentence;
575         break;
576     default:
577         // in any other case return the whole line
578         *startOffset = 0;
579         *endOffset = text.length();
580         return text;
581     }
582
583     QTextBoundaryFinder boundary(type, text);
584     boundary.setPosition(offset);
585
586     if (!boundary.isAtBoundary()) {
587         boundary.toPreviousBoundary();
588     }
589     boundary.toPreviousBoundary();
590     *startOffset = boundary.position();
591     boundary.toNextBoundary();
592     *endOffset = boundary.position();
593
594     return text.mid(*startOffset, *endOffset - *startOffset);
595 }
596
597 /*!
598   \internal
599 */
600 QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
601         int *startOffset, int *endOffset, const QString& text)
602 {
603     QTextBoundaryFinder::BoundaryType type;
604     switch (boundaryType) {
605     case QAccessible2::CharBoundary:
606         type = QTextBoundaryFinder::Grapheme;
607         break;
608     case QAccessible2::WordBoundary:
609         type = QTextBoundaryFinder::Word;
610         break;
611     case QAccessible2::SentenceBoundary:
612         type = QTextBoundaryFinder::Sentence;
613         break;
614     default:
615         // in any other case return the whole line
616         *startOffset = 0;
617         *endOffset = text.length();
618         return text;
619     }
620
621     QTextBoundaryFinder boundary(type, text);
622     boundary.setPosition(offset);
623
624     boundary.toNextBoundary();
625     *startOffset = boundary.position();
626     boundary.toNextBoundary();
627     *endOffset = boundary.position();
628
629     return text.mid(*startOffset, *endOffset - *startOffset);
630 }
631
632 /*!
633   \internal
634 */
635 QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType,
636         int *startOffset, int *endOffset, const QString& text)
637 {
638     QTextBoundaryFinder::BoundaryType type;
639     switch (boundaryType) {
640     case QAccessible2::CharBoundary:
641         type = QTextBoundaryFinder::Grapheme;
642         break;
643     case QAccessible2::WordBoundary:
644         type = QTextBoundaryFinder::Word;
645         break;
646     case QAccessible2::SentenceBoundary:
647         type = QTextBoundaryFinder::Sentence;
648         break;
649     default:
650         // in any other case return the whole line
651         *startOffset = 0;
652         *endOffset = text.length();
653         return text;
654     }
655
656     QTextBoundaryFinder boundary(type, text);
657     boundary.setPosition(offset);
658
659     if (!boundary.isAtBoundary()) {
660         boundary.toPreviousBoundary();
661     }
662     *startOffset = boundary.position();
663     boundary.toNextBoundary();
664     *endOffset = boundary.position();
665
666     return text.mid(*startOffset, *endOffset - *startOffset);
667 }
668
669 QAccessibleSimpleEditableTextInterface::QAccessibleSimpleEditableTextInterface(
670                 QAccessibleInterface *accessibleInterface)
671     : iface(accessibleInterface)
672 {
673     Q_ASSERT(iface);
674 }
675
676 #ifndef QT_NO_CLIPBOARD
677 static QString textForRange(QAccessibleInterface *iface, int startOffset, int endOffset)
678 {
679     return iface->text(QAccessible::Value).mid(startOffset, endOffset - startOffset);
680 }
681 #endif
682
683 /*! \reimp */
684 void QAccessibleSimpleEditableTextInterface::copyText(int startOffset, int endOffset) const
685 {
686 #ifdef QT_NO_CLIPBOARD
687     Q_UNUSED(startOffset);
688     Q_UNUSED(endOffset);
689 #else
690     QGuiApplication::clipboard()->setText(textForRange(iface, startOffset, endOffset));
691 #endif
692 }
693
694 /*! \reimp */
695 void QAccessibleSimpleEditableTextInterface::deleteText(int startOffset, int endOffset)
696 {
697     QString txt = iface->text(QAccessible::Value);
698     txt.remove(startOffset, endOffset - startOffset);
699     iface->setText(QAccessible::Value, txt);
700 }
701
702 /*! \reimp */
703 void QAccessibleSimpleEditableTextInterface::insertText(int offset, const QString &text)
704 {
705     QString txt = iface->text(QAccessible::Value);
706     txt.insert(offset, text);
707     iface->setText(QAccessible::Value, txt);
708 }
709
710 /*! \reimp */
711 void QAccessibleSimpleEditableTextInterface::cutText(int startOffset, int endOffset)
712 {
713 #ifdef QT_NO_CLIPBOARD
714     Q_UNUSED(startOffset);
715     Q_UNUSED(endOffset);
716 #else
717     QString sub = textForRange(iface, startOffset, endOffset);
718     deleteText(startOffset, endOffset);
719     QGuiApplication::clipboard()->setText(sub);
720 #endif
721 }
722
723 /*! \reimp */
724 void QAccessibleSimpleEditableTextInterface::pasteText(int offset)
725 {
726 #ifdef QT_NO_CLIPBOARD
727     Q_UNUSED(offset);
728 #else
729     QString txt = iface->text(QAccessible::Value);
730     txt.insert(offset, QGuiApplication::clipboard()->text());
731     iface->setText(QAccessible::Value, txt);
732 #endif
733 }
734
735 /*! \reimp */
736 void QAccessibleSimpleEditableTextInterface::replaceText(int startOffset, int endOffset, const QString &text)
737 {
738     QString txt = iface->text(QAccessible::Value);
739     txt.replace(startOffset, endOffset - startOffset, text);
740     iface->setText(QAccessible::Value, txt);
741 }
742
743 QT_END_NAMESPACE
744
745 #endif // QT_NO_ACCESSIBILITY