Qt 4.8
Namespaces | Functions
qaccessible2.cpp File Reference
#include "qaccessible2.h"
#include "qapplication.h"
#include "qclipboard.h"
#include "qtextboundaryfinder.h"

Go to the source code of this file.

Namespaces

 QAccessible2
 The QAccessible2 namespace defines constants relating to IAccessible2-based interfaces.
 

Functions

QString Q_GUI_EXPORT qTextAfterOffsetFromString (int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString &text)
 
QString Q_GUI_EXPORT qTextAtOffsetFromString (int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString &text)
 
QString Q_GUI_EXPORT qTextBeforeOffsetFromString (int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString &text)
 
static QString textForRange (QAccessibleInterface *iface, int startOffset, int endOffset)
 

Function Documentation

◆ qTextAfterOffsetFromString()

QString Q_GUI_EXPORT qTextAfterOffsetFromString ( int  offset,
QAccessible2::BoundaryType  boundaryType,
int *  startOffset,
int *  endOffset,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 199 of file qaccessible2.cpp.

Referenced by QAccessibleLineEdit::textAfterOffset().

201 {
203  switch (boundaryType) {
206  break;
209  break;
212  break;
213  default:
214  // in any other case return the whole line
215  *startOffset = 0;
216  *endOffset = text.length();
217  return text;
218  }
219 
220  QTextBoundaryFinder boundary(type, text);
221  boundary.setPosition(offset);
222 
223  boundary.toNextBoundary();
224  *startOffset = boundary.position();
225  boundary.toNextBoundary();
226  *endOffset = boundary.position();
227 
228  return text.mid(*startOffset, *endOffset - *startOffset);
229 }
int type
Definition: qmetatype.cpp:239
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
#define text
Definition: qobjectdefs.h:80

◆ qTextAtOffsetFromString()

QString Q_GUI_EXPORT qTextAtOffsetFromString ( int  offset,
QAccessible2::BoundaryType  boundaryType,
int *  startOffset,
int *  endOffset,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 234 of file qaccessible2.cpp.

Referenced by QAccessibleLineEdit::textAtOffset().

236 {
238  switch (boundaryType) {
241  break;
244  break;
247  break;
248  default:
249  // in any other case return the whole line
250  *startOffset = 0;
251  *endOffset = text.length();
252  return text;
253  }
254 
255  QTextBoundaryFinder boundary(type, text);
256  boundary.setPosition(offset);
257 
258  if (!boundary.isAtBoundary()) {
259  boundary.toPreviousBoundary();
260  }
261  *startOffset = boundary.position();
262  boundary.toNextBoundary();
263  *endOffset = boundary.position();
264 
265  return text.mid(*startOffset, *endOffset - *startOffset);
266 }
int type
Definition: qmetatype.cpp:239
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
#define text
Definition: qobjectdefs.h:80

◆ qTextBeforeOffsetFromString()

QString Q_GUI_EXPORT qTextBeforeOffsetFromString ( int  offset,
QAccessible2::BoundaryType  boundaryType,
int *  startOffset,
int *  endOffset,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 161 of file qaccessible2.cpp.

Referenced by QAccessibleLineEdit::textBeforeOffset().

163 {
165  switch (boundaryType) {
168  break;
171  break;
174  break;
175  default:
176  // in any other case return the whole line
177  *startOffset = 0;
178  *endOffset = text.length();
179  return text;
180  }
181 
182  QTextBoundaryFinder boundary(type, text);
183  boundary.setPosition(offset);
184 
185  if (!boundary.isAtBoundary()) {
186  boundary.toPreviousBoundary();
187  }
188  boundary.toPreviousBoundary();
189  *startOffset = boundary.position();
190  boundary.toNextBoundary();
191  *endOffset = boundary.position();
192 
193  return text.mid(*startOffset, *endOffset - *startOffset);
194 }
int type
Definition: qmetatype.cpp:239
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
#define text
Definition: qobjectdefs.h:80

◆ textForRange()

static QString textForRange ( QAccessibleInterface iface,
int  startOffset,
int  endOffset 
)
static

Definition at line 276 of file qaccessible2.cpp.

Referenced by QAccessibleSimpleEditableTextInterface::copyText(), and QAccessibleSimpleEditableTextInterface::cutText().

277 {
278  return iface->text(QAccessible::Value, 0).mid(startOffset, endOffset - startOffset);
279 }
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
virtual QString text(Text t, int child) const =0
Returns the value of the text property t of the object, or of the object's child if child is not 0...