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 /*************************************************************************
29 *************************************************************************/
31 #define SO2_DECL_BASIC_CLASS_DLL(ClassName,FacName) \
33 static SotFactory ** GetFactoryAdress() \
34 { return &(FacName->p##ClassName##Factory); } \
36 static void * CreateInstance( SotObject ** = NULL ); \
37 static SotFactory * ClassFactory(); \
38 virtual const SotFactory * GetSvFactory() const; \
39 virtual void * Cast( const SotFactory * );
41 #define SO2_DECL_BASIC_CLASS(ClassName) \
43 static SotFactory * pFactory; \
44 static SotFactory ** GetFactoryAdress() { return &pFactory; } \
46 static void * CreateInstance( SotObject ** = NULL ); \
47 static SotFactory * ClassFactory(); \
48 virtual const SotFactory * GetSvFactory() const; \
49 virtual void * Cast( const SotFactory * );
51 /**************************************************************************
52 **************************************************************************/
53 #define SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName) \
54 SotFactory * ClassName::ClassFactory() \
56 SotFactory **ppFactory = GetFactoryAdress(); \
59 *ppFactory = new FactoryName( GlobalName, \
60 OUString( #ClassName ), ClassName::CreateInstance ); \
64 void * ClassName::CreateInstance( SotObject ** ppObj ) \
66 ClassName * p = new ClassName(); \
71 const SotFactory * ClassName::GetSvFactory() const \
73 return ClassFactory(); \
75 void * ClassName::Cast( const SotFactory * pFact ) \
78 if( !pFact || pFact == ClassFactory() ) \
83 #define SO2_IMPL_BASIC_CLASS(ClassName,FactoryName,GlobalName) \
84 SotFactory * ClassName::pFactory = NULL; \
85 SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName)
87 /**************************************************************************
88 **************************************************************************/
89 #define SO2_IMPL_BASIC_CLASS1_DLL(ClassName,FactoryName,Super1,GlobalName)\
90 SotFactory * ClassName::ClassFactory() \
92 SotFactory **ppFactory = GetFactoryAdress(); \
95 *ppFactory = new FactoryName( GlobalName, \
96 OUString( #ClassName ), ClassName::CreateInstance ); \
97 (*ppFactory)->PutSuperClass( Super1::ClassFactory() ); \
101 void * ClassName::CreateInstance( SotObject ** ppObj ) \
103 ClassName * p = new ClassName(); \
104 Super1* pSuper1 = p; \
105 SotObject* pBasicObj = pSuper1; \
107 *ppObj = pBasicObj; \
110 const SotFactory * ClassName::GetSvFactory() const \
112 return ClassFactory(); \
114 void * ClassName::Cast( const SotFactory * pFact ) \
116 void * pRet = NULL; \
117 if( !pFact || pFact == ClassFactory() ) \
120 pRet = Super1::Cast( pFact ); \
124 #define SO2_IMPL_BASIC_CLASS1(ClassName,FactoryName,Super1,GlobalName) \
125 SotFactory * ClassName::pFactory = NULL; \
126 SO2_IMPL_BASIC_CLASS1_DLL(ClassName,FactoryName,Super1,GlobalName)
128 /**************************************************************************
129 **************************************************************************/
130 #define SO2_IMPL_BASIC_CLASS2_DLL(ClassName,FactoryName,Super1,Super2,GlobalName) \
131 SotFactory * ClassName::ClassFactory() \
133 SotFactory **ppFactory = GetFactoryAdress(); \
136 *ppFactory = new FactoryName( GlobalName, \
137 OUString( #ClassName ), ClassName::CreateInstance ); \
138 (*ppFactory)->PutSuperClass( Super1::ClassFactory() ); \
139 (*ppFactory)->PutSuperClass( Super2::ClassFactory() ); \
143 void * ClassName::CreateInstance( SotObject ** ppObj ) \
145 ClassName * p = new ClassName(); \
150 const SotFactory * ClassName::GetSvFactory() const \
152 return ClassFactory(); \
154 void * ClassName::Cast( const SotFactory * pFact ) \
156 void * pRet = NULL; \
157 if( !pFact || pFact == ClassFactory() ) \
160 pRet = Super1::Cast( pFact ); \
162 pRet = Super2::Cast( pFact ); \
165 #define SO2_IMPL_BASIC_CLASS2(ClassName,FactoryName,Super1,Super2,GlobalName) \
166 SotFactory * ClassName::pFactory = NULL; \
167 SO2_IMPL_BASIC_CLASS2_DLL(ClassName,FactoryName,Super1,Super2,GlobalName)
169 /**************************************************************************
170 **************************************************************************/
171 #define SO2_IMPL_BASIC_CLASS3_DLL(ClassName,FactoryName,Super1,Super2,Super3,GlobalName) \
172 SotFactory * ClassName::ClassFactory() \
174 SotFactory **ppFactory = GetFactoryAdress(); \
177 *ppFactory = new FactoryName( GlobalName, \
178 OUString( #ClassName ), ClassName::CreateInstance ); \
179 (*ppFactory)->PutSuperClass( Super1::ClassFactory() ); \
180 (*ppFactory)->PutSuperClass( Super2::ClassFactory() ); \
181 (*ppFactory)->PutSuperClass( Super3::ClassFactory() ); \
185 void * ClassName::CreateInstance( SotObject ** ppObj ) \
187 ClassName * p = new ClassName(); \
192 const SotFactory * ClassName::GetSvFactory() const \
194 return ClassFactory(); \
196 void * ClassName::Cast( const SotFactory * pFact ) \
198 void * pRet = NULL; \
199 if( !pFact || pFact == ClassFactory() ) \
202 pRet = Super1::Cast( pFact ); \
204 pRet = Super2::Cast( pFact ); \
206 pRet = Super3::Cast( pFact ); \
210 #define SO2_IMPL_BASIC_CLASS3(ClassName,FactoryName,Super1,Super2,Super3,GlobalName) \
211 SotFactory * ClassName::pFactory = NULL; \
212 SO2_IMPL_BASIC_CLASS3_DLL(ClassName,FactoryName,Super1,Super2,Super3,GlobalName)
214 /**************************************************************************
215 **************************************************************************/
216 #define SO2_IMPL_BASIC_CLASS4_DLL(ClassName,FactoryName,Super1,Super2,Super3,Super4,GlobalName) \
217 SotFactory * ClassName::ClassFactory() \
219 SotFactory **ppFactory = GetFactoryAdress(); \
222 *ppFactory = new SotFactory( GlobalName, \
223 OUString( #ClassName ), ClassName::CreateInstance ); \
224 (*ppFactory)->PutSuperClass( Super1::ClassFactory() ); \
225 (*ppFactory)->PutSuperClass( Super2::ClassFactory() ); \
226 (*ppFactory)->PutSuperClass( Super3::ClassFactory() ); \
227 (*ppFactory)->PutSuperClass( Super4::ClassFactory() ); \
231 void * ClassName::CreateInstance( SotObject ** ppObj ) \
233 ClassName * p = new ClassName(); \
238 const SotFactory * ClassName::GetSvFactory() const \
240 return ClassFactory(); \
242 void * ClassName::Cast( const SotFactory * pFact ) \
244 void * pRet = NULL; \
245 if( !pFact || pFact == ClassFactory() ) \
248 pRet = Super1::Cast( pFact ); \
250 pRet = Super2::Cast( pFact ); \
252 pRet = Super3::Cast( pFact ); \
254 pRet = Super4::Cast( pFact ); \
258 #define SO2_IMPL_BASIC_CLASS4(ClassName,FactoryName,Super1,Super2,Super3,Super4,GlobalName) \
259 SotFactory * ClassName::pFactory = NULL; \
260 SO2_IMPL_BASIC_CLASS4_DLL(ClassName,FactoryName,Super1,Super2,Super3,Super4,GlobalName)
262 //==================class SotObject========================================
264 #pragma warning(disable: 4250)
268 class SOT_DLLPUBLIC SotObject
: virtual public SvRefBase
270 friend class SotFactory
;
271 friend class SvObject
;
272 sal_uInt16 nOwnerLockCount
;
274 bool bSVObject
; // Ist Proxy, dann TRUE wenn andere Seite SV ist
275 bool bInClose
; // TRUE, im DoClose
278 virtual ~SotObject();
279 void SetExtern() { bOwner
= false; }
280 virtual bool Close();
283 SO2_DECL_BASIC_CLASS_DLL(SotObject
,SOTDATA())
285 // Nur damit die Makros in So3 nicht ganz ausufern
286 virtual IUnknown
* GetInterface( const SvGlobalName
& );
288 bool Owner() const { return bOwner
; }
290 sal_uInt16
GetOwnerLockCount() const { return nOwnerLockCount
; }
292 void OwnerLock( bool bLock
);
294 bool IsInClose() const { return bInClose
; }
297 // Kopieren und Zuweisen dieses Objekttyps ist nicht erlaubt
298 SOT_DLLPRIVATE SotObject
& operator = ( const SotObject
& );
299 SOT_DLLPRIVATE
SotObject( const SotObject
& );
302 //==================class SotObjectRef======================================
303 SV_DECL_IMPL_REF(SotObject
)
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */