def _generateTooLong(self, obj, **args): """If there is text in this spread sheet cell, compare the size of the text within the table cell with the size of the actual table cell and report back to the user if it is larger. Returns an indication of how many characters are greater than the size of the spread sheet cell, or None if the message fits. """ if _settingsManager.getSetting('onlySpeakDisplayedText'): return [] result = [] acss = self.voice(speech_generator.SYSTEM) try: text = obj.queryText() objectText = \ self._script.utilities.substring(obj, 0, -1) extents = obj.queryComponent().getExtents(pyatspi.DESKTOP_COORDS) except NotImplementedError: pass else: tooLongCount = 0 for i in range(0, len(objectText)): [x, y, width, height] = text.getRangeExtents(i, i + 1, 0) if x < extents.x: tooLongCount += 1 elif (x + width) > extents.x + extents.width: tooLongCount += len(objectText) - i break if tooLongCount > 0: result = [messages.charactersTooLong(tooLongCount)] if result: result.extend(acss) return result