LCOV - code coverage report
Current view: top level - include/sot - object.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 4 50.0 %
Date: 2014-11-03 Functions: 2 3 66.7 %
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 INCLUDED_SOT_OBJECT_HXX
      21             : #define INCLUDED_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             : #define SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName)        \
      29             : SotFactory * ClassName::ClassFactory()                                     \
      30             : {                                                                         \
      31             :     SotFactory **ppFactory = GetFactoryAdress();                           \
      32             :     if( !*ppFactory )                                                     \
      33             :     {                                                                     \
      34             :         *ppFactory = new FactoryName( GlobalName,                         \
      35             :             OUString( #ClassName ), ClassName::CreateInstance );     \
      36             :     }                                                                     \
      37             :     return *ppFactory;                                                    \
      38             : }                                                                         \
      39             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
      40             : {                                                                         \
      41             :     ClassName * p = new ClassName();                                      \
      42             :     if( ppObj )                                                           \
      43             :         *ppObj = p;                                                       \
      44             :     return p;                                                             \
      45             : }                                                                         \
      46             : const SotFactory * ClassName::GetSvFactory() const                         \
      47             : {                                                                         \
      48             :     return ClassFactory();                                                \
      49             : }                                                                         \
      50             : void * ClassName::Cast( const SotFactory * pFact )                         \
      51             : {                                                                         \
      52             :     void * pRet = NULL;                                                   \
      53             :     if( !pFact || pFact == ClassFactory() )                               \
      54             :         pRet = this;                                                      \
      55             :     return pRet;                                                          \
      56             : }
      57             : 
      58             : #define SO2_IMPL_BASIC_CLASS1_DLL(ClassName,FactoryName,Super1,GlobalName)\
      59             : SotFactory * ClassName::ClassFactory()                                     \
      60             : {                                                                         \
      61             :     SotFactory **ppFactory = GetFactoryAdress();                           \
      62             :     if( !*ppFactory )                                                     \
      63             :     {                                                                     \
      64             :         *ppFactory = new FactoryName( GlobalName,                         \
      65             :             OUString( #ClassName ), ClassName::CreateInstance );     \
      66             :         (*ppFactory)->PutSuperClass( Super1::ClassFactory() );            \
      67             :     }                                                                     \
      68             :     return *ppFactory;                                                    \
      69             : }                                                                         \
      70             : void * ClassName::CreateInstance( SotObject ** ppObj )            \
      71             : {                                                                         \
      72             :     ClassName * p = new ClassName();                                      \
      73             :     Super1* pSuper1 = p;                                                  \
      74             :     SotObject* pBasicObj = pSuper1;                                        \
      75             :     if( ppObj )                                                           \
      76             :         *ppObj = pBasicObj;                                               \
      77             :     return p;                                                             \
      78             : }                                                                         \
      79             : const SotFactory * ClassName::GetSvFactory() const                \
      80             : {                                                                         \
      81             :     return ClassFactory();                                                \
      82             : }                                                                         \
      83             : void * ClassName::Cast( const SotFactory * pFact )                \
      84             : {                                                                         \
      85             :     void * pRet = NULL;                                                   \
      86             :     if( !pFact || pFact == ClassFactory() )                               \
      87             :         pRet = this;                                                      \
      88             :     if( !pRet )                                                           \
      89             :         pRet = Super1::Cast( pFact );                                     \
      90             :     return pRet;                                                          \
      91             : }
      92             : 
      93             : struct IUnknown;
      94             : class SOT_DLLPUBLIC SotObject : virtual public SvRefBase
      95             : {
      96             : friend class SotFactory;
      97             : friend class SvObject;
      98             :     sal_uInt16  nOwnerLockCount;
      99             :     bool        bOwner;
     100             :     bool        bSVObject;        // Ist Proxy, dann TRUE wenn andere Seite SV ist
     101             :     bool        bInClose;         // TRUE, im DoClose
     102             : 
     103             : protected:
     104             :     virtual             ~SotObject();
     105             :     void                SetExtern() { bOwner = false; }
     106             :     virtual bool        Close();
     107             : public:
     108             :                         SotObject();
     109             : 
     110             : private:
     111           0 :     static SotFactory **       GetFactoryAdress()
     112           0 :                               { return &(SOTDATA()->pSotObjectFactory); }
     113             : public:
     114             :     static void *             CreateInstance( SotObject ** = NULL );
     115             :     static SotFactory *        ClassFactory();
     116             :     virtual const SotFactory * GetSvFactory() const;
     117             :     virtual void *            Cast( const SotFactory * );
     118             : 
     119             :                         // Nur damit die Makros in So3 nicht ganz ausufern
     120             :     virtual IUnknown *  GetInterface( const SvGlobalName & );
     121             : 
     122             :     bool                Owner() const { return bOwner; }
     123             : 
     124        5506 :     sal_uInt16          GetOwnerLockCount() const { return nOwnerLockCount; }
     125             : 
     126             :     void                OwnerLock( bool bLock );
     127             :     bool                DoClose();
     128           6 :     bool                IsInClose() const { return bInClose; }
     129             : 
     130             : private:
     131             :     // Kopieren und Zuweisen dieses Objekttyps ist nicht erlaubt
     132             :     SOT_DLLPRIVATE SotObject & operator = ( const SotObject & );
     133             :     SOT_DLLPRIVATE SotObject( const SotObject & );
     134             : };
     135             : 
     136             : //==================class SotObjectRef======================================
     137             : typedef tools::SvRef<SotObject> SotObjectRef;
     138             : 
     139             : #endif // _IFACE_HXX
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10