use rtl::Reference in AccessibleGridControlAccess
instead of storing both raw pointers and uno::Reference Change-Id: Ie2306b619bec81707c5cff4debb8c7462ac2f9a1
This commit is contained in:
parent
be0089b58b
commit
eede420e30
@ -164,14 +164,9 @@ class AccessibleGridControlAccess :
|
||||
,public ::svt::table::IAccessibleTableControl
|
||||
{
|
||||
private:
|
||||
css::uno::Reference< css::accessibility::XAccessible >
|
||||
m_xParent;
|
||||
::svt::table::IAccessibleTable * m_pTable;
|
||||
|
||||
css::uno::Reference< css::accessibility::XAccessibleContext >
|
||||
m_xContext;
|
||||
AccessibleGridControl* m_pContext;
|
||||
// note that this pointer is valid as long as m_xContext is valid!
|
||||
css::uno::Reference< css::accessibility::XAccessible > m_xParent;
|
||||
::svt::table::IAccessibleTable * m_pTable;
|
||||
rtl::Reference<AccessibleGridControl> m_xContext;
|
||||
|
||||
public:
|
||||
AccessibleGridControlAccess(
|
||||
@ -180,7 +175,7 @@ public:
|
||||
);
|
||||
|
||||
/// returns the AccessibleContext belonging to this Accessible
|
||||
inline AccessibleGridControl* getContext() { return m_pContext; }
|
||||
inline AccessibleGridControl* getContext() { return m_xContext.get(); }
|
||||
|
||||
protected:
|
||||
virtual ~AccessibleGridControlAccess() override;
|
||||
@ -198,7 +193,7 @@ protected:
|
||||
void DisposeAccessImpl() override;
|
||||
virtual bool isAlive() const override
|
||||
{
|
||||
return m_pContext && m_pContext->isAlive();
|
||||
return m_xContext.is() && m_xContext->isAlive();
|
||||
}
|
||||
virtual void commitCellEvent( sal_Int16 nEventId,
|
||||
const css::uno::Any& rNewValue, const css::uno::Any& rOldValue ) override
|
||||
|
@ -47,20 +47,16 @@ public:
|
||||
css::uno::WeakReference< css::accessibility::XAccessible > m_aCreator;
|
||||
|
||||
/** The data table child. */
|
||||
css::uno::Reference< css::accessibility::XAccessible > m_xTable;
|
||||
AccessibleGridControlTable* m_pTable;
|
||||
rtl::Reference<AccessibleGridControlTable> m_xTable;
|
||||
|
||||
/** The header bar for rows. */
|
||||
css::uno::Reference< css::accessibility::XAccessible > m_xRowHeaderBar;
|
||||
AccessibleGridControlHeader* m_pRowHeaderBar;
|
||||
rtl::Reference<AccessibleGridControlHeader> m_xRowHeaderBar;
|
||||
|
||||
/** The header bar for columns (first row of the table). */
|
||||
css::uno::Reference< css::accessibility::XAccessible > m_xColumnHeaderBar;
|
||||
AccessibleGridControlHeader* m_pColumnHeaderBar;
|
||||
rtl::Reference<AccessibleGridControlHeader> m_xColumnHeaderBar;
|
||||
|
||||
/** The table cell child. */
|
||||
css::uno::Reference< css::accessibility::XAccessible > m_xCell;
|
||||
AccessibleGridControlTableCell* m_pCell;
|
||||
rtl::Reference<AccessibleGridControlTableCell> m_xCell;
|
||||
|
||||
};
|
||||
|
||||
@ -83,29 +79,28 @@ void SAL_CALL AccessibleGridControl::disposing()
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
m_xImpl->m_pTable = nullptr;
|
||||
m_xImpl->m_pColumnHeaderBar = nullptr;
|
||||
m_xImpl->m_pRowHeaderBar = nullptr;
|
||||
m_xImpl->m_pCell = nullptr;
|
||||
m_xImpl->m_aCreator.clear();
|
||||
|
||||
css::uno::Reference< css::accessibility::XAccessible > xTable = m_xImpl->m_xTable;
|
||||
|
||||
css::uno::Reference< XComponent > xComp( m_xImpl->m_xTable, UNO_QUERY );
|
||||
if ( xComp.is() )
|
||||
if ( m_xImpl->m_xTable.is() )
|
||||
{
|
||||
xComp->dispose();
|
||||
m_xImpl->m_xTable->dispose();
|
||||
m_xImpl->m_xTable.clear();
|
||||
}
|
||||
css::uno::Reference< css::accessibility::XAccessible > xCell = m_xImpl->m_xCell;
|
||||
|
||||
css::uno::Reference< XComponent > xCellComp( m_xImpl->m_xCell, UNO_QUERY );
|
||||
if ( xCellComp.is() )
|
||||
if ( m_xImpl->m_xCell.is() )
|
||||
{
|
||||
xCellComp->dispose();
|
||||
m_xImpl->m_xCell->dispose();
|
||||
m_xImpl->m_xCell.clear();
|
||||
}
|
||||
if ( m_xImpl->m_xRowHeaderBar.is() )
|
||||
{
|
||||
m_xImpl->m_xRowHeaderBar->dispose();
|
||||
m_xImpl->m_xRowHeaderBar.clear();
|
||||
}
|
||||
if ( m_xImpl->m_xColumnHeaderBar.is() )
|
||||
{
|
||||
m_xImpl->m_xColumnHeaderBar->dispose();
|
||||
m_xImpl->m_xColumnHeaderBar.clear();
|
||||
}
|
||||
|
||||
::comphelper::disposeComponent(m_xImpl->m_xRowHeaderBar);
|
||||
::comphelper::disposeComponent(m_xImpl->m_xColumnHeaderBar);
|
||||
AccessibleGridControlBase::disposing();
|
||||
}
|
||||
|
||||
@ -137,29 +132,25 @@ AccessibleGridControl::getAccessibleChild( sal_Int32 nChildIndex )
|
||||
{
|
||||
if(!m_xImpl->m_xColumnHeaderBar.is())
|
||||
{
|
||||
AccessibleGridControlHeader* pColHeaderBar = new AccessibleGridControlHeader(m_xImpl->m_aCreator, m_aTable, svt::table::TCTYPE_COLUMNHEADERBAR);
|
||||
m_xImpl->m_xColumnHeaderBar = pColHeaderBar;
|
||||
m_xImpl->m_xColumnHeaderBar = new AccessibleGridControlHeader(m_xImpl->m_aCreator, m_aTable, svt::table::TCTYPE_COLUMNHEADERBAR);
|
||||
}
|
||||
xChild = m_xImpl->m_xColumnHeaderBar;
|
||||
xChild = m_xImpl->m_xColumnHeaderBar.get();
|
||||
}
|
||||
else if(m_aTable.HasRowHeader() && (nChildIndex == 1 || nChildIndex == 0))
|
||||
{
|
||||
if(!m_xImpl->m_xRowHeaderBar.is())
|
||||
{
|
||||
AccessibleGridControlHeader* pRowHeaderBar = new AccessibleGridControlHeader(m_xImpl->m_aCreator, m_aTable, svt::table::TCTYPE_ROWHEADERBAR);
|
||||
m_xImpl->m_xRowHeaderBar = pRowHeaderBar;
|
||||
m_xImpl->m_xRowHeaderBar = new AccessibleGridControlHeader(m_xImpl->m_aCreator, m_aTable, svt::table::TCTYPE_ROWHEADERBAR);
|
||||
}
|
||||
xChild = m_xImpl->m_xRowHeaderBar;
|
||||
xChild = m_xImpl->m_xRowHeaderBar.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!m_xImpl->m_xTable.is())
|
||||
{
|
||||
AccessibleGridControlTable* pTable = new AccessibleGridControlTable(m_xImpl->m_aCreator, m_aTable);
|
||||
m_xImpl->m_xTable = pTable;
|
||||
m_xImpl->m_pTable = pTable;
|
||||
m_xImpl->m_xTable = new AccessibleGridControlTable(m_xImpl->m_aCreator, m_aTable);
|
||||
}
|
||||
xChild = m_xImpl->m_xTable;
|
||||
xChild = m_xImpl->m_xTable.get();
|
||||
}
|
||||
}
|
||||
return xChild;
|
||||
@ -246,10 +237,9 @@ css::uno::Reference< css::accessibility::XAccessible > AccessibleGridControl::im
|
||||
{
|
||||
if( !m_xImpl->m_xTable.is() )
|
||||
{
|
||||
m_xImpl->m_pTable = createAccessibleTable();
|
||||
m_xImpl->m_xTable = m_xImpl->m_pTable;
|
||||
m_xImpl->m_xTable = createAccessibleTable();
|
||||
}
|
||||
return m_xImpl->m_xTable;
|
||||
return m_xImpl->m_xTable.get();
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +247,7 @@ css::uno::Reference< css::accessibility::XAccessible >
|
||||
AccessibleGridControl::implGetHeaderBar( AccessibleTableControlObjType eObjType )
|
||||
{
|
||||
css::uno::Reference< css::accessibility::XAccessible > xRet;
|
||||
css::uno::Reference< css::accessibility::XAccessible >* pxMember = nullptr;
|
||||
rtl::Reference< AccessibleGridControlHeader >* pxMember = nullptr;
|
||||
|
||||
if( eObjType == TCTYPE_ROWHEADERBAR )
|
||||
pxMember = &m_xImpl->m_xRowHeaderBar;
|
||||
@ -268,17 +258,10 @@ AccessibleGridControl::implGetHeaderBar( AccessibleTableControlObjType eObjType
|
||||
{
|
||||
if( !pxMember->is() )
|
||||
{
|
||||
AccessibleGridControlHeader* pHeaderBar = new AccessibleGridControlHeader(
|
||||
*pxMember = new AccessibleGridControlHeader(
|
||||
m_xImpl->m_aCreator, m_aTable, eObjType );
|
||||
|
||||
if ( TCTYPE_COLUMNHEADERBAR == eObjType)
|
||||
m_xImpl->m_pColumnHeaderBar = pHeaderBar;
|
||||
else
|
||||
m_xImpl->m_pRowHeaderBar = pHeaderBar;
|
||||
|
||||
*pxMember = pHeaderBar;
|
||||
}
|
||||
xRet = *pxMember;
|
||||
xRet = pxMember->get();
|
||||
}
|
||||
return xRet;
|
||||
}
|
||||
@ -318,16 +301,16 @@ void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNew
|
||||
{
|
||||
css::uno::Reference< css::accessibility::XAccessible > xAccessible = getAccessibleChild(i);
|
||||
css::uno::Reference< css::accessibility::XAccessibleContext > xAccessibleChild = xAccessible->getAccessibleContext();
|
||||
if(m_xImpl->m_xTable == xAccessible)
|
||||
if(css::uno::Reference< css::accessibility::XAccessible >(m_xImpl->m_xTable.get()) == xAccessible)
|
||||
{
|
||||
std::vector< AccessibleGridControlTableCell* >& rCells =
|
||||
m_xImpl->m_pTable->getCellVector();
|
||||
m_xImpl->m_xTable->getCellVector();
|
||||
size_t nIndex = m_aTable.GetCurrentRow() * m_aTable.GetColumnCount()
|
||||
+ m_aTable.GetCurrentColumn();
|
||||
if (nIndex < rCells.size() && rCells[nIndex])
|
||||
{
|
||||
m_xImpl->m_pCell = rCells[nIndex];
|
||||
m_xImpl->m_pCell->commitEvent( _nEventId, _rNewValue, _rOldValue );
|
||||
m_xImpl->m_xCell = rCells[nIndex];
|
||||
m_xImpl->m_xCell->commitEvent( _nEventId, _rNewValue, _rOldValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,7 +318,7 @@ void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNew
|
||||
else
|
||||
{
|
||||
if ( m_xImpl->m_xTable.is() )
|
||||
m_xImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
m_xImpl->m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,9 +334,9 @@ void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNe
|
||||
if (nCurrentRow > -1 && nCurrentCol > -1)
|
||||
{
|
||||
sal_Int32 nColumnCount = m_aTable.GetColumnCount();
|
||||
xChild = m_xImpl->m_pTable->getAccessibleChild(nCurrentRow * nColumnCount + nCurrentCol);
|
||||
xChild = m_xImpl->m_xTable->getAccessibleChild(nCurrentRow * nColumnCount + nCurrentCol);
|
||||
}
|
||||
m_xImpl->m_pTable->commitEvent(_nEventId, makeAny(xChild),_rOldValue);
|
||||
m_xImpl->m_xTable->commitEvent(_nEventId, makeAny(xChild),_rOldValue);
|
||||
}
|
||||
else if(_nEventId == AccessibleEventId::TABLE_MODEL_CHANGED)
|
||||
{
|
||||
@ -363,33 +346,33 @@ void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNe
|
||||
if(aChange.Type == AccessibleTableModelChangeType::DELETE)
|
||||
{
|
||||
std::vector< AccessibleGridControlTableCell* >& rCells =
|
||||
m_xImpl->m_pTable->getCellVector();
|
||||
m_xImpl->m_xTable->getCellVector();
|
||||
std::vector< css::uno::Reference< css::accessibility::XAccessible > >& rAccCells =
|
||||
m_xImpl->m_pTable->getAccessibleCellVector();
|
||||
m_xImpl->m_xTable->getAccessibleCellVector();
|
||||
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 < rCells.size())
|
||||
{
|
||||
m_xImpl->m_pTable->getCellVector().erase(
|
||||
m_xImpl->m_xTable->getCellVector().erase(
|
||||
rCells.begin() + nStart,
|
||||
rCells.begin() + std::min(rCells.size(), nEnd));
|
||||
}
|
||||
if (nStart < rAccCells.size())
|
||||
{
|
||||
m_xImpl->m_pTable->getAccessibleCellVector().erase(
|
||||
m_xImpl->m_xTable->getAccessibleCellVector().erase(
|
||||
rAccCells.begin() + nStart,
|
||||
rAccCells.begin() + std::min(rAccCells.size(), nEnd));
|
||||
}
|
||||
m_xImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
m_xImpl->m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
}
|
||||
else
|
||||
m_xImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
m_xImpl->m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_xImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
m_xImpl->m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,7 +383,6 @@ AccessibleGridControlAccess::AccessibleGridControlAccess(
|
||||
const css::uno::Reference< css::accessibility::XAccessible >& rxParent, ::svt::table::IAccessibleTable& rTable )
|
||||
: m_xParent( rxParent )
|
||||
, m_pTable( & rTable )
|
||||
, m_pContext( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
@ -415,8 +397,11 @@ void AccessibleGridControlAccess::DisposeAccessImpl()
|
||||
SolarMutexGuard g;
|
||||
|
||||
m_pTable = nullptr;
|
||||
m_pContext = nullptr;
|
||||
::comphelper::disposeComponent( m_xContext );
|
||||
if (m_xContext.is())
|
||||
{
|
||||
m_xContext->dispose();
|
||||
m_xContext.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -424,19 +409,15 @@ css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL Accessibl
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
OSL_ENSURE( ( m_pContext && m_xContext.is() ) || ( !m_pContext && !m_xContext.is() ),
|
||||
"extended/AccessibleGridControlAccess::getAccessibleContext: inconsistency!" );
|
||||
|
||||
// if the context died meanwhile (we're no listener, so it won't tell us explicitly when this happens),
|
||||
// then reset an re-create.
|
||||
if ( m_pContext && !m_pContext->isAlive() )
|
||||
m_xContext = m_pContext = nullptr;
|
||||
if ( m_xContext.is() && !m_xContext->isAlive() )
|
||||
m_xContext = nullptr;
|
||||
|
||||
if (!m_xContext.is() && m_pTable)
|
||||
m_xContext = m_pContext =
|
||||
new AccessibleGridControl(m_xParent, this, *m_pTable);
|
||||
m_xContext = new AccessibleGridControl(m_xParent, this, *m_pTable);
|
||||
|
||||
return m_xContext;
|
||||
return m_xContext.get();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user