diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-10-05 16:53:41 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-10-05 16:55:15 +0200 |
commit | cc7556740640e1b3f8730b939e21eaa882abc031 (patch) | |
tree | de9bf6ea2f7dd37d3a069f7556dedcd4f1952818 /sc/source/ui/Accessibility/AccessibleDocument.cxx | |
parent | c30defcf8e34daec6ea0455d772fe296cc26ecc9 (diff) |
Return rtl::Reference from ShapeTypeHandler::CreateAccessibleObject
...and handle related fallout
Change-Id: Ie82d853a9bf28b359d5aab9d0af01b728d68ed70
Diffstat (limited to 'sc/source/ui/Accessibility/AccessibleDocument.cxx')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 4a199a984812..608fd6d71185 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -106,9 +106,9 @@ using ::std::for_each; struct ScAccessibleShapeData { - ScAccessibleShapeData() : pAccShape(NULL), pRelationCell(NULL), bSelected(false), bSelectable(true) {} + ScAccessibleShapeData() : pRelationCell(NULL), bSelected(false), bSelectable(true) {} ~ScAccessibleShapeData(); - mutable ::accessibility::AccessibleShape* pAccShape; + mutable rtl::Reference< ::accessibility::AccessibleShape > pAccShape; mutable ScAddress* pRelationCell; // if it is NULL this shape is anchored on the table com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape; mutable bool bSelected; @@ -117,10 +117,9 @@ struct ScAccessibleShapeData ScAccessibleShapeData::~ScAccessibleShapeData() { - if (pAccShape) + if (pAccShape.is()) { pAccShape->dispose(); - pAccShape->release(); } } @@ -217,7 +216,7 @@ struct DeselectShape if (pAccShapeData) { pAccShapeData->bSelected = false; - if (pAccShapeData->pAccShape) + if (pAccShapeData->pAccShape.is()) pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED); } } @@ -232,7 +231,7 @@ struct SelectShape if (pAccShapeData && pAccShapeData->bSelectable) { pAccShapeData->bSelected = true; - if (pAccShapeData->pAccShape) + if (pAccShapeData->pAccShape.is()) pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED); if (xShapes.is()) xShapes->add(pAccShapeData->xShape); @@ -455,23 +454,22 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC throw (uno::RuntimeException) { // create the new child - ::accessibility::AccessibleShape* pReplacement = ::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject ( + rtl::Reference< ::accessibility::AccessibleShape > pReplacement(::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject ( ::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ), _rShapeTreeInfo - ); - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pReplacement ); // keep this alive (do this before calling Init!) - if ( pReplacement ) + )); + if ( pReplacement.is() ) pReplacement->Init(); bool bResult(false); - if (pReplacement) + if (pReplacement.is()) { OSL_ENSURE(pCurrentChild->GetXShape().get() == pReplacement->GetXShape().get(), "XShape changes and should be inserted sorted"); SortedShapes::iterator aItr; if (FindShape(pCurrentChild->GetXShape(), aItr) || (aItr != maZOrderedShapes.end() && (*aItr))) { - if ((*aItr)->pAccShape) + if ((*aItr)->pAccShape.is()) { OSL_ENSURE((*aItr)->pAccShape == pCurrentChild, "wrong child found"); AccessibleEventObject aEvent; @@ -487,7 +485,7 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::CHILD; aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); - aEvent.NewValue <<= uno::makeAny(uno::Reference<XAccessible>(pReplacement)); + aEvent.NewValue <<= uno::makeAny(uno::Reference<XAccessible>(pReplacement.get())); mpAccessibleDocument->CommitChange(aEvent); // child is new - event bResult = true; @@ -504,10 +502,10 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC ScAccessibleShapeData* pShape = maZOrderedShapes[index]; if (pShape) { - ::accessibility::AccessibleShape* pAccShape = pShape->pAccShape; - if (pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == ::accessibility::DRAWING_CONTROL) + rtl::Reference< ::accessibility::AccessibleShape > pAccShape(pShape->pAccShape); + if (pAccShape.is() && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == ::accessibility::DRAWING_CONTROL) { - ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape); + ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape.get()); if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet) return pCtlAccShape; } @@ -526,7 +524,7 @@ ScChildrenShapes::GetAccessibleCaption (const ::com::sun::star::uno::Reference < ScAccessibleShapeData* pShape = maZOrderedShapes[index]; if (pShape && pShape->xShape == xShape ) { - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pShape->pAccShape ); + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pShape->pAccShape.get() ); if(xNewChild.get()) return xNewChild; } @@ -559,15 +557,14 @@ uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* if (!pData) return NULL; - if (!pData->pAccShape) + if (!pData->pAccShape.is()) { ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); ::accessibility::AccessibleShapeInfo aShapeInfo(pData->xShape, mpAccessibleDocument, const_cast<ScChildrenShapes*>(this)); pData->pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, maShapeTreeInfo); - if (pData->pAccShape) + if (pData->pAccShape.is()) { - pData->pAccShape->acquire(); pData->pAccShape->Init(); if (pData->bSelected) pData->pAccShape->SetState(AccessibleStateType::SELECTED); @@ -576,7 +573,7 @@ uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* pData->pAccShape->SetRelationSet(GetRelationSet(pData)); } } - return pData->pAccShape; + return pData->pAccShape.get(); } uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const @@ -602,16 +599,16 @@ uno::Reference< XAccessible > ScChildrenShapes::GetAt(const awt::Point& rPoint) ScAccessibleShapeData* pShape = maZOrderedShapes[i]; if (pShape) { - if (!pShape->pAccShape) + if (!pShape->pAccShape.is()) Get(pShape); - if (pShape->pAccShape) + if (pShape->pAccShape.is()) { Point aPoint(VCLPoint(rPoint)); aPoint -= VCLRectangle(pShape->pAccShape->getBounds()).TopLeft(); if (pShape->pAccShape->containsPoint(AWTPoint(aPoint))) { - xAccessible = pShape->pAccShape; + xAccessible = pShape->pAccShape.get(); bFound = true; } } @@ -718,7 +715,7 @@ void ScChildrenShapes::Select(sal_Int32 nIndex) { xSelectionSupplier->select(uno::makeAny(xShapes)); maZOrderedShapes[nIndex]->bSelected = true; - if (maZOrderedShapes[nIndex]->pAccShape) + if (maZOrderedShapes[nIndex]->pAccShape.is()) maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED); } catch (lang::IllegalArgumentException&) @@ -848,7 +845,7 @@ uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedC ++aItr; } if (bFound && *aItr) - xAccessible = (*aItr)->pAccShape; + xAccessible = (*aItr)->pAccShape.get(); } return xAccessible; @@ -876,7 +873,7 @@ void ScChildrenShapes::Deselect(sal_Int32 nChildIndex) } maZOrderedShapes[nChildIndex]->bSelected = false; - if (maZOrderedShapes[nChildIndex]->pAccShape) + if (maZOrderedShapes[nChildIndex]->pAccShape.is()) maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED); } } @@ -989,7 +986,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X if (!(*aDataItr)->bSelected) { (*aDataItr)->bSelected = true; - if ((*aDataItr)->pAccShape) + if ((*aDataItr)->pAccShape.is()) { (*aDataItr)->pAccShape->SetState(AccessibleStateType::SELECTED); (*aDataItr)->pAccShape->SetState(AccessibleStateType::FOCUSED); @@ -1010,7 +1007,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X if ((*aDataItr)->bSelected) { (*aDataItr)->bSelected = false; - if ((*aDataItr)->pAccShape) + if ((*aDataItr)->pAccShape.is()) { (*aDataItr)->pAccShape->ResetState(AccessibleStateType::SELECTED); (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED); @@ -1061,8 +1058,8 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X } } } - //if ((aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1)) - if ( bIsFocuseMarked && (aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1) && bWinFocus) + //if ((aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape.is() && (mnShapesSelected == 1)) + if ( bIsFocuseMarked && (aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape.is() && (mnShapesSelected == 1) && bWinFocus) { (*aFocusedItr)->pAccShape->SetState(AccessibleStateType::FOCUSED); } @@ -1132,7 +1129,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; } aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument); - uno::Reference< XAccessible > xChild( (*vi)->pAccShape); + uno::Reference< XAccessible > xChild( (*vi)->pAccShape.get()); aEvent.NewValue <<= xChild; mpAccessibleDocument->CommitChange(aEvent); } @@ -1143,7 +1140,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument); - uno::Reference< XAccessible > xChild( (*vi)->pAccShape); + uno::Reference< XAccessible > xChild( (*vi)->pAccShape.get()); aEvent.NewValue <<= xChild; mpAccessibleDocument->CommitChange(aEvent); } @@ -1233,7 +1230,7 @@ void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, if (pData->pRelationCell) delete pData->pRelationCell; pData->pRelationCell = pAddress; - if (pData->pAccShape) + if (pData->pAccShape.is()) pData->pAccShape->SetRelationSet(GetRelationSet(pData)); } else @@ -1386,7 +1383,7 @@ namespace ScVisAreaChanged(ScAccessibleDocument* pAccDoc) : mpAccDoc(pAccDoc) {} void operator() (const ScAccessibleShapeData* pAccShapeData) const { - if (pAccShapeData && pAccShapeData->pAccShape) + if (pAccShapeData && pAccShapeData->pAccShape.is()) { pAccShapeData->pAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpAccDoc); } |