From 192d97cdf091af08a492416824918ea447bfb16f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 27 Jul 2017 16:10:22 +0100 Subject: Resolves: tdf#106872 only request selected shapes that way we can avoid the super slow code path for filtered rows when we only care about selected shapes Change-Id: I175fa841e406dbbe7075296f2e0a0e79fa115fb7 Reviewed-on: https://gerrit.libreoffice.org/40496 Tested-by: Jenkins Reviewed-by: Eike Rathke --- sc/source/ui/Accessibility/AccessibleDocument.cxx | 24 +++++++++++------------ sc/source/ui/inc/tabvwsh.hxx | 1 + sc/source/ui/unoobj/viewuno.cxx | 21 +++++++++----------- 3 files changed, 21 insertions(+), 25 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 0f967955b11d..73bd5935733c 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -333,7 +333,7 @@ ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, Sc { if (mpAccessibleDocument) xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument); - uno::Reference xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY); + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); if (xShapes.is()) mnShapesSelected = xShapes->getCount(); } @@ -350,7 +350,7 @@ ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, Sc if (!xSelectionSupplier.is()) throw uno::RuntimeException(); - uno::Reference xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY); + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); if (xShapes.is()) FindSelectedShapesChanges(xShapes); } @@ -644,8 +644,8 @@ bool ScChildrenShapes::IsSelected(sal_Int32 nIndex, #if OSL_DEBUG_LEVEL > 0 // test whether it is truly selected by a slower method uno::Reference< drawing::XShape > xReturnShape; bool bDebugResult(false); - uno::Reference xIndexAccess; - xSelectionSupplier->getSelection() >>= xIndexAccess; + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); + uno::Reference xIndexAccess(xShapes, uno::UNO_QUERY); if (xIndexAccess.is()) { @@ -680,7 +680,7 @@ bool ScChildrenShapes::SelectionChanged() if (!xSelectionSupplier.is()) throw uno::RuntimeException(); - uno::Reference xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY); + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); bResult = FindSelectedShapesChanges(xShapes); @@ -701,8 +701,7 @@ void ScChildrenShapes::Select(sal_Int32 nIndex) uno::Reference xShape; if (!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable) { - uno::Reference xShapes; - xSelectionSupplier->getSelection() >>= xShapes; + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); if (!xShapes.is()) xShapes = drawing::ShapeCollection::create( @@ -770,9 +769,8 @@ void ScChildrenShapes::SelectAll() void ScChildrenShapes::FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const { - uno::Reference xIndexAccess; - xSelectionSupplier->getSelection() >>= xIndexAccess; - + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); + uno::Reference xIndexAccess(xShapes, uno::UNO_QUERY); if (xIndexAccess.is()) { sal_uInt32 nCount(xIndexAccess->getCount()); @@ -857,8 +855,7 @@ void ScChildrenShapes::Deselect(sal_Int32 nChildIndex) { if (xShape.is()) { - uno::Reference xShapes; - xSelectionSupplier->getSelection() >>= xShapes; + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); if (xShapes.is()) xShapes->remove(xShape); @@ -1243,7 +1240,8 @@ void ScChildrenShapes::AddShape(const uno::Reference& xShape, b if (!xSelectionSupplier.is()) throw uno::RuntimeException(); - uno::Reference xEnumAcc(xSelectionSupplier->getSelection(), uno::UNO_QUERY); + uno::Reference xShapes(mpViewShell->getSelectedXShapes()); + uno::Reference xEnumAcc(xShapes, uno::UNO_QUERY); if (xEnumAcc.is()) { uno::Reference xEnum = xEnumAcc->createEnumeration(); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index c4888cbd468c..2a7e6690004a 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -389,6 +389,7 @@ public: void NotifyCursor(SfxViewShell* pViewShell) const override; /// Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex static void notifyAllViewsHeaderInvalidation(const OString& rPayload, SCTAB nCurrentTabIndex = -1); + css::uno::Reference getSelectedXShapes(); }; #endif diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 6abd3678be04..3d54ee808868 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -848,12 +848,13 @@ sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection ) return bRet; } -namespace +uno::Reference ScTabViewShell::getSelectedXShapes() { - uno::Reference getSelectedShapes(SdrView& rDrawView) + uno::Reference xShapes; + SdrView* pSdrView = GetSdrView(); + if (pSdrView) { - uno::Reference xShapes; - const SdrMarkList& rMarkList = rDrawView.GetMarkedObjectList(); + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); const size_t nMarkCount = rMarkList.GetMarkCount(); if (nMarkCount) { @@ -872,8 +873,8 @@ namespace } } } - return xShapes; } + return xShapes; } uno::Any SAL_CALL ScTabViewObj::getSelection() @@ -884,13 +885,9 @@ uno::Any SAL_CALL ScTabViewObj::getSelection() if (pViewSh) { // is something selected in drawing layer? - SdrView* pDrawView = pViewSh->GetSdrView(); - if (pDrawView) - { - uno::Reference xRet(getSelectedShapes(*pDrawView)); - if (xRet.is()) - return uno::makeAny(xRet); - } + uno::Reference xRet(pViewSh->getSelectedXShapes()); + if (xRet.is()) + return uno::makeAny(xRet); // otherwise sheet (cell) selection -- cgit