Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


In an effort to make building under windows a pain-free as possible. I'm
playing with removing the atl usage in embedserv seeing as MSVC2008
Express doesn't come with it.

voodoo-programming in embedserv using:
http://samscode.blogspot.com/2009/10/atl-removal-part-1-removing-begincommap.html

I end up with the attached.

a) I haven't a clue what embedserv even does, or how to test it ?
b) I see that we have...

CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
END_OBJECT_MAP()

_Module.Init(ObjectMap, hInstance, NULL);
...
_Module.Term();

because I'm clueless, I'm wondering if this even makes sense when we
have an empty OBJECT_MAP ?, or is still doing some necessary reference
counting of the module itself ? I mean we could follow
http://samscode.blogspot.com/2009/10/atl-removal-part-3-tackling-module-and.html and convert it 
over. But might be a bit silly to do that if its just some non-functional stub left over form some 
wizard generated code.

C.
diff --git a/embedserv/Library_emser.mk b/embedserv/Library_emser.mk
index 4cc20c3..c8089da 100644
--- a/embedserv/Library_emser.mk
+++ b/embedserv/Library_emser.mk
@@ -55,16 +55,6 @@ $(eval $(call gb_Library_use_libraries,emser,\
        $(gb_STDLIBS) \
 ))
 
-ifeq ($(USE_DEBUG_RUNTIME),)
-$(eval $(call gb_Library_add_libs,emser,\
-       $(ATL_LIB)/atls.lib \
-))
-else
-$(eval $(call gb_Library_add_libs,emser,\
-       $(ATL_LIB)/atlsd.lib \
-))
-endif
-
 $(eval $(call gb_Library_add_exception_objects,emser,\
        embedserv/source/embed/docholder \
        embedserv/source/embed/ed_idataobj \
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx
index 306c7aa..7d4f7df 100644
--- a/embedserv/source/embed/docholder.cxx
+++ b/embedserv/source/embed/docholder.cxx
@@ -75,6 +75,8 @@ using namespace ::com::sun::star;
 
 extern ::rtl::OUString  getFilterNameFromGUID_Impl( GUID* );
 
+_COM_SMARTPTR_TYPEDEF(IOleInPlaceActiveObject, __uuidof(IOleInPlaceActiveObject));
+
 // add mutex locking ???
 
 DocumentHolder::DocumentHolder(
@@ -528,7 +530,7 @@ HRESULT DocumentHolder::UIActivate()
     //3.  Set the active object
 
     OLECHAR starOffice[] = {'S','t','a','r','O','f','f','i','c','e',0};
-    CComPtr< IOleInPlaceActiveObject > pObj = new CIIAObj( this );
+    IOleInPlaceActiveObjectPtr pObj = new CIIAObj( this );
 
     if (NULL!=m_pIOleIPFrame)
         m_pIOleIPFrame->SetActiveObject(
diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx
index d4f75f4..4d570c5 100644
--- a/embedserv/source/embed/ed_idataobj.cxx
+++ b/embedserv/source/embed/ed_idataobj.cxx
@@ -29,25 +29,12 @@
 #pragma warning(disable : 4917 4555)
 #endif
 
-// actually this workaround should be in presys.h!
-//#define UINT64 USE_WIN_UINT64
-//#define INT64 USE_WIN_INT64
-//#define UINT32 USE_WIN_UINT32
-//#define INT32 USE_WIN_INT32
-
 #include "embeddoc.hxx"
 
-//#undef UINT64
-//#undef INT64
-//#undef UINT32
-//#undef INT32
-
-
 #include <com/sun/star/uno/Any.h>
 #include <com/sun/star/uno/Exception.hpp>
 #include <com/sun/star/datatransfer/XTransferable.hpp>
 
-
 #include <osl/thread.h>
 
 using namespace ::com::sun::star;
@@ -149,7 +136,7 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM
             if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
                 return DV_E_TYMED;
 
-            CComPtr< IStorage > pNewStg;
+            IStoragePtr pNewStg;
             HRESULT hr = StgCreateDocfile( NULL, STGM_CREATE | STGM_READWRITE | 
STGM_DELETEONRELEASE, 0, &pNewStg );
             if ( FAILED( hr ) || !pNewStg ) return STG_E_MEDIUMFULL;
 
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
index 8eadce0..f6f163e 100644
--- a/embedserv/source/embed/ed_ipersiststr.cxx
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -44,12 +44,13 @@
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/util/XUrlTransformer.hpp>
 
-
 #include <osl/mutex.hxx>
 #include <osl/diagnose.h>
 
 #include <string.h>
 
+_COM_SMARTPTR_TYPEDEF(IMalloc, __uuidof(IMalloc));
+
 #define EXT_STREAM_LENGTH 16
 
 using namespace ::com::sun::star;
@@ -276,8 +277,8 @@ HRESULT EmbedDocument_Impl::SaveTo_Impl( IStorage* pStg )
 
     // for saveto operation the master storage
     // should not enter NoScribble mode
-    CComPtr< IStream > pOrigOwn = m_pOwnStream;
-    CComPtr< IStream > pOrigExt = m_pExtStream;
+    IStreamPtr pOrigOwn = m_pOwnStream;
+    IStreamPtr pOrigExt = m_pExtStream;
     HRESULT hr = Save( pStg, sal_False );
     pStg->Commit( STGC_ONLYIFCURRENT );
     m_pOwnStream = pOrigOwn;
@@ -579,8 +580,8 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
 
     if ( FAILED( hr ) )
     {
-        m_pOwnStream = CComPtr< IStream >();
-        m_pExtStream = CComPtr< IStream >();
+        m_pOwnStream = IStreamPtr();
+        m_pExtStream = IStreamPtr();
         hr = pStg->DestroyElement( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()) );
         hr = pStg->DestroyElement( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()) );
 
@@ -597,8 +598,8 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )
     if ( !m_pDocHolder->GetDocument().is() || !m_xFactory.is() || !pStgSave || !m_pOwnStream || 
!m_pExtStream )
         return E_FAIL;
 
-    CComPtr< IStream > pTargetStream;
-    CComPtr< IStream > pNewExtStream;
+    IStreamPtr pTargetStream;
+    IStreamPtr pNewExtStream;
 
     if ( !fSameAsLoad && pStgSave != m_pMasterStorage )
     {
@@ -673,8 +674,8 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad )
 
                             if ( SUCCEEDED( hr ) )
                             {
-                                m_pOwnStream = CComPtr< IStream >();
-                                m_pExtStream = CComPtr< IStream >();
+                                m_pOwnStream = IStreamPtr();
+                                m_pExtStream = IStreamPtr();
                                 if ( fSameAsLoad || pStgSave == m_pMasterStorage )
                                 {
                                     uno::Reference< util::XModifiable > xMod( 
m_pDocHolder->GetDocument(), uno::UNO_QUERY );
@@ -748,9 +749,9 @@ STDMETHODIMP EmbedDocument_Impl::SaveCompleted( IStorage *pStgNew )
 
 STDMETHODIMP EmbedDocument_Impl::HandsOffStorage()
 {
-    m_pMasterStorage = CComPtr< IStorage >();
-    m_pOwnStream = CComPtr< IStream >();
-    m_pExtStream = CComPtr< IStream >();
+    m_pMasterStorage = IStoragePtr();
+    m_pOwnStream = IStreamPtr();
+    m_pExtStream = IStreamPtr();
 
     return S_OK;
 }
@@ -928,7 +929,7 @@ STDMETHODIMP EmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName )
 
 STDMETHODIMP EmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName )
 {
-    CComPtr<IMalloc> pMalloc;
+    IMallocPtr pMalloc;
 
     HRESULT hr = CoGetMalloc( 1, &pMalloc );
     if ( FAILED( hr ) || !pMalloc ) return E_FAIL;
diff --git a/embedserv/source/embed/esdll.cxx b/embedserv/source/embed/esdll.cxx
index ab92a97..1fb2ebf 100644
--- a/embedserv/source/embed/esdll.cxx
+++ b/embedserv/source/embed/esdll.cxx
@@ -29,30 +29,9 @@
 #define STRICT
 #define _WIN32_WINNT 0x0400
 #define _WIN32_DCOM
-#if defined(_MSC_VER) && (_MSC_VER > 1310)
-#pragma warning(disable : 4917 4555)
-#endif
-
-#ifdef __MINGW32__
-#define _INIT_ATL_COMMON_VARS
-#endif
 
 #include "stdafx.h"
 
-#include <atlbase.h>
-#ifdef _MSC_VER
-#pragma warning( push )
-#pragma warning( disable: 4710 )
-#endif
-CComModule _Module;
-#ifdef _MSC_VER
-#pragma warning( pop )
-#endif
-#include <atlcom.h>
-
-BEGIN_OBJECT_MAP(ObjectMap)
-END_OBJECT_MAP()
-
 /////////////////////////////////////////////////////////////////////////////
 // DLL Entry Point
 
@@ -72,20 +51,16 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
 
     if (dwReason == DLL_PROCESS_ATTACH)
     {
-        _Module.Init(ObjectMap, hInstance, NULL);
+        //TODO: with an empty ObjectMap do we still need this ?
+        //_Module.Init(ObjectMap, hInstance, NULL);
         DisableThreadLibraryCalls(hInstance);
     }
     else if (dwReason == DLL_PROCESS_DETACH)
     {
-        _Module.Term();
+        //TODO: with an empty ObjectMap do we still need this ?
+        //_Module.Term();
     }
     return TRUE;    // ok
 }
 
-// Fix strange warnings about some
-// ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
-// warning C4505: 'xxx' : unreferenced local function has been removed
-#if defined(_MSC_VER)
-#pragma warning(disable: 4505)
-#endif
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx
index 952774c..5e6782a 100644
--- a/embedserv/source/embed/servprov.cxx
+++ b/embedserv/source/embed/servprov.cxx
@@ -100,16 +100,16 @@ void o2u_attachCurrentThread()
 
     if ( oleThreadData.getData() != 0 )
     {
-        HINSTANCE inst= LoadLibrary( _T("ole32.dll"));
+        HINSTANCE inst= LoadLibrary("ole32.dll");
         if( inst )
         {
             HRESULT hr;
-            ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx"));
+            ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress(inst, "CoInitializeEx");
             if( initFuncEx)
                 hr= initFuncEx( NULL, COINIT_MULTITHREADED);
             else
             {
-                ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize"));
+                ptrCoInit initFunc= (ptrCoInit)GetProcAddress(inst, "CoInitialize");
                 if( initFunc)
                     hr= initFunc( NULL);
             }
@@ -127,7 +127,7 @@ EmbedServer_Impl::EmbedServer_Impl( const uno::Reference<lang::XMultiServiceFact
 {
     for( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
     {
-        m_pOLEFactories[nInd] = new EmbedProviderFactory_Impl( m_xFactory, guidList[nInd] );
+        m_pOLEFactories[nInd].reset(new EmbedProviderFactory_Impl(m_xFactory, guidList[nInd]));
         m_pOLEFactories[nInd]->registerClass();
     }
 }
diff --git a/embedserv/source/inc/docholder.hxx b/embedserv/source/inc/docholder.hxx
index 9655f49..ef80f48 100644
--- a/embedserv/source/inc/docholder.hxx
+++ b/embedserv/source/inc/docholder.hxx
@@ -42,6 +42,9 @@
 
 #include "embeddocaccess.hxx"
 
+#include <comdef.h>
+#include <comutil.h>
+
 class EmbedDocument_Impl;
 class Interceptor;
 class CIIAObj;
@@ -50,6 +53,8 @@ namespace winwrap {
     class CHatchWin;
 }
 
+_COM_SMARTPTR_TYPEDEF(IDispatch, __uuidof(IDispatch));
+
 
 class DocumentHolder :
     public ::cppu::WeakImplHelper4<
@@ -103,7 +108,7 @@ private:
 
     ::rtl::OUString m_aContainerName,m_aDocumentNamePart,m_aFilterName;
 
-    CComPtr< IDispatch > m_pIDispatch;
+    IDispatchPtr m_pIDispatch;
 
     sal_Bool m_bLink;
 
diff --git a/embedserv/source/inc/embeddoc.hxx b/embedserv/source/inc/embeddoc.hxx
index fef44f1..19bb3a5 100644
--- a/embedserv/source/inc/embeddoc.hxx
+++ b/embedserv/source/inc/embeddoc.hxx
@@ -46,6 +46,11 @@
 typedef ::boost::unordered_map< DWORD, IAdviseSink* > AdviseSinkHashMap;
 typedef ::boost::unordered_map< DWORD, IAdviseSink* >::iterator AdviseSinkHashMapIterator;
 
+_COM_SMARTPTR_TYPEDEF(IStorage, __uuidof(IStorage));
+_COM_SMARTPTR_TYPEDEF(IStream, __uuidof(IStream));
+_COM_SMARTPTR_TYPEDEF(IOleClientSite, __uuidof(IOleClientSite));
+_COM_SMARTPTR_TYPEDEF(IDataAdviseHolder, __uuidof(IDataAdviseHolder));
+
 class GDIMetaFile;
 class CIIAObj;
 
@@ -168,15 +173,15 @@ protected:
     DocumentHolder*                     m_pDocHolder;
     ::rtl::OUString                     m_aFileName;
 
-    CComPtr< IStorage >                 m_pMasterStorage;
-    CComPtr< IStream >                  m_pOwnStream;
-    CComPtr< IStream >                  m_pExtStream;
+    IStoragePtr                         m_pMasterStorage;
+    IStreamPtr                          m_pOwnStream;
+    IStreamPtr                          m_pExtStream;
     GUID                                m_guid;
 
     sal_Bool                            m_bIsDirty;
 
-    CComPtr< IOleClientSite >           m_pClientSite;
-    CComPtr< IDataAdviseHolder >        m_pDAdviseHolder;
+    IOleClientSitePtr                   m_pClientSite;
+    IDataAdviseHolderPtr                m_pDAdviseHolder;
 
     AdviseSinkHashMap                   m_aAdviseHashMap;
     DWORD                               m_nAdviseNum;
diff --git a/embedserv/source/inc/embeddocaccess.hxx b/embedserv/source/inc/embeddocaccess.hxx
index adb984c..59e246b 100644
--- a/embedserv/source/inc/embeddocaccess.hxx
+++ b/embedserv/source/inc/embeddocaccess.hxx
@@ -37,14 +37,6 @@
 #define OLESERV_DEACTIVATE      6
 
 #include <oleidl.h>
-#ifndef __MINGW32__
-#if defined(_MSC_VER) && (_MSC_VER > 1310)
-#pragma warning(disable : 4265)
-#include <atldbcli.h>
-#else
-#include <atlcomcli.h>
-#endif
-#endif
 #include <cppuhelper/weak.hxx>
 
 class EmbedDocument_Impl;
diff --git a/embedserv/source/inc/servprov.hxx b/embedserv/source/inc/servprov.hxx
index 963170c..d73f638 100644
--- a/embedserv/source/inc/servprov.hxx
+++ b/embedserv/source/inc/servprov.hxx
@@ -31,6 +31,7 @@
 
 #include "common.h"
 #include <oleidl.h>
+#include <boost/scoped_ptr.hpp>
 #include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/uno/Sequence.h>
 #include <com/sun/star/uno/XInterface.hpp>
@@ -60,7 +61,7 @@ public:
 
 protected:
 
-    CComPtr< EmbedProviderFactory_Impl > m_pOLEFactories[ SUPPORTED_FACTORIES_NUM ];
+    boost::scoped_ptr<EmbedProviderFactory_Impl> m_pOLEFactories[ SUPPORTED_FACTORIES_NUM ];
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
 };
 
diff --git a/embedserv/source/inc/stdafx.h b/embedserv/source/inc/stdafx.h
index c1110ac..01fd800 100644
--- a/embedserv/source/inc/stdafx.h
+++ b/embedserv/source/inc/stdafx.h
@@ -18,18 +18,14 @@
 #pragma warning(push, 1)
 #pragma warning(disable: 4548)
 #pragma warning(disable: 4505)
+#pragma warning(disable: 4702)
 #endif
-#include <atlbase.h>
-//You may derive a class from CComModule and use it if you want to override
-//something, but do not change the name of _Module
-extern CComModule _Module;
+#include <comip.h>
 #ifdef __MINGW32__
 #include <algorithm>
 using ::std::min;
 using ::std::max;
 #endif
-#include <atlcom.h>
-#include <atlctl.h>
 
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.