xref: /aoo41x/main/vcl/unx/kde4/main.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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_vcl.hxx"
30 
31 #define Region QtXRegion
32 #include <QApplication>
33 #undef Region
34 
35 #include "KDEData.hxx"
36 #include "KDESalInstance.hxx"
37 
38 #include "vclpluginapi.h"
39 
40 #if OSL_DEBUG_LEVEL > 1
41 #include <stdio.h>
42 #endif
43 
44 #include <rtl/string.hxx>
45 
46 /// entry point for the KDE4 VCL plugin
47 extern "C" {
48 	VCLPLUG_KDE4_PUBLIC SalInstance* create_SalInstance( oslModule )
49 	{
50         /* #i92121# workaround deadlocks in the X11 implementation
51         */
52         static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
53         /* #i90094#
54            from now on we know that an X connection will be
55            established, so protect X against itself
56         */
57         if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
58             XInitThreads();
59 
60 #if QT_VERSION < 0x050000
61 		// Qt 4.x support needs >= 4.1.0
62 		rtl::OString aVersion( qVersion() );
63 #if OSL_DEBUG_LEVEL > 1
64 		fprintf( stderr, "qt version string is \"%s\"\n", aVersion.getStr() );
65 #endif
66 		sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0, nMicro = 0;
67 		nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32();
68 		if( nIndex > 0 )
69 			nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
70 		if( nIndex > 0 )
71 			nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
72 		if( nMajor != 4 || nMinor < 1 )
73 		{
74 #if OSL_DEBUG_LEVEL > 1
75 			fprintf( stderr, "unsuitable qt version %d.%d.%d\n", nMajor, nMinor, nMicro );
76 #endif
77 			return NULL;
78 		}
79 #endif
80 
81 		KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() );
82 #if OSL_DEBUG_LEVEL > 1
83 		fprintf( stderr, "created KDESalInstance 0x%p\n", pInstance );
84 #endif
85 
86 		// initialize SalData
87 		KDEData *salData = new KDEData();
88 		SetSalData(salData);
89 		salData->m_pInstance = pInstance;
90 		salData->Init();
91 		salData->initNWF();
92 
93 		return pInstance;
94 	}
95 }
96