diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-29 16:13:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-29 20:44:00 +0200 |
commit | 6446f79f6a13aad9c60cb52ecfb66ccd9bd4065b (patch) | |
tree | 3d89f2c7db0b0685033933981223055619bd07ad /sc/source | |
parent | 4efce3b3a783549cfdb758d63403863b9407977c (diff) |
loplugin:flatten in sc/ui/Accessibility
Change-Id: Ia99a0f99cbec91fde97bad525768725e5a1ad22a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99702
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCell.cxx | 88 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleContextBase.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 378 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx | 146 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleEditObject.cxx | 66 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePreviewCell.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx | 74 |
7 files changed, 404 insertions, 404 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index 990a296383ff..800cca592385 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -383,44 +383,44 @@ ScDocument* ScAccessibleCell::GetDocument(ScTabViewShell* pViewShell) void ScAccessibleCell::FillDependents(utl::AccessibleRelationSetHelper* pRelationSet) { - if (mpDoc) - { - ScRange aRange(0, 0, maCellAddress.Tab(), mpDoc->MaxCol(), mpDoc->MaxRow(), maCellAddress.Tab()); - ScCellIterator aCellIter(mpDoc, aRange); + if (!mpDoc) + return; - for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next()) + ScRange aRange(0, 0, maCellAddress.Tab(), mpDoc->MaxCol(), mpDoc->MaxRow(), maCellAddress.Tab()); + ScCellIterator aCellIter(mpDoc, aRange); + + for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next()) + { + if (aCellIter.getType() == CELLTYPE_FORMULA) { - if (aCellIter.getType() == CELLTYPE_FORMULA) + bool bFound = false; + ScDetectiveRefIter aIter(mpDoc, aCellIter.getFormulaCell()); + ScRange aRef; + while ( !bFound && aIter.GetNextRef( aRef ) ) { - bool bFound = false; - ScDetectiveRefIter aIter(mpDoc, aCellIter.getFormulaCell()); - ScRange aRef; - while ( !bFound && aIter.GetNextRef( aRef ) ) - { - if (aRef.In(maCellAddress)) - bFound = true; - } - if (bFound) - AddRelation(aCellIter.GetPos(), AccessibleRelationType::CONTROLLER_FOR, pRelationSet); + if (aRef.In(maCellAddress)) + bFound = true; } + if (bFound) + AddRelation(aCellIter.GetPos(), AccessibleRelationType::CONTROLLER_FOR, pRelationSet); } } } void ScAccessibleCell::FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet) { - if (mpDoc) + if (!mpDoc) + return; + + ScRefCellValue aCell(*mpDoc, maCellAddress); + if (aCell.meType == CELLTYPE_FORMULA) { - ScRefCellValue aCell(*mpDoc, maCellAddress); - if (aCell.meType == CELLTYPE_FORMULA) + ScFormulaCell* pCell = aCell.mpFormula; + ScDetectiveRefIter aIter(mpDoc, pCell); + ScRange aRef; + while ( aIter.GetNextRef( aRef ) ) { - ScFormulaCell* pCell = aCell.mpFormula; - ScDetectiveRefIter aIter(mpDoc, pCell); - ScRange aRef; - while ( aIter.GetNextRef( aRef ) ) - { - AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet); - } + AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet); } } } @@ -437,28 +437,28 @@ void ScAccessibleCell::AddRelation(const ScRange& rRange, utl::AccessibleRelationSetHelper* pRelationSet) { uno::Reference < XAccessibleTable > xTable ( getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY ); - if (xTable.is()) + if (!xTable.is()) + return; + + const sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() - + rRange.aStart.Col() + 1) * (rRange.aEnd.Row() - + rRange.aStart.Row() + 1)); + uno::Sequence < uno::Reference < uno::XInterface > > aTargetSet( nCount ); + uno::Reference < uno::XInterface >* pTargetSet = aTargetSet.getArray(); + sal_uInt32 nPos(0); + for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow) { - const sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() - - rRange.aStart.Col() + 1) * (rRange.aEnd.Row() - - rRange.aStart.Row() + 1)); - uno::Sequence < uno::Reference < uno::XInterface > > aTargetSet( nCount ); - uno::Reference < uno::XInterface >* pTargetSet = aTargetSet.getArray(); - sal_uInt32 nPos(0); - for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow) + for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol) { - for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol) - { - pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol); - ++nPos; - } + pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol); + ++nPos; } - OSL_ENSURE(nCount == nPos, "something went wrong"); - AccessibleRelation aRelation; - aRelation.RelationType = aRelationType; - aRelation.TargetSet = aTargetSet; - pRelationSet->AddRelation(aRelation); } + OSL_ENSURE(nCount == nPos, "something went wrong"); + AccessibleRelation aRelation; + aRelation.RelationType = aRelationType; + aRelation.TargetSet = aTargetSet; + pRelationSet->AddRelation(aRelation); } static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& replacedChar, const OUString& replaceStr) diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx b/sc/source/ui/Accessibility/AccessibleContextBase.cxx index 30db54cff5ce..14d660c7fd91 100644 --- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx @@ -380,22 +380,22 @@ void SAL_CALL ScAccessibleContextBase::removeAccessibleEventListener( const uno::Reference<XAccessibleEventListener>& xListener) { - if (xListener.is()) + if (!xListener.is()) + return; + + SolarMutexGuard aGuard; + if (!(!IsDefunc() && mnClientId)) + return; + + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); + if ( !nListenerCount ) { - SolarMutexGuard aGuard; - if (!IsDefunc() && mnClientId) - { - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; - } - } + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); + mnClientId = 0; } } diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 8383ab64d346..737590610bf5 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -319,20 +319,20 @@ ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, Sc if (xShapes.is()) FindSelectedShapesChanges(xShapes); } - if (pViewShell) + if (!pViewShell) + return; + + ScViewData& rViewData = pViewShell->GetViewData(); + SfxBroadcaster* pDrawBC = rViewData.GetDocument()->GetDrawBroadcaster(); + if (pDrawBC) { - ScViewData& rViewData = pViewShell->GetViewData(); - SfxBroadcaster* pDrawBC = rViewData.GetDocument()->GetDrawBroadcaster(); - if (pDrawBC) - { - StartListening(*pDrawBC); + StartListening(*pDrawBC); - maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(rViewData.GetDocument()->GetDrawLayer()) ); - maShapeTreeInfo.SetSdrView(rViewData.GetScDrawView()); - maShapeTreeInfo.SetController(nullptr); - maShapeTreeInfo.SetDevice(pViewShell->GetWindowByPos(meSplitPos)); - maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument); - } + maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(rViewData.GetDocument()->GetDrawLayer()) ); + maShapeTreeInfo.SetSdrView(rViewData.GetScDrawView()); + maShapeTreeInfo.SetController(nullptr); + maShapeTreeInfo.SetDevice(pViewShell->GetWindowByPos(meSplitPos)); + maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument); } } @@ -352,20 +352,20 @@ ScChildrenShapes::~ScChildrenShapes() void ScChildrenShapes::SetDrawBroadcaster() { - if (mpViewShell) + if (!mpViewShell) + return; + + ScViewData& rViewData = mpViewShell->GetViewData(); + SfxBroadcaster* pDrawBC = rViewData.GetDocument()->GetDrawBroadcaster(); + if (pDrawBC) { - ScViewData& rViewData = mpViewShell->GetViewData(); - SfxBroadcaster* pDrawBC = rViewData.GetDocument()->GetDrawBroadcaster(); - if (pDrawBC) - { - StartListening(*pDrawBC, DuplicateHandling::Prevent); + StartListening(*pDrawBC, DuplicateHandling::Prevent); - maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(rViewData.GetDocument()->GetDrawLayer()) ); - maShapeTreeInfo.SetSdrView(rViewData.GetScDrawView()); - maShapeTreeInfo.SetController(nullptr); - maShapeTreeInfo.SetDevice(mpViewShell->GetWindowByPos(meSplitPos)); - maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument); - } + maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(rViewData.GetDocument()->GetDrawLayer()) ); + maShapeTreeInfo.SetSdrView(rViewData.GetScDrawView()); + maShapeTreeInfo.SetController(nullptr); + maShapeTreeInfo.SetDevice(mpViewShell->GetWindowByPos(meSplitPos)); + maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument); } } @@ -376,43 +376,43 @@ void ScChildrenShapes::Notify(SfxBroadcaster&, const SfxHint& rHint) const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint); SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject()); - if (pObj && /*(pObj->GetLayer() != SC_LAYER_INTERN) && */(pObj->getSdrPageFromSdrObject() == GetDrawPage()) && - (pObj->getSdrPageFromSdrObject() == pObj->getParentSdrObjListFromSdrObject()) ) //only do something if the object lies direct on the page + if (!(pObj && /*(pObj->GetLayer() != SC_LAYER_INTERN) && */(pObj->getSdrPageFromSdrObject() == GetDrawPage()) && + (pObj->getSdrPageFromSdrObject() == pObj->getParentSdrObjListFromSdrObject())) ) //only do something if the object lies direct on the page + return; + + switch (pSdrHint->GetKind()) { - switch (pSdrHint->GetKind()) + case SdrHintKind::ObjectChange : // object changed { - case SdrHintKind::ObjectChange : // object changed - { - uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); - if (xShape.is()) - { - mbShapesNeedSorting = true; // sort, because the z index or layer could be changed - auto it = maShapesMap.find(xShape); - if (it != maShapesMap.end()) - SetAnchor(xShape, it->second); - } - } - break; - case SdrHintKind::ObjectInserted : // new drawing object inserted - { - uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); - if (xShape.is()) - AddShape(xShape, true); - } - break; - case SdrHintKind::ObjectRemoved : // Removed drawing object from list - { - uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); - if (xShape.is()) - RemoveShape(xShape); - } - break; - default : + uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); + if (xShape.is()) { - // other events are not interesting + mbShapesNeedSorting = true; // sort, because the z index or layer could be changed + auto it = maShapesMap.find(xShape); + if (it != maShapesMap.end()) + SetAnchor(xShape, it->second); } - break; } + break; + case SdrHintKind::ObjectInserted : // new drawing object inserted + { + uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); + if (xShape.is()) + AddShape(xShape, true); + } + break; + case SdrHintKind::ObjectRemoved : // Removed drawing object from list + { + uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); + if (xShape.is()) + RemoveShape(xShape); + } + break; + default : + { + // other events are not interesting + } + break; } } @@ -684,26 +684,26 @@ void ScChildrenShapes::Select(sal_Int32 nIndex) return; uno::Reference<drawing::XShape> xShape; - if (!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable) - { - uno::Reference<drawing::XShapes> xShapes(mpViewShell->getSelectedXShapes()); + if (!(!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable)) + return; - if (!xShapes.is()) - xShapes = drawing::ShapeCollection::create( - comphelper::getProcessComponentContext()); + uno::Reference<drawing::XShapes> xShapes(mpViewShell->getSelectedXShapes()); - xShapes->add(maZOrderedShapes[nIndex]->xShape); + if (!xShapes.is()) + xShapes = drawing::ShapeCollection::create( + comphelper::getProcessComponentContext()); - try - { - xSelectionSupplier->select(uno::makeAny(xShapes)); - maZOrderedShapes[nIndex]->bSelected = true; - if (maZOrderedShapes[nIndex]->pAccShape.is()) - maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED); - } - catch (lang::IllegalArgumentException&) - { - } + xShapes->add(maZOrderedShapes[nIndex]->xShape); + + try + { + xSelectionSupplier->select(uno::makeAny(xShapes)); + maZOrderedShapes[nIndex]->bSelected = true; + if (maZOrderedShapes[nIndex]->pAccShape.is()) + maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED); + } + catch (lang::IllegalArgumentException&) + { } } @@ -742,30 +742,30 @@ void ScChildrenShapes::SelectAll() if (maZOrderedShapes.size() <= 1) GetCount(); // fill list with filtered shapes (no internal shapes) - if (maZOrderedShapes.size() > 1) - { - uno::Reference<drawing::XShapes> xShapes = drawing::ShapeCollection::create( - comphelper::getProcessComponentContext()); + if (maZOrderedShapes.size() <= 1) + return; + + uno::Reference<drawing::XShapes> xShapes = drawing::ShapeCollection::create( + comphelper::getProcessComponentContext()); - try + try + { + for (const ScAccessibleShapeData* pAccShapeData : maZOrderedShapes) { - for (const ScAccessibleShapeData* pAccShapeData : maZOrderedShapes) + if (pAccShapeData && pAccShapeData->bSelectable) { - if (pAccShapeData && pAccShapeData->bSelectable) - { - pAccShapeData->bSelected = true; - if (pAccShapeData->pAccShape.is()) - pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED); - if (xShapes.is()) - xShapes->add(pAccShapeData->xShape); - } + pAccShapeData->bSelected = true; + if (pAccShapeData->pAccShape.is()) + pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED); + if (xShapes.is()) + xShapes->add(pAccShapeData->xShape); } - xSelectionSupplier->select(uno::makeAny(xShapes)); - } - catch (lang::IllegalArgumentException&) - { - SelectionChanged(); // find all selected shapes and set the flags } + xSelectionSupplier->select(uno::makeAny(xShapes)); + } + catch (lang::IllegalArgumentException&) + { + SelectionChanged(); // find all selected shapes and set the flags } } @@ -844,28 +844,28 @@ uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedC void ScChildrenShapes::Deselect(sal_Int32 nChildIndex) { uno::Reference<drawing::XShape> xShape; - if (IsSelected(nChildIndex, xShape)) // returns false if it is the sheet - { - if (xShape.is()) - { - uno::Reference<drawing::XShapes> xShapes(mpViewShell->getSelectedXShapes()); - if (xShapes.is()) - xShapes->remove(xShape); + if (!IsSelected(nChildIndex, xShape)) // returns false if it is the sheet + return; - try - { - xSelectionSupplier->select(uno::makeAny(xShapes)); - } - catch (lang::IllegalArgumentException&) - { - OSL_FAIL("something not selectable"); - } + if (!xShape.is()) + return; - maZOrderedShapes[nChildIndex]->bSelected = false; - if (maZOrderedShapes[nChildIndex]->pAccShape.is()) - maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED); - } + uno::Reference<drawing::XShapes> xShapes(mpViewShell->getSelectedXShapes()); + if (xShapes.is()) + xShapes->remove(xShape); + + try + { + xSelectionSupplier->select(uno::makeAny(xShapes)); + } + catch (lang::IllegalArgumentException&) + { + OSL_FAIL("something not selectable"); } + + maZOrderedShapes[nChildIndex]->bSelected = false; + if (maZOrderedShapes[nChildIndex]->pAccShape.is()) + maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED); } SdrPage* ScChildrenShapes::GetDrawPage() const @@ -1337,31 +1337,31 @@ ScAccessibleDocument::ScAccessibleDocument( void ScAccessibleDocument::PreInit() { - if (mpViewShell) + if (!mpViewShell) + return; + + mpViewShell->AddAccessibilityObject(*this); + vcl::Window *pWin = mpViewShell->GetWindowByPos(meSplitPos); + if( pWin ) { - mpViewShell->AddAccessibilityObject(*this); - vcl::Window *pWin = mpViewShell->GetWindowByPos(meSplitPos); - if( pWin ) + pWin->AddChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener )); + sal_uInt16 nCount = pWin->GetChildCount(); + for( sal_uInt16 i=0; i < nCount; ++i ) { - pWin->AddChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener )); - sal_uInt16 nCount = pWin->GetChildCount(); - for( sal_uInt16 i=0; i < nCount; ++i ) - { - vcl::Window *pChildWin = pWin->GetChild( i ); - if( pChildWin && - AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() ) - AddChild( pChildWin->GetAccessible(), false ); - } - } - ScViewData& rViewData = mpViewShell->GetViewData(); - if (rViewData.HasEditView(meSplitPos)) - { - uno::Reference<XAccessible> xAcc = new ScAccessibleEditObject(this, rViewData.GetEditView(meSplitPos), - mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(), GetCurrentCellDescription(), - ScAccessibleEditObject::CellInEditMode); - AddChild(xAcc, false); + vcl::Window *pChildWin = pWin->GetChild( i ); + if( pChildWin && + AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() ) + AddChild( pChildWin->GetAccessible(), false ); } } + ScViewData& rViewData = mpViewShell->GetViewData(); + if (rViewData.HasEditView(meSplitPos)) + { + uno::Reference<XAccessible> xAcc = new ScAccessibleEditObject(this, rViewData.GetEditView(meSplitPos), + mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(), GetCurrentCellDescription(), + ScAccessibleEditObject::CellInEditMode); + AddChild(xAcc, false); + } } void ScAccessibleDocument::Init() @@ -1667,19 +1667,19 @@ void SAL_CALL ScAccessibleDocument::grabFocus( ) { SolarMutexGuard aGuard; IsObjectValid(); - if (getAccessibleParent().is()) + if (!getAccessibleParent().is()) + return; + + uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); + if (xAccessibleComponent.is()) { - uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); - if (xAccessibleComponent.is()) + xAccessibleComponent->grabFocus(); + // grab only focus if it does not have the focus and it is not hidden + if (mpViewShell && + (mpViewShell->GetViewData().GetActivePart() != meSplitPos) && + mpViewShell->GetWindowByPos(meSplitPos)->IsVisible()) { - xAccessibleComponent->grabFocus(); - // grab only focus if it does not have the focus and it is not hidden - if (mpViewShell && - (mpViewShell->GetViewData().GetActivePart() != meSplitPos) && - mpViewShell->GetWindowByPos(meSplitPos)->IsVisible()) - { - mpViewShell->ActivatePart(meSplitPos); - } + mpViewShell->ActivatePart(meSplitPos); } } } @@ -1800,26 +1800,26 @@ void SAL_CALL SolarMutexGuard aGuard; IsObjectValid(); - if (mpChildrenShapes && mpViewShell) - { - sal_Int32 nCount(mpChildrenShapes->GetCount()); // all shapes and the table - if (mxTempAcc.is()) - ++nCount; - if (nChildIndex < 0 || nChildIndex >= nCount) - throw lang::IndexOutOfBoundsException(); + if (!(mpChildrenShapes && mpViewShell)) + return; - uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); - if (xAccessible.is()) - { - bool bWasTableSelected(IsTableSelected()); - mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high - if (bWasTableSelected) - mpViewShell->SelectAll(); - } - else - { + sal_Int32 nCount(mpChildrenShapes->GetCount()); // all shapes and the table + if (mxTempAcc.is()) + ++nCount; + if (nChildIndex < 0 || nChildIndex >= nCount) + throw lang::IndexOutOfBoundsException(); + + uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); + if (xAccessible.is()) + { + bool bWasTableSelected(IsTableSelected()); + mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high + if (bWasTableSelected) mpViewShell->SelectAll(); - } + } + else + { + mpViewShell->SelectAll(); } } @@ -1933,26 +1933,26 @@ void SAL_CALL SolarMutexGuard aGuard; IsObjectValid(); - if (mpChildrenShapes && mpViewShell) - { - sal_Int32 nCount(mpChildrenShapes->GetCount()); // all shapes and the table - if (mxTempAcc.is()) - ++nCount; - if (nChildIndex < 0 || nChildIndex >= nCount) - throw lang::IndexOutOfBoundsException(); + if (!(mpChildrenShapes && mpViewShell)) + return; - bool bTabMarked(IsTableSelected()); + sal_Int32 nCount(mpChildrenShapes->GetCount()); // all shapes and the table + if (mxTempAcc.is()) + ++nCount; + if (nChildIndex < 0 || nChildIndex >= nCount) + throw lang::IndexOutOfBoundsException(); - uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); - if (xAccessible.is()) - { - mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high - if (bTabMarked) - mpViewShell->SelectAll(); // select the table again - } - else if (bTabMarked) - mpViewShell->Unmark(); + bool bTabMarked(IsTableSelected()); + + uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); + if (xAccessible.is()) + { + mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high + if (bTabMarked) + mpViewShell->SelectAll(); // select the table again } + else if (bTabMarked) + mpViewShell->Unmark(); } //===== XServiceInfo ==================================================== @@ -2164,19 +2164,19 @@ void ScAccessibleDocument::AddChild(const uno::Reference<XAccessible>& xAcc, boo void ScAccessibleDocument::RemoveChild(const uno::Reference<XAccessible>& xAcc, bool bFireEvent) { OSL_ENSURE(mxTempAcc.is(), "this object should be added before"); - if (xAcc.is()) + if (!xAcc.is()) + return; + + OSL_ENSURE(xAcc.get() == mxTempAcc.get(), "only the same object should be removed"); + if( bFireEvent ) { - OSL_ENSURE(xAcc.get() == mxTempAcc.get(), "only the same object should be removed"); - if( bFireEvent ) - { - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext>(this); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.OldValue <<= mxTempAcc; - CommitChange( aEvent ); - } - mxTempAcc = nullptr; + AccessibleEventObject aEvent; + aEvent.Source = uno::Reference<XAccessibleContext>(this); + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.OldValue <<= mxTempAcc; + CommitChange( aEvent ); } + mxTempAcc = nullptr; } OUString ScAccessibleDocument::GetCurrentCellName() const diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index 6ed759781e6c..ddbc8ecb5ab1 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -469,20 +469,20 @@ struct ScChildNew void ScNotesChildren::DataChanged(const tools::Rectangle& rVisRect) { - if (mpViewShell && mpAccDoc) - { - ScXAccVector aNewParas; - ScXAccVector aOldParas; - ScAccNotes aNewMarks; - mnParagraphs = CheckChanges(mpViewShell->GetLocationData(), rVisRect, true, maMarks, aNewMarks, aOldParas, aNewParas); - maMarks = aNewMarks; - ScAccNotes aNewNotes; - mnParagraphs += CheckChanges(mpViewShell->GetLocationData(), rVisRect, false, maNotes, aNewNotes, aOldParas, aNewParas); - maNotes = aNewNotes; - - std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc)); - std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc)); - } + if (!(mpViewShell && mpAccDoc)) + return; + + ScXAccVector aNewParas; + ScXAccVector aOldParas; + ScAccNotes aNewMarks; + mnParagraphs = CheckChanges(mpViewShell->GetLocationData(), rVisRect, true, maMarks, aNewMarks, aOldParas, aNewParas); + maMarks = aNewMarks; + ScAccNotes aNewNotes; + mnParagraphs += CheckChanges(mpViewShell->GetLocationData(), rVisRect, false, maNotes, aNewNotes, aOldParas, aNewParas); + maNotes = aNewNotes; + + std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc)); + std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc)); } inline ScDocument* ScNotesChildren::GetDocument() const @@ -813,18 +813,18 @@ bool ScShapeChildren::ReplaceChild (::accessibility::AccessibleShape* /* pCurren void ScShapeChildren::Init() { - if(mpViewShell) + if(!mpViewShell) + return; + + const ScPreviewLocationData& rData = mpViewShell->GetLocationData(); + MapMode aMapMode; + tools::Rectangle aPixelPaintRect; + sal_uInt8 nRangeId; + sal_uInt16 nCount(rData.GetDrawRanges()); + for (sal_uInt16 i = 0; i < nCount; ++i) { - const ScPreviewLocationData& rData = mpViewShell->GetLocationData(); - MapMode aMapMode; - tools::Rectangle aPixelPaintRect; - sal_uInt8 nRangeId; - sal_uInt16 nCount(rData.GetDrawRanges()); - for (sal_uInt16 i = 0; i < nCount; ++i) - { - rData.GetDrawRange(i, aPixelPaintRect, aMapMode, nRangeId); - FillShapes(aPixelPaintRect, aMapMode, nRangeId); - } + rData.GetDrawRange(i, aPixelPaintRect, aMapMode, nRangeId); + FillShapes(aPixelPaintRect, aMapMode, nRangeId); } } @@ -999,64 +999,64 @@ void ScShapeChildren::FillShapes(const tools::Rectangle& aPixelPaintRect, const OSL_ENSURE(nRangeId < maShapeRanges.size(), "this is not a valid range for draw objects"); SdrPage* pPage = GetDrawPage(); vcl::Window* pWin = mpViewShell->GetWindow(); - if (pPage && pWin) + if (!(pPage && pWin)) + return; + + bool bForeAdded(false); + bool bBackAdded(false); + bool bControlAdded(false); + tools::Rectangle aClippedPixelPaintRect(aPixelPaintRect); + if (mpAccDoc) { - bool bForeAdded(false); - bool bBackAdded(false); - bool bControlAdded(false); - tools::Rectangle aClippedPixelPaintRect(aPixelPaintRect); - if (mpAccDoc) - { - tools::Rectangle aRect2(Point(0,0), mpAccDoc->GetBoundingBoxOnScreen().GetSize()); - aClippedPixelPaintRect = aPixelPaintRect.GetIntersection(aRect2); - } - ScIAccessibleViewForwarder aViewForwarder(mpViewShell, mpAccDoc, aMapMode); - maShapeRanges[nRangeId].maViewForwarder = aViewForwarder; - const size_t nCount(pPage->GetObjCount()); - for (size_t i = 0; i < nCount; ++i) + tools::Rectangle aRect2(Point(0,0), mpAccDoc->GetBoundingBoxOnScreen().GetSize()); + aClippedPixelPaintRect = aPixelPaintRect.GetIntersection(aRect2); + } + ScIAccessibleViewForwarder aViewForwarder(mpViewShell, mpAccDoc, aMapMode); + maShapeRanges[nRangeId].maViewForwarder = aViewForwarder; + const size_t nCount(pPage->GetObjCount()); + for (size_t i = 0; i < nCount; ++i) + { + SdrObject* pObj = pPage->GetObj(i); + if (pObj) { - SdrObject* pObj = pPage->GetObj(i); - if (pObj) + uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY); + if (xShape.is()) { - uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY); - if (xShape.is()) + tools::Rectangle aRect(pWin->LogicToPixel(VCLPoint(xShape->getPosition()), aMapMode), pWin->LogicToPixel(VCLSize(xShape->getSize()), aMapMode)); + if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty()) { - tools::Rectangle aRect(pWin->LogicToPixel(VCLPoint(xShape->getPosition()), aMapMode), pWin->LogicToPixel(VCLSize(xShape->getSize()), aMapMode)); - if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty()) + ScShapeChild aShape; + aShape.mxShape = xShape; + aShape.mnRangeId = nRangeId; + if (pObj->GetLayer().anyOf(SC_LAYER_INTERN, SC_LAYER_FRONT)) { - ScShapeChild aShape; - aShape.mxShape = xShape; - aShape.mnRangeId = nRangeId; - if (pObj->GetLayer().anyOf(SC_LAYER_INTERN, SC_LAYER_FRONT)) - { - maShapeRanges[nRangeId].maForeShapes.push_back(std::move(aShape)); - bForeAdded = true; - } - else if (pObj->GetLayer() == SC_LAYER_BACK) - { - maShapeRanges[nRangeId].maBackShapes.push_back(std::move(aShape)); - bBackAdded = true; - } - else if (pObj->GetLayer() == SC_LAYER_CONTROLS) - { - maShapeRanges[nRangeId].maControls.push_back(std::move(aShape)); - bControlAdded = true; - } - else - { - OSL_FAIL("I don't know this layer."); - } + maShapeRanges[nRangeId].maForeShapes.push_back(std::move(aShape)); + bForeAdded = true; + } + else if (pObj->GetLayer() == SC_LAYER_BACK) + { + maShapeRanges[nRangeId].maBackShapes.push_back(std::move(aShape)); + bBackAdded = true; + } + else if (pObj->GetLayer() == SC_LAYER_CONTROLS) + { + maShapeRanges[nRangeId].maControls.push_back(std::move(aShape)); + bControlAdded = true; + } + else + { + OSL_FAIL("I don't know this layer."); } } } } - if (bForeAdded) - std::sort(maShapeRanges[nRangeId].maForeShapes.begin(), maShapeRanges[nRangeId].maForeShapes.end(),ScShapeChildLess()); - if (bBackAdded) - std::sort(maShapeRanges[nRangeId].maBackShapes.begin(), maShapeRanges[nRangeId].maBackShapes.end(),ScShapeChildLess()); - if (bControlAdded) - std::sort(maShapeRanges[nRangeId].maControls.begin(), maShapeRanges[nRangeId].maControls.end(),ScShapeChildLess()); } + if (bForeAdded) + std::sort(maShapeRanges[nRangeId].maForeShapes.begin(), maShapeRanges[nRangeId].maForeShapes.end(),ScShapeChildLess()); + if (bBackAdded) + std::sort(maShapeRanges[nRangeId].maBackShapes.begin(), maShapeRanges[nRangeId].maBackShapes.end(),ScShapeChildLess()); + if (bControlAdded) + std::sort(maShapeRanges[nRangeId].maControls.begin(), maShapeRanges[nRangeId].maControls.end(),ScShapeChildLess()); } SdrPage* ScShapeChildren::GetDrawPage() const diff --git a/sc/source/ui/Accessibility/AccessibleEditObject.cxx b/sc/source/ui/Accessibility/AccessibleEditObject.cxx index fccc914de563..e93e6dbdb289 100644 --- a/sc/source/ui/Accessibility/AccessibleEditObject.cxx +++ b/sc/source/ui/Accessibility/AccessibleEditObject.cxx @@ -354,45 +354,45 @@ OutputDevice* ScAccessibleEditObject::GetOutputDeviceForView() void ScAccessibleEditObject::CreateTextHelper() { - if (!mpTextHelper) + if (mpTextHelper) + return; + + ::std::unique_ptr < ScAccessibleTextData > pAccessibleTextData; + if (meObjectType == CellInEditMode || meObjectType == EditControl) { - ::std::unique_ptr < ScAccessibleTextData > pAccessibleTextData; - if (meObjectType == CellInEditMode || meObjectType == EditControl) - { - pAccessibleTextData.reset - (new ScAccessibleEditObjectTextData(mpEditView, GetOutputDeviceForView())); - } - else - { - pAccessibleTextData.reset - (new ScAccessibleEditLineTextData(nullptr, GetOutputDeviceForView())); - } + pAccessibleTextData.reset + (new ScAccessibleEditObjectTextData(mpEditView, GetOutputDeviceForView())); + } + else + { + pAccessibleTextData.reset + (new ScAccessibleEditLineTextData(nullptr, GetOutputDeviceForView())); + } - std::unique_ptr<ScAccessibilityEditSource> pEditSrc = - std::make_unique<ScAccessibilityEditSource>(std::move(pAccessibleTextData)); + std::unique_ptr<ScAccessibilityEditSource> pEditSrc = + std::make_unique<ScAccessibilityEditSource>(std::move(pAccessibleTextData)); - mpTextHelper = std::make_unique<::accessibility::AccessibleTextHelper>(std::move(pEditSrc)); - mpTextHelper->SetEventSource(this); + mpTextHelper = std::make_unique<::accessibility::AccessibleTextHelper>(std::move(pEditSrc)); + mpTextHelper->SetEventSource(this); - const ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); - if ( pInputHdl && pInputHdl->IsEditMode() ) - { - mpTextHelper->SetFocus(); - } - else - { - mpTextHelper->SetFocus(mbHasFocus); - } + const ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); + if ( pInputHdl && pInputHdl->IsEditMode() ) + { + mpTextHelper->SetFocus(); + } + else + { + mpTextHelper->SetFocus(mbHasFocus); + } - // #i54814# activate cell in edit mode - if( meObjectType == CellInEditMode ) + // #i54814# activate cell in edit mode + if( meObjectType == CellInEditMode ) + { + // do not activate cell object, if top edit line is active + if( pInputHdl && !pInputHdl->IsTopMode() ) { - // do not activate cell object, if top edit line is active - if( pInputHdl && !pInputHdl->IsTopMode() ) - { - SdrHint aHint( SdrHintKind::BeginEdit ); - mpTextHelper->GetEditSource().GetBroadcaster().Broadcast( aHint ); - } + SdrHint aHint( SdrHintKind::BeginEdit ); + mpTextHelper->GetEditSource().GetBroadcaster().Broadcast( aHint ); } } } diff --git a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx index 4b5d6636a2f8..6678f40cc7c3 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx @@ -265,19 +265,19 @@ bool ScAccessiblePreviewCell::IsOpaque() const void ScAccessiblePreviewCell::CreateTextHelper() { - if (!mpTextHelper) - { - mpTextHelper.reset( new ::accessibility::AccessibleTextHelper( - std::make_unique<ScAccessibilityEditSource>( - std::make_unique<ScAccessiblePreviewCellTextData>( - mpViewShell, maCellAddress))) ); - mpTextHelper->SetEventSource( this ); - - // paragraphs in preview are transient - ::accessibility::AccessibleTextHelper::VectorOfStates aChildStates; - aChildStates.push_back( AccessibleStateType::TRANSIENT ); - mpTextHelper->SetAdditionalChildStates( aChildStates ); - } + if (mpTextHelper) + return; + + mpTextHelper.reset( new ::accessibility::AccessibleTextHelper( + std::make_unique<ScAccessibilityEditSource>( + std::make_unique<ScAccessiblePreviewCellTextData>( + mpViewShell, maCellAddress))) ); + mpTextHelper->SetEventSource( this ); + + // paragraphs in preview are transient + ::accessibility::AccessibleTextHelper::VectorOfStates aChildStates; + aChildStates.push_back( AccessibleStateType::TRANSIENT ); + mpTextHelper->SetAdditionalChildStates( aChildStates ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index f9d45373618c..9fb0f38b422b 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -288,18 +288,18 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( mnTab = nTab; mbDelIns = false; mbIsFocusSend = false; - if (mpViewShell) - { - mpViewShell->AddAccessibilityObject(*this); + if (!mpViewShell) + return; - const ScViewData& rViewData = mpViewShell->GetViewData(); - maActiveCell = rViewData.GetCurPos(); - mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); - ScDocument* pScDoc= GetDocument(mpViewShell); - if (pScDoc) - { - pScDoc->GetName( maActiveCell.Tab(), m_strOldTabName ); - } + mpViewShell->AddAccessibilityObject(*this); + + const ScViewData& rViewData = mpViewShell->GetViewData(); + maActiveCell = rViewData.GetCurPos(); + mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); + ScDocument* pScDoc= GetDocument(mpViewShell); + if (pScDoc) + { + pScDoc->GetName( maActiveCell.Tab(), m_strOldTabName ); } } @@ -1076,20 +1076,20 @@ void SAL_CALL ScAccessibleSpreadsheet::selectAllAccessibleChildren( ) { SolarMutexGuard aGuard; IsObjectValid(); - if (mpViewShell) + if (!mpViewShell) + return; + + if (IsFormulaMode()) { - if (IsFormulaMode()) - { - ScDocument* pDoc = GetDocument(mpViewShell); - ScViewData& rViewData = mpViewShell->GetViewData(); - mpViewShell->InitRefMode( 0, 0, rViewData.GetTabNo(), SC_REFTYPE_REF ); - rViewData.SetRefStart(0, 0, rViewData.GetTabNo()); - rViewData.SetRefEnd(pDoc->MaxCol(), pDoc->MaxRow(), rViewData.GetTabNo()); - mpViewShell->UpdateRef(pDoc->MaxCol(), pDoc->MaxRow(), rViewData.GetTabNo()); - } - else - mpViewShell->SelectAll(); + ScDocument* pDoc = GetDocument(mpViewShell); + ScViewData& rViewData = mpViewShell->GetViewData(); + mpViewShell->InitRefMode( 0, 0, rViewData.GetTabNo(), SC_REFTYPE_REF ); + rViewData.SetRefStart(0, 0, rViewData.GetTabNo()); + rViewData.SetRefEnd(pDoc->MaxCol(), pDoc->MaxRow(), rViewData.GetTabNo()); + mpViewShell->UpdateRef(pDoc->MaxCol(), pDoc->MaxRow(), rViewData.GetTabNo()); } + else + mpViewShell->SelectAll(); } sal_Int32 SAL_CALL @@ -1167,24 +1167,24 @@ void SAL_CALL ScAccessibleSpreadsheet::deselectAccessibleChild( sal_Int32 nChild if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) throw lang::IndexOutOfBoundsException(); - if (mpViewShell) - { - sal_Int32 nCol(getAccessibleColumn(nChildIndex)); - sal_Int32 nRow(getAccessibleRow(nChildIndex)); + if (!mpViewShell) + return; - if (IsFormulaMode()) + sal_Int32 nCol(getAccessibleColumn(nChildIndex)); + sal_Int32 nRow(getAccessibleRow(nChildIndex)); + + if (IsFormulaMode()) + { + if(IsScAddrFormulaSel( + ScAddress(static_cast<SCCOL>(nCol), nRow,mpViewShell->GetViewData().GetTabNo())) + ) { - if(IsScAddrFormulaSel( - ScAddress(static_cast<SCCOL>(nCol), nRow,mpViewShell->GetViewData().GetTabNo())) - ) - { - SelectCell(nRow, nCol, true); - } - return ; - } - if (mpViewShell->GetViewData().GetMarkData().IsCellMarked(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow))) SelectCell(nRow, nCol, true); + } + return ; } + if (mpViewShell->GetViewData().GetMarkData().IsCellMarked(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow))) + SelectCell(nRow, nCol, true); } void ScAccessibleSpreadsheet::SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect) |