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 /svx | |
parent | c30defcf8e34daec6ea0455d772fe296cc26ecc9 (diff) |
Return rtl::Reference from ShapeTypeHandler::CreateAccessibleObject
...and handle related fallout
Change-Id: Ie82d853a9bf28b359d5aab9d0af01b728d68ed70
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/accessibility/ChildrenManagerImpl.cxx | 19 | ||||
-rw-r--r-- | svx/source/accessibility/GraphCtlAccessibleContext.cxx | 23 | ||||
-rw-r--r-- | svx/source/accessibility/ShapeTypeHandler.cxx | 6 | ||||
-rw-r--r-- | svx/source/inc/GraphCtlAccessibleContext.hxx | 2 |
4 files changed, 21 insertions, 29 deletions
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx index 151cb5af61a7..45b37c0f7ea7 100644 --- a/svx/source/accessibility/ChildrenManagerImpl.cxx +++ b/svx/source/accessibility/ChildrenManagerImpl.cxx @@ -168,16 +168,14 @@ uno::Reference<XAccessible> mnNewNameIndex++); // Create accessible object that corresponds to the descriptor's // shape. - AccessibleShape* pShape = + rtl::Reference<AccessibleShape> pShape( ShapeTypeHandler::Instance().CreateAccessibleObject ( aShapeInfo, - maShapeTreeInfo); + maShapeTreeInfo)); rChildDescriptor.mxAccessibleShape = uno::Reference<XAccessible> ( - static_cast<uno::XWeak*>(pShape), + static_cast<uno::XWeak*>(pShape.get()), uno::UNO_QUERY); - // Now that there is a reference to the new accessible shape we - // can safely call its Init() method. - if ( pShape != NULL ) + if ( pShape.is() ) { pShape->Init(); pShape->setIndexInParent(_nIndex); @@ -802,12 +800,11 @@ bool ChildrenManagerImpl::ReplaceChild ( { AccessibleShapeInfo aShapeInfo( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ); // create the new child - AccessibleShape* pNewChild = ShapeTypeHandler::Instance().CreateAccessibleObject ( + rtl::Reference<AccessibleShape> pNewChild(ShapeTypeHandler::Instance().CreateAccessibleObject ( aShapeInfo, _rShapeTreeInfo - ); - Reference< XAccessible > xNewChild( pNewChild ); // keep this alive (do this before calling Init!) - if ( pNewChild ) + )); + if ( pNewChild.is() ) pNewChild->Init(); bool bResult = false; @@ -831,7 +828,7 @@ bool ChildrenManagerImpl::ReplaceChild ( // Replace with replacement and send an event about existence // of the new child. - I->mxAccessibleShape = pNewChild; + I->mxAccessibleShape = pNewChild.get(); mrContext.CommitChange ( AccessibleEventId::CHILD, uno::makeAny (I->mxAccessibleShape), diff --git a/svx/source/accessibility/GraphCtlAccessibleContext.cxx b/svx/source/accessibility/GraphCtlAccessibleContext.cxx index 21193684901e..5667292e7ddf 100644 --- a/svx/source/accessibility/GraphCtlAccessibleContext.cxx +++ b/svx/source/accessibility/GraphCtlAccessibleContext.cxx @@ -145,7 +145,7 @@ Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessible( if( iter != mxShapes.end() ) { // if we already have one, return it - xAccessibleShape = (*iter).second; + xAccessibleShape = (*iter).second.get(); } else { @@ -154,14 +154,11 @@ Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessible( AccessibleShapeInfo aShapeInfo (xShape,mxParent); // Create accessible object that corresponds to the descriptor's shape. - AccessibleShape* pAcc = ShapeTypeHandler::Instance().CreateAccessibleObject( - aShapeInfo, maTreeInfo); - xAccessibleShape = pAcc; - if (pAcc != NULL) + rtl::Reference<AccessibleShape> pAcc(ShapeTypeHandler::Instance().CreateAccessibleObject( + aShapeInfo, maTreeInfo)); + xAccessibleShape = pAcc.get(); + if (pAcc.is()) { - pAcc->acquire(); - // Now that we acquired the new accessible shape we can - // safely call its Init() method. pAcc->Init (); } mxShapes[pObj] = pAcc; @@ -704,12 +701,10 @@ void SAL_CALL SvxGraphCtrlAccessibleContext::disposing() for (I=mxShapes.begin(); I!=mxShapes.end(); ++I) { - XAccessible* pAcc = (*I).second; - Reference< XComponent > xComp( pAcc, UNO_QUERY ); + rtl::Reference<XAccessible> pAcc((*I).second.get()); + Reference< XComponent > xComp( pAcc.get(), UNO_QUERY ); if( xComp.is() ) xComp->dispose(); - - (*I).second->release(); } mxShapes.clear(); @@ -782,9 +777,9 @@ void SvxGraphCtrlAccessibleContext::Notify( SfxBroadcaster& /*rBC*/, const SfxHi if( iter != mxShapes.end() ) { // if we already have one, return it - AccessibleShape* pShape = (*iter).second; + rtl::Reference<AccessibleShape> pShape((*iter).second); - if( NULL != pShape ) + if( pShape.is() ) pShape->CommitChange( AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any() ); } } diff --git a/svx/source/accessibility/ShapeTypeHandler.cxx b/svx/source/accessibility/ShapeTypeHandler.cxx index 6285a9978f70..57e8b3efb8b3 100644 --- a/svx/source/accessibility/ShapeTypeHandler.cxx +++ b/svx/source/accessibility/ShapeTypeHandler.cxx @@ -113,17 +113,17 @@ ShapeTypeId ShapeTypeHandler::GetTypeId (const uno::Reference<drawing::XShape>& given shape, then calls the descriptor's create function, and finally initializes the new object. */ -AccessibleShape* +rtl::Reference<AccessibleShape> ShapeTypeHandler::CreateAccessibleObject ( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo) const { ShapeTypeId nSlotId (GetSlotId (rShapeInfo.mxShape)); - AccessibleShape* pShape = + rtl::Reference<AccessibleShape> pShape( maShapeTypeDescriptorList[nSlotId].maCreateFunction ( rShapeInfo, rShapeTreeInfo, - maShapeTypeDescriptorList[nSlotId].mnShapeTypeId); + maShapeTypeDescriptorList[nSlotId].mnShapeTypeId)); return pShape; } diff --git a/svx/source/inc/GraphCtlAccessibleContext.hxx b/svx/source/inc/GraphCtlAccessibleContext.hxx index 60e19a946685..289b20d508e4 100644 --- a/svx/source/inc/GraphCtlAccessibleContext.hxx +++ b/svx/source/inc/GraphCtlAccessibleContext.hxx @@ -219,7 +219,7 @@ private: return p1 < p2; } }; - typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType; + typedef ::std::map< const SdrObject*, rtl::Reference<accessibility::AccessibleShape>, SdrObjectCompareLess > ShapesMapType; ShapesMapType mxShapes; VclPtr<GraphCtrl> mpControl; |