[Libreoffice-commits] core.git: include/sot sot/source

Noel Grandin noel at peralex.com
Fri Jul 3 03:46:34 PDT 2015


 include/sot/object.hxx        |   69 ------------------------------------
 sot/source/base/object.cxx    |   37 +++++++++++++++++--
 sot/source/sdstor/storage.cxx |   80 ++++++++++++++++++++++++++++++++++++++----
 3 files changed, 107 insertions(+), 79 deletions(-)

New commits:
commit 9136f2344af88d524b6c10b6b2dfd6017bba60ec
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Jul 3 10:29:31 2015 +0200

    expand out some sot macros
    
    Change-Id: Ic583fe767e5f85628f8270ec740ce3e72fe56ded
    Reviewed-on: https://gerrit.libreoffice.org/16722
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/sot/object.hxx b/include/sot/object.hxx
index c4aa662..8c20856 100644
--- a/include/sot/object.hxx
+++ b/include/sot/object.hxx
@@ -25,72 +25,6 @@
 #include <tools/ref.hxx>
 #include <sot/sotdllapi.h>
 
-#define SO2_IMPL_BASIC_CLASS_DLL(ClassName,FactoryName,GlobalName)        \
-SotFactory * ClassName::ClassFactory()                                     \
-{                                                                         \
-    SotFactory **ppFactory = GetFactoryAdress();                           \
-    if( !*ppFactory )                                                     \
-    {                                                                     \
-        *ppFactory = new FactoryName( GlobalName,                         \
-            OUString( #ClassName ), ClassName::CreateInstance );     \
-    }                                                                     \
-    return *ppFactory;                                                    \
-}                                                                         \
-void * ClassName::CreateInstance( SotObject ** ppObj )            \
-{                                                                         \
-    ClassName * p = new ClassName();                                      \
-    if( ppObj )                                                           \
-        *ppObj = p;                                                       \
-    return p;                                                             \
-}                                                                         \
-const SotFactory * ClassName::GetSvFactory() const                         \
-{                                                                         \
-    return ClassFactory();                                                \
-}                                                                         \
-void * ClassName::Cast( const SotFactory * pFact )                         \
-{                                                                         \
-    void * pRet = NULL;                                                   \
-    if( !pFact || pFact == ClassFactory() )                               \
-        pRet = this;                                                      \
-    return pRet;                                                          \
-}
-
-#define SO2_IMPL_BASIC_CLASS1_DLL(ClassName,FactoryName,Super1,GlobalName)\
-SotFactory * ClassName::ClassFactory()                                     \
-{                                                                         \
-    SotFactory **ppFactory = GetFactoryAdress();                           \
-    if( !*ppFactory )                                                     \
-    {                                                                     \
-        *ppFactory = new FactoryName( GlobalName,                         \
-            OUString( #ClassName ), ClassName::CreateInstance );     \
-        (*ppFactory)->PutSuperClass( Super1::ClassFactory() );            \
-    }                                                                     \
-    return *ppFactory;                                                    \
-}                                                                         \
-void * ClassName::CreateInstance( SotObject ** ppObj )            \
-{                                                                         \
-    ClassName * p = new ClassName();                                      \
-    Super1* pSuper1 = p;                                                  \
-    SotObject* pBasicObj = pSuper1;                                        \
-    if( ppObj )                                                           \
-        *ppObj = pBasicObj;                                               \
-    return p;                                                             \
-}                                                                         \
-const SotFactory * ClassName::GetSvFactory() const                \
-{                                                                         \
-    return ClassFactory();                                                \
-}                                                                         \
-void * ClassName::Cast( const SotFactory * pFact )                \
-{                                                                         \
-    void * pRet = NULL;                                                   \
-    if( !pFact || pFact == ClassFactory() )                               \
-        pRet = this;                                                      \
-    if( !pRet )                                                           \
-        pRet = Super1::Cast( pFact );                                     \
-    return pRet;                                                          \
-}
-
-struct IUnknown;
 class SOT_DLLPUBLIC SotObject : virtual public SvRefBase
 {
 friend class SotFactory;
@@ -128,9 +62,6 @@ private:
     SotObject( const SotObject & ) SAL_DELETED_FUNCTION;
 };
 
-//==================class SotObjectRef======================================
-typedef tools::SvRef<SotObject> SotObjectRef;
-
 #endif // _IFACE_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sot/source/base/object.cxx b/sot/source/base/object.cxx
index b809642..013853d 100644
--- a/sot/source/base/object.cxx
+++ b/sot/source/base/object.cxx
@@ -32,9 +32,38 @@ public:
 };
 
 
-SO2_IMPL_BASIC_CLASS_DLL(SotObject,SotObjectFactory,
-                    SvGlobalName( 0xf44b7830, 0xf83c, 0x11d0,
-                            0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ) )
+SotFactory * SotObject::ClassFactory()
+{
+    SotFactory **ppFactory = GetFactoryAdress();
+    if( !*ppFactory )
+    {
+        *ppFactory = new SotObjectFactory( SvGlobalName( 0xf44b7830, 0xf83c, 0x11d0,
+                            0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ),
+            OUString( "SotObject" ), SotObject::CreateInstance );
+    }
+    return *ppFactory;
+}
+
+void * SotObject::CreateInstance( SotObject ** ppObj )
+{
+    SotObject * p = new SotObject();
+    if( ppObj )
+        *ppObj = p;
+    return p;
+}
+
+const SotFactory * SotObject::GetSvFactory() const
+{
+    return ClassFactory();
+}
+
+void * SotObject::Cast( const SotFactory * pFact )
+{
+    void * pRet = NULL;
+    if( !pFact || pFact == ClassFactory() )
+        pRet = this;
+    return pRet;
+}
 
 /*************************************************************************
 |*    SotObject::SotObject()
@@ -91,7 +120,7 @@ bool SotObject::DoClose()
     bool bRet = false;
     if( !bInClose )
     {
-        SotObjectRef xHoldAlive( this );
+        tools::SvRef<SotObject> xHoldAlive( this );
         bInClose = true;
         bRet = Close();
         bInClose = false;
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 1a01a04..30c80b7 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -53,9 +53,43 @@ public:
 };
 
 
-SO2_IMPL_BASIC_CLASS1_DLL(SotStorageStream,SotStorageStreamFactory,SotObject,
-                        SvGlobalName( 0xd7deb420, 0xf902, 0x11d0,
-                            0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ) )
+SotFactory * SotStorageStream::ClassFactory()
+{
+    SotFactory **ppFactory = GetFactoryAdress();
+    if( !*ppFactory )
+    {
+        *ppFactory = new SotStorageStreamFactory( SvGlobalName( 0xd7deb420, 0xf902, 0x11d0,
+                            0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ),
+            OUString( "SotStorageStream" ), SotStorageStream::CreateInstance );
+        (*ppFactory)->PutSuperClass( SotObject::ClassFactory() );
+    }
+    return *ppFactory;
+}
+
+void * SotStorageStream::CreateInstance( SotObject ** ppObj )
+{
+    SotStorageStream * p = new SotStorageStream();
+    SotObject* pSuper1 = p;
+    SotObject* pBasicObj = pSuper1;
+    if( ppObj )
+        *ppObj = pBasicObj;
+    return p;
+}
+
+const SotFactory * SotStorageStream::GetSvFactory() const
+{
+    return ClassFactory();
+}
+
+void * SotStorageStream::Cast( const SotFactory * pFact )
+{
+    void * pRet = NULL;
+    if( !pFact || pFact == ClassFactory() )
+        pRet = this;
+    if( !pRet )
+        pRet = SotObject::Cast( pFact );
+    return pRet;
+}
 
 SvLockBytesRef MakeLockBytes_Impl( const OUString & rName, StreamMode nMode )
 {
@@ -285,9 +319,43 @@ public:
 };
 
 
-SO2_IMPL_BASIC_CLASS1_DLL(SotStorage,SotStorageFactory,SotObject,
-                          SvGlobalName( 0x980ce7e0, 0xf905, 0x11d0,
-                                        0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ) )
+SotFactory * SotStorage::ClassFactory()
+{
+    SotFactory **ppFactory = GetFactoryAdress();
+    if( !*ppFactory )
+    {
+        *ppFactory = new SotStorageFactory( SvGlobalName( 0x980ce7e0, 0xf905, 0x11d0,
+                                        0xaa, 0xa1, 0x0, 0xa0, 0x24, 0x9d, 0x55, 0x90 ),
+            OUString( "SotStorage" ), SotStorage::CreateInstance );
+        (*ppFactory)->PutSuperClass( SotObject::ClassFactory() );
+    }
+    return *ppFactory;
+}
+
+void * SotStorage::CreateInstance( SotObject ** ppObj )
+{
+    SotStorage * p = new SotStorage();
+    SotObject* pSuper1 = p;
+    SotObject* pBasicObj = pSuper1;
+    if( ppObj )
+        *ppObj = pBasicObj;
+    return p;
+}
+
+const SotFactory * SotStorage::GetSvFactory() const
+{
+    return ClassFactory();
+}
+
+void * SotStorage::Cast( const SotFactory * pFact )
+{
+    void * pRet = NULL;
+    if( !pFact || pFact == ClassFactory() )
+        pRet = this;
+    if( !pRet )
+        pRet = SotObject::Cast( pFact );
+    return pRet;
+}
 
 /************************************************************************
 |*


More information about the Libreoffice-commits mailing list