1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FilePicker.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FILEPICKER_HXX_
32 #define _FILEPICKER_HXX_
34 //_______________________________________________________________________________________________________________________
35 // includes of other projects
36 //_______________________________________________________________________________________________________________________
39 #include <cppuhelper/compbase10.hxx>
40 #include <osl/mutex.hxx>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/lang/XServiceInfo.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 #include "asynceventnotifier.hxx"
51 #include "eventnotification.hxx"
55 //----------------------------------------------------------
56 // Implementation class for the XFilePicker Interface
57 //----------------------------------------------------------
59 //----------------------------------------------------------
60 // forward declarations
61 //----------------------------------------------------------
63 class CWinFileOpenImpl
;
65 //----------------------------------------------------------
67 //----------------------------------------------------------
69 class CFilePickerDummy
73 osl::Mutex m_rbHelperMtx
;
77 public CFilePickerDummy
,
78 public cppu::WeakComponentImplHelper10
<
79 ::com::sun::star::ui::dialogs::XFilterManager
,
80 ::com::sun::star::ui::dialogs::XFilterGroupManager
,
81 ::com::sun::star::ui::dialogs::XFilePickerControlAccess
,
82 ::com::sun::star::ui::dialogs::XFilePickerNotifier
,
83 ::com::sun::star::ui::dialogs::XFilePreview
,
84 ::com::sun::star::ui::dialogs::XFilePicker2
,
85 ::com::sun::star::lang::XInitialization
,
86 ::com::sun::star::util::XCancellable
,
87 ::com::sun::star::lang::XEventListener
,
88 ::com::sun::star::lang::XServiceInfo
>
93 CFilePicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceMgr
);
95 //------------------------------------------------------------------------------------
96 // XFilePickerNotifier
97 //------------------------------------------------------------------------------------
99 virtual void SAL_CALL
addFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
)
100 throw( ::com::sun::star::uno::RuntimeException
);
101 virtual void SAL_CALL
removeFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
)
102 throw( ::com::sun::star::uno::RuntimeException
);
104 //------------------------------------------------------------------------------------
105 // XExecutableDialog functions
106 //------------------------------------------------------------------------------------
108 virtual void SAL_CALL
setTitle( const ::rtl::OUString
& aTitle
)
109 throw( ::com::sun::star::uno::RuntimeException
);
111 virtual sal_Int16 SAL_CALL
execute( )
112 throw( ::com::sun::star::uno::RuntimeException
);
114 //------------------------------------------------------------------------------------
115 // XFilePicker functions
116 //------------------------------------------------------------------------------------
118 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
)
119 throw( ::com::sun::star::uno::RuntimeException
);
121 virtual void SAL_CALL
setDefaultName( const ::rtl::OUString
& aName
)
122 throw( ::com::sun::star::uno::RuntimeException
);
124 virtual void SAL_CALL
setDisplayDirectory( const ::rtl::OUString
& aDirectory
)
125 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
127 virtual ::rtl::OUString SAL_CALL
getDisplayDirectory( )
128 throw( ::com::sun::star::uno::RuntimeException
);
130 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getFiles( )
131 throw( ::com::sun::star::uno::RuntimeException
);
133 //------------------------------------------------------------------------------------
134 // XFilePicker2 functions
135 //------------------------------------------------------------------------------------
136 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSelectedFiles( )
137 throw (::com::sun::star::uno::RuntimeException
);
139 //------------------------------------------------------------------------------------
140 // XFilterManager functions
141 //------------------------------------------------------------------------------------
143 virtual void SAL_CALL
appendFilter( const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aFilter
)
144 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
146 virtual void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aTitle
)
147 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
149 virtual ::rtl::OUString SAL_CALL
getCurrentFilter( )
150 throw( ::com::sun::star::uno::RuntimeException
);
152 //------------------------------------------------------------------------------------
153 // XFilterGroupManager functions
154 //------------------------------------------------------------------------------------
156 virtual void SAL_CALL
appendFilterGroup( const ::rtl::OUString
& sGroupTitle
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& aFilters
)
157 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
159 //------------------------------------------------------------------------------------
160 // XFilePickerControlAccess functions
161 //------------------------------------------------------------------------------------
163 virtual void SAL_CALL
setValue( sal_Int16 aControlId
, sal_Int16 aControlAction
, const ::com::sun::star::uno::Any
& aValue
)
164 throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Any SAL_CALL
getValue( sal_Int16 aControlId
, sal_Int16 aControlAction
)
167 throw (::com::sun::star::uno::RuntimeException
);
169 virtual void SAL_CALL
enableControl( sal_Int16 aControlId
, sal_Bool bEnable
)
170 throw(::com::sun::star::uno::RuntimeException
);
172 virtual void SAL_CALL
setLabel( sal_Int16 aControlId
, const ::rtl::OUString
& aLabel
)
173 throw (::com::sun::star::uno::RuntimeException
);
175 virtual ::rtl::OUString SAL_CALL
getLabel( sal_Int16 aControlId
)
176 throw (::com::sun::star::uno::RuntimeException
);
178 //------------------------------------------------
180 //------------------------------------------------
182 virtual ::com::sun::star::uno::Sequence
< sal_Int16
> SAL_CALL
getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException
);
184 virtual sal_Int32 SAL_CALL
getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException
);
186 virtual sal_Int32 SAL_CALL
getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException
);
188 virtual sal_Int32 SAL_CALL
getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException
);
190 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
);
192 virtual sal_Bool SAL_CALL
setShowState( sal_Bool bShowState
) throw (::com::sun::star::uno::RuntimeException
);
194 virtual sal_Bool SAL_CALL
getShowState( ) throw (::com::sun::star::uno::RuntimeException
);
196 //------------------------------------------------
198 //------------------------------------------------
200 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
201 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
203 //------------------------------------------------
205 //------------------------------------------------
207 virtual void SAL_CALL
cancel( )
208 throw(::com::sun::star::uno::RuntimeException
);
210 //------------------------------------------------
212 //------------------------------------------------
214 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
)
215 throw(::com::sun::star::uno::RuntimeException
);
217 //------------------------------------------------
219 //------------------------------------------------
221 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
222 throw(::com::sun::star::uno::RuntimeException
);
224 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
225 throw(::com::sun::star::uno::RuntimeException
);
227 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
228 throw(::com::sun::star::uno::RuntimeException
);
230 //------------------------------------------------------------------------------------
231 // FilePicker Event functions
232 //------------------------------------------------------------------------------------
234 void SAL_CALL
fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
235 void SAL_CALL
directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
236 rtl::OUString SAL_CALL
helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
) const;
237 void SAL_CALL
controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
238 void SAL_CALL
dialogSizeChanged( );
240 bool startupEventNotification(bool bStartupSuspended
);
241 void shutdownEventNotification();
242 void suspendEventNotification();
243 void resumeEventNotification();
246 // prevent copy and assignment
247 CFilePicker( const CFilePicker
& );
248 CFilePicker
& operator=( const CFilePicker
& );
250 using WeakComponentImplHelperBase::disposing
;
253 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceMgr
; // to instanciate own services
254 CAsyncEventNotifier m_aAsyncEventNotifier
;
255 std::auto_ptr
<CWinFileOpenImpl
> m_pImpl
;