[Libreoffice-commits] core.git: svx/source

Justin Luth justin_luth at sil.org
Mon Feb 8 16:33:15 CET 2016


 svx/source/accessibility/AccessibleTextHelper.cxx |    2 -
 svx/source/table/accessiblecell.cxx               |    2 +
 svx/source/table/accessibletableshape.cxx         |   34 ++++++++++++++++++++++
 svx/source/table/cell.cxx                         |   10 ++++++
 svx/source/table/cell.hxx                         |    1 
 5 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit 1fda8bf08123b521d9ad77eb542d7d1a3c63f54a
Author: Justin Luth <justin_luth at sil.org>
Date:   Sat Jan 16 08:12:47 2016 +0300

    tdf#96685 - set focus of accessible table cells
    
    Newly created accessible cells were not inheriting the focus
    setting of their peer.
    
    Also, IsTextEditActive was way too strict to determine whether a
    table cell was active or not. Typed text with the cursor in the cell was
    not enough to mark the cell as active for example.
    
    Finally, accessible nodes were not being created as additional
    cells gained focus for the first time.
    
    Change-Id: I5be4b1d660f01fc4de7281a319895a2c73e74c48
    Reviewed-on: https://gerrit.libreoffice.org/21121
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jacobo Aragunde PĂ©rez <jaragunde at igalia.com>

diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index 03570b0..f8a724a 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -502,7 +502,7 @@ namespace accessibility
                 {
                     sdr::table::CellRef xCell = pAccessibleCell->getCellRef();
                     if ( xCell.is() )
-                        return xCell->IsTextEditActive();
+                        return xCell->IsActiveCell();
                 }
             }
             if( pViewForwarder->IsValid() )
diff --git a/svx/source/table/accessiblecell.cxx b/svx/source/table/accessiblecell.cxx
index af68170..8059d97 100644
--- a/svx/source/table/accessiblecell.cxx
+++ b/svx/source/table/accessiblecell.cxx
@@ -85,6 +85,8 @@ void AccessibleCell::Init()
             // non-empty text -> use full-fledged edit source right away
 
             mpText = new AccessibleTextHelper( o3tl::make_unique<SvxTextEditSource>(mxCell->GetObject(), mxCell.get(), *pView, *pWindow) );
+            if( mxCell.is() && mxCell.get()->IsActiveCell() )
+                mpText->SetFocus();
             mpText->SetEventSource(this);
         }
 
diff --git a/svx/source/table/accessibletableshape.cxx b/svx/source/table/accessibletableshape.cxx
index 66b01f0..1c76765 100644
--- a/svx/source/table/accessibletableshape.cxx
+++ b/svx/source/table/accessibletableshape.cxx
@@ -85,6 +85,7 @@ public:
     sal_Int32 mRowCount, mColCount;
     //get the cached AccessibleCell from XCell
     Reference< AccessibleCell > getAccessibleCell (Reference< XCell > xCell);
+    Reference< AccessibleCell > getAccessibleCell (sal_Int32 nRow, sal_Int32 nColumn) throw (IndexOutOfBoundsException, RuntimeException);
 };
 
 
@@ -150,6 +151,27 @@ Reference< AccessibleCell > AccessibleTableShapeImpl::getAccessibleCell (Referen
     return Reference< AccessibleCell >();
 }
 
+Reference< AccessibleCell > AccessibleTableShapeImpl::getAccessibleCell (sal_Int32 nRow, sal_Int32 nColumn)
+    throw (IndexOutOfBoundsException, RuntimeException)
+{
+    Reference< XCell > xCell( mxTable->getCellByPosition( nColumn, nRow ) );
+    Reference< AccessibleCell > xChild = getAccessibleCell( xCell );
+
+    if( !xChild.is() && mxTable.is() )
+    {
+        sal_Int32 nChildIndex = mxTable->getColumnCount() * nRow + nColumn;
+        CellRef xCellRef( dynamic_cast< Cell* >( xCell.get() ) );
+
+        rtl::Reference< AccessibleCell > xAccessibleCell( new AccessibleCell( mxAccessible, xCellRef, nChildIndex, mrShapeTreeInfo ) );
+
+        xAccessibleCell->Init();
+        maChildMap[xCell] = xAccessibleCell;
+
+        xChild = Reference< AccessibleCell >( xAccessibleCell.get() );
+    }
+    return xChild;
+}
+
 
 Reference< XAccessible > AccessibleTableShapeImpl::getAccessibleChild(sal_Int32 nChildIndex)
     throw (IndexOutOfBoundsException, RuntimeException)
@@ -979,6 +1001,18 @@ AccessibleCell* AccessibleTableShape::GetActiveAccessibleCell()
                     if (xAccCell.is())
                         pAccCell = xAccCell.get();
                 }
+                else
+                {
+                    try
+                    {
+                        CellPos rPos;
+                        pTableObj->getActiveCellPos( rPos );
+                        xAccCell = mxImpl->getAccessibleCell( rPos.mnRow, rPos.mnCol );
+                        if ( xAccCell.is() )
+                            pAccCell = xAccCell.get();
+                    }
+                    catch ( IndexOutOfBoundsException& ) {}
+                }
             }
         }
     }
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index b2d1604..1946a81 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -565,6 +565,16 @@ void Cell::notifyModified()
 // SdrTextShape proxy
 
 
+bool Cell::IsActiveCell()
+{
+    bool isActive = false;
+    SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
+    if( rTableObj.getActiveCell().get() == this )
+        isActive = true;
+
+    return isActive;
+}
+
 bool Cell::IsTextEditActive()
 {
     bool isActive = false;
diff --git a/svx/source/table/cell.hxx b/svx/source/table/cell.hxx
index e2a28a0..38ebe42 100644
--- a/svx/source/table/cell.hxx
+++ b/svx/source/table/cell.hxx
@@ -64,6 +64,7 @@ public:
     SVX_DLLPRIVATE void dispose();
 
     // SdrTextShape proxy
+    bool IsActiveCell();
     bool IsTextEditActive();
     SVX_DLLPRIVATE bool hasText() const;
 


More information about the Libreoffice-commits mailing list