1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _FILEPICKER_HXX_
29 #define _FILEPICKER_HXX_
31 //_______________________________________________________________________________________________________________________
32 // includes of other projects
33 //_______________________________________________________________________________________________________________________
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"
52 //----------------------------------------------------------
53 // Implementation class for the XFilePicker Interface
54 //----------------------------------------------------------
56 //----------------------------------------------------------
57 // forward declarations
58 //----------------------------------------------------------
60 class CWinFileOpenImpl
;
62 //----------------------------------------------------------
64 //----------------------------------------------------------
66 class CFilePickerDummy
70 osl::Mutex m_rbHelperMtx
;
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
>
90 CFilePicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceMgr
);
92 //------------------------------------------------------------------------------------
93 // XFilePickerNotifier
94 //------------------------------------------------------------------------------------
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
);
101 //------------------------------------------------------------------------------------
102 // XExecutableDialog functions
103 //------------------------------------------------------------------------------------
105 virtual void SAL_CALL
setTitle( const ::rtl::OUString
& aTitle
)
106 throw( ::com::sun::star::uno::RuntimeException
);
108 virtual sal_Int16 SAL_CALL
execute( )
109 throw( ::com::sun::star::uno::RuntimeException
);
111 //------------------------------------------------------------------------------------
112 // XFilePicker functions
113 //------------------------------------------------------------------------------------
115 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
)
116 throw( ::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
setDefaultName( const ::rtl::OUString
& aName
)
119 throw( ::com::sun::star::uno::RuntimeException
);
121 virtual void SAL_CALL
setDisplayDirectory( const ::rtl::OUString
& aDirectory
)
122 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
124 virtual ::rtl::OUString SAL_CALL
getDisplayDirectory( )
125 throw( ::com::sun::star::uno::RuntimeException
);
127 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getFiles( )
128 throw( ::com::sun::star::uno::RuntimeException
);
130 //------------------------------------------------------------------------------------
131 // XFilePicker2 functions
132 //------------------------------------------------------------------------------------
133 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSelectedFiles( )
134 throw (::com::sun::star::uno::RuntimeException
);
136 //------------------------------------------------------------------------------------
137 // XFilterManager functions
138 //------------------------------------------------------------------------------------
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
);
143 virtual void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aTitle
)
144 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
146 virtual ::rtl::OUString SAL_CALL
getCurrentFilter( )
147 throw( ::com::sun::star::uno::RuntimeException
);
149 //------------------------------------------------------------------------------------
150 // XFilterGroupManager functions
151 //------------------------------------------------------------------------------------
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
);
156 //------------------------------------------------------------------------------------
157 // XFilePickerControlAccess functions
158 //------------------------------------------------------------------------------------
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
);
163 virtual ::com::sun::star::uno::Any SAL_CALL
getValue( sal_Int16 aControlId
, sal_Int16 aControlAction
)
164 throw (::com::sun::star::uno::RuntimeException
);
166 virtual void SAL_CALL
enableControl( sal_Int16 aControlId
, sal_Bool bEnable
)
167 throw(::com::sun::star::uno::RuntimeException
);
169 virtual void SAL_CALL
setLabel( sal_Int16 aControlId
, const ::rtl::OUString
& aLabel
)
170 throw (::com::sun::star::uno::RuntimeException
);
172 virtual ::rtl::OUString SAL_CALL
getLabel( sal_Int16 aControlId
)
173 throw (::com::sun::star::uno::RuntimeException
);
175 //------------------------------------------------
177 //------------------------------------------------
179 virtual ::com::sun::star::uno::Sequence
< sal_Int16
> SAL_CALL
getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException
);
181 virtual sal_Int32 SAL_CALL
getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException
);
183 virtual sal_Int32 SAL_CALL
getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException
);
185 virtual sal_Int32 SAL_CALL
getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException
);
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
);
189 virtual sal_Bool SAL_CALL
setShowState( sal_Bool bShowState
) throw (::com::sun::star::uno::RuntimeException
);
191 virtual sal_Bool SAL_CALL
getShowState( ) throw (::com::sun::star::uno::RuntimeException
);
193 //------------------------------------------------
195 //------------------------------------------------
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
);
200 //------------------------------------------------
202 //------------------------------------------------
204 virtual void SAL_CALL
cancel( )
205 throw(::com::sun::star::uno::RuntimeException
);
207 //------------------------------------------------
209 //------------------------------------------------
211 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
)
212 throw(::com::sun::star::uno::RuntimeException
);
214 //------------------------------------------------
216 //------------------------------------------------
218 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
219 throw(::com::sun::star::uno::RuntimeException
);
221 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
222 throw(::com::sun::star::uno::RuntimeException
);
224 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
225 throw(::com::sun::star::uno::RuntimeException
);
227 //------------------------------------------------------------------------------------
228 // FilePicker Event functions
229 //------------------------------------------------------------------------------------
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( );
237 bool startupEventNotification(bool bStartupSuspended
);
238 void shutdownEventNotification();
239 void suspendEventNotification();
240 void resumeEventNotification();
243 // prevent copy and assignment
244 CFilePicker( const CFilePicker
& );
245 CFilePicker
& operator=( const CFilePicker
& );
247 using WeakComponentImplHelperBase::disposing
;
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
;