Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <tools/tempfile.hxx>
31 : :
32 : : #include <osl/file.hxx>
33 : :
34 : : #include <cppuhelper/servicefactory.hxx>
35 : :
36 : : #include <vcl/svapp.hxx>
37 : : #include <vcl/unohelp.hxx>
38 : :
39 : : #include <svdata.hxx>
40 : :
41 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
42 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 : : #include <comphelper/processfactory.hxx>
44 : :
45 : : #include <com/sun/star/i18n/XBreakIterator.hpp>
46 : : #include <com/sun/star/i18n/XCharacterClassification.hpp>
47 : : #include <com/sun/star/awt/XExtendedToolkit.hpp>
48 : : #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
49 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
50 : : #include <com/sun/star/registry/XImplementationRegistration.hpp>
51 : :
52 : :
53 : : using namespace ::com::sun::star;
54 : : using namespace ::rtl;
55 : :
56 : : #define DOSTRING( x ) #x
57 : : #define STRING( x ) DOSTRING( x )
58 : :
59 : : struct VCLRegServiceInfo
60 : : {
61 : : const sal_Char* pLibName;
62 : : sal_Bool bHasSUPD;
63 : : };
64 : :
65 : : static VCLRegServiceInfo aVCLComponentsArray[] =
66 : : {
67 : : {"i18n", sal_True},
68 : : {"i18npool", sal_True},
69 : : #ifdef UNX
70 : : #ifdef MACOSX
71 : : {"dtransaqua", sal_True},
72 : : #else
73 : : {"dtransX11", sal_True},
74 : : #endif
75 : : #endif
76 : : #if defined(WNT)
77 : : {"sysdtrans", sal_False},
78 : : #endif
79 : : {"dtrans", sal_False},
80 : : {"mcnttype", sal_False},
81 : : {"ftransl", sal_False},
82 : : {"dnd", sal_False},
83 : : {NULL, sal_False}
84 : : };
85 : :
86 : 9583 : uno::Reference< lang::XMultiServiceFactory > vcl::unohelper::GetMultiServiceFactory()
87 : : {
88 : 9583 : ImplSVData* pSVData = ImplGetSVData();
89 [ + + ]: 9583 : if ( !pSVData->maAppData.mxMSF.is() )
90 : : {
91 [ + - ]: 158 : pSVData->maAppData.mxMSF = ::comphelper::getProcessServiceFactory();
92 : : }
93 [ - + ]: 9583 : if ( !pSVData->maAppData.mxMSF.is() )
94 : : {
95 [ # # ]: 0 : TempFile aTempFile;
96 : 0 : OUString aTempFileName;
97 [ # # ][ # # ]: 0 : osl::FileBase::getSystemPathFromFileURL( aTempFile.GetName(), aTempFileName );
[ # # ][ # # ]
98 [ # # ][ # # ]: 0 : pSVData->maAppData.mpMSFTempFileName = new String(aTempFileName);
99 : :
100 : : try
101 : : {
102 [ # # ][ # # ]: 0 : pSVData->maAppData.mxMSF = ::cppu::createRegistryServiceFactory( aTempFileName, rtl::OUString(), sal_False );
103 : : uno::Reference < registry::XImplementationRegistration > xReg(
104 [ # # ][ # # ]: 0 : pSVData->maAppData.mxMSF->createInstance( OUString("com.sun.star.registry.ImplementationRegistration")), uno::UNO_QUERY );
[ # # ]
105 : :
106 [ # # ]: 0 : if( xReg.is() )
107 : : {
108 : 0 : sal_Int32 nCompCount = 0;
109 [ # # ]: 0 : while ( aVCLComponentsArray[ nCompCount ].pLibName )
110 : : {
111 [ # # ]: 0 : OUString aComponentPathString = CreateLibraryName( aVCLComponentsArray[ nCompCount ].pLibName, aVCLComponentsArray[ nCompCount ].bHasSUPD );
112 [ # # ]: 0 : if (!aComponentPathString.isEmpty() )
113 : : {
114 : : try
115 : : {
116 [ # # ]: 0 : xReg->registerImplementation(
117 [ # # ][ # # ]: 0 : OUString("com.sun.star.loader.SharedLibrary"),aComponentPathString, NULL );
[ # # ]
118 : : }
119 [ # # ]: 0 : catch( ::com::sun::star::uno::Exception & )
120 : : {
121 : : }
122 : : }
123 : 0 : nCompCount++;
124 : 0 : }
125 : 0 : }
126 : : }
127 [ # # # # ]: 0 : catch( ::com::sun::star::uno::Exception & )
128 : : {
129 [ # # # # ]: 0 : delete pSVData->maAppData.mpMSFTempFileName;
130 : 0 : pSVData->maAppData.mpMSFTempFileName = NULL;
131 [ # # ]: 0 : }
132 : : }
133 : 9583 : return pSVData->maAppData.mxMSF;
134 : : }
135 : :
136 : :
137 : 7 : uno::Reference < i18n::XBreakIterator > vcl::unohelper::CreateBreakIterator()
138 : : {
139 : 7 : uno::Reference < i18n::XBreakIterator > xB;
140 [ + - ]: 7 : uno::Reference< lang::XMultiServiceFactory > xMSF = GetMultiServiceFactory();
141 [ + - ]: 7 : if ( xMSF.is() )
142 : : {
143 [ + - ][ + - ]: 7 : uno::Reference < uno::XInterface > xI = xMSF->createInstance( ::rtl::OUString("com.sun.star.i18n.BreakIterator") );
144 [ + - ]: 7 : if ( xI.is() )
145 : : {
146 [ + - ][ + - ]: 7 : uno::Any x = xI->queryInterface( ::getCppuType((const uno::Reference< i18n::XBreakIterator >*)0) );
[ + - ]
147 [ + - ]: 7 : x >>= xB;
148 : 7 : }
149 : : }
150 : 7 : return xB;
151 : : }
152 : :
153 : 26 : uno::Reference < i18n::XCharacterClassification > vcl::unohelper::CreateCharacterClassification()
154 : : {
155 : 26 : uno::Reference < i18n::XCharacterClassification > xB;
156 [ + - ]: 26 : uno::Reference< lang::XMultiServiceFactory > xMSF = GetMultiServiceFactory();
157 [ + - ]: 26 : if ( xMSF.is() )
158 : : {
159 [ + - ][ + - ]: 26 : uno::Reference < uno::XInterface > xI = xMSF->createInstance( ::rtl::OUString("com.sun.star.i18n.CharacterClassification") );
160 [ + - ]: 26 : if ( xI.is() )
161 : : {
162 [ + - ][ + - ]: 26 : uno::Any x = xI->queryInterface( ::getCppuType((const uno::Reference< i18n::XCharacterClassification >*)0) );
[ + - ]
163 [ + - ]: 26 : x >>= xB;
164 : 26 : }
165 : : }
166 : 26 : return xB;
167 : : }
168 : :
169 : 15978 : ::rtl::OUString vcl::unohelper::CreateLibraryName( const sal_Char* pModName, sal_Bool bSUPD )
170 : : {
171 : : // create variable library name suffixes
172 : 15978 : OUString aDLLSuffix = OUString::createFromAscii( STRING(DLLPOSTFIX) );
173 : :
174 : 15978 : OUString aLibName;
175 : :
176 : : #if defined( WNT)
177 : : aLibName = OUString::createFromAscii( pModName );
178 : : if ( bSUPD )
179 : : {
180 : : aLibName += aDLLSuffix;
181 : : }
182 : : aLibName += rtl::OUString( ".dll" );
183 : : #else
184 : 15978 : aLibName = OUString( "lib" );
185 : 15978 : aLibName += OUString::createFromAscii( pModName );
186 [ + - ]: 15978 : if ( bSUPD )
187 : : {
188 : 15978 : aLibName += aDLLSuffix;
189 : : }
190 : : #ifdef MACOSX
191 : : aLibName += OUString( ".dylib" );
192 : : #else
193 : 15978 : aLibName += OUString( ".so" );
194 : : #endif
195 : : #endif
196 : :
197 : 15978 : return aLibName;
198 : : }
199 : :
200 : 59 : void vcl::unohelper::NotifyAccessibleStateEventGlobally( const ::com::sun::star::accessibility::AccessibleEventObject& rEventObject )
201 : : {
202 [ + - ][ + - ]: 59 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit > xExtToolkit( Application::GetVCLToolkit(), uno::UNO_QUERY );
203 [ + - ]: 59 : if ( xExtToolkit.is() )
204 : : {
205 : : // Only for focus events
206 : 59 : sal_Int16 nType = ::com::sun::star::accessibility::AccessibleStateType::INVALID;
207 : 59 : rEventObject.NewValue >>= nType;
208 [ + + ]: 59 : if ( nType == ::com::sun::star::accessibility::AccessibleStateType::FOCUSED )
209 [ + - ][ + - ]: 5 : xExtToolkit->fireFocusGained( rEventObject.Source );
210 : : else
211 : : {
212 : 54 : rEventObject.OldValue >>= nType;
213 [ + + ]: 54 : if ( nType == ::com::sun::star::accessibility::AccessibleStateType::FOCUSED )
214 [ + - ][ + - ]: 59 : xExtToolkit->fireFocusLost( rEventObject.Source );
215 : : }
216 : :
217 : 59 : }
218 : 59 : }
219 : :
220 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|