Kaydet (Commit) cc755674 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Return rtl::Reference from ShapeTypeHandler::CreateAccessibleObject

...and handle related fallout

Change-Id: Ie82d853a9bf28b359d5aab9d0af01b728d68ed70
üst c30defcf
......@@ -39,7 +39,6 @@ AccessibleChartShape::AccessibleChartShape(
const AccessibleElementInfo& rAccInfo,
bool bMayHaveChildren, bool bAlwaysTransparent )
:impl::AccessibleChartShape_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent )
,m_pAccShape( NULL )
{
if ( rAccInfo.m_aOID.isAdditionalShape() )
{
......@@ -63,9 +62,8 @@ AccessibleChartShape::AccessibleChartShape(
::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo );
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
m_pAccShape->acquire();
m_pAccShape->Init();
}
}
......@@ -75,10 +73,9 @@ AccessibleChartShape::~AccessibleChartShape()
{
OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
m_pAccShape->dispose();
m_pAccShape->release();
}
}
......@@ -94,7 +91,7 @@ sal_Int32 AccessibleChartShape::getAccessibleChildCount()
throw (RuntimeException, std::exception)
{
sal_Int32 nCount(0);
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
nCount = m_pAccShape->getAccessibleChildCount();
}
......@@ -105,7 +102,7 @@ Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i )
throw (lang::IndexOutOfBoundsException, RuntimeException, std::exception)
{
Reference< XAccessible > xChild;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
xChild = m_pAccShape->getAccessibleChild( i );
}
......@@ -116,7 +113,7 @@ sal_Int16 AccessibleChartShape::getAccessibleRole()
throw (RuntimeException, std::exception)
{
sal_Int16 nRole(0);
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
nRole = m_pAccShape->getAccessibleRole();
}
......@@ -127,7 +124,7 @@ OUString AccessibleChartShape::getAccessibleDescription()
throw (::com::sun::star::uno::RuntimeException, std::exception)
{
OUString aDescription;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aDescription = m_pAccShape->getAccessibleDescription();
}
......@@ -138,7 +135,7 @@ OUString AccessibleChartShape::getAccessibleName()
throw (::com::sun::star::uno::RuntimeException, std::exception)
{
OUString aName;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aName = m_pAccShape->getAccessibleName();
}
......@@ -150,7 +147,7 @@ sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint )
throw (uno::RuntimeException, std::exception)
{
bool bReturn = false;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
bReturn = m_pAccShape->containsPoint( aPoint );
}
......@@ -161,7 +158,7 @@ Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::
throw (uno::RuntimeException, std::exception)
{
Reference< XAccessible > xResult;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) );
}
......@@ -172,7 +169,7 @@ awt::Rectangle AccessibleChartShape::getBounds()
throw (uno::RuntimeException, std::exception)
{
awt::Rectangle aBounds;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aBounds = m_pAccShape->getBounds();
}
......@@ -183,7 +180,7 @@ awt::Point AccessibleChartShape::getLocation()
throw (uno::RuntimeException, std::exception)
{
awt::Point aLocation;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aLocation = m_pAccShape->getLocation();
}
......@@ -194,7 +191,7 @@ awt::Point AccessibleChartShape::getLocationOnScreen()
throw (uno::RuntimeException, std::exception)
{
awt::Point aLocation;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aLocation = m_pAccShape->getLocationOnScreen();
}
......@@ -205,7 +202,7 @@ awt::Size AccessibleChartShape::getSize()
throw (uno::RuntimeException, std::exception)
{
awt::Size aSize;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aSize = m_pAccShape->getSize();
}
......@@ -222,7 +219,7 @@ sal_Int32 AccessibleChartShape::getForeground()
throw (uno::RuntimeException, std::exception)
{
sal_Int32 nColor(0);
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
nColor = m_pAccShape->getForeground();
}
......@@ -233,7 +230,7 @@ sal_Int32 AccessibleChartShape::getBackground()
throw (uno::RuntimeException, std::exception)
{
sal_Int32 nColor(0);
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
nColor = m_pAccShape->getBackground();
}
......@@ -245,7 +242,7 @@ Reference< awt::XFont > AccessibleChartShape::getFont()
throw (uno::RuntimeException, std::exception)
{
Reference< awt::XFont > xFont;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
xFont.set( m_pAccShape->getFont() );
}
......@@ -256,7 +253,7 @@ OUString AccessibleChartShape::getTitledBorderText()
throw (uno::RuntimeException, std::exception)
{
OUString aText;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aText = m_pAccShape->getTitledBorderText();
}
......@@ -267,7 +264,7 @@ OUString AccessibleChartShape::getToolTipText()
throw (::com::sun::star::uno::RuntimeException, std::exception)
{
OUString aText;
if ( m_pAccShape )
if ( m_pAccShape.is() )
{
aText = m_pAccShape->getToolTipText();
}
......
......@@ -86,7 +86,7 @@ public:
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
private:
::accessibility::AccessibleShape* m_pAccShape;
rtl::Reference<accessibility::AccessibleShape> m_pAccShape;
::accessibility::AccessibleShapeTreeInfo m_aShapeTreeInfo;
};
......
......@@ -118,7 +118,7 @@ public:
<code>XAccessible</code> interface. This pointer may be NULL
if the specified shape is of unknown type.
*/
AccessibleShape*
rtl::Reference<AccessibleShape>
CreateAccessibleObject (
const AccessibleShapeInfo& rShapeInfo,
const AccessibleShapeTreeInfo& rShapeTreeInfo) const;
......
......@@ -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
......
......@@ -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),
......
......@@ -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() );
}
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -2028,7 +2028,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext(
if( !xAcc.is() && bCreate )
{
::accessibility::AccessibleShape *pAcc = nullptr;
rtl::Reference< ::accessibility::AccessibleShape> pAcc;
uno::Reference < drawing::XShape > xShape(
const_cast< SdrObject * >( pObj )->getUnoShape(),
uno::UNO_QUERY );
......@@ -2043,7 +2043,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext(
pAcc = rShapeTypeHandler.CreateAccessibleObject(
aShapeInfo, mpShapeMap->GetInfo() );
}
xAcc = pAcc;
xAcc = pAcc.get();
OSL_ENSURE( xAcc.is(), "unknown shape type" );
if( xAcc.is() )
......@@ -3204,11 +3204,11 @@ bool SwAccessibleMap::ReplaceChild (
::accessibility::ShapeTypeHandler::Instance();
::accessibility::AccessibleShapeInfo aShapeInfo(
xShape, xParent, this );
::accessibility::AccessibleShape* pReplacement =
rtl::Reference< ::accessibility::AccessibleShape> pReplacement(
rShapeTypeHandler.CreateAccessibleObject (
aShapeInfo, mpShapeMap->GetInfo() );
aShapeInfo, mpShapeMap->GetInfo() ));
uno::Reference < XAccessible > xAcc( pReplacement );
uno::Reference < XAccessible > xAcc( pReplacement.get() );
if( xAcc.is() )
{
pReplacement->Init();
......
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