xref: /aoo42x/main/embedserv/source/embed/esdll.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #define STRICT
29 #define _WIN32_WINNT 0x0400
30 #define _WIN32_DCOM
31 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
32 #undef _DEBUG
33 #endif
34 #if defined(_MSC_VER) && (_MSC_VER > 1310)
35 #pragma warning(disable : 4917 4555)
36 #endif
37 
38 #ifdef __MINGW32__
39 #define _INIT_ATL_COMMON_VARS
40 #endif
41 
42 #include "stdafx.h"
43 
44 #include <atlbase.h>
45 #ifdef _MSC_VER
46 #pragma warning( push )
47 #pragma warning( disable: 4710 )
48 #endif
49 CComModule _Module;
50 #ifdef _MSC_VER
51 #pragma warning( pop )
52 #endif
53 #include <atlcom.h>
54 
55 BEGIN_OBJECT_MAP(ObjectMap)
56 END_OBJECT_MAP()
57 
58 /////////////////////////////////////////////////////////////////////////////
59 // DLL Entry Point
60 
61 
62 #include "syswinwrapper.hxx"
63 #include "docholder.hxx"
64 
65 
66 HINSTANCE DocumentHolder::m_hInstance;
67 
68 extern "C"
69 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
70 {
71     DocumentHolder::m_hInstance = hInstance;
72     if (!winwrap::HatchWindowRegister(hInstance))
73         return FALSE;
74 
75     if (dwReason == DLL_PROCESS_ATTACH)
76     {
77         _Module.Init(ObjectMap, hInstance, NULL);
78         DisableThreadLibraryCalls(hInstance);
79     }
80     else if (dwReason == DLL_PROCESS_DETACH)
81     {
82         _Module.Term();
83     }
84     return TRUE;    // ok
85 }
86 
87 // Fix strange warnings about some
88 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
89 // warning C4505: 'xxx' : unreferenced local function has been removed
90 #if defined(_MSC_VER)
91 #pragma warning(disable: 4505)
92 #endif