diff options
-rw-r--r-- | sot/inc/sot/factory.hxx | 1 | ||||
-rw-r--r-- | sot/inc/sot/object.hxx | 40 | ||||
-rw-r--r-- | sot/inc/sot/sotref.hxx | 8 | ||||
-rw-r--r-- | sot/source/base/factory.cxx | 39 | ||||
-rw-r--r-- | sot/source/base/object.cxx | 290 | ||||
-rw-r--r-- | svtools/source/hatchwindow/hatchwindow.cxx | 6 | ||||
-rw-r--r-- | svtools/source/hatchwindow/hatchwindowfactory.cxx | 2 | ||||
-rw-r--r-- | svtools/source/misc/embedhlp.cxx | 1 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 11 |
9 files changed, 28 insertions, 370 deletions
diff --git a/sot/inc/sot/factory.hxx b/sot/inc/sot/factory.hxx index 08dd21a88aa5..7b7feb0e9ebe 100644 --- a/sot/inc/sot/factory.hxx +++ b/sot/inc/sot/factory.hxx @@ -73,7 +73,6 @@ public: void PutSuperClass( const SotFactory * ); virtual void * CreateInstance( SotObject ** ppObj = NULL ) const; void * CastAndAddRef( SotObject * ) const; - void * AggCastAndAddRef( SotObject * ) const; BOOL Is( const SotFactory * pSuperClass ) const; const SotFactory * GetSuper( USHORT nPos ) const diff --git a/sot/inc/sot/object.hxx b/sot/inc/sot/object.hxx index db2ac3b30ffc..563c90d89a54 100644 --- a/sot/inc/sot/object.hxx +++ b/sot/inc/sot/object.hxx @@ -381,22 +381,17 @@ SotFactory * ClassName::pFactory = NULL; \ #pragma warning(disable: 4250) #endif -class SvAggregateMemberList; struct IUnknown; class SOT_DLLPUBLIC SotObject : virtual public SvRefBase { friend class SotFactory; friend class SvObject; - SvAggregateMemberList * pAggList; // fuer Aggregation, erstes ist das MainObj USHORT nStrongLockCount; USHORT nOwnerLockCount; BOOL bOwner:1, bSVObject:1, // Ist Proxy, dann TRUE wenn andere Seite SV ist bInClose:1; // TRUE, im DoClose - void * DownAggCast( const SotFactory * pFact ); - void RemoveInterface( ULONG ); - void RemoveInterface( SotObject * ); #if defined (GCC) && (defined (C281) || defined (C290) || defined (C291)) public: #else @@ -414,25 +409,10 @@ public: virtual IUnknown * GetInterface( const SvGlobalName & ); BOOL Owner() const { return bOwner; } - BOOL IsSvObject() const; - - // Methoden fuer die Aggregation (siehe OLE2-Spec) - BOOL ShouldDelete(); - virtual void QueryDelete(); - SvAggregateMemberList & GetAggList(); - void AddInterface( SotObject * ); - void AddInterface( SotFactory * ); - virtual SotObjectRef CreateAggObj( const SotFactory * ); - void * AggCast( const SotFactory * pFact ); - void * CastAndAddRef( const SotFactory * pFact ); - SotObject * GetMainObj() const; - - // !!! Read the Manual !!! - virtual USHORT FuzzyLock( BOOL bLock, BOOL bIntern, BOOL bClose ); - void Lock( BOOL bLock ) - { - FuzzyLock( bLock, TRUE, TRUE ); - } + + void* CastAndAddRef( const SotFactory * pFact ); + + USHORT Lock( BOOL bLock ); // affects nStrongLockCount USHORT GetOwnerLockCount() const { return nOwnerLockCount; } USHORT GetStrongLockCount() const { return nStrongLockCount; } @@ -450,18 +430,6 @@ private: //==================class SotObjectRef====================================== SV_IMPL_REF(SotObject) -inline SotObjectRef::SotObjectRef( SotObject * pObjP, SvCastEnum ) -{ - if( pObjP ) - { - pObj = (SotObject *)pObjP->AggCast( SotObject::ClassFactory() ); - if( pObj ) - pObj->AddRef(); - } - else - pObj = NULL; -} - //==================class SotObject*List==================================== SV_DECL_REF_LIST(SotObject,SotObject*) SV_IMPL_REF_LIST(SotObject,SotObject*) diff --git a/sot/inc/sot/sotref.hxx b/sot/inc/sot/sotref.hxx index ae03032e286e..a6728627ef2c 100644 --- a/sot/inc/sot/sotref.hxx +++ b/sot/inc/sot/sotref.hxx @@ -33,14 +33,12 @@ #endif //======================================================================== -enum SvCastEnum { SV_AGGREGATION_CAST }; #ifndef SVT_DECL_SOTOBJECT_DEFINED #define SVT_DECL_SOTOBJECT_DEFINED class SotObject; class SotObjectRef { PRV_SV_DECL_REF(SotObject) - inline SotObjectRef( SotObject * pObjP, SvCastEnum ); }; #endif @@ -52,7 +50,6 @@ class ClassName##Ref \ PRV_SV_DECL_REF(ClassName) \ inline ClassName##Ref( const SotObjectRef & ); \ inline ClassName##Ref( SotObject * pObjP ); \ - inline ClassName##Ref( SotObject * pObjP, SvCastEnum ); \ }; #define SO2_IMPL_REF(ClassName) \ @@ -64,12 +61,9 @@ inline ClassName##Ref::ClassName##Ref( const SotObjectRef & r ) \ inline ClassName##Ref::ClassName##Ref( SotObject * pObjP ) \ { \ pObj = (ClassName *)ClassName::ClassFactory()->CastAndAddRef( pObjP );\ -} \ -inline ClassName##Ref::ClassName##Ref( SotObject * pObjP, SvCastEnum ) \ -{ \ - pObj = (ClassName *)ClassName::ClassFactory()->AggCastAndAddRef( pObjP );\ } + #define SO2_DECL_IMPL_REF(ClassName) \ SO2_DECL_REF(ClassName) \ SO2_IMPL_REF(ClassName) diff --git a/sot/source/base/factory.cxx b/sot/source/base/factory.cxx index ca753265b082..3c034a980578 100644 --- a/sot/source/base/factory.cxx +++ b/sot/source/base/factory.cxx @@ -344,45 +344,6 @@ void * SotFactory::CastAndAddRef return pObj ? pObj->CastAndAddRef( this ) : NULL; } -//========================================================================= -void * SotFactory::AggCastAndAddRef -( - SotObject * pObj /* Das Objekt von dem der Typ gepr"uft wird. */ -) const -/* [Beschreibung] - - Ist eine Optimierung, damit die Ref-Klassen k"urzer implementiert - werden k"onnen. pObj wird auf den Typ der Factory gecastet. - In c++ (wenn es immer erlaubt w"are) w"urde der void * wie im - Beispiel gebildet. - Factory der Klasse SvPersist. - void * p = (void *)(SvPersist *)pObj; - Hinzu kommt noch, dass ein Objekt aus meheren c++ Objekten - zusammengesetzt sein kann. Diese Methode sucht nach einem - passenden Objekt. - - [R"uckgabewert] - - void *, NULL, pObj war NULL oder das Objekt war nicht vom Typ - der Factory. - Ansonsten wird pObj zuerst auf den Typ der Factory - gecastet und dann auf void *. - - [Querverweise] - - <SvObject::AggCast> -*/ -{ - void * pRet = NULL; - if( pObj ) - { - pRet = pObj->AggCast( this ); - if( pRet ) - pObj->AddRef(); - } - return pRet; -} - /************************************************************************* |* SotFactory::Is() |* diff --git a/sot/source/base/object.cxx b/sot/source/base/object.cxx index 9af1b441b37a..70792a325d31 100644 --- a/sot/source/base/object.cxx +++ b/sot/source/base/object.cxx @@ -35,10 +35,6 @@ #include <sot/factory.hxx> #include <sot/agg.hxx> -/************** class SvAggregateMemberList *****************************/ -/************************************************************************/ -PRV_SV_IMPL_OWNER_LIST(SvAggregateMemberList,SvAggregate); - /************** class SotObject ******************************************/ class SotObjectFactory : public SotFactory { @@ -84,8 +80,7 @@ void SotObject::TestMemberInvariant( BOOL /*bPrint*/ ) |* Beschreibung *************************************************************************/ SotObject::SotObject() - : pAggList ( NULL ) - , nStrongLockCount( 0 ) + : nStrongLockCount( 0 ) , nOwnerLockCount( 0 ) , bOwner ( TRUE ) , bSVObject ( FALSE ) @@ -119,246 +114,11 @@ IUnknown * SotObject::GetInterface( const SvGlobalName & ) } /************************************************************************* -|* SotObject::IsSvClass() -|* -|* Beschreibung -*************************************************************************/ -BOOL SotObject::IsSvObject() const -{ - return Owner() || bSVObject; -} - -/************************************************************************* -|* SotObject::QueryDelete() -|* -|* Beschreibung: Bei allen aggregierten Objekte muss der RefCount auf -|* 0 gehen, damit das Gesammt-Objekt zerstoert wird. Das -|* zerst�ren von Teilen ist verboten. Da der Aggregator -|* (oder Cast-Verwalter) den Zaehler der aggregierten -|* Objekte um 1 erhoeht, muss dies bei der Berechnung -|* des 0-RefCounts beruecksichtigt werden. -*************************************************************************/ -BOOL SotObject::ShouldDelete() -{ - if( !pAggList ) - return TRUE; - - SvAggregate & rMO = pAggList->GetObject( 0 ); - if( rMO.bMainObj ) - { - AddRef(); - pAggList->GetObject( 0 ).pObj->ReleaseRef(); - return FALSE; - } - - ULONG i; - for( i = 1; i < pAggList->Count(); i++ ) - { - SvAggregate & rAgg = pAggList->GetObject( i ); - // Groesser 1, wegen AddRef() bei AddInterface - if( !rAgg.bFactory && rAgg.pObj->GetRefCount() > 1 ) - { - // den eigenen hochzaehelen - AddRef(); - // einen Aggregierten runterzaehlen - rAgg.pObj->ReleaseRef(); - return FALSE; - } - } - AddNextRef(); // rekursion stoppen - for( i = pAggList->Count() -1; i > 0; i-- ) - { - // Referenzen aufloesen - DBG_ASSERT( !pAggList->GetObject( i ).bMainObj, "main object reference is opened" ); - RemoveInterface( i ); - } - delete pAggList; - pAggList = NULL; - // und zerstoeren, dies ist unabhaengig vom RefCount - return TRUE; -} - -/************************************************************************* -|* SotObject::QueryDelete() -|* -|* Beschreibung -*************************************************************************/ -void SotObject::QueryDelete() -{ - if( ShouldDelete() ) - SvRefBase::QueryDelete(); -} - - - -/************************************************************************* -|* SotObject::GetAggList() -|* -|* Beschreibung -*************************************************************************/ -SvAggregateMemberList & SotObject::GetAggList() -{ - if( !pAggList ) - { - pAggList = new SvAggregateMemberList( 2, 1 ); - pAggList->Append( SvAggregate() ); - } - return *pAggList; -} - - -/************************************************************************* -|* SotObject::RemoveInterface() -|* -|* Beschreibung -*************************************************************************/ -void SotObject::RemoveInterface( ULONG nPos ) -{ - SvAggregate & rAgg = pAggList->GetObject( nPos ); - if( !rAgg.bFactory ) - { - DBG_ASSERT( rAgg.pObj->pAggList, "no aggregation list" ); - DBG_ASSERT( rAgg.pObj->pAggList->GetObject( 0 ).pObj == this, - "not owner of aggregated object" ); - // sich selbst als Cast-Verwalter austragen - rAgg.pObj->pAggList->GetObject( 0 ) = SvAggregate(); - // Referenz aufloesen - rAgg.pObj->ReleaseRef(); - // Aus der eigenen List austragen - pAggList->Remove( nPos ); - } -} - -/************************************************************************* -|* SotObject::RemoveInterface() -|* -|* Beschreibung -*************************************************************************/ -void SotObject::RemoveInterface( SotObject * pObjP ) -{ - DBG_ASSERT( pObjP, "null pointer" ); - DBG_ASSERT( pAggList, "no aggregation list" ); - ULONG i; - for( i = 0; i < pAggList->Count(); i++ ) - { - SvAggregate & rAgg = pAggList->GetObject( i ); - if( !rAgg.bFactory && pObjP == rAgg.pObj ) - RemoveInterface( i ); - } - DBG_ASSERT( i < pAggList->Count(), "object not found" ); -} - -/************************************************************************* -|* SotObject::AddInterface() -|* -|* Beschreibung -*************************************************************************/ -void SotObject::AddInterface( SotObject * pObjP ) -{ - pObjP->AddRef(); // Objekt festhalten - GetAggList(); - pAggList->Append( SvAggregate( pObjP, FALSE ) ); - - // sich selbst als Typecast-Verwalter eintragen - SvAggregateMemberList & rAList = pObjP->GetAggList(); - DBG_ASSERT( !rAList.GetObject( 0 ).bMainObj, "try to aggregate twice" ); - rAList[ 0 ] = SvAggregate( this, TRUE ); -} - -/************************************************************************* -|* SotObject::AddInterface() -|* -|* Beschreibung -*************************************************************************/ -void SotObject::AddInterface( SotFactory * pFactP ) -{ - GetAggList(); - pAggList->Append( SvAggregate( pFactP ) ); -} - -/************************************************************************* -|* SotObject::CreateAggObj() -|* -|* Beschreibung -*************************************************************************/ -SotObjectRef SotObject::CreateAggObj( const SotFactory * ) -{ - return SotObjectRef(); -} - - -/************************************************************************* -|* SotObject::DownAggCast() -|* -|* Beschreibung -*************************************************************************/ -void * SotObject::DownAggCast( const SotFactory * pFact ) -{ - void * pCast = NULL; - // geht den Pfad nur Richtung aggregierte Objekte - if( pAggList ) - { - for( ULONG i = 1; !pCast || i < pAggList->Count(); i++ ) - { - SvAggregate & rAgg = pAggList->GetObject( i ); - if( rAgg.bFactory ) - { - if( rAgg.pFact->Is( pFact ) ) - { - // On-Demand erzeugen, wenn Typ gebraucht - SotObjectRef aObj( CreateAggObj( rAgg.pFact ) ); - rAgg.bFactory = FALSE; - rAgg.pObj = aObj; - rAgg.pObj->AddRef(); - - // sich selbst als Typecast-Verwalter eintragen - SvAggregateMemberList & rAList = rAgg.pObj->GetAggList(); - DBG_ASSERT( !rAList.GetObject( 0 ).bMainObj, "try to aggregate twice" ); - rAList[ 0 ] = SvAggregate( this, TRUE ); - } - } - if( !rAgg.bFactory ) - { - // muss der (void *) auf Klasse pFact sein - pCast = rAgg.pObj->Cast( pFact ); - if( !pCast ) - pCast = rAgg.pObj->DownAggCast( pFact ); - if( pCast ) - break; - } - } - } - return pCast; -} - -/************************************************************************* -|* SotObject::AggCast() -|* -|* Beschreibung -*************************************************************************/ -void * SotObject::AggCast( const SotFactory * pFact ) -{ - void * pCast = NULL; - if( pAggList ) - { - SvAggregate & rAgg = pAggList->GetObject( 0 ); - if( rAgg.bMainObj ) - return rAgg.pObj->AggCast( pFact ); - pCast = Cast( pFact ); - if( !pCast ) - pCast = DownAggCast( pFact ); - } - else - pCast = Cast( pFact ); - return pCast; -} - -/************************************************************************* |* SotObject::CastAndAddRef() |* |* Beschreibung *************************************************************************/ -void * SotObject::CastAndAddRef( const SotFactory * pFact ) +void* SotObject::CastAndAddRef( const SotFactory * pFact ) { void * pCast = Cast( pFact ); if( pCast ) @@ -366,49 +126,8 @@ void * SotObject::CastAndAddRef( const SotFactory * pFact ) return pCast; } -/************************************************************************* -|* SotObject::GetMainObj() -|* -|* Beschreibung -*************************************************************************/ -SotObject * SotObject::GetMainObj() const -{ - if( pAggList ) - { - if( pAggList->GetObject( 0 ).bMainObj ) - return pAggList->GetObject( 0 ).pObj->GetMainObj(); - } - return (SotObject *)this; -} - //========================================================================= -USHORT SotObject::FuzzyLock -( - BOOL bLock, /* TRUE, lock. FALSE, unlock. */ - BOOL /*bIntern*/, /* TRUE, es handelt sich um einen internen Lock. - FALSE, der Lock kam von aussen (Ole2, Ipc2) */ - BOOL bClose /* TRUE, Close aufrufen wenn letzte Lock */ -) -/* [Beschreibung] - - Erlaubte Parameterkombinationen: - ( TRUE, TRUE, * ) -> interner Lock. - ( FALSE, TRUE, TRUE ) -> interner Unlock mit Close, - wenn LockCount() == 0 - ( TRUE, FALSE, * ) -> externer Lock. - ( FALSE, FALSE, TRUE ) -> externer Unlock mit Close, - wenn LockCount() == 0 - ( FALSE, FALSE, FALSE ) -> externer Unlock - - F"ur !Owner() wird der Aufruf an das externe Objekt weitergeleitet. - F"ur diese muss das <IOleItemContainer>-Interface zur Vef"ugung stehen. - bIntern und bClose werden dann ignoriert. - Wenn der LockCount auf 0 wechselt, wird <SotObject::DoClose> - gerufen, wenn kein OwnerLock besteht. - - [Anmerkung] - -*/ +USHORT SotObject::Lock( BOOL bLock ) { SotObjectRef xHoldAlive( this ); USHORT nRet; @@ -423,8 +142,9 @@ USHORT SotObject::FuzzyLock ReleaseRef(); } - if( !nRet && bClose && !nOwnerLockCount ) + if( !nRet && !nOwnerLockCount ) DoClose(); + return nRet; } diff --git a/svtools/source/hatchwindow/hatchwindow.cxx b/svtools/source/hatchwindow/hatchwindow.cxx index 1b84206d6696..b26f7bbf091b 100644 --- a/svtools/source/hatchwindow/hatchwindow.cxx +++ b/svtools/source/hatchwindow/hatchwindow.cxx @@ -33,6 +33,8 @@ #include "ipwin.hxx" #include <toolkit/helper/convert.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> using namespace ::com::sun::star; @@ -50,6 +52,8 @@ void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer > const awt::Rectangle& aBounds, const awt::Size& aSize ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + Window* pParent = NULL; VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent ); @@ -117,7 +121,7 @@ uno::Any SAL_CALL VCLXHatchWindow::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException ) { // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. + // Don't use mutex or guard in this method!!! Is a method of XInterface. uno::Any aReturn( ::cppu::queryInterface( rType, static_cast< embed::XHatchWindow* >( this ) ) ); diff --git a/svtools/source/hatchwindow/hatchwindowfactory.cxx b/svtools/source/hatchwindow/hatchwindowfactory.cxx index 0eec027167c2..1222013372f7 100644 --- a/svtools/source/hatchwindow/hatchwindowfactory.cxx +++ b/svtools/source/hatchwindow/hatchwindowfactory.cxx @@ -31,6 +31,7 @@ #include "hatchwindowfactory.hxx" #include "hatchwindow.hxx" #include "cppuhelper/factory.hxx" +#include <vcl/svapp.hxx> #include "documentcloser.hxx" @@ -69,6 +70,7 @@ uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchW if ( !xParent.is() ) throw lang::IllegalArgumentException(); // TODO + ::vos::OGuard aGuard( Application::GetSolarMutex() ); VCLXHatchWindow* pResult = new VCLXHatchWindow(); pResult->initializeWindow( xParent, aBounds, aHandlerSize ); return uno::Reference< embed::XHatchWindow >( static_cast< embed::XHatchWindow* >( pResult ) ); diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 3aa0016c225e..a96067f95186 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -343,6 +343,7 @@ void EmbeddedObjectRef::Assign( const NS_UNO::Reference < NS_EMBED::XEmbeddedObj mpImp->xListener = EmbedEventListener_Impl::Create( this ); //#i103460# + if ( IsChart() ) { ::com::sun::star::uno::Reference < ::com::sun::star::chart2::XDefaultSizeTransmitter > xSizeTransmitter( xObj, uno::UNO_QUERY ); DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" ); diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index f21855d20aed..9f4c39b397e1 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -1538,7 +1538,16 @@ ErrCode UcbLockBytes::Flush() const Reference <XOutputStream > xOutputStream = getOutputStream_Impl(); if ( !xOutputStream.is() ) return ERRCODE_IO_CANTWRITE; - xOutputStream->flush(); + + try + { + xOutputStream->flush(); + } + catch( Exception ) + { + return ERRCODE_IO_CANTWRITE; + } + return ERRCODE_NONE; } |