diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-07-27 15:41:16 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-07-27 16:12:19 +0100 |
commit | 221dae68df80298e81e6e6549636f3528f5c8bc3 (patch) | |
tree | 314e636069af1ca6401a4ec0f8d841b711f0e598 /sc | |
parent | 998e3d5cef63cb9c512737bce65519f5a86ba019 (diff) |
Related: tdf#106872 factor out getting selected shapes
Change-Id: I765c482a41e9681a1eb145c1833cc94f35a27db3
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/viewuno.cxx | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 56a8f44a75f6..6abd3678be04 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -848,6 +848,34 @@ sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection ) return bRet; } +namespace +{ + uno::Reference<drawing::XShapes> getSelectedShapes(SdrView& rDrawView) + { + uno::Reference<drawing::XShapes> xShapes; + const SdrMarkList& rMarkList = rDrawView.GetMarkedObjectList(); + const size_t nMarkCount = rMarkList.GetMarkCount(); + if (nMarkCount) + { + // generate ShapeCollection (like in SdXImpressView::getSelection in Draw) + // XInterfaceRef will be returned and it has to be UsrObject-XInterface + xShapes = drawing::ShapeCollection::create(comphelper::getProcessComponentContext()); + + for (size_t i = 0; i < nMarkCount; ++i) + { + SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); + if (pDrawObj) + { + uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY ); + if (xShape.is()) + xShapes->add(xShape); + } + } + } + return xShapes; + } +} + uno::Any SAL_CALL ScTabViewObj::getSelection() { SolarMutexGuard aGuard; @@ -856,34 +884,12 @@ uno::Any SAL_CALL ScTabViewObj::getSelection() if (pViewSh) { // is something selected in drawing layer? - SdrView* pDrawView = pViewSh->GetSdrView(); if (pDrawView) { - const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList(); - const size_t nMarkCount = rMarkList.GetMarkCount(); - if (nMarkCount) - { - // generate ShapeCollection (like in SdXImpressView::getSelection in Draw) - // XInterfaceRef will be returned and it has to be UsrObject-XInterface - - uno::Reference< drawing::XShapes > xShapes = drawing::ShapeCollection::create( - comphelper::getProcessComponentContext()); - - uno::Reference<uno::XInterface> xRet(xShapes); - - for (size_t i=0; i<nMarkCount; ++i) - { - SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); - if (pDrawObj) - { - uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY ); - if (xShape.is()) - xShapes->add(xShape); - } - } + uno::Reference<uno::XInterface> xRet(getSelectedShapes(*pDrawView)); + if (xRet.is()) return uno::makeAny(xRet); - } } // otherwise sheet (cell) selection |