From ef50b51bf0e2d8ce91d89b86b05a149738da8873 Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Fri, 25 Jul 2008 08:06:45 +0000 Subject: INTEGRATION: CWS aqua11y02 (1.2.30); FILE MERGED 2008/06/05 08:21:49 fne 1.2.30.2: #i85851# attributes are now supported 2008/05/15 12:08:33 fne 1.2.30.1: #i87833# when caret pos is -1, VO tries to access invalid memory position --- vcl/aqua/source/a11y/aqua11ytextwrapper.mm | 34 +++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'vcl/aqua/source/a11y') diff --git a/vcl/aqua/source/a11y/aqua11ytextwrapper.mm b/vcl/aqua/source/a11y/aqua11ytextwrapper.mm index 026fab545d54..5859e5f661ba 100644 --- a/vcl/aqua/source/a11y/aqua11ytextwrapper.mm +++ b/vcl/aqua/source/a11y/aqua11ytextwrapper.mm @@ -8,7 +8,7 @@ * * $RCSfile: aqua11ytextwrapper.mm,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * @@ -45,7 +45,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::rtl; -// Wrapper for XAccessibleText and XAccessibleEditableText +// Wrapper for XAccessibleText, XAccessibleEditableText and XAccessibleMultiLineText @implementation AquaA11yTextWrapper : NSObject @@ -85,7 +85,11 @@ using namespace ::rtl; if ( start != end ) { return [ NSValue valueWithRange: NSMakeRange ( start, end - start ) ]; // true selection } else { - return [ NSValue valueWithRange: NSMakeRange ( [ wrapper accessibleText ] -> getCaretPosition(), 0 ) ]; // insertion point + long caretPos = [ wrapper accessibleText ] -> getCaretPosition(); + if ( caretPos < 0 || caretPos > [ wrapper accessibleText ] -> getCharacterCount() ) { + return nil; + } + return [ NSValue valueWithRange: NSMakeRange ( caretPos, 0 ) ]; // insertion point } } @@ -144,9 +148,33 @@ using namespace ::rtl; NSAccessibilityBoundsForRangeParameterizedAttribute, NSAccessibilityStyleRangeForIndexParameterizedAttribute, NSAccessibilityRTFForRangeParameterizedAttribute, + NSAccessibilityLineForIndexParameterizedAttribute, + NSAccessibilityRangeForLineParameterizedAttribute, nil ]; } ++(id)lineForIndexAttributeForElement:(AquaA11yWrapper *)wrapper forParameter:(id)index { + NSNumber * lineNumber = nil; + try { + sal_Int32 line = [ wrapper accessibleMultiLineText ] -> getLineNumberAtIndex ( (sal_Int32) [ index intValue ] ); + lineNumber = [ NSNumber numberWithInt: line ]; + } catch ( IndexOutOfBoundsException & e ) { + // empty + } + return lineNumber; +} + ++(id)rangeForLineAttributeForElement:(AquaA11yWrapper *)wrapper forParameter:(id)line { + NSValue * range = nil; + try { + TextSegment textSegment = [ wrapper accessibleMultiLineText ] -> getTextAtLineNumber ( [ line intValue ] ); + range = [ NSValue valueWithRange: NSMakeRange ( textSegment.SegmentStart, textSegment.SegmentEnd - textSegment.SegmentStart ) ]; + } catch ( IndexOutOfBoundsException & e ) { + // empty + } + return range; +} + +(id)stringForRangeAttributeForElement:(AquaA11yWrapper *)wrapper forParameter:(id)range { int loc = [ range rangeValue ].location; int len = [ range rangeValue ].length; -- cgit