1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_fpicker.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski //----------------------------------------------
28*b1cdbd2cSJim Jagielski // includes of other projects
29*b1cdbd2cSJim Jagielski //----------------------------------------------
30*b1cdbd2cSJim Jagielski #include <cppuhelper/factory.hxx>
31*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XSet.hpp>
32*b1cdbd2cSJim Jagielski #include <osl/diagnose.h>
33*b1cdbd2cSJim Jagielski #include "SalGtkFilePicker.hxx"
34*b1cdbd2cSJim Jagielski #include "SalGtkFolderPicker.hxx"
35*b1cdbd2cSJim Jagielski #include <vcl/svapp.hxx>
36*b1cdbd2cSJim Jagielski #include "FPServiceInfo.hxx"
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim Jagielski #include <glib-object.h>
39*b1cdbd2cSJim Jagielski
40*b1cdbd2cSJim Jagielski extern const guint gtk_major_version;
41*b1cdbd2cSJim Jagielski extern const guint gtk_minor_version;
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski //-----------------------------------------------
44*b1cdbd2cSJim Jagielski // namespace directives
45*b1cdbd2cSJim Jagielski //-----------------------------------------------
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim Jagielski using namespace ::rtl;
48*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::uno;
49*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::container;
50*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::lang;
51*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::registry;
52*b1cdbd2cSJim Jagielski using namespace ::cppu;
53*b1cdbd2cSJim Jagielski using ::com::sun::star::ui::dialogs::XFilePicker;
54*b1cdbd2cSJim Jagielski using ::com::sun::star::ui::dialogs::XFilePicker2;
55*b1cdbd2cSJim Jagielski using ::com::sun::star::ui::dialogs::XFolderPicker;
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim Jagielski //------------------------------------------------
58*b1cdbd2cSJim Jagielski //
59*b1cdbd2cSJim Jagielski //------------------------------------------------
60*b1cdbd2cSJim Jagielski
createFileInstance(const Reference<XMultiServiceFactory> & rServiceManager)61*b1cdbd2cSJim Jagielski static Reference< XInterface > SAL_CALL createFileInstance(
62*b1cdbd2cSJim Jagielski const Reference< XMultiServiceFactory >& rServiceManager )
63*b1cdbd2cSJim Jagielski {
64*b1cdbd2cSJim Jagielski return Reference< XInterface >(
65*b1cdbd2cSJim Jagielski static_cast< XFilePicker2* >(
66*b1cdbd2cSJim Jagielski new SalGtkFilePicker( rServiceManager ) ) );
67*b1cdbd2cSJim Jagielski }
68*b1cdbd2cSJim Jagielski
createFolderInstance(const Reference<XMultiServiceFactory> & rServiceManager)69*b1cdbd2cSJim Jagielski static Reference< XInterface > SAL_CALL createFolderInstance(
70*b1cdbd2cSJim Jagielski const Reference< XMultiServiceFactory >& rServiceManager )
71*b1cdbd2cSJim Jagielski {
72*b1cdbd2cSJim Jagielski return Reference< XInterface >(
73*b1cdbd2cSJim Jagielski static_cast< XFolderPicker* >(
74*b1cdbd2cSJim Jagielski new SalGtkFolderPicker( rServiceManager ) ) );
75*b1cdbd2cSJim Jagielski }
76*b1cdbd2cSJim Jagielski
77*b1cdbd2cSJim Jagielski //------------------------------------------------
78*b1cdbd2cSJim Jagielski // the three uno functions that will be exported
79*b1cdbd2cSJim Jagielski //------------------------------------------------
80*b1cdbd2cSJim Jagielski
81*b1cdbd2cSJim Jagielski extern "C"
82*b1cdbd2cSJim Jagielski {
83*b1cdbd2cSJim Jagielski
84*b1cdbd2cSJim Jagielski //------------------------------------------------
85*b1cdbd2cSJim Jagielski // component_getImplementationEnvironment
86*b1cdbd2cSJim Jagielski //------------------------------------------------
87*b1cdbd2cSJim Jagielski
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)88*b1cdbd2cSJim Jagielski void SAL_CALL component_getImplementationEnvironment(
89*b1cdbd2cSJim Jagielski const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
90*b1cdbd2cSJim Jagielski {
91*b1cdbd2cSJim Jagielski *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
92*b1cdbd2cSJim Jagielski }
93*b1cdbd2cSJim Jagielski
94*b1cdbd2cSJim Jagielski //------------------------------------------------
95*b1cdbd2cSJim Jagielski //
96*b1cdbd2cSJim Jagielski //------------------------------------------------
97*b1cdbd2cSJim Jagielski
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)98*b1cdbd2cSJim Jagielski void* SAL_CALL component_getFactory(
99*b1cdbd2cSJim Jagielski const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
100*b1cdbd2cSJim Jagielski {
101*b1cdbd2cSJim Jagielski void* pRet = 0;
102*b1cdbd2cSJim Jagielski
103*b1cdbd2cSJim Jagielski if( pSrvManager )
104*b1cdbd2cSJim Jagielski {
105*b1cdbd2cSJim Jagielski if (
106*b1cdbd2cSJim Jagielski /* crude gtkplug check */ !g_type_from_name( "GdkDisplay" ) ||
107*b1cdbd2cSJim Jagielski /* old version */ !( gtk_major_version >= 2 && gtk_minor_version >= 4 )
108*b1cdbd2cSJim Jagielski )
109*b1cdbd2cSJim Jagielski {
110*b1cdbd2cSJim Jagielski return 0;
111*b1cdbd2cSJim Jagielski }
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski Reference< XSingleServiceFactory > xFactory;
114*b1cdbd2cSJim Jagielski
115*b1cdbd2cSJim Jagielski if (0 == rtl_str_compare(pImplName, FILE_PICKER_IMPL_NAME))
116*b1cdbd2cSJim Jagielski {
117*b1cdbd2cSJim Jagielski Sequence< OUString > aSNS( 1 );
118*b1cdbd2cSJim Jagielski aSNS.getArray( )[0] =
119*b1cdbd2cSJim Jagielski OUString::createFromAscii(FILE_PICKER_SERVICE_NAME);
120*b1cdbd2cSJim Jagielski
121*b1cdbd2cSJim Jagielski xFactory = createSingleFactory(
122*b1cdbd2cSJim Jagielski reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
123*b1cdbd2cSJim Jagielski OUString::createFromAscii( pImplName ),
124*b1cdbd2cSJim Jagielski createFileInstance,
125*b1cdbd2cSJim Jagielski aSNS );
126*b1cdbd2cSJim Jagielski }
127*b1cdbd2cSJim Jagielski else if (0 == rtl_str_compare(pImplName, FOLDER_PICKER_IMPL_NAME))
128*b1cdbd2cSJim Jagielski {
129*b1cdbd2cSJim Jagielski Sequence< OUString > aSNS( 1 );
130*b1cdbd2cSJim Jagielski aSNS.getArray( )[0] =
131*b1cdbd2cSJim Jagielski OUString::createFromAscii(FOLDER_PICKER_SERVICE_NAME);
132*b1cdbd2cSJim Jagielski
133*b1cdbd2cSJim Jagielski xFactory = createSingleFactory(
134*b1cdbd2cSJim Jagielski reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
135*b1cdbd2cSJim Jagielski OUString::createFromAscii( pImplName ),
136*b1cdbd2cSJim Jagielski createFolderInstance,
137*b1cdbd2cSJim Jagielski aSNS );
138*b1cdbd2cSJim Jagielski }
139*b1cdbd2cSJim Jagielski
140*b1cdbd2cSJim Jagielski if ( xFactory.is() )
141*b1cdbd2cSJim Jagielski {
142*b1cdbd2cSJim Jagielski xFactory->acquire();
143*b1cdbd2cSJim Jagielski pRet = xFactory.get();
144*b1cdbd2cSJim Jagielski }
145*b1cdbd2cSJim Jagielski }
146*b1cdbd2cSJim Jagielski
147*b1cdbd2cSJim Jagielski return pRet;
148*b1cdbd2cSJim Jagielski }
149*b1cdbd2cSJim Jagielski
150*b1cdbd2cSJim Jagielski } // extern "C"
151*b1cdbd2cSJim Jagielski
152