LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/sot - object.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 4 50.0 %
Date: 2012-12-27 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          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             : #ifndef _SOT_OBJECT_HXX
      21             : #define _SOT_OBJECT_HXX
      22             : 
      23             : #include <sot/sotdata.hxx>
      24             : #include <tools/globname.hxx>
      25             : #include <tools/ref.hxx>
      26             : #include "sot/sotdllapi.h"
      27             : 
      28             : /*************************************************************************
      29             : *************************************************************************/
      30             : 
      31             : #define SO2_DECL_BASIC_CLASS_DLL(ClassName,FacName)                       \
      32             : private:                                                                  \
      33             :     static SotFactory **       GetFactoryAdress()                          \
      34             :                               { return &(FacName->p##ClassName##Factory); } \
      35             : public:                                                                   \
      36             :     static void *             CreateInstance( SotObject ** = NULL );       \
      37             :     static SotFactory *        ClassFactory();                             \
      38             :     virtual const SotFactory * GetSvFactory() const;                       \
      39             :     virtual void *            Cast( const SotFactory * );
      40             : 
      41             : #define SO2_DECL_BASIC_CLASS(ClassName)                                   \
      42             : private:                                                                  \
      43             :     static SotFactory *        pFactory;                                   \
      44             :     static SotFactory **       GetFactoryAdress() { return &pFactory; }    \
      45             : public:                                                                   \
      46             :     static void *             CreateInstance( SotObject ** = NULL );       \
      47             :     static SotFactory *        ClassFactory();                             \
      48             :     virtual const SotFactory * GetSvFactory() const;                       \
      49             :     virtual void *            Cast( const SotFactory * );
      50             : 
      51             : /**************************************************************************
      52             : **************************************************************************/
      53             : #define SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName)        \
      54             : SotFactory * ClassName::ClassFactory()                                     \
      55             : {                                                                         \
      56             :     SotFactory **ppFactory = GetFactoryAdress();                           \
      57             :     if( !*ppFactory )                                                     \
      58             :     {                                                                     \
      59             :         *ppFactory = new FactoryName( GlobalName,                         \
      60             :             rtl::OUString( #ClassName ), ClassName::CreateInstance );     \
      61             :     }                                                                     \
      62             :     return *ppFactory;                                                    \
      63             : }                                                                         \
      64             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
      65             : {                                                                         \
      66             :     ClassName * p = new ClassName();                                      \
      67             :     if( ppObj )                                                           \
      68             :         *ppObj = p;                                                       \
      69             :     return p;                                                             \
      70             : }                                                                         \
      71             : const SotFactory * ClassName::GetSvFactory() const                         \
      72             : {                                                                         \
      73             :     return ClassFactory();                                                \
      74             : }                                                                         \
      75             : void * ClassName::Cast( const SotFactory * pFact )                         \
      76             : {                                                                         \
      77             :     void * pRet = NULL;                                                   \
      78             :     if( !pFact || pFact == ClassFactory() )                               \
      79             :         pRet = this;                                                      \
      80             :     return pRet;                                                          \
      81             : }
      82             : 
      83             : #define SO2_IMPL_BASIC_CLASS(ClassName,FactoryName,GlobalName)                        \
      84             : SotFactory * ClassName::pFactory = NULL;                                   \
      85             :     SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName)
      86             : 
      87             : /**************************************************************************
      88             : **************************************************************************/
      89             : #define SO2_IMPL_BASIC_CLASS1_DLL(ClassName,FactoryName,Super1,GlobalName)\
      90             : SotFactory * ClassName::ClassFactory()                                     \
      91             : {                                                                         \
      92             :     SotFactory **ppFactory = GetFactoryAdress();                           \
      93             :     if( !*ppFactory )                                                     \
      94             :     {                                                                     \
      95             :         *ppFactory = new FactoryName( GlobalName,                         \
      96             :             rtl::OUString( #ClassName ), ClassName::CreateInstance );     \
      97             :         (*ppFactory)->PutSuperClass( Super1::ClassFactory() );            \
      98             :     }                                                                     \
      99             :     return *ppFactory;                                                    \
     100             : }                                                                         \
     101             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
     102             : {                                                                         \
     103             :     ClassName * p = new ClassName();                                      \
     104             :     Super1* pSuper1 = p;                                                  \
     105             :     SotObject* pBasicObj = pSuper1;                                        \
     106             :     if( ppObj )                                                           \
     107             :         *ppObj = pBasicObj;                                               \
     108             :     return p;                                                             \
     109             : }                                                                         \
     110             : const SotFactory * ClassName::GetSvFactory() const                \
     111             : {                                                                         \
     112             :     return ClassFactory();                                                \
     113             : }                                                                         \
     114             : void * ClassName::Cast( const SotFactory * pFact )                \
     115             : {                                                                         \
     116             :     void * pRet = NULL;                                                   \
     117             :     if( !pFact || pFact == ClassFactory() )                               \
     118             :         pRet = this;                                                      \
     119             :     if( !pRet )                                                           \
     120             :         pRet = Super1::Cast( pFact );                                     \
     121             :     return pRet;                                                          \
     122             : }
     123             : 
     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)
     127             : 
     128             : /**************************************************************************
     129             : **************************************************************************/
     130             : #define SO2_IMPL_BASIC_CLASS2_DLL(ClassName,FactoryName,Super1,Super2,GlobalName)  \
     131             : SotFactory * ClassName::ClassFactory()                                     \
     132             : {                                                                         \
     133             :     SotFactory **ppFactory = GetFactoryAdress();                           \
     134             :     if( !*ppFactory )                                                     \
     135             :     {                                                                     \
     136             :         *ppFactory = new FactoryName( GlobalName,                         \
     137             :             rtl::OUString( #ClassName ), ClassName::CreateInstance );     \
     138             :         (*ppFactory)->PutSuperClass( Super1::ClassFactory() );            \
     139             :         (*ppFactory)->PutSuperClass( Super2::ClassFactory() );            \
     140             :     }                                                                     \
     141             :     return *ppFactory;                                                    \
     142             : }                                                                         \
     143             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
     144             : {                                                                         \
     145             :     ClassName * p = new ClassName();                                      \
     146             :     if( ppObj )                                                           \
     147             :         *ppObj = p;                                                       \
     148             :     return p;                                                             \
     149             : }                                                                         \
     150             : const SotFactory * ClassName::GetSvFactory() const                \
     151             : {                                                                         \
     152             :     return ClassFactory();                                                \
     153             : }                                                                         \
     154             : void * ClassName::Cast( const SotFactory * pFact )                \
     155             : {                                                                         \
     156             :     void * pRet = NULL;                                                   \
     157             :     if( !pFact || pFact == ClassFactory() )                               \
     158             :         pRet = this;                                                      \
     159             :     if( !pRet )                                                           \
     160             :         pRet = Super1::Cast( pFact );                                     \
     161             :     if( !pRet )                                                           \
     162             :         pRet = Super2::Cast( pFact );                                     \
     163             :     return pRet;                                                          \
     164             : }
     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)
     168             : 
     169             : /**************************************************************************
     170             : **************************************************************************/
     171             : #define SO2_IMPL_BASIC_CLASS3_DLL(ClassName,FactoryName,Super1,Super2,Super3,GlobalName)  \
     172             : SotFactory * ClassName::ClassFactory()                                     \
     173             : {                                                                         \
     174             :     SotFactory **ppFactory = GetFactoryAdress();                           \
     175             :     if( !*ppFactory )                                                     \
     176             :     {                                                                     \
     177             :         *ppFactory = new FactoryName( GlobalName,                         \
     178             :             rtl::OUString( #ClassName ), ClassName::CreateInstance );     \
     179             :         (*ppFactory)->PutSuperClass( Super1::ClassFactory() );            \
     180             :         (*ppFactory)->PutSuperClass( Super2::ClassFactory() );            \
     181             :         (*ppFactory)->PutSuperClass( Super3::ClassFactory() );            \
     182             :     }                                                                     \
     183             :     return *pFactory;                                                     \
     184             : }                                                                         \
     185             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
     186             : {                                                                         \
     187             :     ClassName * p = new ClassName();                                      \
     188             :     if( ppObj )                                                           \
     189             :         *ppObj = p;                                                       \
     190             :     return p;                                                             \
     191             : }                                                                         \
     192             : const SotFactory * ClassName::GetSvFactory() const                \
     193             : {                                                                         \
     194             :     return ClassFactory();                                                \
     195             : }                                                                         \
     196             : void * ClassName::Cast( const SotFactory * pFact )                \
     197             : {                                                                         \
     198             :     void * pRet = NULL;                                                   \
     199             :     if( !pFact || pFact == ClassFactory() )                               \
     200             :         pRet = this;                                                      \
     201             :     if( !pRet )                                                           \
     202             :         pRet = Super1::Cast( pFact );                                     \
     203             :     if( !pRet )                                                           \
     204             :         pRet = Super2::Cast( pFact );                                     \
     205             :     if( !pRet )                                                           \
     206             :         pRet = Super3::Cast( pFact );                                     \
     207             :     return pRet;                                                          \
     208             : }
     209             : 
     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)
     213             : 
     214             : /**************************************************************************
     215             : **************************************************************************/
     216             : #define SO2_IMPL_BASIC_CLASS4_DLL(ClassName,FactoryName,Super1,Super2,Super3,Super4,GlobalName)  \
     217             : SotFactory * ClassName::ClassFactory()                                     \
     218             : {                                                                         \
     219             :     SotFactory **ppFactory = GetFactoryAdress();                           \
     220             :     if( !*ppFactory )                                                     \
     221             :     {                                                                     \
     222             :         *ppFactory = new SotFactory( GlobalName,                           \
     223             :             rtl::OUString( #ClassName ), ClassName::CreateInstance );     \
     224             :         (*ppFactory)->PutSuperClass( Super1::ClassFactory() );            \
     225             :         (*ppFactory)->PutSuperClass( Super2::ClassFactory() );            \
     226             :         (*ppFactory)->PutSuperClass( Super3::ClassFactory() );            \
     227             :         (*ppFactory)->PutSuperClass( Super4::ClassFactory() );            \
     228             :     }                                                                     \
     229             :     return *ppFactory;                                                    \
     230             : }                                                                         \
     231             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
     232             : {                                                                         \
     233             :     ClassName * p = new ClassName();                                      \
     234             :     if( ppObj )                                                           \
     235             :         *ppObj = p;                                                       \
     236             :     return p;                                                             \
     237             : }                                                                         \
     238             : const SotFactory * ClassName::GetSvFactory() const                \
     239             : {                                                                         \
     240             :     return ClassFactory();                                                \
     241             : }                                                                         \
     242             : void * ClassName::Cast( const SotFactory * pFact )                \
     243             : {                                                                         \
     244             :     void * pRet = NULL;                                                   \
     245             :     if( !pFact || pFact == ClassFactory() )                               \
     246             :         pRet = this;                                                      \
     247             :     if( !pRet )                                                           \
     248             :         pRet = Super1::Cast( pFact );                                     \
     249             :     if( !pRet )                                                           \
     250             :         pRet = Super2::Cast( pFact );                                     \
     251             :     if( !pRet )                                                           \
     252             :         pRet = Super3::Cast( pFact );                                     \
     253             :     if( !pRet )                                                           \
     254             :         pRet = Super4::Cast( pFact );                                     \
     255             :     return pRet;                                                          \
     256             : }
     257             : 
     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)
     261             : 
     262             : //==================class SotObject========================================
     263             : #ifdef _MSC_VER
     264             : #pragma warning(disable: 4250)
     265             : #endif
     266             : 
     267             : struct IUnknown;
     268             : class SOT_DLLPUBLIC SotObject : virtual public SvRefBase
     269             : {
     270             : friend class SotFactory;
     271             : friend class SvObject;
     272             :     sal_uInt16  nOwnerLockCount;
     273             :     sal_Bool    bOwner:1,
     274             :                 bSVObject:1,        // Ist Proxy, dann TRUE wenn andere Seite SV ist
     275             :                 bInClose:1;         // TRUE, im DoClose
     276             : 
     277             : protected:
     278             :     virtual             ~SotObject();
     279             :     void                SetExtern() { bOwner = sal_False; }
     280             :     virtual sal_Bool        Close();
     281             : public:
     282             :                         SotObject();
     283           0 :                         SO2_DECL_BASIC_CLASS_DLL(SotObject,SOTDATA())
     284             : 
     285             :                         // Nur damit die Makros in So3 nicht ganz ausufern
     286             :     virtual IUnknown *  GetInterface( const SvGlobalName & );
     287             : 
     288             :     sal_Bool                Owner() const { return bOwner; }
     289             : 
     290          63 :     sal_uInt16              GetOwnerLockCount() const { return nOwnerLockCount; }
     291             : 
     292             :     void                OwnerLock( sal_Bool bLock );
     293             :     sal_Bool                DoClose();
     294           0 :     sal_Bool                IsInClose() const { return bInClose; }
     295             : 
     296             : private:
     297             :     // Kopieren und Zuweisen dieses Objekttyps ist nicht erlaubt
     298             :     SOT_DLLPRIVATE SotObject & operator = ( const SotObject & );
     299             :     SOT_DLLPRIVATE SotObject( const SotObject & );
     300             : };
     301             : 
     302             : //==================class SotObjectRef======================================
     303         126 : SV_DECL_IMPL_REF(SotObject)
     304             : 
     305             : #endif // _IFACE_HXX
     306             : 
     307             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10