Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <sot/object.hxx>
21 : : #include <sot/factory.hxx>
22 : :
23 : : /************** class SotObject ******************************************/
24 [ # # ]: 0 : class SotObjectFactory : public SotFactory
25 : : {
26 : : public:
27 : : TYPEINFO();
28 : 0 : SotObjectFactory( const SvGlobalName & rName,
29 : : const String & rClassName,
30 : : CreateInstanceType pCreateFuncP )
31 : 0 : : SotFactory( rName, rClassName, pCreateFuncP )
32 : 0 : {}
33 : : };
34 [ # # ][ # # ]: 0 : TYPEINIT1(SotObjectFactory,SotFactory);
35 : :
36 : :
37 [ # # ][ # # ]: 0 : SO2_IMPL_BASIC_CLASS_DLL(SotObject,SotObjectFactory,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
38 : : SvGlobalName( 0xf44b7830, 0xf83c, 0x11d0,
39 : : 0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ) )
40 : :
41 : : /*************************************************************************
42 : : |* SotObject::SotObject()
43 : : |*
44 : : |* Beschreibung
45 : : *************************************************************************/
46 : 6417 : SotObject::SotObject()
47 : : : nStrongLockCount( 0 )
48 : : , nOwnerLockCount( 0 )
49 : : , bOwner ( sal_True )
50 : : , bSVObject ( sal_False )
51 : 0 : , bInClose ( sal_False )
52 : : {
53 [ + - ][ # # ]: 6417 : SotFactory::IncSvObjectCount( this );
54 : 6417 : }
55 : :
56 : : /*************************************************************************
57 : : |*
58 : : |* SotObject::~SotObject()
59 : : |*
60 : : *************************************************************************/
61 : 0 : SotObject::~SotObject()
62 : : {
63 [ # # ][ + - ]: 5874 : SotFactory::DecSvObjectCount( this );
64 [ # # ][ # # ]: 5874 : }
[ # # ][ - + ]
[ - + ][ # # ]
65 : :
66 : : /*************************************************************************
67 : : |* SotObject::GetInterface()
68 : : |*
69 : : |* Beschreibung: Um so3 zu helfen
70 : : *************************************************************************/
71 : 0 : IUnknown * SotObject::GetInterface( const SvGlobalName & )
72 : : {
73 : 0 : return NULL;
74 : : }
75 : :
76 : : /*************************************************************************
77 : : |* SotObject::CastAndAddRef()
78 : : |*
79 : : |* Beschreibung
80 : : *************************************************************************/
81 : 0 : void* SotObject::CastAndAddRef( const SotFactory * pFact )
82 : : {
83 : 0 : void * pCast = Cast( pFact );
84 [ # # ]: 0 : if( pCast )
85 : 0 : AddRef();
86 : 0 : return pCast;
87 : : }
88 : :
89 : : //=========================================================================
90 : 0 : sal_uInt16 SotObject::Lock( sal_Bool bLock )
91 : : {
92 : 0 : SotObjectRef xHoldAlive( this );
93 : : sal_uInt16 nRet;
94 [ # # ]: 0 : if( bLock )
95 : : {
96 : 0 : AddRef();
97 : 0 : nRet = ++nStrongLockCount;
98 : : }
99 : : else
100 : : {
101 : 0 : nRet = --nStrongLockCount;
102 [ # # ]: 0 : ReleaseRef();
103 : : }
104 : :
105 [ # # ][ # # ]: 0 : if( !nRet && !nOwnerLockCount )
106 [ # # ]: 0 : DoClose();
107 : :
108 [ # # ]: 0 : return nRet;
109 : : }
110 : :
111 : : //=========================================================================
112 : 3833 : void SotObject::OwnerLock
113 : : (
114 : : sal_Bool bLock /* sal_True, lock. sal_False, unlock. */
115 : : )
116 : : /* [Beschreibung]
117 : :
118 : : Wenn der OwnerLock auf Null dekrementiert, dann wird die Methode
119 : : DoClose gerufen. Dies geschieht unabh"angig vom Lock. bzw. RefCount.
120 : : Ist der OwnerLock-Z"ahler != Null, dann wird kein DoClose durch
121 : : <SotObject::FuzzyLock> gerufen.
122 : : */
123 : : {
124 [ + + ]: 3833 : if( bLock )
125 : : {
126 : 1991 : nOwnerLockCount++;
127 : 1991 : AddRef();
128 : : }
129 [ + - ]: 1842 : else if ( nOwnerLockCount )
130 : : {
131 [ + + ]: 1842 : if( 0 == --nOwnerLockCount )
132 : 1840 : DoClose();
133 : 1842 : ReleaseRef();
134 : : }
135 : 3833 : }
136 : :
137 : : //=========================================================================
138 : 1840 : sal_Bool SotObject::DoClose()
139 : : {
140 : 1840 : sal_Bool bRet = sal_False;
141 [ + - ]: 1840 : if( !bInClose )
142 : : {
143 : 1840 : SotObjectRef xHoldAlive( this );
144 : 1840 : bInClose = sal_True;
145 [ + - ]: 1840 : bRet = Close();
146 [ + - ]: 1840 : bInClose = sal_False;
147 : : }
148 : 1840 : return bRet;
149 : : }
150 : :
151 : : //=========================================================================
152 : 0 : sal_Bool SotObject::Close()
153 : : {
154 : 0 : return sal_True;
155 : : }
156 : :
157 : :
158 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|