1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FPentry.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_fpicker.hxx"
34 //----------------------------------------------
35 // includes of other projects
36 //----------------------------------------------
37 #include <cppuhelper/factory.hxx>
38 #include <com/sun/star/container/XSet.hpp>
39 #include <osl/diagnose.h>
40 #include "SalGtkFilePicker.hxx"
41 #include "SalGtkFolderPicker.hxx"
42 #include <vcl/svapp.hxx>
43 #include "FPServiceInfo.hxx"
45 #include <glib-object.h>
47 extern const guint gtk_major_version
;
48 extern const guint gtk_minor_version
;
50 //-----------------------------------------------
51 // namespace directives
52 //-----------------------------------------------
54 using namespace ::rtl
;
55 using namespace ::com::sun::star::uno
;
56 using namespace ::com::sun::star::container
;
57 using namespace ::com::sun::star::lang
;
58 using namespace ::com::sun::star::registry
;
59 using namespace ::cppu
;
60 using ::com::sun::star::ui::dialogs::XFilePicker
;
61 using ::com::sun::star::ui::dialogs::XFilePicker2
;
62 using ::com::sun::star::ui::dialogs::XFolderPicker
;
64 //------------------------------------------------
66 //------------------------------------------------
68 static Reference
< XInterface
> SAL_CALL
createFileInstance(
69 const Reference
< XMultiServiceFactory
>& rServiceManager
)
71 return Reference
< XInterface
>(
72 static_cast< XFilePicker2
* >(
73 new SalGtkFilePicker( rServiceManager
) ) );
76 static Reference
< XInterface
> SAL_CALL
createFolderInstance(
77 const Reference
< XMultiServiceFactory
>& rServiceManager
)
79 return Reference
< XInterface
>(
80 static_cast< XFolderPicker
* >(
81 new SalGtkFolderPicker( rServiceManager
) ) );
84 //------------------------------------------------
85 // the three uno functions that will be exported
86 //------------------------------------------------
91 //------------------------------------------------
92 // component_getImplementationEnvironment
93 //------------------------------------------------
95 void SAL_CALL
component_getImplementationEnvironment(
96 const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
98 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
101 //------------------------------------------------
103 //------------------------------------------------
105 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey
)
107 sal_Bool bRetVal
= sal_True
;
113 Reference
< XRegistryKey
> pXNewKey( static_cast< XRegistryKey
* >( pRegistryKey
) );
114 pXNewKey
->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME
) );
115 pXNewKey
->createKey( OUString::createFromAscii( FOLDER_PICKER_REGKEY_NAME
) );
117 catch( InvalidRegistryException
& )
119 OSL_ENSURE( sal_False
, "InvalidRegistryException caught" );
127 //------------------------------------------------
129 //------------------------------------------------
131 void* SAL_CALL
component_getFactory(
132 const sal_Char
* pImplName
, uno_Interface
* pSrvManager
, uno_Interface
* /*pRegistryKey*/ )
139 /* crude gtkplug check */ !g_type_from_name( "GdkDisplay" ) ||
140 /* old version */ !( gtk_major_version
>= 2 && gtk_minor_version
>= 4 )
146 Reference
< XSingleServiceFactory
> xFactory
;
148 if (0 == rtl_str_compare(pImplName
, FILE_PICKER_IMPL_NAME
))
150 Sequence
< OUString
> aSNS( 1 );
151 aSNS
.getArray( )[0] =
152 OUString::createFromAscii(FILE_PICKER_SERVICE_NAME
);
154 xFactory
= createSingleFactory(
155 reinterpret_cast< XMultiServiceFactory
* > ( pSrvManager
),
156 OUString::createFromAscii( pImplName
),
160 else if (0 == rtl_str_compare(pImplName
, FOLDER_PICKER_IMPL_NAME
))
162 Sequence
< OUString
> aSNS( 1 );
163 aSNS
.getArray( )[0] =
164 OUString::createFromAscii(FOLDER_PICKER_SERVICE_NAME
);
166 xFactory
= createSingleFactory(
167 reinterpret_cast< XMultiServiceFactory
* > ( pSrvManager
),
168 OUString::createFromAscii( pImplName
),
169 createFolderInstance
,
176 pRet
= xFactory
.get();