use more getSdrObjectFromXShape
Change-Id: Ia237643ab040425f231f781c86e7e060f0b53717
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110400
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
index 9d448b4..ced8421 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 da7461f..a1de2d0 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 670dfab..bf3c96e 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 e449680..c881441 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 24f47d6..d2c8567 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 38c5ddf..b4ce27e 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 077031c..8acb43d 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 128df5c..4c1fcba 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 5ea227f..313969f 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 2274e85..4f7cc5b 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 9662045..1bfcd60 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 0e07542..9ff4d37 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 f5193c6..5ea1219 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 0f0807c..2bdcf14 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 fa5bb83..6dbd130 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 9573703..8f10ffc 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 6f54e00..400a1b8 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 c880b0b..e66c572 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 18e92d3..dff010b 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 5ad1afb..230eeef 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 0e23d10..af642f7 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 17f2192..73c7cda 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 58b3203..f5f5d2a 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 79aa580..03ef0bf 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 d139fe2..23fe9da 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 )
const bool bUndoEnabled = mpModel->IsUndoEnabled();
if (bUndoEnabled)
{
if(mpPage->GetObj(nNum) == pObj)
{
const bool bUndoEnabled = mpModel->IsUndoEnabled();
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));
}
OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
if (!bUndoEnabled)
SdrObject::Free(pObj);
if (bUndoEnabled)
mpModel->EndUndo();
break;
}
mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
}
OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
if (!bUndoEnabled)
SdrObject::Free(pObj);
if (bUndoEnabled)
mpModel->EndUndo();
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 1ff2d3e..2c4487b 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 c7d415e..f2f29c2 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 0879497..781a62d 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 );