sw/source/core/access/accmap.cxx |   65 ++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 34 deletions(-)

New commits:
commit aefb96bb25cd24065898201727b66a34c04acb45
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 15:41:01 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:32:19 2025 +0200

    sw a11y: Return early for null mpShapeMap
    
    (`git show --ignore-space-change` helps see the
    "actual" change more easily.)
    
    Change-Id: I2560921c7868ce278c69a7be5eb4f2f2305ce9d2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184588
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 27f7d964cfb8..028e1d0c30aa 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1784,45 +1784,44 @@ SwAccessibleMap::GetContextImpl(const SdrObject* pObj, 
SwAccessibleContext* pPar
 {
     DBG_TESTSOLARMUTEX();
 
-    rtl::Reference < ::accessibility::AccessibleShape > xAcc;
-
     if( !mpShapeMap && bCreate )
         mpShapeMap.reset(new SwAccessibleShapeMap_Impl( this ));
-    if( mpShapeMap )
-    {
-        SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
-        if( aIter != mpShapeMap->end() )
-            xAcc = (*aIter).second;
+    if (!mpShapeMap)
+        return nullptr;
 
-        if( !xAcc.is() && bCreate )
+    rtl::Reference<::accessibility::AccessibleShape> xAcc;
+    SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
+    if( aIter != mpShapeMap->end() )
+        xAcc = (*aIter).second;
+
+    if( !xAcc.is() && bCreate )
+    {
+        uno::Reference < drawing::XShape > xShape(
+            const_cast< SdrObject * >( pObj )->getUnoShape(),
+            uno::UNO_QUERY );
+        if( xShape.is() )
         {
-            uno::Reference < drawing::XShape > xShape(
-                const_cast< SdrObject * >( pObj )->getUnoShape(),
-                uno::UNO_QUERY );
-            if( xShape.is() )
-            {
-                ::accessibility::ShapeTypeHandler& rShapeTypeHandler =
-                            ::accessibility::ShapeTypeHandler::Instance();
+            ::accessibility::ShapeTypeHandler& rShapeTypeHandler =
+                        ::accessibility::ShapeTypeHandler::Instance();
 
-                ::accessibility::AccessibleShapeInfo aShapeInfo(
-                        xShape, uno::Reference<XAccessible>(pParentImpl), this 
);
+            ::accessibility::AccessibleShapeInfo aShapeInfo(
+                    xShape, uno::Reference<XAccessible>(pParentImpl), this );
 
-                xAcc = rShapeTypeHandler.CreateAccessibleObject(
-                            aShapeInfo, mpShapeMap->GetInfo() );
-            }
-            assert(xAcc.is());
-            xAcc->Init();
-            if( aIter != mpShapeMap->end() )
-            {
-                (*aIter).second = xAcc.get();
-            }
-            else
-            {
-                mpShapeMap->emplace( pObj, xAcc );
-            }
-            // TODO: focus!!!
-            AddGroupContext(pObj, xAcc);
+            xAcc = rShapeTypeHandler.CreateAccessibleObject(
+                        aShapeInfo, mpShapeMap->GetInfo() );
+        }
+        assert(xAcc.is());
+        xAcc->Init();
+        if( aIter != mpShapeMap->end() )
+        {
+            (*aIter).second = xAcc.get();
+        }
+        else
+        {
+            mpShapeMap->emplace( pObj, xAcc );
         }
+        // TODO: focus!!!
+        AddGroupContext(pObj, xAcc);
     }
 
     return xAcc;
commit abf75072ab0c1e0cdc9a6aecc31b15c4538a9cdf
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 15:38:16 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:32:12 2025 +0200

    sw a11y: Drop intermediate local var
    
    Assign directly to `xAcc` instead.
    
    Change-Id: I95b63218ed5b2c72e9cd8ec10399b7ed4cc532cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184587
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 183130eae5aa..27f7d964cfb8 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1796,7 +1796,6 @@ SwAccessibleMap::GetContextImpl(const SdrObject* pObj, 
SwAccessibleContext* pPar
 
         if( !xAcc.is() && bCreate )
         {
-            rtl::Reference< ::accessibility::AccessibleShape> pAcc;
             uno::Reference < drawing::XShape > xShape(
                 const_cast< SdrObject * >( pObj )->getUnoShape(),
                 uno::UNO_QUERY );
@@ -1808,12 +1807,11 @@ SwAccessibleMap::GetContextImpl(const SdrObject* pObj, 
SwAccessibleContext* pPar
                 ::accessibility::AccessibleShapeInfo aShapeInfo(
                         xShape, uno::Reference<XAccessible>(pParentImpl), this 
);
 
-                pAcc = rShapeTypeHandler.CreateAccessibleObject(
+                xAcc = rShapeTypeHandler.CreateAccessibleObject(
                             aShapeInfo, mpShapeMap->GetInfo() );
             }
-            xAcc = pAcc.get();
             assert(xAcc.is());
-            pAcc->Init();
+            xAcc->Init();
             if( aIter != mpShapeMap->end() )
             {
                 (*aIter).second = xAcc.get();

Reply via email to