xref: /AOO41X/main/fpicker/source/win32/filepicker/FilePicker.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _FILEPICKER_HXX_
29*cdf0e10cSrcweir #define _FILEPICKER_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_______________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	includes of other projects
33*cdf0e10cSrcweir //_______________________________________________________________________________________________________________________
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <cppuhelper/compbase10.hxx>
37*cdf0e10cSrcweir #include <osl/mutex.hxx>
38*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
47*cdf0e10cSrcweir #include "asynceventnotifier.hxx"
48*cdf0e10cSrcweir #include "eventnotification.hxx"
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <memory>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir //----------------------------------------------------------
53*cdf0e10cSrcweir // Implementation class for the XFilePicker Interface
54*cdf0e10cSrcweir //----------------------------------------------------------
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //----------------------------------------------------------
57*cdf0e10cSrcweir // forward declarations
58*cdf0e10cSrcweir //----------------------------------------------------------
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir class CWinFileOpenImpl;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //----------------------------------------------------------
63*cdf0e10cSrcweir // class declaration
64*cdf0e10cSrcweir //----------------------------------------------------------
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir class CFilePickerDummy
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir protected:
69*cdf0e10cSrcweir 	osl::Mutex	m_aMutex;
70*cdf0e10cSrcweir 	osl::Mutex	m_rbHelperMtx;
71*cdf0e10cSrcweir };
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir class CFilePicker :
74*cdf0e10cSrcweir 	public CFilePickerDummy,
75*cdf0e10cSrcweir 	public cppu::WeakComponentImplHelper10<
76*cdf0e10cSrcweir         ::com::sun::star::ui::dialogs::XFilterManager,
77*cdf0e10cSrcweir         ::com::sun::star::ui::dialogs::XFilterGroupManager,
78*cdf0e10cSrcweir         ::com::sun::star::ui::dialogs::XFilePickerControlAccess,
79*cdf0e10cSrcweir         ::com::sun::star::ui::dialogs::XFilePickerNotifier,
80*cdf0e10cSrcweir         ::com::sun::star::ui::dialogs::XFilePreview,
81*cdf0e10cSrcweir         ::com::sun::star::ui::dialogs::XFilePicker2,
82*cdf0e10cSrcweir 		::com::sun::star::lang::XInitialization,
83*cdf0e10cSrcweir         ::com::sun::star::util::XCancellable,
84*cdf0e10cSrcweir 		::com::sun::star::lang::XEventListener,
85*cdf0e10cSrcweir 		::com::sun::star::lang::XServiceInfo >
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir public:
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	// ctor
90*cdf0e10cSrcweir 	CFilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
93*cdf0e10cSrcweir 	// XFilePickerNotifier
94*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener )
97*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
98*cdf0e10cSrcweir     virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener )
99*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
102*cdf0e10cSrcweir 	// XExecutableDialog functions
103*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle )
106*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	virtual sal_Int16 SAL_CALL execute(  )
109*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
112*cdf0e10cSrcweir 	// XFilePicker functions
113*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode )
116*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName )
119*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory )
122*cdf0e10cSrcweir 		throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getDisplayDirectory(  )
125*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles(  )
128*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
131*cdf0e10cSrcweir 	// XFilePicker2 functions
132*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
133*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedFiles(  )
134*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
137*cdf0e10cSrcweir 	// XFilterManager functions
138*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter )
141*cdf0e10cSrcweir         throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle )
144*cdf0e10cSrcweir 		throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getCurrentFilter(  )
147*cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     //------------------------------------------------------------------------------------
150*cdf0e10cSrcweir 	// XFilterGroupManager functions
151*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters )
154*cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
157*cdf0e10cSrcweir 	// XFilePickerControlAccess functions
158*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue )
161*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction )
164*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable )
167*cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException );
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 	virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel )
170*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId )
173*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     //------------------------------------------------
176*cdf0e10cSrcweir     // XFilePreview
177*cdf0e10cSrcweir     //------------------------------------------------
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats(  ) throw (::com::sun::star::uno::RuntimeException);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getTargetColorDepth(  ) throw (::com::sun::star::uno::RuntimeException);
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAvailableWidth(  ) throw (::com::sun::star::uno::RuntimeException);
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAvailableHeight(  ) throw (::com::sun::star::uno::RuntimeException);
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     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*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getShowState(  ) throw (::com::sun::star::uno::RuntimeException);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	//------------------------------------------------
194*cdf0e10cSrcweir 	// XInitialization
195*cdf0e10cSrcweir 	//------------------------------------------------
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
198*cdf0e10cSrcweir 		throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     //------------------------------------------------
201*cdf0e10cSrcweir 	// XCancellable
202*cdf0e10cSrcweir 	//------------------------------------------------
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     virtual void SAL_CALL cancel( )
205*cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	//------------------------------------------------
208*cdf0e10cSrcweir     // XEventListener
209*cdf0e10cSrcweir     //------------------------------------------------
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent )
212*cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 	//------------------------------------------------
215*cdf0e10cSrcweir 	// XServiceInfo
216*cdf0e10cSrcweir 	//------------------------------------------------
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
219*cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
222*cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
225*cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
228*cdf0e10cSrcweir 	// FilePicker Event functions
229*cdf0e10cSrcweir 	//------------------------------------------------------------------------------------
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	void SAL_CALL fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
232*cdf0e10cSrcweir 	void SAL_CALL directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
233*cdf0e10cSrcweir     rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const;
234*cdf0e10cSrcweir 	void SAL_CALL controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
235*cdf0e10cSrcweir     void SAL_CALL dialogSizeChanged( );
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir     bool startupEventNotification(bool bStartupSuspended);
238*cdf0e10cSrcweir     void shutdownEventNotification();
239*cdf0e10cSrcweir     void suspendEventNotification();
240*cdf0e10cSrcweir     void resumeEventNotification();
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir private:
243*cdf0e10cSrcweir 	// prevent copy and assignment
244*cdf0e10cSrcweir 	CFilePicker( const CFilePicker& );
245*cdf0e10cSrcweir 	CFilePicker& operator=( const CFilePicker& );
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     using WeakComponentImplHelperBase::disposing;
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir private:
250*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr;   // to instanciate own services
251*cdf0e10cSrcweir     CAsyncEventNotifier				                                               m_aAsyncEventNotifier;
252*cdf0e10cSrcweir 	std::auto_ptr<CWinFileOpenImpl>	    										   m_pImpl;
253*cdf0e10cSrcweir };
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir #endif
256