chart2/source/controller/drawinglayer/DrawViewWrapper.cxx |    4 -
 chart2/source/view/charttypes/BarChart.cxx                |   10 --
 chart2/source/view/diagram/VDiagram.cxx                   |    7 -
 chart2/source/view/main/ChartView.cxx                     |   36 +++------
 filter/source/msfilter/eschesdo.cxx                       |   10 --
 oox/source/drawingml/shape.cxx                            |   10 +-
 reportdesign/source/core/api/Shape.cxx                    |   14 +--
 reportdesign/source/core/sdr/RptPage.cxx                  |    3 
 reportdesign/source/ui/report/ReportSection.cxx           |    6 -
 reportdesign/source/ui/report/ViewsWindow.cxx             |    3 
 sc/source/filter/xml/XMLTableShapeImportHelper.cxx        |   17 +---
 sc/source/filter/xml/xmlexprt.cxx                         |   12 ---
 sc/source/ui/Accessibility/AccessibleDocument.cxx         |   11 +--
 sc/source/ui/unoobj/docuno.cxx                            |   29 +++----
 sc/source/ui/unoobj/shapeuno.cxx                          |    7 -
 sc/source/ui/unoobj/viewuno.cxx                           |   40 ++++------
 sc/source/ui/vba/vbasheetobject.cxx                       |    4 -
 sd/source/ui/unoidl/SdUnoDrawView.cxx                     |   11 +--
 sd/source/ui/unoidl/unolayer.cxx                          |    6 -
 sd/source/ui/unoidl/unomodel.cxx                          |   21 ++---
 sd/source/ui/unoidl/unopage.cxx                           |   22 +-----
 slideshow/source/engine/slide/shapemanagerimpl.cxx        |    3 
 slideshow/source/engine/slide/slideimpl.cxx               |    3 
 svx/source/accessibility/ShapeTypeHandler.cxx             |    4 -
 svx/source/unodraw/unopage.cxx                            |   51 +++++---------
 svx/source/unodraw/unoshap2.cxx                           |   18 +---
 svx/source/unodraw/unoshap3.cxx                           |   11 ---
 sw/source/core/unocore/unodraw.cxx                        |    4 -
 28 files changed, 135 insertions(+), 242 deletions(-)

New commits:
commit 18982376918c88ec09c2c7fd42ef635e93897b05
Author:     Noel <noel.gran...@collabora.co.uk>
AuthorDate: Thu Feb 4 10:22:58 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Feb 4 11:19:35 2021 +0100

    use more getSdrObjectFromXShape
    
    Change-Id: Ia237643ab040425f231f781c86e7e060f0b53717
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110400
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx 
b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
index 9d448b4119fe..ced8421d211b 100644
--- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
+++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
@@ -345,9 +345,7 @@ SdrObject* DrawViewWrapper::getSdrObject( const 
uno::Reference<
     uno::Reference< lang::XTypeProvider > xTypeProvider( xShape, 
uno::UNO_QUERY );
     if(xTypeProvider.is())
     {
-        SvxShape* pSvxShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
-        if(pSvxShape)
-            pRet = pSvxShape->GetSdrObject();
+        pRet = SdrObject::getSdrObjectFromXShape(xShape);
     }
     return pRet;
 }
diff --git a/chart2/source/view/charttypes/BarChart.cxx 
b/chart2/source/view/charttypes/BarChart.cxx
index da7461f38e7a..a1de2d065003 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -441,15 +441,7 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis()
 
 static E3dScene* lcl_getE3dScene(uno::Reference<uno::XInterface> const & 
xInterface)
 {
-    E3dScene* pScene = nullptr;
-
-    SvxShape* pSvxShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xInterface);
-    if (pSvxShape)
-    {
-        SdrObject* pObject = pSvxShape->GetSdrObject();
-        pScene = dynamic_cast<E3dScene*>(pObject);
-    }
-    return pScene;
+    return 
dynamic_cast<E3dScene*>(SdrObject::getSdrObjectFromXShape(xInterface));
 }
 
 void BarChart::createShapes()
