View | Details | Raw Unified | Return to issue 61771
Collapse All | Expand All

(-)inc/svdobj.hxx (-8 / +5 lines)
Lines 141-146 Link Here
141
class SfxPoolItem;
141
class SfxPoolItem;
142
class SdrLineGeometry;
142
class SdrLineGeometry;
143
class SdrVirtObj;
143
class SdrVirtObj;
144
class SvxShape;
144
145
145
namespace sdr
146
namespace sdr
146
{
147
{
Lines 665-672 Link Here
665
	// ueberladen, wenn man sich von SdrObjPlusData abgeleitet hat:
666
	// ueberladen, wenn man sich von SdrObjPlusData abgeleitet hat:
666
	virtual SdrObjPlusData* NewPlusData() const;
667
	virtual SdrObjPlusData* NewPlusData() const;
667
668
668
	// this is a weak reference to a possible living api wrapper for this shape
669
	// this is a direct pointer to a possible living api wrapper for this shape
669
	::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > mxUnoShape;
670
    SvxShape* mpUnoShape;
670
671
671
protected:
672
protected:
672
	// Diese 3 Methoden muss ein abgeleitetes Objekt ueberladen, wenn es eigene
673
	// Diese 3 Methoden muss ein abgeleitetes Objekt ueberladen, wenn es eigene
Lines 1291-1297 Link Here
1291
	////////////////////////////////////////////////////////////////////////////////////////////////////
1292
	////////////////////////////////////////////////////////////////////////////////////////////////////
1292
	// access to the UNO representation of the shape
1293
	// access to the UNO representation of the shape
1293
	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
1294
	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
1294
	::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > getWeakUnoShape() { return mxUnoShape; }
1295
1295
1296
	// helper struct for granting access exclusive to SvxShape
1296
	// helper struct for granting access exclusive to SvxShape
1297
	struct GrantXShapeAccess
1297
	struct GrantXShapeAccess
Lines 1302-1313 Link Here
1302
	};
1302
	};
1303
1303
1304
	// setting the UNO representation is allowed for the UNO representation itself only!
1304
	// setting the UNO representation is allowed for the UNO representation itself only!
1305
	void setUnoShape(
1305
	void setUnoShape( SvxShape* _pUnoShape, GrantXShapeAccess aGrant )
1306
		const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape,
1307
		GrantXShapeAccess aGrant
1308
	)
1309
	{
1306
	{
1310
		mxUnoShape = _rxUnoShape;
1307
		mpUnoShape = _pUnoShape;
1311
	}
1308
	}
1312
1309
1313
	////////////////////////////////////////////////////////////////////////////////////////////////////
1310
	////////////////////////////////////////////////////////////////////////////////////////////////////
(-)source/svdraw/svdobj.cxx (-37 / +42 lines)
Lines 495-503 Link Here
495
	nLayerId(0),
495
	nLayerId(0),
496
	mpProperties(0L),
496
	mpProperties(0L),
497
	// #110094#
497
	// #110094#
498
	mpViewContact(0L)
498
	mpViewContact(0L),
499
    mpUnoShape( NULL )
