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