diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 18 |
2 files changed, 19 insertions, 13 deletions
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 686485ff33e5..2eda7911a320 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -292,7 +292,8 @@ tools::Rectangle SwTextBoxHelper::getTextRectangle(SwFrameFormat* pShape, bool b { tools::Rectangle aRet; aRet.SetEmpty(); - auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->FindRealSdrObject()); + auto pSdrShape = pShape->FindRealSdrObject(); + auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pSdrShape); if (pCustomShape) { // Need to temporarily release the lock acquired in @@ -307,12 +308,17 @@ tools::Rectangle SwTextBoxHelper::getTextRectangle(SwFrameFormat* pShape, bool b if (nLocks) xLockable->setActionLocks(nLocks); } + else if (pSdrShape) + { + // fallback - get *any* bound rect we can possibly get hold of + aRet = pSdrShape->GetCurrentBoundRect(); + } - if (!bAbsolute && pCustomShape) + if (!bAbsolute && pSdrShape) { // Relative, so count the logic (reference) rectangle, see the EnhancedCustomShape2d ctor. - Point aPoint(pCustomShape->GetSnapRect().Center()); - Size aSize(pCustomShape->GetLogicRect().GetSize()); + Point aPoint(pSdrShape->GetSnapRect().Center()); + Size aSize(pSdrShape->GetLogicRect().GetSize()); aPoint.AdjustX(-(aSize.Width() / 2)); aPoint.AdjustY(-(aSize.Height() / 2)); tools::Rectangle aLogicRect(aPoint, aSize); diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 1235469996ec..9652f7914370 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -585,16 +585,16 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) )); } - if(!pShape || pShape->GetRegisteredIn() || !pShape->m_bDescriptor ) - { - uno::RuntimeException aExcept; - if(pShape) - aExcept.Message = "object already inserted"; - else - aExcept.Message = "illegal object"; - throw aExcept; - } + // this is not a writer shape + if(!pShape) + throw uno::RuntimeException("illegal object", + static_cast< cppu::OWeakObject * > ( this ) ); + + // we're already registered in the model / SwXDrawPage::add() already called + if(pShape->GetRegisteredIn() || !pShape->m_bDescriptor ) + return; + // we're inserted elsewhere already if ( pSvxShape->GetSdrObject() ) { if ( pSvxShape->GetSdrObject()->IsInserted() ) |