499
{
500
{
500
	DBG_CTOR(SdrObject,NULL);
501
    DBG_CTOR(SdrObject,NULL);
501
	bVirtObj         =FALSE;
502
	bVirtObj         =FALSE;
502
	bBoundRectDirty  =TRUE;
503
	bBoundRectDirty  =TRUE;
503
	bSnapRectDirty   =TRUE;
504
	bSnapRectDirty   =TRUE;
Lines 531-536 Link Here
531
532
532
SdrObject::~SdrObject()
533
SdrObject::~SdrObject()
533
{
534
{
535
    DBG_TESTSOLARMUTEX();
536
534
	// tell all the registered ObjectUsers that the page is in destruction
537
	// tell all the registered ObjectUsers that the page is in destruction
535
	for(::sdr::ObjectUserVector::iterator aIterator = maObjectUsers.begin(); aIterator != maObjectUsers.end(); aIterator++)
538
	for(::sdr::ObjectUserVector::iterator aIterator = maObjectUsers.begin(); aIterator != maObjectUsers.end(); aIterator++)
536
	{
539
	{
Lines 543-551 Link Here
543
	// when they get called from ObjectInDestruction().
546
	// when they get called from ObjectInDestruction().
544
	maObjectUsers.clear();
547
	maObjectUsers.clear();
545
548
546
	uno::Reference< lang::XComponent > xShape( mxUnoShape, uno::UNO_QUERY );
549
    if ( mpUnoShape )
547
	if( xShape.is() )
550
    {
548
		xShape->dispose();
551
        mpUnoShape->dispose();
552
        mpUnoShape = NULL;
553
    }
549
554
550
	DBG_DTOR(SdrObject,NULL);
555
	DBG_DTOR(SdrObject,NULL);
551
	SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
556
	SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
Lines 595-607 Link Here
595
	// update listeners at possible api wrapper object
600
	// update listeners at possible api wrapper object
596
	if( pModel != pNewModel )
601
	if( pModel != pNewModel )
597
	{
602
	{
598
		uno::Reference< uno::XInterface > xShape( mxUnoShape );
603
        DBG_TESTSOLARMUTEX();
599
		if( xShape.is() )
604
        if ( mpUnoShape )
600
		{
605
			mpUnoShape->ChangeModel( pNewModel );
601
			SvxShape* pShape = SvxShape::getImplementation( xShape );
602
			if( pShape )
603
				pShape->ChangeModel( pNewModel );
604
		}
605
	}
606
	}
606
607
607
	pModel = pNewModel;
608
	pModel = pNewModel;
Lines 3770-3800 Link Here
3770
3771
3771
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
3772
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
3772
{
3773
{
3773
	// try weak reference first
3774
    DBG_TESTSOLARMUTEX();
3774
	uno::Reference< uno::XInterface > xShape( mxUnoShape );
3775
3775
	if( !xShape.is() )
3776
    uno::Reference< uno::XInterface > xShape;
3776
	{
3777
3777
		if ( pPage )
3778
    // try weak reference first
3778
		{
3779
    if ( mpUnoShape )
3779
			uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
3780
        xShape = xShape.query( *mpUnoShape );
3780
			if( xPage.is() )
3781
    else
3781
			{
3782
    {
3782
				SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
3783
        if ( pPage )
3783
				if( pDrawPage )
3784
	    {
3784
				{
3785
		    uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
3785
					// create one
3786
		    if( xPage.is() )
3786
					xShape = pDrawPage->_CreateShape( this );
3787
		    {
3787
					mxUnoShape = xShape;
3788
			    SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
3788
				}
3789
			    if( pDrawPage )
3789
			}
3790
				    // create one
3790
		}
3791
				    xShape = pDrawPage->_CreateShape( this );
3791
		else
3792
		    }
3792
		{
3793
	    }
3793
			uno::Reference< drawing::XShape > xS( SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL ) );
3794
	    else
3794
			xShape = xS;
3795
	    {
3795
			mxUnoShape = xShape;
3796
		    uno::Reference< drawing::XShape > xS( SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL ) );
3796
		}
3797
		    xShape = xS;
3797
	}
3798
	    }
3799
        mpUnoShape = SvxShape::getImplementation( xShape );
3800
        DBG_ASSERT( ( mpUnoShape != NULL ) || ( !xShape.is() ),
3801
            "SdrObject::getUnoShape: invalid SvxShape!" );
3802
    }
3798
3803
3799
	return xShape;
3804
	return xShape;
3800
}
3805
}
(-)source/unodraw/unoshape.cxx (-22 / +35 lines)
Lines 330-335 Link Here
330
	if( pModel )
330
	if( pModel )
331
		EndListening( *pModel );
331
		EndListening( *pModel );
332
332
333
    if ( pObj )
334
    {
335
	    pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
336
        pObj = NULL;
337
    }
338
333
	if( mpImpl )
339
	if( mpImpl )
334
	{
340
	{
335
		if(mpImpl->mpMaster)
341
		if(mpImpl->mpMaster)
Lines 443-449 Link Here
443
449
444
void SvxShape::Init() throw()
450
void SvxShape::Init() throw()
445
{
451
{
446
	if( NULL == mpImpl )
452
    DBG_TESTSOLARMUTEX();
453
454
    if( NULL == mpImpl )
447
	{
455
	{
448
		mpImpl = new SvxShapeImpl;
456
		mpImpl = new SvxShapeImpl;
449
		mpImpl->mpItemSet = NULL;
457
		mpImpl->mpItemSet = NULL;
Lines 463-473 Link Here
463
	if(pObj == NULL)
471
	if(pObj == NULL)
464
		return;
472
		return;
465
473
466
	osl_incrementInterlockedCount( &m_refCount );
474
	pObj->setUnoShape( this, SdrObject::GrantXShapeAccess() );
467
	{
468
		pObj->setUnoShape( *this, SdrObject::GrantXShapeAccess() );
469
	}
470
	osl_decrementInterlockedCount( &m_refCount );
471
475
472
	pModel = pObj->GetModel();
476
	pModel = pObj->GetModel();
473
477
Lines 529-534 Link Here
529
			EndListening( *pObj->GetModel() );
533
			EndListening( *pObj->GetModel() );
530
		}
534
		}
531
535
536
        if ( pObj )
537
            pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
532
		pObj = pNewObj;
538
		pObj = pNewObj;
533
539
534
		Init();
540
		Init();
Lines 1074-1080 Link Here
1074
		(pSdrHint->GetKind() != HINT_OBJCHG)))
1080
		(pSdrHint->GetKind() != HINT_OBJCHG)))
1075
        return;
1081
        return;
1076
1082
1077
	uno::Reference< uno::XInterface > xSelf( pObj->getWeakUnoShape() );
1083
	uno::Reference< uno::XInterface > xSelf( pObj->getUnoShape() );
1078
	if( !xSelf.is() )
1084
	if( !xSelf.is() )
1079
	{
1085
	{
1080
		pObj = NULL;
1086
		pObj = NULL;
Lines 1123-1128 Link Here
1123
1129
1124
	if( bClearMe )
1130
	if( bClearMe )
1125
	{
1131
	{
1132
        if ( pObj )
1133
	        pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
1126
		pObj = NULL;
1134
		pObj = NULL;
1127
		if(!bDisposing)
1135
		if(!bDisposing)
1128
			dispose();
1136
			dispose();
Lines 1360-1380 Link Here
1360
	aDisposeListeners.disposeAndClear(aEvt);
1368
	aDisposeListeners.disposeAndClear(aEvt);
1361
1369
1362
	SdrObject* pObj = GetSdrObject();
1370
	SdrObject* pObj = GetSdrObject();
1363
	if(pObj && pObj->IsInserted() && pObj->GetPage() )
1371
    if ( pObj )
1364
	{
1372
    {
1365
		SdrPage* pPage = pObj->GetPage();
1373
	    pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
1366
		// SdrObject aus der Page loeschen
1374
	    if ( pObj->IsInserted() && pObj->GetPage() )
1367
		sal_uInt32 nCount = pPage->GetObjCount();
1375
	    {
1368
		for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ )
1376
		    SdrPage* pPage = pObj->GetPage();
1369
		{
1377
		    // SdrObject aus der Page loeschen
1370
			if(pPage->GetObj(nNum) == pObj)
1378
		    sal_uInt32 nCount = pPage->GetObjCount();
1371
			{
1379
		    for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ )
1372
				delete pPage->RemoveObject(nNum);
1380
		    {
1373
				InvalidateSdrObject();
1381
			    if(pPage->GetObj(nNum) == pObj)
1374
				break;
1382
			    {
1375
			}
1383
				    delete pPage->RemoveObject(nNum);
1376
		}
1384
				    InvalidateSdrObject();
1377
	}
1385
				    break;
1386
			    }
1387
		    }
1388
	    }
1389
        this->pObj = NULL;
1390
    }
1378
1391
1379
	if( pModel )
1392
	if( pModel )
1380
	{
1393
	{

Return to issue 61771