diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 67 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx | 22 |
2 files changed, 40 insertions, 49 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); } diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index b5e16946d373..8816fd7fe70b 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -566,13 +566,12 @@ Size ScIAccessibleViewForwarder::LogicToPixel (const Size& rSize) const struct ScShapeChild { ScShapeChild() - : mpAccShape(NULL) - , mnRangeId(0) + : mnRangeId(0) { } ScShapeChild(const ScShapeChild& rOld); ~ScShapeChild(); - mutable ::accessibility::AccessibleShape* mpAccShape; + mutable rtl::Reference< ::accessibility::AccessibleShape > mpAccShape; com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape; sal_Int32 mnRangeId; }; @@ -582,17 +581,13 @@ ScShapeChild::ScShapeChild(const ScShapeChild& rOld) mpAccShape(rOld.mpAccShape), mxShape(rOld.mxShape), mnRangeId(rOld.mnRangeId) -{ - if (mpAccShape) - mpAccShape->acquire(); -} +{} ScShapeChild::~ScShapeChild() { - if (mpAccShape) + if (mpAccShape.is()) { mpAccShape->dispose(); - mpAccShape->release(); } } @@ -816,7 +811,7 @@ namespace ScVisAreaChanged(const ScIAccessibleViewForwarder* pViewForwarder) : mpViewForwarder(pViewForwarder) {} void operator() (const ScShapeChild& rAccShapeData) const { - if (rAccShapeData.mpAccShape) + if (rAccShapeData.mpAccShape.is()) { rAccShapeData.mpAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpViewForwarder); } @@ -1015,7 +1010,7 @@ uno::Reference<XAccessible> ScShapeChildren::GetBackgroundShapeAt(const awt::Poi ::accessibility::AccessibleShape* ScShapeChildren::GetAccShape(const ScShapeChild& rShape) const { - if (!rShape.mpAccShape) + if (!rShape.mpAccShape.is()) { ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); ::accessibility::AccessibleShapeInfo aShapeInfo(rShape.mxShape, mpAccDoc, const_cast<ScShapeChildren*>(this)); @@ -1028,14 +1023,13 @@ uno::Reference<XAccessible> ScShapeChildren::GetBackgroundShapeAt(const awt::Poi aShapeTreeInfo.SetWindow(mpViewShell->GetWindow()); aShapeTreeInfo.SetViewForwarder(&(maShapeRanges[rShape.mnRangeId].maViewForwarder)); rShape.mpAccShape = rShapeHandler.CreateAccessibleObject(aShapeInfo, aShapeTreeInfo); - if (rShape.mpAccShape) + if (rShape.mpAccShape.is()) { - rShape.mpAccShape->acquire(); rShape.mpAccShape->Init(); } } } - return rShape.mpAccShape; + return rShape.mpAccShape.get(); } ::accessibility::AccessibleShape* ScShapeChildren::GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const |