1*046d9d1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*046d9d1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*046d9d1fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*046d9d1fSAndrew Rist * distributed with this work for additional information
6*046d9d1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*046d9d1fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*046d9d1fSAndrew Rist * "License"); you may not use this file except in compliance
9*046d9d1fSAndrew Rist * with the License. You may obtain a copy of the License at
10*046d9d1fSAndrew Rist *
11*046d9d1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*046d9d1fSAndrew Rist *
13*046d9d1fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*046d9d1fSAndrew Rist * software distributed under the License is distributed on an
15*046d9d1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*046d9d1fSAndrew Rist * KIND, either express or implied. See the License for the
17*046d9d1fSAndrew Rist * specific language governing permissions and limitations
18*046d9d1fSAndrew Rist * under the License.
19*046d9d1fSAndrew Rist *
20*046d9d1fSAndrew Rist *************************************************************/
21*046d9d1fSAndrew Rist
22*046d9d1fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sot.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #define _SOT_OBJECT_CXX
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <sot/object.hxx>
31cdf0e10cSrcweir #include <sot/factory.hxx>
32cdf0e10cSrcweir #include <sot/agg.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir /************** class SotObject ******************************************/
35cdf0e10cSrcweir class SotObjectFactory : public SotFactory
36cdf0e10cSrcweir {
37cdf0e10cSrcweir public:
38cdf0e10cSrcweir TYPEINFO();
SotObjectFactory(const SvGlobalName & rName,const String & rClassName,CreateInstanceType pCreateFuncP)39cdf0e10cSrcweir SotObjectFactory( const SvGlobalName & rName,
40cdf0e10cSrcweir const String & rClassName,
41cdf0e10cSrcweir CreateInstanceType pCreateFuncP )
42cdf0e10cSrcweir : SotFactory( rName, rClassName, pCreateFuncP )
43cdf0e10cSrcweir {}
44cdf0e10cSrcweir };
45cdf0e10cSrcweir TYPEINIT1(SotObjectFactory,SotFactory);
46cdf0e10cSrcweir
47cdf0e10cSrcweir
48cdf0e10cSrcweir SO2_IMPL_BASIC_CLASS_DLL(SotObject,SotObjectFactory,
49cdf0e10cSrcweir SvGlobalName( 0xf44b7830, 0xf83c, 0x11d0,
50cdf0e10cSrcweir 0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ) )
SO2_IMPL_INVARIANT(SotObject)51cdf0e10cSrcweir SO2_IMPL_INVARIANT(SotObject)
52cdf0e10cSrcweir
53cdf0e10cSrcweir /*************************************************************************
54cdf0e10cSrcweir |* SotObject::TestMemberObjRef()
55cdf0e10cSrcweir |*
56cdf0e10cSrcweir |* Beschreibung:
57cdf0e10cSrcweir *************************************************************************/
58cdf0e10cSrcweir void SotObject::TestMemberObjRef( sal_Bool /*bFree*/ )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir /*************************************************************************
63cdf0e10cSrcweir |* SotObject::TestMemberObjRef()
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir |* Beschreibung:
66cdf0e10cSrcweir *************************************************************************/
67cdf0e10cSrcweir #ifdef TEST_INVARIANT
TestMemberInvariant(sal_Bool)68cdf0e10cSrcweir void SotObject::TestMemberInvariant( sal_Bool /*bPrint*/ )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir }
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir
73cdf0e10cSrcweir /*************************************************************************
74cdf0e10cSrcweir |* SotObject::SotObject()
75cdf0e10cSrcweir |*
76cdf0e10cSrcweir |* Beschreibung
77cdf0e10cSrcweir *************************************************************************/
SotObject()78cdf0e10cSrcweir SotObject::SotObject()
79cdf0e10cSrcweir : nStrongLockCount( 0 )
80cdf0e10cSrcweir , nOwnerLockCount( 0 )
81cdf0e10cSrcweir , bOwner ( sal_True )
82cdf0e10cSrcweir , bSVObject ( sal_False )
83cdf0e10cSrcweir , bInClose ( sal_False )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir SotFactory::IncSvObjectCount( this );
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir /*************************************************************************
89cdf0e10cSrcweir |*
90cdf0e10cSrcweir |* SotObject::~SotObject()
91cdf0e10cSrcweir |*
92cdf0e10cSrcweir |* Beschreibung
93cdf0e10cSrcweir |* Ersterstellung MM 05.06.94
94cdf0e10cSrcweir |* Letzte Aenderung MM 05.06.94
95cdf0e10cSrcweir |*
96cdf0e10cSrcweir *************************************************************************/
~SotObject()97cdf0e10cSrcweir SotObject::~SotObject()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir SotFactory::DecSvObjectCount( this );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir /*************************************************************************
103cdf0e10cSrcweir |* SotObject::GetInterface()
104cdf0e10cSrcweir |*
105cdf0e10cSrcweir |* Beschreibung: Um so3 zu helfen
106cdf0e10cSrcweir *************************************************************************/
GetInterface(const SvGlobalName &)107cdf0e10cSrcweir IUnknown * SotObject::GetInterface( const SvGlobalName & )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir return NULL;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
112cdf0e10cSrcweir /*************************************************************************
113cdf0e10cSrcweir |* SotObject::CastAndAddRef()
114cdf0e10cSrcweir |*
115cdf0e10cSrcweir |* Beschreibung
116cdf0e10cSrcweir *************************************************************************/
CastAndAddRef(const SotFactory * pFact)117cdf0e10cSrcweir void* SotObject::CastAndAddRef( const SotFactory * pFact )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir void * pCast = Cast( pFact );
120cdf0e10cSrcweir if( pCast )
121cdf0e10cSrcweir AddRef();
122cdf0e10cSrcweir return pCast;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir //=========================================================================
Lock(sal_Bool bLock)126cdf0e10cSrcweir sal_uInt16 SotObject::Lock( sal_Bool bLock )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir SotObjectRef xHoldAlive( this );
129cdf0e10cSrcweir sal_uInt16 nRet;
130cdf0e10cSrcweir if( bLock )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir AddRef();
133cdf0e10cSrcweir nRet = ++nStrongLockCount;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir else
136cdf0e10cSrcweir {
137cdf0e10cSrcweir nRet = --nStrongLockCount;
138cdf0e10cSrcweir ReleaseRef();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir if( !nRet && !nOwnerLockCount )
142cdf0e10cSrcweir DoClose();
143cdf0e10cSrcweir
144cdf0e10cSrcweir return nRet;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir //=========================================================================
OwnerLock(sal_Bool bLock)148cdf0e10cSrcweir void SotObject::OwnerLock
149cdf0e10cSrcweir (
150cdf0e10cSrcweir sal_Bool bLock /* sal_True, lock. sal_False, unlock. */
151cdf0e10cSrcweir )
152cdf0e10cSrcweir /* [Beschreibung]
153cdf0e10cSrcweir
154cdf0e10cSrcweir Wenn der OwnerLock auf Null dekrementiert, dann wird die Methode
155cdf0e10cSrcweir DoClose gerufen. Dies geschieht unabh"angig vom Lock. bzw. RefCount.
156cdf0e10cSrcweir Ist der OwnerLock-Z"ahler != Null, dann wird kein DoClose durch
157cdf0e10cSrcweir <SotObject::FuzzyLock> gerufen.
158cdf0e10cSrcweir */
159cdf0e10cSrcweir {
160cdf0e10cSrcweir if( bLock )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir nOwnerLockCount++;
163cdf0e10cSrcweir AddRef();
164cdf0e10cSrcweir }
165cdf0e10cSrcweir else if ( nOwnerLockCount )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir if( 0 == --nOwnerLockCount )
168cdf0e10cSrcweir DoClose();
169cdf0e10cSrcweir ReleaseRef();
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
RemoveOwnerLock()173cdf0e10cSrcweir void SotObject::RemoveOwnerLock()
174cdf0e10cSrcweir {
175cdf0e10cSrcweir if ( nOwnerLockCount )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir --nOwnerLockCount;
178cdf0e10cSrcweir ReleaseRef();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir else {
181cdf0e10cSrcweir DBG_ERROR("OwnerLockCount underflow!");
182cdf0e10cSrcweir }
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir //=========================================================================
DoClose()186cdf0e10cSrcweir sal_Bool SotObject::DoClose()
187cdf0e10cSrcweir {
188cdf0e10cSrcweir sal_Bool bRet = sal_False;
189cdf0e10cSrcweir if( !bInClose )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir SotObjectRef xHoldAlive( this );
192cdf0e10cSrcweir bInClose = sal_True;
193cdf0e10cSrcweir bRet = Close();
194cdf0e10cSrcweir bInClose = sal_False;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir return bRet;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir //=========================================================================
Close()200cdf0e10cSrcweir sal_Bool SotObject::Close()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir return sal_True;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir
206