diff --git a/chart2/source/view/diagram/VDiagram.cxx 
b/chart2/source/view/diagram/VDiagram.cxx
index 670dfab90424..bf3c96e82d53 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -205,12 +205,7 @@ static E3dScene* lcl_getE3dScene( const uno::Reference< 
drawing::XShape >& xShap
     uno::Reference< lang::XTypeProvider > xTypeProvider( xShape, 
uno::UNO_QUERY );
     if(xTypeProvider.is())
     {
-        SvxShape* pSvxShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
-        if(pSvxShape)
-        {
-            SdrObject* pObj = pSvxShape->GetSdrObject();
-            pRet = dynamic_cast< E3dScene* >(pObj);
-        }
+        pRet = dynamic_cast< E3dScene* 
>(SdrObject::getSdrObjectFromXShape(xShape));
     }
     return pRet;
 }
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index e449680daf4c..c88144137721 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1791,22 +1791,18 @@ awt::Rectangle ChartView::getRectangleOfObject( const 
OUString& rObjectCID, bool
         if( eObjectType == OBJECTTYPE_AXIS || eObjectType == 
OBJECTTYPE_DIAGRAM )
         {
             SolarMutexGuard aSolarGuard;
-            SvxShape* pRoot = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
-            if( pRoot )
+            SdrObject* pRootSdrObject = SdrObject::getSdrObjectFromXShape( 
xShape );
+            if( pRootSdrObject )
             {
-                SdrObject* pRootSdrObject = pRoot->GetSdrObject();
-                if( pRootSdrObject )
+                SdrObjList* pRootList = pRootSdrObject->GetSubList();
+                if( pRootList )
                 {
-                    SdrObjList* pRootList = pRootSdrObject->GetSubList();
-                    if( pRootList )
-                    {
-                        OUString aShapeName = "MarkHandles";
-                        if( eObjectType == OBJECTTYPE_DIAGRAM )
-                            aShapeName = "PlotAreaIncludingAxes";
-                        SdrObject* pShape = 
DrawModelWrapper::getNamedSdrObject( aShapeName, pRootList );
-                        if( pShape )
-                            xShape.set( pShape->getUnoShape(), uno::UNO_QUERY);
-                    }
+                    OUString aShapeName = "MarkHandles";
+                    if( eObjectType == OBJECTTYPE_DIAGRAM )
+                        aShapeName = "PlotAreaIncludingAxes";
+                    SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( 
aShapeName, pRootList );
+                    if( pShape )
+                        xShape.set( pShape->getUnoShape(), uno::UNO_QUERY);
                 }
             }
         }
@@ -1817,15 +1813,11 @@ awt::Rectangle ChartView::getRectangleOfObject( const 
OUString& rObjectCID, bool
         if( bSnapRect )
         {
             //for rotated objects the shape size and position differs from the 
visible rectangle
-            SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
-            if( pShape )
+            SdrObject* pSdrObject = SdrObject::getSdrObjectFromXShape( xShape 
);
+            if( pSdrObject )
             {
-                SdrObject* pSdrObject = pShape->GetSdrObject();
-                if( pSdrObject )
-                {
-                    tools::Rectangle aSnapRect( pSdrObject->GetSnapRect() );
-                    aRet = 
awt::Rectangle(aSnapRect.Left(),aSnapRect.Top(),aSnapRect.GetWidth(),aSnapRect.GetHeight());
-                }
+                tools::Rectangle aSnapRect( pSdrObject->GetSnapRect() );
+                aRet = 
awt::Rectangle(aSnapRect.Left(),aSnapRect.Top(),aSnapRect.GetWidth(),aSnapRect.GetHeight());
             }
         }
     }
diff --git a/filter/source/msfilter/eschesdo.cxx 
b/filter/source/msfilter/eschesdo.cxx
index 24f47d62909f..d2c85672ca05 100644
--- a/filter/source/msfilter/eschesdo.cxx
+++ b/filter/source/msfilter/eschesdo.cxx
@@ -991,14 +991,8 @@ sal_uInt32 EscherEx::AddDummyShape()
 // static
 const SdrObject* EscherEx::GetSdrObject( const Reference< XShape >& rShape )
 {
-    const SdrObject* pRet = nullptr;
-    const SvxShape* pSvxShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( rShape );
-    DBG_ASSERT( pSvxShape, "EscherEx::GetSdrObject: no SvxShape" );
-    if( pSvxShape )
-    {
-        pRet = pSvxShape->GetSdrObject();
-        DBG_ASSERT( pRet, "EscherEx::GetSdrObject: no SdrObj" );
-    }
+    const SdrObject* pRet  = SdrObject::getSdrObjectFromXShape( rShape );
+    DBG_ASSERT( pRet, "EscherEx::GetSdrObject: no SdrObj" );
     return pRet;
 }
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 38c5ddfa689f..b4ce27ea4df4 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -580,21 +580,21 @@ static void lcl_createPresetShape(const 
uno::Reference<drawing::XShape>& xShape,
             if (pParagraph->getProperties().getParaAdjust())
                 eAdjust = *pParagraph->getProperties().getParaAdjust();
             xSet->setPropertyValue( "ParaAdjust", uno::makeAny( eAdjust ) );
-            SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
+            SdrObject* pShape = SdrObject::getSdrObjectFromXShape( xShape );
             assert(pShape);
             SdrTextHorzAdjust eHorzAdjust = lcl_convertAdjust( eAdjust );
-            pShape->GetSdrObject()->SetMergedItem( SdrTextHorzAdjustItem( 
eHorzAdjust ) );
+            pShape->SetMergedItem( SdrTextHorzAdjustItem( eHorzAdjust ) );
         }
     }
 
     // Apply vertical adjustment for text on arc
     // ToDo: The property is currently not evaluated.
