[Libreoffice-commits] core.git: chart2/source include/svx sc/source svx/source sw/source

Stephan Bergmann sbergman at redhat.com
Mon Oct 5 07:55:42 PDT 2015


 chart2/source/controller/accessibility/AccessibleChartShape.cxx |   39 ++---
 chart2/source/controller/accessibility/AccessibleChartShape.hxx |    2 
 include/svx/ShapeTypeHandler.hxx                                |    2 
 sc/source/ui/Accessibility/AccessibleDocument.cxx               |   67 ++++------
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx    |   22 +--
 svx/source/accessibility/ChildrenManagerImpl.cxx                |   19 +-
 svx/source/accessibility/GraphCtlAccessibleContext.cxx          |   23 +--
 svx/source/accessibility/ShapeTypeHandler.cxx                   |    6 
 svx/source/inc/GraphCtlAccessibleContext.hxx                    |    2 
 sw/source/core/access/accmap.cxx                                |   10 -
 10 files changed, 86 insertions(+), 106 deletions(-)

New commits:
commit cc7556740640e1b3f8730b939e21eaa882abc031
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Oct 5 16:53:41 2015 +0200

    Return rtl::Reference from ShapeTypeHandler::CreateAccessibleObject
    
    ...and handle related fallout
    
    Change-Id: Ie82d853a9bf28b359d5aab9d0af01b728d68ed70

diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.cxx b/chart2/source/controller/accessibility/AccessibleChartShape.cxx
index aa90d3d..7f64e36 100644
--- a/chart2/source/controller/accessibility/AccessibleChartShape.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartShape.cxx
@@ -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();
     }
diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.hxx b/chart2/source/controller/accessibility/AccessibleChartShape.hxx
index 71bdbce..99e0c8d 100644
--- a/chart2/source/controller/accessibility/AccessibleChartShape.hxx
+++ b/chart2/source/controller/accessibility/AccessibleChartShape.hxx
@@ -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;
 };
 
diff --git a/include/svx/ShapeTypeHandler.hxx b/include/svx/ShapeTypeHandler.hxx
index 7c041ed..297150b 100644
--- a/include/svx/ShapeTypeHandler.hxx
+++ b/include/svx/ShapeTypeHandler.hxx
@@ -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;
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 4a199a9..608fd6d 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 b5e1694..8816fd7 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
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx
index 151cb5a..45b37c0 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 2119368..5667292 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 6285a99..57e8b3e 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 60e19a9..289b20d 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;
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index dbfa78d4..6fc60b3 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -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();


More information about the Libreoffice-commits mailing list