summaryrefslogtreecommitdiffstats
path: root/accessibility/source/extended/AccessibleGridControlTable.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/source/extended/AccessibleGridControlTable.cxx')
-rw-r--r--accessibility/source/extended/AccessibleGridControlTable.cxx116
1 files changed, 82 insertions, 34 deletions
diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx
index 8938ba83a122..3b8f0138267e 100644
--- a/accessibility/source/extended/AccessibleGridControlTable.cxx
+++ b/accessibility/source/extended/AccessibleGridControlTable.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <extended/AccessibleGridControlTable.hxx>
#include <extended/AccessibleGridControlTableCell.hxx>
@@ -41,34 +44,36 @@ namespace accessibility {
AccessibleGridControlTable::AccessibleGridControlTable(
const Reference< XAccessible >& rxParent,
IAccessibleTable& rTable) :
- AccessibleGridControlTableBase( rxParent, rTable, TCTYPE_TABLE )
+ AccessibleGridControlTableBase(rxParent, rTable, AccessibleTableControlObjType::TABLE)
{
}
// XAccessibleContext ---------------------------------------------------------
Reference< XAccessible > SAL_CALL
-AccessibleGridControlTable::getAccessibleChild( sal_Int32 nChildIndex )
+AccessibleGridControlTable::getAccessibleChild( sal_Int64 nChildIndex )
{
SolarMutexGuard aSolarGuard;
ensureIsAlive();
ensureIsValidIndex( nChildIndex );
- sal_Int32 nCount = getAccessibleChildCount();
+ sal_Int64 nCount = getAccessibleChildCount();
if(m_aCellVector.empty() || m_aCellVector.size() != static_cast<unsigned>(nCount))
{
+ assert(o3tl::make_unsigned(nCount) < m_aCellVector.max_size());
m_aCellVector.resize(nCount);
}
if(!m_aCellVector[nChildIndex].is())
{
- rtl::Reference<AccessibleGridControlTableCell> pCell = new AccessibleGridControlTableCell(this, m_aTable, nChildIndex/m_aTable.GetColumnCount(), nChildIndex%m_aTable.GetColumnCount());
- m_aCellVector[nChildIndex] = pCell;
+ m_aCellVector[nChildIndex].set(new AccessibleGridControlTableCell(this, m_aTable, nChildIndex/m_aTable.GetColumnCount(), nChildIndex%m_aTable.GetColumnCount()));
}
return m_aCellVector[nChildIndex];
}
-sal_Int32 SAL_CALL AccessibleGridControlTable::getAccessibleIndexInParent()
+sal_Int64 SAL_CALL AccessibleGridControlTable::getAccessibleIndexInParent()
{
+ SolarMutexGuard aSolarGuard;
+
ensureIsAlive();
if(m_aTable.HasRowHeader() && m_aTable.HasColHeader())
return 0;
@@ -181,18 +186,8 @@ Reference< XAccessible > SAL_CALL AccessibleGridControlTable::getAccessibleCellA
ensureIsAlive();
ensureIsValidAddress( nRow, nColumn );
- sal_Int32 nCount = getAccessibleChildCount();
- sal_Int32 nChildIndex = nRow*m_aTable.GetColumnCount() + nColumn;
- if(m_aCellVector.empty() || m_aCellVector.size() != static_cast<unsigned>(nCount))
- {
- m_aCellVector.resize(nCount);
- }
- if(!m_aCellVector[nChildIndex].is())
- {
- rtl::Reference<AccessibleGridControlTableCell> pCell = new AccessibleGridControlTableCell(this, m_aTable, nRow, nColumn);
- m_aCellVector[nChildIndex] = pCell;
- }
- return m_aCellVector[nChildIndex];
+ sal_Int64 nChildIndex = static_cast<sal_Int64>(nRow) * static_cast<sal_Int64>(m_aTable.GetColumnCount()) + nColumn;
+ return getAccessibleChild(nChildIndex);
}
sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleSelected(
@@ -205,7 +200,7 @@ sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleSelected(
//selection of single cells not possible, so if row is selected, the cell will be selected too
return isAccessibleRowSelected(nRow);
}
-void SAL_CALL AccessibleGridControlTable::selectAccessibleChild( sal_Int32 nChildIndex )
+void SAL_CALL AccessibleGridControlTable::selectAccessibleChild( sal_Int64 nChildIndex )
{
SolarMutexGuard aSolarGuard;
@@ -215,7 +210,7 @@ void SAL_CALL AccessibleGridControlTable::selectAccessibleChild( sal_Int32 nChil
sal_Int32 nRow = nChildIndex / nColumns;
m_aTable.SelectRow( nRow, true );
}
-sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleChildSelected( sal_Int32 nChildIndex )
+sal_Bool SAL_CALL AccessibleGridControlTable::isAccessibleChildSelected( sal_Int64 nChildIndex )
{
SolarMutexGuard aSolarGuard;
@@ -242,29 +237,35 @@ void SAL_CALL AccessibleGridControlTable::selectAllAccessibleChildren()
for(tools::Long i=0; i<m_aTable.GetRowCount(); i++)
selectedRowsRange[i]=i;
}
-sal_Int32 SAL_CALL AccessibleGridControlTable::getSelectedAccessibleChildCount()
+sal_Int64 SAL_CALL AccessibleGridControlTable::getSelectedAccessibleChildCount()
{
SolarMutexGuard aSolarGuard;
ensureIsAlive();
Sequence< sal_Int32 > selectedRows = getSelectedAccessibleRows();
sal_Int32 nColumns = m_aTable.GetColumnCount();
- return selectedRows.getLength()*nColumns;
+ return static_cast<sal_Int64>(selectedRows.getLength()) * static_cast<sal_Int64>(nColumns);
}
Reference< XAccessible > SAL_CALL
-AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
{
SolarMutexGuard aSolarGuard;
ensureIsAlive();
- if(isAccessibleChildSelected(nSelectedChildIndex))
- return getAccessibleChild(nSelectedChildIndex);
- else
- return nullptr;
+ if (nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount())
+ throw lang::IndexOutOfBoundsException("Invalid index into selection", *this);
+
+ const sal_Int32 nColCount = getAccessibleColumnCount();
+ assert(nColCount > 0 && "Column count non-positive, but child count > 0");
+ const sal_Int32 nIndexInSelectedRowsSequence = nSelectedChildIndex / nColCount;
+ const Sequence<sal_Int32> aSelectedRows = getSelectedAccessibleRows();
+ const sal_Int32 nRowIndex = aSelectedRows[nIndexInSelectedRowsSequence];
+ const sal_Int32 nColIndex = nSelectedChildIndex % nColCount;
+ return getAccessibleCellAt(nRowIndex, nColIndex);
}
//not implemented yet, because only row selection possible
void SAL_CALL AccessibleGridControlTable::deselectAccessibleChild(
- sal_Int32 )
+ sal_Int64 )
{
SolarMutexGuard aSolarGuard;
@@ -292,7 +293,50 @@ void SAL_CALL AccessibleGridControlTable::release() noexcept
OUString SAL_CALL AccessibleGridControlTable::getImplementationName()
{
- return "com.sun.star.accessibility.AccessibleGridControlTable";
+ return u"com.sun.star.accessibility.AccessibleGridControlTable"_ustr;
+}
+
+void AccessibleGridControlTable::dispose()
+{
+ for (rtl::Reference<AccessibleGridControlTableCell>& rxCell : m_aCellVector)
+ {
+ if (rxCell.is())
+ {
+ rxCell->dispose();
+ rxCell.clear();
+ }
+ }
+
+ AccessibleGridControlTableBase::dispose();
+}
+
+void AccessibleGridControlTable::commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue,
+ const css::uno::Any& rOldValue)
+{
+ if (nEventId == AccessibleEventId::TABLE_MODEL_CHANGED)
+ {
+ AccessibleTableModelChange aChange;
+ if (rNewValue >>= aChange)
+ {
+ assert(aChange.Type != AccessibleTableModelChangeType::COLUMNS_REMOVED);
+
+ if (aChange.Type == AccessibleTableModelChangeType::ROWS_REMOVED)
+ {
+ int nColCount = m_aTable.GetColumnCount();
+ // check valid index - entries are inserted lazily
+ size_t const nStart = nColCount * aChange.FirstRow;
+ size_t const nEnd = nColCount * aChange.LastRow;
+ if (nStart < m_aCellVector.size())
+ {
+ m_aCellVector.erase(
+ m_aCellVector.begin() + nStart,
+ m_aCellVector.begin() + std::min(m_aCellVector.size(), nEnd));
+ }
+ }
+ }
+ }
+
+ AccessibleGridControlBase::commitEvent(nEventId, rNewValue, rOldValue);
}
// internal virtual methods ---------------------------------------------------
@@ -301,7 +345,7 @@ tools::Rectangle AccessibleGridControlTable::implGetBoundingBox()
{
vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
DBG_ASSERT( pParent, "implGetBoundingBox - missing parent window" );
- tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ));
+ tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( *pParent ));
tools::Rectangle aTableRect( m_aTable.calcTableRect() );
tools::Long nX = aGridRect.Left() + aTableRect.Left();
tools::Long nY = aGridRect.Top() + aTableRect.Top();
@@ -311,15 +355,15 @@ tools::Rectangle AccessibleGridControlTable::implGetBoundingBox()
return aTable;
}
-tools::Rectangle AccessibleGridControlTable::implGetBoundingBoxOnScreen()
+AbsoluteScreenPixelRectangle AccessibleGridControlTable::implGetBoundingBoxOnScreen()
{
- tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( nullptr ));
+ tools::Rectangle aGridRect( m_aTable.GetWindowExtentsAbsolute());
tools::Rectangle aTableRect( m_aTable.calcTableRect() );
tools::Long nX = aGridRect.Left() + aTableRect.Left();
tools::Long nY = aGridRect.Top() + aTableRect.Top();
tools::Long nWidth = aGridRect.GetSize().Width()-aTableRect.Left();
tools::Long nHeight = aGridRect.GetSize().Height()-aTableRect.Top();
- tools::Rectangle aTable( Point( nX, nY ), Size( nWidth, nHeight ));
+ AbsoluteScreenPixelRectangle aTable( AbsoluteScreenPixelPoint( nX, nY ), AbsoluteScreenPixelSize( nWidth, nHeight ));
return aTable;
}
// internal helper methods ----------------------------------------------------
@@ -327,7 +371,11 @@ Reference< XAccessibleTable > AccessibleGridControlTable::implGetHeaderBar(
sal_Int32 nChildIndex )
{
Reference< XAccessible > xRet;
- Reference< XAccessibleContext > xContext( m_xParent, uno::UNO_QUERY );
+
+ if (!m_xParent.is())
+ return nullptr;
+
+ Reference<XAccessibleContext> xContext = m_xParent->getAccessibleContext();
if( xContext.is() )
{
try