diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-03-17 18:17:41 +0100 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Sun.COM> | 2010-03-17 18:17:41 +0100 |
commit | 6f27503a9eb9341d3656149e2fe4b658a643b9ab (patch) | |
tree | 191704903b4bad142a1f84b71ed6fa6938752cb4 /vcl | |
parent | 7a416820ab5e03f8b988656e0f6a592cb1e81d07 (diff) |
vcl110: #i103230# add row/columns attributes to tables
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/aqua/source/a11y/aqua11yfactory.mm | 3 | ||||
-rw-r--r-- | vcl/aqua/source/a11y/aqua11ytablewrapper.h | 10 | ||||
-rw-r--r-- | vcl/aqua/source/a11y/aqua11ytablewrapper.mm | 182 | ||||
-rw-r--r-- | vcl/aqua/source/a11y/aqua11ywrapper.mm | 31 |
4 files changed, 185 insertions, 41 deletions
diff --git a/vcl/aqua/source/a11y/aqua11yfactory.mm b/vcl/aqua/source/a11y/aqua11yfactory.mm index eb745ea24aa5..7732ce202cd2 100644 --- a/vcl/aqua/source/a11y/aqua11yfactory.mm +++ b/vcl/aqua/source/a11y/aqua11yfactory.mm @@ -48,6 +48,7 @@ #include "aqua11ywrappersplitter.h" #include "aqua11ywrappertabgroup.h" #include "aqua11ywrappertoolbar.h" +#include "aqua11ytablewrapper.h" #include <com/sun/star/accessibility/AccessibleStateType.hpp> using namespace ::com::sun::star::accessibility; @@ -142,6 +143,8 @@ static bool enabled = false; aWrapper = [ [ AquaA11yWrapperList alloc ] initWithAccessibleContext: rxAccessibleContext ]; } else if ( [ nativeRole isEqualToString: NSAccessibilitySplitterRole ] ) { aWrapper = [ [ AquaA11yWrapperSplitter alloc ] initWithAccessibleContext: rxAccessibleContext ]; + } else if ( [ nativeRole isEqualToString: NSAccessibilityTableRole ] ) { + aWrapper = [ [ AquaA11yTableWrapper alloc ] initWithAccessibleContext: rxAccessibleContext ]; } else { aWrapper = [ [ AquaA11yWrapper alloc ] initWithAccessibleContext: rxAccessibleContext ]; } diff --git a/vcl/aqua/source/a11y/aqua11ytablewrapper.h b/vcl/aqua/source/a11y/aqua11ytablewrapper.h index 8753365377e3..7bf3e44a2945 100644 --- a/vcl/aqua/source/a11y/aqua11ytablewrapper.h +++ b/vcl/aqua/source/a11y/aqua11ytablewrapper.h @@ -30,9 +30,15 @@ #include "aqua11ywrapper.h" -@interface AquaA11yTableWrapper : NSObject +#define MAXIMUM_ACCESSIBLE_TABLE_CELLS 1000 + +@interface AquaA11yTableWrapper : AquaA11yWrapper { } -+(id)childrenAttributeForElement:(AquaA11yWrapper *)wrapper; ++(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper; ++(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject; + +-(id)rowsAttribute; +-(id)columnsAttribute; @end #endif // _SV_AQUA11TABLEWRAPPER_H diff --git a/vcl/aqua/source/a11y/aqua11ytablewrapper.mm b/vcl/aqua/source/a11y/aqua11ytablewrapper.mm index 08205ac8a66b..98454ab8d57b 100644 --- a/vcl/aqua/source/a11y/aqua11ytablewrapper.mm +++ b/vcl/aqua/source/a11y/aqua11ytablewrapper.mm @@ -35,38 +35,120 @@ using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::uno; -@implementation AquaA11yTableWrapper : NSObject +@implementation AquaA11yTableWrapper : AquaA11yWrapper -+(id)childrenAttributeForElement:(AquaA11yWrapper *)wrapper ++(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper { - try + XAccessibleTable * accessibleTable = [ wrapper accessibleTable ]; + NSArray* pResult = nil; + if( accessibleTable ) { NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; - XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ]; - XAccessibleTable * accessibleTable = [ wrapper accessibleTable ]; - // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell - Size tableSize = accessibleComponent -> getSize(); - Point point; - point.X = 0; - point.Y = 0; - Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point ); - point.X = tableSize.Width - 1; - point.Y = tableSize.Height - 1; - Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point ); - if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() ) + try { - sal_Int32 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent(); - sal_Int32 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent(); - sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft ); - sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); - sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); - sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); - // create an array containing the visible cells - for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + + if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) { - for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ ) + // make all children visible to the hierarchy + for ( sal_Int32 rowCount = 0; rowCount < nRows; rowCount++ ) { - Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); + for ( sal_Int32 columnCount = 0; columnCount < nCols; columnCount++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); + if ( rAccessibleCell.is() ) + { + id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; + [ cells addObject: cell_wrapper ]; + [ cell_wrapper release ]; + } + } + } + } + else + { + XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ]; + // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell + Size tableSize = accessibleComponent -> getSize(); + Point point; + point.X = 0; + point.Y = 0; + Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point ); + point.X = tableSize.Width - 1; + point.Y = tableSize.Height - 1; + Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point ); + if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() ) + { + sal_Int32 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent(); + sal_Int32 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent(); + sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft ); + sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); + sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); + sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); + // create an array containing the visible cells + for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) + { + for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); + if ( rAccessibleCell.is() ) + { + id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; + [ cells addObject: cell_wrapper ]; + [ cell_wrapper release ]; + } + } + } + } + } + pResult = NSAccessibilityUnignoredChildren( cells ); + } + catch (const Exception &e) + { + } + [cells autorelease]; + } + + return pResult; +} + ++(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject +{ + XAccessibleTable * accessibleTable = [ pObject accessibleTable ]; + if( accessibleTable ) + { + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + + + if( nRows*nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + { + [ attributeNames addObject: NSAccessibilityRowsAttribute ]; + [ attributeNames addObject: NSAccessibilityColumnsAttribute ]; + } + } +} + +-(id)rowsAttribute +{ + NSArray* pResult = nil; + + XAccessibleTable * accessibleTable = [ self accessibleTable ]; + if( accessibleTable ) + { + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + { + NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; + try + { + // find out number of rows + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + for( sal_Int32 n = 0; n < nRows; n++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( n, 0 ); if ( rAccessibleCell.is() ) { id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; @@ -74,16 +156,56 @@ using namespace ::com::sun::star::uno; [ cell_wrapper release ]; } } + pResult = NSAccessibilityUnignoredChildren( cells ); + } + catch (const Exception &e) + { + pResult = nil; } + [ cells autorelease ]; } - [ cells autorelease ]; - return NSAccessibilityUnignoredChildren( cells ); } - catch (const Exception &e) + + return pResult; +} + +-(id)columnsAttribute +{ + NSArray* pResult = nil; + + XAccessibleTable * accessibleTable = [ self accessibleTable ]; + + if( accessibleTable ) { - // TODO: Log - return nil; + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + { + NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; + try + { + // find out number of columns + for( sal_Int32 n = 0; n < nCols; n++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( 0, n ); + if ( rAccessibleCell.is() ) + { + id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; + [ cells addObject: cell_wrapper ]; + [ cell_wrapper release ]; + } + } + pResult = NSAccessibilityUnignoredChildren( cells ); + } + catch (const Exception &e) + { + pResult = nil; + } + [ cells autorelease ]; + } } + + return pResult; } @end diff --git a/vcl/aqua/source/a11y/aqua11ywrapper.mm b/vcl/aqua/source/a11y/aqua11ywrapper.mm index 959746d533dc..e86676e725f2 100644 --- a/vcl/aqua/source/a11y/aqua11ywrapper.mm +++ b/vcl/aqua/source/a11y/aqua11ywrapper.mm @@ -29,6 +29,8 @@ #include "precompiled_vcl.hxx" #include "salinst.h" +#include "saldata.hxx" + #include "aqua11ywrapper.h" #include "aqua11yactionwrapper.h" #include "aqua11ycomponentwrapper.h" @@ -41,6 +43,7 @@ #include "aqua11yfocuslistener.hxx" #include "aqua11yfocustracker.hxx" #include "aqua11yrolehelper.h" + #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> @@ -217,7 +220,8 @@ static MacOSBOOL isPopupMenuOpen = NO; -(id)roleAttribute { if ( mActsAsRadioGroup ) { return NSAccessibilityRadioGroupRole; - } else { + } + else { return [ AquaA11yRoleHelper getNativeRoleFrom: [ self accessibleContext ] ]; } } @@ -323,8 +327,10 @@ static MacOSBOOL isPopupMenuOpen = NO; } } return children; - } else if ( [ self accessibleTable ] != nil ) { - return [ AquaA11yTableWrapper childrenAttributeForElement: self ]; + } else if ( [ self accessibleTable ] != nil ) + { + AquaA11yTableWrapper* pTable = [self isKindOfClass: [AquaA11yTableWrapper class]] ? (AquaA11yTableWrapper*)self : nil; + return [ AquaA11yTableWrapper childrenAttributeForElement: pTable ]; } else { try { NSMutableArray * children = [ [ NSMutableArray alloc ] init ]; @@ -663,6 +669,7 @@ static MacOSBOOL isPopupMenuOpen = NO; if ( isPopupMenuOpen ) { return nil; } + id value = nil; // if we are no longer in the wrapper repository, we have been disposed AquaA11yWrapper * theWrapper = [ AquaA11yFactory wrapperForAccessibleContext: [ self accessibleContext ] createIfNotExists: NO ]; @@ -717,6 +724,7 @@ static MacOSBOOL isPopupMenuOpen = NO; NSString * nativeSubrole = nil; NSString * title = nil; NSMutableArray * attributeNames = nil; + sal_Int32 nAccessibleChildren = 0; try { // Default Attributes attributeNames = [ NSMutableArray arrayWithObjects: @@ -737,8 +745,9 @@ static MacOSBOOL isPopupMenuOpen = NO; } try { - if ( [ self accessibleContext ] -> getAccessibleChildCount() > 0 ) { - [ attributeNames addObject: NSAccessibilityChildrenAttribute ]; + nAccessibleChildren = [ self accessibleContext ] -> getAccessibleChildCount(); + if ( nAccessibleChildren > 0 ) { + [ attributeNames addObject: NSAccessibilityChildrenAttribute ]; } } catch( DisposedException& ) {} @@ -754,6 +763,9 @@ static MacOSBOOL isPopupMenuOpen = NO; [ attributeNames addObject: NSAccessibilityServesAsTitleForUIElementsAttribute ]; } // Special Attributes depending on interface + if( [self accessibleContext ] -> getAccessibleRole() == AccessibleRole::TABLE ) + [AquaA11yTableWrapper addAttributeNamesTo: attributeNames object: self]; + if ( [ self accessibleText ] != nil ) { [ AquaA11yTextWrapper addAttributeNamesTo: attributeNames ]; } @@ -953,14 +965,15 @@ static MacOSBOOL isPopupMenuOpen = NO; return hit; } -Reference < XAccessibleContext > hitTestRunner ( Point point, Reference < XAccessibleContext > rxAccessibleContext ) { +Reference < XAccessibleContext > hitTestRunner ( com::sun::star::awt::Point point, + Reference < XAccessibleContext > rxAccessibleContext ) { Reference < XAccessibleContext > hitChild; Reference < XAccessibleContext > emptyReference; try { Reference < XAccessibleComponent > rxAccessibleComponent ( rxAccessibleContext, UNO_QUERY ); if ( rxAccessibleComponent.is() ) { - Point location = rxAccessibleComponent -> getLocationOnScreen(); - Point hitPoint ( point.X - location.X , point.Y - location.Y); + com::sun::star::awt::Point location = rxAccessibleComponent -> getLocationOnScreen(); + com::sun::star::awt::Point hitPoint ( point.X - location.X , point.Y - location.Y); Reference < XAccessible > rxAccessible = rxAccessibleComponent -> getAccessibleAtPoint ( hitPoint ); if ( rxAccessible.is() && rxAccessible -> getAccessibleContext().is() ) { if ( rxAccessible -> getAccessibleContext() -> getAccessibleChildCount() > 0 ) { @@ -999,7 +1012,7 @@ Reference < XAccessibleContext > hitTestRunner ( Point point, Reference < XAcces } Reference < XAccessibleContext > hitChild; NSRect screenRect = [ [ NSScreen mainScreen ] frame ]; - Point hitPoint ( static_cast<long>(point.x) , static_cast<long>(screenRect.size.height - point.y) ); + com::sun::star::awt::Point hitPoint ( static_cast<long>(point.x) , static_cast<long>(screenRect.size.height - point.y) ); // check child windows first NSWindow * window = (NSWindow *) [ self accessibilityAttributeValue: NSAccessibilityWindowAttribute ]; NSArray * childWindows = [ window childWindows ]; |