Kaydet (Commit) 83ccdb02 authored tarafından Michael Stahl's avatar Michael Stahl

winaccessibility: use uno::Reference in AccEventListener

... and clear it in disposing().

Change-Id: I69cfe3cdcf6549a0471453960d1f935d9c3b7a0d
üst ef3f28d0
......@@ -40,7 +40,8 @@ class AccEventListener
{
protected:
//accessible owner's pointer
com::sun::star::accessibility::XAccessible* pAccessible;
com::sun::star::uno::Reference<
com::sun::star::accessibility::XAccessible> m_xAccessible;
//agent pointer for objects' manager
AccObjectManagerAgent* pAgent;
//disposed state indicator
......@@ -74,7 +75,7 @@ public:
//for visible data changed event
virtual void HandleVisibleDataChangedEvent();
//get the accessible role of pAccessible
// get the accessible role of m_xAccessible
virtual short GetRole();
//get the accessible parent's role
virtual short GetParentRole();
......
......@@ -91,7 +91,7 @@ void AccDescendantManagerEventListener::HandleChildChangedEvent(Any oldValue, An
if(xChild.is())
{
XAccessible* pAcc = xChild.get();
pAgent->InsertAccObj( pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
pAgent->InsertChildrenAccObj(pAcc);
pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
......@@ -149,7 +149,7 @@ void AccDescendantManagerEventListener::HandleSelectionChangedEvent(Any oldValue
}
if (!bSend)
{
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED, m_xAccessible.get());
}
}
......@@ -163,7 +163,7 @@ void AccDescendantManagerEventListener::HandleChildChangedNoFocusEvent(Any oldVa
{
XAccessible* pAcc = xChild.get();
pAgent->InsertAccObj(pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
pAgent->InsertChildrenAccObj(pAcc);
}
}
......@@ -188,7 +188,8 @@ bool AccDescendantManagerEventListener::NotifyChildEvent(short nWinEvent,const A
XAccessible* pAcc = xChild.get();
pAgent->NotifyAccEvent(nWinEvent, pAcc);
if (pAgent && pAgent->IsStateManageDescendant(pAccessible) && ( nWinEvent == UM_EVENT_SELECTION_CHANGED_REMOVE) )
if (pAgent && pAgent->IsStateManageDescendant(m_xAccessible.get())
&& (nWinEvent == UM_EVENT_SELECTION_CHANGED_REMOVE))
{
pAgent->DeleteAccObj( pAcc );
}
......@@ -203,7 +204,7 @@ void AccDescendantManagerEventListener::HandleSelectionChangedAddEvent(const Any
{
return ;
}
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_ADD,pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_ADD, m_xAccessible.get());
}
void AccDescendantManagerEventListener::HandleSelectionChangedRemoveEvent(const Any& /*oldValue*/, const Any &newValue)
......@@ -212,7 +213,7 @@ void AccDescendantManagerEventListener::HandleSelectionChangedRemoveEvent(const
{
return ;
}
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_REMOVE,pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_REMOVE, m_xAccessible.get());
}
void AccDescendantManagerEventListener::HandleSelectionChangedWithinEvent(const Any& /*oldValue*/, const Any &newValue)
......@@ -221,7 +222,7 @@ void AccDescendantManagerEventListener::HandleSelectionChangedWithinEvent(const
{
return ;
}
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_WITHIN,pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_WITHIN, m_xAccessible.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -80,7 +80,7 @@ void AccDialogEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
{
XAccessible* pAcc = xChild.get();
//add this child
pAgent->InsertAccObj( pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
//add all oldValue's existing children
pAgent->InsertChildrenAccObj(pAcc);
pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
......@@ -122,9 +122,9 @@ void AccDialogEventListener::SetComponentState(short state, bool enable)
case AccessibleStateType::VISIBLE:
// UNO !VISIBLE == MSAA INVISIBLE
if( enable )
pAgent->IncreaseState( pAccessible, AccessibleStateType::VISIBLE );
pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
else
pAgent->DecreaseState( pAccessible, AccessibleStateType::VISIBLE );
pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
break;
case AccessibleStateType::ACTIVE:
// Only frames should be active
......
......@@ -45,7 +45,7 @@ using namespace cppu;
AccEventListener::AccEventListener(com::sun::star::accessibility::XAccessible* pAcc,
AccObjectManagerAgent* Agent)
: pAccessible(pAcc)
: m_xAccessible(pAcc)
, pAgent(Agent)
, m_isDisposed(false)
{}
......@@ -85,9 +85,9 @@ throw (::com::sun::star::uno::RuntimeException)
*/
void AccEventListener::HandleNameChangedEvent(Any name)
{
if ( pAgent->IsTopWinAcc( pAccessible ) )
if (pAgent->IsTopWinAcc(m_xAccessible.get()))
{
XAccessible* pAccDoc = pAgent->GetAccDocByAccTopWin( pAccessible );
XAccessible* pAccDoc = pAgent->GetAccDocByAccTopWin(m_xAccessible.get());
if ( pAccDoc )
{
pAgent->UpdateAccName(pAccDoc);
......@@ -95,8 +95,8 @@ void AccEventListener::HandleNameChangedEvent(Any name)
}
}
pAgent->UpdateAccName(pAccessible, name);
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_NAMECHANGE, pAccessible);
pAgent->UpdateAccName(m_xAccessible.get(), name);
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_NAMECHANGE, m_xAccessible.get());
}
/**
......@@ -105,8 +105,8 @@ void AccEventListener::HandleNameChangedEvent(Any name)
*/
void AccEventListener::HandleDescriptionChangedEvent(Any desc)
{
pAgent->UpdateDescription(pAccessible, desc);
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_DESCRIPTIONCHANGE, pAccessible);
pAgent->UpdateDescription(m_xAccessible.get(), desc);
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_DESCRIPTIONCHANGE, m_xAccessible.get());
}
/**
......@@ -114,8 +114,8 @@ void AccEventListener::HandleDescriptionChangedEvent(Any desc)
*/
void AccEventListener::HandleBoundrectChangedEvent()
{
pAgent->UpdateLocation(pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_BOUNDRECT_CHANGED, pAccessible);
pAgent->UpdateLocation(m_xAccessible.get());
pAgent->NotifyAccEvent(UM_EVENT_BOUNDRECT_CHANGED, m_xAccessible.get());
}
/**
......@@ -123,8 +123,8 @@ void AccEventListener::HandleBoundrectChangedEvent()
*/
void AccEventListener::HandleVisibleDataChangedEvent()
{
pAgent->UpdateValue(pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_VISIBLE_DATA_CHANGED, pAccessible);
pAgent->UpdateValue(m_xAccessible.get());
pAgent->NotifyAccEvent(UM_EVENT_VISIBLE_DATA_CHANGED, m_xAccessible.get());
}
/**
......@@ -171,8 +171,8 @@ void AccEventListener::FireStateFocusedChange(bool enable)
{
if(enable)
{
pAgent->IncreaseState( pAccessible, AccessibleStateType::FOCUSED);
pAgent->NotifyAccEvent(UM_EVENT_STATE_FOCUSED, pAccessible);
pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSED);
pAgent->NotifyAccEvent(UM_EVENT_STATE_FOCUSED, m_xAccessible.get());
}
else
{
......@@ -203,7 +203,8 @@ void AccEventListener::FireStatePropertyChange(short /*state*/, bool set )
*/
short AccEventListener::GetRole()
{
Reference<com::sun::star::accessibility::XAccessibleContext> xContext(pAccessible->getAccessibleContext(),UNO_QUERY);
Reference<com::sun::star::accessibility::XAccessibleContext> const
xContext(m_xAccessible->getAccessibleContext());
if(xContext.is())
{
return xContext->getAccessibleRole();
......@@ -216,9 +217,9 @@ short AccEventListener::GetRole()
*/
short AccEventListener::GetParentRole()
{
if(pAccessible)
if (m_xAccessible.is())
{
return pAgent->GetParentRole(pAccessible);
return pAgent->GetParentRole(m_xAccessible.get());
}
return -1;
}
......@@ -231,35 +232,21 @@ void AccEventListener::RemoveMeFromBroadcaster()
{
if(m_isDisposed)
return;
//get accessible context
Reference< XAccessibleContext > pRContext;
XAccessibleContext* pContext =NULL;
if( pAccessible == NULL)
if (!m_xAccessible.is())
{
return;
}
pRContext = pAccessible->getAccessibleContext();
if( !pRContext.is() )
{
return;
}
//get broadcaster from accessible component
Reference<XAccessibleComponent> xComponent(pRContext,UNO_QUERY);
if(!xComponent.is())
{
return;
}
Reference<XAccessibleEventBroadcaster> broadcaster(xComponent,UNO_QUERY);
XAccessibleEventBroadcaster* pBroadcaster = broadcaster.get();
if (pBroadcaster != NULL)
Reference<XAccessibleEventBroadcaster> const xBroadcaster(
m_xAccessible->getAccessibleContext(), UNO_QUERY);
if (xBroadcaster.is())
{
//remove the lister from accessible object
pBroadcaster->removeAccessibleEventListener(this);
xBroadcaster->removeAccessibleEventListener(this);
m_isDisposed = true;
pAgent->NotifyDestroy(pAccessible);
pAgent->NotifyDestroy(m_xAccessible.get());
}
m_xAccessible.clear(); // release cyclic reference
}
catch(...)
{
......
......@@ -86,12 +86,13 @@ void AccFrameEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
{
XAccessible* pAcc = xChild.get();
VCLXWindow* pvclwindow = (VCLXWindow*)pAccessible;
VCLXWindow* pvclwindow =
dynamic_cast<VCLXWindow*>(m_xAccessible.get());
Window* window = pvclwindow->GetWindow();
const SystemEnvData* systemdata=window->GetSystemData();
//add this child
pAgent->InsertAccObj(pAcc, pAccessible,
pAgent->InsertAccObj(pAcc, m_xAccessible.get(),
reinterpret_cast<sal_Int64>(systemdata->hWnd));
//add all oldValue's existing children
pAgent->InsertChildrenAccObj(pAcc);
......@@ -134,9 +135,9 @@ void AccFrameEventListener::SetComponentState(short state, bool enable )
case AccessibleStateType::VISIBLE:
// UNO !VISIBLE == MSAA INVISIBLE
if( enable )
pAgent->IncreaseState( pAccessible, AccessibleStateType::VISIBLE );
pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
else
pAgent->DecreaseState( pAccessible, AccessibleStateType::VISIBLE );
pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
break;
case AccessibleStateType::ACTIVE:
// Only frames should be active
......
......@@ -85,7 +85,7 @@ void AccListEventListener::HandleActiveDescendantChangedEvent(Any oldValue, Any
XAccessible* pAcc = xChild.get();
// Valueset has cache the child item xacc,Update state if no insert obj
sal_Bool bHasCache = pAgent->InsertAccObj(pAcc,pAccessible);
bool bHasCache = pAgent->InsertAccObj(pAcc, m_xAccessible.get());
if (!bHasCache)
{
pAgent->UpdateState(pAcc);
......@@ -117,7 +117,8 @@ void AccListEventListener::HandleValueChangedEvent(Any oldValue, Any newValue)
//to enable value changed event
if (GetParentRole() == AccessibleRole::COMBO_BOX)
{
XAccessible* pParentAcc = pAgent->GetParentXAccessible(pAccessible);
XAccessible* pParentAcc =
pAgent->GetParentXAccessible(m_xAccessible.get());
pAgent->UpdateValue(pParentAcc);
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_VALUECHANGE, pParentAcc);
}
......
......@@ -79,7 +79,7 @@ void AccMenuEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
{
XAccessible* pAcc = xChild.get();
//add this child
pAgent->InsertAccObj( pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
//add all oldValue's existing children
pAgent->InsertChildrenAccObj(pAcc);
pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
......@@ -110,7 +110,7 @@ void AccMenuEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
*/
void AccMenuEventListener::HandleSelectionChangedEventNoArgs()
{
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED, m_xAccessible.get());
}
/**
......@@ -125,9 +125,8 @@ void AccMenuEventListener::FireStatePropertyChange(short state, bool set)
{
//for sub menu is popup, there is a menu selected event.
case AccessibleStateType::SELECTED:
pAgent->IncreaseState( pAccessible, state);
pAgent->UpdateChildState(pAccessible);
pAgent->IncreaseState(m_xAccessible.get(), state);
pAgent->UpdateChildState(m_xAccessible.get());
break;
default:
AccComponentEventListener::FireStatePropertyChange(state, set);
......@@ -140,7 +139,7 @@ void AccMenuEventListener::FireStatePropertyChange(short state, bool set)
{
//for sub menu is popup, there is a menu selected event.
case AccessibleStateType::SELECTED:
pAgent->DecreaseState( pAccessible, state );
pAgent->DecreaseState(m_xAccessible.get(), state);
break;
default:
......
......@@ -53,9 +53,8 @@ void AccObjectContainerEventListener::HandleStateChangedEvent(Any oldValue, Any
{
if (newV == AccessibleStateType::FOCUSED)
{
pAgent->UpdateAccName(pAccessible);
pAgent->UpdateDescription(pAccessible);
pAgent->UpdateAccName(m_xAccessible.get());
pAgent->UpdateDescription(m_xAccessible.get());
}
}
AccContainerEventListener::HandleStateChangedEvent(oldValue, newValue);
......
......@@ -65,12 +65,12 @@ throw (::com::sun::star::uno::RuntimeException)
short State;
if( (aEvent.NewValue >>= State) && (State == AccessibleStateType::SELECTED) )
{
pAgent->IncreaseState( pAccessible, State);
pAgent->IncreaseState(m_xAccessible.get(), State);
break;
}
else if( (aEvent.OldValue >>= State) && (State == AccessibleStateType::SELECTED) )
{
pAgent->DecreaseState( pAccessible, State);
pAgent->DecreaseState(m_xAccessible.get(), State);
break;
}
......@@ -95,8 +95,8 @@ throw (::com::sun::star::uno::RuntimeException)
*/
void AccParagraphEventListener::HandleCaretChangedEvent(Any oldValue, Any newValue)
{
pAgent->UpdateLocation(pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_CARETCHANGE, pAccessible);
pAgent->UpdateLocation(m_xAccessible.get());
pAgent->NotifyAccEvent(UM_EVENT_OBJECT_CARETCHANGE, m_xAccessible.get());
}
/**
......@@ -126,7 +126,7 @@ void AccParagraphEventListener::SetComponentState(short state, bool enable )
void AccParagraphEventListener::HandleTextSelectionChangedEvent()
{
pAgent->NotifyAccEvent(UM_EVENT_TEXT_SELECTION_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TEXT_SELECTION_CHANGED, m_xAccessible.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -58,25 +58,25 @@ throw (::com::sun::star::uno::RuntimeException)
case AccessibleEventId::TABLE_CAPTION_CHANGED:
{
pAgent->NotifyAccEvent(UM_EVENT_TABLE_CAPTION_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_CAPTION_CHANGED, m_xAccessible.get());
break;
}
case AccessibleEventId::TABLE_COLUMN_DESCRIPTION_CHANGED:
{
pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED, m_xAccessible.get());
break;
}
case AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED:
{
pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_HEADER_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_HEADER_CHANGED, m_xAccessible.get());
break;
}
case AccessibleEventId::TABLE_ROW_HEADER_CHANGED:
{
pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_HEADER_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_HEADER_CHANGED, m_xAccessible.get());
break;
}
case AccessibleEventId::TABLE_MODEL_CHANGED:
......@@ -88,13 +88,13 @@ throw (::com::sun::star::uno::RuntimeException)
case AccessibleEventId::TABLE_SUMMARY_CHANGED:
{
pAgent->NotifyAccEvent(UM_EVENT_TABLE_SUMMARY_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_SUMMARY_CHANGED, m_xAccessible.get());
break;
}
case AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED:
{
pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_DESCRIPTION_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_DESCRIPTION_CHANGED, m_xAccessible.get());
break;
}
default:
......@@ -116,7 +116,7 @@ void AccTableEventListener::HandleActiveDescendantChangedEvent(Any oldValue, Any
if(xChild.is())
{
XAccessible* pAcc = xChild.get();
pAgent->InsertAccObj(pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
pAgent->NotifyAccEvent(UM_EVENT_ACTIVE_DESCENDANT_CHANGED, pAcc);
}
}
......@@ -136,14 +136,14 @@ void AccTableEventListener::HandleTableModelChangeEvent(Any newValue)
AccessibleTableModelChange aModelChange;
if (newValue >>= aModelChange)
{
if( pAccessible )
if (m_xAccessible.is())
{
//delete all oldValue's existing children
pAgent->DeleteChildrenAccObj( pAccessible );
pAgent->DeleteChildrenAccObj(m_xAccessible.get());
//add all oldValue's existing children
pAgent->InsertChildrenAccObj( pAccessible );
pAgent->InsertChildrenAccObj(m_xAccessible.get());
}
pAgent->NotifyAccEvent(UM_EVENT_TABLE_MODEL_CHANGED, pAccessible);
pAgent->NotifyAccEvent(UM_EVENT_TABLE_MODEL_CHANGED, m_xAccessible.get());
}
}
......
......@@ -71,7 +71,7 @@ void AccTreeEventListener::HandleActiveDescendantChangedEvent(Any oldValue, Any
if(xChild.is())
{
XAccessible* pAcc = xChild.get();
pAgent->InsertAccObj(pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
pAgent->NotifyAccEvent(UM_EVENT_ACTIVE_DESCENDANT_CHANGED, pAcc);
}
}
......
......@@ -79,7 +79,7 @@ void AccWindowEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
{
XAccessible* pAcc = xChild.get();
//add this child
pAgent->InsertAccObj( pAcc,pAccessible);
pAgent->InsertAccObj(pAcc, m_xAccessible.get());
//add all oldValue's existing children
pAgent->InsertChildrenAccObj(pAcc);
pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
......@@ -119,18 +119,18 @@ void AccWindowEventListener::SetComponentState(short state, bool enable )
case AccessibleStateType::VISIBLE:
// UNO !VISIBLE == MSAA INVISIBLE
if( enable )
pAgent->IncreaseState( pAccessible, AccessibleStateType::VISIBLE );
pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
else
pAgent->DecreaseState( pAccessible, AccessibleStateType::VISIBLE );
pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
break;
case AccessibleStateType::SHOWING:
// UNO !SHOWING == MSAA OFFSCREEN
if( enable )
{
pAgent->IncreaseState( pAccessible, AccessibleStateType::SHOWING );
pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::SHOWING);
}
else
pAgent->DecreaseState( pAccessible, AccessibleStateType::SHOWING );
pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::SHOWING);
break;
default:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment