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

Caolán McNamara caolanm at redhat.com
Thu Jul 27 15:20:39 UTC 2017


 sc/source/ui/unoobj/viewuno.cxx |   54 ++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 24 deletions(-)

New commits:
commit 221dae68df80298e81e6e6549636f3528f5c8bc3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 27 15:41:16 2017 +0100

    Related: tdf#106872 factor out getting selected shapes
    
    Change-Id: I765c482a41e9681a1eb145c1833cc94f35a27db3

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


More information about the Libreoffice-commits mailing list