-    SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
+    SdrObject* pShape = SdrObject::getSdrObjectFromXShape(xShape);
     assert(pShape);
     if (rClass == "fontwork-arch-up-curve")
-        pShape->GetSdrObject()->SetMergedItem( SdrTextVertAdjustItem( 
SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM ) );
+        pShape->SetMergedItem( SdrTextVertAdjustItem( 
SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM ) );
     else if (rClass == "fontwork-arch-down-curve")
-        pShape->GetSdrObject()->SetMergedItem( SdrTextVertAdjustItem( 
SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP ) );
+        pShape->SetMergedItem( SdrTextVertAdjustItem( 
SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP ) );
 
     // Apply preset shape
     xDefaulter->createCustomShapeDefaults( rClass );
diff --git a/reportdesign/source/core/api/Shape.cxx 
b/reportdesign/source/core/api/Shape.cxx
index 077031c5c9aa..8acb43d89b15 100644
--- a/reportdesign/source/core/api/Shape.cxx
+++ b/reportdesign/source/core/api/Shape.cxx
@@ -282,17 +282,13 @@ uno::Reference< util::XCloneable > SAL_CALL 
OShape::createClone(  )
     uno::Reference< report::XReportComponent> xSet;
     try
     {
-        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xSource );
-        if ( pShape )
+        SdrObject* pObject = SdrObject::getSdrObjectFromXShape( xSource );
+        if ( pObject )
         {
-            SdrObject* pObject = pShape->GetSdrObject();
-            if ( pObject )
+            SdrObject* 
pClone(pObject->CloneSdrObject(pObject->getSdrModelFromSdrObject()));
+            if ( pClone )
             {
-                SdrObject* 
pClone(pObject->CloneSdrObject(pObject->getSdrModelFromSdrObject()));
-                if ( pClone )
-                {
-                    xSet.set(pClone->getUnoShape(),uno::UNO_QUERY_THROW );
-                }
+                xSet.set(pClone->getUnoShape(),uno::UNO_QUERY_THROW );
             }
         }
     }
