1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef FPICKER_WIN32_VISTA_FILEPICKER_HXX
25 #define FPICKER_WIN32_VISTA_FILEPICKER_HXX
26 
27 //-----------------------------------------------------------------------------
28 // includes
29 //-----------------------------------------------------------------------------
30 
31 #include "asyncrequests.hxx"
32 #include "VistaFilePickerImpl.hxx"
33 #include "VistaFilePickerEventHandler.hxx"
34 
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
39 #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
40 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
41 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
42 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
43 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
45 #include <com/sun/star/util/XCancellable.hpp>
46 
47 #include <cppuhelper/compbase10.hxx>
48 #include <cppuhelper/basemutex.hxx>
49 #include <rtl/ustring.hxx>
50 
51 //-----------------------------------------------------------------------------
52 // namespace
53 //-----------------------------------------------------------------------------
54 
55 #ifdef css
56     #error "Clash on using CSS as namespace define."
57 #else
58     #define css ::com::sun::star
59 #endif
60 
61 namespace fpicker{
62 namespace win32{
63 namespace vista{
64 
65 //-----------------------------------------------------------------------------
66 // types
67 //-----------------------------------------------------------------------------
68 
69 typedef ::cppu::WeakComponentImplHelper10<
70                 css::ui::dialogs::XFilePicker2,
71                 css::ui::dialogs::XFilterManager,
72                 css::ui::dialogs::XFilterGroupManager,
73                 css::ui::dialogs::XFilePickerControlAccess,
74                 css::ui::dialogs::XFilePickerNotifier,
75                 css::ui::dialogs::XFilePreview,
76                 css::lang::XInitialization,
77                 css::util::XCancellable,
78                 css::lang::XEventListener,
79                 css::lang::XServiceInfo >   TVistaFilePickerBase;
80 
81 //-----------------------------------------------------------------------------
82 /** Implements the XFilePicker & friends interface(s)
83     for Windows Vista and upcoming versions.
84 
85     Note: This will be an UNO wrapper for the real file picker
86     implementation oly. The real implementation is done in class
87     VistaFilePickerImpl.
88  */
89 class VistaFilePicker : public ::cppu::BaseMutex
90                       , public TVistaFilePickerBase
91 {
92 public:
93 
94 	//------------------------------------------------------------------------------------
95 	// ctor/dtor
96 	//------------------------------------------------------------------------------------
97 
98              VistaFilePicker( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
99 	virtual ~VistaFilePicker();
100 
101 	//------------------------------------------------------------------------------------
102 	// XFilePickerNotifier
103 	//------------------------------------------------------------------------------------
104 
105     virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener )
106 		throw( css::uno::RuntimeException );
107 
108     virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener )
109 		throw( css::uno::RuntimeException );
110 
111 	//------------------------------------------------------------------------------------
112 	// XExecutableDialog functions
113 	//------------------------------------------------------------------------------------
114 
115 	virtual void SAL_CALL setTitle( const ::rtl::OUString& sTitle )
116 		throw( css::uno::RuntimeException );
117 
118 	virtual sal_Int16 SAL_CALL execute(  )
119 		throw( css::uno::RuntimeException );
120 
121 	//------------------------------------------------------------------------------------
122 	// XFilePicker functions
123 	//------------------------------------------------------------------------------------
124 
125 	virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode )
126 		throw( css::uno::RuntimeException );
127 
128     virtual void SAL_CALL setDefaultName( const ::rtl::OUString& sName )
129         throw( css::uno::RuntimeException );
130 
131     virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& sDirectory )
132         throw (css::lang::IllegalArgumentException,
133                css::uno::RuntimeException         );
134 
135 	virtual ::rtl::OUString SAL_CALL getDisplayDirectory(  )
136 		throw( css::uno::RuntimeException );
137 
138     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles(  )
139 		throw( css::uno::RuntimeException );
140 
141 	//------------------------------------------------------------------------------------
142 	// XFilePicker2 functions
143 	//------------------------------------------------------------------------------------
144 
145     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedFiles(  )
146 		throw( css::uno::RuntimeException );
147 
148 	//------------------------------------------------------------------------------------
149 	// XFilterManager functions
150 	//------------------------------------------------------------------------------------
151 
152 	virtual void SAL_CALL appendFilter( const ::rtl::OUString& sTitle  ,
153                                         const ::rtl::OUString& sFilter )
154         throw (css::lang::IllegalArgumentException,
155                css::uno::RuntimeException         );
156 
157     virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& sTitle )
158         throw (css::lang::IllegalArgumentException,
159                css::uno::RuntimeException         );
160 
161     virtual ::rtl::OUString SAL_CALL getCurrentFilter(  )
162 		throw( css::uno::RuntimeException );
163 
164     //------------------------------------------------------------------------------------
165 	// XFilterGroupManager functions
166 	//------------------------------------------------------------------------------------
167 
168     virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString&                              sGroupTitle,
169                                              const css::uno::Sequence< css::beans::StringPair >& lFilters   )
170         throw (css::lang::IllegalArgumentException,
171                css::uno::RuntimeException         );
172 
173 	//------------------------------------------------------------------------------------
174 	// XFilePickerControlAccess functions
175 	//------------------------------------------------------------------------------------
176 
177 	virtual void SAL_CALL setValue(       sal_Int16      nControlId    ,
178                                           sal_Int16      nControlAction,
179                                     const css::uno::Any& aValue        )
180         throw (css::uno::RuntimeException);
181 
182     virtual css::uno::Any SAL_CALL getValue( sal_Int16 nControlId     ,
183                                              sal_Int16 nControlAction )
184         throw (css::uno::RuntimeException);
185 
186     virtual void SAL_CALL enableControl( sal_Int16 nControlId,
187                                          sal_Bool  bEnable   )
188 		throw(css::uno::RuntimeException );
189 
190 	virtual void SAL_CALL setLabel(       sal_Int16        nControlId,
191                                     const ::rtl::OUString& sLabel    )
192 		throw (css::uno::RuntimeException);
193 
194     virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId )
195 		throw (css::uno::RuntimeException);
196 
197     //------------------------------------------------
198     // XFilePreview
199     //------------------------------------------------
200 
201     virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats(  )
202         throw (css::uno::RuntimeException);
203 
204     virtual sal_Int32 SAL_CALL getTargetColorDepth(  )
205         throw (css::uno::RuntimeException);
206 
207     virtual sal_Int32 SAL_CALL getAvailableWidth(  )
208         throw (css::uno::RuntimeException);
209 
210     virtual sal_Int32 SAL_CALL getAvailableHeight(  )
211         throw (css::uno::RuntimeException);
212 
213     virtual void SAL_CALL setImage(       sal_Int16      nImageFormat,
214                                     const css::uno::Any& aImage      )
215         throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
216 
217     virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState )
218         throw (css::uno::RuntimeException);
219 
220     virtual sal_Bool SAL_CALL getShowState(  )
221         throw (css::uno::RuntimeException);
222 
223 	//------------------------------------------------
224 	// XInitialization
225 	//------------------------------------------------
226 
227 	virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments )
228 		throw(css::uno::Exception       ,
229               css::uno::RuntimeException);
230 
231     //------------------------------------------------
232 	// XCancellable
233 	//------------------------------------------------
234 
235     virtual void SAL_CALL cancel( )
236 		throw(css::uno::RuntimeException);
237 
238 	//------------------------------------------------
239     // XEventListener
240     //------------------------------------------------
241 
242     virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent )
243         throw(css::uno::RuntimeException);
244 
245 	//------------------------------------------------
246 	// XServiceInfo
247 	//------------------------------------------------
248 
249 	virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
250 		throw(css::uno::RuntimeException);
251 
252 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
253 		throw(css::uno::RuntimeException);
254 
255 	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
256 		throw(css::uno::RuntimeException);
257 
258     /*
259 	//------------------------------------------------------------------------------------
260 	// FilePicker Event functions
261 	//------------------------------------------------------------------------------------
262 
263 	void SAL_CALL fileSelectionChanged(const css::ui::dialogs::FilePickerEvent& aEvent );
264 	void SAL_CALL directoryChanged(const css::ui::dialogs::FilePickerEvent& aEvent );
265     ::rtl::OUString SAL_CALL helpRequested(const css::ui::dialogs::FilePickerEvent& aEvent ) const;
266 	void SAL_CALL controlStateChanged(const css::ui::dialogs::FilePickerEvent& aEvent );
267     void SAL_CALL dialogSizeChanged( );
268 
269     bool startupEventNotification(bool bStartupSuspended);
270     void shutdownEventNotification();
271     void suspendEventNotification();
272     void resumeEventNotification();
273     */
274 
275     private:
276 
277         // prevent copy and assignment
278         VistaFilePicker( const VistaFilePicker& );
279         VistaFilePicker& operator=( const VistaFilePicker& );
280 
281         using WeakComponentImplHelperBase::disposing;
282 
283     private:
284 
285         //---------------------------------------------------------------------
286         /// service manager to create own used uno services
287         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
288 
289         //---------------------------------------------------------------------
290         css::uno::Sequence< ::rtl::OUString > m_lLastFiles;
291 
292         //---------------------------------------------------------------------
293         /** execute the COM dialog within a STA thread
294          *  Must be used on the heap ... because it's implemented as OSL thread .-)
295          */
296         RequestHandlerRef m_rDialog;
297         AsyncRequests m_aAsyncExecute;
298 
299         //---------------------------------------------------------------------
300         oslThreadIdentifier m_nFilePickerThreadId;
301 
302         bool m_bInitialized;
303 };
304 
305 } // namespace vista
306 } // namespace win32
307 } // namespace fpicker
308 
309 #undef css
310 
311 #endif  // FPICKER_WIN32_VISTA_FILEPICKER_HXX
312