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_OVERRIDE();
28 0 : SotObjectFactory( const SvGlobalName & rName,
29 : const OUString & 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 10564 : SotObject::SotObject()
47 : : nOwnerLockCount( 0 )
48 : , bOwner ( true )
49 : , bSVObject ( false )
50 10564 : , bInClose ( false )
51 : {
52 10564 : SotFactory::IncSvObjectCount( this );
53 10564 : }
54 :
55 : /*************************************************************************
56 : |*
57 : |* SotObject::~SotObject()
58 : |*
59 : *************************************************************************/
60 10504 : SotObject::~SotObject()
61 : {
62 10504 : SotFactory::DecSvObjectCount( this );
63 10504 : }
64 :
65 6499 : void SotObject::OwnerLock
66 : (
67 : bool bLock /* true, lock. false, unlock. */
68 : )
69 : /* [Beschreibung]
70 :
71 : Wenn der OwnerLock auf Null dekrementiert, dann wird die Methode
72 : DoClose gerufen. Dies geschieht unabh"angig vom Lock. bzw. RefCount.
73 : Ist der OwnerLock-Z"ahler != Null, dann wird kein DoClose durch
74 : <SotObject::FuzzyLock> gerufen.
75 : */
76 : {
77 6499 : if( bLock )
78 : {
79 3252 : nOwnerLockCount++;
80 3252 : AddFirstRef();
81 : }
82 3247 : else if ( nOwnerLockCount )
83 : {
84 3247 : if( 0 == --nOwnerLockCount )
85 3199 : DoClose();
86 3247 : ReleaseRef();
87 : }
88 6499 : }
89 :
90 :
91 3199 : bool SotObject::DoClose()
92 : {
93 3199 : bool bRet = false;
94 3199 : if( !bInClose )
95 : {
96 3199 : SotObjectRef xHoldAlive( this );
97 3199 : bInClose = true;
98 3199 : bRet = Close();
99 3199 : bInClose = false;
100 : }
101 3199 : return bRet;
102 : }
103 :
104 :
105 0 : bool SotObject::Close()
106 : {
107 0 : return true;
108 : }
109 :
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|