diff --git a/reportdesign/source/core/sdr/RptPage.cxx 
b/reportdesign/source/core/sdr/RptPage.cxx
index 128df5c6fd3d..4c1fcba02f43 100644
--- a/reportdesign/source/core/sdr/RptPage.cxx
+++ b/reportdesign/source/core/sdr/RptPage.cxx
@@ -113,8 +113,7 @@ void OReportPage::insertObject(const uno::Reference< 
report::XReportComponent >&
     if ( nPos < GetObjCount() )
         return; // Object already in list
 
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
_xObject );
-    OObjectBase* pObject = pShape ? dynamic_cast< OObjectBase* >( 
pShape->GetSdrObject() ) : nullptr;
+    OObjectBase* pObject = dynamic_cast< OObjectBase* 
>(SdrObject::getSdrObjectFromXShape( _xObject ));
     OSL_ENSURE( pObject, "OReportPage::insertObject: no implementation object 
found for the given shape/component!" );
     if ( pObject )
         pObject->StartListening();
diff --git a/reportdesign/source/ui/report/ReportSection.cxx 
b/reportdesign/source/ui/report/ReportSection.cxx
index 5ea227f5e184..313969f191cb 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -246,8 +246,7 @@ void OReportSection::Paste(const uno::Sequence< 
beans::NamedValue >& _aAllreadyC
                 rObject.Value >>= aCopies;
                 for (const uno::Reference<report::XReportComponent>& rCopy : 
std::as_const(aCopies))
                 {
-                    SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( rCopy );
-                    SdrObject* pObject = pShape ? pShape->GetSdrObject() : 
nullptr;
+                    SdrObject* pObject = SdrObject::getSdrObjectFromXShape( 
rCopy );
                     if ( pObject )
                     {
                         // Clone to target SdrModel
@@ -495,8 +494,7 @@ void 
OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_I
             uno::Reference< report::XReportComponent> 
xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
             awt::Point aPos = xReportComponent->getPosition();
             awt::Size aSize = xReportComponent->getSize();
-            SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xReportComponent );
-            SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
+            SdrObject* pObject = SdrObject::getSdrObjectFromXShape( 
xReportComponent );
             if ( pObject )
             {
                 bool bChanged = false;
diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx 
b/reportdesign/source/ui/report/ViewsWindow.cxx
index 2274e85ca529..4f7cc5be2d7e 100644
--- a/reportdesign/source/ui/report/ViewsWindow.cxx
+++ b/reportdesign/source/ui/report/ViewsWindow.cxx
@@ -613,8 +613,7 @@ void OViewsWindow::setMarked(const uno::Sequence< 
uno::Reference< report::XRepor
             OSectionWindow* pSectionWindow = getSectionWindow(xSection);
             if ( pSectionWindow )
             {
-                SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( rShape );
-                SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
+                SdrObject* pObject = SdrObject::getSdrObjectFromXShape( rShape 
);
                 OSL_ENSURE( pObject, "OViewsWindow::setMarked: no SdrObject 
for the shape!" );
                 if ( pObject )
                     
pSectionWindow->getReportSection().getSectionView().MarkObj( pObject, 
pSectionWindow->getReportSection().getSectionView().GetSdrPageView(), !_bMark );
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx 
b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 966204506256..1bfcd6064c00 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -137,15 +137,12 @@ void XMLTableShapeImportHelper::finishShape(
             }
             SetLayer(rShape, nLayerID, rShape->getShapeType());
 
-            if (SvxShape* pShapeImp = 
comphelper::getUnoTunnelImplementation<SvxShape>(rShape))
+            if (SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(rShape))
             {
-                if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
-                {
-                    if (!bOnTable)
-                        ScDrawLayer::SetCellAnchored(*pSdrObj, aAnchor);
-                    else
-                        ScDrawLayer::SetPageAnchored(*pSdrObj);
-                }
+                if (!bOnTable)
+                    ScDrawLayer::SetCellAnchored(*pSdrObj, aAnchor);
+                else
+                    ScDrawLayer::SetPageAnchored(*pSdrObj);
             }
 
             if (xRangeList)
@@ -193,9 +190,9 @@ void XMLTableShapeImportHelper::finishShape(
             // the group
             Point aStartPoint( rShape->getPosition().X,rShape->getPosition().Y 
);
             uno::Reference< drawing::XShape > xChild( rShapes, uno::UNO_QUERY 
);
-            if (SvxShape* pGroupShapeImp = xChild.is() ? 
comphelper::getUnoTunnelImplementation<SvxShape>(lcl_getTopLevelParent(xChild)) 
: nullptr)
+            if (xChild)
             {
-                if (SdrObject *pSdrObj = pGroupShapeImp->GetSdrObject())
+                if (SdrObject *pSdrObj = 
SdrObject::getSdrObjectFromXShape(lcl_getTopLevelParent(xChild)))
                 {
                     if ( ScDrawObjData* pAnchor = ScDrawLayer::GetObjData( 
pSdrObj ) )
                     {
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 0e07542dcbd4..9ff4d37195b5 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -536,11 +536,7 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, 
sal_Int32& nShapesCount)
 
             ++nShapesCount;
 
-            SvxShape* pShapeImp = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
-            if (!pShapeImp)
-                continue;
-
-            SdrObject* pSdrObj = pShapeImp->GetSdrObject();
+            SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(xShape);
             if (!pSdrObj)
                 continue;
 
@@ -2670,11 +2666,7 @@ void ScXMLExport::ExportMasterStyles_()
 void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > 
const & xShape )
 {
     // detective objects and notes
-    SvxShape* pShapeImp = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-    if( !pShapeImp )
-        return;
-
-    SdrObject* pObject = pShapeImp->GetSdrObject();
+    SdrObject* pObject = SdrObject::getSdrObjectFromXShape( xShape );
     if( !pObject )
         return;
 
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx 
b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index f5193c6a80a2..5ea1219d2616 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1122,15 +1122,12 @@ std::optional<ScAddress> 
ScChildrenShapes::GetAnchor(const uno::Reference<drawin
 {
     if (mpViewShell)
     {
-        SvxShape* pShapeImp = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
+        SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(xShape);
         uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
-        if (pShapeImp && xShapeProp.is())
+        if (pSdrObj && xShapeProp.is())
         {
-            if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
-            {
-                if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
-                    return std::optional<ScAddress>(pAnchor->maStart);
-            }
+            if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
+                return std::optional<ScAddress>(pAnchor->maStart);
         }
     }
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 0f0807c325f1..2bdcf14ab49c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1583,26 +1583,19 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& 
aSelection,
             //print a selected ole object
             // multi selection isn't supported yet
             uno::Reference< drawing::XShape > xShape( xShapes->getByIndex(0), 
uno::UNO_QUERY );
-            SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
-            if( pShape )
+            SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape );
+            if( pSdrObj && pDocShell )
             {
-                SdrObject *pSdrObj = pShape->GetSdrObject();
-                if( pDocShell )
-                {
-                    ScDocument& rDoc = pDocShell->GetDocument();
-                    if( pSdrObj )
-                    {
-                        tools::Rectangle aObjRect = 
pSdrObj->GetCurrentBoundRect();
-                        SCTAB nCurrentTab = ScDocShell::GetCurTab();
-                        ScRange aRange = rDoc.GetRange( nCurrentTab, aObjRect 
);
-                        rMark.SetMarkArea( aRange );
+                ScDocument& rDoc = pDocShell->GetDocument();
+                tools::Rectangle aObjRect = pSdrObj->GetCurrentBoundRect();
+                SCTAB nCurrentTab = ScDocShell::GetCurTab();
+                ScRange aRange = rDoc.GetRange( nCurrentTab, aObjRect );
+                rMark.SetMarkArea( aRange );
 
-                        if( rMark.IsMarked() && !rMark.IsMultiMarked() )
-                        {
-                            rStatus.SetMode( 
SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
-                            bDone = true;
-                        }
-                    }
+                if( rMark.IsMarked() && !rMark.IsMultiMarked() )
+                {
+                    rStatus.SetMode( 
SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
+                    bDone = true;
                 }
             }
         }
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index fa5bb8359334..6dbd130e2e56 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -1308,12 +1308,7 @@ uno::Sequence<sal_Int8> SAL_CALL 
ScShapeObj::getImplementationId()
 SdrObject* ScShapeObj::GetSdrObject() const throw()
 {
     if(mxShapeAgg.is())
-    {
-        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
mxShapeAgg );
-        if(pShape)
-            return pShape->GetSdrObject();
-    }
-
+        return SdrObject::getSdrObjectFromXShape( mxShapeAgg );
     return nullptr;
 }
 
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 957370396254..8f10ffc1e0e2 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -776,30 +776,26 @@ sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& 
aSelection )
                         uno::Reference<drawing::XShape> 
xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
                         if (xShapeInt.is())
                         {
-                            SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShapeInt );
-                            if (pShape)
+                            SdrObject* pObj = 
SdrObject::getSdrObjectFromXShape( xShapeInt );
+                            if (pObj)
                             {
-                                SdrObject *pObj = pShape->GetSdrObject();
-                                if (pObj)
+                                if (!bDrawSelModeSet && (pObj->GetLayer() == 
SC_LAYER_BACK))
                                 {
-                                    if (!bDrawSelModeSet && (pObj->GetLayer() 
== SC_LAYER_BACK))
-                                    {
-                                        pViewSh->SetDrawSelMode(true);
-                                        pViewSh->UpdateLayerLocks();
-                                        bDrawSelModeSet = true;
-                                    }
-                                    if (!pPV)               // first object
-                                    {
-                                        lcl_ShowObject( *pViewSh, *pDrawView, 
pObj );
-                                        pPV = pDrawView->GetSdrPageView();
-                                    }
-                                    if ( pPV && 
pObj->getSdrPageFromSdrObject() == pPV->GetPage() )
-                                    {
-                                        if (pDrawView->IsObjMarkable( pObj, 
pPV ))
-                                            pDrawView->MarkObj( pObj, pPV );
-                                        else
-                                            bAllMarked = false;
-                                    }
+                                    pViewSh->SetDrawSelMode(true);
+                                    pViewSh->UpdateLayerLocks();
+                                    bDrawSelModeSet = true;
+                                }
+                                if (!pPV)               // first object
+                                {
+                                    lcl_ShowObject( *pViewSh, *pDrawView, pObj 
);
+                                    pPV = pDrawView->GetSdrPageView();
+                                }
+                                if ( pPV && pObj->getSdrPageFromSdrObject() == 
pPV->GetPage() )
+                                {
+                                    if (pDrawView->IsObjMarkable( pObj, pPV ))
+                                        pDrawView->MarkObj( pObj, pPV );
+                                    else
+                                        bAllMarked = false;
                                 }
                             }
                         }
diff --git a/sc/source/ui/vba/vbasheetobject.cxx 
b/sc/source/ui/vba/vbasheetobject.cxx
index 6f54e00ddc06..400a1b88b47a 100644
--- a/sc/source/ui/vba/vbasheetobject.cxx
+++ b/sc/source/ui/vba/vbasheetobject.cxx
@@ -231,7 +231,7 @@ sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement()
 {
     sal_Int32 const nRet = excel::XlPlacement::xlMoveAndSize;
 #if 0 // TODO: not working at the moment.
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
mxShape );
+    SvxShape* pShape = SdrObject::getSdrObjectFromXShape( mxShape );
     if(pShape)
     {
         SdrObject* pObj = pShape->GetSdrObject();
@@ -249,7 +249,7 @@ sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement()
 void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ )
 {
 #if 0 // TODO: not working at the moment.
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
mxShape );
+    SvxShape* pShape = SdrObject::getSdrObjectFromXShape( mxShape );
     if(pShape)
     {
         SdrObject* pObj = pShape->GetSdrObject();
diff --git a/sd/source/ui/unoidl/SdUnoDrawView.cxx 
b/sd/source/ui/unoidl/SdUnoDrawView.cxx
index c880b0b4d1df..e66c572a70a9 100644
--- a/sd/source/ui/unoidl/SdUnoDrawView.cxx
+++ b/sd/source/ui/unoidl/SdUnoDrawView.cxx
@@ -159,10 +159,9 @@ sal_Bool SAL_CALL SdUnoDrawView::select( const Any& 
aSelection )
 
     if(xShape.is())
     {
-        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-        if( pShape && (pShape->GetSdrObject() != nullptr) )
+        SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
+        if( pObj )
         {
-            SdrObject* pObj = pShape->GetSdrObject();
             pSdrPage = pObj->getSdrPageFromSdrObject();
             aObjects.push_back( pObj );
         }
@@ -183,15 +182,13 @@ sal_Bool SAL_CALL SdUnoDrawView::select( const Any& 
aSelection )
                 xShapes->getByIndex(i) >>= xShape;
                 if( xShape.is() )
                 {
-                    SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
-                    if( (pShape == nullptr) || (pShape->GetSdrObject() == 
nullptr) )
+                    SdrObject* pObj = 
SdrObject::getSdrObjectFromXShape(xShape);
+                    if( !pObj )
                     {
                         bOk = false;
                         break;
                     }
 
-                    SdrObject* pObj = pShape->GetSdrObject();
-
                     if( pSdrPage == nullptr )
                     {
                         pSdrPage = pObj->getSdrPageFromSdrObject();
diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx
index 18e92d383038..dff010b3722e 100644
--- a/sd/source/ui/unoidl/unolayer.cxx
+++ b/sd/source/ui/unoidl/unolayer.cxx
@@ -483,8 +483,7 @@ void SAL_CALL SdLayerManager::attachShapeToLayer( const 
uno::Reference< drawing:
     if(pSdrLayer==nullptr)
         return;
 
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-    SdrObject* pSdrObject = pShape?pShape->GetSdrObject():nullptr;
+    SdrObject* pSdrObject = SdrObject::getSdrObjectFromXShape( xShape );
 
     if(pSdrObject)
         pSdrObject->SetLayer(pSdrLayer->GetID());
@@ -503,8 +502,7 @@ uno::Reference< drawing::XLayer > SAL_CALL 
SdLayerManager::getLayerForShape( con
 
     if(mpModel->mpDoc)
     {
-        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-        SdrObject* pObj = pShape?pShape->GetSdrObject():nullptr;
+        SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
         if(pObj)
         {
             SdrLayerID aId = pObj->GetLayer();
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 5ad1afb6c58e..230eeefeb420 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2174,21 +2174,16 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 
nRenderer, const uno::Any& r
 
                 if( xShape.is() )
                 {
-                    SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
-
-                    if( pShape )
+                    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( 
xShape );
+                    if( pObj && pObj->getSdrPageFromSdrObject()
+                        && aImplRenderPaintProc.IsVisible( pObj )
+                            && aImplRenderPaintProc.IsPrintable( pObj ) )
                     {
-                        SdrObject* pObj = pShape->GetSdrObject();
-                        if( pObj && pObj->getSdrPageFromSdrObject()
-                            && aImplRenderPaintProc.IsVisible( pObj )
-                                && aImplRenderPaintProc.IsPrintable( pObj ) )
-                        {
-                            if( !pPV )
-                                pPV = pView->ShowSdrPage( 
pObj->getSdrPageFromSdrObject() );
+                        if( !pPV )
+                            pPV = pView->ShowSdrPage( 
pObj->getSdrPageFromSdrObject() );
 
-                            if( pPV )
-                                pView->MarkObj( pObj, pPV );
-                        }
+                        if( pPV )
+                            pView->MarkObj( pObj, pPV );
                     }
                 }
             }
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 0e23d10c07c6..af642f7b1f36 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -2407,15 +2407,11 @@ void SAL_CALL SdDrawPage::remove( const Reference< 
drawing::XShape >& xShape )
 
     throwIfDisposed();
 
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-    if( pShape )
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
+    if( pObj )
     {
-        SdrObject* pObj = pShape->GetSdrObject();
-        if( pObj )
-        {
-            GetPage()->RemovePresObj(pObj);
-            pObj->SetUserCall(nullptr);
-        }
+        GetPage()->RemovePresObj(pObj);
+        pObj->SetUserCall(nullptr);
     }
 
     SdGenericDrawPage::remove( xShape );
@@ -3008,13 +3004,9 @@ void SAL_CALL SdMasterPage::remove( const Reference< 
drawing::XShape >& xShape )
 
     throwIfDisposed();
 
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-    if( pShape )
-    {
-        SdrObject* pObj = pShape->GetSdrObject();
-        if( pObj && GetPage()->IsPresObj( pObj ) )
-            GetPage()->RemovePresObj(pObj);
-    }
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
+    if( pObj && GetPage()->IsPresObj( pObj ) )
+        GetPage()->RemovePresObj(pObj);
 
     SdGenericDrawPage::remove( xShape );
 }
diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx 
b/slideshow/source/engine/slide/shapemanagerimpl.cxx
index 17f21926ac2f..73c7cda1ac02 100644
--- a/slideshow/source/engine/slide/shapemanagerimpl.cxx
+++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx
@@ -390,8 +390,7 @@ OUString ShapeManagerImpl::checkForImageMap( 
awt::MouseEvent const& evt ) const
     for (sal_Int32 i = 0; i < mxDrawPage->getCount(); i++)
     {
         Reference<XShape> xShape(mxDrawPage->getByIndex(i), UNO_QUERY_THROW);
-        SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
-        SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr;
+        SdrObject* pObj = SdrObject::getSdrObjectFromXShape(xShape);
         if (!pObj)
             continue;
         const IMapObject* pIMapObj = SvxIMapInfo::GetHitIMapObject(pObj, 
Point(evt.X, evt.Y));
diff --git a/slideshow/source/engine/slide/slideimpl.cxx 
b/slideshow/source/engine/slide/slideimpl.cxx
index 58b3203dfb74..f5f5d2a56861 100644
--- a/slideshow/source/engine/slide/slideimpl.cxx
+++ b/slideshow/source/engine/slide/slideimpl.cxx
@@ -396,8 +396,7 @@ void SlideImpl::prefetch()
     for (sal_Int32 i = 0; i < mxDrawPage->getCount(); i++)
     {
         com::sun::star::uno::Reference<com::sun::star::drawing::XShape> 
xShape(mxDrawPage->getByIndex(i), com::sun::star::uno::UNO_QUERY_THROW);
-        SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
-        SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr;
+        SdrObject* pObj = SdrObject::getSdrObjectFromXShape(xShape);
         if (!pObj)
             continue;
         if( SdrGrafObj* grafObj = dynamic_cast<SdrGrafObj*>(pObj))
diff --git a/svx/source/accessibility/ShapeTypeHandler.cxx 
b/svx/source/accessibility/ShapeTypeHandler.cxx
index 79aa5807f3a6..03ef0bf86bb6 100644
--- a/svx/source/accessibility/ShapeTypeHandler.cxx
+++ b/svx/source/accessibility/ShapeTypeHandler.cxx
@@ -268,9 +268,9 @@ OUString ShapeTypeHandler::CreateAccessibleBaseName (const 
uno::Reference<drawin
         case DRAWING_CUSTOM:
             pResourceId = STR_ObjNameSingulCUSTOMSHAPE;
 
-            if (SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(rxShape))
+            if (SdrObject* pSdrObject = 
SdrObject::getSdrObjectFromXShape(rxShape))
             {
-                if (auto pCustomShape = 
dynamic_cast<SdrObjCustomShape*>(pShape->GetSdrObject()))
+                if (auto pCustomShape = 
dynamic_cast<SdrObjCustomShape*>(pSdrObject))
                 {
                     if (pCustomShape->IsTextPath())
                         pResourceId = STR_ObjNameSingulFONTWORK;
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index d139fe2ab5c2..23fe9dabd1a6 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -288,40 +288,35 @@ void SAL_CALL SvxDrawPage::remove( const Reference< 
drawing::XShape >& xShape )
     if( (mpModel == nullptr) || (mpPage == nullptr) )
         throw lang::DisposedException();
 
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
+    if (!pObj)
+        return;
 
-    if (pShape)
+    // remove SdrObject from page
+    const size_t nCount = mpPage->GetObjCount();
+    for( size_t nNum = 0; nNum < nCount; ++nNum )
     {
-        SdrObject* pObj = pShape->GetSdrObject();
-        if (pObj)
+        if(mpPage->GetObj(nNum) == pObj)
         {
-            // remove SdrObject from page
-            const size_t nCount = mpPage->GetObjCount();
-            for( size_t nNum = 0; nNum < nCount; ++nNum )
-            {
-                if(mpPage->GetObj(nNum) == pObj)
-                {
-                    const bool bUndoEnabled = mpModel->IsUndoEnabled();
+            const bool bUndoEnabled = mpModel->IsUndoEnabled();
 
-                    if (bUndoEnabled)
-                    {
-                        mpModel->BegUndo(SvxResId(STR_EditDelete),
-                            pObj->TakeObjNameSingul(), SdrRepeatFunc::Delete);
+            if (bUndoEnabled)
+            {
+                mpModel->BegUndo(SvxResId(STR_EditDelete),
+                    pObj->TakeObjNameSingul(), SdrRepeatFunc::Delete);
 
-                        
mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
-                    }
+                
mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
+            }
 
-                    OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
+            OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
 
-                    if (!bUndoEnabled)
-                        SdrObject::Free(pObj);
+            if (!bUndoEnabled)
+                SdrObject::Free(pObj);
 
-                    if (bUndoEnabled)
-                        mpModel->EndUndo();
+            if (bUndoEnabled)
+                mpModel->EndUndo();
 
-                    break;
-                }
-            }
+            break;
         }
     }
 
@@ -386,11 +381,7 @@ namespace
 {
     void lcl_markSdrObjectOfShape( const Reference< drawing::XShape >& 
_rxShape, SdrView& _rView, SdrPageView& _rPageView )
     {
-        SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
_rxShape );
-        if ( !pShape )
-            return;
-
-        SdrObject* pObj = pShape->GetSdrObject();
+        SdrObject* pObj = SdrObject::getSdrObjectFromXShape( _rxShape );
         if ( !pObj )
             return;
 
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 1ff2d3e03e9d..2c4487b4cec6 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -224,11 +224,7 @@ void SAL_CALL SvxShapeGroup::remove( const uno::Reference< 
drawing::XShape >& xS
 {
     ::SolarMutexGuard aGuard;
 
-    SdrObject* pSdrShape = nullptr;
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
-
-    if( pShape )
-        pSdrShape = pShape->GetSdrObject();
+    SdrObject* pSdrShape = SdrObject::getSdrObjectFromXShape( xShape );
 
     if( !HasSdrObject() || pSdrShape == nullptr || 
pSdrShape->getParentSdrObjectFromSdrObject() != GetSdrObject() )
         throw uno::RuntimeException();
@@ -414,10 +410,10 @@ void SAL_CALL SvxShapeConnector::connectStart( const 
uno::Reference< drawing::XC
     ::SolarMutexGuard aGuard;
 
     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xRef 
);
+    SdrObject* pSdrObject = SdrObject::getSdrObjectFromXShape( xRef );
 
-    if( pShape )
-        GetSdrObject()->ConnectToNode( true, pShape->GetSdrObject() );
+    if( pSdrObject )
+        GetSdrObject()->ConnectToNode( true, pSdrObject );
 
     GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
@@ -428,10 +424,10 @@ void SAL_CALL SvxShapeConnector::connectEnd( const 
uno::Reference< drawing::XCon
     ::SolarMutexGuard aGuard;
 
     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xRef 
);
+    SdrObject* pSdrObject = SdrObject::getSdrObjectFromXShape( xRef );
 
-    if( HasSdrObject() && pShape )
-        GetSdrObject()->ConnectToNode( false, pShape->GetSdrObject() );
+    if( HasSdrObject() && pSdrObject )
+        GetSdrObject()->ConnectToNode( false, pSdrObject );
 
     GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx
index c7d415e38975..f2f29c21fc36 100644
--- a/svx/source/unodraw/unoshap3.cxx
+++ b/svx/source/unodraw/unoshap3.cxx
@@ -136,17 +136,12 @@ void SAL_CALL Svx3DSceneObject::remove( const Reference< 
drawing::XShape >& xSha
 {
     SolarMutexGuard aGuard;
 
-    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( 
xShape );
+    SdrObject* pSdrShape = SdrObject::getSdrObjectFromXShape( xShape );
 
-    if(!HasSdrObject() || pShape == nullptr)
+    if(!HasSdrObject() || !pSdrShape ||
+        pSdrShape->getParentSdrObjectFromSdrObject() != GetSdrObject())
         throw uno::RuntimeException();
 
-    SdrObject* pSdrShape = pShape->GetSdrObject();
-    if(pSdrShape == nullptr || pSdrShape->getParentSdrObjectFromSdrObject() != 
GetSdrObject())
-    {
-        throw uno::RuntimeException();
-    }
-
     SdrObjList& rList = *pSdrShape->getParentSdrObjListFromSdrObject();
 
     const size_t nObjCount = rList.GetObjCount();
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 087949787d89..781a62d78a81 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -923,9 +923,7 @@ SwXShape::SwXShape(
         m_xShapeAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
     osl_atomic_decrement(&m_refCount);
 
-    SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>(m_xShapeAgg);
-
-    SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr;
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape(m_xShapeAgg);
     if(pObj)
     {
         auto pFormat = ::FindFrameFormat( pObj );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to