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