1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SOT_OBJECT_HXX
21 #define INCLUDED_SOT_OBJECT_HXX
23 #include <sot/sotdata.hxx>
24 #include <tools/globname.hxx>
25 #include <tools/ref.hxx>
26 #include <sot/sotdllapi.h>
28 #define SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName) \
29 SotFactory * ClassName::ClassFactory() \
31 SotFactory **ppFactory = GetFactoryAdress(); \
34 *ppFactory = new FactoryName( GlobalName, \
35 OUString( #ClassName ), ClassName::CreateInstance ); \
39 void * ClassName::CreateInstance( SotObject ** ppObj ) \
41 ClassName * p = new ClassName(); \
46 const SotFactory * ClassName::GetSvFactory() const \
48 return ClassFactory(); \
50 void * ClassName::Cast( const SotFactory * pFact ) \
53 if( !pFact || pFact == ClassFactory() ) \
58 #define SO2_IMPL_BASIC_CLASS1_DLL(ClassName,FactoryName,Super1,GlobalName)\
59 SotFactory * ClassName::ClassFactory() \
61 SotFactory **ppFactory = GetFactoryAdress(); \
64 *ppFactory = new FactoryName( GlobalName, \
65 OUString( #ClassName ), ClassName::CreateInstance ); \
66 (*ppFactory)->PutSuperClass( Super1::ClassFactory() ); \
70 void * ClassName::CreateInstance( SotObject ** ppObj ) \
72 ClassName * p = new ClassName(); \
73 Super1* pSuper1 = p; \
74 SotObject* pBasicObj = pSuper1; \
79 const SotFactory * ClassName::GetSvFactory() const \
81 return ClassFactory(); \
83 void * ClassName::Cast( const SotFactory * pFact ) \
86 if( !pFact || pFact == ClassFactory() ) \
89 pRet = Super1::Cast( pFact ); \
94 class SOT_DLLPUBLIC SotObject
: virtual public SvRefBase
96 friend class SotFactory
;
97 sal_uInt16 nOwnerLockCount
;
99 bool bSVObject
; // is proxy, then TRUE if other side is SV
100 bool bInClose
; // TRUE, in DoClose
103 virtual ~SotObject();
104 void SetExtern() { bOwner
= false; }
105 virtual bool Close();
110 static SotFactory
** GetFactoryAdress()
111 { return &(SOTDATA()->pSotObjectFactory
); }
113 static void * CreateInstance( SotObject
** = NULL
);
114 static SotFactory
* ClassFactory();
115 virtual const SotFactory
* GetSvFactory() const;
116 virtual void * Cast( const SotFactory
* );
118 bool Owner() const { return bOwner
; }
120 sal_uInt16
GetOwnerLockCount() const { return nOwnerLockCount
; }
122 void OwnerLock( bool bLock
);
124 bool IsInClose() const { return bInClose
; }
127 SotObject
& operator = ( const SotObject
& ) SAL_DELETED_FUNCTION
;
128 SotObject( const SotObject
& ) SAL_DELETED_FUNCTION
;
131 //==================class SotObjectRef======================================
132 typedef tools::SvRef
<SotObject
> SotObjectRef
;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */