1616from controlTypes import TextPosition
1717import textInfos
1818import colors
19- from compoundDocuments import CompoundDocument
19+ from compoundDocuments import CompoundDocument , TreeCompoundTextInfo
2020from NVDAObjects .IAccessible import IAccessible , IA2TextTextInfo
2121from NVDAObjects .behaviors import EditableText
2222from logHandler import log
2323import speech
2424import api
2525import braille
26+ import languageHandler
2627import vision
2728
2829
@@ -275,6 +276,49 @@ class SymphonyParagraph(SymphonyText):
275276 value = None
276277 description = None
277278
279+
280+ def getDistanceTextForTwips (twips ):
281+ """Returns a text representation of the distance given in twips,
282+ converted to the local measurement unit."""
283+ if languageHandler .useImperialMeasurements ():
284+ val = twips / 1440.0
285+ # Translators: a measurement in inches
286+ valText = _ ("{val:.2f} inches" ).format (val = val )
287+ else :
288+ val = twips * 0.0017638889
289+ # Translators: a measurement in centimetres
290+ valText = _ ("{val:.2f} centimetres" ).format (val = val )
291+ return valText
292+
293+
294+ class SymphonyDocumentTextInfo (TreeCompoundTextInfo ):
295+
296+ def __init__ (self , obj , position ):
297+ super (SymphonyDocumentTextInfo , self ).__init__ (obj , position )
298+
299+ def _get_locationText (self ):
300+ try :
301+ # if present, use document attributes to get cursor position relative to page
302+ docAttribs = self .obj .rootNVDAObject .IA2Attributes
303+ horizontalPos = int (docAttribs ["cursor-position-in-page-horizontal" ])
304+ horizontalDistanceText = getDistanceTextForTwips (horizontalPos )
305+ verticalPos = int (docAttribs ["cursor-position-in-page-vertical" ])
306+ verticalDistanceText = getDistanceTextForTwips (verticalPos )
307+ # Translators: LibreOffice, report cursor position in the current page
308+ return _ (
309+ "cursor positioned {horizontalDistance} from left edge of page, {verticalDistance} from top edge of page"
310+ ).format (horizontalDistance = horizontalDistanceText , verticalDistance = verticalDistanceText )
311+ except (AttributeError , KeyError ):
312+ return super (SymphonyDocumentTextInfo , self )._get_locationText ()
313+
314+
315+ class SymphonyDocument (CompoundDocument ):
316+ TextInfo = SymphonyDocumentTextInfo
317+
318+ def __init__ (self , rootNVDAObject ):
319+ super (SymphonyDocument , self ).__init__ (rootNVDAObject )
320+
321+
278322class AppModule (appModuleHandler .AppModule ):
279323
280324 def chooseNVDAObjectOverlayClasses (self , obj , clsList ):
@@ -301,4 +345,4 @@ def event_NVDAObject_init(self, obj):
301345 if windowClass in ("SALTMPSUBFRAME" , "SALFRAME" ) and obj .role in (controlTypes .Role .DOCUMENT ,controlTypes .Role .TEXTFRAME ) and obj .description :
302346 # This is a word processor document.
303347 obj .description = None
304- obj .treeInterceptorClass = CompoundDocument
348+ obj .treeInterceptorClass = SymphonyDocument
0 commit comments