xref: /AOO41X/main/fpicker/source/win32/filepicker/FilePicker.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 _FILEPICKER_HXX_
29 #define _FILEPICKER_HXX_
30 
31 //_______________________________________________________________________________________________________________________
32 //	includes of other projects
33 //_______________________________________________________________________________________________________________________
34 
35 
36 #include <cppuhelper/compbase10.hxx>
37 #include <osl/mutex.hxx>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
41 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
42 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
43 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
45 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
46 #include <com/sun/star/util/XCancellable.hpp>
47 #include "asynceventnotifier.hxx"
48 #include "eventnotification.hxx"
49 
50 #include <memory>
51 
52 //----------------------------------------------------------
53 // Implementation class for the XFilePicker Interface
54 //----------------------------------------------------------
55 
56 //----------------------------------------------------------
57 // forward declarations
58 //----------------------------------------------------------
59 
60 class CWinFileOpenImpl;
61 
62 //----------------------------------------------------------
63 // class declaration
64 //----------------------------------------------------------
65 
66 class CFilePickerDummy
67 {
68 protected:
69 	osl::Mutex	m_aMutex;
70 	osl::Mutex	m_rbHelperMtx;
71 };
72 
73 class CFilePicker :
74 	public CFilePickerDummy,
75 	public cppu::WeakComponentImplHelper10<
76         ::com::sun::star::ui::dialogs::XFilterManager,
77         ::com::sun::star::ui::dialogs::XFilterGroupManager,
78         ::com::sun::star::ui::dialogs::XFilePickerControlAccess,
79         ::com::sun::star::ui::dialogs::XFilePickerNotifier,
80         ::com::sun::star::ui::dialogs::XFilePreview,
81         ::com::sun::star::ui::dialogs::XFilePicker2,
82 		::com::sun::star::lang::XInitialization,
83         ::com::sun::star::util::XCancellable,
84 		::com::sun::star::lang::XEventListener,
85 		::com::sun::star::lang::XServiceInfo >
86 {
87 public:
88 
89 	// ctor
90 	CFilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr );
91 
92 	//------------------------------------------------------------------------------------
93 	// XFilePickerNotifier
94 	//------------------------------------------------------------------------------------
95 
96     virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener )
97 		throw( ::com::sun::star::uno::RuntimeException );
98     virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener )
99 		throw( ::com::sun::star::uno::RuntimeException );
100 
101 	//------------------------------------------------------------------------------------
102 	// XExecutableDialog functions
103 	//------------------------------------------------------------------------------------
104 
105 	virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle )
106 		throw( ::com::sun::star::uno::RuntimeException );
107 
108 	virtual sal_Int16 SAL_CALL execute(  )
109 		throw( ::com::sun::star::uno::RuntimeException );
110 
111 	//------------------------------------------------------------------------------------
112 	// XFilePicker functions
113 	//------------------------------------------------------------------------------------
114 
115 	virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode )
116 		throw( ::com::sun::star::uno::RuntimeException );
117 
118     virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName )
119 		throw( ::com::sun::star::uno::RuntimeException );
120 
121     virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory )
122 		throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
123 
124 	virtual ::rtl::OUString SAL_CALL getDisplayDirectory(  )
125 		throw( ::com::sun::star::uno::RuntimeException );
126 
127     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles(  )
128 		throw( ::com::sun::star::uno::RuntimeException );
129 
130 	//------------------------------------------------------------------------------------
131 	// XFilePicker2 functions
132 	//------------------------------------------------------------------------------------
133     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedFiles(  )
134         throw (::com::sun::star::uno::RuntimeException);
135 
136 	//------------------------------------------------------------------------------------
137 	// XFilterManager functions
138 	//------------------------------------------------------------------------------------
139 
140 	virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter )
141         throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
142 
143     virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle )
144 		throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
145 
146     virtual ::rtl::OUString SAL_CALL getCurrentFilter(  )
147 		throw( ::com::sun::star::uno::RuntimeException );
148 
149     //------------------------------------------------------------------------------------
150 	// XFilterGroupManager functions
151 	//------------------------------------------------------------------------------------
152 
153     virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters )
154         throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
155 
156 	//------------------------------------------------------------------------------------
157 	// XFilePickerControlAccess functions
158 	//------------------------------------------------------------------------------------
159 
160 	virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue )
161         throw (::com::sun::star::uno::RuntimeException);
162 
163     virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction )
164         throw (::com::sun::star::uno::RuntimeException);
165 
166     virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable )
167 		throw(::com::sun::star::uno::RuntimeException );
168 
169 	virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel )
170 		throw (::com::sun::star::uno::RuntimeException);
171 
172     virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId )
173 		throw (::com::sun::star::uno::RuntimeException);
174 
175     //------------------------------------------------
176     // XFilePreview
177     //------------------------------------------------
178 
179     virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats(  ) throw (::com::sun::star::uno::RuntimeException);
180 
181     virtual sal_Int32 SAL_CALL getTargetColorDepth(  ) throw (::com::sun::star::uno::RuntimeException);
182 
183     virtual sal_Int32 SAL_CALL getAvailableWidth(  ) throw (::com::sun::star::uno::RuntimeException);
184 
185     virtual sal_Int32 SAL_CALL getAvailableHeight(  ) throw (::com::sun::star::uno::RuntimeException);
186 
187     virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
188 
189     virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException);
190 
191     virtual sal_Bool SAL_CALL getShowState(  ) throw (::com::sun::star::uno::RuntimeException);
192 
193 	//------------------------------------------------
194 	// XInitialization
195 	//------------------------------------------------
196 
197 	virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
198 		throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
199 
200     //------------------------------------------------
201 	// XCancellable
202 	//------------------------------------------------
203 
204     virtual void SAL_CALL cancel( )
205 		throw(::com::sun::star::uno::RuntimeException);
206 
207 	//------------------------------------------------
208     // XEventListener
209     //------------------------------------------------
210 
211     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent )
212         throw(::com::sun::star::uno::RuntimeException);
213 
214 	//------------------------------------------------
215 	// XServiceInfo
216 	//------------------------------------------------
217 
218 	virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
219 		throw(::com::sun::star::uno::RuntimeException);
220 
221 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
222 		throw(::com::sun::star::uno::RuntimeException);
223 
224 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
225 		throw(::com::sun::star::uno::RuntimeException);
226 
227 	//------------------------------------------------------------------------------------
228 	// FilePicker Event functions
229 	//------------------------------------------------------------------------------------
230 
231 	void SAL_CALL fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
232 	void SAL_CALL directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
233     rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const;
234 	void SAL_CALL controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
235     void SAL_CALL dialogSizeChanged( );
236 
237     bool startupEventNotification(bool bStartupSuspended);
238     void shutdownEventNotification();
239     void suspendEventNotification();
240     void resumeEventNotification();
241 
242 private:
243 	// prevent copy and assignment
244 	CFilePicker( const CFilePicker& );
245 	CFilePicker& operator=( const CFilePicker& );
246 
247     using WeakComponentImplHelperBase::disposing;
248 
249 private:
250 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr;   // to instanciate own services
251     CAsyncEventNotifier				                                               m_aAsyncEventNotifier;
252 	std::auto_ptr<CWinFileOpenImpl>	    										   m_pImpl;
253 };
254 
255 #endif
256