1919#include " TileCacheManager.h"
2020
2121class CMapWinGISModule :
22- public ATL ::CAtlMfcModule
22+ public ATL ::CAtlMfcModule
2323{
2424public:
25- DECLARE_LIBID (LIBID_MapWinGIS);
26- DECLARE_REGISTRY_APPID_RESOURCEID (IDR_MAPWINGIS , " {8308CC9E-4AEF-4D31-9081-86CD61B9E641}" );
25+ DECLARE_LIBID (LIBID_MapWinGIS);
26+ DECLARE_REGISTRY_APPID_RESOURCEID (IDR_MAPWINGIS , " {8308CC9E-4AEF-4D31-9081-86CD61B9E641}" );
2727};
2828
2929#undef THIS_FILE
3030static char THIS_FILE [] = __FILE__;
3131
3232const GUID CDECL BASED_CODE _tlid = { 0xc368d713 , 0xcc5f , 0x40ed , { 0x9f , 0x53 , 0xf8 , 0x4f , 0xe1 , 0x97 , 0xb9 , 0x6a } };
3333const WORD _wVerMajor = 5 ;
34- const WORD _wVerMinor = 2 ;
34+ const WORD _wVerMinor = 3 ;
3535
3636CMapWinGISApp NEAR theApp;
3737CMapWinGISModule _AtlModule; // this one is from ATL7 (used by all ATL co-classes)
@@ -43,136 +43,136 @@ GlobalClassFactory m_factory; // make sure that this one is initialized after th
4343// ******************************************************
4444BOOL CMapWinGISApp::InitInstance ()
4545{
46- // let's generate floating point exceptions
47- #ifndef RELEASE_MODE
48- // _clearfp();
49- // _controlfp(0, EM_ZERODIVIDE);
50- #endif
46+ // let's generate floating point exceptions
47+ #ifndef RELEASE_MODE
48+ // _clearfp();
49+ // _controlfp(0, EM_ZERODIVIDE);
50+ #endif
51+
52+ Debug::Init ();
5153
52- Debug::Init ();
54+ // Neio modified 2009, following http_://www.mapwindow.org/phorum/read.php?7,12162 by gischai, for multi-language support
55+ // std::locale::global(std::locale(""));
56+ // 19-Oct-09 Rob Cairns: (See Bug 1446) - I hate doing this if it prevents our Chinese friends opening Chinese character shapefiles and data.
57+ // However, there are just too many bugs associated with this change. See Bug 1446 for more information. Changing back to classic.
58+ std::locale::global (std::locale (" C" ));
5359
54- // Neio modified 2009, following http_://www.mapwindow.org/phorum/read.php?7,12162 by gischai, for multi-language support
55- // std::locale::global(std::locale(""));
56- // 19-Oct-09 Rob Cairns: (See Bug 1446) - I hate doing this if it prevents our Chinese friends opening Chinese character shapefiles and data.
57- // However, there are just too many bugs associated with this change. See Bug 1446 for more information. Changing back to classic.
58- std::locale::global (std::locale (" C" ));
60+ // http_://stackoverflow.com/questions/7659127/createex-causes-unhandled-exception-the-activation-context-being-deactivated-is
61+ // AfxSetAmbientActCtx(FALSE);
5962
60- // http_://stackoverflow.com/questions/7659127/createex-causes-unhandled-exception-the-activation-context-being-deactivated-is
61- // AfxSetAmbientActCtx(FALSE);
63+ // UTF8 string are expected by default; the enviroment variable shoud be set to restore older behavior
64+ // see more details here: http_://trac.osgeo.org/gdal/wiki/ConfigOptions
65+ m_globalSettings.SetGdalUtf8 (false );
6266
63- // UTF8 string are expected by default; the enviroment variable shoud be set to restore older behavior
64- // see more details here: http_://trac.osgeo.org/gdal/wiki/ConfigOptions
65- m_globalSettings.SetGdalUtf8 (false );
66-
67- GdalHelper::SetDefaultConfigPaths ();
67+ GdalHelper::SetDefaultConfigPaths ();
6868
69- parser::InitializeFunctions ();
69+ parser::InitializeFunctions ();
7070
71- // initialize all static variables, to keep our memory leaking report clean from them
71+ // initialize all static variables, to keep our memory leaking report clean from them
7272#ifdef _DEBUG
73- gMemLeakDetect .stopped = true ;
74- GDALAllRegister ();
75- gMemLeakDetect .stopped = false ;
73+ gMemLeakDetect .stopped = true ;
74+ GDALAllRegister ();
75+ gMemLeakDetect .stopped = false ;
7676#endif
7777
78- // CMapView::GdiplusStartup(); // moved back to CMapView constructor
78+ // CMapView::GdiplusStartup(); // moved back to CMapView constructor
7979
80- return COleControlModule::InitInstance () && InitATL ();
80+ return COleControlModule::InitInstance () && InitATL ();
8181}
8282
8383// *****************************************************
8484// CMapWinGISApp::ExitInstance - DLL termination
8585// *****************************************************
8686int CMapWinGISApp::ExitInstance ()
8787{
88- CPLErrorReset ();
88+ CPLErrorReset ();
8989
90- MercatorProjection::ReleaseGeoProjection ();
90+ MercatorProjection::ReleaseGeoProjection ();
9191
92- #ifndef RELEASE_MODE
92+ #ifndef RELEASE_MODE
9393
94- CComBSTR bstr;
94+ CComBSTR bstr;
9595 // make sure m_utils is still extant
96- if (m_utils)
97- {
98- m_utils->get_ComUsageReport (VARIANT_TRUE , &bstr);
99- }
96+ if (m_utils)
97+ {
98+ m_utils->get_ComUsageReport (VARIANT_TRUE , &bstr);
99+ }
100100
101- USES_CONVERSION ;
102- CString s = OLE2A (bstr);
103- Debug::WriteLine (s);
101+ USES_CONVERSION ;
102+ CString s = OLE2A (bstr);
103+ Debug::WriteLine (s);
104104
105- #endif
105+ #endif
106106
107- if (m_utils)
108- {
109- m_utils->Release ();
110- }
107+ if (m_utils)
108+ {
109+ m_utils->Release ();
110+ }
111111
112- TileCacheManager::CloseAll ();
112+ TileCacheManager::CloseAll ();
113113
114- PrefetchManagerFactory::Clear ();
114+ PrefetchManagerFactory::Clear ();
115115
116- parser::ReleaseFunctions ();
116+ parser::ReleaseFunctions ();
117117
118- // CMapView::GdiplusShutdown(); // moved back to CMapView destructor
118+ // CMapView::GdiplusShutdown(); // moved back to CMapView destructor
119119
120- _Module.Term ();
121- return COleControlModule::ExitInstance ();
120+ _Module.Term ();
121+ return COleControlModule::ExitInstance ();
122122}
123123
124124// **************************************************************
125125// DllRegisterServer - Adds entries to the system registry
126126// **************************************************************
127127STDAPI DllRegisterServer (void )
128128{
129- _AtlModule.UpdateRegistryAppId (TRUE );
130- HRESULT hRes2 = _AtlModule.RegisterServer (TRUE );
131- if (hRes2 != S_OK )
132- return hRes2;
133- AFX_MANAGE_STATE (_afxModuleAddrThis);
129+ _AtlModule.UpdateRegistryAppId (TRUE );
130+ HRESULT hRes2 = _AtlModule.RegisterServer (TRUE );
131+ if (hRes2 != S_OK )
132+ return hRes2;
133+ AFX_MANAGE_STATE (_afxModuleAddrThis);
134+
135+ if (!AfxOleRegisterTypeLib (AfxGetInstanceHandle (), _tlid))
136+ return ResultFromScode (SELFREG_E_TYPELIB );
134137
135- if (!AfxOleRegisterTypeLib ( AfxGetInstanceHandle (), _tlid ))
136- return ResultFromScode (SELFREG_E_TYPELIB );
138+ if (!COleObjectFactoryEx::UpdateRegistryAll ( TRUE ))
139+ return ResultFromScode (SELFREG_E_CLASS );
137140
138- if (!COleObjectFactoryEx::UpdateRegistryAll (TRUE ))
139- return ResultFromScode (SELFREG_E_CLASS );
141+ return _Module.RegisterServer (TRUE );
140142
141- return _Module.RegisterServer (TRUE );
142-
143143
144- return NOERROR ;
144+ return NOERROR ;
145145}
146146
147147// **************************************************************
148148// GetModuleInstance
149149// **************************************************************
150150HINSTANCE GetModuleInstance ()
151151{
152- HINSTANCE instance = _Module.GetModuleInstance ();
153- return instance;
152+ HINSTANCE instance = _Module.GetModuleInstance ();
153+ return instance;
154154}
155155
156156// **************************************************************
157157// DllUnregisterServer - Removes entries from the system registry
158158// **************************************************************
159159STDAPI DllUnregisterServer (void )
160160{
161- _AtlModule.UpdateRegistryAppId (FALSE );
162- HRESULT hRes2 = _AtlModule.UnregisterServer (TRUE );
163- if (hRes2 != S_OK )
164- return hRes2;
165- AFX_MANAGE_STATE (_afxModuleAddrThis);
161+ _AtlModule.UpdateRegistryAppId (FALSE );
162+ HRESULT hRes2 = _AtlModule.UnregisterServer (TRUE );
163+ if (hRes2 != S_OK )
164+ return hRes2;
165+ AFX_MANAGE_STATE (_afxModuleAddrThis);
166166
167- if (!AfxOleUnregisterTypeLib (_tlid, _wVerMajor, _wVerMinor))
168- return ResultFromScode (SELFREG_E_TYPELIB );
167+ if (!AfxOleUnregisterTypeLib (_tlid, _wVerMajor, _wVerMinor))
168+ return ResultFromScode (SELFREG_E_TYPELIB );
169169
170- if (!COleObjectFactoryEx::UpdateRegistryAll (FALSE ))
171- return ResultFromScode (SELFREG_E_CLASS );
170+ if (!COleObjectFactoryEx::UpdateRegistryAll (FALSE ))
171+ return ResultFromScode (SELFREG_E_CLASS );
172172
173- _Module.UnregisterServer (TRUE ); // TRUE indicates that typelib is unreg'd
173+ _Module.UnregisterServer (TRUE ); // TRUE indicates that typelib is unreg'd
174174
175- return NOERROR ;
175+ return NOERROR ;
176176}
177177
178178#if !defined(_WIN32_WCE) && !defined(_AMD64_) && !defined(_IA64_)
@@ -199,12 +199,12 @@ STDAPI DllUnregisterServer(void)
199199// **************************************************************
200200STDAPI DllCanUnloadNow (void )
201201{
202- AFX_MANAGE_STATE (AfxGetStaticModuleState ());
203-
204- if (_AtlModule.GetLockCount () > 0 )
205- return S_FALSE ;
206-
207- return (AfxDllCanUnloadNow ()== S_OK && _Module.GetLockCount ()== 0 ) ? S_OK : S_FALSE ;
202+ AFX_MANAGE_STATE (AfxGetStaticModuleState ());
203+
204+ if (_AtlModule.GetLockCount () > 0 )
205+ return S_FALSE ;
206+
207+ return (AfxDllCanUnloadNow () == S_OK && _Module.GetLockCount () == 0 ) ? S_OK : S_FALSE ;
208208}
209209
210210// ******************************************************************
@@ -213,25 +213,25 @@ STDAPI DllCanUnloadNow(void)
213213STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID * ppv)
214214{
215215#ifdef _DEBUG
216- bool state = gMemLeakDetect .stopped ;
217- gMemLeakDetect .stopped = true ;
216+ bool state = gMemLeakDetect .stopped ;
217+ gMemLeakDetect .stopped = true ;
218218#endif
219219
220- AFX_MANAGE_STATE (AfxGetStaticModuleState ());
221-
222- HRESULT hres;
223- if (S_OK == _AtlModule.GetClassObject (rclsid, riid, ppv))
224- hres = S_OK ;
225- else if (AfxDllGetClassObject (rclsid, riid, ppv) == S_OK )
226- hres = S_OK ;
227- else
228- hres = _Module.GetClassObject (rclsid, riid, ppv);
229-
220+ AFX_MANAGE_STATE (AfxGetStaticModuleState ());
221+
222+ HRESULT hres;
223+ if (S_OK == _AtlModule.GetClassObject (rclsid, riid, ppv))
224+ hres = S_OK ;
225+ else if (AfxDllGetClassObject (rclsid, riid, ppv) == S_OK )
226+ hres = S_OK ;
227+ else
228+ hres = _Module.GetClassObject (rclsid, riid, ppv);
229+
230230#ifdef _DEBUG
231- gMemLeakDetect .stopped = state;
231+ gMemLeakDetect .stopped = state;
232232#endif
233233
234- return hres;
234+ return hres;
235235}
236236
237237// *****************************************************************
@@ -241,8 +241,8 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
241241// According to MSDN this macro is obsolete. OBJECT_ENTRY_AUTO should be used instead
242242BEGIN_OBJECT_MAP (ObjectMap)
243243#ifdef OLD_API
244- OBJECT_ENTRY (CLSID_ShapefileColorScheme, CShapefileColorScheme)
245- OBJECT_ENTRY(CLSID_ShapefileColorBreak, CShapefileColorBreak)
244+ OBJECT_ENTRY (CLSID_ShapefileColorScheme, CShapefileColorScheme)
245+ OBJECT_ENTRY(CLSID_ShapefileColorBreak, CShapefileColorBreak)
246246#endif
247247END_OBJECT_MAP ()
248248
@@ -251,6 +251,6 @@ END_OBJECT_MAP()
251251// *****************************************************************
252252BOOL CMapWinGISApp::InitATL ()
253253{
254- _Module.Init (ObjectMap, AfxGetInstanceHandle ());
255- return TRUE ;
254+ _Module.Init (ObjectMap, AfxGetInstanceHandle ());
255+ return TRUE ;
256256}
0 commit comments