xref: /trunk/main/fpicker/source/win32/filepicker/VistaFilePicker.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
107     virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener );
108 
109     //------------------------------------------------------------------------------------
110     // XExecutableDialog functions
111     //------------------------------------------------------------------------------------
112 
113     virtual void SAL_CALL setTitle( const ::rtl::OUString& sTitle );
114 
115     virtual sal_Int16 SAL_CALL execute(  );
116 
117     //------------------------------------------------------------------------------------
118     // XFilePicker functions
119     //------------------------------------------------------------------------------------
120 
121     virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode );
122 
123     virtual void SAL_CALL setDefaultName( const ::rtl::OUString& sName );
124 
125     virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& sDirectory );
126 
127     virtual ::rtl::OUString SAL_CALL getDisplayDirectory(  );
128 
129     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles(  );
130 
131     //------------------------------------------------------------------------------------
132     // XFilePicker2 functions
133     //------------------------------------------------------------------------------------
134 
135     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedFiles(  );
136 
137     //------------------------------------------------------------------------------------
138     // XFilterManager functions
139     //------------------------------------------------------------------------------------
140 
141     virtual void SAL_CALL appendFilter( const ::rtl::OUString& sTitle  ,
142                                         const ::rtl::OUString& sFilter );
143 
144     virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& sTitle );
145 
146     virtual ::rtl::OUString SAL_CALL getCurrentFilter(  );
147 
148     //------------------------------------------------------------------------------------
149     // XFilterGroupManager functions
150     //------------------------------------------------------------------------------------
151 
152     virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString&                              sGroupTitle,
153                                              const css::uno::Sequence< css::beans::StringPair >& lFilters   );
154 
155     //------------------------------------------------------------------------------------
156     // XFilePickerControlAccess functions
157     //------------------------------------------------------------------------------------
158 
159     virtual void SAL_CALL setValue(       sal_Int16      nControlId    ,
160                                           sal_Int16      nControlAction,
161                                     const css::uno::Any& aValue        );
162 
163     virtual css::uno::Any SAL_CALL getValue( sal_Int16 nControlId     ,
164                                              sal_Int16 nControlAction );
165 
166     virtual void SAL_CALL enableControl( sal_Int16 nControlId,
167                                          sal_Bool  bEnable   );
168 
169     virtual void SAL_CALL setLabel(       sal_Int16        nControlId,
170                                     const ::rtl::OUString& sLabel    );
171 
172     virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId );
173 
174     //------------------------------------------------
175     // XFilePreview
176     //------------------------------------------------
177 
178     virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats(  );
179 
180     virtual sal_Int32 SAL_CALL getTargetColorDepth(  );
181 
182     virtual sal_Int32 SAL_CALL getAvailableWidth(  );
183 
184     virtual sal_Int32 SAL_CALL getAvailableHeight(  );
185 
186     virtual void SAL_CALL setImage(       sal_Int16      nImageFormat,
187                                     const css::uno::Any& aImage      );
188 
189     virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState );
190 
191     virtual sal_Bool SAL_CALL getShowState(  );
192 
193     //------------------------------------------------
194     // XInitialization
195     //------------------------------------------------
196 
197     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments );
198 
199     //------------------------------------------------
200     // XCancellable
201     //------------------------------------------------
202 
203     virtual void SAL_CALL cancel( );
204 
205     //------------------------------------------------
206     // XEventListener
207     //------------------------------------------------
208 
209     virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent );
210 
211     //------------------------------------------------
212     // XServiceInfo
213     //------------------------------------------------
214 
215     virtual ::rtl::OUString SAL_CALL getImplementationName(  );
216 
217     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
218 
219     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  );
220 
221     /*
222     //------------------------------------------------------------------------------------
223     // FilePicker Event functions
224     //------------------------------------------------------------------------------------
225 
226     void SAL_CALL fileSelectionChanged(const css::ui::dialogs::FilePickerEvent& aEvent );
227     void SAL_CALL directoryChanged(const css::ui::dialogs::FilePickerEvent& aEvent );
228     ::rtl::OUString SAL_CALL helpRequested(const css::ui::dialogs::FilePickerEvent& aEvent ) const;
229     void SAL_CALL controlStateChanged(const css::ui::dialogs::FilePickerEvent& aEvent );
230     void SAL_CALL dialogSizeChanged( );
231 
232     bool startupEventNotification(bool bStartupSuspended);
233     void shutdownEventNotification();
234     void suspendEventNotification();
235     void resumeEventNotification();
236     */
237 
238     private:
239 
240         // prevent copy and assignment
241         VistaFilePicker( const VistaFilePicker& );
242         VistaFilePicker& operator=( const VistaFilePicker& );
243 
244         using WeakComponentImplHelperBase::disposing;
245 
246     private:
247 
248         //---------------------------------------------------------------------
249         /// service manager to create own used uno services
250         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
251 
252         //---------------------------------------------------------------------
253         css::uno::Sequence< ::rtl::OUString > m_lLastFiles;
254 
255         //---------------------------------------------------------------------
256         /** execute the COM dialog within a STA thread
257          *  Must be used on the heap ... because it's implemented as OSL thread .-)
258          */
259         RequestHandlerRef m_rDialog;
260         AsyncRequests m_aAsyncExecute;
261 
262         //---------------------------------------------------------------------
263         oslThreadIdentifier m_nFilePickerThreadId;
264 
265         bool m_bInitialized;
266 };
267 
268 } // namespace vista
269 } // namespace win32
270 } // namespace fpicker
271 
272 #undef css
273 
274 #endif  // FPICKER_WIN32_VISTA_FILEPICKER_HXX
275