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