Update ooo320-m1
[ooovba.git] / desktop / win32 / source / setup / setup_main.cxx
blob28fc251ea717e41c6bccb58c0540613ab48f9483
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_desktop.hxx"
31 #if defined _MSC_VER
32 #pragma warning(push, 1)
33 #endif
34 #include <windows.h>
35 #if defined _MSC_VER
36 #pragma warning(pop)
37 #endif
38 #include <new>
40 #include "setup_main.hxx"
42 //--------------------------------------------------------------------------
44 void __cdecl newhandler()
46 throw std::bad_alloc();
47 return;
50 //--------------------------------------------------------------------------
52 SetupApp::SetupApp()
54 m_uiRet = ERROR_SUCCESS;
56 // Get OS version
57 OSVERSIONINFO sInfoOS;
59 ZeroMemory( &sInfoOS, sizeof(OSVERSIONINFO) );
60 sInfoOS.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
62 GetVersionEx( &sInfoOS );
64 m_nOSVersion = sInfoOS.dwMajorVersion;
65 m_nMinorVersion = sInfoOS.dwMinorVersion;
66 m_bIsWin9x = ( VER_PLATFORM_WIN32_NT != sInfoOS.dwPlatformId );
67 m_bNeedReboot = false;
68 m_bAdministrative = false;
71 //--------------------------------------------------------------------------
73 SetupApp::~SetupApp()
77 //--------------------------------------------------------------------------
78 //--------------------------------------------------------------------------
79 //--------------------------------------------------------------------------
81 extern "C" int __stdcall WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int )
83 // Get OS version
84 OSVERSIONINFO sInfoOS;
86 ZeroMemory( &sInfoOS, sizeof(OSVERSIONINFO) );
87 sInfoOS.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
89 GetVersionEx( &sInfoOS );
91 boolean bIsWin9x = ( VER_PLATFORM_WIN32_NT != sInfoOS.dwPlatformId );
93 SetupApp *pSetup;
95 if ( bIsWin9x )
96 pSetup = Create_SetupAppA();
97 else
98 pSetup = Create_SetupAppW();
102 if ( ! pSetup->Initialize( hInst ) )
103 throw pSetup->GetError();
105 if ( pSetup->AlreadyRunning() )
106 throw (UINT) ERROR_INSTALL_ALREADY_RUNNING;
108 if ( ! pSetup->ReadProfile() )
109 throw pSetup->GetError();
111 if ( ! pSetup->CheckVersion() )
112 throw pSetup->GetError();
114 if ( ! pSetup->IsAdminInstall() )
115 if ( ! pSetup->GetPatches() )
116 throw pSetup->GetError();
118 // CheckForUpgrade() has to be called after calling GetPatches()!
119 if ( ! pSetup->CheckForUpgrade() )
120 throw pSetup->GetError();
122 long nLanguage;
124 if ( ! pSetup->ChooseLanguage( nLanguage ) )
125 throw pSetup->GetError();
127 if ( ! pSetup->Install( nLanguage ) )
128 throw pSetup->GetError();
130 catch ( std::bad_alloc )
132 pSetup->DisplayError( ERROR_OUTOFMEMORY );
134 catch ( UINT nErr )
136 pSetup->DisplayError( nErr );
139 int nRet = pSetup->GetError();
141 delete pSetup;
143 return nRet;