Commits

Anonymous committed c6c28b6

accfixes3: AccessibleListBox/Entry::getRoleType replaced with shouldHaveListRole, this way simplifying the
overly complex method to what is really needed by the clients (which is a boolean flag only).

Comments (0)

Files changed (6)

accessibility/inc/accessibility/extended/AccessibleGridControlTableCell.hxx

 										,public AccessibleTextHelper_BASE
 										,public ::comphelper::OCommonAccessibleText
 	{
-    private:
-        sal_Int32   m_nOffset;
-
 	protected:
 		// OCommonAccessibleText
 		virtual ::rtl::OUString					implGetText();

accessibility/inc/accessibility/extended/accessiblelistbox.hxx

 		void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
 
 		// IA2 CWS
-		sal_Int32 SAL_CALL getRoleType();
+        static bool shouldHaveListRole( SvTreeListBox const & i_treeListBox );
 		
 private:
 

accessibility/inc/accessibility/extended/accessiblelistboxentry.hxx

     private:
         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > implGetParentAccessible( ) const;
 		SvLBoxEntry* GetRealChild(sal_Int32 nIndex);
-	public:
-		sal_Int32 SAL_CALL getRoleType();
 	};
 
 //........................................................................

accessibility/source/extended/AccessibleBrowseBoxTableCell.cxx

 	{
         m_nOffset = ( OFFSET_DEFAULT == _nOffset ) ? (sal_Int32)BBINDEX_FIRSTCONTROL : _nOffset;
 		sal_Int32 nIndex = getIndex_Impl( _nRowPos, _nColPos, _rBrowseBox.GetColumnCount() );
-       setAccessibleName( _rBrowseBox.GetAccessibleObjectName( BBTYPE_TABLECELL, nIndex ) );
-       setAccessibleDescription( _rBrowseBox.GetAccessibleObjectDescription( BBTYPE_TABLECELL, nIndex ) );
+        setAccessibleName( _rBrowseBox.GetAccessibleObjectName( BBTYPE_TABLECELL, nIndex ) );
+        setAccessibleDescription( _rBrowseBox.GetAccessibleObjectDescription( BBTYPE_TABLECELL, nIndex ) );
         // Need to register as event listener
         Reference< XComponent > xComponent(_rxParent, UNO_QUERY);
         if( xComponent.is() )

accessibility/source/extended/accessiblelistbox.cxx

 		return m_xParent;
 	}
 	// -----------------------------------------------------------------------------
-	sal_Int32 SAL_CALL AccessibleListBox::getRoleType()
+    bool AccessibleListBox::shouldHaveListRole( SvTreeListBox const & i_treeListBox )
 	{
 		sal_Int32 nCase = 0;
-		SvLBoxEntry* pEntry = getListBox()->GetEntry(0);
+		SvLBoxEntry* pEntry = i_treeListBox.GetEntry(0);
 		if ( pEntry )
 		{
-			if( pEntry->HasChildsOnDemand() || getListBox()->GetChildCount(pEntry) > 0  )
-			{
-				nCase = 1;
-				return nCase;
-			}
+			if( pEntry->HasChildsOnDemand() || i_treeListBox.GetChildCount(pEntry) > 0  )
+                return false;
 		}
 
-		sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 
-		if( !(getListBox()->GetTreeFlags() & TREEFLAG_CHKBTN) )
-		{
-			if( bHasButtons )
-				nCase = 1;
-		}
-		else
-		{
-			if( bHasButtons )
-				nCase = 2;
-			 else
-				nCase = 3;
-		}
-		return nCase;
+		bool const bHasButtons = ( i_treeListBox.GetStyle() & WB_HASBUTTONS ) != 0; 
+        bool const bTreeHasCheckButtons = ( i_treeListBox.GetTreeFlags() & TREEFLAG_CHKBTN ) != 0;
+		if ( !bTreeHasCheckButtons && bHasButtons )
+            return false;
+
+        return true;
 	}
+	// -----------------------------------------------------------------------------
 	sal_Int16 SAL_CALL AccessibleListBox::getAccessibleRole(  ) throw (RuntimeException)
 	{
-		if(getListBox())
+		if ( getListBox() )
 		{
 			short const nType = getListBox()->GetAllEntriesAccessibleRoleType();			
             switch ( nType )
 		if(!bHasButtons && (getListBox()->GetTreeFlags() & TREEFLAG_CHKBTN))
 			return AccessibleRole::LIST;
 		else
-			if(getRoleType() == 0)
+			if ( shouldHaveListRole( *getListBox() ) )
 				return AccessibleRole::LIST;
 			else
 			    return AccessibleRole::TREE;

accessibility/source/extended/accessiblelistboxentry.cxx

 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_accessibility.hxx"
 #include "accessibility/extended/accessiblelistboxentry.hxx"
+#include "accessibility/extended/accessiblelistbox.hxx"
 #include <svtools/svtreebx.hxx>
 #include <accessibility/helper/accresmgr.hxx>
 #include <svtools/stringtransfer.hxx>
     	return m_aEntryPath.empty() ? -1 : m_aEntryPath.back();
 	}
 	// -----------------------------------------------------------------------------
-	sal_Int32 SAL_CALL AccessibleListBoxEntry::getRoleType() 
-	{
-		sal_Int32 nCase = 0;
-		SvLBoxEntry* pEntry = getListBox()->GetEntry(0);
-		if ( pEntry )
-		{
-			if( pEntry->HasChildsOnDemand() || getListBox()->GetChildCount(pEntry) > 0  )
-			{
-				nCase = 1;
-				return nCase;
-			}
-		}
-
-		sal_Bool bHasButtons = (getListBox()->GetStyle() & WB_HASBUTTONS)!=0; 
-		if( !(getListBox()->GetTreeFlags() & TREEFLAG_CHKBTN) )
-		{
-			if( bHasButtons )
-				nCase = 1;
-		}
-		else
-		{
-			if( bHasButtons )
-				nCase = 2;
-			 else
-				nCase = 3;
-		}
-		return nCase;
-	}
 	sal_Int16 SAL_CALL AccessibleListBoxEntry::getAccessibleRole(  ) throw (RuntimeException)
 	{
 		SvTreeListBox* pBox = getListBox();
 		}
 		else
 		{
-
-		if(getRoleType() == 0)
-			return AccessibleRole::LIST_ITEM;
-		else
-			return AccessibleRole::TREE_ITEM;
+            if ( AccessibleListBox::shouldHaveListRole( *getListBox() ) )
+			    return AccessibleRole::LIST_ITEM;
+		    else
+			    return AccessibleRole::TREE_ITEM;
 		}	
 	}
 	// -----------------------------------------------------------------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.